From d3fc579054c0e6de320b703aa39a2c6df5a2c613 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Mon, 8 Dec 2008 02:31:43 +0000 Subject: * Add a hostname dropdown box allowing OP to change hosts * Show a big fat warning if $hostname != $myhostname * All operations are now applicable to all stored hostnames allowing OP to centrally manage all backups from pfS ACB interface --- packages/autoconfigbackup/autoconfigbackup.php | 61 ++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/packages/autoconfigbackup/autoconfigbackup.php b/packages/autoconfigbackup/autoconfigbackup.php index 59d1b20e..5fb28114 100644 --- a/packages/autoconfigbackup/autoconfigbackup.php +++ b/packages/autoconfigbackup/autoconfigbackup.php @@ -48,11 +48,20 @@ $password = $config['installedpackages']['autoconfigbackup']['config'][0]['pas // URL to restore.php $get_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/restore.php"; +// URL to stats +$stats_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/showstats.php"; + // URL to delete.php $del_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/delete.php"; // Set hostname -$hostname = $config['system']['hostname'] . "." . $config['system']['domain']; +if($_REQUEST['hostname']) + $hostname = $_REQUEST['hostname']; +else + $hostname = $config['system']['hostname'] . "." . $config['system']['domain']; + +// Hostname of local machine +$myhostname = $config['system']['hostname'] . "." . $config['system']['domain']; if(!$username) { Header("Location: /pkg_edit.php?xml=autoconfigbackup.xml&id=0"); @@ -69,6 +78,36 @@ else include("head.inc"); +function get_hostnames() { + global $stats_url, $username, $oper_sep; + // Populate available backups + $curl_session = curl_init(); + curl_setopt($curl_session, CURLOPT_URL, $stats_url); + curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($curl_session, CURLOPT_POST, 1); + curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=showstats"); + $data = curl_exec($curl_session); + if (curl_errno($curl_session)) { + $fd = fopen("/tmp/acb_statsdebug.txt", "w"); + fwrite($fd, $stats_url . "" . "action=showstats" . "\n\n"); + fwrite($fd, $data); + fwrite($fd, curl_error($curl_session)); + fclose($fd); + } else { + curl_close($curl_session); + } + // Loop through and create new confvers + $data_split = split("\n", $data); + $statvers = array(); + foreach($data_split as $ds) { + $ds_split = split($oper_sep, $ds); + if($ds_split[0]) + $statvers[] = $ds_split[0];; + } + return $statvers; +} + ?>
@@ -84,6 +123,8 @@ include("head.inc"); } if ($input_errors) print_input_errors($input_errors); + if($hostname <> $myhostname) + print_info_box("Warning! You are currently viewing an alternate hosts backup history ($hostname)"); ?> @@ -269,6 +311,19 @@ EOF; ?> + + + + @@ -284,13 +339,13 @@ EOF; -- cgit v1.2.3
@@ -100,6 +141,7 @@ include("head.inc"); $tab_array[] = array("Backup now", false, "/autoconfigbackup_backup.php"); $tab_array[] = array("Stats", false, "/autoconfigbackup_stats.php"); display_top_tabs($tab_array); + $hostnames = get_hostnames(); ?>
+
+ Hostname: + +
Date Configuration Change - + - +