various fixes to the imported functions:
* respect our function naming convention * remove unrar code as I do not trust it for now * use convertabsolute() instead of addslashes() to sanitize the paths See #1043.
This commit is contained in:
		
							parent
							
								
									593fdc17db
								
							
						
					
					
						commit
						6787f26a12
					
				| 
						 | 
					@ -419,11 +419,11 @@ class m_bro {
 | 
				
			||||||
   * @param string $dest is the path of the extract destination
 | 
					   * @param string $dest is the path of the extract destination
 | 
				
			||||||
   * @return boolean != 0 on error
 | 
					   * @return boolean != 0 on error
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  function brouteur_extract($file, $dest="./")
 | 
					  function ExtractFile($file, $dest="./")
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    static $i=0, $ret;
 | 
					    static $i=0, $ret;
 | 
				
			||||||
    $file = addslashes($file);
 | 
					    $file = $this->convertabsolute($file,0);
 | 
				
			||||||
    $dest = addslashes($dest);
 | 
					    $dest = $this->convertabsolute($dest,0);
 | 
				
			||||||
    if ($i == 0) {
 | 
					    if ($i == 0) {
 | 
				
			||||||
#TODO new version of tar supports `tar xf ...` so there is no
 | 
					#TODO new version of tar supports `tar xf ...` so there is no
 | 
				
			||||||
#     need to specify the compression format
 | 
					#     need to specify the compression format
 | 
				
			||||||
| 
						 | 
					@ -432,19 +432,13 @@ class m_bro {
 | 
				
			||||||
      exec("tar -xjf '$file' -C '$dest'", $void, $ret);
 | 
					      exec("tar -xjf '$file' -C '$dest'", $void, $ret);
 | 
				
			||||||
    } else if ($i == 2) {
 | 
					    } else if ($i == 2) {
 | 
				
			||||||
      exec("unzip '$file' -d '$dest'", $void, $ret);
 | 
					      exec("unzip '$file' -d '$dest'", $void, $ret);
 | 
				
			||||||
    } else if ($i == 3) {
 | 
					 | 
				
			||||||
#FIXME I suck at extracting a rar archive to a specified directory
 | 
					 | 
				
			||||||
#      but I think unrar just sucks <TM>
 | 
					 | 
				
			||||||
      $rarfile = ereg_replace('[a-z0-9]+', '..', $dest)."/$file";
 | 
					 | 
				
			||||||
      exec("mkdir -p '$dest'");
 | 
					 | 
				
			||||||
      exec("cd '$dest' && unrar x -o+ '$rarfile'", $void, $ret);
 | 
					 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      return $ret;
 | 
					      return $ret;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ($ret) {
 | 
					    if ($ret) {
 | 
				
			||||||
      $i++;
 | 
					      $i++;
 | 
				
			||||||
      brouteur_extract($file, $dest);
 | 
					      $this->ExtractFile($file, $dest);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return $ret;
 | 
					    return $ret;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					@ -459,7 +453,7 @@ class m_bro {
 | 
				
			||||||
   * @param string $dest is the absolute path inside the users directory
 | 
					   * @param string $dest is the absolute path inside the users directory
 | 
				
			||||||
   * @return boolean false on error
 | 
					   * @return boolean false on error
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  function brouteur_copy($name, $src, $dest)
 | 
					  function CopyFile($name, $src, $dest)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    global $error, $db;
 | 
					    global $error, $db;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue