} } $page = max(1, intval($_G['page'])); $total = 0; $query = $multipage = ''; if ($do == 'list') { $result = $modsession->get('srchresult_p' . $_G['fid']); $threadoptionselect[$result['threadoption']] = 'selected'; if ($result['fid'] == $_G['fid']) { $total = $result['count']; $tpage = ceil($total / $_G['tpp']); $page = min($tpage, $page); $multipage = multi($total, $_G['tpp'], $page, "{$cpscript}?mod=modcp&action={$_G['gp_action']}&op={$op}&fid={$_G['fid']}&do={$do}"); if ($total && $result['pids']) { $start = ($page - 1) * $_G['tpp']; $postarray = getallwithposts(array('select' => 'p.*, t.subject as tsubject', 'from' => DB::table('forum_post') . " p LEFT JOIN " . DB::table('forum_thread') . " t USING(tid)", 'where' => "pid IN ({$result['pids']})", 'order' => 'dateline DESC', 'limit' => "{$start}, {$_G['tpp']}")); } } } $postlist = array(); if ($postarray) { require_once libfile('function/post'); foreach ($postarray as $post) { $post['dateline'] = dgmdate($post['dateline']); $post['message'] = messagecutstr($post['message'], 200); $post['forum'] = $modforums['list'][$post['fid']]; $post['modthreadkey'] = modauthkey($post['tid']); $postlist[] = $post; } } }
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 ($row['aid'] && $modrecommend['sort'] == 2 || $modrecommend['sort'] == 1) { @unlink(DISCUZ_ROOT . './data/imagecache/' . intval($row['aid']) . '_' . $imgw . '_' . $imgh . '.jpg'); } 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) { $attacharray = getallwithposts(array('select' => 'p.fid, p.tid, a.aid', 'from' => DB::table('forum_post') . " p INNER JOIN " . DB::table('forum_attachment') . " a ON a.pid=p.pid and a.isimage IN ('1', '-1') AND a.width>='{$imgw}'", 'where' => "p.tid IN (" . dimplode($tids) . ") AND p.first='1'")); foreach ($attacharray as $attachment) { if (isset($recommendimagelist[$attachment['tid']])) { continue; } $key = authcode($attachment['aid'] . "\t" . $imgw . "\t" . $imgh, 'ENCODE', $_G['config']['security']['authkey']); $recommendlist[$attachment['tid']]['filename'] = 'forum.php?mod=image&aid=' . $attachment['aid'] . '&size=' . $imgw . 'x' . $imgh . '&key=' . rawurlencode($key); $recommendimagelist[$attachment['tid']] = $recommendlist[$attachment['tid']]; $addimg[$attachment['tid']] = ",'{$attachment['aid']}', '" . 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']) { $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 ($pids) { $query = DB::query("SELECT attachment, thumb, remote, aid FROM " . DB::table('forum_attachment') . " WHERE pid IN ({$deletepids})"); while ($attach = DB::fetch($query)) { dunlink($attach); } DB::query("DELETE FROM " . DB::table('forum_attachment') . " WHERE pid IN ({$pids})", 'UNBUFFERED'); DB::query("DELETE FROM " . DB::table('forum_attachmentfield') . " WHERE pid IN ({$pids})", 'UNBUFFERED'); $deletes = deletepost("pid IN ({$pids})"); DB::query("DELETE FROM " . DB::table('forum_trade') . " WHERE pid IN ({$pids})", 'UNBUFFERED'); } updatemodworks('DLP', count($moderation['delete'])); } if ($validatepids = dimplode($moderation['validate'])) { $forums = $threads = $lastpost = $attachments = $pidarray = $authoridarray = array(); $postarray = getallwithposts(array('select' => 't.lastpost, p.pid, p.fid, p.tid, p.authorid, p.author, p.dateline, p.attachment, p.message, p.anonymous, ff.replycredits', 'from' => DB::table('forum_post') . " p LEFT JOIN " . DB::table('forum_forumfield') . " ff ON ff.fid=p.fid LEFT JOIN " . DB::table('forum_thread') . " t ON t.tid=p.tid", 'where' => "pid IN ({$validatepids}) AND p.invisible='{$displayorder}' AND first='0' {$fidadd['and']}{$fidadd['0']}{$fidadd['fids']}")); foreach ($postarray as $post) { $pidarray[] = $post['pid']; if ($post['replycredits']) { updatepostcredits('+', $post['authorid'], 'reply', $post['fid']); } else { $authoridarray[] = $post['authorid']; } $forums[] = $post['fid']; $threads[$post['tid']]['posts']++; $threads[$post['tid']]['lastpostadd'] = $post['dateline'] > $post['lastpost'] && $post['dateline'] > $lastpost[$post['tid']] ? ", lastpost='{$post['dateline']}', lastposter='" . ($post['anonymous'] && $post['dateline'] != $post['lastpost'] ? '' : addslashes($post[author])) . "'" : ''; $threads[$post['tid']]['attachadd'] = $threads[$post['tid']]['attachadd'] || $post['attachment'] ? ', attachment=\'1\'' : ''; $pm = 'pm_' . $post['pid']; if (isset(${$pm}) && ${$pm} != '' && $post['authorid']) { $pmlist[] = array('action' => 'modreplies_validate', 'notevar' => array('tid' => $_G['tid'], 'post' => $post, 'reason' => stripslashes($reason)), 'authorid' => $post['authorid'], 'tid' => $post['tid'], 'post' => dhtmlspecialchars(cutstr($post['message'], 30)), 'reason' => dhtmlspecialchars(${$pm})); }
$_G['tid'] = intval($pm['tid']); notification_add($pm['authorid'], 'system', $pm['act'], $pm['notevar'], 1); } } showmessage('modcp_mod_succeed', "{$cpscript}?action={$_G['gp_action']}&op={$op}&filter={$filter}&fid={$_G['fid']}"); } $attachlist = array(); require_once libfile('function/discuzcode'); require_once libfile('function/attachment'); $ppp = 10; $page = max(1, intval($_G['page'])); $start_limit = ($page - 1) * $ppp; $modcount = getcountofposts(DB::table('forum_post'), "invisible='{$pstat}' AND first='0' AND " . ($modfidsadd ? $modfidsadd : '1')); $multipage = multi($modcount, $ppp, $page, "{$cpscript}?action={$_G['gp_action']}&op={$op}&filter={$filter}&fid={$_G['fid']}"); if ($modcount) { $postarray = getallwithposts(array('select' => 'f.name AS forumname, f.allowsmilies, f.allowhtml, f.allowbbcode, f.allowimgcode, p.pid, p.fid, p.tid, p.authorid, p.authorid, p.subject, p.dateline, p.message, p.useip, p.attachment, p.htmlon, p.smileyoff, p.bbcodeoff, t.subject AS tsubject', 'from' => DB::table('forum_post') . " p LEFT JOIN " . DB::table('forum_thread') . " t ON t.tid=p.tid LEFT JOIN " . DB::table('forum_forum') . " f ON f.fid=p.fid", 'where' => "p.invisible='{$pstat}' AND p.first='0' AND " . ($modfidsadd ? "p.{$modfidsadd}" : '1'), 'order' => 'p.dateline DESC', 'limit' => "{$start_limit}, {$ppp}")); foreach ($postarray as $post) { $post['id'] = $post['pid']; $post['dateline'] = dgmdate($post['dateline']); $post['subject'] = $post['subject'] ? '<b>' . $post['subject'] . '</b>' : '<i>' . $lang['nosubject'] . '</i>'; $post['message'] = nl2br(dhtmlspecialchars($post['message'])); if ($post['attachment']) { $queryattach = DB::query("SELECT aid, filename, filetype, filesize, attachment, isimage, remote FROM " . DB::table('forum_attachment') . " 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]}/attach[attachment]\" onload=\"if(this.width > 400) {this.resized=true; this.width=400;}\">" : "<a href=\"" . $_G['setting']['attachurl'] . "/{$attach['attachment']}\" target=\"_blank\">{$attach['filename']}</a> (" . sizecount($attach['filesize']) . ")"; $post['message'] .= "<br /><br />File: " . attachtype(fileext($attach['filename']) . "\t" . $attach['filetype']) . $attach['url']; } } $postlist[] = $post; }
$pid = DB::result_first("SELECT pid FROM " . DB::table($posttable) . " WHERE tid='{$ptid}' AND invisible='0' ORDER BY dateline LIMIT {$postno}, 1"); } else { $postno = $postno > 1 ? $postno - 1 : 0; if ($postno) { $pid = DB::result_first("SELECT pid FROM " . DB::table($posttable) . " WHERE tid='{$ptid}' AND invisible='0' ORDER BY dateline LIMIT {$postno}, 1"); } else { $pid = DB::result_first("SELECT pid FROM " . DB::table($posttable) . " WHERE tid='{$ptid}' AND first='1' LIMIT 1"); } } } $_G['gp_goto'] = 'findpost'; } if ($_G['gp_goto'] == 'findpost') { foreach ($threadtableids as $tableid) { $threadtable = $tableid ? "forum_thread_{$tableid}" : 'forum_thread'; $post = getallwithposts(array('select' => 'p.tid, p.dateline, t.status, t.special, t.replies', 'from' => DB::table('forum_post') . " p LEFT JOIN " . DB::table($threadtable) . " t USING(tid)", 'where' => "p.pid='{$pid}'")); if (!empty($post)) { $post = $post[0]; break; } } if ($post) { $ordertype = !isset($_GET['ordertype']) && getstatus($post['status'], 4) ? 1 : intval($ordertype); $sqladd = $post['special'] ? "AND first=0" : ''; $curpostnum = DB::result_first("SELECT count(*) FROM " . DB::table($posttable) . " WHERE tid='{$post['tid']}' AND dateline<='{$post['dateline']}' {$sqladd}"); if ($ordertype != 1) { $page = ceil($curpostnum / $_G['ppp']); } else { if ($curpostnum > 1) { $page = ceil(($post['replies'] - $curpostnum + 3) / $_G['ppp']); } else {
$pagetmp--; } while (!count($postarray) && $pagetmp); $posts = ''; foreach ($postarray as $post) { $post['dateline'] = dgmdate($post['dateline']); $post['subject'] = cutstr($post['subject'], 30); $post['message'] = dhtmlspecialchars(cutstr($post['message'], 50)); $posts .= showtablerow('', '', array("<input class=\"checkbox\" type=\"checkbox\" name=\"pidarray[]\" value=\"{$post['pid']}\" checked />", "<a href=\"forum.php?mod=redirect&goto=findpost&pid={$post['pid']}&ptid={$post['tid']}\" target=\"_blank\">{$post['subject']}</a>", $post['message'], "<a href=\"forum.php?mod=forumdisplay&fid={$post['fid']}\" target=\"_blank\">{$_G['cache'][forums][$post[fid]][name]}</a>", "<a href=\"home.php?mod=space&uid={$post['authorid']}\" target=\"_blank\">{$post['author']}</a>", $post['dateline']), TRUE); } $postcount = getcountofposts(DB::table('forum_post') . " p LEFT JOIN " . DB::table('forum_thread') . " t USING(tid)", "t.digest>=0 {$sql}"); $multi = multi($postcount, $_G['setting']['postperpage'], $page, ADMINSCRIPT . "?action=prune"); $multi = preg_replace("/href=\"" . ADMINSCRIPT . "\\?action=prune&page=(\\d+)\"/", "href=\"javascript:page(\\1)\"", $multi); $multi = str_replace("window.location='" . ADMINSCRIPT . "?action=prune&page='+this.value", "page(this.value)", $multi); } else { $postcount = 0; $postarray = getallwithposts(array('select' => 'pid', 'from' => DB::table('forum_post') . " p LEFT JOIN " . DB::table('forum_thread') . " t USING(tid)", 'where' => "t.digest>=0 {$sql}")); foreach ($postarray as $post) { $pids .= ',' . $post['pid']; $postcount++; } $multi = ''; } if (!$postcount) { $error = 'prune_post_nonexistence'; } } showtagheader('div', 'postlist', $searchsubmit); showformheader('prune&frame=no', 'target="pruneframe"'); showhiddenfields(array('pids' => authcode($pids, 'ENCODE'))); showtableheader(cplang('prune_result') . ' ' . $postcount . ' <a href="###" onclick="$(\'searchposts\').style.display=\'\';$(\'postlist\').style.display=\'none\';" class="act lightlink normal">' . cplang('research') . '</a>', 'fixpadding'); if ($error) {
$sql .= $_G['gp_author'] ? " AND p.author='{$_G['gp_author']}'" : ''; $sql .= $_G['gp_filename'] ? " AND a.filename LIKE '%{$_G['gp_filename']}%'" : ''; if ($_G['gp_keywords']) { $sqlkeywords = $or = ''; foreach (explode(',', str_replace(' ', '', $_G['gp_keywords'])) as $_G['gp_keywords']) { $sqlkeywords .= " {$or} af.description LIKE '%{$_G['gp_keywords']}%'"; $or = 'OR'; } $sql .= " AND ({$sqlkeywords})"; } $sql .= $_G['gp_sizeless'] ? " AND a.filesize<'{$_G['gp_sizeless']}'" : ''; $sql .= $_G['gp_sizemore'] ? " AND a.filesize>'{$_G['gp_sizemore']}' " : ''; $sql .= $_G['gp_dlcountless'] ? " AND a.downloads<'{$_G['gp_dlcountless']}'" : ''; $sql .= $_G['gp_dlcountmore'] ? " AND a.downloads>'{$_G['gp_dlcountmore']}'" : ''; $attachments = ''; $attachmentarray = getallwithposts(array('select' => 'a.*, af.description, p.fid, p.author, t.tid, t.subject, f.name AS fname', 'from' => DB::table('forum_attachment') . " a LEFT JOIN " . DB::table('forum_attachmentfield') . " af ON a.aid=af.aid, " . DB::table('forum_post') . " p, " . DB::table('forum_thread') . " t, " . DB::table('forum_forum') . " f", 'where' => "t.tid=a.tid AND f.fid=p.fid AND t.displayorder>='0' AND p.invisible='0' AND {$sql}", 'limit' => ($page - 1) * $ppp . ',' . $ppp)); foreach ($attachmentarray as $attachment) { if (!$attachment['remote']) { $matched = file_exists($_G['setting']['attachdir'] . '/forum/' . $attachment['attachment']) ? '' : cplang('attach_lost'); $attachment['url'] = $_G['setting']['attachurl'] . 'forum/'; } else { @set_time_limit(0); if (@fclose(@fopen($_G['setting']['ftp']['attachurl'] . '/' . $attachment['attachment'], 'r'))) { $matched = ''; } else { $matched = cplang('attach_lost'); } $attachment['url'] = $_G['setting']['ftp']['attachurl'] . '/forum/'; } $attachsize = sizecount($attachment['filesize']); if (!$_G['gp_nomatched'] || $_G['gp_nomatched'] && $matched) {
$query = DB::query("SELECT attachment, thumb, remote, aid FROM " . DB::table('forum_attachment') . " WHERE pid IN ({$deletepids})"); while ($attach = DB::fetch($query)) { dunlink($attach); } DB::query("DELETE FROM " . DB::table('forum_attachment') . " WHERE pid IN ({$pids})", 'UNBUFFERED'); DB::query("DELETE FROM " . DB::table('forum_attachmentfield') . " WHERE pid IN ({$pids})", 'UNBUFFERED'); require_once libfile('function/delete'); $deletes = deletepost("pid IN ({$pids})"); DB::query("DELETE FROM " . DB::table('forum_trade') . " WHERE pid IN ({$pids})", 'UNBUFFERED'); } updatemodworks('DLP', count($moderation['delete'])); } if ($validatepids = dimplode($moderation['validate'])) { require_once libfile('function/forum'); $forums = $threads = $lastpost = $attachments = $pidarray = $authoridarray = array(); $postarray = getallwithposts(array('select' => 't.lastpost, p.pid, p.fid, p.tid, p.authorid, p.author, p.dateline, p.attachment, p.message, p.anonymous, p.status', 'from' => DB::table('forum_post') . " p LEFT JOIN " . DB::table('forum_thread') . " t ON t.tid=p.tid", 'where' => "pid IN ({$validatepids}) AND first='0'")); foreach ($postarray as $post) { $pidarray[] = $post['pid']; my_post_log('validate', array('pid' => $post['pid'])); if (getstatus($post['status'], 3) == 0) { updatepostcredits('+', $post['authorid'], 'reply', $post['fid']); } $forums[] = $post['fid']; $threads[$post['tid']]['posts']++; $threads[$post['tid']]['lastpostadd'] = $post['dateline'] > $post['lastpost'] && $post['dateline'] > $lastpost[$post['tid']] ? ", lastpost='{$post['dateline']}', lastposter='" . ($post['anonymous'] && $post['dateline'] != $post['lastpost'] ? '' : addslashes($post[author])) . "'" : ''; $threads[$post['tid']]['attachadd'] = $threads[$post['tid']]['attachadd'] || $post['attachment'] ? ', attachment=\'1\'' : ''; $pm = 'pm_' . $post['pid']; if (isset($_G['gp_' . $pm]) && $_G['gp_' . $pm] != '' && $post['authorid']) { $pmlist[] = array('action' => 'modreplies_validate', 'notevar' => array('pid' => $post['pid'], 'tid' => $post['tid'], 'post' => dhtmlspecialchars(cutstr($post['message'], 30)), 'reason' => dhtmlspecialchars($_G['gp_' . $pm])), 'authorid' => $post['authorid']); } }