Ejemplo n.º 1
0
 function usesubmit()
 {
     global $_G;
     if (empty($_GET['pid'])) {
         showmessage(lang('magic/repent', 'repent_info_nonexistence'));
     }
     $_G['tid'] = $_GET['ptid'];
     $post = getpostinfo($_GET['pid'], 'pid', array('p.first', 'p.tid', 'p.fid', 'p.authorid', 'p.replycredit', 't.status as thread_status'));
     $this->_check($post);
     require_once libfile('function/post');
     require_once libfile('function/delete');
     if ($post['first']) {
         if ($have_replycredit = C::t('forum_replycredit')->fetch($post['tid'])) {
             $thread = C::t('forum_thread')->fetch($post['tid']);
             if ($thread['replycredit']) {
                 updatemembercount($post['authorid'], array($_G['setting']['creditstransextra'][10] => $replycredit));
             }
             C::t('forum_replycredit')->delete($post['tid']);
             C::t('common_credit_log')->delete_by_operation_relatedid(array('RCT', 'RCA', 'RCB'), $post['tid']);
         }
         deletethread(array($post['tid']));
         updateforumcount($post['fid']);
     } else {
         if ($post['replycredit'] > 0) {
             updatemembercount($post['authorid'], array($_G['setting']['creditstransextra'][10] => -$post['replycredit']));
             C::t('common_credit_log')->delete_by_uid_operation_relatedid($post['authorid'], 'RCA', $post['tid']);
         }
         deletepost(array($_GET['pid']));
         updatethreadcount($post['tid']);
     }
     usemagic($this->magic['magicid'], $this->magic['num']);
     updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, 'tid', $_G['tid']);
     showmessage(lang('magic/repent', 'repent_succeed'), $post['first'] ? 'forum.php?mod=forumdisplay&fid=' . $post['fid'] : dreferer(), array(), array('alert' => 'right', 'showdialog' => 1, 'locationtime' => true));
 }
Ejemplo n.º 2
0
 function usesubmit()
 {
     global $_G;
     if (empty($_G['gp_pid'])) {
         showmessage(lang('magic/repent', 'repent_info_nonexistence'));
     }
     $_G['tid'] = $_G['gp_ptid'];
     $post = getpostinfo($_G['gp_pid'], 'pid', array('p.first', 'p.tid', 'p.fid', 'p.authorid', 'p.replycredit', 't.status as thread_status'));
     $this->_check($post);
     require_once libfile('function/post');
     require_once libfile('function/delete');
     if ($post['first']) {
         if ($have_replycredit = DB::fetch_first("SELECT * FROM " . DB::table('forum_replycredit') . " WHERE tid ='{$post['tid']}' LIMIT 1")) {
             if ($replycredit = DB::result_first("SELECT replycredit FROM " . DB::table('forum_thread') . " WHERE tid = '{$post['tid']}'")) {
                 updatemembercount($post['authorid'], array($_G['setting']['creditstransextra'][10] => $replycredit));
             }
             DB::delete('forum_replycredit', "tid = '{$post['tid']}'");
             DB::delete('common_credit_log', "operation IN ('RCT', 'RCA', 'RCB') AND relatedid IN({$post['tid']})");
         }
         deletethread(array($post['tid']));
         updateforumcount($post['fid']);
     } else {
         if ($post['replycredit'] > 0) {
             updatemembercount($post['authorid'], array($_G['setting']['creditstransextra'][10] => -$post['replycredit']));
             DB::delete('common_credit_log', "uid = '{$post['authorid']}' AND operation = 'RCA' AND relatedid IN({$post['tid']})");
         }
         deletepost(array($_G['gp_pid']));
         updatethreadcount($post['tid']);
     }
     usemagic($this->magic['magicid'], $this->magic['num']);
     updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, 'tid', $_G['tid']);
     showmessage(lang('magic/repent', 'repent_succeed'), $post['first'] ? 'forum.php?mod=forumdisplay&fid=' . $post['fid'] : dreferer(), array(), array('showdialog' => 1, 'locationtime' => true));
 }
Ejemplo n.º 3
0
 protected function _handleEvilPost($tid, $pid, $evilType, $evilLevel = 1)
 {
     include_once DISCUZ_ROOT . './source/language/lang_admincp_cloud.php';
     $securityService = Cloud::loadClass('Service_Security');
     $securityService->writeLog($pid, 'pid');
     $evilPost = C::t('#security#security_evilpost')->fetch($pid);
     if (count($evilPost)) {
         return true;
     } else {
         require_once libfile('function/delete');
         require_once libfile('function/forum');
         require_once libfile('function/post');
         $data = array('pid' => $pid, 'tid' => $tid, 'evilcount' => 1, 'eviltype' => $evilType, 'createtime' => TIMESTAMP);
         $post = get_post_by_pid($pid);
         if (is_array($post) && count($post) > 0) {
             if ($tid != $post['tid']) {
                 return false;
             }
             $thread = get_thread_by_tid($tid);
             if ($post['first']) {
                 $data['type'] = 1;
                 if ($this->_checkThreadIgnore($tid)) {
                     return false;
                 }
                 C::t('#security#security_evilpost')->insert($data, false, true);
                 $this->_updateEvilCount('thread');
                 deletethread(array($tid), true, true, true);
                 updatemodlog($tid, 'DEL', 0, 1, $extend_lang['security_modreason']);
             } else {
                 $data['type'] = 0;
                 if ($this->_checkPostIgnore($pid, $post)) {
                     return false;
                 }
                 C::t('#security#security_evilpost')->insert($data, false, true);
                 $this->_updateEvilCount('post');
                 deletepost(array($pid), 'pid', true, false, true);
             }
             if (!empty($post['authorid'])) {
                 $data = array('uid' => $post['authorid'], 'createtime' => TIMESTAMP);
                 C::t('#security#security_eviluser')->insert($data, false, true);
             }
         } else {
             $data['operateresult'] = 2;
             C::t('#security#security_evilpost')->insert($data, false, true);
         }
         if ($evilLevel >= 5) {
             $user = C::t('common_member')->fetch($post['authorid'], 0, 1);
             $this->_handleBandUser($user, 1);
         }
     }
     return true;
 }
Ejemplo n.º 4
0
 function usesubmit()
 {
     global $_G;
     if (empty($_G['gp_pid'])) {
         showmessage(lang('magic/repent', 'repent_info_nonexistence'));
     }
     $_G['tid'] = $_G['gp_ptid'];
     $post = getpostinfo($_G['gp_pid'], 'pid', array('p.first', 'p.tid', 'p.fid', 'p.authorid'));
     $this->_check($post);
     require_once libfile('function/post');
     require_once libfile('function/delete');
     if ($post['first']) {
         deletethread("tid='{$post['tid']}'");
         updateforumcount($post['fid']);
     } else {
         deletepost("pid='{$_G['gp_pid']}'");
         updatethreadcount($post['tid']);
     }
     usemagic($this->magic['magicid'], $this->magic['num']);
     updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, 'tid', $_G['tid']);
     showmessage(lang('magic/repent', 'repent_succeed'), $post['first'] ? 'forum.php?mod=forumdisplay&fid=' . $post['fid'] : dreferer(), array(), array('showdialog' => 1, 'locationtime' => 1));
 }
Ejemplo n.º 5
0
     $prune['forums'][] = $post['fid'];
     $prune['thread'][$post['tid']]++;
     $pidsdelete[] = $post['pid'];
     if ($post['first']) {
         $tidsdelete[] = $post['tid'];
     }
     if ($post['first']) {
         my_thread_log('delete', array('tid' => $post['tid']));
     } else {
         my_post_log('delete', array('pid' => $post['pid']));
     }
 }
 if ($pidsdelete) {
     require_once libfile('function/post');
     require_once libfile('function/delete');
     $deletedposts = deletepost($pidsdelete, 'pid', !$_G['gp_donotupdatemember'], $posttable);
     $deletedthreads = deletethread($tidsdelete, !$_G['gp_donotupdatemember'], !$_G['gp_donotupdatemember']);
     if (count($prune['thread']) < 50) {
         foreach ($prune['thread'] as $tid => $decrease) {
             updatethreadcount($tid);
         }
     } else {
         $repliesarray = array();
         foreach ($prune['thread'] as $tid => $decrease) {
             $repliesarray[$decrease][] = $tid;
         }
         foreach ($repliesarray as $decrease => $tidarray) {
             DB::query("UPDATE " . DB::table('forum_thread') . " SET replies=replies-{$decrease} WHERE tid IN (" . implode(',', $tidarray) . ")");
         }
     }
     if ($_G['setting']['globalstick']) {
Ejemplo n.º 6
0
     $tileid = mysql_real_escape_string($_POST['tileid']);
     $userid = mysql_real_escape_string($_POST['userid']);
     sorttiles($tileid, $userid);
     break;
 case "homepage_public":
     $id = mysql_real_escape_string($_POST['id']);
     homepage_public($authuserid);
     break;
 case "userpublic_detail":
     $id = mysql_real_escape_string($_POST['id']);
     userpublic_detail($id);
     break;
 case "deletepost":
     $finao_id = mysql_real_escape_string($_POST['finao_id']);
     $userpostid = mysql_real_escape_string($_POST['userpostid']);
     deletepost($authuserid, $finao_id, $userpostid);
     break;
 case "registration":
     $type = mysql_real_escape_string($_POST['type']);
     $email = mysql_real_escape_string($_POST['email']);
     $password = mysql_real_escape_string($_POST['password']);
     $fname = mysql_real_escape_string($_POST['fname']);
     $lname = mysql_real_escape_string($_POST['lname']);
     $fbid = 0;
     if ($type == 2) {
         $fbid = mysql_real_escape_string($_POST['facebook_id']);
     }
     registration($type, $email, $password, $fname, $lname, $fbid);
     break;
 case "whotofollow":
     whotofollow($authuserid);
Ejemplo n.º 7
0
function deletethreads($tids = array())
{
    global $_G;
    static $cleartable = array('forum_threadmod', 'forum_relatedthread', 'forum_post', 'forum_poll', 'forum_polloption', 'forum_trade', 'forum_activity', 'forum_activityapply', 'forum_debate', 'forum_debatepost', 'forum_attachment', 'forum_typeoptionvar', 'forum_forumrecommend', 'forum_postposition');
    foreach ($tids as $tid) {
        my_thread_log('delete', array('tid' => $tid));
    }
    $threadsdel = 0;
    if ($tids = dimplode($tids)) {
        $auidarray = array();
        $query = DB::query("SELECT uid, attachment, dateline, thumb, remote, aid FROM " . DB::table('forum_attachment') . " WHERE tid IN ({$tids})");
        while ($attach = DB::fetch($query)) {
            dunlink($attach);
            if ($attach['dateline'] > $_G['setting']['losslessdel']) {
                $auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1;
            }
        }
        if ($auidarray) {
            updateattachcredits('-', $auidarray, $_G['setting']['creditspolicy']['postattach']);
        }
        require_once libfile('function/delete');
        foreach ($cleartable as $tb) {
            if ($tb == 'forum_post') {
                deletepost("tid IN ({$tids})");
                continue;
            }
            DB::query("DELETE FROM " . DB::table($tb) . " WHERE tid IN ({$tids})", 'UNBUFFERED');
        }
        DB::query("DELETE FROM " . DB::table('forum_thread') . " WHERE tid IN ({$tids})");
        $threadsdel = DB::affected_rows();
    }
    return $threadsdel;
}
Ejemplo n.º 8
0
                 $tidsdelete[] = $post['tid'];
             }
             $pidsdelete[] = $post['pid'];
             $pidsthread[$post['pid']] = $post['tid'];
         }
         foreach ($pidsdelete as $key => $pid) {
             if (in_array($pidsthread[$pid], $tidsdelete)) {
                 unset($pidsdelete[$key]);
                 unset($prune['thread'][$pidsthread[$pid]]);
                 updatemodlog($pidsthread[$pid], 'DEL');
             } else {
                 updatemodlog($pidsthread[$pid], 'DLP');
             }
         }
     }
     deletepost($pidsdelete, 'pid', false, $posttableid, true);
 }
 unset($postlist);
 if ($tidsdelete) {
     deletethread($tidsdelete, true, true, true);
 }
 if (!empty($prune)) {
     foreach ($prune['thread'] as $tid => $decrease) {
         updatethreadcount($tid);
     }
     foreach (array_unique($prune['forums']) as $fid) {
     }
 }
 if ($_G['setting']['globalstick']) {
     updatecache('globalstick');
 }
