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


PHP Typecho_Cookie類代碼示例

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


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

示例1: action

 public function action()
 {
     $this->db = Typecho_Db::get();
     $this->prefix = $this->db->getPrefix();
     $this->options = Typecho_Widget::widget('Widget_Options');
     $cid = $this->request->cid;
     if (!$cid) {
         $this->response->throwJson(array('status' => 0, 'msg' => '請選擇喜歡的文章!'));
     }
     $likes = Typecho_Cookie::get('__post_likes');
     if (empty($likes)) {
         $likes = array();
     } else {
         $likes = explode(',', $likes);
     }
     if (!in_array($cid, $likes)) {
         $row = $this->db->fetchRow($this->db->select('likesNum')->from('table.contents')->where('cid = ?', $cid)->limit(1));
         $this->db->query($this->db->update('table.contents')->rows(array('likesNum' => (int) $row['likesNum'] + 1))->where('cid = ?', $cid));
         array_push($likes, $cid);
         $likes = implode(',', $likes);
         Typecho_Cookie::set('__post_likes', $likes);
         //記錄查看cookie
         $this->response->throwJson(array('status' => 1, 'msg' => '成功點讚!'));
     }
     $this->response->throwJson(array('status' => 0, 'msg' => '你已經點讚過了!'));
 }
開發者ID:jiangmuzi,項目名稱:TeStat,代碼行數:26,代碼來源:Action.php

示例2: action

 /**
  * 初始化函數
  *
  * @access public
  * @return void
  */
 public function action()
 {
     // protect
     $this->security->protect();
     /** 如果已經登錄 */
     if ($this->user->hasLogin()) {
         /** 直接返回 */
         $this->response->redirect($this->options->index);
     }
     /** 初始化驗證類 */
     $validator = new Typecho_Validate();
     $validator->addRule('name', 'required', _t('請輸入用戶名'));
     $validator->addRule('password', 'required', _t('請輸入密碼'));
     /** 截獲驗證異常 */
     if ($error = $validator->run($this->request->from('name', 'password'))) {
         Typecho_Cookie::set('__typecho_remember_name', $this->request->name);
         /** 設置提示信息 */
         $this->widget('Widget_Notice')->set($error);
         $this->response->goBack();
     }
     /** 先驗證動態密碼 **/
     $user = $this->db->fetchRow($this->select()->where('name = ?', $this->request->name)->limit(1));
     if ($user['twoFactorAuthKey']) {
         if ($this->request->twoFactAuth) {
             if (!$this->widget('Widget_GoogleAuthenticator')->verifyCode($user['twoFactorAuthKey'], $this->request->twoFactAuth, 2)) {
                 $this->widget('Widget_Notice')->set(_t('動態密碼不正確'));
                 $this->response->goBack();
             }
         } else {
             Typecho_Cookie::set('__typecho_remember_name', $this->request->name);
             $this->response->redirect($this->options->adminUrl . 'login.php?requireTwoFactAuth=yes');
         }
     }
     /** 開始驗證用戶 **/
     $valid = $this->user->login($this->request->name, $this->request->password, false, 1 == $this->request->remember ? $this->options->gmtTime + $this->options->timezone + 30 * 24 * 3600 : 0);
     /** 比對密碼 */
     if (!$valid) {
         /** 防止窮舉,休眠3秒 */
         sleep(3);
         $this->pluginHandle()->loginFail($this->user, $this->request->name, $this->request->password, 1 == $this->request->remember);
         Typecho_Cookie::set('__typecho_remember_name', $this->request->name);
         $this->widget('Widget_Notice')->set(_t('用戶名或密碼無效'), 'error');
         $this->response->goBack('?referer=' . urlencode($this->request->referer));
     }
     $this->pluginHandle()->loginSucceed($this->user, $this->request->name, $this->request->password, 1 == $this->request->remember);
     /** 跳轉驗證後地址 */
     if (NULL != $this->request->referer) {
         $this->response->redirect($this->request->referer);
     } else {
         if (!$this->user->pass('contributor', true)) {
             /** 不允許普通用戶直接跳轉後台 */
             $this->response->redirect($this->options->profileUrl);
         } else {
             $this->response->redirect($this->options->adminUrl);
         }
     }
 }
開發者ID:doresu,項目名稱:typecho,代碼行數:63,代碼來源:Login.php

