Пример #1
0
function updateforum($fid, $lastinfo = '')
{
    //TODO Âý²éѯ
    global $db, $db_fcachenum, $todayTopicNum;
    $fm = $db->get_one("SELECT fup,type,password,allowvisit,f_type FROM pw_forums WHERE fid=" . S::sqlEscape($fid));
    if ($fm['type'] != 'category') {
        $subtopics = $subrepliess = 0;
        $query = $db->query("SELECT fid FROM pw_forums WHERE fup=" . S::sqlEscape($fid));
        while ($subinfo = $db->fetch_array($query)) {
            @extract($db->get_one("SELECT COUNT(*) AS subtopic,SUM( replies ) AS subreplies FROM pw_threads WHERE fid=" . S::sqlEscape($subinfo['fid']) . " AND ifcheck='1'"));
            $subtopics += $subtopic;
            $subrepliess += $subreplies;
            $query2 = $db->query("SELECT fid FROM pw_forums WHERE fup=" . S::sqlEscape($subinfo['fid']));
            while ($subinfo2 = $db->fetch_array($query2)) {
                @extract($db->get_one("SELECT COUNT(*) AS subtopic,SUM( replies ) AS subreplies FROM pw_threads WHERE fid=" . S::sqlEscape($subinfo2['fid']) . " AND ifcheck='1'"));
                $subtopics += $subtopic;
                $subrepliess += $subreplies;
            }
        }
        $rs = $db->get_one("SELECT COUNT(*) AS topic,SUM( replies ) AS replies FROM pw_threads WHERE fid=" . S::sqlEscape($fid) . "AND ifcheck='1' AND topped<=3");
        $topic = $rs['topic'];
        $replies = $rs['replies'];
        $article = $topic + $replies + $subtopics + $subrepliess;
        if (!$lastinfo) {
            $lt = $db->get_one("SELECT tid,author,postdate,lastpost,lastposter,subject FROM pw_threads WHERE fid=" . S::sqlEscape($fid) . " AND specialsort=0 AND ifcheck=1 AND lastpost>0 ORDER BY lastpost DESC LIMIT 1");
            if ($lt['postdate'] == $lt['lastpost']) {
                $subject = addslashes(substrs($lt['subject'], 26));
            } else {
                $subject = 'Re:' . addslashes(substrs($lt['subject'], 26));
            }
            $author = addslashes($lt['lastposter']);
            $lastinfo = $lt['tid'] ? $subject . "\t" . $author . "\t" . $lt['lastpost'] . "\t" . "read.php?tid={$lt['tid']}&page=e#a" : '';
        }
        /**
        		$db->update("UPDATE pw_forumdata"
        			. " SET ".S::sqlSingle(array(
        					'topic'		=> $topic,
        					'article'	=> $article,
        					'subtopic'	=> $subtopics,
        					'lastpost'	=> $lastinfo
        				))
        			. " WHERE fid=".S::sqlEscape($fid));
        		**/
        pwQuery::update('pw_forumdata', 'fid=:fid', array($fid), array('topic' => $topic, 'article' => $article, 'subtopic' => $subtopics, 'lastpost' => $lastinfo));
        $todayTopicNum && $db->update("UPDATE pw_forumdata SET tpost = tpost+{$todayTopicNum} WHERE fid\t=\t" . S::sqlEscape($fid));
        if ($fm['password'] != '' || $fm['allowvisit'] != '' || $fm['f_type'] == 'hidden') {
            $lastinfo = '';
        }
        delfcache($fid, $db_fcachenum);
        if ($fm['type'] == 'sub' || $fm['type'] == 'sub2') {
            updateforum($fm['fup'], $lastinfo);
        }
    }
}
Пример #2
0
     $db->update("DELETE FROM {$pw_posts} WHERE pid=" . pwEscape($pid));
     $db->update("UPDATE pw_threads SET replies=replies-1 WHERE tid=" . pwEscape($tid));
     $msg_delrvrc = abs($creditset['Deleterp']['rvrc']);
     $msg_delmoney = abs($creditset['Deleterp']['money']);
     $credit->addLog('topic_Deleterp', $creditset['Deleterp'], array('uid' => $authorid, 'username' => $author, 'ip' => $onlineip, 'fname' => strip_tags($forum[$fid]['name']), 'operator' => $windid));
     $credit->sets($authorid, $creditset['Deleterp'], false);
 }
 $credit->setMdata($authorid, 'postnum', -1);
 $credit->runsql();
 if ($db_guestread) {
     require_once R_P . 'require/guestfunc.php';
     clearguestcache($tid, $rs['replies']);
 }
 P_unlink(D_P . 'data/bbscache/c_cache.php');
 require_once R_P . 'require/updateforum.php';
 updateforum($fid);
 if ($rs['topped']) {
     updatetop();
 }
 $msg_delrvrc = floor($msg_delrvrc / 10);
 require_once R_P . 'require/writelog.php';
 $log = array('type' => 'delete', 'username1' => $author, 'username2' => $windid, 'field1' => $fid, 'field2' => '', 'field3' => '', 'descrip' => $deltype . '_descrip', 'timestamp' => $timestamp, 'ip' => $onlineip, 'tid' => $tid, 'forum' => $pwforum->foruminfo['name'], 'subject' => $deltitle, 'affect' => "{$db_rvrcname}:-{$msg_delrvrc},{$db_moneyname}:-{$msg_delmoney}", 'reason' => 'edit delete article!');
 writelog($log);
 if ($pwforum->foruminfo['allowhtm'] && $article <= $db_readperpage) {
     $StaticPage = L::loadClass('StaticPage');
     $StaticPage->update($tid);
 }
 if ($deltype == 'delrp') {
     refreshto("read.php?tid={$tid}", 'enter_thread');
 } else {
     refreshto("thread.php?fid={$fid}", 'enter_thread');
Пример #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=" . pwEscape($fid));
    $db->update("DELETE FROM pw_forums WHERE fid=" . pwEscape($fid));
    $db->update("DELETE FROM pw_forumdata WHERE fid=" . pwEscape($fid));
    $db->update("DELETE FROM pw_forumsextra WHERE fid=" . pwEscape($fid));
    $db->update("DELETE FROM pw_permission WHERE fid>'0' AND fid=" . pwEscape($fid));
    if ($foruminfo['forumadmin']) {
        $forumadmin = explode(",", $foruminfo['forumadmin']);
        foreach ($forumadmin as $key => $value) {
            if ($value) {
                $gid = $db->get_one("SELECT uid,groupid FROM pw_members WHERE username="******"UPDATE pw_members SET groupid='-1' WHERE username="******"{$db_guestdir}/T_{$fid}");
    }
    P_unlink(D_P . "data/forums/fid_{$fid}.php");
    $ttable_a = $ptable_a = array();
    $query = $db->query("SELECT tid,replies,ptable FROM pw_threads WHERE fid=" . pwEscape($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']);
    }
    foreach ($ttable_a as $pw_tmsgs => $val) {
        $val = pwImplode($val, false);
        $db->update("DELETE FROM {$pw_tmsgs} WHERE tid IN({$val})");
    }
    # $db->update("DELETE FROM pw_threads WHERE fid=".pwEscape($fid));
    # ThreadManager
    $threadManager = L::loadClass("threadmanager");
    $threadManager->deleteByForumId($fid);
    foreach ($ptable_a as $key => $val) {
        $pw_posts = GetPtable($key);
        $db->update("DELETE FROM {$pw_posts} WHERE fid=" . pwEscape($fid));
    }
    updateforum($foruminfo['fup']);
}
Пример #4
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']);
}
Пример #5
0
 /**
  * 改变帖子是否显示在版块中
  * @param int $cyid 群组id
  * @param int $ifTopicShowInForum 帖子是否显示在版块中
  * @param int $cid 关联版块
  * void
  */
 function changeTopicShowInForum($cyid, $ifTopicShowInForum, $cid)
 {
     $ifcheck = $cid > 0 && $ifTopicShowInForum ? 1 : 2;
     //$this->_db->update("UPDATE pw_argument a LEFT JOIN pw_threads t ON a.tid=t.tid SET t.fid=" . S::sqlEscape($cid) . ",t.ifcheck=" . S::sqlEscape($ifcheck) . " WHERE a.cyid=" . S::sqlEscape($cyid) . " AND t.ifcheck>0");
     $this->_db->update(pwQuery::buildClause("UPDATE :pw_table1 a LEFT JOIN :pw_table2 t ON a.tid=t.tid SET t.fid=:fid,t.ifcheck=:ifcheck WHERE a.cyid=:cyid AND t.ifcheck>:ifcheck", array('pw_argument', 'pw_threads', $cid, $ifcheck, $cyid, 0)));
     require_once R_P . 'require/updateforum.php';
     updateforum($cid);
 }
Пример #6
0
    }
    //$db->update("UPDATE pw_threads SET fid=".S::sqlEscape($tofid)."WHERE fid=".S::sqlEscape($fid));
    pwQuery::update('pw_threads', 'fid = :fid', array($fid), array('fid' => $tofid));
    $ptable_a = array('pw_posts');
    if ($db_plist && count($db_plist) > 1) {
        foreach ($db_plist as $key => $value) {
            if ($key == 0) {
                continue;
            }
            $ptable_a[] = 'pw_posts' . $key;
        }
    }
    foreach ($ptable_a as $val) {
        //$db->update("UPDATE $val SET fid=".S::sqlEscape($tofid)."WHERE fid=".S::sqlEscape($fid));
        pwQuery::update($val, 'fid=:fid', array($fid), array('fid' => $tofid));
    }
    $db->update("UPDATE pw_attachs SET fid=" . S::sqlEscape($tofid) . "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));
    //* P_unlink(D_P."data/forums/fid_{$fid}.php");
    pwCache::deleteData(D_P . "data/forums/fid_{$fid}.php");
    updatecache_f();
    updateforum($tofid);
    if ($forum['type'] == 'sub') {
        updateforum($forum['fup']);
    }
    adminmsg('operate_success');
}
Пример #7
0
            $delarticle = L::loadClass('delarticle', 'forum');
            $delarticle->resetReplayToppedFloor('', $selids, $pw_posts);
            $repliesnum = array();
            $query = $db->query("SELECT * FROM pw_recycle WHERE pid IN ({$selids})");
            while ($rt = $db->fetch_array($query)) {
                $repliesnum[$rt['tid']]++;
            }
            foreach ($repliesnum as $key => $val) {
                //$db->update("UPDATE pw_threads SET replies=replies+".S::sqlEscape($val)."WHERE tid=".S::sqlEscape($key,false));
                $db->update(pwQuery::buildClause('UPDATE :pw_table SET replies=replies+:replies WHERE tid=:tid', array('pw_threads', $val, $key)));
            }
            $db->update("DELETE FROM pw_recycle WHERE pid IN ({$selids})");
        }
    }
    foreach ($fids as $key => $value) {
        updateforum($key);
    }
    adminmsg('operate_success', "{$basename}&type={$type}");
} elseif ($action == 'delete' || $action == 'del') {
    $pwServer['REQUEST_METHOD'] != 'POST' && PostCheck($verify);
    if ($action == 'del') {
        S::gp(array('selid'), 'P');
        $selids = array();
        foreach ($selid as $key => $value) {
            if (is_numeric($key)) {
                $selids[] = $key;
            }
        }
        $selids && ($selids = S::sqlImplode($selids));
        empty($selids) && adminmsg('operate_success');
    }
Пример #8
0
function fixthread($bid)
{
    global $_G;
    $config = $_G['cache']['plugin']['sanree_brand'];
    $bids = array();
    if (!is_array($bid)) {
        $bids[] = $bid;
    } else {
        $bids = $bid;
    }
    $category = C::t('#sanree_brand#sanree_brand_category')->fetch_all_category();
    $cates = array();
    foreach ($category as $v) {
        $cates[$v[cateid]] = $v;
    }
    foreach ($bids as $ibid) {
        $lastdata = C::t('#sanree_brand#sanree_brand_businesses')->fetch_first_bybid($ibid);
        $setarr = array();
        $setarr = $lastdata;
        $setarr['forumtitle'] = $config['forumtitle'];
        $setarr['forumbody'] = $config['forumbody'];
        $setarr['fid'] = intval($config['bindingforum']);
        $setarr['catename'] = $cates[$lastdata[cateid]]['name'];
        $setarr['username'] = $lastdata['username'];
        if ($setarr['poster']) {
            $valueparse = parse_url($setarr['poster']);
            if (isset($valueparse['host'])) {
                $result['poster'] = $setarr['poster'];
            } else {
                $setarr['poster'] = $_G['setting']['attachurl'] . 'forum/' . $setarr['poster'];
            }
        }
        $postthread = C::t('#sanree_brand#forum_thread')->fetch($lastdata['tid']);
        $setarr['propaganda'] = empty($setarr['propaganda']) ? srlang('zanwustr') : trim($setarr['propaganda']);
        $setarr['introduction'] = empty($setarr['introduction']) ? srlang('zanwustr') : trim($setarr['introduction']);
        $setarr['contact'] = empty($setarr['contact']) ? srlang('zanwustr') : trim($setarr['contact']);
        $setarr['qq'] = empty($setarr['qq']) ? '' : trim($setarr['qq']);
        $setarr['tel'] = empty($setarr['tel']) ? srlang('zanwustr') : trim($setarr['tel']);
        $setarr['address'] = empty($setarr['address']) ? srlang('zanwustr') : trim($setarr['address']);
        $subject = $setarr['forumtitle'];
        $subject = str_replace('{name}', $setarr['name'], $subject);
        $subject = str_replace('{catename}', $setarr['catename'], $subject);
        $subject = isset($subject) ? dhtmlspecialchars(censor(trim($subject))) : '';
        $setarr['subject'] = !empty($subject) ? str_replace("\t", ' ', $subject) : $subject;
        $message = $setarr['forumbody'];
        $message = str_replace('{name}', $setarr['name'], $message);
        $cateurl = $config['is_rewrite'] ? 'brand-index-' . $setarr['cateid'] . '.html' : 'plugin.php?id=sanree_brand&tid=' . $setarr['cateid'];
        $message = str_replace('{catename}', '[url=' . $cateurl . ']' . $setarr['catename'] . '[/url]', $message);
        $message = str_replace('{poster}', '[img]' . $setarr['poster'] . '[/img]', $message);
        $message = str_replace('{propaganda}', $setarr['propaganda'], $message);
        $message = str_replace('{introduction}', $setarr['introduction'], $message);
        $message = str_replace('{contact}', $setarr['contact'], $message);
        $message = str_replace('{qq}', $setarr['qq'], $message);
        $message = str_replace('{msn}', $setarr['msn'], $message);
        $message = str_replace('{wangwang}', $setarr['wangwang'], $message);
        $message = str_replace('{baiduhi}', $setarr['baiduhi'], $message);
        $message = str_replace('{skype}', $setarr['skype'], $message);
        $message = str_replace('{tel}', $setarr['tel'], $message);
        $message = str_replace('{address}', $setarr['address'], $message);
        $setarr['weburl'] = trim(str_replace("http://", '', $setarr['weburl']));
        $setarr['weburl'] = empty($setarr['weburl']) ? srlang('zanwustr') : '[url]http://' . $setarr['weburl'] . '[/url]';
        $setarr['message'] = str_replace('{weburl}', $setarr['weburl'], $message);
        if ($lastdata['tid'] && $lastdata['pid'] && $postthread) {
            updateforum($setarr, $postthread);
            setattachment($ibid, $lastdata['caid'], $lastdata[tid], $lastdata[pid]);
        } else {
            $thread = instertoforum($setarr);
            C::t('#sanree_brand#sanree_brand_businesses')->update($ibid, array('tid' => $thread[0], 'pid' => $thread[1]));
            setattachment($ibid, $lastdata['caid'], $thread[0], $thread[1]);
        }
        unset($postthread);
        unset($lastdata);
    }
    fixthreadcount(intval($config['bindingforum']));
}