First commit

This commit is contained in:
2025-06-18 10:24:27 +08:00
commit ebc39cd5dd
3873 changed files with 412712 additions and 0 deletions

View File

View File

@@ -0,0 +1,89 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_banpost.php 30872 2012-06-27 10:11:44Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowbanpost']) {
showmessage('no_privilege_banpost');
}
$topiclist = $_GET['topiclist'];
$modpostsnum = count($topiclist);
if(!($banpids = dimplode($topiclist))) {
showmessage('admin_banpost_invalid');
} elseif(!$_G['group']['allowbanpost'] || !$_G['tid']) {
showmessage('admin_nopermission');
}
$posts = $authors = array();
$banstatus = 0;
foreach(C::t('forum_post')->fetch_all_post('tid:'.$_G['tid'], $topiclist) as $post) {
if($post['tid'] != $_G['tid']) {
continue;
}
$banstatus = ($post['status'] & 1) || $banstatus;
$authors[$post['authorid']] = 1;
$posts[] = $post;
}
$authorcount = count(array_keys($authors));
if(!submitcheck('modsubmit')) {
$banid = $checkunban = $checkban = '';
foreach($topiclist as $id) {
$banid .= '<input type="hidden" name="topiclist[]" value="'.$id.'" />';
}
$banstatus ? $checkunban = 'checked="checked"' : $checkban = 'checked="checked"';
if($modpostsnum == 1 || $authorcount == 1) {
include_once libfile('function/member');
$crimenum = crime('getcount', $posts[0]['authorid'], 'crime_banpost');
$crimeauthor = $posts[0]['author'];
}
include template('forum/topicadmin_action');
} else {
$banned = intval($_GET['banned']);
$modaction = $banned ? 'BNP' : 'UBN';
$reason = checkreasonpm();
include_once libfile('function/member');
$pids = $comma = '';
foreach($posts as $k => $post) {
if($banned) {
C::t('forum_postcomment')->delete_by_rpid($post['pid']);
C::t('forum_post')->increase_status_by_pid('tid:'.$_G['tid'], $post['pid'], 1, '|', true);
crime('recordaction', $post['authorid'], 'crime_banpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $_G['tid'], 'pid' => $post['pid'])));
} else {
C::t('forum_post')->increase_status_by_pid('tid:'.$_G['tid'], $post['pid'], 1, '&~', true);
}
$pids .= $comma.$post['pid'];
$comma = ',';
}
$resultarray = array(
'redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page=$page",
'reasonpm' => ($sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_ban_post', 'notictype' => 'post') : array()),
'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason),
'modtids' => 0,
'modlog' => $thread
);
}
?>

View File

@@ -0,0 +1,103 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_copy.php 31594 2012-09-12 04:14:54Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowcopythread'] || !$thread) {
showmessage('no_privilege_copythread');
}
if(!submitcheck('modsubmit')) {
require_once libfile('function/forumlist');
$forumselect = forumselect();
include template('forum/topicadmin_action');
} else {
$modaction = 'CPY';
$reason = checkreasonpm();
$copyto = $_GET['copyto'];
$toforum = C::t('forum_forum')->fetch_info_by_fid($copyto);
if(!$toforum || $toforum['status'] != 1 || $toforum['type'] == 'group') {
showmessage('admin_copy_invalid');
} else {
$modnewthreads = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 1) && $toforum['modnewposts'] ? 1 : 0;
$modnewreplies = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 2) && $toforum['modnewposts'] ? 1 : 0;
if($modnewthreads || $modnewreplies) {
showmessage('admin_copy_hava_mod');
}
}
$toforum['threadsorts_arr'] = dunserialize($toforum['threadsorts']);
if($thread['sortid'] != 0 && $toforum['threadsorts_arr']['types'][$thread['sortid']]) {
foreach(C::t('forum_typeoptionvar')->fetch_all_by_search($thread['sortid'], null, $thread['tid']) as $result) {
$typeoptionvar[] = $result;
}
} else {
$thread['sortid'] = '';
}
$sourcetid = $thread['tid'];
unset($thread['tid']);
$thread['fid'] = $copyto;
$thread['dateline'] = $thread['lastpost'] = TIMESTAMP;
$thread['lastposter'] = $thread['author'];
$thread['views'] = $thread['replies'] = $thread['highlight'] = $thread['digest'] = 0;
$thread['rate'] = $thread['displayorder'] = $thread['attachment'] = 0;
$thread['typeid'] = $_GET['threadtypeid'];
$thread = daddslashes($thread);
$thread['posttableid'] = 0;
$threadid = C::t('forum_thread')->insert($thread, true);
C::t('forum_newthread')->insert(array(
'tid' => $threadid,
'fid' => $thread['fid'],
'dateline' => $thread['dateline'],
));
C::t('forum_sofa')->insert(array('tid' => $threadid,'fid' => $thread['fid']));
if($post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($_G['tid'])) {
$post['pid'] = '';
$post['tid'] = $threadid;
$post['fid'] = $copyto;
$post['dateline'] = $thread['dateline'];
$post['attachment'] = 0;
$post['invisible'] = $post['rate'] = $post['ratetimes'] = 0;
$post['message'] .= "\n".lang('forum/thread', 'source').": [url=forum.php?mod=viewthread&tid={$sourcetid}]{$thread['subject']}[/url]";
$post = daddslashes($post);
$pid = insertpost($post);
}
$class_tag = new tag();
$class_tag->copy_tag($_G['tid'], $threadid, 'tid');
if($typeoptionvar) {
foreach($typeoptionvar AS $key => $value) {
$value['tid'] = $threadid;
$value['fid'] = $toforum['fid'];
C::t('forum_typeoptionvar')->insert($value);
}
}
updatepostcredits('+', $post['authorid'], 'post', $copyto);
updateforumcount($copyto);
updateforumcount($_G['fid']);
$modpostsnum ++;
$resultarray = array(
'redirect' => "forum.php?mod=forumdisplay&fid={$_G['fid']}",
'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_copy', 'notictype' => 'post') : array()),
'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason, 'threadid' => $threadid),
'modtids' => $thread['tid'],
'modlog' => array($thread, $other)
);
}
?>

View File

