From ae9b65e011d8a1a92350db7830c11df3ea97a6f7 Mon Sep 17 00:00:00 2001 From: Evgeny Vedegis Date: Tue, 8 Jan 2019 20:04:03 +0300 Subject: [PATCH] Fixed finder/becup folder. abs path to relative --- src/js/finder.js | 2 +- wcms/wex/core/FileFinder.php | 2 +- wcms/wex/core/classes/backup.php | 22 ++++++---------------- wcms/wex/core/defines.php | 11 ++++++++--- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/js/finder.js b/src/js/finder.js index b2c2c90..cc71223 100644 --- a/src/js/finder.js +++ b/src/js/finder.js @@ -26,7 +26,7 @@ window.change_checkboxes = function (l,v) { window.get_checkboxes = function () { let i = document.getElementsByName('file[]') a = [] - for (let j = i.length-1;j>=0;j--) { + for (let j = i.length-1;j>=0;j--) { if(i[j].type='checkbox') { a.push(i[j]) } diff --git a/wcms/wex/core/FileFinder.php b/wcms/wex/core/FileFinder.php index b86543a..600b3a7 100644 --- a/wcms/wex/core/FileFinder.php +++ b/wcms/wex/core/FileFinder.php @@ -22,7 +22,7 @@ $default_timezone = 'Europe/Minsk'; // UTC+3 // Root path for file manager -$root_path = $_SERVER['DOCUMENT_ROOT']; +$root_path = SITE_DIR; // Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder' // Will not working if $root_path will be outside of server document root diff --git a/wcms/wex/core/classes/backup.php b/wcms/wex/core/classes/backup.php index 9fb4058..72cca93 100644 --- a/wcms/wex/core/classes/backup.php +++ b/wcms/wex/core/classes/backup.php @@ -14,36 +14,26 @@ class Backup { public function create () { //TODO glob + rm to finder - $root_path = $_SERVER['DOCUMENT_ROOT']; - //TODO FIX abs path - $wex_path = dirname(dirname(dirname(__FILE__))); + $root_path = SITE_DIR; // Pack files if (isset($_POST['backup_create'])) { $path = $root_path; - // ZipArchive not found if (!class_exists('ZipArchive')) { //TODO glob vue alert echo 'Operations with archives are not available'; // redirect_to('index.php') } - // Search all files/folder. Fix array .. . + + // Search all files/folder. array_diff - Fixed array '..' + '.' $files = array_diff(scandir($path), array('..', '.')); + // Check folder error if (!empty($files)) { chdir($root_path); - // 1 folder (feature) - //TODO rm - if (count($files) == 1) { - $one_file = reset($files); - $one_file = basename($one_file); - $zipname = date('d-m-Y_H:i:s') . '.zip'; - // > 1 folder - } else { - //TODO fix same name - $zipname = BACKUP_DIR . date('d-m-Y_H:i:s') . '.zip'; - } + //TODO fix same name + $zipname = BACKUP_DIR . date('d-m-Y_H:i:s') . '.zip'; $zipper = new Zipper(); $res = $zipper->create($zipname, $files); diff --git a/wcms/wex/core/defines.php b/wcms/wex/core/defines.php index c005100..1056c10 100644 --- a/wcms/wex/core/defines.php +++ b/wcms/wex/core/defines.php @@ -7,16 +7,21 @@ */ define('DS', '/'); -define('WCMS', true); -define('WCMS_VERSION', '0.3.1'); +// // define('WCMS', true); +define('WCMS_VERSION', '0.3.2'); // Webpack define('WCMS_DEV', false); define('WCMS_DEV_PORT', 'http://localhost:8081'); //! Directories and Paths -define('WCMS_ROOT', str_replace(DIRECTORY_SEPARATOR, DS, getcwd())); +// // old way do not use +// // define('WCMS_ROOT', str_replace(DIRECTORY_SEPARATOR, DS, getcwd())); +// new way +define('WCMS_ROOT', dirname(__DIR__)); define('ROOT_DIR', WCMS_ROOT . '/'); +define('SITE_DIR', dirname(WCMS_ROOT)); + // Backup define('BACKUP_PATH', 'backups/'); define('BACKUP_DIR', ROOT_DIR . BACKUP_PATH); \ No newline at end of file