diff -r e3d7322305bf -r 5e1f1e916419 punbb/admin_bans.php
--- a/punbb/admin_bans.php Sun Sep 02 11:00:57 2007 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,365 +0,0 @@
-query('SELECT group_id, username, email FROM '.$pun_db->prefix.'users WHERE id='.$user_id) or error('Unable to fetch user info', __FILE__, __LINE__, $pun_db->error());
- if ($pun_db->num_rows($result))
- list($group_id, $ban_user, $ban_email) = $pun_db->fetch_row($result);
- else
- message('No user by that ID registered.');
- }
- else // Otherwise the username is in POST
- {
- $ban_user = trim($_POST['new_ban_user']);
-
- if ($ban_user != '')
- {
- $result = $pun_db->query('SELECT id, group_id, username, email FROM '.$pun_db->prefix.'users WHERE username=\''.$pun_db->escape($ban_user).'\' AND id>1') or error('Unable to fetch user info', __FILE__, __LINE__, $pun_db->error());
- if ($pun_db->num_rows($result))
- list($user_id, $group_id, $ban_user, $ban_email) = $pun_db->fetch_row($result);
- else
- message('No user by that username registered. If you want to add a ban not tied to a specific username just leave the username blank.');
- }
- }
-
- // Make sure we're not banning an admin
- if (isset($group_id) && $group_id == PUN_ADMIN)
- message('The user '.pun_htmlspecialchars($ban_user).' is an administrator and can\'t be banned. If you want to ban an administrator, you must first demote him/her to moderator or user.');
-
- // If we have a $user_id, we can try to find the last known IP of that user
- if (isset($user_id))
- {
- $result = $pun_db->query('SELECT poster_ip FROM '.$pun_db->prefix.'posts WHERE poster_id='.$user_id.' ORDER BY posted DESC LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $pun_db->error());
- $ban_ip = ($pun_db->num_rows($result)) ? $pun_db->result($result) : '';
- }
-
- $mode = 'add';
- }
- else // We are editing a ban
- {
- $ban_id = intval($_GET['edit_ban']);
- if ($ban_id < 1)
- message($lang_common['Bad request']);
-
- $result = $pun_db->query('SELECT username, ip, email, message, expire FROM '.$pun_db->prefix.'bans WHERE id='.$ban_id) or error('Unable to fetch ban info', __FILE__, __LINE__, $pun_db->error());
- if ($pun_db->num_rows($result))
- list($ban_user, $ban_ip, $ban_email, $ban_message, $ban_expire) = $pun_db->fetch_row($result);
- else
- message($lang_common['Bad request']);
-
- $ban_expire = ($ban_expire != '') ? date('Y-m-d', $ban_expire) : '';
-
- $mode = 'edit';
- }
-
- $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Bans';
- $focus_element = array('bans2', 'ban_user');
- require PUN_ROOT.'header.php';
-
- generate_admin_menu('bans');
-
-
-?>
-
-
-
- 1) ? ltrim($octets[$c], "0") : $octets[$c];
-
- if ($c > 3 || preg_match('/[^0-9]/', $octets[$c]) || intval($octets[$c]) > 255)
- message('You entered an invalid IP/IP-range.');
- }
-
- $cur_address = implode('.', $octets);
- $addresses[$i] = $cur_address;
- }
-
- $ban_ip = implode(' ', $addresses);
- }
-
- require PUN_ROOT.'include/email.php';
- if ($ban_email != '' && !is_valid_email($ban_email))
- {
- if (!preg_match('/^[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/', $ban_email))
- message('The e-mail address (e.g. user@domain.com) or partial e-mail address domain (e.g. domain.com) you entered is invalid.');
- }
-
- if ($ban_expire != '' && $ban_expire != 'Never')
- {
- $ban_expire = strtotime($ban_expire);
-
- if ($ban_expire == -1 || $ban_expire <= time())
- message('You entered an invalid expire date. The format should be YYYY-MM-DD and the date must be at least one day in the future.');
- }
- else
- $ban_expire = 'NULL';
-
- $ban_user = ($ban_user != '') ? '\''.$pun_db->escape($ban_user).'\'' : 'NULL';
- $ban_ip = ($ban_ip != '') ? '\''.$pun_db->escape($ban_ip).'\'' : 'NULL';
- $ban_email = ($ban_email != '') ? '\''.$pun_db->escape($ban_email).'\'' : 'NULL';
- $ban_message = ($ban_message != '') ? '\''.$pun_db->escape($ban_message).'\'' : 'NULL';
-
- if ($_POST['mode'] == 'add')
- $pun_db->query('INSERT INTO '.$pun_db->prefix.'bans (username, ip, email, message, expire) VALUES('.$ban_user.', '.$ban_ip.', '.$ban_email.', '.$ban_message.', '.$ban_expire.')') or error('Unable to add ban', __FILE__, __LINE__, $pun_db->error());
- else
- $pun_db->query('UPDATE '.$pun_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__, $pun_db->error());
-
- // Regenerate the bans cache
- require_once PUN_ROOT.'include/cache.php';
- generate_bans_cache();
-
- pun_redirect('admin_bans.php', 'Ban '.(($_POST['mode'] == 'edit') ? 'edited' : 'added').'. Redirecting …');
-}
-
-
-// Remove a ban
-else if (isset($_GET['del_ban']))
-{
- confirm_referrer('admin_bans.php');
-
- $ban_id = intval($_GET['del_ban']);
- if ($ban_id < 1)
- message($lang_common['Bad request']);
-
- $pun_db->query('DELETE FROM '.$pun_db->prefix.'bans WHERE id='.$ban_id) or error('Unable to delete ban', __FILE__, __LINE__, $pun_db->error());
-
- // Regenerate the bans cache
- require_once PUN_ROOT.'include/cache.php';
- generate_bans_cache();
-
- pun_redirect('admin_bans.php', 'Ban removed. Redirecting …');
-}
-
-
-$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Bans';
-$focus_element = array('bans', 'new_ban_user');
-require PUN_ROOT.'header.php';
-
-generate_admin_menu('bans');
-
-?>
-
-
-
-