@@ -0,0 +1,84 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_delcomment.php 31950 2012-10-25 09:05:44Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowdelpost'] || empty($_GET['topiclist'])) {
showmessage('no_privilege_delcomment');
}
if(!submitcheck('modsubmit')) {
$commentid = $_GET['topiclist'][0];
$pid = C::t('forum_postcomment')->fetch($commentid);
$pid = $pid['pid'];
if(!$pid) {
showmessage('postcomment_not_found');
}
$deleteid = '<input type="hidden" name="topiclist" value="'.$commentid.'" />';
include template('forum/topicadmin_action');
} else {
$reason = checkreasonpm();
$modaction = 'DCM';
$commentid = intval($_GET['topiclist']);
$postcomment = C::t('forum_postcomment')->fetch($commentid);
if(!$postcomment) {
showmessage('postcomment_not_found');
}
C::t('forum_postcomment')->delete($commentid);
$result = C::t('forum_postcomment')->count_by_pid($postcomment['pid']);
if(!$result) {
C::t('forum_post')->update_post($_G['thread']['posttableid'], $postcomment['pid'], array('comment' => 0));
}
if($thread['comments']) {
C::t('forum_thread')->update($_G['tid'], array('comments' => $thread['comments'] - 1));
}
if(!$postcomment['rpid']) {
updatepostcredits('-', $postcomment['authorid'], 'reply', $_G['fid']);
}
$totalcomment = array();
foreach(C::t('forum_postcomment')->fetch_all_by_pid_score($postcomment['pid'], 1) as $comment) {
if(strexists($comment['comment'], '<br />')) {
if(preg_match_all("/([^:]+?):\s<i>(\d+)<\/i>/", $comment['comment'], $a)) {
foreach($a[1] as $k => $itemk) {
$totalcomment[trim($itemk)][] = $a[2][$k];
}
}
}
}
$totalv = '';
foreach($totalcomment as $itemk => $itemv) {
$totalv .= strip_tags(trim($itemk)).': <i>'.(sprintf('%1.1f', array_sum($itemv) / count($itemv))).'</i> ';
}
if($totalv) {
C::t('forum_postcomment')->update_by_pid($postcomment['pid'], array('comment' => $totalv, 'dateline' => TIMESTAMP + 1), false, false, 0);
} else {
C::t('forum_postcomment')->delete_by_pid($postcomment['pid'], false, 0);
}
C::t('forum_postcache')->delete($postcomment['pid']);
$resultarray = array(
'redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page=$page",
'reasonpm' => ($sendreasonpm ? array('data' => array($postcomment), 'var' => 'post', 'item' => 'reason_delete_comment', 'notictype' => 'pcomment') : array()),
'reasonvar' => array('tid' => $thread['tid'], 'pid' => $postcomment['pid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason),
'modtids' => 0,
'modlog' => $thread
);
}
?>

View File

@@ -0,0 +1,140 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_delpost.php 36334 2017-01-03 01:32:35Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowdelpost']) {
showmessage('no_privilege_delpost');
}
$topiclist = $_GET['topiclist'];
$modpostsnum = count($topiclist);
$authorcount = $crimenum = 0;
$crimeauthor = '';
$pids = $posts = $authors = array();
if(!($deletepids = dimplode($topiclist))) {
showmessage('admin_delpost_invalid');
} elseif(!$_G['group']['allowdelpost'] || !$_G['tid']) {
showmessage('admin_nopermission');
} else {
$posttable = getposttablebytid($_G['tid']);
foreach(C::t('forum_post')->fetch_all_post('tid:'.$_G['tid'], $topiclist, false) as $post) {
if($post['tid'] != $_G['tid']) {
continue;
}
if($post['first'] == 1) {
dheader("location: {$_G['siteurl']}forum.php?mod=topicadmin&action=moderate&operation=delete&optgroup=3&fid={$_G['fid']}&moderate[]={$thread['tid']}&inajax=yes".($_GET['infloat'] ? "&infloat=yes&handlekey={$_GET['handlekey']}" : ''));
} else {
$authors[$post['authorid']] = 1;
$pids[] = $post['pid'];
$posts[] = $post;
}
}
}
if(!submitcheck('modsubmit')) {
$deleteid = '';
foreach($topiclist as $id) {
$deleteid .= '<input type="hidden" name="topiclist[]" value="'.$id.'" />';
}
$authorcount = count(array_keys($authors));
if($modpostsnum == 1 || $authorcount == 1) {
include_once libfile('function/member');
$crimenum = crime('getcount', $posts[0]['authorid'], 'crime_delpost');
$crimeauthor = $posts[0]['author'];
}
include template('forum/topicadmin_action');
} else {
$reason = checkreasonpm();
$uidarray = $puidarray = $auidarray = array();
$losslessdel = $_G['setting']['losslessdel'] > 0 ? TIMESTAMP - $_G['setting']['losslessdel'] * 86400 : 0;
if($pids) {
require_once libfile('function/delete');
if($_G['forum']['recyclebin']) {
deletepost($pids, 'pid', true, false, true);
manage_addnotify('verifyrecyclepost', $modpostsnum);
} else {
$logs = array();
$ratelog = C::t('forum_ratelog')->fetch_all_by_pid($pids);
$rposts = C::t('forum_post')->fetch_all_post('tid:'.$_G['tid'], $pids, false);
foreach(C::t('forum_ratelog')->fetch_all_by_pid($pids) as $rpid => $author) {
if($author['score'] > 0) {
$rpost = $rposts[$rpid];
updatemembercount($rpost['authorid'], array($author['extcredits'] => -$author['score']));
$author['score'] = $_G['setting']['extcredits'][$id]['title'].' '.-$author['score'].' '.$_G['setting']['extcredits'][$id]['unit'];
$logs[] = dhtmlspecialchars("{$_G['timestamp']}\t{$_G['member']['username']}\t{$_G['adminid']}\t{$rpost['author']}\t{$author['extcredits']}\t{$author['score']}\t{$thread['tid']}\t{$thread['subject']}\t$delpostsubmit");
}
}
if(!empty($logs)) {
writelog('ratelog', $logs);
unset($logs);
}
deletepost($pids, 'pid', true);
}
if($_G['group']['allowbanuser'] && ($_GET['banuser'] || $_GET['userdelpost']) && $_G['deleteauthorids']) {
$members = C::t('common_member')->fetch_all($_G['deleteauthorids']);
$banuins = array();
foreach($members as $member) {
if(($_G['cache']['usergroups'][$member['groupid']]['type'] == 'system' &&
in_array($member['groupid'], array(1, 2, 3, 6, 7, 8))) || $_G['cache']['usergroups'][$member['groupid']]['type'] == 'special') {
continue;
}
$banuins[$member['uid']] = $member['uid'];
}
if($banuins) {
if($_GET['banuser']) {
C::t('common_member')->update($banuins, array('groupid' => 4));
}
if($_GET['userdelpost']) {
deletememberpost($banuins);
}
}
}
if($_GET['crimerecord']) {
include_once libfile('function/member');
foreach($posts as $post) {
crime('recordaction', $post['authorid'], 'crime_delpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $post['tid'], 'pid' => $post['pid'])));
}
}
}
updatethreadcount($_G['tid'], 1);
updateforumcount($_G['fid']);
$_G['forum']['threadcaches'] && deletethreadcaches($thread['tid']);
$modaction = 'DLP';
$resultarray = array(
'redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page={$_GET['page']}",
'reasonpm' => ($sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_delete_post', 'notictype' => 'post') : array()),
'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason),
'modtids' => 0,
'modlog' => $thread
);
}
?>

View File

@@ -0,0 +1,37 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_getip.php 33709 2013-08-06 09:06:56Z andyzheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowviewip']) {
showmessage('no_privilege_viewip');
}
$pid = $_GET['pid'];
$member = array();
$post = C::t('forum_post')->fetch_post('tid:'.$_G['tid'], $pid, false);
if($post && $post['tid'] == $_G['tid']) {
$member = getuserbyuid($post['authorid']);
$member = array_merge($post, $member);
}
if(!$member) {
showmessage('thread_nonexistence', NULL);
} elseif(($member['adminid'] == 1 && $_G['adminid'] > 1) || ($member['adminid'] == 2 && $_G['adminid'] > 2)) {
showmessage('admin_getip_nopermission', NULL);
}
$member['iplocation'] = convertip($member['useip']);
$member['useip'] = ip::to_display($member['useip']);
include template('forum/topicadmin_getip');
?>

View File

@@ -0,0 +1,50 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_live.php 32028 2012-10-31 10:12:22Z zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowlivethread']) {
showmessage('no_privilege_livethread');
}
if(!submitcheck('modsubmit')) {
include template('forum/topicadmin_action');
} else {
$modaction = $_GET['live'] ? 'LIV' : 'LIC';
$reason = checkreasonpm();
$expiration = $_GET['expirationlive'] ? dintval($_GET['expirationlive']) : 0;
if($modaction == 'LIV') {
C::t('forum_forumfield')->update($_G['fid'], array('livetid' => $_G['tid']));
} elseif($modaction == 'LIC') {
if($_G['tid'] != $_G['forum']['livetid']) {
showmessage('topicadmin_live_noset_error');
}
C::t('forum_forumfield')->update($_G['fid'], array('livetid' => 0));
}
$resultarray = array(
'redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page=$page",
'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'notictype' => 'post', 'item' => $_GET['live'] ? 'reason_live_update' : 'reason_live_cancle') : array()),
'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason),
'modaction' => $modaction,
'modlog' => $thread
);
$modpostsnum = 1;
updatemodlog($_G['tid'], $modaction, $expiration, 0, '', $modaction == 'LIV' ? 1 : 0);
}
?>

View File

@@ -0,0 +1,123 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_merge.php 31741 2012-09-26 08:12:08Z zhangjie $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowmergethread']) {
showmessage('no_privilege_mergethread');
}
if(!submitcheck('modsubmit')) {
include template('forum/topicadmin_action');
} else {
$posttable = getposttablebytid($_G['tid']);
$othertid = intval($_GET['othertid']);
$otherposttable = getposttablebytid($othertid);
$modaction = 'MRG';
$reason = checkreasonpm();
$other = C::t('forum_thread')->fetch_by_tid_displayorder($othertid, 0);
if(!$other) {
showmessage('admin_merge_nonexistence');
} elseif($other['special']) {
showmessage('special_noaction');
}
if($othertid == $_G['tid'] || ($_G['adminid'] == 3 && $other['fid'] != $_G['forum']['fid'])) {
showmessage('admin_merge_invalid');
}
$other['views'] = intval($other['views']);
$other['replies']++;
if(!$other['maxposition']) {
$other['maxposition'] = C::t('forum_post')->fetch_maxposition_by_tid($other['posttableid'], $othertid);
}
if(!$thread['maxposition']) {
$thread['maxposition'] = C::t('forum_post')->fetch_maxposition_by_tid($thread['posttableid'], $_G['tid']);
}
$pos = 1;
if($posttable != $otherposttable) {
$pidlist = array();
C::t('forum_post')->increase_position_by_tid($thread['posttableid'], $_G['tid'], $other['maxposition'] + $thread['maxposition']);
C::t('forum_post')->increase_position_by_tid($other['posttableid'], $othertid, $other['maxposition'] + $thread['maxposition']);
foreach(C::t('forum_post')->fetch_all_by_tid('tid:'.$_G['tid'], $_G['tid'], false, 'ASC') as $row) {
$pidlist[$row['dateline']] = array('pid' => $row['pid'], 'tid' => $row['tid']);
}
foreach(C::t('forum_post')->fetch_all_by_tid('tid:'.$othertid, $othertid, false, 'ASC') as $row) {
$pidlist[$row['dateline']] = array('pid' => $row['pid'], 'tid' => $row['tid']);
}
ksort($pidlist);
foreach($pidlist as $row) {
C::t('forum_post')->update_post('tid:'.$row['tid'], $row['pid'], array('position' => $pos));
$pos ++;
}
unset($pidlist);
} else {
C::t('forum_post')->increase_position_by_tid($thread['posttableid'], array($_G['tid'], $othertid), $other['maxposition'] + $thread['maxposition']);
foreach(C::t('forum_post')->fetch_all_by_tid('tid:'.$_G['tid'], array($_G['tid'], $othertid), false, 'ASC') as $row) {
C::t('forum_post')->update_post('tid:'.$_G['tid'], $row['pid'], array('position' => $pos));
$pos ++;
}
}
if($posttable != $otherposttable) {
foreach(C::t('forum_post')->fetch_all_by_tid('tid:'.$othertid, $othertid) as $row) {
C::t('forum_post')->insert_post('tid:'.$_G['tid'], $row);
}
C::t('forum_post')->delete_by_tid('tid:'.$othertid, $othertid);
}
$query = C::t('forum_post')->fetch_all_by_tid('tid:'.$_G['tid'], array($_G['tid'], $othertid), false, 'ASC', 0, 1, null, 0);
foreach($query as $row) {
$firstpost = $row;
}
$postsmerged = C::t('forum_post')->update_by_tid('tid:'.$_G['tid'], $othertid, array('tid' => $_G['tid']));
updateattachtid('tid', array($othertid), $othertid, $_G['tid']);
C::t('forum_thread')->delete_by_tid($othertid);
C::t('forum_threadmod')->delete_by_tid($othertid);
C::t('forum_post')->update_by_tid('tid:'.$_G['tid'], $_G['tid'], array('first' => 0, 'fid' => $_G['forum']['fid']));
C::t('forum_post')->update_post('tid:'.$_G['tid'], $firstpost['pid'], array('first' => 1));
$fieldarr = array(
'views' => $other['views'],
'replies' => $other['replies'],
);
C::t('forum_thread')->increase($_G['tid'], $fieldarr);
$fieldarr = array(
'authorid' => $firstpost['authorid'],
'author' => $firstpost['author'],
'subject' => $firstpost['subject'],
'dateline' => $firstpost['dateline'],
'moderated' => 1,
'maxposition' => $other['maxposition'] + $thread['maxposition'],
);
C::t('forum_thread')->update($_G['tid'], $fieldarr);
updateforumcount($other['fid']);
updateforumcount($_G['fid']);
$_G['forum']['threadcaches'] && deletethreadcaches($thread['tid']);
$modpostsnum ++;
$resultarray = array(
'redirect' => "forum.php?mod=forumdisplay&fid={$_G['fid']}",
'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_merge', 'notictype' => 'post') : array()),
'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason),
'modtids' => $thread['tid'],
'modlog' => array($thread, $other)
);
}
?>

