diff options
author | Mark Crane <mcrane@pfsense.org> | 2008-12-27 02:15:03 +0000 |
---|---|---|
committer | Mark Crane <mcrane@pfsense.org> | 2008-12-27 02:15:03 +0000 |
commit | 975ceaa0bc10e81232128f94d514946f42bee36a (patch) | |
tree | 55bfa71fd16c211ed5d033d374f598394ce0bb6c /packages/tftp | |
parent | 9ba11c79e570b185bb598ed4d46823fb7ac5cfa5 (diff) | |
download | pfsense-packages-975ceaa0bc10e81232128f94d514946f42bee36a.tar.gz pfsense-packages-975ceaa0bc10e81232128f94d514946f42bee36a.tar.bz2 pfsense-packages-975ceaa0bc10e81232128f94d514946f42bee36a.zip |
TFTP package add file size, adjust wording, fix backup.
Diffstat (limited to 'packages/tftp')
-rw-r--r-- | packages/tftp/tftp.inc | 13 | ||||
-rw-r--r-- | packages/tftp/tftp.xml | 2 | ||||
-rw-r--r-- | packages/tftp/tftp_files.tmp | 77 |
3 files changed, 55 insertions, 37 deletions
diff --git a/packages/tftp/tftp.inc b/packages/tftp/tftp.inc index 61a41a58..459ad8f5 100644 --- a/packages/tftp/tftp.inc +++ b/packages/tftp/tftp.inc @@ -68,6 +68,18 @@ function pkg_is_service_running($servicename) } } +function byte_convert( $bytes ) { + + 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]; +} + + function php_sync_package() { @@ -104,6 +116,7 @@ function php_install_command() exec("tar zxvf /tmp/tftp.tgz -C /"); unlink_if_exists("/tmp/tftp.tgz"); + system('cd /;tar cvzf /tmp/tftp.bak.tgz tftpboot'); //rename PHP files from .tmp to .php diff --git a/packages/tftp/tftp.xml b/packages/tftp/tftp.xml index 51989fad..77b00689 100644 --- a/packages/tftp/tftp.xml +++ b/packages/tftp/tftp.xml @@ -41,7 +41,7 @@ <requirements>Describe your package requirements here</requirements> <faq>Currently there are no FAQ items provided.</faq> <name>tftp Settings</name> - <version>0.7.5</version> + <version>0.8</version> <title>TFTP: Settings</title> <include_file>/usr/local/pkg/tftp.inc</include_file> <menu> diff --git a/packages/tftp/tftp_files.tmp b/packages/tftp/tftp_files.tmp index 750a1c72..fa7a521e 100644 --- a/packages/tftp/tftp_files.tmp +++ b/packages/tftp/tftp_files.tmp @@ -31,14 +31,13 @@ require("guiconfig.inc"); require("/usr/local/pkg/tftp.inc"); -if (($_GET['a'] == "download") && file_exists("/tftpboot/".$_GET['filename'])) { - - $filename = $_GET['filename']; - if ($_GET['t'] == "backup") { - $tmp = '/tmp/'; - $filename = 'tftp.bak.tgz'; - system('cd /;tar cvzf /tmp/tftp.bak.tgz tftpboot'); - } +$filename = $_GET['filename']; +if (($_GET['a'] == "download") && $_GET['t'] == "backup") { + $tmp = '/tmp/'; + $filename = 'tftp.bak.tgz'; + system('cd /;tar cvzf /tmp/tftp.bak.tgz tftpboot'); +} +if (($_GET['a'] == "download") && file_exists("/tftpboot/".$filename)) { session_cache_limiter('public'); $fd = fopen("/tftpboot/".$filename, "rb"); @@ -77,7 +76,7 @@ if ($_GET['a'] == "other") { if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_name'])) { move_uploaded_file($_FILES['ulfile']['tmp_name'], "/tftpboot/" . $_FILES['ulfile']['name']); - $ulmsg = "Uploaded file to /tftpboot/" . htmlentities($_FILES['ulfile']['name']); + $savemsg = "Uploaded file to /tftpboot/" . htmlentities($_FILES['ulfile']['name']); unset($_POST['txtCommand']); } @@ -127,39 +126,17 @@ if ($savemsg) { </strong></span> Trivial File Transport Protocol is a very simple file transfer protocol. Use the file upload to add files to the /tftpboot directory. - + Click on the file from the file list below to download it. </span></p></td> </tr> </table> <br /> -<?php -echo "<table width='690' cellpadding='0' cellspacing='0' border='0'>\n"; -echo "<tr>\n"; -echo "<td width='80%'>\n"; -echo "<b>Backup / Restore</b><br />\n"; -echo "The 'backup' button will tar gzip /tftpboot/ to /tmp/tftp.bak.tgz it then presents a file to download. \n"; -echo "If the backup file does not exist in /tmp/tftp.bak.tgz then the 'restore' button will be hidden. \n"; -echo "Use Diagnostics->Command->File to upload: to browse to the file and then click on upload it now ready to be restored. \n"; -echo "<br /><br />\n"; -echo "</td>\n"; -echo "<td width='20%' valign='middle' align='right'>\n"; -echo " <input type='button' value='backup' onclick=\"document.location.href='/tftp/tftp_files.php?a=download&t=backup';\" />\n"; -if (file_exists('/tmp/tftp.bak.tgz')) { - echo " <input type='button' value='restore' onclick=\"document.location.href='/tftp/tftp_files.php?a=other&t=restore';\" />\n"; -} -echo "</td>\n"; -echo "</tr>\n"; -echo "</table>\n"; -echo "<br /><br />\n\n"; -?> + <div id="niftyOutter"> <form action="tftp_files.php" method="POST" enctype="multipart/form-data" name="frmUpload" onSubmit=""> <table> - <tr> - <td colspan="2" valign="top" class="">Click on the file to download it.</td> - </tr> <tr> <td align="right">File to upload:</td> <td valign="top" class="label"> @@ -178,13 +155,35 @@ echo "<br /><br />\n\n"; <br /> <br /> + + <?php + echo "<table width='690' cellpadding='0' cellspacing='0' border='0'>\n"; + echo "<tr>\n"; + echo "<td width='80%'>\n"; + echo "<b>Backup / Restore</b><br />\n"; + echo "The 'backup' button will tar gzip /tftpboot/ to /tmp/tftp.bak.tgz it then presents a file to download. \n"; + echo "If the backup file does not exist in /tmp/tftp.bak.tgz then the 'restore' button will be hidden. \n"; + echo "Use Diagnostics->Command->File to upload: to browse to the file and then click on upload it now ready to be restored. \n"; + echo "<br /><br />\n"; + echo "</td>\n"; + echo "<td width='20%' valign='middle' align='right'>\n"; + echo " <input type='button' value='backup' onclick=\"document.location.href='/tftp/tftp_files.php?a=download&t=backup';\" />\n"; + if (file_exists('/tmp/tftp.bak.tgz')) { + echo " <input type='button' value='restore' onclick=\"document.location.href='/tftp/tftp_files.php?a=other&t=restore';\" />\n"; + } + echo "</td>\n"; + echo "</tr>\n"; + echo "</table>\n"; + echo "<br /><br />\n\n"; + ?> <form action="tftp_files.php" method="post" name="iform" id="iform"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> - <td width="25%" class="listhdrr">File Name</td> - <td width="50%" class="listhdr">Last Modified</td> + <td width="25%" class="listhdrr">File Name</td> + <td width="50%" class="listhdr">Last Modified</td> + <td width="50%" class="listhdr">Size</td> </tr> <?php @@ -192,6 +191,9 @@ echo "<br /><br />\n\n"; while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { + $tftp_filesize = filesize('/tftpboot/'.$file); + $tftp_filesize = byte_convert($tftp_filesize); + echo "<tr>\n"; echo " <td class=\"listlr\" ondblclick=\"\">\n"; echo " <a href=\"tftp_files.php?a=download&filename=".$file."\">\n"; @@ -200,7 +202,10 @@ echo "<br /><br />\n\n"; echo " </td>\n"; echo " <td class=\"listlr\" ondblclick=\"\">\n"; echo date ("F d Y H:i:s", filemtime('/tftpboot/'.$file)); - echo " </td>\n"; + echo " </td>\n"; + echo " <td class=\"listlr\" ondblclick=\"\">\n"; + echo " ".$tftp_filesize; + echo " </td>\n"; echo " <td valign=\"middle\" nowrap class=\"list\">\n"; echo " <table border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\n"; echo " <tr>\n"; |