From 76bb105d0a6c2fd757c9673eb4265614409c45da Mon Sep 17 00:00:00 2001 From: nagyrobi Date: Mon, 23 Sep 2013 14:21:32 +0200 Subject: Update asterisk_edit_file.php Added factory settings restore, dist directory delete options protected with checkboxes. --- config/asterisk/asterisk_edit_file.php | 90 +++++++++++++++++++++++++++++++--- 1 file changed, 83 insertions(+), 7 deletions(-) diff --git a/config/asterisk/asterisk_edit_file.php b/config/asterisk/asterisk_edit_file.php index 495703a2..648078f1 100644 --- a/config/asterisk/asterisk_edit_file.php +++ b/config/asterisk/asterisk_edit_file.php @@ -50,7 +50,8 @@ $downname = "asterisk-config-{$host}-".date("YmdHis").".bak.tgz"; //put the dat if (($_GET['a'] == "download") && $_GET['t'] == "backup") { conf_mount_rw(); - system("cd {$files_dir} && tar czf {$backup_path} *"); +// system("cd {$files_dir} && tar czf {$backup_path} *"); + system("cd {$files_dir} && tar czf {$backup_path} --exclude 'dist/*' --exclude dist *"); conf_mount_ro(); } @@ -75,10 +76,8 @@ if ($_GET['a'] == "other") { if (file_exists($backup_path)) { //echo "The file $filename exists"; conf_mount_rw(); - //$sysretval = system("tar -xzC {$files_dir} -f {$backup_path} 2>&1"); exec("tar -xzC {$files_dir} -f {$backup_path} 2>&1", $sysretval); - $savemsg = "Backup has been restored " . $sysretval[1]; - //$savemsg = "Backup has been restored " . $sysretval; + $savemsg = "Backup has been restored, please restart Asterisk now " . $sysretval[1]; system("chmod -R 644 {$files_dir}/*"); header( 'Location: asterisk_edit_file.php?savemsg=' . $savemsg ) ; conf_mount_ro(); @@ -87,6 +86,30 @@ if ($_GET['a'] == "other") { } exit; } + if ($_GET['t'] == "factrest") { + //extract files to $files_dir (/conf/asterisk) + if (file_exists('/conf.default/asterisk_factory_defaults_config.tgz')) { + //echo "The file $filename exists"; + conf_mount_rw(); + exec("tar -xzC {$files_dir} -f /conf.default/asterisk_factory_defaults_config.tgz 2>&1", $sysretval); + $savemsg = "Factory configuration restored, please restart Asterisk now " . $sysretval[1]; + system("chmod -R 644 {$files_dir}/*"); + header( 'Location: asterisk_edit_file.php?savemsg=' . $savemsg ) ; + conf_mount_ro(); + } + exit; + } + if ($_GET['t'] == "deldist") { + //delete dist directory from $files_dir/dist (/conf/asterisk/dist) + if (file_exists($files_dir . "/dist")) { + conf_mount_rw(); + exec("rm -r {$files_dir}/dist 2>&1", $sysretval); + $savemsg = "Deleted dist files " . $sysretval[1]; + header( 'Location: asterisk_edit_file.php?savemsg=' . $savemsg ) ; + conf_mount_ro(); + } + exit; + } } if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_name'])) { @@ -222,6 +245,26 @@ if ($savemsg) { } ); } + + + + function ckrest() { + if(document.getElementById('ckrest').checked==true) { + document.getElementById('restfactdef').disabled=false; + } else { + document.getElementById('restfactdef').disabled=true; + } + } + + function ckdist() { + if(document.getElementById('ckdist').checked==true) { + document.getElementById('deldistdire').disabled=false; + } else { + document.getElementById('deldistdire').disabled=true; + } + } + + @@ -244,11 +287,11 @@ if ($savemsg) {
- +
- @@ -367,6 +431,18 @@ if ($savemsg) {
+
+ + + -- cgit v1.2.3

- Backup / Restore
+
+ Backup / Restore The 'Backup' button will tar gzip asterisk configuration files to it then offers it to download.
The 'Restore' button will be visible only if the backup file exists.
You can upload a backup file to the system, if one already exists at , it will be overwritten. @@ -354,6 +397,27 @@ if ($savemsg) { + +
+
+ + + + +

+ enable   \n"; + } + if (file_exists("/conf.default/asterisk_factory_defaults_config.tgz")) { + echo "enable \n"; + } + ?> +

+
+
+ +