From 330d4acae1727401eef2face8041df4195fcc8a9 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 6 Aug 2015 17:22:24 +0545 Subject: Backup package code style --- config/backup/backup.inc | 45 +++++------ config/backup/backup.php | 110 ++++++++++++--------------- config/backup/backup.xml | 60 +++++++-------- config/backup/backup_edit.php | 173 +++++++++++++++++++++--------------------- pkg_config.10.xml | 2 +- 5 files changed, 188 insertions(+), 202 deletions(-) diff --git a/config/backup/backup.inc b/config/backup/backup.inc index 748b7fc6..e395756a 100644 --- a/config/backup/backup.inc +++ b/config/backup/backup.inc @@ -3,10 +3,10 @@ /* /* ========================================================================== */ /* - backup.inc - Copyright (C) 2008 Mark J Crane - All rights reserved. - */ + backup.inc + Copyright (C) 2008 Mark J Crane + All rights reserved. +*/ /* ========================================================================== */ /* Redistribution and use in source and binary forms, with or without @@ -34,28 +34,28 @@ if (!function_exists("byte_convert")) { function byte_convert( $bytes ) { - if ($bytes<=0) + if ($bytes <= 0) { return '0 Byte'; + } - $convention=1000; //[1000->10^x|1024->2^x] - $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); - $e=floor(log($bytes,$convention)); - return round($bytes/pow($convention,$e),2).' '.$s[$e]; + $convention = 1000; //[1000->10^x|1024->2^x] + $s = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); + $e = floor(log($bytes, $convention)); + return round($bytes/pow($convention, $e), 2) . ' ' . $s[$e]; } } - -function backup_sync_package_php() -{ - global $config; - if($config['installedpackages']['backup']['config'] != "") { +function backup_sync_package_php() { + + global $config; + if ($config['installedpackages']['backup']['config'] != "") { conf_mount_rw(); - foreach($config['installedpackages']['backup']['config'] as $rowhelper) { + foreach ($config['installedpackages']['backup']['config'] as $rowhelper) { if ($rowhelper['enabled'] != "false") { //$tmp_php = base64_decode($rowhelper['php']); if (strlen($tmp_php) > 0) { - $tmp .= "// name: ".$rowhelper['name']." \n"; - $tmp .= "// description: ".$rowhelper['description']." \n\n"; + $tmp .= "// name: " . $rowhelper['name'] . " \n"; + $tmp .= "// description: " . $rowhelper['description'] . " \n\n"; $tmp .= base64_decode($rowhelper['php']); $tmp .= "\n"; } @@ -65,16 +65,13 @@ function backup_sync_package_php() } } - -function backup_sync_package() -{ - global $config; +function backup_sync_package() { + global $config; backup_sync_package_php(); } -function backup_install_command() -{ +function backup_install_command() { global $config; conf_mount_rw(); @@ -87,7 +84,7 @@ function backup_install_command() backup_sync_package(); conf_mount_ro(); - + } ?> diff --git a/config/backup/backup.php b/config/backup/backup.php index 3cada9b3..d4debcd3 100644 --- a/config/backup/backup.php +++ b/config/backup/backup.php @@ -32,7 +32,6 @@ require("/usr/local/pkg/backup.inc"); $a_backup = &$config['installedpackages']['backup']['config']; - if ($_GET['act'] == "del") { if ($_GET['type'] == 'backup') { if ($a_backup[$_GET['id']]) { @@ -58,13 +57,13 @@ if ($_GET['a'] == "download") { if (count($a_backup) > 0) { $backup_cmd = 'tar --create --verbose --gzip --file '.$tmp.$filename.' --directory / '; foreach ($a_backup as $ent) { - if ($ent['enabled'] =="true"){ + if ($ent['enabled'] == "true") { //htmlspecialchars($ent['name']); //htmlspecialchars($ent['path']); //htmlspecialchars($ent['description']); $backup_cmd .= htmlspecialchars($ent['path']).' '; } - $i++; + $i++; } //echo $backup_cmd; //exit; system($backup_cmd); @@ -74,7 +73,7 @@ if ($_GET['a'] == "download") { $fd = fopen($tmp.$filename, "rb"); header("Content-Type: binary/octet-stream"); header("Content-Length: " . filesize($tmp.$filename)); - header('Content-Disposition: attachment; filename="'.$filename.'"'); + header('Content-Disposition: attachment; filename="' . $filename . '"'); fpassthru($fd); conf_mount_ro(); @@ -90,13 +89,12 @@ if ($_GET['a'] == "other") { //extract the tgz file if (file_exists('/root/backup/'.$filename)) { - //echo "The file $filename exists"; - system('cd /; tar xvpfz /root/backup/'.$filename.' '); - header( 'Location: backup.php?savemsg=Backup+has+been+restored.' ) ; - } - else { + //echo "The file $filename exists"; + system('cd /; tar xvpfz /root/backup/'.$filename.' '); + header( 'Location: backup.php?savemsg=Backup+has+been+restored.' ) ; + } else { header( 'Location: backup.php?savemsg=Restore+failed.+Backup+file+not+found.' ) ; - } + } conf_mount_ro(); exit; } @@ -111,7 +109,6 @@ if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_na conf_mount_ro(); } - include("head.inc"); ?> @@ -210,91 +207,85 @@ echo "
\n"; if ($config_change == 1) { write_config(); - $config_change = 0; + $config_change = 0; } -//if ($savemsg) print_info_box($savemsg); +//if ($savemsg) print_info_box($savemsg); //if (file_exists($d_hostsdirty_path)): echo"

"; //print_info_box_np("This is an info box."); //echo"
"; -//endif; +//endif; ?> - +
+ 0) { foreach ($a_backup as $ent) { ?> - - - - -
Name Enabled Description - - - - - - -
- + + + + + +
-   - -   - -   - - + + + + + - - + + + - - + + - - - + + -
+   + +   + +   + + - - + + -
-
- - - - - -
-
+ + + + + +
+
+

-


@@ -310,7 +301,6 @@ if ($config_change == 1) { - diff --git a/config/backup/backup.xml b/config/backup/backup.xml index ae1adf52..f9cf36b9 100644 --- a/config/backup/backup.xml +++ b/config/backup/backup.xml @@ -2,46 +2,46 @@ - - + - - Backup - Describe your package requirements here - Currently there are no FAQ items provided. + ]]> + + Backup + Describe your package requirements here + Currently there are no FAQ items provided. Backup Settings - 0.1.6 + 0.1.8 Settings /usr/local/pkg/backup.inc diff --git a/config/backup/backup_edit.php b/config/backup/backup_edit.php index c7dbc38a..fbaa9096 100755 --- a/config/backup/backup_edit.php +++ b/config/backup/backup_edit.php @@ -1,4 +1,4 @@ - function show_advanced_config() { - document.getElementById("showadvancedbox").innerHTML=''; + document.getElementById("showadvancedbox").innerHTML = ''; aodiv = document.getElementById('showadvanced'); aodiv.style.display = "block"; @@ -124,87 +123,87 @@ function show_advanced_config() { -
- - -
- -
- + - - - - - - - - - - - - - - - - - - - - - + +
+ + +
-
Name - -
Path - -
Enabled - \n"; - echo " \n"; - switch (htmlspecialchars($pconfig['enabled'])) { - case "true": - echo " \n"; - echo " \n"; - break; - case "false": - echo " \n"; - echo " \n"; - - break; - default: - echo " \n"; - echo " \n"; - } - echo " \n"; - ?> -
Description - -
Enter the description here.
-
  - - - - -
+ + + + + + + + + + + + + + + + + + + + + + + +
Name + +
Path + +
Enabled + \n"; + echo " \n"; + switch (htmlspecialchars($pconfig['enabled'])) { + case "true": + echo " \n"; + echo " \n"; + break; + case "false": + echo " \n"; + echo " \n"; + + break; + default: + echo " \n"; + echo " \n"; + } + echo " \n"; + ?> +
Description + +
Enter the description here.
+
  + + + + +
+
+ +
+
+
+
+
+
+ +
diff --git a/pkg_config.10.xml b/pkg_config.10.xml index 60f28e41..41cf26a9 100644 --- a/pkg_config.10.xml +++ b/pkg_config.10.xml @@ -356,7 +356,7 @@ System https://packages.pfsense.org/packages/config/backup/backup.xml - 0.1.7 + 0.1.8 Beta 2.2 markjcrane@gmail.com -- cgit v1.2.3