mirror of
https://github.com/e107inc/e107.git
synced 2025-07-16 12:36:26 +02:00
Update in line with iphandler.php
This commit is contained in:
@ -2,23 +2,29 @@
|
|||||||
/*
|
/*
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2009 e107 Inc (e107.org)
|
* Copyright (C) 2008-2012 e107 Inc (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
* Banlist export
|
* Banlist export
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_admin/banlist_export.php,v $
|
* $URL$
|
||||||
* $Revision$
|
* $Id$
|
||||||
* $Date$
|
|
||||||
* $Author$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once("../class2.php");
|
/**
|
||||||
if (!getperms("4"))
|
* e107 Banlist administration
|
||||||
|
*
|
||||||
|
* @package e107
|
||||||
|
* @subpackage admin
|
||||||
|
* @version $Id$;
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once('../class2.php');
|
||||||
|
if (!getperms('4'))
|
||||||
{
|
{
|
||||||
header("location:../index.php");
|
header('location:../index.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -28,7 +34,9 @@ Selection data:
|
|||||||
$_POST['ban_separator'] - 1 or 2
|
$_POST['ban_separator'] - 1 or 2
|
||||||
$_POST['ban_quote'] - 1,2,3
|
$_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);
|
//define('CSV_DEBUG',TRUE);
|
||||||
|
|
||||||
$separator_char = array(1 => ',', 2 => '|');
|
$separator_char = array(1 => ',', 2 => '|');
|
||||||
@ -51,16 +59,17 @@ $use_quote = varset($quote_char[intval($_POST['ban_quote'])],$quote_char[2]);
|
|||||||
$type_list = '';
|
$type_list = '';
|
||||||
if (is_array($_POST['ban_types']))
|
if (is_array($_POST['ban_types']))
|
||||||
{
|
{
|
||||||
$spacer = '';
|
$validBanTypes = banlistManager::getValidReasonList();
|
||||||
foreach($_POST['ban_types'] as $b)
|
$spacer = '';
|
||||||
{
|
foreach($_POST['ban_types'] as $b)
|
||||||
$b = trim($b);
|
|
||||||
if (is_numeric($b) && ($b >= 0) && ($b <= 10))
|
|
||||||
{
|
{
|
||||||
$type_list .= $spacer.($b);
|
$b = trim($b);
|
||||||
$spacer = ',';
|
if (is_numeric($b) && in_array($b, $validBanTypes))
|
||||||
|
{
|
||||||
|
$type_list .= $spacer.($b);
|
||||||
|
$spacer = ',';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = 'banlist_'.strftime("%Y%m%d_%H%M%S").'.csv';
|
$filename = 'banlist_'.strftime("%Y%m%d_%H%M%S").'.csv';
|
||||||
@ -68,77 +77,75 @@ $filename = 'banlist_'.strftime("%Y%m%d_%H%M%S").'.csv';
|
|||||||
if ($error_string = do_export($filename, $type_list, $format_array, $use_separator, $use_quote))
|
if ($error_string = do_export($filename, $type_list, $format_array, $use_separator, $use_quote))
|
||||||
{
|
{
|
||||||
// Need to report an error here
|
// Need to report an error here
|
||||||
echo "Error report: {$error_string}<br />";
|
echo "Error report: {$error_string}<br />";
|
||||||
}
|
}
|
||||||
banlist_adminlog('06',"File: ".$filename.'<br />'.$error_string);
|
banlist_adminlog('06','File: '.$filename.'<br />'.$error_string);
|
||||||
|
|
||||||
|
|
||||||
function do_export($filename, $type_list='',$format_array, $sep = ',', $quot = '"')
|
function do_export($filename, $type_list='',$format_array, $sep = ',', $quot = '"')
|
||||||
{
|
{
|
||||||
global $sql;
|
$sql = e107::getDb();
|
||||||
$export_text = '';
|
$export_text = '';
|
||||||
$qry = "SELECT * FROM `#banlist` ";
|
$qry = "SELECT * FROM `#banlist` ";
|
||||||
if ($type_list != '') $qry .= " WHERE`banlist_bantype` IN ({$type_list})";
|
if ($type_list != '') $qry .= " WHERE`banlist_bantype` IN ({$type_list})";
|
||||||
if (!$sql->db_Select_gen($qry)) return "No data: ".$qry;
|
if (!$sql->db_Select_gen($qry)) return 'No data: '.$qry;
|
||||||
while ($row = $sql->db_Fetch())
|
while ($row = $sql->db_Fetch())
|
||||||
{
|
|
||||||
$line = '';
|
|
||||||
$spacer = '';
|
|
||||||
foreach ($format_array as $f => $v)
|
|
||||||
{
|
{
|
||||||
switch ($f)
|
$line = '';
|
||||||
{
|
$spacer = '';
|
||||||
case 'banlist_ip' :
|
foreach ($format_array as $f => $v)
|
||||||
case 'banlist_bantype' :
|
{
|
||||||
case 'banlist_reason' :
|
switch ($f)
|
||||||
case 'banlist_notes' :
|
{
|
||||||
$line .= $spacer.$quot.$row[$f].$quot;
|
case 'banlist_ip' :
|
||||||
break;
|
case 'banlist_bantype' :
|
||||||
case 'banlist_datestamp' :
|
case 'banlist_reason' :
|
||||||
case 'banlist_banexpires' :
|
case 'banlist_notes' :
|
||||||
if ($row[$f]) $line .= $spacer.$quot.strftime($v,$row[$f]).$quot; else $line .= $spacer.$quot.'0'.$quot;
|
$line .= $spacer.$quot.$row[$f].$quot;
|
||||||
break;
|
break;
|
||||||
}
|
case 'banlist_datestamp' :
|
||||||
$spacer = $sep;
|
case 'banlist_banexpires' :
|
||||||
}
|
if ($row[$f]) $line .= $spacer.$quot.strftime($v,$row[$f]).$quot; else $line .= $spacer.$quot.'0'.$quot;
|
||||||
$export_text .= $line."\n";
|
break;
|
||||||
}
|
}
|
||||||
|
$spacer = $sep;
|
||||||
if (defined('CSV_DEBUG'))
|
}
|
||||||
{
|
$export_text .= $line."\n";
|
||||||
$export_text .= "Summary data: <br />";
|
|
||||||
$export_text .= 'File: '.$filename.'<br />';
|
|
||||||
$export_text .= 'Types: '.$type_list.'<br />';
|
|
||||||
$export_text .= 'Query: '.$qry.'<br />';
|
|
||||||
echo str_replace("\n","<br />",$export_text);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(headers_sent())
|
|
||||||
{
|
|
||||||
return "Cannot output file - some data already sent<br /><br />";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Secure https check
|
if (defined('CSV_DEBUG'))
|
||||||
if (isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype') header('Pragma: public');
|
{
|
||||||
if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE'))
|
$export_text .= 'Summary data: <br />';
|
||||||
header('Content-Type: application/force-download');
|
$export_text .= 'File: '.$filename.'<br />';
|
||||||
|
$export_text .= 'Types: '.$type_list.'<br />';
|
||||||
|
$export_text .= 'Query: '.$qry.'<br />';
|
||||||
|
echo str_replace("\n","<br />",$export_text);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
header('Content-Type: application/octet-stream');
|
{
|
||||||
header('Content-Length: '.strlen($export_text));
|
if(headers_sent())
|
||||||
header('Content-disposition: attachment; filename="'.$filename.'"');
|
{
|
||||||
echo $export_text;
|
return "Cannot output file - some data already sent<br /><br />";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Secure https check
|
||||||
|
if (isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype') header('Pragma: public');
|
||||||
|
if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE'))
|
||||||
|
header('Content-Type: application/force-download');
|
||||||
|
else
|
||||||
|
header('Content-Type: application/octet-stream');
|
||||||
|
header('Content-Length: '.strlen($export_text));
|
||||||
|
header('Content-disposition: attachment; filename="'.$filename.'"');
|
||||||
|
echo $export_text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Log event to admin log
|
// Log event to admin log
|
||||||
function banlist_adminlog($msg_num='00', $woffle='')
|
function banlist_adminlog($msg_num='00', $woffle='')
|
||||||
{
|
{
|
||||||
global $pref, $admin_log;
|
e107::getAdminLog()->log_event('BANLIST_'.$msg_num, $woffle, E_LOG_INFORMATIVE, '');
|
||||||
// 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,'');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user