Warning: unlink(./data/secure/tokens/8aceaff2cd201c1d80d74de42bef6f685c16a2f4ad6011cc6833e12424ba25b51107db4babc11f528daf6e8e29d4b6fd89251dbc4300d65a70f47041736b6004.token): No such file or directory in /home/sigesthaxo/snippetvamp/assets/php/class/Helium_secure_class.php on line 865

Warning: unlink(./data/secure/tokens/8dd9a57722cae1963b5b536bb50c7060f3413b489b692338b43f072b6dd987ba1342b4b348a658746a6a26830e891193726668157440c2c214dd35e2cda9cf3e.token): No such file or directory in /home/sigesthaxo/snippetvamp/assets/php/class/Helium_secure_class.php on line 865

Warning: filemtime(): stat failed for ./data/secure/tokens/b7d44fc6977bc7787864c110f9ea9c324eb86db43117fae5e8692e55f9e6f9086ccf397d0615a12886c3e20407aedcc2aa60aac7c1239be0b5bee8af27f8ac03.token in /home/sigesthaxo/snippetvamp/assets/php/class/Helium_secure_class.php on line 831

Warning: unlink(./data/secure/tokens/cb95811af870367c8c02c2bfd0ba9ae6bda012880eb424aa9d1d15ebc8d0d515bd8a9ec1409a657adb55f22abd974d7a986cb836a08a9e34057f00ee0fc4f003.token): No such file or directory in /home/sigesthaxo/snippetvamp/assets/php/class/Helium_secure_class.php on line 865

Warning: unlink(./data/secure/tokens/f4ed2dacd9c757121e42564f4c9d66de827852c92d2b9cbf3bd7eea95367e7137945b70d9d06489332322cea68fdb0532d87d182c6b957622a7975b85587d8b9.token): No such file or directory in /home/sigesthaxo/snippetvamp/assets/php/class/Helium_secure_class.php on line 865

Warning: unlink(./data/secure/tokens/f72270647fe2189f73b6912e06e47d2d3407f0ee475c4a8d965901900dbde11b20c2b5a983804ecc47b2ab4e9f936cf43be3a3e914363f1e6e14d8b69800f2d9.token): No such file or directory in /home/sigesthaxo/snippetvamp/assets/php/class/Helium_secure_class.php on line 865
SnippetVamp - open
#key - Générer un zip
/**
* Generates a zip.
*
* @param string $dir
* @return void
* @author Thibaud Rohmer
*/
public static function Zip($dir){

/// Check that user is allowed to acces this content
if( !Judge::view($dir)){
return;
}	


                // Get the relative path of the files
$delimPosition = strrpos($dir, '/');
if (strlen($dir) == $delimPosition) {
echo "Error: Directory has a slash at the end";
return;
}

// Create list with all filenames
$items = Menu::list_files($dir,true);
$itemsString = '';

foreach($items as $item){
if(Judge::view($item)){
                                // Use only the relative path of the filename
$item = str_replace('//', '/', $item);
$itemsString.=" '".substr($item,$delimPosition+1)."'";
}
}

// Close and send to user
header('Content-Type: application/zip');
header("Content-Disposition: attachment; filename=\"".htmlentities(basename($dir), ENT_QUOTES ,'UTF-8').".zip\"");

                // Store the current working directory and change to the albums directory
$cwd = getcwd();
chdir(substr($dir,0,$delimPosition));

// ZIP-on-the-fly method copied from http://stackoverflow.com/questions/4357073
//
// use popen to execute a unix command pipeline
// and grab the stdout as a php stream
$fp = popen('zip -n .jpg:.JPG:.jpeg:.JPEG -0 - ' . $itemsString, 'r');

if(!is_resource($fp)) {
return false;
}

// pick a bufsize that makes you happy (8192 has been suggested).
$bufsize = 8192;
$buff = '';
while( !feof($fp) ) {
$buff = fread($fp, $bufsize);
                        echo $buff;
                        /// flush();
                }
                pclose($fp);
                
                // Chang to the previous working directory
                chdir($cwd);
}