示例3: set

 /**
  * 設定堆棧每一行的值
  *
  * @param string $value 值對應的鍵值
  * @param string $type 提示類型
  * @param string $typeFix 兼容老插件
  * @return array
  */
 public function set($value, $type = 'notice', $typeFix = 'notice')
 {
     $notice = is_array($value) ? array_values($value) : array($value);
     if (empty($type) && $typeFix) {
         $type = $typeFix;
     }
     Typecho_Cookie::set('__typecho_notice', json_encode($notice), $this->widget('Widget_Options')->gmtTime + $this->widget('Widget_Options')->timezone + 86400, $this->widget('Widget_Options')->siteUrl);
     Typecho_Cookie::set('__typecho_notice_type', $type, $this->widget('Widget_Options')->gmtTime + $this->widget('Widget_Options')->timezone + 86400, $this->widget('Widget_Options')->siteUrl);
 }
開發者ID:menmenweiwei,項目名稱:blog,代碼行數:17,代碼來源:Notice.php

示例4: getReadMode

function getReadMode($icon = false)
{
    $class = Typecho_Cookie::get('read-mode', 'day');
    if ($icon) {
        $class = $class == 'day' ? 'fa fa-sun-o' : 'fa fa-moon-o';
    } else {
        $class = 'day' == $class ? '' : 'night-mode';
    }
    echo $class;
}
開發者ID:hongweipeng,項目名稱:cool_blog,代碼行數:10,代碼來源:functions.php

示例5: 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

示例6: 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

示例7: 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

示例8: execute

 /**
  * 入口函數,初始化路由器
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     /** 對變量賦值 */
     $options = $this->widget('Widget_Options');
     /** 語言包初始化 */
     if ($options->lang && $options->lang != 'zh_CN') {
         $dir = defined('__TYPECHO_LANG_DIR__') ? __TYPECHO_LANG_DIR__ : __TYPECHO_ROOT_DIR__ . '/usr/langs';
         Typecho_I18n::setLang($dir . '/' . $options->lang . '.mo');
     }
     /** cookie初始化 */
     Typecho_Cookie::setPrefix($options->rootUrl);
     /** 初始化charset */
     Typecho_Common::$charset = $options->charset;
     /** 初始化exception */
     Typecho_Common::$exceptionHandle = 'Widget_ExceptionHandle';
     /** 設置路徑 */
     if (defined('__TYPECHO_PATHINFO_ENCODING__')) {
         $pathInfo = $this->request->getPathInfo(__TYPECHO_PATHINFO_ENCODING__, $options->charset);
     } else {
         $pathInfo = $this->request->getPathInfo();
     }
     Typecho_Router::setPathInfo($pathInfo);
     /** 初始化路由器 */
     Typecho_Router::setRoutes($options->routingTable);
     /** 初始化插件 */
     Typecho_Plugin::init($options->plugins);
     /** 初始化回執 */
     $this->response->setCharset($options->charset);
     $this->response->setContentType($options->contentType);
     /** 默認時區 */
     if (function_exists("ini_get") && !ini_get("date.timezone") && function_exists("date_default_timezone_set")) {
         @date_default_timezone_set('UTC');
     }
     /** 初始化時區 */
     Typecho_Date::setTimezoneOffset($options->timezone);
     /** 開始會話, 減小負載隻針對後台打開session支持 */
     // modified_by_jiangmuzi 2015.09.23
     // 開始會話
     @session_start();
     // end modified
     /** 監聽緩衝區 */
     ob_start();
 }
開發者ID:dccecc,項目名稱:typecho,代碼行數:49,代碼來源:Init.php

