[slbackup-commit] CVS update: slbackup-php/src index.php

finnarne-guest at alioth.debian.org finnarne-guest at alioth.debian.org
Mon Apr 16 21:08:41 UTC 2007


  User: finnarne-guest
  Date: 07/04/16 21:08:41

  Modified:    src      index.php
  Log:
  Added code to browse the backuplocation
  
  Revision  Changes    Path
  1.16      +52 -0     slbackup-php/src/index.php
  
  Index: index.php
  ===================================================================
  RCS file: /cvsroot/slbackup/slbackup-php/src/index.php,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- index.php	16 Apr 2007 15:58:53 -0000	1.15
  +++ index.php	16 Apr 2007 21:08:41 -0000	1.16
  @@ -20,6 +20,45 @@
   
   
   
  +function listloc ($passwd, $clientdir, $location) {
  +global $backuphost, $backupuser, $ssh_options, $ssh_askpass ;
  +
  +    $loc = array() ; 
  +    $cmd = sprintf ("ssh %s %s@%s find %s/%s -maxdepth 1 -mindepth 1 -type d ", 
  +   		     $ssh_options, $backupuser, 
  +		     $backuphost, $clientdir, $location) ; 
  +
  +    $desc[0] = array ("pipe", "r") ; 
  +    $desc[1] = array ("pipe", "w") ; 
  +    $desc[2] = array ("file", "/tmp/error.log", "a") ; 
  +
  +    $env = array ('SSH_ASKPASS' => $ssh_askpass, 
  +		  'DISPLAY' => ':nowhere') ; 
  +    $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["d"][] = trim ($line) ; 
  +	fclose ($pipes[1]) ; 
  +	proc_close ($proc) ; 
  +    }
  +    $cmd = sprintf ("ssh %s %s@%s find %s/%s -maxdepth 1 -mindepth 1 -type f ", 
  +   		     $ssh_options, $backupuser, 
  +		     $backuphost, $clientdir, $location) ; 
  +    $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["f"][] = trim ($line) ; 
  +	fclose ($pipes[1]) ; 
  +	proc_close ($proc) ; 
  +    }
  +
  +    return $loc ; 
  +}
  +
   function readcron ($passwd) {
   global $backuphost, $backupuser, $backupcron, $ssh_options, $ssh_askpass ;
   
  @@ -259,6 +298,8 @@
           case "addloc":
           case "scheduler":
           case "restore":
  +        case "restoreclient":
  +        case "restorelocation":
           case "logout":
               $submit=$key ; 
               break ;
  @@ -413,6 +454,13 @@
   	$config["clients"][$client]["location"][] = $newconf["newloc"] ; 
   	writeconf ($passwd, $config) ; 
   	break ;
  +    case "restorelocation": 
  +        if (empty($client) || empty ($newconf["location"]))
  +            break ; 
  +        $loc = listloc ($passwd, 
  +                        sprintf ("%s/%s", $config["server_destdir"], $client), 
  +                        $newconf["location"]); 
  +	break ; 
       default:
           $log = array ('start' => '', 'end' => '') ; 
           foreach ($config["clients"] as $key => $value) 
  @@ -423,6 +471,10 @@
   }
   
   switch ($submit) {
  +    case "restorelocation":
  +    debug ($loc) ; 
  +    $smarty->assign ('loc', $loc) ; 
  +    case "restoreclient":
       case "restore":
   	$clients = array_keys($config["clients"]) ; 
   	$smarty->assign ('clients', $clients) ; 
  
  
  



More information about the slbackup-commit mailing list