Beispiel #1
0
 function delReply($replydb, $recycle = false, $delCredit = true, $recount = false, $extra = array())
 {
     global $credit, $windid, $timestamp, $onlineip, $db_creditset;
     !$credit && (require_once R_P . 'require/credit.php');
     $tids = $pids = $_tids = $_pids = $ptable_a = $recycledb = $delfids = $deltids = $deluids = $attachdb = $deltpc = array();
     foreach ($replydb as $key => $reply) {
         $tids[$reply['tid']] = 1;
         if ($reply['pid'] == 'tpc') {
             $reply['pid'] = 0;
         }
         if ($recycle) {
             $recycledb[] = array('pid' => $reply['pid'], 'tid' => $reply['tid'], 'fid' => $reply['fid'], 'deltime' => $timestamp, 'admin' => $windid);
         }
         if ($reply['pid'] > 0) {
             /*回复*/
             $isInRecycle = $reply['fid'] == 0 && $reply['tid'] == 0;
             if ($reply['aid']) {
                 $_tids[$reply['tid']] = $reply['tid'];
                 $_pids[$reply['pid']] = $reply['pid'];
             }
             if (!$isInRecycle) {
                 $deluids[$reply['authorid']]++;
                 if ($reply['ifcheck']) {
                     $delfids[$reply['fid']]['replies']++;
                     $deltids[$reply['tid']]++;
                 }
             }
             $ptable_a[$reply['ptable']] = 1;
             $pids[] = $reply['pid'];
             $creditType = 'Deleterp';
             $logType = 'delrp_descrip';
         } else {
             /* 主题 */
             $isInRecycle = $reply['fid'] == 0 && $reply['ifcheck'] == 1;
             !$isInRecycle && $deluids[$reply['authorid']]++;
             $deltpc[] = $reply['tid'];
             $creditType = 'Delete';
             $logType = 'del_descrip';
         }
         $msg_delrvrc = $msg_delmoney = 0;
         if ($delCredit && !$isInRecycle) {
             $creditset = $this->getcreditset($reply['fid']);
             $credit->addLog("topic_{$creditType}", $creditset[$creditType], array('uid' => $reply['authorid'], 'username' => $reply['author'], 'ip' => $onlineip, 'fname' => strip_tags($this->getForumInfo($reply['fid'], 'name')), 'operator' => $windid));
             $credit->sets($reply['authorid'], $creditset[$creditType], false);
             $msg_delrvrc = abs($creditset[$creditType]['rvrc']);
             $msg_delmoney = abs($creditset[$creditType]['money']);
         }
         /*操作日志 */
         $logdb[] = array('type' => 'delete', 'username1' => $reply['author'], 'username2' => $windid, 'field1' => $reply['fid'], 'field2' => '', 'field3' => '', 'descrip' => $logType, 'timestamp' => $timestamp, 'ip' => $onlineip, 'tid' => $reply['tid'], 'subject' => substrs($reply['subject'] ? $reply['subject'] : $reply['content'], 28), 'affect' => "{$GLOBALS[db_rvrcname]}:-{$msg_delrvrc},{$GLOBALS[db_moneyname]}:-{$msg_delmoney}", 'reason' => $extra['reason']);
     }
     if (!$tids) {
         return true;
     }
     require_once R_P . 'require/updateforum.php';
     $delpids = S::sqlImplode($pids);
     if ($recycle) {
         foreach ($ptable_a as $key => $val) {
             $pw_posts = GetPtable($key);
             //$this->db->update("UPDATE $pw_posts SET tid='0',fid='0' WHERE pid IN($delpids)");
             pwQuery::update($pw_posts, 'pid IN(:pid)', array($pids), array('tid' => '0', 'fid' => '0'));
         }
         if ($recycledb) {
             $this->db->update("REPLACE INTO pw_recycle (pid,tid,fid,deltime,admin) VALUES " . S::sqlMulti($recycledb));
         }
     } else {
         foreach ($ptable_a as $key => $val) {
             $pw_posts = GetPtable($key);
             //$this->db->update("DELETE FROM $pw_posts WHERE pid IN($delpids)");
             pwQuery::delete($pw_posts, 'pid IN(:pid)', array($pids));
         }
     }
     if ($delpids) {
         $this->resetReplayToppedFloor($replydb, '', '', $extra['tpcstatus']);
     }
     /*前台删主题,默认将其设为屏蔽*/
     if ($deltpc) {
         //$this->db->update("UPDATE pw_threads SET ifshield='2' WHERE tid IN (" . S::sqlImplode($deltpc) . ')');
         pwQuery::update('pw_threads', 'tid IN (:tid)', array($deltpc), array('ifshield' => 2));
         $pw_attachs = L::loadDB('attachs', 'forum');
         $attachdb += $pw_attachs->getByTid($deltpc, 0);
         !$recycle && delete_tag(S::sqlImplode($deltpc));
         /* 删除微博 */
         $weiboService = L::loadClass('weibo', 'sns');
         /* @var $weiboService PW_Weibo */
         $weibos = $weiboService->getWeibosByObjectIdsAndType($deltpc, 'article');
         if ($weibos) {
             $mids = array();
             foreach ($weibos as $key => $weibo) {
                 $mids[] = $weibo['mid'];
             }
             $weiboService->deleteWeibos($mids);
         }
     }
     if ($_tids) {
         $pw_attachs = L::loadDB('attachs', 'forum');
         $attachdb += $pw_attachs->getByTid($_tids, $_pids);
     }
     if ($attachdb) {
         delete_att($attachdb, !$recycle);
         require_once R_P . 'require/functions.php';
         pwFtpClose($GLOBALS['ftp']);
     }
     $userService = L::loadClass('UserService', 'user');
     /* @var $userService PW_UserService */
     foreach ($deluids as $uid => $value) {
         $userService->updateByIncrement($uid, array(), array('postnum' => -$value));
     }
     if ($deltopic = $this->delReplyTopic(array_keys($tids), $deltpc, $recount, $recycle)) {
         foreach ($deltopic as $fid => $value) {
             $delfids[$fid]['topic'] = $value;
         }
     }
     if ($delfids) {
         //* $threadlist = L::loadClass("threadlist", 'forum');
         foreach ($delfids as $fid => $value) {
             //* $threadlist->refreshThreadIdsByForumId($fid);
             Perf::gatherInfo('changeThreadWithForumIds', array('fid' => $fid));
             updateForumCount($fid, -$value['topic'], -$value['replies']);
         }
     }
     if ($deltids && !$recount) {
         foreach ($deltids as $tid => $value) {
             //$this->db->update("UPDATE pw_threads SET replies=replies-" . S::sqlEscape($value) . " WHERE tid=" . S::sqlEscape($tid));
             $this->db->update(pwQuery::buildClause("UPDATE :pw_table SET replies=replies-:replies WHERE tid=:tid", array('pw_threads', $value, $tid)));
         }
     }
     /*写操作日志 */
     require_once R_P . 'require/writelog.php';
     foreach ($logdb as $log) {
         writelog($log);
     }
     /*扣除积分*/
     $credit->runsql();
     return !empty($deltopic);
 }
