/dev/null |
b/admin_bans.php |
| 1: <?php |
| 2: |
| 3: /** |
| 4: * Copyright (C) 2008-2012 FluxBB |
| 5: * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB |
| 6: * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher |
| 7: */ |
| 8: |
| 9: // Tell header.php to use the admin template |
| 10: define('PUN_ADMIN_CONSOLE', 1); |
| 11: |
| 12: define('PUN_ROOT', dirname(__FILE__).'/'); |
| 13: require PUN_ROOT.'include/common.php'; |
| 14: require PUN_ROOT.'include/common_admin.php'; |
| 15: |
| 16: |
| 17: if ($pun_user['g_id'] != PUN_ADMIN && ($pun_user['g_moderator'] != '1' || $pun_user['g_mod_ban_users'] == '0')) |
| 18: message($lang_common['No permission'], false, '403 Forbidden'); |
| 19: |
| 20: // Load the admin_bans.php language file |
| 21: require PUN_ROOT.'lang/'.$admin_language.'/admin_bans.php'; |
| 22: |
| 23: // Add/edit a ban (stage 1) |
| 24: if (isset($_REQUEST['add_ban']) || isset($_GET['edit_ban'])) |
| 25: { |
| 26: if (isset($_GET['add_ban']) || isset($_POST['add_ban'])) |
| 27: { |
| 28: // If the ID of the user to ban was provided through GET (a link from profile.php) |
| 29: if (isset($_GET['add_ban'])) |
| 30: { |
| 31: $user_id = intval($_GET['add_ban']); |
| 32: if ($user_id < 2) |
| 33: message($lang_common['Bad request']); |
| 34: |
| 35: $result = $db->query('SELECT group_id, username, email FROM '.$db->prefix.'users WHERE id='.$user_id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
| 36: if ($db->num_rows($result)) |
| 37: list($group_id, $ban_user, $ban_email) = $db->fetch_row($result); |
| 38: else |
| 39: message($lang_admin_bans['No user ID message']); |
| 40: } |
| 41: else // Otherwise the username is in POST |
| 42: { |
| 43: $ban_user = pun_trim($_POST['new_ban_user']); |
| 44: |
| 45: if ($ban_user != '') |
| 46: { |
| 47: $result = $db->query('SELECT id, group_id, username, email FROM '.$db->prefix.'users WHERE username=\''.$db->escape($ban_user).'\' AND id>1') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
| 48: if ($db->num_rows($result)) |
| 49: list($user_id, $group_id, $ban_user, $ban_email) = $db->fetch_row($result); |
| 50: else |
| 51: message($lang_admin_bans['No user message']); |
| 52: } |
| 53: } |
| 54: |
| 55: // Make sure we're not banning an admin or moderator |
| 56: if (isset($group_id)) |
| 57: { |
| 58: if ($group_id == PUN_ADMIN) |
| 59: message(sprintf($lang_admin_bans['User is admin message'], pun_htmlspecialchars($ban_user))); |
| 60: |
| 61: $result = $db->query('SELECT g_moderator FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to fetch group info', __FILE__, __LINE__, $db->error()); |
| 62: $is_moderator_group = $db->result($result); |
| 63: |
| 64: if ($is_moderator_group) |
| 65: message(sprintf($lang_admin_bans['User is mod message'], pun_htmlspecialchars($ban_user))); |
| 66: } |
| 67: |
| 68: // If we have a $user_id, we can try to find the last known IP of that user |
| 69: if (isset($user_id)) |
| 70: { |
| 71: $result = $db->query('SELECT poster_ip FROM '.$db->prefix.'posts WHERE poster_id='.$user_id.' ORDER BY posted DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
| 72: $ban_ip = ($db->num_rows($result)) ? $db->result($result) : ''; |
| 73: |
| 74: if ($ban_ip == '') |
| 75: { |
| 76: $result = $db->query('SELECT registration_ip FROM '.$db->prefix.'users WHERE id='.$user_id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
| 77: $ban_ip = ($db->num_rows($result)) ? $db->result($result) : ''; |
| 78: } |
| 79: } |
| 80: |
| 81: $mode = 'add'; |
| 82: } |
| 83: else // We are editing a ban |
| 84: { |
| 85: $ban_id = intval($_GET['edit_ban']); |
| 86: if ($ban_id < 1) |
| 87: message($lang_common['Bad request']); |
| 88: |
| 89: $result = $db->query('SELECT username, ip, email, message, expire FROM '.$db->prefix.'bans WHERE id='.$ban_id) or error('Unable to fetch ban info', __FILE__, __LINE__, $db->error()); |
| 90: if ($db->num_rows($result)) |
| 91: list($ban_user, $ban_ip, $ban_email, $ban_message, $ban_expire) = $db->fetch_row($result); |
| 92: else |
| 93: message($lang_common['Bad request']); |
| 94: |
| 95: $diff = ($pun_user['timezone'] + $pun_user['dst']) * 3600; |
| 96: $ban_expire = ($ban_expire != '') ? gmdate('Y-m-d', $ban_expire + $diff) : ''; |
| 97: |
| 98: $mode = 'edit'; |
| 99: } |
| 100: |
| 101: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Bans']); |
| 102: $focus_element = array('bans2', 'ban_user'); |
| 103: define('PUN_ACTIVE_PAGE', 'admin'); |
| 104: require PUN_ROOT.'header.php'; |
| 105: |
| 106: generate_admin_menu('bans'); |
| 107: |
| 108: ?> |
| 109: <div class="blockform"> |
| 110: <h2><span><?php echo $lang_admin_bans['Ban advanced head'] ?></span></h2> |
| 111: <div class="box"> |
| 112: <form id="bans2" method="post" action="admin_bans.php"> |
| 113: <div class="inform"> |
| 114: <input type="hidden" name="mode" value="<?php echo $mode ?>" /> |
| 115: <?php if ($mode == 'edit'): ?> <input type="hidden" name="ban_id" value="<?php echo $ban_id ?>" /> |
| 116: <?php endif; ?> <fieldset> |
| 117: <legend><?php echo $lang_admin_bans['Ban advanced subhead'] ?></legend> |
| 118: <div class="infldset"> |
| 119: <table class="aligntop" cellspacing="0"> |
| 120: <tr> |
| 121: <th scope="row"><?php echo $lang_admin_bans['Username label'] ?></th> |
| 122: <td> |
| 123: <input type="text" name="ban_user" size="25" maxlength="25" value="<?php if (isset($ban_user)) echo pun_htmlspecialchars($ban_user); ?>" tabindex="1" /> |
| 124: <span><?php echo $lang_admin_bans['Username help'] ?></span> |
| 125: </td> |
| 126: </tr> |
| 127: <tr> |
| 128: <th scope="row"><?php echo $lang_admin_bans['IP label'] ?></th> |
| 129: <td> |
| 130: <input type="text" name="ban_ip" size="45" maxlength="255" value="<?php if (isset($ban_ip)) echo $ban_ip; ?>" tabindex="2" /> |
| 131: <span><?php echo $lang_admin_bans['IP help'] ?><?php if ($ban_user != '' && isset($user_id)) printf(' '.$lang_admin_bans['IP help link'], '<a href="admin_users.php?ip_stats='.$user_id.'">'.$lang_admin_common['here'].'</a>') ?></span> |
| 132: </td> |
| 133: </tr> |
| 134: <tr> |
| 135: <th scope="row"><?php echo $lang_admin_bans['E-mail label'] ?></th> |
| 136: <td> |
| 137: <input type="text" name="ban_email" size="40" maxlength="80" value="<?php if (isset($ban_email)) echo $ban_email; ?>" tabindex="3" /> |
| 138: <span><?php echo $lang_admin_bans['E-mail help'] ?></span> |
| 139: </td> |
| 140: </tr> |
| 141: </table> |
| 142: <p class="topspace"><strong class="warntext"><?php echo $lang_admin_bans['Ban IP range info'] ?></strong></p> |
| 143: </div> |
| 144: </fieldset> |
| 145: </div> |
| 146: <div class="inform"> |
| 147: <fieldset> |
| 148: <legend><?php echo $lang_admin_bans['Message expiry subhead'] ?></legend> |
| 149: <div class="infldset"> |
| 150: <table class="aligntop" cellspacing="0"> |
| 151: <tr> |
| 152: <th scope="row"><?php echo $lang_admin_bans['Ban message label'] ?></th> |
| 153: <td> |
| 154: <input type="text" name="ban_message" size="50" maxlength="255" value="<?php if (isset($ban_message)) echo pun_htmlspecialchars($ban_message); ?>" tabindex="4" /> |
| 155: <span><?php echo $lang_admin_bans['Ban message help'] ?></span> |
| 156: </td> |
| 157: </tr> |
| 158: <tr> |
| 159: <th scope="row"><?php echo $lang_admin_bans['Expire date label'] ?></th> |
| 160: <td> |
| 161: <input type="text" name="ban_expire" size="17" maxlength="10" value="<?php if (isset($ban_expire)) echo $ban_expire; ?>" tabindex="5" /> |
| 162: <span><?php echo $lang_admin_bans['Expire date help'] ?></span> |
| 163: </td> |
| 164: </tr> |
| 165: </table> |
| 166: </div> |
| 167: </fieldset> |
| 168: </div> |
| 169: <p class="submitend"><input type="submit" name="add_edit_ban" value="<?php echo $lang_admin_common['Save'] ?>" tabindex="6" /></p> |
| 170: </form> |
| 171: </div> |
| 172: </div> |
| 173: <div class="clearer"></div> |
| 174: </div> |
| 175: <?php |
| 176: |
| 177: require PUN_ROOT.'footer.php'; |
| 178: } |
| 179: |
| 180: // Add/edit a ban (stage 2) |
| 181: else if (isset($_POST['add_edit_ban'])) |
| 182: { |
| 183: confirm_referrer('admin_bans.php'); |
| 184: |
| 185: $ban_user = pun_trim($_POST['ban_user']); |
| 186: $ban_ip = pun_trim($_POST['ban_ip']); |
| 187: $ban_email = strtolower(pun_trim($_POST['ban_email'])); |
| 188: $ban_message = pun_trim($_POST['ban_message']); |
| 189: $ban_expire = pun_trim($_POST['ban_expire']); |
| 190: |
| 191: if ($ban_user == '' && $ban_ip == '' && $ban_email == '') |
| 192: message($lang_admin_bans['Must enter message']); |
| 193: else if (strtolower($ban_user) == 'guest') |
| 194: message($lang_admin_bans['Cannot ban guest message']); |
| 195: |
| 196: // Make sure we're not banning an admin or moderator |
| 197: if (!empty($ban_user)) |
| 198: { |
| 199: $result = $db->query('SELECT group_id FROM '.$db->prefix.'users WHERE username=\''.$db->escape($ban_user).'\' AND id>1') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
| 200: if ($db->num_rows($result)) |
| 201: { |
| 202: $group_id = $db->result($result); |
| 203: |
| 204: if ($group_id == PUN_ADMIN) |
| 205: message(sprintf($lang_admin_bans['User is admin message'], pun_htmlspecialchars($ban_user))); |
| 206: |
| 207: $result = $db->query('SELECT g_moderator FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to fetch group info', __FILE__, __LINE__, $db->error()); |
| 208: $is_moderator_group = $db->result($result); |
| 209: |
| 210: if ($is_moderator_group) |
| 211: message(sprintf($lang_admin_bans['User is mod message'], pun_htmlspecialchars($ban_user))); |
| 212: } |
| 213: } |
| 214: |
| 215: // Validate IP/IP range (it's overkill, I know) |
| 216: if ($ban_ip != '') |
| 217: { |
| 218: $ban_ip = preg_replace('%\s{2,}%S', ' ', $ban_ip); |
| 219: $addresses = explode(' ', $ban_ip); |
| 220: $addresses = array_map('pun_trim', $addresses); |
| 221: |
| 222: for ($i = 0; $i < count($addresses); ++$i) |
| 223: { |
| 224: if (strpos($addresses[$i], ':') !== false) |
| 225: { |
| 226: $octets = explode(':', $addresses[$i]); |
| 227: |
| 228: for ($c = 0; $c < count($octets); ++$c) |
| 229: { |
| 230: $octets[$c] = ltrim($octets[$c], "0"); |
| 231: |
| 232: if ($c > 7 || (!empty($octets[$c]) && !ctype_xdigit($octets[$c])) || intval($octets[$c], 16) > 65535) |
| 233: message($lang_admin_bans['Invalid IP message']); |
| 234: } |
| 235: |
| 236: $cur_address = implode(':', $octets); |
| 237: $addresses[$i] = $cur_address; |
| 238: } |
| 239: else |
| 240: { |
| 241: $octets = explode('.', $addresses[$i]); |
| 242: |
| 243: for ($c = 0; $c < count($octets); ++$c) |
| 244: { |
| 245: $octets[$c] = (strlen($octets[$c]) > 1) ? ltrim($octets[$c], "0") : $octets[$c]; |
| 246: |
| 247: if ($c > 3 || preg_match('%[^0-9]%', $octets[$c]) || intval($octets[$c]) > 255) |
| 248: message($lang_admin_bans['Invalid IP message']); |
| 249: } |
| 250: |
| 251: $cur_address = implode('.', $octets); |
| 252: $addresses[$i] = $cur_address; |
| 253: } |
| 254: } |
| 255: |
| 256: $ban_ip = implode(' ', $addresses); |
| 257: } |
| 258: |
| 259: require PUN_ROOT.'include/email.php'; |
| 260: if ($ban_email != '' && !is_valid_email($ban_email)) |
| 261: { |
| 262: if (!preg_match('%^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$%', $ban_email)) |
| 263: message($lang_admin_bans['Invalid e-mail message']); |
| 264: } |
| 265: |
| 266: if ($ban_expire != '' && $ban_expire != 'Never') |
| 267: { |
| 268: $ban_expire = strtotime($ban_expire.' GMT'); |
| 269: |
| 270: if ($ban_expire == -1 || !$ban_expire) |
| 271: message($lang_admin_bans['Invalid date message'].' '.$lang_admin_bans['Invalid date reasons']); |
| 272: |
| 273: $diff = ($pun_user['timezone'] + $pun_user['dst']) * 3600; |
| 274: $ban_expire -= $diff; |
| 275: |
| 276: if ($ban_expire <= time()) |
| 277: message($lang_admin_bans['Invalid date message'].' '.$lang_admin_bans['Invalid date reasons']); |
| 278: } |
| 279: else |
| 280: $ban_expire = 'NULL'; |
| 281: |
| 282: $ban_user = ($ban_user != '') ? '\''.$db->escape($ban_user).'\'' : 'NULL'; |
| 283: $ban_ip = ($ban_ip != '') ? '\''.$db->escape($ban_ip).'\'' : 'NULL'; |
| 284: $ban_email = ($ban_email != '') ? '\''.$db->escape($ban_email).'\'' : 'NULL'; |
| 285: $ban_message = ($ban_message != '') ? '\''.$db->escape($ban_message).'\'' : 'NULL'; |
| 286: |
| 287: if ($_POST['mode'] == 'add') |
| 288: $db->query('INSERT INTO '.$db->prefix.'bans (username, ip, email, message, expire, ban_creator) VALUES('.$ban_user.', '.$ban_ip.', '.$ban_email.', '.$ban_message.', '.$ban_expire.', '.$pun_user['id'].')') or error('Unable to add ban', __FILE__, __LINE__, $db->error()); |
| 289: else |
| 290: $db->query('UPDATE '.$db->prefix.'bans SET username='.$ban_user.', ip='.$ban_ip.', email='.$ban_email.', message='.$ban_message.', expire='.$ban_expire.' WHERE id='.intval($_POST['ban_id'])) or error('Unable to update ban', __FILE__, __LINE__, $db->error()); |
| 291: |
| 292: // Regenerate the bans cache |
| 293: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| 294: require PUN_ROOT.'include/cache.php'; |
| 295: |
| 296: generate_bans_cache(); |
| 297: |
| 298: if ($_POST['mode'] == 'edit') |
| 299: redirect('admin_bans.php', $lang_admin_bans['Ban edited redirect']); |
| 300: else |
| 301: redirect('admin_bans.php', $lang_admin_bans['Ban added redirect']); |
| 302: } |
| 303: |
| 304: // Remove a ban |
| 305: else if (isset($_GET['del_ban'])) |
| 306: { |
| 307: confirm_referrer('admin_bans.php'); |
| 308: |
| 309: $ban_id = intval($_GET['del_ban']); |
| 310: if ($ban_id < 1) |
| 311: message($lang_common['Bad request']); |
| 312: |
| 313: $db->query('DELETE FROM '.$db->prefix.'bans WHERE id='.$ban_id) or error('Unable to delete ban', __FILE__, __LINE__, $db->error()); |
| 314: |
| 315: // Regenerate the bans cache |
| 316: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| 317: require PUN_ROOT.'include/cache.php'; |
| 318: |
| 319: generate_bans_cache(); |
| 320: |
| 321: redirect('admin_bans.php', $lang_admin_bans['Ban removed redirect']); |
| 322: } |
| 323: |
| 324: // Find bans |
| 325: else if (isset($_GET['find_ban'])) |
| 326: { |
| 327: $form = isset($_GET['form']) ? $_GET['form'] : array(); |
| 328: |
| 329: // trim() all elements in $form |
| 330: $form = array_map('pun_trim', $form); |
| 331: $conditions = $query_str = array(); |
| 332: |
| 333: $expire_after = isset($_GET['expire_after']) ? pun_trim($_GET['expire_after']) : ''; |
| 334: $expire_before = isset($_GET['expire_before']) ? pun_trim($_GET['expire_before']) : ''; |
| 335: $order_by = isset($_GET['order_by']) && in_array($_GET['order_by'], array('username', 'ip', 'email', 'expire')) ? 'b.'.$_GET['order_by'] : 'b.username'; |
| 336: $direction = isset($_GET['direction']) && $_GET['direction'] == 'DESC' ? 'DESC' : 'ASC'; |
| 337: |
| 338: $query_str[] = 'order_by='.$order_by; |
| 339: $query_str[] = 'direction='.$direction; |
| 340: |
| 341: // Try to convert date/time to timestamps |
| 342: if ($expire_after != '') |
| 343: { |
| 344: $query_str[] = 'expire_after='.$expire_after; |
| 345: |
| 346: $expire_after = strtotime($expire_after); |
| 347: if ($expire_after === false || $expire_after == -1) |
| 348: message($lang_admin_bans['Invalid date message']); |
| 349: |
| 350: $conditions[] = 'b.expire>'.$expire_after; |
| 351: } |
| 352: if ($expire_before != '') |
| 353: { |
| 354: $query_str[] = 'expire_before='.$expire_before; |
| 355: |
| 356: $expire_before = strtotime($expire_before); |
| 357: if ($expire_before === false || $expire_before == -1) |
| 358: message($lang_admin_bans['Invalid date message']); |
| 359: |
| 360: $conditions[] = 'b.expire<'.$expire_before; |
| 361: } |
| 362: |
| 363: $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE'; |
| 364: foreach ($form as $key => $input) |
| 365: { |
| 366: if ($input != '' && in_array($key, array('username', 'ip', 'email', 'message'))) |
| 367: { |
| 368: $conditions[] = 'b.'.$db->escape($key).' '.$like_command.' \''.$db->escape(str_replace('*', '%', $input)).'\''; |
| 369: $query_str[] = 'form%5B'.$key.'%5D='.urlencode($input); |
| 370: } |
| 371: } |
| 372: |
| 373: // Fetch ban count |
| 374: $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'bans as b WHERE b.id>0'.(!empty($conditions) ? ' AND '.implode(' AND ', $conditions) : '')) or error('Unable to fetch ban list', __FILE__, __LINE__, $db->error()); |
| 375: $num_bans = $db->result($result); |
| 376: |
| 377: // Determine the ban offset (based on $_GET['p']) |
| 378: $num_pages = ceil($num_bans / 50); |
| 379: |
| 380: $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']); |
| 381: $start_from = 50 * ($p - 1); |
| 382: |
| 383: // Generate paging links |
| 384: $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'admin_bans.php?find_ban=&'.implode('&', $query_str)); |
| 385: |
| 386: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Bans'], $lang_admin_bans['Results head']); |
| 387: define('PUN_ACTIVE_PAGE', 'admin'); |
| 388: require PUN_ROOT.'header.php'; |
| 389: |
| 390: ?> |
| 391: <div class="linkst"> |
| 392: <div class="inbox crumbsplus"> |
| 393: <ul class="crumbs"> |
| 394: <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
| 395: <li><span>» </span><a href="admin_bans.php"><?php echo $lang_admin_common['Bans'] ?></a></li> |
| 396: <li><span>» </span><strong><?php echo $lang_admin_bans['Results head'] ?></strong></li> |
| 397: </ul> |
| 398: <div class="pagepost"> |
| 399: <p class="pagelink"><?php echo $paging_links ?></p> |
| 400: </div> |
| 401: <div class="clearer"></div> |
| 402: </div> |
| 403: </div> |
| 404: |
| 405: |
| 406: <div id="bans1" class="blocktable"> |
| 407: <h2><span><?php echo $lang_admin_bans['Results head'] ?></span></h2> |
| 408: <div class="box"> |
| 409: <div class="inbox"> |
| 410: <table cellspacing="0"> |
| 411: <thead> |
| 412: <tr> |
| 413: <th class="tcl" scope="col"><?php echo $lang_admin_bans['Results username head'] ?></th> |
| 414: <th class="tc2" scope="col"><?php echo $lang_admin_bans['Results e-mail head'] ?></th> |
| 415: <th class="tc3" scope="col"><?php echo $lang_admin_bans['Results IP address head'] ?></th> |
| 416: <th class="tc4" scope="col"><?php echo $lang_admin_bans['Results expire head'] ?></th> |
| 417: <th class="tc5" scope="col"><?php echo $lang_admin_bans['Results message head'] ?></th> |
| 418: <th class="tc6" scope="col"><?php echo $lang_admin_bans['Results banned by head'] ?></th> |
| 419: <th class="tcr" scope="col"><?php echo $lang_admin_bans['Results actions head'] ?></th> |
| 420: </tr> |
| 421: </thead> |
| 422: <tbody> |
| 423: <?php |
| 424: |
| 425: $result = $db->query('SELECT b.id, b.username, b.ip, b.email, b.message, b.expire, b.ban_creator, u.username AS ban_creator_username FROM '.$db->prefix.'bans AS b LEFT JOIN '.$db->prefix.'users AS u ON b.ban_creator=u.id WHERE b.id>0'.(!empty($conditions) ? ' AND '.implode(' AND ', $conditions) : '').' ORDER BY '.$db->escape($order_by).' '.$db->escape($direction).' LIMIT '.$start_from.', 50') or error('Unable to fetch ban list', __FILE__, __LINE__, $db->error()); |
| 426: if ($db->num_rows($result)) |
| 427: { |
| 428: while ($ban_data = $db->fetch_assoc($result)) |
| 429: { |
| 430: |
| 431: $actions = '<a href="admin_bans.php?edit_ban='.$ban_data['id'].'">'.$lang_admin_common['Edit'].'</a> | <a href="admin_bans.php?del_ban='.$ban_data['id'].'">'.$lang_admin_common['Remove'].'</a>'; |
| 432: $expire = format_time($ban_data['expire'], true); |
| 433: |
| 434: ?> |
| 435: <tr> |
| 436: <td class="tcl"><?php echo ($ban_data['username'] != '') ? pun_htmlspecialchars($ban_data['username']) : ' ' ?></td> |
| 437: <td class="tc2"><?php echo ($ban_data['email'] != '') ? $ban_data['email'] : ' ' ?></td> |
| 438: <td class="tc3"><?php echo ($ban_data['ip'] != '') ? $ban_data['ip'] : ' ' ?></td> |
| 439: <td class="tc4"><?php echo $expire ?></td> |
| 440: <td class="tc5"><?php echo ($ban_data['message'] != '') ? pun_htmlspecialchars($ban_data['message']) : ' ' ?></td> |
| 441: <td class="tc6"><?php echo ($ban_data['ban_creator_username'] != '') ? '<a href="profile.php?id='.$ban_data['ban_creator'].'">'.pun_htmlspecialchars($ban_data['ban_creator_username']).'</a>' : $lang_admin_bans['Unknown'] ?></td> |
| 442: <td class="tcr"><?php echo $actions ?></td> |
| 443: </tr> |
| 444: <?php |
| 445: |
| 446: } |
| 447: } |
| 448: else |
| 449: echo "\t\t\t\t".'<tr><td class="tcl" colspan="7">'.$lang_admin_bans['No match'].'</td></tr>'."\n"; |
| 450: |
| 451: ?> |
| 452: </tbody> |
| 453: </table> |
| 454: </div> |
| 455: </div> |
| 456: </div> |
| 457: |
| 458: <div class="linksb"> |
| 459: <div class="inbox crumbsplus"> |
| 460: <div class="pagepost"> |
| 461: <p class="pagelink"><?php echo $paging_links ?></p> |
| 462: </div> |
| 463: <ul class="crumbs"> |
| 464: <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
| 465: <li><span>» </span><a href="admin_bans.php"><?php echo $lang_admin_common['Bans'] ?></a></li> |
| 466: <li><span>» </span><strong><?php echo $lang_admin_bans['Results head'] ?></strong></li> |
| 467: </ul> |
| 468: <div class="clearer"></div> |
| 469: </div> |
| 470: </div> |
| 471: <?php |
| 472: |
| 473: require PUN_ROOT.'footer.php'; |
| 474: } |
| 475: |
| 476: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Bans']); |
| 477: $focus_element = array('bans', 'new_ban_user'); |
| 478: define('PUN_ACTIVE_PAGE', 'admin'); |
| 479: require PUN_ROOT.'header.php'; |
| 480: |
| 481: generate_admin_menu('bans'); |
| 482: |
| 483: ?> |
| 484: <div class="blockform"> |
| 485: <h2><span><?php echo $lang_admin_bans['New ban head'] ?></span></h2> |
| 486: <div class="box"> |
| 487: <form id="bans" method="post" action="admin_bans.php?action=more"> |
| 488: <div class="inform"> |
| 489: <fieldset> |
| 490: <legend><?php echo $lang_admin_bans['Add ban subhead'] ?></legend> |
| 491: <div class="infldset"> |
| 492: <table class="aligntop" cellspacing="0"> |
| 493: <tr> |
| 494: <th scope="row"><?php echo $lang_admin_bans['Username label'] ?><div><input type="submit" name="add_ban" value="<?php echo $lang_admin_common['Add'] ?>" tabindex="2" /></div></th> |
| 495: <td> |
| 496: <input type="text" name="new_ban_user" size="25" maxlength="25" tabindex="1" /> |
| 497: <span><?php echo $lang_admin_bans['Username advanced help'] ?></span> |
| 498: </td> |
| 499: </tr> |
| 500: </table> |
| 501: </div> |
| 502: </fieldset> |
| 503: </div> |
| 504: </form> |
| 505: </div> |
| 506: |
| 507: <h2 class="block2"><span><?php echo $lang_admin_bans['Ban search head'] ?></span></h2> |
| 508: <div class="box"> |
| 509: <form id="find_band" method="get" action="admin_bans.php"> |
| 510: <p class="submittop"><input type="submit" name="find_ban" value="<?php echo $lang_admin_bans['Submit search'] ?>" tabindex="3" /></p> |
| 511: <div class="inform"> |
| 512: <fieldset> |
| 513: <legend><?php echo $lang_admin_bans['Ban search subhead'] ?></legend> |
| 514: <div class="infldset"> |
| 515: <p><?php echo $lang_admin_bans['Ban search info'] ?></p> |
| 516: <table class="aligntop" cellspacing="0"> |
| 517: <tr> |
| 518: <th scope="row"><?php echo $lang_admin_bans['Username label'] ?></th> |
| 519: <td><input type="text" name="form[username]" size="25" maxlength="25" tabindex="4" /></td> |
| 520: </tr> |
| 521: <tr> |
| 522: <th scope="row"><?php echo $lang_admin_bans['IP label'] ?></th> |
| 523: <td><input type="text" name="form[ip]" size="30" maxlength="255" tabindex="5" /></td> |
| 524: </tr> |
| 525: <tr> |
| 526: <th scope="row"><?php echo $lang_admin_bans['E-mail label'] ?></th> |
| 527: <td><input type="text" name="form[email]" size="30" maxlength="80" tabindex="6" /></td> |
| 528: </tr> |
| 529: <tr> |
| 530: <th scope="row"><?php echo $lang_admin_bans['Message label'] ?></th> |
| 531: <td><input type="text" name="form[message]" size="30" maxlength="255" tabindex="7" /></td> |
| 532: </tr> |
| 533: <tr> |
| 534: <th scope="row"><?php echo $lang_admin_bans['Expire after label'] ?></th> |
| 535: <td><input type="text" name="expire_after" size="10" maxlength="10" tabindex="8" /> |
| 536: <span><?php echo $lang_admin_bans['Date help'] ?></span></td> |
| 537: </tr> |
| 538: <tr> |
| 539: <th scope="row"><?php echo $lang_admin_bans['Expire before label'] ?></th> |
| 540: <td><input type="text" name="expire_before" size="10" maxlength="10" tabindex="9" /> |
| 541: <span><?php echo $lang_admin_bans['Date help'] ?></span></td> |
| 542: </tr> |
| 543: <tr> |
| 544: <th scope="row"><?php echo $lang_admin_bans['Order by label'] ?></th> |
| 545: <td> |
| 546: <select name="order_by" tabindex="10"> |
| 547: <option value="username" selected="selected"><?php echo $lang_admin_bans['Order by username'] ?></option> |
| 548: <option value="ip"><?php echo $lang_admin_bans['Order by ip'] ?></option> |
| 549: <option value="email"><?php echo $lang_admin_bans['Order by e-mail'] ?></option> |
| 550: <option value="expire"><?php echo $lang_admin_bans['Order by expire'] ?></option> |
| 551: </select>   <select name="direction" tabindex="11"> |
| 552: <option value="ASC" selected="selected"><?php echo $lang_admin_bans['Ascending'] ?></option> |
| 553: <option value="DESC"><?php echo $lang_admin_bans['Descending'] ?></option> |
| 554: </select> |
| 555: </td> |
| 556: </tr> |
| 557: </table> |
| 558: </div> |
| 559: </fieldset> |
| 560: </div> |
| 561: <p class="submitend"><input type="submit" name="find_ban" value="<?php echo $lang_admin_bans['Submit search'] ?>" tabindex="12" /></p> |
| 562: </form> |
| 563: </div> |
| 564: </div> |
| 565: <div class="clearer"></div> |
| 566: </div> |
| 567: <?php |
| 568: |
| 569: require PUN_ROOT.'footer.php'; |
/dev/null |
b/admin_categories.php |
| 1: <?php |
| 2: |
| 3: /** |
| 4: * Copyright (C) 2008-2012 FluxBB |
| 5: * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB |
| 6: * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher |
| 7: */ |
| 8: |
| 9: // Tell header.php to use the admin template |
| 10: define('PUN_ADMIN_CONSOLE', 1); |
| 11: |
| 12: define('PUN_ROOT', dirname(__FILE__).'/'); |
| 13: require PUN_ROOT.'include/common.php'; |
| 14: require PUN_ROOT.'include/common_admin.php'; |
| 15: |
| 16: |
| 17: if ($pun_user['g_id'] != PUN_ADMIN) |
| 18: message($lang_common['No permission'], false, '403 Forbidden'); |
| 19: |
| 20: // Load the admin_categories.php language file |
| 21: require PUN_ROOT.'lang/'.$admin_language.'/admin_categories.php'; |
| 22: |
| 23: // Add a new category |
| 24: if (isset($_POST['add_cat'])) |
| 25: { |
| 26: confirm_referrer('admin_categories.php'); |
| 27: |
| 28: $new_cat_name = pun_trim($_POST['new_cat_name']); |
| 29: if ($new_cat_name == '') |
| 30: message($lang_admin_categories['Must enter name message']); |
| 31: |
| 32: $db->query('INSERT INTO '.$db->prefix.'categories (cat_name) VALUES(\''.$db->escape($new_cat_name).'\')') or error('Unable to create category', __FILE__, __LINE__, $db->error()); |
| 33: |
| 34: redirect('admin_categories.php', $lang_admin_categories['Category added redirect']); |
| 35: } |
| 36: |
| 37: // Delete a category |
| 38: else if (isset($_POST['del_cat']) || isset($_POST['del_cat_comply'])) |
| 39: { |
| 40: confirm_referrer('admin_categories.php'); |
| 41: |
| 42: $cat_to_delete = intval($_POST['cat_to_delete']); |
| 43: if ($cat_to_delete < 1) |
| 44: message($lang_common['Bad request']); |
| 45: |
| 46: if (isset($_POST['del_cat_comply'])) // Delete a category with all forums and posts |
| 47: { |
| 48: @set_time_limit(0); |
| 49: |
| 50: $result = $db->query('SELECT id FROM '.$db->prefix.'forums WHERE cat_id='.$cat_to_delete) or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error()); |
| 51: $num_forums = $db->num_rows($result); |
| 52: |
| 53: for ($i = 0; $i < $num_forums; ++$i) |
| 54: { |
| 55: $cur_forum = $db->result($result, $i); |
| 56: |
| 57: // Prune all posts and topics |
| 58: prune($cur_forum, 1, -1); |
| 59: |
| 60: // Delete the forum |
| 61: $db->query('DELETE FROM '.$db->prefix.'forums WHERE id='.$cur_forum) or error('Unable to delete forum', __FILE__, __LINE__, $db->error()); |
| 62: } |
| 63: |
| 64: // Locate any "orphaned redirect topics" and delete them |
| 65: $result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error()); |
| 66: $num_orphans = $db->num_rows($result); |
| 67: |
| 68: if ($num_orphans) |
| 69: { |
| 70: for ($i = 0; $i < $num_orphans; ++$i) |
| 71: $orphans[] = $db->result($result, $i); |
| 72: |
| 73: $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error()); |
| 74: } |
| 75: |
| 76: // Delete the category |
| 77: $db->query('DELETE FROM '.$db->prefix.'categories WHERE id='.$cat_to_delete) or error('Unable to delete category', __FILE__, __LINE__, $db->error()); |
| 78: |
| 79: // Regenerate the quick jump cache |
| 80: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| 81: require PUN_ROOT.'include/cache.php'; |
| 82: |
| 83: generate_quickjump_cache(); |
| 84: |
| 85: redirect('admin_categories.php', $lang_admin_categories['Category deleted redirect']); |
| 86: } |
| 87: else // If the user hasn't comfirmed the delete |
| 88: { |
| 89: $result = $db->query('SELECT cat_name FROM '.$db->prefix.'categories WHERE id='.$cat_to_delete) or error('Unable to fetch category info', __FILE__, __LINE__, $db->error()); |
| 90: $cat_name = $db->result($result); |
| 91: |
| 92: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Categories']); |
| 93: define('PUN_ACTIVE_PAGE', 'admin'); |
| 94: require PUN_ROOT.'header.php'; |
| 95: |
| 96: generate_admin_menu('categories'); |
| 97: |
| 98: ?> |
| 99: <div class="blockform"> |
| 100: <h2><span><?php echo $lang_admin_categories['Delete category head'] ?></span></h2> |
| 101: <div class="box"> |
| 102: <form method="post" action="admin_categories.php"> |
| 103: <div class="inform"> |
| 104: <input type="hidden" name="cat_to_delete" value="<?php echo $cat_to_delete ?>" /> |
| 105: <fieldset> |
| 106: <legend><?php echo $lang_admin_categories['Confirm delete subhead'] ?></legend> |
| 107: <div class="infldset"> |
| 108: <p><?php printf($lang_admin_categories['Confirm delete info'], pun_htmlspecialchars($cat_name)) ?></p> |
| 109: <p class="warntext"><?php echo $lang_admin_categories['Delete category warn'] ?></p> |
| 110: </div> |
| 111: </fieldset> |
| 112: </div> |
| 113: <p class="buttons"><input type="submit" name="del_cat_comply" value="<?php echo $lang_admin_common['Delete'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_admin_common['Go back'] ?></a></p> |
| 114: </form> |
| 115: </div> |
| 116: </div> |
| 117: <div class="clearer"></div> |
| 118: </div> |
| 119: <?php |
| 120: |
| 121: require PUN_ROOT.'footer.php'; |
| 122: } |
| 123: } |
| 124: |
| 125: else if (isset($_POST['update'])) // Change position and name of the categories |
| 126: { |
| 127: confirm_referrer('admin_categories.php'); |
| 128: |
| 129: $categories = $_POST['cat']; |
| 130: if (empty($categories)) |
| 131: message($lang_common['Bad request']); |
| 132: |
| 133: foreach ($categories as $cat_id => $cur_cat) |
| 134: { |
| 135: $cur_cat['name'] = pun_trim($cur_cat['name']); |
| 136: $cur_cat['order'] = pun_trim($cur_cat['order']); |
| 137: |
| 138: if ($cur_cat['name'] == '') |
| 139: message($lang_admin_categories['Must enter name message']); |
| 140: |
| 141: if ($cur_cat['order'] == '' || preg_match('%[^0-9]%', $cur_cat['order'])) |
| 142: message($lang_admin_categories['Must enter integer message']); |
| 143: |
| 144: $db->query('UPDATE '.$db->prefix.'categories SET cat_name=\''.$db->escape($cur_cat['name']).'\', disp_position='.$cur_cat['order'].' WHERE id='.intval($cat_id)) or error('Unable to update category', __FILE__, __LINE__, $db->error()); |
| 145: } |
| 146: |
| 147: // Regenerate the quick jump cache |
| 148: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| 149: require PUN_ROOT.'include/cache.php'; |
| 150: |
| 151: generate_quickjump_cache(); |
| 152: |
| 153: redirect('admin_categories.php', $lang_admin_categories['Categories updated redirect']); |
| 154: } |
| 155: |
| 156: // Generate an array with all categories |
| 157: $result = $db->query('SELECT id, cat_name, disp_position FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error()); |
| 158: $num_cats = $db->num_rows($result); |
| 159: |
| 160: for ($i = 0; $i < $num_cats; ++$i) |
| 161: $cat_list[] = $db->fetch_assoc($result); |
| 162: |
| 163: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Categories']); |
| 164: define('PUN_ACTIVE_PAGE', 'admin'); |
| 165: require PUN_ROOT.'header.php'; |
| 166: |
| 167: generate_admin_menu('categories'); |
| 168: |
| 169: ?> |
| 170: <div class="blockform"> |
| 171: <h2><span><?php echo $lang_admin_categories['Add categories head'] ?></span></h2> |
| 172: <div class="box"> |
| 173: <form method="post" action="admin_categories.php"> |
| 174: <div class="inform"> |
| 175: <fieldset> |
| 176: <legend><?php echo $lang_admin_categories['Add categories subhead'] ?></legend> |
| 177: <div class="infldset"> |
| 178: <table class="aligntop" cellspacing="0"> |
| 179: <tr> |
| 180: <th scope="row"><?php echo $lang_admin_categories['Add category label'] ?><div><input type="submit" name="add_cat" value="<?php echo $lang_admin_categories['Add new submit'] ?>" tabindex="2" /></div></th> |
| 181: <td> |
| 182: <input type="text" name="new_cat_name" size="35" maxlength="80" tabindex="1" /> |
| 183: <span><?php printf($lang_admin_categories['Add category help'], '<a href="admin_forums.php">'.$lang_admin_common['Forums'].'</a>') ?></span> |
| 184: </td> |
| 185: </tr> |
| 186: </table> |
| 187: </div> |
| 188: </fieldset> |
| 189: </div> |
| 190: </form> |
| 191: </div> |
| 192: |
| 193: <?php if ($num_cats): ?> <h2 class="block2"><span><?php echo $lang_admin_categories['Delete categories head'] ?></span></h2> |
| 194: <div class="box"> |
| 195: <form method="post" action="admin_categories.php"> |
| 196: <div class="inform"> |
| 197: <fieldset> |
| 198: <legend><?php echo $lang_admin_categories['Delete categories subhead'] ?></legend> |
| 199: <div class="infldset"> |
| 200: <table class="aligntop" cellspacing="0"> |
| 201: <tr> |
| 202: <th scope="row"><?php echo $lang_admin_categories['Delete category label'] ?><div><input type="submit" name="del_cat" value="<?php echo $lang_admin_common['Delete'] ?>" tabindex="4" /></div></th> |
| 203: <td> |
| 204: <select name="cat_to_delete" tabindex="3"> |
| 205: <?php |
| 206: |
| 207: foreach ($cat_list as $cur_cat) |
| 208: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'">'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n"; |
| 209: |
| 210: ?> |
| 211: </select> |
| 212: <span><?php echo $lang_admin_categories['Delete category help'] ?></span> |
| 213: </td> |
| 214: </tr> |
| 215: </table> |
| 216: </div> |
| 217: </fieldset> |
| 218: </div> |
| 219: </form> |
| 220: </div> |
| 221: <?php endif; ?> |
| 222: |
| 223: <?php if ($num_cats): ?> <h2 class="block2"><span><?php echo $lang_admin_categories['Edit categories head'] ?></span></h2> |
| 224: <div class="box"> |
| 225: <form method="post" action="admin_categories.php"> |
| 226: <div class="inform"> |
| 227: <fieldset> |
| 228: <legend><?php echo $lang_admin_categories['Edit categories subhead'] ?></legend> |
| 229: <div class="infldset"> |
| 230: <table id="categoryedit" cellspacing="0" > |
| 231: <thead> |
| 232: <tr> |
| 233: <th class="tcl" scope="col"><?php echo $lang_admin_categories['Category name label'] ?></th> |
| 234: <th scope="col"><?php echo $lang_admin_categories['Category position label'] ?></th> |
| 235: </tr> |
| 236: </thead> |
| 237: <tbody> |
| 238: <?php |
| 239: |
| 240: foreach ($cat_list as $cur_cat) |
| 241: { |
| 242: |
| 243: ?> |
| 244: <tr> |
| 245: <td class="tcl"><input type="text" name="cat[<?php echo $cur_cat['id'] ?>][name]" value="<?php echo pun_htmlspecialchars($cur_cat['cat_name']) ?>" size="35" maxlength="80" /></td> |
| 246: <td><input type="text" name="cat[<?php echo $cur_cat['id'] ?>][order]" value="<?php echo $cur_cat['disp_position'] ?>" size="3" maxlength="3" /></td> |
| 247: </tr> |
| 248: <?php |
| 249: |
| 250: } |
| 251: |
| 252: ?> |
| 253: </tbody> |
| 254: </table> |
| 255: <div class="fsetsubmit"><input type="submit" name="update" value="<?php echo $lang_admin_common['Update'] ?>" /></div> |
| 256: </div> |
| 257: </fieldset> |
| 258: </div> |
| 259: </form> |
| 260: </div> |
| 261: <?php endif; ?> </div> |
| 262: <div class="clearer"></div> |
| 263: </div> |
| 264: <?php |
| 265: |
| 266: require PUN_ROOT.'footer.php'; |
/dev/null |
b/admin_forums.php |
| 1: <?php |
| 2: |
| 3: /** |
| 4: * Copyright (C) 2008-2012 FluxBB |
| 5: * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB |
| 6: * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher |
| 7: */ |
| 8: |
| 9: // Tell header.php to use the admin template |
| 10: define('PUN_ADMIN_CONSOLE', 1); |
| 11: |
| 12: define('PUN_ROOT', dirname(__FILE__).'/'); |
| 13: require PUN_ROOT.'include/common.php'; |
| 14: require PUN_ROOT.'include/common_admin.php'; |
| 15: |
| 16: |
| 17: if ($pun_user['g_id'] != PUN_ADMIN) |
| 18: message($lang_common['No permission'], false, '403 Forbidden'); |
| 19: |
| 20: // Load the admin_forums.php language file |
| 21: require PUN_ROOT.'lang/'.$admin_language.'/admin_forums.php'; |
| 22: |
| 23: // Add a "default" forum |
| 24: if (isset($_POST['add_forum'])) |
| 25: { |
| 26: confirm_referrer('admin_forums.php'); |
| 27: |
| 28: $add_to_cat = intval($_POST['add_to_cat']); |
| 29: if ($add_to_cat < 1) |
| 30: message($lang_common['Bad request']); |
| 31: |
| 32: $db->query('INSERT INTO '.$db->prefix.'forums (forum_name, cat_id) VALUES(\''.$db->escape($lang_admin_forums['New forum']).'\', '.$add_to_cat.')') or error('Unable to create forum', __FILE__, __LINE__, $db->error()); |
| 33: |
| 34: // Regenerate the quick jump cache |
| 35: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| 36: require PUN_ROOT.'include/cache.php'; |
| 37: |
| 38: generate_quickjump_cache(); |
| 39: |
| 40: redirect('admin_forums.php', $lang_admin_forums['Forum added redirect']); |
| 41: } |
| 42: |
| 43: // Delete a forum |
| 44: else if (isset($_GET['del_forum'])) |
| 45: { |
| 46: confirm_referrer('admin_forums.php'); |
| 47: |
| 48: $forum_id = intval($_GET['del_forum']); |
| 49: if ($forum_id < 1) |
| 50: message($lang_common['Bad request']); |
| 51: |
| 52: if (isset($_POST['del_forum_comply'])) // Delete a forum with all posts |
| 53: { |
| 54: @set_time_limit(0); |
| 55: |
| 56: // Prune all posts and topics |
| 57: prune($forum_id, 1, -1); |
| 58: |
| 59: // Locate any "orphaned redirect topics" and delete them |
| 60: $result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error()); |
| 61: $num_orphans = $db->num_rows($result); |
| 62: |
| 63: if ($num_orphans) |
| 64: { |
| 65: for ($i = 0; $i < $num_orphans; ++$i) |
| 66: $orphans[] = $db->result($result, $i); |
| 67: |
| 68: $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error()); |
| 69: } |
| 70: |
| 71: // Delete the forum and any forum specific group permissions |
| 72: $db->query('DELETE FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to delete forum', __FILE__, __LINE__, $db->error()); |
| 73: $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error()); |
| 74: |
| 75: // Delete any subscriptions for this forum |
| 76: $db->query('DELETE FROM '.$db->prefix.'forum_subscriptions WHERE forum_id='.$forum_id) or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error()); |
| 77: |
| 78: // Regenerate the quick jump cache |
| 79: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| 80: require PUN_ROOT.'include/cache.php'; |
| 81: |
| 82: generate_quickjump_cache(); |
| 83: |
| 84: redirect('admin_forums.php', $lang_admin_forums['Forum deleted redirect']); |
| 85: } |
| 86: else // If the user hasn't confirmed the delete |
| 87: { |
| 88: $result = $db->query('SELECT forum_name FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error()); |
| 89: $forum_name = pun_htmlspecialchars($db->result($result)); |
| 90: |
| 91: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Forums']); |
| 92: define('PUN_ACTIVE_PAGE', 'admin'); |
| 93: require PUN_ROOT.'header.php'; |
| 94: |
| 95: generate_admin_menu('forums'); |
| 96: |
| 97: ?> |
| 98: <div class="blockform"> |
| 99: <h2><span><?php echo $lang_admin_forums['Confirm delete head'] ?></span></h2> |
| 100: <div class="box"> |
| 101: <form method="post" action="admin_forums.php?del_forum=<?php echo $forum_id ?>"> |
| 102: <div class="inform"> |
| 103: <fieldset> |
| 104: <legend><?php echo $lang_admin_forums['Confirm delete subhead'] ?></legend> |
| 105: <div class="infldset"> |
| 106: <p><?php printf($lang_admin_forums['Confirm delete info'], $forum_name) ?></p> |
| 107: <p class="warntext"><?php echo $lang_admin_forums['Confirm delete warn'] ?></p> |
| 108: </div> |
| 109: </fieldset> |
| 110: </div> |
| 111: <p class="buttons"><input type="submit" name="del_forum_comply" value="<?php echo $lang_admin_common['Delete'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_admin_common['Go back'] ?></a></p> |
| 112: </form> |
| 113: </div> |
| 114: </div> |
| 115: <div class="clearer"></div> |
| 116: </div> |
| 117: <?php |
| 118: |
| 119: require PUN_ROOT.'footer.php'; |
| 120: } |
| 121: } |
| 122: |
| 123: // Update forum positions |
| 124: else if (isset($_POST['update_positions'])) |
| 125: { |
| 126: confirm_referrer('admin_forums.php'); |
| 127: |
| 128: foreach ($_POST['position'] as $forum_id => $disp_position) |
| 129: { |
| 130: $disp_position = trim($disp_position); |
| 131: if ($disp_position == '' || preg_match('%[^0-9]%', $disp_position)) |
| 132: message($lang_admin_forums['Must be integer message']); |
| 133: |
| 134: $db->query('UPDATE '.$db->prefix.'forums SET disp_position='.$disp_position.' WHERE id='.intval($forum_id)) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); |
| 135: } |
| 136: |
| 137: // Regenerate the quick jump cache |
| 138: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| 139: require PUN_ROOT.'include/cache.php'; |
| 140: |
| 141: generate_quickjump_cache(); |
| 142: |
| 143: redirect('admin_forums.php', $lang_admin_forums['Forums updated redirect']); |
| 144: } |
| 145: |
| 146: else if (isset($_GET['edit_forum'])) |
| 147: { |
| 148: $forum_id = intval($_GET['edit_forum']); |
| 149: if ($forum_id < 1) |
| 150: message($lang_common['Bad request']); |
| 151: |
| 152: // Update group permissions for $forum_id |
| 153: if (isset($_POST['save'])) |
| 154: { |
| 155: confirm_referrer('admin_forums.php'); |
| 156: |
| 157: // Start with the forum details |
| 158: $forum_name = pun_trim($_POST['forum_name']); |
| 159: $forum_desc = pun_linebreaks(pun_trim($_POST['forum_desc'])); |
| 160: $cat_id = intval($_POST['cat_id']); |
| 161: $sort_by = intval($_POST['sort_by']); |
| 162: $redirect_url = isset($_POST['redirect_url']) ? pun_trim($_POST['redirect_url']) : null; |
| 163: |
| 164: if ($forum_name == '') |
| 165: message($lang_admin_forums['Must enter name message']); |
| 166: |
| 167: if ($cat_id < 1) |
| 168: message($lang_common['Bad request']); |
| 169: |
| 170: $forum_desc = ($forum_desc != '') ? '\''.$db->escape($forum_desc).'\'' : 'NULL'; |
| 171: $redirect_url = ($redirect_url != '') ? '\''.$db->escape($redirect_url).'\'' : 'NULL'; |
| 172: |
| 173: $db->query('UPDATE '.$db->prefix.'forums SET forum_name=\''.$db->escape($forum_name).'\', forum_desc='.$forum_desc.', redirect_url='.$redirect_url.', sort_by='.$sort_by.', cat_id='.$cat_id.' WHERE id='.$forum_id) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); |
| 174: |
| 175: // Now let's deal with the permissions |
| 176: if (isset($_POST['read_forum_old'])) |
| 177: { |
| 178: $result = $db->query('SELECT g_id, g_read_board, g_post_replies, g_post_topics FROM '.$db->prefix.'groups WHERE g_id!='.PUN_ADMIN) or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); |
| 179: while ($cur_group = $db->fetch_assoc($result)) |
| 180: { |
| 181: $read_forum_new = ($cur_group['g_read_board'] == '1') ? isset($_POST['read_forum_new'][$cur_group['g_id']]) ? '1' : '0' : intval($_POST['read_forum_old'][$cur_group['g_id']]); |
| 182: $post_replies_new = isset($_POST['post_replies_new'][$cur_group['g_id']]) ? '1' : '0'; |
| 183: $post_topics_new = isset($_POST['post_topics_new'][$cur_group['g_id']]) ? '1' : '0'; |
| 184: |
| 185: // Check if the new settings differ from the old |
| 186: if ($read_forum_new != $_POST['read_forum_old'][$cur_group['g_id']] || $post_replies_new != $_POST['post_replies_old'][$cur_group['g_id']] || $post_topics_new != $_POST['post_topics_old'][$cur_group['g_id']]) |
| 187: { |
| 188: // If the new settings are identical to the default settings for this group, delete it's row in forum_perms |
| 189: if ($read_forum_new == '1' && $post_replies_new == $cur_group['g_post_replies'] && $post_topics_new == $cur_group['g_post_topics']) |
| 190: $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error()); |
| 191: else |
| 192: { |
| 193: // Run an UPDATE and see if it affected a row, if not, INSERT |
| 194: $db->query('UPDATE '.$db->prefix.'forum_perms SET read_forum='.$read_forum_new.', post_replies='.$post_replies_new.', post_topics='.$post_topics_new.' WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error()); |
| 195: if (!$db->affected_rows()) |
| 196: $db->query('INSERT INTO '.$db->prefix.'forum_perms (group_id, forum_id, read_forum, post_replies, post_topics) VALUES('.$cur_group['g_id'].', '.$forum_id.', '.$read_forum_new.', '.$post_replies_new.', '.$post_topics_new.')') or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error()); |
| 197: } |
| 198: } |
| 199: } |
| 200: } |
| 201: |
| 202: // Regenerate the quick jump cache |
| 203: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| 204: require PUN_ROOT.'include/cache.php'; |
| 205: |
| 206: generate_quickjump_cache(); |
| 207: |
| 208: redirect('admin_forums.php', $lang_admin_forums['Forum updated redirect']); |
| 209: } |
| 210: else if (isset($_POST['revert_perms'])) |
| 211: { |
| 212: confirm_referrer('admin_forums.php'); |
| 213: |
| 214: $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error()); |
| 215: |
| 216: // Regenerate the quick jump cache |
| 217: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| 218: require PUN_ROOT.'include/cache.php'; |
| 219: |
| 220: generate_quickjump_cache(); |
| 221: |
| 222: redirect('admin_forums.php?edit_forum='.$forum_id, $lang_admin_forums['Perms reverted redirect']); |
| 223: } |
| 224: |
| 225: // Fetch forum info |
| 226: $result = $db->query('SELECT id, forum_name, forum_desc, redirect_url, num_topics, sort_by, cat_id FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error()); |
| 227: if (!$db->num_rows($result)) |
| 228: message($lang_common['Bad request']); |
| 229: |
| 230: $cur_forum = $db->fetch_assoc($result); |
| 231: |
| 232: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Forums']); |
| 233: define('PUN_ACTIVE_PAGE', 'admin'); |
| 234: require PUN_ROOT.'header.php'; |
| 235: |
| 236: generate_admin_menu('forums'); |
| 237: |
| 238: ?> |
| 239: <div class="blockform"> |
| 240: <h2><span><?php echo $lang_admin_forums['Edit forum head'] ?></span></h2> |
| 241: <div class="box"> |
| 242: <form id="edit_forum" method="post" action="admin_forums.php?edit_forum=<?php echo $forum_id ?>"> |
| 243: <p class="submittop"><input type="submit" name="save" value="<?php echo $lang_admin_common['Save changes'] ?>" tabindex="6" /></p> |
| 244: <div class="inform"> |
| 245: <fieldset> |
| 246: <legend><?php echo $lang_admin_forums['Edit details subhead'] ?></legend> |
| 247: <div class="infldset"> |
| 248: <table class="aligntop" cellspacing="0"> |
| 249: <tr> |
| 250: <th scope="row"><?php echo $lang_admin_forums['Forum name label'] ?></th> |
| 251: <td><input type="text" name="forum_name" size="35" maxlength="80" value="<?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?>" tabindex="1" /></td> |
| 252: </tr> |
| 253: <tr> |
| 254: <th scope="row"><?php echo $lang_admin_forums['Forum description label'] ?></th> |
| 255: <td><textarea name="forum_desc" rows="3" cols="50" tabindex="2"><?php echo pun_htmlspecialchars($cur_forum['forum_desc']) ?></textarea></td> |
| 256: </tr> |
| 257: <tr> |
| 258: <th scope="row"><?php echo $lang_admin_forums['Category label'] ?></th> |
| 259: <td> |
| 260: <select name="cat_id" tabindex="3"> |
| 261: <?php |
| 262: |
| 263: $result = $db->query('SELECT id, cat_name FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error()); |
| 264: while ($cur_cat = $db->fetch_assoc($result)) |
| 265: { |
| 266: $selected = ($cur_cat['id'] == $cur_forum['cat_id']) ? ' selected="selected"' : ''; |
| 267: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'"'.$selected.'>'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n"; |
| 268: } |
| 269: |
| 270: ?> |
| 271: </select> |
| 272: </td> |
| 273: </tr> |
| 274: <tr> |
| 275: <th scope="row"><?php echo $lang_admin_forums['Sort by label'] ?></th> |
| 276: <td> |
| 277: <select name="sort_by" tabindex="4"> |
| 278: <option value="0"<?php if ($cur_forum['sort_by'] == '0') echo ' selected="selected"' ?>><?php echo $lang_admin_forums['Last post'] ?></option> |
| 279: <option value="1"<?php if ($cur_forum['sort_by'] == '1') echo ' selected="selected"' ?>><?php echo $lang_admin_forums['Topic start'] ?></option> |
| 280: <option value="2"<?php if ($cur_forum['sort_by'] == '2') echo ' selected="selected"' ?>><?php echo $lang_admin_forums['Subject'] ?></option> |
| 281: </select> |
| 282: </td> |
| 283: </tr> |
| 284: <tr> |
| 285: <th scope="row"><?php echo $lang_admin_forums['Redirect label'] ?></th> |
| 286: <td><?php echo ($cur_forum['num_topics']) ? $lang_admin_forums['Redirect help'] : '<input type="text" name="redirect_url" size="45" maxlength="100" value="'.pun_htmlspecialchars($cur_forum['redirect_url']).'" tabindex="5" />'; ?></td> |
| 287: </tr> |
| 288: </table> |
| 289: </div> |
| 290: </fieldset> |
| 291: </div> |
| 292: <div class="inform"> |
| 293: <fieldset> |
| 294: <legend><?php echo $lang_admin_forums['Group permissions subhead'] ?></legend> |
| 295: <div class="infldset"> |
| 296: <p><?php printf($lang_admin_forums['Group permissions info'], '<a href="admin_groups.php">'.$lang_admin_common['User groups'].'</a>') ?></p> |
| 297: <table id="forumperms" cellspacing="0"> |
| 298: <thead> |
| 299: <tr> |
| 300: <th class="atcl"> </th> |
| 301: <th><?php echo $lang_admin_forums['Read forum label'] ?></th> |
| 302: <th><?php echo $lang_admin_forums['Post replies label'] ?></th> |
| 303: <th><?php echo $lang_admin_forums['Post topics label'] ?></th> |
| 304: </tr> |
| 305: </thead> |
| 306: <tbody> |
| 307: <?php |
| 308: |
| 309: $result = $db->query('SELECT g.g_id, g.g_title, g.g_read_board, g.g_post_replies, g.g_post_topics, fp.read_forum, fp.post_replies, fp.post_topics FROM '.$db->prefix.'groups AS g LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (g.g_id=fp.group_id AND fp.forum_id='.$forum_id.') WHERE g.g_id!='.PUN_ADMIN.' ORDER BY g.g_id') or error('Unable to fetch group forum permission list', __FILE__, __LINE__, $db->error()); |
| 310: |
| 311: $cur_index = 7; |
| 312: |
| 313: while ($cur_perm = $db->fetch_assoc($result)) |
| 314: { |
| 315: $read_forum = ($cur_perm['read_forum'] != '0') ? true : false; |
| 316: $post_replies = (($cur_perm['g_post_replies'] == '0' && $cur_perm['post_replies'] == '1') || ($cur_perm['g_post_replies'] == '1' && $cur_perm['post_replies'] != '0')) ? true : false; |
| 317: $post_topics = (($cur_perm['g_post_topics'] == '0' && $cur_perm['post_topics'] == '1') || ($cur_perm['g_post_topics'] == '1' && $cur_perm['post_topics'] != '0')) ? true : false; |
| 318: |
| 319: // Determine if the current settings differ from the default or not |
| 320: $read_forum_def = ($cur_perm['read_forum'] == '0') ? false : true; |
| 321: $post_replies_def = (($post_replies && $cur_perm['g_post_replies'] == '0') || (!$post_replies && ($cur_perm['g_post_replies'] == '' || $cur_perm['g_post_replies'] == '1'))) ? false : true; |
| 322: $post_topics_def = (($post_topics && $cur_perm['g_post_topics'] == '0') || (!$post_topics && ($cur_perm['g_post_topics'] == '' || $cur_perm['g_post_topics'] == '1'))) ? false : true; |
| 323: |
| 324: ?> |
| 325: <tr> |
| 326: <th class="atcl"><?php echo pun_htmlspecialchars($cur_perm['g_title']) ?></th> |
| 327: <td<?php if (!$read_forum_def) echo ' class="nodefault"'; ?>> |
| 328: <input type="hidden" name="read_forum_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($read_forum) ? '1' : '0'; ?>" /> |
| 329: <input type="checkbox" name="read_forum_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($read_forum) ? ' checked="checked"' : ''; ?><?php echo ($cur_perm['g_read_board'] == '0') ? ' disabled="disabled"' : ''; ?> tabindex="<?php echo $cur_index++ ?>" /> |
| 330: </td> |
| 331: <td<?php if (!$post_replies_def && $cur_forum['redirect_url'] == '') echo ' class="nodefault"'; ?>> |
| 332: <input type="hidden" name="post_replies_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($post_replies) ? '1' : '0'; ?>" /> |
| 333: <input type="checkbox" name="post_replies_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($post_replies) ? ' checked="checked"' : ''; ?><?php echo ($cur_forum['redirect_url'] != '') ? ' disabled="disabled"' : ''; ?> tabindex="<?php echo $cur_index++ ?>" /> |
| 334: </td> |
| 335: <td<?php if (!$post_topics_def && $cur_forum['redirect_url'] == '') echo ' class="nodefault"'; ?>> |
| 336: <input type="hidden" name="post_topics_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($post_topics) ? '1' : '0'; ?>" /> |
| 337: <input type="checkbox" name="post_topics_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($post_topics) ? ' checked="checked"' : ''; ?><?php echo ($cur_forum['redirect_url'] != '') ? ' disabled="disabled"' : ''; ?> tabindex="<?php echo $cur_index++ ?>" /> |
| 338: </td> |
| 339: </tr> |
| 340: <?php |
| 341: |
| 342: } |
| 343: |
| 344: ?> |
| 345: </tbody> |
| 346: </table> |
| 347: <div class="fsetsubmit"><input type="submit" name="revert_perms" value="<?php echo $lang_admin_forums['Revert to default'] ?>" tabindex="<?php echo $cur_index++ ?>" /></div> |
| 348: </div> |
| 349: </fieldset> |
| 350: </div> |
| 351: <p class="submitend"><input type="submit" name="save" value="<?php echo $lang_admin_common['Save changes'] ?>" tabindex="<?php echo $cur_index++ ?>" /></p> |
| 352: </form> |
| 353: </div> |
| 354: </div> |
| 355: <div class="clearer"></div> |
| 356: </div> |
| 357: |
| 358: <?php |
| 359: |
| 360: require PUN_ROOT.'footer.php'; |
| 361: } |
| 362: |
| 363: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Forums']); |
| 364: define('PUN_ACTIVE_PAGE', 'admin'); |
| 365: require PUN_ROOT.'header.php'; |
| 366: |
| 367: generate_admin_menu('forums'); |
| 368: |
| 369: ?> |
| 370: <div class="blockform"> |
| 371: <h2><span><?php echo $lang_admin_forums['Add forum head'] ?></span></h2> |
| 372: <div class="box"> |
| 373: <form method="post" action="admin_forums.php?action=adddel"> |
| 374: <div class="inform"> |
| 375: <fieldset> |
| 376: <legend><?php echo $lang_admin_forums['Create new subhead'] ?></legend> |
| 377: <div class="infldset"> |
| 378: <table class="aligntop" cellspacing="0"> |
| 379: <tr> |
| 380: <th scope="row"><?php echo $lang_admin_forums['Add forum label'] ?><div><input type="submit" name="add_forum" value="<?php echo $lang_admin_forums['Add forum'] ?>" tabindex="2" /></div></th> |
| 381: <td> |
| 382: <select name="add_to_cat" tabindex="1"> |
| 383: <?php |
| 384: |
| 385: $result = $db->query('SELECT id, cat_name FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error()); |
| 386: if ($db->num_rows($result) > 0) |
| 387: { |
| 388: while ($cur_cat = $db->fetch_assoc($result)) |
| 389: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'">'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n"; |
| 390: } |
| 391: else |
| 392: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="0" disabled="disabled">'.$lang_admin_forums['No categories exist'].'</option>'."\n"; |
| 393: |
| 394: ?> |
| 395: </select> |
| 396: <span><?php echo $lang_admin_forums['Add forum help'] ?></span> |
| 397: </td> |
| 398: </tr> |
| 399: </table> |
| 400: </div> |
| 401: </fieldset> |
| 402: </div> |
| 403: </form> |
| 404: </div> |
| 405: <?php |
| 406: |
| 407: // Display all the categories and forums |
| 408: $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.disp_position FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error()); |
| 409: |
| 410: if ($db->num_rows($result) > 0) |
| 411: { |
| 412: |
| 413: ?> |
| 414: <h2 class="block2"><span><?php echo $lang_admin_forums['Edit forums head'] ?></span></h2> |
| 415: <div class="box"> |
| 416: <form id="edforum" method="post" action="admin_forums.php?action=edit"> |
| 417: <p class="submittop"><input type="submit" name="update_positions" value="<?php echo $lang_admin_forums['Update positions'] ?>" tabindex="3" /></p> |
| 418: <?php |
| 419: |
| 420: $cur_index = 4; |
| 421: |
| 422: $cur_category = 0; |
| 423: while ($cur_forum = $db->fetch_assoc($result)) |
| 424: { |
| 425: if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? |
| 426: { |
| 427: if ($cur_category != 0) |
| 428: echo "\t\t\t\t\t\t\t".'</tbody>'."\n\t\t\t\t\t\t\t".'</table>'."\n\t\t\t\t\t\t".'</div>'."\n\t\t\t\t\t".'</fieldset>'."\n\t\t\t\t".'</div>'."\n"; |
| 429: |
| 430: ?> |
| 431: <div class="inform"> |
| 432: <fieldset> |
| 433: <legend><?php echo $lang_admin_forums['Category subhead'] ?> <?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></legend> |
| 434: <div class="infldset"> |
| 435: <table cellspacing="0"> |
| 436: <thead> |
| 437: <tr> |
| 438: <th class="tcl"><?php echo $lang_admin_common['Action'] ?></th> |
| 439: <th class="tc2"><?php echo $lang_admin_forums['Position label'] ?></th> |
| 440: <th class="tcr"><?php echo $lang_admin_forums['Forum label'] ?></th> |
| 441: </tr> |
| 442: </thead> |
| 443: <tbody> |
| 444: <?php |
| 445: |
| 446: $cur_category = $cur_forum['cid']; |
| 447: } |
| 448: |
| 449: ?> |
| 450: <tr> |
| 451: <td class="tcl"><a href="admin_forums.php?edit_forum=<?php echo $cur_forum['fid'] ?>" tabindex="<?php echo $cur_index++ ?>"><?php echo $lang_admin_forums['Edit link'] ?></a> | <a href="admin_forums.php?del_forum=<?php echo $cur_forum['fid'] ?>" tabindex="<?php echo $cur_index++ ?>"><?php echo $lang_admin_forums['Delete link'] ?></a></td> |
| 452: <td class="tc2"><input type="text" name="position[<?php echo $cur_forum['fid'] ?>]" size="3" maxlength="3" value="<?php echo $cur_forum['disp_position'] ?>" tabindex="<?php echo $cur_index++ ?>" /></td> |
| 453: <td class="tcr"><strong><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></strong></td> |
| 454: </tr> |
| 455: <?php |
| 456: |
| 457: } |
| 458: |
| 459: ?> |
| 460: </tbody> |
| 461: </table> |
| 462: </div> |
| 463: </fieldset> |
| 464: </div> |
| 465: <p class="submitend"><input type="submit" name="update_positions" value="<?php echo $lang_admin_forums['Update positions'] ?>" tabindex="<?php echo $cur_index++ ?>" /></p> |
| 466: </form> |
| 467: </div> |
| 468: <?php |
| 469: |
| 470: } |
| 471: |
| 472: ?> |
| 473: </div> |
| 474: <div class="clearer"></div> |
| 475: </div> |
| 476: <?php |
| 477: |
| 478: require PUN_ROOT.'footer.php'; |
/dev/null |
b/admin_groups.php |
| 1: <?php |
| 2: |
| 3: /** |
| 4: * Copyright (C) 2008-2012 FluxBB |
| 5: * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB |
| 6: * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher |
| 7: */ |
| 8: |
| 9: // Tell header.php to use the admin template |
| 10: define('PUN_ADMIN_CONSOLE', 1); |
| 11: |
| 12: define('PUN_ROOT', dirname(__FILE__).'/'); |
| 13: require PUN_ROOT.'include/common.php'; |
| 14: require PUN_ROOT.'include/common_admin.php'; |
| 15: |
| 16: |
| 17: if ($pun_user['g_id'] != PUN_ADMIN) |
| 18: message($lang_common['No permission'], false, '403 Forbidden'); |
| 19: |
| 20: // Load the admin_censoring.php language file |
| 21: require PUN_ROOT.'lang/'.$admin_language.'/admin_groups.php'; |
| 22: |
| 23: // Add/edit a group (stage 1) |
| 24: if (isset($_POST['add_group']) || isset($_GET['edit_group'])) |
| 25: { |
| 26: if (isset($_POST['add_group'])) |
| 27: { |
| 28: $base_group = intval($_POST['base_group']); |
| 29: |
| 30: $result = $db->query('SELECT * FROM '.$db->prefix.'groups WHERE g_id='.$base_group) or error('Unable to fetch user group info', __FILE__, __LINE__, $db->error()); |
| 31: $group = $db->fetch_assoc($result); |
| 32: |
| 33: $mode = 'add'; |
| 34: } |
| 35: else // We are editing a group |
| 36: { |
| 37: $group_id = intval($_GET['edit_group']); |
| 38: if ($group_id < 1) |
| 39: message($lang_common['Bad request']); |
| 40: |
| 41: $result = $db->query('SELECT * FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to fetch user group info', __FILE__, __LINE__, $db->error()); |
| 42: if (!$db->num_rows($result)) |
| 43: message($lang_common['Bad request']); |
| 44: |
| 45: $group = $db->fetch_assoc($result); |
| 46: |
| 47: $mode = 'edit'; |
| 48: } |
| 49: |
| 50: |
| 51: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']); |
| 52: $required_fields = array('req_title' => $lang_admin_groups['Group title label']); |
| 53: $focus_element = array('groups2', 'req_title'); |
| 54: define('PUN_ACTIVE_PAGE', 'admin'); |
| 55: require PUN_ROOT.'header.php'; |
| 56: |
| 57: generate_admin_menu('groups'); |
| 58: |
| 59: ?> |
| 60: <div class="blockform"> |
| 61: <h2><span><?php echo $lang_admin_groups['Group settings head'] ?></span></h2> |
| 62: <div class="box"> |
| 63: <form id="groups2" method="post" action="admin_groups.php" onsubmit="return process_form(this)"> |
| 64: <p class="submittop"><input type="submit" name="add_edit_group" value="<?php echo $lang_admin_common['Save'] ?>" /></p> |
| 65: <div class="inform"> |
| 66: <input type="hidden" name="mode" value="<?php echo $mode ?>" /> |
| 67: <?php if ($mode == 'edit'): ?> <input type="hidden" name="group_id" value="<?php echo $group_id ?>" /> |
| 68: <?php endif; ?><?php if ($mode == 'add'): ?> <input type="hidden" name="base_group" value="<?php echo $base_group ?>" /> |
| 69: <?php endif; ?> <fieldset> |
| 70: <legend><?php echo $lang_admin_groups['Group settings subhead'] ?></legend> |
| 71: <div class="infldset"> |
| 72: <p><?php echo $lang_admin_groups['Group settings info'] ?></p> |
| 73: <table class="aligntop" cellspacing="0"> |
| 74: <tr> |
| 75: <th scope="row"><?php echo $lang_admin_groups['Group title label'] ?></th> |
| 76: <td> |
| 77: <input type="text" name="req_title" size="25" maxlength="50" value="<?php if ($mode == 'edit') echo pun_htmlspecialchars($group['g_title']); ?>" tabindex="1" /> |
| 78: </td> |
| 79: </tr> |
| 80: <tr> |
| 81: <th scope="row"><?php echo $lang_admin_groups['User title label'] ?></th> |
| 82: <td> |
| 83: <input type="text" name="user_title" size="25" maxlength="50" value="<?php echo pun_htmlspecialchars($group['g_user_title']) ?>" tabindex="2" /> |
| 84: <span><?php echo $lang_admin_groups['User title help'] ?></span> |
| 85: </td> |
| 86: </tr> |
| 87: <?php if ($group['g_id'] != PUN_ADMIN): if ($group['g_id'] != PUN_GUEST): if ($mode != 'edit' || $pun_config['o_default_user_group'] != $group['g_id']): ?> <tr> |
| 88: <th scope="row"> <?php echo $lang_admin_groups['Mod privileges label'] ?></th> |
| 89: <td> |
| 90: <input type="radio" name="moderator" value="1"<?php if ($group['g_moderator'] == '1') echo ' checked="checked"' ?> tabindex="3" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="moderator" value="0"<?php if ($group['g_moderator'] == '0') echo ' checked="checked"' ?> tabindex="4" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 91: <span><?php echo $lang_admin_groups['Mod privileges help'] ?></span> |
| 92: </td> |
| 93: </tr> |
| 94: <tr> |
| 95: <th scope="row"><?php echo $lang_admin_groups['Edit profile label'] ?></th> |
| 96: <td> |
| 97: <input type="radio" name="mod_edit_users" value="1"<?php if ($group['g_mod_edit_users'] == '1') echo ' checked="checked"' ?> tabindex="5" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="mod_edit_users" value="0"<?php if ($group['g_mod_edit_users'] == '0') echo ' checked="checked"' ?> tabindex="6" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 98: <span><?php echo $lang_admin_groups['Edit profile help'] ?></span> |
| 99: </td> |
| 100: </tr> |
| 101: <tr> |
| 102: <th scope="row"><?php echo $lang_admin_groups['Rename users label'] ?></th> |
| 103: <td> |
| 104: <input type="radio" name="mod_rename_users" value="1"<?php if ($group['g_mod_rename_users'] == '1') echo ' checked="checked"' ?> tabindex="7" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="mod_rename_users" value="0"<?php if ($group['g_mod_rename_users'] == '0') echo ' checked="checked"' ?> tabindex="8" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 105: <span><?php echo $lang_admin_groups['Rename users help'] ?></span> |
| 106: </td> |
| 107: </tr> |
| 108: <tr> |
| 109: <th scope="row"><?php echo $lang_admin_groups['Change passwords label'] ?></th> |
| 110: <td> |
| 111: <input type="radio" name="mod_change_passwords" value="1"<?php if ($group['g_mod_change_passwords'] == '1') echo ' checked="checked"' ?> tabindex="9" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="mod_change_passwords" value="0"<?php if ($group['g_mod_change_passwords'] == '0') echo ' checked="checked"' ?> tabindex="10" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 112: <span><?php echo $lang_admin_groups['Change passwords help'] ?></span> |
| 113: </td> |
| 114: </tr> |
| 115: <tr> |
| 116: <th scope="row"><?php echo $lang_admin_groups['Ban users label'] ?></th> |
| 117: <td> |
| 118: <input type="radio" name="mod_ban_users" value="1"<?php if ($group['g_mod_ban_users'] == '1') echo ' checked="checked"' ?> tabindex="11" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="mod_ban_users" value="0"<?php if ($group['g_mod_ban_users'] == '0') echo ' checked="checked"' ?> tabindex="12" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 119: <span><?php echo $lang_admin_groups['Ban users help'] ?></span> |
| 120: </td> |
| 121: </tr> |
| 122: <?php endif; endif; ?> <tr> |
| 123: <th scope="row"><?php echo $lang_admin_groups['Read board label'] ?></th> |
| 124: <td> |
| 125: <input type="radio" name="read_board" value="1"<?php if ($group['g_read_board'] == '1') echo ' checked="checked"' ?> tabindex="13" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="read_board" value="0"<?php if ($group['g_read_board'] == '0') echo ' checked="checked"' ?> tabindex="14" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 126: <span><?php echo $lang_admin_groups['Read board help'] ?></span> |
| 127: </td> |
| 128: </tr> |
| 129: <tr> |
| 130: <th scope="row"><?php echo $lang_admin_groups['View user info label'] ?></th> |
| 131: <td> |
| 132: <input type="radio" name="view_users" value="1"<?php if ($group['g_view_users'] == '1') echo ' checked="checked"' ?> tabindex="15" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="view_users" value="0"<?php if ($group['g_view_users'] == '0') echo ' checked="checked"' ?> tabindex="16" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 133: <span><?php echo $lang_admin_groups['View user info help'] ?></span> |
| 134: </td> |
| 135: </tr> |
| 136: <tr> |
| 137: <th scope="row"><?php echo $lang_admin_groups['Post replies label'] ?></th> |
| 138: <td> |
| 139: <input type="radio" name="post_replies" value="1"<?php if ($group['g_post_replies'] == '1') echo ' checked="checked"' ?> tabindex="17" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="post_replies" value="0"<?php if ($group['g_post_replies'] == '0') echo ' checked="checked"' ?> tabindex="18" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 140: <span><?php echo $lang_admin_groups['Post replies help'] ?></span> |
| 141: </td> |
| 142: </tr> |
| 143: <tr> |
| 144: <th scope="row"><?php echo $lang_admin_groups['Post topics label'] ?></th> |
| 145: <td> |
| 146: <input type="radio" name="post_topics" value="1"<?php if ($group['g_post_topics'] == '1') echo ' checked="checked"' ?> tabindex="19" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="post_topics" value="0"<?php if ($group['g_post_topics'] == '0') echo ' checked="checked"' ?> tabindex="20" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 147: <span><?php echo $lang_admin_groups['Post topics help'] ?></span> |
| 148: </td> |
| 149: </tr> |
| 150: <?php if ($group['g_id'] != PUN_GUEST): ?> <tr> |
| 151: <th scope="row"><?php echo $lang_admin_groups['Edit posts label'] ?></th> |
| 152: <td> |
| 153: <input type="radio" name="edit_posts" value="1"<?php if ($group['g_edit_posts'] == '1') echo ' checked="checked"' ?> tabindex="21" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="edit_posts" value="0"<?php if ($group['g_edit_posts'] == '0') echo ' checked="checked"' ?> tabindex="22" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 154: <span><?php echo $lang_admin_groups['Edit posts help'] ?></span> |
| 155: </td> |
| 156: </tr> |
| 157: <tr> |
| 158: <th scope="row"><?php echo $lang_admin_groups['Delete posts label'] ?></th> |
| 159: <td> |
| 160: <input type="radio" name="delete_posts" value="1"<?php if ($group['g_delete_posts'] == '1') echo ' checked="checked"' ?> tabindex="23" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="delete_posts" value="0"<?php if ($group['g_delete_posts'] == '0') echo ' checked="checked"' ?> tabindex="24" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 161: <span><?php echo $lang_admin_groups['Delete posts help'] ?></span> |
| 162: </td> |
| 163: </tr> |
| 164: <tr> |
| 165: <th scope="row"><?php echo $lang_admin_groups['Delete topics label'] ?></th> |
| 166: <td> |
| 167: <input type="radio" name="delete_topics" value="1"<?php if ($group['g_delete_topics'] == '1') echo ' checked="checked"' ?> tabindex="25" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="delete_topics" value="0"<?php if ($group['g_delete_topics'] == '0') echo ' checked="checked"' ?> tabindex="26" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 168: <span><?php echo $lang_admin_groups['Delete topics help'] ?></span> |
| 169: </td> |
| 170: </tr> |
| 171: <tr> |
| 172: <th scope="row"><?php echo $lang_admin_groups['Set own title label'] ?></th> |
| 173: <td> |
| 174: <input type="radio" name="set_title" value="1"<?php if ($group['g_set_title'] == '1') echo ' checked="checked"' ?> tabindex="27" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="set_title" value="0"<?php if ($group['g_set_title'] == '0') echo ' checked="checked"' ?> tabindex="28" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 175: <span><?php echo $lang_admin_groups['Set own title help'] ?></span> |
| 176: </td> |
| 177: </tr> |
| 178: <?php endif; ?> <tr> |
| 179: <th scope="row"><?php echo $lang_admin_groups['User search label'] ?></th> |
| 180: <td> |
| 181: <input type="radio" name="search" value="1"<?php if ($group['g_search'] == '1') echo ' checked="checked"' ?> tabindex="29" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="search" value="0"<?php if ($group['g_search'] == '0') echo ' checked="checked"' ?> tabindex="30" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 182: <span><?php echo $lang_admin_groups['User search help'] ?></span> |
| 183: </td> |
| 184: </tr> |
| 185: <tr> |
| 186: <th scope="row"><?php echo $lang_admin_groups['User list search label'] ?></th> |
| 187: <td> |
| 188: <input type="radio" name="search_users" value="1"<?php if ($group['g_search_users'] == '1') echo ' checked="checked"' ?> tabindex="31" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="search_users" value="0"<?php if ($group['g_search_users'] == '0') echo ' checked="checked"' ?> tabindex="32" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 189: <span><?php echo $lang_admin_groups['User list search help'] ?></span> |
| 190: </td> |
| 191: </tr> |
| 192: <?php if ($group['g_id'] != PUN_GUEST): ?> <tr> |
| 193: <th scope="row"><?php echo $lang_admin_groups['Send e-mails label'] ?></th> |
| 194: <td> |
| 195: <input type="radio" name="send_email" value="1"<?php if ($group['g_send_email'] == '1') echo ' checked="checked"' ?> tabindex="33" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="send_email" value="0"<?php if ($group['g_send_email'] == '0') echo ' checked="checked"' ?> tabindex="34" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 196: <span><?php echo $lang_admin_groups['Send e-mails help'] ?></span> |
| 197: </td> |
| 198: </tr> |
| 199: <?php endif; ?> <tr> |
| 200: <th scope="row"><?php echo $lang_admin_groups['Post flood label'] ?></th> |
| 201: <td> |
| 202: <input type="text" name="post_flood" size="5" maxlength="4" value="<?php echo $group['g_post_flood'] ?>" tabindex="35" /> |
| 203: <span><?php echo $lang_admin_groups['Post flood help'] ?></span> |
| 204: </td> |
| 205: </tr> |
| 206: <tr> |
| 207: <th scope="row"><?php echo $lang_admin_groups['Search flood label'] ?></th> |
| 208: <td> |
| 209: <input type="text" name="search_flood" size="5" maxlength="4" value="<?php echo $group['g_search_flood'] ?>" tabindex="36" /> |
| 210: <span><?php echo $lang_admin_groups['Search flood help'] ?></span> |
| 211: </td> |
| 212: </tr> |
| 213: <?php if ($group['g_id'] != PUN_GUEST): ?> <tr> |
| 214: <th scope="row"><?php echo $lang_admin_groups['E-mail flood label'] ?></th> |
| 215: <td> |
| 216: <input type="text" name="email_flood" size="5" maxlength="4" value="<?php echo $group['g_email_flood'] ?>" tabindex="37" /> |
| 217: <span><?php echo $lang_admin_groups['E-mail flood help'] ?></span> |
| 218: </td> |
| 219: </tr> |
| 220: <tr> |
| 221: <th scope="row"><?php echo $lang_admin_groups['Report flood label'] ?></th> |
| 222: <td> |
| 223: <input type="text" name="report_flood" size="5" maxlength="4" value="<?php echo $group['g_report_flood'] ?>" tabindex="38" /> |
| 224: <span><?php echo $lang_admin_groups['Report flood help'] ?></span> |
| 225: </td> |
| 226: </tr> |
| 227: <?php endif; endif; ?> </table> |
| 228: <?php if ($group['g_moderator'] == '1' ): ?> <p class="warntext"><?php echo $lang_admin_groups['Moderator info'] ?></p> |
| 229: <?php endif; ?> </div> |
| 230: </fieldset> |
| 231: </div> |
| 232: <p class="submitend"><input type="submit" name="add_edit_group" value="<?php echo $lang_admin_common['Save'] ?>" tabindex="39" /></p> |
| 233: </form> |
| 234: </div> |
| 235: </div> |
| 236: <div class="clearer"></div> |
| 237: </div> |
| 238: <?php |
| 239: |
| 240: require PUN_ROOT.'footer.php'; |
| 241: } |
| 242: |
| 243: |
| 244: // Add/edit a group (stage 2) |
| 245: else if (isset($_POST['add_edit_group'])) |
| 246: { |
| 247: confirm_referrer('admin_groups.php'); |
| 248: |
| 249: // Is this the admin group? (special rules apply) |
| 250: $is_admin_group = (isset($_POST['group_id']) && $_POST['group_id'] == PUN_ADMIN) ? true : false; |
| 251: |
| 252: $title = pun_trim($_POST['req_title']); |
| 253: $user_title = pun_trim($_POST['user_title']); |
| 254: $moderator = isset($_POST['moderator']) && $_POST['moderator'] == '1' ? '1' : '0'; |
| 255: $mod_edit_users = $moderator == '1' && isset($_POST['mod_edit_users']) && $_POST['mod_edit_users'] == '1' ? '1' : '0'; |
| 256: $mod_rename_users = $moderator == '1' && isset($_POST['mod_rename_users']) && $_POST['mod_rename_users'] == '1' ? '1' : '0'; |
| 257: $mod_change_passwords = $moderator == '1' && isset($_POST['mod_change_passwords']) && $_POST['mod_change_passwords'] == '1' ? '1' : '0'; |
| 258: $mod_ban_users = $moderator == '1' && isset($_POST['mod_ban_users']) && $_POST['mod_ban_users'] == '1' ? '1' : '0'; |
| 259: $read_board = isset($_POST['read_board']) ? intval($_POST['read_board']) : '1'; |
| 260: $view_users = (isset($_POST['view_users']) && $_POST['view_users'] == '1') || $is_admin_group ? '1' : '0'; |
| 261: $post_replies = isset($_POST['post_replies']) ? intval($_POST['post_replies']) : '1'; |
| 262: $post_topics = isset($_POST['post_topics']) ? intval($_POST['post_topics']) : '1'; |
| 263: $edit_posts = isset($_POST['edit_posts']) ? intval($_POST['edit_posts']) : ($is_admin_group) ? '1' : '0'; |
| 264: $delete_posts = isset($_POST['delete_posts']) ? intval($_POST['delete_posts']) : ($is_admin_group) ? '1' : '0'; |
| 265: $delete_topics = isset($_POST['delete_topics']) ? intval($_POST['delete_topics']) : ($is_admin_group) ? '1' : '0'; |
| 266: $set_title = isset($_POST['set_title']) ? intval($_POST['set_title']) : ($is_admin_group) ? '1' : '0'; |
| 267: $search = isset($_POST['search']) ? intval($_POST['search']) : '1'; |
| 268: $search_users = isset($_POST['search_users']) ? intval($_POST['search_users']) : '1'; |
| 269: $send_email = (isset($_POST['send_email']) && $_POST['send_email'] == '1') || $is_admin_group ? '1' : '0'; |
| 270: $post_flood = (isset($_POST['post_flood']) && $_POST['post_flood'] >= 0) ? intval($_POST['post_flood']) : '0'; |
| 271: $search_flood = (isset($_POST['search_flood']) && $_POST['search_flood'] >= 0) ? intval($_POST['search_flood']) : '0'; |
| 272: $email_flood = (isset($_POST['email_flood']) && $_POST['email_flood'] >= 0) ? intval($_POST['email_flood']) : '0'; |
| 273: $report_flood = (isset($_POST['report_flood']) && $_POST['report_flood'] >= 0) ? intval($_POST['report_flood']) : '0'; |
| 274: |
| 275: if ($title == '') |
| 276: message($lang_admin_groups['Must enter title message']); |
| 277: |
| 278: $user_title = ($user_title != '') ? '\''.$db->escape($user_title).'\'' : 'NULL'; |
| 279: |
| 280: if ($_POST['mode'] == 'add') |
| 281: { |
| 282: $result = $db->query('SELECT 1 FROM '.$db->prefix.'groups WHERE g_title=\''.$db->escape($title).'\'') or error('Unable to check group title collision', __FILE__, __LINE__, $db->error()); |
| 283: if ($db->num_rows($result)) |
| 284: message(sprintf($lang_admin_groups['Title already exists message'], pun_htmlspecialchars($title))); |
| 285: |
| 286: $db->query('INSERT INTO '.$db->prefix.'groups (g_title, g_user_title, g_moderator, g_mod_edit_users, g_mod_rename_users, g_mod_change_passwords, g_mod_ban_users, g_read_board, g_view_users, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_send_email, g_post_flood, g_search_flood, g_email_flood, g_report_flood) VALUES(\''.$db->escape($title).'\', '.$user_title.', '.$moderator.', '.$mod_edit_users.', '.$mod_rename_users.', '.$mod_change_passwords.', '.$mod_ban_users.', '.$read_board.', '.$view_users.', '.$post_replies.', '.$post_topics.', '.$edit_posts.', '.$delete_posts.', '.$delete_topics.', '.$set_title.', '.$search.', '.$search_users.', '.$send_email.', '.$post_flood.', '.$search_flood.', '.$email_flood.', '.$report_flood.')') or error('Unable to add group', __FILE__, __LINE__, $db->error()); |
| 287: $new_group_id = $db->insert_id(); |
| 288: |
| 289: // Now lets copy the forum specific permissions from the group which this group is based on |
| 290: $result = $db->query('SELECT forum_id, read_forum, post_replies, post_topics FROM '.$db->prefix.'forum_perms WHERE group_id='.intval($_POST['base_group'])) or error('Unable to fetch group forum permission list', __FILE__, __LINE__, $db->error()); |
| 291: while ($cur_forum_perm = $db->fetch_assoc($result)) |
| 292: $db->query('INSERT INTO '.$db->prefix.'forum_perms (group_id, forum_id, read_forum, post_replies, post_topics) VALUES('.$new_group_id.', '.$cur_forum_perm['forum_id'].', '.$cur_forum_perm['read_forum'].', '.$cur_forum_perm['post_replies'].', '.$cur_forum_perm['post_topics'].')') or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error()); |
| 293: } |
| 294: else |
| 295: { |
| 296: $result = $db->query('SELECT 1 FROM '.$db->prefix.'groups WHERE g_title=\''.$db->escape($title).'\' AND g_id!='.intval($_POST['group_id'])) or error('Unable to check group title collision', __FILE__, __LINE__, $db->error()); |
| 297: if ($db->num_rows($result)) |
| 298: message(sprintf($lang_admin_groups['Title already exists message'], pun_htmlspecialchars($title))); |
| 299: |
| 300: $db->query('UPDATE '.$db->prefix.'groups SET g_title=\''.$db->escape($title).'\', g_user_title='.$user_title.', g_moderator='.$moderator.', g_mod_edit_users='.$mod_edit_users.', g_mod_rename_users='.$mod_rename_users.', g_mod_change_passwords='.$mod_change_passwords.', g_mod_ban_users='.$mod_ban_users.', g_read_board='.$read_board.', g_view_users='.$view_users.', g_post_replies='.$post_replies.', g_post_topics='.$post_topics.', g_edit_posts='.$edit_posts.', g_delete_posts='.$delete_posts.', g_delete_topics='.$delete_topics.', g_set_title='.$set_title.', g_search='.$search.', g_search_users='.$search_users.', g_send_email='.$send_email.', g_post_flood='.$post_flood.', g_search_flood='.$search_flood.', g_email_flood='.$email_flood.', g_report_flood='.$report_flood.' WHERE g_id='.intval($_POST['group_id'])) or error('Unable to update group', __FILE__, __LINE__, $db->error()); |
| 301: } |
| 302: |
| 303: // Regenerate the quick jump cache |
| 304: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| 305: require PUN_ROOT.'include/cache.php'; |
| 306: |
| 307: $group_id = $_POST['mode'] == 'add' ? $new_group_id : intval($_POST['group_id']); |
| 308: generate_quickjump_cache($group_id); |
| 309: |
| 310: if ($_POST['mode'] == 'edit') |
| 311: redirect('admin_groups.php', $lang_admin_groups['Group edited redirect']); |
| 312: else |
| 313: redirect('admin_groups.php', $lang_admin_groups['Group added redirect']); |
| 314: } |
| 315: |
| 316: |
| 317: // Set default group |
| 318: else if (isset($_POST['set_default_group'])) |
| 319: { |
| 320: confirm_referrer('admin_groups.php'); |
| 321: |
| 322: $group_id = intval($_POST['default_group']); |
| 323: |
| 324: // Make sure it's not the admin or guest groups |
| 325: if ($group_id == PUN_ADMIN || $group_id == PUN_GUEST) |
| 326: message($lang_common['Bad request']); |
| 327: |
| 328: // Make sure it's not a moderator group |
| 329: $result = $db->query('SELECT 1 FROM '.$db->prefix.'groups WHERE g_id='.$group_id.' AND g_moderator=0') or error('Unable to check group moderator status', __FILE__, __LINE__, $db->error()); |
| 330: if (!$db->num_rows($result)) |
| 331: message($lang_common['Bad request']); |
| 332: |
| 333: $db->query('UPDATE '.$db->prefix.'config SET conf_value='.$group_id.' WHERE conf_name=\'o_default_user_group\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error()); |
| 334: |
| 335: // Regenerate the config cache |
| 336: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| 337: require PUN_ROOT.'include/cache.php'; |
| 338: |
| 339: generate_config_cache(); |
| 340: |
| 341: redirect('admin_groups.php', $lang_admin_groups['Default group redirect']); |
| 342: } |
| 343: |
| 344: |
| 345: // Remove a group |
| 346: else if (isset($_GET['del_group'])) |
| 347: { |
| 348: confirm_referrer('admin_groups.php'); |
| 349: |
| 350: $group_id = isset($_POST['group_to_delete']) ? intval($_POST['group_to_delete']) : intval($_GET['del_group']); |
| 351: if ($group_id < 5) |
| 352: message($lang_common['Bad request']); |
| 353: |
| 354: // Make sure we don't remove the default group |
| 355: if ($group_id == $pun_config['o_default_user_group']) |
| 356: message($lang_admin_groups['Cannot remove default message']); |
| 357: |
| 358: // Check if this group has any members |
| 359: $result = $db->query('SELECT g.g_title, COUNT(u.id) FROM '.$db->prefix.'groups AS g INNER JOIN '.$db->prefix.'users AS u ON g.g_id=u.group_id WHERE g.g_id='.$group_id.' GROUP BY g.g_id, g_title') or error('Unable to fetch group info', __FILE__, __LINE__, $db->error()); |
| 360: |
| 361: // If the group doesn't have any members or if we've already selected a group to move the members to |
| 362: if (!$db->num_rows($result) || isset($_POST['del_group'])) |
| 363: { |
| 364: if (isset($_POST['del_group_comply']) || isset($_POST['del_group'])) |
| 365: { |
| 366: if (isset($_POST['del_group'])) |
| 367: { |
| 368: $move_to_group = intval($_POST['move_to_group']); |
| 369: $db->query('UPDATE '.$db->prefix.'users SET group_id='.$move_to_group.' WHERE group_id='.$group_id) or error('Unable to move users into group', __FILE__, __LINE__, $db->error()); |
| 370: } |
| 371: |
| 372: // Delete the group and any forum specific permissions |
| 373: $db->query('DELETE FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to delete group', __FILE__, __LINE__, $db->error()); |
| 374: $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE group_id='.$group_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error()); |
| 375: |
| 376: redirect('admin_groups.php', $lang_admin_groups['Group removed redirect']); |
| 377: } |
| 378: else |
| 379: { |
| 380: $result = $db->query('SELECT g_title FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to fetch group title', __FILE__, __LINE__, $db->error()); |
| 381: $group_title = $db->result($result); |
| 382: |
| 383: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']); |
| 384: define('PUN_ACTIVE_PAGE', 'admin'); |
| 385: require PUN_ROOT.'header.php'; |
| 386: |
| 387: generate_admin_menu('groups'); |
| 388: |
| 389: ?> |
| 390: <div class="blockform"> |
| 391: <h2><span><?php echo $lang_admin_groups['Group delete head'] ?></span></h2> |
| 392: <div class="box"> |
| 393: <form method="post" action="admin_groups.php?del_group=<?php echo $group_id ?>"> |
| 394: <div class="inform"> |
| 395: <input type="hidden" name="group_to_delete" value="<?php echo $group_id ?>" /> |
| 396: <fieldset> |
| 397: <legend><?php echo $lang_admin_groups['Confirm delete subhead'] ?></legend> |
| 398: <div class="infldset"> |
| 399: <p><?php printf($lang_admin_groups['Confirm delete info'], pun_htmlspecialchars($group_title)) ?></p> |
| 400: <p class="warntext"><?php echo $lang_admin_groups['Confirm delete warn'] ?></p> |
| 401: </div> |
| 402: </fieldset> |
| 403: </div> |
| 404: <p class="buttons"><input type="submit" name="del_group_comply" value="<?php echo $lang_admin_common['Delete'] ?>" tabindex="1" /><a href="javascript:history.go(-1)" tabindex="2"><?php echo $lang_admin_common['Go back'] ?></a></p> |
| 405: </form> |
| 406: </div> |
| 407: </div> |
| 408: <div class="clearer"></div> |
| 409: </div> |
| 410: <?php |
| 411: |
| 412: require PUN_ROOT.'footer.php'; |
| 413: } |
| 414: } |
| 415: |
| 416: list($group_title, $group_members) = $db->fetch_row($result); |
| 417: |
| 418: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']); |
| 419: define('PUN_ACTIVE_PAGE', 'admin'); |
| 420: require PUN_ROOT.'header.php'; |
| 421: |
| 422: generate_admin_menu('groups'); |
| 423: |
| 424: ?> |
| 425: <div class="blockform"> |
| 426: <h2><span><?php echo $lang_admin_groups['Delete group head'] ?></span></h2> |
| 427: <div class="box"> |
| 428: <form id="groups" method="post" action="admin_groups.php?del_group=<?php echo $group_id ?>"> |
| 429: <div class="inform"> |
| 430: <fieldset> |
| 431: <legend><?php echo $lang_admin_groups['Move users subhead'] ?></legend> |
| 432: <div class="infldset"> |
| 433: <p><?php printf($lang_admin_groups['Move users info'], pun_htmlspecialchars($group_title), forum_number_format($group_members)) ?></p> |
| 434: <label><?php echo $lang_admin_groups['Move users label'] ?> |
| 435: <select name="move_to_group"> |
| 436: <?php |
| 437: |
| 438: $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_GUEST.' AND g_id!='.$group_id.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); |
| 439: |
| 440: while ($cur_group = $db->fetch_assoc($result)) |
| 441: { |
| 442: if ($cur_group['g_id'] == PUN_MEMBER) // Pre-select the pre-defined Members group |
| 443: echo "\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
| 444: else |
| 445: echo "\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
| 446: } |
| 447: |
| 448: ?> |
| 449: </select> |
| 450: <br /></label> |
| 451: </div> |
| 452: </fieldset> |
| 453: </div> |
| 454: <p class="buttons"><input type="submit" name="del_group" value="<?php echo $lang_admin_groups['Delete group'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_admin_common['Go back'] ?></a></p> |
| 455: </form> |
| 456: </div> |
| 457: </div> |
| 458: <div class="clearer"></div> |
| 459: </div> |
| 460: <?php |
| 461: |
| 462: require PUN_ROOT.'footer.php'; |
| 463: } |
| 464: |
| 465: |
| 466: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']); |
| 467: define('PUN_ACTIVE_PAGE', 'admin'); |
| 468: require PUN_ROOT.'header.php'; |
| 469: |
| 470: generate_admin_menu('groups'); |
| 471: |
| 472: ?> |
| 473: <div class="blockform"> |
| 474: <h2><span><?php echo $lang_admin_groups['Add groups head'] ?></span></h2> |
| 475: <div class="box"> |
| 476: <form id="groups" method="post" action="admin_groups.php"> |
| 477: <div class="inform"> |
| 478: <fieldset> |
| 479: <legend><?php echo $lang_admin_groups['Add group subhead'] ?></legend> |
| 480: <div class="infldset"> |
| 481: <table class="aligntop" cellspacing="0"> |
| 482: <tr> |
| 483: <th scope="row"><?php echo $lang_admin_groups['New group label'] ?><div><input type="submit" name="add_group" value="<?php echo $lang_admin_common['Add'] ?>" tabindex="2" /></div></th> |
| 484: <td> |
| 485: <select id="base_group" name="base_group" tabindex="1"> |
| 486: <?php |
| 487: |
| 488: $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_ADMIN.' AND g_id!='.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); |
| 489: |
| 490: while ($cur_group = $db->fetch_assoc($result)) |
| 491: { |
| 492: if ($cur_group['g_id'] == $pun_config['o_default_user_group']) |
| 493: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
| 494: else |
| 495: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
| 496: } |
| 497: |
| 498: ?> |
| 499: </select> |
| 500: <span><?php echo $lang_admin_groups['New group help'] ?></span> |
| 501: </td> |
| 502: </tr> |
| 503: </table> |
| 504: </div> |
| 505: </fieldset> |
| 506: </div> |
| 507: <div class="inform"> |
| 508: <fieldset> |
| 509: <legend><?php echo $lang_admin_groups['Default group subhead'] ?></legend> |
| 510: <div class="infldset"> |
| 511: <table class="aligntop" cellspacing="0"> |
| 512: <tr> |
| 513: <th scope="row"><?php echo $lang_admin_groups['Default group label'] ?><div><input type="submit" name="set_default_group" value="<?php echo $lang_admin_common['Save'] ?>" tabindex="4" /></div></th> |
| 514: <td> |
| 515: <select id="default_group" name="default_group" tabindex="3"> |
| 516: <?php |
| 517: |
| 518: $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id>'.PUN_GUEST.' AND g_moderator=0 ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); |
| 519: |
| 520: while ($cur_group = $db->fetch_assoc($result)) |
| 521: { |
| 522: if ($cur_group['g_id'] == $pun_config['o_default_user_group']) |
| 523: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'" selected="selected">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
| 524: else |
| 525: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n"; |
| 526: } |
| 527: |
| 528: ?> |
| 529: </select> |
| 530: <span><?php echo $lang_admin_groups['Default group help'] ?></span> |
| 531: </td> |
| 532: </tr> |
| 533: </table> |
| 534: </div> |
| 535: </fieldset> |
| 536: </div> |
| 537: </form> |
| 538: </div> |
| 539: |
| 540: <h2 class="block2"><span><?php echo $lang_admin_groups['Existing groups head'] ?></span></h2> |
| 541: <div class="box"> |
| 542: <div class="fakeform"> |
| 543: <div class="inform"> |
| 544: <fieldset> |
| 545: <legend><?php echo $lang_admin_groups['Edit groups subhead'] ?></legend> |
| 546: <div class="infldset"> |
| 547: <p><?php echo $lang_admin_groups['Edit groups info'] ?></p> |
| 548: <table cellspacing="0"> |
| 549: <?php |
| 550: |
| 551: $cur_index = 5; |
| 552: |
| 553: $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups ORDER BY g_id') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); |
| 554: |
| 555: while ($cur_group = $db->fetch_assoc($result)) |
| 556: echo "\t\t\t\t\t\t\t\t".'<tr><th scope="row"><a href="admin_groups.php?edit_group='.$cur_group['g_id'].'" tabindex="'.$cur_index++.'">'.$lang_admin_groups['Edit link'].'</a>'.(($cur_group['g_id'] > PUN_MEMBER) ? ' | <a href="admin_groups.php?del_group='.$cur_group['g_id'].'" tabindex="'.$cur_index++.'">'.$lang_admin_groups['Delete link'].'</a>' : '').'</th><td>'.pun_htmlspecialchars($cur_group['g_title']).'</td></tr>'."\n"; |
| 557: |
| 558: ?> |
| 559: </table> |
| 560: </div> |
| 561: </fieldset> |
| 562: </div> |
| 563: </div> |
| 564: </div> |
| 565: </div> |
| 566: <div class="clearer"></div> |
| 567: </div> |
| 568: <?php |
| 569: |
| 570: require PUN_ROOT.'footer.php'; |
/dev/null |
b/admin_index.php |
| 1: <?php |
| 2: |
| 3: /** |
| 4: * Copyright (C) 2008-2012 FluxBB |
| 5: * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB |
| 6: * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher |
| 7: */ |
| 8: |
| 9: // Tell header.php to use the admin template |
| 10: define('PUN_ADMIN_CONSOLE', 1); |
| 11: |
| 12: define('PUN_ROOT', dirname(__FILE__).'/'); |
| 13: require PUN_ROOT.'include/common.php'; |
| 14: require PUN_ROOT.'include/common_admin.php'; |
| 15: |
| 16: |
| 17: if (!$pun_user['is_admmod']) |
| 18: message($lang_common['No permission'], false, '403 Forbidden'); |
| 19: |
| 20: // Load the admin_index.php language file |
| 21: require PUN_ROOT.'lang/'.$admin_language.'/admin_index.php'; |
| 22: |
| 23: $action = isset($_GET['action']) ? $_GET['action'] : null; |
| 24: |
| 25: // Check for upgrade |
| 26: if ($action == 'check_upgrade') |
| 27: { |
| 28: if (!ini_get('allow_url_fopen')) |
| 29: message($lang_admin_index['fopen disabled message']); |
| 30: |
| 31: $latest_version = trim(@file_get_contents('http://fluxbb.org/latest_version')); |
| 32: if (empty($latest_version)) |
| 33: message($lang_admin_index['Upgrade check failed message']); |
| 34: |
| 35: if (version_compare($pun_config['o_cur_version'], $latest_version, '>=')) |
| 36: message($lang_admin_index['Running latest version message']); |
| 37: else |
| 38: message(sprintf($lang_admin_index['New version available message'], '<a href="http://fluxbb.org/">FluxBB.org</a>')); |
| 39: } |
| 40: |
| 41: |
| 42: // Show phpinfo() output |
| 43: else if ($action == 'phpinfo' && $pun_user['g_id'] == PUN_ADMIN) |
| 44: { |
| 45: // Is phpinfo() a disabled function? |
| 46: if (strpos(strtolower((string) ini_get('disable_functions')), 'phpinfo') !== false) |
| 47: message($lang_admin_index['PHPinfo disabled message']); |
| 48: |
| 49: phpinfo(); |
| 50: exit; |
| 51: } |
| 52: |
| 53: |
| 54: // Get the server load averages (if possible) |
| 55: if (@file_exists('/proc/loadavg') && is_readable('/proc/loadavg')) |
| 56: { |
| 57: // We use @ just in case |
| 58: $fh = @fopen('/proc/loadavg', 'r'); |
| 59: $load_averages = @fread($fh, 64); |
| 60: @fclose($fh); |
| 61: |
| 62: if (($fh = @fopen('/proc/loadavg', 'r'))) |
| 63: { |
| 64: $load_averages = fread($fh, 64); |
| 65: fclose($fh); |
| 66: } |
| 67: else |
| 68: $load_averages = ''; |
| 69: |
| 70: $load_averages = @explode(' ', $load_averages); |
| 71: $server_load = isset($load_averages[2]) ? $load_averages[0].' '.$load_averages[1].' '.$load_averages[2] : $lang_admin_index['Not available']; |
| 72: } |
| 73: else if (!in_array(PHP_OS, array('WINNT', 'WIN32')) && preg_match('%averages?: ([0-9\.]+),?\s+([0-9\.]+),?\s+([0-9\.]+)%i', @exec('uptime'), $load_averages)) |
| 74: $server_load = $load_averages[1].' '.$load_averages[2].' '.$load_averages[3]; |
| 75: else |
| 76: $server_load = $lang_admin_index['Not available']; |
| 77: |
| 78: |
| 79: // Get number of current visitors |
| 80: $result = $db->query('SELECT COUNT(user_id) FROM '.$db->prefix.'online WHERE idle=0') or error('Unable to fetch online count', __FILE__, __LINE__, $db->error()); |
| 81: $num_online = $db->result($result); |
| 82: |
| 83: |
| 84: // Collect some additional info about MySQL |
| 85: if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb') |
| 86: { |
| 87: // Calculate total db size/row count |
| 88: $result = $db->query('SHOW TABLE STATUS LIKE \''.$db->prefix.'%\'') or error('Unable to fetch table status', __FILE__, __LINE__, $db->error()); |
| 89: |
| 90: $total_records = $total_size = 0; |
| 91: while ($status = $db->fetch_assoc($result)) |
| 92: { |
| 93: $total_records += $status['Rows']; |
| 94: $total_size += $status['Data_length'] + $status['Index_length']; |
| 95: } |
| 96: |
| 97: $total_size = file_size($total_size); |
| 98: } |
| 99: |
| 100: |
| 101: // Check for the existence of various PHP opcode caches/optimizers |
| 102: if (function_exists('mmcache')) |
| 103: $php_accelerator = '<a href="http://'.$lang_admin_index['Turck MMCache link'].'">'.$lang_admin_index['Turck MMCache'].'</a>'; |
| 104: else if (isset($_PHPA)) |
| 105: $php_accelerator = '<a href="http://'.$lang_admin_index['ionCube PHP Accelerator link'].'">'.$lang_admin_index['ionCube PHP Accelerator'].'</a>'; |
| 106: else if (ini_get('apc.enabled')) |
| 107: $php_accelerator ='<a href="http://'.$lang_admin_index['Alternative PHP Cache (APC) link'].'">'.$lang_admin_index['Alternative PHP Cache (APC)'].'</a>'; |
| 108: else if (ini_get('zend_optimizer.optimization_level')) |
| 109: $php_accelerator = '<a href="http://'.$lang_admin_index['Zend Optimizer link'].'">'.$lang_admin_index['Zend Optimizer'].'</a>'; |
| 110: else if (ini_get('eaccelerator.enable')) |
| 111: $php_accelerator = '<a href="http://'.$lang_admin_index['eAccelerator link'].'">'.$lang_admin_index['eAccelerator'].'</a>'; |
| 112: else if (ini_get('xcache.cacher')) |
| 113: $php_accelerator = '<a href="http://'.$lang_admin_index['XCache link'].'">'.$lang_admin_index['XCache'].'</a>'; |
| 114: else |
| 115: $php_accelerator = $lang_admin_index['NA']; |
| 116: |
| 117: |
| 118: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Index']); |
| 119: define('PUN_ACTIVE_PAGE', 'admin'); |
| 120: require PUN_ROOT.'header.php'; |
| 121: |
| 122: generate_admin_menu('index'); |
| 123: |
| 124: ?> |
| 125: <div class="block"> |
| 126: <h2><span><?php echo $lang_admin_index['Forum admin head'] ?></span></h2> |
| 127: <div id="adintro" class="box"> |
| 128: <div class="inbox"> |
| 129: <p><?php echo $lang_admin_index['Welcome to admin'] ?></p> |
| 130: <ul> |
| 131: <li><span><?php echo $lang_admin_index['Welcome 1'] ?></span></li> |
| 132: <li><span><?php echo $lang_admin_index['Welcome 2'] ?></span></li> |
| 133: <li><span><?php echo $lang_admin_index['Welcome 3'] ?></span></li> |
| 134: <li><span><?php echo $lang_admin_index['Welcome 4'] ?></span></li> |
| 135: <li><span><?php echo $lang_admin_index['Welcome 5'] ?></span></li> |
| 136: <li><span><?php echo $lang_admin_index['Welcome 6'] ?></span></li> |
| 137: <li><span><?php echo $lang_admin_index['Welcome 7'] ?></span></li> |
| 138: <li><span><?php echo $lang_admin_index['Welcome 8'] ?></span></li> |
| 139: <li><span><?php echo $lang_admin_index['Welcome 9'] ?></span></li> |
| 140: </ul> |
| 141: </div> |
| 142: </div> |
| 143: |
| 144: <h2 class="block2"><span><?php echo $lang_admin_index['Statistics head'] ?></span></h2> |
| 145: <div id="adstats" class="box"> |
| 146: <div class="inbox"> |
| 147: <dl> |
| 148: <dt><?php echo $lang_admin_index['FluxBB version label'] ?></dt> |
| 149: <dd> |
| 150: <?php printf($lang_admin_index['FluxBB version data']."\n", $pun_config['o_cur_version'], '<a href="admin_index.php?action=check_upgrade">'.$lang_admin_index['Check for upgrade'].'</a>') ?> |
| 151: </dd> |
| 152: <dt><?php echo $lang_admin_index['Server load label'] ?></dt> |
| 153: <dd> |
| 154: <?php printf($lang_admin_index['Server load data']."\n", $server_load, $num_online) ?> |
| 155: </dd> |
| 156: <?php if ($pun_user['g_id'] == PUN_ADMIN): ?> <dt><?php echo $lang_admin_index['Environment label'] ?></dt> |
| 157: <dd> |
| 158: <?php printf($lang_admin_index['Environment data OS'], PHP_OS) ?><br /> |
| 159: <?php printf($lang_admin_index['Environment data version'], phpversion(), '<a href="admin_index.php?action=phpinfo">'.$lang_admin_index['Show info'].'</a>') ?><br /> |
| 160: <?php printf($lang_admin_index['Environment data acc']."\n", $php_accelerator) ?> |
| 161: </dd> |
| 162: <dt><?php echo $lang_admin_index['Database label'] ?></dt> |
| 163: <dd> |
| 164: <?php echo implode(' ', $db->get_version())."\n" ?> |
| 165: <?php if (isset($total_records) && isset($total_size)): ?> <br /><?php printf($lang_admin_index['Database data rows']."\n", forum_number_format($total_records)) ?> |
| 166: <br /><?php printf($lang_admin_index['Database data size']."\n", $total_size) ?> |
| 167: <?php endif; ?> </dd> |
| 168: <?php endif; ?> |
| 169: </dl> |
| 170: </div> |
| 171: </div> |
| 172: </div> |
| 173: <div class="clearer"></div> |
| 174: </div> |
| 175: <?php |
| 176: |
| 177: require PUN_ROOT.'footer.php'; |
/dev/null |
b/admin_maintenance.php |
| 1: <?php |
| 2: |
| 3: /** |
| 4: * Copyright (C) 2008-2012 FluxBB |
| 5: * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB |
| 6: * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher |
| 7: */ |
| 8: |
| 9: // Tell header.php to use the admin template |
| 10: define('PUN_ADMIN_CONSOLE', 1); |
| 11: // Tell common.php that we don't want output buffering |
| 12: define('PUN_DISABLE_BUFFERING', 1); |
| 13: |
| 14: define('PUN_ROOT', dirname(__FILE__).'/'); |
| 15: require PUN_ROOT.'include/common.php'; |
| 16: require PUN_ROOT.'include/common_admin.php'; |
| 17: |
| 18: |
| 19: if ($pun_user['g_id'] != PUN_ADMIN) |
| 20: message($lang_common['No permission'], false, '403 Forbidden'); |
| 21: |
| 22: // Load the admin_maintenance.php language file |
| 23: require PUN_ROOT.'lang/'.$admin_language.'/admin_maintenance.php'; |
| 24: |
| 25: $action = isset($_REQUEST['action']) ? pun_trim($_REQUEST['action']) : ''; |
| 26: |
| 27: if ($action == 'rebuild') |
| 28: { |
| 29: $per_page = isset($_GET['i_per_page']) ? intval($_GET['i_per_page']) : 0; |
| 30: $start_at = isset($_GET['i_start_at']) ? intval($_GET['i_start_at']) : 0; |
| 31: |
| 32: // Check per page is > 0 |
| 33: if ($per_page < 1) |
| 34: message($lang_admin_maintenance['Posts must be integer message']); |
| 35: |
| 36: @set_time_limit(0); |
| 37: |
| 38: // If this is the first cycle of posts we empty the search index before we proceed |
| 39: if (isset($_GET['i_empty_index'])) |
| 40: { |
| 41: // This is the only potentially "dangerous" thing we can do here, so we check the referer |
| 42: confirm_referrer('admin_maintenance.php'); |
| 43: |
| 44: $db->truncate_table('search_matches') or error('Unable to empty search index match table', __FILE__, __LINE__, $db->error()); |
| 45: $db->truncate_table('search_words') or error('Unable to empty search index words table', __FILE__, __LINE__, $db->error()); |
| 46: |
| 47: // Reset the sequence for the search words (not needed for SQLite) |
| 48: switch ($db_type) |
| 49: { |
| 50: case 'mysql': |
| 51: case 'mysqli': |
| 52: case 'mysql_innodb': |
| 53: case 'mysqli_innodb': |
| 54: $result = $db->query('ALTER TABLE '.$db->prefix.'search_words auto_increment=1') or error('Unable to update table auto_increment', __FILE__, __LINE__, $db->error()); |
| 55: break; |
| 56: |
| 57: case 'pgsql'; |
| 58: $result = $db->query('SELECT setval(\''.$db->prefix.'search_words_id_seq\', 1, false)') or error('Unable to update sequence', __FILE__, __LINE__, $db->error()); |
| 59: } |
| 60: } |
| 61: |
| 62: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_maintenance['Rebuilding search index']); |
| 63: |
| 64: ?> |
| 65: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 66: |
| 67: <html> |
| 68: <head> |
| 69: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 70: <title><?php echo generate_page_title($page_title) ?></title> |
| 71: <style type="text/css"> |
| 72: body { |
| 73: font: 12px Verdana, Arial, Helvetica, sans-serif; |
| 74: color: #333333; |
| 75: background-color: #FFFFFF |
| 76: } |
| 77: |
| 78: h1 { |
| 79: font-size: 16px; |
| 80: font-weight: normal; |
| 81: } |
| 82: </style> |
| 83: </head> |
| 84: <body> |
| 85: |
| 86: <h1><?php echo $lang_admin_maintenance['Rebuilding index info'] ?></h1> |
| 87: <hr /> |
| 88: |
| 89: <?php |
| 90: |
| 91: $query_str = ''; |
| 92: |
| 93: require PUN_ROOT.'include/search_idx.php'; |
| 94: |
| 95: // Fetch posts to process this cycle |
| 96: $result = $db->query('SELECT p.id, p.message, t.subject, t.first_post_id FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id WHERE p.id >= '.$start_at.' ORDER BY p.id ASC LIMIT '.$per_page) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error()); |
| 97: |
| 98: $end_at = 0; |
| 99: while ($cur_item = $db->fetch_assoc($result)) |
| 100: { |
| 101: echo '<p><span>'.sprintf($lang_admin_maintenance['Processing post'], $cur_item['id']).'</span></p>'."\n"; |
| 102: |
| 103: if ($cur_item['id'] == $cur_item['first_post_id']) |
| 104: update_search_index('post', $cur_item['id'], $cur_item['message'], $cur_item['subject']); |
| 105: else |
| 106: update_search_index('post', $cur_item['id'], $cur_item['message']); |
| 107: |
| 108: $end_at = $cur_item['id']; |
| 109: } |
| 110: |
| 111: // Check if there is more work to do |
| 112: if ($end_at > 0) |
| 113: { |
| 114: $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE id > '.$end_at.' ORDER BY id ASC LIMIT 1') or error('Unable to fetch next ID', __FILE__, __LINE__, $db->error()); |
| 115: |
| 116: if ($db->num_rows($result) > 0) |
| 117: $query_str = '?action=rebuild&i_per_page='.$per_page.'&i_start_at='.$db->result($result); |
| 118: } |
| 119: |
| 120: $db->end_transaction(); |
| 121: $db->close(); |
| 122: |
| 123: exit('<script type="text/javascript">window.location="admin_maintenance.php'.$query_str.'"</script><hr /><p>'.sprintf($lang_admin_maintenance['Javascript redirect failed'], '<a href="admin_maintenance.php'.$query_str.'">'.$lang_admin_maintenance['Click here'].'</a>').'</p>'); |
| 124: } |
| 125: |
| 126: if ($action == 'prune') |
| 127: { |
| 128: $prune_from = pun_trim($_POST['prune_from']); |
| 129: $prune_sticky = intval($_POST['prune_sticky']); |
| 130: |
| 131: if (isset($_POST['prune_comply'])) |
| 132: { |
| 133: confirm_referrer('admin_maintenance.php'); |
| 134: |
| 135: $prune_days = intval($_POST['prune_days']); |
| 136: $prune_date = ($prune_days) ? time() - ($prune_days * 86400) : -1; |
| 137: |
| 138: @set_time_limit(0); |
| 139: |
| 140: if ($prune_from == 'all') |
| 141: { |
| 142: $result = $db->query('SELECT id FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error()); |
| 143: $num_forums = $db->num_rows($result); |
| 144: |
| 145: for ($i = 0; $i < $num_forums; ++$i) |
| 146: { |
| 147: $fid = $db->result($result, $i); |
| 148: |
| 149: prune($fid, $prune_sticky, $prune_date); |
| 150: update_forum($fid); |
| 151: } |
| 152: } |
| 153: else |
| 154: { |
| 155: $prune_from = intval($prune_from); |
| 156: prune($prune_from, $prune_sticky, $prune_date); |
| 157: update_forum($prune_from); |
| 158: } |
| 159: |
| 160: // Locate any "orphaned redirect topics" and delete them |
| 161: $result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error()); |
| 162: $num_orphans = $db->num_rows($result); |
| 163: |
| 164: if ($num_orphans) |
| 165: { |
| 166: for ($i = 0; $i < $num_orphans; ++$i) |
| 167: $orphans[] = $db->result($result, $i); |
| 168: |
| 169: $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error()); |
| 170: } |
| 171: |
| 172: redirect('admin_maintenance.php', $lang_admin_maintenance['Posts pruned redirect']); |
| 173: } |
| 174: |
| 175: $prune_days = pun_trim($_POST['req_prune_days']); |
| 176: if ($prune_days == '' || preg_match('%[^0-9]%', $prune_days)) |
| 177: message($lang_admin_maintenance['Days must be integer message']); |
| 178: |
| 179: $prune_date = time() - ($prune_days * 86400); |
| 180: |
| 181: // Concatenate together the query for counting number of topics to prune |
| 182: $sql = 'SELECT COUNT(id) FROM '.$db->prefix.'topics WHERE last_post<'.$prune_date.' AND moved_to IS NULL'; |
| 183: |
| 184: if ($prune_sticky == '0') |
| 185: $sql .= ' AND sticky=0'; |
| 186: |
| 187: if ($prune_from != 'all') |
| 188: { |
| 189: $prune_from = intval($prune_from); |
| 190: $sql .= ' AND forum_id='.$prune_from; |
| 191: |
| 192: // Fetch the forum name (just for cosmetic reasons) |
| 193: $result = $db->query('SELECT forum_name FROM '.$db->prefix.'forums WHERE id='.$prune_from) or error('Unable to fetch forum name', __FILE__, __LINE__, $db->error()); |
| 194: $forum = '"'.pun_htmlspecialchars($db->result($result)).'"'; |
| 195: } |
| 196: else |
| 197: $forum = $lang_admin_maintenance['All forums']; |
| 198: |
| 199: $result = $db->query($sql) or error('Unable to fetch topic prune count', __FILE__, __LINE__, $db->error()); |
| 200: $num_topics = $db->result($result); |
| 201: |
| 202: if (!$num_topics) |
| 203: message(sprintf($lang_admin_maintenance['No old topics message'], $prune_days)); |
| 204: |
| 205: |
| 206: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Prune']); |
| 207: define('PUN_ACTIVE_PAGE', 'admin'); |
| 208: require PUN_ROOT.'header.php'; |
| 209: |
| 210: generate_admin_menu('maintenance'); |
| 211: |
| 212: ?> |
| 213: <div class="blockform"> |
| 214: <h2><span><?php echo $lang_admin_maintenance['Prune head'] ?></span></h2> |
| 215: <div class="box"> |
| 216: <form method="post" action="admin_maintenance.php"> |
| 217: <div class="inform"> |
| 218: <input type="hidden" name="action" value="prune" /> |
| 219: <input type="hidden" name="prune_days" value="<?php echo $prune_days ?>" /> |
| 220: <input type="hidden" name="prune_sticky" value="<?php echo $prune_sticky ?>" /> |
| 221: <input type="hidden" name="prune_from" value="<?php echo $prune_from ?>" /> |
| 222: <fieldset> |
| 223: <legend><?php echo $lang_admin_maintenance['Confirm prune subhead'] ?></legend> |
| 224: <div class="infldset"> |
| 225: <p><?php printf($lang_admin_maintenance['Confirm prune info'], $prune_days, $forum, forum_number_format($num_topics)) ?></p> |
| 226: <p class="warntext"><?php echo $lang_admin_maintenance['Confirm prune warn'] ?></p> |
| 227: </div> |
| 228: </fieldset> |
| 229: </div> |
| 230: <p class="buttons"><input type="submit" name="prune_comply" value="<?php echo $lang_admin_common['Prune'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_admin_common['Go back'] ?></a></p> |
| 231: </form> |
| 232: </div> |
| 233: </div> |
| 234: <div class="clearer"></div> |
| 235: </div> |
| 236: <?php |
| 237: |
| 238: require PUN_ROOT.'footer.php'; |
| 239: exit; |
| 240: } |
| 241: |
| 242: |
| 243: // Get the first post ID from the db |
| 244: $result = $db->query('SELECT id FROM '.$db->prefix.'posts ORDER BY id ASC LIMIT 1') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error()); |
| 245: if ($db->num_rows($result)) |
| 246: $first_id = $db->result($result); |
| 247: |
| 248: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Maintenance']); |
| 249: define('PUN_ACTIVE_PAGE', 'admin'); |
| 250: require PUN_ROOT.'header.php'; |
| 251: |
| 252: generate_admin_menu('maintenance'); |
| 253: |
| 254: ?> |
| 255: <div class="blockform"> |
| 256: <h2><span><?php echo $lang_admin_maintenance['Maintenance head'] ?></span></h2> |
| 257: <div class="box"> |
| 258: <form method="get" action="admin_maintenance.php"> |
| 259: <div class="inform"> |
| 260: <input type="hidden" name="action" value="rebuild" /> |
| 261: <fieldset> |
| 262: <legend><?php echo $lang_admin_maintenance['Rebuild index subhead'] ?></legend> |
| 263: <div class="infldset"> |
| 264: <p><?php printf($lang_admin_maintenance['Rebuild index info'], '<a href="admin_options.php#maintenance">'.$lang_admin_common['Maintenance mode'].'</a>') ?></p> |
| 265: <table class="aligntop" cellspacing="0"> |
| 266: <tr> |
| 267: <th scope="row"><?php echo $lang_admin_maintenance['Posts per cycle label'] ?></th> |
| 268: <td> |
| 269: <input type="text" name="i_per_page" size="7" maxlength="7" value="300" tabindex="1" /> |
| 270: <span><?php echo $lang_admin_maintenance['Posts per cycle help'] ?></span> |
| 271: </td> |
| 272: </tr> |
| 273: <tr> |
| 274: <th scope="row"><?php echo $lang_admin_maintenance['Starting post label'] ?></th> |
| 275: <td> |
| 276: <input type="text" name="i_start_at" size="7" maxlength="7" value="<?php echo (isset($first_id)) ? $first_id : 0 ?>" tabindex="2" /> |
| 277: <span><?php echo $lang_admin_maintenance['Starting post help'] ?></span> |
| 278: </td> |
| 279: </tr> |
| 280: <tr> |
| 281: <th scope="row"><?php echo $lang_admin_maintenance['Empty index label'] ?></th> |
| 282: <td class="inputadmin"> |
| 283: <span><input type="checkbox" name="i_empty_index" value="1" tabindex="3" checked="checked" />  <?php echo $lang_admin_maintenance['Empty index help'] ?></span> |
| 284: </td> |
| 285: </tr> |
| 286: </table> |
| 287: <p class="topspace"><?php echo $lang_admin_maintenance['Rebuild completed info'] ?></p> |
| 288: <div class="fsetsubmit"><input type="submit" name="rebuild_index" value="<?php echo $lang_admin_maintenance['Rebuild index'] ?>" tabindex="4" /></div> |
| 289: </div> |
| 290: </fieldset> |
| 291: </div> |
| 292: </form> |
| 293: |
| 294: <form method="post" action="admin_maintenance.php" onsubmit="return process_form(this)"> |
| 295: <div class="inform"> |
| 296: <input type="hidden" name="action" value="prune" /> |
| 297: <fieldset> |
| 298: <legend><?php echo $lang_admin_maintenance['Prune subhead'] ?></legend> |
| 299: <div class="infldset"> |
| 300: <table class="aligntop" cellspacing="0"> |
| 301: <tr> |
| 302: <th scope="row"><?php echo $lang_admin_maintenance['Days old label'] ?></th> |
| 303: <td> |
| 304: <input type="text" name="req_prune_days" size="3" maxlength="3" tabindex="5" /> |
| 305: <span><?php echo $lang_admin_maintenance['Days old help'] ?></span> |
| 306: </td> |
| 307: </tr> |
| 308: <tr> |
| 309: <th scope="row"><?php echo $lang_admin_maintenance['Prune sticky label'] ?></th> |
| 310: <td> |
| 311: <input type="radio" name="prune_sticky" value="1" tabindex="6" checked="checked" /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="prune_sticky" value="0" /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| 312: <span><?php echo $lang_admin_maintenance['Prune sticky help'] ?></span> |
| 313: </td> |
| 314: </tr> |
| 315: <tr> |
| 316: <th scope="row"><?php echo $lang_admin_maintenance['Prune from label'] ?></th> |
| 317: <td> |
| 318: <select name="prune_from" tabindex="7"> |
| 319: <option value="all"><?php echo $lang_admin_maintenance['All forums'] ?></option> |
| 320: <?php |
| 321: |
| 322: $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id WHERE f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error()); |
| 323: |
| 324: $cur_category = 0; |
| 325: while ($forum = $db->fetch_assoc($result)) |
| 326: { |
| 327: if ($forum['cid'] != $cur_category) // Are we still in the same category? |
| 328: { |
| 329: if ($cur_category) |
| 330: echo "\t\t\t\t\t\t\t\t\t\t\t".'</optgroup>'."\n"; |
| 331: |
| 332: echo "\t\t\t\t\t\t\t\t\t\t\t".'<optgroup label="'.pun_htmlspecialchars($forum['cat_name']).'">'."\n"; |
| 333: $cur_category = $forum['cid']; |
| 334: } |
| 335: |
| 336: echo "\t\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$forum['fid'].'">'.pun_htmlspecialchars($forum['forum_name']).'</option>'."\n"; |
| 337: } |
| 338: |
| 339: ?> |
| 340: </optgroup> |
| 341: </select> |
| 342: <span><?php echo $lang_admin_maintenance['Prune from help'] ?></span> |
| 343: </td> |
| 344: </tr> |
| 345: </table> |
| 346: <p class="topspace"><?php printf($lang_admin_maintenance['Prune info'], '<a href="admin_options.php#maintenance">'.$lang_admin_common['Maintenance mode'].'</a>') ?></p> |
| 347: <div class="fsetsubmit"><input type="submit" name="prune" value="<?php echo $lang_admin_common['Prune'] ?>" tabindex="8" /></div> |
| 348: </div> |
| 349: </fieldset> |
| 350: </div> |
| 351: </form> |
| 352: </div> |
| 353: </div> |
| 354: <div class="clearer"></div> |
| 355: </div> |
| 356: <?php |
| 357: |
| 358: require PUN_ROOT.'footer.php'; |
/dev/null |
b/admin_options.php |
| 1: <?php |
| 2: |
| 3: /** |
| 4: * Copyright (C) 2008-2012 FluxBB |
| 5: * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB |
| 6: * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher |
| 7: */ |
| 8: |
| 9: // Tell header.php to use the admin template |
| 10: define('PUN_ADMIN_CONSOLE', 1); |
| 11: |
| 12: define('PUN_ROOT', dirname(__FILE__).'/'); |
| 13: require PUN_ROOT.'include/common.php'; |
| 14: require PUN_ROOT.'include/common_admin.php'; |
| 15: |
| 16: |
| 17: if ($pun_user['g_id'] != PUN_ADMIN) |
| 18: message($lang_common['No permission'], false, '403 Forbidden'); |
| 19: |
| 20: // Load the admin_options.php language file |
| 21: require PUN_ROOT.'lang/'.$admin_language.'/admin_options.php'; |
| 22: |
| 23: if (isset($_POST['form_sent'])) |
| 24: { |
| 25: confirm_referrer('admin_options.php', $lang_admin_options['Bad HTTP Referer message']); |
| 26: |
| 27: $form = array( |
| 28: 'board_title' => pun_trim($_POST['form']['board_title']), |
| 29: 'board_desc' => pun_trim($_POST['form']['board_desc']), |
| 30: 'base_url' => pun_trim($_POST['form']['base_url']), |
| 31: 'default_timezone' => floatval($_POST['form']['default_timezone']), |
| 32: 'default_dst' => $_POST['form']['default_dst'] != '1' ? '0' : '1', |
| 33: 'default_lang' => pun_trim($_POST['form']['default_lang']), |
| 34: 'default_style' => pun_trim($_POST['form']['default_style']), |
| 35: 'time_format' => pun_trim($_POST['form']['time_format']), |
| 36: 'date_format' => pun_trim($_POST['form']['date_format']), |
| 37: 'timeout_visit' => (intval($_POST['form']['timeout_visit']) > 0) ? intval($_POST['form']['timeout_visit']) : 1, |
| 38: 'timeout_online' => (intval($_POST['form']['timeout_online']) > 0) ? intval($_POST['form']['timeout_online']) : 1, |
| 39: 'redirect_delay' => (intval($_POST['form']['redirect_delay']) >= 0) ? intval($_POST['form']['redirect_delay']) : 0, |
| 40: 'show_version' => $_POST['form']['show_version'] != '1' ? '0' : '1', |
| 41: 'show_user_info' => $_POST['form']['show_user_info'] != '1' ? '0' : '1', |
| 42: 'show_post_count' => $_POST['form']['show_post_count'] != '1' ? '0' : '1', |
| 43: 'smilies' => $_POST['form']['smilies'] != '1' ? '0' : '1', |
| 44: 'smilies_sig' => $_POST['form']['smilies_sig'] != '1' ? '0' : '1', |
| 45: 'make_links' => $_POST['form']['make_links'] != '1' ? '0' : '1', |
| 46: 'topic_review' => (intval($_POST['form']['topic_review']) >= 0) ? intval($_POST['form']['topic_review']) : 0, |
| 47: 'disp_topics_default' => intval($_POST['form']['disp_topics_default']), |
| 48: 'disp_posts_default' => intval($_POST['form']['disp_posts_default']), |
| 49: 'indent_num_spaces' => (intval($_POST['form']['indent_num_spaces']) >= 0) ? intval($_POST['form']['indent_num_spaces']) : 0, |
| 50: 'quote_depth' => (intval($_POST['form']['quote_depth']) > 0) ? intval($_POST['form']['quote_depth']) : 1, |
| 51: 'quickpost' => $_POST['form']['quickpost'] != '1' ? '0' : '1', |
| 52: 'users_online' => $_POST['form']['users_online'] != '1' ? '0' : '1', |
| 53: 'censoring' => $_POST['form']['censoring'] != '1' ? '0' : '1', |
| 54: 'signatures' => $_POST['form']['signatures'] != '1' ? '0' : '1', |
| 55: 'ranks' => $_POST['form']['ranks'] != '1' ? '0' : '1', |
| 56: 'show_dot' => $_POST['form']['show_dot'] != '1' ? '0' : '1', |
| 57: 'topic_views' => $_POST['form']['topic_views'] != '1' ? '0' : '1', |
| 58: 'quickjump' => $_POST['form']['quickjump'] != '1' ? '0' : '1', |
| 59: 'gzip' => $_POST['form']['gzip'] != '1' ? '0' : '1', |
| 60: 'search_all_forums' => $_POST['form']['search_all_forums'] != '1' ? '0' : '1', |
| 61: 'additional_navlinks' => pun_trim($_POST['form']['additional_navlinks']), |
| 62: 'feed_type' => intval($_POST['form']['feed_type']), |
| 63: 'feed_ttl' => intval($_POST['form']['feed_ttl']), |
| 64: 'report_method' => intval($_POST['form']['report_method']), |
| 65: 'mailing_list' => pun_trim($_POST['form']['mailing_list']), |
| 66: 'avatars' => $_POST['form']['avatars'] != '1' ? '0' : '1', |
| 67: 'avatars_dir' => pun_trim($_POST['form']['avatars_dir']), |
| 68: 'avatars_width' => (intval($_POST['form']['avatars_width']) > 0) ? intval($_POST['form']['avatars_width']) : 1, |
| 69: 'avatars_height' => (intval($_POST['form']['avatars_height']) > 0) ? intval($_POST['form']['avatars_height']) : 1, |
| 70: 'avatars_size' => (intval($_POST['form']['avatars_size']) > 0) ? intval($_POST['form']['avatars_size']) : 1, |
| 71: 'admin_email' => strtolower(pun_trim($_POST['form']['admin_email'])), |
| 72: 'webmaster_email' => strtolower(pun_trim($_POST['form']['webmaster_email'])), |
| 73: 'forum_subscriptions' => $_POST['form']['forum_subscriptions'] != '1' ? '0' : '1', |
| 74: 'topic_subscriptions' => $_POST['form']['topic_subscriptions'] != '1' ? '0' : '1', |
| 75: 'smtp_host' => pun_trim($_POST['form']['smtp_host']), |
| 76: 'smtp_user' => pun_trim($_POST['form']['smtp_user']), |
| 77: 'smtp_ssl' => $_POST['form']['smtp_ssl'] != '1' ? '0' : '1', |
| 78: 'regs_allow' => $_POST['form']['regs_allow'] != '1' ? '0' : '1', |
| 79: 'regs_verify' => $_POST['form']['regs_verify'] != '1' ? '0' : '1', |
| 80: 'regs_report' => $_POST['form']['regs_report'] != '1' ? '0' : '1', |
| 81: 'rules' => $_POST['form']['rules'] != '1' ? '0' : '1', |
| 82: 'rules_message' => pun_trim($_POST['form']['rules_message']), |
| 83: 'default_email_setting' => intval($_POST['form']['default_email_setting']), |
| 84: 'announcement' => $_POST['form']['announcement'] != '1' ? '0' : '1', |
| 85: 'announcement_message' => pun_trim($_POST['form']['announcement_message']), |
| 86: 'maintenance' => $_POST['form']['maintenance'] != '1' ? '0' : '1', |
| 87: 'maintenance_message' => pun_trim($_POST['form']['maintenance_message']), |
| 88: ); |
| 89: |
| 90: if ($form['board_title'] == '') |
| 91: message($lang_admin_options['Must enter title message']); |
| 92: |
| 93: // Make sure base_url doesn't end with a slash |
| 94: if (substr($form['base_url'], -1) == '/') |
| 95: $form['base_url'] = substr($form['base_url'], 0, -1); |
| 96: |
| 97: $languages = forum_list_langs(); |
| 98: if (!in_array($form['default_lang'], $languages)) |
| 99: message($lang_common['Bad request']); |
| 100: |
| 101: $styles = forum_list_styles(); |
| 102: if (!in_array($form['default_style'], $styles)) |
| 103: message($lang_common['Bad request']); |
| 104: |
| 105: if ($form['time_format'] == '') |
| 106: $form['time_format'] = 'H:i:s'; |
| 107: |
| 108: if ($form['date_format'] == '') |
| 109: $form['date_format'] = 'Y-m-d'; |
| 110: |
| 111: |
| 112: require PUN_ROOT.'include/email.php'; |
| 113: |
| 114: if (!is_valid_email($form['admin_email'])) |
| 115: message($lang_admin_options['Invalid e-mail message']); |
| 116: |
| 117: if (!is_valid_email($form['webmaster_email'])) |
| 118: message($lang_admin_options['Invalid webmaster e-mail message']); |
| 119: |
| 120: if ($form['mailing_list'] != '') |
| 121: $form['mailing_list'] = strtolower(preg_replace('%\s%S', '', $form['mailing_list'])); |
| 122: |
| 123: // Make sure avatars_dir doesn't end with a slash |
| 124: if (substr($form['avatars_dir'], -1) == '/') |
| 125: $form['avatars_dir'] = substr($form['avatars_dir'], 0, -1); |
| 126: |
| 127: if ($form['additional_navlinks'] != '') |
| 128: $form['additional_navlinks'] = pun_trim(pun_linebreaks($form['additional_navlinks'])); |
| 129: |
| 130: // Change or enter a SMTP password |
| 131: if (isset($_POST['form']['smtp_change_pass'])) |
| 132: { |
| 133: $smtp_pass1 = isset($_POST['form']['smtp_pass1']) ? pun_trim($_POST['form']['smtp_pass1']) : ''; |
| 134: $smtp_pass2 = isset($_POST['form']['smtp_pass2']) ? pun_trim($_POST['form']['smtp_pass2']) : ''; |
| 135: |
| 136: if ($smtp_pass1 == $smtp_pass2) |
| 137: $form['smtp_pass'] = $smtp_pass1; |
| 138: else |
| 139: message($lang_admin_options['SMTP passwords did not match']); |
| 140: } |
| 141: |
| 142: if ($form['announcement_message'] != '') |
| 143: $form['announcement_message'] = pun_linebreaks($form['announcement_message']); |
| 144: else |
| 145: { |
| 146: $form['announcement_message'] = $lang_admin_options['Enter announcement here']; |
| 147: $form['announcement'] = '0'; |
| 148: } |
| 149: |
| 150: if ($form['rules_message'] != '') |
| 151: $form['rules_message'] = pun_linebreaks($form['rules_message']); |
| 152: else |
| 153: { |
| 154: $form['rules_message'] = $lang_admin_options['Enter rules here']; |
| 155: $form['rules'] = '0'; |
| 156: } |
| 157: |
| 158: if ($form['maintenance_message'] != '') |
| 159: $form['maintenance_message'] = pun_linebreaks($form['maintenance_message']); |
| 160: else |
| 161: { |
| 162: $form['maintenance_message'] = $lang_admin_options['Default maintenance message']; |
| 163: $form['maintenance'] = '0'; |
| 164: } |
| 165: |
| 166: // Make sure the number of displayed topics and posts is between 3 and 75 |
| 167: if ($form['disp_topics_default'] < 3) |
| 168: $form['disp_topics_default'] = 3; |
| 169: else if ($form['disp_topics_default'] > 75) |
| 170: $form['disp_topics_default'] = 75; |
| 171: |
| 172: if ($form['disp_posts_default'] < 3) |
| 173: $form['disp_posts_default'] = 3; |
| 174: else if ($form['disp_posts_default'] > 75) |
| 175: $form['disp_posts_default'] = 75; |
| 176: |
| 177: if ($form['feed_type'] < 0 || $form['feed_type'] > 2) |
| 178: message($lang_common['Bad request']); |
| 179: |
| 180: if ($form['feed_ttl'] < 0) |
| 181: message($lang_common['Bad request']); |
| 182: |
| 183: if ($form['report_method'] < 0 || $form['report_method'] > 2) |
| 184: message($lang_common['Bad request']); |
| 185: |
| 186: if ($form['default_email_setting'] < 0 || $form['default_email_setting'] > 2) |
| 187: message($lang_common['Bad request']); |
| 188: |
| 189: if ($form['timeout_online'] >= $form['timeout_visit']) |
| 190: message($lang_admin_options['Timeout error message']); |
| 191: |
| 192: foreach ($form as $key => $input) |
| 193: { |
| 194: // Only update values that have changed |
| 195: if (array_key_exists('o_'.$key, $pun_config) && $pun_config['o_'.$key] != $input) |
| 196: { |
| 197: if ($input != '' || is_int($input)) |
| 198: $value = '\''.$db->escape($input).'\''; |
| 199: else |
| 200: $value = 'NULL'; |
| 201: |
| 202: $db->query('UPDATE '.$db->prefix.'config SET conf_value='.$value.' WHERE conf_name=\'o_'.$db->escape($key).'\'') or error('Unable to update board config', __FILE__, __LINE__, $db->error()); |
| 203: } |
| 204: } |
| 205: |
| 206: // Regenerate the config cache |
| 207: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| 208: require PUN_ROOT.'include/cache.php'; |
| 209: |
| 210: generate_config_cache(); |
| 211: clear_feed_cache(); |
| 212: |
| 213: redirect('admin_options.php', $lang_admin_options['Options updated redirect']); |
| 214: } |
| 215: |
| 216: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Options']); |
| 217: define('PUN_ACTIVE_PAGE', 'admin'); |
| 218: require PUN_ROOT.'header.php'; |
| 219: |
| 220: generate_admin_menu('options'); |
| 221: |
| 222: ?> |
| 223: <div class="blockform"> |
| 224: <h2><span><?php echo $lang_admin_options['Options head'] ?></span></h2> |
| 225: <div class="box"> |
| 226: <form method="post" action="admin_options.php"> |
| 227: <p class="submittop"><input type="submit" name="save" value="<?php echo $lang_admin_common['Save changes'] ?>" /></p> |
| 228: <div class="inform"> |
| 229: <input type="hidden" name="form_sent" value="1" /> |
| 230: <fieldset> |
| 231: <legend><?php echo $lang_admin_options['Essentials subhead'] ?></legend> |
| 232: <div class="infldset"> |
| 233: <table class="aligntop" cellspacing="0"> |
| 234: <tr> |
| 235: <th scope="row"><?php echo $lang_admin_options['Board title label'] ?></th> |
| 236: <td> |
| 237: <input type="text" name="form[board_title]" size="50" maxlength="255" value="<?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?>" /> |
| 238: <span><?php echo $lang_admin_options['Board title help'] ?></span> |
| 239: </td> |
| 240: </tr> |
| 241: <tr> |
| 242: <th scope="row"><?php echo $lang_admin_options['Board desc label'] ?></th> |
| 243: <td> |
| 244: <input type="text" name="form[board_desc]" size="50" maxlength="255" value="<?php echo pun_htmlspecialchars($pun_config['o_board_desc']) ?>" /> |
| 245: <span><?php echo $lang_admin_options['Board desc help'] ?></span> |
| 246: </td> |
| 247: </tr> |
| 248: <tr> |
| 249: <th scope="row"><?php echo $lang_admin_options['Base URL label'] ?></th> |
| 250: <td> |
| 251: <input type="text" name="form[base_url]" size="50" maxlength="100" value="<?php echo pun_htmlspecialchars($pun_config['o_base_url']) ?>" /> |
| 252: <span><?php echo $lang_admin_options['Base URL help'] ?></span> |
| 253: </td> |
| 254: </tr> |
| 255: <tr> |
| 256: <th scope="row"><?php echo $lang_admin_options['Timezone label'] ?></th> |
| 257: <td> |
| 258: <select name="form[default_timezone]"> |
| 259: <option value="-12"<?php if ($pun_config['o_default_timezone'] == -12) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-12:00'] ?></option> |
| 260: <option value="-11"<?php if ($pun_config['o_default_timezone'] == -11) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-11:00'] ?></option> |
| 261: <option value="-10"<?php if ($pun_config['o_default_timezone'] == -10) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-10:00'] ?></option> |
| 262: <option value="-9.5"<?php if ($pun_config['o_default_timezone'] == -9.5) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-09:30'] ?></option> |
| 263: <option value="-9"<?php if ($pun_config['o_default_timezone'] == -9) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-09:00'] ?></option> |
| 264: <option value="-8.5"<?php if ($pun_config['o_default_timezone'] == -8.5) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-08:30'] ?></option> |
| 265: <option value="-8"<?php if ($pun_config['o_default_timezone'] == -8) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-08:00'] ?></option> |
| 266: <option value="-7"<?php if ($pun_config['o_default_timezone'] == -7) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-07:00'] ?></option> |
| 267: <option value="-6"<?php if ($pun_config['o_default_timezone'] == -6) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-06:00'] ?></option> |
| 268: <option value="-5"<?php if ($pun_config['o_default_timezone'] == -5) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-05:00'] ?></option> |
| 269: <option value="-4"<?php if ($pun_config['o_default_timezone'] == -4) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-04:00'] ?></option> |
| 270: <option value="-3.5"<?php if ($pun_config['o_default_timezone'] == -3.5) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-03:30'] ?></option> |
| 271: <option value="-3"<?php if ($pun_config['o_default_timezone'] == -3) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-03:00'] ?></option> |
| 272: <option value="-2"<?php if ($pun_config['o_default_timezone'] == -2) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-02:00'] ?></option> |
| 273: <option value="-1"<?php if ($pun_config['o_default_timezone'] == -1) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-01:00'] ?></option> |
| 274: <option value="0"<?php if ($pun_config['o_default_timezone'] == 0) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC'] ?></option> |
| 275: <option value="1"<?php if ($pun_config['o_default_timezone'] == 1) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+01:00'] ?></option> |
| 276: <option value="2"<?php if ($pun_config['o_default_timezone'] == 2) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+02:00'] ?></option> |
| 277: <option value="3"<?php if ($pun_config['o_default_timezone'] == 3) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+03:00'] ?></option> |
| 278: <option value="3.5"<?php if ($pun_config['o_default_timezone'] == 3.5) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+03:30'] ?></option> |
| 279: <option value="4"<?php if ($pun_config['o_default_timezone'] == 4) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+04:00'] ?></option> |
| 280: <option value="4.5"<?php if ($pun_config['o_default_timezone'] == 4.5) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+04:30'] ?></option> |
| 281: <option value="5"<?php if ($pun_config['o_default_timezone'] == 5) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+05:00'] ?></option> |
| 282: <option value="5.5"<?php if ($pun_config['o_default_timezone'] == 5.5) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+05:30'] ?></option> |
| 283: <option value="5.75"<?php if ($pun_config['o_default_timezone'] == 5.75) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+05:45'] ?></option> |
| 284: <option value="6"<?php if ($pun_config['o_default_timezone'] == 6) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+06:00'] ?></option> |
| 285: <option value="6.5"<?php if ($pun_config['o_default_timezone'] == 6.5) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+06:30'] ?></option> |
| 286: <option value="7"<?php if ($pun_config['o_default_timezone'] == 7) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+07:00'] ?></option> |
| 287: <option value="8"<?php if ($pun_config['o_default_timezone'] == 8) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+08:00'] ?></option> |
| 288: <option value="8.75"<?php if ($pun_config['o_default_timezone'] == 8.75) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+08:45'] ?></option> |
| 289: <option value="9"<?php if ($pun_config['o_default_timezone'] == 9) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+09:00'] ?></option> |
| 290: <option value="9.5"<?php if ($pun_config['o_default_timezone'] == 9.5) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+09:30'] ?></option> |
| 291: <option value="10"<?php if ($pun_config['o_default_timezone'] == 10) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+10:00'] ?></option> |
| 292: <option value="10.5"<?php if ($pun_config['o_default_timezone'] == 10.5) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+10:30'] ?></option> |
| 293: <option value="11"<?php if ($pun_config['o_default_timezone'] == 11) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+11:00'] ?></option> |
| 294: <option value="11.5"<?php if ($pun_config['o_default_timezone'] == 11.5) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+11:30'] ?></option> |
| 295: <option value="12"<?php if ($pun_config['o_default_timezone'] == 12) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+12:00'] ?></option> |
| 296: <option value="12.75"<?php if ($pun_config['o_default_timezone'] == 12.75) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+12:45'] ?></option> |
| 297: <option value="13"<?php if ($pun_config['o_default_timezone'] == 13) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+13:00'] ?></option> |
| 298: <option value="14"<?php if ($pun_config['o_default_timezone'] == 14) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+14:00'] ?></option> |
| 299: </select> |
| 300: <span><?php echo $lang_admin_options['Timezone help'] ?></span> |
| 301: </td> |
| 302: </tr> |
| 303: <tr> |
| 304: <th scope="row"><?php echo $lang_admin_options['DST label'] ?></th> |
| 305: <td> |
| 306: <input type="radio" name="form[default_dst]" id="form_default_dst_1" value="1"<?php if ($pun_config['o_default_dst'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_default_dst_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[default_dst]" id="form_default_dst_0" value="0"<?php if ($pun_config['o_default_dst'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_default_dst_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 307: <span><?php echo $lang_admin_options['DST help'] ?></span> |
| 308: </td> |
| 309: </tr> |
| 310: <tr> |
| 311: <th scope="row"><?php echo $lang_admin_options['Language label'] ?></th> |
| 312: <td> |
| 313: <select name="form[default_lang]"> |
| 314: <?php |
| 315: |
| 316: $languages = forum_list_langs(); |
| 317: |
| 318: foreach ($languages as $temp) |
| 319: { |
| 320: if ($pun_config['o_default_lang'] == $temp) |
| 321: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.$temp.'</option>'."\n"; |
| 322: else |
| 323: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.$temp.'</option>'."\n"; |
| 324: } |
| 325: |
| 326: ?> |
| 327: </select> |
| 328: <span><?php echo $lang_admin_options['Language help'] ?></span> |
| 329: </td> |
| 330: </tr> |
| 331: <tr> |
| 332: <th scope="row"><?php echo $lang_admin_options['Default style label'] ?></th> |
| 333: <td> |
| 334: <select name="form[default_style]"> |
| 335: <?php |
| 336: |
| 337: $styles = forum_list_styles(); |
| 338: |
| 339: foreach ($styles as $temp) |
| 340: { |
| 341: if ($pun_config['o_default_style'] == $temp) |
| 342: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.str_replace('_', ' ', $temp).'</option>'."\n"; |
| 343: else |
| 344: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.str_replace('_', ' ', $temp).'</option>'."\n"; |
| 345: } |
| 346: |
| 347: ?> |
| 348: </select> |
| 349: <span><?php echo $lang_admin_options['Default style help'] ?></span> |
| 350: </td> |
| 351: </tr> |
| 352: </table> |
| 353: </div> |
| 354: </fieldset> |
| 355: </div> |
| 356: <?php |
| 357: |
| 358: $diff = ($pun_user['timezone'] + $pun_user['dst']) * 3600; |
| 359: $timestamp = time() + $diff; |
| 360: |
| 361: ?> |
| 362: <div class="inform"> |
| 363: <fieldset> |
| 364: <legend><?php echo $lang_admin_options['Timeouts subhead'] ?></legend> |
| 365: <div class="infldset"> |
| 366: <table class="aligntop" cellspacing="0"> |
| 367: <tr> |
| 368: <th scope="row"><?php echo $lang_admin_options['Time format label'] ?></th> |
| 369: <td> |
| 370: <input type="text" name="form[time_format]" size="25" maxlength="25" value="<?php echo pun_htmlspecialchars($pun_config['o_time_format']) ?>" /> |
| 371: <span><?php printf($lang_admin_options['Time format help'], gmdate($pun_config['o_time_format'], $timestamp), '<a href="http://www.php.net/manual/en/function.date.php">'.$lang_admin_options['PHP manual'].'</a>') ?></span> |
| 372: </td> |
| 373: </tr> |
| 374: <tr> |
| 375: <th scope="row"><?php echo $lang_admin_options['Date format label'] ?></th> |
| 376: <td> |
| 377: <input type="text" name="form[date_format]" size="25" maxlength="25" value="<?php echo pun_htmlspecialchars($pun_config['o_date_format']) ?>" /> |
| 378: <span><?php printf($lang_admin_options['Date format help'], gmdate($pun_config['o_date_format'], $timestamp), '<a href="http://www.php.net/manual/en/function.date.php">'.$lang_admin_options['PHP manual'].'</a>') ?></span> |
| 379: </td> |
| 380: </tr> |
| 381: <tr> |
| 382: <th scope="row"><?php echo $lang_admin_options['Visit timeout label'] ?></th> |
| 383: <td> |
| 384: <input type="text" name="form[timeout_visit]" size="5" maxlength="5" value="<?php echo $pun_config['o_timeout_visit'] ?>" /> |
| 385: <span><?php echo $lang_admin_options['Visit timeout help'] ?></span> |
| 386: </td> |
| 387: </tr> |
| 388: <tr> |
| 389: <th scope="row"><?php echo $lang_admin_options['Online timeout label'] ?></th> |
| 390: <td> |
| 391: <input type="text" name="form[timeout_online]" size="5" maxlength="5" value="<?php echo $pun_config['o_timeout_online'] ?>" /> |
| 392: <span><?php echo $lang_admin_options['Online timeout help'] ?></span> |
| 393: </td> |
| 394: </tr> |
| 395: <tr> |
| 396: <th scope="row"><?php echo $lang_admin_options['Redirect time label'] ?></th> |
| 397: <td> |
| 398: <input type="text" name="form[redirect_delay]" size="3" maxlength="3" value="<?php echo $pun_config['o_redirect_delay'] ?>" /> |
| 399: <span><?php echo $lang_admin_options['Redirect time help'] ?></span> |
| 400: </td> |
| 401: </tr> |
| 402: </table> |
| 403: </div> |
| 404: </fieldset> |
| 405: </div> |
| 406: <div class="inform"> |
| 407: <fieldset> |
| 408: <legend><?php echo $lang_admin_options['Display subhead'] ?></legend> |
| 409: <div class="infldset"> |
| 410: <table class="aligntop" cellspacing="0"> |
| 411: <tr> |
| 412: <th scope="row"><?php echo $lang_admin_options['Version number label'] ?></th> |
| 413: <td> |
| 414: <input type="radio" name="form[show_version]" id="form_show_version_1" value="1"<?php if ($pun_config['o_show_version'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_show_version_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[show_version]" id="form_show_version_0" value="0"<?php if ($pun_config['o_show_version'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_show_version_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 415: <span><?php echo $lang_admin_options['Version number help'] ?></span> |
| 416: </td> |
| 417: </tr> |
| 418: <tr> |
| 419: <th scope="row"><?php echo $lang_admin_options['Info in posts label'] ?></th> |
| 420: <td> |
| 421: <input type="radio" name="form[show_user_info]" id="form_show_user_info_1" value="1"<?php if ($pun_config['o_show_user_info'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_show_user_info_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[show_user_info]" id="form_show_user_info_0" value="0"<?php if ($pun_config['o_show_user_info'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_show_user_info_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 422: <span><?php echo $lang_admin_options['Info in posts help'] ?></span> |
| 423: </td> |
| 424: </tr> |
| 425: <tr> |
| 426: <th scope="row"><?php echo $lang_admin_options['Post count label'] ?></th> |
| 427: <td> |
| 428: <input type="radio" name="form[show_post_count]" id="form_show_post_count_1" value="1"<?php if ($pun_config['o_show_post_count'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_show_post_count_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[show_post_count]" id="form_show_post_count_0" value="0"<?php if ($pun_config['o_show_post_count'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_show_post_count_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 429: <span><?php echo $lang_admin_options['Post count help'] ?></span> |
| 430: </td> |
| 431: </tr> |
| 432: <tr> |
| 433: <th scope="row"><?php echo $lang_admin_options['Smilies label'] ?></th> |
| 434: <td> |
| 435: <input type="radio" name="form[smilies]" id="form_smilies_1" value="1"<?php if ($pun_config['o_smilies'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_smilies_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[smilies]" id="form_smilies_0" value="0"<?php if ($pun_config['o_smilies'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_smilies_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 436: <span><?php echo $lang_admin_options['Smilies help'] ?></span> |
| 437: </td> |
| 438: </tr> |
| 439: <tr> |
| 440: <th scope="row"><?php echo $lang_admin_options['Smilies sigs label'] ?></th> |
| 441: <td> |
| 442: <input type="radio" name="form[smilies_sig]" id="form_smilies_sig_1" value="1"<?php if ($pun_config['o_smilies_sig'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_smilies_sig_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[smilies_sig]" id="form_smilies_sig_0" value="0"<?php if ($pun_config['o_smilies_sig'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_smilies_sig_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 443: <span><?php echo $lang_admin_options['Smilies sigs help'] ?></span> |
| 444: </td> |
| 445: </tr> |
| 446: <tr> |
| 447: <th scope="row"><?php echo $lang_admin_options['Clickable links label'] ?></th> |
| 448: <td> |
| 449: <input type="radio" name="form[make_links]" id="form_make_links_1" value="1"<?php if ($pun_config['o_make_links'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_make_links_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[make_links]" id="form_make_links_0" value="0"<?php if ($pun_config['o_make_links'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_make_links_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 450: <span><?php echo $lang_admin_options['Clickable links help'] ?></span> |
| 451: </td> |
| 452: </tr> |
| 453: <tr> |
| 454: <th scope="row"><?php echo $lang_admin_options['Topic review label'] ?></th> |
| 455: <td> |
| 456: <input type="text" name="form[topic_review]" size="3" maxlength="3" value="<?php echo $pun_config['o_topic_review'] ?>" /> |
| 457: <span><?php echo $lang_admin_options['Topic review help'] ?></span> |
| 458: </td> |
| 459: </tr> |
| 460: <tr> |
| 461: <th scope="row"><?php echo $lang_admin_options['Topics per page label'] ?></th> |
| 462: <td> |
| 463: <input type="text" name="form[disp_topics_default]" size="3" maxlength="3" value="<?php echo $pun_config['o_disp_topics_default'] ?>" /> |
| 464: <span><?php echo $lang_admin_options['Topics per page help'] ?></span> |
| 465: </td> |
| 466: </tr> |
| 467: <tr> |
| 468: <th scope="row"><?php echo $lang_admin_options['Posts per page label'] ?></th> |
| 469: <td> |
| 470: <input type="text" name="form[disp_posts_default]" size="3" maxlength="3" value="<?php echo $pun_config['o_disp_posts_default'] ?>" /> |
| 471: <span><?php echo $lang_admin_options['Posts per page help'] ?></span> |
| 472: </td> |
| 473: </tr> |
| 474: <tr> |
| 475: <th scope="row"><?php echo $lang_admin_options['Indent label'] ?></th> |
| 476: <td> |
| 477: <input type="text" name="form[indent_num_spaces]" size="3" maxlength="3" value="<?php echo $pun_config['o_indent_num_spaces'] ?>" /> |
| 478: <span><?php echo $lang_admin_options['Indent help'] ?></span> |
| 479: </td> |
| 480: </tr> |
| 481: <tr> |
| 482: <th scope="row"><?php echo $lang_admin_options['Quote depth label'] ?></th> |
| 483: <td> |
| 484: <input type="text" name="form[quote_depth]" size="3" maxlength="3" value="<?php echo $pun_config['o_quote_depth'] ?>" /> |
| 485: <span><?php echo $lang_admin_options['Quote depth help'] ?></span> |
| 486: </td> |
| 487: </tr> |
| 488: </table> |
| 489: </div> |
| 490: </fieldset> |
| 491: </div> |
| 492: <div class="inform"> |
| 493: <fieldset> |
| 494: <legend><?php echo $lang_admin_options['Features subhead'] ?></legend> |
| 495: <div class="infldset"> |
| 496: <table class="aligntop" cellspacing="0"> |
| 497: <tr> |
| 498: <th scope="row"><?php echo $lang_admin_options['Quick post label'] ?></th> |
| 499: <td> |
| 500: <input type="radio" name="form[quickpost]" id="form_quickpost_1" value="1"<?php if ($pun_config['o_quickpost'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_quickpost_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[quickpost]" id="form_quickpost_0" value="0"<?php if ($pun_config['o_quickpost'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_quickpost_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 501: <span><?php echo $lang_admin_options['Quick post help'] ?></span> |
| 502: </td> |
| 503: </tr> |
| 504: <tr> |
| 505: <th scope="row"><?php echo $lang_admin_options['Users online label'] ?></th> |
| 506: <td> |
| 507: <input type="radio" name="form[users_online]" id="form_users_online_1" value="1"<?php if ($pun_config['o_users_online'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_users_online_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[users_online]" id="form_users_online_0" value="0"<?php if ($pun_config['o_users_online'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_users_online_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 508: <span><?php echo $lang_admin_options['Users online help'] ?></span> |
| 509: </td> |
| 510: </tr> |
| 511: <tr> |
| 512: <th scope="row"><a name="censoring"></a><?php echo $lang_admin_options['Censor words label'] ?></th> |
| 513: <td> |
| 514: <input type="radio" name="form[censoring]" id="form_censoring_1" value="1"<?php if ($pun_config['o_censoring'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_censoring_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[censoring]" id="form_censoring_0" value="0"<?php if ($pun_config['o_censoring'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_censoring_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 515: <span><?php printf($lang_admin_options['Censor words help'], '<a href="admin_censoring.php">'.$lang_admin_common['Censoring'].'</a>') ?></span> |
| 516: </td> |
| 517: </tr> |
| 518: <tr> |
| 519: <th scope="row"><a name="signatures"></a><?php echo $lang_admin_options['Signatures label'] ?></th> |
| 520: <td> |
| 521: <input type="radio" name="form[signatures]" id="form_signatures_1" value="1"<?php if ($pun_config['o_signatures'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_signatures_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[signatures]" id="form_signatures_0" value="0"<?php if ($pun_config['o_signatures'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_signatures_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 522: <span><?php echo $lang_admin_options['Signatures help'] ?></span> |
| 523: </td> |
| 524: </tr> |
| 525: <tr> |
| 526: <th scope="row"><a name="ranks"></a><?php echo $lang_admin_options['User ranks label'] ?></th> |
| 527: <td> |
| 528: <input type="radio" name="form[ranks]" id="form_ranks_1" value="1"<?php if ($pun_config['o_ranks'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_ranks_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[ranks]" id="form_ranks_0" value="0"<?php if ($pun_config['o_ranks'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_ranks_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 529: <span><?php printf($lang_admin_options['User ranks help'], '<a href="admin_ranks.php">'.$lang_admin_common['Ranks'].'</a>') ?></span> |
| 530: </td> |
| 531: </tr> |
| 532: <tr> |
| 533: <th scope="row"><?php echo $lang_admin_options['User has posted label'] ?></th> |
| 534: <td> |
| 535: <input type="radio" name="form[show_dot]" id="form_show_dot_1" value="1"<?php if ($pun_config['o_show_dot'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_show_dot_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[show_dot]" id="form_show_dot_0" value="0"<?php if ($pun_config['o_show_dot'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_show_dot_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 536: <span><?php echo $lang_admin_options['User has posted help'] ?></span> |
| 537: </td> |
| 538: </tr> |
| 539: <tr> |
| 540: <th scope="row"><?php echo $lang_admin_options['Topic views label'] ?></th> |
| 541: <td> |
| 542: <input type="radio" name="form[topic_views]" id="form_topic_views_1" value="1"<?php if ($pun_config['o_topic_views'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_topic_views_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[topic_views]" id="form_topic_views_0" value="0"<?php if ($pun_config['o_topic_views'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_topic_views_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 543: <span><?php echo $lang_admin_options['Topic views help'] ?></span> |
| 544: </td> |
| 545: </tr> |
| 546: <tr> |
| 547: <th scope="row"><?php echo $lang_admin_options['Quick jump label'] ?></th> |
| 548: <td> |
| 549: <input type="radio" name="form[quickjump]" id="form_quickjump_1" value="1"<?php if ($pun_config['o_quickjump'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_quickjump_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[quickjump]" id="form_quickjump_0" value="0"<?php if ($pun_config['o_quickjump'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_quickjump_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 550: <span><?php echo $lang_admin_options['Quick jump help'] ?></span> |
| 551: </td> |
| 552: </tr> |
| 553: <tr> |
| 554: <th scope="row"><?php echo $lang_admin_options['GZip label'] ?></th> |
| 555: <td> |
| 556: <input type="radio" name="form[gzip]" id="form_gzip_1" value="1"<?php if ($pun_config['o_gzip'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_gzip_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[gzip]" id="form_gzip_0" value="0"<?php if ($pun_config['o_gzip'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_gzip_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 557: <span><?php echo $lang_admin_options['GZip help'] ?></span> |
| 558: </td> |
| 559: </tr> |
| 560: <tr> |
| 561: <th scope="row"><?php echo $lang_admin_options['Search all label'] ?></th> |
| 562: <td> |
| 563: <input type="radio" name="form[search_all_forums]" id="form_search_all_forums_1" value="1"<?php if ($pun_config['o_search_all_forums'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_search_all_forums_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[search_all_forums]" id="form_search_all_forums_0" value="0"<?php if ($pun_config['o_search_all_forums'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_search_all_forums_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 564: <span><?php echo $lang_admin_options['Search all help'] ?></span> |
| 565: </td> |
| 566: </tr> |
| 567: <tr> |
| 568: <th scope="row"><?php echo $lang_admin_options['Menu items label'] ?></th> |
| 569: <td> |
| 570: <textarea name="form[additional_navlinks]" rows="3" cols="55"><?php echo pun_htmlspecialchars($pun_config['o_additional_navlinks']) ?></textarea> |
| 571: <span><?php echo $lang_admin_options['Menu items help'] ?></span> |
| 572: </td> |
| 573: </tr> |
| 574: </table> |
| 575: </div> |
| 576: </fieldset> |
| 577: </div> |
| 578: <div class="inform"> |
| 579: <fieldset> |
| 580: <legend><?php echo $lang_admin_options['Feed subhead'] ?></legend> |
| 581: <div class="infldset"> |
| 582: <table class="aligntop" cellspacing="0"> |
| 583: <tr> |
| 584: <th scope="row"><?php echo $lang_admin_options['Default feed label'] ?></th> |
| 585: <td> |
| 586: <input type="radio" name="form[feed_type]" id="form_feed_type_0" value="0"<?php if ($pun_config['o_feed_type'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_options['None'] ?></strong>   <input type="radio" name="form[feed_type]" id="form_feed_type_1" value="1"<?php if ($pun_config['o_feed_type'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_feed_type_0"><strong><?php echo $lang_admin_options['RSS'] ?></strong></label>   <input type="radio" name="form[feed_type]" id="form_feed_type_2" value="2"<?php if ($pun_config['o_feed_type'] == '2') echo ' checked="checked"' ?> /> <label class="conl" for="form_feed_type_1"><strong><?php echo $lang_admin_options['Atom'] ?></strong></label> |
| 587: <span><?php echo $lang_admin_options['Default feed help'] ?></span> |
| 588: </td> |
| 589: </tr> |
| 590: <tr> |
| 591: <th scope="row"><?php echo $lang_admin_options['Feed TTL label'] ?></th> |
| 592: <td> |
| 593: <select name="form[feed_ttl]"> |
| 594: <option value="0"<?php if ($pun_config['o_feed_ttl'] == '0') echo ' selected="selected"'; ?>><?php echo $lang_admin_options['No cache'] ?></option> |
| 595: <?php |
| 596: |
| 597: $times = array(5, 15, 30, 60); |
| 598: |
| 599: foreach ($times as $time) |
| 600: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$time.'"'.($pun_config['o_feed_ttl'] == $time ? ' selected="selected"' : '').'>'.sprintf($lang_admin_options['Minutes'], $time).'</option>'."\n"; |
| 601: |
| 602: ?> |
| 603: </select> |
| 604: <span><?php echo $lang_admin_options['Feed TTL help'] ?></span> |
| 605: </td> |
| 606: </tr> |
| 607: </table> |
| 608: </div> |
| 609: </fieldset> |
| 610: </div> |
| 611: <div class="inform"> |
| 612: <fieldset> |
| 613: <legend><?php echo $lang_admin_options['Reports subhead'] ?></legend> |
| 614: <div class="infldset"> |
| 615: <table class="aligntop" cellspacing="0"> |
| 616: <tr> |
| 617: <th scope="row"><?php echo $lang_admin_options['Reporting method label'] ?></th> |
| 618: <td> |
| 619: <input type="radio" name="form[report_method]" id="form_report_method_0" value="0"<?php if ($pun_config['o_report_method'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_options['Internal'] ?></strong>   <input type="radio" name="form[report_method]" id="form_report_method_1" value="1"<?php if ($pun_config['o_report_method'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_report_method_0"><strong><?php echo $lang_admin_options['By e-mail'] ?></strong></label>   <input type="radio" name="form[report_method]" id="form_report_method_2" value="2"<?php if ($pun_config['o_report_method'] == '2') echo ' checked="checked"' ?> /> <label class="conl" for="form_report_method_1"><strong><?php echo $lang_admin_options['Both'] ?></strong></label> |
| 620: <span><?php echo $lang_admin_options['Reporting method help'] ?></span> |
| 621: </td> |
| 622: </tr> |
| 623: <tr> |
| 624: <th scope="row"><?php echo $lang_admin_options['Mailing list label'] ?></th> |
| 625: <td> |
| 626: <textarea name="form[mailing_list]" rows="5" cols="55"><?php echo pun_htmlspecialchars($pun_config['o_mailing_list']) ?></textarea> |
| 627: <span><?php echo $lang_admin_options['Mailing list help'] ?></span> |
| 628: </td> |
| 629: </tr> |
| 630: </table> |
| 631: </div> |
| 632: </fieldset> |
| 633: </div> |
| 634: <div class="inform"> |
| 635: <fieldset> |
| 636: <legend><?php echo $lang_admin_options['Avatars subhead'] ?></legend> |
| 637: <div class="infldset"> |
| 638: <table class="aligntop" cellspacing="0"> |
| 639: <tr> |
| 640: <th scope="row"><?php echo $lang_admin_options['Use avatars label'] ?></th> |
| 641: <td> |
| 642: <input type="radio" name="form[avatars]" id="form_avatars_1" value="1"<?php if ($pun_config['o_avatars'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_avatars_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[avatars]" id="form_avatars_0" value="0"<?php if ($pun_config['o_avatars'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_avatars_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 643: <span><?php echo $lang_admin_options['Use avatars help'] ?></span> |
| 644: </td> |
| 645: </tr> |
| 646: <tr> |
| 647: <th scope="row"><?php echo $lang_admin_options['Upload directory label'] ?></th> |
| 648: <td> |
| 649: <input type="text" name="form[avatars_dir]" size="35" maxlength="50" value="<?php echo pun_htmlspecialchars($pun_config['o_avatars_dir']) ?>" /> |
| 650: <span><?php echo $lang_admin_options['Upload directory help'] ?></span> |
| 651: </td> |
| 652: </tr> |
| 653: <tr> |
| 654: <th scope="row"><?php echo $lang_admin_options['Max width label'] ?></th> |
| 655: <td> |
| 656: <input type="text" name="form[avatars_width]" size="5" maxlength="5" value="<?php echo $pun_config['o_avatars_width'] ?>" /> |
| 657: <span><?php echo $lang_admin_options['Max width help'] ?></span> |
| 658: </td> |
| 659: </tr> |
| 660: <tr> |
| 661: <th scope="row"><?php echo $lang_admin_options['Max height label'] ?></th> |
| 662: <td> |
| 663: <input type="text" name="form[avatars_height]" size="5" maxlength="5" value="<?php echo $pun_config['o_avatars_height'] ?>" /> |
| 664: <span><?php echo $lang_admin_options['Max height help'] ?></span> |
| 665: </td> |
| 666: </tr> |
| 667: <tr> |
| 668: <th scope="row"><?php echo $lang_admin_options['Max size label'] ?></th> |
| 669: <td> |
| 670: <input type="text" name="form[avatars_size]" size="6" maxlength="6" value="<?php echo $pun_config['o_avatars_size'] ?>" /> |
| 671: <span><?php echo $lang_admin_options['Max size help'] ?></span> |
| 672: </td> |
| 673: </tr> |
| 674: </table> |
| 675: </div> |
| 676: </fieldset> |
| 677: </div> |
| 678: <div class="inform"> |
| 679: <fieldset> |
| 680: <legend><?php echo $lang_admin_options['E-mail subhead'] ?></legend> |
| 681: <div class="infldset"> |
| 682: <table class="aligntop" cellspacing="0"> |
| 683: <tr> |
| 684: <th scope="row"><?php echo $lang_admin_options['Admin e-mail label'] ?></th> |
| 685: <td> |
| 686: <input type="text" name="form[admin_email]" size="50" maxlength="80" value="<?php echo $pun_config['o_admin_email'] ?>" /> |
| 687: <span><?php echo $lang_admin_options['Admin e-mail help'] ?></span> |
| 688: </td> |
| 689: </tr> |
| 690: <tr> |
| 691: <th scope="row"><?php echo $lang_admin_options['Webmaster e-mail label'] ?></th> |
| 692: <td> |
| 693: <input type="text" name="form[webmaster_email]" size="50" maxlength="80" value="<?php echo $pun_config['o_webmaster_email'] ?>" /> |
| 694: <span><?php echo $lang_admin_options['Webmaster e-mail help'] ?></span> |
| 695: </td> |
| 696: </tr> |
| 697: <tr> |
| 698: <th scope="row"><?php echo $lang_admin_options['Forum subscriptions label'] ?></th> |
| 699: <td> |
| 700: <input type="radio" name="form[forum_subscriptions]" id="form_forum_subscriptions_1" value="1"<?php if ($pun_config['o_forum_subscriptions'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_forum_subscriptions_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[forum_subscriptions]" id="form_forum_subscriptions_0" value="0"<?php if ($pun_config['o_forum_subscriptions'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_forum_subscriptions_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 701: <span><?php echo $lang_admin_options['Forum subscriptions help'] ?></span> |
| 702: </td> |
| 703: </tr> |
| 704: <tr> |
| 705: <th scope="row"><?php echo $lang_admin_options['Topic subscriptions label'] ?></th> |
| 706: <td> |
| 707: <input type="radio" name="form[topic_subscriptions]" id="form_topic_subscriptions_1" value="1"<?php if ($pun_config['o_topic_subscriptions'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_topic_subscriptions_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[topic_subscriptions]" id="form_topic_subscriptions_0" value="0"<?php if ($pun_config['o_topic_subscriptions'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_topic_subscriptions_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 708: <span><?php echo $lang_admin_options['Topic subscriptions help'] ?></span> |
| 709: </td> |
| 710: </tr> |
| 711: <tr> |
| 712: <th scope="row"><?php echo $lang_admin_options['SMTP address label'] ?></th> |
| 713: <td> |
| 714: <input type="text" name="form[smtp_host]" size="30" maxlength="100" value="<?php echo pun_htmlspecialchars($pun_config['o_smtp_host']) ?>" /> |
| 715: <span><?php echo $lang_admin_options['SMTP address help'] ?></span> |
| 716: </td> |
| 717: </tr> |
| 718: <tr> |
| 719: <th scope="row"><?php echo $lang_admin_options['SMTP username label'] ?></th> |
| 720: <td> |
| 721: <input type="text" name="form[smtp_user]" size="25" maxlength="50" value="<?php echo pun_htmlspecialchars($pun_config['o_smtp_user']) ?>" /> |
| 722: <span><?php echo $lang_admin_options['SMTP username help'] ?></span> |
| 723: </td> |
| 724: </tr> |
| 725: <tr> |
| 726: <th scope="row"><?php echo $lang_admin_options['SMTP password label'] ?></th> |
| 727: <td> |
| 728: <span><input type="checkbox" name="form[smtp_change_pass]" id="form_smtp_change_pass" value="1" />  <label class="conl" for="form_smtp_change_pass"><?php echo $lang_admin_options['SMTP change password help'] ?></label></span> |
| 729: <?php $smtp_pass = !empty($pun_config['o_smtp_pass']) ? random_key(pun_strlen($pun_config['o_smtp_pass']), true) : ''; ?> |
| 730: <input type="password" name="form[smtp_pass1]" size="25" maxlength="50" value="<?php echo $smtp_pass ?>" /> |
| 731: <input type="password" name="form[smtp_pass2]" size="25" maxlength="50" value="<?php echo $smtp_pass ?>" /> |
| 732: <span><?php echo $lang_admin_options['SMTP password help'] ?></span> |
| 733: </td> |
| 734: </tr> |
| 735: <tr> |
| 736: <th scope="row"><?php echo $lang_admin_options['SMTP SSL label'] ?></th> |
| 737: <td> |
| 738: <input type="radio" name="form[smtp_ssl]" id="form_smtp_ssl_1" value="1"<?php if ($pun_config['o_smtp_ssl'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_smtp_ssl_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[smtp_ssl]" id="form_smtp_ssl_0" value="0"<?php if ($pun_config['o_smtp_ssl'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_smtp_ssl_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 739: <span><?php echo $lang_admin_options['SMTP SSL help'] ?></span> |
| 740: </td> |
| 741: </tr> |
| 742: </table> |
| 743: </div> |
| 744: </fieldset> |
| 745: </div> |
| 746: <div class="inform"> |
| 747: <fieldset> |
| 748: <legend><?php echo $lang_admin_options['Registration subhead'] ?></legend> |
| 749: <div class="infldset"> |
| 750: <table class="aligntop" cellspacing="0"> |
| 751: <tr> |
| 752: <th scope="row"><?php echo $lang_admin_options['Allow new label'] ?></th> |
| 753: <td> |
| 754: <input type="radio" name="form[regs_allow]" id="form_regs_allow_1" value="1"<?php if ($pun_config['o_regs_allow'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_regs_allow_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[regs_allow]" id="form_regs_allow_0" value="0"<?php if ($pun_config['o_regs_allow'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_regs_allow_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 755: <span><?php echo $lang_admin_options['Allow new help'] ?></span> |
| 756: </td> |
| 757: </tr> |
| 758: <tr> |
| 759: <th scope="row"><?php echo $lang_admin_options['Verify label'] ?></th> |
| 760: <td> |
| 761: <input type="radio" name="form[regs_verify]" id="form_regs_verify_1" value="1"<?php if ($pun_config['o_regs_verify'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_regs_verify_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[regs_verify]" id="form_regs_verify_0" value="0"<?php if ($pun_config['o_regs_verify'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_regs_verify_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 762: <span><?php echo $lang_admin_options['Verify help'] ?></span> |
| 763: </td> |
| 764: </tr> |
| 765: <tr> |
| 766: <th scope="row"><?php echo $lang_admin_options['Report new label'] ?></th> |
| 767: <td> |
| 768: <input type="radio" name="form[regs_report]" id="form_regs_report_1" value="1"<?php if ($pun_config['o_regs_report'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_regs_report_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[regs_report]" id="form_regs_report_0" value="0"<?php if ($pun_config['o_regs_report'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_regs_report_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 769: <span><?php echo $lang_admin_options['Report new help'] ?></span> |
| 770: </td> |
| 771: </tr> |
| 772: <tr> |
| 773: <th scope="row"><?php echo $lang_admin_options['Use rules label'] ?></th> |
| 774: <td> |
| 775: <input type="radio" name="form[rules]" id="form_rules_1" value="1"<?php if ($pun_config['o_rules'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_rules_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[rules]" id="form_rules_0" value="0"<?php if ($pun_config['o_rules'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_rules_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 776: <span><?php echo $lang_admin_options['Use rules help'] ?></span> |
| 777: </td> |
| 778: </tr> |
| 779: <tr> |
| 780: <th scope="row"><?php echo $lang_admin_options['Rules label'] ?></th> |
| 781: <td> |
| 782: <textarea name="form[rules_message]" rows="10" cols="55"><?php echo pun_htmlspecialchars($pun_config['o_rules_message']) ?></textarea> |
| 783: <span><?php echo $lang_admin_options['Rules help'] ?></span> |
| 784: </td> |
| 785: </tr> |
| 786: <tr> |
| 787: <th scope="row"><?php echo $lang_admin_options['E-mail default label'] ?></th> |
| 788: <td> |
| 789: <span><?php echo $lang_admin_options['E-mail default help'] ?></span> |
| 790: <input type="radio" name="form[default_email_setting]" id="form_default_email_setting_0" value="0"<?php if ($pun_config['o_default_email_setting'] == '0') echo ' checked="checked"' ?> /> <?php echo $lang_admin_options['Display e-mail label'] ?><br /> |
| 791: <input type="radio" name="form[default_email_setting]" id="form_default_email_setting_1" value="1"<?php if ($pun_config['o_default_email_setting'] == '1') echo ' checked="checked"' ?> /> <?php echo $lang_admin_options['Hide allow form label'] ?><br /> |
| 792: <input type="radio" name="form[default_email_setting]" id="form_default_email_setting_2" value="2"<?php if ($pun_config['o_default_email_setting'] == '2') echo ' checked="checked"' ?> /> <?php echo $lang_admin_options['Hide both label'] ?><br /> |
| 793: </td> |
| 794: </tr> |
| 795: </table> |
| 796: </div> |
| 797: </fieldset> |
| 798: </div> |
| 799: <div class="inform"> |
| 800: <fieldset> |
| 801: <legend><?php echo $lang_admin_options['Announcement subhead'] ?></legend> |
| 802: <div class="infldset"> |
| 803: <table class="aligntop" cellspacing="0"> |
| 804: <tr> |
| 805: <th scope="row"><?php echo $lang_admin_options['Display announcement label'] ?></th> |
| 806: <td> |
| 807: <input type="radio" name="form[announcement]" id="form_announcement_1" value="1"<?php if ($pun_config['o_announcement'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_announcement_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[announcement]" id="form_announcement_0" value="0"<?php if ($pun_config['o_announcement'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_announcement_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 808: <span><?php echo $lang_admin_options['Display announcement help'] ?></span> |
| 809: </td> |
| 810: </tr> |
| 811: <tr> |
| 812: <th scope="row"><?php echo $lang_admin_options['Announcement message label'] ?></th> |
| 813: <td> |
| 814: <textarea name="form[announcement_message]" rows="5" cols="55"><?php echo pun_htmlspecialchars($pun_config['o_announcement_message']) ?></textarea> |
| 815: <span><?php echo $lang_admin_options['Announcement message help'] ?></span> |
| 816: </td> |
| 817: </tr> |
| 818: </table> |
| 819: </div> |
| 820: </fieldset> |
| 821: </div> |
| 822: <div class="inform"> |
| 823: <fieldset> |
| 824: <legend><?php echo $lang_admin_options['Maintenance subhead'] ?></legend> |
| 825: <div class="infldset"> |
| 826: <table class="aligntop" cellspacing="0"> |
| 827: <tr> |
| 828: <th scope="row"><a name="maintenance"></a><?php echo $lang_admin_options['Maintenance mode label'] ?></th> |
| 829: <td> |
| 830: <input type="radio" name="form[maintenance]" id="form_maintenance_1" value="1"<?php if ($pun_config['o_maintenance'] == '1') echo ' checked="checked"' ?> /> <label class="conl" for="form_maintenance_1"><strong><?php echo $lang_admin_common['Yes'] ?></strong></label>   <input type="radio" name="form[maintenance]" id="form_maintenance_0" value="0"<?php if ($pun_config['o_maintenance'] == '0') echo ' checked="checked"' ?> /> <label class="conl" for="form_maintenance_0"><strong><?php echo $lang_admin_common['No'] ?></strong></label> |
| 831: <span><?php echo $lang_admin_options['Maintenance mode help'] ?></span> |
| 832: </td> |
| 833: </tr> |
| 834: <tr> |
| 835: <th scope="row"><?php echo $lang_admin_options['Maintenance message label'] ?></th> |
| 836: <td> |
| 837: <textarea name="form[maintenance_message]" rows="5" cols="55"><?php echo pun_htmlspecialchars($pun_config['o_maintenance_message']) ?></textarea> |
| 838: <span><?php echo $lang_admin_options['Maintenance message help'] ?></span> |
| 839: </td> |
| 840: </tr> |
| 841: </table> |
| 842: </div> |
| 843: </fieldset> |
| 844: </div> |
| 845: <p class="submitend"><input type="submit" name="save" value="<?php echo $lang_admin_common['Save changes'] ?>" /></p> |
| 846: </form> |
| 847: </div> |
| 848: </div> |
| 849: <div class="clearer"></div> |
| 850: </div> |
| 851: <?php |
| 852: |
| 853: require PUN_ROOT.'footer.php'; |
/dev/null |
b/admin_reports.php |
| 1: <?php |
| 2: |
| 3: /** |
| 4: * Copyright (C) 2008-2012 FluxBB |
| 5: * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB |
| 6: * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher |
| 7: */ |
| 8: |
| 9: // Tell header.php to use the admin template |
| 10: define('PUN_ADMIN_CONSOLE', 1); |
| 11: |
| 12: define('PUN_ROOT', dirname(__FILE__).'/'); |
| 13: require PUN_ROOT.'include/common.php'; |
| 14: require PUN_ROOT.'include/common_admin.php'; |
| 15: |
| 16: |
| 17: if (!$pun_user['is_admmod']) |
| 18: message($lang_common['No permission'], false, '403 Forbidden'); |
| 19: |
| 20: // Load the admin_reports.php language file |
| 21: require PUN_ROOT.'lang/'.$admin_language.'/admin_reports.php'; |
| 22: |
| 23: // Zap a report |
| 24: if (isset($_POST['zap_id'])) |
| 25: { |
| 26: confirm_referrer('admin_reports.php'); |
| 27: |
| 28: $zap_id = intval(key($_POST['zap_id'])); |
| 29: |
| 30: $result = $db->query('SELECT zapped FROM '.$db->prefix.'reports WHERE id='.$zap_id) or error('Unable to fetch report info', __FILE__, __LINE__, $db->error()); |
| 31: $zapped = $db->result($result); |
| 32: |
| 33: if ($zapped == '') |
| 34: $db->query('UPDATE '.$db->prefix.'reports SET zapped='.time().', zapped_by='.$pun_user['id'].' WHERE id='.$zap_id) or error('Unable to zap report', __FILE__, __LINE__, $db->error()); |
| 35: |
| 36: // Delete old reports (which cannot be viewed anyway) |
| 37: $result = $db->query('SELECT zapped FROM '.$db->prefix.'reports WHERE zapped IS NOT NULL ORDER BY zapped DESC LIMIT 10,1') or error('Unable to fetch read reports to delete', __FILE__, __LINE__, $db->error()); |
| 38: if ($db->num_rows($result) > 0) |
| 39: { |
| 40: $zapped_threshold = $db->result($result); |
| 41: $db->query('DELETE FROM '.$db->prefix.'reports WHERE zapped <= '.$zapped_threshold) or error('Unable to delete old read reports', __FILE__, __LINE__, $db->error()); |
| 42: } |
| 43: |
| 44: redirect('admin_reports.php', $lang_admin_reports['Report zapped redirect']); |
| 45: } |
| 46: |
| 47: |
| 48: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Reports']); |
| 49: define('PUN_ACTIVE_PAGE', 'admin'); |
| 50: require PUN_ROOT.'header.php'; |
| 51: |
| 52: generate_admin_menu('reports'); |
| 53: |
| 54: ?> |
| 55: <div class="blockform"> |
| 56: <h2><span><?php echo $lang_admin_reports['New reports head'] ?></span></h2> |
| 57: <div class="box"> |
| 58: <form method="post" action="admin_reports.php?action=zap"> |
| 59: <?php |
| 60: |
| 61: $result = $db->query('SELECT r.id, r.topic_id, r.forum_id, r.reported_by, r.created, r.message, p.id AS pid, t.subject, f.forum_name, u.username AS reporter FROM '.$db->prefix.'reports AS r LEFT JOIN '.$db->prefix.'posts AS p ON r.post_id=p.id LEFT JOIN '.$db->prefix.'topics AS t ON r.topic_id=t.id LEFT JOIN '.$db->prefix.'forums AS f ON r.forum_id=f.id LEFT JOIN '.$db->prefix.'users AS u ON r.reported_by=u.id WHERE r.zapped IS NULL ORDER BY created DESC') or error('Unable to fetch report list', __FILE__, __LINE__, $db->error()); |
| 62: |
| 63: if ($db->num_rows($result)) |
| 64: { |
| 65: while ($cur_report = $db->fetch_assoc($result)) |
| 66: { |
| 67: $reporter = ($cur_report['reporter'] != '') ? '<a href="profile.php?id='.$cur_report['reported_by'].'">'.pun_htmlspecialchars($cur_report['reporter']).'</a>' : $lang_admin_reports['Deleted user']; |
| 68: $forum = ($cur_report['forum_name'] != '') ? '<span><a href="viewforum.php?id='.$cur_report['forum_id'].'">'.pun_htmlspecialchars($cur_report['forum_name']).'</a></span>' : '<span>'.$lang_admin_reports['Deleted'].'</span>'; |
| 69: $topic = ($cur_report['subject'] != '') ? '<span>» <a href="viewtopic.php?id='.$cur_report['topic_id'].'">'.pun_htmlspecialchars($cur_report['subject']).'</a></span>' : '<span>» '.$lang_admin_reports['Deleted'].'</span>'; |
| 70: $post = str_replace("\n", '<br />', pun_htmlspecialchars($cur_report['message'])); |
| 71: $post_id = ($cur_report['pid'] != '') ? '<span>» <a href="viewtopic.php?pid='.$cur_report['pid'].'#p'.$cur_report['pid'].'">'.sprintf($lang_admin_reports['Post ID'], $cur_report['pid']).'</a></span>' : '<span>» '.$lang_admin_reports['Deleted'].'</span>'; |
| 72: $report_location = array($forum, $topic, $post_id); |
| 73: |
| 74: ?> |
| 75: <div class="inform"> |
| 76: <fieldset> |
| 77: <legend><?php printf($lang_admin_reports['Report subhead'], format_time($cur_report['created'])) ?></legend> |
| 78: <div class="infldset"> |
| 79: <table class="aligntop" cellspacing="0"> |
| 80: <tr> |
| 81: <th scope="row"><?php printf($lang_admin_reports['Reported by'], $reporter) ?></th> |
| 82: <td class="location"><?php echo implode(' ', $report_location) ?></td> |
| 83: </tr> |
| 84: <tr> |
| 85: <th scope="row"><?php echo $lang_admin_reports['Reason'] ?><div><input type="submit" name="zap_id[<?php echo $cur_report['id'] ?>]" value="<?php echo $lang_admin_reports['Zap'] ?>" /></div></th> |
| 86: <td><?php echo $post ?></td> |
| 87: </tr> |
| 88: </table> |
| 89: </div> |
| 90: </fieldset> |
| 91: </div> |
| 92: <?php |
| 93: |
| 94: } |
| 95: } |
| 96: else |
| 97: { |
| 98: |
| 99: ?> |
| 100: <div class="inform"> |
| 101: <fieldset> |
| 102: <legend><?php echo $lang_admin_common['None'] ?></legend> |
| 103: <div class="infldset"> |
| 104: <p><?php echo $lang_admin_reports['No new reports'] ?></p> |
| 105: </div> |
| 106: </fieldset> |
| 107: </div> |
| 108: <?php |
| 109: |
| 110: } |
| 111: |
| 112: ?> |
| 113: </form> |
| 114: </div> |
| 115: </div> |
| 116: |
| 117: <div class="blockform block2"> |
| 118: <h2><span><?php echo $lang_admin_reports['Last 10 head'] ?></span></h2> |
| 119: <div class="box"> |
| 120: <div class="fakeform"> |
| 121: <?php |
| 122: |
| 123: $result = $db->query('SELECT r.id, r.topic_id, r.forum_id, r.reported_by, r.message, r.zapped, r.zapped_by AS zapped_by_id, p.id AS pid, t.subject, f.forum_name, u.username AS reporter, u2.username AS zapped_by FROM '.$db->prefix.'reports AS r LEFT JOIN '.$db->prefix.'posts AS p ON r.post_id=p.id LEFT JOIN '.$db->prefix.'topics AS t ON r.topic_id=t.id LEFT JOIN '.$db->prefix.'forums AS f ON r.forum_id=f.id LEFT JOIN '.$db->prefix.'users AS u ON r.reported_by=u.id LEFT JOIN '.$db->prefix.'users AS u2 ON r.zapped_by=u2.id WHERE r.zapped IS NOT NULL ORDER BY zapped DESC LIMIT 10') or error('Unable to fetch report list', __FILE__, __LINE__, $db->error()); |
| 124: |
| 125: if ($db->num_rows($result)) |
| 126: { |
| 127: while ($cur_report = $db->fetch_assoc($result)) |
| 128: { |
| 129: $reporter = ($cur_report['reporter'] != '') ? '<a href="profile.php?id='.$cur_report['reported_by'].'">'.pun_htmlspecialchars($cur_report['reporter']).'</a>' : $lang_admin_reports['Deleted user']; |
| 130: $forum = ($cur_report['forum_name'] != '') ? '<span><a href="viewforum.php?id='.$cur_report['forum_id'].'">'.pun_htmlspecialchars($cur_report['forum_name']).'</a></span>' : '<span>'.$lang_admin_reports['Deleted'].'</span>'; |
| 131: $topic = ($cur_report['subject'] != '') ? '<span>» <a href="viewtopic.php?id='.$cur_report['topic_id'].'">'.pun_htmlspecialchars($cur_report['subject']).'</a></span>' : '<span>» '.$lang_admin_reports['Deleted'].'</span>'; |
| 132: $post = str_replace("\n", '<br />', pun_htmlspecialchars($cur_report['message'])); |
| 133: $post_id = ($cur_report['pid'] != '') ? '<span>» <a href="viewtopic.php?pid='.$cur_report['pid'].'#p'.$cur_report['pid'].'">'.sprintf($lang_admin_reports['Post ID'], $cur_report['pid']).'</a></span>' : '<span>» '.$lang_admin_reports['Deleted'].'</span>'; |
| 134: $zapped_by = ($cur_report['zapped_by'] != '') ? '<a href="profile.php?id='.$cur_report['zapped_by_id'].'">'.pun_htmlspecialchars($cur_report['zapped_by']).'</a>' : $lang_admin_reports['NA']; |
| 135: $zapped_by = ($cur_report['zapped_by'] != '') ? '<strong>'.pun_htmlspecialchars($cur_report['zapped_by']).'</strong>' : $lang_admin_reports['NA']; |
| 136: $report_location = array($forum, $topic, $post_id); |
| 137: |
| 138: ?> |
| 139: <div class="inform"> |
| 140: <fieldset> |
| 141: <legend><?php printf($lang_admin_reports['Zapped subhead'], format_time($cur_report['zapped']), $zapped_by) ?></legend> |
| 142: <div class="infldset"> |
| 143: <table class="aligntop" cellspacing="0"> |
| 144: <tr> |
| 145: <th scope="row"><?php printf($lang_admin_reports['Reported by'], $reporter) ?></th> |
| 146: <td class="location"><?php echo implode(' ', $report_location) ?></td> |
| 147: </tr> |
| 148: <tr> |
| 149: <th scope="row"><?php echo $lang_admin_reports['Reason'] ?></th> |
| 150: <td><?php echo $post ?></td> |
| 151: </tr> |
| 152: </table> |
| 153: </div> |
| 154: </fieldset> |
| 155: </div> |
| 156: <?php |
| 157: |
| 158: } |
| 159: } |
| 160: else |
| 161: { |
| 162: |
| 163: ?> |
| 164: <div class="inform"> |
| 165: <fieldset> |
| 166: <legend><?php echo $lang_admin_common['None'] ?></legend> |
| 167: <div class="infldset"> |
| 168: <p><?php echo $lang_admin_reports['No zapped reports'] ?></p> |
| 169: </div> |
| 170: </fieldset> |
| 171: </div> |
| 172: <?php |
| 173: |
| 174: } |
| 175: |
| 176: ?> |
| 177: </div> |
| 178: </div> |
| 179: </div> |
| 180: <div class="clearer"></div> |
| 181: </div> |
| 182: <?php |
| 183: |
| 184: require PUN_ROOT.'footer.php'; |
/dev/null |
b/admin_users.php |
| 1: <?php |
| 2: |
| 3: /** |
| 4: * Copyright (C) 2008-2012 FluxBB |
| 5: * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB |
| 6: * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher |
| 7: */ |
| 8: |
| 9: // Tell header.php to use the admin template |
| 10: define('PUN_ADMIN_CONSOLE', 1); |
| 11: |
| 12: define('PUN_ROOT', dirname(__FILE__).'/'); |
| 13: require PUN_ROOT.'include/common.php'; |
| 14: require PUN_ROOT.'include/common_admin.php'; |
| 15: |
| 16: |
| 17: if (!$pun_user['is_admmod']) |
| 18: message($lang_common['No permission'], false, '403 Forbidden'); |
| 19: |
| 20: // Load the admin_users.php language file |
| 21: require PUN_ROOT.'lang/'.$admin_language.'/admin_users.php'; |
| 22: |
| 23: // Show IP statistics for a certain user ID |
| 24: if (isset($_GET['ip_stats'])) |
| 25: { |
| 26: $ip_stats = intval($_GET['ip_stats']); |
| 27: if ($ip_stats < 1) |
| 28: message($lang_common['Bad request']); |
| 29: |
| 30: // Fetch ip count |
| 31: $result = $db->query('SELECT poster_ip, MAX(posted) AS last_used FROM '.$db->prefix.'posts WHERE poster_id='.$ip_stats.' GROUP BY poster_ip') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
| 32: $num_ips = $db->num_rows($result); |
| 33: |
| 34: // Determine the ip offset (based on $_GET['p']) |
| 35: $num_pages = ceil($num_ips / 50); |
| 36: |
| 37: $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']); |
| 38: $start_from = 50 * ($p - 1); |
| 39: |
| 40: // Generate paging links |
| 41: $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'admin_users.php?ip_stats='.$ip_stats ); |
| 42: |
| 43: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Results head']); |
| 44: define('PUN_ACTIVE_PAGE', 'admin'); |
| 45: require PUN_ROOT.'header.php'; |
| 46: |
| 47: ?> |
| 48: <div class="linkst"> |
| 49: <div class="inbox crumbsplus"> |
| 50: <ul class="crumbs"> |
| 51: <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
| 52: <li><span>» </span><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li> |
| 53: <li><span>» </span><strong><?php echo $lang_admin_users['Results head'] ?></strong></li> |
| 54: </ul> |
| 55: <div class="pagepost"> |
| 56: <p class="pagelink"><?php echo $paging_links ?></p> |
| 57: </div> |
| 58: <div class="clearer"></div> |
| 59: </div> |
| 60: </div> |
| 61: |
| 62: <div id="users1" class="blocktable"> |
| 63: <h2><span><?php echo $lang_admin_users['Results head'] ?></span></h2> |
| 64: <div class="box"> |
| 65: <div class="inbox"> |
| 66: <table cellspacing="0"> |
| 67: <thead> |
| 68: <tr> |
| 69: <th class="tcl" scope="col"><?php echo $lang_admin_users['Results IP address head'] ?></th> |
| 70: <th class="tc2" scope="col"><?php echo $lang_admin_users['Results last used head'] ?></th> |
| 71: <th class="tc3" scope="col"><?php echo $lang_admin_users['Results times found head'] ?></th> |
| 72: <th class="tcr" scope="col"><?php echo $lang_admin_users['Results action head'] ?></th> |
| 73: </tr> |
| 74: </thead> |
| 75: <tbody> |
| 76: <?php |
| 77: |
| 78: $result = $db->query('SELECT poster_ip, MAX(posted) AS last_used, COUNT(id) AS used_times FROM '.$db->prefix.'posts WHERE poster_id='.$ip_stats.' GROUP BY poster_ip ORDER BY last_used DESC LIMIT '.$start_from.', 50') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
| 79: if ($db->num_rows($result)) |
| 80: { |
| 81: while ($cur_ip = $db->fetch_assoc($result)) |
| 82: { |
| 83: |
| 84: ?> |
| 85: <tr> |
| 86: <td class="tcl"><a href="moderate.php?get_host=<?php echo $cur_ip['poster_ip'] ?>"><?php echo $cur_ip['poster_ip'] ?></a></td> |
| 87: <td class="tc2"><?php echo format_time($cur_ip['last_used']) ?></td> |
| 88: <td class="tc3"><?php echo $cur_ip['used_times'] ?></td> |
| 89: <td class="tcr"><a href="admin_users.php?show_users=<?php echo $cur_ip['poster_ip'] ?>"><?php echo $lang_admin_users['Results find more link'] ?></a></td> |
| 90: </tr> |
| 91: <?php |
| 92: |
| 93: } |
| 94: } |
| 95: else |
| 96: echo "\t\t\t\t".'<tr><td class="tcl" colspan="4">'.$lang_admin_users['Results no posts found'].'</td></tr>'."\n"; |
| 97: |
| 98: ?> |
| 99: </tbody> |
| 100: </table> |
| 101: </div> |
| 102: </div> |
| 103: </div> |
| 104: |
| 105: <div class="linksb"> |
| 106: <div class="inbox crumbsplus"> |
| 107: <div class="pagepost"> |
| 108: <p class="pagelink"><?php echo $paging_links ?></p> |
| 109: </div> |
| 110: <ul class="crumbs"> |
| 111: <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
| 112: <li><span>» </span><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li> |
| 113: <li><span>» </span><strong><?php echo $lang_admin_users['Results head'] ?></strong></li> |
| 114: </ul> |
| 115: <div class="clearer"></div> |
| 116: </div> |
| 117: </div> |
| 118: <?php |
| 119: |
| 120: require PUN_ROOT.'footer.php'; |
| 121: } |
| 122: |
| 123: |
| 124: if (isset($_GET['show_users'])) |
| 125: { |
| 126: $ip = pun_trim($_GET['show_users']); |
| 127: |
| 128: if (!@preg_match('%^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$%', $ip) && !@preg_match('%^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$%', $ip)) |
| 129: message($lang_admin_users['Bad IP message']); |
| 130: |
| 131: // Fetch user count |
| 132: $result = $db->query('SELECT DISTINCT poster_id, poster FROM '.$db->prefix.'posts WHERE poster_ip=\''.$db->escape($ip).'\'') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
| 133: $num_users = $db->num_rows($result); |
| 134: |
| 135: // Determine the user offset (based on $_GET['p']) |
| 136: $num_pages = ceil($num_users / 50); |
| 137: |
| 138: $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']); |
| 139: $start_from = 50 * ($p - 1); |
| 140: |
| 141: // Generate paging links |
| 142: $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'admin_users.php?show_users='.$ip); |
| 143: |
| 144: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Results head']); |
| 145: define('PUN_ACTIVE_PAGE', 'admin'); |
| 146: require PUN_ROOT.'header.php'; |
| 147: |
| 148: ?> |
| 149: <div class="linkst"> |
| 150: <div class="inbox crumbsplus"> |
| 151: <ul class="crumbs"> |
| 152: <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
| 153: <li><span>» </span><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li> |
| 154: <li><span>» </span><strong><?php echo $lang_admin_users['Results head'] ?></strong></li> |
| 155: </ul> |
| 156: <div class="pagepost"> |
| 157: <p class="pagelink"><?php echo $paging_links ?></p> |
| 158: </div> |
| 159: <div class="clearer"></div> |
| 160: </div> |
| 161: </div> |
| 162: |
| 163: <div id="users2" class="blocktable"> |
| 164: <h2><span><?php echo $lang_admin_users['Results head'] ?></span></h2> |
| 165: <div class="box"> |
| 166: <div class="inbox"> |
| 167: <table cellspacing="0"> |
| 168: <thead> |
| 169: <tr> |
| 170: <th class="tcl" scope="col"><?php echo $lang_admin_users['Results username head'] ?></th> |
| 171: <th class="tc2" scope="col"><?php echo $lang_admin_users['Results e-mail head'] ?></th> |
| 172: <th class="tc3" scope="col"><?php echo $lang_admin_users['Results title head'] ?></th> |
| 173: <th class="tc4" scope="col"><?php echo $lang_admin_users['Results posts head'] ?></th> |
| 174: <th class="tc5" scope="col"><?php echo $lang_admin_users['Results admin note head'] ?></th> |
| 175: <th class="tcr" scope="col"><?php echo $lang_admin_users['Results actions head'] ?></th> |
| 176: </tr> |
| 177: </thead> |
| 178: <tbody> |
| 179: <?php |
| 180: |
| 181: $result = $db->query('SELECT DISTINCT poster_id, poster FROM '.$db->prefix.'posts WHERE poster_ip=\''.$db->escape($ip).'\' ORDER BY poster DESC') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
| 182: $num_posts = $db->num_rows($result); |
| 183: |
| 184: if ($num_posts) |
| 185: { |
| 186: // Loop through users and print out some info |
| 187: for ($i = 0; $i < $num_posts; ++$i) |
| 188: { |
| 189: list($poster_id, $poster) = $db->fetch_row($result); |
| 190: |
| 191: $result2 = $db->query('SELECT u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1 AND u.id='.$poster_id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
| 192: |
| 193: if (($user_data = $db->fetch_assoc($result2))) |
| 194: { |
| 195: $user_title = get_title($user_data); |
| 196: |
| 197: $actions = '<a href="admin_users.php?ip_stats='.$user_data['id'].'">'.$lang_admin_users['Results view IP link'].'</a> | <a href="search.php?action=show_user_posts&user_id='.$user_data['id'].'">'.$lang_admin_users['Results show posts link'].'</a>'; |
| 198: |
| 199: ?> |
| 200: <tr> |
| 201: <td class="tcl"><?php echo '<a href="profile.php?id='.$user_data['id'].'">'.pun_htmlspecialchars($user_data['username']).'</a>' ?></td> |
| 202: <td class="tc2"><a href="mailto:<?php echo $user_data['email'] ?>"><?php echo $user_data['email'] ?></a></td> |
| 203: <td class="tc3"><?php echo $user_title ?></td> |
| 204: <td class="tc4"><?php echo forum_number_format($user_data['num_posts']) ?></td> |
| 205: <td class="tc5"><?php echo ($user_data['admin_note'] != '') ? pun_htmlspecialchars($user_data['admin_note']) : ' ' ?></td> |
| 206: <td class="tcr"><?php echo $actions ?></td> |
| 207: </tr> |
| 208: <?php |
| 209: |
| 210: } |
| 211: else |
| 212: { |
| 213: |
| 214: ?> |
| 215: <tr> |
| 216: <td class="tcl"><?php echo pun_htmlspecialchars($poster) ?></td> |
| 217: <td class="tc2"> </td> |
| 218: <td class="tc3"><?php echo $lang_admin_users['Results guest'] ?></td> |
| 219: <td class="tc4"> </td> |
| 220: <td class="tc5"> </td> |
| 221: <td class="tcr"> </td> |
| 222: </tr> |
| 223: <?php |
| 224: |
| 225: } |
| 226: } |
| 227: } |
| 228: else |
| 229: echo "\t\t\t\t".'<tr><td class="tcl" colspan="6">'.$lang_admin_users['Results no IP found'].'</td></tr>'."\n"; |
| 230: |
| 231: ?> |
| 232: </tbody> |
| 233: </table> |
| 234: </div> |
| 235: </div> |
| 236: </div> |
| 237: |
| 238: <div class="linksb"> |
| 239: <div class="inbox crumbsplus"> |
| 240: <div class="pagepost"> |
| 241: <p class="pagelink"><?php echo $paging_links ?></p> |
| 242: </div> |
| 243: <ul class="crumbs"> |
| 244: <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
| 245: <li><span>» </span><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li> |
| 246: <li><span>» </span><strong><?php echo $lang_admin_users['Results head'] ?></strong></li> |
| 247: </ul> |
| 248: <div class="clearer"></div> |
| 249: </div> |
| 250: </div> |
| 251: <?php |
| 252: require PUN_ROOT.'footer.php'; |
| 253: } |
| 254: |
| 255: |
| 256: // Move multiple users to other user groups |
| 257: else if (isset($_POST['move_users']) || isset($_POST['move_users_comply'])) |
| 258: { |
| 259: if ($pun_user['g_id'] > PUN_ADMIN) |
| 260: message($lang_common['No permission'], false, '403 Forbidden'); |
| 261: |
| 262: confirm_referrer('admin_users.php'); |
| 263: |
| 264: if (isset($_POST['users'])) |
| 265: { |
| 266: $user_ids = is_array($_POST['users']) ? array_keys($_POST['users']) : explode(',', $_POST['users']); |
| 267: $user_ids = array_map('intval', $user_ids); |
| 268: |
| 269: // Delete invalid IDs |
| 270: $user_ids = array_diff($user_ids, array(0, 1)); |
| 271: } |
| 272: else |
| 273: $user_ids = array(); |
| 274: |
| 275: if (empty($user_ids)) |
| 276: message($lang_admin_users['No users selected']); |
| 277: |
| 278: // Are we trying to batch move any admins? |
| 279: $result = $db->query('SELECT COUNT(*) FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).') AND group_id='.PUN_ADMIN) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
| 280: if ($db->result($result) > 0) |
| 281: message($lang_admin_users['No move admins message']); |
| 282: |
| 283: // Fetch all user groups |
| 284: $all_groups = array(); |
| 285: $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id NOT IN ('.PUN_GUEST.','.PUN_ADMIN.') ORDER BY g_title ASC') or error('Unable to fetch groups', __FILE__, __LINE__, $db->error()); |
| 286: while ($row = $db->fetch_row($result)) |
| 287: $all_groups[$row[0]] = $row[1]; |
| 288: |
| 289: if (isset($_POST['move_users_comply'])) |
| 290: { |
| 291: $new_group = isset($_POST['new_group']) && isset($all_groups[$_POST['new_group']]) ? $_POST['new_group'] : message($lang_admin_users['Invalid group message']); |
| 292: |
| 293: // Is the new group a moderator group? |
| 294: $result = $db->query('SELECT g_moderator FROM '.$db->prefix.'groups WHERE g_id='.$new_group) or error('Unable to fetch group info', __FILE__, __LINE__, $db->error()); |
| 295: $new_group_mod = $db->result($result); |
| 296: |
| 297: // Fetch user groups |
| 298: $user_groups = array(); |
| 299: $result = $db->query('SELECT id, group_id FROM '.$db->prefix.'users WHERE id IN ('.implode(',', $user_ids).')') or error('Unable to fetch user groups', __FILE__, __LINE__, $db->error()); |
| 300: while ($cur_user = $db->fetch_assoc($result)) |
| 301: { |
| 302: if (!isset($user_groups[$cur_user['group_id']])) |
| 303: $user_groups[$cur_user['group_id']] = array(); |
| 304: |
| 305: $user_groups[$cur_user['group_id']][] = $cur_user['id']; |
| 306: } |
| 307: |
| 308: // Are any users moderators? |
| 309: $group_ids = array_keys($user_groups); |
| 310: $result = $db->query('SELECT g_id, g_moderator FROM '.$db->prefix.'groups WHERE g_id IN ('.implode(',', $group_ids).')') or error('Unable to fetch group moderators', __FILE__, __LINE__, $db->error()); |
| 311: while ($cur_group = $db->fetch_assoc($result)) |
| 312: { |
| 313: if ($cur_group['g_moderator'] == '0') |
| 314: unset($user_groups[$cur_group['g_id']]); |
| 315: } |
| 316: |
| 317: if (!empty($user_groups) && $new_group != PUN_ADMIN && $new_group_mod != '1') |
| 318: { |
| 319: // Fetch forum list and clean up their moderator list |
| 320: $result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error()); |
| 321: while ($cur_forum = $db->fetch_assoc($result)) |
| 322: { |
| 323: $cur_moderators = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['moderators']) : array(); |
| 324: |
| 325: foreach ($user_groups as $group_users) |
| 326: $cur_moderators = array_diff($cur_moderators, $group_users); |
| 327: |
| 328: $cur_moderators = (!empty($cur_moderators)) ? '\''.$db->escape(serialize($cur_moderators)).'\'' : 'NULL'; |
| 329: $db->query('UPDATE '.$db->prefix.'forums SET moderators='.$cur_moderators.' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); |
| 330: } |
| 331: } |
| 332: |
| 333: // Change user group |
| 334: $db->query('UPDATE '.$db->prefix.'users SET group_id='.$new_group.' WHERE id IN ('.implode(',', $user_ids).')') or error('Unable to change user group', __FILE__, __LINE__, $db->error()); |
| 335: |
| 336: redirect('admin_users.php', $lang_admin_users['Users move redirect']); |
| 337: } |
| 338: |
| 339: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Move users']); |
| 340: define('PUN_ACTIVE_PAGE', 'admin'); |
| 341: require PUN_ROOT.'header.php'; |
| 342: |
| 343: generate_admin_menu('users'); |
| 344: |
| 345: ?> |
| 346: <div class="blockform"> |
| 347: <h2><span><?php echo $lang_admin_users['Move users'] ?></span></h2> |
| 348: <div class="box"> |
| 349: <form name="confirm_move_users" method="post" action="admin_users.php"> |
| 350: <input type="hidden" name="users" value="<?php echo implode(',', $user_ids) ?>" /> |
| 351: <div class="inform"> |
| 352: <fieldset> |
| 353: <legend><?php echo $lang_admin_users['Move users subhead'] ?></legend> |
| 354: <div class="infldset"> |
| 355: <table class="aligntop" cellspacing="0"> |
| 356: <tr> |
| 357: <th scope="row"><?php echo $lang_admin_users['New group label'] ?></th> |
| 358: <td> |
| 359: |