topicadmin.php
- <?php
- /*
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: [DISCUZ!] Crossday Discuz! Board ::
- :: (c) 2001-2005 Comsenz Technology Ltd (www.discuz.com) ::
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: Author: Crossday (tech@discuz.com) Cnteacher (cnteacher@discuz.com) ::
- :: Version: 2.5F 2004/10/01 05:15 ::
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- */
- //fix: BY pk0909
- /*
- 1 癸だ澄???肈?ぶhtml锣竡矪瞶
- 2 铬锣?url把计拜肈
- 3 у秖?埃?肈??⊿Τ?埃癸莱?ン
- */
- require './include/common.php';
- require_once DISCUZ_ROOT.'./include/post.php';
- //pk top hack 2005-3-20
- require_once DISCUZ_ROOT.'./include/cache.php';
- $discuz_action = 151;
- $tid = $tid ? $tid :'';
- $page = intval($page);
- $fpage = intval($fpage);
- if($tid) {
- $query = $db->query("SELECT * FROM $table_threads WHERE tid='$tid'");
- $thread = $db->fetch_array($query);
- $thread['subject'] .= $action == 'delthread' ? ", etc." : NULL;
- }
- if($forum['type'] == 'forum') {
- $navigation = "» <a href="forumdisplay.php?fid=$fid&page=$fpage">$forum[name]</a> » <a href="viewthread.php?tid=$tid">$thread[subject]</a> ";
- $navtitle = ' - '.strip_tags($forum['name']).' - '.$thread['subject'];
- } else {
- $query = $db->query("SELECT name, fid, moderator FROM $table_forums WHERE fid='$forum[fup]'");
- $fup = $db->fetch_array($query);
- $navigation = "» <a href="forumdisplay.php?fid=$fup[fid]">$fup[name]</a> » <a href="forumdisplay.php?fid=$fid&page=$fpage">$forum[name]</a> » <a href="viewthread.php?tid=$tid">$thread[subject]</a> ";
- $navtitle = ' - '.strip_tags($fup['name']).' - '.strip_tags($forum['name']).' - '.$thread['subject'];
- }
- if(!$discuz_user || !$discuz_pw || !modcheck($discuz_user)) {
- showmessage('admin_nopermission', NULL, 'HALTED');
- }
- $fupadd = $fup ? "OR (fid='$fup[fid]' && type<>'group')" : NULL;
- if($action == 'moderate') {
- if(!is_array($moderate) || !count($moderate)) {
- showmessage('admin_moderate_nothread');
- }elseif(!$operation){
- showmessage('admin_moderate_nooperation');
- }
- $tids = implode_ids($moderate);
- $query = $db->query("SELECT * FROM $table_threads WHERE tid IN($tids) ");
- if(!submitcheck('moderatesubmit')){
- $threadlist = array();
- while($thread = $db->fetch_array($query)) {
- if($thread['fid'] == $fid){
- $thread['lastposterenc'] = rawurlencode($thread['lastposter']);
- if($thread['attachment']) {
- require_once DISCUZ_ROOT.'./include/attachment.php';
- $thread['attachment'] = attachtype($thread['attachment']).' ';
- } else {
- $thread['attachment'] = '';
- }
- $thread[subject] = cutstr($thread[subject],77);
- $thread['dateline'] = gmdate($dateformat, $thread['dateline'] + $timeoffset * 3600);
- $thread['lastpost'] = gmdate("$dateformat $timeformat", $thread['lastpost'] + $timeoffset * 3600);
- $threadlist[] = $thread;
- }
- }
-
- if(!$threadlist) showmessage('admin_moderate_nothread');
- if($operation == 'move') {
- require_once DISCUZ_ROOT.'./include/forum.php';
- $forumselect = forumselect();
- }
- include template('topicadmin_moderate');
-
- }else{
-
- if($operation == 'move' && $allowmove) {
- if(!$moveto) {
- showmessage('admin_move_invalid');
- }
- accesscheck($query);
- $displayorderadd = !$adminglobal ? ", displayorder='0'" : NULL;
- $db->query("UPDATE $table_threads SET fid='$moveto' $displayorderadd WHERE tid IN($tids)");
- $db->query("UPDATE $table_posts SET fid='$moveto' WHERE tid IN($tids) ");
- if ($forum['type'] == 'sub') {
- $query= $db->query("SELECT fup FROM $table_forums WHERE fid='$fid' LIMIT 1");
- $fup = $db->result($query, 0);
- updateforumcount($fup);
- }
- modlog();
- updateforumcount($moveto);
- updateforumcount($fid);
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$page");
- }elseif($operation == 'stick' && $allowtop){
- accesscheck($query);
- if($level < 0 || $level > 3 || ($level == 2 && $adminid != 1 && $adminid != 2) || ($level == 3 && $adminid != 1)) {
- showmessage('undefined_action');
- }
- $db->query("UPDATE $table_threads SET displayorder='$level' WHERE tid IN ($tids)");
- //pk top hack 2005-3-20
- if ($level < 2) {
- $db->query("DELETE FROM {$tablepre}topthreads WHERE tid IN ($tids)");
- if ($db->affected_rows()) updatecache('topthreads');
- } else {
- $tidArray = explode(',', $tids);
- foreach ($tidArray as $tmp) {
- $db->query("INSERT INTO {$tablepre}topthreads (tid) VALUES ($tmp)", 'SILENT');
- }
- updatecache('topthreads');
- }
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$page");
- }elseif($operation == 'delete' && $allowdelpost) {
- accesscheck($query);
- $uids = $comma = '';
- $haveattach = 0;
- $query = $db->query("SELECT authorid ,aid FROM $table_posts WHERE tid IN ($tids)");
- while($post = $db->fetch_array($query)) {
- $uids .= "$comma$post[authorid]";
- $comma = ',';
- if ($post['aid']) $haveattach++;
- }
- updatemember('-', $uids, $deletedcredits);
- if ($haveattach){
- $query = $db->query("SELECT attachment FROM $table_attachments WHERE tid IN ($tids)");
- while($attach = $db->fetch_array($query)) {
- @unlink(DISCUZ_ROOT.'./'.$attachdir.'/'.$attach['attachment']);
- }
- $db->query("DELETE FROM $table_attachments WHERE tid IN ($tids)");
- }
-
- $db->query("DELETE FROM $table_threads WHERE tid IN ($tids)");
- $db->query("DELETE FROM $table_polls WHERE tid IN ($tids)");
- $db->query("DELETE FROM $table_posts WHERE tid IN ($tids)");
- //pk top hack 2005-3-20
- $db->query("DELETE FROM {$tablepre}topthreads WHERE tid IN ($tids)");
- if ($db->affected_rows()) updatecache('topthreads');
- updateforumcount($fid);
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$page");
- }elseif($operation == 'close' && $allowclose){
- accesscheck($query);
- $close = $type ? 1 : 0;
- $db->query("UPDATE $table_threads SET closed='$close' WHERE tid in($tids)");
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$page");
- }elseif($operation == 'digest' && $allowdigest){
- if($level < 0 || $level > 3) {
- showmessage('undefined_action', NULL, 'HALTED');
- }
- while($thread = $db->fetch_array($query)) {
- if ($thread['fid'] == $fid && $thread['digest']<>$level){
- $digest_mark=($level-intval($thread['digest']))*$digestcredits;
- $db->query("UPDATE $table_threads SET digest='$level' WHERE tid='$thread[tid]'");
- if($digest_mark && $discuz_uid != $thread[authorid]) {
- $db->query("UPDATE $table_members SET credit=credit".($digest_mark > 0 ? '+' : '')."$digest_mark WHERE uid='$thread[authorid]'");
- }
- }
- }
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$page");
- }else{
- showmessage('admin_nopermission', NULL, 'HALTED');
- }
- }
- } elseif($action == 'delpost' && $allowdelpost) {
- if(!is_array($delete) || !count($delete)) {
- showmessage('admin_delpost_invalid');
- }
- if(!submitcheck('delpostsubmit')) {
- $query = $db->query("SELECT COUNT(*) FROM $table_posts WHERE tid='$tid'");
- if(count($delete) < $db->result($query, 0)) {
- $deleteid = '';
- foreach($delete as $id) {
- $deleteid .= '<input type="hidden" name="delete[]" value="'.$id.'">';
- }
- include template('topicadmin_delpost');
-
- } else {
- header("Location: {$boardurl}topicadmin.php?action=delete&fid=$fid&tid=$tid&page=$page&fpage=$fpage");
- }
- } else {
- $pids = implode_ids( $delete );
- $uids = $comma = '';
- $actionpost = $totalpost = $aids = 0;
- $query = $db->query("SELECT pid, authorid, aid FROM $table_posts WHERE tid='$tid'");
- $totalpost = $db->num_rows($query);
- while($post = $db->fetch_array($query)) {
- if (in_array($post[pid], $delete)){
- $uids .= "$comma$post[authorid]";
- $comma = ',';
- $actionpost ++;
- if ($post['aid']) $aids .=','.$post[pid];
- }
- }
- if ($actionpost < 1) {
- showmessage('admin_delpost_invalid');
- }elseif($actionpost <> count($delete)){
- showmessage('admin_moderate_accesserror', NULL, 'HALTED');
- }elseif($actionpost >= $totalpost ){
- header("Location: {$boardurl}topicadmin.php?action=delete&fid=$fid&tid=$tid&page=$page&fpage=$fpage");
- }
-
- updatemember('-', $uids, $deletedcredits);
- if ($aids){
- require_once DISCUZ_ROOT.'./include/attachment.php';
- $query = $db->query("SELECT pid, attachment, filetype FROM $table_attachments WHERE pid IN ($aids)");
- while($attach = $db->fetch_array($query)) {
- @unlink(DISCUZ_ROOT.'./'.$attachdir.'/'.$attach['attachment']);
- }
- $db->query("DELETE FROM $table_attachments WHERE pid IN ($aids)");
- updatethread_type($tid , $thread['attachment']);
- }
- $db->query("DELETE FROM $table_posts WHERE pid IN ($pids)");
- updatethreadcount($tid);
- updateforumcount($fid);
- modlog();
- showmessage('admin_succeed', "viewthread.php?tid=$tid&page=$page&fpage=$fpage");
- }
- } elseif($action == 'highlight' && $allowhighlight) {
- if(!submitcheck('highlightsubmit')) {
- $string = sprintf('%02d', $thread['highlight']);
- $stylestr = sprintf('%03b', $string[0]);
- for($i = 1; $i <= 3; $i++) {
- $stylecheck[$i] = $stylestr[$i - 1] ? 'checked' : NULL;
- }
- $colorcheck = array($string[1] => 'checked');
-
- include template('topicadmin_highlight');
- } else {
- $stylebin = '';
- for($i = 1; $i <= 3; $i++) {
- $stylebin .= empty($highlight_style[$i]) ? '0' : '1';
- }
- $highlight_style = bindec($stylebin);
- if($highlight_style < 0 || $highlight_style > 7 || $highlight_color < 0 || $highlight_color > 8) {
- showmessage('undefined_action', NULL, 'HALTED');
- }
- $db->query("UPDATE $table_threads SET highlight='$highlight_style$highlight_color' WHERE tid='$tid'");
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } elseif($action == 'digest' && $allowdigest) {
- if(!submitcheck('digestsubmit')) {
- include template('topicadmin_digest');
- } else {
- if($level < 0 || $level > 3) {
- showmessage('undefined_action', NULL, 'HALTED');
- }
- $digest_mark=($level-intval($thread['digest']))*$digestcredits;
- $db->query("UPDATE $table_threads SET digest='$level' WHERE tid='$tid'");
- if($digest_mark && $discuz_uid != $thread['authorid'] ) {
- $db->query("UPDATE $table_members SET credit=credit".($digest_mark > 0 ? '+' : '')."$digest_mark WHERE uid='$thread[authorid]'");
- }
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } elseif($action == 'recount') {
- $query = $db->query("SELECT COUNT(*) FROM $table_posts WHERE tid='$tid'");
- $replies = $db->result($query, 0) - 1;
- $query = $db->query("SELECT author, dateline FROM $table_posts WHERE tid='$tid' ORDER BY dateline DESC LIMIT 1");
- $post = $db->fetch_array($query);
- $db->query("UPDATE $table_threads SET replies='$replies', lastpost='$post[dateline]', lastposter='".addslashes($post['author'])."' WHERE tid='$tid'");
- showmessage('admin_succeed', "viewthread.php?tid=$tid&fpage=$fpage");
- } elseif($action == 'delete' && $allowdelpost) {
- if(!submitcheck('deletesubmit')) {
- include template('topicadmin_delete');
- } else {
- $uids = $comma = '';
- $query = $db->query("SELECT authorid,aid FROM $table_posts WHERE tid='$tid'");
- $aids = 0;
- while($post = $db->fetch_array($query)) {
- $uids .= "$comma$post[authorid]";
- $comma = ',';
- if ($post['aid']) $aids++;
- }
- updatemember('-', $uids, $deletedcredits);
- $db->query("DELETE FROM $table_threads WHERE tid='$tid'");
- $db->query("DELETE FROM $table_posts WHERE tid='$tid'");
-
- if ($aids){
- $query = $db->query("SELECT attachment FROM $table_attachments WHERE tid='$tid'");
- while($attach = $db->fetch_array($query)) {
- @unlink(DISCUZ_ROOT.'./'.$attachdir.'/'.$attach['attachment']);
- }
- $db->query("DELETE FROM $table_attachments WHERE tid='$tid'");
- }
-
- updateforumcount($fid);
- if ($forum['type'] == 'sub') {
- updateforumcount($fup['fid']);
- }
- modlog();
- //pk top hack 2005-3-20
- $db->query("DELETE FROM {$tablepre}topthreads WHERE tid='$tid'");
- if ($db->affected_rows()) updatecache('topthreads');
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } elseif($action == 'close' && $allowclose) {
- if(!submitcheck('closesubmit')) {
- include template('topicadmin_openclose');
- } else {
- $openclose = $thread['closed'] ? 0 : 1;
- $db->query("UPDATE $table_threads SET closed='$openclose' WHERE tid='$tid' AND fid='$fid'");
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } elseif($action == 'move' && $allowmove) {
- if(!submitcheck('movesubmit')) {
- require_once DISCUZ_ROOT.'./include/forum.php';
- $forumselect = forumselect();
- include template('topicadmin_move');
- } else {
- if(!$moveto) {
- showmessage('admin_move_invalid');
- }
- $displayorderadd = !$adminglobal ? ", displayorder='0'" : NULL;
- if($type == 'normal') {
- $db->query("UPDATE $table_threads SET fid='$moveto' $displayorderadd WHERE tid='$tid' AND fid='$fid'");
- $db->query("UPDATE $table_posts SET fid='$moveto' WHERE tid='$tid' AND fid='$fid'");
- } else {
- $db->query("INSERT INTO $table_threads (fid, creditsrequire, iconid, author, authorid, subject, dateline, lastpost, lastposter, views, replies, displayorder, digest, closed, poll, attachment)
- VALUES ('$thread[fid]', '$thread[creditsrequire]', '$thread[iconid]', '".addslashes($thread['author'])."', '$thread[authorid]', '$thread[subject]', '$thread[dateline]', '$thread[lastpost]', '$thread[lastposter]', '0', '0', '0', '0', '$thread[tid]', '0', '0')");
- $db->query("UPDATE $table_threads SET fid='$moveto' $displayorderadd WHERE tid='$tid' AND fid='$fid'");
- $db->query("UPDATE $table_posts SET fid='$moveto' WHERE tid='$tid' AND fid='$fid'");
- }
- if ($forum['type'] == 'sub') {
- $query= $db->query("SELECT fup FROM $table_forums WHERE fid='$fid' LIMIT 1");
- $fup = $db->result($query, 0);
- updateforumcount($fup);
- }
- modlog();
- updateforumcount($moveto);
- updateforumcount($fid);
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } elseif($action == 'top' && $allowtop) {
- if(!submitcheck('topsubmit')) {
- include template('topicadmin_topuntop');
- } else {
- if($level < 0 || $level > 3 || ($level == 2 && $adminid != 1 && $adminid != 2) || ($level == 3 && $adminid != 1)) {
- showmessage('undefined_action');
- }
- $db->query("UPDATE $table_threads SET displayorder='$level' WHERE tid='$tid' AND fid='$fid'");
- modlog();
- //pk top hack 2005-3-20
- if ($level > 1) {
- $db->query("INSERT INTO {$tablepre}topthreads (tid) VALUES ('$tid')", 'SILENT');
- updatecache('topthreads');
- } else {
- $db->query("DELETE FROM {$tablepre}topthreads WHERE tid='$tid'");
- if ($db->affected_rows()) updatecache('topthreads');
- }
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } elseif($action == 'getip' && $allowviewip) {
- require_once DISCUZ_ROOT.'./include/misc.php';
- $query = $db->query("SELECT m.adminid, p.useip FROM $table_posts p
- LEFT JOIN $table_members m ON m.uid=p.authorid
- WHERE pid='$pid' AND tid='$tid'");
- if(!$member = $db->fetch_array($query)) {
- showmessage('thread_nonexistence', NULL, 'HALTED');
- } elseif(($member['adminid'] == 1 && $adminid > 1) || ($member['adminid'] == 2 && $adminid > 2)) {
- showmessage('admin_getip_nopermission', NULL, 'HALTED');
- }
- $member['iplocation'] = convertip($member['useip']);
- include template('topicadmin_getip');
- } elseif($action == 'bump') {
- if(!submitcheck('bumpsubmit')) {
- include template('topicadmin_bump');
- } else {
- $query = $db->query("SELECT subject, lastposter, lastpost FROM $table_threads WHERE tid='$tid' LIMIT 1");
- $thread = $db->fetch_array($query);
- $thread[lastposter] = addslashes($thread['lastposter']);
- $db->query("UPDATE $table_threads SET lastpost='$timestamp' WHERE tid='$tid' AND fid='$fid'");
- $db->query("UPDATE $table_forums SET lastpost='$thread[subject]\t$timestamp\t$thread[lastposter]' WHERE fid='$fid' $fupadd");
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } elseif($action == 'split' && $allowsplit) {
- if(!submitcheck('splitsubmit')) {
- require_once DISCUZ_ROOT.'./include/discuzcode.php';
- $replies = $thread['replies'];
- if($replies <= 0) {
- showmessage('admin_split_invalid');
- }
- $postlist = array();
- $query = $db->query("SELECT * FROM $table_posts WHERE tid='$tid' ORDER BY dateline");
- while($post = $db->fetch_array($query)) {
- $post['message'] = postify($post['message'], $post['smileyoff'], $post['bbcodeoff']);
- $postlist[] = $post;
- }
- include template('topicadmin_split');
- } else {
- if(!trim($subject)) {
- showmessage('admin_split_subject_invalid');
- }
- $subject = $subject ? dhtmlspecialchars(censor(trim($subject))) :'';
- $pids = implode_ids( $split );
- if($pids) {
- $db->query("INSERT INTO $table_threads (fid, subject) VALUES ('$fid', '$subject')");
- $newtid = $db->insert_id();
- $db->query("UPDATE $table_posts SET tid='$newtid' WHERE pid IN ($pids)");
- $db->query("UPDATE $table_attachments SET tid='$newtid' WHERE pid IN ($pids)");
- $query = $db->query("SELECT author, authorid, dateline FROM $table_posts WHERE tid='$tid' ORDER BY dateline ASC LIMIT 1");
- $fpost = $db->fetch_array($query);
- $db->query("UPDATE $table_threads SET author='$fpost[author]', authorid='$fpost[authorid]', dateline='$fpost[dateline]' WHERE tid='$tid'");
- $query = $db->query("SELECT author, authorid, dateline FROM $table_posts WHERE tid='$newtid' ORDER BY dateline ASC LIMIT 1");
- $fpost = $db->fetch_array($query);
- $db->query("UPDATE $table_threads SET author='$fpost[author]', authorid='$fpost[authorid]', dateline='$fpost[dateline]' WHERE tid='$newtid'");
- updatethreadcount($tid);
- updatethreadcount($newtid);
- updateforumcount($fid);
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- } else {
- showmessage('admin_split_new_invalid');
- }
- }
- } elseif($action == 'merge' && $allowmerge) {
- if(!submitcheck('mergesubmit')) {
- include template('topicadmin_merge');
- } else {
- $query = $db->query("SELECT fid, views, replies FROM $table_threads WHERE tid='$othertid'");
- if(!$other = $db->fetch_array($query)) {
- showmessage('admin_merge_nonexistence');
- }
- if(!$adminglobal && $other['fid'] != $forum['fid']) {
- showmessage('admin_merge_invalid');
- }
- $other['views'] = intval($other['views']);
- $other['replies']++;
- $db->query("UPDATE $table_posts SET tid='$tid' WHERE tid='$othertid'");
- $postsmerged = $db->affected_rows();
- $db->query("UPDATE $table_attachments SET tid='$tid' WHERE tid='$othertid'");
- $db->query("DELETE FROM $table_threads WHERE tid='$othertid'");
- $db->query("UPDATE $table_threads SET views=views+$other[views], replies=replies+$other[replies] WHERE tid='$tid'");
-
- if($fid == $other['fid']) {
- $db->query("UPDATE $table_forums SET threads=threads-1 WHERE fid='$fid' $fupadd");
- } else {
- $db->query("UPDATE $table_forums SET threads=threads-1, posts=posts-$postsmerged WHERE fid='$other[fid]'");
- $db->query("UPDATE $table_forums SET posts=$posts+$postsmerged WHERE fid='$fid' $fupadd");
- }
- modlog();
- showmessage('admin_succeed', "forumdisplay.php?fid=$fid&page=$fpage");
- }
- } else {
- showmessage('admin_nopermission', NULL, 'HALTED');
- }
- function modlog($action = '') {
- global $discuz_user, $groupid, $adminid, $onlineip, $timestamp, $forum, $thread, $operation, $tids;
- if(!$action) {
- $action = $GLOBALS['action'];
- }
- if (!$thread['tid']) $thread['tid']=intval($GLOBALS['tid']);
- if ($action == 'moderate'){
- $action .='_'.$operation;
- $thread[subject] = $tids;
- $thread[tid] = 0;
- }
- @$fp = fopen(DISCUZ_ROOT.'./forumdata/modslog.php', 'a');
- @flock($fp, 2);
- @fwrite($fp, "$timestamp\t$discuz_user\t$groupid\t$onlineip\t$forum[fid]\t$forum[name]\t$thread[tid]\t$thread[subject]\t$action\n");
- @fclose($fp);
- }
- function accesscheck($query) {
- global $db,$fid;
- while($thread = $db->fetch_array($query)) {
- if($thread['fid'] <> $fid){
- showmessage('admin_moderate_accesserror', NULL, 'HALTED');
- }
- }
- }
- ?>
复制代码
forumdisplay.php
- <?php
- /*
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: [DISCUZ!] Crossday Discuz! Board ::
- :: (c) 2001-2005 Comsenz Technology Ltd (www.discuz.com) ::
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: Author: Crossday (tech@discuz.com) Cnteacher (cnteacher@discuz.com) ::
- :: Version: 2.5F 2004/10/01 05:15 ::
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- */
- //fix: BY pk0909
- /*
- 1 そ???硈钡拜肈
- 2 accessmask?拜肈
- */
- define('CURRSCRIPT', 'forumdisplay');
- require './include/common.php';
- require DISCUZ_ROOT.'./include/forum.php';
- $discuz_action = 2;
- if(isset($showoldetails)) {
- switch ($showoldetails) {
- case 'no': setcookie('onlinedetail', 0, $timestamp + 86400 * 365, $cookiepath, $cookiedomain); break;
- case 'yes': setcookie('onlinedetail', 1, $timestamp + 86400 * 365, $cookiepath, $cookiedomain); break;
- }
- } else {
- $showoldetails = false;
- }
- if(!$forum['fid'] || $forum['type'] == 'group' || ($adminid<>1 && !$forum[status])) {
- showmessage('forum_nonexistence', NULL, 'HALTED');
- }
- if($forum['type'] == 'forum') {
- $navigation = "» $forum[name]";
- $navtitle = ' - '.strip_tags($forum['name']);
- } else {
- $forumup = $_DCACHE['forums'][$forum['fup']]['name'];
- $navigation = "» <a href="forumdisplay.php?fid=$forum[fup]">$forumup</a> » $forum[name]";
- $navtitle = ' - '.strip_tags($forumup).' - '.strip_tags($forum['name']);
- }
- if($forum['password'] && $action == 'pwverify') {
- if($pw != $forum['password']) {
- showmessage('forum_passwd_incorrect', NULL, 'HALTED');
- } else {
- setcookie("fidpw$fid", $pw, 0, $cookiepath, $cookiedomain);
- showmessage('forum_passwd_correct', "forumdisplay.php?fid=$fid");
- }
- }
- if($forum['viewperm'] && !strstr($forum['viewperm'], "\t$groupid\t") && !$forum['allowview']) {
- showmessage('forum_nopermission', NULL, 'HALTED');
- }
- if(!empty($forum['password']) && $forum['password'] != $_COOKIE["fidpw$fid"]) {
- include template('forumdisplay_passwd');
- exit();
- }
- $ismoderator = modcheck($discuz_user);
- $moderatedby = moddisplay($forum['moderator'], 'forumdisplay');
- $postcredits = $forum['postcredits'] != -1 ? $forum['postcredits'] : $postcredits;
- $replycredits = $forum['replycredits'] != -1 ? $forum['replycredits'] : $replycredits;
- $subexists = 0;
- foreach($_DCACHE['forums'] as $sub) {
- if($sub['type'] == 'sub' && $sub['fup'] == $fid && ($accessmasks || !$hideprivate || !$sub['viewperm'] || strstr($sub['viewperm'], "\t$groupid\t") || strstr($sub['users'], "\t$discuz_uid\t"))) {
- $sublist = array();
- $sql = $accessmasks ? "SELECT f.fid, f.fup, f.type, f.icon, f.name, f.description, f.moderator, f.threads, f.posts, f.lastpost, f.viewperm, a.allowview FROM $table_forums f
- LEFT JOIN $table_access a ON a.uid='$discuz_uid' AND a.fid=f.fid
- WHERE fup='$fid' AND status='1' AND type='sub' ORDER BY f.displayorder"
- : "SELECT fid, fup, type, icon, name, description, moderator, threads, posts, lastpost, viewperm FROM $table_forums WHERE fup='$fid' AND status='1' AND type='sub' ORDER BY displayorder";
- $query = $db->query($sql);
- while($sub = $db->fetch_array($query)) {
- if(forum($sub)) {
- $sublist[] = $sub;
- $subexists = 1;
- }
- }
- break;
- }
- }
- $page = intval($page) ? intval($page) : 1;
- $start_limit = ($page - 1) * $tpp;
- $announcement_list = array();
- if($page == 1 && $_DCACHE['announcements_forum']) {
- foreach($_DCACHE['announcements_forum'] as $ann) {
- $ann['authorencode'] = rawurlencode($ann['author']);
- $ann['starttime'] = gmdate("$dateformat $timeformat", $ann['starttime'] + ($timeoffset * 3600));
- $announcement_list[] = $ann ;
- }
- }
- $forumdisplayadd = $filteradd = '';
- if(!empty($filter)) {
- if(is_numeric($filter)) {
- $forumdisplayadd .= "&filter=$filter";
- $filteradd = "AND lastpost>='".($timestamp - $filter)."'";
- } elseif($filter == 'digest') {
- $forumdisplayadd .= "&filter=digest";
- $filteradd = "AND digest>'0'";
- }
- } else {
- $filter = '';
- }
- $ascdesc == 'ASC' ? $forumdisplayadd .= "&ascdesc=$ascdesc" : $ascdesc = 'DESC';
- if($whosonlinestatus == 2 || $whosonlinestatus == 3) {
- $whosonlinestatus = 0;
- $onlineinfo = explode("\t", $onlinerecord);
- $detailstatus = ((!isset($_COOKIE['onlinedetail']) && $onlineinfo[0] < 500) || ($_COOKIE['onlinedetail'] || $showoldetails == 'yes')) && $showoldetails != 'no';
- if($detailstatus) {
- updatesession();
- @include language('actions');
- $whosonline = array();
- $forumname = strip_tags($forum['name']);
- $query = $db->query("SELECT uid, groupid, username, invisible, lastactivity, action FROM $table_sessions WHERE uid>'0' AND fid='$fid' AND invisible='0'");
- if($db->num_rows($query)) {
- $whosonlinestatus = 1;
- while($online = $db->fetch_array($query)) {
- $online['icon'] = isset($_DCACHE['onlinelist'][$online['groupid']]) ? $_DCACHE['onlinelist'][$online['groupid']] : $_DCACHE['onlinelist'][0];
- $online['action'] = $actioncode[$online['action']];
- $online['lastactivity'] = gmdate($timeformat, $online['lastactivity'] + ($timeoffset * 3600));
- $whosonline[] = $online;
- }
- }
- unset($online);
- }
- } else {
- $whosonlinestatus = 0;
- }
- if($discuz_uid && $newpm) {
- require DISCUZ_ROOT.'./include/pmprompt.php';
- }
- if(!empty($filter)) {
- $query = $db->query("SELECT COUNT(*) FROM $table_threads WHERE fid='$fid' $filteradd");
- $threadcount = $db->result($query, 0);
- } else {
- $threadcount = $forum['threads'];
- }
- $multipage = multi($threadcount, $tpp, $page, "forumdisplay.php?fid=$fid$forumdisplayadd");
- $separatepos = 0;
- $threadlist = array();
- $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
- $toptids = '0';
- $topcount = 0;
- if (!$filter && $page == 1) {
- foreach ($_DCACHE['topthreads'] as $topthread) {
- $toptids .= ',' . $topthread['tid'];
- $topcount++;
- }
- }
- if ($topcount) {
- $tfids = '0';
- $tForumArray = array();
- if ($forum['type'] == 'forum') {
- $groupfid = $forum['fup'];
- } elseif ($forum['type'] == 'sub') {
- $groupfid = $_DCACHE['forums'][$forum['fup']]['fup'];
- }
- foreach($_DCACHE['forums'] as $key => $value) {
- if ($value['type'] == 'forum' && $value['fup'] == $groupfid) {
- $tfids .= ','.$key;
- $tForumArray[] = $key;
- }
- }
- foreach($_DCACHE['forums'] as $key => $value) {
- if ($value['type'] == 'sub' && in_array($value['fup'],$tForumArray)) {
- $tfids .= ','.$key;
- }
- }
- $sql = "SELECT t.* FROM $table_threads t
- WHERE tid IN ($toptids)
- AND (t.displayorder=3 OR (t.displayorder=2 AND t.fid IN ($tfids)))
- ORDER BY t.displayorder DESC, t.lastpost DESC";
- $query = $db->query($sql);
- while($thread = $db->fetch_array($query)) {
- if($thread['attachment']) {
- require_once DISCUZ_ROOT.'./include/attachment.php';
- }
- parseThread();
- $threadlist[] = $thread;
- }
- }
- $sql = "SELECT t.* FROM $table_threads t
- WHERE t.fid='$fid' $filteradd
- ORDER BY t.displayorder DESC, t.lastpost $ascdesc
- LIMIT $start_limit, $tpp ";
- $query = $db->query($sql);
- while($thread = $db->fetch_array($query)) {
- if($thread['attachment']) {
- require_once DISCUZ_ROOT.'./include/attachment.php';
- }
- if ($thread['displayorder'] < 2 || !$topcount) {
- parseThread();
- $threadlist[] = $thread;
- }
- }
- $check[$filter] = 'selected="selected"';
- $ascdesc == 'ASC' ? $check['asc'] = 'selected="selected"' : $check['desc'] = 'selected="selected"';
- $forumselect = $forumjump ? forumselect() : NULL;
- $usesigcheck = $signature ? 'checked' : NULL;
- $allowpost = (!$forum['postperm'] && $allowpost) || ($forum['postperm'] && strstr($forum['postperm'], "\t$groupid\t")) || $forum['allowpost'];
- include template('forumdisplay');
- function parseThread() {
- global $thread, $_DCACHE, $postsnum, $ppp, $pagelinks, $topicpages, $string, $colorarray, $dateformat, $timeformat, $timeoffset, $separatepos, $hottopic;
- $thread['icon'] = isset($_DCACHE['icons'][$thread['iconid']]) ? '<img src="'.SMDIR.'/'.$_DCACHE['icons'][$thread['iconid']].'" align="absmiddle">' : ' ';
- $thread['lastposterenc'] = rawurlencode($thread['lastposter']);
- $postsnum = $thread['replies'] + 1;
- if($postsnum > $ppp) {
- $pagelinks = '';
- $topicpages = ceil($postsnum / $ppp);
- for ($i = 1; $i <= $topicpages; $i++) {
- $pagelinks .= "<a href="viewthread.php?tid=$thread[tid]&page=$i&fpage=$page">$i</a> ";
- if($i == 6) {
- $i = $topicpages + 1;
- }
- }
- if($topicpages > 6) {
- $pagelinks .= " .. <a href="viewthread.php?tid=$thread[tid]&page=$topicpages&fpage=$page">$topicpages</a> ";
- }
- $thread['multipage'] = ' ( <img src="'.IMGDIR.'/multipage.gif" align="absmiddle" boader="0"> '.$pagelinks.')';
- } else {
- $thread['multipage'] = '';
- }
- 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: '.$colorarray[$string[1]] : '';
- $thread['highlight'] .= '"';
- } else {
- $thread['highlight'] = '';
- }
- if($thread['closed']) {
- $thread['new'] = 0;
- if($thread['closed'] > 1) {
- $thread['moved'] = $thread['tid'];
- $thread['tid'] = $thread['closed'];
- $thread['replies'] = '-';
- $thread['views'] = '-';
- } else {
- $thread['moved'] = 0;
- }
- $thread['folder'] = 'lock_folder.gif';
- } else {
- $thread['folder'] = 'folder.gif';
- if($lastvisit < $thread['lastpost'] && !strstr($_COOKIE['oldtopics'], "\t$thread[tid]\t")) {
- $thread['new'] = 1;
- $thread['folder'] = 'red_'.$thread['folder'];
- } else {
- $thread['new'] = 0;
- }
- if($thread['replies'] > $thread['views']) {
- $thread['views'] = $thread['replies'];
- }
- if($thread['replies'] >= $hottopic) {
- $thread['folder'] = 'hot_'.$thread['folder'];
- }
- }
- if($thread['attachment']) {
- $thread['attachment'] = attachtype($thread['attachment']).' ';
- } else {
- $thread['attachment'] = '';
- }
- $thread[subject] = cutstr($thread[subject],77);
- $thread['dateline'] = gmdate($dateformat, $thread['dateline'] + $timeoffset * 3600);
- $thread['lastpost'] = gmdate("$dateformat $timeformat", $thread['lastpost'] + $timeoffset * 3600);
- if($thread['displayorder'] > 0) {
- $separatepos++;
- }
- }
- ?>
复制代码 |