View File

@@ -0,0 +1,758 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_moderate.php 36334 2017-01-03 01:32:35Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!empty($_G['tid'])) {
$_GET['moderate'] = array($_G['tid']);
}
$allow_operation = array('delete', 'highlight', 'open', 'close', 'stick', 'digest', 'bump', 'down', 'recommend', 'type', 'move', 'recommend_group');
$operations = empty($_GET['operations']) ? array() : $_GET['operations'];
if($operations && $operations != array_intersect($operations, $allow_operation) || (!$_G['group']['allowdelpost'] && in_array('delete', $operations)) || (!$_G['group']['allowstickthread'] && in_array('stick', $operations))) {
showmessage('admin_moderate_invalid');
}
$threadlist = $loglist = $posttablearr = $authors = array();
$crimenum = $crimeauthor = '';
$recommend_group_count = 0;
$operation = getgpc('operation');
loadcache('threadtableids');
$threadtableids = !empty($_G['cache']['threadtableids']) ? $_G['cache']['threadtableids'] : array();
if(!in_array(0, $threadtableids)) {
$threadtableids = array_merge(array(0), $threadtableids);
}
if($_GET['moderate']) {
foreach($threadtableids as $tableid) {
foreach(C::t('forum_thread')->fetch_all_by_tid_fid_displayorder($_GET['moderate'], $_G['fid'], null, '', 0, $_G['tpp'], '', '', $tableid) as $thread) {
if($thread['closed'] > 1 && $operation && !in_array($operation, array('delete', 'highlight', 'stick', 'digest', 'bump', 'down')) || $thread['displayorder'] < 0 && $thread['displayorder'] != -4) {
if($operation == 'recommend_group') {
$recommend_group_count ++;
}
continue;
}
$thread['lastposterenc'] = rawurlencode($thread['lastposter']);
$thread['dblastpost'] = $thread['lastpost'];
$thread['lastpost'] = dgmdate($thread['lastpost'], 'u');
$posttablearr[$thread['posttableid'] ? $thread['posttableid'] : 0][] = $thread['tid'];
$authors[$thread['authorid']] = 1;
$threadlist[$thread['tid']] = $thread;
$_G['tid'] = empty($_G['tid']) ? $thread['tid'] : $_G['tid'];
}
if(!empty($threadlist)) {
break;
}
}
}
if(empty($threadlist)) {
if($recommend_group_count) {
showmessage('recommend_group_invalid');
}
showmessage('admin_moderate_invalid');
}
$authorcount = count(array_keys($authors));
$modpostsnum = count($threadlist);
$single = $modpostsnum == 1 ? TRUE : FALSE;
$frommodcp = getgpc('frommodcp');
switch($frommodcp) {
case '1':
$_G['referer'] = "forum.php?mod=modcp&action=thread&fid={$_G['fid']}&op=thread&do=list";
break;
case '2':
$_G['referer'] = "forum.php?mod=modcp&action=forum&op=recommend".(getgpc('show') ? "&show=getgpc('show')" : '')."&fid={$_G['fid']}";
break;
default:
if(in_array('delete', $operations) || in_array('move', $operations) && !strpos($_SERVER['HTTP_REFERER'], 'search.php?mod=forum')) {
$_G['referer'] = 'forum.php?mod=forumdisplay&fid='.$_G['fid'].(!empty($_GET['listextra']) ? '&'.rawurldecode($_GET['listextra']) : '');
} else {
$_G['referer'] = $_GET['redirect'];
}
break;
}
$optgroup = $_GET['optgroup'] = isset($_GET['optgroup']) ? intval($_GET['optgroup']) : 0;
$expirationstick = getgpc('expirationstick');
$defaultcheck = array();
foreach ($allow_operation as $v) {
$defaultcheck[$v] = '';
}
$defaultcheck[$operation] = 'checked="checked"';
if(!submitcheck('modsubmit')) {
$stickcheck = $closecheck = $digestcheck = array('', '', '', '', '');
$expirationdigest = $expirationhighlight = $expirationclose = '';
if($_GET['optgroup'] == 1 && $single) {
empty($threadlist[$_G['tid']]['displayorder']) ? $stickcheck[0] ='selected="selected"' : $stickcheck[$threadlist[$_G['tid']]['displayorder']] = 'selected="selected"';
empty($threadlist[$_G['tid']]['digest']) ? $digestcheck[0] = 'selected="selected"' : $digestcheck[$threadlist[$_G['tid']]['digest']] = 'selected="selected"';
$string = sprintf('%02d', $threadlist[$_G['tid']]['highlight']);
$stylestr = sprintf('%03b', $string[0]);
for($i = 1; $i <= 3; $i++) {
$stylecheck[$i] = $stylestr[$i - 1] ? 1 : 0;
}
$colorcheck = $string[1];
$highlight_bgcolor = $threadlist[$_G['tid']]['bgcolor'];
$_G['forum']['modrecommend'] = is_array($_G['forum']['modrecommend']) ? $_G['forum']['modrecommend'] : array();
$expirationstick = get_expiration($_G['tid'], 'EST');
$expirationdigest = get_expiration($_G['tid'], 'EDI');
$expirationhighlight = get_expiration($_G['tid'], 'EHL');
} elseif($_GET['optgroup'] == 2 || $_GET['optgroup'] == 5) {
require_once libfile('function/forumlist');
$forumselect = forumselect(FALSE, 0, $threadlist[$_G['tid']]['fid'], $_G['adminid']==1 ? TRUE : FALSE);
$typeselect = typeselect($single ? $threadlist[$_G['tid']]['typeid'] : 0);
} elseif($_GET['optgroup'] == 4 && $single) {
!empty($threadlist[$_G['tid']]['closed']) ? $closecheck[0] = 'checked="checked"' : $closecheck[1] = 'checked="checked"';
if($threadlist[$_G['tid']]['closed']) {
$expirationclose = get_expiration($_G['tid'], 'ECL');
}
} elseif($_GET['optgroup'] == 3 && ($modpostsnum == 1 || $authorcount == 1)) {
include_once libfile('function/member');
$crimenum = crime('getcount', $threadlist[$_G['tid']]['authorid'], 'crime_delpost');
$crimeauthor = $threadlist[$_G['tid']]['author'];
}
$imgattach = array();
if(count($threadlist) == 1 && $operation == 'recommend') {
$imgattach = C::t('forum_attachment_n')->fetch_all_by_id('tid:'.$_G['tid'], 'tid', $_G['tid'], '', array(1, -1));
$oldthread = C::t('forum_forumrecommend')->fetch($_G['tid']);
if($oldthread) {
$threadlist[$_G['tid']]['subject'] = $oldthread['subject'];
$selectposition[$oldthread['position']] = ' selected="selected"';
$selectattach = $oldthread['aid'];
} else {
$keys = array_keys($imgattach);
$selectattach = $imgattach[$keys[0]]['aid'];
$selectposition[0] = ' selected="selected"';
}
$expirationrecommend = get_expiration($_G['tid'], 'REC');
}
include template('forum/topicadmin');
} else {
$tidsarr = array_keys($threadlist);
$moderatetids = dimplode($tidsarr);
$reason = checkreasonpm();
$stampaction = 'SPA';
if(empty($operations)) {
showmessage('admin_nonexistence');
} else {
$images = array();
foreach($operations as $operation) {
$stampstatus = 0;
$updatemodlog = TRUE;
if($operation == 'stick') {
$sticklevel = intval($_GET['sticklevel']);
if($sticklevel < 0 || $sticklevel > 3 || $sticklevel > $_G['group']['allowstickthread']) {
showmessage('no_privilege_stickthread');
}
$expiration = checkexpiration($_GET['expirationstick'], $operation);
$expirationstick = $sticklevel ? $_GET['expirationstick'] : 0;
$forumstickthreads = $_G['setting']['forumstickthreads'];
$forumstickthreads = isset($forumstickthreads) ? dunserialize($forumstickthreads) : array();
C::t('forum_thread')->update($tidsarr, array('displayorder'=>$sticklevel, 'moderated'=>1), true);
$delkeys = array_keys($threadlist);
foreach($delkeys as $k) {
unset($forumstickthreads[$k]);
}
C::t('common_setting')->update_setting('forumstickthreads', $forumstickthreads);
$stickmodify = 0;
foreach($threadlist as $thread) {
$stickmodify = (in_array($thread['displayorder'], array(2, 3)) || in_array($sticklevel, array(2, 3))) && $sticklevel != $thread['displayorder'] ? 1 : $stickmodify;
C::t('common_member_secwhite')->add($thread['authorid']);
}
if($_G['setting']['globalstick'] && $stickmodify) {
require_once libfile('function/cache');
updatecache('globalstick');
}
$modaction = $sticklevel ? ($expiration ? 'EST' : 'STK') : 'UST';
C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('STK', 'UST', 'EST', 'UES'), array('status' => 0));
C::t('forum_threadhidelog')->delete_by_tid($tidsarr);
if(!$sticklevel) {
$stampaction = 'SPD';
}
$stampstatus = 1;
} elseif($operation == 'highlight') {
if(!$_G['group']['allowhighlightthread']) {
showmessage('no_privilege_highlightthread');
}
$highlight_style = $_GET['highlight_style'];
$highlight_color = $_GET['highlight_color'];
$highlight_bgcolor = $_GET['highlight_bgcolor'];
$expiration = checkexpiration($_GET['expirationhighlight'], $operation);
$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('parameters_error ');
}
$bgcolor = dhtmlspecialchars(preg_replace("/[^\[A-Za-z0-9#]/", '', $_GET['highlight_bgcolor']));
C::t('forum_thread')->update($tidsarr, array('highlight'=>$highlight_style.$highlight_color, 'moderated'=>1, 'bgcolor' => $bgcolor), true);
C::t('forum_forumrecommend')->update($tidsarr, array('highlight' => $highlight_style.$highlight_color));
C::t('forum_threadhidelog')->delete_by_tid($tidsarr);
$modaction = ($highlight_style + $highlight_color) ? ($expiration ? 'EHL' : 'HLT') : 'UHL';
$expiration = $modaction == 'UHL' ? 0 : $expiration;
foreach($threadlist as $thread) {
C::t('common_member_secwhite')->add($thread['authorid']);
}
C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('HLT', 'UHL', 'EHL', 'UEH'), array('status' => 0));
} elseif($operation == 'digest') {
$digestlevel = intval($_GET['digestlevel']);
if($digestlevel < 0 || $digestlevel > 3 || $digestlevel > $_G['group']['allowdigestthread']) {
showmessage('no_privilege_digestthread');
}
$expiration = checkexpiration($_GET['expirationdigest'], $operation);
$expirationdigest = $digestlevel ? $expirationdigest : 0;
C::t('forum_thread')->update($tidsarr, array('digest'=>$digestlevel, 'moderated'=>1), true);
C::t('forum_threadhidelog')->delete_by_tid($tidsarr);
foreach($threadlist as $thread) {
if($thread['digest'] != $digestlevel) {
if($digestlevel == $thread['digest']) continue;
$extsql = array();
if($digestlevel > 0 && $thread['digest'] == 0) {
$extsql = array('digestposts' => 1);
}
if($digestlevel == 0 && $thread['digest'] > 0) {
$extsql = array('digestposts' => -1);
}
if($digestlevel == 0) {
$stampaction = 'SPD';
}
updatecreditbyaction('digest', $thread['authorid'], $extsql, '', $digestlevel - $thread['digest']);
C::t('common_member_secwhite')->add($thread['authorid']);
}
}
$modaction = $digestlevel ? ($expiration ? 'EDI' : 'DIG') : 'UDG';
C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('DIG', 'UDI', 'EDI', 'UED'), array('status' => 0));
$stampstatus = 2;
} elseif($operation == 'recommend') {
if(!$_G['group']['allowrecommendthread']) {
showmessage('no_privilege_recommendthread');
}
$isrecommend = $_GET['isrecommend'];
$modrecommend = !empty($_G['forum']['modrecommend']) ? $_G['forum']['modrecommend'] : array();
$imgw = $modrecommend['imagewidth'] ? intval($modrecommend['imagewidth']) : 200;
$imgh = $modrecommend['imageheight'] ? intval($modrecommend['imageheight']) : 150;
$expiration = checkexpiration($_GET['expirationrecommend'], $operation);
C::t('forum_thread')->update($tidsarr, array('moderated'=>1), true);
$modaction = $isrecommend ? 'REC' : 'URE';
$thread = daddslashes($thread, 1);
$selectattach = $_GET['selectattach'];
$position = $_GET['position'];
C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('REC'), array('status' => 0));
if($isrecommend) {
C::t('forum_threadhidelog')->delete_by_tid($tidsarr);
$oldrecommendlist = $addthread = array();
foreach(C::t('forum_forumrecommend')->fetch_all($tidsarr) as $row) {
$oldrecommendlist[$row['tid']] = $row;
}
foreach($threadlist as $thread) {
if(count($threadlist) > 1) {
if($oldrecommendlist[$thread['tid']]) {
$oldthread = $oldrecommendlist[$thread['tid']];
$reducetitle = $oldthread['subject'];
$selectattach = $oldthread['aid'];
$typeid = $oldthread['typeid'];
$position = $oldthread['position'];
} else {
$reducetitle = $thread['subject'];
$typeid = 0;
$position = 0;
}
} else {
if(empty($_GET['reducetitle'])) {
$reducetitle = $thread['subject'];
} else {
$reducetitle = $_GET['reducetitle'];
}
$typeid = $selectattach ? 1 : 0;
empty($_GET['position']) && $position = 0;
}
if($selectattach) {
$key = md5($selectattach.'|'.$imgw.'|'.$imgh);
$filename = $selectattach."\t".$imgw."\t".$imgh."\t".$key;
} else {
$selectattach = 0;
$filename = '';
}
$addthread[] = array(
'fid' => $thread['fid'],
'tid' => $thread['tid'],
'typeid' => $typeid,
'displayorder' => 0,
'subject' => $reducetitle,
'author' => $thread['author'],
'authorid' => $thread['authorid'],
'moderatorid' => $_G['uid'],
'expiration' => $expiration,
'position' => $position,
'aid' => $selectattach,
'filename' => $filename,
'highlight' => $thread['highlight']
);
$reducetitle = '';
}
if($addthread) {
foreach($addthread as $row) {
C::t('forum_forumrecommend')->insert($row, false, true);
}
}
} else {
C::t('forum_forumrecommend')->delete($tidsarr);
$stampaction = 'SPD';
}
$stampstatus = 3;
} elseif($operation == 'bump') {
if(!$_G['group']['allowbumpthread']) {
showmessage('no_privilege_bumpthread');
}
$modaction = 'BMP';
$thread = $threadlist;
$thread = array_pop($thread);
$expiration = checkexpiration($_GET['expirationbump'], $operation);
if(!$expiration) {
$expiration = $_G['timestamp'];
}
C::t('forum_thread')->update($tidsarr, array('lastpost'=>$expiration, 'moderated'=>1), true);
C::t('forum_forum')->update($_G['fid'], array('lastpost' => "{$thread['tid']}\t{$thread['subject']}\t$expiration\t{$thread['lastposter']}"));
$_G['forum']['threadcaches'] && deletethreadcaches($moderatetids);
} elseif($operation == 'down') {
if(!$_G['group']['allowbumpthread']) {
showmessage('no_privilege_downthread');
}
$modaction = 'DWN';
$downtime = TIMESTAMP - 86400 * 730;
C::t('forum_thread')->update($tidsarr, array('lastpost'=>$downtime, 'moderated'=>1), true);
$_G['forum']['threadcaches'] && deletethreadcaches($moderatetids);
} elseif($operation == 'delete') {
if(!$_G['group']['allowdelpost']) {
showmessage('no_privilege_delpost');
}
loadcache('threadtableids');
$stickmodify = 0;
$deleteredirect = $remarkclosed = array();
foreach($threadlist as $thread) {
if($thread['digest']) {
updatecreditbyaction('digest', $thread['authorid'], array('digestposts' => -1), '', -$thread['digest']);
}
if(in_array($thread['displayorder'], array(2, 3))) {
$stickmodify = 1;
}
if($_G['forum']['status'] == 3 && $thread['closed'] > 1) {
$deleteredirect[] = $thread['closed'];
}
if($thread['isgroup'] == 1 && $thread['closed'] > 1) {
$remarkclosed[] = $thread['closed'];
}
}
$modaction = 'DEL';
require_once libfile('function/delete');
$tids = array_keys($threadlist);
if($_G['forum']['recyclebin']) {
deletethread($tids, true, true, true);
manage_addnotify('verifyrecycle', $modpostsnum);
} else {
deletethread($tids, true, true);
$updatemodlog = FALSE;
}
if($_G['group']['allowbanuser'] && ($_GET['banuser'] || $_GET['userdelpost']) && $_G['deleteauthorids']) {
$members = C::t('common_member')->fetch_all($_G['deleteauthorids']);
$banuins = array();
foreach($members as $member) {
if(($_G['cache']['usergroups'][$member['groupid']]['type'] == 'system' &&
in_array($member['groupid'], array(1, 2, 3, 6, 7, 8))) || $_G['cache']['usergroups'][$member['groupid']]['type'] == 'special') {
continue;
}
$banuins[$member['uid']] = $member['uid'];
}
if($banuins) {
if($_GET['banuser']) {
C::t('common_member')->update($banuins, array('groupid' => 4));
}
if($_GET['userdelpost']) {
deletememberpost($banuins);
}
}
}
$forumstickthreads = $_G['setting']['forumstickthreads'];
$forumstickthreads = !empty($forumstickthreads) ? dunserialize($forumstickthreads) : array();
$delkeys = array_keys($threadlist);
foreach($delkeys as $k) {
unset($forumstickthreads[$k]);
}
C::t('common_setting')->update_setting('forumstickthreads', $forumstickthreads);
C::t('forum_forum_threadtable')->delete_none_threads();
if(!empty($deleteredirect)) {
deletethread($deleteredirect);
}
if(!empty($remarkclosed)) {
C::t('forum_thread')->update($remarkclosed, array('closed'=>0));
}
if($_G['setting']['globalstick'] && $stickmodify) {
require_once libfile('function/cache');
updatecache('globalstick');
}
updateforumcount($_G['fid']);
if($_GET['crimerecord']) {
include_once libfile('function/member');
foreach($threadlist as $thread) {
crime('recordaction', $thread['authorid'], 'crime_delpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $thread['tid'], 'pid' => 0)));
}
}
} elseif($operation == 'close') {
if(!$_G['group']['allowclosethread']) {
showmessage('no_privilege_closethread');
}
$expiration = checkexpiration($_GET['expirationclose'], $operation);
$modaction = $expiration ? 'ECL' : 'CLS';
C::t('forum_thread')->update($tidsarr, array('closed'=>1, 'moderated'=>1), true);
C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('CLS','OPN','ECL','UCL','EOP','UEO'), array('status' => 0));
} elseif($operation == 'open') {
if(!$_G['group']['allowclosethread']) {
showmessage('no_privilege_openthread');
}
$expiration = checkexpiration($_GET['expirationclose'], $operation);
$modaction = $expiration ? 'EOP' : 'OPN';
C::t('forum_thread')->update($tidsarr, array('closed'=>0, 'moderated'=>1), true);
C::t('forum_threadmod')->update_by_tid_action($tidsarr, array('CLS','OPN','ECL','UCL','EOP','UEO'), array('status' => 0));
} elseif($operation == 'move') {
if(!$_G['group']['allowmovethread']) {
showmessage('no_privilege_movethread');
}
$moveto = $_GET['moveto'];
$toforum = C::t('forum_forum')->fetch_info_by_fid($moveto);
if(!$toforum || ($_G['adminid'] != 1 && $toforum['status'] != 1) || $toforum['type'] == 'group') {
showmessage('admin_move_invalid');
} elseif($_G['fid'] == $toforum['fid']) {
continue;
} else {
$moveto = $toforum['fid'];
$modnewthreads = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 1) && $toforum['modnewposts'] ? 1 : 0;
$modnewreplies = (!$_G['group']['allowdirectpost'] || $_G['group']['allowdirectpost'] == 2) && $toforum['modnewposts'] ? 1 : 0;
if($modnewthreads || $modnewreplies) {
showmessage('admin_move_have_mod');
}
}
if($_G['adminid'] == 3) {
$priv = C::t('forum_forumfield')->check_moderator_for_uid($moveto, $_G['uid'], $_G['member']['accessmasks']);
if((($priv['postperm'] && !in_array($_G['groupid'], explode("\t", $priv['postperm']))) || ($_G['member']['accessmasks'] && ($priv['allowview'] || $priv['allowreply'] || $priv['allowgetattach'] || $priv['allowpostattach']) && !$priv['allowpost'])) && !$priv['istargetmod']) {
showmessage('admin_move_nopermission');
}
}
$moderate = array();
$stickmodify = 0;
$toforumallowspecial = array(
1 => $toforum['allowpostspecial'] & 1,
2 => $toforum['allowpostspecial'] & 2,
3 => isset($_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]) && ($toforum['allowpostspecial'] & 4),
4 => $toforum['allowpostspecial'] & 8,
5 => $toforum['allowpostspecial'] & 16,
127 => $_G['setting']['threadplugins'] ? dunserialize($toforum['threadplugin']) : array(),
);
foreach($threadlist as $tid => $thread) {
$allowmove = 0;
if(!$thread['special']) {
$allowmove = 1;
} else {
if($thread['special'] != 127) {
$allowmove = $toforum['allowpostspecial'] ? $toforumallowspecial[$thread['special']] : 0;
} else {
if($toforumallowspecial[127]) {
$posttable = getposttablebytid($thread['tid']);
$message = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']);
$message = $message['message'];
$sppos = strrpos($message, chr(0).chr(0).chr(0));
$specialextra = substr($message, $sppos + 3);
$allowmove = in_array($specialextra, $toforumallowspecial[127]);
} else {
$allowmove = 0;
}
}
}
if($allowmove) {
$moderate[] = $tid;
if(in_array($thread['displayorder'], array(2, 3))) {
$stickmodify = 1;
}
if($_GET['type'] == 'redirect') {
$insertdata = array(
'fid' => $thread['fid'],
'readperm' => $thread['readperm'],
'author' => $thread['author'],
'authorid' => $thread['authorid'],
'subject' => $thread['subject'],
'dateline' => $thread['dateline'],
'lastpost' => $thread['dblastpost'],
'lastposter' => $thread['lastposter'],
'views' => 0,
'replies' => 0,
'displayorder' => 0,
'digest' => 0,
'closed' => $thread['tid'],
'special' => 0,
'attachment' => 0,
'typeid' => $_GET['threadtypeid']
);
$newtid = C::t('forum_thread')->insert($insertdata, true);
if($newtid) {
C::t('forum_threadclosed')->insert(array('tid' => $thread['tid'], 'redirect' => $newtid), true, true);
}
}
}
}
if(!$moderatetids = implode(',', $moderate)) {
showmessage('admin_moderate_invalid');
}
$fieldarr = array(
'fid' => $moveto,
'isgroup' => 0,
'typeid' => $_GET['threadtypeid'],
'moderated' => 1
);
if($_G['adminid'] == 3) {
$fieldarr['displayorder'] = 0;
}
C::t('forum_thread')->update($tidsarr, $fieldarr, true);
C::t('forum_forumrecommend')->update($tidsarr, array('fid' => $moveto));
loadcache('posttableids');
$posttableids = $_G['cache']['posttableids'] ? $_G['cache']['posttableids'] : array('0');
foreach($posttableids as $id) {
C::t('forum_post')->update_by_tid($id, $tidsarr, array('fid' => $moveto));
}
$typeoptionvars = C::t('forum_typeoptionvar')->fetch_all_by_tid_optionid($tidsarr);
foreach($typeoptionvars as $typeoptionvar) {
C::t('forum_typeoptionvar')->update_by_tid($typeoptionvar['tid'], array('fid' => $moveto));
C::t('forum_optionvalue')->update_optionvalue($typeoptionvar['sortid'], $typeoptionvar['tid'], $_G['fid'], "fid='$moveto'");
}
if($_G['setting']['globalstick'] && $stickmodify) {
require_once libfile('function/cache');
updatecache('globalstick');
}
$modaction = 'MOV';
$_G['toforum'] = $toforum;
updateforumcount($moveto);
updateforumcount($_G['fid']);
} elseif($operation == 'type') {
if(!$_G['group']['allowedittypethread']) {
showmessage('no_privilege_edittypethread');
}
if(!isset($_G['forum']['threadtypes']['types'][$_GET['typeid']]) && ($_GET['typeid'] != 0 || $_G['forum']['threadtypes']['required'])) {
showmessage('admin_type_invalid');
}
C::t('forum_thread')->update($tidsarr, array('typeid'=>$_GET['typeid'], 'moderated'=>1), true);
$modaction = 'TYP';
} elseif($operation == 'recommend_group') {
if($_G['forum']['status'] != 3 || !in_array($_G['adminid'], array(1, 2))) {
showmessage('undefined_action');
}
$moveto = $_GET['moveto'];
$toforum = C::t('forum_forum')->fetch_info_by_fid($moveto);
if(!$toforum || $toforum['status'] != 1 || $toforum['type'] == 'group') {
showmessage('admin_move_invalid');
} elseif($_G['fid'] == $toforum['fid']) {
continue;
}
$moderate = array();
$toforumallowspecial = array(
1 => $toforum['allowpostspecial'] & 1,
2 => $toforum['allowpostspecial'] & 2,
3 => isset($_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]) && ($toforum['allowpostspecial'] & 4),
4 => $toforum['allowpostspecial'] & 8,
5 => $toforum['allowpostspecial'] & 16,
127 => $_G['setting']['threadplugins'] ? dunserialize($toforum['threadplugin']) : array(),
);
foreach($threadlist as $tid => $thread) {
$allowmove = 0;
if($thread['closed']) {
continue;
}
if(!$thread['special']) {
$allowmove = 1;
} else {
if($thread['special'] != 127) {
$allowmove = $toforum['allowpostspecial'] ? $toforumallowspecial[$thread['special']] : 0;
} else {
if($toforumallowspecial[127]) {
$posttable = getposttablebytid($thread['tid']);
$message = C::t('forum_post')->fetch_threadpost_by_tid_invisible($thread['tid']);
$message = $message['message'];
$sppos = strrpos($message, chr(0).chr(0).chr(0));
$specialextra = substr($message, $sppos + 3);
$allowmove = in_array($specialextra, $toforumallowspecial[127]);
} else {
$allowmove = 0;
}
}
}
if($allowmove) {
$moderate[] = $tid;
$newthread = array(
'fid' => $moveto,
'readperm' => $thread['readperm'],
'author' => $thread['author'],
'authorid' => $thread['authorid'],
'subject' => $thread['subject'],
'dateline' => $thread['dateline'],
'lastpost' => TIMESTAMP,
'lastposter' => $thread['lastposter'],
'views' => $thread['views'],
'replies' => $thread['replies'],
'displayorder' => 0,
'digest' => $thread['digest'],
'closed' => $thread['tid'],
'special' => $thread['special'],
'attachment' => $thread['attachment'],
'isgroup' => $thread['isgroup']
);
$newtid = C::t('forum_thread')->insert($newthread, true);
C::t('forum_thread')->update($thread['tid'], array('closed'=>$newtid, 'moderated'=>1), true);
}
}
if(!$moderatetids = implode(',', $moderate)) {
showmessage('admin_succeed', $_G['referer']);
}
$modaction = 'REG';
}
if($updatemodlog) {
updatemodlog($moderatetids, $modaction, $expiration, 0, $reason);
}
updatemodworks($modaction, $modpostsnum);
foreach($threadlist as $thread) {
modlog($thread, $modaction);
}
if($sendreasonpm) {
$modactioncode = lang('forum/modaction');
$modtype = $modaction;
$modaction = $modactioncode[$modaction];
foreach($threadlist as $thread) {
if($operation == 'move') {
sendreasonpm($thread, 'reason_move', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason, 'tofid' => $toforum['fid'], 'toname' => $toforum['name'], 'from_id' => 0, 'from_idtype' => 'movethread'), 'post');
} else {
sendreasonpm($thread, 'reason_moderate', array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason, 'from_id' => 0, 'from_idtype' => 'moderate_'.$modtype), 'post');
}
}
}
if($stampstatus) {
set_stamp($stampstatus, $stampaction, $threadlist, $expiration);
}
$fidarr = array();
foreach ($threadlist as $thread) {
$fidarr[] = $thread['fid'];
}
C::t('forum_thread')->clear_cache($fidarr, 'forumdisplay_');
}
showmessage('admin_succeed', $_G['referer']);
}
}
function checkexpiration($expiration, $operation) {
global $_G;
if(!empty($expiration) && in_array($operation, array('recommend', 'stick', 'digest', 'highlight', 'close', 'open', 'bump'))) {
$expiration = strtotime($expiration) - $_G['setting']['timeoffset'] * 3600 + date('Z');
if(dgmdate($expiration, 'Ymd') <= dgmdate(TIMESTAMP, 'Ymd') || ($expiration > TIMESTAMP + 86400 * 180)) {
showmessage('admin_expiration_invalid', '', array('min'=>dgmdate(TIMESTAMP, 'Y-m-d'), 'max'=>dgmdate(TIMESTAMP + 86400 * 180, 'Y-m-d')));
}
} else {
$expiration = 0;
}
return $expiration;
}
function set_stamp($typeid, $stampaction, &$threadlist, $expiration) {
global $_G;
$moderatetids = array_keys($threadlist);
if(empty($threadlist)) {
return false;
}
if(array_key_exists($typeid, $_G['cache']['stamptypeid'])) {
if($stampaction == 'SPD') {
C::t('forum_thread')->update($moderatetids, array('stamp'=>-1), true);
} else {
C::t('forum_thread')->update($moderatetids, array('stamp'=>$_G['cache']['stamptypeid'][$typeid]), true);
}
!empty($moderatetids) && updatemodlog($moderatetids, $stampaction, $expiration, 0, '', $_G['cache']['stamptypeid'][$typeid]);
}
}
function get_expiration($tid, $action) {
$tid = intval($tid);
if(empty($tid) || empty($action)) {
return '';
}
$row = C::t('forum_threadmod')->fetch_by_tid_action_status($tid, $action);
return $row['expiration'] ? date('Y-m-d H:i', $row['expiration']) : '';
}
?>

