Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
36 righe
1.3 KiB
36 righe
1.3 KiB
<? |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
$error = true; |
|
if (!empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice) && !empty($_GET["token"]) && !empty($_GET["modulo"]) && !empty($_SESSION["reportManagerData"][$_GET["token"]][$_GET["modulo"]])) { |
|
$error = false; |
|
$data = $_SESSION["reportManagerData"][$_GET["token"]][$_GET["modulo"]]; |
|
$firstLine = [array_keys($data[0])]; |
|
$data = array_merge($firstLine,$data); |
|
header('Content-Description: File Transfer'); |
|
header("Content-type: text/csv"); |
|
header("Content-Disposition: attachment; filename=\"export.csv\""); |
|
header('Content-Transfer-Encoding: binary'); |
|
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
header('Pragma: public'); |
|
header("Expires: 0"); |
|
foreach($data AS $row) { |
|
array_walk($row,function(&$item) { |
|
if (is_numeric($item)) { |
|
$item = str_replace(".",",",$item); |
|
} else { |
|
$item = strip_tags($item); |
|
$item = convert_to_utf8($item); |
|
$item = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $item); |
|
$item = preg_replace( "/\r|\n/", "", $item); |
|
$item = str_replace('"', '""', $item); |
|
} |
|
return $item; |
|
}); |
|
echo "\"" . implode("\";\"",$row) . "\"".PHP_EOL; |
|
} |
|
} |
|
if ($error) { |
|
header('HTTP/1.0 403 Forbidden'); |
|
die(); |
|
} |