diff --git a/e107_admin/banlist.php b/e107_admin/banlist.php index 323aa2d12..8862e47b4 100644 --- a/e107_admin/banlist.php +++ b/e107_admin/banlist.php @@ -9,45 +9,53 @@ * Ban List Management * * $Source: /cvs_backup/e107_0.8/e107_admin/banlist.php,v $ - * $Revision: 1.22 $ - * $Date: 2009-11-18 01:04:25 $ - * $Author: e107coders $ + * $Revision: 1.23 $ + * $Date: 2009-12-19 23:04:42 $ + * $Author: e107steved $ * */ +/** + * e107 Banlist administration + * + * @package e107 + * @subpackage admin + * @version $Id: banlist.php,v 1.23 2009-12-19 23:04:42 e107steved Exp $; + */ + define('BAN_TIME_FORMAT', "%d-%m-%Y %H:%M"); define('BAN_REASON_COUNT', 7); // Update as more ban reasons added (max 10 supported) -define('BAN_TYPE_MANUAL', 1); // Manually entered bans -define('BAN_TYPE_IMPORTED', 5); // Imported bans -define('BAN_TYPE_TEMPORARY', 9); // Used during CSV import +define('BAN_TYPE_MANUAL', 1); // Manually entered bans +define('BAN_TYPE_IMPORTED', 5); // Imported bans +define('BAN_TYPE_TEMPORARY', 9); // Used during CSV import -define('BAN_TYPE_WHITELIST', 100); // Entry for whitelist +define('BAN_TYPE_WHITELIST', 100); // Entry for whitelist -require_once ("../class2.php"); -if(!getperms("4")) +require_once ('../class2.php'); +if(!getperms('4')) { - header("location:".e_BASE."index.php"); + header('location:'.e_BASE.'index.php'); exit(); } include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE); $e_sub_cat = 'banlist'; -require_once ("auth.php"); -require_once (e_HANDLER."form_handler.php"); +require_once ('auth.php'); +require_once (e_HANDLER.'form_handler.php'); $frm = new e_form(true); -require_once(e_HANDLER."message_handler.php"); +require_once(e_HANDLER.'message_handler.php'); $emessage = &eMessage::getInstance(); $action = 'list'; if(e_QUERY) { - $tmp = explode("-", e_QUERY); // Use '-' instead of '.' to avoid confusion with IP addresses + $tmp = explode('-', e_QUERY); // Use '-' instead of '.' to avoid confusion with IP addresses $action = $tmp[0]; $sub_action = varset($tmp[1], ''); if($sub_action) @@ -58,12 +66,14 @@ if(e_QUERY) $images_path = e_IMAGE_ABS.'admin_images/'; + + if(isset($_POST['update_ban_prefs'])) { for($i = 0; $i < BAN_REASON_COUNT; $i ++) { - $pref['ban_messages'][$i] = $tp->toDB(varset($_POST['ban_text'][$i], '')); - $pref['ban_durations'][$i] = intval(varset($_POST['ban_time'][$i], 0)); + $pref['ban_messages'][$i] = $tp->toDB(varset($_POST['ban_text_'.($i+1)], '')); + $pref['ban_durations'][$i] = intval(varset($_POST['ban_time_'.($i+1)], 0)); } save_prefs(); banlist_adminlog('08', ""); @@ -71,6 +81,7 @@ if(isset($_POST['update_ban_prefs'])) $emessage->add(BANLAN_33, E_MESSAGE_SUCCESS); } + if(isset($_POST['ban_ip'])) { $_POST['ban_ip'] = trim($_POST['ban_ip']); @@ -148,6 +159,8 @@ if(isset($_POST['ban_ip'])) } } + + // Remove a ban if(($action == "remove" || $action == "whremove") && varsettrue($_POST['ban_secure'])) //if ($action == "remove") @@ -166,21 +179,28 @@ if(($action == "remove" || $action == "whremove") && varsettrue($_POST['ban_secu } } + + // Update the ban expiry time/date - timed from now (only done on banlist) if($action == 'newtime') { $end_time = $id ? time() + ($id * 60 * 60) : 0; admin_update($sql->db_Update("banlist", "banlist_banexpires='".intval($end_time)."' WHERE banlist_ip='".$sub_action."'"), 'update', false, false, false); - banlist_adminlog("03", $sub_action); + banlist_adminlog('03', $sub_action); $action = 'list'; } + + +/** + * @todo - eliminate extract(); + */ // Edit modes - get existing entry -if($action == "edit" || $action == "whedit") +if($action == 'edit' || $action == 'whedit') { - $sql->db_Select("banlist", "*", "banlist_ip='{$sub_action}'"); + $sql->db_Select('banlist', '*', "banlist_ip='{$sub_action}'"); $row = $sql->db_Fetch(); - extract($row);//FIXME - kill extract() + extract($row); //FIXME - kill extract() } else { @@ -191,6 +211,8 @@ else } } + + function ban_time_dropdown($click_js = '', $zero_text = BANLAN_21, $curval = -1, $drop_name = 'ban_time') { global $frm; @@ -218,6 +240,8 @@ function ban_time_dropdown($click_js = '', $zero_text = BANLAN_21, $curval = -1, return $ret; } + + // Character options for import & export $separator_char = array(1 => ',', 2 => '|'); $quote_char = array(1 => '(none)', 2 => "'", 3 => '"'); @@ -235,7 +259,6 @@ function select_box($name, $data, $curval = FALSE) return $ret; } -$text = ""; // Drop-down box for access counts function drop_box($box_name, $curval) @@ -252,6 +275,11 @@ function drop_box($box_name, $curval) return $ret; } + + +$text = ''; + + switch($action) { case 'options': @@ -389,9 +417,9 @@ switch($action)