Example #1
0
 public function show_recent_comments($format, $length = 100, $trim = '...')
 {
     /** 处理输入数据 */
     if (empty($format)) {
         return;
     }
     $length = !empty($length) && is_numeric($length) ? intval($length) : 100;
     $trim = !empty($trim) ? $trim : '...';
     $limit = setting_item('comments_list_size');
     $limit = $limit && is_numeric($limit) ? intval($limit) : 10;
     $comments = $this->_CI->stcache->get('Widget::Comments::Recent');
     if (FALSE == $comments) {
         $comments = $this->_CI->db->select('comments.pid, comments.cid, comments.text, comments.author, posts.slug as post_slug, posts.title as post_title, posts.type as post_type')->from('comments')->join('posts', 'comments.pid = posts.pid', 'left')->where('comments.type', 'comment')->where('comments.status', 'approved')->order_by('comments.created', 'DESC')->limit($limit)->offset(0)->get()->result();
         $this->_CI->stcache->set('Widget::Comments::Recent', $comments);
     }
     $sequence = 1;
     if ($comments) {
         foreach ($comments as $comment) {
             $wildcards = array('{permalink}', '{parent_post_desc}', '{title}', '{content}');
             $permalink = 'post' == $comment->post_type ? site_url('posts/' . $comment->post_slug . '#comment-' . $comment->cid) : site_url('pages/' . $comment->post_slug . '#comment-' . $comment->cid);
             $replaces = array($permalink, '对[' . $comment->post_title . ']一文的评论:', $comment->author, Common::subStr(strip_tags($comment->text), 0, $length, $trim));
             echo str_replace($wildcards, $replaces, $format) . "\r\n";
             $post = NULL;
             $sequence++;
         }
     }
 }
Example #2
0
 public function show_related_posts($post_id, $list_size, $format)
 {
     /** 输出格式为空?*/
     if (empty($format) || !is_numeric($post_id) || empty($list_size)) {
         return;
     }
     /** 参数初始化 */
     $post_id = intval($post_id);
     $list_size = $list_size && is_numeric($list_size) ? intval($list_size) : 10;
     $date_format = setting_item('post_date_format');
     $date_format = !empty($date_format) ? $date_format : 'Y-m-d';
     $this->_CI->metas_mdl->get_metas($post_id);
     $tags = implode(',', Common::array_flatten($this->_CI->metas_mdl->metas['tag'], 'mid'));
     if (empty($tags)) {
         echo "<p>没有相关文章</p>\r\n";
         return;
     }
     $posts = $this->_CI->db->select('posts.slug, posts.title, posts.created')->from('posts')->join('relationships', 'posts.pid = relationships.pid', 'INNER')->where_in('relationships.mid', $tags)->where('posts.pid <>', $post_id)->where('posts.status', 'publish')->where('posts.type', 'post')->order_by('posts.created', 'DESC')->limit($list_size)->offset(0)->get()->result();
     if ($posts) {
         foreach ($posts as $post) {
             $wildcards = array('{permalink}', '{title}', '{date}');
             $replaces = array(site_url('posts/' . $post->slug), $post->title, date($date_format, $post->created));
             echo str_replace($wildcards, $replaces, $format) . "\r\n";
         }
     }
     return;
 }
Example #3
0
 /**
  * 解析函数
  *
  * @access public
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     /** privilege confirm */
     $this->auth->exceed('administrator');
     $this->_current_theme = setting_item('current_theme');
     $this->load->model('themes_mdl');
     $this->_data['parentPage'] = 'dashboard';
     $this->_data['currentPage'] = 'themes';
 }
