當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Typecho_Cookie::delete方法代碼示例

本文整理匯總了PHP中Typecho_Cookie::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP Typecho_Cookie::delete方法的具體用法?PHP Typecho_Cookie::delete怎麽用?PHP Typecho_Cookie::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Typecho_Cookie的用法示例。


在下文中一共展示了Typecho_Cookie::delete方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: comment

 /**
  * 評論處理函數
  *
  * @throws Typecho_Widget_Exception
  * @throws Exception
  * @throws Typecho_Exception
  */
 private function comment()
 {
     // modified_by_jiangmuzi 2015.09.23
     // 必須登錄後才可以回複
     if (!$this->user->hasLogin()) {
         $this->widget('Widget_Notice')->set(_t('請先<a href="%s">登錄</a>', $this->options->someUrl('login', null, false) . '?redir=' . $this->request->getRequestUrl()), NULL, 'success');
         $this->response->goBack();
     }
     // end modified
     // 使用安全模塊保護
     $this->security->protect();
     $comment = array('cid' => $this->_content->cid, 'created' => $this->options->gmtTime, 'agent' => $this->request->getAgent(), 'ip' => $this->request->getIp(), 'ownerId' => $this->_content->author->uid, 'type' => 'comment', 'status' => !$this->_content->allow('edit') && $this->options->commentsRequireModeration ? 'waiting' : 'approved');
     //檢驗格式
     $validator = new Typecho_Validate();
     $validator->addRule('text', 'required', _t('必須填寫評論內容'));
     $comment['text'] = $this->request->text;
     /** 記錄登錄用戶的id */
     $comment['authorId'] = $this->user->uid;
     if ($error = $validator->run($comment)) {
         /** 記錄文字 */
         Typecho_Cookie::set('__some_remember_text', $comment['text']);
         throw new Typecho_Widget_Exception(implode("\n", $error));
     }
     /** 生成過濾器 */
     try {
         $comment = $this->pluginHandle()->comment($comment, $this->_content);
     } catch (Typecho_Exception $e) {
         Typecho_Cookie::set('__some_remember_text', $comment['text']);
         throw $e;
     }
     // modified_by_jiangmuzi 2015.09.23
     // 解析@數據
     $atArr = $this->searchAt($comment);
     // end modified
     /** 添加評論 */
     $commentId = $this->insert($comment);
     Typecho_Cookie::delete('__some_remember_text');
     $this->db->fetchRow($this->select()->where('coid = ?', $commentId)->limit(1), array($this, 'push'));
     //更新最後評論人及時間
     $this->db->query($this->db->update('table.contents')->rows(array('lastUid' => $this->authorId, 'lastComment' => $this->created))->where('cid = ?', $this->cid));
     //提醒主題作者
     if ($comment['authorId'] != $comment['ownerId']) {
         $atArr[] = array('uid' => $comment['ownerId'], 'type' => 'comment');
     }
     if (!empty($atArr)) {
         foreach ($atArr as $v) {
             $this->widget('Widget_Users_Messages')->addMessage($v['uid'], $commentId, $v['type']);
         }
     }
     //觸發評論積分規則
     Widget_Common::credits('reply', null, $commentId);
     /** 評論完成接口 */
     $this->pluginHandle()->finishComment($this);
     $this->response->goBack('#' . $this->theId);
 }
開發者ID:dccecc,項目名稱:typecho,代碼行數:62,代碼來源:Feedback.php

示例2: getNotice

/**
 * 獲取提示消息
 */
function getNotice()
{
    $notice = Typecho_Cookie::get('__typecho_notice');
    if (empty($notice)) {
        echo "''";
        return;
    }
    $notice = json_decode($notice, true);
    $rs = array('msg' => $notice[0], 'type' => Typecho_Cookie::get('__typecho_notice_type'));
    Typecho_Cookie::delete('__typecho_notice');
    Typecho_Cookie::delete('__typecho_notice_type');
    echo json_encode($rs);
}
開發者ID:rootml,項目名稱:jianshu,代碼行數:16,代碼來源:header.php

