diff options
author | Phil Davis <phil.davis@inf.org> | 2015-08-06 17:22:24 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2015-08-06 17:22:24 +0545 |
commit | 330d4acae1727401eef2face8041df4195fcc8a9 (patch) | |
tree | ea250c330857d76ad07dba79a85b71dcb37c81e2 /config | |
parent | bad0f316bf513e8a7b61646ceb2e1ddb3bf2b03d (diff) | |
download | pfsense-packages-330d4acae1727401eef2face8041df4195fcc8a9.tar.gz pfsense-packages-330d4acae1727401eef2face8041df4195fcc8a9.tar.bz2 pfsense-packages-330d4acae1727401eef2face8041df4195fcc8a9.zip |
Backup package code style
Diffstat (limited to 'config')
-rw-r--r-- | config/backup/backup.inc | 45 | ||||
-rw-r--r-- | config/backup/backup.php | 110 | ||||
-rw-r--r-- | config/backup/backup.xml | 60 | ||||
-rwxr-xr-x | config/backup/backup_edit.php | 173 |
4 files changed, 187 insertions, 201 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 " <form action='backup.php' method='post' name='iform' id='iform'>\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"<p>"; //print_info_box_np("This is an info box."); //echo"<br />"; -//endif; +//endif; ?> - <table width="100%" border="0" cellpadding="0" cellspacing="0"> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="30%" class="listhdrr">Name</td> <td width="20%" class="listhdrr">Enabled</td> <td width="40%" class="listhdr">Description</td> <td width="10%" class="list"> - - <table border="0" cellspacing="0" cellpadding="1"> - <tr> - <td width="17"></td> - <td valign="middle"><a href="backup_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td> - </tr> - </table> - + <table border="0" cellspacing="0" cellpadding="1"> + <tr> + <td width="17"></td> + <td valign="middle"><a href="backup_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td> + </tr> + </table> </td> </tr> + <?php - <?php - $i = 0; if (count($a_backup) > 0) { foreach ($a_backup as $ent) { ?> - <tr> - <td class="listr" ondblclick="document.location='backup_edit.php?id=<?=$i;?>';"> - <?=$ent['name'];?> - </td> - <td class="listr" ondblclick="document.location='backup_edit.php?id=<?=$i;?>';"> - <?=$ent['enabled'];?> - </td> - <td class="listbg" ondblclick="document.location='backup_edit.php?id=<?=$i;?>';"> - <font color="#FFFFFF"><?=htmlspecialchars($ent['description']);?> - </td> - <td valign="middle" nowrap class="list"> - <table border="0" cellspacing="0" cellpadding="1"> + <tr> + <td class="listr" ondblclick="document.location='backup_edit.php?id=<?=$i;?>';"> + <?=$ent['name'];?> + </td> + <td class="listr" ondblclick="document.location='backup_edit.php?id=<?=$i;?>';"> + <?=$ent['enabled'];?> + </td> + <td class="listbg" ondblclick="document.location='backup_edit.php?id=<?=$i;?>';"> + <font color="#FFFFFF"><?=htmlspecialchars($ent['description']);?> + </td> + <td valign="middle" nowrap class="list"> + <table border="0" cellspacing="0" cellpadding="1"> <tr> - <td valign="middle"><a href="backup_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td> - <td><a href="backup_edit.php?type=backup&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td> + <td valign="middle"><a href="backup_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td> + <td><a href="backup_edit.php?type=backup&act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td> </tr> - </table> - </td> - </tr> - <?php - - $i++; + </table> + </td> + </tr> + <?php + $i++; } } ?> <tr> - <td class="list" colspan="3"></td> - <td class="list"> - <table border="0" cellspacing="0" cellpadding="1"> - <tr> - <td width="17"></td> - <td valign="middle"><a href="backup_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td> - </tr> - </table> - </td> + <td class="list" colspan="3"></td> + <td class="list"> + <table border="0" cellspacing="0" cellpadding="1"> + <tr> + <td width="17"></td> + <td valign="middle"><a href="backup_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td> + </tr> + </table> + </td> </tr> - <tr> - <td class="list" colspan="3"></td> - <td class="list"></td> + <td class="list" colspan="3"></td> + <td class="list"></td> </tr> - </table> +</table> </form> - <br> <br> <br> @@ -310,7 +301,6 @@ if ($config_change == 1) { </div> - <?php include("fend.inc"); ?> </body> </html> 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 @@ <!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> <?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> <packagegui> - <copyright> - <![CDATA[ + <copyright> + <![CDATA[ /* $Id$ */ /* ========================================================================== */ /* - backup.xml - Copyright (C) 2008 Mark J Crane - All rights reserved. - */ + backup.xml + Copyright (C) 2008 Mark J Crane + All rights reserved. +*/ /* ========================================================================== */ /* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ /* ========================================================================== */ - ]]> - </copyright> - <description>Backup</description> - <requirements>Describe your package requirements here</requirements> - <faq>Currently there are no FAQ items provided.</faq> + ]]> + </copyright> + <description>Backup</description> + <requirements>Describe your package requirements here</requirements> + <faq>Currently there are no FAQ items provided.</faq> <name>Backup Settings</name> - <version>0.1.6</version> + <version>0.1.8</version> <title>Settings</title> <include_file>/usr/local/pkg/backup.inc</include_file> <menu> 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 @@ -<?php +<?php /* $Id$ */ /* @@ -66,7 +66,7 @@ if ($_POST) { unset($input_errors); $pconfig = $_POST; - + if (!$input_errors) { $ent = array(); @@ -76,11 +76,10 @@ if ($_POST) { $ent['description'] = $_POST['description']; if (isset($id) && $a_backup[$id]) { - //update - $a_backup[$id] = $ent; - } - else { - //add + //update + $a_backup[$id] = $ent; + } else { + //add $a_backup[] = $ent; } @@ -99,7 +98,7 @@ include("head.inc"); <script type="text/javascript" language="JavaScript"> function show_advanced_config() { - document.getElementById("showadvancedbox").innerHTML=''; + document.getElementById("showadvancedbox").innerHTML = ''; aodiv = document.getElementById('showadvanced'); aodiv.style.display = "block"; </script> @@ -124,87 +123,87 @@ function show_advanced_config() { </table> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> - <td class="tabcont" > - - <!-- - <table width="100%" border="0" cellpadding="6" cellspacing="0"> - <tr> - <td><p><span class="vexpl"><span class="red"><strong>PHP<br> - </strong></span> - </p></td> - </tr> - </table> - --> - <br /> - - <form action="backup_edit.php" method="post" name="iform" id="iform"> - <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <td class="tabcont" > - <tr> - <td width="25%" valign="top" class="vncellreq">Name</td> - <td width="75%" class="vtable"> - <input name="name" type="text" class="formfld" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>"> - </td> - </tr> - - <tr> - <td width="22%" valign="top" class="vncellreq">Path</td> - <td width="78%" class="vtable"> - <input name="path" type="text" class="formfld" id="path" size="40" value="<?=htmlspecialchars($pconfig['path']);?>"> - </td> - </tr> - <tr> - <td width="22%" valign="top" class="vncellreq">Enabled</td> - <td width="78%" class="vtable"> - <?php - echo " <select name='enabled' class='formfld'>\n"; - echo " <option></option>\n"; - switch (htmlspecialchars($pconfig['enabled'])) { - case "true": - echo " <option value='true' selected='yes'>true</option>\n"; - echo " <option value='false'>false</option>\n"; - break; - case "false": - echo " <option value='true'>true</option>\n"; - echo " <option value='false' selected='yes'>false</option>\n"; - - break; - default: - echo " <option value='true' selected='yes'>true</option>\n"; - echo " <option value='false'>false</option>\n"; - } - echo " </select>\n"; - ?> - </td> - </tr> - <tr> - <td width="25%" valign="top" class="vncellreq">Description</td> - <td width="75%" class="vtable"> - <input name="description" type="text" class="formfld" id="description" size="40" value="<?=htmlspecialchars($pconfig['description']);?>"> - <br><span class="vexpl">Enter the description here.<br></span> - </td> - </tr> - - <tr> - <td valign="top"> </td> - <td> - <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()"> - <?php if (isset($id) && $a_backup[$id]): ?> - <input name="id" type="hidden" value="<?=$id;?>"> - <?php endif; ?> - </td> - </tr> + <!-- + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td><p><span class="vexpl"><span class="red"><strong>PHP<br> + </strong></span> + </p></td> + </tr> </table> - </form> - - <br> - <br> - <br> - <br> - <br> - <br> - - </td> + --> + <br /> + + <form action="backup_edit.php" method="post" name="iform" id="iform"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + + <tr> + <td width="25%" valign="top" class="vncellreq">Name</td> + <td width="75%" class="vtable"> + <input name="name" type="text" class="formfld" id="name" size="40" value="<?=htmlspecialchars($pconfig['name']);?>"> + </td> + </tr> + + <tr> + <td width="22%" valign="top" class="vncellreq">Path</td> + <td width="78%" class="vtable"> + <input name="path" type="text" class="formfld" id="path" size="40" value="<?=htmlspecialchars($pconfig['path']);?>"> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq">Enabled</td> + <td width="78%" class="vtable"> + <?php + echo " <select name='enabled' class='formfld'>\n"; + echo " <option></option>\n"; + switch (htmlspecialchars($pconfig['enabled'])) { + case "true": + echo " <option value='true' selected='yes'>true</option>\n"; + echo " <option value='false'>false</option>\n"; + break; + case "false": + echo " <option value='true'>true</option>\n"; + echo " <option value='false' selected='yes'>false</option>\n"; + + break; + default: + echo " <option value='true' selected='yes'>true</option>\n"; + echo " <option value='false'>false</option>\n"; + } + echo " </select>\n"; + ?> + </td> + </tr> + <tr> + <td width="25%" valign="top" class="vncellreq">Description</td> + <td width="75%" class="vtable"> + <input name="description" type="text" class="formfld" id="description" size="40" value="<?=htmlspecialchars($pconfig['description']);?>"> + <br><span class="vexpl">Enter the description here.<br></span> + </td> + </tr> + + <tr> + <td valign="top"> </td> + <td> + <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()"> + <?php if (isset($id) && $a_backup[$id]): ?> + <input name="id" type="hidden" value="<?=$id;?>"> + <?php endif; ?> + </td> + </tr> + </table> + </form> + + <br> + <br> + <br> + <br> + <br> + <br> + + </td> </tr> </table> |