$pageurl = 'index.php?action=article&searchid=' . $searchid; $catename = '搜索:' . $search['keywords']; // 查看首页文章 } else { $catename = '全部文章'; $total = $stats['article_count']; $setdate = (int) $_GET['setdate']; if ($setdate && getstrlen($setdate) == 6) { $setyear = substr($setdate, 0, 4); if ($setyear >= 2038 || $setyear <= 1970) { $setyear = sadate('Y'); $setmonth = sadate('m'); $start = $end = 0; } else { $setmonth = substr($setdate, -2); list($start, $end) = explode('-', gettimestamp($setyear, $setmonth)); $catename = $setyear . '年' . $setmonth . '月的文章'; } } else { $setyear = sadate('Y'); $setmonth = sadate('m'); $start = $end = 0; } //*******************************// $startadd = $start ? " AND a.dateline >= '" . correcttime($start) . "' " : ''; $endadd = $end ? " AND a.dateline < '" . correcttime($end) . "' " : ''; //*******************************// if ($setdate) { $query = $DB->query("SELECT COUNT(articleid) FROM {$db_prefix}articles a WHERE a.visible='1' " . $startadd . $endadd); $total = $DB->result($query, 0); }
$subnav = '隐藏的日志'; $pagelink .= '&view=hidden'; } elseif ($view == 'display') { $addquery .= " AND a.visible='1'"; $subnav = '显示的日志'; $pagelink .= '&view=display'; } if ($uid) { $user = $DB->fetch_one_array("SELECT username FROM {$db_prefix}users WHERE userid='{$uid}'"); $subnav = $user['username'] . '发表的文章'; $addquery .= " AND a.uid='{$uid}'"; $pagelink .= '&uid=' . $uid; } if ($m) { $mdb = explode('-', $m); list($start, $end) = explode('-', gettimestamp($mdb[0], $mdb[1])); $pagelink .= '&m=' . $m; $subnav = '在' . $mdb[0] . '年' . $mdb[1] . '月里'; //*******************************// $addquery .= " AND a.dateline >= '" . correcttime($start) . "' AND a.dateline < '" . correcttime($end) . "' "; } // 搜索部分 $keywords = sax_addslashes(trim($keywords)); if ($keywords) { $keywords = str_replace("_", "\\_", $keywords); $keywords = str_replace("%", "\\%", $keywords); if (preg_match("(AND|\\+|&|\\s)", $keywords) && !preg_match("(OR|\\|)", $keywords)) { $andor = ' AND '; $sqltxtsrch = '1'; $keywords = preg_replace("/( AND |&| )/is", "+", $keywords); } else {
if (count($__LIST__) == 0) { echo "没有相关文章.."; } else { foreach ($__LIST__ as $key => $post) { $mod = $i % 2; ++$i; ?> <div class="widget-blog-item media"> <div class="pull-left"> <div class="date"> <span class="month"><?php echo gettimestamp($post["post_date"], 'month'); ?> 月</span> <span class="day"><?php echo gettimestamp($post["post_date"], 'day'); ?> 日</span> </div> </div> <div class="media-body"> <a href="<?php echo get_post_url($post); ?> "> <h5><?php echo is_top($post["post_top"]); echo $post["post_title"]; ?> </h5></a> </div>
function calendar($y, $m) { global $DB, $db_prefix, $options, $timestamp, $timeoffset; !$y && ($y = sadate('Y')); !$m && ($m = sadate('m')); //当前月等于1 if ($m == 1) { $lastyear = $y - 1; $lastmonth = 12; $nextmonth = $m + 1; $nextyear = $y; } elseif ($m == 12) { $lastyear = $y; $lastmonth = $m - 1; $nextyear = $y + 1; $nextmonth = 1; } else { $lastmonth = $m - 1; $nextmonth = $m + 1; $lastyear = $nextyear = $y; } if ($nextmonth < 10) { $nextmonth = '0' . $nextmonth; } if ($lastmonth < 10) { $lastmonth = '0' . $lastmonth; } $weekday = sadate('w', mktime(0, 0, 0, $m, 1, $y)); $totalday = sadate('t', mktime(0, 0, 0, $m, 1, $y)); list($start, $end) = explode('-', gettimestamp($y, $m)); // 动态缓存 $expiration = 0; $cachefile = SABLOG_ROOT . 'data/cache/cache_calendar.php'; if ($m != sadate('m') || $y != sadate('Y') || !@(include $cachefile) || $expiration < $timestamp) { $query = $DB->query("SELECT dateline FROM {$db_prefix}articles WHERE visible='1' AND dateline >= '" . correcttime($start) . "' AND dateline < '" . correcttime($end) . "'"); $datelines = array(); $articledb = array(); while ($article = $DB->fetch_array($query)) { $datelines[] = sadate('Y-m-j', $article['dateline']); $day = sadate('j', $article['dateline']); if (!isset($articledb[$day])) { $articledb[$day]['num'] = 1; } else { $articledb[$day]['num']++; } } $br = 0; $ret['html'] = "<tr>\n"; for ($i = 1; $i <= $weekday; $i++) { $ret['html'] .= "<td class=\"cal_day1\"></td>\n"; $br++; } for ($i = 1; $i <= $totalday; $i++) { $br++; if (in_array($y . '-' . $m . '-' . $i, $datelines)) { $td = '<a title="' . $i . '日内发表了' . $articledb[$i]['num'] . '篇文章" href="' . getdaylink($y . $m, $i) . '">' . $i . '</a>'; } else { $td = $i; } if ($i == sadate('d') && $m == sadate('m') && $y == sadate('Y')) { $class = 'cal_day2'; } else { $class = 'cal_day1'; } $ret['html'] .= "<td class=\"" . $class . "\">" . $td . "</td>\n"; if ($br >= 7) { $ret['html'] .= "</tr>\n<tr>\n"; $br = 0; } } if ($br != 0) { for ($i = $br; $i < 7; $i++) { $ret['html'] .= "<td class=\"cal_day1\"></td>\n"; } } $ret['html'] .= "</tr>\n"; if ($y . $m == sadate('Ym')) { $cachedata = "<?php\r\nif(!defined('SABLOG_ROOT')) exit('Access Denied');\r\n\$expiration='" . ($timestamp + 300) . "';\r\n\$ret = unserialize('" . addcslashes(serialize($ret), '\\\'') . "');\r\n?>"; if (!writefile($cachefile, $cachedata)) { exit('Can not write to calendar cache files, please check directory ./data/cache/ .'); } } } $ret['prevmonth'] = $lastyear . $lastmonth; $ret['nextmonth'] = $nextyear . $nextmonth; $ret['cur_month'] = $m; $e_month = $m < 10 ? str_replace('0', '', $m) : $m; $ret['cur_date'] = $y . '年' . $m . '月'; return $ret; }