Your IP : 216.73.216.229


Current Path : /home/jeromecohp/www/aesecure/premium/helpers/
Upload File :
Current File : /home/jeromecohp/www/aesecure/premium/helpers/zip.php

<?php
   // @file : /premium/helpers/zip.php
   // @version : 2.0.2
   // @author : AVONTURE Christophe - christophe@aesecure.com
   // @copyright : (C) 2013-2015 - Christophe Avonture - all right reserved.
   // @url : http://www.aesecure.com/
   // @package : 2015-02-14 13:37:44
   // @license : This program is a commercial software.  You CAN'T redistribute it and/or modify it.
   // Source code is the property of Christophe Avonture and can't be reused, in whole or in part, in any programs.
?>
<?php
defined( '_AESECURE') or die('No direct access allowed');
class recurseZip{
private function recurse_zip($src,&$zip,$path){
if(is_readable($src)){
try{
$dir = opendir($src);
while(false !== ( $file = readdir($dir))){
if(($file!='.')&&($file!='..')&&($file!='/')){
if( is_dir($src.'/'.$file)){
$this->recurse_zip($src.'/'.$file,$zip,$path);} else{
$zip->addFile($src.'/'.$file,substr($src.'/'.$file,$path));}}}  closedir($dir);} catch (Exception $e){}} }  public function compress($src,$dst=''){
@ini_set('max_execution_time', '0');
@ini_set('set_time_limit', '0');if(substr($src,-1)==='/'){$src=substr($src,0,-1);}
if(substr($dst,-1)==='/'){$dst=substr($dst,0,-1);}
$path=strlen(dirname($src).'/');if(file_exists($dst)) unlink($dst);
$zip = new ZipArchive;
$res = $zip->open($dst, ZipArchive::CREATE);if($res !== TRUE){echo 'Error: Unable to create zip file'; exit;}
if(is_file($src)){
$zip->addFile($src,substr($src,$path));} else{
if(!is_dir($src)){
$zip->close();
@unlink($dst);echo 'Error: File not found';
exit;}
$this->recurse_zip($src,$zip,$path);}
$zip->close();
return $dst;}}