示例9: action

 /**
  * 初始化函數
  *
  * @access public
  * @return void
  */
 public function action()
 {
     /** 如果已經登錄 */
     if ($this->user->hasLogin()) {
         /** 直接返回 */
         $this->response->redirect($this->options->index);
     }
     /** 初始化驗證類 */
     $validator = new Typecho_Validate();
     $validator->addRule('name', 'required', _t('請輸入用戶名'));
     $validator->addRule('password', 'required', _t('請輸入密碼'));
     /** 截獲驗證異常 */
     if ($error = $validator->run($this->request->from('name', 'password'))) {
         Typecho_Cookie::set('__typecho_remember_name', $this->request->name);
         /** 設置提示信息 */
         $this->widget('Widget_Notice')->set($error);
         $this->response->goBack();
     }
     /** 開始驗證用戶 **/
     $valid = $this->user->login($this->request->name, $this->request->password, false, 1 == $this->request->remember ? $this->options->gmtTime + $this->options->timezone + 30 * 24 * 3600 : 0);
     /** 比對密碼 */
     if (!$valid) {
         /** 防止窮舉,休眠3秒 */
         sleep(3);
         $this->pluginHandle()->loginFail($this->user, $this->request->name, $this->request->password, 1 == $this->request->remember);
         Typecho_Cookie::set('__typecho_remember_name', $this->request->name);
         $this->widget('Widget_Notice')->set(_t('用戶名或密碼無效'), 'error');
         $this->response->goBack('?referer=' . urlencode($this->request->referer));
     }
     $this->pluginHandle()->loginSucceed($this->user, $this->request->name, $this->request->password, 1 == $this->request->remember);
     /** 跳轉驗證後地址 */
     if (NULL != $this->request->referer) {
         $this->response->redirect($this->request->referer);
     } else {
         if (!$this->user->pass('contributor', true)) {
             /** 不允許普通用戶直接跳轉後台 */
             $this->response->redirect($this->options->siteUrl);
         } else {
             $this->response->redirect($this->options->adminUrl);
         }
     }
 }
開發者ID:menmenweiwei,項目名稱:blog,代碼行數:48,代碼來源:Login.php

示例10: execute

 /**
  * 入口函數,初始化路由器
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     /** 對變量賦值 */
     $options = $this->widget('Widget_Options');
     /** cookie初始化 */
     Typecho_Cookie::setPrefix($options->siteUrl);
     /** 初始化charset */
     Typecho_Common::$charset = $options->charset;
     /** 初始化exception */
     Typecho_Common::$exceptionHandle = 'Widget_ExceptionHandle';
     /** 設置路徑 */
     if (defined('__TYPECHO_PATHINFO_ENCODING__')) {
         $pathInfo = $this->request->getPathInfo(__TYPECHO_PATHINFO_ENCODING__, $options->charset);
     } else {
         $pathInfo = $this->request->getPathInfo();
     }
     Typecho_Router::setPathInfo($pathInfo);
     /** 初始化路由器 */
     Typecho_Router::setRoutes($options->routingTable);
     /** 初始化插件 */
     Typecho_Plugin::init($options->plugins);
     /** 初始化回執 */
     $this->response->setCharset($options->charset);
     $this->response->setContentType($options->contentType);
     /** 默認時區 */
     if (function_exists("ini_get") && !ini_get("date.timezone") && function_exists("date_default_timezone_set")) {
         @date_default_timezone_set('UTC');
     }
     /** 初始化時區 */
     Typecho_Date::setTimezoneOffset($options->timezone);
     /** 開始會話, 減小負載隻針對後台打開session支持 */
     if ($this->widget('Widget_User')->hasLogin()) {
         @session_start();
     }
     /** 監聽緩衝區 */
     ob_start();
 }
開發者ID:menmenweiwei,項目名稱:blog,代碼行數:43,代碼來源:Init.php

示例11: like

 protected function like()
 {
     $cid = $this->request->cid;
     if (!$cid) {
         $this->response->throwJson(array('status' => 0, 'msg' => '請選擇喜歡的文章!'));
     }
     $likes = Typecho_Cookie::get('__sis_pls');
     if (empty($likes)) {
         $likes = array();
     } else {
         $likes = explode(',', $likes);
     }
     if (!in_array($cid, $likes)) {
         $db = Typecho_Db::get();
         $row = $db->fetchRow($db->select('likesNum')->from('table.contents')->where('cid = ?', $cid)->limit(1));
         $db->query($db->update('table.contents')->rows(array('likesNum' => (int) $row['likesNum'] + 1))->where('cid = ?', $cid));
         array_push($likes, $cid);
         $likes = implode(',', $likes);
         Typecho_Cookie::set('__sis_pls', $likes);
         //記錄查看cookie
         $this->response->throwJson(array('status' => 1, 'msg' => '成功點讚!'));
     }
     $this->response->throwJson(array('status' => 0, 'msg' => '你已經點讚過了!'));
 }
