Ejemplo n.º 1
0
 /**
  * 获取当前评论链接
  *
  * @access protected
  * @return string
  */
 protected function ___permalink()
 {
     if ($this->options->commentsPageBreak && 'approved' == $this->status) {
         $coid = $this->coid;
         $parent = $this->parent;
         while ($parent > 0 && $this->options->commentsThreaded) {
             $parentRows = $this->db->fetchRow($this->db->select('parent')->from('table.comments')->where('coid = ? AND status = ?', $parent, 'approved')->limit(1));
             if (!empty($parentRows)) {
                 $coid = $parent;
                 $parent = $parentRows['parent'];
             } else {
                 break;
             }
         }
         $select = $this->db->select('coid', 'parent')->from('table.comments')->where('cid = ? AND status = ?', $this->parentContent['cid'], 'approved')->where('coid ' . ('DESC' == $this->options->commentsOrder ? '>=' : '<=') . ' ?', $coid)->order('coid', Typecho_Db::SORT_ASC);
         if ($this->options->commentsShowCommentOnly) {
             $select->where('type = ?', 'comment');
         }
         $comments = $this->db->fetchAll($select);
         $commentsMap = array();
         $total = 0;
         foreach ($comments as $comment) {
             $commentsMap[$comment['coid']] = $comment['parent'];
             if (0 == $comment['parent'] || !isset($commentsMap[$comment['parent']])) {
                 $total++;
             }
         }
         $currentPage = ceil($total / $this->options->commentsPageSize);
         $pageRow = array('permalink' => $this->parentContent['pathinfo'], 'commentPage' => $currentPage);
         return Typecho_Router::url('comment_page', $pageRow, $this->options->index) . '#' . $this->theId;
     }
     return $this->parentContent['permalink'] . '#' . $this->theId;
 }
Ejemplo n.º 2
0
 /**
  * 入口函数,初始化路由器
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     /** 对变量赋值 */
     $options = $this->widget('Widget_Options');
     /** 开始会话 */
     @session_start();
     /** 初始化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 (!ini_get("date.timezone") && function_exists("date_default_timezone_set")) {
         @date_default_timezone_set('UTC');
     }
     /** 初始化时区 */
     Typecho_Date::setTimezoneOffset($options->timezone);
     /** 监听缓冲区 */
     ob_start();
 }
Ejemplo n.º 3
0
 /**
  * 初始化函数
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     /** 设置参数默认值 */
     $this->parameter->setDefault('format=Y-m&type=month&limit=0');
     $resource = $this->db->query($this->db->select('created')->from('table.contents')->where('type = ?', 'post')->where('table.contents.status = ?', 'publish')->where('table.contents.created < ?', $this->options->gmtTime)->order('table.contents.created', Typecho_Db::SORT_DESC));
     $offset = $this->options->timezone - $this->options->serverTimezone;
     $result = array();
     while ($post = $this->db->fetchRow($resource)) {
         $timeStamp = $post['created'] + $offset;
         $date = date($this->parameter->format, $timeStamp);
         if (isset($result[$date])) {
             $result[$date]['count']++;
         } else {
             $result[$date]['year'] = date('Y', $timeStamp);
             $result[$date]['month'] = date('m', $timeStamp);
             $result[$date]['day'] = date('d', $timeStamp);
             $result[$date]['date'] = $date;
             $result[$date]['count'] = 1;
         }
     }
     if ($this->parameter->limit > 0) {
         $result = array_slice($result, 0, $this->parameter->limit);
     }
     foreach ($result as $row) {
         $row['permalink'] = Typecho_Router::url('archive_' . $this->parameter->type, $row, $this->widget('Widget_Options')->index);
         $this->push($row);
     }
 }
