Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (if_group("backup_download")) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support // require_once "app_languages.php"; foreach($text as $key => $value) { $text[$key] = $value[$_SESSION['domain']['language']['code']]; } //download the backup if ($_GET['a'] == "download" && permission_exists('backup_download')) { //build the backup file $backup_path = '/tmp'; $backup_name = 'backup.tgz'; //system('cd /tmp;tar cvzf /tmp/backup.tgz backup); $i = 0; if (count($_SESSION['backup']['path']) > 0) { $cmd = 'tar --create --verbose --gzip --file '.$backup_path.'/'.$backup_name.' --directory '; foreach ($_SESSION['backup']['path'] as $value) { $cmd .= $value.' '; $i++; } //echo $cmd; system($cmd); } //download the file session_cache_limiter('public'); if (file_exists($_SESSION['switch']['recordings']['dir'].'/'.base64_decode($_GET['filename']))) { $fd = fopen($_SESSION['switch']['recordings']['dir'].'/'.base64_decode($_GET['filename']), "rb"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); //header("Content-Transfer-Encoding: binary"); header("Content-Type: application/download"); header("Content-Description: File Transfer"); header('Content-Disposition: attachment; filename=backup.tgz'); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Content-Length: " . filesize($_SESSION['switch']['recordings']['dir'].'/'.base64_decode($_GET['filename']))); header("Pragma: no-cache"); header("Expires: 0"); ob_clean(); fpassthru($fd); } } exit; } //upload the backup if (permission_exists('backup_upload')) { if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('recording_upload')) { //upload the file move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['switch']['recordings']['dir'].'/'.$_FILES['ulfile']['name']); $savemsg = $text['message-uploaded']." ".$_SESSION['switch']['recordings']['dir']."/". htmlentities($_FILES['ulfile']['name']); //system('chmod -R 744 '.$_SESSION['switch']['recordings']['dir'].'*'); unset($_POST['txtCommand']); //restore the backup system('tar -xvpzf /tmp/backup.tgz -C /tmp'); } } //add the header require_once "resources/header.php"; //show the content echo "\n"; echo "\n"; echo " \n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "
Backup
\n"; echo " download \n"; echo " \n"; echo "
\n"; echo "To backup your application click on the download link and then choose \n"; echo "a safe location on your computer to save the file. You may want to \n"; echo "save the backup to more than one computer to prevent the backup from being lost. \n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "Restore Application
\n"; echo "
\n"; //Browse to Backup File echo "Click on 'Browse' then locate and select the application backup file named '.bak'. \n"; echo "Then click on 'Restore.' \n"; echo "

"; echo "
"; echo "
"; echo " "; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " "; echo " "; echo " "; echo "
"; echo " \n"; echo " \n"; echo "
"; echo "
\n"; echo "
\n"; echo "
"; echo "
"; //show the footer require_once "resources/footer.php"; ?>