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)
".constant('BANLAN_11'.$i)."
- ".$frm->textarea('ban_text[]', $pref['ban_messages'][$i], 4, 15)." + ".$frm->textarea('ban_text_'.($i+1), $pref['ban_messages'][$i], 4, 15)." - ".ban_time_dropdown('', BANLAN_32, $pref['ban_durations'][$i], 'ban_time[]')." + ".ban_time_dropdown('', BANLAN_32, $pref['ban_durations'][$i], 'ban_time_'.($i+1))." "; } @@ -408,10 +436,13 @@ switch($action) $e107->ns->tablerender(BANLAN_77, $emessage->render().$text); break; - case 'edit': - case 'add': - case 'whedit': - case 'whadd': + case 'edit': // Edit an existing ban + case 'add': // Add a new ban + case 'whedit': // Edit existing whitelist entry + case 'whadd': // Add a new whitelist entry + if (!isset($banlist_reason)) $banlist_reason = ''; + if (!isset($banlist_ip)) $banlist_ip = ''; + if (!isset($banlist_notes)) $banlist_notes = ''; $page_title = array('edit' => BANLAN_60, 'add' => BANLAN_9, 'whedit' => BANLAN_59, 'whadd' => BANLAN_58); $rdns_warn = varsettrue($pref['enable_rdns']) ? '' : '
'.BANLAN_12.'
'; $next = ($action == 'whedit' || $action == 'whadd') ? '?white' : '?list'; @@ -509,22 +540,17 @@ switch($action) "; */ - if($action == "edit" || $action == "whedit") + if($action == 'edit' || $action == 'whedit') { - $text .= " - - ".$frm->admin_button('update_ban', LAN_UPDATE, 'update')." - "; + $text .= " + ".$frm->admin_button('update_ban', LAN_UPDATE, 'update'); } else { - $text .= " - ".$frm->admin_button('add_ban', ($action == 'add' ? BANLAN_8 : BANLAN_53), 'create')." - "; + $text .= $frm->admin_button('add_ban', ($action == 'add' ? BANLAN_8 : BANLAN_53), 'create'); } - $text .= " - + $text .= " "; @@ -564,54 +590,39 @@ switch($action)
".BANLAN_40." - - + + + - - + + - - - "; + "; + for($i = 0; $i < BAN_REASON_COUNT; $i ++) { - $colspan = ($i > 1) ? "2" : '1'; - $text .= " - - + "; - - if($i == 0) - { - $text .= ""; - } - - if($i ==1) - { - $text .= ""; - } - - $text .= ""; } + $text .= " + + + "; $text .= " - - -
".BANLAN_36."".BANLAN_15."".BANLAN_36." 
+ ".$frm->checkbox("ban_types[{$i}]", $i).$frm->label(constant('BANLAN_10'.$i), "ban_types[{$i}]", $i)." (".constant('BANLAN_11'.$i).") -
".select_box('ban_separator', $separator_char).' '.BANLAN_37."".select_box('ban_quote', $quote_char).' '.BANLAN_38."
".BANLAN_79."".select_box('ban_separator', $separator_char).' '.BANLAN_37."".select_box('ban_quote', $quote_char).' '.BANLAN_38."
-
".$frm->admin_button('ban_export', BANLAN_39, 'export', BANLAN_39)."
- +
".$frm->admin_button('ban_export', BANLAN_39, 'export', BANLAN_39)."
"; @@ -622,28 +633,32 @@ switch($action)
".BANLAN_41." - - + + + - - + + - - + - - + + - + + + + +
".BANLAN_42."".BANLAN_15."".BANLAN_42." 
".$frm->checkbox('ban_over_import', 1).$frm->label(BANLAN_43, 'ban_over_import', 1)."".select_box('ban_separator', $separator_char).' '.BANLAN_37."".$frm->checkbox('ban_over_import', 1).$frm->label(BANLAN_43, 'ban_over_import', 1)."
".$frm->checkbox('ban_over_expiry', 1).$frm->label(BANLAN_44, 'ban_over_expiry', 1)."".select_box('ban_quote', $quote_char).' '.BANLAN_38."".$frm->checkbox('ban_over_expiry', 1).$frm->label(BANLAN_44, 'ban_over_expiry', 1)."
".BANLAN_46." - ".$frm->file('file_userfile[]')." + ".$frm->file('file_userfile[]', array('size' => '40'))."
".BANLAN_80."".select_box('ban_separator', $separator_char).' '.BANLAN_37."".select_box('ban_quote', $quote_char).' '.BANLAN_38."
@@ -653,10 +668,9 @@ switch($action)
- "; + "; - //XXX LAN - Import/Export - $e107->ns->tablerender("Import/Export", $emessage->render().$text); + $e107->ns->tablerender(BANLAN_35, $emessage->render().$text); break; case 'list': @@ -706,22 +720,16 @@ switch($action) foreach($col_titles[$action] as $ct) { $cnt ++; - $text .= " - {$ct} - "; + $text .= "{$ct}"; } - $text .= " - + $text .= " - - "; + "; while($row = $sql->db_Fetch()) { extract($row);//FIXME - kill extract() $banlist_reason = str_replace("LAN_LOGIN_18", BANLAN_11, $banlist_reason); - $text .= " - - "; + $text .= ""; foreach($col_defs[$action] as $cd => $fv) { $row_class = ''; @@ -750,16 +758,11 @@ switch($action) $val = $row[$cd]; } - $text .= " - {$val} - "; + $text .= "{$val}"; } - $text .= ' - - '; + $text .= ''; } - $text .= " - + $text .= "