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; $record = isset($params[1]) && $params[1] == 'record' ? intval($params[2]) : ''; $GLOBALS['record'] = $record; //for sidebar calendar $pageurl = ''; //page meta $site_title = $record . ' - ' . $site_title; if (preg_match("/^([\\d]{4})([\\d]{2})\$/", $record, $match)) { $days = getMonthDayNum($match[2], $match[1]); $record_stime = emStrtotime($record . '01'); $record_etime = $record_stime + 3600 * 24 * $days; } else { $record_stime = emStrtotime($record); $record_etime = $record_stime + 3600 * 24; } $sqlSegment = "and date>={$record_stime} and date<{$record_etime} order by date desc"; $lognum = $Log_Model->getLogNum('n', $sqlSegment); $total_pages = ceil($lognum / $index_lognum); if ($page > $total_pages) { $page = $total_pages; } $start_limit = ($page - 1) * $index_lognum; $pageurl .= Url::record($record, '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'); }
function displayRecordItem($record) { if (preg_match("/^([\\d]{4})([\\d]{2})\$/", $record, $match)) { $days = getMonthDayNum($match[2], $match[1]); $record_stime = emStrtotime($record . '01'); $record_etime = $record_stime + 3600 * 24 * $days; } else { $record_stime = emStrtotime($record); $record_etime = $record_stime + 3600 * 24; } $sql = "and date>={$record_stime} and date<{$record_etime} order by top desc ,date desc"; $result = archiver_db($sql); return $result; }
private function setData() { $CACHE = Cache::getInstance(); $data = array(); $lastCommentTime = $this->getLastCommentTime(); $data[] = array('url' => BLOG_URL, 'lastmod' => time(), 'changefreq' => 'always', 'priority' => '1.0'); //日志 $query = $this->db->query("SELECT gid,date FROM " . DB_PREFIX . "blog WHERE type='blog' AND hide='n' ORDER BY date DESC"); while ($row = $this->db->fetch_array($query)) { $lastmod = $this->comment_time && isset($lastCommentTime[$row['gid']]) ? $lastCommentTime[$row['gid']] : $row['date']; $data[] = array('url' => Url::log($row['gid']), 'lastmod' => $lastmod, 'changefreq' => $this->changefreq[0], 'priority' => $this->priority[0]); } //页面 $query = $this->db->query("SELECT gid,date FROM " . DB_PREFIX . "blog WHERE type='page' AND hide='n' ORDER BY date DESC"); while ($row = $this->db->fetch_array($query)) { $lastmod = $this->comment_time && isset($lastCommentTime[$row['gid']]) ? $lastCommentTime[$row['gid']] : $row['date']; $data[] = array('url' => Url::log($row['gid']), 'lastmod' => $lastmod, 'changefreq' => $this->changefreq[0], 'priority' => $this->priority[0]); } //分类 foreach ($CACHE->readCache('sort') as $value) { $data[] = array('url' => Url::sort($value['sid']), 'lastmod' => time(), 'changefreq' => $this->changefreq[2], 'priority' => $this->priority[2]); } //标签 foreach ($CACHE->readCache('tags') as $value) { $data[] = array('url' => Url::tag($value['tagurl']), 'lastmod' => time(), 'changefreq' => $this->changefreq[3], 'priority' => $this->priority[3]); } //碎语 if (Option::get('istwitter') == 'y') { $newtws_cache = $CACHE->readCache('newtw'); $data[] = array('url' => BLOG_URL . 't/', 'lastmod' => $newtws_cache[0]['date'], 'changefreq' => $this->changefreq[4], 'priority' => $this->priority[4]); } //归档 foreach ($CACHE->readCache('record') as $value) { preg_match("/^([\\d]{4})([\\d]{2})\$/", $value['date'], $match); $days = getMonthDayNum($match[2], $match[1]); $lastmod = emStrtotime($value['date'] . '01') + 3600 * 24 * $days; $data[] = array('url' => Url::record($value['date']), 'lastmod' => $lastmod, 'changefreq' => $this->changefreq[5], 'priority' => $this->priority[5]); } $this->data = $data; }