[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:13:24 UTC 2007
User: finnarne-guest
Date: 07/04/17 00:13:24
Modified: src index.php
Log:
Now the browsing works for folders, only file restoring left
Revision Changes Path
1.20 +38 -13 slbackup-php/src/index.php
Index: index.php
===================================================================
RCS file: /cvsroot/slbackup/slbackup-php/src/index.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- index.php 16 Apr 2007 22:47:11 -0000 1.19
+++ index.php 17 Apr 2007 00:13:24 -0000 1.20
@@ -20,13 +20,25 @@
-function listloc ($passwd, $clientdir, $location) {
+function listloc ($passwd, $clientdir, $location, $sub = "") {
global $backuphost, $backupuser, $ssh_options, $ssh_askpass ;
$loc = array() ;
- $cmd = sprintf ("ssh %s %s@%s 'find %s%s -maxdepth 1 -mindepth 1 -type d -printf \"%s\"'",
+ $parent = dirname ($sub) ;
+ if (!empty($sub)) {
+ if ($parent == ".") $parent="" ;
+ $loc[] = array ('type' => 'parent',
+ 'name' => "Parent directory",
+ 'sub' => trim ($parent)) ;
+ }
+
+ $cmd = sprintf ("ssh %s %s@%s 'find %s%s/%s -maxdepth 1 -mindepth 1 -type d'",
+ $ssh_options, $backupuser,
+ $backuphost, $clientdir, $location, $sub ) ;
+
+ $cmd = sprintf ("ssh %s %s@%s 'find %s%s/%s -maxdepth 1 -mindepth 1 -type d'",
$ssh_options, $backupuser,
- $backuphost, $clientdir, $location, '%P\n') ;
+ $backuphost, $clientdir, $location, $sub ) ;
$desc[0] = array ("pipe", "r") ;
$desc[1] = array ("pipe", "w") ;
@@ -38,24 +50,26 @@
if (is_resource ($proc)) {
fprintf ($pipes[0], "%s\n", $passwd) ;
fclose ($pipes[0]) ;
- while ($line = fgets ($pipes[1], 1024))
+ while ($line = fgets ($pipes[1], 1024)) {
$loc[] = array ('type' => 'dir',
'name' => basename (trim($line)),
- 'path' => trim ($line)) ;
+ 'sub' => substr (trim ($line), strlen ($clientdir) + strlen ($location) + 1)) ;
+
+ }
fclose ($pipes[1]) ;
proc_close ($proc) ;
}
- $cmd = sprintf ("ssh %s %s@%s find %s/%s -maxdepth 1 -mindepth 1 -type f ",
+ $cmd = sprintf ("ssh %s %s@%s find %s/%s/%s -maxdepth 1 -mindepth 1 -type f ",
$ssh_options, $backupuser,
- $backuphost, $clientdir, $location) ;
+ $backuphost, $clientdir, $location, $sub) ;
$proc = proc_open ($cmd, $desc, $pipes, '/tmp', $env) ;
if (is_resource ($proc)) {
fprintf ($pipes[0], "%s\n", $passwd) ;
fclose ($pipes[0]) ;
while ($line = fgets ($pipes[1], 1024))
- $loc[] = array ('type' => 'files',
+ $loc[] = array ('type' => 'file',
'name' => basename (trim($line)),
- 'path' => trim ($line)) ;
+ 'sub' => trim ($line)) ;
fclose ($pipes[1]) ;
proc_close ($proc) ;
}
@@ -282,6 +296,11 @@
# Fetch arguments passed as the script is executed
foreach ($_REQUEST as $key => $value) {
switch ($key) {
+ case "smarty_templ":
+ case "smarty_compile":
+ case "locale":
+ case "PHPSESSID":
+ break ;
case "Passwd":
$passwd = $value ;
$submit = "status" ;
@@ -464,9 +483,15 @@
case "restorelocation":
if (empty($client) || empty ($newconf["location"]))
break ;
- $loc = listloc ($passwd,
- sprintf ("%s/%s", $config["server_destdir"], $client),
- $newconf["location"]);
+ if (empty($newconf["sub"]))
+ $loc = listloc ($passwd,
+ sprintf ("%s/%s", $config["server_destdir"], $client),
+ $newconf["location"]) ;
+ else
+ $loc = listloc ($passwd,
+ sprintf ("%s/%s", $config["server_destdir"], $client),
+ $newconf["location"], $newconf["sub"]) ;
+
break ;
default:
$log = array ('start' => '', 'end' => '') ;
@@ -480,7 +505,7 @@
switch ($submit) {
case "restorelocation":
$smarty->assign ('loc', $loc) ;
- $smarty->assign ('location', $loctions) ;
+ $smarty->assign ('location', $newconf["location"]) ;
case "restoreclient":
case "restore":
$clients = array_keys($config["clients"]) ;
More information about the slbackup-commit
mailing list