Example #1
0
         $_pids = $_tids = array();
         $flag = false;
         !is_numeric($ptable) && ($ptable = $db_ptable);
         $pw_posts = GetPtable($ptable);
         $query = $db->query("SELECT * FROM pw_recycle WHERE fid=" . pwEscape($fid) . " AND pid>'0' LIMIT 100");
         while ($rt = $db->fetch_array($query)) {
             $flag || ($flag = true);
             $_pids[$rt['pid']] = $rt['pid'];
             $_tids[$rt['tid']] = $rt['tid'];
         }
         if ($flag) {
             if ($_pids) {
                 $pw_attachs = L::loadDB('attachs');
                 $attachdb = $pw_attachs->getByTid($_tids, $_pids);
                 require_once R_P . 'require/updateforum.php';
                 delete_att($attachdb);
                 pwFtpClose($ftp);
                 $_pids = pwImplode($_pids);
                 $db->update("DELETE FROM {$pw_posts} WHERE pid IN ({$_pids})");
                 $db->update("DELETE FROM pw_recycle WHERE pid IN ({$_pids})");
             }
             refreshto("forumcp.php?action=edit&type={$type}&fid={$fid}&step=3&ptable={$ptable}&verify={$verifyhash}", 'delete_recycle');
         } else {
             $logdb = array('type' => 'recycle', 'username1' => '', 'username2' => $windid, 'field1' => $fid, 'field2' => '', 'field3' => '', 'descrip' => 'recycle_reply_empty', 'timestamp' => $timestamp, 'ip' => $onlineip, 'affect' => '', 'forum' => $forum[$fid]['name'], 'reason' => '');
             writelog($logdb);
             refreshto("forumcp.php?action=edit&type=precycle&fid={$fid}", 'operate_success');
         }
     }
 } elseif ($type == 'msg') {
     $msgdb = array();
     $pages = '';
Example #2
0
 $pw_posts = GetPtable('N', $tid);
 $rt = $db->get_one("SELECT COUNT(*) AS count FROM {$pw_posts} WHERE tid=" . pwEscape($tid) . " AND ifcheck='1'");
 $count = $rt['count'] + 1;
 if ($article == 0 && !$admincheck && $count > 1) {
     Showmsg('modify_replied');
 }
 $rs = $db->get_one("SELECT replies,topped,tpcstatus FROM pw_threads WHERE tid=" . pwEscape($tid));
 $thread_tpcstatus = $rs['tpcstatus'];
 if ($rs['replies'] != $rt['count']) {
     $db->update("UPDATE pw_threads SET replies=" . pwEscape($rt['count']) . "WHERE tid=" . pwEscape($tid));
 }
 require_once R_P . 'require/credit.php';
 $creditset = $credit->creditset($creditset, $db_creditset);
 if ($atcdb['aid']) {
     require_once R_P . 'require/updateforum.php';
     delete_att($atcdb['aid']);
     pwFtpClose($ftp);
 }
 if ($article == 0) {
     $deltype = 'deltpc';
     $deltitle = substrs($subject, 28);
     if ($count == 1) {
         $db->update("DELETE FROM {$pw_tmsgs} WHERE tid=" . pwEscape($tid));
         # $db->update("DELETE FROM pw_threads WHERE tid=".pwEscape($tid));
         # ThreadManager
         $threadManager = L::loadClass("threadmanager");
         $threadManager->deleteByThreadId($fid, $tid);
         P_unlink(R_P . "{$db_htmdir}/{$fid}/" . date('ym', $postdate) . "/{$tid}.html");
     } else {
         $rt = $db->get_one("SELECT * FROM {$pw_posts} WHERE tid=" . pwEscape($tid) . "ORDER BY postdate LIMIT 1");
         if ($count == 2) {
Example #3
0
function delforum($fid)
{
    global $db, $db_guestdir, $db_guestthread, $db_guestread;
    $foruminfo = $db->get_one("SELECT fid,fup,forumadmin FROM pw_forums WHERE fid=" . S::sqlEscape($fid));
    //$db->update("DELETE FROM pw_forums WHERE fid=".S::sqlEscape($fid));
    pwQuery::delete('pw_forums', 'fid=:fid', array($fid));
    //* $db->update("DELETE FROM pw_forumdata WHERE fid=".S::sqlEscape($fid));
    pwQuery::delete('pw_forumdata', 'fid=:fid', array($fid));
    $db->update("DELETE FROM pw_forumsextra WHERE fid=" . S::sqlEscape($fid));
    $db->update("DELETE FROM pw_permission WHERE fid>'0' AND fid=" . S::sqlEscape($fid));
    if ($foruminfo['forumadmin']) {
        $userService = L::loadClass('UserService', 'user');
        /* @var $userService PW_UserService */
        $forumadmin = explode(",", $foruminfo['forumadmin']);
        foreach ($forumadmin as $key => $value) {
            if ($value) {
                $gid = $userService->getByUserName($value);
                if ($gid['groupid'] == 5 && !ifadmin($value)) {
                    $userService->update($gid['uid'], array('groupid' => -1));
                    admincheck($gid['uid'], $value, $gid['groupid'], '', 'delete');
                }
            }
        }
    }
    if ($db_guestthread || $db_guestread) {
        require_once R_P . 'require/guestfunc.php';
        $db_guestthread && deldir(D_P . "{$db_guestdir}/T_{$fid}");
    }
    //* P_unlink(D_P."data/forums/fid_{$fid}.php");
    pwCache::deleteData(D_P . "data/forums/fid_{$fid}.php");
    require_once R_P . 'require/functions.php';
    require_once R_P . 'require/updateforum.php';
    $pw_attachs = L::loadDB('attachs', 'forum');
    $ttable_a = $ptable_a = array();
    $query = $db->query("SELECT tid,replies,ptable FROM pw_threads WHERE fid=" . S::sqlEscape($fid));
    while ($tpc = $db->fetch_array($query)) {
        $tid = $tpc['tid'];
        $ttable_a[GetTtable($tid)][] = $tid;
        $ptable_a[$tpc['ptable']] = 1;
        $db_guestread && clearguestcache($tid, $tpc['replies']);
        if ($attachdb = $pw_attachs->getByTid($tid)) {
            delete_att($attachdb);
        }
    }
    pwFtpClose($GLOBALS['ftp']);
    foreach ($ttable_a as $pw_tmsgs => $val) {
        //* $val = S::sqlImplode($val,false);
        //* $db->update("DELETE FROM $pw_tmsgs WHERE tid IN($val)");
        pwQuery::delete($pw_tmsgs, 'tid IN(:tid)', array($val));
    }
    # $db->update("DELETE FROM pw_threads WHERE fid=".S::sqlEscape($fid));
    # ThreadManager
    //* $threadManager = L::loadClass("threadmanager", 'forum');
    //* $threadManager->deleteByForumId($fid);
    $threadService = L::loadclass('threads', 'forum');
    $threadService->deleteByForumId($fid);
    //* Perf::gatherInfo('changeThreadWithForumIds', array('fid'=>$fid));
    foreach ($ptable_a as $key => $val) {
        $pw_posts = GetPtable($key);
        //$db->update("DELETE FROM $pw_posts WHERE fid=".S::sqlEscape($fid));
        pwQuery::delete($pw_posts, 'fid=:fid', array($fid));
    }
    updateforum($foruminfo['fup']);
}
Example #4
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);
 }
Example #5
0
 function addCredit()
 {
     if ($this->attachs && $this->post->_G['allowupload'] == 1 && $this->uploadmoney) {
         global $credit, $onlineip;
         $credit->addLog('topic_upload', array($this->uploadcredit => $this->uploadmoney), array('uid' => $this->post->uid, 'username' => $this->post->username, 'ip' => $onlineip, 'fname' => $this->forum->name));
         if (!$credit->set($this->post->uid, $this->uploadcredit, $this->uploadmoney, false)) {
             require_once R_P . 'require/updateforum.php';
             delete_att($this->attachs);
             Showmsg('undefined_action');
         }
     }
 }
Example #6
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);
 }