示例3: execute

 /**
  * 執行函數
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     if (NULL !== Typecho_Cookie::get('__typecho_notice')) {
         $this->noticeType = Typecho_Cookie::get('__typecho_notice_type');
         $this->push(Typecho_Cookie::get('__typecho_notice'));
         Typecho_Cookie::delete('__typecho_notice', $this->widget('Widget_Options')->siteUrl);
         Typecho_Cookie::delete('__typecho_notice_type', $this->widget('Widget_Options')->siteUrl);
     }
     if (NULL !== Typecho_Cookie::get('__typecho_notice_highlight')) {
         $this->highlight = Typecho_Cookie::get('__typecho_notice_highlight');
         Typecho_Cookie::delete('__typecho_notice_highlight', $this->widget('Widget_Options')->siteUrl);
     }
 }
開發者ID:raindali,項目名稱:express,代碼行數:19,代碼來源:Notice.php

示例4: action

 /**
  * 初始化函數
  *
  * @access public
  * @return void
  */
 public function action()
 {
     // protect
     $this->security->protect();
     /** 如果已經登錄 */
     if ($this->user->hasLogin() || !$this->options->allowRegister) {
         /** 直接返回 */
         $this->response->redirect($this->options->index);
     }
     /** 初始化驗證類 */
     $validator = new Typecho_Validate();
     $validator->addRule('name', 'required', _t('必須填寫用戶名稱'));
     $validator->addRule('name', 'minLength', _t('用戶名至少包含2個字符'), 2);
     $validator->addRule('name', 'maxLength', _t('用戶名最多包含32個字符'), 32);
     $validator->addRule('name', 'xssCheck', _t('請不要在用戶名中使用特殊字符'));
     $validator->addRule('name', array($this, 'nameExists'), _t('用戶名已經存在'));
     $validator->addRule('mail', 'required', _t('必須填寫電子郵箱'));
     $validator->addRule('mail', array($this, 'mailExists'), _t('電子郵箱地址已經存在'));
     $validator->addRule('mail', 'email', _t('電子郵箱格式錯誤'));
     $validator->addRule('mail', 'maxLength', _t('電子郵箱最多包含200個字符'), 200);
     /** 如果請求中有password */
     if (array_key_exists('password', $_REQUEST)) {
         $validator->addRule('password', 'required', _t('必須填寫密碼'));
         $validator->addRule('password', 'minLength', _t('為了保證賬戶安全, 請輸入至少六位的密碼'), 6);
         $validator->addRule('password', 'maxLength', _t('為了便於記憶, 密碼長度請不要超過十八位'), 18);
         $validator->addRule('confirm', 'confirm', _t('兩次輸入的密碼不一致'), 'password');
     }
     /** 截獲驗證異常 */
     if ($error = $validator->run($this->request->from('name', 'password', 'mail', 'confirm'))) {
         Typecho_Cookie::set('__typecho_remember_name', $this->request->name);
         Typecho_Cookie::set('__typecho_remember_mail', $this->request->mail);
         /** 設置提示信息 */
         $this->widget('Widget_Notice')->set($error);
         $this->response->goBack();
     }
     $hasher = new PasswordHash(8, true);
     $generatedPassword = Typecho_Common::randString(7);
     $dataStruct = array('name' => $this->request->name, 'mail' => $this->request->mail, 'screenName' => $this->request->name, 'password' => $hasher->HashPassword($generatedPassword), 'created' => $this->options->gmtTime, 'group' => 'subscriber');
     $dataStruct = $this->pluginHandle()->register($dataStruct);
     $insertId = $this->insert($dataStruct);
     $this->db->fetchRow($this->select()->where('uid = ?', $insertId)->limit(1), array($this, 'push'));
     $this->pluginHandle()->finishRegister($this);
     $this->user->login($this->request->name, $generatedPassword);
     Typecho_Cookie::delete('__typecho_first_run');
     Typecho_Cookie::delete('__typecho_remember_name');
     Typecho_Cookie::delete('__typecho_remember_mail');
     $this->widget('Widget_Notice')->set(_t('用戶 <strong>%s</strong> 已經成功注冊, 密碼為 <strong>%s</strong>', $this->screenName, $generatedPassword), 'success');
     $this->response->redirect($this->options->adminUrl);
 }
