-
Notifications
You must be signed in to change notification settings - Fork 0
/
csv-emails.php
30 lines (25 loc) · 941 Bytes
/
csv-emails.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
require_once("config.php");
if ($_REQUEST["p"] !== RESULTS_PASSWORD) {
header('HTTP/1.0 403 Forbidden');
die('You are not allowed to access this file.');
}
date_default_timezone_set('Europe/London');
$data = json_decode(file_get_contents(FILE_EMAILS . ".json"), true);
header('Content-Description: File Transfer');
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="csv-emails-' . date("Y-m-d_H-i-s") . '.csv"');
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
header('Pragma: public');
echo "timestamp,email,ip address,proxied ip address\n";
if ($data) {
foreach ($data as $row) {
echo "" . date("Y-m-d H:i:s", $row['timestamp']) . ",";
echo $row['email'] . ",";
echo $row['ip'] . ",";
echo $row['proxy']. "\n";
}
}
?>