| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
<span class="code-comment"> * admin_forumauth.php |
|---|
| 4 |
* ------------------- |
|---|
| 5 |
* begin : Saturday, Feb 13, 2001 |
|---|
| 6 |
* copyright : (C) 2001 The phpBB Group |
|---|
| 7 |
* email : support@phpbb.com |
|---|
| 8 |
* |
|---|
| 9 |
* $Id: admin_forumauth.php,v 1.23.2.5 2004/03/25 15:57:19 acydburn Exp $ |
|---|
| 10 |
* |
|---|
| 11 |
* |
|---|
| 12 |
***************************************************************************/ |
|---|
| 13 |
|
|---|
| 14 |
/*************************************************************************** |
|---|
| 15 |
* |
|---|
| 16 |
* This program is free software; you can redistribute it and/or modify |
|---|
| 17 |
* it under the terms of the GNU General Public License as published by |
|---|
| 18 |
* the Free Software Foundation; either version 2 of the License, or |
|---|
| 19 |
* (at your option) any later version. |
|---|
| 20 |
* |
|---|
| 21 |
***************************************************************************/ |
|---|
| 22 |
|
|---|
| 23 |
if( !empty($setmodules) )</span> |
|---|
| 24 |
<span class="code-keyword">{ |
|---|
| 25 |
$filename = basename(__FILE__); |
|---|
| 26 |
$module['forums']['permissions'] = $filename; |
|---|
| 27 |
|
|---|
| 28 |
return; |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
define('IN_PHPBB', 1); |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
<span class="code-comment">// Load default header |
|---|
| 35 |
// |
|---|
| 36 |
$no_page_header = TRUE; |
|---|
| 37 |
$root_path = './../';</span> |
|---|
| 38 |
<span class="code-lang">require($root_path . 'extension.inc'); |
|---|
| 39 |
require('./pagestart.' . $phpEx); |
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
<span class="code-comment">// Start program - define vars |
|---|
| 43 |
// |
|---|
| 44 |
// View Read Post Reply Edit Delete Sticky Announce Vote Poll |
|---|
| 45 |
$simple_auth_ary = array(</span> |
|---|
| 46 |
<span class="code-lang"> 0 => array(AUTH_ALL, AUTH_ALL, AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_REG, AUTH_REG), |
|---|
| 47 |
1 => array(AUTH_ALL, AUTH_ALL, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_REG, AUTH_REG), |
|---|
| 48 |
2 => array(AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_REG, AUTH_MOD, AUTH_MOD, AUTH_REG, AUTH_REG), |
|---|
| 49 |
3 => array(AUTH_ALL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_ACL, AUTH_ACL), |
|---|
| 50 |
4 => array(AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_ACL, AUTH_MOD, AUTH_ACL, AUTH_ACL), |
|---|
| 51 |
5 => array(AUTH_ALL, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD), |
|---|
| 52 |
6 => array(AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD, AUTH_MOD), |
|---|
| 53 |
); |
|---|
| 54 |
|
|---|
| 55 |
$simple_auth_types = array($lang['public'], $lang['registered'], $lang['registered'] . ' [' . $lang['hidden'] . ']', $lang['private'], $lang['private'] . ' [' . $lang['hidden'] . ']', $lang['moderators'], $lang['moderators'] . ' [' . $lang['hidden'] . ']'); |
|---|
| 56 |
|
|---|
| 57 |
$forum_auth_fields = array('auth_view', 'auth_read', 'auth_post', 'auth_reply', 'auth_edit', 'auth_delete', 'auth_sticky', 'auth_announce', 'auth_vote', 'auth_pollcreate'); |
|---|
| 58 |
|
|---|
| 59 |
$field_names = array(</span> |
|---|
| 60 |
<span class="code-lang"> 'auth_view' => $lang['view'], |
|---|
| 61 |
'auth_read' => $lang['read'], |
|---|
| 62 |
'auth_post' => $lang['post'], |
|---|
| 63 |
'auth_reply' => $lang['reply'], |
|---|
| 64 |
'auth_edit' => $lang['edit'], |
|---|
| 65 |
'auth_delete' => $lang['delete'], |
|---|
| 66 |
'auth_sticky' => $lang['sticky'], |
|---|
| 67 |
'auth_announce' => $lang['announce'], |
|---|
| 68 |
'auth_vote' => $lang['vote'], |
|---|
| 69 |
'auth_pollcreate' => $lang['pollcreate']); |
|---|
| 70 |
|
|---|
| 71 |
$forum_auth_levels = array('ALL', 'REG', 'PRIVATE', 'MOD', 'ADMIN'); |
|---|
| 72 |
$forum_auth_const = array(AUTH_ALL, AUTH_REG, AUTH_ACL, AUTH_MOD, AUTH_ADMIN);</span> |
|---|
| 73 |
<span class="code-lang"> |
|---|
| 74 |
if(isset($_GET[POST_FORUM_URL]) || isset($_POST[POST_FORUM_URL])) |
|---|
| 75 |
{ |
|---|
| 76 |
$forum_id = (isset($_POST[POST_FORUM_URL])) ? intval($_POST[POST_FORUM_URL]) : intval($_GET[POST_FORUM_URL]); |
|---|
| 77 |
$forum_sql = "AND forum_id = $forum_id"; |
|---|
| 78 |
} |
|---|
| 79 |
else |
|---|
| 80 |
{ |
|---|
| 81 |
unset($forum_id); |
|---|
| 82 |
$forum_sql = ''; |
|---|
| 83 |
} |
|---|
| 84 |
|
|---|
| 85 |
if( isset($_GET['adv']) ) |
|---|
| 86 |
{ |
|---|
| 87 |
$adv = intval($_GET['adv']); |
|---|
| 88 |
} |
|---|
| 89 |
else |
|---|
| 90 |
{ |
|---|
| 91 |
unset($adv); |
|---|
| 92 |
} |
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
<span class="code-comment">// Start program proper |
|---|
| 96 |
// |
|---|
| 97 |
if( isset($_POST['submit']) )</span> |
|---|
| 98 |
<span class="code-keyword">{ |
|---|
| 99 |
$sql = ''; |
|---|
| 100 |
|
|---|
| 101 |
if(!empty($forum_id)) |
|---|
| 102 |
{ |
|---|
| 103 |
if(isset($_POST['simpleauth'])) |
|---|
| 104 |
{ |
|---|
| 105 |
$simple_ary = $simple_auth_ary[intval($_POST['simpleauth'])]; |
|---|
| 106 |
|
|---|
| 107 |
for($i = 0; $i < count($simple_ary); $i++) |
|---|
| 108 |
{ |
|---|
| 109 |
$sql .= ( ( $sql != '' ) ? ', ' : '' ) . $forum_auth_fields[$i] . ' = ' . $simple_ary[$i]; |
|---|
| 110 |
} |
|---|
| 111 |
|
|---|
| 112 |
if (is_array($simple_ary)) |
|---|
| 113 |
{ |
|---|
| 114 |
$sql = "UPDATE " . FORUMS_TABLE . " SET $sql WHERE forum_id = $forum_id"; |
|---|
| 115 |
} |
|---|
| 116 |
} |
|---|
| 117 |
else |
|---|
| 118 |
{ |
|---|
| 119 |
for($i = 0; $i < count($forum_auth_fields); $i++) |
|---|
| 120 |
{ |
|---|
| 121 |
$value = intval($_POST[$forum_auth_fields[$i]]); |
|---|
| 122 |
|
|---|
| 123 |
if ( $forum_auth_fields[$i] == 'auth_vote' ) |
|---|
| 124 |
{ |
|---|
| 125 |
if ( $_POST['auth_vote'] == AUTH_ALL ) |
|---|
| 126 |
{ |
|---|
| 127 |
$value = AUTH_REG; |
|---|
| 128 |
} |
|---|
| 129 |
} |
|---|
| 130 |
|
|---|
| 131 |
$sql .= ( ( $sql != '' ) ? ', ' : '' ) .$forum_auth_fields[$i] . ' = ' . $value; |
|---|
| 132 |
} |
|---|
| 133 |
|
|---|
| 134 |
$sql = "UPDATE " . FORUMS_TABLE . " SET $sql WHERE forum_id = $forum_id"; |
|---|
| 135 |
} |
|---|
| 136 |
|
|---|
| 137 |
if ( $sql != '' ) |
|---|
| 138 |
{ |
|---|
| 139 |
$db->sql_query($sql); |
|---|
| 140 |
} |
|---|
| 141 |
|
|---|
| 142 |
$forum_sql = ''; |
|---|
| 143 |
$adv = 0; |
|---|
| 144 |
} |
|---|
| 145 |
|
|---|
| 146 |
meta_refresh(3, append_sid("admin_forumauth.$phpEx?" . POST_FORUM_URL . "=$forum_id")); |
|---|
| 147 |
$message = $lang['forum_auth_updated'] . '<br /><br />' . sprintf($lang['click_return_forumauth'], '<a href="' . append_sid("admin_forumauth.$phpEx") . '">', "</a>"); |
|---|
| 148 |
trigger_error($message); |
|---|
| 149 |
return; |
|---|
| 150 |
|
|---|
| 151 |
} |
|---|
| 152 |
|
|---|
| 153 |
// |
|---|
| 154 |
// Get required information, either all forums if |
|---|
| 155 |
// no id was specified or just the requsted if it |
|---|
| 156 |
// was |
|---|
| 157 |
// |
|---|
| 158 |
$sql = "SELECT f.*</span> |
|---|
| 159 |
<span class="code-lang"> FROM " . FORUMS_TABLE . " f, " . FORUM_CATEGORIES_TABLE . " c |
|---|
| 160 |
WHERE c.cat_id = f.cat_id |
|---|
| 161 |
$forum_sql |
|---|
| 162 |
ORDER BY c.cat_order ASC, f.forum_order ASC"; |
|---|
| 163 |
$result = $db->sql_query($sql); |
|---|
| 164 |
|
|---|
| 165 |
$forum_rows = $db->sql_fetchrowset($result); |
|---|
| 166 |
$db->sql_freeresult($result);</span> |
|---|
| 167 |
<span class="code-lang"> |
|---|
| 168 |
if( empty($forum_id) ) |
|---|
| 169 |
{ |
|---|
| 170 |
|
|---|
| 171 |
// Output the selection table if no forum id was |
|---|
| 172 |
// specified |
|---|
| 173 |
// |
|---|
| 174 |
$template->set_filenames(array( |
|---|
| 175 |
'body' => '../admin/auth_select_body.tpl') |
|---|
| 176 |
); |
|---|
| 177 |
|
|---|
| 178 |
$select_list = '<select name="' . POST_FORUM_URL . '">'; |
|---|
| 179 |
for($i = 0; $i < count($forum_rows); $i++) |
|---|
| 180 |
{ |
|---|
| 181 |
if( !$forum_rows[$i]['forum_parent'] ) |
|---|
| 182 |
{ |
|---|
| 183 |
|
|---|
| 184 |
$select_list .= '<option value="' . $forum_rows[$i]['forum_id'] . '">' . $forum_rows[$i]['forum_name'] . '</option>'; |
|---|
| 185 |
|
|---|
| 186 |
$parent_id = $forum_rows[$i]['forum_id']; |
|---|
| 187 |
for( $j = 0; $j < count($forum_rows); $j++ ) |
|---|
| 188 |
{ |
|---|
| 189 |
if( $forum_rows[$j]['forum_parent'] == $parent_id ) |
|---|
| 190 |
{ |
|---|
| 191 |
$select_list .= '<option value="' . $forum_rows[$j]['forum_id'] . '">-- ' . $forum_rows[$j]['forum_name'] . '</option>'; |
|---|
| 192 |
} |
|---|
| 193 |
} |
|---|
| 194 |
} |
|---|
| 195 |
|
|---|
| 196 |
} |
|---|
| 197 |
$select_list .= '</select>'; |
|---|
| 198 |
|
|---|
| 199 |
$template->assign_vars(array( |
|---|
| 200 |
'L_AUTH_TITLE' => $lang['auth_control_forum'], |
|---|
| 201 |
'L_AUTH_EXPLAIN' => $lang['forum_auth_explain'], |
|---|
| 202 |
'L_AUTH_SELECT' => $lang['select_a_forum'], |
|---|
| 203 |
'L_LOOK_UP' => $lang['look_up_forum'], |
|---|
| 204 |
|
|---|
| 205 |
'S_AUTH_ACTION' => append_sid("admin_forumauth.$phpEx"), |
|---|
| 206 |
'S_AUTH_SELECT' => $select_list) |
|---|
| 207 |
); |
|---|
| 208 |
|
|---|
| 209 |
} |
|---|
| 210 |
else |
|---|
| 211 |
{ |
|---|
| 212 |
|
|---|
| 213 |
// Output the authorisation details if an id was |
|---|
| 214 |
// specified |
|---|
| 215 |
// |
|---|
| 216 |
$template->set_filenames(array( |
|---|
| 217 |
'body' => '../admin/auth_forum_body.tpl') |
|---|
| 218 |
); |
|---|
| 219 |
|
|---|
| 220 |
$forum_name = $forum_rows[0]['forum_name']; |
|---|
| 221 |
|
|---|
| 222 |
@reset($simple_auth_ary); |
|---|
| 223 |
while( list($key, $auth_levels) = each($simple_auth_ary)) |
|---|
| 224 |
{ |
|---|
| 225 |
$matched = 1; |
|---|
| 226 |
for($k = 0; $k < count($auth_levels); $k++) |
|---|
| 227 |
{ |
|---|
| 228 |
$matched_type = $key; |
|---|
| 229 |
|
|---|
| 230 |
if ( $forum_rows[0][$forum_auth_fields[$k]] != $auth_levels[$k] ) |
|---|
| 231 |
{ |
|---|
| 232 |
$matched = 0; |
|---|
| 233 |
} |
|---|
| 234 |
} |
|---|
| 235 |
|
|---|
| 236 |
if ( $matched ) |
|---|
| 237 |
{ |
|---|
| 238 |
break; |
|---|
| 239 |
} |
|---|
| 240 |
} |
|---|
| 241 |
|
|---|
| 242 |
|
|---|
| 243 |
// If we didn't get a match above then we |
|---|
| 244 |
// automatically switch into 'advanced' mode |
|---|
| 245 |
// |
|---|
| 246 |
if ( !isset($adv) && !$matched ) |
|---|
| 247 |
{ |
|---|
| 248 |
$adv = 1; |
|---|
| 249 |
} |
|---|
| 250 |
|
|---|
| 251 |
$s_column_span = 0; |
|---|
| 252 |
|
|---|
| 253 |
if ( empty($adv) ) |
|---|
| 254 |
{ |
|---|
| 255 |
$simple_auth = '<select name="simpleauth">'; |
|---|
| 256 |
|
|---|
| 257 |
for($j = 0; $j < count($simple_auth_types); $j++) |
|---|
| 258 |
{ |
|---|
| 259 |
$selected = ( $matched_type == $j ) ? ' selected="selected"' : ''; |
|---|
| 260 |
$simple_auth .= '<option value="' . $j . '"' . $selected . '>' . $simple_auth_types[$j] . '</option>'; |
|---|
| 261 |
} |
|---|
| 262 |
|
|---|
| 263 |
$simple_auth .= '</select>'; |
|---|
| 264 |
|
|---|
| 265 |
$template->assign_block_vars('forum_auth_titles', array( |
|---|
| 266 |
'CELL_TITLE' => $lang['simple_mode']) |
|---|
| 267 |
); |
|---|
| 268 |
$template->assign_block_vars('forum_auth_data', array( |
|---|
| 269 |
'S_AUTH_LEVELS_SELECT' => $simple_auth) |
|---|
| 270 |
); |
|---|
| 271 |
|
|---|
| 272 |
$s_column_span++; |
|---|
| 273 |
} |
|---|
| 274 |
else |
|---|
| 275 |
{ |
|---|
| 276 |
|
|---|
| 277 |
// Output values of individual |
|---|
| 278 |
// fields |
|---|
| 279 |
// |
|---|
| 280 |
for($j = 0; $j < count($forum_auth_fields); $j++) |
|---|
| 281 |
{ |
|---|
| 282 |
$custom_auth[$j] = ' <select name="' . $forum_auth_fields[$j] . '">'; |
|---|
| 283 |
|
|---|
| 284 |
for($k = 0; $k < count($forum_auth_levels); $k++) |
|---|
| 285 |
{ |
|---|
| 286 |
$selected = ( $forum_rows[0][$forum_auth_fields[$j]] == $forum_auth_const[$k] ) ? ' selected="selected"' : ''; |
|---|
| 287 |
$custom_auth[$j] .= '<option value="' . $forum_auth_const[$k] . '"' . $selected . '>' . $lang['forum_auth_' . strtolower($forum_auth_levels[$k])] . '</option>'; |
|---|
| 288 |
} |
|---|
| 289 |
$custom_auth[$j] .= '</select> '; |
|---|
| 290 |
|
|---|
| 291 |
$cell_title = $field_names[$forum_auth_fields[$j]]; |
|---|
| 292 |
|
|---|
| 293 |
$template->assign_block_vars('forum_auth_titles', array( |
|---|
| 294 |
'CELL_TITLE' => $cell_title) |
|---|
| 295 |
); |
|---|
| 296 |
$template->assign_block_vars('forum_auth_data', array( |
|---|
| 297 |
'S_AUTH_LEVELS_SELECT' => $custom_auth[$j]) |
|---|
| 298 |
); |
|---|
| 299 |
|
|---|
| 300 |
$s_column_span++; |
|---|
| 301 |
} |
|---|
| 302 |
} |
|---|
| 303 |
|
|---|
| 304 |
$adv_mode = ( empty($adv) ) ? '1' : '0'; |
|---|
| 305 |
$switch_mode = append_sid("admin_forumauth.$phpEx?" . POST_FORUM_URL . "=" . $forum_id . "&adv=". $adv_mode); |
|---|
| 306 |
$switch_mode_text = ( empty($adv) ) ? $lang['advanced_mode'] : $lang['simple_mode']; |
|---|
| 307 |
$u_switch_mode = '<a href="' . $switch_mode . '">' . $switch_mode_text . '</a>'; |
|---|
| 308 |
|
|---|
| 309 |
$s_hidden_fields = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '">'; |
|---|
| 310 |
|
|---|
| 311 |
$template->assign_vars(array( |
|---|
| 312 |
'FORUM_NAME' => $forum_name, |
|---|
| 313 |
|
|---|
| 314 |
'L_FORUM' => $lang['forum'], |
|---|
| 315 |
'L_AUTH_TITLE' => $lang['auth_control_forum'], |
|---|
| 316 |
'L_AUTH_EXPLAIN' => $lang['forum_auth_explain'], |
|---|
| 317 |
'L_SUBMIT' => $lang['submit'], |
|---|
| 318 |
'L_RESET' => $lang['reset'], |
|---|
| 319 |
|
|---|
| 320 |
'U_SWITCH_MODE' => $u_switch_mode, |
|---|
| 321 |
|
|---|
| 322 |
'S_FORUMAUTH_ACTION' => append_sid("admin_forumauth.$phpEx"), |
|---|
| 323 |
'S_COLUMN_SPAN' => $s_column_span, |
|---|
| 324 |
'S_HIDDEN_FIELDS' => $s_hidden_fields) |
|---|
| 325 |
); |
|---|
| 326 |
|
|---|
| 327 |
} |
|---|
| 328 |
|
|---|
| 329 |
include('./page_header_admin.'.$phpEx); |
|---|
| 330 |
|
|---|
| 331 |
$template->display('body');</span> |
|---|
| 332 |
<span class="code-lang"> |
|---|
| 333 |
include('./page_footer_admin.'.$phpEx); |
|---|
| 334 |
|
|---|
| 335 |
?> |
|---|