From 97d65aadb3431c8f7fe214fe09bd7a70f509c99e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Tue, 22 Jan 2008 03:23:26 +0000 Subject: [PATCH] make UploadFile() return the uploaded path make ExtractFile extract in the same directory as the archive by default --- bureau/class/m_bro.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bureau/class/m_bro.php b/bureau/class/m_bro.php index 02e5ad55..2c7f7eaf 100644 --- a/bureau/class/m_bro.php +++ b/bureau/class/m_bro.php @@ -390,6 +390,7 @@ class m_bro { * Le champ file-upload originel doit s'appeler "userfile" et doit * bien être un fichier d'upload. * @param string $R Dossier dans lequel on upload le fichier + * @returns the path where the file resides or false if upload failed */ function UploadFile($R) { global $_FILES,$err; @@ -405,23 +406,30 @@ class m_bro { } move_uploaded_file($_FILES['userfile']['tmp_name'], $absolute."/".$_FILES['userfile']['name']); } else { - $err->log("bro","uploadfile","Tentative d'attaque : ".$_FILES['userfile']['tmp_name']); + $err->log("bro","uploadfile","Tentative d'attaque : ".$_FILES['userfile']['tmp_name']); + return false; } } + return $absolute."/".$_FILES['userfile']['name']; } /** * Extract an archive by using GNU and non-GNU tools * @param string $file is the full or relative path to the archive - * @param string $dest is the path of the extract destination + * @param string $dest is the path of the extract destination, the + * same directory as the archive by default * @return boolean != 0 on error */ - function ExtractFile($file, $dest="./") + function ExtractFile($file, $dest=null) { global $err; static $i=0, $ret; $file = $this->convertabsolute($file,0); - $dest = $this->convertabsolute($dest,0); + if (is_null($dest)) { + $dest = dirname($file); + } else { + $dest = $this->convertabsolute($dest,0); + } if (!$file || !$dest) { $err->raise("bro",1); return false;