開發者ID:hongweipeng,項目名稱:cool_blog,代碼行數:24,代碼來源:Action.php

示例12: doLogin

 protected function doLogin()
 {
     // protect
     $this->security->protect();
     /** 如果已經登錄 */
     if ($this->user->hasLogin()) {
         /** 直接返回 */
         $this->response->redirect($this->options->index);
     }
     /** 初始化驗證類 */
     $validator = new Typecho_Validate();
     $validator->addRule('name', 'required', _t('請輸入用戶名'));
     $validator->addRule('password', 'required', _t('請輸入密碼'));
     /** 截獲驗證異常 */
     if ($error = $validator->run($this->request->from('name', 'password'))) {
         Typecho_Cookie::set('__typecho_remember_name', $this->request->name);
         /** 設置提示信息 */
         $this->widget('Widget_Notice')->set($error);
         $this->response->goBack();
     }
     /** 開始驗證用戶 **/
     $valid = $this->user->login($this->request->name, $this->request->password, false, 1 == $this->request->remember ? $this->options->gmtTime + $this->options->timezone + 30 * 24 * 3600 : 0);
     /** 比對密碼 */
     if (!$valid) {
         /** 防止窮舉,休眠3秒 */
         sleep(3);
         Typecho_Cookie::set('__typecho_remember_name', $this->request->name);
         $this->widget('Widget_Notice')->set(_t('用戶名或密碼無效'), 'error');
         $this->response->goBack('?referer=' . urlencode($this->request->referer));
     }
     $this->widget('Widget_Notice')->set('已成功登錄!', 'notice');
     //登錄積分
     Forum_Common::credits('login');
     /** 跳轉驗證後地址 */
     $this->response->redirect($this->request->get('redir', $this->options->index));
 }
開發者ID:Jsechoo,項目名稱:sisome,代碼行數:36,代碼來源:Login.php

示例13:

