Created
January 30, 2017 20:10
-
-
Save alissonsilvas/ed4c83344e8405cf3de450d696cd13a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ZipFiles extends ZipArchive | |
{ | |
public function Compact($cwd) { | |
$open = opendir($cwd); | |
while($folder = readdir($open)) | |
{ | |
if ($folder != '.' && $folder != '..') | |
{ | |
if (is_dir($cwd.'/'.$folder)) | |
{ | |
$dir = str_replace('./', '',($cwd.'/'.$folder)); | |
$this->addEmptyDir($dir); | |
$this->Compact($dir); | |
} | |
elseif (is_file($cwd.'/'.$folder)) | |
{ | |
$arq = str_replace('./', '',$cwd.'/'.$folder); | |
$this->addFile($arq); | |
} | |
} | |
} | |
} | |
} | |
$zip = new ZipFiles(); | |
$path = date('Ym'); | |
$arquivo = "../nfephp/files_nfe/homologacao/Xml$path.zip"; | |
chmod($arquivo, 0777); | |
if ($zip->open($arquivo, ZIPARCHIVE::CREATE) === true){ | |
$zip->Compact("."); | |
} | |
$zip->close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment