mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-03 07:13:59 +01:00
Sanitising vars and working with new exclude var
Cleaning vars with strClean function now Made a slight change to zipTgt to handle root with empty var Checks and only adds file to zip if it's not excluded
This commit is contained in:
@@ -1,29 +1,26 @@
|
||||
<?php
|
||||
// -----------------------------------------------
|
||||
// Zip-It! for ICEcoder v0.9.0 by Matt Pass
|
||||
// Zip-It! for ICEcoder v0.9.1 by Matt Pass
|
||||
// Will backup requested files/folders in ICEcoder
|
||||
// -----------------------------------------------
|
||||
include("../../lib/settings.php");
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Zip It! for ICEcoder</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?
|
||||
$zipItSaveLocation = '../../backups/';
|
||||
if ($_GET['zip']=="|") {$zipItFileName = "root";} else {$zipItFileName = str_replace("|","_",$_GET['zip']);};
|
||||
if ($_GET['zip']=="|") {$zipItFileName = "root";} else {$zipItFileName = str_replace("|","_",strClean($_GET['zip']));};
|
||||
$zipItFileName .= '-'.time().'.zip';
|
||||
|
||||
if (!is_dir($zipItSaveLocation)) {mkdir($zipItSaveLocation, 0777);}
|
||||
|
||||
Class zipIt {
|
||||
public function zipFilesUp($zipName='') {
|
||||
$zipFiles = array();
|
||||
$zipTgt = str_replace("|","/",$_GET['zip']);
|
||||
$_GET['zip']=="|" ? $zipTgt = "" : $zipTgt = str_replace("|","/",strClean($_GET['zip']));
|
||||
if (strpos($_GET['zip'],"/")!==0) {$zipTgt = "/".$zipTgt;};
|
||||
$addItem = $_SERVER['DOCUMENT_ROOT'].$zipTgt;
|
||||
if (is_dir($addItem)) {
|
||||
@@ -45,8 +42,15 @@ Class zipIt {
|
||||
if(count($zipFiles)) {
|
||||
$zip = new ZipArchive();
|
||||
if($zip->open($zipName,ZIPARCHIVE::CREATE)!== true) {return false;}
|
||||
$excludeFilesFolders = explode(",",strClean($_GET['exclude']));
|
||||
foreach($zipFiles as $file) {
|
||||
$zip->addFile($file,str_replace($_SERVER['DOCUMENT_ROOT']."/","",$file));
|
||||
$canAdd=true;
|
||||
for ($i=0;$i<count($excludeFilesFolders);$i++) {
|
||||
if(strpos($file,$excludeFilesFolders[$i])!==false) {$canAdd=false;};
|
||||
}
|
||||
if ($canAdd==true) {
|
||||
$zip->addFile($file,str_replace($_SERVER['DOCUMENT_ROOT']."/","",$file));
|
||||
}
|
||||
}
|
||||
$zip->close();
|
||||
return file_exists($zipName);
|
||||
@@ -67,5 +71,4 @@ if($_SESSION['userLevel']==10) {
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user