From 7e6fad76175d9e872063dff755c0f74fec866821 Mon Sep 17 00:00:00 2001 From: mcrane Date: Fri, 27 Mar 2009 19:08:43 -0600 Subject: TFTP package make the backup deliver the backup file as a download, fix restore and add restore message --- config/tftp/tftp.inc | 3 ++- config/tftp/tftp_files.tmp | 29 +++++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'config/tftp') diff --git a/config/tftp/tftp.inc b/config/tftp/tftp.inc index 8649bc22..61d81b4a 100644 --- a/config/tftp/tftp.inc +++ b/config/tftp/tftp.inc @@ -274,8 +274,9 @@ function php_deinstall_command() unlink_if_exists("/usr/local/pkg/tftp.xml"); unlink_if_exists("/usr/local/pkg/tftp.inc"); unlink_if_exists("/usr/local/www/packages/tftp/tftp_files.php"); + exec("rm -R /usr/local/www/packages/tftp/"); - exec("rm -R /tftpboot"); + //exec("rm -R /tftpboot"); unlink_if_exists("/usr/local/etc/rc.d/tftp.sh"); unlink_if_exists("/tmp/pkg_mgr_tftp.log"); diff --git a/config/tftp/tftp_files.tmp b/config/tftp/tftp_files.tmp index f49ea76e..a5fb5ecc 100644 --- a/config/tftp/tftp_files.tmp +++ b/config/tftp/tftp_files.tmp @@ -37,18 +37,18 @@ if (($_GET['a'] == "download") && $_GET['t'] == "backup") { $filename = 'tftp.bak.tgz'; system('cd /;tar cvzf /tmp/tftp.bak.tgz tftpboot'); } -if (($_GET['a'] == "download") && file_exists("/tftpboot/".$filename)) { - +if (($_GET['a'] == "download") && file_exists("/tmp/".$filename)) { + session_cache_limiter('public'); - $fd = fopen("/tftpboot/".$filename, "rb"); + $fd = fopen("/tmp/".$filename, "rb"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Description: File Transfer"); - header('Content-Disposition: attachment; filename="'.$filename.'"'); + header('Content-Disposition: attachment; filename="'.$filename.'"'); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 - header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past - header("Content-Length: " . filesize("/tftpboot/".$filename)); + header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past + header("Content-Length: " . filesize("/tmp/".$filename)); fpassthru($fd); exit; } @@ -58,18 +58,18 @@ if ($_GET['a'] == "other") { if ($_GET['t'] == "restore") { $tmp = '/tmp/'; $filename = 'tftp.bak.tgz'; - + //extract a specific directory to /tftpboot if (file_exists('/tmp/'.$filename)) { //echo "The file $filename exists"; system('cd /; tar xvpfz /tmp/'.$filename); - system('chmod -R 744 /tftpboot/*'); + system('chmod -R 744 /tftpboot/*'); header( 'Location: tftp_files.php?savemsg=Backup+has+been+restored.' ) ; } else { header( 'Location: tftp_files.php?savemsg=Restore+failed.+Backup+file+not+found.' ) ; - } - + } + exit; } } @@ -99,7 +99,8 @@ include("head.inc");

TFTP: Files

- @@ -169,9 +170,9 @@ if ($savemsg) { echo "

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