Beispiel #2
0
 function _mergeThreads(&$tmp, $toid, $fromid, $cydb)
 {
     if ($cydb[$toid]['classid'] == $cydb[$fromid]['classid']) {
         //$this->_db->update("UPDATE pw_argument a LEFT JOIN pw_threads b ON a.tid=b.tid SET a.cyid=" . S::sqlEscape($toid) . " WHERE a.cyid=" . S::sqlEscape($fromid));
         $this->_db->update(pwQuery::buildClause("UPDATE :pw_table1 a LEFT JOIN :pw_table2 b ON a.tid=b.tid SET a.cyid=:cyidx WHERE a.cyid=:cyid", array('pw_argument', 'pw_threads', $toid, $fromid)));
         $tmp['tnum'] = $this->_db->affected_rows();
         $tmp['pnum'] = $cydb[$fromid]['pnum'];
     } else {
         global $db_plist;
         $ptable_a = array('pw_posts');
         if ($db_plist) {
             foreach ($db_plist as $key => $val) {
                 $key > 0 && ($ptable_a[] = 'pw_posts' . $key);
             }
         }
         $pnum = 0;
         foreach ($ptable_a as $val) {
             $this->_db->update("UPDATE pw_argument a LEFT JOIN {$val} b ON a.tid=b.tid SET b.fid=" . S::sqlEscape($cydb[$toid]['classid']) . " WHERE a.cyid=" . S::sqlEscape($fromid));
             $pnum += $this->_db->affected_rows();
         }
         $this->_db->update("UPDATE pw_argument a LEFT JOIN pw_attachs b ON a.tid=b.tid SET b.fid=" . S::sqlEscape($cydb[$toid]['classid']) . " WHERE a.cyid=" . S::sqlEscape($fromid));
         //$this->_db->update("UPDATE pw_argument a LEFT JOIN pw_threads b ON a.tid=b.tid SET a.cyid=" . S::sqlEscape($toid) . ",b.fid=" . S::sqlEscape($cydb[$toid]['classid']) . " WHERE a.cyid=" . S::sqlEscape($fromid));
         $this->_db->update(pwQuery::buildClause("UPDATE :pw_table1 a LEFT JOIN :pw_table2 b ON a.tid=b.tid SET a.cyid=:cyidx, b.fid=:bid WHERE a.cyid=:cyid", array('pw_argument', 'pw_threads', $toid, $cydb[$toid]['classid'], $fromid)));
         $tnum = $this->_db->affected_rows();
         $tmp['tnum'] = $tnum;
         $tmp['pnum'] = $pnum + $tnum;
         require_once R_P . 'require/updateforum.php';
         updateForumCount($cydb[$toid]['classid'], $tnum, $pnum);
         updateForumCount($cydb[$fromid]['classid'], -$tnum, -$pnum);
     }
 }
