summaryrefslogtreecommitdiffstats
path: root/usr/local/www/system_firmware_restorefullbackup.php
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@gmail.com>2011-09-26 18:10:33 -0400
committerScott Ullrich <sullrich@gmail.com>2011-09-26 18:10:33 -0400
commitceb3515deac6b7cb6431a64938065417c8745c7c (patch)
treee476510297535db572f7f47c385fd7ad65a971d3 /usr/local/www/system_firmware_restorefullbackup.php
parent68e14a6bbcaad573b6c9b61acbfd14248957b774 (diff)
downloadpfsense-ceb3515deac6b7cb6431a64938065417c8745c7c.zip
pfsense-ceb3515deac6b7cb6431a64938065417c8745c7c.tar.gz
Add download feature
Diffstat (limited to 'usr/local/www/system_firmware_restorefullbackup.php')
-rwxr-xr-xusr/local/www/system_firmware_restorefullbackup.php37
1 files changed, 20 insertions, 17 deletions
diff --git a/usr/local/www/system_firmware_restorefullbackup.php b/usr/local/www/system_firmware_restorefullbackup.php
index 96e488d..1dd2f9d 100755
--- a/usr/local/www/system_firmware_restorefullbackup.php
+++ b/usr/local/www/system_firmware_restorefullbackup.php
@@ -47,9 +47,6 @@
ini_set('max_execution_time', '0');
ini_set('max_input_time', '0');
-/* omit no-cache headers because it confuses IE with file downloads */
-$omit_nocacheheaders = true;
-
require_once("functions.inc");
require("guiconfig.inc");
require_once("filter.inc");
@@ -63,21 +60,27 @@ if($_GET['backupnow'])
if($_GET['downloadbackup']) {
$filename = $_GET['downloadbackup'];
+ $path = "/root/{$filename}";
if(file_exists("/root/{$filename}")) {
+ session_write_close();
+ ob_end_clean();
session_cache_limiter('public');
- $fd = fopen("/root/" . $filename, "rb");
+ //$fd = fopen("/root/{$filename}", "rb");
+ $filesize = filesize("/root/{$filename}");
+ header("Cache-Control: ");
+ header("Pragma: ");
header("Content-Type: application/octet-stream");
- header("Content-Length: " . filesize("/root/" . $filename));
- header("Content-Disposition: attachment; filename=\"" .
- trim(htmlentities(basename($filename))) . "\"");
- if (isset($_SERVER['HTTPS'])) {
- header('Pragma: ');
- header('Cache-Control: ');
- } else {
- header("Pragma: private");
- header("Cache-Control: private, must-revalidate");
+ header("Content-Length: " .(string)(filesize($path)) );
+ header('Content-Disposition: attachment; filename="'.$name.'"');
+ header("Content-Transfer-Encoding: binary\n");
+ if($file = fopen("/root/{$filename}", 'rb')){
+ while( (!feof($file)) && (connection_status()==0) ){
+ print(fread($file, 1024*8));
+ flush();
+ }
+ fclose($file);
}
- fpassthru($fd);
+
exit;
}
}
@@ -158,9 +161,9 @@ include("head.inc");
echo "<a onclick=\"return confirm('" . gettext("Do you really want to delete this backup?") . "')\" href='system_firmware_restorefullbackup.php?deletefile=" . htmlspecialchars($arf) . "'>";
echo gettext("Delete");
echo "</a> | ";
- //echo "<a href='system_firmware_restorefullbackup.php?downloadbackup=" . htmlspecialchars($arf) . "'>";
- //echo gettext("Download");
- //echo "</a>";
+ echo "<a href='system_firmware_restorefullbackup.php?downloadbackup=" . htmlspecialchars($arf) . "'>";
+ echo gettext("Download");
+ echo "</a>";
echo "</td>";
echo "</tr>";
}
OpenPOWER on IntegriCloud