開發者ID:r0ker,項目名稱:hctf2015-all-problems,代碼行數:55,代碼來源:Register.php

示例5: htmlspecialchars

if (!defined('__TYPECHO_ROOT_DIR__')) {
    exit;
}
$this->need('header.php');
?>
<style>.user-page .page-title,.user-page footer{display:none;}</style>
<?php 
$rememberName = htmlspecialchars(Typecho_Cookie::get('__some_remember_name'));
$rememberMail = htmlspecialchars(Typecho_Cookie::get('__some_remember_mail'));
$notice = Typecho_Cookie::get('__some_notice');
if (!empty($notice)) {
    $notice = json_decode($notice, true);
}
Typecho_Cookie::delete('__some_remember_name');
Typecho_Cookie::delete('__some_remember_mail');
?>
<div id="sidebar">
    <?php 
$this->need('user/widget_login.php');
?>
</div>
<div class="box" id="main">
    <div class="head">
        <div class="location">
            <a href="<?php 
$this->options->siteUrl();
?>
"><?php 
$this->options->title();
?>
開發者ID:dccecc,項目名稱:typecho,代碼行數:30,代碼來源:register.php

示例6: foreach

             foreach ($tableArray as $table) {
                 if ($type == 'Mysql') {
                     $installDb->query("DROP TABLE IF EXISTS `{$table}`");
                 } elseif ($type == 'Pgsql') {
                     $installDb->query("DROP TABLE {$table}");
                 } elseif ($type == 'SQLite') {
                     $installDb->query("DROP TABLE {$table}");
                 }
             }
             echo '<p class="message success">' . _t('已經刪除完原有數據') . '<br /><br /><button type="submit" class="primary">' . _t('繼續安裝 &raquo;') . '</button></p>';
         } elseif (_r('goahead')) {
             //使用原有數據
             //但是要更新用戶網站
             $installDb->query($installDb->update('table.options')->rows(array('value' => $config['siteUrl']))->where('name = ?', 'siteUrl'));
             unset($_SESSION['typecho']);
             Typecho_Cookie::delete('__typecho_config');
             header('Location: ./install.php?finish&use_old');
             exit;
         } else {
             echo '<p class="message error">' . _t('安裝程序檢查到原有數據表已經存在.') . '<br /><br />' . '<button type="submit" name="delete" value="1" class="btn-warn">' . _t('刪除原有數據') . '</button> ' . _t('或者') . ' <button type="submit" name="goahead" value="1" class="primary">' . _t('使用原有數據') . '</button></p>';
         }
     } else {
         echo '<p class="message error">' . _t('安裝程序捕捉到以下錯誤: "%s". 程序被終止, 請檢查您的配置信息.', $e->getMessage()) . '</p>';
     }
     ?>
             </form>
         </div>
                                 <?php 
 }
 ?>
         <?php 
開發者ID:menmenweiwei,項目名稱:blog,代碼行數:31,代碼來源:install.php

示例7: comment