Ejemplo n.º 4
0
function OutputArchives($db, $options)
{
    $select = $db->select('cid', 'title', 'slug', 'created', 'allowComment', 'commentsNum')->from('table.contents')->where('status = ?', 'publish')->where('type = ?', 'post');
    $rawposts = $db->fetchAll($select);
    $posts = array();
    // Loop through each post and sort it into a structured array
    foreach ($rawposts as $post) {
        /** 取出所有分类 */
        $categories = $isTypechoEX ? Cache_Plugin::meta_get($post['cid'], "category") : $db->fetchAll($db->select('slug')->from('table.metas')->join('table.relationships', 'table.metas.mid = table.relationships.mid')->where('table.relationships.cid = ?', $post['cid'])->where('table.metas.type = ?', 'category')->order('table.metas.order', Typecho_Db::SORT_ASC));
        /** 取出第一个分类作为slug条件 */
        $post['category'] = current(Typecho_Common::arrayFlatten($categories, 'slug'));
        $date = new Typecho_Date($post['created']);
        $post['year'] = $date->year;
        $post['month'] = $date->month;
        $post['day'] = $date->day;
        $type = 'post';
        //$p['type'];
        $routeExists = NULL != Typecho_Router::get($type);
        $permalink = $routeExists ? Typecho_Router::url($type, $post, $options->index) : '#';
        $post['permalink'] = $permalink;
        $posts[$post['year'] . '.' . $post['month']][] = $post;
    }
    $rawposts = null;
    // More memory cleanup
    // Sort the months based on $atts
    krsort($posts);
    // Sort the posts within each month based on $atts
    foreach ($posts as $key => $month) {
        $sorter = array();
        foreach ($month as $post) {
            $sorter[] = $post['created'];
        }
        array_multisort($sorter, SORT_DESC, $month);
        $posts[$key] = $month;
        unset($month);
    }
    // Generate the HTML
    $html = "";
    foreach ($posts as $yearmonth => $posts) {
        list($year, $month) = explode('.', $yearmonth);
        $html .= "<li><b><a href=\"" . Typecho_Router::url('archive_month', array('year' => $year, 'month' => $month), $options->index) . "\">" . $year . "年" . $month . "月</a></b> <span>(" . number_format(count($posts)) . " 篇文章)</span><ul>";
        foreach ($posts as $post) {
            $html .= "<li>" . $post['day'] . ": <a href=\"" . $post['permalink'] . "\">" . $post['title'] . "</a> <span>(" . number_format($post['commentsNum']) . ")</span></li>";
        }
        $html .= "</ul></li>";
    }
    return $html;
}
Ejemplo n.º 5
0
 /**
  * 获取当前评论链接
  *
  * @access protected
  * @return string
  */
 protected function ___permalink()
 {
     if ($this->options->commentsPageBreak && 'approved' == $this->status) {
         $coid = $this->coid;
         $select = $this->db->select('coid')->from('table.comments')->where('cid = ? AND status = ?', $this->parentContent['cid'], 'approved')->where('coid ' . ('DESC' == $this->options->commentsOrder ? '>=' : '<=') . ' ?', $coid)->order('coid', Typecho_Db::SORT_ASC);
         if ($this->options->commentsShowCommentOnly) {
             $select->where('type = ?', 'comment');
         }
         $comments = $this->db->fetchAll($select);
         $total = count($comments);
         $currentPage = ceil($total / $this->options->commentsPageSize);
         $pageRow = array('permalink' => $this->parentContent['pathinfo'], 'commentPage' => $currentPage);
         return Typecho_Router::url('comment_page', $pageRow, $this->options->index) . '#' . $this->theId;
     }
     return $this->parentContent['permalink'] . '#' . $this->theId;
 }
Ejemplo n.º 6
0
 /**
  * 入口函数,初始化路由器
  *
  * @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();
 }
Ejemplo n.º 7
0
 /**
  * 输出分页
  *
  * @access public
  * @param string $prev 上一页文字
  * @param string $next 下一页文字
  * @param int $splitPage 分割范围
  * @param string $splitWord 分割字符
  * @param string $template 展现配置信息
  * @return void
  */
 public function pageNav($prev = '&laquo;', $next = '&raquo;', $splitPage = 3, $splitWord = '...', $template = '')
 {
     if ($this->options->commentsPageBreak && $this->_total > $this->options->commentsPageSize) {
         $default = array('wrapTag' => 'ol', 'wrapClass' => 'page-navigator');
         if (is_string($template)) {
             parse_str($template, $config);
         } else {
             $config = $template;
         }
         $template = array_merge($default, $config);
         $pageRow = $this->parameter->parentContent;
         $pageRow['permalink'] = $pageRow['pathinfo'];
         $query = Typecho_Router::url('comment_page', $pageRow, $this->options->index);
         /** 使用盒状分页 */
         $nav = new Typecho_Widget_Helper_PageNavigator_Box($this->_total, $this->_currentPage, $this->options->commentsPageSize, $query);
         $nav->setPageHolder('commentPage');
         $nav->setAnchor('comments');
         echo '<' . $template['wrapTag'] . (empty($template['wrapClass']) ? '' : ' class="' . $template['wrapClass'] . '"') . '>';
         $nav->render($prev, $next, $splitPage, $splitWord, $template);
         echo '</' . $template['wrapTag'] . '>';
     }
 }
