Update index.php

This commit is contained in:
FusionPBX
2019-04-05 17:02:58 -06:00
committed by GitHub
parent 0af41dfc34
commit a61bc4f418
+25 -17
View File
@@ -17,22 +17,25 @@
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2016 Portions created by the Initial Developer are Copyright (C) 2008-2019
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
include "root.php"; //includes
require_once "resources/require.php"; include "root.php";
require_once "resources/check_auth.php"; require_once "resources/require.php";
if (permission_exists("backup_download")) { require_once "resources/check_auth.php";
//access granted
} //check permissions
else { if (permission_exists("backup_download")) {
echo "access denied"; //access granted
exit; }
} else {
echo "access denied";
exit;
}
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
@@ -40,8 +43,9 @@ else {
//download the backup //download the backup
if ($_GET['a'] == "download" && permission_exists('backup_download')) { if ($_GET['a'] == "download" && permission_exists('backup_download')) {
$file_format = $_GET['file_format']; //get the file format
$file_format = ($file_format != '') ? $file_format : 'tgz'; $file_format = $_GET['file_format'];
$file_format = ($file_format != '') ? $file_format : 'tgz';
//build the backup file //build the backup file
$backup_path = ($_SESSION['server']['backup']['path'] != '') ? $_SESSION['server']['backup']['path'] : '/tmp'; $backup_path = ($_SESSION['server']['backup']['path'] != '') ? $_SESSION['server']['backup']['path'] : '/tmp';
@@ -55,8 +59,12 @@ else {
default : $cmd = 'tar -zvcf '; default : $cmd = 'tar -zvcf ';
} }
$cmd .= $backup_path.'/'.$backup_file.' '; $cmd .= $backup_path.'/'.$backup_file.' ';
if (isset($_SESSION['backup']['path'])) foreach ($_SESSION['backup']['path'] as $value) { if (isset($_SESSION['backup']['path'])) {
$cmd .= $value.' '; foreach ($_SESSION['backup']['path'] as $value) {
if (file_exists($value)) {
$cmd .= $value.' ';
}
}
} }
$cmd .= " 2>&1"; $cmd .= " 2>&1";
exec($cmd, $response, $restore_errlevel); exec($cmd, $response, $restore_errlevel);
@@ -109,7 +117,7 @@ else {
$backup_path = ($_SESSION['server']['backup']['path'] != '') ? $_SESSION['server']['backup']['path'] : '/tmp'; $backup_path = ($_SESSION['server']['backup']['path'] != '') ? $_SESSION['server']['backup']['path'] : '/tmp';
$backup_file = $_FILES['backup_file']['name']; $backup_file = $_FILES['backup_file']['name'];
if (is_uploaded_file($_FILES['backup_file']['tmp_name'])) { if (is_uploaded_file($_FILES['backup_file']['tmp_name']) && file_exists($backup_path.'/'.$backup_file)) {
//move temp file to backup path //move temp file to backup path
move_uploaded_file($_FILES['backup_file']['tmp_name'], $backup_path.'/'.$backup_file); move_uploaded_file($_FILES['backup_file']['tmp_name'], $backup_path.'/'.$backup_file);
//determine file format and restore backup //determine file format and restore backup
@@ -265,4 +273,4 @@ else {
//show the footer //show the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>