//.........這裏部分代碼省略.........
     if ($this->options->commentsRequireMail && !$this->user->hasLogin()) {
         $validator->addRule('mail', 'required', _t('必須填寫電子郵箱地址'));
     }
     $validator->addRule('mail', 'email', _t('郵箱地址不合法'));
     $validator->addRule('mail', 'maxLength', _t('電子郵箱最多包含200個字符'), 200);
     if ($this->options->commentsRequireUrl && !$this->user->hasLogin()) {
         $validator->addRule('url', 'required', _t('必須填寫個人主頁'));
     }
     $validator->addRule('url', 'url', _t('個人主頁地址格式錯誤'));
     $validator->addRule('url', 'maxLength', _t('個人主頁地址最多包含200個字符'), 200);
     $validator->addRule('text', 'required', _t('必須填寫評論內容'));
     $comment['text'] = $this->request->text;
     /** 對一般匿名訪問者,將用戶數據保存一個月 */
     if (!$this->user->hasLogin()) {
         /** Anti-XSS */
         $comment['author'] = $this->request->filter('trim')->author;
         $comment['mail'] = $this->request->filter('trim')->mail;
         $comment['url'] = $this->request->filter('trim')->url;
         /** 修正用戶提交的url */
         if (!empty($comment['url'])) {
             $urlParams = parse_url($comment['url']);
             if (!isset($urlParams['scheme'])) {
                 $comment['url'] = 'http://' . $comment['url'];
             }
         }
         $expire = $this->options->gmtTime + $this->options->timezone + 30 * 24 * 3600;
         Typecho_Cookie::set('__typecho_remember_author', $comment['author'], $expire);
         Typecho_Cookie::set('__typecho_remember_mail', $comment['mail'], $expire);
         Typecho_Cookie::set('__typecho_remember_url', $comment['url'], $expire);
     } else {
         $comment['author'] = $this->user->screenName;
         $comment['mail'] = $this->user->mail;
         $comment['url'] = $this->user->url;
         /** 記錄登錄用戶的id */
         $comment['authorId'] = $this->user->uid;
     }
     /** 評論者之前須有評論通過了審核 */
     if (!$this->options->commentsRequireModeration && $this->options->commentsWhitelist) {
         if ($commentApprovedNum = $this->size($this->select()->where('author = ? AND mail = ? AND status = ?', $comment['author'], $comment['mail'], 'approved'))) {
             $comment['status'] = 'approved';
         } else {
             $comment['status'] = 'waiting';
         }
     }
     if ($error = $validator->run($comment)) {
         /** 記錄文字 */
         Typecho_Cookie::set('__typecho_remember_text', $comment['text']);
         throw new Typecho_Widget_Exception(implode("\n", $error));
     }
     /** 生成過濾器 */
     try {
         $comment = $this->pluginHandle()->comment($comment, $this->_content);
     } catch (Typecho_Exception $e) {
         Typecho_Cookie::set('__typecho_remember_text', $comment['text']);
         throw $e;
     }
     // modified_by_jiangmuzi 2015.09.23
     // 解析@數據
     $search = $replace = $atMsg = array();
     $pattern = "/@([^@^\\s^:]{1,})([\\s\\:\\,\\;]{0,1})/";
     preg_match_all($pattern, $comment['text'], $matches);
     if (!empty($matches[1])) {
         $matches[1] = array_unique($matches[1]);
         foreach ($matches[1] as $name) {
             if (empty($name)) {
                 continue;
             }
             $atUser = $this->widget('Forum_Query_User@name_' . $name, array('name' => $name));
             if (!$atUser->have()) {
                 continue;
             }
             $search[] = '@' . $name;
             $replace[] = '<a href="' . $atUser->ucenter . '" target="_blank">@' . $name . '</a>';
             //提醒at用戶
             if ($comment['authorId'] != $atUser->uid && $atUser->uid != $comment['ownerId']) {
                 $atMsg[] = array('uid' => $atUser->uid, 'type' => 'at');
             }
         }
         if (!empty($search)) {
             $comment['text'] = str_replace(@$search, @$replace, $comment['text']);
         }
     }
     // end modified
     /** 添加評論 */
     $commentId = $this->insert($comment);
     Typecho_Cookie::delete('__typecho_remember_text');
     $this->db->fetchRow($this->select()->where('coid = ?', $commentId)->limit(1), array($this, 'push'));
     //提醒主題作者
     if ($comment['authorId'] != $comment['ownerId']) {
         $atMsg[] = array('uid' => $comment['ownerId'], 'type' => 'comment');
     }
     if (!empty($atMsg)) {
         foreach ($atMsg as $v) {
             $this->widget('Forum_Messages')->addMessage($v['uid'], $commentId, $v['type']);
         }
     }
     /** 評論完成接口 */
     $this->pluginHandle()->finishComment($this);
     $this->response->goBack('#' . $this->theId);
 }
開發者ID:Jsechoo,項目名稱:sisome,代碼行數:101,代碼來源:Feedback.php

示例8: logout

 /**
  * 用戶登出函數
  *
  * @access public
  * @return void
  */
 public function logout()
 {
     $this->pluginHandle()->trigger($logoutPluggable)->logout();
     if ($logoutPluggable) {
         return;
     }
     Typecho_Cookie::delete('__typecho_uid');
     Typecho_Cookie::delete('__typecho_authCode');
 }