View File

@@ -0,0 +1,70 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_refund.php 30872 2012-06-27 10:11:44Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowrefund'] || $thread['price'] <= 0) {
showmessage('undefined_action', NULL);
}
if(!isset($_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]])) {
showmessage('credits_transaction_disabled');
}
if($thread['special'] != 0) {
showmessage('special_refundment_invalid');
}
if(!submitcheck('modsubmit')) {
$payment = C::t('common_credit_log')->count_stc_by_relatedid($_G['tid'], $_G['setting']['creditstransextra'][1]);
$payment['payers'] = intval($payment['payers']);
$payment['income'] = intval($payment['income']);
include template('forum/topicadmin_action');
} else {
$modaction = 'RFD';
$modpostsnum ++;
$reason = checkreasonpm();
$totalamount = 0;
$amountarray = array();
$logarray = array();
foreach(C::t('common_credit_log')->fetch_all_by_uid_operation_relatedid(0, 'BTC', $_G['tid']) as $log) {
$amount = abs($log['extcredits'.$_G['setting']['creditstransextra'][1]]);
$totalamount += $amount;
$amountarray[$amount][] = $log['uid'];
}
updatemembercount($thread['authorid'], array($_G['setting']['creditstransextra'][1] => -$totalamount));
C::t('forum_thread')->update($_G['tid'], array('price'=>-1, 'moderated'=>1));
foreach($amountarray as $amount => $uidarray) {
updatemembercount($uidarray, array($_G['setting']['creditstransextra'][1] => $amount));
}
C::t('common_credit_log')->delete_by_operation_relatedid(array('BTC', 'STC'), $_G['tid']);
$resultarray = array(
'redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}",
'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_moderate', 'notictype' => 'post') : array()),
'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason),
'modtids' => $thread['tid'],
'modlog' => $thread
);
}
?>

