diff --git a/class2.php b/class2.php
index af5cc9a7c..896440360 100644
--- a/class2.php
+++ b/class2.php
@@ -223,6 +223,9 @@ $e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY',
$sql_info = compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix');
$e107 = e107::getInstance()->initCore($e107_paths, realpath(dirname(__FILE__)), $sql_info, varset($E107_CONFIG, array()));
+e107::getSingleton('eIPHandler'); // This auto-handles bans etc
+
+
### NEW Register Autoload - do it asap
if(!function_exists('spl_autoload_register'))
{
@@ -777,8 +780,8 @@ if (!class_exists('e107table', false))
$ns = e107::getRender(); //TODO - find & replace $ns, $e107->ns
// EONE-134 - bad e_module could destroy e107 instance
-$e107 = e107::getInstance();
-$e107->ban();
+$e107 = e107::getInstance(); // Is this needed now?
+e107::getIPHandler()->ban();
if(varset($pref['force_userupdate']) && USER && !isset($_E107['no_forceuserupdate']))
{
diff --git a/e107_admin/banlist.php b/e107_admin/banlist.php
index 97e401f55..777ec5a6c 100644
--- a/e107_admin/banlist.php
+++ b/e107_admin/banlist.php
@@ -2,7 +2,7 @@
/*
* e107 website system
*
- * Copyright (C) 2008-2010 e107 Inc (e107.org)
+ * Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
@@ -21,70 +21,105 @@
* @version $Id$;
*/
-define('BAN_TIME_FORMAT', "%d-%m-%Y %H:%M");
-define('BAN_REASON_COUNT', 7); // Update as more ban reasons added (max 10 supported)
+
+require_once('../class2.php');
+/*
+@todo should this be here?
+if(count($_POST) && !varset($_POST['e-token']))
+{
+ die('Access denied - bl');
+}
+*/
-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
-
-
-require_once ('../class2.php');
-if(!getperms('4'))
+if (!getperms('4'))
{
header('location:'.e_BASE.'index.php');
exit();
}
+
+
+require_once(e_HANDLER.'iphandler_class.php'); // This is probably already loaded in class2.php
+
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');
$emessage = &eMessage::getInstance();
+$pref = e107::getPref();
+
+// Set a default to avoid issues with legacy systems
+if (!isset($pref['ban_date_format'])) $pref['ban_date_format'] = '%H:%M %d-%m-%y';
+
+$ipAdministrator = new banlistManager;
+
+// Character options for import & export
+$separator_char = array(1 => ',', 2 => '|');
+$quote_char = array(1 => '(none)', 2 => "'", 3 => '"');
+
+
$action = 'list';
-if(e_QUERY)
+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)
- $sub_action = preg_replace('/[^\w@\.:]*/', '', urldecode($sub_action));
+ if ($sub_action) $sub_action = preg_replace('/[^\w*@\.:]*/', '', urldecode($sub_action));
$id = intval(varset($tmp[2], 0));
unset($tmp);
}
-$images_path = e_IMAGE_ABS.'admin_images/';
-
-if(isset($_POST['update_ban_prefs']))
+if (isset($_POST['update_ban_prefs'])) // Update ban messages
{
- for($i = 0; $i < BAN_REASON_COUNT; $i ++)
+ $changed = FALSE;
+
+ foreach ($ipAdministrator->getValidReasonList() as $bt)
{
- $pref['ban_messages'][$i] = $tp->toDB(varset($_POST['ban_text_'.($i+1)], ''));
- $pref['ban_durations'][$i] = intval(varset($_POST['ban_time_'.($i+1)], 0));
+ $i = abs($bt) + 1; // Forces a single-digit positive number for part of field name
+ $t1 = $tp->toDB(varset($_POST['ban_text_'.($i)],''));
+ $t2 = intval(varset($_POST['ban_time_'.($i)],0));
+ if ($pref['ban_messages'][$bt] != $t1)
+ {
+ $pref['ban_messages'][$bt] = $t1;
+ $changed = TRUE;
+ }
+ if ($pref['ban_durations'][$bt] != $t2)
+ {
+ $pref['ban_durations'][$bt] = $t2;
+ $changed = TRUE;
+ }
+ }
+ if ($changed)
+ {
+ // @todo write actual prefs changes to log file (different methods for prefs?)
+ save_prefs();
+ /*****************************************
+ Write messages and times to disc file
+ *****************************************/
+ $ipAdministrator->writeBanMessageFile();
+ banlist_adminlog('08','');
+ //$ns->tablerender(BANLAN_9, "
".BANLAN_33.'
');
+ $emessage->add(BANLAN_33, E_MESSAGE_SUCCESS);
}
- save_prefs();
- banlist_adminlog('08', "");
- //$ns->tablerender(BANLAN_9, "".BANLAN_33.'
');
- $emessage->add(BANLAN_33, E_MESSAGE_SUCCESS);
}
-if(isset($_POST['ban_ip']))
+
+$writeBanFile = FALSE;
+if (isset($_POST['ban_ip']))
{
$_POST['ban_ip'] = trim($_POST['ban_ip']);
- $new_ban_ip = preg_replace('/[^\w@\.\*]*/', '', urldecode($_POST['ban_ip']));
- if($new_ban_ip != $_POST['ban_ip'])
+ $new_ban_ip = preg_replace('/[^\w*@\.:]*/', '', urldecode($_POST['ban_ip']));
+ if ($new_ban_ip != $_POST['ban_ip'])
{
$message = BANLAN_27.' '.$new_ban_ip;
//$ns->tablerender(BANLAN_9, $message);
@@ -92,100 +127,114 @@ if(isset($_POST['ban_ip']))
$_POST['ban_ip'] = $new_ban_ip;
}
- if(isset($_POST['entry_intent']) && (isset($_POST['add_ban']) || isset($_POST['update_ban'])) && $_POST['ban_ip'] != "" && strpos($_POST['ban_ip'], ' ') === false)
+ if (isset($_POST['entry_intent']) && (isset($_POST['add_ban']) || isset($_POST['update_ban'])) && $_POST['ban_ip'] != "" && strpos($_POST['ban_ip'], ' ') === false)
{
/* $_POST['entry_intent'] says why we're here:
- 'edit' - Editing blacklist
- 'add' - Adding to blacklist
- 'whedit' - Editing whitelist
- 'whadd' - Adding to whitelist
-*/
- if($e107->whatIsThis($new_ban_ip) == 'ip')
+ 'edit' - Editing blacklist
+ 'add' - Adding to blacklist
+ 'whedit' - Editing whitelist
+ 'whadd' - Adding to whitelist
+ */
+ if(e107::getIPHandler()->whatIsThis($new_ban_ip) == 'ip')
{
- $new_ban_ip = $e107->IPencode($new_ban_ip); // Normalise numeric IP addresses
+ $new_ban_ip = e107::getIPHandler()->IPencode($new_ban_ip, TRUE); // Normalise numeric IP addresses (allow wildcards)
}
$new_vals = array('banlist_ip' => $new_ban_ip);
- if(isset($_POST['add_ban']))
+ if (isset($_POST['add_ban']))
{
$new_vals['banlist_datestamp'] = time();
- if($_POST['entry_intent'] == 'add')
- $new_vals['banlist_bantype'] = BAN_TYPE_MANUAL; // Manual ban
- if($_POST['entry_intent'] == 'whadd')
- $new_vals['banlist_bantype'] = BAN_TYPE_WHITELIST;
+ if ($_POST['entry_intent'] == 'add') $new_vals['banlist_bantype'] = eIPHandler::BAN_TYPE_MANUAL; // Manual ban
+ if ($_POST['entry_intent'] == 'whadd') $new_vals['banlist_bantype'] = eIPHandler::BAN_TYPE_WHITELIST;
}
$new_vals['banlist_admin'] = ADMINID;
- if(varsettrue($_POST['ban_reason']))
- $new_vals['banlist_reason'] = $tp->toDB($_POST['ban_reason']);
+ $new_vals['banlist_reason'] = $tp->toDB(varset($_POST['ban_reason'], ''));
$new_vals['banlist_notes'] = $tp->toDB($_POST['ban_notes']);
- if(isset($_POST['ban_time']) && is_numeric($_POST['ban_time']) && ($_POST['entry_intent'] == 'edit' || $_POST['entry_intent'] == 'add'))
+ if (isset($_POST['ban_time']) && is_numeric($_POST['ban_time']) && (($_POST['entry_intent']== 'edit') || ($_POST['entry_intent'] == 'add')))
{
$bt = intval($_POST['ban_time']);
- $new_vals['banlist_banexpires'] = $bt ? time() + ($bt * 60 * 60) : 0;
+ $new_vals['banlist_banexpires'] = $bt ? time() + ($bt*60*60) : 0;
}
- if(isset($_POST['add_ban']))
- { // Insert new value - can just pass an array
- admin_update($sql->db_Insert("banlist", $new_vals), 'insert', false, false, false);
- if($_POST['entry_intent'] == 'add')
+ if (isset($_POST['add_ban']))
+ { // Insert new value - can just pass an array
+ admin_update($sql->db_Insert('banlist', $new_vals), 'insert');
+ if ($_POST['entry_intent'] == 'add')
{
- banlist_adminlog('01', $new_vals['banlist_ip']);
+ banlist_adminlog('01', $new_vals['banlist_ip']); // Write to banlist
}
else
{
- banlist_adminlog('04', $new_vals['banlist_ip']);
+ banlist_adminlog('04', $new_vals['banlist_ip']); // Write to whitelist
}
}
else
- { // Update existing value
+ { // Update existing value
$qry = '';
$spacer = '';
- foreach($new_vals as $k => $v)
+ foreach ($new_vals as $k => $v)
{
$qry .= $spacer."`{$k}`='$v'";
$spacer = ', ';
}
- admin_update($sql->db_Update("banlist", $qry." WHERE banlist_ip='".$_POST['old_ip']."'"), 'update', false, false, false);
- if($_POST['entry_intent'] == 'edit')
+ admin_update($sql->db_Update('banlist', $qry." WHERE banlist_ip='".$_POST['old_ip']."'"));
+ if ($_POST['entry_intent'] == 'edit')
{
- banlist_adminlog("09", $new_vals['banlist_ip']);
+ banlist_adminlog('09',$new_vals['banlist_ip']);
}
else
{
- banlist_adminlog("10", $new_vals['banlist_ip']);
+ banlist_adminlog('10',$new_vals['banlist_ip']);
}
}
unset($ban_ip);
+ $writeBanFile = TRUE;
}
}
// Remove a ban
-if(($action == "remove" || $action == "whremove") && varsettrue($_POST['ban_secure']))
-//if ($action == "remove")
+if (($action == 'remove' || $action == 'whremove') && isset($_POST['ban_secure']))
{
- $sql->db_Delete("generic", "gen_type='failed_login' AND gen_ip='{$sub_action}'");
- admin_update($sql->db_Delete("banlist", "banlist_ip='{$sub_action}'"), 'delete', false, false, false);
- if($action == "remove")
+ $sql->db_Delete('generic', "gen_type='failed_login' AND gen_ip='{$sub_action}'");
+ admin_update($sql->db_Delete('banlist', "banlist_ip='{$sub_action}'"), 'delete');
+ if ($action == "remove")
{
$action = 'list';
- banlist_adminlog("02", $sub_action);
+ banlist_adminlog('02', $sub_action);
}
else
{
$action = 'white';
- banlist_adminlog("05", $sub_action);
+ banlist_adminlog('05', $sub_action);
}
+ $writeBanFile = TRUE;
}
// Update the ban expiry time/date - timed from now (only done on banlist)
-if($action == 'newtime')
+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);
+ $end_time = $id ? time() + ($id*60*60) : 0;
+ admin_update($sql->db_Update('banlist', 'banlist_banexpires='.intval($end_time)." WHERE banlist_ip='".$sub_action."'"));
banlist_adminlog('03', $sub_action);
$action = 'list';
+ $writeBanFile = TRUE;
+}
+
+
+if ($writeBanFile)
+{
+/************************************************
+ update list of banned IPs
+*************************************************/
+ $ipAdministrator->writeBanListFiles('ip,htaccess');
+ if (!$ipAdministrator->doesMessageFileExist())
+ {
+ $ipAdministrator->writeBanMessageFile(); // Message file must exist - may not on fresh site
+ banlist_adminlog('08','');
+ $emessage->add(BANLAN_33, E_MESSAGE_SUCCESS);
+ }
}
@@ -194,7 +243,7 @@ if($action == 'newtime')
* @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}'");
$row = $sql->db_Fetch();
@@ -203,7 +252,7 @@ if($action == 'edit' || $action == 'whedit')
else
{
unset($banlist_ip, $banlist_reason);
- if(e_QUERY && ($action == 'add' || $action == 'whadd') && strpos($_SERVER["HTTP_REFERER"], "userinfo"))
+ if (e_QUERY && ($action == 'add' || $action == 'whadd') && strpos($_SERVER["HTTP_REFERER"], "userinfo"))
{
$banlist_ip = $sub_action;
}
@@ -211,6 +260,9 @@ else
+/**
+ * Create dropdown with options for ban time - uses internal fixed list of reasonable values
+ */
function ban_time_dropdown($click_js = '', $zero_text = BANLAN_21, $curval = -1, $drop_name = 'ban_time')
{
global $frm;
@@ -218,13 +270,13 @@ function ban_time_dropdown($click_js = '', $zero_text = BANLAN_21, $curval = -1,
$ret = $frm->select_open($drop_name, array('other' => $click_js, 'id' => false));
$ret .= $frm->option(' ', '');
- foreach($intervals as $i)
+ foreach ($intervals as $i)
{
- if($i == 0)
+ if ($i == 0)
{
$words = $zero_text ? $zero_text : BANLAN_21;
}
- elseif(($i % 24) == 0)
+ elseif (($i % 24) == 0)
{
$words = floor($i / 24).' '.BANLAN_23;
}
@@ -240,16 +292,16 @@ function ban_time_dropdown($click_js = '', $zero_text = BANLAN_21, $curval = -1,
-// Character options for import & export
-$separator_char = array(1 => ',', 2 => '|');
-$quote_char = array(1 => '(none)', 2 => "'", 3 => '"');
+/**
+ * Create generic dropdown from array of data
+ */
function select_box($name, $data, $curval = FALSE)
{
global $frm;
$ret = $frm->select_open($name, array('class' => 'tbox', 'id' => false));
- foreach($data as $k => $v)
+ foreach ($data as $k => $v)
{
$ret .= $frm->option($v, $k, ($curval !== FALSE) && ($curval == $k));
}
@@ -258,14 +310,17 @@ function select_box($name, $data, $curval = FALSE)
}
-// Drop-down box for access counts
+
+/**
+ * Create dropdown with options for access counts before ban - uses internal fixed list of reasonable values
+ */
function drop_box($box_name, $curval)
{
global $frm;
$opts = array(50, 100, 150, 200, 250, 300, 400, 500);
$ret = $frm->select_open($box_name, array('class' => 'tbox'));
- foreach($opts as $o)
+ foreach ($opts as $o)
{
$ret .= $frm->option($o, $o, ($curval == $o));
}
@@ -278,25 +333,95 @@ function drop_box($box_name, $curval)
$text = '';
-switch($action)
+switch ($action)
{
- case 'options':
- if(!getperms("0"))
+ case 'banlog' :
+ if(!getperms('0')) exit;
+ if (isset($_POST['delete_ban_log']))
+ {
+ $message = ($ipAdministrator->deleteLogFile() ? BANLAN_89 : BANLAN_90);
+ e107::getRender()->tablerender(BANLAN_88, "".$message."
");
+ }
+ $from = 0;
+ $amount = 20; // Number per page - could make configurable later if required
+ if ($sub_action) $from = intval($sub_action);
+
+// @todo format form the 0.8 way
+ $text = "";
+
+ if (count($banLogEntries))
+ {
+ $text .= " ".str_replace('--NUM--', $num_entry, BANLAN_87);
+ }
+
+ e107::getRender()->tablerender("".BANLAN_86.'
', $text);
+ break;
+
+
+ case 'options' :
+ if (!getperms('0'))
exit();
- if(isset($_POST['update_ban_options']))
+ if (isset($_POST['update_ban_options']))
{
$pref['enable_rdns'] = intval($_POST['ban_rdns_on_access']);
$pref['enable_rdns_on_ban'] = intval($_POST['ban_rdns_on_ban']);
$pref['ban_max_online_access'] = intval($_POST['ban_access_guest']).','.intval($_POST['ban_access_member']);
$pref['ban_retrigger'] = intval($_POST['ban_retrigger']);
- save_prefs();
+ $pref['ban_date_format'] = $tp->toDB($_POST['ban_date_format']);
+ save_prefs(); // @todo FIXME log detail of changes. Right prefs to use?
$emessage->add(LAN_SETSAVED, E_MESSAGE_SUCCESS);
}
- if(isset($_POST['remove_expired_bans']))
+ if (isset($_POST['remove_expired_bans']))
{
- //FIXME - proper messages
- admin_update($sql->db_Delete('banlist', "`banlist_bantype` < ".BAN_TYPE_WHITELIST." AND `banlist_banexpires` > 0 AND `banlist_banexpires` < ".time()), 'delete', false, false, false);
+ $result = $sql->db_Delete('banlist',"`banlist_bantype` < ".eIPHandler::BAN_TYPE_WHITELIST." AND `banlist_banexpires` > 0 AND `banlist_banexpires` < ".time());
+ banlist_adminlog('12', $result);
+ $emessage->add(str_replace('--NUM--', $result, BANLAN_48), E_MESSAGE_SUCCESS);
}
list($ban_access_guest, $ban_access_member) = explode(',', varset($pref['ban_max_online_access'], '100,200'));
@@ -346,10 +471,19 @@ switch($action)
+
+
+ ".BANLAN_91."
+
+ ".$frm->text('ban_date_format', varset($pref['ban_date_format'], '%H:%M %d-%m-%y'), 40)."
+ ".BANLAN_92."
+
+
".$frm->admin_button('update_ban_options', LAN_UPDATE, 'update')."
+
@@ -364,6 +498,7 @@ switch($action)
".BANLAN_75."
".$frm->admin_button('remove_expired_bans', BANLAN_76, 'delete')."
+
@@ -371,20 +506,26 @@ switch($action)
";
- $e107->ns->tablerender(BANLAN_72, $emessage->render().$text);
+ e107::getRender()->tablerender(BANLAN_72, $emessage->render().$text);
break;
- case 'times':
- if(!getperms("0"))
+ case 'times' :
+ if (!getperms('0'))
exit();
$text = '';
- if((!isset($pref['ban_messages'])) || !is_array($pref['ban_messages']))
+ if ((!isset($pref['ban_messages'])) || !is_array($pref['ban_messages']))
{
- $pref['ban_messages'] = array_fill(0, BAN_REASON_COUNT - 1, '');
+ foreach ($ipAdministrator->getValidReasonList() as $bt)
+ {
+ $pref['ban_messages'][$bt] = '';
+ }
}
- if((!isset($pref['ban_durations'])) || !is_array($pref['ban_durations']))
+ if ((!isset($pref['ban_durations'])) || !is_array($pref['ban_durations']))
{
- $pref['ban_durations'] = array_fill(0, BAN_REASON_COUNT - 1, 0);
+ foreach ($ipAdministrator->getValidReasonList() as $bt)
+ {
+ $pref['ban_durations'][$bt] = 0;
+ }
}
$text .= "
@@ -406,19 +547,20 @@ switch($action)
";
- for($i = 0; $i < BAN_REASON_COUNT; $i ++)
+ foreach ($ipAdministrator->getValidReasonList() as $bt)
{
+ $i = abs($bt) + 1; // Forces a single-digit positive number
$text .= "
-
-
- ".constant('BANLAN_10'.$i)."
- ".constant('BANLAN_11'.$i)."
-
-
- ".$frm->textarea('ban_text_'.($i+1), $pref['ban_messages'][$i], 4, 15)."
-
- ".ban_time_dropdown('', BANLAN_32, $pref['ban_durations'][$i], 'ban_time_'.($i+1))."
-
+
+
+ ".$ipAdministrator->getBanTypeString($bt, FALSE)."
+ ".$ipAdministrator->getBanTypeString($bt, TRUE)."
+
+
+ ".$frm->textarea('ban_text_'.($i), $pref['ban_messages'][$bt], 4, 15)."
+
+ ".ban_time_dropdown('', BANLAN_32, $pref['ban_durations'][$bt], 'ban_time_'.($i))."
+
";
}
$text .= "
@@ -426,21 +568,23 @@ switch($action)
".$frm->admin_button('update_ban_prefs', LAN_UPDATE, 'update')."
+
";
- $e107->ns->tablerender(BANLAN_77, $emessage->render().$text);
+ e107::getRender()->tablerender(BANLAN_77, $emessage->render().$text);
break;
- 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
+ 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';
@@ -459,18 +603,18 @@ switch($action)
".BANLAN_5.":
- ".BANLAN_13."
+ ".BANLAN_13."
- ".$frm->text('ban_ip', $e107->ipDecode($banlist_ip), 200)."
+ ".$frm->text('ban_ip', e107::getIPHandler()->ipDecode($banlist_ip), 200)."
{$rdns_warn}
";
- if(($action == 'add') || ($action == 'whadd') || ($banlist_bantype <= 1) || ($banlist_bantype >= BAN_TYPE_WHITELIST))
+ if (($action == 'add') || ($action == 'whadd') || ($banlist_bantype <= 1) || ($banlist_bantype >= eIPHandler::BAN_TYPE_WHITELIST))
{ // Its a manual or unknown entry - only allow edit of reason on those
$text .= "
@@ -481,7 +625,7 @@ switch($action)
";
}
- elseif($action == 'edit')
+ elseif ($action == 'edit')
{
$text .= "
@@ -491,12 +635,12 @@ switch($action)
";
}
- if($action == 'edit')
+ if ($action == 'edit')
{
$text .= "
".BANLAN_28.":
- ".constant('BANLAN_10'.$banlist_bantype)." - ".constant('BANLAN_11'.$banlist_bantype)."
+ ".$ipAdministrator->getBanTypeString($banlist_bantype, FALSE)." - ".$ipAdministrator->getBanTypeString($banlist_bantype, TRUE)."
";
}
@@ -510,9 +654,9 @@ switch($action)
";
- if($action == 'edit' || $action == 'add')
+ if ($action == 'edit' || $action == 'add')
{
- $inhelp = (($action == 'edit') ? ''.BANLAN_26.($banlist_banexpires ? strftime(BAN_TIME_FORMAT, $banlist_banexpires) : BANLAN_21).'
' : '');
+ $inhelp = (($action == 'edit') ? ''.BANLAN_26.($banlist_banexpires ? strftime($pref['ban_date_format'], $banlist_banexpires) : BANLAN_21).'
' : '');
$text .= "
@@ -525,6 +669,7 @@ switch($action)
$text .= "
+
";
@@ -532,13 +677,13 @@ switch($action)
/* FORM NOTE EXAMPLE - not needed here as this note is added as label-note (see below)
$text .= "
";
*/
- if($action == 'edit' || $action == 'whedit')
+ if ($action == 'edit' || $action == 'whedit')
{
$text .= "
".$frm->admin_button('update_ban', LAN_UPDATE, 'update');
@@ -553,17 +698,17 @@ switch($action)
";
- $e107->ns->tablerender($page_title[$action], $emessage->render().$text);
- break; // End of 'Add' and 'Edit'
+ e107::getRender()->tablerender($page_title[$action], $emessage->render().$text);
+ break; // End of 'Add' and 'Edit'
- case 'transfer':
+ case 'transfer' :
$message = '';
$error = false;
- if(isset($_POST['ban_import']))
+ if (isset($_POST['ban_import']))
{ // Got a file to import
- require_once (e_HANDLER.'upload_handler.php');
- if(($files = process_uploaded_files(e_UPLOAD, FALSE, array('overwrite' => TRUE, 'max_file_count' => 1, 'file_mask' => 'csv'))) === FALSE)
+ require_once(e_HANDLER.'upload_handler.php');
+ if (($files = process_uploaded_files(e_UPLOAD, FALSE, array('overwrite' => TRUE, 'max_file_count' => 1, 'file_mask' => 'csv'))) === FALSE)
{ // Invalid file
$error = true;
$message = BANLAN_47;
@@ -577,8 +722,12 @@ switch($action)
}
if(!$error)
{ // Got a file of some sort
- $message = process_csv(e_UPLOAD.$files[0]['name'], intval(varset($_POST['ban_over_import'], 0)), intval(varset($_POST['ban_over_expiry'], 0)), $separator_char[intval(varset($_POST['ban_separator'], 1))], $quote_char[intval(varset($_POST['ban_quote'], 3))]);
- banlist_adminlog("07", 'File: '.e_UPLOAD.$files[0]['name'].'
'.$message);
+ $message = process_csv(e_UPLOAD.$files[0]['name'],
+ intval(varset($_POST['ban_over_import'], 0)),
+ intval(varset($_POST['ban_over_expiry'], 0)),
+ $separator_char[intval(varset($_POST['ban_separator'], 1))],
+ $quote_char[intval(varset($_POST['ban_quote'], 3))]);
+ banlist_adminlog('07', 'File: '.e_UPLOAD.$files[0]['name'].'
'.$message);
}
}
@@ -601,14 +750,14 @@ switch($action)
";
- for($i = 0; $i < BAN_REASON_COUNT; $i ++)
+ foreach ($ipAdministrator->getValidReasonList() as $i)
{
$text .= "
-
-
- ".$frm->checkbox("ban_types[{$i}]", $i).$frm->label(constant('BANLAN_10'.$i), "ban_types[{$i}]", $i)."
- (".constant('BANLAN_11'.$i).")
-
+
+
+ ".$frm->checkbox("ban_types[{$i}]", $i).$frm->label($ipAdministrator->getBanTypeString($i, FALSE), "ban_types[{$i}]", $i)."
+ (".$ipAdministrator->getBanTypeString($i, TRUE).")
+
";
}
@@ -621,6 +770,7 @@ switch($action)
".$frm->admin_button('ban_export', BANLAN_39, 'export', BANLAN_39)."
+
";
@@ -661,6 +811,7 @@ switch($action)
".$frm->admin_button('ban_import', BANLAN_45, 'import')."
+
@@ -668,21 +819,23 @@ switch($action)
";
- $e107->ns->tablerender(BANLAN_35, $emessage->render().$text);
- break;
+ e107::getRender()->tablerender(BANLAN_35, $emessage->render().$text);
+ break; // End case 'transfer'
- case 'list':
- case 'white':
- default:
- if(($action != 'list') && ($action != 'white'))
+ case 'list' :
+ case 'white' :
+ default :
+ if (($action != 'list') && ($action != 'white'))
$action = 'list';
$edit_action = ($action == 'list' ? 'edit' : 'whedit');
$del_action = ($action == 'list' ? 'remove' : 'whremove');
$col_widths = array('list' => array(10, 5, 35, 30, 10, 10), 'white' => array(15, 40, 35, 10));
- $col_titles = array('list' => array(BANLAN_17, BANLAN_20, BANLAN_10, BANLAN_19, BANLAN_18, LAN_OPTIONS), 'white' => array(BANLAN_55, BANLAN_56, BANLAN_19, LAN_OPTIONS));
+ $col_titles = array('list' => array(BANLAN_17, BANLAN_20, BANLAN_10, BANLAN_19, BANLAN_18, LAN_OPTIONS),
+ 'white' => array(BANLAN_55, BANLAN_56, BANLAN_19, LAN_OPTIONS));
$no_values = array('list' => BANLAN_2, 'white' => BANLAN_54);
- $col_defs = array('list' => array('banlist_datestamp' => 0, 'banlist_bantype' => 0, 'ip_reason' => BANLAN_7, 'banlist_notes' => 0, 'banlist_banexpires' => 0, 'ban_options' => 0), 'white' => array('banlist_datestamp' => 0, 'ip_reason' => BANLAN_57, 'banlist_notes' => 0, 'ban_options' => 0));
+ $col_defs = array('list' => array('banlist_datestamp' => 0, 'banlist_bantype' => 0, 'ip_reason' => BANLAN_7, 'banlist_notes' => 0, 'banlist_banexpires' => 0, 'ban_options' => 0),
+ 'white' => array('banlist_datestamp' => 0, 'ip_reason' => BANLAN_57, 'banlist_notes' => 0, 'ban_options' => 0));
$text = "