開發者ID:r0ker,項目名稱:hctf2015-all-problems,代碼行數:15,代碼來源:User.php

示例9: htmlspecialchars

<?php

include 'common.php';
if ($user->hasLogin() || !$options->allowRegister) {
    $response->redirect($options->siteUrl);
}
$rememberName = htmlspecialchars(Typecho_Cookie::get('__typecho_remember_name'));
$rememberMail = htmlspecialchars(Typecho_Cookie::get('__typecho_remember_mail'));
Typecho_Cookie::delete('__typecho_remember_name');
Typecho_Cookie::delete('__typecho_remember_mail');
$bodyClass = 'body-100';
include 'header.php';
?>
<div class="typecho-login-wrap">
    <div class="typecho-login">
        
        <form action="<?php 
$options->registerAction();
?>
" method="post" name="register" role="form">
            <p>
                <label for="name" class="sr-only"><?php 
_e('用戶名');
?>
</label>
                <input type="text" id="name" name="name" placeholder="<?php 
_e('用戶名');
?>
" value="<?php 
echo $rememberName;
?>
開發者ID:Ants-Database,項目名稱:Ants,代碼行數:31,代碼來源:register.php

示例10: setTheme

 /**
  * 插件實現方法
  *
  * @access public
  * @return void
  */
 public static function setTheme($widget)
 {
     $cookie = array('name' => '__typecho_theme', 'expire' => 86400);
     $options = Typecho_Widget::widget('Widget_Options');
     if (isset($widget->request->theme) && $widget->request->isGet()) {
         if ($widget->request->theme) {
             $theme = $widget->request->theme;
             if (static::check($theme)) {
                 Typecho_Cookie::set($cookie['name'], $widget->request->theme, $options->gmtTime + $cookie['expire'], $options->siteUrl);
             } else {
                 $widget->response->redirect(Typecho_Common::url($widget->request->getPathInfo(), $options->siteUrl));
             }
         } else {
             Typecho_Cookie::delete($cookie['name']);
             //直接提交?theme將刪除cookie,恢複默認主題
             return;
         }
     } else {
         $theme = Typecho_Cookie::get($cookie['name']);
         if (!$theme) {
             return;
         }
         if (!static::check($theme)) {
             Typecho_Cookie::delete($cookie['name']);
             return;
         }
     }
     /** 刪除舊主題的相關設置 */
     $themeRow = 'theme:' . $options->theme;
     if (isset($options->{$themeRow})) {
         $config = unserialize($options->{$themeRow});
         $options->{$themeRow} = '';
         foreach ($config as $row => $value) {
             $options->{$row} = '';
         }
     }
     /** 載入新主題的相關設置 參考var/Widget/Themes/Edit.php */
     $themeDir = __TYPECHO_ROOT_DIR__ . __TYPECHO_THEME_DIR__ . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR;
     $configFile = $themeDir . 'functions.php';
     if (file_exists($configFile)) {
         require_once $configFile;
         if (function_exists('themeConfig')) {
             $form = new Typecho_Widget_Helper_Form();
             themeConfig($form);
             $config = $form->getValues();
             if ($config) {
                 $options->{'theme:' . $theme} = serialize($config);
                 foreach ($config as $row => $value) {
                     $options->{$row} = $value;
                 }
             }
         }
     }
     /** 修改$this->options->theme */
     $options->theme = $theme;
     /** 修改$this->_themeDir */
     $widget->setThemeDir($themeDir);
 }
開發者ID:duxiangfei,項目名稱:plugins,代碼行數:64,代碼來源:Plugin.php

