function display($params) { $Log_Model = new Log_Model(); $CACHE = Cache::getInstance(); $options_cache = Option::getAll(); extract($options_cache); $page = isset($params[4]) && $params[4] == 'page' ? abs(intval($params[5])) : 1; $author = isset($params[1]) && $params[1] == 'author' ? intval($params[2]) : ''; $pageurl = ''; $user_cache = $CACHE->readCache('user'); if (!isset($user_cache[$author])) { show_404_page(); } $author_name = $user_cache[$author]['name']; //page meta $site_title = $author_name . ' - ' . $site_title; $sqlSegment = "and author={$author} order by date desc"; $sta_cache = $CACHE->readCache('sta'); $lognum = $sta_cache[$author]['lognum']; $total_pages = ceil($lognum / $index_lognum); if ($page > $total_pages) { $page = $total_pages; } $start_limit = ($page - 1) * $index_lognum; $pageurl .= Url::author($author, 'page'); $Log_Model = new Log_Model(); $logs = $Log_Model->getLogsForHome($sqlSegment, $page, $index_lognum); $page_url = pagination($lognum, $index_lognum, $page, $pageurl); include View::getView('header'); include View::getView('log_list'); }
function display($params) { $Log_Model = new Log_Model(); $options_cache = Option::getAll(); extract($options_cache); $page = isset($params[4]) && $params[4] == 'page' ? abs(intval($params[5])) : 1; $tag = isset($params[1]) && $params[1] == 'tag' ? addslashes(urldecode(trim($params[2]))) : ''; $pageurl = ''; //page meta $site_title = stripslashes($tag) . ' - ' . $site_title; $Tag_Model = new Tag_Model(); $blogIdStr = $Tag_Model->getTagByName($tag); if ($blogIdStr === false) { show_404_page(); } $sqlSegment = "and gid IN ({$blogIdStr}) order by date desc"; $lognum = $Log_Model->getLogNum('n', $sqlSegment); $total_pages = ceil($lognum / $index_lognum); if ($page > $total_pages) { $page = $total_pages; } $pageurl .= Url::tag(urlencode($tag), 'page'); $logs = $Log_Model->getLogsForHome($sqlSegment, $page, $index_lognum); $page_url = pagination($lognum, $index_lognum, $page, $pageurl); include View::getView('header'); include View::getView('log_list'); }
private function __construct() { $this->_path = $this->setPath(); $this->_routingTable = Option::getRoutingTable(); $urlMode = Option::get('isurlrewrite'); foreach ($this->_routingTable as $route) { if (!isset($route['reg_' . $urlMode])) { $reg = isset($route['reg']) ? $route['reg'] : $route['reg_0']; } else { $reg = $route['reg_' . $urlMode]; } if (preg_match($reg, $this->_path, $matches)) { $this->_model = $route['model']; $this->_method = $route['method']; $this->_params = $matches; break; } elseif (preg_match($route['reg_0'], $this->_path, $matches)) { $this->_model = $route['model']; $this->_method = $route['method']; $this->_params = $matches; break; } } if (empty($this->_model)) { show_404_page(); } }
function display($params) { $Log_Model = new Log_Model(); $CACHE = Cache::getInstance(); $options_cache = Option::getAll(); extract($options_cache); $page = isset($params[4]) && $params[4] == 'page' ? abs(intval($params[5])) : 1; $sortid = ''; if (!empty($params[2])) { if (is_numeric($params[2])) { $sortid = intval($params[2]); } else { $sort_cache = $CACHE->readCache('sort'); foreach ($sort_cache as $key => $value) { $alias = addslashes(urldecode(trim($params[2]))); if (array_search($alias, $value, true)) { $sortid = $key; break; } } } } $pageurl = ''; $sort_cache = $CACHE->readCache('sort'); if (!isset($sort_cache[$sortid])) { show_404_page(); } $sort = $sort_cache[$sortid]; $sortName = $sort['sortname']; //page meta $site_title = $sortName . ' - ' . $site_title; if (!empty($sort_cache[$sortid]['description'])) { $site_description = $sort_cache[$sortid]['description']; } if ($sort['pid'] != 0 || empty($sort['children'])) { $sqlSegment = "and sortid={$sortid}"; } else { $sortids = array_merge(array($sortid), $sort['children']); $sqlSegment = "and sortid in (" . implode(',', $sortids) . ")"; } $sqlSegment .= " order by sortop desc, date desc"; $lognum = $Log_Model->getLogNum('n', $sqlSegment); $total_pages = ceil($lognum / $index_lognum); if ($page > $total_pages) { $page = $total_pages; } $pageurl .= Url::sort($sortid, 'page'); $logs = $Log_Model->getLogsForHome($sqlSegment, $page, $index_lognum); $page_url = pagination($lognum, $index_lognum, $page, $pageurl); $template = !empty($sort['template']) && file_exists(TEMPLATE_PATH . $sort['template'] . '.php') ? $sort['template'] : 'log_list'; include View::getView('header'); include View::getView($template); }
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); } }