38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
// output headers so that the file is downloaded rather than displayed
|
|
include('conn.php');
|
|
date_default_timezone_set("America/Montreal");
|
|
$datetime=date('Ymdhis');
|
|
|
|
header('Content-Type: text/csv; charset=utf-8');
|
|
|
|
if (isset($_POST['sql_find_b'])&&!empty($_POST['sql_find_b'])){
|
|
$sql_find=$_POST['sql_find_b'];
|
|
header("Content-Disposition: attachment; filename=ipban_blacklist_".$datetime.".csv");
|
|
}
|
|
elseif (isset($_POST['sql_find_w'])&&!empty($_POST['sql_find_w'])){
|
|
$sql_find=$_POST['sql_find_w'];
|
|
header("Content-Disposition: attachment; filename=ipban_whitelist_".$datetime.".csv");
|
|
}
|
|
else{
|
|
$_SESSION['ret_link']="index.php";
|
|
$_SESSION['rezult_msg']="There aren't any values available to export.";
|
|
header("location:index.php?var=2");
|
|
return false;
|
|
}
|
|
//echo $sql_find;
|
|
//exit;
|
|
|
|
// create a file pointer connected to the output stream
|
|
$output = fopen('php://output', 'w');
|
|
|
|
// output the column headings
|
|
fputcsv($output, array('IP','Type','Add Date','End Date','Reason','Type-Label'));
|
|
|
|
// fetch the data
|
|
|
|
$sql_rez = mysqli_query($con,$sql_find);
|
|
|
|
// loop over the rows, outputting them
|
|
while ($row = mysqli_fetch_assoc($sql_rez)) fputcsv($output, $row);
|
|
?>
|