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";
-?>
+