Ejemplo n.º 9
0
         if ($post['first']) {
             $tuidarray[] = $post['authorid'];
         } else {
             $ruidarray[] = $post['authorid'];
         }
     }
     if ($tuidarray) {
         updatepostcredits('-', $tuidarray, 'post');
     }
     if ($ruidarray) {
         updatepostcredits('-', $ruidarray, 'reply');
     }
 }
 require_once libfile('function/delete');
 $deletedposts = deletepost("pid IN ({$pidsdelete})");
 $deletedposts += deletepost("tid IN ({$tidsdelete})");
 $deletedthreads = deletethread("tid IN ({$tidsdelete})");
 if (count($prune['thread']) < 50) {
     foreach ($prune['thread'] as $tid => $decrease) {
         updatethreadcount($tid);
     }
 } else {
     $repliesarray = array();
     foreach ($prune['thread'] as $tid => $decrease) {
         $repliesarray[$decrease][] = $tid;
     }
     foreach ($repliesarray as $decrease => $tidarray) {
         DB::query("UPDATE " . DB::table('forum_thread') . " SET replies=replies-{$decrease} WHERE tid IN (" . implode(',', $tidarray) . ")");
     }
 }
 foreach (array_unique($prune['forums']) as $id) {
Ejemplo n.º 10
0
     $result['count'] = count($result['pids']);
     $modsession->set($cachekey, $result, true);
     unset($result);
 }
 if ($pidsdelete) {
     require_once libfile('function/post');
     require_once libfile('function/delete');
     $forums = array();
     $query = DB::query('SELECT fid, recyclebin FROM ' . DB::table('forum_forum') . " WHERE fid IN (" . dimplode($prune['forums']) . ")");
     while ($value = DB::fetch($query)) {
         $forums[$value['fid']] = $value;
     }
     foreach ($pidsdelete as $fid => $pids) {
         foreach ($pids as $pid) {
             if (!$tidsdelete[$pid]) {
                 $deletedposts = deletepost($pid, 'pid', !getgpc('nocredit'), $posttableid, $forums[$fid]['recyclebin']);
                 updatemodlog($pids_tids[$pid], 'DLP');
             } else {
                 $deletedthreads = deletethread($tidsdelete[$pid], false, !getgpc('nocredit'), $forums[$fid]['recyclebin']);
                 updatemodlog($tidsdelete[$pid], 'DEL');
             }
         }
     }
     if (count($prune['thread']) < 50) {
         foreach ($prune['thread'] as $tid => $decrease) {
             updatethreadcount($tid);
         }
     } else {
         $repliesarray = array();
         foreach ($prune['thread'] as $tid => $decrease) {
             $repliesarray[$decrease][] = $tid;
Ejemplo n.º 11
0
function recyclebinpostdelete($deletepids, $posttableid = false)
{
    if (empty($deletepids)) {
        return 0;
    }
    require_once libfile('function/delete');
    return deletepost($deletepids, 'pid', true, $posttableid);
}
Ejemplo n.º 12
0
function handleEvilPost($tid, $pid, $evilType, $evilLevel = 1)
{
    global $_G;
    if (notOpenService()) {
        return false;
    }
    include_once DISCUZ_ROOT . './source/language/lang_admincp_cloud.php';
    loadSecLog($pid, 'pid');
    $evilPost = DB::fetch_first("SELECT * FROM " . DB::table('security_evilpost') . " WHERE pid='{$pid}'");
    if (is_array($evilPost)) {
        $data = $evilPost;
        $data['evilcount'] = $evilPost['evilcount'] + 1;
    } else {
        require_once libfile('function/delete');
        require_once libfile('function/forum');
        require_once libfile('function/post');
        $data = array('pid' => $pid, 'tid' => $tid, 'evilcount' => 1, 'eviltype' => $evilType, 'createtime' => TIMESTAMP);
        $post = get_post_by_pid($pid);
        if (is_array($post) && count($post) > 0) {
            if ($tid != $post['tid']) {
                return false;
            }
            if ($post['first']) {
                $data['type'] = 1;
                if (checkThreadIgnore($tid)) {
                    return false;
                }
                DB::insert('security_evilpost', $data, 0, 1);
                updateEvilCount('thread');
                DB::query("UPDATE " . DB::table('forum_thread') . " SET displayorder='-1', digest='0', moderated='1' WHERE tid = '" . $tid . "'");
                deletethread(array($tid), true, true, true);
                updatepost(array('invisible' => '-1'), "tid = '" . $tid . "'");
                updatemodlog($tid, 'DEL', 0, 1, $extend_lang['security_modreason']);
            } else {
                $data['type'] = 0;
                if (checkPostIgnore($pid, $post)) {
                    return false;
                }
                DB::insert('security_evilpost', $data, 0, 1);
                updateEvilCount('post');
                deletepost(array($pid), 'pid', true, false, true);
            }
        } else {
            $data['operateresult'] = 2;
            DB::insert('security_evilpost', $data, 0, 1);
        }
    }
    return true;
}
Ejemplo n.º 13
0
         dunlink($attach);
     }
     if ($member['uid']) {
         require_once libfile('function/post');
         $pidsdelete = $tidsdelete = '0';
         $postarray = getfieldsofposts('pid, fid, tid, first', "authorid='{$member['uid']}'");
         foreach ($postarray as $post) {
             $prune['forums'][] = $post['fid'];
             $prune['thread'][$post['tid']]++;
             if ($post['first']) {
                 $tidsdelete .= ",{$post['tid']}";
             }
             $pidsdelete .= ",{$post['pid']}";
         }
         deletepost("pid IN ({$pidsdelete})");
         deletepost("tid IN ({$tidsdelete})");
         deletethread("tid IN ({$tidsdelete})");
         if (!empty($prune)) {
             foreach ($prune['thread'] as $tid => $decrease) {
                 updatethreadcount($tid);
             }
             foreach (array_unique($prune['forums']) as $fid) {
                 updateforumcount($fid);
             }
         }
         if ($_G['setting']['globalstick']) {
             updatecache('globalstick');
         }
     }
 }
 if ($_G['gp_delblog']) {
Ejemplo n.º 14
0
             $pmlist[] = array('act' => 'modthreads_delete', 'notevar' => array('reason' => dhtmlspecialchars($_G['gp_reason']), 'threadsubject' => $thread['subject']), 'authorid' => $thread['authorid']);
         }
     }
     if ($recyclebintids) {
         DB::query("UPDATE " . DB::table('forum_thread') . " SET displayorder='-1', moderated='1' WHERE tid IN ({$recyclebintids})");
         updatemodworks('MOD', DB::affected_rows());
         updatepost(array('invisible' => '-1'), "tid IN ({$recyclebintids})");
         updatemodlog($recyclebintids, 'DEL');
     }
     $query = DB::query("SELECT attachment, thumb, remote, aid FROM " . DB::table('forum_attachment') . " WHERE tid IN ({$deletetids})");
     while ($attach = DB::fetch($query)) {
         dunlink($attach);
     }
     DB::query("DELETE FROM " . DB::table('forum_thread') . " WHERE tid IN ({$deletetids})", 'UNBUFFERED');
     require_once libfile('function/delete');
     deletepost("tid IN ({$deletetids})");
     DB::query("DELETE FROM " . DB::table('forum_polloption') . " WHERE tid IN ({$deletetids})");
     DB::query("DELETE FROM " . DB::table('forum_poll') . " WHERE tid IN ({$deletetids})", 'UNBUFFERED');
     DB::query("DELETE FROM " . DB::table('forum_trade') . " WHERE tid IN ({$deletetids})", 'UNBUFFERED');
     DB::query("DELETE FROM " . DB::table('forum_attachment') . " WHERE tid IN ({$deletetids})", 'UNBUFFERED');
     DB::query("DELETE FROM " . DB::table('forum_attachmentfield') . " WHERE tid IN ({$deletetids})", 'UNBUFFERED');
 }
 foreach ($moderation['validate'] as $tid) {
     my_thread_log('validate', array('tid' => $tid));
 }
 if ($validatetids = dimplode($moderation['validate'])) {
     $tids = $comma = $comma2 = '';
     $moderatedthread = array();
     $query = DB::query("SELECT t.fid, t.tid, t.authorid, t.subject, t.author, t.dateline FROM " . DB::table('forum_thread') . " t\n\t\t\t\tWHERE t.tid IN ({$validatetids}) AND t.displayorder='{$pstat}' AND " . ($modfidsadd ? "t.{$modfidsadd}" : '1'));
     while ($thread = DB::fetch($query)) {
         $tids .= $comma . $thread['tid'];
Ejemplo n.º 15
0
function deletemember($uids, $other = 1)
{
    $query = DB::query("DELETE FROM " . DB::table('common_member') . " WHERE uid IN ({$uids})");
    $numdeleted = DB::affected_rows();
    DB::query("DELETE FROM " . DB::table('common_member_field_forum') . " WHERE uid IN ({$uids})", 'UNBUFFERED');
    DB::query("DELETE FROM " . DB::table('common_member_field_home') . " WHERE uid IN ({$uids})", 'UNBUFFERED');
    DB::query("DELETE FROM " . DB::table('common_member_count') . " WHERE uid IN ({$uids})", 'UNBUFFERED');
    DB::query("DELETE FROM " . DB::table('common_member_log') . " WHERE uid IN ({$uids})", 'UNBUFFERED');
    DB::query("DELETE FROM " . DB::table('common_member_profile') . " WHERE uid IN ({$uids})", 'UNBUFFERED');
    DB::query("DELETE FROM " . DB::table('common_member_security') . " WHERE uid IN ({$uids})", 'UNBUFFERED');
    DB::query("DELETE FROM " . DB::table('common_member_status') . " WHERE uid IN ({$uids})", 'UNBUFFERED');
    DB::query("DELETE FROM " . DB::table('common_member_validate') . " WHERE uid IN ({$uids})", 'UNBUFFERED');
    DB::query("DELETE FROM " . DB::table('forum_access') . " WHERE uid IN ({$uids})", 'UNBUFFERED');
    DB::query("DELETE FROM " . DB::table('forum_moderator') . " WHERE uid IN ({$uids})", 'UNBUFFERED');
    if ($other) {
        DB::query("DELETE FROM " . DB::table('common_member_validate') . " WHERE uid IN ({$uids})", 'UNBUFFERED');
        DB::query("DELETE FROM " . DB::table('common_member_magic') . " WHERE uid IN ({$uids})", 'UNBUFFERED');
        $query = DB::query("SELECT uid, attachment, thumb, remote, aid FROM " . DB::table('forum_attachment') . " WHERE uid IN ({$uids})");
        while ($attach = DB::fetch($query)) {
            dunlink($attach);
        }
        DB::query("DELETE FROM " . DB::table('forum_attachment') . " WHERE uid IN ({$uids})", 'UNBUFFERED');
        DB::query("DELETE FROM " . DB::table('forum_attachmentfield') . " WHERE uid IN ({$uids})", 'UNBUFFERED');
        deletepost("authorid IN ({$uids})", true, false);
    }
    DB::query("DELETE FROM " . DB::table('home_feed') . " WHERE uid IN ({$uids}) OR (id IN ({$uids}) AND idtype='uid')");
    $doids = array();
    $query = DB::query("SELECT * FROM " . DB::table('home_doing') . " WHERE uid IN ({$uids})");
    while ($value = DB::fetch($query)) {
        $doids[$value['doid']] = $value['doid'];
    }
    DB::query("DELETE FROM " . DB::table('home_doing') . " WHERE uid IN ({$uids})");
    $delsql = !empty($doids) ? "doid IN (" . dimplode($doids) . ") OR " : "";
    DB::query("DELETE FROM " . DB::table('home_docomment') . " WHERE {$delsql} uid IN ({$uids})");
    DB::query("DELETE FROM " . DB::table('home_share') . " WHERE uid IN ({$uids})");
    DB::query("DELETE FROM " . DB::table('home_album') . " WHERE uid IN ({$uids})");
    DB::query("DELETE FROM " . DB::table('common_credit_rule_log') . " WHERE uid IN ({$uids})");
    DB::query("DELETE FROM " . DB::table('common_credit_rule_log_field') . " WHERE uid IN ({$uids})");
    DB::query("DELETE FROM " . DB::table('home_notification') . " WHERE (uid IN ({$uids}) OR authorid IN ({$uids}))");
    DB::query("DELETE FROM " . DB::table('home_poke') . " WHERE (uid IN ({$uids}) OR fromuid IN ({$uids}))");
    $query = DB::query("SELECT filepath, thumb, remote FROM " . DB::table('home_pic') . " WHERE uid IN ({$uids})");
    while ($value = DB::fetch($query)) {
        deletepicfiles($value);
    }
    DB::query("DELETE FROM " . DB::table('home_pic') . " WHERE uid IN ({$uids})");
    DB::query("DELETE FROM " . DB::table('home_blog') . " WHERE uid IN ({$uids})");
    DB::query("DELETE FROM " . DB::table('home_blogfield') . " WHERE uid IN ({$uids})");
    DB::query("DELETE FROM " . DB::table('home_comment') . " WHERE (uid IN ({$uids}) OR authorid IN ({$uids}) OR (id IN ({$uids}) AND idtype='uid'))");
    DB::query("DELETE FROM " . DB::table('home_visitor') . " WHERE (uid IN ({$uids}) OR vuid IN ({$uids}))");
    DB::query("DELETE FROM " . DB::table('home_class') . " WHERE uid IN ({$uids})");
    DB::query("DELETE FROM " . DB::table('home_friend') . " WHERE (uid IN ({$uids}) OR fuid IN ({$uids}))");
    DB::query("DELETE FROM " . DB::table('home_clickuser') . " WHERE uid IN ({$uids})");
    DB::query("DELETE FROM " . DB::table('common_invite') . " WHERE (uid IN ({$uids}) OR fuid IN ({$uids}))");
    DB::query("DELETE FROM " . DB::table('common_mailcron') . ", " . DB::table('common_mailqueue') . " USING " . DB::table('common_mailcron') . ", " . DB::table('common_mailqueue') . " WHERE " . DB::table('common_mailcron') . ".touid IN ({$uids}) AND " . DB::table('common_mailcron') . ".cid=" . DB::table('common_mailqueue') . ".cid");
    DB::query("DELETE FROM " . DB::table('common_myinvite') . " WHERE (touid IN ({$uids}) OR fromuid IN ({$uids}))");
    DB::query("DELETE FROM " . DB::table('home_userapp') . " WHERE uid IN ({$uids})");
    DB::query("DELETE FROM " . DB::table('home_userappfield') . " WHERE uid IN ({$uids})");
    DB::query("DELETE FROM " . DB::table('home_show') . " WHERE uid IN ({$uids})");
    manyoulog('user', $uids, 'delete');
    require_once libfile('function/forum');
    foreach (explode(',', $uids) as $uid) {
        my_thread_log('deluser', array('uid' => $uid));
    }
    return $numdeleted;
}
Ejemplo n.º 16
0
     foreach ($postarray as $post) {
         $pids .= $comma . $post['pid'];
         $pm = 'pm_' . $post['pid'];
         if (isset(${$pm}) && ${$pm} != '' && $post['authorid']) {
             $pmlist[] = array('action' => 'modreplies_delete', 'notevar' => array('post' => $post, 'reason' => stripslashes($reason)), 'authorid' => $post['authorid'], 'tid' => $post['tid'], 'post' => dhtmlspecialchars(cutstr($post['message'], 30)), 'reason' => dhtmlspecialchars(${$pm}));
         }
         $comma = ',';
     }
     if ($pids) {
         $query = DB::query("SELECT attachment, thumb, remote, aid FROM " . DB::table('forum_attachment') . " WHERE pid IN ({$deletepids})");
         while ($attach = DB::fetch($query)) {
             dunlink($attach);
         }
         DB::query("DELETE FROM " . DB::table('forum_attachment') . " WHERE pid IN ({$pids})", 'UNBUFFERED');
         DB::query("DELETE FROM " . DB::table('forum_attachmentfield') . " WHERE pid IN ({$pids})", 'UNBUFFERED');
         $deletes = deletepost("pid IN ({$pids})");
         DB::query("DELETE FROM " . DB::table('forum_trade') . " WHERE pid IN ({$pids})", 'UNBUFFERED');
     }
     updatemodworks('DLP', count($moderation['delete']));
 }
 if ($validatepids = dimplode($moderation['validate'])) {
     $forums = $threads = $lastpost = $attachments = $pidarray = $authoridarray = array();
     $postarray = getallwithposts(array('select' => 't.lastpost, p.pid, p.fid, p.tid, p.authorid, p.author, p.dateline, p.attachment, p.message, p.anonymous, ff.replycredits', 'from' => DB::table('forum_post') . " p LEFT JOIN " . DB::table('forum_forumfield') . " ff ON ff.fid=p.fid LEFT JOIN " . DB::table('forum_thread') . " t ON t.tid=p.tid", 'where' => "pid IN ({$validatepids}) AND p.invisible='{$displayorder}' AND first='0' {$fidadd['and']}{$fidadd['0']}{$fidadd['fids']}"));
     foreach ($postarray as $post) {
         $pidarray[] = $post['pid'];
         if ($post['replycredits']) {
             updatepostcredits('+', $post['authorid'], 'reply', $post['fid']);
         } else {
             $authoridarray[] = $post['authorid'];
         }
         $forums[] = $post['fid'];
 private function _adminTopic($fid, $tid, $pid, $act, $type)
 {
     global $_G;
     $errorMsg = '';
     $_GET['topiclist'] = array($_GET['pid']);
     // 在DISCUZ_ROOT/source/module/forum/forum_topicadmin.php基础上进行二次开发
     $_GET['topiclist'] = !empty($_GET['topiclist']) ? is_array($_GET['topiclist']) ? array_unique($_GET['topiclist']) : $_GET['topiclist'] : array();
     loadcache(array('modreasons', 'stamptypeid', 'threadtableids'));
     require_once libfile('function/post');
     require_once libfile('function/misc');
     $modpostsnum = 0;
     $resultarray = $thread = array();
     if ($_G['group']['reasonpm'] == 2 || $_G['group']['reasonpm'] == 3 || !empty($_GET['sendreasonpm'])) {
         $forumname = strip_tags($_G['forum']['name']);
         $sendreasonpm = 1;
     } else {
         $sendreasonpm = 0;
     }
     if ($type == 'topic') {
         if ($act == 'band') {
             $resultarray = $this->_topicAdmin_band($fid, $tid, $pid, $act, $type, array('sendreasonpm' => $sendreasonpm, 'thread' => $_G['forum_thread']));
         } else {
             // 在DISCUZ_ROOT/source/include/topicadmin/topicadmin_moderate.php基础上进行二次开发
             $thread = $_G['forum_thread'];
             $thread['dblastpost'] = $thread['lastpost'];
             $threadlist[$thread['tid']] = $thread;
             $modpostsnum = count($threadlist);
             $stickcheck = $closecheck = $digestcheck = array('', '', '', '', '');
             empty($threadlist[$_G['tid']]['displayorder']) ? $stickcheck[0] = 'selected="selected"' : ($stickcheck[$threadlist[$_G['tid']]['displayorder']] = 'selected="selected"');
             empty($threadlist[$_G['tid']]['digest']) ? $digestcheck[0] = 'selected="selected"' : ($digestcheck[$threadlist[$_G['tid']]['digest']] = 'selected="selected"');
             empty($threadlist[$_G['tid']]['closed']) ? $closecheck[0] = 'checked="checked"' : ($closecheck[1] = 'checked="checked"');
             if (!empty($_POST)) {
                 $tidsarr = array_keys($threadlist);
                 $moderatetids = dimplode($tidsarr);
                 $reason = checkreasonpm();
                 $stampstatus = 0;
                 $stampaction = 'SPA';
                 $operationMap = array('top' => 'stick', 'marrow' => 'digest', 'delete' => 'delete');
                 $operation = $operationMap[$act];
                 $updatemodlog = TRUE;
                 switch ($act) {
                     case 'top':
                         $sticklevel = intval($_GET['sticklevel']);
                         if ($sticklevel < 0 || $sticklevel > 3 || $sticklevel > $_G['group']['allowstickthread']) {
                             // showmessage('no_privilege_stickthread');
                             $this->_exitWithHtmlAlert('no_privilege_stickthread');
                         }
                         $expiration = checkexpiration($_GET['expirationstick'], $operation);
                         $expirationstick = $sticklevel ? $_GET['expirationstick'] : 0;
                         $forumstickthreads = $_G['setting']['forumstickthreads'];
                         $forumstickthreads = isset($forumstickthreads) ? dunserialize($forumstickthreads) : array();
                         C::t('forum_thread')->update($tidsarr, array('displayorder' => $sticklevel, 'moderated' => 1), true);
                         $delkeys = array_keys($threadlist);
                         foreach ($delkeys as $k) {
                             unset($forumstickthreads[$k]);
                         }
                         C::t('common_setting')->update('forumstickthreads', $forumstickthreads);
                         $stickmodify = 0;
                         foreach ($threadlist as $thread) {
                             $stickmodify = (in_array($thread['displayorder'], array(2, 3)) || in_array($sticklevel, array(2, 3))) && $sticklevel != $thread['displayorder'] ? 1 : $stickmodify;
                         }
                         if ($_G['setting']['globalstick'] && $stickmodify) {
                             require_once libfile('function/cache');
                             updatecache('globalstick');
                         }
                         $modaction = $sticklevel ? $expiration ? 'EST' : 'STK' : 'UST';
                         C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('STK', 'UST', 'EST', 'UES'), array('status' => 0));
                         if (!$sticklevel) {
                             $stampaction = 'SPD';
                         }
                         $stampstatus = 1;
                         break;
                     case 'marrow':
                         $digestlevel = intval($_GET['digestlevel']);
                         if ($digestlevel < 0 || $digestlevel > 3 || $digestlevel > $_G['group']['allowdigestthread']) {
                             // showmessage('no_privilege_digestthread');
                             $this->_exitWithHtmlAlert('no_privilege_digestthread');
                         }
                         $expiration = checkexpiration($_GET['expirationdigest'], $operation);
                         $expirationdigest = $digestlevel ? $expirationdigest : 0;
                         C::t('forum_thread')->update($tidsarr, array('digest' => $digestlevel, 'moderated' => 1), true);
                         foreach ($threadlist as $thread) {
                             if ($thread['digest'] != $digestlevel) {
                                 if ($digestlevel == $thread['digest']) {
                                     continue;
                                 }
                                 $extsql = array();
                                 if ($digestlevel > 0 && $thread['digest'] == 0) {
                                     $extsql = array('digestposts' => 1);
                                 }
                                 if ($digestlevel == 0 && $thread['digest'] > 0) {
                                     $extsql = array('digestposts' => -1);
                                 }
                                 if ($digestlevel == 0) {
                                     $stampaction = 'SPD';
                                 }
                                 updatecreditbyaction('digest', $thread['authorid'], $extsql, '', $digestlevel - $thread['digest']);
                             }
                         }
                         $modaction = $digestlevel ? $expiration ? 'EDI' : 'DIG' : 'UDG';
                         C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('DIG', 'UDI', 'EDI', 'UED'), array('status' => 0));
                         $stampstatus = 2;
                         break;
                     case 'delete':
                         if (!$_G['group']['allowdelpost']) {
                             // showmessage('no_privilege_delpost');
                             $this->_exitWithHtmlAlert('no_privilege_delpost');
                         }
                         loadcache('threadtableids');
                         $stickmodify = 0;
                         $deleteredirect = $remarkclosed = array();
                         foreach ($threadlist as $thread) {
                             if ($thread['digest']) {
                                 updatecreditbyaction('digest', $thread['authorid'], array('digestposts' => -1), '', -$thread['digest']);
                             }
                             if (in_array($thread['displayorder'], array(2, 3))) {
                                 $stickmodify = 1;
                             }
                             if ($_G['forum']['status'] == 3 && $thread['closed'] > 1) {
                                 $deleteredirect[] = $thread['closed'];
                             }
                             if ($thread['isgroup'] == 1 && $thread['closed'] > 1) {
                                 $remarkclosed[] = $thread['closed'];
                             }
                         }
                         $modaction = 'DEL';
                         require_once libfile('function/delete');
                         $tids = array_keys($threadlist);
                         if ($_G['forum']['recyclebin']) {
                             deletethread($tids, true, true, true);
                             manage_addnotify('verifyrecycle', $modpostsnum);
                         } else {
                             deletethread($tids, true, true);
                             $updatemodlog = FALSE;
                         }
                         $forumstickthreads = $_G['setting']['forumstickthreads'];
                         $forumstickthreads = !empty($forumstickthreads) ? dunserialize($forumstickthreads) : array();
                         $delkeys = array_keys($threadlist);
                         foreach ($delkeys as $k) {
                             unset($forumstickthreads[$k]);
                         }
                         C::t('common_setting')->update('forumstickthreads', $forumstickthreads);
                         C::t('forum_forum_threadtable')->delete_none_threads();
                         if (!empty($deleteredirect)) {
                             deletethread($deleteredirect);
                         }
                         if (!empty($remarkclosed)) {
                             C::t('forum_thread')->update($remarkclosed, array('closed' => 0));
                         }
                         if ($_G['setting']['globalstick'] && $stickmodify) {
                             require_once libfile('function/cache');
                             updatecache('globalstick');
                         }
                         updateforumcount($_G['fid']);
                         if ($_GET['crimerecord']) {
                             include_once libfile('function/member');
                             foreach ($threadlist as $thread) {
                                 crime('recordaction', $thread['authorid'], 'crime_delpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $thread['tid'], 'pid' => 0)));
                             }
                         }
                         break;
                     case 'close':
                         if (!$_G['group']['allowclosethread']) {
                             $this->_exitWithHtmlAlert('no_privilege_closethread');
                         }
                         $expiration = checkexpiration($_GET['expirationclose'], $operation);
                         $modaction = $expiration ? 'ECL' : 'CLS';
                         C::t('forum_thread')->update($tidsarr, array('closed' => 1, 'moderated' => 1), true);
                         C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('CLS', 'OPN', 'ECL', 'UCL', 'EOP', 'UEO'), array('status' => 0));
                         break;
                     case 'open':
                         if (!$_G['group']['allowclosethread']) {
                             $this->_exitWithHtmlAlert('no_privilege_openthread');
                         }
                         $expiration = checkexpiration($_GET['expirationclose'], $operation);
                         $modaction = $expiration ? 'EOP' : 'OPN';
                         C::t('forum_thread')->update($tidsarr, array('closed' => 0, 'moderated' => 1), true);
                         C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('CLS', 'OPN', 'ECL', 'UCL', 'EOP', 'UEO'), array('status' => 0));
                         break;
                     case 'move':
                         if (!$_G['group']['allowmovethread']) {
                             $this->_exitWithHtmlAlert('no_privilege_movethread');
                         }
                         $moveto = $_GET['moveto'];
                         $toforum = C::t('forum_forum')->fetch_info_by_fid($moveto);
                         if (!$toforum || $_G['adminid'] != 1 && $toforum['status'] != 1 || $toforum['type'] == 'group') {
                             // showmessage('admin_move_invalid');
                             $this->_exitWithHtmlAlert('admin_move_invalid');
                         } elseif ($_G['fid'] == $toforum['fid']) {
                             continue;
                         } else {
                             $moveto = $toforum['fid'];
                             $modnewthreads = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 1) && $toforum['modnewposts'] ? 1 : 0;
                             $modnewreplies = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 2) && $toforum['modnewposts'] ? 1 : 0;
                             if ($modnewthreads || $modnewreplies) {
                                 // showmessage('admin_move_have_mod');
                                 $this->_exitWithHtmlAlert('admin_move_have_mod');
                             }
                         }
                         if ($_G['adminid'] == 3) {
                             $priv = C::t('forum_forumfield')->check_moderator_for_uid($moveto, $_G['uid'], $_G['member']['accessmasks']);
                             if (($priv['postperm'] && !in_array($_G['groupid'], explode("\t", $priv['postperm'])) || $_G['member']['accessmasks'] && ($priv['allowview'] || $priv['allowreply'] || $priv['allowgetattach'] || $priv['allowpostattach']) && !$priv['allowpost']) && !$priv['istargetmod']) {
                                 // showmessage('admin_move_nopermission');
                                 $this->_exitWithHtmlAlert('admin_move_nopermission');
                             }
                         }
                         $moderate = array();
                         $stickmodify = 0;
                         $toforumallowspecial = array(1 => $toforum['allowpostspecial'] & 1, 2 => $toforum['allowpostspecial'] & 2, 3 => isset($_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]) && $toforum['allowpostspecial'] & 4, 4 => $toforum['allowpostspecial'] & 8, 5 => $toforum['allowpostspecial'] & 16, 127 => $_G['setting']['threadplugins'] ? dunserialize($toforum['threadplugin']) : array());
                         foreach ($threadlist as $tid => $thread) {
                             $allowmove = 0;
                             if (!$thread['special']) {
                                 $allowmove = 1;
                             } else {
                                 if ($thread['special'] != 127) {
                                     $allowmove = $toforum['allowpostspecial'] ? $toforumallowspecial[$thread['special']] : 0;
                                 } else {
                                     if ($toforumallowspecial[127]) {
                                         $posttable = getposttablebytid($thread['tid']);
                                         $message = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']);
                                         $message = $message['message'];
                                         $sppos = strrpos($message, chr(0) . chr(0) . chr(0));
                                         $specialextra = substr($message, $sppos + 3);
                                         $allowmove = in_array($specialextra, $toforumallowspecial[127]);
                                     } else {
                                         $allowmove = 0;
                                     }
                                 }
                             }
                             if ($allowmove) {
                                 $moderate[] = $tid;
                                 if (in_array($thread['displayorder'], array(2, 3))) {
                                     $stickmodify = 1;
                                 }
                                 if ($_GET['appbyme_movetype'] == 'redirect') {
                                     // if($_GET['type'] == 'redirect') {
                                     $insertdata = array('fid' => $thread['fid'], 'readperm' => $thread['readperm'], 'author' => $thread['author'], 'authorid' => $thread['authorid'], 'subject' => $thread['subject'], 'dateline' => $thread['dateline'], 'lastpost' => $thread['dblastpost'], 'lastposter' => $thread['lastposter'], 'views' => 0, 'replies' => 0, 'displayorder' => 0, 'digest' => 0, 'closed' => $thread['tid'], 'special' => 0, 'attachment' => 0, 'typeid' => $_GET['threadtypeid']);
                                     $newtid = C::t('forum_thread')->insert($insertdata, true);
                                     if ($newtid) {
                                         C::t('forum_threadclosed')->insert(array('tid' => $thread['tid'], 'redirect' => $newtid), true, true);
                                     }
                                 }
                             }
                         }
                         if (!($moderatetids = implode(',', $moderate))) {
                             showmessage('admin_moderate_invalid');
                         }
                         $fieldarr = array('fid' => $moveto, 'isgroup' => 0, 'typeid' => $_GET['threadtypeid'], 'moderated' => 1);
                         if ($_G['adminid'] == 3) {
                             $fieldarr['displayorder'] = 0;
                         }
                         C::t('forum_thread')->update($tidsarr, $fieldarr, true);
                         C::t('forum_forumrecommend')->update($tidsarr, array('fid' => $moveto));
                         loadcache('posttableids');
                         $posttableids = $_G['cache']['posttableids'] ? $_G['cache']['posttableids'] : array('0');
                         foreach ($posttableids as $id) {
                             C::t('forum_post')->update_by_tid($id, $tidsarr, array('fid' => $moveto));
                         }
                         $typeoptionvars = C::t('forum_typeoptionvar')->fetch_all_by_tid_optionid($tidsarr);
                         foreach ($typeoptionvars as $typeoptionvar) {
                             C::t('forum_typeoptionvar')->update_by_tid($typeoptionvar['tid'], array('fid' => $moveto));
                             C::t('forum_optionvalue')->update($typeoptionvar['sortid'], $typeoptionvar['tid'], $_G['fid'], "fid='{$moveto}'");
                         }
                         if ($_G['setting']['globalstick'] && $stickmodify) {
                             require_once libfile('function/cache');
                             updatecache('globalstick');
                         }
                         $modaction = 'MOV';
                         $_G['toforum'] = $toforum;
                         updateforumcount($moveto);
                         updateforumcount($_G['fid']);
                         break;
                     default:
                         $errorMsg = '错误的动作参数';
                         break;
                 }
                 if ($errorMsg == '') {
                     if ($updatemodlog) {
                         if ($operation != 'delete') {
                             updatemodlog($moderatetids, $modaction, $expiration);
                         } else {
                             updatemodlog($moderatetids, $modaction, $expiration, 0, $reason);
                         }
                     }
                     updatemodworks($modaction, $modpostsnum);
                     foreach ($threadlist as $thread) {
                         modlog($thread, $modaction);
                     }
                     if ($sendreasonpm) {
                         $modactioncode = lang('forum/modaction');
                         $modtype = $modaction;
                         $modaction = $modactioncode[$modaction];
                         foreach ($threadlist as $thread) {
                             if ($operation == 'move') {
                                 sendreasonpm($thread, 'reason_move', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason, 'tofid' => $toforum['fid'], 'toname' => $toforum['name'], 'from_id' => 0, 'from_idtype' => 'movethread'));
                             } else {
                                 sendreasonpm($thread, 'reason_moderate', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason, 'from_id' => 0, 'from_idtype' => 'moderate_' . $modtype));
                             }
                         }
                     }
                     if ($stampstatus) {
                         set_stamp($stampstatus, $stampaction, $threadlist, $expiration);
                     }
                     $this->getController()->redirect(WebUtils::createUrl_oldVersion('index/returnmobileview'));
                 }
             } else {
                 if ($act == 'move') {
                     require_once libfile('function/forumlist');
                     $forumselect = forumselect(FALSE, 0, $threadlist[$_G['tid']]['fid'], $_G['adminid'] == 1 ? TRUE : FALSE);
                 }
             }
         }
     } else {
         if ($type == 'post') {
             if ($act == 'band') {
                 $resultarray = $this->_topicAdmin_band($fid, $tid, $pid, $act, $type, array('sendreasonpm' => $sendreasonpm, 'thread' => $_G['forum_thread']));
             } else {
                 // 在DISCUZ_ROOT/source/include/topicadmin/topicadmin_delpost.php基础上进行二次开发
                 $resultarray = array();
                 $thread = $_G['forum_thread'];
                 $topiclist = array($pid);
                 $modpostsnum = 1;
                 $pids = $posts = $authors = array();
                 $posttable = getposttablebytid($_G['tid']);
                 foreach (C::t('forum_post')->fetch_all('tid:' . $_G['tid'], $topiclist, false) as $post) {
                     if ($post['tid'] != $_G['tid']) {
                         continue;
                     }
                     if ($post['first'] == 1) {
                         dheader("location: {$_G['siteurl']}forum.php?mod=topicadmin&action=moderate&operation=delete&optgroup=3&fid={$_G['fid']}&moderate[]={$thread['tid']}&inajax=yes" . ($_GET['infloat'] ? "&infloat=yes&handlekey={$_GET['handlekey']}" : ''));
                     } else {
                         $authors[$post['authorid']] = 1;
                         $pids[] = $post['pid'];
                         $posts[] = $post;
                     }
                 }
                 if (!empty($_POST)) {
                     $reason = checkreasonpm();
                     $uidarray = $puidarray = $auidarray = array();
                     $losslessdel = $_G['setting']['losslessdel'] > 0 ? TIMESTAMP - $_G['setting']['losslessdel'] * 86400 : 0;
                     if ($pids) {
                         require_once libfile('function/delete');
                         if ($_G['forum']['recyclebin']) {
                             deletepost($pids, 'pid', true, false, true);
                             manage_addnotify('verifyrecyclepost', $modpostsnum);
                         } else {
                             $logs = array();
                             $ratelog = C::t('forum_ratelog')->fetch_all_by_pid($pids);
                             $rposts = C::t('forum_post')->fetch_all('tid:' . $_G['tid'], $pids, false);
                             foreach (C::t('forum_ratelog')->fetch_all_by_pid($pids) as $rpid => $author) {
                                 if ($author['score'] > 0) {
                                     $rpost = $rposts[$rpid];
                                     updatemembercount($rpost['authorid'], array($author['extcredits'] => -$author['score']));
                                     $author['score'] = $_G['setting']['extcredits'][$id]['title'] . ' ' . -$author['score'] . ' ' . $_G['setting']['extcredits'][$id]['unit'];
                                     $logs[] = dhtmlspecialchars("{$_G['timestamp']}\t{$_G[member][username]}\t{$_G['adminid']}\t{$rpost['author']}\t{$author['extcredits']}\t{$author['score']}\t{$thread['tid']}\t{$thread['subject']}\t{$delpostsubmit}");
                                 }
                             }
                             if (!empty($logs)) {
                                 writelog('ratelog', $logs);
                                 unset($logs);
                             }
                             deletepost($pids, 'pid', true);
                         }
                         if ($_GET['crimerecord']) {
                             include_once libfile('function/member');
                             foreach ($posts as $post) {
                                 crime('recordaction', $post['authorid'], 'crime_delpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $post['tid'], 'pid' => $post['pid'])));
                             }
                         }
                     }
                     updatethreadcount($_G['tid'], 1);
                     updateforumcount($_G['fid']);
                     $_G['forum']['threadcaches'] && deletethreadcaches($thread['tid']);
                     $modaction = 'DLP';
                     $resultarray = array('redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page={$_GET['page']}", 'reasonpm' => $sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_delete_post', 'notictype' => 'post') : array(), 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason), 'modtids' => 0, 'modlog' => $thread);
                 }
             }
         }
     }
     // 在DISCUZ_ROOT/source/module/forum/forum_topicadmin.php基础上进行二次开发
     if ($resultarray) {
         if ($resultarray['modtids']) {
             updatemodlog($resultarray['modtids'], $modaction, $resultarray['expiration']);
         }
         updatemodworks($modaction, $modpostsnum);
         if (is_array($resultarray['modlog'])) {
             if (isset($resultarray['modlog']['tid'])) {
                 modlog($resultarray['modlog'], $modaction);
             } else {
                 foreach ($resultarray['modlog'] as $thread) {
                     modlog($thread, $modaction);
                 }
             }
         }
         if ($resultarray['reasonpm']) {
             $modactioncode = lang('forum/modaction');
             $modaction = $modactioncode[$modaction];
             foreach ($resultarray['reasonpm']['data'] as $var) {
                 sendreasonpm($var, $resultarray['reasonpm']['item'], $resultarray['reasonvar'], $resultarray['reasonpm']['notictype']);
             }
         }
         // showmessage((isset($resultarray['message']) ? $resultarray['message'] : 'admin_succeed'), $resultarray['redirect']);
         $this->getController()->redirect(WebUtils::createUrl_oldVersion('index/returnmobileview'));
     }
     $this->getController()->renderPartial('topicAdmin', array('formUrl' => WebUtils::createUrl_oldVersion('forum/topicadminview', array('fid' => $fid, 'tid' => $tid, 'pid' => $pid, 'act' => $act, 'type' => $type)), 'errorMsg' => $errorMsg, 'action' => $act, '_G' => $_G, 'stickcheck' => $stickcheck, 'digestcheck' => $digestcheck, 'closecheck' => $closecheck, 'forumselect' => WebUtils::u($forumselect)));
 }