View File

@@ -0,0 +1,46 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_removereward.php 31998 2012-10-30 07:17:49Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowremovereward']) {
showmessage('no_privilege_removereward');
}
if(!submitcheck('modsubmit')) {
include template('forum/topicadmin_action');
} else {
if(!is_array($thread) || $thread['special'] != '3') {
showmessage('reward_end');
}
$modaction = 'RMR';
$reason = checkreasonpm();
$log = C::t('common_credit_log')->fetch_by_operation_relatedid('RAC', $thread['tid']);
$answererid = $log['uid'];
if($thread['price'] < 0) {
$thread['price'] = abs($thread['price']);
updatemembercount($answererid, array($_G['setting']['creditstransextra'][2] => -$thread['price']));
}
updatemembercount($thread['authorid'], array($_G['setting']['creditstransextra'][2] => $thread['price']));
C::t('forum_thread')->update($thread['tid'], array('special'=>0, 'price'=>0), true);
C::t('common_credit_log')->delete_by_operation_relatedid(array('RTC', 'RAC'), $thread['tid']);
$resultarray = array(
'redirect' => "forum.php?mod=viewthread&tid={$thread['tid']}",
'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'item' => 'reason_remove_reward', 'notictype' => 'post') : array()),
'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason, 'threadid' => $thread['tid']),
'modtids' => $thread['tid']
);
}
?>

