diff --git a/.gitignore b/.gitignore index 3641ae77a..a805acbe6 100755 --- a/.gitignore +++ b/.gitignore @@ -82,6 +82,8 @@ files/* !files/impianti/ files/impianti/* !files/impianti/componente.ini +!files/temp/ +files/temp/* tmp/ config.inc.php database.sql diff --git a/files/temp/.gitkeep b/files/temp/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/lib/util.php b/lib/util.php index d8e5655e4..431dd2975 100755 --- a/lib/util.php +++ b/lib/util.php @@ -334,9 +334,13 @@ if (!function_exists('download')) { header('Content-Type: application/octet-stream'); header('Content-Transfer-Encoding: binary'); - header('Content-Length: '.filesize($file)); - $open = fopen($file, 'rb'); + + fseek($open, 0, SEEK_END); + $size = ftell($open); + header('Content-Length: '.$size); + + fseek($open, 0); while (!feof($open)) { echo fread($open, 1024 * 8); ob_flush(); @@ -544,12 +548,15 @@ if (!function_exists('temp_file')) { $name = secure_random_string(); } - /*$file = DIRECTORY_SEPARATOR. - trim(sys_get_temp_dir(), DIRECTORY_SEPARATOR). + // $base_directory = trim(sys_get_temp_dir(), DIRECTORY_SEPARATOR); + $base_directory = implode(DIRECTORY_SEPARATOR, [ + trim(base_dir(), DIRECTORY_SEPARATOR), + 'files', + 'temp', + ]); + $file = trim($base_directory, DIRECTORY_SEPARATOR). DIRECTORY_SEPARATOR. - ltrim($name, DIRECTORY_SEPARATOR);*/ - - $file = implode(DIRECTORY_SEPARATOR, [base_dir(), 'files', 'temp', ltrim($name, DIRECTORY_SEPARATOR)]); + ltrim($name, DIRECTORY_SEPARATOR); file_put_contents($file, $content); diff --git a/modules/anagrafiche/bulk.php b/modules/anagrafiche/bulk.php index c87d18f7a..f86840896 100755 --- a/modules/anagrafiche/bulk.php +++ b/modules/anagrafiche/bulk.php @@ -70,7 +70,7 @@ switch (post('op')) { $exporter = new CSV($file); // Esportazione dei record selezionati - $anagrafiche = Anagrafica::whereIn('id', $id_records)->get(); + $anagrafiche = Anagrafica::whereIn('idanagrafica', $id_records)->get(); $exporter->setRecords($anagrafiche); $count = $exporter->exportRecords(); diff --git a/modules/fatture/bulk.php b/modules/fatture/bulk.php index bbfe9e531..6b5570692 100755 --- a/modules/fatture/bulk.php +++ b/modules/fatture/bulk.php @@ -431,8 +431,7 @@ switch (post('op')) { break; case 'export-csv': - $file = temp_file().'.csv'; - + $file = temp_file(); $exporter = new CSV($file); // Esportazione dei record selezionati