function increase($userId, $increments) { $userId = intval($userId); if ($userId <= 0 || !is_array($increments)) { return 0; } $incrementStatement = array(); foreach ($increments as $field => $offset) { $offset = intval($offset); if (!$offset) { continue; } if ($offset < 0) { $incrementStatement[] = $field . "=" . $field . $offset; } else { $incrementStatement[] = $field . "=" . $field . "+" . $offset; } } if (empty($incrementStatement)) { return 0; } //* $this->_db->update("UPDATE " . $this->_tableName . " SET " . implode(", ", $incrementStatement) . " WHERE uid=" . $this->_addSlashes($userId)); $this->_db->update(pwQuery::buildClause("UPDATE :pw_table SET " . implode(", ", $incrementStatement) . " WHERE uid=:uid", array($this->_tableName, $userId))); return $this->_db->affected_rows(); }
function reduceReplyNumByCommentid($num, $commentid) { $num = intval($num); $commentid = intval($commentid); if ($num < 1 || $commentid < 1) { return false; } return $this->_db->update(pwQuery::buildClause("UPDATE :pw_table SET replynum=replynum-" . S::sqlEscape($num) . ' WHERE commentid=:commentid', array($this->_tableName, $commentid))); }
function delUserByIds($uids) { if (!is_array($uids) || !count($uids)) { return; } $userService = $this->_getUserService(); $userService->deletes($uids); $count = $userService->count(); $lastestUser = $userService->getLatestNewUser(); //* $this->db->update("UPDATE pw_bbsinfo SET newmember=" . S::sqlEscape($lastestUser['username']) . ',totalmember=' . S::sqlEscape($count) . " WHERE id='1'"); $this->db->update(pwQuery::buildClause("UPDATE :pw_table SET newmember=:newmember,totalmember=:totalmember WHERE id=:id", array('pw_bbsinfo', $lastestUser['username'], $count))); }
/** * 更新 * * @param int $commentid * @param array $fieldsData * @return boolean */ function updateReplynumByCommentid($exp = '+1', $commentid) { $commentid = intval($commentid); if ($commentid < 1 || !$exp) { return false; } $num = intval(trim($exp, '+-')); if (strpos($exp, '+') !== false) { return $this->_db->update(pwQuery::buildClause("UPDATE :pw_table SET replynum=replynum+" . S::sqlEscape($num) . ' WHERE commentid=:commentid', array($this->_tableName, $commentid))); } else { return $this->_db->update(pwQuery::buildClause("UPDATE :pw_table SET replynum=replynum-" . S::sqlEscape($num) . ' WHERE commentid=:commentid', array($this->_tableName, $commentid))); } return false; }
/** * 批量增加套餐信息 * @param array $fieldData * @return bool */ function addSpreads($fieldData) { if (!S::isArray($fieldData)) { return false; } $data = array(); foreach ($fieldData as $value) { $value = $this->_checkAllowField($value, $this->_allowFields); if (!S::isArray($value)) { continue; } $data[] = $value; } if (!S::isArray($data)) { return false; } return $this->_db->query(pwQuery::buildClause('INSERT INTO :table VALUES :data', array($this->_tableName, S::sqlMulti($data)))); }
exit; } elseif ($_POST['action'] == 'submit') { S::gp(array('selid'), 'P'); $_tmpSelid = $selid; $selid = checkselid($selid); if ($selid === false) { $basename = "javascript:history.go(-1);"; adminmsg('operate_error'); } elseif ($selid == '') { //* $db->update("UPDATE pw_forums SET allowhtm='0' $sqladd"); $db->update(pwQuery::buildClause("UPDATE :pw_table SET allowhtm='0' {$sqladd}", array('pw_forums'))); } elseif ($selid) { //* $db->update("UPDATE pw_forums SET allowhtm='1' $sqladd AND fid IN($selid)"); //* $db->update("UPDATE pw_forums SET allowhtm='0' $sqladd AND fid NOT IN($selid)"); $db->update(pwQuery::buildClause("UPDATE :pw_table SET allowhtm='1' {$sqladd} AND fid IN(:fid)", array('pw_forums', $_tmpSelid))); $db->update(pwQuery::buildClause("UPDATE :pw_table SET allowhtm='0' {$sqladd} AND fid NOT IN(:fid)", array('pw_forums', $_tmpSelid))); } updatecache_f(); adminmsg('operate_success'); } elseif ($action == 'creat') { @set_time_limit(0); $pwServer['REQUEST_METHOD'] != 'POST' && PostCheck($verify); S::gp(array('creatfid', 'percount', 'step', 'tfid', 'forumnum')); $fids = $tid = $fieldadd = $tableadd = $tids = ''; !is_array($creatfid) && ($creatfid = explode(',', $creatfid)); if (in_array('all', $creatfid)) { $query = $db->query("SELECT fid FROM pw_forums {$sqladd} AND allowhtm='1'"); while ($rt = $db->fetch_array($query)) { $fids .= ($fids ? ',' : '') . $rt['fid']; } $creatfid = explode(',', $fids);
/** * 圈子中各种用户发表信息统计,记录、分享、群组、相册、回复等 * * @param string $exp 表达式,包含+或-符号 */ function countPosts($exp = '+1') { global $db; $num = intval(trim($exp, '+-')); if (strpos($exp, '+') !== false) { //* $db->update("UPDATE pw_bbsinfo SET o_post=o_post+".S::sqlEscape($num,false).",o_tpost=o_tpost+".S::sqlEscape($num,false)); $db->update(pwQuery::buildClause("UPDATE :pw_table SET o_post=o_post+:o_post, o_tpost=o_tpost+:o_tpost", array('pw_bbsinfo', $num, $num))); } else { //* $db->update("UPDATE pw_bbsinfo SET o_post=o_post-".S::sqlEscape($num,false).",o_tpost=o_tpost-".S::sqlEscape($num,false)); $db->update(pwQuery::buildClause("UPDATE :pw_table SET o_post=o_post-:o_post, o_tpost=o_tpost-:o_tpost", array('pw_bbsinfo', $num, $num))); } }
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); } }
$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 0,1"); if ($lt['tid']) { $lt['subject'] = substrs($lt['subject'], 21); if ($lt['postdate'] != $lt['lastpost']) { $lt['subject'] = 'Re:' . $lt['subject']; $add = '&page=e#a'; } $toread = $cms ? '&toread=1' : ''; $htmurl = $db_readdir . '/' . $fid . '/' . date('ym', $lt['postdate']) . '/' . $lt['tid'] . '.html'; $new_url = file_exists(R_P . $htmurl) && $allowhtm == 1 && !$cms ? "{$R_url}/{$htmurl}" : "read.php?tid={$lt['tid']}{$toread}{$add}"; $lastinfo = addslashes(S::escapeChar($lt['subject']) . "\t" . $lt['lastposter'] . "\t" . $lt['lastpost'] . "\t" . $new_url); } else { $lastinfo = ''; } //* $db->update("UPDATE pw_forumdata SET topic=".S::sqlEscape($topic).',article=article+'.S::sqlEscape($article).',lastpost='.S::sqlEscape($lastinfo).' WHERE fid='.S::sqlEscape($fid)); $db->update(pwQuery::buildClause("UPDATE :pw_table SET topic=:topic, article=article+:article,lastpost=:lastpost WHERE fid=:fid", array('pw_forumdata', $topic, $article, $lastinfo, $fid))); } if ($goon) { adminmsg('updatecache_step', EncodeUrl($j_url)); } else { adminmsg('operate_success'); } } elseif ($action == 'thread') { $pwServer['REQUEST_METHOD'] != 'POST' && PostCheck($verify); S::gp(array('step', 'percount')); !$step && ($step = 1); !$percount && ($percount = 300); $start = ($step - 1) * $percount; $next = $start + $percount; $step++; $j_url = "{$basename}&action={$action}&step={$step}&percount={$percount}";
function _insertUser() { global $timestamp, $onlineip, $credit; /** $pwSQL = S::sqlSingle(array( 'uid' => $this->uid, 'username' => $this->data['username'], 'password' => $this->data['password'], 'safecv' => $this->data['safecv'], 'email' => $this->data['email'], 'groupid' => $this->data['groupid'], 'memberid' => $this->data['memberid'], 'regdate' => $timestamp, 'yz' => $this->data['yz'], 'userstatus' => $this->data['userstatus'], 'newpm' => 0 )); $this->db->update("REPLACE INTO pw_members SET $pwSQL"); **/ $pwSQL = array('uid' => $this->uid, 'username' => $this->data['username'], 'password' => $this->data['password'], 'safecv' => $this->data['safecv'], 'email' => $this->data['email'], 'groupid' => $this->data['groupid'], 'memberid' => $this->data['memberid'], 'regdate' => $timestamp, 'yz' => $this->data['yz'], 'userstatus' => $this->data['userstatus'], 'newpm' => 0); pwQuery::replace('pw_members', $pwSQL); /** $pwSQL = S::sqlSingle(array( 'uid' => $this->uid, 'postnum' => 0, 'lastvisit' => $timestamp, 'thisvisit' => $timestamp, 'onlineip' => $onlineip )); $this->db->pw_update( 'SELECT uid FROM pw_memberdata WHERE uid=' . S::sqlEscape($this->uid), 'UPDATE pw_memberdata SET ' . $pwSQL . ' WHERE uid=' . S::sqlEscape($this->uid), 'INSERT INTO pw_memberdata SET ' . $pwSQL ); **/ $pwSQL = array('uid' => $this->uid, 'postnum' => 0, 'lastvisit' => $timestamp, 'thisvisit' => $timestamp, 'onlineip' => $onlineip); $this->db->pw_update('SELECT uid FROM pw_memberdata WHERE uid=' . S::sqlEscape($this->uid), pwQuery::updateClause('pw_memberdata', 'uid =:uid', array($this->uid), $pwSQL), pwQuery::insertClause('pw_memberdata', $pwSQL)); //$this->db->update("REPLACE INTO pw_memberdata SET $pwSQL"); require_once R_P . 'require/credit.php'; $credit->addLog('reg_register', L::reg('rg_regcredit'), array('uid' => $this->uid, 'username' => stripslashes($this->data['username']), 'ip' => $onlineip)); $credit->sets($this->uid, L::reg('rg_regcredit'), false); $credit->runsql(); //* $this->db->update("UPDATE pw_bbsinfo SET newmember=" . S::sqlEscape($this->data['username']) . ",totalmember=totalmember+1 WHERE id='1'"); $this->db->update(pwQuery::buildClause("UPDATE :pw_table SET newmember=:newmember,totalmember=totalmember+1 WHERE id=:id", array('pw_bbsinfo', $this->data['username'], 1))); $this->memberinfo or $this->memberinfo['uid'] = $this->uid; if ($this->memberinfo) { /** $this->db->update("REPLACE INTO pw_memberinfo SET uid=" . S::sqlEscape($this->uid) . ',' . S::sqlSingle($this->memberinfo)); **/ $_temp = array('uid' => $this->uid) + $this->memberinfo; pwQuery::replace('pw_memberinfo', $_temp); } $statistics = L::loadClass('Statistics', 'datanalyse'); $statistics->register(); }
<?php !function_exists('readover') && exit('Forbidden'); $query = $db->query("SELECT id,uid,fid FROM pw_banuser WHERE type='1' AND startdate+days*86400<" . S::sqlEscape($timestamp)); $ids = $uids1 = $uids2 = array(); while ($rt = $db->fetch_array($query)) { $ids[] = $rt['id']; if ($rt['fid']) { $uids2[] = $rt['uid']; } else { $uids1[] = $rt['uid']; } } if ($ids) { $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */ $db->update("DELETE FROM pw_banuser WHERE id IN(" . S::sqlImplode($ids) . ")"); $uids1 && $userService->updates($uids1, array('groupid' => -1)); /** $uids2 && $db->update("UPDATE pw_members m LEFT JOIN pw_banuser b ON m.uid=b.uid AND b.fid>0 SET m.userstatus=m.userstatus&(~1) WHERE b.uid is NULL AND m.uid IN(".S::sqlImplode($uids2).")"); **/ $uids2 && $db->update(pwQuery::buildClause("UPDATE :pw_table m LEFT JOIN pw_banuser b ON m.uid=b.uid AND b.fid>0 SET m.userstatus=m.userstatus&(~1) WHERE b.uid is NULL AND m.uid IN(:uid)", array('pw_members', $uids2))); }
/** * 取消评分 * @param $tid * @param $pids * @param $params */ function deletePing($params = array()) { global $groupid, $windid, $winduid, $credit, $onlineip, $timestamp, $gp_gptype; //* $threadService = L::loadClass("threads", 'forum'); require_once R_P . 'require/credit.php'; foreach ($this->postData as $pid => $atc) { $rpid = $pid == 'tpc' ? '0' : $pid; // delete pinglog $pingdata = $this->db->get_one('SELECT * FROM pw_pinglog WHERE tid=' . S::sqlEscape($this->tid) . ' AND pid=' . S::sqlEscape($rpid) . ' AND pinger=' . S::sqlEscape($windid) . ' ORDER BY pingdate DESC LIMIT 1'); //$this->db->update('DELETE FROM pw_pinglog WHERE id=' . S::sqlEscape($pingdata['id'])); pwQuery::delete('pw_pinglog', 'id=:id', array($pingdata['id'])); $this->update_markinfo($this->tid, $rpid); //* $threadService->clearTmsgsByThreadId($this->tid); Perf::gatherInfo('changeTmsgWithThreadIds', array('tid' => $this->tid)); $addpoint = $pingdata['point']; if (!($cid = $credit->getCreditTypeByName($pingdata['name']))) { continue; } $cName = $credit->cType[$cid]; $addpoint = $addpoint > 0 ? -$addpoint : abs($addpoint); !$atc['subject'] && ($atc['subject'] = substrs(strip_tags(convert($atc['content'])), 35)); $credit->addLog('credit_delping', array($cid => $addpoint), array('uid' => $atc['authorid'], 'username' => $atc['author'], 'ip' => $onlineip, 'operator' => $windid, 'tid' => $this->tid, 'subject' => $atc['subject'], 'reason' => $params['atc_content'])); $credit->set($atc['authorid'], $cid, $addpoint); if (!is_numeric($pid)) { //* $this->db->update('UPDATE pw_threads SET ifmark=ifmark+'.S::sqlEscape($addpoint).' WHERE tid='.S::sqlEscape($tid)); $this->db->update(pwQuery::buildClause("UPDATE :pw_table SET ifmark=ifmark+:ifmark WHERE tid=:tid", array('pw_threads', $addpoint, $this->tid))); } if ($params['ifmsg'] && !$atc['anonymous'] && $atc['author'] != $windid) { //发消息 $title = getLangInfo('writemsg', 'delping_title', array('sender' => $windid, 'receiver' => $atc['author'])); $content = getLangInfo('writemsg', 'delping_content', array('manager' => $windid, 'fid' => $atc['fid'], 'tid' => $this->tid, 'pid' => $pid, 'subject' => $atc['subject'], 'postdate' => get_date($atc['postdate']), 'forum' => strip_tags($this->forum->foruminfo['name']), 'affect' => "{$cName}:{$addpoint}", 'admindate' => get_date($timestamp), 'reason' => stripslashes($params['atc_content']), 'sender' => $windid, 'receiver' => $atc['author'])); $this->sendMessage($atc['author'], $title, $content); } if ($gp_gptype == 'system') { require_once R_P . 'require/writelog.php'; $log = array('type' => 'credit', 'username1' => $atc['author'], 'username2' => $windid, 'field1' => $atc['fid'], 'field2' => '', 'field3' => '', 'descrip' => 'creditdel_descrip', 'timestamp' => $timestamp, 'ip' => $onlineip, 'tid' => $this->tid, 'forum' => strip_tags($this->forum->foruminfo['name']), 'subject' => $atc['subject'], 'affect' => "{$name}:{$addpoint}", 'reason' => $params['atc_content']); writelog($log); } $pingLog[$pid] = $pingdata['id']; } $credit->runsql(); defined('AJAX') && ($GLOBALS['pingLog'] = $pingLog); //GLOBAL if ($this->forum->foruminfo['allowhtm'] && $_REQUEST['page'] == 1) { $StaticPage = L::loadClass('StaticPage'); $StaticPage->update($this->tid); } return true; }
$last = $db->get_one($sql); # 更新主题的回复数,最后回复信息 //$sql = "UPDATE pw_threads SET replies=replies-".S::sqlEscape($num) . ",lastpost=" . S::sqlEscape($last['postdate'],false) . ",lastposter =" . S::sqlEscape($last['author'],false) . "WHERE tid=" . S::sqlEscape($tid); $sql = pwQuery::buildClause('UPDATE :pw_table SET replies = replies - :replies, lastpost = :lastpost, lastposter = :lastposter WHERE tid = :tid', array('pw_threads', $num, $last['postdate'], $last['author'], $tid)); $db->update($sql); # memcache refresh // $threadList = L::loadClass("threadlist", 'forum'); // $threadList->updateThreadIdsByForumId($fid,$tid); Perf::gatherInfo('changeThreadWithForumIds', array('fid' => $fid)); } # 更新版块文章数 /** $sql = "UPDATE pw_forumdata SET article=article-".S::sqlEscape($forum_count)." WHERE fid=".S::sqlEscape($fid); $db->update($sql); **/ $db->update(pwQuery::buildClause("UPDATE :pw_table SET article=article-:article WHERE fid=:fid", array('pw_forumdata', $forum_count, $fid))); } foreach ($db_threads as $tid => $thread) { $toUser = array(); foreach ($thread as $post) { $toUser[] = $post['author']; } $sql = "SELECT subject FROM pw_threads WHERE tid =" . S::sqlEscape($tid); $subject = $db->get_value($sql); M::sendNotice($toUser, array('title' => getLangInfo('writemsg', 'filtermsg_post_del_title'), 'content' => getLangInfo('writemsg', 'filtermsg_post_del_content', array('subject' => $subject)))); } } $delarticle->delReply($replydb, $db_recycle); if (is_array($objid)) { $filter_id = implode(',', $objid); if ($filter_id) {
$_cacheService = Perf::gatherCache('pw_space'); $tmp = $_cacheService->getSpaceByUid($winduid); $tovisitors = $tmp['tovisitors']; } else { $tovisitors = $db->get_value("SELECT tovisitors FROM pw_space WHERE uid=" . S::sqlEscape($winduid)); } $tovisitors = unserialize($tovisitors); is_array($tovisitors) || ($tovisitors = array()); if (!isset($tovisitors[$uid]) || $timestamp - $tovisitors[$uid] > 900) { $tovisitors[$uid] = $timestamp; arsort($tovisitors); if (count($tovisitors) > 12) { array_pop($tovisitors); } //$db->update("UPDATE pw_space SET tovisits=tovisits+'1',tovisitors=" . S::sqlEscape(serialize($tovisitors),false) . " WHERE uid=" . S::sqlEscape($winduid)); $db->update(pwQuery::buildClause("UPDATE :pw_table SET tovisits=tovisits+1,tovisitors=:tovisitors WHERE uid=:uid", array('pw_space', serialize($tovisitors), $winduid))); } //猪头回收 $user_icon = explode('|', $space['icon']); if ($user_icon[4] && $space['tooltime'] < $timestamp - 86400) { $space['icon'] = "{$user_icon['0']}|{$user_icon['1']}|{$user_icon['2']}|{$user_icon['3']}|0"; /** $db->update("UPDATE pw_members SET icon=".S::sqlEscape($space['icon'],false)." WHERE uid=".S::sqlEscape($space['uid'])); **/ pwQuery::update('pw_members', 'uid =:uid', array($space['uid']), array('icon' => $space['icon'])); } } $isSpace = true; $spaceTemplate = ""; $spacestyle = $space['spacestyle'] === '2' || $space['spacestyle'] === '3' ? $space['spacestyle'] : 2; $spaceTemplate = 'space_' . $spacestyle . '_index';
$msgdb[] = array('toUser' => $fromdb['author'], 'title' => getLangInfo('writemsg', 'unite_title', array('manager' => $windid)), 'content' => getLangInfo('writemsg', 'unite_content', array('manager' => $windid, 'fid' => $fid, 'tid' => $totid, 'subject' => $todb['subject'], 'postdate' => get_date($todb['postdate']), 'forum' => strip_tags($forum[$fid]['name']), 'admindate' => get_date($timestamp), 'reason' => stripslashes($atc_content)))); } $log = array('type' => 'unite', 'username1' => $fromdb['author'], 'username2' => $windid, 'field1' => $fid, 'field2' => '', 'field3' => '', 'descrip' => 'unite_descrip', 'timestamp' => $timestamp, 'ip' => $onlineip, 'tid' => $totid, 'subject' => substrs($todb['subject'], 28), 'forum' => $forum[$fid]['name'], 'reason' => stripslashes($atc_content)); writelog($log); $istucool && $tucoolService->delete($fromdb['tid']); //更新评分 $oldPid = $fromdb['pid'] == 'tpc' ? 0 : $fromdb['pid']; //$db->update(pwQuery::buildClause('UPDATE :pw_table SET tid=:tid1,pid=:pid WHERE tid=:tid AND pid=0', array('pw_pinglog', $totid, $pid, $fromdb['tid']))); //$db->update(pwQuery::buildClause('UPDATE :pw_table SET tid=:tid1 WHERE tid=:tid AND pid>0', array('pw_pinglog', $totid, $fromdb['tid']))); pwQuery::update('pw_pinglog', 'tid=:tid', array($fromdb['tid']), array('tid' => $totid, 'pid' => $pid)); //pwQuery::update('pw_pinglog', 'tid=:tid AND pid>0', array($fromdb['tid']), array('tid'=>$totid)); //更新elements pwQuery::delete('pw_elements', 'id=:id AND type IN (:type)', array($fromdb['tid'], array('newpic', 'hitsort', 'hitsortday', 'hitsortweek', 'replysort', 'replysortday', 'replysortweek'))); } //$db->update("UPDATE pw_threads SET replies=replies+" . S::sqlEscape($replies, false) . " WHERE tid=" . S::sqlEscape($totid)); $db->update(pwQuery::buildClause('UPDATE :pw_table SET replies=replies+:replies WHERE tid=:tid', array('pw_threads', $replies, $totid))); $pw_tmsgs = GetTtable($totid); //* $db->update("UPDATE $pw_tmsgs SET remindinfo=" . S::sqlEscape($remindinfo, false) . " WHERE tid=" . S::sqlEscape($totid)); pwQuery::update($pw_tmsgs, 'tid=:tid', array($totid), array('remindinfo' => $remindinfo)); updateforum($fid); $weiboService = L::loadClass('weibo', 'sns'); $fromColonyIds && $weiboService->deleteWeibosByObjectIdsAndType($fromColonyIds, 'group_article'); $fromArticleIds && $weiboService->deleteWeibosByObjectIdsAndType($fromArticleIds, 'article'); $tousername = $db->get_value("SELECT author FROM pw_threads WHERE tid=" . S::sqlEscape($totid)); M::sendNotice(array($tousername), array('title' => getLangInfo('writemsg', 'unite_title'), 'content' => getLangInfo('writemsg', 'unite_content', array('manager' => $windid, 'fid' => $fid, 'tid' => $totid, 'subject' => $todb['subject'], 'postdate' => get_date($todb['postdate']), 'forum' => strip_tags($forum[$fid]['name']), 'admindate' => get_date($timestamp), 'reason' => stripslashes($atc_content))))); if ($ifmsg) { sendMawholeMessages($msgdb); } //* $threads = L::loadClass('Threads', 'forum'); //* $threads->delThreads($totid); //* $threads->delThreads($fromdb['tid']);
$db->update(pwQuery::buildClause('UPDATE :pw_table SET replies = replies + :replies, lastpost = :lastpost, lastposter = :lastposter WHERE tid = :tid', array('pw_threads', $value, $rt['postdate'], $rt['author'], $key))); # memcache refresh M::sendNotice(array($rt['author']), array('title' => getLangInfo('writemsg', 'post_pass_title'), 'content' => getLangInfo('writemsg', 'post_pass_content', array('tid' => $key)))); /* $threadList = L::loadClass("threadlist", 'forum'); $threadList->updateThreadIdsByForumId($fid,$key); $thread = L::loadClass("Threads", 'forum'); $thread->clearThreadByThreadId($key); */ Perf::gatherInfo('changeThreadWithForumIds', array('fid' => $fid)); } foreach ($fids as $key => $value) { /** $db->update("UPDATE pw_forumdata SET article=article+".S::sqlEscape($value).",tpost=tpost+".S::sqlEscape($value,false)."WHERE fid=".S::sqlEscape($key)); **/ $db->update(pwQuery::buildClause("UPDATE :pw_table SET article=article+:article,tpost=tpost+:tpost WHERE fid=:fid", array('pw_forumdata', $value, $value, $key))); } $db->update("UPDATE {$pw_posts} SET ifcheck='1',ifwordsfb='{$db_wordsfb}' WHERE {$sql} AND pid IN(" . S::sqlImplode($pass) . ")"); Perf::gatherInfo('changePosts', array('_tablename' => $pw_posts, 'pid' => $pass)); /** $threadIds = explode(",",$pass); if($threadIds){ $threads = L::loadClass('Threads', 'forum'); $threads->delThreads($threadIds); }**/ } else { if (is_array($dels)) { require_once R_P . 'require/credit.php'; $creditOpKey = "Deleterp"; $forumInfos = array(); $_tids = $_pids = $deluids = array();
/** * @desc 扫描回复表 */ function scanPosts() { # 获取帖子信息,判断是否重复记录 $sql = "SELECT p.pid,p.content,p.subject,t.tid,t.subject AS title,p.author,p.postdate,p.ifcheck,f.id,f.state " . "FROM {$this->table} AS p LEFT JOIN pw_threads AS t ON p.tid=t.tid LEFT JOIN pw_filter AS f ON p.pid = f.pid " . "WHERE p.tid > 0 AND p.pid>" . S::sqlEscape($this->table_progress[$this->table]) . " AND t.fid =" . S::sqlEscape($this->fid) . " GROUP BY p.pid ORDER BY p.pid ASC LIMIT " . $this->pagesize; $query = $this->db->query($sql); while ($post = $this->db->fetch_array($query)) { # 扫描进度 $this->progress++; $this->objid = $post['pid']; # 内容 $content = $post['subject'] . $post['content']; # 过滤敏感词 $result = $this->filter->paraseContent($content, $this->skip, $this->convert); # 处理扫描结果 if (is_array($result)) { $word = $this->getWordString($result[1]); $score = round($result[0], 2); if ($this->dispose && $score > 0 && $post['ifcheck']) { $tids[$post['tid']]++; # 待审核 $sql = "UPDATE {$this->table} SET ifcheck=0 WHERE pid = " . S::sqlEscape($post['pid']); $this->db->update($sql); # 发消息通知 $msg = array('subject' => $post['title'], 'tid' => $post['tid'], 'pid' => $post['pid'], 'fid' => $this->fid); $this->sendMsg($post['author'], $msg, 'p'); } if (!$post['id']) { # 如果不是重复记录,扫描到的结果+1 $this->result++; $compart = $insertSql ? ',' : ''; # 处理数据 $insertSql .= $compart . "( " . S::sqlEscape($post['tid']) . ", " . S::sqlEscape($post['pid']) . ", " . S::sqlEscape($word) . ", " . S::sqlEscape($post['postdate']) . ")"; } elseif ($post['state']) { # 如果是已经处理过的审核记录再次被扫到,扫描到的结果+1 $this->result++; # 处理数据 $value = array('state' => 0, 'filter' => $word, 'created_at' => $post['postdate']); $value = S::sqlSingle($value); # 更新记录 $sql = "UPDATE pw_filter SET {$value} WHERE tid=" . S::sqlEscape($post['tid']) . " AND pid=" . S::sqlEscape($post['pid']); $this->db->update($sql); } } } if ($this->dispose && $tids) { # 总文章数 $article = 0; foreach ($tids as $key => $value) { # 更新主题帖回复数 //$sql = "UPDATE pw_threads SET replies=replies-".S::sqlEscape($value,false)." WHERE tid=".S::sqlEscape($key); $sql = pwQuery::buildClause('UPDATE :pw_table SET replies=replies-:replies WHERE tid=:tid', array('pw_threads', $value, $key)); $this->db->update($sql); $article += $value; } # 更新版块文章数 /** $sql = "UPDATE pw_forumdata SET article=article-".S::sqlEscape($article,false)." WHERE fid=".S::sqlEscape($this->fid); $this->db->update($sql); **/ $this->db->update(pwQuery::buildClause("UPDATE :pw_table SET article=article-:article WHERE fid=:fid", array('pw_forumdata', $article, $this->fid))); } # 插入记录 if ($insertSql) { $sql = "INSERT INTO pw_filter (tid, pid, filter, created_at) VALUES " . $insertSql; $this->db->update($sql); } }
if ($value > $credit->get($winduid, $key)) { Showmsg('colony_moneylimit2'); } } } //积分变动 $creditset = getCreditset($o_groups_creditset['Createalbum'], false); $credit->sets($winduid, $creditset, true); updateMemberid($winduid); } if ($creditlog = $o_groups_creditlog) { addLog($creditlog['Createalbum'], $windid, $winduid, 'groups_Createalbum'); } $db->update("INSERT INTO pw_cnalbum SET " . S::sqlSingle(array('aname' => $aname, 'aintro' => $aintro, 'atype' => 1, 'private' => $private ? 1 : 0, 'ownerid' => $cyid, 'owner' => $colony['cname'], 'lasttime' => $timestamp, 'crtime' => $timestamp, 'memopen' => $memopen))); //* $db->update("UPDATE pw_colonys SET albumnum=albumnum+1 WHERE id=" . S::sqlEscape($cyid)); $db->update(pwQuery::buildClause("UPDATE :pw_table SET albumnum=albumnum+1 WHERE id=:id", array('pw_colonys', $cyid))); $aid = $db->insert_id(); $colony['albumnum']++; updateGroupLevel($colony['id'], $colony); if ($ajax == 1) { echo "success\t{$aid}\t{$aname}\t{$job}"; ajax_footer(); } else { refreshto("thread.php?cyid={$cyid}&showtype=galbum&a=upload&job=flash&aid={$aid}", 'operate_success'); } } } elseif ($a == 'getallowflash') { define('AJAX', 1); define('F_M', true); ob_end_clean(); ObStart();
function updatecache_fd1() { global $db; require_once R_P . 'admin/cache.php'; //* $db->update("UPDATE pw_forums SET childid='0',fupadmin=''"); $db->update(pwQuery::buildClause("UPDATE :pw_table SET childid='0',fupadmin=''", array('pw_forums'))); $query = $db->query("SELECT fid,forumadmin FROM pw_forums WHERE type='category' ORDER BY vieworder"); while ($cate = $db->fetch_array($query)) { S::slashes($cate); $query2 = $db->query("SELECT fid,forumadmin FROM pw_forums WHERE type='forum' AND fup=" . S::sqlEscape($cate['fid'])); if ($db->num_rows($query2)) { $havechild[] = $cate['fid']; while ($forum = $db->fetch_array($query2)) { S::slashes($forum); $fupadmin = trim($cate['forumadmin']); if ($fupadmin) { //$db->update("UPDATE pw_forums SET fupadmin=".S::sqlEscape($fupadmin)." WHERE fid=".S::sqlEscape($forum['fid'])); pwQuery::update('pw_forums', 'fid=:fid', array($forum['fid']), array('fupadmin' => $fupadmin)); } if (trim($forum['forumadmin'])) { $fupadmin .= $fupadmin ? substr($forum['forumadmin'], 1) : $forum['forumadmin']; //is } $query3 = $db->query("SELECT fid,forumadmin FROM pw_forums WHERE type='sub' AND fup=" . S::sqlEscape($forum['fid'])); if ($db->num_rows($query3)) { $havechild[] = $forum['fid']; while ($sub1 = $db->fetch_array($query3)) { S::slashes($sub1); $fupadmin1 = $fupadmin; if ($fupadmin1) { //$db->update("UPDATE pw_forums SET fupadmin=".S::sqlEscape($fupadmin1)." WHERE fid=".S::sqlEscape($sub1['fid'])); pwQuery::update('pw_forums', 'fid=:fid', array($sub1['fid']), array('fupadmin' => $fupadmin1)); } if (trim($sub1['forumadmin'])) { $fupadmin1 .= $fupadmin1 ? substr($sub1['forumadmin'], 1) : $sub1['forumadmin']; } $query4 = $db->query("SELECT fid,forumadmin FROM pw_forums WHERE type='sub' AND fup=" . S::sqlEscape($sub1['fid'])); if ($db->num_rows($query4)) { $havechild[] = $sub1['fid']; while ($sub2 = $db->fetch_array($query4)) { S::slashes($sub2); $fupadmin2 = $fupadmin1; if ($fupadmin2) { //$db->update("UPDATE pw_forums SET fupadmin=".S::sqlEscape($fupadmin2)." WHERE fid=".S::sqlEscape($sub2['fid'])); pwQuery::update('pw_forums', 'fid=:fid', array($sub2['fid']), array('fupadmin' => $fupadmin2)); } } } } } } } } if ($havechild) { /* $havechilds = S::sqlImplode($havechild); $db->update("UPDATE pw_forums SET childid='1' WHERE fid IN($havechilds)"); */ pwQuery::update('pw_forums', 'fid IN(:fid)', array($havechild), array('childid' => '1')); } }
/** * 更新userstatus字段 * * @param int $userId 用户id * @param int $bit 用户状态类型 常量:PW_USERSTATUS_* * @param bool|int $status 状态值,0-false, 1-true, other * @param int $num 所占bit位数 * @return int 更新条数 */ function setUserStatus($userId, $bit, $status = true, $num = 1) { list($userId, $bit, $num) = array(intval($userId), intval($bit), intval($num)); if ($userId <= 0 || $bit <= 0 || $num <= 0) { return false; } $status = sprintf('%0' . $num . 'b', $status); // to binary --$bit; $userstatus = array(); $userstatus[] = '&~((pow(2, ' . $num . ') - 1)<<' . $bit . ')'; //alacner said: clean all bits for ($i = $num - 1; $i >= 0; $i--) { if (isset($status[$i]) && $status[$i]) { $userstatus[] = '|(1<<' . $bit . ')'; } else { $userstatus[] = '&~(1<<' . $bit . ')'; } ++$bit; } $userstatus = 'userstatus=userstatus' . implode('', $userstatus); //* $this->_db->update("UPDATE " . $this->_tableName . " SET $userstatus WHERE uid=" . $this->_addSlashes($userId)); $this->_db->update(pwQuery::buildClause("UPDATE :pw_table SET {$userstatus} WHERE uid=:uid", array($this->_tableName, $userId))); return $this->_db->affected_rows(); }
function _reCountColony($tids) { $query = $this->db->query("SELECT COUNT(*) AS tnum, SUM(b.replies+1) AS pnum, a.cyid FROM pw_argument a LEFT JOIN pw_threads b ON a.tid=b.tid WHERE a.tid IN(" . S::sqlImplode($tids) . ") AND b.fid>0 AND b.ifcheck='1' GROUP BY a.cyid"); while ($rt = $this->db->fetch_array($query)) { //* $this->db->update("UPDATE pw_colonys SET tnum=tnum-" . S::sqlEscape($rt['tnum']) . ',pnum=pnum-' . S::sqlEscape($rt['pnum']) . ' WHERE id=' . S::sqlEscape($rt['cyid'])); $this->db->update(pwQuery::buildClause("UPDATE :pw_table SET tnum=tnum-:tnum,pnum=pnum-:pnum WHERE id=:id", array('pw_colonys', $rt['tnum'], $rt['pnum'], $rt['cyid']))); } }
function topicModify($tid, $postdata) { if ($postdata['ifcheck']) { $actions = '+'; $this->info['tnum']++; } else { $actions = '-'; $this->info['tnum']--; } //* $this->_db->update("UPDATE pw_colonys SET tnum=tnum{$actions}'1' WHERE id=" . S::sqlEscape($this->cyid)); $this->_db->update(pwQuery::buildClause("UPDATE :pw_table SET tnum=tnum{$actions}'1' WHERE id=:id", array('pw_colonys', $this->cyid))); updateGroupLevel($this->cyid, $this->info); }
$db->free_result($query); $count = $db->get_value('SELECT COUNT(*) FROM pw_colonys WHERE 1' . $sqladd); if ($count > $db_perpage) { $pages = numofpage($count, $page, ceil($count / $db_perpage), "{$basename}&action=colony{$pageadd}&"); } $jsStyle = pwJsonEncode($o_styledb); $jsStyleRelation = pwJsonEncode($o_style_relation); require_once PrintApp('admin'); } else { S::gp(array('ifshow', 'selid', 'ids', 'ifshowpic', 'vieworder')); $basename .= '&action=colony'; is_array($ifshow) || ($ifshow = array()); is_array($vieworder) || ($vieworder = array()); foreach ($ids as $key => $id) { //* $db->update("UPDATE pw_colonys SET ifshow=".S::sqlEscape($ifshow[$id]).",vieworder=".S::sqlEscape($vieworder[$id]).",ifshowpic=".S::sqlEscape($ifshowpic[$id])." WHERE id=".S::sqlEscape($id)); $db->update(pwQuery::buildClause("UPDATE :pw_table SET ifshow=:ifshow,vieworder=:vieworder,ifshowpic=:ifshowpic WHERE id=:id", array('pw_colonys', $ifshow[$id], $vieworder[$id], $ifshowpic[$id], $id))); } adminmsg('operate_success'); } } elseif ($action == 'editcolony') { require_once R_P . 'require/credit.php'; require_once R_P . 'apps/groups/lib/colony.class.php'; S::gp(array('cyid')); $colony = $db->get_one("SELECT * FROM pw_colonys WHERE id=" . S::sqlEscape($cyid)); !$colony && adminmsg('undefined_action'); if (empty($_POST['step'])) { is_array($creditset = unserialize($colony['creditset'])) || ($creditset = array()); list($colony['cnimg']) = PwColony::getColonyCnimg($colony['cnimg']); $filetype = is_array($db_uploadfiletype) ? $db_uploadfiletype : unserialize($db_uploadfiletype); $default_type = array('gif', 'jpg', 'jpeg', 'bmp', 'png'); foreach ($default_type as $value) {
$rvrc += $value['rvrc']; $money += $value['money']; $credits += $value['credit']; $currency += $value['currency']; $deposit += $value['deposit']; $ddeposit += $value['ddeposit']; $creditdb = $credit->get($value['uid'], 'CUSTOM'); foreach ($creditdb as $k => $val) { /** $db->pw_update( "SELECT uid FROM pw_membercredit WHERE uid=".S::sqlEscape($newuid)."AND cid=".S::sqlEscape($k), "UPDATE pw_membercredit SET value=value+".S::sqlEscape($val[1])."WHERE uid=".S::sqlEscape($newuid)."AND cid=".S::sqlEscape($k), "INSERT INTO pw_membercredit SET".S::sqlSingle(array('uid'=>$newuid,'cid'=>$k,'value'=>$val[1])) ); **/ $db->pw_update("SELECT uid FROM pw_membercredit WHERE uid=" . S::sqlEscape($newuid) . "AND cid=" . S::sqlEscape($k), pwQuery::buildClause("UPDATE :pw_table SET value=value+:value WHERE uid=:uid AND cid=:cid", array('pw_membercredit', $val[1], $newuid, $k)), pwQuery::insertClause('pw_membercredit', array('uid' => $newuid, 'cid' => $k, 'value' => $val[1]))); } //$db->update("UPDATE pw_threads SET ".S::sqlSingle(array('author'=>$touser['username'],'authorid'=>$newuid))."WHERE authorid=".S::sqlEscape($value['uid'])); pwQuery::update('pw_threads', 'authorid=:authorid', array($value['uid']), array('author' => $touser['username'], 'authorid' => $newuid)); foreach ($ptable_a as $val) { //$db->update("UPDATE $val SET ".S::sqlSingle(array('author'=>$touser['username'],'authorid'=>$newuid))."WHERE authorid=".S::sqlEscape($value['uid'])); pwQuery::update($val, 'authorid=:authorid', array($value['uid']), array('author' => $touser['username'], 'authorid' => $newuid)); } $db->update("UPDATE pw_attachs SET uid=" . S::sqlEscape($newuid) . "WHERE uid=" . S::sqlEscape($value['uid'])); $userService->delete($value['uid']); $messageServer = L::loadClass('message', 'message'); $messageServer->clearMessages($value['uid'], array('groupsms', 'sms', 'notice', 'request', 'history')); } $mainFields = array(); $memberDataFields = array('postnum' => $postnum, 'digests' => $digests, 'rvrc' => $rvrc, 'money' => $money, 'credit' => $credits, 'currency' => $currency); $memberInfoFields = array('deposit' => $deposit, 'ddeposit' => $ddeposit);
} require_once PrintEot('m_topicadmin'); footer(); } else { PostCheck(); S::gp(array('ifmsg', 'nextto', 'timelimit', 'ifpush')); $timelimit < 0 && ($timelimit = 24); $downtime = $timelimit * 3600; $msgdb = $logdb = array(); //* $threadList = L::loadClass("threadlist", 'forum'); $query = $db->query("SELECT tid,fid,postdate,author,authorid,subject,locked FROM pw_threads WHERE tid IN(" . S::sqlImplode($selids) . ")"); while ($rt = $db->fetch_array($query)) { $sql = "locked='" . ($ifpush ? $rt['locked'] % 3 + 3 : $rt['locked'] % 3) . "'"; $db->update("UPDATE pw_argument SET lastpost=lastpost-" . S::sqlEscape($downtime) . " WHERE tid=" . S::sqlEscape($rt['tid'])); //$db->update("UPDATE pw_threads SET $sql WHERE tid=".S::sqlEscape($rt['tid'])); $db->update(pwQuery::buildClause("UPDATE :pw_table SET {$sql} WHERE tid=:tid", array('pw_threads', $rt['tid']))); if ($ifmsg) { $msgdb[] = array('toUser' => $rt['author'], 'title' => getLangInfo('writemsg', 'down_title'), 'content' => getLangInfo('writemsg', 'down_content', array('manager' => $windid, 'timelimit' => $timelimit, 'fid' => $fid, 'tid' => $rt['tid'], 'subject' => $rt['subject'], 'postdate' => get_date($rt['postdate']), 'forum' => strip_tags($forum[$fid]['name']), 'admindate' => get_date($timestamp), 'reason' => stripslashes($atc_content)))); } $logdb[] = array('type' => 'down', 'username1' => $rt['author'], 'username2' => $windid, 'field1' => $fid, 'field2' => $rt['tid'], 'field3' => '', 'descrip' => 'down_descrip', 'timestamp' => $timestamp, 'ip' => $onlineip, 'tid' => $rt['tid'], 'subject' => substrs($rt['subject'], 28), 'forum' => $forum[$fid]['name'], 'reason' => stripslashes($atc_content)); //* $threadList->updateThreadIdsByForumId($fid,$rt['tid'],$downtime); Perf::gatherInfo('changeThreadWithForumIds', array('fid' => $fid)); } sendMawholeMessages($msgdb); foreach ($logdb as $key => $val) { writelog($val); } refreshto("apps.php?q=group&a=thread&cyid={$cyid}", 'downtopic_success'); } } elseif ($action == 'highlight') { if (empty($_POST['step'])) {
/** * 发表、回复、修改帖子后更新帖子数、回复时间和生成静态页面访问地址的函数 * * @param int $fid 所属版块 * @param int $allowhtm 是否允许生成静态页 * @param string $type new:发表新帖、reply:回复 * @param string $sys_type:现无用 */ function lastinfo($fid, $allowhtm = 0, $type = '', $sys_type = '') { global $db, $R_url, $db_readdir, $foruminfo, $tid, $windid, $timestamp, $atc_title, $t_date, $replytitle; if ($type == 'new') { $rt['tid'] = $tid; $rt['postdate'] = $timestamp; $rt['lastpost'] = $timestamp; $author = $windid; $subject = substrs($atc_title, 26); $topicadd = ",tpost=tpost+1,article=article+1,topic=topic+1 "; $fupadd = "subtopic=subtopic+1,tpost=tpost+1,article=article+1"; } elseif ($type == 'reply') { $rt['tid'] = $tid; $rt['postdate'] = $t_date; $rt['lastpost'] = $timestamp; $author = $windid; $subject = $atc_title ? substrs($atc_title, 26) : 'Re:' . addslashes(substrs($replytitle, 26)); $topicadd = ",tpost=tpost+1,article=article+1 "; $fupadd = "tpost=tpost+1,article=article+1 "; } else { $rt = $db->get_one("SELECT tid,author,postdate,subject,lastpost,lastposter FROM pw_threads WHERE fid=" . S::sqlEscape($fid) . " AND specialsort=0 AND ifcheck=1 AND lastpost>0 ORDER BY lastpost DESC LIMIT 0,1"); if ($rt['postdate'] == $rt['lastpost']) { $subject = addslashes(substrs($rt['subject'], 26)); $author = $rt['author']; } else { $subject = 'Re:' . addslashes(substrs($rt['subject'], 26)); $author = $rt['lastposter']; } $topicadd = $fupadd = ""; } $GLOBALS['anonymous'] && ($author = $GLOBALS['db_anonymousname']); $htmurl = $db_readdir . '/' . $fid . '/' . date('ym', $rt['postdate']) . '/' . $rt['tid'] . '.html'; $new_url = file_exists(R_P . $htmurl) && $allowhtm && $sys_type != '1B' ? "{$R_url}/{$htmurl}" : "read.php?tid={$rt['tid']}&page=e#a"; $lastpost = $subject . "\t" . addslashes($author) . "\t" . $rt['lastpost'] . "\t" . $new_url; //* $db->update("UPDATE pw_forumdata SET lastpost=".S::sqlEscape($lastpost).$topicadd." WHERE fid=".S::sqlEscape($fid)); $db->update(pwQuery::buildClause("UPDATE :pw_table SET lastpost=:lastpost {$topicadd} WHERE fid=:fid", array('pw_forumdata', $lastpost, $fid))); if ($foruminfo['type'] == 'sub' || $foruminfo['type'] == 'sub2') { if ($foruminfo['password'] != '' || $foruminfo['allowvisit'] != '' || $foruminfo['f_type'] == 'hidden') { $lastpost = ''; } else { $lastpost = "lastpost=" . S::sqlEscape($lastpost); } if ($lastpost && $fupadd) { $lastpost .= ', '; } if ($lastpost || $fupadd) { $db->update("UPDATE pw_forumdata SET {$lastpost} {$fupadd} WHERE fid=" . S::sqlEscape($foruminfo['fup'])); Perf::gatherInfo('changeForumData', array('fid' => $foruminfo['fup'])); if ($foruminfo['type'] == 'sub2') { $rt1 = $db->get_one("SELECT fup FROM pw_forums WHERE fid=" . S::sqlEscape($foruminfo['fup'])); $db->update("UPDATE pw_forumdata SET {$lastpost} {$fupadd} WHERE fid=" . S::sqlEscape($rt1['fup'])); Perf::gatherInfo('changeForumData', array('fid' => $rt1['fup'])); } } } }
list($t, $e) = explode(',', $thread['toolfield']); $sqladd = ''; if ($t && $t < $timestamp) { $sqladd .= ",toolinfo='',topped='0'"; $t = ''; $thread['topped'] > 0 && ($updatetop = 1); } if ($e && $e < $timestamp) { $sqladd .= ",titlefont=''"; $thread['titlefont'] = ''; $e = ''; } if ($sqladd) { $thread['toolfield'] = $t . ($e ? ',' . $e : ''); //$db->update("UPDATE pw_threads SET toolfield=".S::sqlEscape($thread['toolfield'])." $sqladd WHERE tid=".S::sqlEscape($thread['tid'])); $db->update(pwQuery::buildClause("UPDATE :pw_table SET toolfield=:toolfield {$sqladd} WHERE tid=:tid", array('pw_threads', $thread['toolfield'], $thread['tid']))); } } $thread['src_subject'] = $thread['subject']; $thread['subject'] = substrs($thread['subject'], 54); if ($thread['titlefont']) { $titledetail = explode("~", $thread['titlefont']); if ($titledetail[0]) { $thread['subject'] = "<font color={$titledetail['0']}>{$thread['subject']}</font>"; } if ($titledetail[1]) { $thread['subject'] = "<b>{$thread['subject']}</b>"; } if ($titledetail[2]) { $thread['subject'] = "<i>{$thread['subject']}</i>"; }
/** * 删除活动 * void */ function delActive($id) { list($activedb) = $this->searchList(array('id' => $id)); foreach ($activedb as $key => $value) { if ($value['poster']) { pwDelatt($value['poster'], $GLOBALS['db_ifftp']); } //* $this->_db->update("UPDATE pw_colonys SET activitynum=activitynum-1 WHERE id=". S::sqlEscape($value['cid'])); $this->_db->update(pwQuery::buildClause("UPDATE :pw_table SET activitynum=activitynum-1 WHERE id=:id", array('pw_colonys', $value['cid']))); } $this->_db->update("DELETE FROM pw_actmembers WHERE actid" . $this->sqlIn($id)); $this->_db->update("DELETE FROM pw_active WHERE id" . $this->sqlIn($id)); }
/** * 对给定数据进行数据库积分增减操作 * * @param array $setArr 操作数据 array(1 => array('money' => ??, 'rvrc' => ??), 2 => array(), 3 => array(), ...) * @param bool $isAdd 是否实时进行数据库操作 */ function runsql($setArr = null, $isAdd = true) { global $db, $uc_server, $uc_syncredit; $setUser = isset($setArr) ? $setArr : $this->setUser; $retv = array(); if ($uc_server && $uc_syncredit) { require_once R_P . 'uc_client/uc_client.php'; $retv = uc_credit_add($setUser, $isAdd); } $cacheUids = $cacheCredits = array(); $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */ foreach ($setUser as $uid => $setv) { $updateUser = $increaseUser = array(); foreach ($setv as $cid => $v) { if ($this->check($cid) && ($v != 0 || !$isAdd)) { if (isset($retv[$uid][$cid])) { if ($uc_server == 1) { continue; } $act = 'set'; $v = $retv[$uid][$cid]; } else { $act = $isAdd ? 'add' : 'set'; } if (is_numeric($cid)) { $v = intval($v); /** $db->pw_update( "SELECT uid FROM pw_membercredit WHERE uid=" . S::sqlEscape($uid) . ' AND cid=' . S::sqlEscape($cid), "UPDATE pw_membercredit SET " . ($act == 'add' ? 'value=value+' : 'value=') . S::sqlEscape($v) . ' WHERE uid=' . S::sqlEscape($uid) . ' AND cid=' . S::sqlEscape($cid), "INSERT INTO pw_membercredit SET " . S::sqlSingle(array('uid' => $uid, 'cid' => $cid, 'value' => $v)) ); **/ $db->pw_update("SELECT uid FROM pw_membercredit WHERE uid=" . S::sqlEscape($uid) . ' AND cid=' . S::sqlEscape($cid), pwQuery::buildClause("UPDATE :pw_table SET " . ($act == 'add' ? 'value=value+' : 'value=') . ':value' . ' WHERE uid=:uid AND cid=:cid', array('pw_membercredit', $v, $uid, $cid)), pwQuery::insertClause('pw_membercredit', array('uid' => $uid, 'cid' => $cid, 'value' => $v))); } else { $cid == 'rvrc' && ($v *= 10); if ($act == 'add') { $increaseUser[$cid] = intval($v); } else { $updateUser[$cid] = intval($v); } } } } if ($increaseUser) { $userService->updateByIncrement($uid, array(), $increaseUser); } if ($updateUser) { $userService->update($uid, array(), $updateUser); } unset($this->getUser[$uid]); $cacheUids[] = 'UID_' . $uid; $cacheCredits[] = 'UID_CREDIT_' . $uid; } // if ($cacheUids) { // $_cache = getDatastore(); // $_cache->delete($cacheUids); // $_cache->delete($cacheCredits);/*积分*/ // } $this->writeLog(); !isset($setArr) && ($this->setUser = array()); }
/** * 根据uid获取所有未付款的记录 * @param int $uid * @return array */ function getUnPayedLogsByUid($uid) { $uid = intval($uid); if ($uid < 1) { return array(); } $query = $this->_db->query(pwQuery::buildClause("SELECT l.*, s.name, s.price, s.discount,s.day FROM {$this->_tableName} l LEFT JOIN pw_kmd_spread s USING(sid) WHERE l.uid=:uid AND l.status=:status ORDER BY l.createtime DESC", array($uid, 1))); return $this->_getAllResultFromQuery($query, 'id'); }