Ejemplo n.º 8
0
 public static function authorizeIcon()
 {
     return '<a href="' . Typecho_Router::url('sinauthAuthorize', array('feed' => '/atom/comments/')) . '">新浪登陆</a>';
 }
Ejemplo n.º 9
0
 /**
  * 设置路由器默认配置
  *
  * @access public
  * @param mixed $routes 配置信息
  * @return void
  */
 public static function setRoutes($routes)
 {
     if (isset($routes[0])) {
         self::$_routingTable = $routes[0];
     } else {
         /** 解析路由配置 */
         $parser = new Typecho_Router_Parser($routes);
         self::$_routingTable = $parser->parse();
     }
 }
Ejemplo n.º 10
0
          <div class="site-state-item site-state-posts">
            <a href="<?php 
echo Typecho_Router::url('page', array('slug' => 'archive'), $this->options->index);
?>
">
              <span class="site-state-item-count"><?php 
echo $stat->publishedPostsNum;
?>
</span>
              <span class="site-state-item-name">日志</span>
          </a>
      </div>

      <div class="site-state-item site-state-categories">
        <a href="<?php 
echo Typecho_Router::url('page', array('slug' => 'categories'), $this->options->index);
?>
">
          <span class="site-state-item-count"><?php 
echo $stat->categoriesNum;
?>
</span>
          <span class="site-state-item-name">分类</span>
</a>
      </div>

      <div class="site-state-item site-state-tags">
          <span class="site-state-item-count"><?php 
echo $stat->publishedPagesNum;
?>
</span>
Ejemplo n.º 11
0
 /**
  * Grab all posts and filter them into an array
  *
  */
 public static function GetPosts()
 {
     $options = Typecho_Widget::widget('Widget_Options');
     /**
      * 获取数据库实例化对象
      * 用静态变量存储实例化的数据库对象,可以保证数据连接仅进行一次
      */
     $db = Typecho_Db::get();
     $select = $db->select('cid', 'title', 'slug', 'created', 'allowComment', 'commentsNum')->from('table.contents')->where('status = ?', 'publish')->where('type = ?', 'post');
     $rawposts = $db->fetchAll($select);
     $posts = array();
     // Loop through each post and sort it into a structured array
     foreach ($rawposts as $post) {
         /** 取出所有分类 */
         $categories = $db->fetchAll($db->select('slug')->from('table.metas')->join('table.relationships', 'table.metas.mid = table.relationships.mid')->where('table.relationships.cid = ?', $post['cid'])->where('table.metas.type = ?', 'category')->order('table.metas.order', Typecho_Db::SORT_ASC));
         /** 取出第一个分类作为slug条件 */
         $post['category'] = current(Typecho_Common::arrayFlatten($categories, 'slug'));
         $date = new Typecho_Date($post['created']);
         $post['year'] = $date->year;
         $post['month'] = $date->month;
         $post['day'] = $date->day;
         $type = 'post';
         //$p['type'];
         $routeExists = NULL != Typecho_Router::get($type);
         $permalink = $routeExists ? Typecho_Router::url($type, $post, $options->index) : '#';
         $post['permalink'] = $permalink;
         $posts[$post['year'] . '.' . $post['month']][] = $post;
     }
     $rawposts = null;
     // More memory cleanup
     return $posts;
 }