示例11: comment

 /**
  * 評論處理函數
  *
  * @throws Typecho_Widget_Exception
  * @throws Exception
  * @throws Typecho_Exception
  */
 private function comment()
 {
     // modified_by_jiangmuzi 2015.09.23
     // 必須登錄後才可以回複
     if (!$this->user->hasLogin()) {
         $this->widget('Widget_Notice')->set(_t('請先<a href="%s">登錄</a>', $this->options->someUrl('login', null, false) . '?redir=' . $this->request->getRequestUrl()), NULL, 'success');
         $this->response->goBack();
     }
     // end modified
     // 使用安全模塊保護
     $this->security->protect();
     $comment = array('cid' => $this->_content->cid, 'created' => $this->options->gmtTime, 'agent' => $this->request->getAgent(), 'ip' => $this->request->getIp(), 'ownerId' => $this->_content->author->uid, 'type' => 'comment', 'status' => !$this->_content->allow('edit') && $this->options->commentsRequireModeration ? 'waiting' : 'approved');
     /** 判斷父節點 */
     /*
             if ($parentId = $this->request->filter('int')->get('parent')) {
                 if ($this->options->commentsThreaded && ($parent = $this->db->fetchRow($this->db->select('coid', 'cid')->from('table.comments')
                 ->where('coid = ?', $parentId))) && $this->_content->cid == $parent['cid']) {
                     $comment['parent'] = $parentId;
                 } else {
                     throw new Typecho_Widget_Exception(_t('父級評論不存在'));
                 }
             }*/
     //檢驗格式
     $validator = new Typecho_Validate();
     $validator->addRule('text', 'required', _t('必須填寫評論內容'));
     $comment['text'] = $this->request->text;
     /** 記錄登錄用戶的id */
     $comment['authorId'] = $this->user->uid;
     if ($error = $validator->run($comment)) {
         /** 記錄文字 */
         Typecho_Cookie::set('__some_remember_text', $comment['text']);
         throw new Typecho_Widget_Exception(implode("\n", $error));
     }
     /** 生成過濾器 */
     try {
         $comment = $this->pluginHandle()->comment($comment, $this->_content);
     } catch (Typecho_Exception $e) {
         Typecho_Cookie::set('__some_remember_text', $comment['text']);
         throw $e;
     }
     // modified_by_jiangmuzi 2015.09.23
     // 解析@數據
     $search = $replace = $atMsg = array();
     $pattern = "/@([^@^\\s^:]{1,})([\\s\\:\\,\\;]{0,1})/";
     preg_match_all($pattern, $comment['text'], $matches);
     if (!empty($matches[1])) {
         $matches[1] = array_unique($matches[1]);
         foreach ($matches[1] as $name) {
             if (empty($name)) {
                 continue;
             }
             $atUser = $this->widget('Widget_Users_Query@name_' . $name, array('name' => $name));
             if (!$atUser->have()) {
                 continue;
             }
             $search[] = '@' . $name;
             $replace[] = '<a href="' . $atUser->ucenter . '" target="_blank">@' . $name . '</a>';
             //提醒at用戶
             if ($comment['authorId'] != $atUser->uid && $atUser->uid != $comment['ownerId']) {
                 $atMsg[] = array('uid' => $atUser->uid, 'type' => 'at');
             }
         }
         if (!empty($search)) {
             $comment['text'] = str_replace(@$search, @$replace, $comment['text']);
         }
     }
     // end modified
     /** 添加評論 */
     $commentId = $this->insert($comment);
     Typecho_Cookie::delete('__some_remember_text');
     $this->db->fetchRow($this->select()->where('coid = ?', $commentId)->limit(1), array($this, 'push'));
     //更新最後評論人及時間
     $this->db->query($this->db->update('table.contents')->rows(array('lastUid' => $this->authorId, 'lastComment' => $this->created))->where('cid = ?', $this->cid));
     //提醒主題作者
     if ($comment['authorId'] != $comment['ownerId']) {
         $atMsg[] = array('uid' => $comment['ownerId'], 'type' => 'comment');
     }
     if (!empty($atMsg)) {
         foreach ($atMsg as $v) {
             $this->widget('Widget_Users_Messages')->addMessage($v['uid'], $commentId, $v['type']);
         }
     }
     //觸發評論積分規則
     Widget_Common::credits('reply');
     /** 評論完成接口 */
     $this->pluginHandle()->finishComment($this);
     $this->response->goBack('#' . $this->theId);
 }
開發者ID:rptec,項目名稱:sisome,代碼行數:95,代碼來源:Feedback.php

