docRoot being passed in, delimiting on asterisk

Recently started using $docRoot in place of the $_SERVER version but
this var isn't available within the class. Now being passed in so it can
be used.

Also now exploding the exclude list on asterisk rather than comma to
avoid problems elsewhere.
This commit is contained in:
Matt Pass
2012-07-28 13:20:02 +01:00
parent 047daf4e44
commit eeffd207be

View File

@@ -20,12 +20,13 @@ $keepLastDays = 7;
if (!is_dir($zipItSaveLocation)) {mkdir($zipItSaveLocation, 0777);}
Class zipIt {
public function zipFilesUp($zipDir,$zipFile,$keepLastDays) {
public function zipFilesUp($zipDir,$zipFile,$keepLastDays,$docRoot) {
$zipName = $zipDir.$zipFile;
$zipFiles = array();
$_GET['zip']=="|" ? $zipTgt = "" : $zipTgt = str_replace("|","/",strClean($_GET['zip']));
if (strpos($_GET['zip'],"/")!==0) {$zipTgt = "/".$zipTgt;};
$addItem = $docRoot.$zipTgt;
if (is_dir($addItem)) {
$dirStack = array($addItem);
while (!empty($dirStack)) {
@@ -57,7 +58,7 @@ Class zipIt {
if(count($zipFiles)) {
$zip = new ZipArchive();
if($zip->open($zipName,ZIPARCHIVE::CREATE)!== true) {return false;}
$excludeFilesFolders = explode(",",strClean($_GET['exclude']));
$excludeFilesFolders = explode("*",strClean($_GET['exclude']));
foreach($zipFiles as $file) {
$canAdd=true;
for ($i=0;$i<count($excludeFilesFolders);$i++) {
@@ -78,7 +79,7 @@ Class zipIt {
if($_SESSION['userLevel']==10) {
$zipItDoZip = new zipIt();
echo '<script>top.ICEcoder.serverMessage("<b>Zipping Files</b>");</script>';
$zipItAddToZip = $zipItDoZip->zipFilesUp($zipItSaveLocation,$zipItFileName,$keepLastDays);
$zipItAddToZip = $zipItDoZip->zipFilesUp($zipItSaveLocation,$zipItFileName,$keepLastDays,$docRoot);
if (!$zipItAddToZip) {
echo '<script>top.ICEcoder.message("Could not zip files up!");</script>';
} else {