Current Path : /data/web/virtuals/51568/virtual/www/www/galerie/ |
Current File : /data/web/virtuals/51568/virtual/www/www/galerie/galerie-download.php |
<?php function createZipArchive($files=array(), $destination='', $overwrite=false) { if(file_exists($destination) && !$overwrite) { return false; } $validFiles=array(); if(is_array($files)) { foreach($files as $file) { if(file_exists($file)) { $validFiles[] = $file; } } } if(count($validFiles)) { $zip=new ZipArchive(); if($zip->open($destination, $overwrite? ZIPARCHIVE::OVERWRITE: ZIPARCHIVE::CREATE) == true) { foreach($validFiles as $file) { $zip->addFile($file, $file); } $zip->close(); return file_exists($destination); } else { return false; } } else { return false; } } if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') {$url = 'https://'; } else {$url = 'http://';} $url.= $_SERVER['HTTP_HOST']; $downloadDir = $url.'/ftp/tmp/'; $downloadFile=$downloadDir.'myzipfile.zip'; $targetDir = "../../ftp/tmp"; if(!is_dir($targetDir)){ mkdir($targetDir); } $targetDir .= "/"; $urlFile = $targetDir .= "myzipfile.zip"; $files=array('galerie.js', 'galerie.php'); $result= createZipArchive($files, $urlFile); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Length: ' . filesize($urlFile)); header('Content-Disposition: attachment; filename="'.basename($downloadFile).'"'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); readfile($downloadFile); ?>