Commit 90e86ddf authored by Thomas Bella's avatar Thomas Bella

Add option to export domain list as csv

parent d283ce70
Pipeline #308 passed with stage
in 16 seconds
......@@ -72,6 +72,47 @@ if (isset($_SESSION["active"]) && isset($_GET["ajax"])) {
define("AJAXCALL", true);
require_once "page/ajax.php";
exit;
} else if (isset($_SESSION['active']) && isset($_GET['export'])) {
if ($_GET['export'] == 'csv') {
header('Content-Type: text/csv; Charset=UTF-8');
header('Content-Disposition: attachment; filename="certificate-monitor-' . date('Ymd') . '.csv"');
header('Pragma: no-cache');
// Fetch table column names
$fields = $SQL->query("PRAGMA table_info(domain);");
$i = 0;
foreach ($fields as $column) {
if ($i != 0) {
echo ';';
}
echo $column['name'];
$i++;
}
echo "\n";
// Fetch table data
$domains = $SQL->query("SELECT * FROM domain ORDER BY id", [], PDO::FETCH_ASSOC);
foreach ($domains as $singleEntry) {
$i = 0;
foreach ($singleEntry as $entry) {
if ($i != 0) {
echo ';';
}
// have to use double-quotes because email is separated with ";"
if (strpos($entry, ';')) {
echo '"';
}
echo $entry;
// have to use double-quotes because email is separated with ";"
if (strpos($entry, ';')) {
echo '"';
}
$i++;
}
echo "\n";
}
}
exit;
}
?>
......
......@@ -270,7 +270,7 @@ if ($filesize < 1000) {
} else {
echo round($filesize/(1000*1000),2) . " MB";
}
?></div>
?> (<a href="index.php?export=csv">Export</a>)</div>
<div class="col-xs-5 col-sm-3">Software update</div>
<div class="col-xs-7 col-sm-9" id="versionstatus">Checking ...</div>
<div class="col-xs-5 col-sm-3">Latest version</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment