From 0592459666f7c32d2fa8ac9562e73cf4cd859f06 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Tue, 8 Sep 2015 08:03:53 +0100 Subject: [PATCH] Backup system working with params now Only run backup process if user has this turned on. Some code simplification added. Removes old backups past X days as per user setting. --- lib/file-control-xhr.php | 80 ++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/lib/file-control-xhr.php b/lib/file-control-xhr.php index 6aff266..189c920 100644 --- a/lib/file-control-xhr.php +++ b/lib/file-control-xhr.php @@ -247,41 +247,59 @@ if (!$error && $_GET['action']=="save") { } // Save a version controlled backup source of the file - // Establish the base, host and date dir parts... - $backupDirBase = str_replace("\\","/",dirname(__FILE__))."/../backups/"; - $backupDirHost = isset($ftpSite) ? parse_url($ftpSite,PHP_URL_HOST) : "localhost"; - $backupDirDate = date("Y")."-".date("m")."-".date("d"); + if ($ICEcoder["backupsKept"]) { + $backupDirFormat = "Y-m-d"; - // Establish an array of dirs from base to our file location - $subDirsArray = explode("/",ltrim($fileLoc,"/")); - array_unshift($subDirsArray,$backupDirHost,$backupDirDate); - // Make any dirs that don't exist - if (!is_dir($backupDirBase.implode("/",$subDirsArray))) { - $pathIncr = ""; - for ($i=0; $i