[slbackup-commit] CVS update: slbackup-php/src index.php
finnarne-guest at alioth.debian.org
finnarne-guest at alioth.debian.org
Tue Apr 17 00:56:55 UTC 2007
User: finnarne-guest
Date: 07/04/17 00:56:55
Modified: src index.php
Log:
Set headers to make the file appear correct
Revision Changes Path
1.22 +9 -7 slbackup-php/src/index.php
Index: index.php
===================================================================
RCS file: /cvsroot/slbackup/slbackup-php/src/index.php,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- index.php 17 Apr 2007 00:30:26 -0000 1.21
+++ index.php 17 Apr 2007 00:56:55 -0000 1.22
@@ -23,7 +23,6 @@
function fetchfile ($passwd, $clientdir, $location, $file) {
global $backuphost, $backupuser, $ssh_options, $ssh_askpass ;
- $out= "" ;
$cmd = sprintf ("ssh %s %s@%s 'cat %s%s/%s'",
$ssh_options, $backupuser,
$backuphost, $clientdir, $location, $file ) ;
@@ -38,11 +37,10 @@
if (is_resource ($proc)) {
fprintf ($pipes[0], "%s\n", $passwd) ;
fclose ($pipes[0]) ;
- while ($line = fgets ($pipes[1], 1024))
- $out .= $line ;
+ $out = stream_get_contents($pipes[1]) ;
fclose ($pipes[1]) ;
proc_close ($proc) ;
- }
+ } else unset ($out) ;
return $out ;
}
@@ -508,11 +506,15 @@
case "restorefile":
if (empty($client) || empty ($newconf["location"]))
break ;
- debug (fetchfile ($passwd,
+ $out = fetchfile ($passwd,
sprintf ("%s/%s", $config["server_destdir"], $client),
- $newconf["location"], $newconf["file"])) ;
+ $newconf["location"], $newconf["file"]) ;
- break ;
+ header ('Content-Type: binary/raw') ;
+ header ('Content-Length: ' . strlen ($out)) ;
+ header (sprintf ("Content-Disposition: attachment; filename=\"%s\"", basename ($newconf["file"]))) ;
+ echo $out ;
+ return ;
case "restorelocation":
if (empty($client) || empty ($newconf["location"]))
break ;
More information about the slbackup-commit
mailing list