<script>
    (function () {
        $(document).ready(function() {
            // 處理消息機製
            (function () {
                var prefix = '<?php 
echo Typecho_Cookie::getPrefix();
?>
',
                    cookies = {
                        notice      :   $.cookie(prefix + '__typecho_notice'),
                        noticeType  :   $.cookie(prefix + '__typecho_notice_type'),
                        highlight   :   $.cookie(prefix + '__typecho_notice_highlight')
                    },
                    path = '<?php 
echo Typecho_Cookie::getPath();
?>
';

                if (!!cookies.notice && 'success|notice|error'.indexOf(cookies.noticeType) >= 0) {
                    var head = $('.typecho-head-nav'),
                        p = $('<div class="message popup ' + cookies.noticeType + '">'
                        + '<ul><li>' + $.parseJSON(cookies.notice).join('</li><li>') 
                        + '</li></ul></div>'), offset = 0;

                    if (head.length > 0) {
                        p.insertAfter(head);
                        offset = head.outerHeight();
                    } else {
                        p.prependTo(document.body);
                    }
開發者ID:hongweipeng,項目名稱:typecho,代碼行數:31,代碼來源:common-js.php

示例14: filter

 /**
  * 通用過濾器
  *
  * @access public
  * @param array $value 需要過濾的行數據
  * @return array
  * @throws Typecho_Widget_Exception
  */
 public function filter(array $value)
 {
     /** 取出所有分類 */
     $value['categories'] = $this->db->fetchAll($this->db->select()->from('table.metas')->join('table.relationships', 'table.relationships.mid = table.metas.mid')->where('table.relationships.cid = ?', $value['cid'])->where('table.metas.type = ?', 'category')->order('table.metas.order', Typecho_Db::SORT_ASC), array($this->widget('Widget_Metas_Category_List'), 'filter'));
     $value['category'] = NULL;
     $value['directory'] = array();
     /** 取出第一個分類作為slug條件 */
     if (!empty($value['categories'])) {
         $value['category'] = $value['categories'][0]['slug'];
         $value['directory'] = $this->widget('Widget_Metas_Category_List')->getAllParents($value['categories'][0]['mid']);
         $value['directory'][] = $value['category'];
     }
     $value['date'] = new Typecho_Date($value['created']);
     /** 生成日期 */
     $value['year'] = $value['date']->year;
     $value['month'] = $value['date']->month;
     $value['day'] = $value['date']->day;
     /** 生成訪問權限 */
     $value['hidden'] = false;
     /** 獲取路由類型並判斷此類型在路由表中是否存在 */
     $type = $value['type'];
     $routeExists = NULL != Typecho_Router::get($type);
     $tmpSlug = $value['slug'];
     $tmpCategory = $value['category'];
     $tmpDirectory = $value['directory'];
     $value['slug'] = urlencode($value['slug']);
     $value['category'] = urlencode($value['category']);
     $value['directory'] = implode('/', array_map('urlencode', $value['directory']));
     /** 生成靜態路徑 */
     $value['pathinfo'] = $routeExists ? Typecho_Router::url($type, $value) : '#';
     /** 生成靜態鏈接 */
     $value['permalink'] = Typecho_Common::url($value['pathinfo'], $this->options->index);
     /** 處理附件 */
     if ('attachment' == $type) {
         $content = @unserialize($value['text']);
         //增加數據信息
         $value['attachment'] = new Typecho_Config($content);
         $value['attachment']->isImage = in_array($content['type'], array('jpg', 'jpeg', 'gif', 'png', 'tiff', 'bmp'));
         $value['attachment']->url = Widget_Upload::attachmentHandle($value);
         if ($value['attachment']->isImage) {
             $value['text'] = '<img src="' . $value['attachment']->url . '" alt="' . $value['title'] . '" />';
         } else {
             $value['text'] = '<a href="' . $value['attachment']->url . '" title="' . $value['title'] . '">' . $value['title'] . '</a>';
         }
     }
     /** 處理Markdown **/
     $value['isMarkdown'] = 0 === strpos($value['text'], '<!--markdown-->');
     if ($value['isMarkdown']) {
         $value['text'] = substr($value['text'], 15);
     }
     /** 生成聚合鏈接 */
     /** RSS 2.0 */
     $value['feedUrl'] = $routeExists ? Typecho_Router::url($type, $value, $this->options->feedUrl) : '#';
     /** RSS 1.0 */
     $value['feedRssUrl'] = $routeExists ? Typecho_Router::url($type, $value, $this->options->feedRssUrl) : '#';
     /** ATOM 1.0 */
     $value['feedAtomUrl'] = $routeExists ? Typecho_Router::url($type, $value, $this->options->feedAtomUrl) : '#';
     $value['slug'] = $tmpSlug;
     $value['category'] = $tmpCategory;
     $value['directory'] = $tmpDirectory;
     /** 處理密碼保護流程 */
     if (!empty($value['password']) && $value['password'] !== Typecho_Cookie::get('protectPassword') && $value['authorId'] != $this->user->uid && !$this->user->pass('editor', true)) {
         $value['hidden'] = true;
         /** 拋出錯誤 */
         if ($this->request->isPost() && isset($this->request->protectPassword)) {
             throw new Typecho_Widget_Exception(_t('對不起,您輸入的密碼錯誤'), 403);
         }
     }
     $value = $this->pluginHandle(__CLASS__)->filter($value, $this);
     /** 如果訪問權限被禁止 */
     if ($value['hidden']) {
         $value['text'] = '<form class="protected" action="' . $this->security->getTokenUrl($value['permalink']) . '" method="post">' . '<p class="word">' . _t('請輸入密碼訪問') . '</p>' . '<p><input type="password" class="text" name="protectPassword" />
         <input type="submit" class="submit" value="' . _t('提交') . '" /></p>' . '</form>';
         $value['title'] = _t('此內容被密碼保護');
         $value['tags'] = array();
         $value['commentsNum'] = 0;
     }
     return $value;
 }
開發者ID:Jsechoo,項目名稱:sisome,代碼行數:87,代碼來源:Contents.php

示例15: showButton

 function showButton()
 {
     if (Typecho_Cookie::get('oauth_access_token') && Typecho_Cookie::get('oauth_access_token_secret')) {
         echo '<p><input type="checkbox" checked="" value="yes" id="post_to_twitter" name="post_to_twitter"/><label for="post_to_twitter">同時把留言更新到你的 Twitter</label></p>';
     } else {
         echo '<p><a href="?connect_to_twitter=yes"><img src="http://s3.amazonaws.com/static.whitleymedia/twitconnect.png" /></a></p>';
     }
 }
開發者ID:luobenyu,項目名稱:plugins,代碼行數:8,代碼來源:Plugin.php


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