modcp_forum.php
4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: modcp_forum.php 32563 2013-02-21 03:38:50Z zhangguosheng $
 */
if(!defined('IN_DISCUZ') || !defined('IN_MODCP')) {
	exit('Access Denied');
}
$forumupdate = $listupdate = false;
$op = !in_array($op , array('editforum', 'recommend')) ? 'editforum' : $op;
if(empty($_G['fid'])) {
	if(!empty($_G['cookie']['modcpfid'])) {
		$fid = $_G['cookie']['modcpfid'];
	} else {
		list($fid) = array_keys($modforums['list']);
	}
	dheader("Location: {$cpscript}?mod=modcp&action=$_GET[action]&op=$op&fid=$fid");
}
if($_G['fid'] && $_G['forum']['ismoderator']) {
	if($op == 'editforum') {
		require_once libfile('function/editor');
		$alloweditrules = $_G['adminid'] == 1 || $_G['forum']['alloweditrules'] ? true : false;
		if(!submitcheck('editsubmit')) {
			$_G['forum']['rules'] = html2bbcode($_G['forum']['rules']);
		} else {
			require_once libfile('function/discuzcode');
			$forumupdate = true;
			$rulesnew = $alloweditrules ? preg_replace('/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i', '', discuzcode($_GET['rulesnew'], 1, 0, 0, 0, 1, 1, 0, 0, 1)) : $_G['forum']['rules'];
			C::t('forum_forumfield')->update($_G['fid'], array('rules' => $rulesnew));
			$_G['forum']['description'] = html2bbcode($descnew);
			$_G['forum']['rules'] = html2bbcode($rulesnew);
		}
	} elseif($op == 'recommend') {
		$useradd = 0;
		if($_G['adminid'] == 3) {
			$useradd = $_G['uid'];
		}
		$ordernew = !empty($_GET['ordernew']) && is_array($_GET['ordernew']) ? $_GET['ordernew'] : array();
		if(submitcheck('editsubmit') && $_G['forum']['modrecommend']['sort'] != 1) {
			$threads = array();
			foreach($_GET['order'] as $id => $position) {
				$threads[$id]['order'] = $position;
			}
			foreach($_GET['subject'] as $id => $title) {
				$threads[$id]['subject'] = $title;
			}
			foreach($_GET['expirationrecommend'] as $id => $expiration) {
				$expiration = trim($expiration);
				if(!empty($expiration)) {
					if(!preg_match('/^\d{4}-\d{1,2}-\d{1,2} +\d{1,2}:\d{1,2}$/', $expiration)) {
						showmessage('recommend_expiration_invalid');
					}
					list($expiration_date, $expiration_time) = explode(' ', $expiration);
					list($expiration_year, $expiration_month, $expiration_day) = explode('-', $expiration_date);
					list($expiration_hour, $expiration_min) = explode(':', $expiration_time);
					$expiration_sec = 0;
					$expiration_timestamp = mktime($expiration_hour, $expiration_min, $expiration_sec, $expiration_month, $expiration_day, $expiration_year);
				} else {
					$expiration_timestamp = 0;
				}
				$threads[$id]['expiration'] = $expiration_timestamp;
			}
			if($_GET['delete']) {
				$listupdate = true;
				C::t('forum_forumrecommend')->delete($_GET['delete']);
			}
			if(!empty($_GET['delete']) && is_array($_GET['delete'])) {
				foreach($_GET['delete'] as $id) {
					$threads[$id]['delete'] = true;
					unset($threads[$id]);
				}
			}
			foreach($threads as $id => $item) {
				$item['displayorder'] = intval($item['order']);
				$item['subject'] = dhtmlspecialchars($item['subject']);
				C::t('forum_forumrecommend')->update($id, array(
					'subject' => $item['subject'],
					'displayorder' => $item['displayorder'],
					'expiration' => $item['expiration']
				));
			}
			$listupdate = true;
		}
		$page = max(1, intval($_G['page']));
		$start_limit = ($page - 1) * $_G['tpp'];
		$threadcount = C::t('forum_forumrecommend')->count_by_fid($_G['fid']);
		$multipage = multi($threadcount, $_G['tpp'], $page, "$cpscript?action=$_GET[action]&fid=$_G[fid]&page=$page");
		$threadlist = $moderatormembers = array();
		$moderatorids = array();
		foreach(C::t('forum_forumrecommend')->fetch_all_by_fid($_G['fid'], false, $useradd, $start_limit, $_G['tpp']) as $thread) {
			if($thread['moderatorid']) {
				$moderatorids[$thread['moderatorid']] = $thread['moderatorid'];
			}
			$thread['authorlink'] = $thread['authorid'] ? "<a href=\"home.php?mod=space&uid=$thread[authorid]\" target=\"_blank\">$thread[author]</a>" : 'Guest';
			$thread['expiration'] = $thread['expiration'] ? dgmdate($thread['expiration']) : '';
			$threadlist[] = $thread;
		}
		if($moderatorids) {
			$moderatormembers = C::t('common_member')->fetch_all($moderatorids, false, 0);
		}
	}
}
?>