$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); function do_export($filename, $type_list = '', $format_array, $sep = ',', $quot = '"') { $sql = e107::getDb(); $export_text = ''; $qry = "SELECT * FROM `#banlist` "; if ($type_list != '') { $qry .= " WHERE`banlist_bantype` IN ({$type_list})"; } if (!$sql->db_Select_gen($qry)) { return 'No data: ' . $qry; } while ($row = $sql->db_Fetch()) { $line = ''; $spacer = ''; foreach ($format_array as $f => $v) {
private function timesPageSave() { $ipAdministrator = new banlistManager(); $tp = e107::getParser(); $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?) e107::getConfig()->setPref($pref)->save(); // save_prefs(); /***************************************** Write messages and times to disc file *****************************************/ $ipAdministrator->writeBanMessageFile(); banlist_adminlog('08', ''); //$ns->tablerender(BANLAN_9, "<div style='text-align:center'>".BANLAN_33.'</div>'); // $mes->addSuccess(BANLAN_33); } }
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; $emessage->add($message, E_MESSAGE_ERROR); } if (empty($files) || varsettrue($files[0]['error'])) { $error = true; if (varset($files[0]['message'])) { $emessage->add($files[0]['message'], E_MESSAGE_ERROR); } } 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'] . '<br />' . $message); } } $text = "\n\t\t\t<form method='post' action='" . e_ADMIN_ABS . "banlist_export.php' id='core-banlist-transfer-form' >\n\t\t\t\t<fieldset id='core-banlist-transfer-export'>\n\t\t\t\t\t<legend>" . BANLAN_40 . "</legend>\n\t\t\t\t\t<table class='table adminlist'>\n\t\t\t\t\t\t<colgroup>\n\t\t\t\t\t\t\t<col style='width:30%' />\n\t\t\t\t\t\t\t<col style='width:30%' />\n\t\t\t\t\t\t\t<col style='width:40%' />\n\t\t\t\t\t\t</colgroup>\n\t\t\t\t\t\t<tbody>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th colspan='2'>" . BANLAN_36 . "</th>\n\t\t\t\t\t\t\t\t<th> </th>\n\t\t\t\t\t\t\t</tr>\n\t\t\t"; foreach ($ipAdministrator->getValidReasonList() as $i) { $text .= "\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan='3'>\n\t\t\t\t\t\t\t\t" . $frm->checkbox("ban_types[{$i}]", $i) . $frm->label($ipAdministrator->getBanTypeString($i, FALSE), "ban_types[{$i}]", $i) . "\n\t\t\t\t\t\t\t\t<span class='field-help'>(" . $ipAdministrator->getBanTypeString($i, TRUE) . ")</span>\n\t\t\t\t\t\t\t</td></tr>\n\t\t\t"; } $text .= "<tr>\n\t\t\t<td>" . BANLAN_79 . "</td>\n\t\t\t<td>" . select_box('ban_separator', $separator_char) . ' ' . BANLAN_37 . "</td>\n\t\t<td>" . select_box('ban_quote', $quote_char) . ' ' . BANLAN_38 . "</td></tr>"; $text .= "\n\n\t\t\t\t\t\t</tbody>\n\t\t\t\t\t</table>\n\t\t\t\t\t<div class='buttons-bar center'>" . $frm->admin_button('ban_export', BANLAN_39, 'export', BANLAN_39) . "</div>\n\t\t\t\t\t\t<input type='hidden' name='e-token' value='" . e_TOKEN . "' />\n\t\t\t\t</fieldset>\n\t\t\t</form>\n\t\t"; // Now do the import options $text .= "\n\t\t\t<form enctype='multipart/form-data' method='post' action='" . e_SELF . "?transfer' id='ban_import_form' >\n\t\t\t\t<fieldset id='core-banlist-transfer-import'>\n\t\t\t\t\t<legend>" . BANLAN_41 . "</legend>\n\t\t\t\t\t<table class='table adminlist'>\n\t\t\t\t\t\t<colgroup>\n\t\t\t\t\t\t\t<col style='width:30%' />\n\t\t\t\t\t\t\t<col style='width:30%' />\n\t\t\t\t\t\t\t<col style='width:40%' />\n\t\t\t\t\t\t</colgroup>\n\t\t\t\t\t\t<tbody>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<th colspan='2'>" . BANLAN_42 . "</th>\n\t\t\t\t\t\t\t\t<th> </th>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td colspan='3'>" . $frm->checkbox('ban_over_import', 1) . $frm->label(BANLAN_43, 'ban_over_import', 1) . "</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td colspan='3'>" . $frm->checkbox('ban_over_expiry', 1) . $frm->label(BANLAN_44, 'ban_over_expiry', 1) . "</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>" . BANLAN_46 . "</td>\n\t\t\t\t\t\t\t\t<td colspan='2'>\n\t\t\t\t\t\t\t\t\t" . $frm->file('file_userfile[]', array('size' => '40')) . "\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t<td>" . BANLAN_80 . "</td>\n\t\t\t<td>" . select_box('ban_separator', $separator_char) . ' ' . BANLAN_37 . "</td>\n\t\t<td>" . select_box('ban_quote', $quote_char) . ' ' . BANLAN_38 . "</td></tr>\n\t\t\t\t\t\t</tbody>\n\t\t\t\t\t</table>\n\t\t\t\t\t\t\t\t<div class='buttons-bar center'>\n\t\t\t\t\t\t\t\t" . $frm->admin_button('ban_import', BANLAN_45, 'import') . "\n\t\t\t\t\t\t\t\t<input type='hidden' name='e-token' value='" . e_TOKEN . "' />\n\t\t\t\t\t\t\t\t</div>\n\n\n\t\t\t\t</fieldset>\n\t\t\t</form>\n\t\t"; e107::getRender()->tablerender(BANLAN_35, $emessage->render() . $text); break; // End case 'transfer' // End case 'transfer' case 'list':