From 55eddd7accf2c5f9b0f52b22a010c4c4b7c130d1 Mon Sep 17 00:00:00 2001 From: Bill Marquette Date: Fri, 6 Feb 2009 19:18:00 -0600 Subject: mv packages to config dir to match web layout --- config/autoconfigbackup/autoconfigbackup.php | 387 +++++++++++++++++++++++++++ 1 file changed, 387 insertions(+) create mode 100644 config/autoconfigbackup/autoconfigbackup.php (limited to 'config/autoconfigbackup/autoconfigbackup.php') diff --git a/config/autoconfigbackup/autoconfigbackup.php b/config/autoconfigbackup/autoconfigbackup.php new file mode 100644 index 00000000..80db5543 --- /dev/null +++ b/config/autoconfigbackup/autoconfigbackup.php @@ -0,0 +1,387 @@ + + +
+ +{$pgtitle}

"; + if($savemsg) { + echo "
"; + print_info_box($savemsg); + echo "
"; + } + 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)"); +?> + + +
+
+ +
+ + +
+
+ Loading, please wait... +
+ $sha256) + $input_errors[] = "SHA256 values does not match, cannot restore."; + if (curl_errno($curl_session)) { + /* If an error occured, log the error in /tmp/ */ + $fd = fopen("/tmp/acb_restoredebug.txt", "w"); + fwrite($fd, $get_url . "" . "action=restore&hostname={$hostname}&revision=" . urlencode($_REQUEST['newver']) . "\n\n"); + fwrite($fd, $data); + fwrite($fd, curl_error($curl_session)); + fclose($fd); + } else { + curl_close($curl_session); + } + if(!$input_errors && $data) { + if(config_restore("/tmp/config_restore.xml") == 0) { + $savemsg = "Successfully reverted the pfSense configuration to revision " . urldecode($_REQUEST['newver']) . "."; + $savemsg .= << +
+ Would you like to reboot? + + +
+EOF; + } else { + $savemsg = "Unable to revert to the selected configuration."; + } + print_info_box($savemsg); + } + unlink("/tmp/config_restore.xml"); + } + if($_REQUEST['download']) { + // Phone home and obtain backups + $curl_session = curl_init(); + curl_setopt($curl_session, CURLOPT_URL, $get_url); + curl_setopt($curl_session, CURLOPT_POST, 3); + curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=restore" . + "&hostname=" . urlencode($hostname) . + "&revision=" . urlencode($_REQUEST['download'])); + $data = curl_exec($curl_session); + if (!tagfile_deformat($data, $data1, "config.xml")) + $input_errors[] = "The downloaded file does not appear to contain an encrypted pfSense configuration."; + if ($input_errors) { + print_input_errors($input_errors); + } else { + $ds = split("\+\+\+\+", $data); + $revision = $_REQUEST['download']; + $sha256sum = $ds[0]; + if($sha256sum == "0") + $sha256sum = "None on file."; + $data = $ds[1]; + $configtype = "Encrypted"; + if (!tagfile_deformat($data, $data, "config.xml")) + $input_errors[] = "The downloaded file does not appear to contain an encrypted pfSense configuration."; + $data = decrypt_data($data, $decrypt_password); + if(!strstr($data, "pfsense")) { + $data = "Could not decrypt. Different encryption key?"; + $input_errors[] = "Could not decrypt config.xml"; + } + echo "

Hostname

"; + echo ""; + echo "

Revision date/time

"; + echo ""; + echo "

Revision reason

"; + echo ""; + echo "

SHA256 summary

"; + echo ""; + echo "

Encrypted config.xml

"; + echo ""; + echo "

Decrypted config.xml

"; + echo ""; + } + if(!$input_errors) + echo "

"; + echo ""; + echo "

"; + require("fend.inc"); + exit; + } + // Populate available backups + $curl_session = curl_init(); + curl_setopt($curl_session, CURLOPT_URL, $get_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=showbackups&hostname={$hostname}"); + $data = curl_exec($curl_session); + if (curl_errno($curl_session)) { + $fd = fopen("/tmp/acb_backupdebug.txt", "w"); + fwrite($fd, $get_url . "" . "action=showbackups" . "\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); + $confvers = array(); + foreach($data_split as $ds) { + $ds_split = split($oper_sep, $ds); + $tmp_array = array(); + $tmp_array['username'] = $ds_split[0]; + $tmp_array['reason'] = $ds_split[1]; + $tmp_array['time'] = $ds_split[2]; + if($ds_split[2] && $ds_split[0]) + $confvers[] = $tmp_array; + } + ?> + + + + +
+ Hostname: + + + + + + Date + Configuration Change + +"; + echo "$('loading').innerHTML = '';"; + echo ""; + foreach($confvers as $cv): +?> + + + + + + + + + + + + + + + +
Sorry, we could not locate any backups at portal.pfsense.org for this hostname ({$hostname})."; + else + echo "

Backups hosted currently for this hostname on portalpfsense.org: {$counter}."; +?> + +
+ + + +

+ +    + + Hint:  + + + Click the + sign next to the revision you would like to restore. +

+ + + + + + + + \ No newline at end of file -- cgit v1.2.3