Example #7
0
        if ($db_ifpwcache & 512 && $value['type'] == 'img' && !$value['needrvrc'] && !$elementpic) {
            $elementpic = array('aid' => $aid, 'attachurl' => $value['attachurl'], 'ifthumb' => $value['ifthumb']);
        }
        //End elementupdate
    }
}
unset($_FILES);
/*
* 上传附件积分控制
*/
if ($ifupload && $_G['allowupload'] == 1 && $uploadmoney) {
    require_once R_P . 'require/credit.php';
    if ($uploadmoney < 0 && $credit->get($winduid, $uploadcredit) < abs($uploadmoney)) {
        require_once R_P . 'require/updateforum.php';
        delete_att(array($attachs));
        $creditname = $credit->cType[$uploadcredit];
        Showmsg('upload_money_limit');
    }
    $credit->addLog('topic_upload', array($uploadcredit => $uploadmoney), array('uid' => $winduid, 'username' => $windid, 'ip' => $onlineip, 'fname' => $forum[$fid]['name']));
    if (!$credit->set($winduid, $uploadcredit, $uploadmoney, false)) {
        require_once R_P . 'require/updateforum.php';
        delete_att(array($attachs));
        Showmsg('undefined_action');
    }
}
foreach ($attachs as $key => $value) {
    $aids[] = $key;
}
$aids && ($aids = pwImplode($aids));
$attachs = !empty($attachs) ? addslashes(serialize($attachs)) : '';
pwFtpClose($ftp);
Example #8
0
 function updateAtt()
 {
     if ($this->delattach) {
         require_once R_P . 'require/updateforum.php';
         delete_att($this->delattach);
         pwFtpClose($GLOBALS['ftp']);
     }
     if ($this->alterattach) {
         $pw_attachs = L::loadDB('attachs');
         foreach ($this->alterattach as $aid => $v) {
             $pw_attachs->updateById($aid, array('needrvrc' => $v['needrvrc'], 'descrip' => $v['desc'], 'special' => $v['special'], 'ctype' => $v['ctype']));
         }
     }
     if (is_object($this->att) && ($aids = $this->att->getAids())) {
         $pw_attachs = L::loadDB('attachs');
         $pw_attachs->updateById($aids, array('tid' => $this->tid, 'pid' => $this->pid));
     }
 }
