$_POST['ban_types'] - array of 0..9 $_POST['ban_separator'] - 1 or 2 $_POST['ban_quote'] - 1,2,3 */ require_once e_HANDLER . 'iphandler_class.php'; // This is probably already loaded in class2.php // Uncomment what's going on to get debug data //define('CSV_DEBUG',TRUE); $separator_char = array(1 => ',', 2 => '|'); $quote_char = array(1 => '', 2 => "'", 3 => '"'); $format_array = array('banlist_ip' => 1, 'banlist_datestamp' => "%Y%m%d_%H%M%S", 'banlist_banexpires' => "%Y%m%d_%H%M%S", 'banlist_bantype' => 1, 'banlist_reason' => 1, 'banlist_notes' => 1); $use_separator = varset($separator_char[intval($_POST['ban_separator'])], $separator_char[1]); $use_quote = varset($quote_char[intval($_POST['ban_quote'])], $quote_char[2]); $type_list = ''; if (is_array($_POST['ban_types'])) { $validBanTypes = banlistManager::getValidReasonList(); $spacer = ''; foreach ($_POST['ban_types'] as $b) { $b = trim($b); if (is_numeric($b) && in_array($b, $validBanTypes)) { $type_list .= $spacer . $b; $spacer = ','; } } } $filename = 'banlist_' . strftime("%Y%m%d_%H%M%S") . '.csv'; if ($error_string = do_export($filename, $type_list, $format_array, $use_separator, $use_quote)) { // Need to report an error here echo "Error report: {$error_string}<br />"; } banlist_adminlog('06', 'File: ' . $filename . '<br />' . $error_string);
public function timesPage() { if (!getperms('0')) { return; } $pref = e107::getPref(); $tp = e107::getParser(); $frm = e107::getForm(); $mes = e107::getMessage(); $ipAdministrator = new banlistManager(); $text = ''; if (!isset($pref['ban_messages']) || !is_array($pref['ban_messages'])) { foreach ($ipAdministrator->getValidReasonList() as $bt) { $pref['ban_messages'][$bt] = ''; } } if (!isset($pref['ban_durations']) || !is_array($pref['ban_durations'])) { foreach ($ipAdministrator->getValidReasonList() as $bt) { $pref['ban_durations'][$bt] = 0; } } $text .= "\n\t\t\t\t<form method='post' action='" . e_SELF . '?' . e_QUERY . "' id='ban_options'>\n\t\t\t\t\t<fieldset id='core-banlist-times'>\n\t\t\t\t\t\t<legend class='e-hideme'>" . BANLAN_77 . "</legend>\n\t\t\t\t\t\t<table class='table adminlist'>\n\t\t\t\t\t\t\t<colgroup>\n\t\t\t\t\t\t\t\t<col style='width: 20%' />\n\t\t\t\t\t\t\t\t<col style='width: 65%' />\n\t\t\t\t\t\t\t\t<col style='width: 15%' />\n\t\t\t\t\t\t\t</colgroup>\n\t\t\t\t\t\t\t<thead>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<th>" . BANLAN_28 . "</th>\n\t\t\t\t\t\t\t\t\t<th>" . BANLAN_29 . "<br />" . BANLAN_31 . "</th>\n\t\t\t\t\t\t\t\t\t<th class='center last'>" . BANLAN_30 . "</th>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</thead>\n\t\t\t\t\t\t\t<tbody>\n\t\t\t"; foreach ($ipAdministrator->getValidReasonList() as $bt) { $i = abs($bt) + 1; // Forces a single-digit positive number $text .= "\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<strong>" . $ipAdministrator->getBanTypeString($bt, FALSE) . "</strong>\n\t\t\t\t\t\t\t\t<div class='field-help'>" . $ipAdministrator->getBanTypeString($bt, TRUE) . "</div>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class='left'>\n\t\t\t\t\t\t\t\t" . $frm->textarea('ban_text_' . $i, $pref['ban_messages'][$bt], 4, 15) . "\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td class='center'>" . ban_time_dropdown('', BANLAN_32, $pref['ban_durations'][$bt], 'ban_time_' . $i) . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t"; } $text .= "\n\t\t\t\t\t\t\t</tbody>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t\t<div class='buttons-bar center'>\n\t\t\t\t\t\t\t" . $frm->admin_button('update_ban_prefs', LAN_UPDATE, 'update') . "\n\t\t\t\t\t\t\t<input type='hidden' name='e-token' value='" . e_TOKEN . "' />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</fieldset>\n\t\t\t\t</form>\n\t\t\t\t"; echo $mes->render() . $text; }
$quote_char = array(1 => '(none)', 2 => "'", 3 => '"'); $action = 'list'; if (e_QUERY) { $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)); } $id = intval(varset($tmp[2], 0)); unset($tmp); } if (isset($_POST['update_ban_prefs'])) { $changed = FALSE; foreach ($ipAdministrator->getValidReasonList() as $bt) { $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 (!isset($pref['ban_messages'][$bt]) || $pref['ban_messages'][$bt] != $t1) { $pref['ban_messages'][$bt] = $t1; $changed = TRUE; } if (!isset($pref['ban_durations'][$bt]) || $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?)