2 include("incl/functions.php");
3 include("incl/config.php");
5 if($do_file_download) {
7 $selected_file_paths = array();
8 foreach($_REQUEST['selected_files'] as $selected_file) {
9 $selected_file_path = $save_dir . basename($selected_file);
10 if(is_readable($selected_file_path)) {
11 array_push($selected_file_paths, $selected_file_path);
14 $zipfile_path = $temp_dir . 'scanned_' . time() . '.zip';
15 if(sizeof($selected_file_paths) > 0) {
16 create_zip($selected_file_paths, $zipfile_path, true);
17 if(is_readable($zipfile_path)) {
18 //output path to created file
25 /* creates a compressed zip file */
26 function create_zip($files = array(),$destination = '',$overwrite = false) {
27 //if the zip file already exists and overwrite is false, return false
28 if(file_exists($destination) && !$overwrite) { return false; }
30 $valid_files = array();
31 //if files were passed in...
32 if(is_array($files)) {
33 //cycle through each file
34 foreach($files as $file) {
35 //make sure the file exists
36 if(file_exists($file)) {
37 $valid_files[] = $file;
41 //if we have good files...
42 if(count($valid_files)) {
44 $zip = new ZipArchive();
45 if($zip->open($destination,$overwrite ? ZIPARCHIVE
::OVERWRITE
: ZIPARCHIVE
::CREATE
) !== true) {
50 foreach($valid_files as $file) {
51 $zip->addFile($file, basename($file));
57 //check to make sure the file exists
58 return file_exists($destination);