Ejemplo n.º 12
0
 /**
  * 通用过滤器
  *
  * @access public
  * @param array $value 需要过滤的行数据
  * @return array
  */
 public function filter(array $value)
 {
     //生成静态链接
     $type = $value['type'];
     $routeExists = NULL != Typecho_Router::get($type);
     $tmpSlug = $value['slug'];
     $value['slug'] = urlencode($value['slug']);
     $value['permalink'] = $routeExists ? Typecho_Router::url($type, $value, $this->options->index) : '#';
     /** 生成聚合链接 */
     /** 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 = $this->pluginHandle(__CLASS__)->filter($value, $this);
     return $value;
 }
Ejemplo n.º 13
0
 /**
  * 设置路由器默认配置
  *
  * @access public
  * @param mixed $routes 配置信息
  * @return void
  */
 public static function setRoutes($routes)
 {
     /** 载入路由解析支持 */
     require_once 'Typecho/Router/Parser.php';
     if (isset($routes[0])) {
         self::$_routingTable = $routes[0];
     } else {
         /** 解析路由配置 */
         $parser = new Typecho_Router_Parser($routes);
         self::$_routingTable = $parser->parse();
     }
 }
Ejemplo n.º 14
0
 /**
  * 获取登录提交地址
  *
  * @access protected
  * @return string
  */
 protected function ___registerAction()
 {
     return Typecho_Router::url('do', array('action' => 'register', 'widget' => 'Register'), $this->index);
 }
Ejemplo n.º 15
0
include 'common.php';
include 'header.php';
include 'menu.php';
?>

<div class="main">
    <div class="body container">
        <?php 
include 'page-title.php';
?>
        <div class="row typecho-page-main" role="main">
            <div class="col-mb-12">
                <div id="typecho-welcome">
                    <form action="<?php 
echo $security->getTokenUrl(Typecho_Router::url('do', array('action' => 'upgrade', 'widget' => 'Upgrade'), Typecho_Common::url('index.php', $options->rootUrl)));
?>
" method="post">
                    <h3><?php 
_e('检测到新版本!');
?>
</h3>
                    <ul>
                        <li><?php 
_e('您已经更新了系统程序, 我们还需要执行一些后续步骤来完成升级');
?>
</li>
                        <li><?php 
_e('此程序将把您的系统从 <strong>%s</strong> 升级到 <strong>%s</strong>', $options->version, Typecho_Common::VERSION);
?>
</li>
Ejemplo n.º 16
0
 /**
  * 准备数据
  * @param $contents 文章内容
  * @param $class 调用接口的类
  * @throws Typecho_Plugin_Exception
  */
 public static function send($contents, $class)
 {
     //如果文章属性为隐藏或滞后发布
     if ('publish' != $contents['visibility'] || $contents['created'] > time()) {
         return;
     }
     //获取系统配置
     $options = Helper::options();
     //判断是否配置好API
     if (is_null($options->plugin('BaiduSubmit')->api)) {
         throw new Typecho_Plugin_Exception(_t('api未配置'));
     }
     //获取文章类型
     $type = $contents['type'];
     //获取路由信息
     $routeExists = NULL != Typecho_Router::get($type);
     if (!is_null($routeExists)) {
         $db = Typecho_Db::get();
         $contents['cid'] = $class->cid;
         $contents['categories'] = $db->fetchAll($db->select()->from('table.metas')->join('table.relationships', 'table.relationships.mid = table.metas.mid')->where('table.relationships.cid = ?', $contents['cid'])->where('table.metas.type = ?', 'category')->order('table.metas.order', Typecho_Db::SORT_ASC));
         $contents['category'] = urlencode(current(Typecho_Common::arrayFlatten($contents['categories'], 'slug')));
         $contents['slug'] = urlencode($contents['slug']);
         $contents['date'] = new Typecho_Date($contents['created']);
         $contents['year'] = $contents['date']->year;
         $contents['month'] = $contents['date']->month;
         $contents['day'] = $contents['date']->day;
     }
     //生成永久连接
     $path_info = $routeExists ? Typecho_Router::url($type, $contents) : '#';
     $permalink = Typecho_Common::url($path_info, $options->index);
     //调用post方法
     self::post($permalink);
 }
Ejemplo n.º 17
0
 /**
  * 获取登录提交地址
  *
  * @access protected
  * @return string
  */
 protected function ___registerAction()
 {
     return $this->widget('Widget_Security')->getTokenUrl(Typecho_Router::url('do', array('action' => 'register', 'widget' => 'Register'), $this->index));
 }
Ejemplo n.º 18
0
                <div class="typecho-option-tabs">
                    <ul class="typecho-option-tabs clearfix">
                        <li class="current">
                           <form action="<?php 
$options->index('/action/golinks?add');
?>
" method="post" >
                          &nbsp;&nbsp;&nbsp;&nbsp;KEY:<input name="key" id="key" type="text" value="" />&nbsp;&nbsp;&nbsp;&nbsp;
                          目标:<input name="target" id="target" type="text" value="http://" />
                          <input type="submit" class="btn-s primary" value="添加" />  
                           </form> 
                        </li>
               
                    <li class="right current">                    
                        <?php 
$ro = Typecho_Router::get('go');
?>
                            自定义链接:<input id="links" name="links" value="<?php 
echo $ro['url'];
?>
" type="text">
                        <button id="qlinks" type="button">修改</button>
                    </li>
                     </ul>
               </div>               
                <div class="typecho-table-wrap">
                <table class="typecho-list-table">
                    <colgroup>                       
                        <col width="15%"/>
                        <col width="25%"/>
                        <col width="47%"/>
Ejemplo n.º 19
0
function Comments_Pager($obj)
{
    //set total
    $pagesize = MyTypechoTheme_Plugin::$_options->commentsPageSize;
    $total = $obj->getTotal();
    if (MyTypechoTheme_Plugin::$_options->commentsPageBreak && $total > $pagesize) {
        $currentPage = $obj->getCurrentPage();
        $totalPage = ceil($total / $pagesize);
        if ($currentPage < $totalPage) {
            $pageRow = $obj->parameter->parentContent;
            $pageRow['permalink'] = $pageRow['pathinfo'];
            //get url
            $query = Typecho_Router::url('comment_page', $pageRow, MyTypechoTheme_Plugin::$_options->index);
            echo "<div class=\"navigation\"><a class=\"loadmore\" role=\"navigation\" href=\"#\" data=\"" . str_replace('{commentPage}', $currentPage + 1, $query) . "\">更多评论</a></div>";
        }
    }
}
Ejemplo n.º 20
0
 /**
  * 输出分页
  *
  * @access public
  * @param string $prev 上一页文字
  * @param string $next 下一页文字
  * @param int $splitPage 分割范围
  * @param string $splitWord 分割字符
  * @return void
  */
 public function pageNav($prev = '&laquo;', $next = '&raquo;', $splitPage = 3, $splitWord = '...')
 {
     if ($this->options->commentsPageBreak && $this->_total > $this->options->commentsPageSize) {
         $pageRow = $this->parameter->parentContent;
         $pageRow['permalink'] = $pageRow['pathinfo'];
         $query = Typecho_Router::url('comment_page', $pageRow, $this->options->index);
         /** 使用盒状分页 */
         $nav = new Typecho_Widget_Helper_PageNavigator_Box($this->_total, $this->_currentPage, $this->options->commentsPageSize, $query);
         $nav->setPageHolder('commentPage');
         $nav->setAnchor('comments');
         echo '<ol class="page-navigator">';
         $nav->render($prev, $next, $splitPage, $splitWord);
         echo '</ol>';
     }
 }
Ejemplo n.º 21
0
 /**
  * 通用过滤器
  *
  * @access public
  * @param array $value 需要过滤的行数据
  * @return array
  */
 public function filter(array $value)
 {
     //生成静态链接
     $routeExists = NULL != Typecho_Router::get('author');
     $value['permalink'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->index) : '#';
     /** 生成聚合链接 */
     /** RSS 2.0 */
     $value['feedUrl'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->feedUrl) : '#';
     /** RSS 1.0 */
     $value['feedRssUrl'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->feedRssUrl) : '#';
     /** ATOM 1.0 */
     $value['feedAtomUrl'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->feedAtomUrl) : '#';
     // modified_by_jiangmuzi 2015.09.22
     $avatar = Forum_Common::parseUserAvatar($value['uid']);
     $value = array_merge($value, $avatar);
     $value['ucenter'] = $this->options->someUrl('ucenter', array('u' => $value['name']), false);
     // end modified
     $value = $this->pluginHandle(__CLASS__)->filter($value, $this);
     return $value;
 }
Ejemplo n.º 22
0
 /**
  * 检查链接是否正确
  *
  * @access private
  * @return void
  */
 private function checkPermalink()
 {
     $type = $this->parameter->type;
     if (in_array($type, array('index', 'comment_page', 404)) || $this->_makeSinglePageAsFrontPage || !$this->parameter->checkPermalink) {
         // 强制关闭
         return;
     }
     if ($this->_archiveSingle) {
         $permalink = $this->permalink;
     } else {
         $value = array_merge($this->_pageRow, array('page' => $this->_currentPage));
         $path = Typecho_Router::url($type, $value);
         $permalink = Typecho_Common::url($path, $this->options->index);
     }
     $requestUrl = $this->request->getRequestUrl();
     $src = parse_url($permalink);
     $target = parse_url($requestUrl);
     if ($src['host'] != $target['host'] || urldecode($src['path']) != urldecode($target['path'])) {
         $this->response->redirect($permalink, true);
     }
 }
Ejemplo n.º 23
0
include 'common.php';
include 'header.php';
include 'menu.php';
?>

<div class="main">
    <div class="body container">
        <?php 
include 'page-title.php';
?>
        <div class="colgroup typecho-page-main" role="main">
            <div class="col-mb-12">
                <div id="typecho-welcome">
                    <form action="<?php 
echo Typecho_Router::url('do', array('action' => 'upgrade', 'widget' => 'Upgrade'), Typecho_Common::url('index.php', $options->siteUrl));
?>
" method="post">
                    <h3><?php 
_e('检测到新版本!');
?>
</h3>
                    <ul>
                        <li><?php 
_e('您已经更新了系统程序, 我们还需要执行一些后续步骤来完成升级');
?>
</li>
                        <li><?php 
_e('此程序将把您的系统从 <strong>%s</strong> 升级到 <strong>%s</strong>', $options->version, Typecho_Common::VERSION);
?>
</li>
Ejemplo n.º 24
0
<?php

/**
 * Typecho Blog Platform
 *
 * @copyright  Copyright (c) 2008 Typecho team (http://www.typecho.org)
 * @license    GNU General Public License 2.0
 * @version    $Id: index.php 1153 2009-07-02 10:53:22Z magike.net $
 */
//require_once($_SERVER['DOCUMENT_ROOT'].'/BrutalSafe.php');
/** 载入配置支持 */
if (!defined('__TYPECHO_ROOT_DIR__') && !@(include_once 'config.inc.php')) {
    file_exists('./install.php') ? header('Location: install.php') : (print 'Missing Config File');
    exit;
}
/** 初始化组件 */
Typecho_Widget::widget('Widget_Init');
/** 注册一个初始化插件 */
Typecho_Plugin::factory('index.php')->begin();
/** 开始路由分发 */
Typecho_Router::dispatch();
/** 注册一个结束插件 */
Typecho_Plugin::factory('index.php')->end();
Ejemplo n.º 25
0
 /**
  * pingbackPing
  *
  * @param string $source
  * @param string $target
  * @access public
  * @return void
  */
 public function pingbackPing($source, $target)
 {
     /** 检查源地址是否存在*/
     if (!($http = Typecho_Http_Client::get())) {
         return new IXR_Error(16, _t('源地址服务器错误'));
     }
     try {
         $http->setTimeout(5)->send($source);
         $response = $http->getResponseBody();
         if (200 == $http->getResponseStatus()) {
             if (!$http->getResponseHeader('x-pingback')) {
                 preg_match_all("/<link[^>]*rel=[\"']([^\"']*)[\"'][^>]*href=[\"']([^\"']*)[\"'][^>]*>/i", $response, $out);
                 if (!isset($out[1]['pingback'])) {
                     return new IXR_Error(50, _t('源地址不支持PingBack'));
                 }
             }
         } else {
             return new IXR_Error(16, _t('源地址服务器错误'));
         }
     } catch (Exception $e) {
         return new IXR_Error(16, _t('源地址服务器错误'));
     }
     /** 检查目标地址是否正确*/
     $pathInfo = Typecho_Common::url(substr($target, strlen($this->options->index)), '/');
     $post = Typecho_Router::match($pathInfo);
     /** 这样可以得到cid或者slug*/
     if (!$post instanceof Widget_Archive || !$post->have() || !$post->is('single')) {
         return new IXR_Error(33, _t('这个目标地址不存在'));
     }
     if ($post) {
         /** 检查是否可以ping*/
         if ($post->allowPing) {
             /** 现在可以ping了,但是还得检查下这个pingback是否已经存在了*/
             $pingNum = $this->db->fetchObject($this->db->select(array('COUNT(coid)' => 'num'))->from('table.comments')->where('table.comments.cid = ? AND table.comments.url = ? AND table.comments.type <> ?', $post->cid, $source, 'comment'))->num;
             if ($pingNum <= 0) {
                 /** 现在开始插入以及邮件提示了 $response就是第一行请求时返回的数组*/
                 preg_match("/\\<title\\>([^<]*?)\\<\\/title\\>/is", $response, $matchTitle);
                 $finalTitle = Typecho_Common::removeXSS(trim(strip_tags($matchTitle[1])));
                 /** 干掉html tag,只留下<a>*/
                 $text = Typecho_Common::stripTags($response, '<a href="">');
                 /** 此处将$target quote,留着后面用*/
                 $pregLink = preg_quote($target);
                 /** 找出含有target链接的最长的一行作为$finalText*/
                 $finalText = '';
                 $lines = explode("\n", $text);
                 foreach ($lines as $line) {
                     $line = trim($line);
                     if (NULL != $line) {
                         if (preg_match("|<a[^>]*href=[\"']{$pregLink}[\"'][^>]*>(.*?)</a>|", $line)) {
                             if (strlen($line) > strlen($finalText)) {
                                 /** <a>也要干掉,*/
                                 $finalText = Typecho_Common::stripTags($line);
                             }
                         }
                     }
                 }
                 /** 截取一段字*/
                 if (NULL == trim($finalText)) {
                     return new IXR_Error('17', _t('源地址中不包括目标地址'));
                 }
                 $finalText = '[...]' . Typecho_Common::subStr($finalText, 0, 200, '') . '[...]';
                 $pingback = array('cid' => $post->cid, 'created' => $this->options->gmtTime, 'agent' => $this->request->getAgent(), 'ip' => $this->request->getIp(), 'author' => $finalTitle, 'url' => Typecho_Common::safeUrl($source), 'text' => $finalText, 'ownerId' => $post->author->uid, 'type' => 'pingback', 'status' => $this->options->commentsRequireModeration ? 'waiting' : 'approved');
                 /** 加入plugin */
                 $pingback = $this->pluginHandle()->pingback($pingback, $post);
                 /** 执行插入*/
                 $insertId = $this->singletonWidget('Widget_Abstract_Comments')->insert($pingback);
                 /** 评论完成接口 */
                 $this->pluginHandle()->finishPingback($this);
                 return $insertId;
                 /** todo:发送邮件提示*/
             } else {
                 return new IXR_Error(48, _t('PingBack已经存在'));
             }
         } else {
             return IXR_Error(49, _t('目标地址禁止Ping'));
         }
     } else {
         return new IXR_Error(33, _t('这个目标地址不存在'));
     }
 }
Ejemplo n.º 26
0
 /**
  * 初始化函数
  *
  * @access public
  * @return void
  * @throws Typecho_Widget_Exception
  */
 public function action()
 {
     /** 回调方法 */
     $callback = $this->request->type;
     $this->_content = Typecho_Router::match($this->request->permalink);
     /** 判断内容是否存在 */
     if (false !== $this->_content && $this->_content instanceof Widget_Archive && $this->_content->have() && $this->_content->is('single') && in_array($callback, array('comment', 'trackback'))) {
         /** 如果文章不允许反馈 */
         if ('comment' == $callback) {
             /** 评论关闭 */
             if (!$this->_content->allow('comment')) {
                 throw new Typecho_Widget_Exception(_t('对不起,此内容的反馈被禁止.'), 403);
             }
             /** 检查来源 */
             if ($this->options->commentsCheckReferer && 'false' != $this->parameter->checkReferer) {
                 $referer = $this->request->getReferer();
                 if (empty($referer)) {
                     throw new Typecho_Widget_Exception(_t('评论来源页错误.'), 403);
                 }
                 $refererPart = parse_url($referer);
                 $currentPart = parse_url($this->_content->permalink);
                 if ($refererPart['host'] != $currentPart['host'] || 0 !== strpos($refererPart['path'], $currentPart['path'])) {
                     //自定义首页支持
                     if ('page:' . $this->_content->cid == $this->options->frontPage) {
                         $currentPart = parse_url(rtrim($this->options->siteUrl, '/') . '/');
                         if ($refererPart['host'] != $currentPart['host'] || 0 !== strpos($refererPart['path'], $currentPart['path'])) {
                             throw new Typecho_Widget_Exception(_t('评论来源页错误.'), 403);
                         }
                     } else {
                         throw new Typecho_Widget_Exception(_t('评论来源页错误.'), 403);
                     }
                 }
             }
             /** 检查ip评论间隔 */
             if (!$this->user->pass('editor', true) && $this->_content->authorId != $this->user->uid && $this->options->commentsPostIntervalEnable) {
                 $latestComment = $this->db->fetchRow($this->db->select('created')->from('table.comments')->where('cid = ?', $this->_content->cid)->order('created', Typecho_Db::SORT_DESC)->limit(1));
                 if ($latestComment && ($this->options->gmtTime - $latestComment['created'] > 0 && $this->options->gmtTime - $latestComment['created'] < $this->options->commentsPostInterval)) {
                     throw new Typecho_Widget_Exception(_t('对不起, 您的发言过于频繁, 请稍侯再次发布.'), 403);
                 }
             }
         }
         /** 如果文章不允许引用 */
         if ('trackback' == $callback && !$this->_content->allow('ping')) {
             throw new Typecho_Widget_Exception(_t('对不起,此内容的引用被禁止.'), 403);
         }
         /** 调用函数 */
         $this->{$callback}();
     } else {
         throw new Typecho_Widget_Exception(_t('找不到内容'), 404);
     }
 }
Ejemplo n.º 27
0
 public function someAction($route, $params = null, $echo = true)
 {
     $params['action'] = $route;
     $url = $this->widget('Widget_Security')->getTokenUrl(Typecho_Router::url('do', $params, $this->index));
     if ($echo) {
         echo $url;
     } else {
         return $url;
     }
 }
Ejemplo n.º 28
0
 /**
  * 通用过滤器
  *
  * @access public
  * @param array $value 需要过滤的行数据
  * @return array
  */
 public function filter(array $value)
 {
     //生成静态链接
     $routeExists = NULL != Typecho_Router::get('author');
     $value['permalink'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->index) : '#';
     /** 生成聚合链接 */
     /** RSS 2.0 */
     $value['feedUrl'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->feedUrl) : '#';
     /** RSS 1.0 */
     $value['feedRssUrl'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->feedRssUrl) : '#';
     /** ATOM 1.0 */
     $value['feedAtomUrl'] = $routeExists ? Typecho_Router::url('author', $value, $this->options->feedAtomUrl) : '#';
     $value = $this->pluginHandle(__CLASS__)->filter($value, $this);
     return $value;
 }
Ejemplo n.º 29
0
 /**
  * 通用过滤器
  *
  * @access public
  * @param array $value 需要过滤的行数据
  * @return array
  */
 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_Abstract_Metas'), 'filter'));
     /** 取出第一个分类作为slug条件 */
     $value['category'] = current(Typecho_Common::arrayFlatten($value['categories'], 'slug'));
     $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'];
     $value['slug'] = urlencode($value['slug']);
     $value['category'] = urlencode($value['category']);
     /** 生成静态路径 */
     $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;
     /** 处理密码保护流程 */
     if (!empty($value['password']) && $value['password'] != $this->request->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="' . $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;
 }
Ejemplo n.º 30
0
 /**
  * 前一页
  *
  * @access public
  * @param string $word 链接标题
  * @param string $page 页面链接
  * @return void
  */
 public function pageLink($word = '&laquo; Previous Entries', $page = 'prev')
 {
     if ($this->have()) {
         if (empty($this->_pageNav)) {
             $query = Typecho_Router::url($this->parameter->type . (false === strpos($this->parameter->type, '_page') ? '_page' : NULL), $this->_pageRow, $this->options->index);
             /** 使用盒状分页 */
             $this->_pageNav = new Typecho_Widget_Helper_PageNavigator_Classic($this->getTotal(), $this->_currentPage, $this->parameter->pageSize, $query);
         }
         $this->_pageNav->{$page}($word);
     }
 }