Skip to content

Commit

Permalink
Fixed finder/becup folder. abs path to relative
Browse files Browse the repository at this point in the history
  • Loading branch information
vedees committed Jan 8, 2019
1 parent a69e59a commit ae9b65e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/js/finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
Expand Down
2 changes: 1 addition & 1 deletion wcms/wex/core/FileFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 6 additions & 16 deletions wcms/wex/core/classes/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 8 additions & 3 deletions wcms/wex/core/defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit ae9b65e

Please sign in to comment.