Example #4
0
    /**
     * 检查博客状态
     */
    public function check_blog_status()
    {
        if (setting_item('blog_status')) {
            if ('off' == setting_item('blog_status')) {
                $title = sprintf('%s - Site Close Notice', setting_item('blog_title'));
                $heading = sprintf('%s is closed by ites administrator TEMPORARILY.', setting_item('blog_title'));
                $message = sprintf('Reason: %s', setting_item('offline_reason') ? setting_item('offline_reason') : 'n/a');
                echo <<<EOT
<html xmlns="http://www.w3.org/1999/xhtml" > <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>{$title}</title><style type="text/css">body{padding-right: 32px;margin-top: 40px;padding-left: 32px;font-size: 13px;background: #eee;padding-bottom: 32px;color: #000;padding-top: 32px;font-family:Verdana;}#main{border-right: #bbb 1px solid;border-top: #bbb 1px solid;background: #fff;padding-bottom: 32px;border-left: #bbb 1px solid;width: 550px;padding-top: 20px;border-bottom: #bbb 1px solid;text-align:left;padding-left:60px;padding-right:50px;}div#heading{padding-right: 0px;padding-left: 0px;font-weight: bold;font-size: 120%;padding-bottom: 15px;margin: 0px;color: #904;padding-top: 0px;font-family: arial;}h2{padding-right: 0px;padding-left: 0px;font-weight: bold;font-size: 105%;padding-bottom: 0px;margin: 0px 0px 8px;text-transform: uppercase;color: #999;padding-top: 0px;border-bottom: #ddd 1px solid;font-family: "trebuchet ms" , "" lucida grande "" , verdana, arial, sans-serif;}p{padding-right: 0px;padding-left: 0px;padding-bottom: 6px;margin: 0px;padding-top: 6px;}a:link{color: #002c99;font-size: 12px;}a:visited{color: #002c99;font-size: 12px;}a:hover{color: #cc0066;background-color: #f5f5f5;text-decoration: underline;font-size: 12px;}</style> </head> <body> <div style="width:100%;"><div align="center"> <div id="main"><div id="heading">{$heading}</div>{$message}</div></div> </div> </body></html>
EOT;
                exit;
            }
        }
    }
Example #5
0
 /**
  * 加载某个主题页面下的VIEW
  *
  * 第1/2/4个参数分别对应CI原有的load view中的第1/2/3参数,这里的第三个参数用于一些特殊场合:
  * 当整站缓存功能被开启时,为了避免当前被操作的页面缓存,可以设置第三个参数为FALSE避免。
  *
  *
  * @access   public
  * @param    string
  * @param    array
  * @param	 bool
  * @param    bool
  * @return   void
  */
 function load_theme_view($view, $vars = array(), $cached = TRUE, $return = FALSE)
 {
     /** 加载对应主题下的view */
     if (file_exists(FCPATH . ST_THEMES_DIR . DIRECTORY_SEPARATOR . setting_item('current_theme') . DIRECTORY_SEPARATOR . $view . '.php')) {
         echo $this->load->view($view, $vars, $return);
     } else {
         show_404();
     }
     /** 是否开启缓存? */
     if (1 == intval(setting_item('cache_enabled')) && $cached) {
         $cache_expired = setting_item('cache_expire_time');
         $cache_expired = $cache_expired && is_numeric($cache_expired) ? intval($cache_expired) : 60;
         /** 开启缓存 */
         $this->output->cache($cache_expired);
     }
 }
Example #6
0
 public function show_recent_posts($format)
 {
     /** 输出格式为空?*/
     if (empty($format)) {
         return;
     }
     /** 输出多少条? */
     $list_size = setting_item('posts_list_size');
     $list_size = $list_size && is_numeric($list_size) ? intval($list_size) : 10;
     $posts = $this->_CI->stcache->get('Widget::Posts::Recent');
     if (FALSE == $posts) {
         $posts = $posts = $this->_CI->db->select('slug, title')->from('posts')->where('type', 'post')->where('status', 'publish')->order_by('created', 'DESC')->limit($list_size)->offset(0)->get()->result();
         $this->_CI->stcache->set('Widget::Posts::Recent', $posts);
     }
     if ($posts) {
         foreach ($posts as $post) {
             $wildcards = array('{permalink}', '{title}');
             $replaces = array(site_url('posts/' . $post->slug), $post->title);
             echo str_replace($wildcards, $replaces, $format) . "\r\n";
         }
     }
 }
Example #7
0
 /**
  * 搜索
  * 
  * @access public
  * @return void
  */
 public function search()
 {
     $keywords = strip_tags($this->input->get('s', TRUE));
     $page = strip_tags($this->input->get('p', TRUE));
     /** 分页参数 */
     $this->_init_pagination($page);
     $this->_posts = $this->posts_mdl->get_posts('post', 'publish', NULL, $this->_limit, $this->_offset, 0, $keywords, TRUE)->result();
     $this->_total_count = $this->posts_mdl->get_posts('post', 'publish', NULL, 10000, 0, 0, $keywords, TRUE)->num_rows();
     if (!empty($this->_posts)) {
         $this->_prepare_posts();
         $this->_apply_pagination(site_url('search?s=' . urlencode($keywords)), FALSE, 'p');
     }
     /** 页面初始化 */
     $data['page_title'] = sprintf('搜索:%s', $keywords);
     $data['page_description'] = setting_item('blog_description');
     $data['page_keywords'] = setting_item('blog_keywords');
     $data['posts'] = $this->_posts;
     $data['parsed_feed'] = Common::render_feed_meta();
     $data['current_view_hints'] = sprintf('关键字 %s 的搜索结果(第 %d 页 / 共 %d 篇)', $keywords, $this->_current_page, $this->_total_count);
     $data['pagination'] = $this->_pagination;
     $this->load_theme_view('index', $data);
 }
Example #8
0
<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
/** 触发一个初始化插件admin/header */
//$this->plugin->trigger('admin/header');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title><?php 
echo $page_title . ' - ' . setting_item('blog_title');
?>
</title>
        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
        <link rel="stylesheet" type="text/css" href="<?php 
echo base_url();
?>
application/views/admin/styles/reset.source.css" /> 
		<link rel="stylesheet" type="text/css" href="<?php 
echo base_url();
?>
application/views/admin/styles/grid.source.css" /> 
		<link rel="stylesheet" type="text/css" href="<?php 
echo base_url();
?>
application/views/admin/styles/typecho.source.css" />    
</head>
Example #9
0
<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}
?>
	<div id="footer"><!-- //footer-->
		<hr />
		<p class="left">&copy;2007-2010 <?php 
