$multi = preg_replace("/href=\"" . ADMINSCRIPT . "\\?action=recyclebin&page=(\\d+)\"/", "href=\"javascript:page(\\1)\"", $multi); $multi = str_replace("window.location='" . ADMINSCRIPT . "?action=recyclebin&page='+this.value", "page(this.value)", $multi); echo '<script type="text/JavaScript">var replyreload;function attachimg() {}</script>'; showtagheader('div', 'threadlist', $searchsubmit); showformheader('recyclebin&operation=search&frame=no', 'target="rbframe"', 'rbform'); showtableheader(cplang('recyclebin_result') . ' ' . $threadcount . ' <a href="#" onclick="$(\'threadlist\').style.display=\'none\';$(\'threadsearch\').style.display=\'\';" class="act lightlink normal">' . cplang('research') . '</a>', 'fixpadding'); while ($thread = DB::fetch($query)) { $posttable = $thread['posttableid'] ? "forum_post_{$thread['posttableid']}" : 'forum_post'; $post = DB::fetch_first("SELECT p.message, p.useip, p.attachment, p.htmlon, p.smileyoff, p.bbcodeoff FROM " . DB::table($posttable) . " p WHERE p.tid='{$thread['tid']}' AND p.first='1'"); $thread = array_merge($thread, $post); $thread['message'] = discuzcode($thread['message'], $thread['smileyoff'], $thread['bbcodeoff'], sprintf('%00b', $thread['htmlon']), $thread['allowsmilies'], $thread['allowbbcode'], $thread['allowimgcode'], $thread['allowhtml']); $thread['moddateline'] = dgmdate($thread['moddateline']); $thread['dateline'] = dgmdate($thread['dateline']); if ($thread['attachment']) { require_once libfile('function/attachment'); $queryattach = DB::query("SELECT aid, filename, filesize, attachment, isimage, remote FROM " . DB::table(getattachtablebytid($thread['tid'])) . " WHERE tid='{$thread['tid']}'"); while ($attach = DB::fetch($queryattach)) { $_G['setting']['attachurl'] = $attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']; $attach['url'] = $attach['isimage'] ? " {$attach['filename']} (" . sizecount($attach['filesize']) . ")<br /><br /><img src=\"" . $_G['setting']['attachurl'] . "forum/{$attach['attachment']}\" onload=\"if(this.width > 400) {this.resized=true; this.width=400;}\">" : "<a href=\"" . $_G['setting']['attachurl'] . "forum/{$attach['attachment']}\" target=\"_blank\">{$attach['filename']}</a> (" . sizecount($attach['filesize']) . ")"; $thread['message'] .= "<br /><br />{$lang['attachment']}: " . attachtype(fileext($attach['filename']) . "\t") . $attach['url']; } } showtablerow("id=\"mod_{$thread['tid']}_row1\"", array('rowspan="3" class="rowform threadopt" style="width:80px;"', 'class="threadtitle"'), array("<ul class=\"nofloat\"><li><input class=\"radio\" type=\"radio\" name=\"moderate[{$thread['tid']}]\" id=\"mod_{$thread['tid']}_1\" value=\"delete\" checked=\"checked\" /><label for=\"mod_{$thread['tid']}_1\">{$lang['delete']}</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[{$thread['tid']}]\" id=\"mod_{$thread['tid']}_2\" value=\"undelete\" /><label for=\"mod_{$thread['tid']}_2\">{$lang['undelete']}</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[{$thread['tid']}]\" id=\"mod_{$thread['tid']}_3\" value=\"ignore\" /><label for=\"mod_{$thread['tid']}_3\">{$lang['ignore']}</label></li></ul>", "<h3><a href=\"forum.php?mod=forumdisplay&fid={$thread['fid']}\" target=\"_blank\">{$thread['forumname']}</a> » {$thread['subject']}</h3><p><span class=\"bold\">{$lang['author']}:</span> <a href=\"home.php?mod=space&uid={$thread['authorid']}\" target=\"_blank\">{$thread['author']}</a> <span class=\"bold\">{$lang['time']}:</span> {$thread['dateline']} {$lang['threads_replies']}: {$thread['replies']} {$lang['threads_views']}: {$thread['views']}</p>")); showtablerow("id=\"mod_{$thread['tid']}_row2\"", 'colspan="2" style="padding: 10px; line-height: 180%;"', '<div style="overflow: auto; overflow-x: hidden; max-height:120px; height:auto !important; height:120px; word-break: break-all;">' . $thread['message'] . '</div>'); showtablerow("id=\"mod_{$thread['tid']}_row3\"", 'class="threadopt threadtitle" colspan="2"', "{$lang['operator']}: <a href=\"home.php?mod=space&uid={$thread['moduid']}\" target=\"_blank\">{$thread['modusername']}</a> {$lang['recyclebin_delete_time']}: {$thread['moddateline']} {$lang['reason']}: {$thread['reason']}"); } showsubmit('rbsubmit', 'submit', '', '<a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'delete\')">' . cplang('recyclebin_all_delete') . '</a> <a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'undelete\')">' . cplang('recyclebin_all_undelete') . '</a> <a href="#rb" onclick="checkAll(\'option\', $(\'rbform\'), \'ignore\')">' . cplang('recyclebin_all_ignore') . '</a> ', $multi); showtablefooter(); showformfooter(); echo '<iframe name="rbframe" style="display:none"></iframe>'; showtagfooter('div');
function _reportPostData($type, $tid, $pid, $threadUrl, $extra = null) { global $_G; if (!$this->_secStatus) { return false; } $startTime = microtime(true); $tid = intval($tid); $pid = intval($pid); $thread = DB::fetch(DB::query("SELECT * FROM " . DB::table('forum_thread') . " WHERE tid='{$tid}'")); if (!is_array($thread)) { return true; } $post = DB::fetch(DB::query("SELECT * FROM " . DB::table(getposttable($thread['posttableid'])) . " WHERE pid='{$pid}'")); $member = DB::fetch_first("SELECT * FROM " . DB::table('common_member') . " WHERE uid = '{$post['authorid']}'"); $memberField = DB::fetch_first("SELECT * FROM " . DB::table('common_member_field_forum') . " WHERE uid='{$post['authorid']}'"); $memberStatus = DB::fetch_first("SELECT * FROM " . DB::table('common_member_status') . " WHERE uid='{$post['authorid']}'"); $memberVerify = DB::fetch_first("SELECT * FROM " . DB::table('common_member_verify') . " WHERE uid = '{$post['authorid']}'"); if ($post['first'] == 1) { $type = $type . 'Thread'; } else { $type = $type . 'Post'; } $query = DB::query('SELECT filename,filesize FROM ' . DB::table(getattachtablebytid($tid)) . " WHERE pid='{$pid}'"); while ($res = DB::fetch($query)) { $postAttachs[] = array('filename' => $res['filename'], 'filesize' => $res['filesize']); } if (!$post['first']) { $firstPost = DB::fetch(DB::query("SELECT * FROM " . DB::table(getposttable($thread['posttableid'])) . " WHERE tid='{$tid}' and first=1")); $query = DB::query('SELECT filename,filesize FROM ' . DB::table(getattachtablebytid($tid)) . " WHERE pid='{$pid}'"); while ($res = DB::fetch($query)) { $threadAttachs[] = array('filename' => $res['filename'], 'filesize' => $res['filesize']); } } else { $firstPost = $post; $firstPostAttachs = $postAttachs; } $views = intval($thread['views']); $replies = intval($thread['replies']); $favourites = intval($thread['favtimes']); $supports = intval($thread['recommend_add']); $opposes = intval($thread['recommend_sub']); $shares = intval($thread['sharetimes']); if ($member['conisbind']) { $memberConnect = DB::fetch_first('SELECT * FROM ' . DB::table('common_member_connect') . ' WHERE uid=\'' . $_G['uid'] . '\''); $openId = $memberConnect['conopenid']; } else { $openId = 0; } if (!$thread || !$post) { return true; } $fid = $thread["fid"]; if ($post['first']) { $threadShield = $post['status'] & 1 ? 1 : 2; $threadWarning = $post['status'] & 2 ? 1 : 2; } else { $threadShield = $firstPost['status'] & 1 ? 1 : 2; $threadWarning = $firstPost['status'] & 2 ? 1 : 2; } $threadSort = 2; if ($thread['sortid']) { $threadSort = 1; if ($post['first']) { $sortMessage = $this->convertSortInfo($thread['sortid'], $thread['tid']); $post['message'] = $sortMessage . '<br/>' . $post['message']; } } $contentBitMap = array('onTop' => $thread['displayorder'] ? 1 : 2, 'hide' => strpos($post['message'], '[hide') ? 1 : 2, 'digest' => $thread['digest'] ? 1 : 2, 'highLight' => $thread['highlight'] ? 1 : 2, 'special' => $thread['special'] ? 1 : 2, 'threadAttach' => 2, 'threadAttachFlash' => 2, 'threadAttachPic' => 2, 'threadAttachVideo' => 2, 'threadAttachAudio' => 2, 'threadShield' => $threadShield, 'threadWarning' => $threadWarning, 'postAttach' => 2, 'postAttachFlash' => 2, 'postAttachPic' => 2, 'postAttachVideo' => 2, 'postAttachAudio' => 2, 'postShield' => $post['status'] & 1 ? 1 : 2, 'postWarning' => $post['status'] & 2 ? 1 : 2, 'isAdmin' => $member['adminid'] ? 1 : 2, 'threadSort' => $threadSort, 'isRush' => getstatus($thread['status'], 3) ? 1 : 2, 'hasReadPerm' => $thread['readperm'] ? 1 : 2, 'hasStamp' => $thread['stamp'] >= 0 ? 1 : 2, 'hasIcon' => $thread['icon'] >= 0 ? 1 : 2, 'isPushed' => $thread['pushedaid'] ? 1 : 2, 'hasCover' => $thread['cover'] ? 1 : 2, 'hasReward' => $thread['replycredit'] ? 1 : 2, 'threadStatus' => $thread['status'], 'postStatus' => $post['status']); if ($post['first']) { $contentBitMap['isMobile'] = $this->isMobile($thread['status']) ? 1 : 2; if ($contentBitMap['isMobile'] == 1) { $contentBitMap['isMobileSound'] = $this->mobileHasSound($thread['status']) ? 1 : 2; $contentBitMap['isMobilePhoto'] = $this->mobileHasPhoto($thread['status']) ? 1 : 2; $contentBitMap['isMobileGPS'] = $this->mobileHasGPS($thread['status']) ? 1 : 2; } } else { $contentBitMap['isMobile'] = getstatus($post['status'], 4) ? 1 : 2; } $userBitMap = array('isAdmin' => $member['adminid'] ? 1 : 2, 'hasMedal' => $memberField['medals'] ? 1 : 2, 'hasAvatar' => $member['avatarstatus'] ? 1 : 2, 'hasVerify' => is_array($memberVerify) ? 1 : 2); $videoExt = array('.rm', '.flv', '.mkv', '.rmvb', '.avi', '.wmv', '.mp4', '.mpeg', '.mpg'); $audioExt = array('.wav', '.mid', '.mp3', '.m3u', '.wma', '.asf', '.asx'); if ($firstPostAttachs) { foreach ($firstPostAttachs as $attach) { $fileExt = substr($attach['filename'], strrpos($attach['filename'], '.')); if ($fileExt == '.bmp' || $fileExt == '.jpg' || $fileExt == '.jpeg' || $fileExt == '.gif' || $fileExt == '.png') { $contentBitMap['threadAttachPic'] = 1; } if ($fileExt == '.swf' || $fileExt == '.fla') { $contentBitMap['threadAttachFlash'] = 1; } if (in_array($fileExt, $videoExt)) { $contentBitMap['threadAttachVideo'] = 1; } if (in_array($fileExt, $audioExt)) { $contentBitMap['threadAttachAudio'] = 1; } } $contentBitMap['threadAttach'] = 1; } if ($postAttachs) { foreach ($postAttachs as $attach) { $fileExt = substr($attach['filename'], strrpos($attach['filename'], '.')); if ($fileExt == '.bmp' || $fileExt == '.jpg' || $fileExt == '.jpeg' || $fileExt == '.gif' || $fileExt == '.png') { $contentBitMap['postAttachPic'] = 1; } if ($fileExt == '.swf' || $fileExt == '.fla') { $contentBitMap['postAttachFlash'] = 1; } if (in_array($fileExt, $videoExt)) { $contentBitMap['postAttachVideo'] = 1; } if (in_array($fileExt, $audioExt)) { $contentBitMap['postAttachAudio'] = 1; } } $contentBitMap['postAttach'] = 1; } if ($thread['authorid'] == $_G['uid']) { $threadEmail = $_G['member']['email']; } else { $threadEmail = DB::result_first('SELECT email FROM ' . DB::table('common_member') . ' WHERE uid=' . $thread['authorid']); } if ($post['authorid'] == $_G['uid']) { $postEmail = $_G['member']['email']; } else { $postEmail = DB::result_first('SELECT email FROM ' . DB::table('common_member') . ' WHERE uid=' . $post['authorid']); } if ($thread['special']) { if (array_key_exists($thread['special'], $this->specialType)) { $threadSpecial = $this->specialType[$thread['special']]; } else { $threadSpecial = 'other'; } } if ($_G['gp_action'] == 'newtrade') { $type = 'newThread'; $pid = $firstPost['pid']; } $batchData[] = array('tId' => $tid, 'pId' => $pid, 'threadUid' => intval($thread['authorid']), 'threadUsername' => $thread['author'], 'threadEmail' => $threadEmail, 'postUid' => intval($post['authorid']), 'postUsername' => $post['author'], 'postEmail' => $postEmail, 'openId' => $openId, 'fId' => intval($fid), 'threadUrl' => $threadUrl, 'operateTime' => $_G['timestamp'], 'clientIp' => $_G['clientip'], 'remoteIp' => $_SERVER['REMOTE_ADDR'], 'views' => $views, 'replies' => $replies, 'favourites' => $favourites, 'supports' => $supports, 'opposes' => $opposes, 'shares' => $shares, 'title' => $post['subject'], 'content' => $post['message'], 'sortMessage' => $sortMessage, 'attachList' => $postAttachs, 'reportType' => $type, 'contentBitMap' => $contentBitMap, 'userBitMap' => $userBitMap, 'extra' => $extra, 'specialType' => $threadSpecial, 'signature' => $memberField['sightml'], 'userAgent' => $this->_getUA()); $result = $this->_secClient->securityReportPost($batchData); $this->benchMarkLog($startTime, $pid, $batchData, $type); if (!$result) { $ids = array($tid, $pid); $this->logFailed($type, $ids); return false; } else { return true; } }
function updateattachtid($where, $oldtid, $newtid) { $oldattachtable = getattachtablebytid($oldtid); $newattachtable = getattachtablebytid($newtid); if ($oldattachtable != $newattachtable) { $query = DB::query("SELECT * FROM " . DB::table($oldattachtable) . " WHERE {$where}"); while ($attach = DB::fetch($query)) { $attach = daddslashes($attach); $attach['tid'] = $newtid; DB::insert($newattachtable, $attach); } DB::delete($oldattachtable, $where); } DB::query("UPDATE " . DB::table('forum_attachment') . " SET tid='{$newtid}',tableid='" . getattachtableid($newtid) . "' WHERE {$where}"); }
} $thread_attachment = $post_attachment = 0; $query = DB::query("SELECT pid, attachment, thumb, remote, aid FROM " . DB::table(getattachtablebytid($_G['tid'])) . " WHERE tid='{$_G['tid']}'"); while ($attach = DB::fetch($query)) { if ($attach['pid'] == $pid) { if ($thread['displayorder'] >= 0) { $post_attachment++; } dunlink($attach); } else { $thread_attachment = 1; } } if ($post_attachment) { DB::query("DELETE FROM " . DB::table('forum_attachment') . " WHERE pid='{$pid}'", 'UNBUFFEREED'); DB::query("DELETE FROM " . DB::table(getattachtablebytid($_G['tid'])) . " WHERE pid='{$pid}'", 'UNBUFFEREED'); updatecreditbyaction('postattach', $orig['authorid'], array(), '', -$post_attachment); } DB::query("DELETE FROM " . DB::table($posttable) . " WHERE pid='{$pid}'"); DB::delete('forum_postcomment', "rpid='{$pid}'"); if ($thread['special'] == 2) { DB::query("DELETE FROM " . DB::table('forum_trade') . " WHERE pid='{$pid}'"); } if ($isfirstpost) { $forumadd = 'threads=threads-\'1\', posts=posts-\'1\''; $tablearray = array('forum_threadmod', 'forum_relatedthread', 'forum_thread', 'forum_debate', 'forum_debatepost', 'forum_polloption', 'forum_poll', 'forum_typeoptionvar'); foreach ($tablearray as $table) { DB::query("DELETE FROM " . DB::table($table) . " WHERE tid='{$_G['tid']}'", 'UNBUFFERED'); } if ($_G['setting']['globalstick'] && in_array($thread['displayorder'], array(2, 3))) { require_once libfile('function/cache');
$stylestr = sprintf('%03b', $string[0]); for ($i = 1; $i <= 3; $i++) { $stylecheck[$i] = $stylestr[$i - 1] ? 1 : 0; } $colorcheck = $string[1]; $_G['forum']['modrecommend'] = is_array($_G['forum']['modrecommend']) ? $_G['forum']['modrecommend'] : array(); } elseif ($_G['gp_optgroup'] == 2 || $_G['gp_optgroup'] == 5) { require_once libfile('function/forumlist'); $forumselect = forumselect(FALSE, 0, $threadlist[$_G['tid']]['fid']); $typeselect = typeselect($single ? $threadlist[$_G['tid']]['typeid'] : 0); } elseif ($_G['gp_optgroup'] == 4 && $single) { empty($threadlist[$_G['tid']]['closed']) ? $closecheck[0] = 'checked="checked"' : ($closecheck[1] = 'checked="checked"'); } $imgattach = array(); if (count($threadlist) == 1 && $operation == 'recommend') { $query = DB::query("SELECT * FROM " . DB::table(getattachtablebytid($_G['tid'])) . " WHERE tid='{$_G['tid']}' AND isimage IN ('1', '-1')"); while ($row = DB::fetch($query)) { $imgattach[] = $row; } $query = DB::query("SELECT * FROM " . DB::table('forum_forumrecommend') . " WHERE tid='{$_G['tid']}'"); if ($oldthread = DB::fetch($query)) { $threadlist[$_G['tid']]['subject'] = $oldthread['subject']; $selectposition[$oldthread['position']] = ' selected="selected"'; $selectattach = $oldthread['aid']; } else { $selectattach = $imgattach[0]['aid']; $selectposition[0] = ' selected="selected"'; } } include template('forum/topicadmin'); } else {
function recyclebinpostshowpostlist($sql, $start_limit, $lpp) { global $_G, $lang, $posttableid; $tids = $fids = array(); $query = DB::query("SELECT message, useip, attachment, htmlon, smileyoff, bbcodeoff, pid, tid, fid, author, dateline, subject, authorid, anonymous FROM " . DB::table(getposttable($posttableid)) . "\r\n\t\tWHERE invisible='-5' {$sql} ORDER BY dateline DESC LIMIT {$start_limit}, {$lpp}"); while ($post = DB::fetch($query)) { $postlist[] = $post; } if (empty($postlist)) { return false; } foreach ($postlist as $key => $post) { $tids[$post['tid']] = $post['tid']; $fids[$post['fid']] = $post['fid']; } $query = DB::query("SELECT tid, subject as tsubject FROM " . DB::table('forum_thread') . " WHERE tid IN (" . dimplode($tids) . ")"); while ($thread = DB::fetch($query)) { $threadlist[$thread['tid']] = $thread; } $query = DB::query("SELECT fid, name AS forumname, allowsmilies, allowhtml, allowbbcode, allowimgcode FROM " . DB::table('forum_forum') . " WHERE fid IN (" . dimplode($fids) . ")"); while ($forum = DB::fetch($query)) { $forumlist[$forum['fid']] = $forum; } foreach ($postlist as $key => $post) { $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], sprintf('%00b', $post['htmlon']), $forumlist[$post['fid']]['allowsmilies'], $forumlist[$post['fid']]['allowbbcode'], $forumlist[$post['fid']]['allowimgcode'], $forumlist[$post['fid']]['allowhtml']); $post['dateline'] = dgmdate($post['dateline']); if ($post['attachment']) { require_once libfile('function/attachment'); $queryattach = DB::query("SELECT aid, filename, filesize, attachment, isimage, remote FROM " . DB::table(getattachtablebytid($post['tid'])) . " WHERE pid='{$post['pid']}'"); while ($attach = DB::fetch($queryattach)) { $_G['setting']['attachurl'] = $attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']; $attach['url'] = $attach['isimage'] ? " {$attach['filename']} (" . sizecount($attach['filesize']) . ")<br /><br /><img src=\"" . $_G['setting']['attachurl'] . "forum/{$attach['attachment']}\" onload=\"if(this.width > 400) {this.resized=true; this.width=400;}\">" : "<a href=\"" . $_G['setting']['attachurl'] . "forum/{$attach['attachment']}\" target=\"_blank\">{$attach['filename']}</a> (" . sizecount($attach['filesize']) . ")"; $post['message'] .= "<br /><br />{$lang['attachment']}: " . attachtype(fileext($attach['filename']) . "\t") . $attach['url']; } } showtablerow("id=\"mod_{$post['pid']}_row1\"", array('rowspan="3" class="rowform threadopt" style="width:80px;"', 'class="threadtitle"'), array("<ul class=\"nofloat\"><li><input class=\"radio\" type=\"radio\" name=\"moderate[{$post['pid']}]\" id=\"mod_{$post['pid']}_1\" value=\"delete\" checked=\"checked\" /><label for=\"mod_{$post['pid']}_1\">{$lang['delete']}</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[{$post['pid']}]\" id=\"mod_{$post['pid']}_2\" value=\"undelete\" /><label for=\"mod_{$post['pid']}_2\">{$lang['undelete']}</label></li><li><input class=\"radio\" type=\"radio\" name=\"moderate[{$post['pid']}]\" id=\"mod_{$post['pid']}_3\" value=\"ignore\" /><label for=\"mod_{$post['pid']}_3\">{$lang['ignore']}</label></li></ul>", "<h3><a href=\"forum.php?mod=forumdisplay&fid={$post['fid']}\" target=\"_blank\">" . $forumlist[$post['fid']]['forumname'] . "</a> » <a href=\"forum.php?mod=viewthread&tid={$post['tid']}\" target=\"_blank\">" . $threadlist[$post['tid']]['tsubject'] . "</a>" . ($post['subject'] ? ' » ' . $post['subject'] : '') . "</h3><p><span class=\"bold\">{$lang['author']}:</span> <a href=\"home.php?mod=space&uid={$post['authorid']}\" target=\"_blank\">{$post['author']}</a> <span class=\"bold\">{$lang['time']}:</span> {$post['dateline']} IP: {$post['useip']}</p>")); showtablerow("id=\"mod_{$post['pid']}_row2\"", 'colspan="2" style="padding: 10px; line-height: 180%;"', '<div style="overflow: auto; overflow-x: hidden; max-height:120px; height:auto !important; height:120px; word-break: break-all;">' . $post['message'] . '</div>'); showtablerow("id=\"mod_{$post['pid']}_row3\"", 'class="threadopt threadtitle" colspan="2"', "{$lang['isanonymous']}: " . ($post['anonymous'] ? $lang['yes'] : $lang['no']) . " {$lang['ishtmlon']}: " . ($post['htmlon'] ? $lang['yes'] : $lang['no'])); } return true; }
public function before_deletepost($parameters) { $thread_attachment = $post_attachment = 0; foreach (C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $this->thread['tid'], 'tid', $this->thread['tid']) as $attach) { if ($attach['pid'] == $this->post['pid']) { if ($this->thread['displayorder'] >= 0) { $post_attachment++; } dunlink($attach); } else { $thread_attachment = 1; } } $this->param['updatefieldarr']['attachment'] = array($thread_attachment); if ($post_attachment) { C::t('forum_attachment')->delete_by_id('pid', $this->post['pid']); DB::query("DELETE FROM " . DB::table(getattachtablebytid($this->thread['tid'])) . " WHERE pid='" . $this->post['pid'] . "'", 'UNBUFFEREED'); updatecreditbyaction('postattach', $this->post['authorid'], array(), '', -$post_attachment); } }
function recommendupdate($fid, &$modrecommend, $force = '', $position = 0) { global $_G; $recommendlist = $recommendimagelist = $modedtids = array(); $num = $modrecommend['num'] ? intval($modrecommend['num']) : 10; $imagenum = $modrecommend['imagenum'] = $modrecommend['imagenum'] ? intval($modrecommend['imagenum']) : 0; $imgw = $modrecommend['imagewidth'] = $modrecommend['imagewidth'] ? intval($modrecommend['imagewidth']) : 200; $imgh = $modrecommend['imageheight'] = $modrecommend['imageheight'] ? intval($modrecommend['imageheight']) : 150; if ($modrecommend['sort'] && (TIMESTAMP - $modrecommend['updatetime'] > $modrecommend['cachelife'] || $force)) { foreach (C::t('forum_forumrecommend')->fetch_all_by_fid($fid) as $row) { if ($modrecommend['sort'] == 2 && $row['moderatorid']) { $modedtids[] = $row['tid']; } } C::t('forum_forumrecommend')->delete_by_fid($fid, $modrecommend['sort'] == 2 ? 0 : false); $orderby = 'dateline'; $dateline = $modrecommend['dateline'] ? TIMESTAMP - $modrecommend['dateline'] * 3600 : null; $recommends = null; switch ($modrecommend['orderby']) { case '': case '1': $orderby = 'lastpost'; break; case '2': $orderby = 'views'; break; case '3': $orderby = 'replies'; break; case '4': $orderby = 'digest'; break; case '5': $orderby = 'recommends'; $recommends = 0; break; case '6': $orderby = 'heats'; break; } $i = 0; $addthread = $addimg = $recommendlist = $recommendimagelist = $tids = array(); foreach (C::t('forum_thread')->fetch_all_by_fid_displayorder($fid, 0, $dateline, $recommends, 0, $num, $orderby) as $thread) { $recommendlist[$thread['tid']] = $thread; $tids[] = $thread['tid']; if (!$modedtids || !in_array($thread['tid'], $modedtids)) { $addthread[$thread['tid']] = array('fid' => $thread['fid'], 'tid' => $thread['tid'], 'position' => 1, 'displayorder' => $i, 'subject' => $thread['subject'], 'author' => $thread['author'], 'authorid' => $thread['authorid'], 'moderatorid' => 0, 'expiration' => 0, 'highlight' => $thread['highlight']); $i++; } } if ($tids && $imagenum) { $attachtables = array(); foreach ($tids as $tid) { $attachtables[getattachtablebytid($tid)][] = $tid; } foreach ($attachtables as $attachtable => $tids) { $attachmentpost = array(); $postlist = C::t('forum_post')->fetch_all_by_tid(0, $tids, false, '', 0, 0, 1); if ($postlist) { $pids = array(); foreach ($postlist as $post) { $pids[] = $post['pid']; } $attachmentlist = C::t('forum_attachment_n')->fetch_all_by_pid_width('tid:' . $tids[0], $pids, $imgw); if ($attachmentlist) { foreach ($attachmentlist as $k => $attachment) { $attachmentpost[$k]['fid'] = $postlist[$attachment['pid']]['fid']; $attachmentpost[$k]['tid'] = $postlist[$attachment['pid']]['tid']; $attachmentpost[$k]['aid'] = $attachment['aid']; } } unset($postlist, $attachmentlist, $pids); } foreach ($attachmentpost as $attachment) { if (isset($recommendimagelist[$attachment['tid']])) { continue; } $key = md5($attachment['aid'] . '|' . $imgw . '|' . $imgh); $recommendlist[$attachment['tid']]['filename'] = $attachment['aid'] . "\t" . $imgw . "\t" . $imgh . "\t" . $key; $recommendimagelist[$attachment['tid']] = $recommendlist[$attachment['tid']]; $recommendimagelist[$attachment['tid']]['subject'] = addslashes($recommendimagelist[$attachment['tid']]['subject']); $addthread[$attachment['tid']]['aid'] = ''; $addthread[$attachment['tid']]['filename'] = $recommendlist[$attachment['tid']]['filename']; $addthread[$attachment['tid']]['typeid'] = 1; if (count($recommendimagelist) == $imagenum) { break; } } } } unset($recommendimagelist); if ($addthread) { foreach ($addthread as $row) { C::t('forum_forumrecommend')->insert($row, false, true); } $modrecommend['updatetime'] = TIMESTAMP; $modrecommendnew = serialize($modrecommend); C::t('forum_forumfield')->update($fid, array('modrecommend' => $modrecommendnew)); } } $recommendlists = $recommendlist = array(); foreach (C::t('forum_forumrecommend')->fetch_all_by_fid($fid, $position) as $recommend) { if ($recommend['expiration'] && $recommend['expiration'] > TIMESTAMP || !$recommend['expiration']) { if ($recommend['filename'] && strexists($recommend['filename'], "\t")) { $imgd = explode("\t", $recommend['filename']); if ($imgd[0] && $imgd[3]) { $recommend['filename'] = 'forum.php?mod=image&aid=' . $imgd[0] . '&size=' . $imgd[1] . 'x' . $imgd[2] . '&key=' . rawurlencode($imgd[3]); } } $recommendlist[] = $recommend; if ($recommend['typeid'] && count($recommendimagelist) < $imagenum) { $recommendimagelist[] = $recommend; } } if (count($recommendlist) == $num) { break; } } if ($recommendlist) { $_G['forum_colorarray'] = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282'); foreach ($recommendlist as $thread) { if ($thread['highlight']) { $string = sprintf('%02d', $thread['highlight']); $stylestr = sprintf('%03b', $string[0]); $thread['highlight'] = ' style="'; $thread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : ''; $thread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : ''; $thread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : ''; $thread['highlight'] .= $string[1] ? 'color: ' . $_G['forum_colorarray'][$string[1]] : ''; $thread['highlight'] .= '"'; } else { $thread['highlight'] = ''; } $recommendlists[$thread['tid']]['author'] = $thread['author']; $recommendlists[$thread['tid']]['authorid'] = $thread['authorid']; $recommendlists[$thread['tid']]['subject'] = $modrecommend['maxlength'] ? cutstr($thread['subject'], $modrecommend['maxlength']) : $thread['subject']; $recommendlists[$thread['tid']]['subjectstyles'] = $thread['highlight']; } } if ($recommendimagelist && $recommendlist) { $recommendlists['images'] = $recommendimagelist; } return $recommendlists; }
if ($isgroup) { DB::query("UPDATE " . DB::table('forum_groupuser') . " SET threads=threads+1, lastupdate='" . TIMESTAMP . "' WHERE uid='{$_G['uid']}' AND fid='{$_G['fid']}'"); } $subject = str_replace("\t", ' ', $subject); $lastpost = "{$tid}\t{$subject}\t{$_G['timestamp']}\t{$author}"; DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$lastpost}', threads=threads+1, posts=posts+1, todayposts=todayposts+1 WHERE fid='{$_G['fid']}'", 'UNBUFFERED'); if ($_G['forum']['type'] == 'sub') { DB::query("UPDATE " . DB::table('forum_forum') . " SET lastpost='{$lastpost}' WHERE fid='" . $_G['forum'][fup] . "'", 'UNBUFFERED'); } } if ($_G['forum']['status'] == 3) { require_once libfile('function/group'); updateactivity($_G['fid'], 0); require_once libfile('function/grouplog'); updategroupcreditlog($_G['fid'], $_G['uid']); } // д��¼����Ϣ by shawn $table_att = DB::table(getattachtablebytid($tid)); $attache_s = DB::query("SELECT * FROM " . $table_att . " WHERE pid='" . $pid . "' AND dateline>0 ORDER BY dateline"); $str = "****"; $str .= "SELECT * FROM " . $table_att . " WHERE pid='{$pid}' AND dateline>'0' ORDER BY dateline"; $str .= "****"; file_put_contents('./log.txt', $str, FILE_APPEND); @(include_once DISCUZ_ROOT . './source/class/class_replayparse.php'); while ($row = DB::fetch($attache_s)) { //print_r($row); writeReplayInfo($row['aid'], $table_att); } showmessage('post_newthread_succeed', "forum.php?mod=viewthread&tid={$tid}&extra={$extra}", $param); } }
function getTopicThread() { global $_G; $tid = intval($_G['gp_tid']); if (empty($tid)) { ajaxshowheader(); echo showTopicTemplate(0); ajaxshowfooter(); return false; } require_once libfile('function/forum'); require_once libfile('function/discuzcode'); loadforum(); $posttable = $_G['thread']['posttable']; if (empty($posttable)) { ajaxshowheader(); echo showTopicTemplate(0); ajaxshowfooter(); return false; } $imagePath = $imageUrl = ''; $subject = strip_tags($_G['thread']['subject']); $post = DB::fetch_first('SELECT message, pid FROM ' . DB::table($posttable) . " WHERE tid='{$tid}' AND first='1'"); $pid = intval($post['pid']); $message = cutstr(strip_tags(discuzcode($post['message'], 1, 0, 1)), 200); $message = preg_replace('/\\[attach\\](\\d+)\\[\\/attach\\]/is', '', $message); $imageDir = 'qqgroup'; $imageName = 'miniportal_tid_' . $tid . '.jpg'; $thumbTarget = $imageDir . '/' . $imageName; if (file_exists($_G['setting']['attachdir'] . './' . $thumbTarget)) { $imagePath = $thumbTarget; $imageUrl = $_G['setting']['attachurl'] . $imagePath; } else { $attachment = DB::result_first("SELECT attachment FROM " . DB::table(getattachtablebytid($tid)) . " WHERE pid='{$pid}' AND (isimage='1' OR isimage='-1') AND remote='0'"); if ($attachment) { $imagePath = 'forum/' . $attachment; $imageUrl = $_G['setting']['attachurl'] . $imagePath; } } ajaxshowheader(); echo showTopicTemplate($tid, $subject, $message, $imagePath, $imageUrl); ajaxshowfooter(); }
$trade = DB::fetch_first("SELECT * FROM " . DB::table('forum_trade') . " WHERE tid='{$_G['tid']}' AND pid='{$pid}'"); if (empty($trade)) { showmessage('trade_not_found'); } $fromcode = false; if ($trade['closed']) { showmessage('trade_closed', 'forum.php?mod=viewthread&tid=' . $_G['tid'] . '&page=' . $page); } if ($trade['price'] <= 0 && $trade['credit'] <= 0) { showmessage('trade_invalid', 'forum.php?mod=viewthread&tid=' . $_G['tid'] . '&page=' . $page); } if ($trade['credit'] > 0 && $_G['setting']['creditstransextra'][5] == -1) { showmessage('trade_credit_invalid', 'forum.php?mod=viewthread&tid=' . $_G['tid'] . '&page=' . $page); } $limit = 6; $query = DB::query("SELECT t.tid, t.pid, t.aid, t.subject, t.price, t.credit, t.displayorder FROM " . DB::table('forum_trade') . " t\r\n\t\tLEFT JOIN " . DB::table(getattachtablebytid($_G['tid'])) . " a ON t.aid=a.aid\r\n\t\tWHERE t.sellerid='{$trade['sellerid']}' ORDER BY t.displayorder DESC LIMIT {$limit}"); $usertrades = array(); $usertradecount = 0; while ($usertrade = DB::fetch($query)) { $usertradecount++; $usertrades[] = $usertrade; } if ($_G['gp_action'] != 'trade' && !submitcheck('tradesubmit')) { $lastbuyerinfo = dhtmlspecialchars(DB::fetch_first("SELECT buyername,buyercontact,buyerzip,buyerphone,buyermobile FROM " . DB::table('forum_tradelog') . " WHERE buyerid='{$_G['uid']}' AND status!=0 AND buyername!='' ORDER BY lastupdate DESC LIMIT 1")); $extra = rawurlencode($extra); include template('forum/trade'); } else { if ($trade['sellerid'] == $_G['uid']) { showmessage('trade_by_myself'); } elseif ($_G['gp_number'] <= 0) { showmessage('trade_input_no');
<?php /** * [Discuz!] (C)2001-2099 Comsenz Inc. * This is NOT a freeware, use is subject to license terms * * $Id: topicadmin_repair.php 20522 2011-02-25 04:03:05Z monkey $ */ if (!defined('IN_DISCUZ')) { exit('Access Denied'); } if (!$_G['group']['allowrepairthread']) { showmessage('no_privilege_repairthread'); } $posttable = getposttablebytid($_G['tid']); $replies = DB::result_first("SELECT COUNT(*) FROM " . DB::table($posttable) . " WHERE tid='{$_G['tid']}' AND invisible='0'") - 1; $attachcount = DB::result_first("SELECT count(*) FROM " . DB::table(getattachtablebytid($_G['tid'])) . " WHERE tid='{$_G['tid']}'"); $attachment = $attachcount ? DB::result_first("SELECT COUNT(*) FROM " . DB::table(getattachtablebytid($_G['tid'])) . " WHERE tid='{$_G['tid']}' AND isimage != 0") ? 2 : 1 : 0; $firstpost = DB::fetch_first("SELECT pid, subject, rate FROM " . DB::table($posttable) . " WHERE tid='{$_G['tid']}' AND invisible='0' ORDER BY dateline LIMIT 1"); $firstpost['subject'] = addslashes(cutstr($firstpost['subject'], 79)); @($firstpost['rate'] = $firstpost['rate'] / abs($firstpost['rate'])); $lastpost = DB::fetch_first("SELECT author, dateline FROM " . DB::table($posttable) . " WHERE tid='{$_G['tid']}' AND invisible='0' ORDER BY dateline DESC LIMIT 1"); DB::query("UPDATE " . DB::table('forum_thread') . " SET subject='{$firstpost['subject']}', replies='{$replies}', lastpost='{$lastpost['dateline']}', lastposter='" . addslashes($lastpost['author']) . "', rate='{$firstpost['rate']}', attachment='{$attachment}' WHERE tid='{$_G['tid']}'", 'UNBUFFERED'); DB::query("UPDATE " . DB::table($posttable) . " SET first='1', subject='{$firstpost['subject']}' WHERE pid='{$firstpost['pid']}'", 'UNBUFFERED'); DB::query("UPDATE " . DB::table($posttable) . " SET first='0' WHERE tid='{$_G['tid']}' AND pid<>'{$firstpost['pid']}'", 'UNBUFFERED'); showmessage('admin_repair_succeed', '', array(), array('alert' => 'right'));
if (empty($ufielddata['userfield'])) { $query = DB::query("SELECT " . implode(',', $activity['ufield']['userfield']) . " FROM " . DB::table('common_member_profile') . " WHERE uid='{$_G['uid']}'"); $ufielddata['userfield'] = DB::fetch($query); } $html = profile_setting($fieldid, $ufielddata['userfield'], false, true); if ($html) { $settings[$fieldid] = $_G['cache']['profilesetting'][$fieldid]; $htmls[$fieldid] = $html; } } } } else { $activity['ufield'] = ''; } if ($activity['aid']) { $attach = DB::fetch_first("SELECT * FROM " . DB::table(getattachtablebytid($_G['tid'])) . " WHERE aid='{$activity['aid']}'"); if ($attach['isimage']) { $activity['attachurl'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/' . $attach['attachment']; $activity['thumb'] = $attach['thumb'] ? getimgthumbname($activity['attachurl']) : $activity['attachurl']; $activity['width'] = $attach['thumb'] && $_G['setting']['thumbwidth'] < $attach['width'] ? $_G['setting']['thumbwidth'] : $attach['width']; } $skipaids[] = $activity['aid']; } $applylistverified = array(); $noverifiednum = 0; $query = DB::query("SELECT aa.username, aa.uid, aa.verified, aa.dateline, aa.message, aa.payment, aa.ufielddata, m.groupid FROM " . DB::table('forum_activityapply') . " aa\r\n\tLEFT JOIN " . DB::table('common_member') . " m USING(uid)\r\n\tLEFT JOIN " . DB::table('common_member_field_forum') . " mf USING(uid)\r\n\tWHERE aa.tid='{$_G['tid']}' ORDER BY aa.dateline DESC"); while ($activityapplies = DB::fetch($query)) { $activityapplies['dateline'] = dgmdate($activityapplies['dateline'], 'u'); if ($activityapplies['verified'] == 1) { $activityapplies['ufielddata'] = unserialize($activityapplies['ufielddata']); if (count($applylist) < $_G['setting']['activitypp']) {
} else { $thread['author'] = 'guest'; } $thread['dateline'] = dgmdate($thread['dateline']); $posttable = $thread['posttableid'] ? "forum_post_{$thread['posttableid']}" : 'forum_post'; $posttablearr[$posttable][$thread['tid']] = $thread['tid']; $postlist[$thread['tid']] = $thread; } $attachtablearr = array(); foreach ($posttablearr as $posttable => $tids) { $query = DB::query('SELECT pid, tid, message, useip, attachment FROM ' . DB::table($posttable) . " WHERE tid IN(" . dimplode($tids) . ") AND first='1'"); while ($post = DB::fetch($query)) { $thread = array_merge($postlist[$post['tid']], $post); $thread['message'] = nl2br(dhtmlspecialchars($thread['message'])); if ($thread['attachment']) { $attachtable = getattachtablebytid($thread['tid']); $attachtablearr[$attachtable][$thread['tid']] = $thread['tid']; } else { $thread['attach'] = ''; } if ($thread['sortid']) { require_once libfile('function/threadsort'); $threadsortshow = threadsortshow($thread['sortid'], $thread['tid']); foreach ($threadsortshow['optionlist'] as $option) { $thread['sortinfo'] .= $option['title'] . ' ' . $option['value'] . "<br />"; } } else { $thread['sortinfo'] = ''; } $postlist[$post['tid']] = $thread; }
if ($_G['gp_item_price'] > 0) { if ($_G['setting']['creditstransextra'][5] != -1 && $_G['gp_item_credit']) { $feed['body_template'] = 'feed_thread_goods_message_1'; } else { $feed['body_template'] = 'feed_thread_goods_message_2'; } } else { $feed['body_template'] = 'feed_thread_goods_message_3'; } $feed['body_data'] = array('itemname' => "<a href=\"forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}\">{$_G['gp_item_name']}</a>", 'itemprice' => $_G['gp_item_price'], 'itemcredit' => $_G['gp_item_credit'], 'creditunit' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][5]]['unit'] . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][5]]['title']); if ($_G['gp_tradeaid']) { $feed['images'] = array(getforumimg($_G['gp_tradeaid'])); $feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}"); } if ($_G['gp_tradeaid']) { $attachment = DB::fetch_first("SELECT * FROM " . DB::table(getattachtablebytid($tid)) . " WHERE aid='{$_G['gp_tradeaid']}'"); if (in_array($attachment['filetype'], array('image/gif', 'image/jpeg', 'image/png'))) { $imgurl = $_G['setting']['attachurl'] . 'forum/' . ($attachment['thumb'] && $attachment['filetype'] != 'image/gif' ? getimgthumbname($attachment['attachment']) : $attachment['attachment']); $feed['images'][] = $attachment['attachment'] ? $imgurl : ''; $feed['image_links'][] = $attachment['attachment'] ? "forum.php?mod=viewthread&tid={$tid}" : ''; } } $feed['title_data']['hash_data'] = "tid{$tid}"; $feed['id'] = $tid; $feed['idtype'] = 'tid'; postfeed($feed); } if ($displayorder != -4) { if ($digest) { updatepostcredits('+', $_G['uid'], 'digest', $_G['fid']); }
function deletethread($tids, $membercount = false, $credit = false, $ponly = false) { global $_G; if ($_G['setting']['plugins'][HOOKTYPE . '_deletethread']) { $_G['deletethreadtids'] =& $tids; $hookparam = func_get_args(); hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'check'), 'deletethread'); } if (!$tids) { return 0; } require_once libfile('function/forum'); foreach ($tids as $tid) { my_post_log('delete', array('tid' => $tid)); } $count = count($tids); $tids = dimplode($tids); loadcache(array('threadtableids', 'posttableids')); $threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array(); $posttableids = !empty($_G['cache']['posttableids']) ? $_G['cache']['posttableids'] : array('0'); if (!in_array(0, $threadtableids)) { $threadtableids = array_merge(array(0), $threadtableids); } DB::delete('common_moderate', "id IN ({$tids}) AND idtype='tid'"); $atids = $fids = $postids = $threadtables = array(); foreach ($threadtableids as $tableid) { $threadtable = !$tableid ? "forum_thread" : "forum_thread_{$tableid}"; $query = DB::query("SELECT cover, tid, fid, posttableid FROM " . DB::table($threadtable) . " WHERE tid IN ({$tids})"); while ($row = DB::fetch($query)) { $atids[] = $row['tid']; $row['posttableid'] = !empty($row['posttableid']) && in_array($row['posttableid'], $posttableids) ? $row['posttableid'] : '0'; $postids[$row['posttableid']][$row['tid']] = $row['tid']; if ($tableid) { $fids[$row['fid']][] = $tableid; } } if (!$tableid && !$ponly) { $threadtables[] = $threadtable; } } if ($credit || $membercount) { $losslessdel = $_G['setting']['losslessdel'] > 0 ? TIMESTAMP - $_G['setting']['losslessdel'] * 86400 : 0; $postlist = $uidarray = $tuidarray = $ruidarray = array(); foreach ($postids as $posttableid => $posttabletids) { $query = DB::query('SELECT tid, first, authorid, dateline, replycredit, invisible FROM ' . DB::table(getposttable($posttableid)) . ' WHERE tid IN (' . dimplode($posttabletids) . ')'); while ($post = DB::fetch($query)) { if ($post['invisible'] != -1 && $post['invisible'] != -5) { $postlist[] = $post; } } } $query = DB::query("SELECT tid, extcreditstype FROM " . DB::table('forum_replycredit') . " WHERE tid IN ({$tids})"); while ($rule = DB::fetch($query)) { $rule['extcreditstype'] = $rule['extcreditstype'] ? $rule['extcreditstype'] : $_G['setting']['creditstransextra'][10]; $replycredit_rule[$rule['tid']] = $rule; } foreach ($postlist as $post) { if ($post['dateline'] < $losslessdel) { if ($membercount) { if ($post['first']) { updatemembercount($post['authorid'], array('threads' => -1, 'post' => -1), false); } else { updatemembercount($post['authorid'], array('posts' => -1), false); } } } else { if ($credit) { if ($post['first']) { $tuidarray[] = $post['authorid']; } else { $ruidarray[] = $post['authorid']; } } } if ($credit || $membercount) { if ($post['authorid'] > 0 && $post['replycredit'] > 0) { if ($replycredit_rule[$post['tid']]['extcreditstype']) { updatemembercount($post['authorid'], array($replycredit_rule[$post['tid']]['extcreditstype'] => (int) ('-' . $post['replycredit']))); } } } } if ($credit) { if ($tuidarray || $ruidarray) { require_once libfile('function/post'); } if ($tuidarray) { updatepostcredits('-', $tuidarray, 'post', $_G['forum']['fid']); } if ($ruidarray) { updatepostcredits('-', $ruidarray, 'reply', $_G['forum']['fid']); } $auidarray = $attachtables = array(); foreach ($atids as $tid) { $attachtables[getattachtablebytid($tid)][] = $tid; } foreach ($attachtables as $attachtable => $attachtids) { $query = DB::query("SELECT uid, dateline FROM " . DB::table($attachtable) . " WHERE tid IN (" . dimplode($attachtids) . ")"); while ($attach = DB::fetch($query)) { if ($attach['dateline'] > $losslessdel) { $auidarray[$attach['uid']] = !empty($auidarray[$attach['uid']]) ? $auidarray[$attach['uid']] + 1 : 1; } } } if ($auidarray) { $postattachcredits = !empty($_G['forum']['postattachcredits']) ? $_G['forum']['postattachcredits'] : $_G['setting']['creditspolicy']['postattach']; updateattachcredits('-', $auidarray, $postattachcredits); } } } if ($ponly) { if ($_G['setting']['plugins'][HOOKTYPE . '_deletethread']) { hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread'); } return $count; } DB::delete('forum_replycredit', "tid IN ({$tids})"); DB::delete('common_credit_log', "operation IN ('RCT', 'RCA', 'RCB') AND relatedid IN ({$tids})"); deletethreadcover($tids); foreach ($threadtables as $threadtable) { DB::delete($threadtable, "tid IN ({$tids})"); } if ($atids) { foreach ($postids as $posttableid => $oneposttids) { deletepost($oneposttids, 'tid', false, $posttableid); } deleteattach($atids, 'tid'); } if ($fids) { foreach ($fids as $fid => $tableids) { $tableids = array_unique($tableids); foreach ($tableids as $tableid) { $query = DB::query("SELECT COUNT(*) AS threads, SUM(replies)+COUNT(*) AS posts FROM " . DB::table("forum_thread_{$tableid}") . " WHERE fid='{$fid}'"); while ($row = DB::fetch($query)) { DB::insert('forum_forum_threadtable', array('fid' => $fid, 'threadtableid' => $tableid, 'threads' => intval($row['threads']), 'posts' => intval($row['posts'])), false, true); } } } } foreach (array('forum_forumrecommend', 'forum_polloption', 'forum_poll', 'forum_activity', 'forum_activityapply', 'forum_debate', 'forum_debatepost', 'forum_threadmod', 'forum_relatedthread', 'forum_typeoptionvar', 'forum_postposition', 'forum_poststick', 'forum_pollvoter', 'forum_threadimage') as $table) { DB::delete($table, "tid IN ({$tids})"); } DB::query("DELETE FROM " . DB::table('home_feed') . " WHERE id IN ({$tids}) AND idtype='tid'", 'UNBUFFERED'); DB::query("DELETE FROM " . DB::table('common_tagitem') . " WHERE idtype='tid' AND itemid IN ({$tids})", 'UNBUFFERED'); DB::query("DELETE FROM " . DB::table('forum_threadrush') . " WHERE tid IN ({$tids})", 'UNBUFFERED'); if ($_G['setting']['plugins'][HOOKTYPE . '_deletethread']) { hookscript('deletethread', 'global', 'funcs', array('param' => $hookparam, 'step' => 'delete'), 'deletethread'); } return $count; }
} } else { $data = @file($cachefile); if(!$data) { show_msg("Nâng cấp bảng chủ đề", "$theurl?step=data&op=$nextop"); } $data = explode('|', $data[0]); } $tids = array_slice($data, $start, $limit); if(!$tids) { @unlink($cachefile); show_msg("Nâng cấp cache", "$theurl?step=data&op=$nextop"); } $insertsql = array(); foreach(C::t('forum_post')->fetch_all_by_tid(0, $tids, false, '', 0, 0, 1) as $row) { $threadimage = DB::fetch_first("SELECT attachment, remote FROM ".DB::table(getattachtablebytid($row['tid']))." WHERE pid='$row[pid]' AND isimage IN ('1', '-1') ORDER BY width DESC LIMIT 1"); if($threadimage['attachment']) { $threadimage = daddslashes($threadimage); $insertsql[$row['tid']] = "('$row[tid]', '$threadimage[attachment]', '$threadimage[remote]')"; } } if($insertsql) { DB::query("INSERT INTO ".DB::table('forum_threadimage')." (`tid`, `attachment`, `remote`) VALUES ".implode(',', $insertsql)); } $start += $limit; show_msg("Đang xác thực dữ liệu ... ... $start ", "$theurl?step=data&op=threadimage&start=$start"); } else { show_msg("Nâng cấp dữ liệu ảnh chủ đề", "$theurl?step=data&op=$nextop"); } } elseif($_GET['op'] == 'moderate') {
if ($modnewthreads) { updatemoderate('tid', $tid); DB::query("UPDATE " . DB::table('forum_forum') . " SET todayposts=todayposts+1 WHERE fid='{$_G['fid']}'", 'UNBUFFERED'); manage_addnotify('verifythread'); showmessage('post_newthread_mod_succeed', "forum.php?mod=viewthread&tid={$tid}&extra={$extra}", $param); } else { $feed = array('icon' => '', 'title_template' => '', 'title_data' => array(), 'body_template' => '', 'body_data' => array(), 'title_data' => array(), 'images' => array()); if (!empty($_G['gp_addfeed']) && $_G['forum']['allowfeed'] && !$isanonymous) { $message = !($price || $readperm) ? $message : ''; if ($special == 0) { $feed['icon'] = 'thread'; $feed['title_template'] = 'feed_thread_title'; $feed['body_template'] = 'feed_thread_message'; $feed['body_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$tid}\">{$subject}</a>", 'message' => messagecutstr($message, 150)); if (!empty($_G['forum_attachexist'])) { $firstaid = DB::result_first("SELECT aid FROM " . DB::table(getattachtablebytid($tid)) . " WHERE pid='{$pid}' AND dateline>'0' AND isimage='1' ORDER BY dateline LIMIT 1"); if ($firstaid) { $feed['images'] = array(getforumimg($firstaid)); $feed['image_links'] = array("forum.php?mod=viewthread&do=tradeinfo&tid={$tid}&pid={$pid}"); } } } elseif ($special > 0) { if ($special == 1) { $pvs = explode("\t", messagecutstr($polloptionpreview, 150)); $s = ''; $i = 1; foreach ($pvs as $pv) { $s .= $i . '. ' . $pv . '<br />'; } $s .= ' ...'; $feed['icon'] = 'poll';
function parseattach($attachpids, $attachtags, &$postlist, $skipaids = array()) { global $_G; $query = DB::query("SELECT * FROM " . DB::table(getattachtablebytid($_G['tid'])) . " a WHERE a.pid IN ({$attachpids})"); $attachexists = FALSE; $skipattachcode = $aids = $payaids = $findattach = array(); while ($attach = DB::fetch($query)) { $attachexists = TRUE; if ($skipaids && in_array($attach['aid'], $skipaids)) { $skipattachcode[$attach[pid]][] = "/\\[attach\\]{$attach['aid']}\\[\\/attach\\]/i"; continue; } $attached = 0; $extension = strtolower(fileext($attach['filename'])); $attach['ext'] = $extension; $attach['imgalt'] = $attach['isimage'] ? strip_tags(str_replace('"', '\\"', $attach['description'] ? $attach['description'] : $attach['filename'])) : ''; $attach['attachicon'] = attachtype($extension . "\t" . $attach['filetype']); $attach['attachsize'] = sizecount($attach['filesize']); if ($attach['isimage'] && !$_G['setting']['attachimgpost']) { $attach['isimage'] = 0; } $attach['attachimg'] = $attach['isimage'] && (!$attach['readperm'] || $_G['group']['readaccess'] >= $attach['readperm']) ? 1 : 0; if ($attach['attachimg']) { $GLOBALS['aimgs'][$attach['pid']][] = $attach['aid']; } if ($attach['price']) { if ($_G['setting']['maxchargespan'] && TIMESTAMP - $attach['dateline'] >= $_G['setting']['maxchargespan'] * 3600) { DB::query("UPDATE " . DB::table(getattachtablebytid($_G['tid'])) . " SET price='0' WHERE aid='{$attach['aid']}'"); $attach['price'] = 0; } elseif (!$_G['forum_attachmentdown'] && $_G['uid'] != $attach['uid']) { $payaids[$attach['aid']] = $attach['pid']; } } $attach['payed'] = $_G['forum_attachmentdown'] || $_G['uid'] == $attach['uid'] ? 1 : 0; $attach['url'] = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/'; $attach['dateline'] = dgmdate($attach['dateline'], 'u'); $postlist[$attach['pid']]['attachments'][$attach['aid']] = $attach; if (!empty($attachtags[$attach['pid']]) && is_array($attachtags[$attach['pid']]) && in_array($attach['aid'], $attachtags[$attach['pid']])) { $findattach[$attach['pid']][$attach['aid']] = "/\\[attach\\]{$attach['aid']}\\[\\/attach\\]/i"; $attached = 1; } if (!$attached) { if ($attach['isimage']) { $postlist[$attach['pid']]['imagelist'][] = $attach['aid']; $postlist[$attach['pid']]['imagelistcount']++; if ($postlist[$attach['pid']]['first']) { $GLOBALS['firstimgs'][] = $attach['aid']; } } else { if (!$_G['forum_skipaidlist'] || !in_array($attach['aid'], $_G['forum_skipaidlist'])) { $postlist[$attach['pid']]['attachlist'][] = $attach['aid']; } } } $aids[] = $attach['aid']; } if ($aids) { $query = DB::query("SELECT aid, pid, downloads FROM " . DB::table('forum_attachment') . " WHERE aid IN (" . dimplode($aids) . ")"); while ($attach = DB::fetch($query)) { $postlist[$attach['pid']]['attachments'][$attach['aid']]['downloads'] = $attach['downloads']; } } if ($payaids) { $query = DB::query("SELECT relatedid FROM " . DB::table('common_credit_log') . " WHERE relatedid IN (" . dimplode(array_keys($payaids)) . ") AND uid='{$_G['uid']}' AND operation='BAC'"); while ($creditlog = DB::fetch($query)) { $postlist[$payaids[$creditlog['relatedid']]]['attachments'][$creditlog['relatedid']]['payed'] = 1; } } if (!empty($skipattachcode)) { foreach ($skipattachcode as $pid => $findskipattach) { foreach ($findskipattach as $findskip) { $postlist[$pid]['message'] = preg_replace($findskip, '', $postlist[$pid]['message']); } } } if ($attachexists) { foreach ($attachtags as $pid => $aids) { if ($findattach[$pid]) { foreach ($findattach[$pid] as $aid => $find) { $postlist[$pid]['message'] = preg_replace($find, attachinpost($postlist[$pid]['attachments'][$aid], $postlist[$pid]['first']), $postlist[$pid]['message'], 1); $postlist[$pid]['message'] = preg_replace($find, '', $postlist[$pid]['message']); } } } } else { updatepost(array('attachment' => '0'), "pid IN ({$attachpids})", true); } }
$article['author'] = $blog['username']; $article_content['content'] = dhtmlspecialchars($blog['message']); } break; default: $posttable = getposttablebytid($_GET['from_id']); $query = DB::query("SELECT t.*, p.* FROM " . DB::table('forum_thread') . " t\r\n\t\t\t\tLEFT JOIN " . DB::table($posttable) . " p ON p.tid=t.tid AND p.first='1'\r\n\t\t\t\tWHERE t.tid='{$_GET['from_id']}'"); if ($thread = DB::fetch($query)) { $article['title'] = $thread['subject']; $thread['message'] = portalcp_get_postmessage($thread); $article['summary'] = portalcp_get_summary($thread['message']); $article['fromurl'] = 'forum.php?mod=viewthread&tid=' . $thread['tid']; $article['author'] = $thread['author']; $article_content['content'] = dhtmlspecialchars($thread['message']); $article['attach_image'] = $article['attach_file'] = ''; $query = DB::query("SELECT * FROM " . DB::table(getattachtablebytid($thread['tid'])) . " WHERE pid='{$thread['pid']}' ORDER BY aid DESC"); while ($attach = DB::fetch($query)) { $attachcode = '[attach]' . $attach['aid'] . '[/attach]'; if (!strexists($article_content['content'], $attachcode)) { $article_content['content'] .= '<br /><br />' . $attachcode; } if ($attach['isimage']) { if ($article['pic']) { $attach['pic'] = $article['pic']; } $article['attach_image'] .= get_uploadcontent($attach, 'forum'); } else { $article['attach_file'] .= get_uploadcontent($attach, 'forum'); } } }
function recommendupdate($fid, &$modrecommend, $force = '', $position = 0) { global $_G; $recommendlist = $recommendimagelist = $modedtids = array(); $num = $modrecommend['num'] ? intval($modrecommend['num']) : 10; $imagenum = $modrecommend['imagenum'] = $modrecommend['imagenum'] ? intval($modrecommend['imagenum']) : 0; $imgw = $modrecommend['imagewidth'] = $modrecommend['imagewidth'] ? intval($modrecommend['imagewidth']) : 200; $imgh = $modrecommend['imageheight'] = $modrecommend['imageheight'] ? intval($modrecommend['imageheight']) : 150; if ($modrecommend['sort'] && (TIMESTAMP - $modrecommend['updatetime'] > $modrecommend['cachelife'] || $force)) { $query = DB::query("SELECT tid, moderatorid, aid FROM " . DB::table('forum_forumrecommend') . " WHERE fid='{$fid}'"); while ($row = DB::fetch($query)) { if ($modrecommend['sort'] == 2 && $row['moderatorid']) { $modedtids[] = $row['tid']; } } DB::query("DELETE FROM " . DB::table('forum_forumrecommend') . " WHERE fid='{$fid}'" . ($modrecommend['sort'] == 2 ? " AND moderatorid='0'" : '')); $orderby = 'dateline'; $conditions = $modrecommend['dateline'] ? 'AND dateline>' . (TIMESTAMP - $modrecommend['dateline'] * 3600) : ''; switch ($modrecommend['orderby']) { case '': case '1': $orderby = 'lastpost'; break; case '2': $orderby = 'views'; break; case '3': $orderby = 'replies'; break; case '4': $orderby = 'digest'; break; case '5': $orderby = 'recommends'; $conditions .= " AND recommends>'0'"; break; case '6': $orderby = 'heats'; break; } $add = $comma = $i = ''; $addthread = $addimg = $recommendlist = $recommendimagelist = $tids = array(); $query = DB::query("SELECT fid, tid, author, authorid, subject, highlight FROM " . DB::table('forum_thread') . " WHERE fid='{$fid}' AND displayorder>='0' {$conditions} ORDER BY {$orderby} DESC LIMIT 0, {$num}"); while ($thread = DB::fetch($query)) { $recommendlist[$thread['tid']] = $thread; $tids[] = $thread['tid']; if (!$modedtids || !in_array($thread['tid'], $modedtids)) { $addthread[$thread['tid']] = "'{$thread['fid']}', '{$thread['tid']}', '1', '{$i}', '" . addslashes($thread['subject']) . "', '" . addslashes($thread['author']) . "', '{$thread['authorid']}', '0', '0', '{$thread['highlight']}'"; $i++; } } if ($tids && $imagenum) { $attachtables = array(); foreach ($tids as $tid) { $attachtables[getattachtablebytid($tid)][] = $tid; } foreach ($attachtables as $attachtable => $tids) { $query = DB::query('SELECT p.fid, p.tid, a.aid FROM ' . DB::table(getposttable()) . " p\n\t\t\t\t\t\t\tINNER JOIN " . DB::table($attachtable) . " a\n\t\t\t\t\t\t\tON a.pid=p.pid AND a.isimage IN ('1', '-1') AND a.width>='{$imgw}'" . "\n\t\t\t\t\t\t\tWHERE p.tid IN (" . dimplode($tids) . ") AND p.first='1'"); while ($attachment = DB::fetch($query)) { if (isset($recommendimagelist[$attachment['tid']])) { continue; } $key = md5($attachment['aid'] . '|' . $imgw . '|' . $imgh); $recommendlist[$attachment['tid']]['filename'] = $attachment['aid'] . "\t" . $imgw . "\t" . $imgh . "\t" . $key; $recommendimagelist[$attachment['tid']] = $recommendlist[$attachment['tid']]; $addimg[$attachment['tid']] = ",'', '" . addslashes($recommendlist[$attachment['tid']]['filename']) . "', '1'"; if (count($recommendimagelist) == $imagenum) { break; } } } } foreach ($addthread as $tid => $row) { $add .= $comma . '(' . $row . (!isset($addimg[$tid]) ? ",'0','','0'" : $addimg[$tid]) . ')'; $comma = ', '; } unset($recommendimagelist); if ($add) { DB::query("REPLACE INTO " . DB::table('forum_forumrecommend') . " (fid, tid, position, displayorder, subject, author, authorid, moderatorid, expiration, highlight, aid, filename, typeid) VALUES {$add}"); $modrecommend['updatetime'] = TIMESTAMP; $modrecommendnew = addslashes(serialize($modrecommend)); DB::query("UPDATE " . DB::table('forum_forumfield') . " SET modrecommend='{$modrecommendnew}' WHERE fid='{$fid}'"); } } $recommendlists = $recommendlist = array(); $position = $position ? "AND position IN ('0','{$position}')" : ''; $query = DB::query("SELECT * FROM " . DB::table('forum_forumrecommend') . " WHERE fid='{$fid}' {$position} ORDER BY displayorder"); while ($recommend = DB::fetch($query)) { if ($recommend['expiration'] && $recommend['expiration'] > TIMESTAMP || !$recommend['expiration']) { if ($recommend['filename'] && strexists($recommend['filename'], "\t")) { $imgd = explode("\t", $recommend['filename']); if ($imgd[0] && $imgd[3]) { $recommend['filename'] = 'forum.php?mod=image&aid=' . $imgd[0] . '&size=' . $imgd[1] . 'x' . $imgd[2] . '&key=' . rawurlencode($imgd[3]); } } $recommendlist[] = $recommend; if ($recommend['typeid'] && count($recommendimagelist) < $imagenum) { $recommendimagelist[] = $recommend; } } if (count($recommendlist) == $num) { break; } } if ($recommendlist) { $_G['forum_colorarray'] = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282'); foreach ($recommendlist as $thread) { if ($thread['highlight']) { $string = sprintf('%02d', $thread['highlight']); $stylestr = sprintf('%03b', $string[0]); $thread['highlight'] = ' style="'; $thread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : ''; $thread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : ''; $thread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : ''; $thread['highlight'] .= $string[1] ? 'color: ' . $_G['forum_colorarray'][$string[1]] : ''; $thread['highlight'] .= '"'; } else { $thread['highlight'] = ''; } $recommendlists[$thread['tid']]['author'] = $thread['author']; $recommendlists[$thread['tid']]['authorid'] = $thread['authorid']; $recommendlists[$thread['tid']]['subject'] = $modrecommend['maxlength'] ? cutstr($thread['subject'], $modrecommend['maxlength']) : $thread['subject']; $recommendlists[$thread['tid']]['subjectstyles'] = $thread['highlight']; } } if ($recommendimagelist && $recommendlist) { $recommendlists['images'] = $recommendimagelist; } return $recommendlists; }
case 'thread': $feed_hash_data = "tid{$id}"; $actives = array('share' => ' class="active"'); $thread = DB::fetch(DB::query("SELECT * FROM " . DB::table('forum_thread') . " WHERE tid='{$id}'")); if (in_array($thread['displayorder'], array(-2, -3))) { showmessage('moderate_thread_not_share'); } $posttable = getposttable(); $post = DB::fetch(DB::query("SELECT * FROM " . DB::table($posttable) . " WHERE tid='{$id}' AND first='1'")); $arr['title_template'] = lang('spacecp', 'share_thread'); $arr['body_template'] = '<b>{subject}</b><br>{author}<br>{message}'; $attachment = !preg_match("/\\[hide=?\\d*\\](.*?)\\[\\/hide\\]/is", $post['message'], $a) && preg_match("/\\[attach\\]\\d+\\[\\/attach\\]/i", $a[1]); $arr['body_data'] = array('subject' => "<a href=\"forum.php?mod=viewthread&tid={$id}\">{$thread['subject']}</a>", 'author' => "<a href=\"home.php?mod=space&uid={$thread['authorid']}\">{$thread['author']}</a>", 'message' => getstr($post['message'], 150, 0, 1, 0, -1)); $arr['itemid'] = $id; $arr['fromuid'] = $thread['uid']; $attachment = $attachment ? DB::fetch_first('SELECT attachment, isimage, thumb, remote FROM ' . DB::table(getattachtablebytid($id)) . " WHERE tid='{$id}' AND isimage IN ('1', '-1') LIMIT 0,1") : false; if ($attachment) { $arr['image'] = pic_get($attachment['attachment'], 'forum', $attachment['thumb'], $attachment['remote'], 1); $arr['image_link'] = "forum.php?mod=viewthread&tid={$id}"; } $note_uid = $thread['authorid']; $note_message = 'share_thread'; $note_values = array('url' => "forum.php?mod=viewthread&tid={$id}", 'subject' => $thread['subject'], 'from_id' => $id, 'from_idtype' => 'tid'); break; case 'article': $feed_hash_data = "articleid{$id}"; $query = DB::query("SELECT * FROM " . DB::table('portal_article_title') . " WHERE aid='{$id}'"); if (!($article = DB::fetch($query))) { showmessage('article_does_not_exist'); } if (in_array($article['status'], array(1, 2))) {
if ($firstaid) { $feed['images'] = array(getforumimg($firstaid)); $feed['image_links'] = array($post_url); } } } $feed['title_data']['hash_data'] = "tid{$_G[tid]}"; $feed['id'] = $pid; $feed['idtype'] = 'pid'; if ($feed['icon']) { postfeed($feed); } } $page = getstatus($thread['status'], 4) ? 1 : @ceil(($thread['special'] ? $thread['replies'] + 1 : $thread['replies'] + 2) / $_G['ppp']); //写入录像的相关解析信息 by shawn 20120218 $table_att = DB::table(getattachtablebytid($_G['tid'])); $attache_s = DB::query("SELECT * FROM " . $table_att . " WHERE pid='{$pid}'"); @(include_once DISCUZ_ROOT . './source/class/class_replayparse.php'); while ($row = DB::fetch($attache_s)) { //print_r($row); writeReplayInfo($row['aid'], $table_att); } //end by shawn if ($special == 2 && !empty($_G['gp_continueadd'])) { dheader("location: forum.php?mod=post&action=reply&fid={$_G[forum][fid]}&firstpid={$pid}&tid={$thread[tid]}&addtrade=yes"); } else { $url = empty($_POST['portal_referer']) ? "forum.php?mod=viewthread&tid={$thread[tid]}&pid={$pid}&page={$page}&extra={$extra}#pid{$pid}" : $_POST['portal_referer']; } if (!isset($inspacecpshare)) { showmessage($replymessage, $url, $param); }
updatemoderate('tid', $moderation['delete'], 2); } if ($moderation['validate']) { require_once libfile('function/forum'); $forums = array(); $validatetids = '\'' . implode('\',\'', $moderation['validate']) . '\''; $tids = $authoridarray = $moderatedthread = array(); $query = DB::query("SELECT t.fid, t.tid, t.authorid, t.subject, t.author, t.dateline, t.posttableid FROM " . DB::table('forum_thread') . " t\r\n\t\t\tWHERE t.tid IN ({$validatetids}) {$fidadd['and']}{$fidadd['t']}{$fidadd['fids']}"); while ($thread = DB::fetch($query)) { $posttable = $thread['posttableid'] ? "forum_post_{$thread['posttableid']}" : 'forum_post'; $poststatus = DB::result_first("SELECT status FROM " . DB::table($posttable) . " WHERE tid='{$thread['tid']}' AND first='1'"); $tids[] = $thread['tid']; my_thread_log('validate', array('tid' => $thread['tid'])); if (getstatus($poststatus, 3) == 0) { updatepostcredits('+', $thread['authorid'], 'post', $thread['fid']); $attachcount = DB::result_first("SELECT COUNT(*) FROM " . DB::table(getattachtablebytid($thread['tid'])) . " WHERE tid='{$thread['tid']}'"); updatecreditbyaction('postattach', $thread['authorid'], array(), '', $attachcount, 1, $thread['fid']); } $forums[] = $thread['fid']; $validatedthreads[] = $thread; $pm = 'pm_' . $thread['tid']; if (isset($_G['gp_' . $pm]) && $_G['gp_' . $pm] != '' && $thread['authorid']) { $pmlist[] = array('action' => 'modthreads_validate', 'notevar' => array('tid' => $thread['tid'], 'threadsubject' => $thread['subject'], 'reason' => dhtmlspecialchars($_G['gp_' . $pm])), 'authorid' => $thread['authorid']); } } if ($tids) { $tidstr = dimplode($tids); $validates = DB::query("UPDATE " . DB::table(getposttable()) . " SET status='4' WHERE tid IN ({$tidstr}) AND status='0' AND invisible='-2'"); updatepost(array('invisible' => '0'), "tid IN ({$tidstr}) AND first='1'"); DB::query("UPDATE " . DB::table('forum_thread') . " SET displayorder='0', moderated='1' WHERE tid IN ({$tidstr})"); $validates = DB::affected_rows();
function getpic($tid) { global $_G; if (!$tid) { return ''; } $pic = DB::fetch_first("SELECT attachment, remote FROM " . DB::table(getattachtablebytid($tid)) . " WHERE tid='{$tid}' AND isimage IN (1, -1) ORDER BY dateline DESC LIMIT 0,1"); return $pic; }
function setthreadcover($pid, $tid = 0, $aid = 0) { global $_G; $cover = 0; if (empty($_G['uid']) || !intval($_G['setting']['forumpicstyle']['thumbwidth']) || !intval($_G['setting']['forumpicstyle']['thumbwidth'])) { return false; } if (($pid || $aid) && empty($tid)) { if ($aid) { $attachtable = getattachtablebyaid($aid); $wheresql = "aid='{$aid}' AND isimage IN ('1', '-1')"; } else { $attachtable = getattachtablebypid($pid); $wheresql = "pid='{$pid}' AND isimage IN ('1', '-1') ORDER BY width DESC LIMIT 1"; } $query = DB::query("SELECT * FROM " . DB::table($attachtable) . " WHERE {$wheresql}"); if (!($attach = DB::fetch($query))) { return false; } if (empty($_G['forum']['ismoderator']) && $_G['uid'] != $attach['uid']) { return false; } $pid = empty($pid) ? $attach['pid'] : $pid; $tid = empty($tid) ? $attach['tid'] : $tid; $basedir = !$_G['setting']['attachdir'] ? DISCUZ_ROOT . './data/attachment/' : $_G['setting']['attachdir']; $coverdir = 'threadcover/' . substr(md5($tid), 0, 2) . '/' . substr(md5($tid), 2, 2) . '/'; dmkdir($basedir . './forum/' . $coverdir); $picsource = ($attach['remote'] ? $_G['setting']['ftp']['attachurl'] : $_G['setting']['attachurl']) . 'forum/' . $attach['attachment']; require_once libfile('class/image'); $image = new image(); if ($image->Thumb($picsource, 'forum/' . $coverdir . $tid . '.jpg', $_G['setting']['forumpicstyle']['thumbwidth'], $_G['setting']['forumpicstyle']['thumbheight'], 2)) { $remote = ''; if (getglobal('setting/ftp/on')) { if (ftpcmd('upload', 'forum/' . $coverdir . $tid . '.jpg')) { $remote = '-'; } } $cover = DB::result_first("SELECT COUNT(*) FROM " . DB::table($attachtable) . " WHERE pid='{$pid}' AND isimage IN ('1', '-1')"); $cover = $remote . $cover; } else { return false; } } if ($tid || $cover) { if (empty($cover)) { $oldcover = DB::result_first("SELECT cover FROM " . DB::table('forum_thread') . " WHERE tid='{$tid}'"); $cover = DB::result_first("SELECT COUNT(*) FROM " . DB::table(getattachtablebytid($tid)) . " WHERE pid='{$pid}' AND isimage IN ('1', '-1')"); $cover = $cover && $oldcover < 0 ? '-' . $cover : $cover; } DB::update('forum_thread', array('cover' => $cover), array('tid' => $tid)); } return true; }
function updatersscache($num) { global $_G; $processname = 'forum_rss_cache'; if (discuz_process::islocked($processname, 600)) { return false; } DB::query("DELETE FROM " . DB::table('forum_rsscache') . ""); require_once libfile('function/post'); foreach ($_G['cache']['forums'] as $fid => $forum) { if ($forum['type'] != 'group') { $query = DB::query("SELECT tid, readperm, author, dateline, subject\n\t\t\t\tFROM " . DB::table('forum_thread') . "\n\t\t\t\tWHERE fid='{$fid}' AND displayorder>='0'\n\t\t\t\tORDER BY tid DESC LIMIT {$num}"); $forum['name'] = addslashes($forum['name']); while ($thread = DB::fetch($query)) { $thread['author'] = $thread['author'] != '' ? addslashes($thread['author']) : 'Anonymous'; $thread['subject'] = addslashes($thread['subject']); $posttable = getposttablebytid($thread['tid']); $post = DB::fetch_first("SELECT pid, attachment, message, status FROM " . DB::table($posttable) . " WHERE tid='{$thread['tid']}' AND first='1'"); $attachdata = ''; if ($post['attachment'] == 2) { $attach = DB::fetch_first("SELECT remote, attachment, filesize FROM " . DB::table(getattachtablebytid($thread['tid'])) . " WHERE pid='{$post['pid']}' AND isimage='1' ORDER BY dateline LIMIT 1"); $attachdata = "\t" . $attach['remote'] . "\t" . $attach['attachment'] . "\t" . $attach['filesize']; } $thread['message'] = $post['message']; $thread['status'] = $post['status']; $thread['description'] = $thread['readperm'] > 0 || $thread['price'] > 0 || $thread['status'] & 1 ? '' : addslashes(messagecutstr($thread['message'], 250 - strlen($attachdata)) . $attachdata); DB::query("REPLACE INTO " . DB::table('forum_rsscache') . " (lastupdate, fid, tid, dateline, forum, author, subject, description)\n\t\t\t\t\tVALUES ('{$_G['timestamp']}', '{$fid}', '{$thread['tid']}', '{$thread['dateline']}', '{$forum['name']}', '{$thread['author']}', '{$thread['subject']}', '{$thread['description']}')"); } } } discuz_process::unlock($processname); return true; }
} if ($_G['gp_do'] == 'tradeinfo') { $verifyadd = ''; if ($_G['setting']['verify']['enabled']) { $verifyadd = "LEFT JOIN " . DB::table('common_member_verify') . " mv USING(uid)"; $fieldsadd .= ', mv.verify1, mv.verify2, mv.verify3, mv.verify4, mv.verify5'; } $trade = $trades[$_G['gp_pid']]; unset($trades); $posttable = getposttablebytid($_G['tid']); $post = DB::fetch_first("SELECT p.*, m.uid, mp.realname, m.username, m.groupid, m.adminid, m.regdate, ms.lastactivity,\r\n\t\t\tm.credits, m.email, mp.gender, mp.site,\tmp.icq, mp.qq, mp.yahoo, mp.msn, mp.taobao, mp.alipay,\r\n\t\t\tms.buyercredit, ms.sellercredit {$fieldsadd}\r\n\t\t\tFROM " . DB::table($posttable) . " p\r\n\t\t\tLEFT JOIN " . DB::table('common_member') . " m ON m.uid=p.authorid\r\n\t\t\tLEFT JOIN " . DB::table('common_member_status') . " ms USING(uid)\r\n\t\t\tLEFT JOIN " . DB::table('common_member_profile') . " mp USING(uid)\r\n\t\t\t{$verifyadd}\r\n\t\t\tWHERE pid='{$_G['gp_pid']}'"); $postlist[$post['pid']] = viewthread_procpost($post, $lastvisit, $ordertype); $usertrades = $userthreads = array(); if (!$_G['inajax']) { $limit = 6; $query = DB::query("SELECT t.tid, t.pid, t.aid, t.subject, t.price, t.credit, t.displayorder FROM " . DB::table('forum_trade') . " t\r\n\t\t\t\tLEFT JOIN " . DB::table(getattachtablebytid($_G['tid'])) . " a ON t.aid=a.aid\r\n\t\t\t\tWHERE t.sellerid='" . $_G['forum_thread']['authorid'] . "' AND t.tid='{$_G['tid']}' ORDER BY t.displayorder DESC LIMIT " . ($limit + 1)); $usertradecount = 0; while ($usertrade = DB::fetch($query)) { if ($usertrade['pid'] == $post['pid']) { continue; } $usertradecount++; $usertrades[] = $usertrade; if ($usertradecount == $limit) { break; } } } if ($_G['forum_attachpids']) { require_once libfile('function/attachment'); parseattach($_G['forum_attachpids'], $_G['forum_attachtags'], $postlist, array($trade['aid']));
function forum_downremotefile($arr, $old_arr) { global $_G; $evo_img_no = $_G['cache']['evn_milu_pick']['evo_img_no']; $config = get_pick_set(); $get_file_ext_arr = $config['get_file_ext'] ? explode('|', $config['get_file_ext']) : array(); $arr['is_download_file'] = $arr['is_download_file'] ? $arr['is_download_file'] : $arr['p_arr']['is_download_file']; $arr['message'] = dstripslashes($arr['content']); //print_r($arr); //$arr['message'] = str_replace(array("\r", "\n"), array($_GET['wysiwyg'] ? '<br />' : '', "\\n"), $arr['message']); preg_match_all("/\\[img\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]|\\[img=\\d{1,4}[x|\\,]\\d{1,4}\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/img\\]/is", $arr['message'], $image1, PREG_SET_ORDER); //preg_match_all("/\<img.+src=('|\"|)?(.*)(\\1)([\s].*)?\>/ismUe", $arr['message'], $image2, PREG_SET_ORDER); preg_match_all("/\\<img.+src=('|\"|)?(.*)(\\1)(.*)?\\>/isU", $arr['message'], $image2, PREG_SET_ORDER); $temp = $aids = $existentimg = $attach_arr = array(); if (is_array($image1) && !empty($image1)) { foreach ($image1 as $value) { $v = trim(!empty($value[1]) ? $value[1] : $value[2]); $no_remote = 0; if (!filter_something($v, $evo_img_no)) { //存在 $no_remote = 1; } if ($no_remote == 0) { $temp[] = array('0' => $value[0], '1' => $v); } } } if (is_array($image2) && !empty($image2)) { foreach ($image2 as $v) { $no_remote = 0; $v[2] = trim(strip_tags($v[2])); if (!filter_something($v[2], $evo_img_no)) { //存在 $no_remote = 1; } if ($no_remote == 0) { $temp[] = array('0' => $v[0], '1' => $v[2]); } } } if ($arr['is_download_file'] == 1) { $attach_arr = get_attach_data($arr['page_url'], $arr['message']); } $attach_arr = $attach_arr ? $attach_arr : array(); $temp = $temp ? $temp : array(); $temp = array_merge($temp, $attach_arr); //if(VIP) $arr['message'] = post($arr['message'], array('cookie' => $arr['cookie'], 'page_url' => $arr['page_url'], 'cid' => $arr['cid'])); $del_a = 0; if ($arr['content_filter_html'][0] == 0 && $arr['content_filter_html']) { $del_a = 1; } //print_r($arr['message']);exit(); require_once libfile('class/image'); if (is_array($temp) && !empty($temp)) { if (file_exists(libfile('class/upload'))) { require_once libfile('class/upload'); } else { require_once libfile('discuz/upload', 'class'); } $upload = new discuz_upload(); $attachaids = array(); $threadimage_flag = 0; $content_md5_arr = array(); foreach ($temp as $key => $value) { $snoopy_args['cookie'] = $arr['cookie']; $snoop_obj = get_snoopy_obj($snoopy_args); $imageurl = $value[1]; $hash = md5($imageurl); if (strlen($imageurl)) { $imagereplace['oldimageurl'][] = $value[0]; if (!isset($existentimg[$hash])) { $existentimg[$hash] = $imageurl; $attach['ext'] = $upload->fileext($imageurl); if ($upload->is_image_ext($attach['ext']) == 1 && $arr['is_download_img'] != 1) { $imagereplace['newimageurl'][] = $value[0]; continue; } if (!$upload->is_image_ext($attach['ext'])) { $ext = 'no_get'; } if (preg_match('/^(http:\\/\\/|\\.)/i', $imageurl)) { if ($imageurl && snoop_obj) { $content_re = get_img_content($imageurl, $snoop_obj, $ext); } if (is_array($content_re)) { $content = $content_re['content']; $file_name = $attach['name'] = $content_re['file_name'] ? $content_re['file_name'] : ($value[2] ? _striptext($value[2]) : time() . '.' . $content_re['file_ext']); $attach['ext'] = $content_re['file_ext'] ? $content_re['file_ext'] : trim($upload->fileext($file_name)); $file_name = $attach['name'] = $file_name; } else { $content = $content_re; } if (in_array(md5($content), $content_md5_arr)) { $imagereplace['newimageurl'][] = ''; continue; } $content_md5_arr[] = md5($content); } elseif (preg_match('/^(' . preg_quote(getglobal('setting/attachurl'), '/') . ')/i', $imageurl)) { $imagereplace['newimageurl'][] = $value[0]; } if (empty($content)) { if ($value[4] == 1) { if ($del_a == 1) { $imagereplace['newimageurl'][] = $value[2]; } else { unset($imagereplace['oldimageurl'][$key]); } } else { $imagereplace['newimageurl'][] = ''; } continue; } if (!$attach['name']) { $patharr = explode('/', $imageurl); $attach['name'] = trim($patharr[count($patharr) - 1]); } $patharr = explode('/', $imageurl); if (!$attach['name']) { $attach['name'] = trim($patharr[count($patharr) - 1]); } $attach['thumb'] = ''; $attach['ext'] = trim($attach['ext']); //不加这个有些还真不行 $attach['isimage'] = $upload->is_image_ext($attach['ext']); if ($attach['isimage'] == 1 && $arr['is_download_img'] != 1) { $imagereplace['newimageurl'][] = $value[0]; continue; } $attach['extension'] = $upload->get_target_extension($attach['ext']); $attach['attachdir'] = $upload->get_target_dir('forum'); $attach['attachment'] = $attach['attachdir'] . $upload->get_target_filename('forum') . '.' . $attach['extension']; $attach['target'] = getglobal('setting/attachdir') . './forum/' . $attach['attachment']; if (!in_array($attach['ext'], $get_file_ext_arr) && $get_file_ext_arr && $attach['isimage'] == 0) { if ($value[4] == 1) { if ($del_a == 1) { $imagereplace['newimageurl'][] = $value[2]; } else { unset($imagereplace['oldimageurl'][$key]); } } else { $imagereplace['newimageurl'][] = ''; } continue; } if (!@($fp = fopen($attach['target'], 'wb'))) { continue; } else { flock($fp, 2); fwrite($fp, $content); fclose($fp); } if (!$upload->get_image_info($attach['target']) && $attach['isimage'] == 1) { @unlink($attach['target']); continue; } $attach['size'] = filesize($attach['target']); $upload->attach = $attach; $thumb = $width = 0; if ($upload->attach['isimage']) { if ($_G['setting']['thumbstatus']) { $image = new image(); $thumb = $image->Thumb($upload->attach['target'], '', $_G['setting']['thumbwidth'], $_G['setting']['thumbheight'], $_G['setting']['thumbstatus'], $_G['setting']['thumbsource']) ? 1 : 0; $width = $image->imginfo['width']; } if ($_G['setting']['thumbsource'] || !$_G['setting']['thumbstatus']) { list($width) = @getimagesize($upload->attach['target']); } if ($_G['setting']['watermarkstatus'] && empty($_G['forum']['disablewatermark']) && $arr['is_water_img'] == 1) { $image = new image(); $image->Watermark($attach['target'], '', 'forum'); } } $desc = $value[3]; $arr['public_time'] = $arr['public_time'] ? $arr['public_time'] : $arr['dateline']; $arr['public_time'] = $arr['public_time'] ? $arr['public_time'] : $_G['timestamp']; $remote = 0; $setarr = array('uid' => $arr['uid'], 'tid' => $arr['tid'], 'pid' => $arr['pid'], 'filename' => daddslashes($upload->attach['name']), 'attachment' => $upload->attach['attachment'], 'filesize' => $upload->attach['size'], 'thumb' => $thumb, 'remote' => $remote, 'picid' => $picid, 'isimage' => $attach['isimage'], 'description' => $desc, 'readperm' => 0, 'price' => 0, 'width' => $width, 'dateline' => $arr['public_time']); $setimg_arr = array('tid' => $arr['tid'], 'attachment' => $upload->attach['attachment'], 'remote' => $remote); $set_att = array('downloads' => rand(1, 15), 'tableid' => getattachtableid($arr['tid']), 'uid' => $arr['uid'], 'pid' => $arr['pid'], 'tid' => $arr['tid']); if ($threadimage_flag == 0 && !$arr['is_post'] && $attach['isimage'] == 1) { DB::insert('forum_threadimage', $setimg_arr, true); $threadimage_flag = 1; } $setarr['aid'] = $newaids[] = DB::insert('forum_attachment', $set_att, true); $at[] = $setarr['aid']; $attachnew_arr[$setarr['aid']] = array('description' => $setarr['description']); DB::insert(getattachtablebytid($arr['tid']), $setarr, true); $attachaids[$hash] = $imagereplace['newimageurl'][] = '[attach]' . $setarr['aid'] . '[/attach]'; } else { $imagereplace['newimageurl'][] = $attachaids[$hash]; } } } if ($_G['setting']['ftp']['on'] == 1) { require_once libfile('function/post'); ftpupload($newaids, $arr['uid']); } if (count($at) > 0) { $arr['attachment'] = 2; } $arr['message'] = str_replace($imagereplace['oldimageurl'], $imagereplace['newimageurl'], $arr['message']); if ($del_a == 1) { $arr['message'] = clear_html_script($arr['message'], array(0)); } forum_article_content($arr); } }