From 975ceaa0bc10e81232128f94d514946f42bee36a Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Sat, 27 Dec 2008 02:15:03 +0000 Subject: TFTP package add file size, adjust wording, fix backup. --- packages/tftp/tftp.inc | 13 ++++++++ packages/tftp/tftp.xml | 2 +- packages/tftp/tftp_files.tmp | 77 +++++++++++++++++++++++--------------------- pkg_config.7.xml | 2 +- 4 files changed, 56 insertions(+), 38 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 @@ Describe your package requirements here Currently there are no FAQ items provided. tftp Settings - 0.7.5 + 0.8 TFTP: Settings /usr/local/pkg/tftp.inc 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) { 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.


-\n"; -echo "\n"; -echo "\n"; -echo "Backup / Restore
\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 "

\n"; -echo "\n"; -echo "\n"; -echo " \n"; -if (file_exists('/tmp/tftp.bak.tgz')) { - echo " \n"; -} -echo "\n"; -echo "\n"; -echo "\n"; -echo "

\n\n"; -?> +
- - - \n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Click on the file to download it.
File to upload: @@ -178,13 +155,35 @@ echo "

\n\n";

+ + \n"; + echo "
\n"; + echo "Backup / Restore
\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 "

\n"; + echo "
\n"; + echo " \n"; + if (file_exists('/tmp/tftp.bak.tgz')) { + echo " \n"; + } + echo "
\n"; + echo "

\n\n"; + ?> - - + + +
\n\n"; while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { + $tftp_filesize = filesize('/tftpboot/'.$file); + $tftp_filesize = byte_convert($tftp_filesize); + echo "\n"; echo " \n"; echo " \n"; + echo " \n"; + echo " \n"; echo "
File NameLast ModifiedFile NameLast ModifiedSize
\n"; echo " \n"; @@ -200,7 +202,10 @@ echo "

\n\n"; echo "
\n"; echo date ("F d Y H:i:s", filemtime('/tftpboot/'.$file)); - echo " \n"; + echo " ".$tftp_filesize; + echo " \n"; echo " \n"; echo " \n"; diff --git a/pkg_config.7.xml b/pkg_config.7.xml index 1762a02e..c4f70f73 100644 --- a/pkg_config.7.xml +++ b/pkg_config.7.xml @@ -80,7 +80,7 @@ http://www.pfsense.com/packages/config/tftp/tftp.xmlhttp://files.pfsense.org/packages/7/All/ - 0.7.5 + 0.8Beta1.2.1markjcrane@gmail.com -- cgit v1.2.3