diff --git a/lib/config.php b/lib/config.php
index 0350b2f..ce81f20 100644
--- a/lib/config.php
+++ b/lib/config.php
@@ -18,7 +18,7 @@ $ICEcoder = array(
"plugins" => array(
array("Database Admin","images/database.png","margin-top: 3px","plugins/adminer/adminer-3.3.3-mysql-en.php","_blank",""),
array("Batch Image Processor","images/images.png","margin-top: 5px","http://birme.net","_blank",""),
- array("Zip It!","images/zip-it.png","margin-top: 3px","plugins/zip-it/?zip=|&exclude=.doc,.gif,.jpg,.jpeg,.pdf,.png,.swf,.xml,.zip","fileControl:Zipping Files","10")
+ array("Zip It!","images/zip-it.png","margin-top: 3px","plugins/zip-it/?zip=|&exclude=.doc,.gif,.jpg,.jpeg,.pdf,.png,.swf,.xml,.zip","fileControl:Zipping Files","30")
),
"theme" => "default",
"tabWidth" => 4,
diff --git a/plugins/zip-it/index.php b/plugins/zip-it/index.php
index c4eecba..57f52ac 100644
--- a/plugins/zip-it/index.php
+++ b/plugins/zip-it/index.php
@@ -15,10 +15,12 @@ include("../../lib/settings.php");
$zipItSaveLocation = '../../backups/';
if ($_GET['zip']=="|") {$zipItFileName = "root";} else {$zipItFileName = str_replace("|","_",strClean($_GET['zip']));};
$zipItFileName .= '-'.time().'.zip';
+$keepLastDays = 7;
if (!is_dir($zipItSaveLocation)) {mkdir($zipItSaveLocation, 0777);}
Class zipIt {
- public function zipFilesUp($zipName='') {
+ public function zipFilesUp($zipDir,$zipFile,$keepLastDays) {
+ $zipName = $zipDir.$zipFile;
$zipFiles = array();
$_GET['zip']=="|" ? $zipTgt = "" : $zipTgt = str_replace("|","/",strClean($_GET['zip']));
if (strpos($_GET['zip'],"/")!==0) {$zipTgt = "/".$zipTgt;};
@@ -39,6 +41,17 @@ Class zipIt {
} else {
if(file_exists($addItem)) {$zipFiles[] = $addItem;}
}
+ if ($backupsDir = opendir($zipDir)) {
+ $keepTime = $keepLastDays*60*60*24;
+ while (false !== ($backup = readdir($backupsDir))) {
+ if ($backup != "." && $backup != "..") {
+ if ((time()-filemtime($zipDir.$backup)) > $keepTime) {
+ unlink($zipDir.$entry) or DIE("couldn't delete $zipDir$backup
");
+ }
+ }
+ }
+ closedir($backupsDir);
+ }
if(count($zipFiles)) {
$zip = new ZipArchive();
if($zip->open($zipName,ZIPARCHIVE::CREATE)!== true) {return false;}
@@ -53,6 +66,7 @@ Class zipIt {
}
}
$zip->close();
+ chmod($zipName, 0777);
return file_exists($zipName);
} else {
return false;
@@ -62,7 +76,7 @@ Class zipIt {
if($_SESSION['userLevel']==10) {
$zipItDoZip = new zipIt();
echo '';
- $zipItAddToZip = $zipItDoZip->zipFilesUp($zipItSaveLocation.$zipItFileName);
+ $zipItAddToZip = $zipItDoZip->zipFilesUp($zipItSaveLocation,$zipItFileName,$keepLastDays);
if (!$zipItAddToZip) {
echo '';
} else {