summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorDarren Embry <dse@webonastick.com>2012-05-17 14:03:00 -0400
committerDarren Embry <dse@webonastick.com>2012-05-17 14:03:00 -0400
commit754b75d076b0ea6cdfe54759d28f19c1cc59fa9b (patch)
treeba7c6af39d47824706d6a3eecf4fa8b39085531a /usr
parentb61e89600ea0053d8ab4a9d0e18809cc29828b92 (diff)
downloadpfsense-754b75d076b0ea6cdfe54759d28f19c1cc59fa9b.zip
pfsense-754b75d076b0ea6cdfe54759d28f19c1cc59fa9b.tar.gz
move certain code to new function restore_rrddata()
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/diag_backup.php51
1 files changed, 28 insertions, 23 deletions
diff --git a/usr/local/www/diag_backup.php b/usr/local/www/diag_backup.php
index 896763b..e600515 100755
--- a/usr/local/www/diag_backup.php
+++ b/usr/local/www/diag_backup.php
@@ -82,6 +82,33 @@ function rrd_data_xml() {
return $result;
}
+function restore_rrddata() {
+ global $config, $g, $rrdtool;
+ foreach($config['rrddata']['rrddatafile'] as $rrd) {
+ if ($rrd['xmldata']) {
+ $rrd_file = "{$g['vardb_path']}/rrd/{$rrd['filename']}";
+ $xml_file = preg_replace('/\.rrd$/', ".xml", $rrd_file);
+ file_put_contents($xml_file, gzinflate(base64_decode($rrd['xmldata'])));
+ exec("$rrdtool restore '{$xml_file}' '{$rrd_file}'");
+ unlink($xml_file);
+ }
+ else if ($rrd['data']) {
+ $rrd_fd = fopen("{$g['vardb_path']}/rrd/{$rrd['filename']}", "w");
+ $data = base64_decode($rrd['data']);
+ /* Try to decompress the data. */
+ $dcomp = @gzinflate($data);
+ if ($dcomp) {
+ /* If the decompression worked, write the decompressed data */
+ fwrite($rrd_fd, $dcomp);
+ } else {
+ /* If the decompression failed, it wasn't compressed, so write raw data */
+ fwrite($rrd_fd, $data);
+ }
+ fclose($rrd_fd);
+ }
+ }
+}
+
function add_base_packages_menu_items() {
global $g, $config;
$base_packages = explode($g['base_packages'], ",");
@@ -334,29 +361,7 @@ if ($_POST) {
$config = parse_config(true);
/* extract out rrd items, unset from $config when done */
if($config['rrddata']) {
- foreach($config['rrddata']['rrddatafile'] as $rrd) {
- if ($rrd['xmldata']) {
- $rrd_file = "{$g['vardb_path']}/rrd/{$rrd['filename']}";
- $xml_file = preg_replace('/\.rrd$/', ".xml", $rrd_file);
- file_put_contents($xml_file, gzinflate(base64_decode($rrd['xmldata'])));
- exec("$rrdtool restore '{$xml_file}' '{$rrd_file}'");
- unlink($xml_file);
- }
- else if ($rrd['data']) {
- $rrd_fd = fopen("{$g['vardb_path']}/rrd/{$rrd['filename']}", "w");
- $data = base64_decode($rrd['data']);
- /* Try to decompress the data. */
- $dcomp = @gzinflate($data);
- if ($dcomp) {
- /* If the decompression worked, write the decompressed data */
- fwrite($rrd_fd, $dcomp);
- } else {
- /* If the decompression failed, it wasn't compressed, so write raw data */
- fwrite($rrd_fd, $data);
- }
- fclose($rrd_fd);
- }
- }
+ restore_rrddata();
unset($config['rrddata']);
unlink_if_exists("{$g['tmp_path']}/config.cache");
write_config();
OpenPOWER on IntegriCloud