View File

@@ -0,0 +1,37 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_repair.php 24573 2011-09-26 10:31:21Z zhengqingpeng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowrepairthread']) {
showmessage('no_privilege_repairthread');
}
$posttable = getposttablebytid($_G['tid']);
$replies = C::t('forum_post')->count_visiblepost_by_tid($_G['tid']) - 1;
$attachcount = C::t('forum_attachment_n')->count_by_id('tid:'.$_G['tid'], 'tid', $_G['tid']);
$attachment = $attachcount ? (C::t('forum_attachment_n')->count_image_by_id('tid:'.$_G['tid'], 'tid', $_G['tid']) ? 2 : 1) : 0;
$firstpost = C::t('forum_post')->fetch_visiblepost_by_tid('tid:'.$_G['tid'], $_G['tid'], 0);
$firstpost['subject'] = addslashes(cutstr($firstpost['subject'], 79));
$firstpost['rate'] = intval(abs($firstpost['rate']) ? ($firstpost['rate'] / abs($firstpost['rate'])) : 0);
$lastpost = C::t('forum_post')->fetch_visiblepost_by_tid('tid:'.$_G['tid'], $_G['tid'], 0, 1);
C::t('forum_thread')->update($_G['tid'], array('subject'=>$firstpost['subject'], 'replies'=>$replies, 'lastpost'=>$lastpost['dateline'], 'lastposter'=>$lastpost['author'], 'rate'=>$firstpost['rate'], 'attachment'=>$attachment), true);
C::t('forum_post')->update_by_tid('tid:'.$_G['tid'], $_G['tid'], array('first' => 0), true);
C::t('forum_post')->update_post('tid:'.$_G['tid'], $firstpost['pid'], array('first' => 1, 'subject' => $firstpost['subject']), true);
showmessage('admin_repair_succeed', '', array(), array('alert' => 'right'));
?>