Beispiel #3
0
     //* $val = S::sqlImplode($val);
     //* $db->update("UPDATE $pw_tmsgs SET remindinfo=" . S::sqlEscape($remindinfo) . " WHERE tid IN($val)");
     pwQuery::update($pw_tmsgs, 'tid IN (:tid)', array($val), array('remindinfo' => $remindinfo));
 }
 foreach ($ptable_a as $key => $val) {
     $pw_posts = GetPtable($key);
     //$db->update("UPDATE $pw_posts SET fid=" . S::sqlEscape($to_id) . " WHERE tid IN(" . S::sqlImplode($mids) . ")");
     pwQuery::update($pw_posts, 'tid IN(:tid)', array($mids), array('fid' => $to_id));
 }
 //tucool
 foreach ($mids as $tid) {
     $tucoolService->updateTucoolImageNum($tid);
 }
 //end tucool
 updateForumCount($fid, -$topic_all, -$replies_all, -$todaypost);
 updateForumCount($to_id, $topic_all, $replies_all, $todaypost);
 // $threadList = L::loadClass("threadlist", 'forum');
 // $threadList->refreshThreadIdsByForumId($fid);
 // $threadList->refreshThreadIdsByForumId($to_id);
 Perf::gatherInfo('changeThreadWithForumIds', array('fid' => array($fid, $to_id)));
 if (!empty($cy_tids)) {
     $db->update("DELETE FROM pw_argument WHERE tid IN(" . S::sqlImplode($cy_tids) . ')');
     pwQuery::update('pw_threads', 'tid IN (:tid)', array($cy_tids), array('tpcstatus' => 0));
 }
 if ($updatetop) {
     updatetop();
 }
 //* P_unlink(D_P . 'data/bbscache/c_cache.php');
 pwCache::deleteData(D_P . 'data/bbscache/c_cache.php');
 if (!defined('AJAX')) {
     refreshto("thread.php?fid={$fid}{$viewbbs}&search=all", 'operate_success');
Beispiel #4
0
 function delReply($replydb, $recount = true, $recycle = false)
 {
     $tids = $pids = $_tids = $_pids = $ptable_a = $recycledb = $delfids = $deltids = $deluids = $attachdb = $deltpc = array();
     foreach ($replydb as $key => $reply) {
         $tids[$reply['tid']] = 1;
         if ($reply['pid'] == 'tpc') {
             $reply['pid'] = 0;
         }
         if ($recycle) {
             $recycledb[] = array('pid' => $reply['pid'], 'tid' => $reply['tid'], 'fid' => $reply['fid'], 'deltime' => $GLOBALS['timestamp'], 'admin' => $GLOBALS['windid']);
         }
         if ($reply['pid'] > 0) {
             if ($reply['aid']) {
                 $_tids[$reply['tid']] = $reply['tid'];
                 $_pids[$reply['pid']] = $reply['pid'];
             }
             if ($reply['fid'] > 0) {
                 $deluids[$reply['authorid']]++;
                 if ($reply['ifcheck']) {
                     $delfids[$reply['fid']]['replies']++;
                     $deltids[$reply['tid']]++;
                 }
             }
             $ptable_a[$reply['ptable']] = 1;
             $pids[] = $reply['pid'];
         } else {
             $reply['fid'] > 0 && $reply['ifcheck'] && $deluids[$reply['authorid']]++;
             $deltpc[] = $reply['tid'];
         }
     }
     if (!$tids) {
         return true;
     }
     require_once R_P . 'require/updateforum.php';
     $delpids = pwImplode($pids);
     if ($recycle) {
         foreach ($ptable_a as $key => $val) {
             $pw_posts = GetPtable($key);
             $this->db->update("UPDATE {$pw_posts} SET tid='0',fid='0' WHERE pid IN({$delpids})");
         }
         if ($recycledb) {
             $this->db->update("REPLACE INTO pw_recycle (pid,tid,fid,deltime,admin) VALUES " . pwSqlMulti($recycledb));
         }
     } else {
         foreach ($ptable_a as $key => $val) {
             $pw_posts = GetPtable($key);
             $this->db->update("DELETE FROM {$pw_posts} WHERE pid IN({$delpids})");
         }
     }
     if ($delpids) {
         $this->resetReplayToppedFloor($replydb);
     }
     if ($deltpc) {
         $this->db->update("UPDATE pw_threads SET ifshield='2' WHERE tid IN (" . pwImplode($deltpc) . ')');
         $pw_attachs = L::loadDB('attachs');
         $attachdb += $pw_attachs->getByTid($deltpc, 0);
         !$recycle && delete_tag(pwImplode($deltpc));
     }
     if ($_tids) {
         $pw_attachs = L::loadDB('attachs');
         $attachdb += $pw_attachs->getByTid($_tids, $_pids);
     }
     if ($attachdb) {
         delete_att($attachdb, !$recycle);
         pwFtpClose($GLOBALS['ftp']);
     }
     foreach ($deluids as $uid => $value) {
         $this->db->update("UPDATE pw_memberdata SET postnum=postnum-" . pwEscape($value) . " WHERE uid=" . pwEscape($uid));
     }
     if ($deltopic = $this->delReplyTopic(array_keys($tids), $deltpc, $recount, $recycle)) {
         foreach ($deltopic as $fid => $value) {
             $delfids[$fid]['topic'] = $value;
         }
     }
     if ($delfids) {
         $threadlist = L::loadClass("threadlist");
         foreach ($delfids as $fid => $value) {
             $threadlist->refreshThreadIdsByForumId($fid);
             updateForumCount($fid, -$value['topic'], -$value['replies']);
         }
     }
     if ($deltids && !$recount) {
         foreach ($deltids as $tid => $value) {
             $this->db->update("UPDATE pw_threads SET replies=replies-" . pwEscape($value) . " WHERE tid=" . pwEscape($tid));
         }
     }
     return !empty($deltopic);
 }