130 |
kaklik |
1 |
<?php |
|
|
2 |
/*************************************************************************** |
|
|
3 |
* admin_forums.php |
|
|
4 |
* ------------------- |
|
|
5 |
* begin : Thursday, Jul 12, 2001 |
|
|
6 |
* copyright : (C) 2001 The phpBB Group |
|
|
7 |
* email : support@phpbb.com |
|
|
8 |
* |
|
|
9 |
* $Id: admin_forums.php,v 1.40.2.13 2006/03/09 21:55:09 grahamje Exp $ |
|
|
10 |
* |
|
|
11 |
***************************************************************************/ |
|
|
12 |
|
|
|
13 |
/*************************************************************************** |
|
|
14 |
* |
|
|
15 |
* This program is free software; you can redistribute it and/or modify |
|
|
16 |
* it under the terms of the GNU General Public License as published by |
|
|
17 |
* the Free Software Foundation; either version 2 of the License, or |
|
|
18 |
* (at your option) any later version. |
|
|
19 |
* |
|
|
20 |
***************************************************************************/ |
|
|
21 |
|
|
|
22 |
define('IN_PHPBB', 1); |
|
|
23 |
|
|
|
24 |
if( !empty($setmodules) ) |
|
|
25 |
{ |
|
|
26 |
$file = basename(__FILE__); |
|
|
27 |
$module['Forums']['Manage'] = $file; |
|
|
28 |
return; |
|
|
29 |
} |
|
|
30 |
|
|
|
31 |
// |
|
|
32 |
// Load default header |
|
|
33 |
// |
|
|
34 |
$phpbb_root_path = "./../"; |
|
|
35 |
require($phpbb_root_path . 'extension.inc'); |
|
|
36 |
require('./pagestart.' . $phpEx); |
|
|
37 |
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx); |
|
|
38 |
|
|
|
39 |
$forum_auth_ary = array( |
|
|
40 |
"auth_view" => AUTH_ALL, |
|
|
41 |
"auth_read" => AUTH_ALL, |
|
|
42 |
"auth_post" => AUTH_REG, |
|
|
43 |
"auth_reply" => AUTH_REG, |
|
|
44 |
"auth_edit" => AUTH_REG, |
|
|
45 |
"auth_delete" => AUTH_REG, |
|
|
46 |
"auth_sticky" => AUTH_MOD, |
|
|
47 |
"auth_announce" => AUTH_MOD, |
|
|
48 |
"auth_vote" => AUTH_REG, |
|
|
49 |
"auth_pollcreate" => AUTH_REG |
|
|
50 |
); |
|
|
51 |
|
|
|
52 |
// |
|
|
53 |
// Mode setting |
|
|
54 |
// |
|
|
55 |
if( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) ) |
|
|
56 |
{ |
|
|
57 |
$mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode']; |
|
|
58 |
$mode = htmlspecialchars($mode); |
|
|
59 |
} |
|
|
60 |
else |
|
|
61 |
{ |
|
|
62 |
$mode = ""; |
|
|
63 |
} |
|
|
64 |
|
|
|
65 |
// ------------------ |
|
|
66 |
// Begin function block |
|
|
67 |
// |
|
|
68 |
function get_info($mode, $id) |
|
|
69 |
{ |
|
|
70 |
global $db; |
|
|
71 |
|
|
|
72 |
switch($mode) |
|
|
73 |
{ |
|
|
74 |
case 'category': |
|
|
75 |
$table = CATEGORIES_TABLE; |
|
|
76 |
$idfield = 'cat_id'; |
|
|
77 |
$namefield = 'cat_title'; |
|
|
78 |
break; |
|
|
79 |
|
|
|
80 |
case 'forum': |
|
|
81 |
$table = FORUMS_TABLE; |
|
|
82 |
$idfield = 'forum_id'; |
|
|
83 |
$namefield = 'forum_name'; |
|
|
84 |
break; |
|
|
85 |
|
|
|
86 |
default: |
|
|
87 |
message_die(GENERAL_ERROR, "Wrong mode for generating select list", "", __LINE__, __FILE__); |
|
|
88 |
break; |
|
|
89 |
} |
|
|
90 |
$sql = "SELECT count(*) as total |
|
|
91 |
FROM $table"; |
|
|
92 |
if( !$result = $db->sql_query($sql) ) |
|
|
93 |
{ |
|
|
94 |
message_die(GENERAL_ERROR, "Couldn't get Forum/Category information", "", __LINE__, __FILE__, $sql); |
|
|
95 |
} |
|
|
96 |
$count = $db->sql_fetchrow($result); |
|
|
97 |
$count = $count['total']; |
|
|
98 |
|
|
|
99 |
$sql = "SELECT * |
|
|
100 |
FROM $table |
|
|
101 |
WHERE $idfield = $id"; |
|
|
102 |
|
|
|
103 |
if( !$result = $db->sql_query($sql) ) |
|
|
104 |
{ |
|
|
105 |
message_die(GENERAL_ERROR, "Couldn't get Forum/Category information", "", __LINE__, __FILE__, $sql); |
|
|
106 |
} |
|
|
107 |
|
|
|
108 |
if( $db->sql_numrows($result) != 1 ) |
|
|
109 |
{ |
|
|
110 |
message_die(GENERAL_ERROR, "Forum/Category doesn't exist or multiple forums/categories with ID $id", "", __LINE__, __FILE__); |
|
|
111 |
} |
|
|
112 |
|
|
|
113 |
$return = $db->sql_fetchrow($result); |
|
|
114 |
$return['number'] = $count; |
|
|
115 |
return $return; |
|
|
116 |
} |
|
|
117 |
|
|
|
118 |
function get_list($mode, $id, $select) |
|
|
119 |
{ |
|
|
120 |
global $db; |
|
|
121 |
|
|
|
122 |
switch($mode) |
|
|
123 |
{ |
|
|
124 |
case 'category': |
|
|
125 |
$table = CATEGORIES_TABLE; |
|
|
126 |
$idfield = 'cat_id'; |
|
|
127 |
$namefield = 'cat_title'; |
|
|
128 |
break; |
|
|
129 |
|
|
|
130 |
case 'forum': |
|
|
131 |
$table = FORUMS_TABLE; |
|
|
132 |
$idfield = 'forum_id'; |
|
|
133 |
$namefield = 'forum_name'; |
|
|
134 |
break; |
|
|
135 |
|
|
|
136 |
default: |
|
|
137 |
message_die(GENERAL_ERROR, "Wrong mode for generating select list", "", __LINE__, __FILE__); |
|
|
138 |
break; |
|
|
139 |
} |
|
|
140 |
|
|
|
141 |
$sql = "SELECT * |
|
|
142 |
FROM $table"; |
|
|
143 |
if( $select == 0 ) |
|
|
144 |
{ |
|
|
145 |
$sql .= " WHERE $idfield <> $id"; |
|
|
146 |
} |
|
|
147 |
|
|
|
148 |
if( !$result = $db->sql_query($sql) ) |
|
|
149 |
{ |
|
|
150 |
message_die(GENERAL_ERROR, "Couldn't get list of Categories/Forums", "", __LINE__, __FILE__, $sql); |
|
|
151 |
} |
|
|
152 |
|
|
|
153 |
$cat_list = ""; |
|
|
154 |
|
|
|
155 |
while( $row = $db->sql_fetchrow($result) ) |
|
|
156 |
{ |
|
|
157 |
$s = ""; |
|
|
158 |
if ($row[$idfield] == $id) |
|
|
159 |
{ |
|
|
160 |
$s = " selected=\"selected\""; |
|
|
161 |
} |
|
|
162 |
$catlist .= "<option value=\"$row[$idfield]\"$s>" . $row[$namefield] . "</option>\n"; |
|
|
163 |
} |
|
|
164 |
|
|
|
165 |
return($catlist); |
|
|
166 |
} |
|
|
167 |
|
|
|
168 |
function renumber_order($mode, $cat = 0) |
|
|
169 |
{ |
|
|
170 |
global $db; |
|
|
171 |
|
|
|
172 |
switch($mode) |
|
|
173 |
{ |
|
|
174 |
case 'category': |
|
|
175 |
$table = CATEGORIES_TABLE; |
|
|
176 |
$idfield = 'cat_id'; |
|
|
177 |
$orderfield = 'cat_order'; |
|
|
178 |
$cat = 0; |
|
|
179 |
break; |
|
|
180 |
|
|
|
181 |
case 'forum': |
|
|
182 |
$table = FORUMS_TABLE; |
|
|
183 |
$idfield = 'forum_id'; |
|
|
184 |
$orderfield = 'forum_order'; |
|
|
185 |
$catfield = 'cat_id'; |
|
|
186 |
break; |
|
|
187 |
|
|
|
188 |
default: |
|
|
189 |
message_die(GENERAL_ERROR, "Wrong mode for generating select list", "", __LINE__, __FILE__); |
|
|
190 |
break; |
|
|
191 |
} |
|
|
192 |
|
|
|
193 |
$sql = "SELECT * FROM $table"; |
|
|
194 |
if( $cat != 0) |
|
|
195 |
{ |
|
|
196 |
$sql .= " WHERE $catfield = $cat"; |
|
|
197 |
} |
|
|
198 |
$sql .= " ORDER BY $orderfield ASC"; |
|
|
199 |
|
|
|
200 |
|
|
|
201 |
if( !$result = $db->sql_query($sql) ) |
|
|
202 |
{ |
|
|
203 |
message_die(GENERAL_ERROR, "Couldn't get list of Categories", "", __LINE__, __FILE__, $sql); |
|
|
204 |
} |
|
|
205 |
|
|
|
206 |
$i = 10; |
|
|
207 |
$inc = 10; |
|
|
208 |
|
|
|
209 |
while( $row = $db->sql_fetchrow($result) ) |
|
|
210 |
{ |
|
|
211 |
$sql = "UPDATE $table |
|
|
212 |
SET $orderfield = $i |
|
|
213 |
WHERE $idfield = " . $row[$idfield]; |
|
|
214 |
if( !$db->sql_query($sql) ) |
|
|
215 |
{ |
|
|
216 |
message_die(GENERAL_ERROR, "Couldn't update order fields", "", __LINE__, __FILE__, $sql); |
|
|
217 |
} |
|
|
218 |
$i += 10; |
|
|
219 |
} |
|
|
220 |
|
|
|
221 |
} |
|
|
222 |
// |
|
|
223 |
// End function block |
|
|
224 |
// ------------------ |
|
|
225 |
|
|
|
226 |
// |
|
|
227 |
// Begin program proper |
|
|
228 |
// |
|
|
229 |
if( isset($HTTP_POST_VARS['addforum']) || isset($HTTP_POST_VARS['addcategory']) ) |
|
|
230 |
{ |
|
|
231 |
$mode = ( isset($HTTP_POST_VARS['addforum']) ) ? "addforum" : "addcat"; |
|
|
232 |
|
|
|
233 |
if( $mode == "addforum" ) |
|
|
234 |
{ |
|
|
235 |
list($cat_id) = each($HTTP_POST_VARS['addforum']); |
|
|
236 |
$cat_id = intval($cat_id); |
|
|
237 |
// |
|
|
238 |
// stripslashes needs to be run on this because slashes are added when the forum name is posted |
|
|
239 |
// |
|
|
240 |
$forumname = stripslashes($HTTP_POST_VARS['forumname'][$cat_id]); |
|
|
241 |
} |
|
|
242 |
} |
|
|
243 |
|
|
|
244 |
if( !empty($mode) ) |
|
|
245 |
{ |
|
|
246 |
switch($mode) |
|
|
247 |
{ |
|
|
248 |
case 'addforum': |
|
|
249 |
case 'editforum': |
|
|
250 |
// |
|
|
251 |
// Show form to create/modify a forum |
|
|
252 |
// |
|
|
253 |
if ($mode == 'editforum') |
|
|
254 |
{ |
|
|
255 |
// $newmode determines if we are going to INSERT or UPDATE after posting? |
|
|
256 |
|
|
|
257 |
$l_title = $lang['Edit_forum']; |
|
|
258 |
$newmode = 'modforum'; |
|
|
259 |
$buttonvalue = $lang['Update']; |
|
|
260 |
|
|
|
261 |
$forum_id = intval($HTTP_GET_VARS[POST_FORUM_URL]); |
|
|
262 |
|
|
|
263 |
$row = get_info('forum', $forum_id); |
|
|
264 |
|
|
|
265 |
$cat_id = $row['cat_id']; |
|
|
266 |
$forumname = $row['forum_name']; |
|
|
267 |
$forumdesc = $row['forum_desc']; |
|
|
268 |
$forumstatus = $row['forum_status']; |
|
|
269 |
|
|
|
270 |
// |
|
|
271 |
// start forum prune stuff. |
|
|
272 |
// |
|
|
273 |
if( $row['prune_enable'] ) |
|
|
274 |
{ |
|
|
275 |
$prune_enabled = "checked=\"checked\""; |
|
|
276 |
$sql = "SELECT * |
|
|
277 |
FROM " . PRUNE_TABLE . " |
|
|
278 |
WHERE forum_id = $forum_id"; |
|
|
279 |
if(!$pr_result = $db->sql_query($sql)) |
|
|
280 |
{ |
|
|
281 |
message_die(GENERAL_ERROR, "Auto-Prune: Couldn't read auto_prune table.", __LINE__, __FILE__); |
|
|
282 |
} |
|
|
283 |
|
|
|
284 |
$pr_row = $db->sql_fetchrow($pr_result); |
|
|
285 |
} |
|
|
286 |
else |
|
|
287 |
{ |
|
|
288 |
$prune_enabled = ''; |
|
|
289 |
} |
|
|
290 |
} |
|
|
291 |
else |
|
|
292 |
{ |
|
|
293 |
$l_title = $lang['Create_forum']; |
|
|
294 |
$newmode = 'createforum'; |
|
|
295 |
$buttonvalue = $lang['Create_forum']; |
|
|
296 |
|
|
|
297 |
$forumdesc = ''; |
|
|
298 |
$forumstatus = FORUM_UNLOCKED; |
|
|
299 |
$forum_id = ''; |
|
|
300 |
$prune_enabled = ''; |
|
|
301 |
} |
|
|
302 |
|
|
|
303 |
$catlist = get_list('category', $cat_id, TRUE); |
|
|
304 |
|
|
|
305 |
$forumstatus == ( FORUM_LOCKED ) ? $forumlocked = "selected=\"selected\"" : $forumunlocked = "selected=\"selected\""; |
|
|
306 |
|
|
|
307 |
// These two options ($lang['Status_unlocked'] and $lang['Status_locked']) seem to be missing from |
|
|
308 |
// the language files. |
|
|
309 |
$lang['Status_unlocked'] = isset($lang['Status_unlocked']) ? $lang['Status_unlocked'] : 'Unlocked'; |
|
|
310 |
$lang['Status_locked'] = isset($lang['Status_locked']) ? $lang['Status_locked'] : 'Locked'; |
|
|
311 |
|
|
|
312 |
$statuslist = "<option value=\"" . FORUM_UNLOCKED . "\" $forumunlocked>" . $lang['Status_unlocked'] . "</option>\n"; |
|
|
313 |
$statuslist .= "<option value=\"" . FORUM_LOCKED . "\" $forumlocked>" . $lang['Status_locked'] . "</option>\n"; |
|
|
314 |
|
|
|
315 |
$template->set_filenames(array( |
|
|
316 |
"body" => "admin/forum_edit_body.tpl") |
|
|
317 |
); |
|
|
318 |
|
|
|
319 |
$s_hidden_fields = '<input type="hidden" name="mode" value="' . $newmode .'" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />'; |
|
|
320 |
|
|
|
321 |
$template->assign_vars(array( |
|
|
322 |
'S_FORUM_ACTION' => append_sid("admin_forums.$phpEx"), |
|
|
323 |
'S_HIDDEN_FIELDS' => $s_hidden_fields, |
|
|
324 |
'S_SUBMIT_VALUE' => $buttonvalue, |
|
|
325 |
'S_CAT_LIST' => $catlist, |
|
|
326 |
'S_STATUS_LIST' => $statuslist, |
|
|
327 |
'S_PRUNE_ENABLED' => $prune_enabled, |
|
|
328 |
|
|
|
329 |
'L_FORUM_TITLE' => $l_title, |
|
|
330 |
'L_FORUM_EXPLAIN' => $lang['Forum_edit_delete_explain'], |
|
|
331 |
'L_FORUM_SETTINGS' => $lang['Forum_settings'], |
|
|
332 |
'L_FORUM_NAME' => $lang['Forum_name'], |
|
|
333 |
'L_CATEGORY' => $lang['Category'], |
|
|
334 |
'L_FORUM_DESCRIPTION' => $lang['Forum_desc'], |
|
|
335 |
'L_FORUM_STATUS' => $lang['Forum_status'], |
|
|
336 |
'L_AUTO_PRUNE' => $lang['Forum_pruning'], |
|
|
337 |
'L_ENABLED' => $lang['Enabled'], |
|
|
338 |
'L_PRUNE_DAYS' => $lang['prune_days'], |
|
|
339 |
'L_PRUNE_FREQ' => $lang['prune_freq'], |
|
|
340 |
'L_DAYS' => $lang['Days'], |
|
|
341 |
|
|
|
342 |
'PRUNE_DAYS' => ( isset($pr_row['prune_days']) ) ? $pr_row['prune_days'] : 7, |
|
|
343 |
'PRUNE_FREQ' => ( isset($pr_row['prune_freq']) ) ? $pr_row['prune_freq'] : 1, |
|
|
344 |
'FORUM_NAME' => $forumname, |
|
|
345 |
'DESCRIPTION' => $forumdesc) |
|
|
346 |
); |
|
|
347 |
$template->pparse("body"); |
|
|
348 |
break; |
|
|
349 |
|
|
|
350 |
case 'createforum': |
|
|
351 |
// |
|
|
352 |
// Create a forum in the DB |
|
|
353 |
// |
|
|
354 |
if( trim($HTTP_POST_VARS['forumname']) == "" ) |
|
|
355 |
{ |
|
|
356 |
message_die(GENERAL_ERROR, "Can't create a forum without a name"); |
|
|
357 |
} |
|
|
358 |
|
|
|
359 |
$sql = "SELECT MAX(forum_order) AS max_order |
|
|
360 |
FROM " . FORUMS_TABLE . " |
|
|
361 |
WHERE cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]); |
|
|
362 |
if( !$result = $db->sql_query($sql) ) |
|
|
363 |
{ |
|
|
364 |
message_die(GENERAL_ERROR, "Couldn't get order number from forums table", "", __LINE__, __FILE__, $sql); |
|
|
365 |
} |
|
|
366 |
$row = $db->sql_fetchrow($result); |
|
|
367 |
|
|
|
368 |
$max_order = $row['max_order']; |
|
|
369 |
$next_order = $max_order + 10; |
|
|
370 |
|
|
|
371 |
$sql = "SELECT MAX(forum_id) AS max_id |
|
|
372 |
FROM " . FORUMS_TABLE; |
|
|
373 |
if( !$result = $db->sql_query($sql) ) |
|
|
374 |
{ |
|
|
375 |
message_die(GENERAL_ERROR, "Couldn't get order number from forums table", "", __LINE__, __FILE__, $sql); |
|
|
376 |
} |
|
|
377 |
$row = $db->sql_fetchrow($result); |
|
|
378 |
|
|
|
379 |
$max_id = $row['max_id']; |
|
|
380 |
$next_id = $max_id + 1; |
|
|
381 |
|
|
|
382 |
// |
|
|
383 |
// Default permissions of public :: |
|
|
384 |
// |
|
|
385 |
$field_sql = ""; |
|
|
386 |
$value_sql = ""; |
|
|
387 |
while( list($field, $value) = each($forum_auth_ary) ) |
|
|
388 |
{ |
|
|
389 |
$field_sql .= ", $field"; |
|
|
390 |
$value_sql .= ", $value"; |
|
|
391 |
|
|
|
392 |
} |
|
|
393 |
|
|
|
394 |
// There is no problem having duplicate forum names so we won't check for it. |
|
|
395 |
$sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id, forum_name, cat_id, forum_desc, forum_order, forum_status, prune_enable" . $field_sql . ") |
|
|
396 |
VALUES ('" . $next_id . "', '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', $next_order, " . intval($HTTP_POST_VARS['forumstatus']) . ", " . intval($HTTP_POST_VARS['prune_enable']) . $value_sql . ")"; |
|
|
397 |
if( !$result = $db->sql_query($sql) ) |
|
|
398 |
{ |
|
|
399 |
message_die(GENERAL_ERROR, "Couldn't insert row in forums table", "", __LINE__, __FILE__, $sql); |
|
|
400 |
} |
|
|
401 |
|
|
|
402 |
if( $HTTP_POST_VARS['prune_enable'] ) |
|
|
403 |
{ |
|
|
404 |
|
|
|
405 |
if( $HTTP_POST_VARS['prune_days'] == "" || $HTTP_POST_VARS['prune_freq'] == "") |
|
|
406 |
{ |
|
|
407 |
message_die(GENERAL_MESSAGE, $lang['Set_prune_data']); |
|
|
408 |
} |
|
|
409 |
|
|
|
410 |
$sql = "INSERT INTO " . PRUNE_TABLE . " (forum_id, prune_days, prune_freq) |
|
|
411 |
VALUES('" . $next_id . "', " . intval($HTTP_POST_VARS['prune_days']) . ", " . intval($HTTP_POST_VARS['prune_freq']) . ")"; |
|
|
412 |
if( !$result = $db->sql_query($sql) ) |
|
|
413 |
{ |
|
|
414 |
message_die(GENERAL_ERROR, "Couldn't insert row in prune table", "", __LINE__, __FILE__, $sql); |
|
|
415 |
} |
|
|
416 |
} |
|
|
417 |
|
|
|
418 |
$message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); |
|
|
419 |
|
|
|
420 |
message_die(GENERAL_MESSAGE, $message); |
|
|
421 |
|
|
|
422 |
break; |
|
|
423 |
|
|
|
424 |
case 'modforum': |
|
|
425 |
// Modify a forum in the DB |
|
|
426 |
if( isset($HTTP_POST_VARS['prune_enable'])) |
|
|
427 |
{ |
|
|
428 |
if( $HTTP_POST_VARS['prune_enable'] != 1 ) |
|
|
429 |
{ |
|
|
430 |
$HTTP_POST_VARS['prune_enable'] = 0; |
|
|
431 |
} |
|
|
432 |
} |
|
|
433 |
|
|
|
434 |
$sql = "UPDATE " . FORUMS_TABLE . " |
|
|
435 |
SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]) . ", forum_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ", prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . " |
|
|
436 |
WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]); |
|
|
437 |
if( !$result = $db->sql_query($sql) ) |
|
|
438 |
{ |
|
|
439 |
message_die(GENERAL_ERROR, "Couldn't update forum information", "", __LINE__, __FILE__, $sql); |
|
|
440 |
} |
|
|
441 |
|
|
|
442 |
if( $HTTP_POST_VARS['prune_enable'] == 1 ) |
|
|
443 |
{ |
|
|
444 |
if( $HTTP_POST_VARS['prune_days'] == "" || $HTTP_POST_VARS['prune_freq'] == "" ) |
|
|
445 |
{ |
|
|
446 |
message_die(GENERAL_MESSAGE, $lang['Set_prune_data']); |
|
|
447 |
} |
|
|
448 |
|
|
|
449 |
$sql = "SELECT * |
|
|
450 |
FROM " . PRUNE_TABLE . " |
|
|
451 |
WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]); |
|
|
452 |
if( !$result = $db->sql_query($sql) ) |
|
|
453 |
{ |
|
|
454 |
message_die(GENERAL_ERROR, "Couldn't get forum Prune Information","",__LINE__, __FILE__, $sql); |
|
|
455 |
} |
|
|
456 |
|
|
|
457 |
if( $db->sql_numrows($result) > 0 ) |
|
|
458 |
{ |
|
|
459 |
$sql = "UPDATE " . PRUNE_TABLE . " |
|
|
460 |
SET prune_days = " . intval($HTTP_POST_VARS['prune_days']) . ", prune_freq = " . intval($HTTP_POST_VARS['prune_freq']) . " |
|
|
461 |
WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]); |
|
|
462 |
} |
|
|
463 |
else |
|
|
464 |
{ |
|
|
465 |
$sql = "INSERT INTO " . PRUNE_TABLE . " (forum_id, prune_days, prune_freq) |
|
|
466 |
VALUES(" . intval($HTTP_POST_VARS[POST_FORUM_URL]) . ", " . intval($HTTP_POST_VARS['prune_days']) . ", " . intval($HTTP_POST_VARS['prune_freq']) . ")"; |
|
|
467 |
} |
|
|
468 |
|
|
|
469 |
if( !$result = $db->sql_query($sql) ) |
|
|
470 |
{ |
|
|
471 |
message_die(GENERAL_ERROR, "Couldn't Update Forum Prune Information","",__LINE__, __FILE__, $sql); |
|
|
472 |
} |
|
|
473 |
} |
|
|
474 |
|
|
|
475 |
$message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); |
|
|
476 |
|
|
|
477 |
message_die(GENERAL_MESSAGE, $message); |
|
|
478 |
|
|
|
479 |
break; |
|
|
480 |
|
|
|
481 |
case 'addcat': |
|
|
482 |
// Create a category in the DB |
|
|
483 |
if( trim($HTTP_POST_VARS['categoryname']) == '') |
|
|
484 |
{ |
|
|
485 |
message_die(GENERAL_ERROR, "Can't create a category without a name"); |
|
|
486 |
} |
|
|
487 |
|
|
|
488 |
$sql = "SELECT MAX(cat_order) AS max_order |
|
|
489 |
FROM " . CATEGORIES_TABLE; |
|
|
490 |
if( !$result = $db->sql_query($sql) ) |
|
|
491 |
{ |
|
|
492 |
message_die(GENERAL_ERROR, "Couldn't get order number from categories table", "", __LINE__, __FILE__, $sql); |
|
|
493 |
} |
|
|
494 |
$row = $db->sql_fetchrow($result); |
|
|
495 |
|
|
|
496 |
$max_order = $row['max_order']; |
|
|
497 |
$next_order = $max_order + 10; |
|
|
498 |
|
|
|
499 |
// |
|
|
500 |
// There is no problem having duplicate forum names so we won't check for it. |
|
|
501 |
// |
|
|
502 |
$sql = "INSERT INTO " . CATEGORIES_TABLE . " (cat_title, cat_order) |
|
|
503 |
VALUES ('" . str_replace("\'", "''", $HTTP_POST_VARS['categoryname']) . "', $next_order)"; |
|
|
504 |
if( !$result = $db->sql_query($sql) ) |
|
|
505 |
{ |
|
|
506 |
message_die(GENERAL_ERROR, "Couldn't insert row in categories table", "", __LINE__, __FILE__, $sql); |
|
|
507 |
} |
|
|
508 |
|
|
|
509 |
$message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); |
|
|
510 |
|
|
|
511 |
message_die(GENERAL_MESSAGE, $message); |
|
|
512 |
|
|
|
513 |
break; |
|
|
514 |
|
|
|
515 |
case 'editcat': |
|
|
516 |
// |
|
|
517 |
// Show form to edit a category |
|
|
518 |
// |
|
|
519 |
$newmode = 'modcat'; |
|
|
520 |
$buttonvalue = $lang['Update']; |
|
|
521 |
|
|
|
522 |
$cat_id = intval($HTTP_GET_VARS[POST_CAT_URL]); |
|
|
523 |
|
|
|
524 |
$row = get_info('category', $cat_id); |
|
|
525 |
$cat_title = $row['cat_title']; |
|
|
526 |
|
|
|
527 |
$template->set_filenames(array( |
|
|
528 |
"body" => "admin/category_edit_body.tpl") |
|
|
529 |
); |
|
|
530 |
|
|
|
531 |
$s_hidden_fields = '<input type="hidden" name="mode" value="' . $newmode . '" /><input type="hidden" name="' . POST_CAT_URL . '" value="' . $cat_id . '" />'; |
|
|
532 |
|
|
|
533 |
$template->assign_vars(array( |
|
|
534 |
'CAT_TITLE' => $cat_title, |
|
|
535 |
|
|
|
536 |
'L_EDIT_CATEGORY' => $lang['Edit_Category'], |
|
|
537 |
'L_EDIT_CATEGORY_EXPLAIN' => $lang['Edit_Category_explain'], |
|
|
538 |
'L_CATEGORY' => $lang['Category'], |
|
|
539 |
|
|
|
540 |
'S_HIDDEN_FIELDS' => $s_hidden_fields, |
|
|
541 |
'S_SUBMIT_VALUE' => $buttonvalue, |
|
|
542 |
'S_FORUM_ACTION' => append_sid("admin_forums.$phpEx")) |
|
|
543 |
); |
|
|
544 |
|
|
|
545 |
$template->pparse("body"); |
|
|
546 |
break; |
|
|
547 |
|
|
|
548 |
case 'modcat': |
|
|
549 |
// Modify a category in the DB |
|
|
550 |
$sql = "UPDATE " . CATEGORIES_TABLE . " |
|
|
551 |
SET cat_title = '" . str_replace("\'", "''", $HTTP_POST_VARS['cat_title']) . "' |
|
|
552 |
WHERE cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]); |
|
|
553 |
if( !$result = $db->sql_query($sql) ) |
|
|
554 |
{ |
|
|
555 |
message_die(GENERAL_ERROR, "Couldn't update forum information", "", __LINE__, __FILE__, $sql); |
|
|
556 |
} |
|
|
557 |
|
|
|
558 |
$message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); |
|
|
559 |
|
|
|
560 |
message_die(GENERAL_MESSAGE, $message); |
|
|
561 |
|
|
|
562 |
break; |
|
|
563 |
|
|
|
564 |
case 'deleteforum': |
|
|
565 |
// Show form to delete a forum |
|
|
566 |
$forum_id = intval($HTTP_GET_VARS[POST_FORUM_URL]); |
|
|
567 |
|
|
|
568 |
$select_to = '<select name="to_id">'; |
|
|
569 |
$select_to .= "<option value=\"-1\"$s>" . $lang['Delete_all_posts'] . "</option>\n"; |
|
|
570 |
$select_to .= get_list('forum', $forum_id, 0); |
|
|
571 |
$select_to .= '</select>'; |
|
|
572 |
|
|
|
573 |
$buttonvalue = $lang['Move_and_Delete']; |
|
|
574 |
|
|
|
575 |
$newmode = 'movedelforum'; |
|
|
576 |
|
|
|
577 |
$foruminfo = get_info('forum', $forum_id); |
|
|
578 |
$name = $foruminfo['forum_name']; |
|
|
579 |
|
|
|
580 |
$template->set_filenames(array( |
|
|
581 |
"body" => "admin/forum_delete_body.tpl") |
|
|
582 |
); |
|
|
583 |
|
|
|
584 |
$s_hidden_fields = '<input type="hidden" name="mode" value="' . $newmode . '" /><input type="hidden" name="from_id" value="' . $forum_id . '" />'; |
|
|
585 |
|
|
|
586 |
$template->assign_vars(array( |
|
|
587 |
'NAME' => $name, |
|
|
588 |
|
|
|
589 |
'L_FORUM_DELETE' => $lang['Forum_delete'], |
|
|
590 |
'L_FORUM_DELETE_EXPLAIN' => $lang['Forum_delete_explain'], |
|
|
591 |
'L_MOVE_CONTENTS' => $lang['Move_contents'], |
|
|
592 |
'L_FORUM_NAME' => $lang['Forum_name'], |
|
|
593 |
|
|
|
594 |
"S_HIDDEN_FIELDS" => $s_hidden_fields, |
|
|
595 |
'S_FORUM_ACTION' => append_sid("admin_forums.$phpEx"), |
|
|
596 |
'S_SELECT_TO' => $select_to, |
|
|
597 |
'S_SUBMIT_VALUE' => $buttonvalue) |
|
|
598 |
); |
|
|
599 |
|
|
|
600 |
$template->pparse("body"); |
|
|
601 |
break; |
|
|
602 |
|
|
|
603 |
case 'movedelforum': |
|
|
604 |
// |
|
|
605 |
// Move or delete a forum in the DB |
|
|
606 |
// |
|
|
607 |
$from_id = intval($HTTP_POST_VARS['from_id']); |
|
|
608 |
$to_id = intval($HTTP_POST_VARS['to_id']); |
|
|
609 |
$delete_old = intval($HTTP_POST_VARS['delete_old']); |
|
|
610 |
|
|
|
611 |
// Either delete or move all posts in a forum |
|
|
612 |
if($to_id == -1) |
|
|
613 |
{ |
|
|
614 |
// Delete polls in this forum |
|
|
615 |
$sql = "SELECT v.vote_id |
|
|
616 |
FROM " . VOTE_DESC_TABLE . " v, " . TOPICS_TABLE . " t |
|
|
617 |
WHERE t.forum_id = $from_id |
|
|
618 |
AND v.topic_id = t.topic_id"; |
|
|
619 |
if (!($result = $db->sql_query($sql))) |
|
|
620 |
{ |
|
|
621 |
message_die(GENERAL_ERROR, "Couldn't obtain list of vote ids", "", __LINE__, __FILE__, $sql); |
|
|
622 |
} |
|
|
623 |
|
|
|
624 |
if ($row = $db->sql_fetchrow($result)) |
|
|
625 |
{ |
|
|
626 |
$vote_ids = ''; |
|
|
627 |
do |
|
|
628 |
{ |
|
|
629 |
$vote_ids = (($vote_ids != '') ? ', ' : '') . $row['vote_id']; |
|
|
630 |
} |
|
|
631 |
while ($row = $db->sql_fetchrow($result)); |
|
|
632 |
|
|
|
633 |
$sql = "DELETE FROM " . VOTE_DESC_TABLE . " |
|
|
634 |
WHERE vote_id IN ($vote_ids)"; |
|
|
635 |
$db->sql_query($sql); |
|
|
636 |
|
|
|
637 |
$sql = "DELETE FROM " . VOTE_RESULTS_TABLE . " |
|
|
638 |
WHERE vote_id IN ($vote_ids)"; |
|
|
639 |
$db->sql_query($sql); |
|
|
640 |
|
|
|
641 |
$sql = "DELETE FROM " . VOTE_USERS_TABLE . " |
|
|
642 |
WHERE vote_id IN ($vote_ids)"; |
|
|
643 |
$db->sql_query($sql); |
|
|
644 |
} |
|
|
645 |
$db->sql_freeresult($result); |
|
|
646 |
|
|
|
647 |
include($phpbb_root_path . "includes/prune.$phpEx"); |
|
|
648 |
prune($from_id, 0, true); // Delete everything from forum |
|
|
649 |
} |
|
|
650 |
else |
|
|
651 |
{ |
|
|
652 |
$sql = "SELECT * |
|
|
653 |
FROM " . FORUMS_TABLE . " |
|
|
654 |
WHERE forum_id IN ($from_id, $to_id)"; |
|
|
655 |
if( !$result = $db->sql_query($sql) ) |
|
|
656 |
{ |
|
|
657 |
message_die(GENERAL_ERROR, "Couldn't verify existence of forums", "", __LINE__, __FILE__, $sql); |
|
|
658 |
} |
|
|
659 |
|
|
|
660 |
if($db->sql_numrows($result) != 2) |
|
|
661 |
{ |
|
|
662 |
message_die(GENERAL_ERROR, "Ambiguous forum ID's", "", __LINE__, __FILE__); |
|
|
663 |
} |
|
|
664 |
$sql = "UPDATE " . TOPICS_TABLE . " |
|
|
665 |
SET forum_id = $to_id |
|
|
666 |
WHERE forum_id = $from_id"; |
|
|
667 |
if( !$result = $db->sql_query($sql) ) |
|
|
668 |
{ |
|
|
669 |
message_die(GENERAL_ERROR, "Couldn't move topics to other forum", "", __LINE__, __FILE__, $sql); |
|
|
670 |
} |
|
|
671 |
$sql = "UPDATE " . POSTS_TABLE . " |
|
|
672 |
SET forum_id = $to_id |
|
|
673 |
WHERE forum_id = $from_id"; |
|
|
674 |
if( !$result = $db->sql_query($sql) ) |
|
|
675 |
{ |
|
|
676 |
message_die(GENERAL_ERROR, "Couldn't move posts to other forum", "", __LINE__, __FILE__, $sql); |
|
|
677 |
} |
|
|
678 |
sync('forum', $to_id); |
|
|
679 |
} |
|
|
680 |
|
|
|
681 |
// Alter Mod level if appropriate - 2.0.4 |
|
|
682 |
$sql = "SELECT ug.user_id |
|
|
683 |
FROM " . AUTH_ACCESS_TABLE . " a, " . USER_GROUP_TABLE . " ug |
|
|
684 |
WHERE a.forum_id <> $from_id |
|
|
685 |
AND a.auth_mod = 1 |
|
|
686 |
AND ug.group_id = a.group_id"; |
|
|
687 |
if( !$result = $db->sql_query($sql) ) |
|
|
688 |
{ |
|
|
689 |
message_die(GENERAL_ERROR, "Couldn't obtain moderator list", "", __LINE__, __FILE__, $sql); |
|
|
690 |
} |
|
|
691 |
|
|
|
692 |
if ($row = $db->sql_fetchrow($result)) |
|
|
693 |
{ |
|
|
694 |
$user_ids = ''; |
|
|
695 |
do |
|
|
696 |
{ |
|
|
697 |
$user_ids .= (($user_ids != '') ? ', ' : '' ) . $row['user_id']; |
|
|
698 |
} |
|
|
699 |
while ($row = $db->sql_fetchrow($result)); |
|
|
700 |
|
|
|
701 |
$sql = "SELECT ug.user_id |
|
|
702 |
FROM " . AUTH_ACCESS_TABLE . " a, " . USER_GROUP_TABLE . " ug |
|
|
703 |
WHERE a.forum_id = $from_id |
|
|
704 |
AND a.auth_mod = 1 |
|
|
705 |
AND ug.group_id = a.group_id |
|
|
706 |
AND ug.user_id NOT IN ($user_ids)"; |
|
|
707 |
if( !$result2 = $db->sql_query($sql) ) |
|
|
708 |
{ |
|
|
709 |
message_die(GENERAL_ERROR, "Couldn't obtain moderator list", "", __LINE__, __FILE__, $sql); |
|
|
710 |
} |
|
|
711 |
|
|
|
712 |
if ($row = $db->sql_fetchrow($result2)) |
|
|
713 |
{ |
|
|
714 |
$user_ids = ''; |
|
|
715 |
do |
|
|
716 |
{ |
|
|
717 |
$user_ids .= (($user_ids != '') ? ', ' : '' ) . $row['user_id']; |
|
|
718 |
} |
|
|
719 |
while ($row = $db->sql_fetchrow($result2)); |
|
|
720 |
|
|
|
721 |
$sql = "UPDATE " . USERS_TABLE . " |
|
|
722 |
SET user_level = " . USER . " |
|
|
723 |
WHERE user_id IN ($user_ids) |
|
|
724 |
AND user_level <> " . ADMIN; |
|
|
725 |
$db->sql_query($sql); |
|
|
726 |
} |
|
|
727 |
$db->sql_freeresult($result); |
|
|
728 |
|
|
|
729 |
} |
|
|
730 |
$db->sql_freeresult($result2); |
|
|
731 |
|
|
|
732 |
$sql = "DELETE FROM " . FORUMS_TABLE . " |
|
|
733 |
WHERE forum_id = $from_id"; |
|
|
734 |
if( !$result = $db->sql_query($sql) ) |
|
|
735 |
{ |
|
|
736 |
message_die(GENERAL_ERROR, "Couldn't delete forum", "", __LINE__, __FILE__, $sql); |
|
|
737 |
} |
|
|
738 |
|
|
|
739 |
$sql = "DELETE FROM " . AUTH_ACCESS_TABLE . " |
|
|
740 |
WHERE forum_id = $from_id"; |
|
|
741 |
if( !$result = $db->sql_query($sql) ) |
|
|
742 |
{ |
|
|
743 |
message_die(GENERAL_ERROR, "Couldn't delete forum", "", __LINE__, __FILE__, $sql); |
|
|
744 |
} |
|
|
745 |
|
|
|
746 |
$sql = "DELETE FROM " . PRUNE_TABLE . " |
|
|
747 |
WHERE forum_id = $from_id"; |
|
|
748 |
if( !$result = $db->sql_query($sql) ) |
|
|
749 |
{ |
|
|
750 |
message_die(GENERAL_ERROR, "Couldn't delete forum prune information!", "", __LINE__, __FILE__, $sql); |
|
|
751 |
} |
|
|
752 |
|
|
|
753 |
$message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); |
|
|
754 |
|
|
|
755 |
message_die(GENERAL_MESSAGE, $message); |
|
|
756 |
|
|
|
757 |
break; |
|
|
758 |
|
|
|
759 |
case 'deletecat': |
|
|
760 |
// |
|
|
761 |
// Show form to delete a category |
|
|
762 |
// |
|
|
763 |
$cat_id = intval($HTTP_GET_VARS[POST_CAT_URL]); |
|
|
764 |
|
|
|
765 |
$buttonvalue = $lang['Move_and_Delete']; |
|
|
766 |
$newmode = 'movedelcat'; |
|
|
767 |
$catinfo = get_info('category', $cat_id); |
|
|
768 |
$name = $catinfo['cat_title']; |
|
|
769 |
|
|
|
770 |
if ($catinfo['number'] == 1) |
|
|
771 |
{ |
|
|
772 |
$sql = "SELECT count(*) as total |
|
|
773 |
FROM ". FORUMS_TABLE; |
|
|
774 |
if( !$result = $db->sql_query($sql) ) |
|
|
775 |
{ |
|
|
776 |
message_die(GENERAL_ERROR, "Couldn't get Forum count", "", __LINE__, __FILE__, $sql); |
|
|
777 |
} |
|
|
778 |
$count = $db->sql_fetchrow($result); |
|
|
779 |
$count = $count['total']; |
|
|
780 |
|
|
|
781 |
if ($count > 0) |
|
|
782 |
{ |
|
|
783 |
message_die(GENERAL_ERROR, $lang['Must_delete_forums']); |
|
|
784 |
} |
|
|
785 |
else |
|
|
786 |
{ |
|
|
787 |
$select_to = $lang['Nowhere_to_move']; |
|
|
788 |
} |
|
|
789 |
} |
|
|
790 |
else |
|
|
791 |
{ |
|
|
792 |
$select_to = '<select name="to_id">'; |
|
|
793 |
$select_to .= get_list('category', $cat_id, 0); |
|
|
794 |
$select_to .= '</select>'; |
|
|
795 |
} |
|
|
796 |
|
|
|
797 |
$template->set_filenames(array( |
|
|
798 |
"body" => "admin/forum_delete_body.tpl") |
|
|
799 |
); |
|
|
800 |
|
|
|
801 |
$s_hidden_fields = '<input type="hidden" name="mode" value="' . $newmode . '" /><input type="hidden" name="from_id" value="' . $cat_id . '" />'; |
|
|
802 |
|
|
|
803 |
$template->assign_vars(array( |
|
|
804 |
'NAME' => $name, |
|
|
805 |
|
|
|
806 |
'L_FORUM_DELETE' => $lang['Forum_delete'], |
|
|
807 |
'L_FORUM_DELETE_EXPLAIN' => $lang['Forum_delete_explain'], |
|
|
808 |
'L_MOVE_CONTENTS' => $lang['Move_contents'], |
|
|
809 |
'L_FORUM_NAME' => $lang['Forum_name'], |
|
|
810 |
|
|
|
811 |
'S_HIDDEN_FIELDS' => $s_hidden_fields, |
|
|
812 |
'S_FORUM_ACTION' => append_sid("admin_forums.$phpEx"), |
|
|
813 |
'S_SELECT_TO' => $select_to, |
|
|
814 |
'S_SUBMIT_VALUE' => $buttonvalue) |
|
|
815 |
); |
|
|
816 |
|
|
|
817 |
$template->pparse("body"); |
|
|
818 |
break; |
|
|
819 |
|
|
|
820 |
case 'movedelcat': |
|
|
821 |
// |
|
|
822 |
// Move or delete a category in the DB |
|
|
823 |
// |
|
|
824 |
$from_id = intval($HTTP_POST_VARS['from_id']); |
|
|
825 |
$to_id = intval($HTTP_POST_VARS['to_id']); |
|
|
826 |
|
|
|
827 |
if (!empty($to_id)) |
|
|
828 |
{ |
|
|
829 |
$sql = "SELECT * |
|
|
830 |
FROM " . CATEGORIES_TABLE . " |
|
|
831 |
WHERE cat_id IN ($from_id, $to_id)"; |
|
|
832 |
if( !$result = $db->sql_query($sql) ) |
|
|
833 |
{ |
|
|
834 |
message_die(GENERAL_ERROR, "Couldn't verify existence of categories", "", __LINE__, __FILE__, $sql); |
|
|
835 |
} |
|
|
836 |
if($db->sql_numrows($result) != 2) |
|
|
837 |
{ |
|
|
838 |
message_die(GENERAL_ERROR, "Ambiguous category ID's", "", __LINE__, __FILE__); |
|
|
839 |
} |
|
|
840 |
|
|
|
841 |
$sql = "UPDATE " . FORUMS_TABLE . " |
|
|
842 |
SET cat_id = $to_id |
|
|
843 |
WHERE cat_id = $from_id"; |
|
|
844 |
if( !$result = $db->sql_query($sql) ) |
|
|
845 |
{ |
|
|
846 |
message_die(GENERAL_ERROR, "Couldn't move forums to other category", "", __LINE__, __FILE__, $sql); |
|
|
847 |
} |
|
|
848 |
} |
|
|
849 |
|
|
|
850 |
$sql = "DELETE FROM " . CATEGORIES_TABLE ." |
|
|
851 |
WHERE cat_id = $from_id"; |
|
|
852 |
|
|
|
853 |
if( !$result = $db->sql_query($sql) ) |
|
|
854 |
{ |
|
|
855 |
message_die(GENERAL_ERROR, "Couldn't delete category", "", __LINE__, __FILE__, $sql); |
|
|
856 |
} |
|
|
857 |
|
|
|
858 |
$message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); |
|
|
859 |
|
|
|
860 |
message_die(GENERAL_MESSAGE, $message); |
|
|
861 |
|
|
|
862 |
break; |
|
|
863 |
|
|
|
864 |
case 'forum_order': |
|
|
865 |
// |
|
|
866 |
// Change order of forums in the DB |
|
|
867 |
// |
|
|
868 |
$move = intval($HTTP_GET_VARS['move']); |
|
|
869 |
$forum_id = intval($HTTP_GET_VARS[POST_FORUM_URL]); |
|
|
870 |
|
|
|
871 |
$forum_info = get_info('forum', $forum_id); |
|
|
872 |
|
|
|
873 |
$cat_id = $forum_info['cat_id']; |
|
|
874 |
|
|
|
875 |
$sql = "UPDATE " . FORUMS_TABLE . " |
|
|
876 |
SET forum_order = forum_order + $move |
|
|
877 |
WHERE forum_id = $forum_id"; |
|
|
878 |
if( !$result = $db->sql_query($sql) ) |
|
|
879 |
{ |
|
|
880 |
message_die(GENERAL_ERROR, "Couldn't change category order", "", __LINE__, __FILE__, $sql); |
|
|
881 |
} |
|
|
882 |
|
|
|
883 |
renumber_order('forum', $forum_info['cat_id']); |
|
|
884 |
$show_index = TRUE; |
|
|
885 |
|
|
|
886 |
break; |
|
|
887 |
|
|
|
888 |
case 'cat_order': |
|
|
889 |
// |
|
|
890 |
// Change order of categories in the DB |
|
|
891 |
// |
|
|
892 |
$move = intval($HTTP_GET_VARS['move']); |
|
|
893 |
$cat_id = intval($HTTP_GET_VARS[POST_CAT_URL]); |
|
|
894 |
|
|
|
895 |
$sql = "UPDATE " . CATEGORIES_TABLE . " |
|
|
896 |
SET cat_order = cat_order + $move |
|
|
897 |
WHERE cat_id = $cat_id"; |
|
|
898 |
if( !$result = $db->sql_query($sql) ) |
|
|
899 |
{ |
|
|
900 |
message_die(GENERAL_ERROR, "Couldn't change category order", "", __LINE__, __FILE__, $sql); |
|
|
901 |
} |
|
|
902 |
|
|
|
903 |
renumber_order('category'); |
|
|
904 |
$show_index = TRUE; |
|
|
905 |
|
|
|
906 |
break; |
|
|
907 |
|
|
|
908 |
case 'forum_sync': |
|
|
909 |
sync('forum', intval($HTTP_GET_VARS[POST_FORUM_URL])); |
|
|
910 |
$show_index = TRUE; |
|
|
911 |
|
|
|
912 |
break; |
|
|
913 |
|
|
|
914 |
default: |
|
|
915 |
message_die(GENERAL_MESSAGE, $lang['No_mode']); |
|
|
916 |
break; |
|
|
917 |
} |
|
|
918 |
|
|
|
919 |
if ($show_index != TRUE) |
|
|
920 |
{ |
|
|
921 |
include('./page_footer_admin.'.$phpEx); |
|
|
922 |
exit; |
|
|
923 |
} |
|
|
924 |
} |
|
|
925 |
|
|
|
926 |
// |
|
|
927 |
// Start page proper |
|
|
928 |
// |
|
|
929 |
$template->set_filenames(array( |
|
|
930 |
"body" => "admin/forum_admin_body.tpl") |
|
|
931 |
); |
|
|
932 |
|
|
|
933 |
$template->assign_vars(array( |
|
|
934 |
'S_FORUM_ACTION' => append_sid("admin_forums.$phpEx"), |
|
|
935 |
'L_FORUM_TITLE' => $lang['Forum_admin'], |
|
|
936 |
'L_FORUM_EXPLAIN' => $lang['Forum_admin_explain'], |
|
|
937 |
'L_CREATE_FORUM' => $lang['Create_forum'], |
|
|
938 |
'L_CREATE_CATEGORY' => $lang['Create_category'], |
|
|
939 |
'L_EDIT' => $lang['Edit'], |
|
|
940 |
'L_DELETE' => $lang['Delete'], |
|
|
941 |
'L_MOVE_UP' => $lang['Move_up'], |
|
|
942 |
'L_MOVE_DOWN' => $lang['Move_down'], |
|
|
943 |
'L_RESYNC' => $lang['Resync']) |
|
|
944 |
); |
|
|
945 |
|
|
|
946 |
$sql = "SELECT cat_id, cat_title, cat_order |
|
|
947 |
FROM " . CATEGORIES_TABLE . " |
|
|
948 |
ORDER BY cat_order"; |
|
|
949 |
if( !$q_categories = $db->sql_query($sql) ) |
|
|
950 |
{ |
|
|
951 |
message_die(GENERAL_ERROR, "Could not query categories list", "", __LINE__, __FILE__, $sql); |
|
|
952 |
} |
|
|
953 |
|
|
|
954 |
if( $total_categories = $db->sql_numrows($q_categories) ) |
|
|
955 |
{ |
|
|
956 |
$category_rows = $db->sql_fetchrowset($q_categories); |
|
|
957 |
|
|
|
958 |
$sql = "SELECT * |
|
|
959 |
FROM " . FORUMS_TABLE . " |
|
|
960 |
ORDER BY cat_id, forum_order"; |
|
|
961 |
if(!$q_forums = $db->sql_query($sql)) |
|
|
962 |
{ |
|
|
963 |
message_die(GENERAL_ERROR, "Could not query forums information", "", __LINE__, __FILE__, $sql); |
|
|
964 |
} |
|
|
965 |
|
|
|
966 |
if( $total_forums = $db->sql_numrows($q_forums) ) |
|
|
967 |
{ |
|
|
968 |
$forum_rows = $db->sql_fetchrowset($q_forums); |
|
|
969 |
} |
|
|
970 |
|
|
|
971 |
// |
|
|
972 |
// Okay, let's build the index |
|
|
973 |
// |
|
|
974 |
$gen_cat = array(); |
|
|
975 |
|
|
|
976 |
for($i = 0; $i < $total_categories; $i++) |
|
|
977 |
{ |
|
|
978 |
$cat_id = $category_rows[$i]['cat_id']; |
|
|
979 |
|
|
|
980 |
$template->assign_block_vars("catrow", array( |
|
|
981 |
'S_ADD_FORUM_SUBMIT' => "addforum[$cat_id]", |
|
|
982 |
'S_ADD_FORUM_NAME' => "forumname[$cat_id]", |
|
|
983 |
|
|
|
984 |
'CAT_ID' => $cat_id, |
|
|
985 |
'CAT_DESC' => $category_rows[$i]['cat_title'], |
|
|
986 |
|
|
|
987 |
'U_CAT_EDIT' => append_sid("admin_forums.$phpEx?mode=editcat&" . POST_CAT_URL . "=$cat_id"), |
|
|
988 |
'U_CAT_DELETE' => append_sid("admin_forums.$phpEx?mode=deletecat&" . POST_CAT_URL . "=$cat_id"), |
|
|
989 |
'U_CAT_MOVE_UP' => append_sid("admin_forums.$phpEx?mode=cat_order&move=-15&" . POST_CAT_URL . "=$cat_id"), |
|
|
990 |
'U_CAT_MOVE_DOWN' => append_sid("admin_forums.$phpEx?mode=cat_order&move=15&" . POST_CAT_URL . "=$cat_id"), |
|
|
991 |
'U_VIEWCAT' => append_sid($phpbb_root_path."index.$phpEx?" . POST_CAT_URL . "=$cat_id")) |
|
|
992 |
); |
|
|
993 |
|
|
|
994 |
for($j = 0; $j < $total_forums; $j++) |
|
|
995 |
{ |
|
|
996 |
$forum_id = $forum_rows[$j]['forum_id']; |
|
|
997 |
|
|
|
998 |
if ($forum_rows[$j]['cat_id'] == $cat_id) |
|
|
999 |
{ |
|
|
1000 |
|
|
|
1001 |
$template->assign_block_vars("catrow.forumrow", array( |
|
|
1002 |
'FORUM_NAME' => $forum_rows[$j]['forum_name'], |
|
|
1003 |
'FORUM_DESC' => $forum_rows[$j]['forum_desc'], |
|
|
1004 |
'ROW_COLOR' => $row_color, |
|
|
1005 |
'NUM_TOPICS' => $forum_rows[$j]['forum_topics'], |
|
|
1006 |
'NUM_POSTS' => $forum_rows[$j]['forum_posts'], |
|
|
1007 |
|
|
|
1008 |
'U_VIEWFORUM' => append_sid($phpbb_root_path."viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"), |
|
|
1009 |
'U_FORUM_EDIT' => append_sid("admin_forums.$phpEx?mode=editforum&" . POST_FORUM_URL . "=$forum_id"), |
|
|
1010 |
'U_FORUM_DELETE' => append_sid("admin_forums.$phpEx?mode=deleteforum&" . POST_FORUM_URL . "=$forum_id"), |
|
|
1011 |
'U_FORUM_MOVE_UP' => append_sid("admin_forums.$phpEx?mode=forum_order&move=-15&" . POST_FORUM_URL . "=$forum_id"), |
|
|
1012 |
'U_FORUM_MOVE_DOWN' => append_sid("admin_forums.$phpEx?mode=forum_order&move=15&" . POST_FORUM_URL . "=$forum_id"), |
|
|
1013 |
'U_FORUM_RESYNC' => append_sid("admin_forums.$phpEx?mode=forum_sync&" . POST_FORUM_URL . "=$forum_id")) |
|
|
1014 |
); |
|
|
1015 |
|
|
|
1016 |
}// if ... forumid == catid |
|
|
1017 |
|
|
|
1018 |
} // for ... forums |
|
|
1019 |
|
|
|
1020 |
} // for ... categories |
|
|
1021 |
|
|
|
1022 |
}// if ... total_categories |
|
|
1023 |
|
|
|
1024 |
$template->pparse("body"); |
|
|
1025 |
|
|
|
1026 |
include('./page_footer_admin.'.$phpEx); |
|
|
1027 |
|
|
|
1028 |
?> |