View File

@@ -0,0 +1,47 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_restore.php 27088 2012-01-05 02:36:48Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if($_G['adminid'] != '1') {
showmessage('no_privilege_restore');
}
$archiveid = intval($_GET['archiveid']);
if(!submitcheck('modsubmit')) {
include template('forum/topicadmin_action');
} else {
if(!in_array($archiveid, $threadtableids)) {
$archiveid = 0;
}
C::t('forum_thread')->insert_thread_copy_by_tid($_G['tid'], $archiveid, 0);
C::t('forum_thread')->delete_by_tid($_G['tid'], false, $archiveid);
$threadcount = C::t('forum_thread')->count_by_fid($_G['fid'], $archiveid);
if($threadcount) {
C::t('forum_forum_threadtable')->update_threadtable($_G['fid'], $archiveid, array('threads' => $threadcount));
} else {
C::t('forum_forum_threadtable')->delete_threadtable($_G['fid'], $archiveid);
}
if(!C::t('forum_forum_threadtable')->count_by_fid($_G['fid'])) {
C::t('forum_forum')->update($_G['fid'], array('archive' => 0));
}
$modaction = 'RST';
$reason = checkreasonpm();
$resultarray = array(
'redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page=$page",
'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread') : array()),
'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason),
'modaction' => $modaction,
'modlog' => $thread
);
}
?>

View File

@@ -0,0 +1,116 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_split.php 30872 2012-06-27 10:11:44Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowsplitthread']) {
showmessage('no_privilege_splitthread');
}
$thread = C::t('forum_thread')->fetch_thread($_G['tid']);
$posttableid = $thread['posttableid'];
if(!submitcheck('modsubmit')) {
require_once libfile('function/discuzcode');
$replies = $thread['replies'];
if($replies <= 0) {
showmessage('admin_split_invalid');
}
$postlist = array();
foreach(C::t('forum_post')->fetch_all_by_tid('tid:'.$_G['tableid'], $_G['tid'], 'ASC') as $post) {
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], sprintf('%00b', $post['htmlon']), $_G['forum']['allowsmilies'], $_G['forum']['allowbbcode'], $_G['forum']['allowimgcode'], $_G['forum']['allowhtml']);
$postlist[] = $post;
}
include template('forum/topicadmin_action');
} else {
if(!trim($_GET['subject'])) {
showmessage('admin_split_subject_invalid');
} elseif(!($nos = explode(',', $_GET['split']))) {
showmessage('admin_split_new_invalid');
}
sort($nos);
foreach(C::t('forum_post')->fetch_all_by_tid_position($thread['posttableid'], $_G['tid'], $nos) as $post) {
$pids[] = $post['pid'];
}
$pids = is_array($pids) ? $pids : array($pids);
if(!($pids = implode(',',$pids))) {
showmessage('admin_split_new_invalid');
}
$modaction = 'SPL';
$reason = checkreasonpm();
$subject = dhtmlspecialchars($_GET['subject']);
$newtid = C::t('forum_thread')->insert(array('fid'=>$_G['fid'], 'posttableid'=>$posttableid, 'subject'=>$subject), true);
C::t('forum_post')->update_post('tid:'.$_G['tid'], explode(',', $pids), array('tid' => $newtid));
updateattachtid('pid', (array)explode(',', $pids), $_G['tid'], $newtid);
$splitauthors = array();
foreach(C::t('forum_post')->fetch_all_visiblepost_by_tid_groupby_authorid('tid:'.$_G['tid'], $newtid) as $splitauthor) {
$splitauthor['subject'] = $subject;
$splitauthors[] = $splitauthor;
}
C::t('forum_post')->update_post('tid:'.$_G['tid'], $splitauthors[0]['pid'], array('first' => 1, 'subject' => $subject), true);
$query = C::t('forum_post')->fetch_all_by_tid('tid:'.$_G['tid'], $_G['tid'], false, 'ASC', 0, 1);
foreach($query as $row) {
$fpost = $row;
}
C::t('forum_thread')->update($_G['tid'], array('author'=>$fpost['author'], 'authorid'=>$fpost['authorid'],'dateline'=>$fpost['dateline'], 'moderated'=>1));
C::t('forum_post')->update_post('tid:'.$_G['post'], $fpost['pid'], array('first' => 1, 'subject' => $thread['subject']));
$query = C::t('forum_post')->fetch_all_by_tid('tid:'.$_G['tid'], $newtid, false, 'ASC', 0, 1);
foreach($query as $row) {
$fpost = $row;
}
$maxposition = 1;
foreach(C::t('forum_post')->fetch_all_by_tid('tid:'.$_G['tid'], $_G['tid'], false, 'ASC') as $row) {
if($row['position'] != $maxposition) {
C::t('forum_post')->update_post('tid:'.$_G['tid'], $row['pid'], array('position' => $maxposition));
}
$maxposition ++;
}
C::t('forum_thread')->update($_G['tid'], array('maxposition' => $maxposition));
$maxposition = 1;
foreach(C::t('forum_post')->fetch_all_by_tid('tid:'.$_G['tid'], $newtid, false, 'ASC') as $row) {
if($row['position'] != $maxposition) {
C::t('forum_post')->update_post('tid:'.$_G['tid'], $row['pid'], array('position' => $maxposition));
}
$maxposition ++;
}
C::t('forum_thread')->update($newtid, array('author'=>$fpost['author'], 'authorid'=>$fpost['authorid'], 'dateline'=>$fpost['dateline'], 'rate'=>intval(abs($fpost['rate']) ? ($fpost['rate'] / abs($fpost['rate'])) : 0), 'maxposition' => $maxposition));
updatethreadcount($_G['tid']);
updatethreadcount($newtid);
updateforumcount($_G['fid']);
$_G['forum']['threadcaches'] && deletethreadcaches($thread['tid']);
$modpostsnum++;
$resultarray = array(
'redirect' => "forum.php?mod=forumdisplay&fid={$_G['fid']}",
'reasonpm' => ($sendreasonpm ? array('data' => $splitauthors, 'var' => 'thread', 'item' => 'reason_moderate', 'notictype' => 'post') : array()),
'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason),
'modtids' => $thread['tid'].','.$newtid,
'modlog' => array($thread, array('tid' => $newtid, 'subject' => $subject))
);
}
?>

View File

@@ -0,0 +1,53 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_stamp.php 33825 2013-08-19 08:32:40Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowstampthread']) {
showmessage('no_privilege_stampthread');
}
loadcache('stamps');
if(!submitcheck('modsubmit')) {
include template('forum/topicadmin_action');
} else {
$modaction = $_GET['stamp'] !== '' ? 'SPA' : 'SPD';
$_GET['stamp'] = $_GET['stamp'] !== '' ? $_GET['stamp'] : -1;
$reason = checkreasonpm();
C::t('forum_thread')->update($_G['tid'], array('moderated'=>1, 'stamp'=>$_GET['stamp']));
if($modaction == 'SPA' && $_G['cache']['stamps'][$_GET['stamp']]['icon']) {
C::t('forum_thread')->update($_G['tid'], array('icon'=>$_G['cache']['stamps'][$_GET['stamp']]['icon']));
C::t('forum_threadhidelog')->delete_by_tid($_G['tid']);
} elseif($modaction == 'SPD' && $_G['cache']['stamps'][$thread['stamp']]['icon'] == $thread['icon']) {
C::t('forum_thread')->update($_G['tid'], array('icon'=>-1));
}
C::t('common_member_secwhite')->add($thread['authorid']);
$resultarray = array(
'redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page=$page",
'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'notictype' => 'post', 'item' => $_GET['stamp'] !== '' ? 'reason_stamp_update' : 'reason_stamp_delete') : array()),
'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason, 'stamp' => $_G['cache']['stamps'][$stamp]['text']),
'modaction' => $modaction,
'modlog' => $thread
);
$modpostsnum = 1;
updatemodlog($_G['tid'], $modaction, 0, 0, '', $modaction == 'SPA' ? $_GET['stamp'] : 0);
}
?>

