first commit

This commit is contained in:
dev-chiefworks
2022-05-31 16:21:53 -04:00
commit f76abffdcd
5978 changed files with 1078901 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
function deleteDir($dirPath)
{
if (!is_dir($dirPath)) {
throw new InvalidArgumentException("$dirPath must be a directory");
}
if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
$dirPath .= '/';
}
$files = glob($dirPath . '*', GLOB_MARK);
foreach ($files as $file) {
if (is_dir($file)) {
deleteDir($file);
} else {
unlink($file);
}
}
rmdir($dirPath);
}
function zipDir($pathdir, $zipcreated, $extensions = [])
{
// Create new zip class
$zip = new ZipArchive;
if($zip->open($pathdir . DIRECTORY_SEPARATOR . $zipcreated, (ZipArchive::CREATE)) === TRUE) {
// Store the path into the variable
$dir = opendir($pathdir);
while($file = readdir($dir)) {
$file_parts = pathinfo($pathdir . DIRECTORY_SEPARATOR . $file);
if ( ! in_array($file_parts['extension'], $extensions)) {
continue;
}
if(is_file($pathdir . DIRECTORY_SEPARATOR . $file)) {
$zip -> addFile($pathdir . DIRECTORY_SEPARATOR . $file, $file);
}
}
$zip ->close();
}
}