Ejemplo n.º 18
0
         if ($recyclebins[$post['fid']]) {
             $recyclebinpids[] = $post['pid'];
         } else {
             $pids[] = $post['pid'];
         }
         $pm = 'pm_' . $post['pid'];
         if (isset($_G['gp_' . $pm]) && $_G['gp_' . $pm] != '' && $post['authorid']) {
             $pmlist[] = array('action' => 'modreplies_delete', 'notevar' => array('pid' => $post['pid'], 'post' => dhtmlspecialchars(cutstr($post['message'], 30)), 'reason' => dhtmlspecialchars($_G['gp_' . $pm])), 'authorid' => $post['authorid']);
         }
     }
     if ($recyclebinpids) {
         DB::query("UPDATE " . DB::table(getposttable($posttable)) . " SET invisible='-5' WHERE pid IN (" . dimplode($recyclebinpids) . ")");
     }
     if ($pids) {
         require_once libfile('function/delete');
         $deletes = deletepost($pids, 'pid', false, $posttable);
     }
     $deletes += count($recyclebinpids);
     updatemodworks('DLP', count($moderation['delete']));
     updatemoderate('pid', $moderation['delete'], 2);
 }
 if ($validatepids = dimplode($moderation['validate'])) {
     require_once libfile('function/forum');
     $forums = $threads = $lastpost = $attachments = $pidarray = $authoridarray = array();
     $query = DB::query("SELECT t.lastpost, p.pid, p.fid, p.tid, p.authorid, p.author, p.dateline, p.attachment, p.message, p.anonymous, p.status\n\t\t\tFROM " . DB::table(getposttable($posttable)) . " p LEFT JOIN " . DB::table('forum_thread') . " t ON t.tid=p.tid\n\t\t\tWHERE pid IN ({$validatepids})  AND first='0'");
     while ($post = DB::fetch($query)) {
         $pidarray[] = $post['pid'];
         my_post_log('validate', array('pid' => $post['pid']));
         if (getstatus($post['status'], 3) == 0) {
             updatepostcredits('+', $post['authorid'], 'reply', $post['fid']);
             $attachcount = DB::result_first("SELECT COUNT(*) FROM " . DB::table(getattachtablebytid($post['tid'])) . " WHERE pid='{$post['pid']}'");
Ejemplo n.º 19
0
 require_once libfile('function/post');
 $tids = array();
 $query = DB::query("SELECT tid FROM " . DB::table('forum_thread') . " WHERE fid='{$fid}' LIMIT {$pp}");
 while ($thread = DB::fetch($query)) {
     $tids[] = $thread['tid'];
 }
 $tids = implode(',', $tids);
 if ($tids) {
     $query = DB::query("SELECT attachment, thumb, remote, aid FROM " . DB::table('forum_attachment') . " WHERE tid IN ({$tids})");
     while ($attach = DB::fetch($query)) {
         dunlink($attach);
     }
     require_once libfile('function/delete');
     foreach (array('forum_thread', 'forum_threadmod', 'forum_relatedthread', 'forum_post', 'forum_poll', 'forum_polloption', 'forum_trade', 'forum_activity', 'forum_activityapply', 'forum_debate', 'forum_debatepost', 'forum_attachment', 'forum_typeoptionvar', 'forum_forumrecommend', 'forum_postposition') as $value) {
         if ($value == 'forum_post') {
             deletepost("tid IN ({$tids})", true);
             continue;
         }
         DB::query("DELETE FROM " . DB::table($value) . " WHERE tid IN ({$tids})", 'UNBUFFERED');
         if ($value == 'attachments') {
             DB::query("DELETE FROM " . DB::table('forum_attachmentfield') . " WHERE tid IN ({$tids})", 'UNBUFFERED');
         }
     }
 }
 if ($currow + $pp > $total) {
     my_thread_log('delforum', array('fid' => $fid));
     DB::query("DELETE FROM " . DB::table('forum_forum') . " WHERE fid='{$fid}'");
     DB::query("DELETE FROM " . DB::table('forum_forumfield') . " WHERE fid='{$fid}'");
     DB::query("DELETE FROM " . DB::table('forum_moderator') . " WHERE fid='{$fid}'");
     DB::query("DELETE FROM " . DB::table('forum_access') . " WHERE fid='{$fid}'");
     echo 'TRUE';
Ejemplo n.º 20
0
        } else {
            $logs = array();
            $ratelog = C::t('forum_ratelog')->fetch_all_by_pid($pids);
            $rposts = C::t('forum_post')->fetch_all('tid:' . $_G['tid'], $pids, false);
            foreach (C::t('forum_ratelog')->fetch_all_by_pid($pids) as $rpid => $author) {
                if ($author['score'] > 0) {
                    $rpost = $rposts[$rpid];
                    updatemembercount($rpost['authorid'], array($author['extcredits'] => -$author['score']));
                    $author['score'] = $_G['setting']['extcredits'][$id]['title'] . ' ' . -$author['score'] . ' ' . $_G['setting']['extcredits'][$id]['unit'];
                    $logs[] = dhtmlspecialchars("{$_G['timestamp']}\t{$_G[member][username]}\t{$_G['adminid']}\t{$rpost['author']}\t{$author['extcredits']}\t{$author['score']}\t{$thread['tid']}\t{$thread['subject']}\t{$delpostsubmit}");
                }
            }
            if (!empty($logs)) {
                writelog('ratelog', $logs);
                unset($logs);
            }
            deletepost($pids, 'pid', true);
        }
        if ($_GET['crimerecord']) {
            include_once libfile('function/member');
            foreach ($posts as $post) {
                crime('recordaction', $post['authorid'], 'crime_delpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $post['tid'], 'pid' => $post['pid'])));
            }
        }
    }
    updatethreadcount($_G['tid'], 1);
    updateforumcount($_G['fid']);
    $_G['forum']['threadcaches'] && deletethreadcaches($thread['tid']);
    $modaction = 'DLP';
    $resultarray = array('redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page={$_GET['page']}", 'reasonpm' => $sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_delete_post') : array(), 'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason), 'modtids' => 0, 'modlog' => $thread);
}
Ejemplo n.º 21
0
function deletethread($tids, $membercount = false, $credit = false, $ponly = false)
{
    global $_G;
    if ($_G['setting']['plugins']['func'][HOOKTYPE]['deletethread']) {
        $_G['deletethreadtids'] =& $tids;
        $hookparam = func_get_args();
        hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'check'), 'deletethread');
    }
    if (!$tids) {
        return 0;
    }
    $count = count($tids);
    $arrtids = $tids;
    $tids = dimplode($tids);
    loadcache(array('threadtableids', 'posttableids'));
    $threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array();
    $posttableids = !empty($_G['cache']['posttableids']) ? $_G['cache']['posttableids'] : array('0');
    if (!in_array(0, $threadtableids)) {
        $threadtableids = array_merge(array(0), $threadtableids);
    }
    C::t('common_moderate')->delete($arrtids, 'tid');
    C::t('forum_threadclosed')->delete($arrtids);
    $cachefids = $atids = $fids = $postids = $threadtables = array();
    foreach ($threadtableids as $tableid) {
        foreach (C::t('forum_thread')->fetch_all_by_tid($arrtids, 0, 0, $tableid) as $row) {
            $atids[] = $row['tid'];
            $row['posttableid'] = !empty($row['posttableid']) && in_array($row['posttableid'], $posttableids) ? $row['posttableid'] : '0';
            $postids[$row['posttableid']][$row['tid']] = $row['tid'];
            if ($tableid) {
                $fids[$row['fid']][] = $tableid;
            }
            $cachefids[$row['fid']] = $row['fid'];
        }
        if (!$tableid && !$ponly) {
            $threadtables[] = $tableid;
        }
    }
    if ($credit || $membercount) {
        $losslessdel = $_G['setting']['losslessdel'] > 0 ? TIMESTAMP - $_G['setting']['losslessdel'] * 86400 : 0;
        $postlist = $uidarray = $tuidarray = $ruidarray = array();
        foreach ($postids as $posttableid => $posttabletids) {
            foreach (C::t('forum_post')->fetch_all_by_tid($posttableid, $posttabletids, false) as $post) {
                if ($post['invisible'] != -1 && $post['invisible'] != -5) {
                    $postlist[] = $post;
                }
            }
        }
        foreach (C::t('forum_replycredit')->fetch_all($arrtids) as $rule) {
            $rule['extcreditstype'] = $rule['extcreditstype'] ? $rule['extcreditstype'] : $_G['setting']['creditstransextra'][10];
            $replycredit_rule[$rule['tid']] = $rule;
        }
        foreach ($postlist as $post) {
            if ($post['dateline'] < $losslessdel) {
                if ($membercount) {
                    if ($post['first']) {
                        updatemembercount($post['authorid'], array('threads' => -1, 'post' => -1), false);
                    } else {
                        updatemembercount($post['authorid'], array('posts' => -1), false);
                    }
                }
            } else {
                if ($credit) {
                    if ($post['first']) {
                        $tuidarray[$post['fid']][] = $post['authorid'];
                    } else {
                        $ruidarray[$post['fid']][] = $post['authorid'];
                    }
                }
            }
            if ($credit || $membercount) {
                if ($post['authorid'] > 0 && $post['replycredit'] > 0) {
                    if ($replycredit_rule[$post['tid']]['extcreditstype']) {
                        updatemembercount($post['authorid'], array($replycredit_rule[$post['tid']]['extcreditstype'] => (int) ('-' . $post['replycredit'])));
                    }
                }
            }
        }
        if ($credit) {
            if ($tuidarray || $ruidarray) {
                require_once libfile('function/post');
            }
            if ($tuidarray) {
                foreach ($tuidarray as $fid => $tuids) {
                    updatepostcredits('-', $tuids, 'post', $fid);
                }
            }
            if ($ruidarray) {
                foreach ($ruidarray as $fid => $ruids) {
                    updatepostcredits('-', $ruids, 'reply', $fid);
                }
            }
            $auidarray = $attachtables = array();
            foreach ($atids as $tid) {
                $attachtables[getattachtableid($tid)][] = $tid;
            }
            foreach ($attachtables as $attachtable => $attachtids) {
                foreach (C::t('forum_attachment_n')->fetch_all_by_id($attachtable, 'tid', $attachtids) as $attach) {
                    if ($attach['dateline'] > $losslessdel) {
                        $auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1;
                    }
                }
            }
            if ($auidarray) {
                $postattachcredits = !empty($_G['forum']['postattachcredits']) ? $_G['forum']['postattachcredits'] : $_G['setting']['creditspolicy']['postattach'];
                updateattachcredits('-', $auidarray, $postattachcredits);
            }
        }
    }
    $relatecollection = C::t('forum_collectionthread')->fetch_all_by_tids($arrtids);
    if (count($relatecollection) > 0) {
        $collectionids = array();
        foreach ($relatecollection as $collection) {
            $collectionids[] = $collection['ctid'];
        }
        $collectioninfo = C::t('forum_collection')->fetch_all($collectionids);
        foreach ($relatecollection as $collection) {
            $decthread = C::t('forum_collectionthread')->delete_by_ctid_tid($collection['ctid'], $arrtids);
            $lastpost = null;
            if (in_array($collectioninfo[$collection['ctid']]['lastpost'], $arrtids) && $collectioninfo[$collection['ctid']]['threadnum'] - $decthread > 0) {
                $collection_thread = C::t('forum_collectionthread')->fetch_by_ctid_dateline($collection['ctid']);
                if ($collection_thread) {
                    $thread = C::t('forum_thread')->fetch($collection_thread['tid']);
                    $lastpost = array('lastpost' => $thread['tid'], 'lastsubject' => $thread['subject'], 'lastposttime' => $thread['dateline'], 'lastposter' => $thread['authorid']);
                }
            }
            C::t('forum_collection')->update_by_ctid($collection['ctid'], -$decthread, 0, 0, 0, 0, 0, $lastpost);
        }
        C::t('forum_collectionrelated')->delete($arrtids);
    }
    if ($cachefids) {
        C::t('forum_thread')->clear_cache($cachefids, 'forumdisplay_');
    }
    if ($ponly) {
        if ($_G['setting']['plugins']['func'][HOOKTYPE]['deletethread']) {
            hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread');
        }
        C::t('forum_thread')->update($arrtids, array('displayorder' => -1, 'digest' => 0, 'moderated' => 1));
        foreach ($postids as $posttableid => $oneposttids) {
            C::t('forum_post')->update_by_tid($posttableid, $oneposttids, array('invisible' => '-1'));
        }
        return $count;
    }
    C::t('forum_replycredit')->delete($arrtids);
    C::t('forum_post_location')->delete_by_tid($arrtids);
    C::t('common_credit_log')->delete_by_operation_relatedid(array('RCT', 'RCA', 'RCB'), $arrtids);
    deletethreadcover($arrtids);
    foreach ($threadtables as $tableid) {
        C::t('forum_thread')->delete_by_tid($arrtids, false, $tableid);
    }
    if ($atids) {
        foreach ($postids as $posttableid => $oneposttids) {
            deletepost($oneposttids, 'tid', false, $posttableid);
        }
        deleteattach($atids, 'tid');
    }
    if ($fids) {
        loadcache('forums');
        foreach ($fids as $fid => $tableids) {
            if (empty($_G['cache']['forums'][$fid]['archive'])) {
                continue;
            }
            foreach (C::t('forum_thread')->count_posts_by_fid($fid) as $row) {
                C::t('forum_forum_threadtable')->insert(array('fid' => $fid, 'threadtableid' => $tableid, 'threads' => $row['threads'], 'posts' => $row['posts']), false, true);
            }
        }
    }
    foreach (array('forum_forumrecommend', 'forum_polloption', 'forum_poll', 'forum_activity', 'forum_activityapply', 'forum_debate', 'forum_debatepost', 'forum_threadmod', 'forum_relatedthread', 'forum_pollvoter', 'forum_threadimage', 'forum_threadpreview') as $table) {
        C::t($table)->delete_by_tid($arrtids);
    }
    C::t('forum_typeoptionvar')->delete_by_tid($arrtids);
    C::t('forum_poststick')->delete_by_tid($arrtids);
    C::t('home_feed')->delete_by_id_idtype($arrtids, 'tid');
    C::t('common_tagitem')->delete(0, $tids, 'tid');
    C::t('forum_threadrush')->delete($arrtids);
    if ($_G['setting']['plugins']['func'][HOOKTYPE]['deletethread']) {
        hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread');
    }
    return $count;
}
Ejemplo n.º 22
0
         foreach ($postarray as $post) {
             if ($post['first']) {
                 $tuidarray[] = $post['authorid'];
             } else {
                 $ruidarray[] = $post['authorid'];
             }
         }
         if ($tuidarray) {
             updatepostcredits('-', $tuidarray, 'post');
         }
         if ($ruidarray) {
             updatepostcredits('-', $ruidarray, 'reply');
         }
     }
     require_once libfile('function/delete');
     deletepost($tidsadd);
     deletethread($tidsadd);
     if ($_G['setting']['globalstick']) {
         updatecache('globalstick');
     }
     foreach (explode(',', $_G['gp_fids']) as $fid) {
         updateforumcount(intval($fid));
     }
     foreach ($_G['gp_tidarray'] as $tid) {
         my_thread_log('delete', array('tid' => $tid));
     }
     $cpmsg = cplang('threads_succeed');
 } elseif ($operation == 'deleteattach') {
     $query = DB::query("SELECT attachment, thumb, remote, aid FROM " . DB::table('forum_attachment') . " WHERE {$tidsadd}");
     while ($attach = DB::fetch($query)) {
         dunlink($attach);
Ejemplo n.º 23
0
         }
         if ($modforums['recyclebins'][$post['fid']]) {
             $recyclebinpids[] = $post['pid'];
         } else {
             $pids[] = $post['pid'];
         }
         if ($post['authorid'] && $post['authorid'] != $_G['uid']) {
             $pmlist[] = array('act' => 'modreplies_delete', 'notevar' => array('reason' => dhtmlspecialchars($_GET['reason']), 'post' => messagecutstr($post['message'], 30)), 'authorid' => $post['authorid']);
         }
     }
     if ($recyclebinpids) {
         C::t('forum_post')->update($posttableid, $recyclebinpids, array('invisible' => '-5'), true);
     }
     if ($pids) {
         require_once libfile('function/delete');
         deletepost($pids, 'pid', false, $posttableid);
     }
     updatemodworks('DLP', count($moderation['delete']));
     updatemoderate('pid', $moderation['delete'], 2);
 }
 $repliesmod = 0;
 if ($validatepids = dimplode($moderation['validate'])) {
     $threads = $lastpost = $attachments = $pidarray = array();
     $postlist = $tids = array();
     foreach (C::t('forum_post')->fetch_all($posttableid, $moderation['validate']) as $post) {
         if ($post['invisible'] != $pstat || $post['first'] != '0' || ($modfids ? !in_array($post['fid'], explode(',', $modfids)) : 0)) {
             continue;
         }
         $tids[$post['tid']] = $post['tid'];
         $postlist[] = $post;
     }
Ejemplo n.º 24
0
 $prune = array('forums' => array(), 'thread' => array());
 if ($pids = dimplode($_G['gp_delete'])) {
     $query = DB::query('SELECT fid, tid, pid, first, authorid FROM ' . DB::table(getposttable($posttableid)) . ' WHERE ' . "pid IN ({$pids}) {$fidadd}");
     while ($post = DB::fetch($query)) {
         $prune['forums'][] = $post['fid'];
         @$prune['thread'][$post['tid']]++;
         $pidsdelete[$post['pid']] = $post['pid'];
         if ($post['first']) {
             $tidsdelete[$post['tid']] = $post['tid'];
         }
     }
 }
 if ($pidsdelete) {
     require_once libfile('function/post');
     require_once libfile('function/delete');
     $deletedposts = deletepost($pidsdelete, 'pid', !getgpc('nocredit'), $posttableid);
     $deletedthreads = deletethread($tidsdelete, !getgpc('nocredit'));
     if (count($prune['thread']) < 50) {
         foreach ($prune['thread'] as $tid => $decrease) {
             updatethreadcount($tid);
         }
     } else {
         $repliesarray = array();
         foreach ($prune['thread'] as $tid => $decrease) {
             $repliesarray[$decrease][] = $tid;
         }
         foreach ($repliesarray as $decrease => $tidarray) {
             DB::query("UPDATE " . DB::table('forum_thread') . " SET replies=replies-'{$decrease}' WHERE tid IN (" . implode(',', $tidarray) . ")");
         }
     }
     foreach (array_unique($prune['forums']) as $id) {
Ejemplo n.º 25
0
 $tids = $nums = array();
 $pp = 100;
 $start = intval($_GET['start']);
 $query = C::t('forum_forum')->fetch_all_info_by_fids($fidarray);
 foreach ($query as $fup) {
     $nums[$fup['fup']]++;
 }
 foreach ($nums as $fup => $num) {
     C::t('forum_forumfield')->update_groupnum($fup, -$num);
 }
 foreach (C::t('forum_thread')->fetch_all_by_fid($fidarray, $start, $pp) as $thread) {
     $tids[] = $thread['tid'];
 }
 require_once libfile('function/delete');
 if ($tids) {
     deletepost($tids, 'tid');
     deletethread($tids);
     cpmsg('group_thread_removing', 'action=group&operation=manage&mtype=managetype&optype=delete&submit=yes&confirmed=yes&fidarray=' . $_GET['fidarray'] . '&start=' . ($start + $pp));
 }
 loadcache('posttable_info');
 if (!empty($_G['cache']['posttable_info']) && is_array($_G['cache']['posttable_info'])) {
     foreach ($_G['cache']['posttable_info'] as $key => $value) {
         C::t('forum_post')->delete_by_fid($key, $fidarray, true);
     }
 }
 loadcache('threadtableids');
 $threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array('0');
 foreach ($threadtableids as $tableid) {
     C::t('forum_thread')->delete_by_fid($fidarray, true, $tableid);
 }
 C::t('forum_forumrecommend')->delete_by_fid($fidarray);
Ejemplo n.º 26
0
function deletethread($tids, $membercount = false, $credit = false, $ponly = false)
{
    global $_G;
    if ($_G['setting']['plugins'][HOOKTYPE . '_deletethread']) {
        $_G['deletethreadtids'] =& $tids;
        $hookparam = func_get_args();
        hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'check'), 'deletethread');
    }
    if (!$tids) {
        return 0;
    }
    require_once libfile('function/forum');
    foreach ($tids as $tid) {
        my_post_log('delete', array('tid' => $tid));
    }
    $count = count($tids);
    $tids = dimplode($tids);
    loadcache(array('threadtableids', 'posttableids'));
    $threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array();
    $posttableids = !empty($_G['cache']['posttableids']) ? $_G['cache']['posttableids'] : array('0');
    if (!in_array(0, $threadtableids)) {
        $threadtableids = array_merge(array(0), $threadtableids);
    }
    DB::delete('common_moderate', "id IN ({$tids}) AND idtype='tid'");
    $atids = $fids = $postids = $threadtables = array();
    foreach ($threadtableids as $tableid) {
        $threadtable = !$tableid ? "forum_thread" : "forum_thread_{$tableid}";
        $query = DB::query("SELECT cover, tid, fid, posttableid FROM " . DB::table($threadtable) . " WHERE tid IN ({$tids})");
        while ($row = DB::fetch($query)) {
            $atids[] = $row['tid'];
            $row['posttableid'] = !empty($row['posttableid']) && in_array($row['posttableid'], $posttableids) ? $row['posttableid'] : '0';
            $postids[$row['posttableid']][$row['tid']] = $row['tid'];
            if ($tableid) {
                $fids[$row['fid']][] = $tableid;
            }
        }
        if (!$tableid && !$ponly) {
            $threadtables[] = $threadtable;
        }
    }
    if ($credit || $membercount) {
        $losslessdel = $_G['setting']['losslessdel'] > 0 ? TIMESTAMP - $_G['setting']['losslessdel'] * 86400 : 0;
        $postlist = $uidarray = $tuidarray = $ruidarray = array();
        foreach ($postids as $posttableid => $posttabletids) {
            $query = DB::query('SELECT tid, first, authorid, dateline, replycredit, invisible FROM ' . DB::table(getposttable($posttableid)) . ' WHERE tid IN (' . dimplode($posttabletids) . ')');
            while ($post = DB::fetch($query)) {
                if ($post['invisible'] != -1 && $post['invisible'] != -5) {
                    $postlist[] = $post;
                }
            }
        }
        $query = DB::query("SELECT tid, extcreditstype FROM " . DB::table('forum_replycredit') . " WHERE tid IN ({$tids})");
        while ($rule = DB::fetch($query)) {
            $rule['extcreditstype'] = $rule['extcreditstype'] ? $rule['extcreditstype'] : $_G['setting']['creditstransextra'][10];
            $replycredit_rule[$rule['tid']] = $rule;
        }
        foreach ($postlist as $post) {
            if ($post['dateline'] < $losslessdel) {
                if ($membercount) {
                    if ($post['first']) {
                        updatemembercount($post['authorid'], array('threads' => -1, 'post' => -1), false);
                    } else {
                        updatemembercount($post['authorid'], array('posts' => -1), false);
                    }
                }
            } else {
                if ($credit) {
                    if ($post['first']) {
                        $tuidarray[] = $post['authorid'];
                    } else {
                        $ruidarray[] = $post['authorid'];
                    }
                }
            }
            if ($credit || $membercount) {
                if ($post['authorid'] > 0 && $post['replycredit'] > 0) {
                    if ($replycredit_rule[$post['tid']]['extcreditstype']) {
                        updatemembercount($post['authorid'], array($replycredit_rule[$post['tid']]['extcreditstype'] => (int) ('-' . $post['replycredit'])));
                    }
                }
            }
        }
        if ($credit) {
            if ($tuidarray || $ruidarray) {
                require_once libfile('function/post');
            }
            if ($tuidarray) {
                updatepostcredits('-', $tuidarray, 'post', $_G['forum']['fid']);
            }
            if ($ruidarray) {
                updatepostcredits('-', $ruidarray, 'reply', $_G['forum']['fid']);
            }
            $auidarray = $attachtables = array();
            foreach ($atids as $tid) {
                $attachtables[getattachtablebytid($tid)][] = $tid;
            }
            foreach ($attachtables as $attachtable => $attachtids) {
                $query = DB::query("SELECT uid, dateline FROM " . DB::table($attachtable) . " WHERE tid IN (" . dimplode($attachtids) . ")");
                while ($attach = DB::fetch($query)) {
                    if ($attach['dateline'] > $losslessdel) {
                        $auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1;
                    }
                }
            }
            if ($auidarray) {
                $postattachcredits = !empty($_G['forum']['postattachcredits']) ? $_G['forum']['postattachcredits'] : $_G['setting']['creditspolicy']['postattach'];
                updateattachcredits('-', $auidarray, $postattachcredits);
            }
        }
    }
    if ($ponly) {
        if ($_G['setting']['plugins'][HOOKTYPE . '_deletethread']) {
            hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread');
        }
        return $count;
    }
    DB::delete('forum_replycredit', "tid IN ({$tids})");
    DB::delete('common_credit_log', "operation IN ('RCT', 'RCA', 'RCB') AND relatedid IN ({$tids})");
    deletethreadcover($tids);
    foreach ($threadtables as $threadtable) {
        DB::delete($threadtable, "tid IN ({$tids})");
    }
    if ($atids) {
        foreach ($postids as $posttableid => $oneposttids) {
            deletepost($oneposttids, 'tid', false, $posttableid);
        }
        deleteattach($atids, 'tid');
    }
    if ($fids) {
        foreach ($fids as $fid => $tableids) {
            $tableids = array_unique($tableids);
            foreach ($tableids as $tableid) {
                $query = DB::query("SELECT COUNT(*) AS threads, SUM(replies)+COUNT(*) AS posts FROM " . DB::table("forum_thread_{$tableid}") . " WHERE fid='{$fid}'");
                while ($row = DB::fetch($query)) {
                    DB::insert('forum_forum_threadtable', array('fid' => $fid, 'threadtableid' => $tableid, 'threads' => intval($row['threads']), 'posts' => intval($row['posts'])), false, true);
                }
            }
        }
    }
    foreach (array('forum_forumrecommend', 'forum_polloption', 'forum_poll', 'forum_activity', 'forum_activityapply', 'forum_debate', 'forum_debatepost', 'forum_threadmod', 'forum_relatedthread', 'forum_typeoptionvar', 'forum_postposition', 'forum_poststick', 'forum_pollvoter', 'forum_threadimage') as $table) {
        DB::delete($table, "tid IN ({$tids})");
    }
    DB::query("DELETE FROM " . DB::table('home_feed') . " WHERE id IN ({$tids}) AND idtype='tid'", 'UNBUFFERED');
    DB::query("DELETE FROM " . DB::table('common_tagitem') . " WHERE idtype='tid' AND itemid IN ({$tids})", 'UNBUFFERED');
    DB::query("DELETE FROM " . DB::table('forum_threadrush') . " WHERE tid IN ({$tids})", 'UNBUFFERED');
    if ($_G['setting']['plugins'][HOOKTYPE . '_deletethread']) {
        hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread');
    }
    return $count;
}
Ejemplo n.º 27
0
session_start();
require_once "install.php";
/* REQUEST = $_POST $_GET */
if (!empty($_REQUEST['action'])) {
    $accion = $_REQUEST['action'];
    if ($accion == 'crear') {
        crearPost();
    } else {
        if ($accion == 'ver') {
            verpost();
        } else {
            if ($accion == 'update') {
                updatepost();
            } else {
                if ($accion == 'delete') {
                    deletepost();
                }
            }
        }
    }
}
function crearPost()
{
    /* Proteccion de Datos */
    $params = array(':Utc ' => $_POST['Utc'], ':Anio ' => $_POST['Anio'], ':Mes ' => $_POST['Mes'], ':Dia ' => $_POST['Dia'], ':Hora ' => $_POST['Hora'], ':Minuto ' => $_POST['Minuto'], ':Segundo ' => $_POST['Segundo'], ':Titulo ' => $_POST['Titulo'], ':SubTitulo ' => $_POST['SubTitulo'], ':Icono ' => $_POST['Icono'], ':Texto ' => $_POST['Texto'], ':Imagen ' => $_POST['Imagen']);
    /* Preparamos el query apartir del array $params*/
    $query = 'INSERT INTO Post 
					(Utc,Anio,Mes,Dia,Hora,Minuto,Segundo,Titulo,SubTitulo,Icono,Texto,Imagen) 
				VALUES 
					(:Utc,:Anio,:Mes,:Dia,:Hora,:Minuto,:Segundo,:Titulo,:SubTitulo,:Icono,:Texto,:Imagen)';
    /* Ejecutamos el query con los parametros */
Ejemplo n.º 28
0
     DB::query("DELETE FROM " . DB::table('home_feed') . " WHERE id IN ({$moderatetids}) AND idtype='tid'");
 } else {
     $auidarray = array();
     $query = DB::query("SELECT uid, attachment, dateline, thumb, remote, aid FROM " . DB::table('forum_attachment') . " WHERE tid IN ({$moderatetids})");
     while ($attach = DB::fetch($query)) {
         dunlink($attach);
         if ($attach['dateline'] > $_G['setting']['losslessdel']) {
             $auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1;
         }
     }
     if ($auidarray) {
         updateattachcredits('-', $auidarray, $postattachcredits);
     }
     loadcache('threadtableids');
     require_once libfile('function/delete');
     deletepost("tid IN ({$moderatetids})");
     deletethread("tid IN ({$moderatetids})");
     $threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array();
     foreach ($threadtableids as $tableid) {
         if ($tableid) {
             DB::delete("forum_thread_{$tableid}", "tid IN ({$moderatetids})");
             $query = DB::query("SELECT COUNT(*) AS threads, SUM(replies)+COUNT(*) AS posts FROM " . DB::table("forum_thread_{$tableid}") . " WHERE fid='{$_G['fid']}'");
             while ($row = DB::fetch($query)) {
                 DB::insert('forum_forum_threadtable', array('fid' => $_G['fid'], 'threadtableid' => $tableid, 'threads' => intval($row['threads']), 'posts' => intval($row['posts'])), false, true);
             }
         }
     }
     $updatemodlog = FALSE;
 }
 $forumstickthreads = $_G['setting']['forumstickthreads'];
 $forumstickthreads = !empty($forumstickthreads) ? unserialize($forumstickthreads) : array();