View File

@@ -0,0 +1,44 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_stamplist.php 30872 2012-06-27 10:11:44Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowstamplist']) {
showmessage('no_privilege_stamplist');
}
loadcache('stamps');
if(!submitcheck('modsubmit')) {
include template('forum/topicadmin_action');
} else {
$_GET['stamplist'] = $_GET['stamplist'] !== '' ? $_GET['stamplist'] : -1;
$modaction = $_GET['stamplist'] >= 0 ? 'L'.sprintf('%02d', $_GET['stamplist']) : 'SLD';
$reason = checkreasonpm();
C::t('forum_thread')->update($_G['tid'], array('moderated'=>1, 'icon'=>$_GET['stamplist']));
$resultarray = array(
'redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page=$page",
'reasonpm' => ($sendreasonpm ? array('data' => array($thread), 'var' => 'thread', 'notictype' => 'post', 'item' => $_GET['stamplist'] !== '' ? 'reason_stamplist_update' : 'reason_stamplist_delete') : array()),
'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason, 'stamp' => $_G['cache']['stamps'][$_GET['stamplist']]['text']),
'modaction' => $modaction,
'modlog' => $thread
);
$modpostsnum = 1;
updatemodlog($_G['tid'], $modaction);
}
?>

View File

@@ -0,0 +1,82 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_stickreply.php 35235 2015-03-19 06:27:54Z nemohou $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowstickreply'] && !$specialperm) {
showmessage('no_privilege_stickreply');
}
$topiclist = $_GET['topiclist'];
$modpostsnum = count($topiclist);
if(empty($topiclist)) {
showmessage('admin_stickreply_invalid');
} elseif(!$_G['tid']) {
showmessage('admin_nopermission', NULL);
}
$sticktopiclist = $posts = array();
$authorids = array();
foreach($topiclist as $pid) {
$post = C::t('forum_post')->fetch_post('tid:'.$_G['tid'], $pid, false);
$authorids[] = array('authorid' => $post['authorid']);
$sticktopiclist[$pid] = $post['position'];
}
if(!submitcheck('modsubmit')) {
$stickpid = '';
foreach($sticktopiclist as $id => $postnum) {
$stickpid .= '<input type="hidden" name="topiclist[]" value="'.dintval($id).'" />';
}
include template('forum/topicadmin_action');
} else {
if($_GET['stickreply']) {
foreach($sticktopiclist as $pid => $postnum) {
$post = C::t('forum_post')->fetch_all_by_pid('tid:'.$_G['tid'], $pid, false);
if($post[$pid]['tid'] != $_G['tid']) {
continue;
}
C::t('forum_poststick')->insert(array(
'tid' => $_G['tid'],
'pid' => $pid,
'position' => $postnum,
'dateline' => $_G['timestamp'],
), false, true);
}
} else {
foreach($sticktopiclist as $pid => $postnum) {
C::t('forum_poststick')->delete_stick($_G['tid'], $pid);
}
}
$sticknum = C::t('forum_poststick')->count_by_tid($_G['tid']);
$stickreply = intval($_GET['stickreply']);
if($sticknum == 0 || $stickreply == 1) {
C::t('forum_thread')->update($_G['tid'], array('moderated'=>1, 'stickreply'=>$stickreply));
}
$modaction = $_GET['stickreply'] ? 'SRE' : 'USR';
$reason = checkreasonpm();
$resultarray = array(
'redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page=$page",
'reasonpm' => ($sendreasonpm ? array('data' => $authorids, 'var' => 'post', 'notictype' => 'post', 'item' => $_GET['stickreply'] ? 'reason_stickreply': 'reason_stickdeletereply') : array()),
'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason),
'modlog' => $thread
);
}
?>

View File

@@ -0,0 +1,131 @@
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: topicadmin_warn.php 30872 2012-06-27 10:11:44Z liulanbo $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
if(!$_G['group']['allowwarnpost']) {
showmessage('no_privilege_warnpost');
}
$topiclist = $_GET['topiclist'];
if(!($warnpids = dimplode($topiclist))) {
showmessage('admin_warn_invalid');
} elseif(!$_G['group']['allowbanpost'] || !$_G['tid']) {
showmessage('admin_nopermission', NULL);
}
$posts = $authors = array();
$authorwarnings = $warningauthor = $warnstatus = '';
$postlist = C::t('forum_post')->fetch_all_post('tid:'.$_G['tid'], $topiclist);
foreach($postlist as $post) {
$uids[] = $post['authorid'];
}
$memberlist = C::t('common_member')->fetch_all($uids);
foreach($postlist as $post) {
if($post['tid'] != $_G['tid']) {
continue;
}
$post['adminid'] = $memberlist[$post['authorid']]['adminid'];
if($_G['adminid'] == 1 && $post['adminid'] != 1 ||
$_G['adminid'] == 2 && !in_array($post['adminid'], array(1, 2)) ||
$_G['adminid'] == 3 && in_array($post['adminid'], array(0, -1))) {
$warnstatus = ($post['status'] & 2) || $warnstatus;
$authors[$post['authorid']] = 1;
$posts[] = $post;
}
}
unset($memberlist, $postlist, $uids);
if(!$posts) {
showmessage('admin_warn_nopermission');
}
$authorcount = count(array_keys($authors));
$modpostsnum = count($posts);
if($modpostsnum == 1 || $authorcount == 1) {
$authorwarnings = C::t('forum_warning')->count_by_authorid_dateline($posts[0]['authorid']);
$warningauthor = $posts[0]['author'];
}
if(!submitcheck('modsubmit')) {
$warnpid = $checkunwarn = $checkwarn = '';
foreach($topiclist as $id) {
$warnpid .= '<input type="hidden" name="topiclist[]" value="'.$id.'" />';
}
$warnstatus ? $checkunwarn = 'checked="checked"' : $checkwarn = 'checked="checked"';
include template('forum/topicadmin_action');
} else {
$warned = intval($_GET['warned']);
$modaction = $warned ? 'WRN' : 'UWN';
$reason = checkreasonpm();
include_once libfile('function/member');
$pids = $comma = '';
foreach($posts as $k => $post) {
if($warned && !($post['status'] & 2)) {
C::t('forum_post')->increase_status_by_pid('tid:'.$_G['tid'], $post['pid'], 2, '|', true);
$reason = dhtmlspecialchars($_GET['reason']);
C::t('forum_warning')->insert(array(
'pid' => $post['pid'],
'operatorid' => $_G['uid'],
'operator' => $_G['username'],
'authorid' => $post['authorid'],
'author' => $post['author'],
'dateline' => $_G['timestamp'],
'reason' => $reason,
));
$authorwarnings = C::t('forum_warning')->count_by_authorid_dateline($post['authorid'], $_G['timestamp'] - $_G['setting']['warningexpiration'] * 86400);
if($authorwarnings >= $_G['setting']['warninglimit']) {
$member = getuserbyuid($post['authorid']);
$memberfieldforum = C::t('common_member_field_forum')->fetch($post['authorid']);
$groupterms = dunserialize($memberfieldforum['groupterms']);
unset($memberfieldforum);
if($member && $member['groupid'] != 4) {
$banexpiry = TIMESTAMP + $_G['setting']['warningexpiration'] * 86400;
$groupterms['main'] = array('time' => $banexpiry, 'adminid' => $member['adminid'], 'groupid' => $member['groupid']);
$groupterms['ext'][4] = $banexpiry;
C::t('common_member')->update($post['authorid'], array('groupid' => 4, 'adminid' => -1, 'groupexpiry' => groupexpiry($groupterms)));
C::t('common_member_field_forum')->update($post['authorid'], array('groupterms' => serialize($groupterms)));
}
}
$pids .= $comma.$post['pid'];
$comma = ',';
crime('recordaction', $post['authorid'], 'crime_warnpost', lang('forum/misc', 'crime_postreason', array('reason' => $reason, 'tid' => $_G['tid'], 'pid' => $post['pid'])));
} elseif(!$warned && ($post['status'] & 2)) {
C::t('forum_post')->increase_status_by_pid('tid:'.$_G['tid'], $post['pid'], 2, '^', true);
C::t('forum_warning')->delete_by_pid($post['pid']);
$pids .= $comma.$post['pid'];
$comma = ',';
}
}
$resultarray = array(
'redirect' => "forum.php?mod=viewthread&tid={$_G['tid']}&page=$page",
'reasonpm' => ($sendreasonpm ? array('data' => $posts, 'var' => 'post', 'item' => 'reason_warn_post', 'notictype' => 'post') : array()),
'reasonvar' => array('tid' => $thread['tid'], 'subject' => $thread['subject'], 'modaction' => $modaction, 'reason' => $reason,
'warningexpiration' => $_G['setting']['warningexpiration'], 'warninglimit' => $_G['setting']['warninglimit'], 'warningexpiration' => $_G['setting']['warningexpiration'],
'authorwarnings' => $authorwarnings),
'modtids' => 0,
'modlog' => $thread
);
}
?>