Changeset 2080

Show
Ignore:
Timestamp:
01/22/08 03:19:54 (9 months ago)
Author:
anarcat
Message:

adaptation du code de copie de fichier:

  • desactiver le code de copie par http:// pour l'instant
  • utilise escapeshellarg() au lieu de addslashes() pour echapper les arguments
  • utiliser le bon systeme de message d'erreurs
  • ajouter -p a l'appel de cp
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • alternc/trunk/bureau/class/m_bro.php

    r2078 r2080  
    425425    $file = $this->convertabsolute($file,0); 
    426426    $dest = $this->convertabsolute($dest,0); 
     427    if (!$file || !$dest) { 
     428      $err->raise("bro",1); 
     429      return false; 
     430    } 
    427431    if ($i == 0) { 
    428432#TODO new version of tar supports `tar xf ...` so there is no 
     
    475479    } 
    476480 
     481    /* 
     482     * XXX: Disabled functionality until audit is completed 
     483     */ 
     484    /* 
    477485    if (substr($src, 0, 7) == "http://") { 
    478486      $filename = basename($src); 
     
    524532      } 
    525533    } 
     534    */ 
    526535 
    527536    // Last step // Copy -R 
    528     $src = addslashes($src); 
    529     $dest = addslashes($dest); 
     537    $src = escapeshellarg($this->convertabsolute($src)); 
     538    $dest = escapeshellarg($this->convertabsolute($dest)); 
     539    if (!$src || !$dest) { 
     540      $err->raise("bro",1); 
     541      return false; 
     542    } 
     543    /* XXX: UNIX-specific because of that slash */ 
    530544    $array = explode('/', $dest); 
    531545    $dir = ""; 
     
    534548      @mkdir($dest); 
    535549    } 
    536 #TODO write a recursive copy function(?) 
    537     exec("cp -Rf '$src'/* '$dest'", $void, $ret); 
     550    #TODO write a recursive copy function(?) 
     551    exec("cp -Rpf '$src'/* '$dest'", $void, $ret); 
    538552    if ($ret) { 
    539       $error = _("Errors happened while copying the source to destination."); 
    540       return false; 
    541     } 
    542  
    543     $error = _("The web application has been successfully installed."); 
     553      $err->raise("bro","Errors happened while copying the source to destination."); 
     554      return false; 
     555    } 
     556 
    544557    return true; 
    545558  }