diff --git a/e107_admin/banlist.php b/e107_admin/banlist.php index 921e3b40e..3bba234de 100644 --- a/e107_admin/banlist.php +++ b/e107_admin/banlist.php @@ -9,17 +9,12 @@ * Ban List Management * * $Source: /cvs_backup/e107_0.8/e107_admin/banlist.php,v $ - * $Revision: 1.12 $ - * $Date: 2008-12-22 16:50:07 $ + * $Revision: 1.13 $ + * $Date: 2008-12-23 15:18:31 $ * $Author: secretr $ * */ -/* - * [SecretR] WORK IN PROGRESS! - * -*/ - define('BAN_TIME_FORMAT', "%d-%m-%Y %H:%M"); define('BAN_REASON_COUNT', 7); // Update as more ban reasons added (max 10 supported) @@ -33,18 +28,20 @@ define('BAN_TYPE_WHITELIST', 100); // Entry for whitelist require_once ("../class2.php"); -if(! getperms("4")) +if(!getperms("4")) { - header("location:" . e_BASE . "index.php"); + header("location:".e_BASE."index.php"); exit(); } + $e_sub_cat = 'banlist'; require_once ("auth.php"); -require_once (e_HANDLER . "form_handler.php"); - -$rs = new form(); +require_once (e_HANDLER."form_handler.php"); $frm = new e_form(true); +require_once(e_HANDLER."message_handler.php"); +$emessage = &eMessage::getInstance(); + $action = 'list'; if(e_QUERY) { @@ -52,21 +49,12 @@ if(e_QUERY) $action = $tmp[0]; $sub_action = varset($tmp[1], ''); if($sub_action) - $sub_action = preg_replace("/[^\w@\.]*/", '', urldecode($sub_action)); + $sub_action = preg_replace('/[^\w@\.:]*/', '', urldecode($sub_action)); $id = intval(varset($tmp[2], 0)); unset($tmp); } -/* -if (varsettrue($imode)) -{ - $images_path = e_IMAGE.'packs/'.$imode.'/admin_images/'; -} -else -{*/ -$images_path = e_IMAGE . 'admin_images/'; -// } - +$images_path = e_IMAGE_ABS.'admin_images/'; if(isset($_POST['update_ban_prefs'])) { @@ -77,17 +65,19 @@ if(isset($_POST['update_ban_prefs'])) } save_prefs(); banlist_adminlog('08', ""); - $ns->tablerender(BANLAN_9, "
" . BANLAN_33 . '
'); + //$ns->tablerender(BANLAN_9, "
".BANLAN_33.'
'); + $emessage->add(BANLAN_33, E_MESSAGE_SUCCESS); } if(isset($_POST['ban_ip'])) { $_POST['ban_ip'] = trim($_POST['ban_ip']); - $new_ban_ip = preg_replace("/[^\w@\.\*]*/", '', urldecode($_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); + $message = BANLAN_27.' '.$new_ban_ip; + //$ns->tablerender(BANLAN_9, $message); + $emessage->add(BANLAN_33, $message); $_POST['ban_ip'] = $new_ban_ip; } @@ -123,7 +113,7 @@ if(isset($_POST['ban_ip'])) } if(isset($_POST['add_ban'])) { // Insert new value - can just pass an array - admin_update($sql->db_Insert("banlist", $new_vals), 'insert'); + admin_update($sql->db_Insert("banlist", $new_vals), 'insert', false, false, false); if($_POST['entry_intent'] == 'add') { banlist_adminlog('01', $new_vals['banlist_ip']); @@ -139,10 +129,10 @@ if(isset($_POST['ban_ip'])) $spacer = ''; foreach($new_vals as $k => $v) { - $qry .= $spacer . "`{$k}`='$v'"; + $qry .= $spacer."`{$k}`='$v'"; $spacer = ', '; } - admin_update($sql->db_Update("banlist", $qry . " WHERE banlist_ip='" . $_POST['old_ip'] . "'")); + admin_update($sql->db_Update("banlist", $qry." WHERE banlist_ip='".$_POST['old_ip']."'"), 'update', false, false, false); if($_POST['entry_intent'] == 'edit') { banlist_adminlog("09", $new_vals['banlist_ip']); @@ -157,11 +147,11 @@ if(isset($_POST['ban_ip'])) } // Remove a ban -if(($action == "remove" || $action == "whremove") && isset($_POST['ban_secure'])) +if(($action == "remove" || $action == "whremove") && varsettrue($_POST['ban_secure'])) //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'); + admin_update($sql->db_Delete("banlist", "banlist_ip='{$sub_action}'"), 'delete', false, false, false); if($action == "remove") { $action = 'list'; @@ -178,7 +168,7 @@ if(($action == "remove" || $action == "whremove") && isset($_POST['ban_secure']) 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 . "'")); + 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); $action = 'list'; } @@ -188,7 +178,7 @@ if($action == "edit" || $action == "whedit") { $sql->db_Select("banlist", "*", "banlist_ip='{$sub_action}'"); $row = $sql->db_Fetch(); - extract($row); + extract($row);//FIXME - kill extract() } else { @@ -201,25 +191,26 @@ else function ban_time_dropdown($click_js = '', $zero_text = BANLAN_21, $curval = -1, $drop_name = 'ban_time') { + global $frm; $intervals = array(0, 1, 2, 3, 6, 8, 12, 24, 36, 48, 72, 96, 120, 168, 336, 672); - $ret = "'; return $ret; @@ -231,13 +222,12 @@ $quote_char = array(1 => '(none)', 2 => "'", 3 => '"'); function select_box($name, $data, $curval = FALSE) { - $ret = "\n"; return $ret; @@ -248,12 +238,13 @@ $text = ""; // Drop-down box for access counts function drop_box($box_name, $curval) { + global $frm; + $opts = array(50, 100, 150, 200, 250, 300, 400, 500); - $ret = "\n"; return $ret; @@ -262,28 +253,30 @@ function drop_box($box_name, $curval) switch($action) { case 'options': - if(! getperms("0")) + if(!getperms("0")) exit(); 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_max_online_access'] = intval($_POST['ban_access_guest']).','.intval($_POST['ban_access_member']); $pref['ban_retrigger'] = intval($_POST['ban_retrigger']); save_prefs(); + $emessage->add(LAN_SETSAVED, E_MESSAGE_SUCCESS); } if(isset($_POST['remove_expired_bans'])) { - $sql->db_Delete('banlist', "`banlist_bantype` < " . BAN_TYPE_WHITELIST . " AND `banlist_banexpires` > 0 AND `banlist_banexpires` < " . time()); + //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); } list($ban_access_guest, $ban_access_member) = explode(',', varset($pref['ban_max_online_access'], '100,200')); $ban_access_member = max($ban_access_guest, $ban_access_member); $text = " -
+
- " . BANLAN_72 . " + ".BANLAN_72." @@ -291,42 +284,48 @@ switch($action) - + - + - + - +
" . BANLAN_63 . "".BANLAN_63." - -
" . BANLAN_65 . "
+
+ ".$frm->checkbox('ban_rdns_on_access', 1, $pref['enable_rdns'] == 1)." +
".BANLAN_65."
+
" . BANLAN_64 . "".BANLAN_64." - -
" . BANLAN_66 . "
+
+ ".$frm->checkbox('ban_rdns_on_ban', 1, $pref['enable_rdns_on_ban'] == 1)." +
".BANLAN_66."
+
" . BANLAN_67 . "".BANLAN_67." -
" . drop_box('ban_access_guest', $ban_access_guest) . BANLAN_70 . "
-
" . drop_box('ban_access_member', $ban_access_member) . BANLAN_69 . "
-
" . BANLAN_68 . "
+
".drop_box('ban_access_guest', $ban_access_guest).BANLAN_70."
+
".drop_box('ban_access_member', $ban_access_member).BANLAN_69."
+
".BANLAN_68."
" . BANLAN_71 . "".BANLAN_71." - -
" . BANLAN_73 . "
+
+ ".$frm->checkbox('ban_retrigger', 1, $pref['ban_retrigger'] == 1)." +
".BANLAN_73."
+
- " . $frm->admin_button('update_ban_options', LAN_UPDATE, 'update', LAN_UPDATE) . " + ".$frm->admin_button('update_ban_options', LAN_UPDATE, 'update')."
- " . BANLAN_74 . " + ".BANLAN_74." @@ -334,9 +333,9 @@ switch($action) - + @@ -344,33 +343,32 @@ switch($action) "; - $ns->tablerender(BANLAN_72, $text); + $e107->ns->tablerender(BANLAN_72, $emessage->render().$text); break; case 'times': - if(! getperms("0")) + 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, ''); } - 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); } - if(! $ban_total = $sql->db_Select("banlist", "*", "ORDER BY banlist_ip", "nowhere")) + if(!$ban_total = $sql->db_Select("banlist", "*", "ORDER BY banlist_ip", "nowhere")) { - $text .= "
" . BANLAN_2 . "
"; + $text .= "
".BANLAN_2."
"; } else { - //XXX Lan - Messages/Ban Periods $text .= " - +
- Messages/Ban Periods + ".BANLAN_77."
" . BANLAN_75 . "".BANLAN_75." - " . $frm->admin_button('remove_expired_bans', BANLAN_76, 'delete', BANLAN_76) . " + ".$frm->admin_button('remove_expired_bans', BANLAN_76, 'delete')."
@@ -379,9 +377,9 @@ switch($action) - - - + + + @@ -391,13 +389,13 @@ switch($action) $text .= " - + "; } @@ -405,14 +403,14 @@ switch($action)
" . BANLAN_28 . "" . BANLAN_29 . "
" . BANLAN_31 . "
" . BANLAN_30 . "".BANLAN_28."".BANLAN_29."
".BANLAN_31."
".BANLAN_30."
- " . constant('BANLAN_10' . $i) . " -
" . constant('BANLAN_11' . $i) . "
+ ".constant('BANLAN_10'.$i)." +
".constant('BANLAN_11'.$i)."
- + ".$frm->textarea('ban_text[]', $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[]')."
- " . $frm->admin_button('update_ban_prefs', LAN_UPDATE, 'update', LAN_UPDATE) . " + ".$frm->admin_button('update_ban_prefs', LAN_UPDATE, 'update')."
"; } - //XXX Lan - Messages/Ban Periods - $ns->tablerender("Messages/Ban Periods", $text); + + $e107->ns->tablerender(BANLAN_77, $emessage->render().$text); break; case 'edit': @@ -420,13 +418,13 @@ switch($action) case 'whedit': case 'whadd': $page_title = array('edit' => BANLAN_60, 'add' => BANLAN_9, 'whedit' => BANLAN_59, 'whadd' => BANLAN_58); - $rdns_warn = varsettrue($pref['enable_rdns']) ? '' : '
' . BANLAN_12 . '
'; + $rdns_warn = varsettrue($pref['enable_rdns']) ? '' : '
'.BANLAN_12.'
'; $next = ($action == 'whedit' || $action == 'whadd') ? '?white' : '?list'; // Edit/add form first $text .= " -
+
- " . $page_title[$action] . " + ".$page_title[$action]." @@ -434,9 +432,15 @@ switch($action) - + @@ -446,9 +450,9 @@ switch($action) { // Its a manual or unknown entry - only allow edit of reason on those $text .= " - + "; @@ -457,7 +461,7 @@ switch($action) { $text .= " - + "; @@ -467,27 +471,29 @@ switch($action) { $text .= " - - + + "; } $text .= " - + "; if($action == 'edit' || $action == 'add') { + $inhelp = (($action == 'edit') ? '
'.BANLAN_26.($banlist_banexpires ? strftime(BAN_TIME_FORMAT, $banlist_banexpires) : BANLAN_21).'
' : ''); + $text .= " - - + + "; } @@ -496,19 +502,29 @@ switch($action)
" . BANLAN_5 . ": + ".BANLAN_5.": +
+ ".BANLAN_13." +
+
- + + ".$frm->text('ban_ip', $e107->ipDecode($banlist_ip), 200)." {$rdns_warn}
" . BANLAN_7 . ": ".BANLAN_7.": - + ".$frm->textarea('ban_reason', $banlist_reason, 4, 50)."
" . BANLAN_7 . ": ".BANLAN_7.": {$banlist_reason}
" . BANLAN_28 . ": " . constant('BANLAN_10' . $banlist_bantype) . " - " . constant('BANLAN_11' . $banlist_bantype) . "".BANLAN_28.": ".constant('BANLAN_10'.$banlist_bantype)." - ".constant('BANLAN_11'.$banlist_bantype)."
" . BANLAN_19 . ": ".BANLAN_19.": - + ".$frm->textarea('ban_notes', $banlist_notes, 4, 50)."
" . BANLAN_18 . ": " . ban_time_dropdown() . (($action == 'edit') ? '   (' . BANLAN_26 . ($banlist_banexpires ? strftime(BAN_TIME_FORMAT, $banlist_banexpires) : BANLAN_21) . ')' : '') . "".BANLAN_18.": ".ban_time_dropdown().$inhelp."
+ "; + /* FORM NOTE EXAMPLE - not needed here as this note is added as label-note (see below) + $text .= " +
+ ".BANLAN_13." +
+ + "; + */ + if($action == "edit" || $action == "whedit") { $text .= " - - " . $frm->admin_button('update_ban', LAN_UPDATE, 'update', LAN_UPDATE) . " + + ".$frm->admin_button('update_ban', LAN_UPDATE, 'update')." "; } else { $text .= " - " . $frm->admin_button('add_ban', ($action == 'add' ? BANLAN_8 : BANLAN_53), 'submit', ($action == 'add' ? BANLAN_8 : BANLAN_53)) . " + ".$frm->admin_button('add_ban', ($action == 'add' ? BANLAN_8 : BANLAN_53), 'create')." "; } @@ -518,47 +534,40 @@ switch($action) "; - //FIXME - Put this notes somewhere - $text .= " -
- " . BANLAN_13 . " -
- "; - if(! varsettrue($pref['enable_rdns'])) - { - $text .= " -

" . BANLAN_12 . "
- "; - } - $ns->tablerender($page_title[$action], $text); + $e107->ns->tablerender($page_title[$action], $emessage->render().$text); break; // End of 'Add' and 'Edit' case 'transfer': $message = ''; + $error = false; if(isset($_POST['ban_import'])) { // Got a file to import - require_once (e_HANDLER . 'upload_handler.php'); - if(($files = process_uploaded_files(e_FILE . "public/", 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_FILE."public/", FALSE, array('overwrite' => TRUE, 'max_file_count' => 1, 'file_mask' => 'csv'))) === FALSE) { // Invalid file + $error = true; $message = BANLAN_47; + $emessage->add($message, E_MESSAGE_ERROR); } - if(! $message && $files[0]['error']) - $message = $files[0]['message']; - if(! $message) + if(empty($files) || varsettrue($files[0]['error'])) + { + $error = true; + if(varset($files[0]['message'])) + $emessage->add($files[0]['message'], E_MESSAGE_ERROR); var_dump(empty($files), $files[0]['error']); + } + if(!$error) { // Got a file of some sort - $message = process_csv(e_FILE . "public/" . $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_FILE . "public/" . $files[0]['name'] . '
' . $message); + $message = process_csv(e_FILE."public/".$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_FILE."public/".$files[0]['name'].'
'.$message); } } - if($message) - $ns->tablerender(BANLAN_48, "
{$message}
"); $text = " -
+
- " . BANLAN_40 . " + ".BANLAN_40." @@ -566,32 +575,33 @@ switch($action) - - + + - - - @@ -602,9 +612,9 @@ switch($action) // Now do the import options $text .= " - +
- " . BANLAN_41 . " + ".BANLAN_41."
" . BANLAN_36 . "" . BANLAN_15 . "".BANLAN_36."".BANLAN_15."
+ "; for($i = 0; $i < BAN_REASON_COUNT; $i ++) { $text .= "
-  " . constant('BANLAN_10' . $i) . " - " . constant('BANLAN_11' . $i) . " + ".$frm->checkbox("ban_types[{$i}]", $i).$frm->label(constant('BANLAN_10'.$i), "ban_types[{$i}]", $i)." + (".constant('BANLAN_11'.$i).")
"; } $text .= "
-
" . select_box('ban_separator', $separator_char) . ' ' . BANLAN_37 . "
-
" . select_box('ban_quote', $quote_char) . ' ' . BANLAN_38 . "
+
+
".select_box('ban_separator', $separator_char).' '.BANLAN_37."
+
".select_box('ban_quote', $quote_char).' '.BANLAN_38."
- " . $frm->admin_button('ban_export', BANLAN_39, 'submit', BANLAN_39) . " + +
".$frm->admin_button('ban_export', BANLAN_39, 'export', BANLAN_39)."
@@ -612,25 +622,25 @@ switch($action) - - + + - - - - @@ -640,7 +650,7 @@ switch($action) "; //XXX LAN - Import/Export - $ns->tablerender("Import/Export", $text); + $e107->ns->tablerender("Import/Export", $emessage->render().$text); break; case 'list': @@ -657,23 +667,23 @@ switch($action) $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 = " - +
- " . ($action == 'list' ? BANLAN_3 : BANLAN_61) . " - " . $frm->hidden("ban_secure", "1") . " + ".($action == 'list' ? BANLAN_3 : BANLAN_61)." + ".$frm->hidden("ban_secure", "1")." "; - $filter = ($action == 'white') ? 'banlist_bantype=' . BAN_TYPE_WHITELIST : 'banlist_bantype!=' . BAN_TYPE_WHITELIST; + $filter = ($action == 'white') ? 'banlist_bantype='.BAN_TYPE_WHITELIST : 'banlist_bantype!='.BAN_TYPE_WHITELIST; - if(! $ban_total = $sql->db_Select("banlist", "*", $filter . " ORDER BY banlist_ip")) + if(!$ban_total = $sql->db_Select("banlist", "*", $filter." ORDER BY banlist_ip")) { - $text .= "
" . $no_values[$action] . "
"; + $text .= "
".$no_values[$action]."
"; } else { $text .= "
" . BANLAN_42 . "" . BANLAN_15 . "".BANLAN_42."".BANLAN_15."
-  " . BANLAN_43 . "
-  " . BANLAN_44 . " +
+
".$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_separator', $separator_char) . ' ' . BANLAN_37 . "
-
" . select_box('ban_quote', $quote_char) . ' ' . BANLAN_38 . "
+
+
".select_box('ban_separator', $separator_char).' '.BANLAN_37."
+
".select_box('ban_quote', $quote_char).' '.BANLAN_38."
- + + ".$frm->file('file_userfile[]')." - " . $frm->admin_button('ban_import', BANLAN_45, 'submit', BANLAN_45) . " + +
".$frm->admin_button('ban_import', BANLAN_45, 'import')."
- + "; foreach($col_widths[$action] as $fw) { @@ -691,7 +701,7 @@ switch($action) { $cnt ++; $text .= " - {$ct} + {$ct} "; } $text .= " @@ -701,7 +711,7 @@ switch($action) "; while($row = $sql->db_Fetch()) { - extract($row); + extract($row);//FIXME - kill extract() $banlist_reason = str_replace("LAN_LOGIN_18", BANLAN_11, $banlist_reason); $text .= " @@ -715,21 +725,19 @@ switch($action) $val = ($banlist_datestamp ? strftime(BAN_TIME_FORMAT, $banlist_datestamp) : BANLAN_22); break; case 'banlist_bantype': - $val = "" . constant('BANLAN_10' . $banlist_bantype) . ""; + $val = "
".constant('BANLAN_10'.$banlist_bantype)."
"; break; case 'ip_reason': - $val = $e107->ipDecode($banlist_ip) . "
" . $fv . ": " . $banlist_reason; + $val = $e107->ipDecode($banlist_ip)."
".$fv.": ".$banlist_reason; break; case 'banlist_banexpires': - $val = ($banlist_banexpires ? strftime(BAN_TIME_FORMAT, $banlist_banexpires) . (($banlist_banexpires < time()) ? ' (' . BANLAN_34 . ')' : '') : BANLAN_21) . "
" . ban_time_dropdown("onchange=\"urljump('" . e_SELF . "?newtime-{$banlist_ip}-'+this.value)\""); + $val = ($banlist_banexpires ? strftime(BAN_TIME_FORMAT, $banlist_banexpires).(($banlist_banexpires < time()) ? ' ('.BANLAN_34.')' : '') : BANLAN_21)."
".ban_time_dropdown("onchange=\"e107Helper.urlJump('".e_SELF."?newtime-{$banlist_ip}-'+this.value)\""); break; case 'ban_options': $row_class = ' class="center"'; $val = " - " . LAN_EDIT . " - toJS(LAN_CONFIRMDEL . " [" . $e107->ipDecode($banlist_ip) . "]") . "'); - if (r) { document.getElementById('ban_form').action='" . e_SELF . "?{$del_action}-{$banlist_ip}'; } return r; \" />"; + ".LAN_EDIT." +"; break; case 'banlist_notes': default: @@ -747,6 +755,21 @@ switch($action) $text .= "
+ "; } $text .= " @@ -754,7 +777,7 @@ switch($action) "; - $ns->tablerender(($action == 'list' ? BANLAN_3 : BANLAN_61), $text); + $e107->ns->tablerender(($action == 'list' ? BANLAN_3 : BANLAN_61), $emessage->render().$text); // End of case 'list' and the default case } // End switch ($action) @@ -766,33 +789,33 @@ function banlist_adminmenu() $action = (e_QUERY) ? e_QUERY : "list"; $var['list']['text'] = BANLAN_14; // List existing bans - $var['list']['link'] = e_SELF . "?list"; + $var['list']['link'] = e_SELF."?list"; $var['list']['perm'] = "4"; $var['add']['text'] = BANLAN_25; // Add a new ban - $var['add']['link'] = e_SELF . "?add"; + $var['add']['link'] = e_SELF."?add"; $var['add']['perm'] = "4"; $var['white']['text'] = BANLAN_52; // List existing whitelist entries - $var['white']['link'] = e_SELF . "?white"; + $var['white']['link'] = e_SELF."?white"; $var['white']['perm'] = "4"; $var['whadd']['text'] = BANLAN_53; // Add a new whitelist entry - $var['whadd']['link'] = e_SELF . "?whadd"; + $var['whadd']['link'] = e_SELF."?whadd"; $var['whadd']['perm'] = "4"; $var['transfer']['text'] = BANLAN_35; - $var['transfer']['link'] = e_SELF . "?transfer"; + $var['transfer']['link'] = e_SELF."?transfer"; $var['transfer']['perm'] = "4"; if(getperms("0")) { $var['times']['text'] = BANLAN_15; - $var['times']['link'] = e_SELF . "?times"; + $var['times']['link'] = e_SELF."?times"; $var['times']['perm'] = "0"; $var['options']['text'] = BANLAN_62; - $var['options']['link'] = e_SELF . "?options"; + $var['options']['link'] = e_SELF."?options"; $var['options']['perm'] = "0"; } e_admin_menu(BANLAN_16, $action, $var); @@ -810,11 +833,11 @@ function parse_date($instr) // Return a message function process_csv($filename, $override_imports, $override_expiry, $separator = ',', $quote = '"') { - global $sql, $pref, $e107; + global $sql, $pref, $e107, $emessage; // echo "Read CSV: {$filename} separator: {$separator}, quote: {$quote} override imports: {$override_imports} override expiry: {$override_expiry}
"; // Renumber imported bans if($override_imports) - $sql->db_Update('banlist', "`banlist_bantype`=" . BAN_TYPE_TEMPORARY . " WHERE `banlist_bantype` = " . BAN_TYPE_IMPORTED); + $sql->db_Update('banlist', "`banlist_bantype`=".BAN_TYPE_TEMPORARY." WHERE `banlist_bantype` = ".BAN_TYPE_IMPORTED); $temp = file($filename); $line_num = 0; foreach($temp as $line) @@ -837,7 +860,8 @@ function process_csv($filename, $override_imports, $override_expiry, $separator } else { - return BANLAN_49 . $line_num; + $emessage->add(BANLAN_49.$line_num, E_MESSAGE_ERROR); + return BANLAN_49.$line_num; } } // Now handle the field @@ -871,19 +895,21 @@ function process_csv($filename, $override_imports, $override_expiry, $separator default: // Just ignore any others } } - $qry = "REPLACE INTO `#banlist` (" . implode(',', array_keys($field_list)) . ") values ('" . implode("', '", $field_list) . "')"; + $qry = "REPLACE INTO `#banlist` (".implode(',', array_keys($field_list)).") values ('".implode("', '", $field_list)."')"; // echo count($field_list)." elements, query: ".$qry."
"; - if(! $sql->db_Select_gen($qry)) + if(!$sql->db_Select_gen($qry)) { - return BANLAN_50 . $line_num; + $emessage->add(BANLAN_50.$line_num, E_MESSAGE_ERROR); + return BANLAN_50.$line_num; } } } // Success here - may need to delete old imported bans if($override_imports) - $sql->db_Delete('banlist', "`banlist_bantype` = " . BAN_TYPE_TEMPORARY); + $sql->db_Delete('banlist', "`banlist_bantype` = ".BAN_TYPE_TEMPORARY); @unlink($filename); // Delete file once done - return str_replace('--NUM--', $line_num, BANLAN_51) . $filename; + $emessage->add(str_replace('--NUM--', $line_num, BANLAN_51).$filename, E_MESSAGE_SUCCESS); + return str_replace('--NUM--', $line_num, BANLAN_51).$filename; } // Log event to admin log @@ -892,7 +918,34 @@ function banlist_adminlog($msg_num = '00', $woffle = '') global $pref, $admin_log; // if (!varset($pref['admin_log_log']['admin_banlist'],0)) return; // $admin_log->log_event($title,$woffle,E_LOG_INFORMATIVE,'BANLIST_'.$msg_num); - $admin_log->log_event('BANLIST_' . $msg_num, $woffle, E_LOG_INFORMATIVE, ''); + $admin_log->log_event('BANLIST_'.$msg_num, $woffle, E_LOG_INFORMATIVE, ''); } -?> +/** + * Handle page DOM within the page header + * + * @return string JS source + */ +function headerjs() +{ + require_once(e_HANDLER.'js_helper.php'); + $ret = " + + + "; + + return $ret; +} +?> \ No newline at end of file diff --git a/e107_admin/banner.php b/e107_admin/banner.php index 502d9ab39..5f6004e0f 100644 --- a/e107_admin/banner.php +++ b/e107_admin/banner.php @@ -9,8 +9,8 @@ * Banner Administration * * $Source: /cvs_backup/e107_0.8/e107_admin/banner.php,v $ - * $Revision: 1.8 $ - * $Date: 2008-12-22 16:50:07 $ + * $Revision: 1.9 $ + * $Date: 2008-12-23 15:18:31 $ * $Author: secretr $ * */ @@ -26,7 +26,6 @@ $e_sub_cat = 'banner'; require_once("auth.php"); require_once(e_HANDLER."form_handler.php"); -$rs = new form; $frm = new e_form(); require_once(e_HANDLER."userclass_class.php"); @@ -244,7 +243,7 @@ if (!$action) { ".$banner_row['banner_id']." - + ".($banner_row['banner_clientname'] ? $banner_row['banner_clientname'] : BNRLAN_66)."