echo anchor(site_url(), setting_item('blog_title'));
?>
, All Rights Reserved. </p>
		<p class="right">Powered by <?php 
echo anchor('http://code.google.com/p/stblog/', ST_NAME . ' ' . ST_VERSION, array('title' => '基于CodeIgniter构建'));
?>
</p>
		<p>&nbsp;</p>          
	</div><!-- end footer -->
</div><!-- end container -->
<script type="text/javascript" src="<?php 
echo base_url() . ST_PLUGINS_DIR;
?>
/editor/syntaxhighlighter/scripts/shCore.js"></script>
	<script type="text/javascript" src="<?php 
echo base_url() . ST_PLUGINS_DIR;
?>
/editor/syntaxhighlighter/scripts/shBrushPhp.js"></script>
	<script type="text/javascript" src="<?php 
echo base_url() . ST_PLUGINS_DIR;
?>
/editor/syntaxhighlighter/scripts/shBrushXml.js"></script>
Example #10
0
 /**
  * 过滤评论内容
  * 
  * @access public
  * @param string $text 评论内容
  * @return string
  */
 private function _filter_text($text)
 {
     $text = str_replace("\r", '', $text);
     $text = preg_replace("/\n{2,}/", "\n\n", $text);
     return Common::stripTags($text, setting_item('commentsHTMLTagAllowed'));
 }
Example #11
0
    ?>
</h4>
                        <cite>作者: <?php 
    echo empty($theme['uri']) ? $theme['author'] : '<a href="' . $theme['uri'] . '">' . $theme['author'] . '</a>';
    ?>
                        &nbsp;&nbsp;&nbsp;版本: <?php 
    echo $theme['version'];
    ?>
                        </cite>
                        <p><?php 
    echo nl2br($theme['description']);
    ?>
</p>
                        </div>
                        <?php 
    if (setting_item('current_theme') != $theme['directory']) {
        ?>
                            <a class="edit" href="<?php 
        echo site_url('admin/themes/editor/' . $theme['directory']);
        ?>
">编辑</a>
                            <a class="activate" href="<?php 
        echo site_url('admin/themes/activate/' . $theme['directory']);
        ?>
">激活</a>
                        <?php 
    }
    ?>
                    
                    
                    </td>
Example #12
0
$val = trim(ini_get('upload_max_filesize'));
$last = strtolower($val[strlen($val) - 1]);
switch ($last) {
    // The 'G' modifier is available since PHP 5.1.0
    case 'g':
        $val *= 1024;
    case 'm':
        $val *= 1024;
    case 'k':
        $val *= 1024;
}
echo $val;
?>
 byte",
                file_types : "<?php 