Example #9
0
if ($step == 2) {
    list($uploadcredit, $uploadmoney, , ) = explode("\t", $pwforum->forumset['uploadset']);
    //处理旧附件删除
    if ($postmodify->hasAtt() && is_array($attachs)) {
        $keep = array();
        $deleteAtt = array();
        foreach ($attachs as $key => $value) {
            $kname = "keep" . $key;
            if (!$_POST["keep" . $key]) {
                $deleteAtt[$key] = $value;
            }
        }
        if ($deleteAtt) {
            require_once R_P . 'require/functions.php';
            require_once R_P . 'require/updateforum.php';
            delete_att($deleteAtt);
        }
    }
    require_once W_P . 'include/wapupload.php';
    if (PwUpload::getUploadNum()) {
        $ext = strtolower(substr(strrchr($_FILES['attachment_']['name'], '.'), 1));
        $imageType = array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'swf');
        $_G['uploadtype'] && ($db_uploadfiletype = $_G['uploadtype']);
        $db_uploadfiletype = !empty($db_uploadfiletype) ? is_array($db_uploadfiletype) ? $db_uploadfiletype : unserialize($db_uploadfiletype) : array();
        foreach ($db_uploadfiletype as $key => $var) {
            if (!in_array($key, $imageType)) {
                unset($db_uploadfiletype[$key]);
            }
        }
        if (!array_key_exists($ext, $db_uploadfiletype)) {
            wap_msg('非法图片类型', $returnedit);