示例12: upgrade

 /**
  * 執行升級程序
  *
  * @access public
  * @return void
  */
 public function upgrade()
 {
     list($prefix, $this->_currentVersion) = explode('/', $this->options->generator);
     $packages = get_class_methods('Upgrade');
     $packages = array_filter($packages, array($this, 'filterPackage'));
     usort($packages, array($this, 'sortPackage'));
     $message = array();
     foreach ($packages as $package) {
         $options = $this->widget('Widget_Options@' . $package);
         /** 執行升級腳本 */
         try {
             $result = call_user_func(array('Upgrade', $package), $this->db, $options);
             if (!empty($result)) {
                 $message[] = $result;
             }
         } catch (Typecho_Exception $e) {
             $this->widget('Widget_Notice')->set($e->getMessage(), 'error');
             $this->response->goBack();
             return;
         }
         list($ver, $rev) = explode('r', $package);
         $ver = substr(str_replace('_', '.', $ver), 1);
         $rev = str_replace('_', '.', $rev);
         /** 更新版本號 */
         $this->update(array('value' => 'Typecho ' . $ver . '/' . $rev), $this->db->sql()->where('name = ?', 'generator'));
         $this->destory('Widget_Options@' . $package);
     }
     /** 更新版本號 */
     $this->update(array('value' => 'Typecho ' . Typecho_Common::VERSION), $this->db->sql()->where('name = ?', 'generator'));
     /** 刪除更新cookie */
     Typecho_Cookie::delete('__typecho_check_version');
     $this->widget('Widget_Notice')->set(empty($message) ? _t("升級已經完成") : $message, empty($message) ? 'success' : 'notice');
 }
開發者ID:menmenweiwei,項目名稱:blog,代碼行數:39,代碼來源:Upgrade.php

示例13: render

 /**
  * 顯示表單
  *
  * @access public
  * @return void
  */
 public function render()
 {
     $id = md5(implode('"', array_keys($this->_inputs)));
     /** 恢複表單值 */
     if ($record = Typecho_Cookie::get('__typecho_form_record_' . $id)) {
         $message = Typecho_Cookie::get('__typecho_form_message_' . $id);
         foreach ($this->_inputs as $name => $input) {
             $input->value(isset($record[$name]) ? $record[$name] : $input->value);
             /** 顯示錯誤消息 */
             if (isset($message[$name])) {
                 $input->message($message[$name]);
             }
         }
         Typecho_Cookie::delete('__typecho_form_record_' . $id);
     }
     parent::render();
     Typecho_Cookie::delete('__typecho_form_message_' . $id);
 }
開發者ID:raindali,項目名稱:express,代碼行數:24,代碼來源:Form.php