echo setting_item('upload_exts');
?>
",
                file_types_description : "所有文件",
                file_upload_limit : 0,
                file_queue_limit : 1,
                debug: false,
                
                //Handle Settings
                file_dialog_complete_handler : fileDialogComplete,
                upload_start_handler : uploadStart,
                upload_progress_handler : uploadProgress,
                upload_success_handler : uploadSuccess,
                queue_complete_handler : uploadComplete,
                upload_error_handler : uploadError,
                swfupload_loaded_handler : swfuploadLoaded,
Example #13
0
</p>
			</div>
		</div>
        <div class="container typecho-page-main">
            <div class="column-24">
                <ul class="typecho-option-tabs">
                    <li><?php 
echo anchor('admin/themes/manage', '可以使用的外观');
?>
</li>
                    <li class="current"><a href="<?php 
echo site_url('admin/themes/editor');
?>
">
                    <?php 
if (setting_item('current_theme') == $theme) {
    ?>
                    编辑当前外观
                    <?php 
} else {
    ?>
                    <?php 
    printf('编辑%s外观', ' <cite>' . $theme . '</cite> ');
    ?>
                    <?php 
}
?>
                    </a></li>
                </ul>
                
                <div class="typecho-edit-theme">
Example #14
0
    /**
     * 输出头部feed meta信息
     * 
     * @access public
     * @param string $type 类型
     * @param mixed $slug slug
     * @param string $alt_title 
     * @return string
     */
    public static function render_feed_meta($type = 'default', $slug = NULL, $alt_title = '')
    {
        if (empty($type) || !in_array($type, array('default', 'post', 'category', 'tag'))) {
            return;
        }
        /** 初始化默认值 */
        $feed_rss_url = site_url('feed');
        $feed_atom_url = site_url('feed/atom');
        $alt_title = empty($alt_title) ? setting_item('blog_title') : htmlspecialchars($alt_title);
        $parsed_feed = <<<EOT
<link rel="alternate" type="application/rss+xml" href="{$feed_rss_url}" title="订阅 {$alt_title} 所有文章" />

<link rel="alternate" type="application/rss+xml" href="{$feed_rss_url}/comments" title="订阅 {$alt_title} 所有评论" />

EOT;
        if ('default' === $type) {
            return $parsed_feed;
        } else {
            $title = '订阅';
            switch ($type) {
                case 'post':
                    $title .= $alt_title . '下的评论';
                    break;
                case 'category':
                    $title .= $alt_title . '分类下的文章';
                    break;
                case 'tag':
                    $title .= $alt_title . '标签下的文章';
                    break;
            }
            return <<<EOT
<link rel="alternate" type="application/rss+xml" href="{$feed_rss_url}/{$type}/{$slug}" title="{$title}" />

EOT;
        }
    }
Example #15
0
 public function __construct()
 {
     $this->_CI =& get_instance();
     $limit = setting_item('cache_file_limit');
     $this->_cache_file_limit = $limit && is_numeric($limit) ? intval($limit) : 200;
 }
Example #16
0
 /**
  * 生成tag中的日志feed
  * 
  * @access public
  * @param  string $slug
  * @return void
  */
 public function generate_tag_feed($slug)
 {
     $tag = $this->metas_mdl->get_meta_by_slug($slug);
     if (empty($tag)) {
         show_error('发生错误:标签不存在或已被删除');
         exit;
     }
     /** init */
     $this->feedwriter->setTitle(setting_item('blog_title') . ' - 标签:' . $tag->name);
     $this->feedwriter->setLink(site_url('tag/' . $tag->slug));
     $this->feedwriter->setDescription(setting_item('blog_description'));
     $this->feedwriter->setChannelElement('language', 'zh-CN');
     $this->feedwriter->setChannelElement('pubDate', date(DATE_RSS, now()));
     $posts = $this->posts_mdl->get_posts_by_meta($slug, 'tag', 'post', 'publish', 'posts.*', 10, 0, TRUE);
     $this->_generate($posts);
 }
