Esempio n. 1
0
    exit;
}
//删除用户
if ($_POST['action'] == 'delusers') {
    if ($uids = implode_ids($_POST['selectall'])) {
        $aids = $comma = '';
        $comment_count = $a_total = $a_stick = 0;
        // 删除该用户发表的文章以及相关数据
        require_once SABLOG_ROOT . 'include/func/attachment.func.php';
        $query = $DB->query("SELECT articleid,visible,uid,comments,stick FROM {$db_prefix}articles WHERE uid IN ({$uids})");
        while ($article = $DB->fetch_array($query)) {
            $aids .= $comma . $article['articleid'];
            $comma = ',';
            if ($article['visible']) {
                $a_total++;
                $mids = get_mids($article['articleid']);
                $DB->unbuffered_query("UPDATE {$db_prefix}metas SET count=count-1 WHERE mid IN ({$mids})");
                $comment_count = $comment_count + $article['comments'];
            }
            if ($article['stick']) {
                $a_stick = 1;
            }
        }
        //end while
        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;
            }
     statistics_recache();
     stick_recache();
     $location = getlink('article', 'list', array('message' => 18));
 } elseif ($doit == 'display') {
     $a_total = 0;
     $vaids = $comma = '';
     $query = $DB->query("SELECT articleid,visible,uid FROM {$db_prefix}articles WHERE articleid IN ({$aids})" . $uquery);
     while ($article = $DB->fetch_array($query)) {
         if (!$article['visible']) {
             $a_total++;
             $vaids .= $comma . $article['articleid'];
             $comma = ',';
             $DB->unbuffered_query("UPDATE {$db_prefix}users SET articles=articles+1 WHERE userid='" . $article['uid'] . "'");
         }
     }
     $mids = get_mids($vaids);
     $DB->unbuffered_query("UPDATE {$db_prefix}metas SET count=count+1 WHERE mid IN ({$mids})");
     $DB->unbuffered_query("UPDATE {$db_prefix}articles SET visible='1' WHERE articleid IN ({$aids})");
     $DB->unbuffered_query("UPDATE {$db_prefix}statistics SET article_count=article_count+" . $a_total);
     archives_recache();
     categories_recache();
     statistics_recache();
     newarticles_recache();
     newcomments_recache();
     stick_recache();
     $location = getlink('article', 'list', array('message' => 19));
 } elseif ($doit == 'stick') {
     $DB->unbuffered_query("UPDATE {$db_prefix}articles SET stick='1' WHERE articleid IN ({$aids})" . $uquery);
     stick_recache();
     $location = getlink('article', 'list', array('message' => 20));
 } elseif ($doit == 'unstick') {