示例14: comment

 /**
  * 評論處理函數
  *
  * @throws Typecho_Widget_Exception
  * @throws Exception
  * @throws Typecho_Exception
  */
 private function comment()
 {
     // 使用安全模塊保護
     $this->security->protect();
     $comment = array('cid' => $this->_content->cid, 'created' => $this->options->gmtTime, 'agent' => $this->request->getAgent(), 'ip' => $this->request->getIp(), 'ownerId' => $this->_content->author->uid, 'type' => 'comment', 'status' => !$this->_content->allow('edit') && $this->options->commentsRequireModeration ? 'waiting' : 'approved');
     /** 判斷父節點 */
     if ($parentId = $this->request->filter('int')->get('parent')) {
         if ($this->options->commentsThreaded && ($parent = $this->db->fetchRow($this->db->select('coid', 'cid')->from('table.comments')->where('coid = ?', $parentId))) && $this->_content->cid == $parent['cid']) {
             $comment['parent'] = $parentId;
         } else {
             throw new Typecho_Widget_Exception(_t('父級評論不存在'));
         }
     }
     //檢驗格式
     $validator = new Typecho_Validate();
     $validator->addRule('author', 'required', _t('必須填寫用戶名'));
     $validator->addRule('author', 'xssCheck', _t('請不要在用戶名中使用特殊字符'));
     $validator->addRule('author', array($this, 'requireUserLogin'), _t('您所使用的用戶名已經被注冊,請登錄後再次提交'));
     $validator->addRule('author', 'maxLength', _t('用戶名最多包含200個字符'), 200);
     if ($this->options->commentsRequireMail && !$this->user->hasLogin()) {
         $validator->addRule('mail', 'required', _t('必須填寫電子郵箱地址'));
     }
     $validator->addRule('mail', 'email', _t('郵箱地址不合法'));
     $validator->addRule('mail', 'maxLength', _t('電子郵箱最多包含200個字符'), 200);
     if ($this->options->commentsRequireUrl && !$this->user->hasLogin()) {
         $validator->addRule('url', 'required', _t('必須填寫個人主頁'));
     }
     $validator->addRule('url', 'url', _t('個人主頁地址格式錯誤'));
     $validator->addRule('url', 'maxLength', _t('個人主頁地址最多包含200個字符'), 200);
     $validator->addRule('text', 'required', _t('必須填寫評論內容'));
     $comment['text'] = $this->request->text;
     /** 對一般匿名訪問者,將用戶數據保存一個月 */
     if (!$this->user->hasLogin()) {
         /** Anti-XSS */
         $comment['author'] = $this->request->filter('trim')->author;
         $comment['mail'] = $this->request->filter('trim')->mail;
         $comment['url'] = $this->request->filter('trim')->url;
         /** 修正用戶提交的url */
         if (!empty($comment['url'])) {
             $urlParams = parse_url($comment['url']);
             if (!isset($urlParams['scheme'])) {
                 $comment['url'] = 'http://' . $comment['url'];
             }
         }
         $expire = $this->options->gmtTime + $this->options->timezone + 30 * 24 * 3600;
         Typecho_Cookie::set('__typecho_remember_author', $comment['author'], $expire);
         Typecho_Cookie::set('__typecho_remember_mail', $comment['mail'], $expire);
         Typecho_Cookie::set('__typecho_remember_url', $comment['url'], $expire);
     } else {
         $comment['author'] = $this->user->screenName;
         $comment['mail'] = $this->user->mail;
         $comment['url'] = $this->user->url;
         /** 記錄登錄用戶的id */
         $comment['authorId'] = $this->user->uid;
     }
     /** 評論者之前須有評論通過了審核 */
     if (!$this->options->commentsRequireModeration && $this->options->commentsWhitelist) {
         if ($this->size($this->select()->where('author = ? AND mail = ? AND status = ?', $comment['author'], $comment['mail'], 'approved'))) {
             $comment['status'] = 'approved';
         } else {
             $comment['status'] = 'waiting';
         }
     }
     if ($error = $validator->run($comment)) {
         /** 記錄文字 */
         Typecho_Cookie::set('__typecho_remember_text', $comment['text']);
         throw new Typecho_Widget_Exception(implode("\n", $error));
     }
     /** 生成過濾器 */
     try {
         $comment = $this->pluginHandle()->comment($comment, $this->_content);
     } catch (Typecho_Exception $e) {
         Typecho_Cookie::set('__typecho_remember_text', $comment['text']);
         throw $e;
     }
     /** 添加評論 */
     $commentId = $this->insert($comment);
     Typecho_Cookie::delete('__typecho_remember_text');
     $this->db->fetchRow($this->select()->where('coid = ?', $commentId)->limit(1), array($this, 'push'));
     /** 評論完成接口 */
     $this->pluginHandle()->finishComment($this);
     $this->response->goBack('#' . $this->theId);
 }
開發者ID:hongweipeng,項目名稱:typecho,代碼行數:90,代碼來源:Feedback.php

示例15: logout

 /**
  * 用戶登出函數
  *
  * @access public
  * @return void
  */
 public function logout()
 {
     $this->pluginHandle()->trigger($logoutPluggable)->logout();
     if ($logoutPluggable) {
         return;
     }
     Typecho_Cookie::delete('__typecho_uid', $this->options->siteUrl);
     Typecho_Cookie::delete('__typecho_authCode', $this->options->siteUrl);
     Typecho_Cookie::delete('__typecho_feed');
     Typecho_Cookie::delete('__typecho_check_version');
 }
開發者ID:raindali,項目名稱:express,代碼行數:17,代碼來源:User.php


注:本文中的Typecho_Cookie::delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。