Example #1
0
/**
 * 获取文章信息
 *
 * @return array
 */
function getBlog($sortid = null)
{
    $rss_output_num = Option::get('rss_output_num');
    if ($rss_output_num == 0) {
        return array();
    }
    $DB = Database::getInstance();
    $sorts = Cache::getInstance()->readCache('sort');
    if (isset($sorts[$sortid])) {
        $sort = $sorts[$sortid];
        if ($sort['pid'] != 0 || empty($sort['children'])) {
            $subsql = "and sortid={$sortid}";
        } else {
            $sortids = array_merge(array($sortid), $sort['children']);
            $subsql = "and sortid in (" . implode(',', $sortids) . ")";
        }
    } else {
        $subsql = $sortid ? "and sortid={$sortid}" : '';
    }
    $sql = "SELECT * FROM " . DB_PREFIX . "blog  WHERE hide='n' and type='blog' {$subsql} ORDER BY date DESC limit 0," . $rss_output_num;
    $result = $DB->query($sql);
    $blog = array();
    while ($re = $DB->fetch_array($result)) {
        $re['id'] = $re['gid'];
        $re['title'] = htmlspecialchars($re['title']);
        $re['date'] = $re['date'];
        $re['content'] = $re['content'];
        if (!empty($re['password'])) {
            $re['content'] = '<p>[该文章已设置加密]</p>';
        } elseif (Option::get('rss_output_fulltext') == 'n') {
            if (!empty($re['excerpt'])) {
                $re['content'] = $re['excerpt'];
            } else {
                $re['content'] = extractHtmlData($re['content'], 330);
            }
            $re['content'] .= ' <a href="' . Url::log($re['id']) . '">阅读全文&gt;&gt;</a>';
        }
        $blog[] = $re;
    }
    return $blog;
}
Example #2
0
 function displayContent($params)
 {
     $comment_page = isset($params[4]) && $params[4] == 'comment-page' ? intval($params[5]) : 1;
     $Log_Model = new Log_Model();
     $CACHE = Cache::getInstance();
     $options_cache = $CACHE->readCache('options');
     extract($options_cache);
     $logid = 0;
     if (isset($params[1])) {
         if ($params[1] == 'post') {
             $logid = isset($params[2]) ? intval($params[2]) : 0;
         } elseif (is_numeric($params[1])) {
             $logid = intval($params[1]);
         } else {
             $logalias_cache = $CACHE->readCache('logalias');
             if (!empty($logalias_cache)) {
                 $alias = addslashes(urldecode(trim($params[1])));
                 $logid = array_search($alias, $logalias_cache);
                 if (!$logid) {
                     show_404_page();
                 }
             }
         }
     }
     $Comment_Model = new Comment_Model();
     $logData = $Log_Model->getOneLogForHome($logid);
     if ($logData === false) {
         show_404_page();
     }
     extract($logData);
     if (!empty($password)) {
         $postpwd = isset($_POST['logpwd']) ? addslashes(trim($_POST['logpwd'])) : '';
         $cookiepwd = isset($_COOKIE['em_logpwd_' . $logid]) ? addslashes(trim($_COOKIE['em_logpwd_' . $logid])) : '';
         $Log_Model->AuthPassword($postpwd, $cookiepwd, $password, $logid);
     }
     //meta
     switch ($log_title_style) {
         case '0':
             $site_title = $log_title;
             break;
         case '1':
             $site_title = $log_title . ' - ' . $blogname;
             break;
         case '2':
             $site_title = $log_title . ' - ' . $site_title;
             break;
     }
     $site_description = extractHtmlData($log_content, 90);
     $log_cache_tags = $CACHE->readCache('logtags');
     if (!empty($log_cache_tags[$logid])) {
         foreach ($log_cache_tags[$logid] as $value) {
             $site_key .= ',' . $value['tagname'];
         }
     }
     //comments
     $verifyCode = ISLOGIN == false && $comment_code == 'y' ? "<img src=\"" . BLOG_URL . "include/lib/checkcode.php\" align=\"absmiddle\" /><input name=\"imgcode\" type=\"text\" class=\"input\" size=\"5\" tabindex=\"5\" />" : '';
     $ckname = isset($_COOKIE['commentposter']) ? htmlspecialchars(stripslashes($_COOKIE['commentposter'])) : '';
     $ckmail = isset($_COOKIE['postermail']) ? htmlspecialchars($_COOKIE['postermail']) : '';
     $ckurl = isset($_COOKIE['posterurl']) ? htmlspecialchars($_COOKIE['posterurl']) : '';
     $comments = $Comment_Model->getComments(0, $logid, 'n', $comment_page);
     include View::getView('header');
     if ($type == 'blog') {
         $Log_Model->updateViewCount($logid);
         $neighborLog = $Log_Model->neighborLog($timestamp);
         $tb = array();
         $tb_url = '';
         //兼容未删除引用模板
         include View::getView('echo_log');
     } elseif ($type == 'page') {
         $template = !empty($template) && file_exists(TEMPLATE_PATH . $template . '.php') ? $template : 'page';
         include View::getView($template);
     }
 }