예제 #1
0
        if ($aids) {
            // 删除该用户的文章中的附件
            $query = $DB->query("SELECT attachmentid,filepath,thumb_filepath FROM {$db_prefix}attachments WHERE articleid IN ({$aids})");
            $nokeep = array();
            while ($attach = $DB->fetch_array($query)) {
                $nokeep[$attach['attachmentid']] = $attach;
            }
            removeattachment($nokeep);
            $DB->unbuffered_query("DELETE FROM {$db_prefix}comments WHERE articleid IN ({$aids})");
            $DB->unbuffered_query("DELETE FROM {$db_prefix}articles WHERE uid IN ({$uids})");
            $DB->unbuffered_query("UPDATE {$db_prefix}statistics SET article_count=article_count-" . $a_total . ", comment_count=comment_count-{$comment_count}");
            archives_recache();
            categories_recache();
            statistics_recache();
            if ($a_stick) {
                stick_recache();
            }
        }
        // 删除用户
        $DB->unbuffered_query("DELETE FROM {$db_prefix}users WHERE userid IN ({$uids})");
        $location = getlink('user', 'list', array('message' => 13, 'userid' => $sax_uid));
    } else {
        $location = getlink('user', 'list', array('message' => 14, 'userid' => $sax_uid));
    }
    header("Location: {$location}");
    exit;
}
if (in_array($action, array('add', 'mod', 'profile'))) {
    $info = array();
    if ($action == 'add') {
        $subnav = '添加用户';
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();
}