| /dev/null |
b/admin_bans.php |
| | 1: <?php |
| | 2: |
| | 3: /** |
| | 4: * Copyright (C) 2008-2010 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', './'); |
| | 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']); |
| | 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 |
| | 56: if (isset($group_id) && $group_id == PUN_ADMIN) |
| | 57: message(sprintf($lang_admin_bans['User is admin message'], pun_htmlspecialchars($ban_user))); |
| | 58: |
| | 59: // If we have a $user_id, we can try to find the last known IP of that user |
| | 60: if (isset($user_id)) |
| | 61: { |
| | 62: $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()); |
| | 63: $ban_ip = ($db->num_rows($result)) ? $db->result($result) : ''; |
| | 64: } |
| | 65: |
| | 66: $mode = 'add'; |
| | 67: } |
| | 68: else // We are editing a ban |
| | 69: { |
| | 70: $ban_id = intval($_GET['edit_ban']); |
| | 71: if ($ban_id < 1) |
| | 72: message($lang_common['Bad request']); |
| | 73: |
| | 74: $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()); |
| | 75: if ($db->num_rows($result)) |
| | 76: list($ban_user, $ban_ip, $ban_email, $ban_message, $ban_expire) = $db->fetch_row($result); |
| | 77: else |
| | 78: message($lang_common['Bad request']); |
| | 79: |
| | 80: $diff = ($pun_user['timezone'] + $pun_user['dst']) * 3600; |
| | 81: $ban_expire = ($ban_expire != '') ? gmdate('Y-m-d', $ban_expire + $diff) : ''; |
| | 82: |
| | 83: $mode = 'edit'; |
| | 84: } |
| | 85: |
| | 86: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Bans']); |
| | 87: $focus_element = array('bans2', 'ban_user'); |
| | 88: define('PUN_ACTIVE_PAGE', 'admin'); |
| | 89: require PUN_ROOT.'header.php'; |
| | 90: |
| | 91: generate_admin_menu('bans'); |
| | 92: |
| | 93: ?> |
| | 94: <div class="blockform"> |
| | 95: <h2><span><?php echo $lang_admin_bans['Ban advanced head'] ?></span></h2> |
| | 96: <div class="box"> |
| | 97: <form id="bans2" method="post" action="admin_bans.php"> |
| | 98: <div class="inform"> |
| | 99: <input type="hidden" name="mode" value="<?php echo $mode ?>" /> |
| | 100: <?php if ($mode == 'edit'): ?> <input type="hidden" name="ban_id" value="<?php echo $ban_id ?>" /> |
| | 101: <?php endif; ?> <fieldset> |
| | 102: <legend><?php echo $lang_admin_bans['Ban advanced subhead'] ?></legend> |
| | 103: <div class="infldset"> |
| | 104: <table class="aligntop" cellspacing="0"> |
| | 105: <tr> |
| | 106: <th scope="row"><?php echo $lang_admin_bans['Username label'] ?></th> |
| | 107: <td> |
| | 108: <input type="text" name="ban_user" size="25" maxlength="25" value="<?php if (isset($ban_user)) echo pun_htmlspecialchars($ban_user); ?>" tabindex="1" /> |
| | 109: <span><?php echo $lang_admin_bans['Username help'] ?></span> |
| | 110: </td> |
| | 111: </tr> |
| | 112: <tr> |
| | 113: <th scope="row"><?php echo $lang_admin_bans['IP label'] ?></th> |
| | 114: <td> |
| | 115: <input type="text" name="ban_ip" size="45" maxlength="255" value="<?php if (isset($ban_ip)) echo $ban_ip; ?>" tabindex="2" /> |
| | 116: <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> |
| | 117: </td> |
| | 118: </tr> |
| | 119: <tr> |
| | 120: <th scope="row"><?php echo $lang_admin_bans['E-mail label'] ?></th> |
| | 121: <td> |
| | 122: <input type="text" name="ban_email" size="40" maxlength="80" value="<?php if (isset($ban_email)) echo $ban_email; ?>" tabindex="3" /> |
| | 123: <span><?php echo $lang_admin_bans['E-mail help'] ?></span> |
| | 124: </td> |
| | 125: </tr> |
| | 126: </table> |
| | 127: <p class="topspace"><strong class="warntext"><?php echo $lang_admin_bans['Ban IP range info'] ?></strong></p> |
| | 128: </div> |
| | 129: </fieldset> |
| | 130: </div> |
| | 131: <div class="inform"> |
| | 132: <fieldset> |
| | 133: <legend><?php echo $lang_admin_bans['Message expiry subhead'] ?></legend> |
| | 134: <div class="infldset"> |
| | 135: <table class="aligntop" cellspacing="0"> |
| | 136: <tr> |
| | 137: <th scope="row"><?php echo $lang_admin_bans['Ban message label'] ?></th> |
| | 138: <td> |
| | 139: <input type="text" name="ban_message" size="50" maxlength="255" value="<?php if (isset($ban_message)) echo pun_htmlspecialchars($ban_message); ?>" tabindex="4" /> |
| | 140: <span><?php echo $lang_admin_bans['Ban message help'] ?></span> |
| | 141: </td> |
| | 142: </tr> |
| | 143: <tr> |
| | 144: <th scope="row"><?php echo $lang_admin_bans['Expire date label'] ?></th> |
| | 145: <td> |
| | 146: <input type="text" name="ban_expire" size="17" maxlength="10" value="<?php if (isset($ban_expire)) echo $ban_expire; ?>" tabindex="5" /> |
| | 147: <span><?php echo $lang_admin_bans['Expire date help'] ?></span> |
| | 148: </td> |
| | 149: </tr> |
| | 150: </table> |
| | 151: </div> |
| | 152: </fieldset> |
| | 153: </div> |
| | 154: <p class="submitend"><input type="submit" name="add_edit_ban" value="<?php echo $lang_admin_common['Save'] ?>" tabindex="6" /></p> |
| | 155: </form> |
| | 156: </div> |
| | 157: </div> |
| | 158: <div class="clearer"></div> |
| | 159: </div> |
| | 160: <?php |
| | 161: |
| | 162: require PUN_ROOT.'footer.php'; |
| | 163: } |
| | 164: |
| | 165: // Add/edit a ban (stage 2) |
| | 166: else if (isset($_POST['add_edit_ban'])) |
| | 167: { |
| | 168: confirm_referrer('admin_bans.php'); |
| | 169: |
| | 170: $ban_user = pun_trim($_POST['ban_user']); |
| | 171: $ban_ip = trim($_POST['ban_ip']); |
| | 172: $ban_email = strtolower(trim($_POST['ban_email'])); |
| | 173: $ban_message = pun_trim($_POST['ban_message']); |
| | 174: $ban_expire = trim($_POST['ban_expire']); |
| | 175: |
| | 176: if ($ban_user == '' && $ban_ip == '' && $ban_email == '') |
| | 177: message($lang_admin_bans['Must enter message']); |
| | 178: else if (strtolower($ban_user) == 'guest') |
| | 179: message($lang_admin_bans['Cannot ban guest message']); |
| | 180: |
| | 181: // Validate IP/IP range (it's overkill, I know) |
| | 182: if ($ban_ip != '') |
| | 183: { |
| | 184: $ban_ip = preg_replace('/\s{2,}/S', ' ', $ban_ip); |
| | 185: $addresses = explode(' ', $ban_ip); |
| | 186: $addresses = array_map('pun_trim', $addresses); |
| | 187: |
| | 188: for ($i = 0; $i < count($addresses); ++$i) |
| | 189: { |
| | 190: if (strpos($addresses[$i], ':') !== false) |
| | 191: { |
| | 192: $octets = explode(':', $addresses[$i]); |
| | 193: |
| | 194: for ($c = 0; $c < count($octets); ++$c) |
| | 195: { |
| | 196: $octets[$c] = ltrim($octets[$c], "0"); |
| | 197: |
| | 198: if ($c > 7 || (!empty($octets[$c]) && !ctype_xdigit($octets[$c])) || intval($octets[$c], 16) > 65535) |
| | 199: message($lang_admin_bans['Invalid IP message']); |
| | 200: } |
| | 201: |
| | 202: $cur_address = implode(':', $octets); |
| | 203: $addresses[$i] = $cur_address; |
| | 204: } |
| | 205: else |
| | 206: { |
| | 207: $octets = explode('.', $addresses[$i]); |
| | 208: |
| | 209: for ($c = 0; $c < count($octets); ++$c) |
| | 210: { |
| | 211: $octets[$c] = (strlen($octets[$c]) > 1) ? ltrim($octets[$c], "0") : $octets[$c]; |
| | 212: |
| | 213: if ($c > 3 || preg_match('/[^0-9]/', $octets[$c]) || intval($octets[$c]) > 255) |
| | 214: message($lang_admin_bans['Invalid IP message']); |
| | 215: } |
| | 216: |
| | 217: $cur_address = implode('.', $octets); |
| | 218: $addresses[$i] = $cur_address; |
| | 219: } |
| | 220: } |
| | 221: |
| | 222: $ban_ip = implode(' ', $addresses); |
| | 223: } |
| | 224: |
| | 225: require PUN_ROOT.'include/email.php'; |
| | 226: if ($ban_email != '' && !is_valid_email($ban_email)) |
| | 227: { |
| | 228: if (!preg_match('/^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/', $ban_email)) |
| | 229: message($lang_admin_bans['Invalid e-mail message']); |
| | 230: } |
| | 231: |
| | 232: if ($ban_expire != '' && $ban_expire != 'Never') |
| | 233: { |
| | 234: $ban_expire = strtotime($ban_expire.' GMT'); |
| | 235: |
| | 236: if ($ban_expire == -1 || !$ban_expire) |
| | 237: message($lang_admin_bans['Invalid date message'].' '.$lang_admin_bans['Invalid date reasons']); |
| | 238: |
| | 239: $diff = ($pun_user['timezone'] + $pun_user['dst']) * 3600; |
| | 240: $ban_expire -= $diff; |
| | 241: |
| | 242: if ($ban_expire <= time()) |
| | 243: message($lang_admin_bans['Invalid date message'].' '.$lang_admin_bans['Invalid date reasons']); |
| | 244: } |
| | 245: else |
| | 246: $ban_expire = 'NULL'; |
| | 247: |
| | 248: $ban_user = ($ban_user != '') ? '\''.$db->escape($ban_user).'\'' : 'NULL'; |
| | 249: $ban_ip = ($ban_ip != '') ? '\''.$db->escape($ban_ip).'\'' : 'NULL'; |
| | 250: $ban_email = ($ban_email != '') ? '\''.$db->escape($ban_email).'\'' : 'NULL'; |
| | 251: $ban_message = ($ban_message != '') ? '\''.$db->escape($ban_message).'\'' : 'NULL'; |
| | 252: |
| | 253: if ($_POST['mode'] == 'add') |
| | 254: $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()); |
| | 255: else |
| | 256: $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()); |
| | 257: |
| | 258: // Regenerate the bans cache |
| | 259: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| | 260: require PUN_ROOT.'include/cache.php'; |
| | 261: |
| | 262: generate_bans_cache(); |
| | 263: |
| | 264: if ($_POST['mode'] == 'edit') |
| | 265: redirect('admin_bans.php', $lang_admin_bans['Ban edited redirect']); |
| | 266: else |
| | 267: redirect('admin_bans.php', $lang_admin_bans['Ban added redirect']); |
| | 268: } |
| | 269: |
| | 270: // Remove a ban |
| | 271: else if (isset($_GET['del_ban'])) |
| | 272: { |
| | 273: confirm_referrer('admin_bans.php'); |
| | 274: |
| | 275: $ban_id = intval($_GET['del_ban']); |
| | 276: if ($ban_id < 1) |
| | 277: message($lang_common['Bad request']); |
| | 278: |
| | 279: $db->query('DELETE FROM '.$db->prefix.'bans WHERE id='.$ban_id) or error('Unable to delete ban', __FILE__, __LINE__, $db->error()); |
| | 280: |
| | 281: // Regenerate the bans cache |
| | 282: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| | 283: require PUN_ROOT.'include/cache.php'; |
| | 284: |
| | 285: generate_bans_cache(); |
| | 286: |
| | 287: redirect('admin_bans.php', $lang_admin_bans['Ban removed redirect']); |
| | 288: } |
| | 289: |
| | 290: // Find bans |
| | 291: else if (isset($_GET['find_ban'])) |
| | 292: { |
| | 293: $form = isset($_GET['form']) ? $_GET['form'] : array(); |
| | 294: |
| | 295: // trim() all elements in $form |
| | 296: $form = array_map('pun_trim', $form); |
| | 297: $conditions = $query_str = array(); |
| | 298: |
| | 299: $expire_after = isset($_GET['expire_after']) ? trim($_GET['expire_after']) : ''; |
| | 300: $expire_before = isset($_GET['expire_before']) ? trim($_GET['expire_before']) : ''; |
| | 301: $order_by = isset($_GET['order_by']) && in_array($_GET['order_by'], array('username', 'ip', 'email', 'expire')) ? $_GET['order_by'] : 'username'; |
| | 302: $direction = isset($_GET['direction']) && $_GET['direction'] == 'DESC' ? 'DESC' : 'ASC'; |
| | 303: |
| | 304: $query_str[] = 'order_by='.$order_by; |
| | 305: $query_str[] = 'direction='.$direction; |
| | 306: |
| | 307: // Try to convert date/time to timestamps |
| | 308: if ($expire_after != '') |
| | 309: { |
| | 310: $query_str[] = 'expire_after='.$expire_after; |
| | 311: |
| | 312: $expire_after = strtotime($expire_after); |
| | 313: if ($expire_after === false || $expire_after == -1) |
| | 314: message($lang_admin_bans['Invalid date message']); |
| | 315: |
| | 316: $conditions[] = 'expire>'.$expire_after; |
| | 317: } |
| | 318: if ($expire_before != '') |
| | 319: { |
| | 320: $query_str[] = 'expire_before='.$expire_before; |
| | 321: |
| | 322: $expire_before = strtotime($expire_before); |
| | 323: if ($expire_before === false || $expire_before == -1) |
| | 324: message($lang_admin_bans['Invalid date message']); |
| | 325: |
| | 326: $conditions[] = 'expire<'.$expire_before; |
| | 327: } |
| | 328: |
| | 329: $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE'; |
| | 330: foreach ($form as $key => $input) |
| | 331: { |
| | 332: if ($input != '' && in_array($key, array('username', 'ip', 'email', 'message'))) |
| | 333: { |
| | 334: $conditions[] = 'b.'.$db->escape($key).' '.$like_command.' \''.$db->escape(str_replace('*', '%', $input)).'\''; |
| | 335: $query_str[] = 'form%5B'.$key.'%5D='.urlencode($input); |
| | 336: } |
| | 337: } |
| | 338: |
| | 339: // Fetch ban count |
| | 340: $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()); |
| | 341: $num_bans = $db->result($result); |
| | 342: |
| | 343: // Determine the ban offset (based on $_GET['p']) |
| | 344: $num_pages = ceil($num_bans / 50); |
| | 345: |
| | 346: $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']); |
| | 347: $start_from = 50 * ($p - 1); |
| | 348: |
| | 349: // Generate paging links |
| | 350: $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'admin_bans.php?find_ban=&'.implode('&', $query_str)); |
| | 351: |
| | 352: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Bans'], $lang_admin_bans['Results head']); |
| | 353: define('PUN_ACTIVE_PAGE', 'admin'); |
| | 354: require PUN_ROOT.'header.php'; |
| | 355: |
| | 356: ?> |
| | 357: <div class="linkst"> |
| | 358: <div class="inbox crumbsplus"> |
| | 359: <ul class="crumbs"> |
| | 360: <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
| | 361: <li><span>» </span><a href="admin_bans.php"><?php echo $lang_admin_common['Bans'] ?></a></li> |
| | 362: <li><span>» </span><strong><?php echo $lang_admin_bans['Results head'] ?></strong></li> |
| | 363: </ul> |
| | 364: <div class="pagepost"> |
| | 365: <p class="pagelink"><?php echo $paging_links ?></p> |
| | 366: </div> |
| | 367: <div class="clearer"></div> |
| | 368: </div> |
| | 369: </div> |
| | 370: |
| | 371: |
| | 372: <div id="bans1" class="blocktable"> |
| | 373: <h2><span><?php echo $lang_admin_bans['Results head'] ?></span></h2> |
| | 374: <div class="box"> |
| | 375: <div class="inbox"> |
| | 376: <table cellspacing="0"> |
| | 377: <thead> |
| | 378: <tr> |
| | 379: <th class="tcl" scope="col"><?php echo $lang_admin_bans['Results username head'] ?></th> |
| | 380: <th class="tc2" scope="col"><?php echo $lang_admin_bans['Results e-mail head'] ?></th> |
| | 381: <th class="tc3" scope="col"><?php echo $lang_admin_bans['Results IP address head'] ?></th> |
| | 382: <th class="tc4" scope="col"><?php echo $lang_admin_bans['Results expire head'] ?></th> |
| | 383: <th class="tc5" scope="col"><?php echo $lang_admin_bans['Results message head'] ?></th> |
| | 384: <th class="tc6" scope="col"><?php echo $lang_admin_bans['Results banned by head'] ?></th> |
| | 385: <th class="tcr" scope="col"><?php echo $lang_admin_bans['Results actions head'] ?></th> |
| | 386: </tr> |
| | 387: </thead> |
| | 388: <tbody> |
| | 389: <?php |
| | 390: |
| | 391: $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()); |
| | 392: if ($db->num_rows($result)) |
| | 393: { |
| | 394: while ($ban_data = $db->fetch_assoc($result)) |
| | 395: { |
| | 396: |
| | 397: $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>'; |
| | 398: $expire = format_time($ban_data['expire'], true); |
| | 399: |
| | 400: ?> |
| | 401: <tr> |
| | 402: <td class="tcl"><?php echo ($ban_data['username'] != '') ? pun_htmlspecialchars($ban_data['username']) : ' ' ?></td> |
| | 403: <td class="tc2"><?php echo ($ban_data['email'] != '') ? $ban_data['email'] : ' ' ?></td> |
| | 404: <td class="tc3"><?php echo ($ban_data['ip'] != '') ? $ban_data['ip'] : ' ' ?></td> |
| | 405: <td class="tc4"><?php echo $expire ?></td> |
| | 406: <td class="tc5"><?php echo ($ban_data['message'] != '') ? pun_htmlspecialchars($ban_data['message']) : ' ' ?></td> |
| | 407: <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> |
| | 408: <td class="tcr"><?php echo $actions ?></td> |
| | 409: </tr> |
| | 410: <?php |
| | 411: |
| | 412: } |
| | 413: } |
| | 414: else |
| | 415: echo "\t\t\t\t".'<tr><td class="tcl" colspan="7">'.$lang_admin_bans['No match'].'</td></tr>'."\n"; |
| | 416: |
| | 417: ?> |
| | 418: </tbody> |
| | 419: </table> |
| | 420: </div> |
| | 421: </div> |
| | 422: </div> |
| | 423: |
| | 424: <div class="linksb"> |
| | 425: <div class="inbox crumbsplus"> |
| | 426: <div class="pagepost"> |
| | 427: <p class="pagelink"><?php echo $paging_links ?></p> |
| | 428: </div> |
| | 429: <ul class="crumbs"> |
| | 430: <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
| | 431: <li><span>» </span><a href="admin_bans.php"><?php echo $lang_admin_common['Bans'] ?></a></li> |
| | 432: <li><span>» </span><strong><?php echo $lang_admin_bans['Results head'] ?></strong></li> |
| | 433: </ul> |
| | 434: <div class="clearer"></div> |
| | 435: </div> |
| | 436: </div> |
| | 437: <?php |
| | 438: |
| | 439: require PUN_ROOT.'footer.php'; |
| | 440: } |
| | 441: |
| | 442: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Bans']); |
| | 443: $focus_element = array('bans', 'new_ban_user'); |
| | 444: define('PUN_ACTIVE_PAGE', 'admin'); |
| | 445: require PUN_ROOT.'header.php'; |
| | 446: |
| | 447: generate_admin_menu('bans'); |
| | 448: |
| | 449: ?> |
| | 450: <div class="blockform"> |
| | 451: <h2><span><?php echo $lang_admin_bans['New ban head'] ?></span></h2> |
| | 452: <div class="box"> |
| | 453: <form id="bans" method="post" action="admin_bans.php?action=more"> |
| | 454: <div class="inform"> |
| | 455: <fieldset> |
| | 456: <legend><?php echo $lang_admin_bans['Add ban subhead'] ?></legend> |
| | 457: <div class="infldset"> |
| | 458: <table class="aligntop" cellspacing="0"> |
| | 459: <tr> |
| | 460: <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> |
| | 461: <td> |
| | 462: <input type="text" name="new_ban_user" size="25" maxlength="25" tabindex="1" /> |
| | 463: <span><?php echo $lang_admin_bans['Username advanced help'] ?></span> |
| | 464: </td> |
| | 465: </tr> |
| | 466: </table> |
| | 467: </div> |
| | 468: </fieldset> |
| | 469: </div> |
| | 470: </form> |
| | 471: </div> |
| | 472: |
| | 473: <h2 class="block2"><span><?php echo $lang_admin_bans['Ban search head'] ?></span></h2> |
| | 474: <div class="box"> |
| | 475: <form id="find_band" method="get" action="admin_bans.php"> |
| | 476: <p class="submittop"><input type="submit" name="find_ban" value="<?php echo $lang_admin_bans['Submit search'] ?>" tabindex="3" /></p> |
| | 477: <div class="inform"> |
| | 478: <fieldset> |
| | 479: <legend><?php echo $lang_admin_bans['Ban search subhead'] ?></legend> |
| | 480: <div class="infldset"> |
| | 481: <p><?php echo $lang_admin_bans['Ban search info'] ?></p> |
| | 482: <table class="aligntop" cellspacing="0"> |
| | 483: <tr> |
| | 484: <th scope="row"><?php echo $lang_admin_bans['Username label'] ?></th> |
| | 485: <td><input type="text" name="form[username]" size="25" maxlength="25" tabindex="4" /></td> |
| | 486: </tr> |
| | 487: <tr> |
| | 488: <th scope="row"><?php echo $lang_admin_bans['IP label'] ?></th> |
| | 489: <td><input type="text" name="form[ip]" size="30" maxlength="255" tabindex="5" /></td> |
| | 490: </tr> |
| | 491: <tr> |
| | 492: <th scope="row"><?php echo $lang_admin_bans['E-mail label'] ?></th> |
| | 493: <td><input type="text" name="form[email]" size="30" maxlength="80" tabindex="6" /></td> |
| | 494: </tr> |
| | 495: <tr> |
| | 496: <th scope="row"><?php echo $lang_admin_bans['Message label'] ?></th> |
| | 497: <td><input type="text" name="form[message]" size="30" maxlength="255" tabindex="7" /></td> |
| | 498: </tr> |
| | 499: <tr> |
| | 500: <th scope="row"><?php echo $lang_admin_bans['Expire after label'] ?></th> |
| | 501: <td><input type="text" name="expire_after" size="10" maxlength="10" tabindex="8" /> |
| | 502: <span><?php echo $lang_admin_bans['Date help'] ?></span></td> |
| | 503: </tr> |
| | 504: <tr> |
| | 505: <th scope="row"><?php echo $lang_admin_bans['Expire before label'] ?></th> |
| | 506: <td><input type="text" name="expire_before" size="10" maxlength="10" tabindex="9" /> |
| | 507: <span><?php echo $lang_admin_bans['Date help'] ?></span></td> |
| | 508: </tr> |
| | 509: <tr> |
| | 510: <th scope="row"><?php echo $lang_admin_bans['Order by label'] ?></th> |
| | 511: <td> |
| | 512: <select name="order_by" tabindex="10"> |
| | 513: <option value="username" selected="selected"><?php echo $lang_admin_bans['Order by username'] ?></option> |
| | 514: <option value="ip"><?php echo $lang_admin_bans['Order by ip'] ?></option> |
| | 515: <option value="email"><?php echo $lang_admin_bans['Order by e-mail'] ?></option> |
| | 516: <option value="expire"><?php echo $lang_admin_bans['Order by expire'] ?></option> |
| | 517: </select>   <select name="direction" tabindex="11"> |
| | 518: <option value="ASC" selected="selected"><?php echo $lang_admin_bans['Ascending'] ?></option> |
| | 519: <option value="DESC"><?php echo $lang_admin_bans['Descending'] ?></option> |
| | 520: </select> |
| | 521: </td> |
| | 522: </tr> |
| | 523: </table> |
| | 524: </div> |
| | 525: </fieldset> |
| | 526: </div> |
| | 527: <p class="submitend"><input type="submit" name="find_ban" value="<?php echo $lang_admin_bans['Submit search'] ?>" tabindex="12" /></p> |
| | 528: </form> |
| | 529: </div> |
| | 530: </div> |
| | 531: <div class="clearer"></div> |
| | 532: </div> |
| | 533: <?php |
| | 534: |
| | 535: require PUN_ROOT.'footer.php'; |
| /dev/null |
b/admin_forums.php |
| | 1: <?php |
| | 2: |
| | 3: /** |
| | 4: * Copyright (C) 2008-2010 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', './'); |
| | 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']); |
| | 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 (cat_id) VALUES('.$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: // Regenerate the quick jump cache |
| | 76: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| | 77: require PUN_ROOT.'include/cache.php'; |
| | 78: |
| | 79: generate_quickjump_cache(); |
| | 80: |
| | 81: redirect('admin_forums.php', $lang_admin_forums['Forum deleted redirect']); |
| | 82: } |
| | 83: else // If the user hasn't confirmed the delete |
| | 84: { |
| | 85: $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()); |
| | 86: $forum_name = pun_htmlspecialchars($db->result($result)); |
| | 87: |
| | 88: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Forums']); |
| | 89: define('PUN_ACTIVE_PAGE', 'admin'); |
| | 90: require PUN_ROOT.'header.php'; |
| | 91: |
| | 92: generate_admin_menu('forums'); |
| | 93: |
| | 94: ?> |
| | 95: <div class="blockform"> |
| | 96: <h2><span><?php echo $lang_admin_forums['Confirm delete head'] ?></span></h2> |
| | 97: <div class="box"> |
| | 98: <form method="post" action="admin_forums.php?del_forum=<?php echo $forum_id ?>"> |
| | 99: <div class="inform"> |
| | 100: <fieldset> |
| | 101: <legend><?php echo $lang_admin_forums['Confirm delete subhead'] ?></legend> |
| | 102: <div class="infldset"> |
| | 103: <p><?php printf($lang_admin_forums['Confirm delete info'], $forum_name) ?></p> |
| | 104: <p class="warntext"><?php echo $lang_admin_forums['Confirm delete warn'] ?></p> |
| | 105: </div> |
| | 106: </fieldset> |
| | 107: </div> |
| | 108: <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> |
| | 109: </form> |
| | 110: </div> |
| | 111: </div> |
| | 112: <div class="clearer"></div> |
| | 113: </div> |
| | 114: <?php |
| | 115: |
| | 116: require PUN_ROOT.'footer.php'; |
| | 117: } |
| | 118: } |
| | 119: |
| | 120: // Update forum positions |
| | 121: else if (isset($_POST['update_positions'])) |
| | 122: { |
| | 123: confirm_referrer('admin_forums.php'); |
| | 124: |
| | 125: foreach ($_POST['position'] as $forum_id => $disp_position) |
| | 126: { |
| | 127: $disp_position = trim($disp_position); |
| | 128: if ($disp_position == '' || preg_match('/[^0-9]/', $disp_position)) |
| | 129: message($lang_admin_forums['Must be integer message']); |
| | 130: |
| | 131: $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()); |
| | 132: } |
| | 133: |
| | 134: // Regenerate the quick jump cache |
| | 135: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| | 136: require PUN_ROOT.'include/cache.php'; |
| | 137: |
| | 138: generate_quickjump_cache(); |
| | 139: |
| | 140: redirect('admin_forums.php', $lang_admin_forums['Forums updated redirect']); |
| | 141: } |
| | 142: |
| | 143: else if (isset($_GET['edit_forum'])) |
| | 144: { |
| | 145: $forum_id = intval($_GET['edit_forum']); |
| | 146: if ($forum_id < 1) |
| | 147: message($lang_common['Bad request']); |
| | 148: |
| | 149: // Update group permissions for $forum_id |
| | 150: if (isset($_POST['save'])) |
| | 151: { |
| | 152: confirm_referrer('admin_forums.php'); |
| | 153: |
| | 154: // Start with the forum details |
| | 155: $forum_name = pun_trim($_POST['forum_name']); |
| | 156: $forum_desc = pun_linebreaks(pun_trim($_POST['forum_desc'])); |
| | 157: $cat_id = intval($_POST['cat_id']); |
| | 158: $sort_by = intval($_POST['sort_by']); |
| | 159: $redirect_url = isset($_POST['redirect_url']) ? trim($_POST['redirect_url']) : null; |
| | 160: |
| | 161: if ($forum_name == '') |
| | 162: message($lang_admin_forums['Must enter name message']); |
| | 163: |
| | 164: if ($cat_id < 1) |
| | 165: message($lang_common['Bad request']); |
| | 166: |
| | 167: $forum_desc = ($forum_desc != '') ? '\''.$db->escape($forum_desc).'\'' : 'NULL'; |
| | 168: $redirect_url = ($redirect_url != '') ? '\''.$db->escape($redirect_url).'\'' : 'NULL'; |
| | 169: |
| | 170: $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()); |
| | 171: |
| | 172: // Now let's deal with the permissions |
| | 173: if (isset($_POST['read_forum_old'])) |
| | 174: { |
| | 175: $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()); |
| | 176: while ($cur_group = $db->fetch_assoc($result)) |
| | 177: { |
| | 178: $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']]); |
| | 179: $post_replies_new = isset($_POST['post_replies_new'][$cur_group['g_id']]) ? '1' : '0'; |
| | 180: $post_topics_new = isset($_POST['post_topics_new'][$cur_group['g_id']]) ? '1' : '0'; |
| | 181: |
| | 182: // Check if the new settings differ from the old |
| | 183: 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']]) |
| | 184: { |
| | 185: // If the new settings are identical to the default settings for this group, delete it's row in forum_perms |
| | 186: if ($read_forum_new == '1' && $post_replies_new == $cur_group['g_post_replies'] && $post_topics_new == $cur_group['g_post_topics']) |
| | 187: $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()); |
| | 188: else |
| | 189: { |
| | 190: // Run an UPDATE and see if it affected a row, if not, INSERT |
| | 191: $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()); |
| | 192: if (!$db->affected_rows()) |
| | 193: $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()); |
| | 194: } |
| | 195: } |
| | 196: } |
| | 197: } |
| | 198: |
| | 199: // Regenerate the quick jump cache |
| | 200: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| | 201: require PUN_ROOT.'include/cache.php'; |
| | 202: |
| | 203: generate_quickjump_cache(); |
| | 204: |
| | 205: redirect('admin_forums.php', $lang_admin_forums['Forum updated redirect']); |
| | 206: } |
| | 207: else if (isset($_POST['revert_perms'])) |
| | 208: { |
| | 209: confirm_referrer('admin_forums.php'); |
| | 210: |
| | 211: $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()); |
| | 212: |
| | 213: // Regenerate the quick jump cache |
| | 214: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| | 215: require PUN_ROOT.'include/cache.php'; |
| | 216: |
| | 217: generate_quickjump_cache(); |
| | 218: |
| | 219: redirect('admin_forums.php?edit_forum='.$forum_id, $lang_admin_forums['Perms reverted redirect']); |
| | 220: } |
| | 221: |
| | 222: // Fetch forum info |
| | 223: $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()); |
| | 224: if (!$db->num_rows($result)) |
| | 225: message($lang_common['Bad request']); |
| | 226: |
| | 227: $cur_forum = $db->fetch_assoc($result); |
| | 228: |
| | 229: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Forums']); |
| | 230: define('PUN_ACTIVE_PAGE', 'admin'); |
| | 231: require PUN_ROOT.'header.php'; |
| | 232: |
| | 233: generate_admin_menu('forums'); |
| | 234: |
| | 235: ?> |
| | 236: <div class="blockform"> |
| | 237: <h2><span><?php echo $lang_admin_forums['Edit forum head'] ?></span></h2> |
| | 238: <div class="box"> |
| | 239: <form id="edit_forum" method="post" action="admin_forums.php?edit_forum=<?php echo $forum_id ?>"> |
| | 240: <p class="submittop"><input type="submit" name="save" value="<?php echo $lang_admin_common['Save changes'] ?>" tabindex="6" /></p> |
| | 241: <div class="inform"> |
| | 242: <fieldset> |
| | 243: <legend><?php echo $lang_admin_forums['Edit details subhead'] ?></legend> |
| | 244: <div class="infldset"> |
| | 245: <table class="aligntop" cellspacing="0"> |
| | 246: <tr> |
| | 247: <th scope="row"><?php echo $lang_admin_forums['Forum name label'] ?></th> |
| | 248: <td><input type="text" name="forum_name" size="35" maxlength="80" value="<?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?>" tabindex="1" /></td> |
| | 249: </tr> |
| | 250: <tr> |
| | 251: <th scope="row"><?php echo $lang_admin_forums['Forum description label'] ?></th> |
| | 252: <td><textarea name="forum_desc" rows="3" cols="50" tabindex="2"><?php echo pun_htmlspecialchars($cur_forum['forum_desc']) ?></textarea></td> |
| | 253: </tr> |
| | 254: <tr> |
| | 255: <th scope="row"><?php echo $lang_admin_forums['Category label'] ?></th> |
| | 256: <td> |
| | 257: <select name="cat_id" tabindex="3"> |
| | 258: <?php |
| | 259: |
| | 260: $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()); |
| | 261: while ($cur_cat = $db->fetch_assoc($result)) |
| | 262: { |
| | 263: $selected = ($cur_cat['id'] == $cur_forum['cat_id']) ? ' selected="selected"' : ''; |
| | 264: 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"; |
| | 265: } |
| | 266: |
| | 267: ?> |
| | 268: </select> |
| | 269: </td> |
| | 270: </tr> |
| | 271: <tr> |
| | 272: <th scope="row"><?php echo $lang_admin_forums['Sort by label'] ?></th> |
| | 273: <td> |
| | 274: <select name="sort_by" tabindex="4"> |
| | 275: <option value="0"<?php if ($cur_forum['sort_by'] == '0') echo ' selected="selected"' ?>><?php echo $lang_admin_forums['Last post'] ?></option> |
| | 276: <option value="1"<?php if ($cur_forum['sort_by'] == '1') echo ' selected="selected"' ?>><?php echo $lang_admin_forums['Topic start'] ?></option> |
| | 277: </select> |
| | 278: </td> |
| | 279: </tr> |
| | 280: <tr> |
| | 281: <th scope="row"><?php echo $lang_admin_forums['Redirect label'] ?></th> |
| | 282: <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> |
| | 283: </tr> |
| | 284: </table> |
| | 285: </div> |
| | 286: </fieldset> |
| | 287: </div> |
| | 288: <div class="inform"> |
| | 289: <fieldset> |
| | 290: <legend><?php echo $lang_admin_forums['Group permissions subhead'] ?></legend> |
| | 291: <div class="infldset"> |
| | 292: <p><?php printf($lang_admin_forums['Group permissions info'], '<a href="admin_groups.php">'.$lang_admin_common['User groups'].'</a>') ?></p> |
| | 293: <table id="forumperms" cellspacing="0"> |
| | 294: <thead> |
| | 295: <tr> |
| | 296: <th class="atcl"> </th> |
| | 297: <th><?php echo $lang_admin_forums['Read forum label'] ?></th> |
| | 298: <th><?php echo $lang_admin_forums['Post replies label'] ?></th> |
| | 299: <th><?php echo $lang_admin_forums['Post topics label'] ?></th> |
| | 300: </tr> |
| | 301: </thead> |
| | 302: <tbody> |
| | 303: <?php |
| | 304: |
| | 305: $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()); |
| | 306: |
| | 307: while ($cur_perm = $db->fetch_assoc($result)) |
| | 308: { |
| | 309: $read_forum = ($cur_perm['read_forum'] != '0') ? true : false; |
| | 310: $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; |
| | 311: $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; |
| | 312: |
| | 313: // Determine if the current settings differ from the default or not |
| | 314: $read_forum_def = ($cur_perm['read_forum'] == '0') ? false : true; |
| | 315: $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; |
| | 316: $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; |
| | 317: |
| | 318: ?> |
| | 319: <tr> |
| | 320: <th class="atcl"><?php echo pun_htmlspecialchars($cur_perm['g_title']) ?></th> |
| | 321: <td<?php if (!$read_forum_def) echo ' class="nodefault"'; ?>> |
| | 322: <input type="hidden" name="read_forum_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($read_forum) ? '1' : '0'; ?>" /> |
| | 323: <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"' : ''; ?> /> |
| | 324: </td> |
| | 325: <td<?php if (!$post_replies_def && $cur_forum['redirect_url'] == '') echo ' class="nodefault"'; ?>> |
| | 326: <input type="hidden" name="post_replies_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($post_replies) ? '1' : '0'; ?>" /> |
| | 327: <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"' : ''; ?> /> |
| | 328: </td> |
| | 329: <td<?php if (!$post_topics_def && $cur_forum['redirect_url'] == '') echo ' class="nodefault"'; ?>> |
| | 330: <input type="hidden" name="post_topics_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($post_topics) ? '1' : '0'; ?>" /> |
| | 331: <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"' : ''; ?> /> |
| | 332: </td> |
| | 333: </tr> |
| | 334: <?php |
| | 335: |
| | 336: } |
| | 337: |
| | 338: ?> |
| | 339: </tbody> |
| | 340: </table> |
| | 341: <div class="fsetsubmit"><input type="submit" name="revert_perms" value="<?php echo $lang_admin_forums['Revert to default'] ?>" /></div> |
| | 342: </div> |
| | 343: </fieldset> |
| | 344: </div> |
| | 345: <p class="submitend"><input type="submit" name="save" value="<?php echo $lang_admin_common['Save changes'] ?>" /></p> |
| | 346: </form> |
| | 347: </div> |
| | 348: </div> |
| | 349: <div class="clearer"></div> |
| | 350: </div> |
| | 351: |
| | 352: <?php |
| | 353: |
| | 354: require PUN_ROOT.'footer.php'; |
| | 355: } |
| | 356: |
| | 357: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Forums']); |
| | 358: define('PUN_ACTIVE_PAGE', 'admin'); |
| | 359: require PUN_ROOT.'header.php'; |
| | 360: |
| | 361: generate_admin_menu('forums'); |
| | 362: |
| | 363: ?> |
| | 364: <div class="blockform"> |
| | 365: <h2><span><?php echo $lang_admin_forums['Add forum head'] ?></span></h2> |
| | 366: <div class="box"> |
| | 367: <form method="post" action="admin_forums.php?action=adddel"> |
| | 368: <div class="inform"> |
| | 369: <fieldset> |
| | 370: <legend><?php echo $lang_admin_forums['Create new subhead'] ?></legend> |
| | 371: <div class="infldset"> |
| | 372: <table class="aligntop" cellspacing="0"> |
| | 373: <tr> |
| | 374: <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> |
| | 375: <td> |
| | 376: <select name="add_to_cat" tabindex="1"> |
| | 377: <?php |
| | 378: |
| | 379: $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()); |
| | 380: if ($db->num_rows($result) > 0) |
| | 381: { |
| | 382: while ($cur_cat = $db->fetch_assoc($result)) |
| | 383: 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"; |
| | 384: } |
| | 385: else |
| | 386: 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"; |
| | 387: |
| | 388: ?> |
| | 389: </select> |
| | 390: <span><?php echo $lang_admin_forums['Add forum help'] ?></span> |
| | 391: </td> |
| | 392: </tr> |
| | 393: </table> |
| | 394: </div> |
| | 395: </fieldset> |
| | 396: </div> |
| | 397: </form> |
| | 398: </div> |
| | 399: <?php |
| | 400: |
| | 401: // Display all the categories and forums |
| | 402: $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()); |
| | 403: |
| | 404: if ($db->num_rows($result) > 0) |
| | 405: { |
| | 406: |
| | 407: ?> |
| | 408: <h2 class="block2"><span><?php echo $lang_admin_forums['Edit forums head'] ?></span></h2> |
| | 409: <div class="box"> |
| | 410: <form id="edforum" method="post" action="admin_forums.php?action=edit"> |
| | 411: <p class="submittop"><input type="submit" name="update_positions" value="<?php echo $lang_admin_forums['Update positions'] ?>" tabindex="3" /></p> |
| | 412: <?php |
| | 413: |
| | 414: $tabindex_count = 4; |
| | 415: |
| | 416: $cur_category = 0; |
| | 417: while ($cur_forum = $db->fetch_assoc($result)) |
| | 418: { |
| | 419: if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? |
| | 420: { |
| | 421: if ($cur_category != 0) |
| | 422: 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"; |
| | 423: |
| | 424: ?> |
| | 425: <div class="inform"> |
| | 426: <fieldset> |
| | 427: <legend><?php echo $lang_admin_forums['Category subhead'] ?> <?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></legend> |
| | 428: <div class="infldset"> |
| | 429: <table cellspacing="0"> |
| | 430: <thead> |
| | 431: <tr> |
| | 432: <th class="tcl"><?php echo $lang_admin_common['Action'] ?></th> |
| | 433: <th class="tc2"><?php echo $lang_admin_forums['Position label'] ?></th> |
| | 434: <th class="tcr"><?php echo $lang_admin_forums['Forum label'] ?></th> |
| | 435: </tr> |
| | 436: </thead> |
| | 437: <tbody> |
| | 438: <?php |
| | 439: |
| | 440: $cur_category = $cur_forum['cid']; |
| | 441: } |
| | 442: |
| | 443: ?> |
| | 444: <tr> |
| | 445: <td class="tcl"><a href="admin_forums.php?edit_forum=<?php echo $cur_forum['fid'] ?>"><?php echo $lang_admin_forums['Edit link'] ?></a> | <a href="admin_forums.php?del_forum=<?php echo $cur_forum['fid'] ?>"><?php echo $lang_admin_forums['Delete link'] ?></a></td> |
| | 446: <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 $tabindex_count ?>" /></td> |
| | 447: <td class="tcr"><strong><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></strong></td> |
| | 448: </tr> |
| | 449: <?php |
| | 450: |
| | 451: $tabindex_count += 2; |
| | 452: } |
| | 453: |
| | 454: ?> |
| | 455: </tbody> |
| | 456: </table> |
| | 457: </div> |
| | 458: </fieldset> |
| | 459: </div> |
| | 460: <p class="submitend"><input type="submit" name="update_positions" value="<?php echo $lang_admin_forums['Update positions'] ?>" tabindex="<?php echo $tabindex_count ?>" /></p> |
| | 461: </form> |
| | 462: </div> |
| | 463: <?php |
| | 464: |
| | 465: } |
| | 466: |
| | 467: ?> |
| | 468: </div> |
| | 469: <div class="clearer"></div> |
| | 470: </div> |
| | 471: <?php |
| | 472: |
| | 473: require PUN_ROOT.'footer.php'; |
| /dev/null |
b/admin_groups.php |
| | 1: <?php |
| | 2: |
| | 3: /** |
| | 4: * Copyright (C) 2008-2010 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', './'); |
| | 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']); |
| | 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="5" /> <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="6" /> <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="5" /> <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="6" /> <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="5" /> <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="6" /> <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="3" /> <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="4" /> <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="3" /> <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="4" /> <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="5" /> <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="6" /> <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="7" /> <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="8" /> <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="11" /> <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="12" /> <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="13" /> <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="14" /> <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="15" /> <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="16" /> <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="17" /> <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="18" /> <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="19" /> <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="20" /> <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="21" /> <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="22" /> <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="21" /> <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="22" /> <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="24" /> |
| | 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="25" /> |
| | 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="26" /> |
| | 217: <span><?php echo $lang_admin_groups['E-mail flood help'] ?></span> |
| | 218: </td> |
| | 219: </tr> |
| | 220: <?php endif; endif; ?> </table> |
| | 221: <?php if ($group['g_moderator'] == '1' ): ?> <p class="warntext"><?php echo $lang_admin_groups['Moderator info'] ?></p> |
| | 222: <?php endif; ?> </div> |
| | 223: </fieldset> |
| | 224: </div> |
| | 225: <p class="submitend"><input type="submit" name="add_edit_group" value="<?php echo $lang_admin_common['Save'] ?>" tabindex="26" /></p> |
| | 226: </form> |
| | 227: </div> |
| | 228: </div> |
| | 229: <div class="clearer"></div> |
| | 230: </div> |
| | 231: <?php |
| | 232: |
| | 233: require PUN_ROOT.'footer.php'; |
| | 234: } |
| | 235: |
| | 236: |
| | 237: // Add/edit a group (stage 2) |
| | 238: else if (isset($_POST['add_edit_group'])) |
| | 239: { |
| | 240: confirm_referrer('admin_groups.php'); |
| | 241: |
| | 242: // Is this the admin group? (special rules apply) |
| | 243: $is_admin_group = (isset($_POST['group_id']) && $_POST['group_id'] == PUN_ADMIN) ? true : false; |
| | 244: |
| | 245: $title = pun_trim($_POST['req_title']); |
| | 246: $user_title = pun_trim($_POST['user_title']); |
| | 247: $moderator = isset($_POST['moderator']) && $_POST['moderator'] == '1' ? '1' : '0'; |
| | 248: $mod_edit_users = $moderator == '1' && isset($_POST['mod_edit_users']) && $_POST['mod_edit_users'] == '1' ? '1' : '0'; |
| | 249: $mod_rename_users = $moderator == '1' && isset($_POST['mod_rename_users']) && $_POST['mod_rename_users'] == '1' ? '1' : '0'; |
| | 250: $mod_change_passwords = $moderator == '1' && isset($_POST['mod_change_passwords']) && $_POST['mod_change_passwords'] == '1' ? '1' : '0'; |
| | 251: $mod_ban_users = $moderator == '1' && isset($_POST['mod_ban_users']) && $_POST['mod_ban_users'] == '1' ? '1' : '0'; |
| | 252: $read_board = isset($_POST['read_board']) ? intval($_POST['read_board']) : '1'; |
| | 253: $view_users = (isset($_POST['view_users']) && $_POST['view_users'] == '1') || $is_admin_group ? '1' : '0'; |
| | 254: $post_replies = isset($_POST['post_replies']) ? intval($_POST['post_replies']) : '1'; |
| | 255: $post_topics = isset($_POST['post_topics']) ? intval($_POST['post_topics']) : '1'; |
| | 256: $edit_posts = isset($_POST['edit_posts']) ? intval($_POST['edit_posts']) : ($is_admin_group) ? '1' : '0'; |
| | 257: $delete_posts = isset($_POST['delete_posts']) ? intval($_POST['delete_posts']) : ($is_admin_group) ? '1' : '0'; |
| | 258: $delete_topics = isset($_POST['delete_topics']) ? intval($_POST['delete_topics']) : ($is_admin_group) ? '1' : '0'; |
| | 259: $set_title = isset($_POST['set_title']) ? intval($_POST['set_title']) : ($is_admin_group) ? '1' : '0'; |
| | 260: $search = isset($_POST['search']) ? intval($_POST['search']) : '1'; |
| | 261: $search_users = isset($_POST['search_users']) ? intval($_POST['search_users']) : '1'; |
| | 262: $send_email = (isset($_POST['send_email']) && $_POST['send_email'] == '1') || $is_admin_group ? '1' : '0'; |
| | 263: $post_flood = isset($_POST['post_flood']) ? intval($_POST['post_flood']) : '0'; |
| | 264: $search_flood = isset($_POST['search_flood']) ? intval($_POST['search_flood']) : '0'; |
| | 265: $email_flood = isset($_POST['email_flood']) ? intval($_POST['email_flood']) : '0'; |
| | 266: |
| | 267: if ($title == '') |
| | 268: message($lang_admin_groups['Must enter title message']); |
| | 269: |
| | 270: $user_title = ($user_title != '') ? '\''.$db->escape($user_title).'\'' : 'NULL'; |
| | 271: |
| | 272: if ($_POST['mode'] == 'add') |
| | 273: { |
| | 274: $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()); |
| | 275: if ($db->num_rows($result)) |
| | 276: message(sprintf($lang_admin_groups['Title already exists message'], pun_htmlspecialchars($title))); |
| | 277: |
| | 278: $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) 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.')') or error('Unable to add group', __FILE__, __LINE__, $db->error()); |
| | 279: $new_group_id = $db->insert_id(); |
| | 280: |
| | 281: // Now lets copy the forum specific permissions from the group which this group is based on |
| | 282: $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()); |
| | 283: while ($cur_forum_perm = $db->fetch_assoc($result)) |
| | 284: $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()); |
| | 285: } |
| | 286: else |
| | 287: { |
| | 288: $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()); |
| | 289: if ($db->num_rows($result)) |
| | 290: message(sprintf($lang_admin_groups['Title already exists message'], pun_htmlspecialchars($title))); |
| | 291: |
| | 292: $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.' WHERE g_id='.intval($_POST['group_id'])) or error('Unable to update group', __FILE__, __LINE__, $db->error()); |
| | 293: } |
| | 294: |
| | 295: // Regenerate the quick jump cache |
| | 296: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| | 297: require PUN_ROOT.'include/cache.php'; |
| | 298: |
| | 299: generate_quickjump_cache(); |
| | 300: |
| | 301: if ($_POST['mode'] == 'edit') |
| | 302: redirect('admin_groups.php', $lang_admin_groups['Group edited redirect']); |
| | 303: else |
| | 304: redirect('admin_groups.php', $lang_admin_groups['Group added redirect']); |
| | 305: } |
| | 306: |
| | 307: |
| | 308: // Set default group |
| | 309: else if (isset($_POST['set_default_group'])) |
| | 310: { |
| | 311: confirm_referrer('admin_groups.php'); |
| | 312: |
| | 313: $group_id = intval($_POST['default_group']); |
| | 314: |
| | 315: // Make sure it's not the admin or guest groups |
| | 316: if ($group_id == PUN_ADMIN || $group_id == PUN_GUEST) |
| | 317: message($lang_common['Bad request']); |
| | 318: |
| | 319: // Make sure it's not a moderator group |
| | 320: $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()); |
| | 321: if (!$db->num_rows($result)) |
| | 322: message($lang_common['Bad request']); |
| | 323: |
| | 324: $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()); |
| | 325: |
| | 326: // Regenerate the config cache |
| | 327: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| | 328: require PUN_ROOT.'include/cache.php'; |
| | 329: |
| | 330: generate_config_cache(); |
| | 331: |
| | 332: redirect('admin_groups.php', $lang_admin_groups['Default group redirect']); |
| | 333: } |
| | 334: |
| | 335: |
| | 336: // Remove a group |
| | 337: else if (isset($_GET['del_group'])) |
| | 338: { |
| | 339: confirm_referrer('admin_groups.php'); |
| | 340: |
| | 341: $group_id = isset($_POST['group_to_delete']) ? intval($_POST['group_to_delete']) : intval($_GET['del_group']); |
| | 342: if ($group_id < 5) |
| | 343: message($lang_common['Bad request']); |
| | 344: |
| | 345: // Make sure we don't remove the default group |
| | 346: if ($group_id == $pun_config['o_default_user_group']) |
| | 347: message($lang_admin_groups['Cannot remove default message']); |
| | 348: |
| | 349: // Check if this group has any members |
| | 350: $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()); |
| | 351: |
| | 352: // If the group doesn't have any members or if we've already selected a group to move the members to |
| | 353: if (!$db->num_rows($result) || isset($_POST['del_group'])) |
| | 354: { |
| | 355: if (isset($_POST['del_group_comply']) || isset($_POST['del_group'])) |
| | 356: { |
| | 357: if (isset($_POST['del_group'])) |
| | 358: { |
| | 359: $move_to_group = intval($_POST['move_to_group']); |
| | 360: $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()); |
| | 361: } |
| | 362: |
| | 363: // Delete the group and any forum specific permissions |
| | 364: $db->query('DELETE FROM '.$db->prefix.'groups WHERE g_id='.$group_id) or error('Unable to delete group', __FILE__, __LINE__, $db->error()); |
| | 365: $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()); |
| | 366: |
| | 367: // Regenerate the quick jump cache |
| | 368: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| | 369: require PUN_ROOT.'include/cache.php'; |
| | 370: |
| | 371: generate_quickjump_cache(); |
| | 372: |
| | 373: redirect('admin_groups.php', $lang_admin_groups['Group removed redirect']); |
| | 374: } |
| | 375: else |
| | 376: { |
| | 377: $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()); |
| | 378: $group_title = $db->result($result); |
| | 379: |
| | 380: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']); |
| | 381: define('PUN_ACTIVE_PAGE', 'admin'); |
| | 382: require PUN_ROOT.'header.php'; |
| | 383: |
| | 384: generate_admin_menu('groups'); |
| | 385: |
| | 386: ?> |
| | 387: <div class="blockform"> |
| | 388: <h2><span><?php echo $lang_admin_groups['Group delete head'] ?></span></h2> |
| | 389: <div class="box"> |
| | 390: <form method="post" action="admin_groups.php?del_group=<?php echo $group_id ?>"> |
| | 391: <div class="inform"> |
| | 392: <input type="hidden" name="group_to_delete" value="<?php echo $group_id ?>" /> |
| | 393: <fieldset> |
| | 394: <legend><?php echo $lang_admin_groups['Confirm delete subhead'] ?></legend> |
| | 395: <div class="infldset"> |
| | 396: <p><?php printf($lang_admin_groups['Confirm delete info'], pun_htmlspecialchars($group_title)) ?></p> |
| | 397: <p class="warntext"><?php echo $lang_admin_groups['Confirm delete warn'] ?></p> |
| | 398: </div> |
| | 399: </fieldset> |
| | 400: </div> |
| | 401: <p class="buttons"><input type="submit" name="del_group_comply" value="<?php echo $lang_admin_common['Delete'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_admin_common['Go back'] ?></a></p> |
| | 402: </form> |
| | 403: </div> |
| | 404: </div> |
| | 405: <div class="clearer"></div> |
| | 406: </div> |
| | 407: <?php |
| | 408: |
| | 409: require PUN_ROOT.'footer.php'; |
| | 410: } |
| | 411: } |
| | 412: |
| | 413: list($group_title, $group_members) = $db->fetch_row($result); |
| | 414: |
| | 415: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']); |
| | 416: define('PUN_ACTIVE_PAGE', 'admin'); |
| | 417: require PUN_ROOT.'header.php'; |
| | 418: |
| | 419: generate_admin_menu('groups'); |
| | 420: |
| | 421: ?> |
| | 422: <div class="blockform"> |
| | 423: <h2><span><?php echo $lang_admin_groups['Delete group head'] ?></span></h2> |
| | 424: <div class="box"> |
| | 425: <form id="groups" method="post" action="admin_groups.php?del_group=<?php echo $group_id ?>"> |
| | 426: <div class="inform"> |
| | 427: <fieldset> |
| | 428: <legend><?php echo $lang_admin_groups['Move users subhead'] ?></legend> |
| | 429: <div class="infldset"> |
| | 430: <p><?php printf($lang_admin_groups['Move users info'], pun_htmlspecialchars($group_title), forum_number_format($group_members)) ?></p> |
| | 431: <label><?php echo $lang_admin_groups['Move users label'] ?> |
| | 432: <select name="move_to_group"> |
| | 433: <?php |
| | 434: |
| | 435: $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()); |
| | 436: |
| | 437: while ($cur_group = $db->fetch_assoc($result)) |
| | 438: { |
| | 439: if ($cur_group['g_id'] == PUN_MEMBER) // Pre-select the pre-defined Members group |
| | 440: 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"; |
| | 441: else |
| | 442: 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"; |
| | 443: } |
| | 444: |
| | 445: ?> |
| | 446: </select> |
| | 447: <br /></label> |
| | 448: </div> |
| | 449: </fieldset> |
| | 450: </div> |
| | 451: <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> |
| | 452: </form> |
| | 453: </div> |
| | 454: </div> |
| | 455: <div class="clearer"></div> |
| | 456: </div> |
| | 457: <?php |
| | 458: |
| | 459: require PUN_ROOT.'footer.php'; |
| | 460: } |
| | 461: |
| | 462: |
| | 463: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['User groups']); |
| | 464: define('PUN_ACTIVE_PAGE', 'admin'); |
| | 465: require PUN_ROOT.'header.php'; |
| | 466: |
| | 467: generate_admin_menu('groups'); |
| | 468: |
| | 469: ?> |
| | 470: <div class="blockform"> |
| | 471: <h2><span><?php echo $lang_admin_groups['Add groups head'] ?></span></h2> |
| | 472: <div class="box"> |
| | 473: <form id="groups" method="post" action="admin_groups.php?action=foo"> |
| | 474: <div class="inform"> |
| | 475: <fieldset> |
| | 476: <legend><?php echo $lang_admin_groups['Add group subhead'] ?></legend> |
| | 477: <div class="infldset"> |
| | 478: <table class="aligntop" cellspacing="0"> |
| | 479: <tr> |
| | 480: <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> |
| | 481: <td> |
| | 482: <select id="base_group" name="base_group" tabindex="1"> |
| | 483: <?php |
| | 484: |
| | 485: $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()); |
| | 486: |
| | 487: while ($cur_group = $db->fetch_assoc($result)) |
| | 488: { |
| | 489: if ($cur_group['g_id'] == $pun_config['o_default_user_group']) |
| | 490: 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"; |
| | 491: else |
| | 492: 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"; |
| | 493: } |
| | 494: |
| | 495: ?> |
| | 496: </select> |
| | 497: <span><?php echo $lang_admin_groups['New group help'] ?></span> |
| | 498: </td> |
| | 499: </tr> |
| | 500: </table> |
| | 501: </div> |
| | 502: </fieldset> |
| | 503: </div> |
| | 504: <div class="inform"> |
| | 505: <fieldset> |
| | 506: <legend><?php echo $lang_admin_groups['Default group subhead'] ?></legend> |
| | 507: <div class="infldset"> |
| | 508: <table class="aligntop" cellspacing="0"> |
| | 509: <tr> |
| | 510: <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> |
| | 511: <td> |
| | 512: <select id="default_group" name="default_group" tabindex="3"> |
| | 513: <?php |
| | 514: |
| | 515: $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()); |
| | 516: |
| | 517: while ($cur_group = $db->fetch_assoc($result)) |
| | 518: { |
| | 519: if ($cur_group['g_id'] == $pun_config['o_default_user_group']) |
| | 520: 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"; |
| | 521: else |
| | 522: 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"; |
| | 523: } |
| | 524: |
| | 525: ?> |
| | 526: </select> |
| | 527: <span><?php echo $lang_admin_groups['Default group help'] ?></span> |
| | 528: </td> |
| | 529: </tr> |
| | 530: </table> |
| | 531: </div> |
| | 532: </fieldset> |
| | 533: </div> |
| | 534: </form> |
| | 535: </div> |
| | 536: |
| | 537: <h2 class="block2"><span><?php echo $lang_admin_groups['Existing groups head'] ?></span></h2> |
| | 538: <div class="box"> |
| | 539: <div class="fakeform"> |
| | 540: <div class="inform"> |
| | 541: <fieldset> |
| | 542: <legend><?php echo $lang_admin_groups['Edit groups subhead'] ?></legend> |
| | 543: <div class="infldset"> |
| | 544: <p><?php echo $lang_admin_groups['Edit groups info'] ?></p> |
| | 545: <table cellspacing="0"> |
| | 546: <?php |
| | 547: |
| | 548: $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()); |
| | 549: |
| | 550: while ($cur_group = $db->fetch_assoc($result)) |
| | 551: echo "\t\t\t\t\t\t\t\t".'<tr><th scope="row"><a href="admin_groups.php?edit_group='.$cur_group['g_id'].'">'.$lang_admin_groups['Edit link'].'</a>'.(($cur_group['g_id'] > PUN_MEMBER) ? ' | <a href="admin_groups.php?del_group='.$cur_group['g_id'].'">'.$lang_admin_groups['Delete link'].'</a>' : '').'</th><td>'.pun_htmlspecialchars($cur_group['g_title']).'</td></tr>'."\n"; |
| | 552: |
| | 553: ?> |
| | 554: </table> |
| | 555: </div> |
| | 556: </fieldset> |
| | 557: </div> |
| | 558: </div> |
| | 559: </div> |
| | 560: </div> |
| | 561: <div class="clearer"></div> |
| | 562: </div> |
| | 563: <?php |
| | 564: |
| | 565: require PUN_ROOT.'footer.php'; |
| /dev/null |
b/admin_options.php |
| | 1: <?php |
| | 2: |
| | 3: /** |
| | 4: * Copyright (C) 2008-2010 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', './'); |
| | 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']); |
| | 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: // Custom referrer check (so we can output a custom error message) |
| | 26: if (!preg_match('#^'.preg_quote(str_replace('www.', '', $pun_config['o_base_url']).'/admin_options.php', '#').'#i', str_replace('www.', '', (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')))) |
| | 27: message($lang_admin_options['Bad HTTP Referer message']); |
| | 28: |
| | 29: $form = array( |
| | 30: 'board_title' => pun_trim($_POST['form']['board_title']), |
| | 31: 'board_desc' => pun_trim($_POST['form']['board_desc']), |
| | 32: 'base_url' => pun_trim($_POST['form']['base_url']), |
| | 33: 'default_timezone' => floatval($_POST['form']['default_timezone']), |
| | 34: 'default_dst' => $_POST['form']['default_dst'] != '1' ? '0' : '1', |
| | 35: 'default_lang' => preg_replace('#[\.\\\/]#', '', pun_trim($_POST['form']['default_lang'])), |
| | 36: 'default_style' => preg_replace('#[\.\\\/]#', '', pun_trim($_POST['form']['default_style'])), |
| | 37: 'time_format' => pun_trim($_POST['form']['time_format']), |
| | 38: 'date_format' => pun_trim($_POST['form']['date_format']), |
| | 39: 'timeout_visit' => intval($_POST['form']['timeout_visit']), |
| | 40: 'timeout_online' => intval($_POST['form']['timeout_online']), |
| | 41: 'redirect_delay' => intval($_POST['form']['redirect_delay']), |
| | 42: 'show_version' => $_POST['form']['show_version'] != '1' ? '0' : '1', |
| | 43: 'show_user_info' => $_POST['form']['show_user_info'] != '1' ? '0' : '1', |
| | 44: 'show_post_count' => $_POST['form']['show_post_count'] != '1' ? '0' : '1', |
| | 45: 'smilies' => $_POST['form']['smilies'] != '1' ? '0' : '1', |
| | 46: 'smilies_sig' => $_POST['form']['smilies_sig'] != '1' ? '0' : '1', |
| | 47: 'make_links' => $_POST['form']['make_links'] != '1' ? '0' : '1', |
| | 48: 'topic_review' => intval($_POST['form']['topic_review']), |
| | 49: 'disp_topics_default' => intval($_POST['form']['disp_topics_default']), |
| | 50: 'disp_posts_default' => intval($_POST['form']['disp_posts_default']), |
| | 51: 'indent_num_spaces' => intval($_POST['form']['indent_num_spaces']), |
| | 52: 'quote_depth' => intval($_POST['form']['quote_depth']), |
| | 53: 'quickpost' => $_POST['form']['quickpost'] != '1' ? '0' : '1', |
| | 54: 'users_online' => $_POST['form']['users_online'] != '1' ? '0' : '1', |
| | 55: 'censoring' => $_POST['form']['censoring'] != '1' ? '0' : '1', |
| | 56: 'signatures' => $_POST['form']['signatures'] != '1' ? '0' : '1', |
| | 57: 'ranks' => $_POST['form']['ranks'] != '1' ? '0' : '1', |
| | 58: 'show_dot' => $_POST['form']['show_dot'] != '1' ? '0' : '1', |
| | 59: 'topic_views' => $_POST['form']['topic_views'] != '1' ? '0' : '1', |
| | 60: 'quickjump' => $_POST['form']['quickjump'] != '1' ? '0' : '1', |
| | 61: 'gzip' => $_POST['form']['gzip'] != '1' ? '0' : '1', |
| | 62: 'search_all_forums' => $_POST['form']['search_all_forums'] != '1' ? '0' : '1', |
| | 63: 'additional_navlinks' => pun_trim($_POST['form']['additional_navlinks']), |
| | 64: 'feed_type' => intval($_POST['form']['feed_type']), |
| | 65: 'report_method' => intval($_POST['form']['report_method']), |
| | 66: 'mailing_list' => pun_trim($_POST['form']['mailing_list']), |
| | 67: 'avatars' => $_POST['form']['avatars'] != '1' ? '0' : '1', |
| | 68: 'avatars_dir' => pun_trim($_POST['form']['avatars_dir']), |
| | 69: 'avatars_width' => intval($_POST['form']['avatars_width']), |
| | 70: 'avatars_height' => intval($_POST['form']['avatars_height']), |
| | 71: 'avatars_size' => intval($_POST['form']['avatars_size']), |
| | 72: 'admin_email' => strtolower(pun_trim($_POST['form']['admin_email'])), |
| | 73: 'webmaster_email' => strtolower(pun_trim($_POST['form']['webmaster_email'])), |
| | 74: 'subscriptions' => $_POST['form']['subscriptions'] != '1' ? '0' : '1', |
| | 75: 'smtp_host' => pun_trim($_POST['form']['smtp_host']), |
| | 76: 'smtp_user' => pun_trim($_POST['form']['smtp_user']), |
| | 77: 'smtp_pass' => pun_trim($_POST['form']['smtp_pass']), |
| | 78: 'smtp_ssl' => $_POST['form']['smtp_ssl'] != '1' ? '0' : '1', |
| | 79: 'regs_allow' => $_POST['form']['regs_allow'] != '1' ? '0' : '1', |
| | 80: 'regs_verify' => $_POST['form']['regs_verify'] != '1' ? '0' : '1', |
| | 81: 'regs_report' => $_POST['form']['regs_report'] != '1' ? '0' : '1', |
| | 82: 'rules' => $_POST['form']['rules'] != '1' ? '0' : '1', |
| | 83: 'rules_message' => pun_trim($_POST['form']['rules_message']), |
| | 84: 'default_email_setting' => intval($_POST['form']['default_email_setting']), |
| | 85: 'announcement' => $_POST['form']['announcement'] != '1' ? '0' : '1', |
| | 86: 'announcement_message' => pun_trim($_POST['form']['announcement_message']), |
| | 87: 'maintenance' => $_POST['form']['maintenance'] != '1' ? '0' : '1', |
| | 88: 'maintenance_message' => pun_trim($_POST['form']['maintenance_message']), |
| | 89: ); |
| | 90: |
| | 91: if ($form['board_title'] == '') |
| | 92: message($lang_admin_options['Must enter title message']); |
| | 93: |
| | 94: // Make sure base_url doesn't end with a slash |
| | 95: if (substr($form['base_url'], -1) == '/') |
| | 96: $form['base_url'] = substr($form['base_url'], 0, -1); |
| | 97: |
| | 98: if (!file_exists(PUN_ROOT.'lang/'.$form['default_lang'].'/common.php')) |
| | 99: message($lang_common['Bad request']); |
| | 100: if (!file_exists(PUN_ROOT.'style/'.$form['default_style'].'.css')) |
| | 101: message($lang_common['Bad request']); |
| | 102: |
| | 103: if ($form['time_format'] == '') |
| | 104: $form['time_format'] = 'H:i:s'; |
| | 105: |
| | 106: if ($form['date_format'] == '') |
| | 107: $form['date_format'] = 'Y-m-d'; |
| | 108: |
| | 109: |
| | 110: require PUN_ROOT.'include/email.php'; |
| | 111: |
| | 112: if (!is_valid_email($form['admin_email'])) |
| | 113: message($lang_admin_options['Invalid e-mail message']); |
| | 114: |
| | 115: if (!is_valid_email($form['webmaster_email'])) |
| | 116: message($lang_admin_options['Invalid webmaster e-mail message']); |
| | 117: |
| | 118: if ($form['mailing_list'] != '') |
| | 119: $form['mailing_list'] = strtolower(preg_replace('/\s/S', '', $form['mailing_list'])); |
| | 120: |
| | 121: // Make sure avatars_dir doesn't end with a slash |
| | 122: if (substr($form['avatars_dir'], -1) == '/') |
| | 123: $form['avatars_dir'] = substr($form['avatars_dir'], 0, -1); |
| | 124: |
| | 125: if ($form['additional_navlinks'] != '') |
| | 126: $form['additional_navlinks'] = pun_trim(pun_linebreaks($form['additional_navlinks'])); |
| | 127: |
| | 128: if ($form['announcement_message'] != '') |
| | 129: $form['announcement_message'] = pun_linebreaks($form['announcement_message']); |
| | 130: else |
| | 131: { |
| | 132: $form['announcement_message'] = $lang_admin_options['Enter announcement here']; |
| | 133: $form['announcement'] = '0'; |
| | 134: } |
| | 135: |
| | 136: if ($form['rules_message'] != '') |
| | 137: $form['rules_message'] = pun_linebreaks($form['rules_message']); |
| | 138: else |
| | 139: { |
| | 140: $form['rules_message'] = $lang_admin_options['Enter rules here']; |
| | 141: $form['rules'] = '0'; |
| | 142: } |
| | 143: |
| | 144: if ($form['maintenance_message'] != '') |
| | 145: $form['maintenance_message'] = pun_linebreaks($form['maintenance_message']); |
| | 146: else |
| | 147: { |
| | 148: $form['maintenance_message'] = $lang_admin_options['Default maintenance message']; |
| | 149: $form['maintenance'] = '0'; |
| | 150: } |
| | 151: |
| | 152: // Make sure the number of displayed topics and posts is between 3 and 75 |
| | 153: if ($form['disp_topics_default'] < 3) |
| | 154: $form['disp_topics_default'] = 3; |
| | 155: else if ($form['disp_topics_default'] > 75) |
| | 156: $form['disp_topics_default'] = 75; |
| | 157: |
| | 158: if ($form['disp_posts_default'] < 3) |
| | 159: $form['disp_posts_default'] = 3; |
| | 160: else if ($form['disp_posts_default'] > 75) |
| | 161: $form['disp_posts_default'] = 75; |
| | 162: |
| | 163: if ($form['feed_type'] < 0 || $form['feed_type'] > 2) |
| | 164: message($lang_common['Bad request']); |
| | 165: |
| | 166: if ($form['report_method'] < 0 || $form['report_method'] > 2) |
| | 167: message($lang_common['Bad request']); |
| | 168: |
| | 169: if ($form['default_email_setting'] < 0 || $form['default_email_setting'] > 2) |
| | 170: message($lang_common['Bad request']); |
| | 171: |
| | 172: if ($form['timeout_online'] >= $form['timeout_visit']) |
| | 173: message($lang_admin_options['Timeout error message']); |
| | 174: |
| | 175: foreach ($form as $key => $input) |
| | 176: { |
| | 177: // Only update values that have changed |
| | 178: if (array_key_exists('o_'.$key, $pun_config) && $pun_config['o_'.$key] != $input) |
| | 179: { |
| | 180: if ($input != '' || is_int($input)) |
| | 181: $value = '\''.$db->escape($input).'\''; |
| | 182: else |
| | 183: $value = 'NULL'; |
| | 184: |
| | 185: $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()); |
| | 186: } |
| | 187: } |
| | 188: |
| | 189: // Regenerate the config cache |
| | 190: if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
| | 191: require PUN_ROOT.'include/cache.php'; |
| | 192: |
| | 193: generate_config_cache(); |
| | 194: |
| | 195: redirect('admin_options.php', $lang_admin_options['Options updated redirect']); |
| | 196: } |
| | 197: |
| | 198: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Options']); |
| | 199: define('PUN_ACTIVE_PAGE', 'admin'); |
| | 200: require PUN_ROOT.'header.php'; |
| | 201: |
| | 202: generate_admin_menu('options'); |
| | 203: |
| | 204: ?> |
| | 205: <div class="blockform"> |
| | 206: <h2><span><?php echo $lang_admin_options['Options head'] ?></span></h2> |
| | 207: <div class="box"> |
| | 208: <form method="post" action="admin_options.php?action=foo"> |
| | 209: <p class="submittop"><input type="submit" name="save" value="<?php echo $lang_admin_common['Save changes'] ?>" /></p> |
| | 210: <div class="inform"> |
| | 211: <input type="hidden" name="form_sent" value="1" /> |
| | 212: <fieldset> |
| | 213: <legend><?php echo $lang_admin_options['Essentials subhead'] ?></legend> |
| | 214: <div class="infldset"> |
| | 215: <table class="aligntop" cellspacing="0"> |
| | 216: <tr> |
| | 217: <th scope="row"><?php echo $lang_admin_options['Board title label'] ?></th> |
| | 218: <td> |
| | 219: <input type="text" name="form[board_title]" size="50" maxlength="255" value="<?php echo pun_htmlspecialchars($pun_config['o_board_title']) ?>" /> |
| | 220: <span><?php echo $lang_admin_options['Board title help'] ?></span> |
| | 221: </td> |
| | 222: </tr> |
| | 223: <tr> |
| | 224: <th scope="row"><?php echo $lang_admin_options['Board desc label'] ?></th> |
| | 225: <td> |
| | 226: <input type="text" name="form[board_desc]" size="50" maxlength="255" value="<?php echo pun_htmlspecialchars($pun_config['o_board_desc']) ?>" /> |
| | 227: <span><?php echo $lang_admin_options['Board desc help'] ?></span> |
| | 228: </td> |
| | 229: </tr> |
| | 230: <tr> |
| | 231: <th scope="row"><?php echo $lang_admin_options['Base URL label'] ?></th> |
| | 232: <td> |
| | 233: <input type="text" name="form[base_url]" size="50" maxlength="100" value="<?php echo $pun_config['o_base_url'] ?>" /> |
| | 234: <span><?php echo $lang_admin_options['Base URL help'] ?></span> |
| | 235: </td> |
| | 236: </tr> |
| | 237: <tr> |
| | 238: <th scope="row"><?php echo $lang_admin_options['Timezone label'] ?></th> |
| | 239: <td> |
| | 240: <select name="form[default_timezone]"> |
| | 241: <option value="-12"<?php if ($pun_config['o_default_timezone'] == -12) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-12:00'] ?></option> |
| | 242: <option value="-11"<?php if ($pun_config['o_default_timezone'] == -11) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-11:00'] ?></option> |
| | 243: <option value="-10"<?php if ($pun_config['o_default_timezone'] == -10) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-10:00'] ?></option> |
| | 244: <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> |
| | 245: <option value="-9"<?php if ($pun_config['o_default_timezone'] == -9) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-09:00'] ?></option> |
| | 246: <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> |
| | 247: <option value="-8"<?php if ($pun_config['o_default_timezone'] == -8) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-08:00'] ?></option> |
| | 248: <option value="-7"<?php if ($pun_config['o_default_timezone'] == -7) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-07:00'] ?></option> |
| | 249: <option value="-6"<?php if ($pun_config['o_default_timezone'] == -6) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-06:00'] ?></option> |
| | 250: <option value="-5"<?php if ($pun_config['o_default_timezone'] == -5) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-05:00'] ?></option> |
| | 251: <option value="-4"<?php if ($pun_config['o_default_timezone'] == -4) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-04:00'] ?></option> |
| | 252: <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> |
| | 253: <option value="-3"<?php if ($pun_config['o_default_timezone'] == -3) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-03:00'] ?></option> |
| | 254: <option value="-2"<?php if ($pun_config['o_default_timezone'] == -2) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-02:00'] ?></option> |
| | 255: <option value="-1"<?php if ($pun_config['o_default_timezone'] == -1) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC-01:00'] ?></option> |
| | 256: <option value="0"<?php if ($pun_config['o_default_timezone'] == 0) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC'] ?></option> |
| | 257: <option value="1"<?php if ($pun_config['o_default_timezone'] == 1) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+01:00'] ?></option> |
| | 258: <option value="2"<?php if ($pun_config['o_default_timezone'] == 2) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+02:00'] ?></option> |
| | 259: <option value="3"<?php if ($pun_config['o_default_timezone'] == 3) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+03:00'] ?></option> |
| | 260: <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> |
| | 261: <option value="4"<?php if ($pun_config['o_default_timezone'] == 4) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+04:00'] ?></option> |
| | 262: <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> |
| | 263: <option value="5"<?php if ($pun_config['o_default_timezone'] == 5) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+05:00'] ?></option> |
| | 264: <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> |
| | 265: <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> |
| | 266: <option value="6"<?php if ($pun_config['o_default_timezone'] == 6) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+06:00'] ?></option> |
| | 267: <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> |
| | 268: <option value="7"<?php if ($pun_config['o_default_timezone'] == 7) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+07:00'] ?></option> |
| | 269: <option value="8"<?php if ($pun_config['o_default_timezone'] == 8) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+08:00'] ?></option> |
| | 270: <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> |
| | 271: <option value="9"<?php if ($pun_config['o_default_timezone'] == 9) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+09:00'] ?></option> |
| | 272: <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> |
| | 273: <option value="10"<?php if ($pun_config['o_default_timezone'] == 10) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+10:00'] ?></option> |
| | 274: <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> |
| | 275: <option value="11"<?php if ($pun_config['o_default_timezone'] == 11) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+11:00'] ?></option> |
| | 276: <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> |
| | 277: <option value="12"<?php if ($pun_config['o_default_timezone'] == 12) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+12:00'] ?></option> |
| | 278: <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> |
| | 279: <option value="13"<?php if ($pun_config['o_default_timezone'] == 13) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+13:00'] ?></option> |
| | 280: <option value="14"<?php if ($pun_config['o_default_timezone'] == 14) echo ' selected="selected"' ?>><?php echo $lang_admin_options['UTC+14:00'] ?></option> |
| | 281: </select> |
| | 282: <span><?php echo $lang_admin_options['Timezone help'] ?></span> |
| | 283: </td> |
| | 284: </tr> |
| | 285: <tr> |
| | 286: <th scope="row"><?php echo $lang_admin_options['DST label'] ?></th> |
| | 287: <td> |
| | 288: <input type="radio" name="form[default_dst]" value="1"<?php if ($pun_config['o_default_dst'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[default_dst]" value="0"<?php if ($pun_config['o_default_dst'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 289: <span><?php echo $lang_admin_options['DST help'] ?></span> |
| | 290: </td> |
| | 291: </tr> |
| | 292: <tr> |
| | 293: <th scope="row"><?php echo $lang_admin_options['Language label'] ?></th> |
| | 294: <td> |
| | 295: <select name="form[default_lang]"> |
| | 296: <?php |
| | 297: |
| | 298: $languages = forum_list_langs(); |
| | 299: |
| | 300: foreach ($languages as $temp) |
| | 301: { |
| | 302: if ($pun_config['o_default_lang'] == $temp) |
| | 303: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.$temp.'</option>'."\n"; |
| | 304: else |
| | 305: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.$temp.'</option>'."\n"; |
| | 306: } |
| | 307: |
| | 308: ?> |
| | 309: </select> |
| | 310: <span><?php echo $lang_admin_options['Language help'] ?></span> |
| | 311: </td> |
| | 312: </tr> |
| | 313: <tr> |
| | 314: <th scope="row"><?php echo $lang_admin_options['Default style label'] ?></th> |
| | 315: <td> |
| | 316: <select name="form[default_style]"> |
| | 317: <?php |
| | 318: |
| | 319: $styles = forum_list_styles(); |
| | 320: |
| | 321: foreach ($styles as $temp) |
| | 322: { |
| | 323: if ($pun_config['o_default_style'] == $temp) |
| | 324: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.str_replace('_', ' ', $temp).'</option>'."\n"; |
| | 325: else |
| | 326: echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.str_replace('_', ' ', $temp).'</option>'."\n"; |
| | 327: } |
| | 328: |
| | 329: ?> |
| | 330: </select> |
| | 331: <span><?php echo $lang_admin_options['Default style help'] ?></span> |
| | 332: </td> |
| | 333: </tr> |
| | 334: </table> |
| | 335: </div> |
| | 336: </fieldset> |
| | 337: </div> |
| | 338: <?php |
| | 339: |
| | 340: $diff = ($pun_user['timezone'] + $pun_user['dst']) * 3600; |
| | 341: $timestamp = time() + $diff; |
| | 342: |
| | 343: ?> |
| | 344: <div class="inform"> |
| | 345: <fieldset> |
| | 346: <legend><?php echo $lang_admin_options['Timeouts subhead'] ?></legend> |
| | 347: <div class="infldset"> |
| | 348: <table class="aligntop" cellspacing="0"> |
| | 349: <tr> |
| | 350: <th scope="row"><?php echo $lang_admin_options['Time format label'] ?></th> |
| | 351: <td> |
| | 352: <input type="text" name="form[time_format]" size="25" maxlength="25" value="<?php echo pun_htmlspecialchars($pun_config['o_time_format']) ?>" /> |
| | 353: <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> |
| | 354: </td> |
| | 355: </tr> |
| | 356: <tr> |
| | 357: <th scope="row"><?php echo $lang_admin_options['Date format label'] ?></th> |
| | 358: <td> |
| | 359: <input type="text" name="form[date_format]" size="25" maxlength="25" value="<?php echo pun_htmlspecialchars($pun_config['o_date_format']) ?>" /> |
| | 360: <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> |
| | 361: </td> |
| | 362: </tr> |
| | 363: <tr> |
| | 364: <th scope="row"><?php echo $lang_admin_options['Visit timeout label'] ?></th> |
| | 365: <td> |
| | 366: <input type="text" name="form[timeout_visit]" size="5" maxlength="5" value="<?php echo $pun_config['o_timeout_visit'] ?>" /> |
| | 367: <span><?php echo $lang_admin_options['Visit timeout help'] ?></span> |
| | 368: </td> |
| | 369: </tr> |
| | 370: <tr> |
| | 371: <th scope="row"><?php echo $lang_admin_options['Online timeout label'] ?></th> |
| | 372: <td> |
| | 373: <input type="text" name="form[timeout_online]" size="5" maxlength="5" value="<?php echo $pun_config['o_timeout_online'] ?>" /> |
| | 374: <span><?php echo $lang_admin_options['Online timeout help'] ?></span> |
| | 375: </td> |
| | 376: </tr> |
| | 377: <tr> |
| | 378: <th scope="row"><?php echo $lang_admin_options['Redirect time label'] ?></th> |
| | 379: <td> |
| | 380: <input type="text" name="form[redirect_delay]" size="3" maxlength="3" value="<?php echo $pun_config['o_redirect_delay'] ?>" /> |
| | 381: <span><?php echo $lang_admin_options['Redirect time help'] ?></span> |
| | 382: </td> |
| | 383: </tr> |
| | 384: </table> |
| | 385: </div> |
| | 386: </fieldset> |
| | 387: </div> |
| | 388: <div class="inform"> |
| | 389: <fieldset> |
| | 390: <legend><?php echo $lang_admin_options['Display subhead'] ?></legend> |
| | 391: <div class="infldset"> |
| | 392: <table class="aligntop" cellspacing="0"> |
| | 393: <tr> |
| | 394: <th scope="row"><?php echo $lang_admin_options['Version number label'] ?></th> |
| | 395: <td> |
| | 396: <input type="radio" name="form[show_version]" value="1"<?php if ($pun_config['o_show_version'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[show_version]" value="0"<?php if ($pun_config['o_show_version'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 397: <span><?php echo $lang_admin_options['Version number help'] ?></span> |
| | 398: </td> |
| | 399: </tr> |
| | 400: <tr> |
| | 401: <th scope="row"><?php echo $lang_admin_options['Info in posts label'] ?></th> |
| | 402: <td> |
| | 403: <input type="radio" name="form[show_user_info]" value="1"<?php if ($pun_config['o_show_user_info'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[show_user_info]" value="0"<?php if ($pun_config['o_show_user_info'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 404: <span><?php echo $lang_admin_options['Info in posts help'] ?></span> |
| | 405: </td> |
| | 406: </tr> |
| | 407: <tr> |
| | 408: <th scope="row"><?php echo $lang_admin_options['Post count label'] ?></th> |
| | 409: <td> |
| | 410: <input type="radio" name="form[show_post_count]" value="1"<?php if ($pun_config['o_show_post_count'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[show_post_count]" value="0"<?php if ($pun_config['o_show_post_count'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 411: <span><?php echo $lang_admin_options['Post count help'] ?></span> |
| | 412: </td> |
| | 413: </tr> |
| | 414: <tr> |
| | 415: <th scope="row"><?php echo $lang_admin_options['Smilies label'] ?></th> |
| | 416: <td> |
| | 417: <input type="radio" name="form[smilies]" value="1"<?php if ($pun_config['o_smilies'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[smilies]" value="0"<?php if ($pun_config['o_smilies'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 418: <span><?php echo $lang_admin_options['Smilies help'] ?></span> |
| | 419: </td> |
| | 420: </tr> |
| | 421: <tr> |
| | 422: <th scope="row"><?php echo $lang_admin_options['Smilies sigs label'] ?></th> |
| | 423: <td> |
| | 424: <input type="radio" name="form[smilies_sig]" value="1"<?php if ($pun_config['o_smilies_sig'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[smilies_sig]" value="0"<?php if ($pun_config['o_smilies_sig'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 425: <span><?php echo $lang_admin_options['Smilies sigs help'] ?></span> |
| | 426: </td> |
| | 427: </tr> |
| | 428: <tr> |
| | 429: <th scope="row"><?php echo $lang_admin_options['Clickable links label'] ?></th> |
| | 430: <td> |
| | 431: <input type="radio" name="form[make_links]" value="1"<?php if ($pun_config['o_make_links'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[make_links]" value="0"<?php if ($pun_config['o_make_links'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 432: <span><?php echo $lang_admin_options['Clickable links help'] ?></span> |
| | 433: </td> |
| | 434: </tr> |
| | 435: <tr> |
| | 436: <th scope="row"><?php echo $lang_admin_options['Topic review label'] ?></th> |
| | 437: <td> |
| | 438: <input type="text" name="form[topic_review]" size="3" maxlength="3" value="<?php echo $pun_config['o_topic_review'] ?>" /> |
| | 439: <span><?php echo $lang_admin_options['Topic review help'] ?></span> |
| | 440: </td> |
| | 441: </tr> |
| | 442: <tr> |
| | 443: <th scope="row"><?php echo $lang_admin_options['Topics per page label'] ?></th> |
| | 444: <td> |
| | 445: <input type="text" name="form[disp_topics_default]" size="3" maxlength="3" value="<?php echo $pun_config['o_disp_topics_default'] ?>" /> |
| | 446: <span><?php echo $lang_admin_options['Topics per page help'] ?></span> |
| | 447: </td> |
| | 448: </tr> |
| | 449: <tr> |
| | 450: <th scope="row"><?php echo $lang_admin_options['Posts per page label'] ?></th> |
| | 451: <td> |
| | 452: <input type="text" name="form[disp_posts_default]" size="3" maxlength="3" value="<?php echo $pun_config['o_disp_posts_default'] ?>" /> |
| | 453: <span><?php echo $lang_admin_options['Posts per page help'] ?></span> |
| | 454: </td> |
| | 455: </tr> |
| | 456: <tr> |
| | 457: <th scope="row"><?php echo $lang_admin_options['Indent label'] ?></th> |
| | 458: <td> |
| | 459: <input type="text" name="form[indent_num_spaces]" size="3" maxlength="3" value="<?php echo $pun_config['o_indent_num_spaces'] ?>" /> |
| | 460: <span><?php echo $lang_admin_options['Indent help'] ?></span> |
| | 461: </td> |
| | 462: </tr> |
| | 463: <tr> |
| | 464: <th scope="row"><?php echo $lang_admin_options['Quote depth label'] ?></th> |
| | 465: <td> |
| | 466: <input type="text" name="form[quote_depth]" size="3" maxlength="3" value="<?php echo $pun_config['o_quote_depth'] ?>" /> |
| | 467: <span><?php echo $lang_admin_options['Quote depth help'] ?></span> |
| | 468: </td> |
| | 469: </tr> |
| | 470: </table> |
| | 471: </div> |
| | 472: </fieldset> |
| | 473: </div> |
| | 474: <div class="inform"> |
| | 475: <fieldset> |
| | 476: <legend><?php echo $lang_admin_options['Features subhead'] ?></legend> |
| | 477: <div class="infldset"> |
| | 478: <table class="aligntop" cellspacing="0"> |
| | 479: <tr> |
| | 480: <th scope="row"><?php echo $lang_admin_options['Quick post label'] ?></th> |
| | 481: <td> |
| | 482: <input type="radio" name="form[quickpost]" value="1"<?php if ($pun_config['o_quickpost'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[quickpost]" value="0"<?php if ($pun_config['o_quickpost'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 483: <span><?php echo $lang_admin_options['Quick post help'] ?></span> |
| | 484: </td> |
| | 485: </tr> |
| | 486: <tr> |
| | 487: <th scope="row"><?php echo $lang_admin_options['Users online label'] ?></th> |
| | 488: <td> |
| | 489: <input type="radio" name="form[users_online]" value="1"<?php if ($pun_config['o_users_online'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[users_online]" value="0"<?php if ($pun_config['o_users_online'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 490: <span><?php echo $lang_admin_options['Users online help'] ?></span> |
| | 491: </td> |
| | 492: </tr> |
| | 493: <tr> |
| | 494: <th scope="row"><a name="censoring"><?php echo $lang_admin_options['Censor words label'] ?></a></th> |
| | 495: <td> |
| | 496: <input type="radio" name="form[censoring]" value="1"<?php if ($pun_config['o_censoring'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[censoring]" value="0"<?php if ($pun_config['o_censoring'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 497: <span><?php printf($lang_admin_options['Censor words help'], '<a href="admin_censoring.php">'.$lang_admin_common['Censoring'].'</a>') ?></span> |
| | 498: </td> |
| | 499: </tr> |
| | 500: <tr> |
| | 501: <th scope="row"><a name="signatures"><?php echo $lang_admin_options['Signatures label'] ?></a></th> |
| | 502: <td> |
| | 503: <input type="radio" name="form[signatures]" value="1"<?php if ($pun_config['o_signatures'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[signatures]" value="0"<?php if ($pun_config['o_signatures'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 504: <span><?php echo $lang_admin_options['Signatures help'] ?></span> |
| | 505: </td> |
| | 506: </tr> |
| | 507: <tr> |
| | 508: <th scope="row"><a name="ranks"><?php echo $lang_admin_options['User ranks label'] ?></a></th> |
| | 509: <td> |
| | 510: <input type="radio" name="form[ranks]" value="1"<?php if ($pun_config['o_ranks'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[ranks]" value="0"<?php if ($pun_config['o_ranks'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 511: <span><?php printf($lang_admin_options['User ranks help'], '<a href="admin_ranks.php">'.$lang_admin_common['Ranks'].'</a>') ?></span> |
| | 512: </td> |
| | 513: </tr> |
| | 514: <tr> |
| | 515: <th scope="row"><?php echo $lang_admin_options['User has posted label'] ?></th> |
| | 516: <td> |
| | 517: <input type="radio" name="form[show_dot]" value="1"<?php if ($pun_config['o_show_dot'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[show_dot]" value="0"<?php if ($pun_config['o_show_dot'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 518: <span><?php echo $lang_admin_options['User has posted help'] ?></span> |
| | 519: </td> |
| | 520: </tr> |
| | 521: <tr> |
| | 522: <th scope="row"><?php echo $lang_admin_options['Topic views label'] ?></th> |
| | 523: <td> |
| | 524: <input type="radio" name="form[topic_views]" value="1"<?php if ($pun_config['o_topic_views'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[topic_views]" value="0"<?php if ($pun_config['o_topic_views'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 525: <span><?php echo $lang_admin_options['Topic views help'] ?></span> |
| | 526: </td> |
| | 527: </tr> |
| | 528: <tr> |
| | 529: <th scope="row"><?php echo $lang_admin_options['Quick jump label'] ?></th> |
| | 530: <td> |
| | 531: <input type="radio" name="form[quickjump]" value="1"<?php if ($pun_config['o_quickjump'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[quickjump]" value="0"<?php if ($pun_config['o_quickjump'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 532: <span><?php echo $lang_admin_options['Quick jump help'] ?></span> |
| | 533: </td> |
| | 534: </tr> |
| | 535: <tr> |
| | 536: <th scope="row"><?php echo $lang_admin_options['GZip label'] ?></th> |
| | 537: <td> |
| | 538: <input type="radio" name="form[gzip]" value="1"<?php if ($pun_config['o_gzip'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[gzip]" value="0"<?php if ($pun_config['o_gzip'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 539: <span><?php echo $lang_admin_options['GZip help'] ?></span> |
| | 540: </td> |
| | 541: </tr> |
| | 542: <tr> |
| | 543: <th scope="row"><?php echo $lang_admin_options['Search all label'] ?></th> |
| | 544: <td> |
| | 545: <input type="radio" name="form[search_all_forums]" value="1"<?php if ($pun_config['o_search_all_forums'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[search_all_forums]" value="0"<?php if ($pun_config['o_search_all_forums'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 546: <span><?php echo $lang_admin_options['Search all help'] ?></span> |
| | 547: </td> |
| | 548: </tr> |
| | 549: <tr> |
| | 550: <th scope="row"><?php echo $lang_admin_options['Menu items label'] ?></th> |
| | 551: <td> |
| | 552: <textarea name="form[additional_navlinks]" rows="3" cols="55"><?php echo pun_htmlspecialchars($pun_config['o_additional_navlinks']) ?></textarea> |
| | 553: <span><?php echo $lang_admin_options['Menu items help'] ?></span> |
| | 554: </td> |
| | 555: </tr> |
| | 556: <tr> |
| | 557: <th scope="row"><?php echo $lang_admin_options['Default feed label'] ?></th> |
| | 558: <td> |
| | 559: <input type="radio" name="form[feed_type]" 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]" value="1"<?php if ($pun_config['o_feed_type'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_options['RSS'] ?></strong>   <input type="radio" name="form[feed_type]" value="2"<?php if ($pun_config['o_feed_type'] == '2') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_options['Atom'] ?></strong> |
| | 560: <span><?php echo $lang_admin_options['Default feed help'] ?></span> |
| | 561: </td> |
| | 562: </tr> |
| | 563: </table> |
| | 564: </div> |
| | 565: </fieldset> |
| | 566: </div> |
| | 567: <div class="inform"> |
| | 568: <fieldset> |
| | 569: <legend><?php echo $lang_admin_options['Reports subhead'] ?></legend> |
| | 570: <div class="infldset"> |
| | 571: <table class="aligntop" cellspacing="0"> |
| | 572: <tr> |
| | 573: <th scope="row"><?php echo $lang_admin_options['Reporting method label'] ?></th> |
| | 574: <td> |
| | 575: <input type="radio" name="form[report_method]" 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]" value="1"<?php if ($pun_config['o_report_method'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_options['By e-mail'] ?></strong>   <input type="radio" name="form[report_method]" value="2"<?php if ($pun_config['o_report_method'] == '2') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_options['Both'] ?></strong> |
| | 576: <span><?php echo $lang_admin_options['Reporting method help'] ?></span> |
| | 577: </td> |
| | 578: </tr> |
| | 579: <tr> |
| | 580: <th scope="row"><?php echo $lang_admin_options['Mailing list label'] ?></th> |
| | 581: <td> |
| | 582: <textarea name="form[mailing_list]" rows="5" cols="55"><?php echo pun_htmlspecialchars($pun_config['o_mailing_list']) ?></textarea> |
| | 583: <span><?php echo $lang_admin_options['Mailing list help'] ?></span> |
| | 584: </td> |
| | 585: </tr> |
| | 586: </table> |
| | 587: </div> |
| | 588: </fieldset> |
| | 589: </div> |
| | 590: <div class="inform"> |
| | 591: <fieldset> |
| | 592: <legend><?php echo $lang_admin_options['Avatars subhead'] ?></legend> |
| | 593: <div class="infldset"> |
| | 594: <table class="aligntop" cellspacing="0"> |
| | 595: <tr> |
| | 596: <th scope="row"><?php echo $lang_admin_options['Use avatars label'] ?></th> |
| | 597: <td> |
| | 598: <input type="radio" name="form[avatars]" value="1"<?php if ($pun_config['o_avatars'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[avatars]" value="0"<?php if ($pun_config['o_avatars'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 599: <span><?php echo $lang_admin_options['Use avatars help'] ?></span> |
| | 600: </td> |
| | 601: </tr> |
| | 602: <tr> |
| | 603: <th scope="row"><?php echo $lang_admin_options['Upload directory label'] ?></th> |
| | 604: <td> |
| | 605: <input type="text" name="form[avatars_dir]" size="35" maxlength="50" value="<?php echo pun_htmlspecialchars($pun_config['o_avatars_dir']) ?>" /> |
| | 606: <span><?php echo $lang_admin_options['Upload directory help'] ?></span> |
| | 607: </td> |
| | 608: </tr> |
| | 609: <tr> |
| | 610: <th scope="row"><?php echo $lang_admin_options['Max width label'] ?></th> |
| | 611: <td> |
| | 612: <input type="text" name="form[avatars_width]" size="5" maxlength="5" value="<?php echo $pun_config['o_avatars_width'] ?>" /> |
| | 613: <span><?php echo $lang_admin_options['Max width help'] ?></span> |
| | 614: </td> |
| | 615: </tr> |
| | 616: <tr> |
| | 617: <th scope="row"><?php echo $lang_admin_options['Max height label'] ?></th> |
| | 618: <td> |
| | 619: <input type="text" name="form[avatars_height]" size="5" maxlength="5" value="<?php echo $pun_config['o_avatars_height'] ?>" /> |
| | 620: <span><?php echo $lang_admin_options['Max height help'] ?></span> |
| | 621: </td> |
| | 622: </tr> |
| | 623: <tr> |
| | 624: <th scope="row"><?php echo $lang_admin_options['Max size label'] ?></th> |
| | 625: <td> |
| | 626: <input type="text" name="form[avatars_size]" size="6" maxlength="6" value="<?php echo $pun_config['o_avatars_size'] ?>" /> |
| | 627: <span><?php echo $lang_admin_options['Max size 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['E-mail subhead'] ?></legend> |
| | 637: <div class="infldset"> |
| | 638: <table class="aligntop" cellspacing="0"> |
| | 639: <tr> |
| | 640: <th scope="row"><?php echo $lang_admin_options['Admin e-mail label'] ?></th> |
| | 641: <td> |
| | 642: <input type="text" name="form[admin_email]" size="50" maxlength="80" value="<?php echo $pun_config['o_admin_email'] ?>" /> |
| | 643: <span><?php echo $lang_admin_options['Admin e-mail help'] ?></span> |
| | 644: </td> |
| | 645: </tr> |
| | 646: <tr> |
| | 647: <th scope="row"><?php echo $lang_admin_options['Webmaster e-mail label'] ?></th> |
| | 648: <td> |
| | 649: <input type="text" name="form[webmaster_email]" size="50" maxlength="80" value="<?php echo $pun_config['o_webmaster_email'] ?>" /> |
| | 650: <span><?php echo $lang_admin_options['Webmaster e-mail help'] ?></span> |
| | 651: </td> |
| | 652: </tr> |
| | 653: <tr> |
| | 654: <th scope="row"><?php echo $lang_admin_options['Subscriptions label'] ?></th> |
| | 655: <td> |
| | 656: <input type="radio" name="form[subscriptions]" value="1"<?php if ($pun_config['o_subscriptions'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[subscriptions]" value="0"<?php if ($pun_config['o_subscriptions'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 657: <span><?php echo $lang_admin_options['Subscriptions help'] ?></span> |
| | 658: </td> |
| | 659: </tr> |
| | 660: <tr> |
| | 661: <th scope="row"><?php echo $lang_admin_options['SMTP address label'] ?></th> |
| | 662: <td> |
| | 663: <input type="text" name="form[smtp_host]" size="30" maxlength="100" value="<?php echo pun_htmlspecialchars($pun_config['o_smtp_host']) ?>" /> |
| | 664: <span><?php echo $lang_admin_options['SMTP address help'] ?></span> |
| | 665: </td> |
| | 666: </tr> |
| | 667: <tr> |
| | 668: <th scope="row"><?php echo $lang_admin_options['SMTP username label'] ?></th> |
| | 669: <td> |
| | 670: <input type="text" name="form[smtp_user]" size="25" maxlength="50" value="<?php echo pun_htmlspecialchars($pun_config['o_smtp_user']) ?>" /> |
| | 671: <span><?php echo $lang_admin_options['SMTP username help'] ?></span> |
| | 672: </td> |
| | 673: </tr> |
| | 674: <tr> |
| | 675: <th scope="row"><?php echo $lang_admin_options['SMTP password label'] ?></th> |
| | 676: <td> |
| | 677: <input type="text" name="form[smtp_pass]" size="25" maxlength="50" value="<?php echo pun_htmlspecialchars($pun_config['o_smtp_pass']) ?>" /> |
| | 678: <span><?php echo $lang_admin_options['SMTP password help'] ?></span> |
| | 679: </td> |
| | 680: </tr> |
| | 681: <tr> |
| | 682: <th scope="row"><?php echo $lang_admin_options['SMTP SSL label'] ?></th> |
| | 683: <td> |
| | 684: <input type="radio" name="form[smtp_ssl]" value="1"<?php if ($pun_config['o_smtp_ssl'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[smtp_ssl]" value="0"<?php if ($pun_config['o_smtp_ssl'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 685: <span><?php echo $lang_admin_options['SMTP SSL help'] ?></span> |
| | 686: </td> |
| | 687: </tr> |
| | 688: </table> |
| | 689: </div> |
| | 690: </fieldset> |
| | 691: </div> |
| | 692: <div class="inform"> |
| | 693: <fieldset> |
| | 694: <legend><?php echo $lang_admin_options['Registration subhead'] ?></legend> |
| | 695: <div class="infldset"> |
| | 696: <table class="aligntop" cellspacing="0"> |
| | 697: <tr> |
| | 698: <th scope="row"><?php echo $lang_admin_options['Allow new label'] ?></th> |
| | 699: <td> |
| | 700: <input type="radio" name="form[regs_allow]" value="1"<?php if ($pun_config['o_regs_allow'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[regs_allow]" value="0"<?php if ($pun_config['o_regs_allow'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 701: <span><?php echo $lang_admin_options['Allow new help'] ?></span> |
| | 702: </td> |
| | 703: </tr> |
| | 704: <tr> |
| | 705: <th scope="row"><?php echo $lang_admin_options['Verify label'] ?></th> |
| | 706: <td> |
| | 707: <input type="radio" name="form[regs_verify]" value="1"<?php if ($pun_config['o_regs_verify'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[regs_verify]" value="0"<?php if ($pun_config['o_regs_verify'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 708: <span><?php echo $lang_admin_options['Verify help'] ?></span> |
| | 709: </td> |
| | 710: </tr> |
| | 711: <tr> |
| | 712: <th scope="row"><?php echo $lang_admin_options['Report new label'] ?></th> |
| | 713: <td> |
| | 714: <input type="radio" name="form[regs_report]" value="1"<?php if ($pun_config['o_regs_report'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[regs_report]" value="0"<?php if ($pun_config['o_regs_report'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 715: <span><?php echo $lang_admin_options['Report new help'] ?></span> |
| | 716: </td> |
| | 717: </tr> |
| | 718: <tr> |
| | 719: <th scope="row"><?php echo $lang_admin_options['Use rules label'] ?></th> |
| | 720: <td> |
| | 721: <input type="radio" name="form[rules]" value="1"<?php if ($pun_config['o_rules'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[rules]" value="0"<?php if ($pun_config['o_rules'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 722: <span><?php echo $lang_admin_options['Use rules help'] ?></span> |
| | 723: </td> |
| | 724: </tr> |
| | 725: <tr> |
| | 726: <th scope="row"><?php echo $lang_admin_options['Rules label'] ?></th> |
| | 727: <td> |
| | 728: <textarea name="form[rules_message]" rows="10" cols="55"><?php echo pun_htmlspecialchars($pun_config['o_rules_message']) ?></textarea> |
| | 729: <span><?php echo $lang_admin_options['Rules help'] ?></span> |
| | 730: </td> |
| | 731: </tr> |
| | 732: <tr> |
| | 733: <th scope="row"><?php echo $lang_admin_options['E-mail default label'] ?></th> |
| | 734: <td> |
| | 735: <span><?php echo $lang_admin_options['E-mail default help'] ?></span> |
| | 736: <input type="radio" name="form[default_email_setting]" value="0"<?php if ($pun_config['o_default_email_setting'] == '0') echo ' checked="checked"' ?> /> <?php echo $lang_admin_options['Display e-mail label'] ?><br /> |
| | 737: <input type="radio" name="form[default_email_setting]" value="1"<?php if ($pun_config['o_default_email_setting'] == '1') echo ' checked="checked"' ?> /> <?php echo $lang_admin_options['Hide allow form label'] ?><br /> |
| | 738: <input type="radio" name="form[default_email_setting]" value="2"<?php if ($pun_config['o_default_email_setting'] == '2') echo ' checked="checked"' ?> /> <?php echo $lang_admin_options['Hide both label'] ?><br /> |
| | 739: </td> |
| | 740: </tr> |
| | 741: </table> |
| | 742: </div> |
| | 743: </fieldset> |
| | 744: </div> |
| | 745: <div class="inform"> |
| | 746: <fieldset> |
| | 747: <legend><?php echo $lang_admin_options['Announcement subhead'] ?></legend> |
| | 748: <div class="infldset"> |
| | 749: <table class="aligntop" cellspacing="0"> |
| | 750: <tr> |
| | 751: <th scope="row"><?php echo $lang_admin_options['Display announcement label'] ?></th> |
| | 752: <td> |
| | 753: <input type="radio" name="form[announcement]" value="1"<?php if ($pun_config['o_announcement'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[announcement]" value="0"<?php if ($pun_config['o_announcement'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 754: <span><?php echo $lang_admin_options['Display announcement help'] ?></span> |
| | 755: </td> |
| | 756: </tr> |
| | 757: <tr> |
| | 758: <th scope="row"><?php echo $lang_admin_options['Announcement message label'] ?></th> |
| | 759: <td> |
| | 760: <textarea name="form[announcement_message]" rows="5" cols="55"><?php echo pun_htmlspecialchars($pun_config['o_announcement_message']) ?></textarea> |
| | 761: <span><?php echo $lang_admin_options['Announcement message help'] ?></span> |
| | 762: </td> |
| | 763: </tr> |
| | 764: </table> |
| | 765: </div> |
| | 766: </fieldset> |
| | 767: </div> |
| | 768: <div class="inform"> |
| | 769: <fieldset> |
| | 770: <legend><?php echo $lang_admin_options['Maintenance subhead'] ?></legend> |
| | 771: <div class="infldset"> |
| | 772: <table class="aligntop" cellspacing="0"> |
| | 773: <tr> |
| | 774: <th scope="row"><a name="maintenance"><?php echo $lang_admin_options['Maintenance mode label'] ?></a></th> |
| | 775: <td> |
| | 776: <input type="radio" name="form[maintenance]" value="1"<?php if ($pun_config['o_maintenance'] == '1') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['Yes'] ?></strong>   <input type="radio" name="form[maintenance]" value="0"<?php if ($pun_config['o_maintenance'] == '0') echo ' checked="checked"' ?> /> <strong><?php echo $lang_admin_common['No'] ?></strong> |
| | 777: <span><?php echo $lang_admin_options['Maintenance mode help'] ?></span> |
| | 778: </td> |
| | 779: </tr> |
| | 780: <tr> |
| | 781: <th scope="row"><?php echo $lang_admin_options['Maintenance message label'] ?></th> |
| | 782: <td> |
| | 783: <textarea name="form[maintenance_message]" rows="5" cols="55"><?php echo pun_htmlspecialchars($pun_config['o_maintenance_message']) ?></textarea> |
| | 784: <span><?php echo $lang_admin_options['Maintenance message help'] ?></span> |
| | 785: </td> |
| | 786: </tr> |
| | 787: </table> |
| | 788: </div> |
| | 789: </fieldset> |
| | 790: </div> |
| | 791: <p class="submitend"><input type="submit" name="save" value="<?php echo $lang_admin_common['Save changes'] ?>" /></p> |
| | 792: </form> |
| | 793: </div> |
| | 794: </div> |
| | 795: <div class="clearer"></div> |
| | 796: </div> |
| | 797: <?php |
| | 798: |
| | 799: require PUN_ROOT.'footer.php'; |
| /dev/null |
b/admin_users.php |
| | 1: <?php |
| | 2: |
| | 3: /** |
| | 4: * Copyright (C) 2008-2010 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', './'); |
| | 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']); |
| | 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 = 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&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: else if (isset($_GET['find_user'])) |
| | 257: { |
| | 258: $form = isset($_GET['form']) ? $_GET['form'] : array(); |
| | 259: |
| | 260: // trim() all elements in $form |
| | 261: $form = array_map('pun_trim', $form); |
| | 262: $conditions = $query_str = array(); |
| | 263: |
| | 264: $posts_greater = isset($_GET['posts_greater']) ? trim($_GET['posts_greater']) : ''; |
| | 265: $posts_less = isset($_GET['posts_less']) ? trim($_GET['posts_less']) : ''; |
| | 266: $last_post_after = isset($_GET['last_post_after']) ? trim($_GET['last_post_after']) : ''; |
| | 267: $last_post_before = isset($_GET['last_post_before']) ? trim($_GET['last_post_before']) : ''; |
| | 268: $registered_after = isset($_GET['registered_after']) ? trim($_GET['registered_after']) : ''; |
| | 269: $registered_before = isset($_GET['registered_before']) ? trim($_GET['registered_before']) : ''; |
| | 270: $order_by = isset($_GET['order_by']) && in_array($_GET['order_by'], array('username', 'email', 'num_posts', 'last_post', 'registered')) ? $_GET['order_by'] : 'username'; |
| | 271: $direction = isset($_GET['direction']) && $_GET['direction'] == 'DESC' ? 'DESC' : 'ASC'; |
| | 272: $user_group = isset($_GET['user_group']) ? intval($_GET['user_group']) : -1; |
| | 273: |
| | 274: $query_str[] = 'order_by='.$order_by; |
| | 275: $query_str[] = 'direction='.$direction; |
| | 276: $query_str[] = 'user_group='.$user_group; |
| | 277: |
| | 278: if (preg_match('/[^0-9]/', $posts_greater.$posts_less)) |
| | 279: message($lang_admin_users['Non numeric message']); |
| | 280: |
| | 281: // Try to convert date/time to timestamps |
| | 282: if ($last_post_after != '') |
| | 283: { |
| | 284: $query_str[] = 'last_post_after='.$last_post_after; |
| | 285: |
| | 286: $last_post_after = strtotime($last_post_after); |
| | 287: if ($last_post_after === false || $last_post_after == -1) |
| | 288: message($lang_admin_users['Invalid date time message']); |
| | 289: |
| | 290: $conditions[] = 'u.last_post>'.$last_post_after; |
| | 291: } |
| | 292: if ($last_post_before != '') |
| | 293: { |
| | 294: $query_str[] = 'last_post_before='.$last_post_before; |
| | 295: |
| | 296: $last_post_before = strtotime($last_post_before); |
| | 297: if ($last_post_before === false || $last_post_before == -1) |
| | 298: message($lang_admin_users['Invalid date time message']); |
| | 299: |
| | 300: $conditions[] = 'u.last_post<'.$last_post_before; |
| | 301: } |
| | 302: if ($registered_after != '') |
| | 303: { |
| | 304: $query_str[] = 'registered_after='.$registered_after; |
| | 305: |
| | 306: $registered_after = strtotime($registered_after); |
| | 307: if ($registered_after === false || $registered_after == -1) |
| | 308: message($lang_admin_users['Invalid date time message']); |
| | 309: |
| | 310: $conditions[] = 'u.registered>'.$registered_after; |
| | 311: } |
| | 312: if ($registered_before != '') |
| | 313: { |
| | 314: $query_str[] = 'registered_before='.$registered_before; |
| | 315: |
| | 316: $registered_before = strtotime($registered_before); |
| | 317: if ($registered_before === false || $registered_before == -1) |
| | 318: message($lang_admin_users['Invalid date time message']); |
| | 319: |
| | 320: $conditions[] = 'u.registered<'.$registered_before; |
| | 321: } |
| | 322: |
| | 323: $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE'; |
| | 324: foreach ($form as $key => $input) |
| | 325: { |
| | 326: if ($input != '' && in_array($key, array('username', 'email', 'title', 'realname', 'url', 'jabber', 'icq', 'msn', 'aim', 'yahoo', 'location', 'signature', 'admin_note'))) |
| | 327: { |
| | 328: $conditions[] = 'u.'.$db->escape($key).' '.$like_command.' \''.$db->escape(str_replace('*', '%', $input)).'\''; |
| | 329: $query_str[] = 'form%5B'.$key.'%5D='.urlencode($input); |
| | 330: } |
| | 331: } |
| | 332: |
| | 333: if ($posts_greater != '') |
| | 334: { |
| | 335: $query_str[] = 'posts_greater='.$posts_greater; |
| | 336: $conditions[] = 'u.num_posts>'.$posts_greater; |
| | 337: } |
| | 338: if ($posts_less != '') |
| | 339: { |
| | 340: $query_str[] = 'posts_less='.$posts_less; |
| | 341: $conditions[] = 'u.num_posts<'.$posts_less; |
| | 342: } |
| | 343: |
| | 344: if ($user_group > -1) |
| | 345: $conditions[] = 'u.group_id='.$user_group; |
| | 346: |
| | 347: // Fetch user count |
| | 348: $result = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($conditions) ? ' AND '.implode(' AND ', $conditions) : '')) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
| | 349: $num_users = $db->result($result); |
| | 350: |
| | 351: // Determine the user offset (based on $_GET['p']) |
| | 352: $num_pages = ceil($num_users / 50); |
| | 353: |
| | 354: $p = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $num_pages) ? 1 : intval($_GET['p']); |
| | 355: $start_from = 50 * ($p - 1); |
| | 356: |
| | 357: // Generate paging links |
| | 358: $paging_links = '<span class="pages-label">'.$lang_common['Pages'].' </span>'.paginate($num_pages, $p, 'admin_users.php?find_user=&'.implode('&', $query_str)); |
| | 359: |
| | 360: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Results head']); |
| | 361: define('PUN_ACTIVE_PAGE', 'admin'); |
| | 362: require PUN_ROOT.'header.php'; |
| | 363: |
| | 364: ?> |
| | 365: <div class="linkst"> |
| | 366: <div class="inbox crumbsplus"> |
| | 367: <ul class="crumbs"> |
| | 368: <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
| | 369: <li><span>» </span><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li> |
| | 370: <li><span>» </span><strong><?php echo $lang_admin_users['Results head'] ?></strong></li> |
| | 371: </ul> |
| | 372: <div class="pagepost"> |
| | 373: <p class="pagelink"><?php echo $paging_links ?></p> |
| | 374: </div> |
| | 375: <div class="clearer"></div> |
| | 376: </div> |
| | 377: </div> |
| | 378: |
| | 379: |
| | 380: <div id="users2" class="blocktable"> |
| | 381: <h2><span><?php echo $lang_admin_users['Results head'] ?></span></h2> |
| | 382: <div class="box"> |
| | 383: <div class="inbox"> |
| | 384: <table cellspacing="0"> |
| | 385: <thead> |
| | 386: <tr> |
| | 387: <th class="tcl" scope="col"><?php echo $lang_admin_users['Results username head'] ?></th> |
| | 388: <th class="tc2" scope="col"><?php echo $lang_admin_users['Results e-mail head'] ?></th> |
| | 389: <th class="tc3" scope="col"><?php echo $lang_admin_users['Results title head'] ?></th> |
| | 390: <th class="tc4" scope="col"><?php echo $lang_admin_users['Results posts head'] ?></th> |
| | 391: <th class="tc5" scope="col"><?php echo $lang_admin_users['Results admin note head'] ?></th> |
| | 392: <th class="tcr" scope="col"><?php echo $lang_admin_users['Results actions head'] ?></th> |
| | 393: </tr> |
| | 394: </thead> |
| | 395: <tbody> |
| | 396: <?php |
| | 397: |
| | 398: $result = $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 LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($conditions) ? ' AND '.implode(' AND ', $conditions) : '').' ORDER BY '.$db->escape($order_by).' '.$db->escape($direction).' LIMIT '.$start_from.', 50') or error('Unable to fetch user info', __FILE__, __LINE__, $db->error()); |
| | 399: if ($db->num_rows($result)) |
| | 400: { |
| | 401: while ($user_data = $db->fetch_assoc($result)) |
| | 402: { |
| | 403: $user_title = get_title($user_data); |
| | 404: |
| | 405: // This script is a special case in that we want to display "Not verified" for non-verified users |
| | 406: if (($user_data['g_id'] == '' || $user_data['g_id'] == PUN_UNVERIFIED) && $user_title != $lang_common['Banned']) |
| | 407: $user_title = '<span class="warntext">'.$lang_admin_users['Not verified'].'</span>'; |
| | 408: |
| | 409: $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&user_id='.$user_data['id'].'">'.$lang_admin_users['Results show posts link'].'</a>'; |
| | 410: |
| | 411: ?> |
| | 412: <tr> |
| | 413: <td class="tcl"><?php echo '<a href="profile.php?id='.$user_data['id'].'">'.pun_htmlspecialchars($user_data['username']).'</a>' ?></td> |
| | 414: <td class="tc2"><a href="mailto:<?php echo $user_data['email'] ?>"><?php echo $user_data['email'] ?></a></td> |
| | 415: <td class="tc3"><?php echo $user_title ?></td> |
| | 416: <td class="tc4"><?php echo forum_number_format($user_data['num_posts']) ?></td> |
| | 417: <td class="tc5"><?php echo ($user_data['admin_note'] != '') ? pun_htmlspecialchars($user_data['admin_note']) : ' ' ?></td> |
| | 418: <td class="tcr"><?php echo $actions ?></td> |
| | 419: </tr> |
| | 420: <?php |
| | 421: |
| | 422: } |
| | 423: } |
| | 424: else |
| | 425: echo "\t\t\t\t".'<tr><td class="tcl" colspan="6">'.$lang_admin_users['No match'].'</td></tr>'."\n"; |
| | 426: |
| | 427: ?> |
| | 428: </tbody> |
| | 429: </table> |
| | 430: </div> |
| | 431: </div> |
| | 432: </div> |
| | 433: |
| | 434: <div class="linksb"> |
| | 435: <div class="inbox crumbsplus"> |
| | 436: <div class="pagepost"> |
| | 437: <p class="pagelink"><?php echo $paging_links ?></p> |
| | 438: </div> |
| | 439: <ul class="crumbs"> |
| | 440: <li><a href="admin_index.php"><?php echo $lang_admin_common['Admin'].' '.$lang_admin_common['Index'] ?></a></li> |
| | 441: <li><span>» </span><a href="admin_users.php"><?php echo $lang_admin_common['Users'] ?></a></li> |
| | 442: <li><span>» </span><strong><?php echo $lang_admin_users['Results head'] ?></strong></li> |
| | 443: </ul> |
| | 444: <div class="clearer"></div> |
| | 445: </div> |
| | 446: </div> |
| | 447: <?php |
| | 448: |
| | 449: require PUN_ROOT.'footer.php'; |
| | 450: } |
| | 451: |
| | 452: |
| | 453: else |
| | 454: { |
| | 455: $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users']); |
| | 456: $focus_element = array('find_user', 'username'); |
| | 457: define('PUN_ACTIVE_PAGE', 'admin'); |
| | 458: require PUN_ROOT.'header.php'; |
| | 459: |
| | 460: generate_admin_menu('users'); |
| | 461: |
| | 462: ?> |
| | 463: <div class="blockform"> |
| | 464: <h2><span><?php echo $lang_admin_users['User search head'] ?></span></h2> |
| | 465: <div class="box"> |
| | 466: <form id="find_user" method="get" action="admin_users.php"> |
| | 467: <p class="submittop"><input type="submit" name="find_user" value="<?php echo $lang_admin_users['Submit search'] ?>" tabindex="1" /></p> |
| | 468: <div class="inform"> |
| | 469: <fieldset> |
| | 470: <legend><?php echo $lang_admin_users['User search subhead'] ?></legend> |
| | 471: <div class="infldset"> |
| | 472: <p><?php echo $lang_admin_users['User search info'] ?></p> |
| | 473: <table class="aligntop" cellspacing="0"> |
| | 474: <tr> |
| | 475: <th scope="row"><?php echo $lang_admin_users['Username label'] ?></th> |
| | 476: <td><input type="text" name="form[username]" size="25" maxlength="25" tabindex="2" /></td> |
| | 477: </tr> |
| | 478: <tr> |
| | 479: <th scope="row"><?php echo $lang_admin_users['E-mail address label'] ?></th> |
| | 480: <td><input type="text" name="form[email]" size="30" maxlength="80" tabindex="3" /></td> |
| | 481: </tr> |
| | 482: <tr> |
| | 483: <th scope="row"><?php echo $lang_admin_users['Title label'] ?></th> |
| | 484: <td><input type="text" name="form[title]" size="30" maxlength="50" tabindex="4" /></td> |
| | 485: </tr> |
| | 486: <tr> |
| | 487: <th scope="row"><?php echo $lang_admin_users['Real name label'] ?></th> |
| | 488: <td><input type="text" name="form[realname]" size="30" maxlength="40" tabindex="5" /></td> |
| | 489: </tr> |
| | 490: <tr> |
| | 491: <th scope="row"><?php echo $lang_admin_users['Website label'] ?></th> |
| | 492: <td><input type="text" name="form[url]" size="35" maxlength="100" tabindex="6" /></td> |
| | 493: </tr> |
| | 494: <tr> |
| | 495: <th scope="row"><?php echo $lang_admin_users['Jabber label'] ?></th> |
| | 496: <td><input type="text" name="form[jabber]" size="30" maxlength="75" tabindex="7" /></td> |
| | 497: </tr> |
| | 498: <tr> |
| | 499: <th scope="row"><?php echo $lang_admin_users['ICQ label'] ?></th> |
| | 500: <td><input type="text" name="form[icq]" size="12" maxlength="12" tabindex="8" /></td> |
| | 501: </tr> |
| | 502: <tr> |
| | 503: <th scope="row"><?php echo $lang_admin_users['MSN label'] ?></th> |
| | 504: <td><input type="text" name="form[msn]" size="30" maxlength="50" tabindex="9" /></td> |
| | 505: </tr> |
| | 506: <tr> |
| | 507: <th scope="row"><?php echo $lang_admin_users['AOL label'] ?></th> |
| | 508: <td><input type="text" name="form[aim]" size="20" maxlength="20" tabindex="10" /></td> |
| | 509: </tr> |
| | 510: <tr> |
| | 511: <th scope="row"><?php echo $lang_admin_users['Yahoo label'] ?></th> |
| | 512: <td><input type="text" name="form[yahoo]" size="20" maxlength="20" tabindex="11" /></td> |
| | 513: </tr> |
| | 514: <tr> |
| | 515: <th scope="row"><?php echo $lang_admin_users['Location label'] ?></th> |
| | 516: <td><input type="text" name="form[location]" size="30" maxlength="30" tabindex="12" /></td> |
| | 517: </tr> |
| | 518: <tr> |
| | 519: <th scope="row"><?php echo $lang_admin_users['Signature label'] ?></th> |
| | 520: <td><input type="text" name="form[signature]" size="35" maxlength="512" tabindex="13" /></td> |
| | 521: </tr> |
| | 522: <tr> |
| | 523: <th scope="row"><?php echo $lang_admin_users['Admin note label'] ?></th> |
| | 524: <td><input type="text" name="form[admin_note]" size="30" maxlength="30" tabindex="14" /></td> |
| | 525: </tr> |
| | 526: <tr> |
| | 527: <th scope="row"><?php echo $lang_admin_users['Posts more than label'] ?></th> |
| | 528: <td><input type="text" name="posts_greater" size="5" maxlength="8" tabindex="15" /></td> |
| | 529: </tr> |
| | 530: <tr> |
| | 531: <th scope="row"><?php echo $lang_admin_users['Posts less than label'] ?></th> |
| | 532: <td><input type="text" name="posts_less" size="5" maxlength="8" tabindex="16" /></td> |
| | 533: </tr> |
| | 534: <tr> |
| | 535: <th scope="row"><?php echo $lang_admin_users['Last post after label'] ?></th> |
| | 536: <td><input type="text" name="last_post_after" size="24" maxlength="19" tabindex="17" /> |
| | 537: <span><?php echo $lang_admin_users['Date help'] ?></span></td> |
| | 538: </tr> |
| | 539: <tr> |
| | 540: <th scope="row"><?php echo $lang_admin_users['Last post before label'] ?></th> |
| | 541: <td><input type="text" name="last_post_before" size="24" maxlength="19" tabindex="18" /> |
| | 542: <span><?php echo $lang_admin_users['Date help'] ?></span></td> |
| | 543: </tr> |
| | 544: <tr> |
| | 545: <th scope="row"><?php echo $lang_admin_users['Registered after label'] ?></th> |
| | 546: <td><input type="text" name="registered_after" size="24" maxlength="19" tabindex="19" /> |
| | 547: <span><?php echo $lang_admin_users['Date help'] ?></span></td> |
| | 548: </tr> |
| | 549: <tr> |
| | 550: <th scope="row"><?php echo $lang_admin_users['Registered before label'] ?></th> |
| | 551: <td><input type="text" name="registered_before" size="24" maxlength="19" tabindex="20" /> |
| | 552: <span><?php echo $lang_admin_users['Date help'] ?></span></td> |
| | 553: </tr> |
| | 554: <tr> |
| | 555: <th scope="row"><?php echo $lang_admin_users['Order by label'] ?></th> |
| | 556: <td> |
| | 557: <select name="order_by" tabindex="21"> |
| | 558: <option value="username" selected="selected"><?php echo $lang_admin_users['Order by username'] ?></option> |
| | 559: <option value="email"><?php echo $lang_admin_users['Order by e-mail'] ?></option> |
| | 560: <option value="num_posts"><?php echo $lang_admin_users['Order by posts'] ?></option> |
| | 561: <option value="last_post"><?php echo $lang_admin_users['Order by last post'] ?></option> |
| | 562: <option value="registered"><?php echo $lang_admin_users['Order by registered'] ?></option> |
| | 563: </select>   <select name="direction" tabindex="22"> |
| | 564: <option value="ASC" selected="selected"><?php echo $lang_admin_users['Ascending'] ?></option> |
| | 565: <option value="DESC"><?php echo $lang_admin_users['Descending'] ?></option> |
| | 566: </select> |
| | 567: </td> |
| | 568: </tr> |
| | 569: <tr> |
| | 570: <th scope="row"><?php echo $lang_admin_users['User group label'] ?></th> |
| | 571: <td> |
| | 572: <select name="user_group" tabindex="23"> |
| | 573: <option value="-1" selected="selected"><?php echo $lang_admin_users['All groups'] ?></option> |
| | 574: <option value="0"><?php echo $lang_admin_users['Unverified users'] ?></option> |
| | 575: <?php |
| | 576: |
| | 577: $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); |
| | 578: |
| | 579: while ($cur_group = $db->fetch_assoc($result)) |
| | 580: 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"; |
| | 581: |
| | 582: ?> |
| | 583: </select> |
| | 584: </td> |
| | 585: </tr> |
| | 586: </table> |
| | 587: </div> |
| | 588: </fieldset> |
| | 589: </div> |
| | 590: <p class="submitend"><input type="submit" name="find_user" value="<?php echo $lang_admin_users['Submit search'] ?>" tabindex="25" /></p> |
| | 591: </form> |
| | 592: </div> |
| | 593: |
| | 594: <h2 class="block2"><span><?php echo $lang_admin_users['IP search head'] ?></span></h2> |
| | 595: <div class="box"> |
| | 596: <form method="get" action="admin_users.php"> |
| | 597: <div class="inform"> |
| | 598: <fieldset> |
| | 599: <legend><?php echo $lang_admin_users['IP search subhead'] ?></legend> |
| | 600: <div class="infldset"> |
| | 601: <table class="aligntop" cellspacing="0"> |
| | 602: <tr> |
| | 603: <th scope="row"><?php echo $lang_admin_users['IP address label'] ?><div><input type="submit" value="<?php echo $lang_admin_users['Find IP address'] ?>" tabindex="26" /></div></th> |
| | 604: <td><input type="text" name="show_users" size="18" maxlength="15" tabindex="24" /> |
| | 605: <span><?php echo $lang_admin_users['IP address help'] ?></span></td> |
| | 606: </tr> |
| | 607: </table> |
| | 608: </div> |
| | 609: </fieldset> |
| | 610: </div> |
| | 611: </form> |
| | 612: </div> |
| | 613: </div> |
| | 614: <div class="clearer"></div> |
| | 615: </div> |
| | 616: <?php |
| | 617: |
| | 618: require PUN_ROOT.'footer.php'; |
| | 619: } |
| /dev/null |
b/db_update.php |
| | 1: <?php |
| | 2: |
| | 3: /** |
| | 4: * Copyright (C) 2008-2010 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: // The FluxBB version this script updates to |
| | 10: define('UPDATE_TO', '1.4.1'); |
| | 11: |
| | 12: define('UPDATE_TO_DB_REVISION', 7); |
| | 13: define('UPDATE_TO_SI_REVISION', 1); |
| | 14: define('UPDATE_TO_PARSER_REVISION', 1); |
| | 15: |
| | 16: define('MIN_PHP_VERSION', '4.3.0'); |
| | 17: define('MIN_MYSQL_VERSION', '4.1.2'); |
| | 18: define('MIN_PGSQL_VERSION', '7.0.0'); |
| | 19: define('PUN_SEARCH_MIN_WORD', 3); |
| | 20: define('PUN_SEARCH_MAX_WORD', 20); |
| | 21: |
| | 22: // The MySQL connection character set that was used for FluxBB 1.2 - in 99% of cases this should be detected automatically, |
| | 23: // but can be overridden using the below constant if required. |
| | 24: //define('FORUM_DEFAULT_CHARSET', 'latin1'); |
| | 25: |
| | 26: |
| | 27: // The number of items to process per page view (lower this if the update script times out during UTF-8 conversion) |
| | 28: define('PER_PAGE', 300); |
| | 29: |
| | 30: // Don't set to UTF-8 until after we've found out what the default character set is |
| | 31: define('FORUM_NO_SET_NAMES', 1); |
| | 32: |
| | 33: // Make sure we are running at least MIN_PHP_VERSION |
| | 34: if (!function_exists('version_compare') || version_compare(PHP_VERSION, MIN_PHP_VERSION, '<')) |
| | 35: exit('You are running PHP version '.PHP_VERSION.'. FluxBB '.UPDATE_TO.' requires at least PHP '.MIN_PHP_VERSION.' to run properly. You must upgrade your PHP installation before you can continue.'); |
| | 36: |
| | 37: define('PUN_ROOT', './'); |
| | 38: |
| | 39: // Attempt to load the configuration file config.php |
| | 40: if (file_exists(PUN_ROOT.'config.php')) |
| | 41: include PUN_ROOT.'config.php'; |
| | 42: |
| | 43: // If we have the 1.3-legacy constant defined, define the proper 1.4 constant so we don't get an incorrect "need to install" message |
| | 44: if (defined('FORUM')) |
| | 45: define('PUN', FORUM); |
| | 46: |
| | 47: // If PUN isn't defined, config.php is missing or corrupt or we are outside the root directory |
| | 48: if (!defined('PUN')) |
| | 49: exit('This file must be run from the forum root directory.'); |
| | 50: |
| | 51: // Enable debug mode |
| | 52: if (!defined('PUN_DEBUG')) |
| | 53: define('PUN_DEBUG', 1); |
| | 54: |
| | 55: // Load the functions script |
| | 56: require PUN_ROOT.'include/functions.php'; |
| | 57: |
| | 58: // Load UTF-8 functions |
| | 59: require PUN_ROOT.'include/utf8/utf8.php'; |
| | 60: |
| | 61: // Strip out "bad" UTF-8 characters |
| | 62: forum_remove_bad_characters(); |
| | 63: |
| | 64: // Reverse the effect of register_globals |
| | 65: forum_unregister_globals(); |
| | 66: |
| | 67: // Turn on full PHP error reporting |
| | 68: error_reporting(E_ALL); |
| | 69: |
| | 70: // Force POSIX locale (to prevent functions such as strtolower() from messing up UTF-8 strings) |
| | 71: setlocale(LC_CTYPE, 'C'); |
| | 72: |
| | 73: // Turn off magic_quotes_runtime |
| | 74: if (get_magic_quotes_runtime()) |
| | 75: set_magic_quotes_runtime(0); |
| | 76: |
| | 77: // Strip slashes from GET/POST/COOKIE (if magic_quotes_gpc is enabled) |
| | 78: if (get_magic_quotes_gpc()) |
| | 79: { |
| | 80: function stripslashes_array($array) |
| | 81: { |
| | 82: return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array); |
| | 83: } |
| | 84: |
| | 85: $_GET = stripslashes_array($_GET); |
| | 86: $_POST = stripslashes_array($_POST); |
| | 87: $_COOKIE = stripslashes_array($_COOKIE); |
| | 88: $_REQUEST = stripslashes_array($_REQUEST); |
| | 89: } |
| | 90: |
| | 91: // If a cookie name is not specified in config.php, we use the default (forum_cookie) |
| | 92: if (empty($cookie_name)) |
| | 93: $cookie_name = 'pun_cookie'; |
| | 94: |
| | 95: // If the cache directory is not specified, we use the default setting |
| | 96: if (!defined('FORUM_CACHE_DIR')) |
| | 97: define('FORUM_CACHE_DIR', PUN_ROOT.'cache/'); |
| | 98: |
| | 99: // Turn off PHP time limit |
| | 100: @set_time_limit(0); |
| | 101: |
| | 102: // Load DB abstraction layer and try to connect |
| | 103: require PUN_ROOT.'include/dblayer/common_db.php'; |
| | 104: |
| | 105: // Check what the default character set is - since 1.2 didn't specify any we will use whatever the default was (usually latin1) |
| | 106: $old_connection_charset = defined('FORUM_DEFAULT_CHARSET') ? FORUM_DEFAULT_CHARSET : $db->get_names(); |
| | 107: |
| | 108: // Set the connection to UTF-8 now |
| | 109: $db->set_names('utf8'); |
| | 110: |
| | 111: // Check current version |
| | 112: $result = $db->query('SELECT conf_value FROM '.$db->prefix.'config WHERE conf_name=\'o_cur_version\'') or error('Unable to fetch version info.', __FILE__, __LINE__, $db->error()); |
| | 113: $cur_version = $db->result($result); |
| | 114: |
| | 115: if (version_compare($cur_version, '1.2', '<')) |
| | 116: exit('Version mismatch. The database \''.$db_name.'\' doesn\'t seem to be running a FluxBB database schema supported by this update script.'); |
| | 117: |
| | 118: // Do some DB type specific checks |
| | 119: $mysql = false; |
| | 120: switch ($db_type) |
| | 121: { |
| | 122: case 'mysql': |
| | 123: case 'mysqli': |
| | 124: case 'mysql_innodb': |
| | 125: case 'mysqli_innodb': |
| | 126: $mysql_info = $db->get_version(); |
| | 127: if (version_compare($mysql_info['version'], MIN_MYSQL_VERSION, '<')) |
| | 128: error('You are running MySQL version '.$mysql_version.'. FluxBB '.UPDATE_TO.' requires at least MySQL '.MIN_MYSQL_VERSION.' to run properly. You must upgrade your MySQL installation before you can continue.'); |
| | 129: |
| | 130: $mysql = true; |
| | 131: break; |
| | 132: |
| | 133: case 'pgsql': |
| | 134: $pgsql_info = $db->get_version(); |
| | 135: if (version_compare($pgsql_info['version'], MIN_PGSQL_VERSION, '<')) |
| | 136: error('You are running PostgreSQL version '.$pgsql_info.'. FluxBB '.UPDATE_TO.' requires at least PostgreSQL '.MIN_PGSQL_VERSION.' to run properly. You must upgrade your PostgreSQL installation before you can continue.'); |
| | 137: |
| | 138: break; |
| | 139: } |
| | 140: |
| | 141: // Get the forum config |
| | 142: $result = $db->query('SELECT * FROM '.$db->prefix.'config') or error('Unable to fetch config.', __FILE__, __LINE__, $db->error()); |
| | 143: while ($cur_config_item = $db->fetch_row($result)) |
| | 144: $pun_config[$cur_config_item[0]] = $cur_config_item[1]; |
| | 145: |
| | 146: // Check the database revision and the current version |
| | 147: if (isset($pun_config['o_database_revision']) && $pun_config['o_database_revision'] >= UPDATE_TO_DB_REVISION && |
| | 148: isset($pun_config['o_searchindex_revision']) && $pun_config['o_searchindex_revision'] >= UPDATE_TO_SI_REVISION && |
| | 149: isset($pun_config['o_parser_revision']) && $pun_config['o_parser_revision'] >= UPDATE_TO_PARSER_REVISION && |
| | 150: version_compare($pun_config['o_cur_version'], UPDATE_TO, '>=')) |
| | 151: exit('Your database is already as up-to-date as this script can make it.'); |
| | 152: |
| | 153: $default_style = $pun_config['o_default_style']; |
| | 154: if (!file_exists(PUN_ROOT.'style/'.$default_style.'.css')) |
| | 155: $default_style = 'Air'; |
| | 156: |
| | 157: // |
| | 158: // Determines whether $str is UTF-8 encoded or not |
| | 159: // |
| | 160: function seems_utf8($str) |
| | 161: { |
| | 162: $str_len = strlen($str); |
| | 163: for ($i = 0; $i < $str_len; ++$i) |
| | 164: { |
| | 165: if (ord($str[$i]) < 0x80) continue; # 0bbbbbbb |
| | 166: else if ((ord($str[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb |
| | 167: else if ((ord($str[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb |
| | 168: else if ((ord($str[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb |
| | 169: else if ((ord($str[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb |
| | 170: else if ((ord($str[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b |
| | 171: else return false; # Does not match any model |
| | 172: |
| | 173: for ($j = 0; $j < $n; ++$j) # n bytes matching 10bbbbbb follow ? |
| | 174: { |
| | 175: if ((++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) |
| | 176: return false; |
| | 177: } |
| | 178: } |
| | 179: |
| | 180: return true; |
| | 181: } |
| | 182: |
| | 183: |
| | 184: // |
| | 185: // Translates the number from a HTML numeric entity into an UTF-8 character |
| | 186: // |
| | 187: function dcr2utf8($src) |
| | 188: { |
| | 189: $dest = ''; |
| | 190: if ($src < 0) |
| | 191: return false; |
| | 192: else if ($src <= 0x007f) |
| | 193: $dest .= chr($src); |
| | 194: else if ($src <= 0x07ff) |
| | 195: { |
| | 196: $dest .= chr(0xc0 | ($src >> 6)); |
| | 197: $dest .= chr(0x80 | ($src & 0x003f)); |
| | 198: } |
| | 199: else if ($src == 0xFEFF) |
| | 200: { |
| | 201: // nop -- zap the BOM |
| | 202: } |
| | 203: else if ($src >= 0xD800 && $src <= 0xDFFF) |
| | 204: { |
| | 205: // found a surrogate |
| | 206: return false; |
| | 207: } |
| | 208: else if ($src <= 0xffff) |
| | 209: { |
| | 210: $dest .= chr(0xe0 | ($src >> 12)); |
| | 211: $dest .= chr(0x80 | (($src >> 6) & 0x003f)); |
| | 212: $dest .= chr(0x80 | ($src & 0x003f)); |
| | 213: } |
| | 214: else if ($src <= 0x10ffff) |
| | 215: { |
| | 216: $dest .= chr(0xf0 | ($src >> 18)); |
| | 217: $dest .= chr(0x80 | (($src >> 12) & 0x3f)); |
| | 218: $dest .= chr(0x80 | (($src >> 6) & 0x3f)); |
| | 219: $dest .= chr(0x80 | ($src & 0x3f)); |
| | 220: } |
| | 221: else |
| | 222: { |
| | 223: // out of range |
| | 224: return false; |
| | 225: } |
| | 226: |
| | 227: return $dest; |
| | 228: } |
| | 229: |
| | 230: |
| | 231: // |
| | 232: // Attempts to convert $str from $old_charset to UTF-8. Also converts HTML entities (including numeric entities) to UTF-8 characters |
| | 233: // |
| | 234: function convert_to_utf8(&$str, $old_charset) |
| | 235: { |
| | 236: if ($str === null || $str == '') |
| | 237: return false; |
| | 238: |
| | 239: $save = $str; |
| | 240: |
| | 241: // Replace literal entities (for non-UTF-8 compliant html_entity_encode) |
| | 242: if (version_compare(PHP_VERSION, '5.0.0', '<') && $old_charset == 'ISO-8859-1' || $old_charset == 'ISO-8859-15') |
| | 243: $str = html_entity_decode($str, ENT_QUOTES, $old_charset); |
| | 244: |
| | 245: if ($old_charset != 'UTF-8' && !seems_utf8($str)) |
| | 246: { |
| | 247: if (function_exists('iconv')) |
| | 248: $str = iconv($old_charset == 'ISO-8859-1' ? 'WINDOWS-1252' : 'ISO-8859-1', 'UTF-8', $str); |
| | 249: else if (function_exists('mb_convert_encoding')) |
| | 250: $str = mb_convert_encoding($str, 'UTF-8', $old_charset == 'ISO-8859-1' ? 'WINDOWS-1252' : 'ISO-8859-1'); |
| | 251: else if ($old_charset == 'ISO-8859-1') |
| | 252: $str = utf8_encode($str); |
| | 253: } |
| | 254: |
| | 255: // Replace literal entities (for UTF-8 compliant html_entity_encode) |
| | 256: if (version_compare(PHP_VERSION, '5.0.0', '>=')) |
| | 257: $str = html_entity_decode($str, ENT_QUOTES, 'UTF-8'); |
| | 258: |
| | 259: // Replace numeric entities |
| | 260: $str = preg_replace_callback('/&#([0-9]+);/', 'utf8_callback_1', $str); |
| | 261: $str = preg_replace_callback('/&#x([a-f0-9]+);/i', 'utf8_callback_2', $str); |
| | 262: |
| | 263: // Remove "bad" characters |
| | 264: $str = remove_bad_characters($str); |
| | 265: |
| | 266: return ($save != $str); |
| | 267: } |
| | 268: |
| | 269: |
| | 270: function utf8_callback_1($matches) |
| | 271: { |
| | 272: return dcr2utf8($matches[1]); |
| | 273: } |
| | 274: |
| | 275: |
| | 276: function utf8_callback_2($matches) |
| | 277: { |
| | 278: return dcr2utf8(hexdec($matches[1])); |
| | 279: } |
| | 280: |
| | 281: |
| | 282: // |
| | 283: // Alter a table to be utf8. MySQL only |
| | 284: // Function based on update_convert_table_utf8() from the Drupal project (http://drupal.org/) |
| | 285: // |
| | 286: function alter_table_utf8($table) |
| | 287: { |
| | 288: global $mysql, $db; |
| | 289: static $types; |
| | 290: |
| | 291: if (!$mysql) |
| | 292: return; |
| | 293: |
| | 294: if (!isset($types)) |
| | 295: { |
| | 296: $types = array( |
| | 297: 'char' => 'binary', |
| | 298: 'varchar' => 'varbinary', |
| | 299: 'tinytext' => 'tinyblob', |
| | 300: 'mediumtext' => 'mediumblob', |
| | 301: 'text' => 'blob', |
| | 302: 'longtext' => 'longblob' |
| | 303: ); |
| | 304: } |
| | 305: |
| | 306: // Set table default charset to utf8 |
| | 307: $db->query('ALTER TABLE '.$table.' CHARACTER SET utf8') or error('Unable to set table character set', __FILE__, __LINE__, $db->error()); |
| | 308: |
| | 309: // Find out which columns need converting and build SQL statements |
| | 310: $result = $db->query('SHOW FULL COLUMNS FROM '.$table) or error('Unable to fetch column information', __FILE__, __LINE__, $db->error()); |
| | 311: while ($cur_column = $db->fetch_assoc($result)) |
| | 312: { |
| | 313: if ($cur_column['Collation'] === null) |
| | 314: continue; |
| | 315: |
| | 316: list($type) = explode('(', $cur_column['Type']); |
| | 317: if (isset($types[$type]) && strpos($cur_column['Collation'], 'utf8') === false) |
| | 318: { |
| | 319: $allow_null = ($cur_column['Null'] == 'YES'); |
| | 320: $collate = (substr($cur_column['Collation'], -3) == 'bin') ? 'utf8_bin' : 'utf8_general_ci'; |
| | 321: |
| | 322: $db->alter_field($table, $cur_column['Field'], preg_replace('/'.$type.'/i', $types[$type], $cur_column['Type']), $allow_null, $cur_column['Default'], null, true) or error('Unable to alter field to binary', __FILE__, __LINE__, $db->error()); |
| | 323: $db->alter_field($table, $cur_column['Field'], $cur_column['Type'].' CHARACTER SET utf8 COLLATE '.$collate, $allow_null, $cur_column['Default'], null, true) or error('Unable to alter field to utf8', __FILE__, __LINE__, $db->error()); |
| | 324: } |
| | 325: } |
| | 326: } |
| | 327: |
| | 328: // |
| | 329: // Safely converts text type columns into utf8 |
| | 330: // If finished returns true, otherwise returns $end_at |
| | 331: // |
| | 332: function convert_table_utf8($table, $callback, $old_charset, $key = null, $start_at = null) |
| | 333: { |
| | 334: global $mysql, $db, $old_connection_charset; |
| | 335: |
| | 336: $finished = true; |
| | 337: $end_at = 0; |
| | 338: if ($mysql) |
| | 339: { |
| | 340: // Only set up the tables if we are doing this in 1 go, or its the first go |
| | 341: if ($start_at === null || $start_at == 0) |
| | 342: { |
| | 343: // Drop any temp table that exists, in-case it's left over from a failed update |
| | 344: $db->drop_table($table.'_utf8', true) or error('Unable to drop left over temp table', __FILE__, __LINE__, $db->error()); |
| | 345: |
| | 346: // Copy the table |
| | 347: $db->query('CREATE TABLE '.$table.'_utf8 LIKE '.$table) or error('Unable to create new table', __FILE__, __LINE__, $db->error()); |
| | 348: |
| | 349: // Set table default charset to utf8 |
| | 350: alter_table_utf8($table.'_utf8'); |
| | 351: } |
| | 352: |
| | 353: // Change to the old character set so MySQL doesn't attempt to perform conversion on the data from the old table |
| | 354: $db->set_names($old_connection_charset); |
| | 355: |
| | 356: // Move & Convert everything |
| | 357: $result = $db->query('SELECT * FROM '.$table.($start_at === null ? '' : ' WHERE '.$key.'>'.$start_at).' ORDER BY '.$key.' ASC'.($start_at === null ? '' : ' LIMIT '.PER_PAGE), false) or error('Unable to select from old table', __FILE__, __LINE__, $db->error()); |
| | 358: |
| | 359: // Change back to utf8 mode so we can insert it into the new table |
| | 360: $db->set_names('utf8'); |
| | 361: |
| | 362: while ($cur_item = $db->fetch_assoc($result)) |
| | 363: { |
| | 364: $cur_item = call_user_func($callback, $cur_item, $old_charset); |
| | 365: |
| | 366: $temp = array(); |
| | 367: foreach ($cur_item as $idx => $value) |
| | 368: $temp[$idx] = $value === null ? 'NULL' : '\''.$db->escape($value).'\''; |
| | 369: |
| | 370: $db->query('INSERT INTO '.$table.'_utf8('.implode(',', array_keys($temp)).') VALUES ('.implode(',', array_values($temp)).')') or error('Unable to insert data to new table', __FILE__, __LINE__, $db->error()); |
| | 371: |
| | 372: $end_at = $cur_item[$key]; |
| | 373: } |
| | 374: |
| | 375: // If we aren't doing this all in 1 go and $end_at has a value (i.e. we have processed at least 1 row), figure out if we have more to do or not |
| | 376: if ($start_at !== null && $end_at > 0) |
| | 377: { |
| | 378: $result = $db->query('SELECT 1 FROM '.$table.' WHERE '.$key.'>'.$end_at.' ORDER BY '.$key.' ASC LIMIT 1') or error('Unable to check for next row', __FILE__, __LINE__, $db->error()); |
| | 379: $finished = $db->num_rows($result) == 0; |
| | 380: } |
| | 381: |
| | 382: // Only swap the tables if we are doing this in 1 go, or its the last go |
| | 383: if ($finished) |
| | 384: { |
| | 385: // Delete old table |
| | 386: $db->drop_table($table, true) or error('Unable to drop old table', __FILE__, __LINE__, $db->error()); |
| | 387: |
| | 388: // Rename table |
| | 389: $db->query('ALTER TABLE '.$table.'_utf8 RENAME '.$table) or error('Unable to rename new table', __FILE__, __LINE__, $db->error()); |
| | 390: |
| | 391: return true; |
| | 392: } |
| | 393: |
| | 394: return $end_at; |
| | 395: } |
| | 396: else |
| | 397: { |
| | 398: // Convert everything |
| | 399: $result = $db->query('SELECT * FROM '.$table.($start_at === null ? '' : ' WHERE '.$key.'>'.$start_at).' ORDER BY '.$key.' ASC'.($start_at === null ? '' : ' LIMIT '.PER_PAGE)) or error('Unable to select from table', __FILE__, __LINE__, $db->error()); |
| | 400: while ($cur_item = $db->fetch_assoc($result)) |
| | 401: { |
| | 402: $cur_item = call_user_func($callback, $cur_item, $old_charset); |
| | 403: |
| | 404: $temp = array(); |
| | 405: foreach ($cur_item as $idx => $value) |
| | 406: $temp[] = $idx.'='.($value === null ? 'NULL' : '\''.$db->escape($value).'\''); |
| | 407: |
| | 408: if (!empty($temp)) |
| | 409: $db->query('UPDATE '.$table.' SET '.implode(', ', $temp).' WHERE '.$key.'=\''.$db->escape($cur_item[$key]).'\'') or error('Unable to update data', __FILE__, __LINE__, $db->error()); |
| | 410: |
| | 411: $end_at = $cur_item[$key]; |
| | 412: } |
| | 413: |
| | 414: if ($start_at !== null && $end_at > 0) |
| | 415: { |
| | 416: $result = $db->query('SELECT 1 FROM '.$table.' WHERE '.$key.'>'.$end_at.' ORDER BY '.$key.' ASC LIMIT 1') or error('Unable to check for next row', __FILE__, __LINE__, $db->error()); |
| | 417: if ($db->num_rows($result) == 0) |
| | 418: return true; |
| | 419: |
| | 420: return $end_at; |
| | 421: } |
| | 422: |
| | 423: return true; |
| | 424: } |
| | 425: } |
| | 426: |
| | 427: |
| | 428: header('Content-type: text/html; charset=utf-8'); |
| | 429: |
| | 430: // Empty all output buffers and stop buffering |
| | 431: while (@ob_end_clean()); |
| | 432: |
| | 433: |
| | 434: $stage = isset($_GET['stage']) ? $_GET['stage'] : ''; |
| | 435: $old_charset = isset($_GET['req_old_charset']) ? str_replace('ISO8859', 'ISO-8859', strtoupper($_GET['req_old_charset'])) : 'ISO-8859-1'; |
| | 436: $start_at = isset($_GET['start_at']) ? intval($_GET['start_at']) : 0; |
| | 437: $query_str = ''; |
| | 438: |
| | 439: switch ($stage) |
| | 440: { |
| | 441: // Show form |
| | 442: case '': |
| | 443: |
| | 444: ?> |
| | 445: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| | 446: |
| | 447: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> |
| | 448: <head> |
| | 449: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| | 450: <title>FluxBB Database Update</title> |
| | 451: <link rel="stylesheet" type="text/css" href="style/<?php echo $default_style ?>.css" /> |
| | 452: </head> |
| | 453: <body> |
| | 454: |
| | 455: <div id="pundb_update" class="pun"> |
| | 456: <div class="top-box"><div><!-- Top Corners --></div></div> |
| | 457: <div class="punwrap"> |
| | 458: |
| | 459: <div class="blockform"> |
| | 460: <h2><span>FluxBB Update</span></h2> |
| | 461: <div class="box"> |
| | 462: <form method="get" action="<?php echo pun_htmlspecialchars($_SERVER['REQUEST_URI']) ?>" onsubmit="this.start.disabled=true"> |
| | 463: <input type="hidden" name="stage" value="start" /> |
| | 464: <div class="inform"> |
| | 465: <div class="forminfo"> |
| | 466: <p style="font-size: 1.1em">This script will update your forum database. The update procedure might take anything from a second to hours depending on the speed of the server and the size of the forum database. Don't forget to make a backup of the database before continuing.</p> |
| | 467: <p style="font-size: 1.1em">Did you read the update instructions in the documentation? If not, start there.</p> |
| | 468: <?php |
| | 469: |
| | 470: if (strpos($cur_version, '1.2') === 0) |
| | 471: { |
| | 472: if (!function_exists('iconv') && !function_exists('mb_convert_encoding')) |
| | 473: { |
| | 474: |
| | 475: ?> |
| | 476: <p style="font-size: 1.1em"><strong>IMPORTANT!</strong> FluxBB has detected that this PHP environment does not have support for the encoding mechanisms required to do UTF-8 conversion from character sets other than ISO-8859-1. What this means is that if the current character set is not ISO-8859-1, FluxBB won't be able to convert your forum database to UTF-8 and you will have to do it manually. Instructions for doing manual charset conversion can be found in the update instructions.</p> |
| | 477: <?php |
| | 478: |
| | 479: } |
| | 480: |
| | 481: ?> |
| | 482: </div> |
| | 483: </div> |
| | 484: <div class="inform"> |
| | 485: <div class="forminfo"> |
| | 486: <p style="font-size: 1.1em"><strong>Enable conversion:</strong> When enabled this update script will, after it has made the required structural changes to the database, convert all text in the database from the current character set to UTF-8. This conversion is required if you're upgrading from version 1.2.</p> |
| | 487: <p style="font-size: 1.1em"><strong>Current character set:</strong> If the primary language in your forum is English, you can leave this at the default value. However, if your forum is non-English, you should enter the character set of the primary language pack used in the forum. <i>Getting this wrong can corrupt your database so don't just guess!</i> Note: This is required even if the old database is UTF-8.</p> |
| | 488: </div> |
| | 489: <fieldset> |
| | 490: <legend>Charset conversion</legend> |
| | 491: <div class="infldset"> |
| | 492: <div class="rbox"> |
| | 493: <label><input type="checkbox" name="convert_charset" value="1" checked="checked" /><strong>Enable conversion</strong> (perform database charset conversion).<br /></label> |
| | 494: </div> |
| | 495: <label> |
| | 496: <strong>Current character set</strong><br />Accept default for English forums otherwise the character set of the primary language pack.<br /> |
| | 497: <input type="text" name="req_old_charset" size="12" maxlength="20" value="<?php echo $old_charset ?>" /><br /> |
| | 498: </label> |
| | 499: </div> |
| | 500: </fieldset> |
| | 501: <?php |
| | 502: |
| | 503: } |
| | 504: else |
| | 505: echo "\t\t\t\t".'</div>'."\n"; |
| | 506: |
| | 507: ?> |
| | 508: </div> |
| | 509: <p class="buttons"><input type="submit" name="start" value="Start update" /></p> |
| | 510: </form> |
| | 511: </div> |
| | 512: </div> |
| | 513: |
| | 514: </div> |
| | 515: <div class="end-box"><div><!-- Bottom Corners --></div></div> |
| | 516: </div> |
| | 517: |
| | 518: </body> |
| | 519: </html> |
| | 520: <?php |
| | 521: |
| | 522: break; |
| | 523: |
| | 524: |
| | 525: // Start by updating the database structure |
| | 526: case 'start': |
| | 527: $query_str = '?stage=preparse_posts'; |
| | 528: |
| | 529: // If we don't need to update the database, skip this stage |
| | 530: if (isset($pun_config['o_database_revision']) && $pun_config['o_database_revision'] >= UPDATE_TO_DB_REVISION) |
| | 531: break; |
| | 532: |
| | 533: // Make all email fields VARCHAR(80) |
| | 534: $db->alter_field('bans', 'email', 'VARCHAR(80)', true) or error('Unable to alter email field', __FILE__, __LINE__, $db->error()); |
| | 535: $db->alter_field('posts', 'poster_email', 'VARCHAR(80)', true) or error('Unable to alter poster_email field', __FILE__, __LINE__, $db->error()); |
| | 536: $db->alter_field('users', 'email', 'VARCHAR(80)', false, '') or error('Unable to alter email field', __FILE__, __LINE__, $db->error()); |
| | 537: $db->alter_field('users', 'jabber', 'VARCHAR(80)', true) or error('Unable to alter jabber field', __FILE__, __LINE__, $db->error()); |
| | 538: $db->alter_field('users', 'msn', 'VARCHAR(80)', true) or error('Unable to alter msn field', __FILE__, __LINE__, $db->error()); |
| | 539: $db->alter_field('users', 'activate_string', 'VARCHAR(80)', true) or error('Unable to alter activate_string field', __FILE__, __LINE__, $db->error()); |
| | 540: |
| | 541: // Make all IP fields VARCHAR(39) to support IPv6 |
| | 542: $db->alter_field('posts', 'poster_ip', 'VARCHAR(39)', true) or error('Unable to alter poster_ip field', __FILE__, __LINE__, $db->error()); |
| | 543: $db->alter_field('users', 'registration_ip', 'VARCHAR(39)', false, '0.0.0.0') or error('Unable to alter registration_ip field', __FILE__, __LINE__, $db->error()); |
| | 544: |
| | 545: // Add the DST option to the users table |
| | 546: $db->add_field('users', 'dst', 'TINYINT(1)', false, 0, 'timezone') or error('Unable to add dst field', __FILE__, __LINE__, $db->error()); |
| | 547: |
| | 548: // Add the last_post field to the online table |
| | 549: $db->add_field('online', 'last_post', 'INT(10) UNSIGNED', true, null, null) or error('Unable to add last_post field', __FILE__, __LINE__, $db->error()); |
| | 550: |
| | 551: // Add the last_search field to the online table |
| | 552: $db->add_field('online', 'last_search', 'INT(10) UNSIGNED', true, null, null) or error('Unable to add last_search field', __FILE__, __LINE__, $db->error()); |
| | 553: |
| | 554: // Add the last_search column to the users table |
| | 555: $db->add_field('users', 'last_search', 'INT(10) UNSIGNED', true, null, 'last_post') or error('Unable to add last_search field', __FILE__, __LINE__, $db->error()); |
| | 556: |
| | 557: // Drop use_avatar column from users table |
| | 558: $db->drop_field('users', 'use_avatar') or error('Unable to drop use_avatar field', __FILE__, __LINE__, $db->error()); |
| | 559: |
| | 560: // Drop save_pass column from users table |
| | 561: $db->drop_field('users', 'save_pass') or error('Unable to drop save_pass field', __FILE__, __LINE__, $db->error()); |
| | 562: |
| | 563: // Drop g_edit_subjects_interval column from groups table |
| | 564: $db->drop_field('groups', 'g_edit_subjects_interval'); |
| | 565: |
| | 566: // Add database revision number |
| | 567: if (!array_key_exists('o_database_revision', $pun_config)) |
| | 568: $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_database_revision\', \'0\')') or error('Unable to insert config value \'o_database_revision\'', __FILE__, __LINE__, $db->error()); |
| | 569: |
| | 570: // Add search index revision number |
| | 571: if (!array_key_exists('o_searchindex_revision', $pun_config)) |
| | 572: $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_searchindex_revision\', \'0\')') or error('Unable to insert config value \'o_searchindex_revision\'', __FILE__, __LINE__, $db->error()); |
| | 573: |
| | 574: // Add parser revision number |
| | 575: if (!array_key_exists('o_parser_revision', $pun_config)) |
| | 576: $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_parser_revision\', \'0\')') or error('Unable to insert config value \'o_parser_revision\'', __FILE__, __LINE__, $db->error()); |
| | 577: |
| | 578: // Add default email setting option |
| | 579: if (!array_key_exists('o_default_email_setting', $pun_config)) |
| | 580: $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_default_email_setting\', \'1\')') or error('Unable to insert config value \'o_default_email_setting\'', __FILE__, __LINE__, $db->error()); |
| | 581: |
| | 582: // Make sure we have o_additional_navlinks (was added in 1.2.1) |
| | 583: if (!array_key_exists('o_additional_navlinks', $pun_config)) |
| | 584: $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_additional_navlinks\', \'\')') or error('Unable to insert config value \'o_additional_navlinks\'', __FILE__, __LINE__, $db->error()); |
| | 585: |
| | 586: // Insert new config option o_topic_views |
| | 587: if (!array_key_exists('o_topic_views', $pun_config)) |
| | 588: $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_topic_views\', \'1\')') or error('Unable to insert config value \'o_topic_views\'', __FILE__, __LINE__, $db->error()); |
| | 589: |
| | 590: // Insert new config option o_signatures |
| | 591: if (!array_key_exists('o_signatures', $pun_config)) |
| | 592: $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_signatures\', \'1\')') or error('Unable to insert config value \'o_signatures\'', __FILE__, __LINE__, $db->error()); |
| | 593: |
| | 594: // Insert new config option o_smtp_ssl |
| | 595: if (!array_key_exists('o_smtp_ssl', $pun_config)) |
| | 596: $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_smtp_ssl\', \'0\')') or error('Unable to insert config value \'o_smtp_ssl\'', __FILE__, __LINE__, $db->error()); |
| | 597: |
| | 598: // Insert new config option o_default_dst |
| | 599: if (!array_key_exists('o_default_dst', $pun_config)) |
| | 600: $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_default_dst\', \'0\')') or error('Unable to insert config value \'o_default_dst\'', __FILE__, __LINE__, $db->error()); |
| | 601: |
| | 602: // Insert new config option o_quote_depth |
| | 603: if (!array_key_exists('o_quote_depth', $pun_config)) |
| | 604: $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_quote_depth\', \'3\')') or error('Unable to insert config value \'o_quote_depth\'', __FILE__, __LINE__, $db->error()); |
| | 605: |
| | 606: // Insert new config option o_feed_type |
| | 607: if (!array_key_exists('o_feed_type', $pun_config)) |
| | 608: $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_feed_type\', \'2\')') or error('Unable to insert config value \'o_feed_type\'', __FILE__, __LINE__, $db->error()); |
| | 609: |
| | 610: // Insert config option o_base_url which was removed in 1.3 |
| | 611: if (!array_key_exists('o_base_url', $pun_config)) |
| | 612: { |
| | 613: // If it isn't in $pun_config['o_base_url'] it should be in $base_url, but just in-case it isn't we can make a guess at it |
| | 614: if (!isset($base_url)) |
| | 615: { |
| | 616: // Make an educated guess regarding base_url |
| | 617: $base_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; // protocol |
| | 618: $base_url .= preg_replace('/:(80|443)$/', '', $_SERVER['HTTP_HOST']); // host[:port] |
| | 619: $base_url .= str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])); // path |
| | 620: } |
| | 621: |
| | 622: if (substr($base_url, -1) == '/') |
| | 623: $base_url = substr($base_url, 0, -1); |
| | 624: |
| | 625: $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\'o_base_url\', \''.$db->escape($base_url).'\')') or error('Unable to insert config value \'o_quote_depth\'', __FILE__, __LINE__, $db->error()); |
| | 626: } |
| | 627: |
| | 628: if (strpos($cur_version, '1.2') === 0) |
| | 629: { |
| | 630: // Groups are almost the same as 1.2: |
| | 631: // unverified: 32000 -> 0 |
| | 632: |
| | 633: $db->query('UPDATE '.$db->prefix.'users SET group_id = 0 WHERE group_id = 32000') or error('Unable to update unverified users', __FILE__, __LINE__, $db->error()); |
| | 634: } |
| | 635: else if (strpos($cur_version, '1.3') === 0) |
| | 636: { |
| | 637: // Groups have changed quite a lot from 1.3: |
| | 638: // unverified: 0 -> 0 |
| | 639: // admin: 1 -> 1 |
| | 640: // mod: ? -> 2 |
| | 641: // guest: 2 -> 3 |
| | 642: // member: ? -> 4 |
| | 643: |
| | 644: $result = $db->query('SELECT MAX(g_id) + 1 FROM '.$db->prefix.'groups') or error('Unable to select temp group ID', __FILE__, __LINE__, $db->error()); |
| | 645: $temp_id = $db->result($result); |
| | 646: |
| | 647: $result = $db->query('SELECT g_id FROM '.$db->prefix.'groups WHERE g_moderator = 1 AND g_id > 1 LIMIT 1') or error('Unable to select moderator group', __FILE__, __LINE__, $db->error()); |
| | 648: if ($db->num_rows($result)) |
| | 649: $mod_gid = $db->result($result); |
| | 650: else |
| | 651: { |
| | 652: $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) VALUES('."'Moderators', 'Moderator', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0)") or error('Unable to add group', __FILE__, __LINE__, $db->error()); |
| | 653: $mod_gid = $db->insert_id(); |
| | 654: } |
| | 655: |
| | 656: $member_gid = $pun_config['o_default_user_group']; |
| | 657: |
| | 658: // move the mod group to a temp place |
| | 659: $db->query('UPDATE '.$db->prefix.'groups SET g_id = '.$temp_id.' WHERE g_id = '.$mod_gid) or error('Unable to update group ID', __FILE__, __LINE__, $db->error()); |
| | 660: $db->query('UPDATE '.$db->prefix.'users SET group_id = '.$temp_id.' WHERE group_id = '.$mod_gid) or error('Unable to update users group ID', __FILE__, __LINE__, $db->error()); |
| | 661: $db->query('UPDATE '.$db->prefix.'forum_perms SET group_id = '.$temp_id.' WHERE group_id = '.$mod_gid) or error('Unable to forum_perms group ID', __FILE__, __LINE__, $db->error()); |
| | 662: if ($member_gid == $mod_gid) $member_gid = $temp_id; |
| | 663: |
| | 664: // move whoever is in 3 to a spare slot |
| | 665: $db->query('UPDATE '.$db->prefix.'groups SET g_id = '.$mod_gid.' WHERE g_id = 3') or error('Unable to update group ID', __FILE__, __LINE__, $db->error()); |
| | 666: $db->query('UPDATE '.$db->prefix.'users SET group_id = '.$mod_gid.' WHERE group_id = 3') or error('Unable to update users group ID', __FILE__, __LINE__, $db->error()); |
| | 667: $db->query('UPDATE '.$db->prefix.'forum_perms SET group_id = '.$mod_gid.' WHERE group_id = 3') or error('Unable to forum_perms group ID', __FILE__, __LINE__, $db->error()); |
| | 668: if ($member_gid == 3) $member_gid = $mod_gid; |
| | 669: |
| | 670: // move guest to 3 |
| | 671: $db->query('UPDATE '.$db->prefix.'groups SET g_id = 3 WHERE g_id = 2') or error('Unable to update group ID', __FILE__, __LINE__, $db->error()); |
| | 672: $db->query('UPDATE '.$db->prefix.'users SET group_id = 3 WHERE group_id = 2') or error('Unable to update users group ID', __FILE__, __LINE__, $db->error()); |
| | 673: $db->query('UPDATE '.$db->prefix.'forum_perms SET group_id = 3 WHERE group_id = 2') or error('Unable to forum_perms group ID', __FILE__, __LINE__, $db->error()); |
| | 674: if ($member_gid == 2) $member_gid = 3; |
| | 675: |
| | 676: // move mod group in temp place to 2 |
| | 677: $db->query('UPDATE '.$db->prefix.'groups SET g_id = 2 WHERE g_id = '.$temp_id) or error('Unable to update group ID', __FILE__, __LINE__, $db->error()); |
| | 678: $db->query('UPDATE '.$db->prefix.'users SET group_id = 2 WHERE group_id = '.$temp_id) or error('Unable to update users group ID', __FILE__, __LINE__, $db->error()); |
| | 679: $db->query('UPDATE '.$db->prefix.'forum_perms SET group_id = 2 WHERE group_id = '.$temp_id) or error('Unable to forum_perms group ID', __FILE__, __LINE__, $db->error()); |
| | 680: if ($member_gid == $temp_id) $member_gid = 2; |
| | 681: |
| | 682: // Only move stuff around if it isn't already in the right place |
| | 683: if ($member_gid != $mod_gid || $member_gid != 4) |
| | 684: { |
| | 685: // move members to temp place |
| | 686: $db->query('UPDATE '.$db->prefix.'groups SET g_id = '.$temp_id.' WHERE g_id = '.$member_gid) or error('Unable to update group ID', __FILE__, __LINE__, $db->error()); |
| | 687: $db->query('UPDATE '.$db->prefix.'users SET group_id = '.$temp_id.' WHERE group_id = '.$member_gid) or error('Unable to update users group ID', __FILE__, __LINE__, $db->error()); |
| | 688: $db->query('UPDATE '.$db->prefix.'forum_perms SET group_id = '.$temp_id.' WHERE group_id = '.$member_gid) or error('Unable to forum_perms group ID', __FILE__, __LINE__, $db->error()); |
| | 689: |
| | 690: // move whoever is in 4 to members place |
| | 691: $db->query('UPDATE '.$db->prefix.'groups SET g_id = '.$member_gid.' WHERE g_id = 4') or error('Unable to update group ID', __FILE__, __LINE__, $db->error()); |
| | 692: $db->query('UPDATE '.$db->prefix.'users SET group_id = '.$member_gid.' WHERE group_id = 4') or error('Unable to update users group ID', __FILE__, __LINE__, $db->error()); |
| | 693: $db->query('UPDATE '.$db->prefix.'forum_perms SET group_id = '.$member_gid.' WHERE group_id = 4') or error('Unable to forum_perms group ID', __FILE__, __LINE__, $db->error()); |
| | 694: |
| | 695: // move members in temp place to 4 |
| | 696: $db->query('UPDATE '.$db->prefix.'groups SET g_id = 4 WHERE g_id = '.$temp_id) or error('Unable to update group ID', __FILE__, __LINE__, $db->error()); |
| | 697: $db->query('UPDATE '.$db->prefix.'users SET group_id = 4 WHERE group_id = '.$temp_id) or error('Unable to update users group ID', __FILE__, __LINE__, $db->error()); |
| | 698: $db->query('UPDATE '.$db->prefix.'forum_perms SET group_id = 4 WHERE group_id = '.$temp_id) or error('Unable to forum_perms group ID', __FILE__, __LINE__, $db->error()); |
| | 699: } |
| | 700: |
| | 701: $db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$member_gid.'\' WHERE conf_name=\'o_default_user_group\'') or error('Unable to update default user group ID', __FILE__, __LINE__, $db->error()); |
| | 702: } |
| | 703: |
| | 704: // Server time zone is now simply the default time zone |
| | 705: if (!array_key_exists('o_default_timezone', $pun_config)) |
| | 706: $db->query('UPDATE '.$db->prefix.'config SET conf_name = \'o_default_timezone\' WHERE conf_name = \'o_server_timezone\'') or error('Unable to update time zone config', __FILE__, __LINE__, $db->error()); |
| | 707: |
| | 708: // Increase visit timeout to 30 minutes (only if it hasn't been changed from the default) |
| | 709: if (!array_key_exists('o_database_revision', $pun_config) && $pun_config['o_timeout_visit'] == '600') |
| | 710: $db->query('UPDATE '.$db->prefix.'config SET conf_value = \'1800\' WHERE conf_name = \'o_timeout_visit\'') or error('Unable to update visit timeout config', __FILE__, __LINE__, $db->error()); |
| | 711: |
| | 712: // Remove obsolete g_post_polls permission from groups table |
| | 713: $db->drop_field('groups', 'g_post_polls'); |
| | 714: |
| | 715: // Make room for multiple moderator groups |
| | 716: if (!$db->field_exists('groups', 'g_moderator')) |
| | 717: { |
| | 718: // Add g_moderator column to groups table |
| | 719: $db->add_field('groups', 'g_moderator', 'TINYINT(1)', false, 0, 'g_user_title') or error('Unable to add g_moderator field', __FILE__, __LINE__, $db->error()); |
| | 720: |
| | 721: // Give the moderator group moderator privileges |
| | 722: $db->query('UPDATE '.$db->prefix.'groups SET g_moderator = 1 WHERE g_id = 2') or error('Unable to update moderator powers', __FILE__, __LINE__, $db->error()); |
| | 723: } |
| | 724: |
| | 725: // Replace obsolete p_mod_edit_users config setting with new per-group permission |
| | 726: if (array_key_exists('p_mod_edit_users', $pun_config)) |
| | 727: { |
| | 728: $db->query('DELETE FROM '.$db->prefix.'config WHERE conf_name = \'p_mod_edit_users\'') or error('Unable to update moderator powers', __FILE__, __LINE__, $db->error()); |
| | 729: |
| | 730: $db->add_field('groups', 'g_mod_edit_users', 'TINYINT(1)', false, 0, 'g_moderator') or error('Unable to add g_mod_edit_users field', __FILE__, __LINE__, $db->error()); |
| | 731: |
| | 732: $db->query('UPDATE '.$db->prefix.'groups SET g_mod_edit_users = '.$pun_config['p_mod_edit_users'].' WHERE g_moderator = 1') or error('Unable to update moderator powers', __FILE__, __LINE__, $db->error()); |
| | 733: } |
| | 734: |
| | 735: // Replace obsolete p_mod_rename_users config setting with new per-group permission |
| | 736: if (array_key_exists('p_mod_rename_users', $pun_config)) |
| | 737: { |
| | 738: $db->query('DELETE FROM '.$db->prefix.'config WHERE conf_name = \'p_mod_rename_users\'') or error('Unable to update moderator powers', __FILE__, __LINE__, $db->error()); |
| | 739: |
| | 740: $db->add_field('groups', 'g_mod_rename_users', 'TINYINT(1)', false, 0, 'g_mod_edit_users') or error('Unable to add g_mod_rename_users field', __FILE__, __LINE__, $db->error()); |
| | 741: |
| | 742: $db->query('UPDATE '.$db->prefix.'groups SET g_mod_rename_users = '.$pun_config['p_mod_rename_users'].' WHERE g_moderator = 1') or error('Unable to update moderator powers', __FILE__, __LINE__, $db->error()); |
| | 743: } |
| | 744: |
| | 745: // Replace obsolete p_mod_change_passwords config setting with new per-group permission |
| | 746: if (array_key_exists('p_mod_change_passwords', $pun_config)) |
| | 747: { |
| | 748: $db->query('DELETE FROM '.$db->prefix.'config WHERE conf_name = \'p_mod_change_passwords\'') or error('Unable to update moderator powers', __FILE__, __LINE__, $db->error()); |
| | 749: |
| | 750: $db->add_field('groups', 'g_mod_change_passwords', 'TINYINT(1)', false, 0, 'g_mod_rename_users') or error('Unable to add g_mod_change_passwords field', __FILE__, __LINE__, $db->error()); |
| | 751: |
| | 752: $db->query('UPDATE '.$db->prefix.'groups SET g_mod_change_passwords = '.$pun_config['p_mod_change_passwords'].' WHERE g_moderator = 1') or error('Unable to update moderator powers', __FILE__, __LINE__, $db->error()); |
| | 753: } |
| | 754: |
| | 755: // Replace obsolete p_mod_ban_users config setting with new per-group permission |
| | 756: if (array_key_exists('p_mod_ban_users', $pun_config)) |
| | 757: { |
| | 758: $db->query('DELETE FROM '.$db->prefix.'config WHERE conf_name = \'p_mod_ban_users\'') or error('Unable to update moderator powers', __FILE__, __LINE__, $db->error()); |
| | 759: |
| | 760: $db->add_field('groups', 'g_mod_ban_users', 'TINYINT(1)', false, 0, 'g_mod_change_passwords') or error('Unable to add g_mod_ban_users field', __FILE__, __LINE__, $db->error()); |
| | 761: |
| | 762: $db->query('UPDATE '.$db->prefix.'groups SET g_mod_ban_users = '.$pun_config['p_mod_ban_users'].' WHERE g_moderator = 1') or error('Unable to update moderator powers', __FILE__, __LINE__, $db->error()); |
| | 763: } |
| | 764: |
| | 765: // We need to add a unique index to avoid users having multiple rows in the online table |
| | 766: if (!$db->index_exists('online', 'user_id_ident_idx')) |
| | 767: { |
| | 768: $db->truncate_table('online') or error('Unable to clear online table', __FILE__, __LINE__, $db->error()); |
| | 769: |
| | 770: if ($mysql) |
| | 771: $db->add_index('online', 'user_id_ident_idx', array('user_id', 'ident(25)'), true) or error('Unable to add user_id_ident_idx index', __FILE__, __LINE__, $db->error()); |
| | 772: else |
| | 773: $db->add_index('online', 'user_id_ident_idx', array('user_id', 'ident'), true) or error('Unable to add user_id_ident_idx index', __FILE__, __LINE__, $db->error()); |
| | 774: } |
| | 775: |
| | 776: // Remove the redundant user_id_idx on the online table |
| | 777: $db->drop_index('online', 'user_id_idx') or error('Unable to drop user_id_idx index', __FILE__, __LINE__, $db->error()); |
| | 778: |
| | 779: // Add an index to ident on the online table |
| | 780: if ($mysql) |
| | 781: $db->add_index('online', 'ident_idx', array('ident(25)')) or error('Unable to add ident_idx index', __FILE__, __LINE__, $db->error()); |
| | 782: else |
| | 783: $db->add_index('online', 'ident_idx', array('ident')) or error('Unable to add ident_idx index', __FILE__, __LINE__, $db->error()); |
| | 784: |
| | 785: // Add an index to logged in the online table |
| | 786: $db->add_index('online', 'logged_idx', array('logged')) or error('Unable to add logged_idx index', __FILE__, __LINE__, $db->error()); |
| | 787: |
| | 788: // Add an index to last_post in the topics table |
| | 789: $db->add_index('topics', 'last_post_idx', array('last_post')) or error('Unable to add last_post_idx index', __FILE__, __LINE__, $db->error()); |
| | 790: |
| | 791: // Add an index to username on the bans table |
| | 792: if ($mysql) |
| | 793: $db->add_index('bans', 'username_idx', array('username(25)')) or error('Unable to add username_idx index', __FILE__, __LINE__, $db->error()); |
| | 794: else |
| | 795: $db->add_index('bans', 'username_idx', array('username')) or error('Unable to add username_idx index', __FILE__, __LINE__, $db->error()); |
| | 796: |
| | 797: // Change the username_idx on users to a unique index of max size 25 |
| | 798: $db->drop_index('users', 'username_idx') or error('Unable to drop old username_idx index', __FILE__, __LINE__, $db->error()); |
| | 799: $field = $mysql ? 'username(25)' : 'username'; |
| | 800: |
| | 801: // Attempt to add a unique index. If the user doesn't use a transactional database this can fail due to multiple matching usernames in the |
| | 802: // users table. This is bad, but just giving up if it happens is even worse! If it fails just add a regular non-unique index. |
| | 803: if (!$db->add_index('users', 'username_idx', array($field), true)) |
| | 804: $db->add_index('users', 'username_idx', array($field)) or error('Unable to add username_idx field', __FILE__, __LINE__, $db->error()); |
| | 805: |
| | 806: // Add g_view_users field to groups table |
| | 807: $db->add_field('groups', 'g_view_users', 'TINYINT(1)', false, 1, 'g_read_board') or error('Unable to add g_view_users field', __FILE__, __LINE__, $db->error()); |
| | 808: |
| | 809: // Add the last_email_sent column to the users table and the g_send_email and |
| | 810: // g_email_flood columns to the groups table |
| | 811: $db->add_field('users', 'last_email_sent', 'INT(10) UNSIGNED', true, null, 'last_search') or error('Unable to add last_email_sent field', __FILE__, __LINE__, $db->error()); |
| | 812: $db->add_field('groups', 'g_send_email', 'TINYINT(1)', false, 1, 'g_search_users') or error('Unable to add g_send_email field', __FILE__, __LINE__, $db->error()); |
| | 813: $db->add_field('groups', 'g_email_flood', 'SMALLINT(6)', false, 60, 'g_search_flood') or error('Unable to add g_email_flood field', __FILE__, __LINE__, $db->error()); |
| | 814: |
| | 815: // Set non-default g_send_email and g_flood_email values properly |
| | 816: $db->query('UPDATE '.$db->prefix.'groups SET g_send_email = 0 WHERE g_id = 3') or error('Unable to update group email permissions', __FILE__, __LINE__, $db->error()); |
| | 817: $db->query('UPDATE '.$db->prefix.'groups SET g_email_flood = 0 WHERE g_id IN (1,2,3)') or error('Unable to update group email permissions', __FILE__, __LINE__, $db->error()); |
| | 818: |
| | 819: // Add the auto notify/subscription option to the users table |
| | 820: $db->add_field('users', 'auto_notify', 'TINYINT(1)', false, 0, 'notify_with_post') or error('Unable to add auto_notify field', __FILE__, __LINE__, $db->error()); |
| | 821: |
| | 822: // Add the first_post_id column to the topics table |
| | 823: if (!$db->field_exists('topics', 'first_post_id')) |
| | 824: { |
| | 825: $db->add_field('topics', 'first_post_id', 'INT(10) UNSIGNED', false, 0, 'posted') or error('Unable to add first_post_id field', __FILE__, __LINE__, $db->error()); |
| | 826: $db->add_index('topics', 'first_post_id_idx', array('first_post_id')) or error('Unable to add first_post_id_idx index', __FILE__, __LINE__, $db->error()); |
| | 827: |
| | 828: // Now that we've added the column and indexed it, we need to give it correct data |
| | 829: $result = $db->query('SELECT MIN(id) AS first_post, topic_id FROM '.$db->prefix.'posts GROUP BY topic_id') or error('Unable to fetch first_post_id', __FILE__, __LINE__, $db->error()); |
| | 830: |
| | 831: while ($cur_post = $db->fetch_assoc($result)) |
| | 832: $db->query('UPDATE '.$db->prefix.'topics SET first_post_id = '.$cur_post['first_post'].' WHERE id = '.$cur_post['topic_id']) or error('Unable to update first_post_id', __FILE__, __LINE__, $db->error()); |
| | 833: } |
| | 834: |
| | 835: // Move any users with the old unverified status to their new group |
| | 836: $db->query('UPDATE '.$db->prefix.'users SET group_id=0 WHERE group_id=32000') or error('Unable to move unverified users', __FILE__, __LINE__, $db->error()); |
| | 837: |
| | 838: // Add the ban_creator column to the bans table |
| | 839: $db->add_field('bans', 'ban_creator', 'INT(10) UNSIGNED', false, 0) or error('Unable to add ban_creator field', __FILE__, __LINE__, $db->error()); |
| | 840: |
| | 841: // Add the time/date format settings to the user table |
| | 842: $db->add_field('users', 'time_format', 'TINYINT(1)', false, 0, 'dst') or error('Unable to add time_format field', __FILE__, __LINE__, $db->error()); |
| | 843: $db->add_field('users', 'date_format', 'TINYINT(1)', false, 0, 'dst') or error('Unable to add date_format field', __FILE__, __LINE__, $db->error()); |
| | 844: |
| | 845: // Change the search_data field to mediumtext |
| | 846: $db->alter_field('search_cache', 'search_data', 'MEDIUMTEXT', true) or error('Unable to alter search_data field', __FILE__, __LINE__, $db->error()); |
| | 847: |
| | 848: // Incase we had the fulltext search extension installed (1.3-legacy), remove it |
| | 849: $db->drop_index('topics', 'subject_idx') or error('Unable to drop subject_idx index', __FILE__, __LINE__, $db->error()); |
| | 850: $db->drop_index('posts', 'message_idx') or error('Unable to drop message_idx index', __FILE__, __LINE__, $db->error()); |
| | 851: |
| | 852: // If the search_cache table has been dropped by the fulltext search extension, recreate it |
| | 853: if (!$db->table_exists('search_cache')) |
| | 854: { |
| | 855: $schema = array( |
| | 856: 'FIELDS' => array( |
| | 857: 'id' => array( |
| | 858: 'datatype' => 'INT(10) UNSIGNED', |
| | 859: 'allow_null' => false, |
| | 860: 'default' => '0' |
| | 861: ), |
| | 862: 'ident' => array( |
| | 863: 'datatype' => 'VARCHAR(200)', |
| | 864: 'allow_null' => false, |
| | 865: 'default' => '\'\'' |
| | 866: ), |
| | 867: 'search_data' => array( |
| | 868: 'datatype' => 'MEDIUMTEXT', |
| | 869: 'allow_null' => true |
| | 870: ) |
| | 871: ), |
| | 872: 'PRIMARY KEY' => array('id'), |
| | 873: 'INDEXES' => array( |
| | 874: 'ident_idx' => array('ident') |
| | 875: ) |
| | 876: ); |
| | 877: |
| | 878: if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb') |
| | 879: $schema['INDEXES']['ident_idx'] = array('ident(8)'); |
| | 880: |
| | 881: $db->create_table('search_cache', $schema); |
| | 882: } |
| | 883: |
| | 884: // If the search_matches table has been dropped by the fulltext search extension, recreate it |
| | 885: if (!$db->table_exists('search_matches')) |
| | 886: { |
| | 887: $schema = array( |
| | 888: 'FIELDS' => array( |
| | 889: 'post_id' => array( |
| | 890: 'datatype' => 'INT(10) UNSIGNED', |
| | 891: 'allow_null' => false, |
| | 892: 'default' => '0' |
| | 893: ), |
| | 894: 'word_id' => array( |
| | 895: 'datatype' => 'INT(10) UNSIGNED', |
| | 896: 'allow_null' => false, |
| | 897: 'default' => '0' |
| | 898: ), |
| | 899: 'subject_match' => array( |
| | 900: 'datatype' => 'TINYINT(1)', |
| | 901: 'allow_null' => false, |
| | 902: 'default' => '0' |
| | 903: ) |
| | 904: ), |
| | 905: 'INDEXES' => array( |
| | 906: 'word_id_idx' => array('word_id'), |
| | 907: 'post_id_idx' => array('post_id') |
| | 908: ) |
| | 909: ); |
| | 910: |
| | 911: $db->create_table('search_matches', $schema); |
| | 912: } |
| | 913: |
| | 914: // If the search_words table has been dropped by the fulltext search extension, recreate it |
| | 915: if (!$db->table_exists('search_words')) |
| | 916: { |
| | 917: $schema = array( |
| | 918: 'FIELDS' => array( |
| | 919: 'id' => array( |
| | 920: 'datatype' => 'SERIAL', |
| | 921: 'allow_null' => false |
| | 922: ), |
| | 923: 'word' => array( |
| | 924: 'datatype' => 'VARCHAR(20)', |
| | 925: 'allow_null' => false, |
| | 926: 'default' => '\'\'', |
| | 927: 'collation' => 'bin' |
| | 928: ) |
| | 929: ), |
| | 930: 'PRIMARY KEY' => array('word'), |
| | 931: 'INDEXES' => array( |
| | 932: 'id_idx' => array('id') |
| | 933: ) |
| | 934: ); |
| | 935: |
| | 936: if ($db_type == 'sqlite') |
| | 937: { |
| | 938: $schema['PRIMARY KEY'] = array('id'); |
| | 939: $schema['UNIQUE KEYS'] = array('word_idx' => array('word')); |
| | 940: } |
| | 941: |
| | 942: $db->create_table('search_words', $schema); |
| | 943: } |
| | 944: |
| | 945: // Change the default style if the old doesn't exist anymore |
| | 946: if ($pun_config['o_default_style'] != $default_style) |
| | 947: $db->query('UPDATE '.$db->prefix.'config SET conf_value = \''.$db->escape($default_style).'\' WHERE conf_name = \'o_default_style\'') or error('Unable to update default style config', __FILE__, __LINE__, $db->error()); |
| | 948: |
| | 949: // Should we do charset conversion or not? |
| | 950: if (strpos($cur_version, '1.2') === 0 && isset($_GET['convert_charset'])) |
| | 951: $query_str = '?stage=conv_bans&req_old_charset='.$old_charset; |
| | 952: |
| | 953: break; |
| | 954: |
| | 955: |
| | 956: // Convert bans |
| | 957: case 'conv_bans': |
| | 958: $query_str = '?stage=conv_categories&req_old_charset='.$old_charset; |
| | 959: |
| | 960: function _conv_bans($cur_item, $old_charset) |
| | 961: { |
| | 962: echo 'Converting ban '.$cur_item['id'].' …<br />'."\n"; |
| | 963: |
| | 964: convert_to_utf8($cur_item['username'], $old_charset); |
| | 965: convert_to_utf8($cur_item['message'], $old_charset); |
| | 966: |
| | 967: return $cur_item; |
| | 968: } |
| | 969: |
| | 970: $end_at = convert_table_utf8($db->prefix.'bans', '_conv_bans', $old_charset, 'id', $start_at); |
| | 971: |
| | 972: if ($end_at !== true) |
| | 973: $query_str = '?stage=conv_bans&req_old_charset='.$old_charset.'&start_at='.$end_at; |
| | 974: |
| | 975: break; |
| | 976: |
| | 977: |
| | 978: // Convert categories |
| | 979: case 'conv_categories': |
| | 980: $query_str = '?stage=conv_censors&req_old_charset='.$old_charset; |
| | 981: |
| | 982: echo 'Converting categories …'."<br />\n"; |
| | 983: |
| | 984: function _conv_categories($cur_item, $old_charset) |
| | 985: { |
| | 986: convert_to_utf8($cur_item['cat_name'], $old_charset); |
| | 987: |
| | 988: return $cur_item; |
| | 989: } |
| | 990: |
| | 991: convert_table_utf8($db->prefix.'categories', '_conv_categories', $old_charset, 'id'); |
| | 992: |
| | 993: break; |
| | 994: |
| | 995: |
| | 996: // Convert censor words |
| | 997: case 'conv_censors': |
| | 998: $query_str = '?stage=conv_config&req_old_charset='.$old_charset; |
| | 999: |
| | 1000: echo 'Converting censor words …'."<br />\n"; |
| | 1001: |
| | 1002: function _conv_censoring($cur_item, $old_charset) |
| | 1003: { |
| | 1004: convert_to_utf8($cur_item['search_for'], $old_charset); |
| | 1005: convert_to_utf8($cur_item['replace_with'], $old_charset); |
| | 1006: |
| | 1007: return $cur_item; |
| | 1008: } |
| | 1009: |
| | 1010: convert_table_utf8($db->prefix.'censoring', '_conv_censoring', $old_charset, 'id'); |
| | 1011: |
| | 1012: break; |
| | 1013: |
| | 1014: |
| | 1015: // Convert config |
| | 1016: case 'conv_config': |
| | 1017: $query_str = '?stage=conv_forums&req_old_charset='.$old_charset; |
| | 1018: |
| | 1019: echo 'Converting configuration …'."<br />\n"; |
| | 1020: |
| | 1021: function _conv_config($cur_item, $old_charset) |
| | 1022: { |
| | 1023: convert_to_utf8($cur_item['conf_value'], $old_charset); |
| | 1024: |
| | 1025: return $cur_item; |
| | 1026: } |
| | 1027: |
| | 1028: convert_table_utf8($db->prefix.'config', '_conv_config', $old_charset, 'conf_name'); |
| | 1029: |
| | 1030: break; |
| | 1031: |
| | 1032: |
| | 1033: // Convert forums |
| | 1034: case 'conv_forums': |
| | 1035: $query_str = '?stage=conv_perms&req_old_charset='.$old_charset; |
| | 1036: |
| | 1037: echo 'Converting forums …'."<br />\n"; |
| | 1038: |
| | 1039: function _conv_forums($cur_item, $old_charset) |
| | 1040: { |
| | 1041: $moderators = ($cur_item['moderators'] != '') ? unserialize($cur_item['moderators']) : array(); |
| | 1042: $moderators_utf8 = array(); |
| | 1043: foreach ($moderators as $mod_username => $mod_user_id) |
| | 1044: { |
| | 1045: convert_to_utf8($mod_username, $old_charset); |
| | 1046: $moderators_utf8[$mod_username] = $mod_user_id; |
| | 1047: } |
| | 1048: |
| | 1049: convert_to_utf8($cur_item['forum_name'], $old_charset); |
| | 1050: convert_to_utf8($cur_item['forum_desc'], $old_charset); |
| | 1051: |
| | 1052: if (!empty($moderators_utf8)) |
| | 1053: $cur_item['moderators'] = serialize($moderators_utf8); |
| | 1054: |
| | 1055: return $cur_item; |
| | 1056: } |
| | 1057: |
| | 1058: convert_table_utf8($db->prefix.'forums', '_conv_forums', $old_charset, 'id'); |
| | 1059: |
| | 1060: break; |
| | 1061: |
| | 1062: |
| | 1063: // Convert forum permissions |
| | 1064: case 'conv_perms': |
| | 1065: $query_str = '?stage=conv_groups&req_old_charset='.$old_charset; |
| | 1066: |
| | 1067: alter_table_utf8($db->prefix.'forum_perms'); |
| | 1068: |
| | 1069: break; |
| | 1070: |
| | 1071: |
| | 1072: // Convert groups |
| | 1073: case 'conv_groups': |
| | 1074: $query_str = '?stage=conv_online&req_old_charset='.$old_charset; |
| | 1075: |
| | 1076: echo 'Converting groups …'."<br />\n"; |
| | 1077: |
| | 1078: function _conv_groups($cur_item, $old_charset) |
| | 1079: { |
| | 1080: convert_to_utf8($cur_item['g_title'], $old_charset); |
| | 1081: convert_to_utf8($cur_item['g_user_title'], $old_charset); |
| | 1082: |
| | 1083: return $cur_item; |
| | 1084: } |
| | 1085: |
| | 1086: convert_table_utf8($db->prefix.'groups', '_conv_groups', $old_charset, 'g_id'); |
| | 1087: |
| | 1088: break; |
| | 1089: |
| | 1090: |
| | 1091: // Convert online |
| | 1092: case 'conv_online': |
| | 1093: $query_str = '?stage=conv_posts&req_old_charset='.$old_charset; |
| | 1094: |
| | 1095: // Truncate the table |
| | 1096: $db->truncate_table('online') or error('Unable to empty online table', __FILE__, __LINE__, $db->error()); |
| | 1097: |
| | 1098: alter_table_utf8($db->prefix.'online'); |
| | 1099: |
| | 1100: break; |
| | 1101: |
| | 1102: |
| | 1103: // Convert posts |
| | 1104: case 'conv_posts': |
| | 1105: $query_str = '?stage=conv_ranks&req_old_charset='.$old_charset; |
| | 1106: |
| | 1107: function _conv_posts($cur_item, $old_charset) |
| | 1108: { |
| | 1109: echo 'Converting post '.$cur_item['id'].' …<br />'."\n"; |
| | 1110: |
| | 1111: convert_to_utf8($cur_item['poster'], $old_charset); |
| | 1112: convert_to_utf8($cur_item['message'], $old_charset); |
| | 1113: convert_to_utf8($cur_item['edited_by'], $old_charset); |
| | 1114: |
| | 1115: return $cur_item; |
| | 1116: } |
| | 1117: |
| | 1118: $end_at = convert_table_utf8($db->prefix.'posts', '_conv_posts', $old_charset, 'id', $start_at); |
| | 1119: |
| | 1120: if ($end_at !== true) |
| | 1121: $query_str = '?stage=conv_posts&req_old_charset='.$old_charset.'&start_at='.$end_at; |
| | 1122: |
| | 1123: break; |
| | 1124: |
| | 1125: |
| | 1126: // Convert ranks |
| | 1127: case 'conv_ranks': |
| | 1128: $query_str = '?stage=conv_reports&req_old_charset='.$old_charset; |
| | 1129: |
| | 1130: echo 'Converting ranks …'."<br />\n"; |
| | 1131: |
| | 1132: function _conv_ranks($cur_item, $old_charset) |
| | 1133: { |
| | 1134: convert_to_utf8($cur_item['rank'], $old_charset); |
| | 1135: |
| | 1136: return $cur_item; |
| | 1137: } |
| | 1138: |
| | 1139: convert_table_utf8($db->prefix.'ranks', '_conv_ranks', $old_charset, 'id'); |
| | 1140: |
| | 1141: break; |
| | 1142: |
| | 1143: |
| | 1144: // Convert reports |
| | 1145: case 'conv_reports': |
| | 1146: $query_str = '?stage=conv_search_cache&req_old_charset='.$old_charset; |
| | 1147: |
| | 1148: function _conv_reports($cur_item, $old_charset) |
| | 1149: { |
| | 1150: echo 'Converting report '.$cur_item['id'].' …<br />'."\n"; |
| | 1151: |
| | 1152: convert_to_utf8($cur_item['message'], $old_charset); |
| | 1153: |
| | 1154: return $cur_item; |
| | 1155: } |
| | 1156: |
| | 1157: $end_at = convert_table_utf8($db->prefix.'reports', '_conv_reports', $old_charset, 'id', $start_at); |
| | 1158: |
| | 1159: if ($end_at !== true) |
| | 1160: $query_str = '?stage=conv_reports&req_old_charset='.$old_charset.'&start_at='.$end_at; |
| | 1161: |
| | 1162: break; |
| | 1163: |
| | 1164: |
| | 1165: // Convert search cache |
| | 1166: case 'conv_search_cache': |
| | 1167: $query_str = '?stage=conv_search_matches&req_old_charset='.$old_charset; |
| | 1168: |
| | 1169: // Truncate the table |
| | 1170: $db->truncate_table('search_cache') or error('Unable to empty search cache table', __FILE__, __LINE__, $db->error()); |
| | 1171: |
| | 1172: alter_table_utf8($db->prefix.'search_cache'); |
| | 1173: |
| | 1174: break; |
| | 1175: |
| | 1176: |
| | 1177: // Convert search matches |
| | 1178: case 'conv_search_matches': |
| | 1179: $query_str = '?stage=conv_search_words&req_old_charset='.$old_charset; |
| | 1180: |
| | 1181: // Truncate the table |
| | 1182: $db->truncate_table('search_matches') or error('Unable to empty search index match table', __FILE__, __LINE__, $db->error()); |
| | 1183: |
| | 1184: alter_table_utf8($db->prefix.'search_matches'); |
| | 1185: |
| | 1186: break; |
| | 1187: |
| | 1188: |
| | 1189: // Convert search words |
| | 1190: case 'conv_search_words': |
| | 1191: $query_str = '?stage=conv_subscriptions&req_old_charset='.$old_charset; |
| | 1192: |
| | 1193: // Truncate the table |
| | 1194: $db->truncate_table('search_words') or error('Unable to empty search index words table', __FILE__, __LINE__, $db->error()); |
| | 1195: |
| | 1196: // Reset the sequence for the search words (not needed for SQLite) |
| | 1197: switch ($db_type) |
| | 1198: { |
| | 1199: case 'mysql': |
| | 1200: case 'mysqli': |
| | 1201: case 'mysql_innodb': |
| | 1202: case 'mysqli_innodb': |
| | 1203: $db->query('ALTER TABLE '.$db->prefix.'search_words auto_increment=1') or error('Unable to update table auto_increment', __FILE__, __LINE__, $db->error()); |
| | 1204: break; |
| | 1205: |
| | 1206: case 'pgsql'; |
| | 1207: $db->query('SELECT setval(\''.$db->prefix.'search_words_id_seq\', 1, false)') or error('Unable to update sequence', __FILE__, __LINE__, $db->error()); |
| | 1208: break; |
| | 1209: } |
| | 1210: |
| | 1211: alter_table_utf8($db->prefix.'search_words'); |
| | 1212: |
| | 1213: break; |
| | 1214: |
| | 1215: |
| | 1216: // Convert subscriptions |
| | 1217: case 'conv_subscriptions': |
| | 1218: $query_str = '?stage=conv_topics&req_old_charset='.$old_charset; |
| | 1219: |
| | 1220: alter_table_utf8($db->prefix.'subscriptions'); |
| | 1221: |
| | 1222: break; |
| | 1223: |
| | 1224: |
| | 1225: // Convert topics |
| | 1226: case 'conv_topics': |
| | 1227: $query_str = '?stage=conv_users&req_old_charset='.$old_charset; |
| | 1228: |
| | 1229: function _conv_topics($cur_item, $old_charset) |
| | 1230: { |
| | 1231: echo 'Converting topic '.$cur_item['id'].' …<br />'."\n"; |
| | 1232: |
| | 1233: convert_to_utf8($cur_item['poster'], $old_charset); |
| | 1234: convert_to_utf8($cur_item['subject'], $old_charset); |
| | 1235: convert_to_utf8($cur_item['last_poster'], $old_charset); |
| | 1236: |
| | 1237: return $cur_item; |
| | 1238: } |
| | 1239: |
| | 1240: $end_at = convert_table_utf8($db->prefix.'topics', '_conv_topics', $old_charset, 'id', $start_at); |
| | 1241: |
| | 1242: if ($end_at !== true) |
| | 1243: $query_str = '?stage=conv_topics&req_old_charset='.$old_charset.'&start_at='.$end_at; |
| | 1244: |
| | 1245: break; |
| | 1246: |
| | 1247: |
| | 1248: // Convert users |
| | 1249: case 'conv_users': |
| | 1250: $query_str = '?stage=preparse_posts'; |
| | 1251: |
| | 1252: function _conv_users($cur_item, $old_charset) |
| | 1253: { |
| | 1254: echo 'Converting user '.$cur_item['id'].' …<br />'."\n"; |
| | 1255: |
| | 1256: convert_to_utf8($cur_item['username'], $old_charset); |
| | 1257: convert_to_utf8($cur_item['title'], $old_charset); |
| | 1258: convert_to_utf8($cur_item['realname'], $old_charset); |
| | 1259: convert_to_utf8($cur_item['location'], $old_charset); |
| | 1260: convert_to_utf8($cur_item['signature'], $old_charset); |
| | 1261: convert_to_utf8($cur_item['admin_note'], $old_charset); |
| | 1262: |
| | 1263: return $cur_item; |
| | 1264: } |
| | 1265: |
| | 1266: $end_at = convert_table_utf8($db->prefix.'users', '_conv_users', $old_charset, 'id', $start_at); |
| | 1267: |
| | 1268: if ($end_at !== true) |
| | 1269: $query_str = '?stage=conv_users&req_old_charset='.$old_charset.'&start_at='.$end_at; |
| | 1270: |
| | 1271: break; |
| | 1272: |
| | 1273: |
| | 1274: // Preparse posts |
| | 1275: case 'preparse_posts': |
| | 1276: $query_str = '?stage=preparse_sigs'; |
| | 1277: |
| | 1278: // If we don't need to parse the posts, skip this stage |
| | 1279: if (isset($pun_config['o_parser_revision']) && $pun_config['o_parser_revision'] >= UPDATE_TO_PARSER_REVISION) |
| | 1280: break; |
| | 1281: |
| | 1282: require PUN_ROOT.'include/parser.php'; |
| | 1283: |
| | 1284: // Fetch posts to process this cycle |
| | 1285: $result = $db->query('SELECT id, message FROM '.$db->prefix.'posts WHERE id > '.$start_at.' ORDER BY id ASC LIMIT '.PER_PAGE) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error()); |
| | 1286: |
| | 1287: $temp = array(); |
| | 1288: $end_at = 0; |
| | 1289: while ($cur_item = $db->fetch_assoc($result)) |
| | 1290: { |
| | 1291: echo 'Preparsing post '.$cur_item['id'].' …<br />'."\n"; |
| | 1292: $db->query('UPDATE '.$db->prefix.'posts SET message = \''.$db->escape(preparse_bbcode($cur_item['message'], $temp)).'\' WHERE id = '.$cur_item['id']) or error('Unable to update post', __FILE__, __LINE__, $db->error()); |
| | 1293: |
| | 1294: $end_at = $cur_item['id']; |
| | 1295: } |
| | 1296: |
| | 1297: // Check if there is more work to do |
| | 1298: if ($end_at > 0) |
| | 1299: { |
| | 1300: $result = $db->query('SELECT 1 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()); |
| | 1301: |
| | 1302: if ($db->num_rows($result) > 0) |
| | 1303: $query_str = '?stage=preparse_posts&start_at='.$end_at; |
| | 1304: } |
| | 1305: |
| | 1306: break; |
| | 1307: |
| | 1308: |
| | 1309: // Preparse signatures |
| | 1310: case 'preparse_sigs': |
| | 1311: $query_str = '?stage=rebuild_idx'; |
| | 1312: |
| | 1313: // If we don't need to parse the sigs, skip this stage |
| | 1314: if (isset($pun_config['o_parser_revision']) && $pun_config['o_parser_revision'] >= UPDATE_TO_PARSER_REVISION) |
| | 1315: break; |
| | 1316: |
| | 1317: require PUN_ROOT.'include/parser.php'; |
| | 1318: |
| | 1319: // Fetch users to process this cycle |
| | 1320: $result = $db->query('SELECT id, signature FROM '.$db->prefix.'users WHERE id > '.$start_at.' ORDER BY id ASC LIMIT '.PER_PAGE) or error('Unable to fetch users', __FILE__, __LINE__, $db->error()); |
| | 1321: |
| | 1322: $temp = array(); |
| | 1323: $end_at = 0; |
| | 1324: while ($cur_item = $db->fetch_assoc($result)) |
| | 1325: { |
| | 1326: echo 'Preparsing signature '.$cur_item['id'].' …<br />'."\n"; |
| | 1327: $db->query('UPDATE '.$db->prefix.'users SET signature = \''.$db->escape(preparse_bbcode($cur_item['signature'], $temp, true)).'\' WHERE id = '.$cur_item['id']) or error('Unable to update user', __FILE__, __LINE__, $db->error()); |
| | 1328: |
| | 1329: $end_at = $cur_item['id']; |
| | 1330: } |
| | 1331: |
| | 1332: // Check if there is more work to do |
| | 1333: if ($end_at > 0) |
| | 1334: { |
| | 1335: $result = $db->query('SELECT 1 FROM '.$db->prefix.'users WHERE id > '.$end_at.' ORDER BY id ASC LIMIT 1') or error('Unable to fetch next ID', __FILE__, __LINE__, $db->error()); |
| | 1336: if ($db->num_rows($result) > 0) |
| | 1337: $query_str = '?stage=preparse_sigs&start_at='.$end_at; |
| | 1338: } |
| | 1339: |
| | 1340: break; |
| | 1341: |
| | 1342: |
| | 1343: // Rebuild the search index |
| | 1344: case 'rebuild_idx': |
| | 1345: $query_str = '?stage=finish'; |
| | 1346: |
| | 1347: // If we don't need to update the search index, skip this stage |
| | 1348: if (isset($pun_config['o_searchindex_revision']) && $pun_config['o_searchindex_revision'] >= UPDATE_TO_SI_REVISION) |
| | 1349: break; |
| | 1350: |
| | 1351: if ($start_at == 0) |
| | 1352: { |
| | 1353: // Truncate the tables just in-case we didn't already (if we are coming directly here without converting the tables) |
| | 1354: $db->truncate_table('search_cache') or error('Unable to empty search cache table', __FILE__, __LINE__, $db->error()); |
| | 1355: $db->truncate_table('search_matches') or error('Unable to empty search index match table', __FILE__, __LINE__, $db->error()); |
| | 1356: $db->truncate_table('search_words') or error('Unable to empty search index words table', __FILE__, __LINE__, $db->error()); |
| | 1357: |
| | 1358: // Reset the sequence for the search words (not needed for SQLite) |
| | 1359: switch ($db_type) |
| | 1360: { |
| | 1361: case 'mysql': |
| | 1362: case 'mysqli': |
| | 1363: case 'mysql_innodb': |
| | 1364: case 'mysqli_innodb': |
| | 1365: $db->query('ALTER TABLE '.$db->prefix.'search_words auto_increment=1') or error('Unable to update table auto_increment', __FILE__, __LINE__, $db->error()); |
| | 1366: break; |
| | 1367: |
| | 1368: case 'pgsql'; |
| | 1369: $db->query('SELECT setval(\''.$db->prefix.'search_words_id_seq\', 1, false)') or error('Unable to update sequence', __FILE__, __LINE__, $db->error()); |
| | 1370: break; |
| | 1371: } |
| | 1372: } |
| | 1373: |
| | 1374: require PUN_ROOT.'include/search_idx.php'; |
| | 1375: |
| | 1376: // Fetch posts to process this cycle |
| | 1377: $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()); |
| | 1378: |
| | 1379: $end_at = 0; |
| | 1380: while ($cur_item = $db->fetch_assoc($result)) |
| | 1381: { |
| | 1382: echo 'Rebuilding index for post '.$cur_item['id'].' …<br />'."\n"; |
| | 1383: |
| | 1384: if ($cur_item['id'] == $cur_item['first_post_id']) |
| | 1385: update_search_index('post', $cur_item['id'], $cur_item['message'], $cur_item['subject']); |
| | 1386: else |
| | 1387: update_search_index('post', $cur_item['id'], $cur_item['message']); |
| | 1388: |
| | 1389: $end_at = $cur_item['id']; |
| | 1390: } |
| | 1391: |
| | 1392: // Check if there is more work to do |
| | 1393: if ($end_at > 0) |
| | 1394: { |
| | 1395: $result = $db->query('SELECT 1 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()); |
| | 1396: |
| | 1397: if ($db->num_rows($result) > 0) |
| | 1398: $query_str = '?stage=rebuild_idx&start_at='.$end_at; |
| | 1399: } |
| | 1400: |
| | 1401: break; |
| | 1402: |
| | 1403: |
| | 1404: // Show results page |
| | 1405: case 'finish': |
| | 1406: // We update the version number |
| | 1407: $db->query('UPDATE '.$db->prefix.'config SET conf_value = \''.UPDATE_TO.'\' WHERE conf_name = \'o_cur_version\'') or error('Unable to update version', __FILE__, __LINE__, $db->error()); |
| | 1408: |
| | 1409: // And the database revision number |
| | 1410: $db->query('UPDATE '.$db->prefix.'config SET conf_value = \''.UPDATE_TO_DB_REVISION.'\' WHERE conf_name = \'o_database_revision\'') or error('Unable to update database revision number', __FILE__, __LINE__, $db->error()); |
| | 1411: |
| | 1412: // And the search index revision number |
| | 1413: $db->query('UPDATE '.$db->prefix.'config SET conf_value = \''.UPDATE_TO_SI_REVISION.'\' WHERE conf_name = \'o_searchindex_revision\'') or error('Unable to update search index revision number', __FILE__, __LINE__, $db->error()); |
| | 1414: |
| | 1415: // And the parser revision number |
| | 1416: $db->query('UPDATE '.$db->prefix.'config SET conf_value = \''.UPDATE_TO_PARSER_REVISION.'\' WHERE conf_name = \'o_parser_revision\'') or error('Unable to update parser revision number', __FILE__, __LINE__, $db->error()); |
| | 1417: |
| | 1418: // Check the default language still exists! |
| | 1419: if (!file_exists(PUN_ROOT.'lang/'.$pun_config['o_default_lang'].'/common.php')) |
| | 1420: $db->query('UPDATE '.$db->prefix.'config SET conf_value = \'English\' WHERE conf_name = \'o_default_lang\'') or error('Unable to update default language', __FILE__, __LINE__, $db->error()); |
| | 1421: |
| | 1422: // Check the default style still exists! |
| | 1423: if (!file_exists(PUN_ROOT.'style/'.$pun_config['o_default_style'].'.css')) |
| | 1424: $db->query('UPDATE '.$db->prefix.'config SET conf_value = \'Air\' WHERE conf_name = \'o_default_style\'') or error('Unable to update default style', __FILE__, __LINE__, $db->error()); |
| | 1425: |
| | 1426: // This feels like a good time to synchronize the forums |
| | 1427: $result = $db->query('SELECT id FROM '.$db->prefix.'forums') or error('Unable to fetch forum IDs', __FILE__, __LINE__, $db->error()); |
| | 1428: |
| | 1429: while ($row = $db->fetch_row($result)) |
| | 1430: update_forum($row[0]); |
| | 1431: |
| | 1432: // Empty the PHP cache |
| | 1433: forum_clear_cache(); |
| | 1434: |
| | 1435: ?> |
| | 1436: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| | 1437: |
| | 1438: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> |
| | 1439: <head> |
| | 1440: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| | 1441: <title>FluxBB Database Update</title> |
| | 1442: <link rel="stylesheet" type="text/css" href="style/<?php echo $default_style ?>.css" /> |
| | 1443: </head> |
| | 1444: <body> |
| | 1445: |
| | 1446: <div id="pundb_update" class="pun"> |
| | 1447: <div class="top-box"><div><!-- Top Corners --></div></div> |
| | 1448: <div class="punwrap"> |
| | 1449: |
| | 1450: <div class="blockform"> |
| | 1451: <h2><span>FluxBB Update</span></h2> |
| | 1452: <div class="box"> |
| | 1453: <div class="fakeform"> |
| | 1454: <div class="inform"> |
| | 1455: <div class="forminfo"> |
| | 1456: <p style="font-size: 1.1em">Your forum database was successfully updated. You may now <a href="<?php echo PUN_ROOT ?>index.php">go to the forum index</a>.</p> |
| | 1457: </div> |
| | 1458: </div> |
| | 1459: </div> |
| | 1460: </div> |
| | 1461: </div> |
| | 1462: |
| | 1463: </div> |
| | 1464: <div class="end-box"><div><!-- Bottom Corners --></div></div> |
| | 1465: </div> |
| | 1466: |
| | 1467: </body> |
| | 1468: </html> |
| | 1469: <?php |
| | 1470: |
| | 1471: break; |
| | 1472: } |
| | 1473: |
| | 1474: $db->end_transaction(); |
| | 1475: $db->close(); |
| | 1476: |
| | 1477: if ($query_str != '') |
| | 1478: exit('<script type="text/javascript">window.location="db_update.php'.$query_str.'"</script><noscript>JavaScript seems to be disabled. <a href="db_update.php'.$query_str.'">Click here to continue</a>.</noscript>'); |
| /dev/null |
b/extern.php |
| | 1: <?php |
| | 2: |
| | 3: /** |
| | 4: * Copyright (C) 2008-2010 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: /*----------------------------------------------------------------------------- |
| | 10: |
| | 11: INSTRUCTIONS |
| | 12: |
| | 13: This script is used to include information about your board from |
| | 14: pages outside the forums and to syndicate news about recent |
| | 15: discussions via RSS/Atom/XML. The script can display a list of |
| | 16: recent discussions, a list of active users or a collection of |
| | 17: general board statistics. The script can be called directly via |
| | 18: an URL, from a PHP include command or through the use of Server |
| | 19: Side Includes (SSI). |
| | 20: |
| | 21: The scripts behaviour is controlled via variables supplied in the |
| | 22: URL to the script. The different variables are: action (what to |
| | 23: do), show (how many items to display), fid (the ID or IDs of |
| | 24: the forum(s) to poll for topics), nfid (the ID or IDs of forums |
| | 25: that should be excluded), tid (the ID of the topic from which to |
| | 26: display posts) and type (output as HTML or RSS). The only |
| | 27: mandatory variable is action. Possible/default values are: |
| | 28: |
| | 29: action: feed - show most recent topics/posts (HTML or RSS) |
| | 30: online - show users online (HTML) |
| | 31: online_full - as above, but includes a full list (HTML) |
| | 32: stats - show board statistics (HTML) |
| | 33: |
| | 34: type: rss - output as RSS 2.0 |
| | 35: atom - output as Atom 1.0 |
| | 36: xml - output as XML |
| | 37: html - output as HTML (<li>'s) |
| | 38: |
| | 39: fid: One or more forum IDs (comma-separated). If ignored, |
| | 40: topics from all readable forums will be pulled. |
| | 41: |
| | 42: nfid: One or more forum IDs (comma-separated) that are to be |
| | 43: excluded. E.g. the ID of a a test forum. |
| | 44: |
| | 45: tid: A topic ID from which to show posts. If a tid is supplied, |
| | 46: fid and nfid are ignored. |
| | 47: |
| | 48: show: Any integer value between 1 and 50. The default is 15. |
| | 49: |
| | 50: order: last_post - show topics ordered by when they were last |
| | 51: posted in, giving information about the reply. |
| | 52: posted - show topics ordered by when they were first |
| | 53: posted, giving information about the original post. |
| | 54: |
| | 55: -----------------------------------------------------------------------------*/ |
| | 56: |
| | 57: define('PUN_QUIET_VISIT', 1); |
| | 58: |
| | 59: if (!defined('PUN_ROOT')) |
| | 60: define('PUN_ROOT', './'); |
| | 61: require PUN_ROOT.'include/common.php'; |
| | 62: |
| | 63: // The length at which topic subjects will be truncated (for HTML output) |
| | 64: if (!defined('FORUM_EXTERN_MAX_SUBJECT_LENGTH')) |
| | 65: define('FORUM_EXTERN_MAX_SUBJECT_LENGTH', 30); |
| | 66: |
| | 67: // If we're a guest and we've sent a username/pass, we can try to authenticate using those details |
| | 68: if ($pun_user['is_guest'] && isset($_SERVER['PHP_AUTH_USER'])) |
| | 69: authenticate_user($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); |
| | 70: |
| | 71: if ($pun_user['g_read_board'] == '0') |
| | 72: { |
| | 73: http_authenticate_user(); |
| | 74: exit($lang_common['No view']); |
| | 75: } |
| | 76: |
| | 77: $action = isset($_GET['action']) ? $_GET['action'] : 'feed'; |
| | 78: |
| | 79: |
| | 80: // |
| | 81: // Sends the proper headers for Basic HTTP Authentication |
| | 82: // |
| | 83: function http_authenticate_user() |
| | 84: { |
| | 85: global $pun_config, $pun_user; |
| | 86: |
| | 87: if (!$pun_user['is_guest']) |
| | 88: return; |
| | 89: |
| | 90: header('WWW-Authenticate: Basic realm="'.$pun_config['o_board_title'].' External Syndication"'); |
| | 91: header('HTTP/1.0 401 Unauthorized'); |
| | 92: } |
| | 93: |
| | 94: |
| | 95: // |
| | 96: // Output $feed as RSS 2.0 |
| | 97: // |
| | 98: function output_rss($feed) |
| | 99: { |
| | 100: global $lang_common, $pun_config; |
| | 101: |
| | 102: // Send XML/no cache headers |
| | 103: header('Content-Type: application/xml; charset=utf-8'); |
| | 104: header('Expires: '.gmdate('D, d M Y H:i:s').' GMT'); |
| | 105: header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
| | 106: header('Pragma: public'); |
| | 107: |
| | 108: echo '<?xml version="1.0" encoding="utf-8"?>'."\n"; |
| | 109: echo '<rss version="2.0">'."\n"; |
| | 110: echo "\t".'<channel>'."\n"; |
| | 111: echo "\t\t".'<title><![CDATA['.escape_cdata($feed['title']).']]></title>'."\n"; |
| | 112: echo "\t\t".'<link>'.$feed['link'].'</link>'."\n"; |
| | 113: echo "\t\t".'<description><![CDATA['.escape_cdata($feed['description']).']]></description>'."\n"; |
| | 114: echo "\t\t".'<lastBuildDate>'.gmdate('r', count($feed['items']) ? $feed['items'][0]['pubdate'] : time()).'</lastBuildDate>'."\n"; |
| | 115: |
| | 116: if ($pun_config['o_show_version'] == '1') |
| | 117: echo "\t\t".'<generator>FluxBB '.$pun_config['o_cur_version'].'</generator>'."\n"; |
| | 118: else |
| | 119: echo "\t\t".'<generator>FluxBB</generator>'."\n"; |
| | 120: |
| | 121: foreach ($feed['items'] as $item) |
| | 122: { |
| | 123: echo "\t\t".'<item>'."\n"; |
| | 124: echo "\t\t\t".'<title><![CDATA['.escape_cdata($item['title']).']]></title>'."\n"; |
| | 125: echo "\t\t\t".'<link>'.$item['link'].'</link>'."\n"; |
| | 126: echo "\t\t\t".'<description><![CDATA['.escape_cdata($item['description']).']]></description>'."\n"; |
| | 127: echo "\t\t\t".'<author><![CDATA['.(isset($item['author']['email']) ? escape_cdata($item['author']['email']) : 'dummy@example.com').' ('.escape_cdata($item['author']['name']).')]]></author>'."\n"; |
| | 128: echo "\t\t\t".'<pubDate>'.gmdate('r', $item['pubdate']).'</pubDate>'."\n"; |
| | 129: echo "\t\t\t".'<guid>'.$item['link'].'</guid>'."\n"; |
| | 130: |
| | 131: echo "\t\t".'</item>'."\n"; |
| | 132: } |
| | 133: |
| | 134: echo "\t".'</channel>'."\n"; |
| | 135: echo '</rss>'."\n"; |
| | 136: } |
| | 137: |
| | 138: |
| | 139: // |
| | 140: // Output $feed as Atom 1.0 |
| | 141: // |
| | 142: function output_atom($feed) |
| | 143: { |
| | 144: global $lang_common, $pun_config; |
| | 145: |
| | 146: // Send XML/no cache headers |
| | 147: header('Content-Type: application/atom+xml; charset=utf-8'); |
| | 148: header('Expires: '.gmdate('D, d M Y H:i:s').' GMT'); |
| | 149: header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
| | 150: header('Pragma: public'); |
| | 151: |
| | 152: echo '<?xml version="1.0" encoding="utf-8"?>'."\n"; |
| | 153: echo '<feed xmlns="http://www.w3.org/2005/Atom">'."\n"; |
| | 154: |
| | 155: echo "\t".'<title type="html"><![CDATA['.escape_cdata($feed['title']).']]></title>'."\n"; |
| | 156: echo "\t".'<link rel="self" href="'.pun_htmlspecialchars(get_current_url()).'"/>'."\n"; |
| | 157: echo "\t".'<link href="'.$feed['link'].'"/>'."\n"; |
| | 158: echo "\t".'<updated>'.gmdate('Y-m-d\TH:i:s\Z', count($feed['items']) ? $feed['items'][0]['pubdate'] : time()).'</updated>'."\n"; |
| | 159: |
| | 160: if ($pun_config['o_show_version'] == '1') |
| | 161: echo "\t".'<generator version="'.$pun_config['o_cur_version'].'">FluxBB</generator>'."\n"; |
| | 162: else |
| | 163: echo "\t".'<generator>FluxBB</generator>'."\n"; |
| | 164: |
| | 165: echo "\t".'<id>'.$feed['link'].'</id>'."\n"; |
| | 166: |
| | 167: $content_tag = ($feed['type'] == 'posts') ? 'content' : 'summary'; |
| | 168: |
| | 169: foreach ($feed['items'] as $item) |
| | 170: { |
| | 171: echo "\t".'<entry>'."\n"; |
| | 172: echo "\t\t".'<title type="html"><![CDATA['.escape_cdata($item['title']).']]></title>'."\n"; |
| | 173: echo "\t\t".'<link rel="alternate" href="'.$item['link'].'"/>'."\n"; |
| | 174: echo "\t\t".'<'.$content_tag.' type="html"><![CDATA['.escape_cdata($item['description']).']]></'.$content_tag.'>'."\n"; |
| | 175: echo "\t\t".'<author>'."\n"; |
| | 176: echo "\t\t\t".'<name><![CDATA['.escape_cdata($item['author']['name']).']]></name>'."\n"; |
| | 177: |
| | 178: if (isset($item['author']['email'])) |
| | 179: echo "\t\t\t".'<email><![CDATA['.escape_cdata($item['author']['email']).']]></email>'."\n"; |
| | 180: |
| | 181: if (isset($item['author']['uri'])) |
| | 182: echo "\t\t\t".'<uri>'.$item['author']['uri'].'</uri>'."\n"; |
| | 183: |
| | 184: echo "\t\t".'</author>'."\n"; |
| | 185: echo "\t\t".'<updated>'.gmdate('Y-m-d\TH:i:s\Z', $item['pubdate']).'</updated>'."\n"; |
| | 186: |
| | 187: echo "\t\t".'<id>'.$item['link'].'</id>'."\n"; |
| | 188: echo "\t".'</entry>'."\n"; |
| | 189: } |
| | 190: |
| | 191: echo '</feed>'."\n"; |
| | 192: } |
| | 193: |
| | 194: |
| | 195: // |
| | 196: // Output $feed as XML |
| | 197: // |
| | 198: function output_xml($feed) |
| | 199: { |
| | 200: global $lang_common, $pun_config; |
| | 201: |
| | 202: // Send XML/no cache headers |
| | 203: header('Content-Type: application/xml; charset=utf-8'); |
| | 204: header('Expires: '.gmdate('D, d M Y H:i:s').' GMT'); |
| | 205: header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
| | 206: header('Pragma: public'); |
| | 207: |
| | 208: echo '<?xml version="1.0" encoding="utf-8"?>'."\n"; |
| | 209: echo '<source>'."\n"; |
| | 210: echo "\t".'<url>'.$feed['link'].'</url>'."\n"; |
| | 211: |
| | 212: $forum_tag = ($feed['type'] == 'posts') ? 'post' : 'topic'; |
| | 213: |
| | 214: foreach ($feed['items'] as $item) |
| | 215: { |
| | 216: echo "\t".'<'.$forum_tag.' id="'.$item['id'].'">'."\n"; |
| | 217: |
| | 218: echo "\t\t".'<title><![CDATA['.escape_cdata($item['title']).']]></title>'."\n"; |
| | 219: echo "\t\t".'<link>'.$item['link'].'</link>'."\n"; |
| | 220: echo "\t\t".'<content><![CDATA['.escape_cdata($item['description']).']]></content>'."\n"; |
| | 221: echo "\t\t".'<author>'."\n"; |
| | 222: echo "\t\t\t".'<name><![CDATA['.escape_cdata($item['author']['name']).']]></name>'."\n"; |
| | 223: |
| | 224: if (isset($item['author']['email'])) |
| | 225: echo "\t\t\t".'<email><![CDATA['.escape_cdata($item['author']['email']).']]></email>'."\n"; |
| | 226: |
| | 227: if (isset($item['author']['uri'])) |
| | 228: echo "\t\t\t".'<uri>'.$item['author']['uri'].'</uri>'."\n"; |
| | 229: |
| | 230: echo "\t\t".'</author>'."\n"; |
| | 231: echo "\t\t".'<posted>'.gmdate('r', $item['pubdate']).'</posted>'."\n"; |
| | 232: |
| | 233: echo "\t".'</'.$forum_tag.'>'."\n"; |
| | 234: } |
| | 235: |
| | 236: echo '</source>'."\n"; |
| | 237: } |
| | 238: |
| | 239: |
| | 240: // |
| | 241: // Output $feed as HTML (using <li> tags) |
| | 242: // |
| | 243: function output_html($feed) |
| | 244: { |
| | 245: |
| | 246: // Send the Content-type header in case the web server is setup to send something else |
| | 247: header('Content-type: text/html; charset=utf-8'); |
| | 248: header('Expires: '.gmdate('D, d M Y H:i:s').' GMT'); |
| | 249: header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
| | 250: header('Pragma: public'); |
| | 251: |
| | 252: foreach ($feed['items'] as $item) |
| | 253: { |
| | 254: if (utf8_strlen($item['title']) > FORUM_EXTERN_MAX_SUBJECT_LENGTH) |
| | 255: $subject_truncated = pun_htmlspecialchars(pun_trim(utf8_substr($item['title'], 0, (FORUM_EXTERN_MAX_SUBJECT_LENGTH - 5)))).' …'; |
| | 256: else |
| | 257: $subject_truncated = pun_htmlspecialchars($item['title']); |
| | 258: |
| | 259: echo '<li><a href="'.$item['link'].'" title="'.pun_htmlspecialchars($item['title']).'">'.$subject_truncated.'</a></li>'."\n"; |
| | 260: } |
| | 261: } |
| | 262: |
| | 263: // Show recent discussions |
| | 264: if ($action == 'feed') |
| | 265: { |
| | 266: require PUN_ROOT.'include/parser.php'; |
| | 267: |
| | 268: // Determine what type of feed to output |
| | 269: $type = isset($_GET['type']) && in_array($_GET['type'], array('html', 'rss', 'atom', 'xml')) ? $_GET['type'] : 'html'; |
| | 270: |
| | 271: $show = isset($_GET['show']) ? intval($_GET['show']) : 15; |
| | 272: if ($show < 1 || $show > 50) |
| | 273: $show = 15; |
| | 274: |
| | 275: // Was a topic ID supplied? |
| | 276: if (isset($_GET['tid'])) |
| | 277: { |
| | 278: $tid = intval($_GET['tid']); |
| | 279: |
| | 280: // Fetch topic subject |
| | 281: $result = $db->query('SELECT t.subject, t.first_post_id FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL AND t.id='.$tid) or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error()); |
| | 282: if (!$db->num_rows($result)) |
| | 283: { |
| | 284: http_authenticate_user(); |
| | 285: exit($lang_common['Bad request']); |
| | 286: } |
| | 287: |
| | 288: $cur_topic = $db->fetch_assoc($result); |
| | 289: |
| | 290: if ($pun_config['o_censoring'] == '1') |
| | 291: $cur_topic['subject'] = censor_words($cur_topic['subject']); |
| | 292: |
| | 293: // Setup the feed |
| | 294: $feed = array( |
| | 295: 'title' => $pun_config['o_board_title'].$lang_common['Title separator'].$cur_topic['subject'], |
| | 296: 'link' => $pun_config['o_base_url'].'/viewtopic.php?id='.$tid, |
| | 297: 'description' => sprintf($lang_common['RSS description topic'], $cur_topic['subject']), |
| | 298: 'items' => array(), |
| | 299: 'type' => 'posts' |
| | 300: ); |
| | 301: |
| | 302: // Fetch $show posts |
| | 303: $result = $db->query('SELECT p.id, p.poster, p.message, p.hide_smilies, p.posted, p.poster_id, u.email_setting, u.email, p.poster_email FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id WHERE p.topic_id='.$tid.' ORDER BY p.posted DESC LIMIT '.$show) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error()); |
| | 304: while ($cur_post = $db->fetch_assoc($result)) |
| | 305: { |
| | 306: $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']); |
| | 307: |
| | 308: $item = array( |
| | 309: 'id' => $cur_post['id'], |
| | 310: 'title' => $cur_topic['first_post_id'] == $cur_post['id'] ? $cur_topic['subject'] : $lang_common['RSS reply'].$cur_topic['subject'], |
| | 311: 'link' => $pun_config['o_base_url'].'/viewtopic.php?pid='.$cur_post['id'].'#p'.$cur_post['id'], |
| | 312: 'description' => $cur_post['message'], |
| | 313: 'author' => array( |
| | 314: 'name' => $cur_post['poster'], |
| | 315: ), |
| | 316: 'pubdate' => $cur_post['posted'] |
| | 317: ); |
| | 318: |
| | 319: if ($cur_post['poster_id'] > 1) |
| | 320: { |
| | 321: if ($cur_post['email_setting'] == '0' && !$pun_user['is_guest']) |
| | 322: $item['author']['email'] = $cur_post['email']; |
| | 323: |
| | 324: $item['author']['uri'] = $pun_config['o_base_url'].'/profile.php?id='.$cur_post['poster_id']; |
| | 325: } |
| | 326: else if ($cur_post['poster_email'] != '' && !$pun_user['is_guest']) |
| | 327: $item['author']['email'] = $cur_post['poster_email']; |
| | 328: |
| | 329: $feed['items'][] = $item; |
| | 330: } |
| | 331: |
| | 332: $output_func = 'output_'.$type; |
| | 333: $output_func($feed); |
| | 334: } |
| | 335: else |
| | 336: { |
| | 337: $order_posted = isset($_GET['order']) && $_GET['order'] == 'posted'; |
| | 338: $forum_name = ''; |
| | 339: $forum_sql = ''; |
| | 340: |
| | 341: // Were any forum IDs supplied? |
| | 342: if (isset($_GET['fid']) && is_scalar($_GET['fid']) && $_GET['fid'] != '') |
| | 343: { |
| | 344: $fids = explode(',', pun_trim($_GET['fid'])); |
| | 345: $fids = array_map('intval', $fids); |
| | 346: |
| | 347: if (!empty($fids)) |
| | 348: $forum_sql .= ' AND t.forum_id IN('.implode(',', $fids).')'; |
| | 349: |
| | 350: if (count($fids) == 1) |
| | 351: { |
| | 352: // Fetch forum name |
| | 353: $result = $db->query('SELECT f.forum_name FROM '.$db->prefix.'forums AS f LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.id='.$fids[0]) or error('Unable to fetch forum name', __FILE__, __LINE__, $db->error()); |
| | 354: if ($db->num_rows($result)) |
| | 355: $forum_name = $lang_common['Title separator'].$db->result($result); |
| | 356: } |
| | 357: } |
| | 358: |
| | 359: // Any forum IDs to exclude? |
| | 360: if (isset($_GET['nfid']) && is_scalar($_GET['nfid']) && $_GET['nfid'] != '') |
| | 361: { |
| | 362: $nfids = explode(',', pun_trim($_GET['nfid'])); |
| | 363: $nfids = array_map('intval', $nfids); |
| | 364: |
| | 365: if (!empty($nfids)) |
| | 366: $forum_sql .= ' AND t.forum_id NOT IN('.implode(',', $nfids).')'; |
| | 367: } |
| | 368: |
| | 369: // Setup the feed |
| | 370: $feed = array( |
| | 371: 'title' => $pun_config['o_board_title'].$forum_name, |
| | 372: 'link' => $pun_config['o_base_url'].'/index.php', |
| | 373: 'description' => sprintf($lang_common['RSS description'], $pun_config['o_board_title']), |
| | 374: 'items' => array(), |
| | 375: 'type' => 'topics' |
| | 376: ); |
| | 377: |
| | 378: // Fetch $show topics |
| | 379: $result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, t.last_poster, p.message, p.hide_smilies, u.email_setting, u.email, p.poster_id, p.poster_email FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON p.id='.($order_posted ? 't.first_post_id' : 't.last_post_id').' INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=t.forum_id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL'.$forum_sql.' ORDER BY '.($order_posted ? 't.posted' : 't.last_post').' DESC LIMIT '.$show) or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error()); |
| | 380: while ($cur_topic = $db->fetch_assoc($result)) |
| | 381: { |
| | 382: if ($pun_config['o_censoring'] == '1') |
| | 383: $cur_topic['subject'] = censor_words($cur_topic['subject']); |
| | 384: |
| | 385: $cur_topic['message'] = parse_message($cur_topic['message'], $cur_topic['hide_smilies']); |
| | 386: |
| | 387: $item = array( |
| | 388: 'id' => $cur_topic['id'], |
| | 389: 'title' => $cur_topic['subject'], |
| | 390: 'link' => $pun_config['o_base_url'].($order_posted ? '/viewtopic.php?id='.$cur_topic['id'] : '/viewtopic.php?id='.$cur_topic['id'].'&action=new'), |
| | 391: 'description' => $cur_topic['message'], |
| | 392: 'author' => array( |
| | 393: 'name' => $order_posted ? $cur_topic['poster'] : $cur_topic['last_poster'] |
| | 394: ), |
| | 395: 'pubdate' => $order_posted ? $cur_topic['posted'] : $cur_topic['last_post'] |
| | 396: ); |
| | 397: |
| | 398: if ($cur_topic['poster_id'] > 1) |
| | 399: { |
| | 400: if ($cur_topic['email_setting'] == '0' && !$pun_user['is_guest']) |
| | 401: $item['author']['email'] = $cur_topic['email']; |
| | 402: |
| | 403: $item['author']['uri'] = $pun_config['o_base_url'].'/profile.php?id='.$cur_topic['poster_id']; |
| | 404: } |
| | 405: else if ($cur_topic['poster_email'] != '' && !$pun_user['is_guest']) |
| | 406: $item['author']['email'] = $cur_topic['poster_email']; |
| | 407: |
| | 408: $feed['items'][] = $item; |
| | 409: } |
| | 410: |
| | 411: $output_func = 'output_'.$type; |
| | 412: $output_func($feed); |
| | 413: } |
| | 414: |
| | 415: exit; |
| | 416: } |
| | 417: |
| | 418: // Show users online |
| | 419: else if ($action == 'online' || $action == 'online_full') |
| | 420: { |
| | 421: // Load the index.php language file |
| | 422: require PUN_ROOT.'lang/'.$pun_config['o_default_lang'].'/index.php'; |
| | 423: |
| | 424: // Fetch users online info and generate strings for output |
| | 425: $num_guests = $num_users = 0; |
| | 426: $users = array(); |
| | 427: |
| | 428: $result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error()); |
| | 429: |
| | 430: while ($pun_user_online = $db->fetch_assoc($result)) |
| | 431: { |
| | 432: if ($pun_user_online['user_id'] > 1) |
| | 433: { |
| | 434: $users[] = ($pun_user['g_view_users'] == '1') ? '<a href="'.$pun_config['o_base_url'].'/profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>' : pun_htmlspecialchars($pun_user_online['ident']); |
| | 435: ++$num_users; |
| | 436: } |
| | 437: else |
| | 438: ++$num_guests; |
| | 439: } |
| | 440: |
| | 441: // Send the Content-type header in case the web server is setup to send something else |
| | 442: header('Content-type: text/html; charset=utf-8'); |
| | 443: header('Expires: '.gmdate('D, d M Y H:i:s').' GMT'); |
| | 444: header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
| | 445: header('Pragma: public'); |
| | 446: |
| | 447: echo sprintf($lang_index['Guests online'], forum_number_format($num_guests)).'<br />'."\n"; |
| | 448: |
| | 449: if ($action == 'online_full' && !empty($users)) |
| | 450: echo sprintf($lang_index['Users online'], implode(', ', $users)).'<br />'."\n"; |
| | 451: else |
| | 452: echo sprintf($lang_index['Users online'], forum_number_format($num_users)).'<br />'."\n"; |
| | 453: |
| | 454: exit; |
| | 455: } |
| | 456: |
| | 457: // Show board statistics |
| | 458: else if ($action == 'stats') |
| | 459: { |
| | 460: // Load the index.php language file |
| | 461: require PUN_ROOT.'lang/'.$pun_config['o_default_lang'].'/index.php'; |
| | 462: |
| | 463: // Collect some statistics from the database |
| | 464: $result = $db->query('SELECT COUNT(id)-1 FROM '.$db->prefix.'users WHERE group_id!='.PUN_UNVERIFIED) or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error()); |
| | 465: $stats['total_users'] = $db->result($result); |
| | 466: |
| | 467: $result = $db->query('SELECT id, username FROM '.$db->prefix.'users WHERE group_id!='.PUN_UNVERIFIED.' ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error()); |
| | 468: $stats['last_user'] = $db->fetch_assoc($result); |
| | 469: |
| | 470: $result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error()); |
| | 471: list($stats['total_topics'], $stats['total_posts']) = $db->fetch_row($result); |
| | 472: |
| | 473: // Send the Content-type header in case the web server is setup to send something else |
| | 474: header('Content-type: text/html; charset=utf-8'); |
| | 475: header('Expires: '.gmdate('D, d M Y H:i:s').' GMT'); |
| | 476: header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
| | 477: header('Pragma: public'); |
| | 478: |
| | 479: echo sprintf($lang_index['No of users'], forum_number_format($stats['total_users'])).'<br />'."\n"; |
| | 480: echo sprintf($lang_index['Newest user'], (($pun_user['g_view_users'] == '1') ? '<a href="'.$pun_config['o_base_url'].'/profile.php?id='.$stats['last_user']['id'].'">'.pun_htmlspecialchars($stats['last_user']['username']).'</a>' : pun_htmlspecialchars($stats['last_user']['username']))).'<br />'."\n"; |
| | 481: echo sprintf($lang_index['No of topics'], forum_number_format($stats['total_topics'])).'<br />'."\n"; |
| | 482: echo sprintf($lang_index['No of posts'], forum_number_format($stats['total_posts'])).'<br />'."\n"; |
| | 483: |
| | 484: exit; |
| | 485: } |
| | 486: |
| | 487: // If we end up here, the script was called with some wacky parameters |
| | 488: exit($lang_common['Bad request']); |
| /dev/null |
b/include/dblayer/sqlite.php |
| | 1: <?php |
| | 2: |
| | 3: /** |
| | 4: * Copyright (C) 2008-2010 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: // Make sure we have built in support for SQLite |
| | 10: if (!function_exists('sqlite_open')) |
| | 11: exit('This PHP environment doesn\'t have SQLite support built in. SQLite support is required if you want to use a SQLite database to run this forum. Consult the PHP documentation for further assistance.'); |
| | 12: |
| | 13: |
| | 14: class DBLayer |
| | 15: { |
| | 16: var $prefix; |
| | 17: var $link_id; |
| | 18: var $query_result; |
| | 19: var $in_transaction = 0; |
| | 20: |
| | 21: var $saved_queries = array(); |
| | 22: var $num_queries = 0; |
| | 23: |
| | 24: var $error_no = false; |
| | 25: var $error_msg = 'Unknown'; |
| | 26: |
| | 27: var $datatype_transformations = array( |
| | 28: '/^SERIAL$/' => 'INTEGER', |
| | 29: '/^(TINY|SMALL|MEDIUM|BIG)?INT( )?(\\([0-9]+\\))?( )?(UNSIGNED)?$/i' => 'INTEGER', |
| | 30: '/^(TINY|MEDIUM|LONG)?TEXT$/i' => 'TEXT' |
| | 31: ); |
| | 32: |
| | 33: |
| | 34: function DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect) |
| | 35: { |
| | 36: // Prepend $db_name with the path to the forum root directory |
| | 37: $db_name = PUN_ROOT.$db_name; |
| | 38: |
| | 39: $this->prefix = $db_prefix; |
| | 40: |
| | 41: if (!file_exists($db_name)) |
| | 42: { |
| | 43: @touch($db_name); |
| | 44: @chmod($db_name, 0666); |
| | 45: if (!file_exists($db_name)) |
| | 46: error('Unable to create new database \''.$db_name.'\'. Permission denied', __FILE__, __LINE__); |
| | 47: } |
| | 48: |
| | 49: if (!is_readable($db_name)) |
| | 50: error('Unable to open database \''.$db_name.'\' for reading. Permission denied', __FILE__, __LINE__); |
| | 51: |
| | 52: if (!is_writable($db_name)) |
| | 53: error('Unable to open database \''.$db_name.'\' for writing. Permission denied', __FILE__, __LINE__); |
| | 54: |
| | 55: if ($p_connect) |
| | 56: $this->link_id = @sqlite_popen($db_name, 0666, $sqlite_error); |
| | 57: else |
| | 58: $this->link_id = @sqlite_open($db_name, 0666, $sqlite_error); |
| | 59: |
| | 60: if (!$this->link_id) |
| | 61: error('Unable to open database \''.$db_name.'\'. SQLite reported: '.$sqlite_error, __FILE__, __LINE__); |
| | 62: else |
| | 63: return $this->link_id; |
| | 64: } |
| | 65: |
| | 66: |
| | 67: function start_transaction() |
| | 68: { |
| | 69: ++$this->in_transaction; |
| | 70: |
| | 71: return (@sqlite_query($this->link_id, 'BEGIN')) ? true : false; |
| | 72: } |
| | 73: |
| | 74: |
| | 75: function end_transaction() |
| | 76: { |
| | 77: --$this->in_transaction; |
| | 78: |
| | 79: if (@sqlite_query($this->link_id, 'COMMIT')) |
| | 80: return true; |
| | 81: else |
| | 82: { |
| | 83: @sqlite_query($this->link_id, 'ROLLBACK'); |
| | 84: return false; |
| | 85: } |
| | 86: } |
| | 87: |
| | 88: |
| | 89: function query($sql, $unbuffered = false) |
| | 90: { |
| | 91: if (defined('PUN_SHOW_QUERIES')) |
| | 92: $q_start = get_microtime(); |
| | 93: |
| | 94: if ($unbuffered) |
| | 95: $this->query_result = @sqlite_unbuffered_query($this->link_id, $sql); |
| | 96: else |
| | 97: $this->query_result = @sqlite_query($this->link_id, $sql); |
| | 98: |
| | 99: if ($this->query_result) |
| | 100: { |
| | 101: if (defined('PUN_SHOW_QUERIES')) |
| | 102: $this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start)); |
| | 103: |
| | 104: ++$this->num_queries; |
| | 105: |
| | 106: return $this->query_result; |
| | 107: } |
| | 108: else |
| | 109: { |
| | 110: if (defined('PUN_SHOW_QUERIES')) |
| | 111: $this->saved_queries[] = array($sql, 0); |
| | 112: |
| | 113: $this->error_no = @sqlite_last_error($this->link_id); |
| | 114: $this->error_msg = @sqlite_error_string($this->error_no); |
| | 115: |
| | 116: if ($this->in_transaction) |
| | 117: @sqlite_query($this->link_id, 'ROLLBACK'); |
| | 118: |
| | 119: --$this->in_transaction; |
| | 120: |
| | 121: return false; |
| | 122: } |
| | 123: } |
| | 124: |
| | 125: |
| | 126: function result($query_id = 0, $row = 0, $col = 0) |
| | 127: { |
| | 128: if ($query_id) |
| | 129: { |
| | 130: if ($row !== 0 && @sqlite_seek($query_id, $row) === false) |
| | 131: return false; |
| | 132: |
| | 133: $cur_row = @sqlite_current($query_id); |
| | 134: if ($cur_row === false) |
| | 135: return false; |
| | 136: |
| | 137: return $cur_row[$col]; |
| | 138: } |
| | 139: else |
| | 140: return false; |
| | 141: } |
| | 142: |
| | 143: |
| | 144: function fetch_assoc($query_id = 0) |
| | 145: { |
| | 146: if ($query_id) |
| | 147: { |
| | 148: $cur_row = @sqlite_fetch_array($query_id, SQLITE_ASSOC); |
| | 149: if ($cur_row) |
| | 150: { |
| | 151: // Horrible hack to get rid of table names and table aliases from the array keys |
| | 152: foreach ($cur_row as $key => $value) |
| | 153: { |
| | 154: $dot_spot = strpos($key, '.'); |
| | 155: if ($dot_spot !== false) |
| | 156: { |
| | 157: unset($cur_row[$key]); |
| | 158: $key = substr($key, $dot_spot+1); |
| | 159: $cur_row[$key] = $value; |
| | 160: } |
| | 161: } |
| | 162: } |
| | 163: |
| | 164: return $cur_row; |
| | 165: } |
| | 166: else |
| | 167: return false; |
| | 168: } |
| | 169: |
| | 170: |
| | 171: function fetch_row($query_id = 0) |
| | 172: { |
| | 173: return ($query_id) ? @sqlite_fetch_array($query_id, SQLITE_NUM) : false; |
| | 174: } |
| | 175: |
| | 176: |
| | 177: function num_rows($query_id = 0) |
| | 178: { |
| | 179: return ($query_id) ? @sqlite_num_rows($query_id) : false; |
| | 180: } |
| | 181: |
| | 182: |
| | 183: function affected_rows() |
| | 184: { |
| | 185: return ($this->query_result) ? @sqlite_changes($this->query_result) : false; |
| | 186: } |
| | 187: |
| | 188: |
| | 189: function insert_id() |
| | 190: { |
| | 191: return ($this->link_id) ? @sqlite_last_insert_rowid($this->link_id) : false; |
| | 192: } |
| | 193: |
| | 194: |
| | 195: function get_num_queries() |
| | 196: { |
| | 197: return $this->num_queries; |
| | 198: } |
| | 199: |
| | 200: |
| | 201: function get_saved_queries() |
| | 202: { |
| | 203: return $this->saved_queries; |
| | 204: } |
| | 205: |
| | 206: |
| | 207: function free_result($query_id = false) |
| | 208: { |
| | 209: return true; |
| | 210: } |
| | 211: |
| | 212: |
| | 213: function escape($str) |
| | 214: { |
| | 215: return is_array($str) ? '' : sqlite_escape_string($str); |
| | 216: } |
| | 217: |
| | 218: |
| | 219: function error() |
| | 220: { |
| | 221: $result['error_sql'] = @current(@end($this->saved_queries)); |
| | 222: $result['error_no'] = $this->error_no; |
| | 223: $result['error_msg'] = $this->error_msg; |
| | 224: |
| | 225: return $result; |
| | 226: } |
| | 227: |
| | 228: |
| | 229: function close() |
| | 230: { |
| | 231: if ($this->link_id) |
| | 232: { |
| | 233: if ($this->in_transaction) |
| | 234: { |
| | 235: if (defined('PUN_SHOW_QUERIES')) |
| | 236: $this->saved_queries[] = array('COMMIT', 0); |
| | 237: |
| | 238: @sqlite_query($this->link_id, 'COMMIT'); |
| | 239: } |
| | 240: |
| | 241: return @sqlite_close($this->link_id); |
| | 242: } |
| | 243: else |
| | 244: return false; |
| | 245: } |
| | 246: |
| | 247: |
| | 248: function get_names() |
| | 249: { |
| | 250: return ''; |
| | 251: } |
| | 252: |
| | 253: |
| | 254: function set_names($names) |
| | 255: { |
| | 256: return true; |
| | 257: } |
| | 258: |
| | 259: |
| | 260: function get_version() |
| | 261: { |
| | 262: return array( |
| | 263: 'name' => 'SQLite', |
| | 264: 'version' => sqlite_libversion() |
| | 265: ); |
| | 266: } |
| | 267: |
| | 268: |
| | 269: function table_exists($table_name, $no_prefix = false) |
| | 270: { |
| | 271: $result = $this->query('SELECT 1 FROM sqlite_master WHERE name = \''.($no_prefix ? '' : $this->prefix).$this->escape($table_name).'\' AND type=\'table\''); |
| | 272: return $this->num_rows($result) > 0; |
| | 273: } |
| | 274: |
| | 275: |
| | 276: function field_exists($table_name, $field_name, $no_prefix = false) |
| | 277: { |
| | 278: $result = $this->query('SELECT sql FROM sqlite_master WHERE name = \''.($no_prefix ? '' : $this->prefix).$this->escape($table_name).'\' AND type=\'table\''); |
| | 279: if (!$this->num_rows($result)) |
| | 280: return false; |
| | 281: |
| | 282: return preg_match('/[\r\n]'.preg_quote($field_name).' /', $this->result($result)); |
| | 283: } |
| | 284: |
| | 285: |
| | 286: function index_exists($table_name, $index_name, $no_prefix = false) |
| | 287: { |
| | 288: $result = $this->query('SELECT 1 FROM sqlite_master WHERE tbl_name = \''.($no_prefix ? '' : $this->prefix).$this->escape($table_name).'\' AND name = \''.($no_prefix ? '' : $this->prefix).$this->escape($table_name).'_'.$this->escape($index_name).'\' AND type=\'index\''); |
| | 289: return $this->num_rows($result) > 0; |
| | 290: } |
| | 291: |
| | 292: |
| | 293: function create_table($table_name, $schema, $no_prefix = false) |
| | 294: { |
| | 295: if ($this->table_exists($table_name, $no_prefix)) |
| | 296: return true; |
| | 297: |
| | 298: $query = 'CREATE TABLE '.($no_prefix ? '' : $this->prefix).$table_name." (\n"; |
| | 299: |
| | 300: // Go through every schema element and add it to the query |
| | 301: foreach ($schema['FIELDS'] as $field_name => $field_data) |
| | 302: { |
| | 303: $field_data['datatype'] = preg_replace(array_keys($this->datatype_transformations), array_values($this->datatype_transformations), $field_data['datatype']); |
| | 304: |
| | 305: $query .= $field_name.' '.$field_data['datatype']; |
| | 306: |
| | 307: if (!$field_data['allow_null']) |
| | 308: $query .= ' NOT NULL'; |
| | 309: |
| | 310: if (isset($field_data['default'])) |
| | 311: $query .= ' DEFAULT '.$field_data['default']; |
| | 312: |
| | 313: $query .= ",\n"; |
| | 314: } |
| | 315: |
| | 316: // If we have a primary key, add it |
| | 317: if (isset($schema['PRIMARY KEY'])) |
| | 318: $query .= 'PRIMARY KEY ('.implode(',', $schema['PRIMARY KEY']).'),'."\n"; |
| | 319: |
| | 320: // Add unique keys |
| | 321: if (isset($schema['UNIQUE KEYS'])) |
| | 322: { |
| | 323: foreach ($schema['UNIQUE KEYS'] as $key_name => $key_fields) |
| | 324: $query .= 'UNIQUE ('.implode(',', $key_fields).'),'."\n"; |
| | 325: } |
| | 326: |
| | 327: // We remove the last two characters (a newline and a comma) and add on the ending |
| | 328: $query = substr($query, 0, strlen($query) - 2)."\n".')'; |
| | 329: |
| | 330: $result = $this->query($query) ? true : false; |
| | 331: |
| | 332: // Add indexes |
| | 333: if (isset($schema['INDEXES'])) |
| | 334: { |
| | 335: foreach ($schema['INDEXES'] as $index_name => $index_fields) |
| | 336: $result &= $this->add_index($table_name, $index_name, $index_fields, false, $no_prefix); |
| | 337: } |
| | 338: |
| | 339: return $result; |
| | 340: } |
| | 341: |
| | 342: |
| | 343: function drop_table($table_name, $no_prefix = false) |
| | 344: { |
| | 345: if (!$this->table_exists($table_name, $no_prefix)) |
| | 346: return true; |
| | 347: |
| | 348: return $this->query('DROP TABLE '.($no_prefix ? '' : $this->prefix).$table_name) ? true : false; |
| | 349: } |
| | 350: |
| | 351: |
| | 352: function get_table_info($table_name, $no_prefix = false) |
| | 353: { |
| | 354: // Grab table info |
| | 355: $result = $this->query('SELECT sql FROM sqlite_master WHERE tbl_name = \''.($no_prefix ? '' : $this->prefix).$this->escape($table_name).'\' ORDER BY type DESC') or error('Unable to fetch table information', __FILE__, __LINE__, $this->error()); |
| | 356: $num_rows = $this->num_rows($result); |
| | 357: |
| | 358: if ($num_rows == 0) |
| | 359: return; |
| | 360: |
| | 361: $table = array(); |
| | 362: $table['indices'] = array(); |
| | 363: while ($cur_index = $this->fetch_assoc($result)) |
| | 364: { |
| | 365: if (empty($cur_index['sql'])) |
| | 366: continue; |
| | 367: |
| | 368: if (!isset($table['sql'])) |
| | 369: $table['sql'] = $cur_index['sql']; |
| | 370: else |
| | 371: $table['indices'][] = $cur_index['sql']; |
| | 372: } |
| | 373: |
| | 374: // Work out the columns in the table currently |
| | 375: $table_lines = explode("\n", $table['sql']); |
| | 376: $table['columns'] = array(); |
| | 377: foreach ($table_lines as $table_line) |
| | 378: { |
| | 379: $table_line = pun_trim($table_line); |
| | 380: if (substr($table_line, 0, 12) == 'CREATE TABLE') |
| | 381: continue; |
| | 382: else if (substr($table_line, 0, 11) == 'PRIMARY KEY') |
| | 383: $table['primary_key'] = $table_line; |
| | 384: else if (substr($table_line, 0, 6) == 'UNIQUE') |
| | 385: $table['unique'] = $table_line; |
| | 386: else if (substr($table_line, 0, strpos($table_line, ' ')) != '') |
| | 387: $table['columns'][substr($table_line, 0, strpos($table_line, ' '))] = pun_trim(substr($table_line, strpos($table_line, ' '))); |
| | 388: } |
| | 389: |
| | 390: return $table; |
| | 391: } |
| | 392: |
| | 393: |
| | 394: function add_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = 0, $no_prefix = false) |
| | 395: { |
| | 396: if ($this->field_exists($table_name, $field_name, $no_prefix)) |
| | 397: return true; |
| | 398: |
| | 399: $table = $this->get_table_info($table_name, $no_prefix); |
| | 400: |
| | 401: // Create temp table |
| | 402: $now = time(); |
| | 403: $tmptable = str_replace('CREATE TABLE '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).' (', 'CREATE TABLE '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).'_t'.$now.' (', $table['sql']); |
| | 404: $result = $this->query($tmptable) ? true : false; |
| | 405: $result &= $this->query('INSERT INTO '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).'_t'.$now.' SELECT * FROM '.($no_prefix ? '' : $this->prefix).$this->escape($table_name)) ? true : false; |
| | 406: |
| | 407: // Create new table sql |
| | 408: $field_type = preg_replace(array_keys($this->datatype_transformations), array_values($this->datatype_transformations), $field_type); |
| | 409: $query = $field_type; |
| | 410: if (!$allow_null) |
| | 411: $query .= ' NOT NULL'; |
| | 412: if ($default_value === null || $default_value === '') |
| | 413: $default_value = '\'\''; |
| | 414: |
| | 415: $query .= ' DEFAULT '.$default_value; |
| | 416: |
| | 417: $old_columns = array_keys($table['columns']); |
| | 418: array_insert($table['columns'], $after_field, $query.',', $field_name); |
| | 419: |
| | 420: $new_table = 'CREATE TABLE '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).' ('; |
| | 421: |
| | 422: foreach ($table['columns'] as $cur_column => $column_details) |
| | 423: $new_table .= "\n".$cur_column.' '.$column_details; |
| | 424: |
| | 425: if (isset($table['unique'])) |
| | 426: $new_table .= "\n".$table['unique'].','; |
| | 427: |
| | 428: if (isset($table['primary_key'])) |
| | 429: $new_table .= "\n".$table['primary_key']; |
| | 430: |
| | 431: $new_table = trim($new_table, ',')."\n".');'; |
| | 432: |
| | 433: // Drop old table |
| | 434: $result &= $this->drop_table(($no_prefix ? '' : $this->prefix).$this->escape($table_name)); |
| | 435: |
| | 436: // Create new table |
| | 437: $result &= $this->query($new_table) ? true : false; |
| | 438: |
| | 439: // Recreate indexes |
| | 440: if (!empty($table['indices'])) |
| | 441: { |
| | 442: foreach ($table['indices'] as $cur_index) |
| | 443: $result &= $this->query($cur_index) ? true : false; |
| | 444: } |
| | 445: |
| | 446: // Copy content back |
| | 447: $result &= $this->query('INSERT INTO '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).' ('.implode(', ', $old_columns).') SELECT * FROM '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).'_t'.$now) ? true : false; |
| | 448: |
| | 449: // Drop temp table |
| | 450: $result &= $this->drop_table(($no_prefix ? '' : $this->prefix).$this->escape($table_name).'_t'.$now); |
| | 451: |
| | 452: return $result; |
| | 453: } |
| | 454: |
| | 455: |
| | 456: function alter_field($table_name, $field_name, $field_type, $allow_null, $default_value = null, $after_field = 0, $no_prefix = false) |
| | 457: { |
| | 458: // Unneeded for SQLite |
| | 459: return true; |
| | 460: } |
| | 461: |
| | 462: |
| | 463: function drop_field($table_name, $field_name, $no_prefix = false) |
| | 464: { |
| | 465: if (!$this->field_exists($table_name, $field_name, $no_prefix)) |
| | 466: return true; |
| | 467: |
| | 468: $table = $this->get_table_info($table_name, $no_prefix); |
| | 469: |
| | 470: // Create temp table |
| | 471: $now = time(); |
| | 472: $tmptable = str_replace('CREATE TABLE '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).' (', 'CREATE TABLE '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).'_t'.$now.' (', $table['sql']); |
| | 473: $result = $this->query($tmptable) ? true : false; |
| | 474: $result &= $this->query('INSERT INTO '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).'_t'.$now.' SELECT * FROM '.($no_prefix ? '' : $this->prefix).$this->escape($table_name)) ? true : false; |
| | 475: |
| | 476: // Work out the columns we need to keep and the sql for the new table |
| | 477: unset($table['columns'][$field_name]); |
| | 478: $new_columns = array_keys($table['columns']); |
| | 479: |
| | 480: $new_table = 'CREATE TABLE '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).' ('; |
| | 481: |
| | 482: foreach ($table['columns'] as $cur_column => $column_details) |
| | 483: $new_table .= "\n".$cur_column.' '.$column_details; |
| | 484: |
| | 485: if (isset($table['unique'])) |
| | 486: $new_table .= "\n".$table['unique'].','; |
| | 487: |
| | 488: if (isset($table['primary_key'])) |
| | 489: $new_table .= "\n".$table['primary_key']; |
| | 490: |
| | 491: $new_table = trim($new_table, ',')."\n".');'; |
| | 492: |
| | 493: // Drop old table |
| | 494: $result &= $this->drop_table(($no_prefix ? '' : $this->prefix).$this->escape($table_name)); |
| | 495: |
| | 496: // Create new table |
| | 497: $result &= $this->query($new_table) ? true : false; |
| | 498: |
| | 499: // Recreate indexes |
| | 500: if (!empty($table['indices'])) |
| | 501: { |
| | 502: foreach ($table['indices'] as $cur_index) |
| | 503: if (!preg_match('%\('.preg_quote($field_name, '%').'\)%', $cur_index)) |
| | 504: $result &= $this->query($cur_index) ? true : false; |
| | 505: } |
| | 506: |
| | 507: // Copy content back |
| | 508: $result &= $this->query('INSERT INTO '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).' SELECT '.implode(', ', $new_columns).' FROM '.($no_prefix ? '' : $this->prefix).$this->escape($table_name).'_t'.$now) ? true : false; |
| | 509: |
| | 510: // Drop temp table |
| | 511: $result &= $this->drop_table(($no_prefix ? '' : $this->prefix).$this->escape($table_name).'_t'.$now); |
| | 512: |
| | 513: return $result; |
| | 514: } |
| | 515: |
| | 516: |
| | 517: function add_index($table_name, $index_name, $index_fields, $unique = false, $no_prefix = false) |
| | 518: { |
| | 519: if ($this->index_exists($table_name, $index_name, $no_prefix)) |
| | 520: return true; |
| | 521: |
| | 522: return $this->query('CREATE '.($unique ? 'UNIQUE ' : '').'INDEX '.($no_prefix ? '' : $this->prefix).$table_name.'_'.$index_name.' ON '.($no_prefix ? '' : $this->prefix).$table_name.'('.implode(',', $index_fields).')') ? true : false; |
| | 523: } |
| | 524: |
| | 525: |
| | 526: function drop_index($table_name, $index_name, $no_prefix = false) |
| | 527: { |
| | 528: if (!$this->index_exists($table_name, $index_name, $no_prefix)) |
| | 529: return true; |
| | 530: |
| | 531: return $this->query('DROP INDEX '.($no_prefix ? '' : $this->prefix).$table_name.'_'.$index_name) ? true : false; |
| | 532: } |
| | 533: |
| | 534: function truncate_table($table_name, $no_prefix = false) |
| | 535: { |
| | 536: return $this->query('DELETE FROM '.($no_prefix ? '' : $this->prefix).$table_name) ? true : false; |
| | 537: } |
| | 538: } |