Example #17
0
 /**
  * 评论格式化
  * 
  * @access private
  * @param  stdClass $post
  * @param  array $comments
  * @return array
  */
 private function _prepare_comments($post, $comments)
 {
     foreach ($comments->result() as $comment) {
         $comment->published = setting_item('comments_date_format') ? date(setting_item('comments_date_format'), $comment->created) : date('Y-m-d', $comment->created);
         $comment->permalink = site_url('posts/' . $post->slug . '#comment-' . $comment->cid);
         $comment->author_link = $comment->author;
         if (!empty($comment->url)) {
             $nofollow = array();
             if ('1' == setting_item('comments_url_no_follow')) {
                 $nofollow = array('rel' => 'external nofollow');
             }
             $comment->author_link = anchor($comment->url, $comment->author, $nofollow);
         }
         if ('trackback' == $comment->type) {
             $text = unserialize($comment->text);
             $comment->author_link = '来自' . $comment->author_link . '在文章' . anchor($comment->url, $text['title']) . '中的引用';
             $comment->text = $text['excerpt'];
         }
         $comment->content = Common::cut_paragraph($comment->text);
         unset($comment->text);
     }
     return $comments;
 }
Example #18
0
<body onLoad="ReImgSize()">

<div id="container">
	<div id="header"><!-- header -->
		<form id="search" method="get" action="<?php 
echo site_url('search');
?>
">
			<div><input type="text" name="s" class="text" size="25" /> <input type="submit" class="submit" value="Search" /></div>
	    </form>
    	<h1><?php 
echo anchor(site_url(), setting_item('blog_title'));
?>
</h1>
        <h2><?php 
echo setting_item('blog_slogan');
?>
        	<?php 
$this->plugin->trigger('hook_test');
?>
        </h2>
                
        <br />
        <div id="topbar">
        	<ul>
			    <li><?php 
echo anchor(site_url(), '首页');
?>
</li>
			    <?php 
$this->plugin->trigger('Widget::Navigation', '<li><a href="{permalink}">{title}</a></li>');
Example #19
0
 /**
  * 发送Ping
  *
  * @access private
  * @param  string $pid
  * @param  array  $trackbacks
  * @return void
  */
 private function _send_trackback($pid, $trackbacks = array())
 {
     if (empty($pid)) {
         return;
     }
     $post = $this->posts_mdl->get_post_by_id('pid', $pid);
     $trackbacks = $trackbacks ? is_array($trackbacks) ? $trackbacks : array($trackbacks) : array();
     $this->load->library('trackback');
     foreach ($trackbacks as $trackback) {
         if (empty($trackback)) {
             continue;
         }
         $tb_data = array('ping_url' => $trackback, 'url' => site_url('posts/' . $post->slug), 'title' => $post->title, 'excerpt' => Common::get_excerpt($post->text), 'blog_name' => setting_item('blog_title'), 'charset' => 'utf-8');
         if (!$this->trackback->send($tb_data)) {
             log_message('error', $this->trackback->display_errors());
         }
     }
 }
Example #20
0
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title><?php 
echo $title;
?>
</title><style type="text/css">body{padding-right: 32px;margin-top: 40px;padding-left: 32px;font-size: 13px;background: #eee;padding-bottom: 32px;color: #000;padding-top: 32px;font-family:Verdana;}#main{border-right: #bbb 1px solid;border-top: #bbb 1px solid;background: #fff;padding-bottom: 32px;border-left: #bbb 1px solid;width: 550px;padding-top: 20px;border-bottom: #bbb 1px solid;text-align:left;padding-left:60px;padding-right:50px;}div#heading{padding-right: 0px;padding-left: 0px;font-weight: bold;font-size: 120%;padding-bottom: 15px;margin: 0px;color: #904;padding-top: 0px;font-family: arial;}h2{padding-right: 0px;padding-left: 0px;font-weight: bold;font-size: 105%;padding-bottom: 0px;margin: 0px 0px 8px;text-transform: uppercase;color: #999;padding-top: 0px;border-bottom: #ddd 1px solid;font-family: "trebuchet ms" , "" lucida grande "" , verdana, arial, sans-serif;}p{padding-right: 0px;padding-left: 0px;padding-bottom: 6px;margin: 0px;padding-top: 6px;}a:link{color: #002c99;font-size: 12px;}a:visited{color: #002c99;font-size: 12px;}a:hover{color: #cc0066;background-color: #f5f5f5;text-decoration: underline;font-size: 12px;}</style> </head> <body> <div style="width:100%;"><div align="center"> <div id="main"><div id="heading"><?php 
echo $heading;
?>
</div><?php 
echo $message;
?>
<p>你可以选择<a href="javascript:window.history.go(-1);">返回上一页</a>,或者<a href="<?php 
echo site_url();
?>
">返回 <?php 
echo setting_item('blog_title');
?>
 首页</a>。</p></div></div> </div> </body></html>