} header("Location: {$location}"); exit; } if ($action == 'delstylevar') { $DB->query("DELETE FROM\t{$db_prefix}stylevars WHERE stylevarid = '{$stylevarid}'"); stylevars_recache(); $location = getlink('template', 'stylevar', array('message' => 14)); header("Location: {$location}"); exit; } //批量处理自定义模板变量 if ($action == 'domorestylevar') { if ($ids = implode_ids($_POST['selectall'])) { $DB->query("DELETE FROM\t{$db_prefix}stylevars WHERE stylevarid IN ({$ids})"); stylevars_recache(); $location = getlink('template', 'stylevar', array('message' => 14)); } else { $location = getlink('template', 'stylevar', array('message' => 15)); } header("Location: {$location}"); exit; } // 生成模板缓存 if ($action == 'buildtemplate') { buildtemplate($path); $location = getlink('template', 'template', array('message' => 16)); header("Location: {$location}"); exit; } if ($action == 'add') {
function rethestats($cachename = '') { global $DB, $db_prefix; if (!$cachename || $cachename == 'settings') { settings_recache(); } if (!$cachename || $cachename == 'statistics') { // 更新首页显示的文章数 $article_count = $DB->result($DB->query("SELECT COUNT(articleid) FROM {$db_prefix}articles WHERE visible = '1'"), 0); // 更新首页显示的评论数 $comment_count = $DB->result($DB->query("SELECT COUNT(commentid) FROM {$db_prefix}comments c LEFT JOIN {$db_prefix}articles a ON (a.articleid=c.articleid) WHERE a.visible='1' AND c.visible='1'"), 0); // 更新首页显示的标签(Tags)数 $tag_count = $DB->result($DB->query("SELECT COUNT(mid) FROM {$db_prefix}metas WHERE type='tag'"), 0); $DB->unbuffered_query("UPDATE {$db_prefix}statistics SET article_count='{$article_count}', comment_count='{$comment_count}', tag_count='{$tag_count}'"); //$DB->unbuffered_query("DELETE FROM {$db_prefix}metas WHERE type='tag' AND count=0"); // 更新主人发表文章数 $query = $DB->query("SELECT userid,articles FROM {$db_prefix}users WHERE groupid='1' OR groupid='2'"); while ($user = $DB->fetch_array($query)) { $total = $DB->result($DB->query("SELECT COUNT(articleid) FROM {$db_prefix}articles WHERE visible = '1' AND uid='" . $user['userid'] . "'"), 0); if ($user['articles'] != $total) { $DB->unbuffered_query("UPDATE {$db_prefix}users SET articles='{$total}' WHERE userid='" . $user['userid'] . "'"); } } statistics_recache(); } if (!$cachename || $cachename == 'newarticles') { newarticles_recache(); } if (!$cachename || $cachename == 'stick') { stick_recache(); } if (!$cachename || $cachename == 'newcomments') { newcomments_recache(); } if (!$cachename || $cachename == 'categories') { // 更新所有文章的评论数 $query = $DB->query("SELECT mid,count FROM {$db_prefix}metas"); while ($meta = $DB->fetch_array($query)) { $ctotal = get_meta_article_count($meta['mid']); if ($meta['count'] != $ctotal) { update_meta_count($meta['mid'], $ctotal); } } categories_recache(); } if (!$cachename || $cachename == 'archives') { // 重建文章数据 $query = $DB->query("SELECT articleid,comments FROM {$db_prefix}articles"); while ($article = $DB->fetch_array($query)) { // 更新所有文章的评论数 $ctotal = $DB->result($DB->query("SELECT COUNT(commentid) FROM {$db_prefix}comments WHERE articleid='" . $article['articleid'] . "' AND visible='1'"), 0); if ($article['comments'] != $ctotal) { $DB->unbuffered_query("UPDATE {$db_prefix}articles SET comments='{$ctotal}' WHERE articleid='" . $article['articleid'] . "'"); } } archives_recache(); } if (!$cachename || $cachename == 'hottags') { hottags_recache(); } if (!$cachename || $cachename == 'links') { links_recache(); } if (!$cachename || $cachename == 'stylevars') { stylevars_recache(); } if (!$cachename || $cachename == 'allarticleids') { allarticleids_recache(); } }
function restats() { allarticleids_recache(); links_recache(); newarticles_recache(); newcomments_recache(); settings_recache(); categories_recache(); statistics_recache(); archives_recache(); hottags_recache(); stylevars_recache(); stick_recache(); }