From 04462b0cf3733edb0d20861ec7065c63d31d9640 Mon Sep 17 00:00:00 2001 From: Alan Garcia Date: Mon, 18 Feb 2013 13:48:30 +0000 Subject: [PATCH] Classes browser, ftp et hta n'ont plus alternc_html en dur --- bureau/admin/ftp_list.php | 2 +- bureau/class/config.php | 2 +- bureau/class/functions.php | 2 -- bureau/class/m_bro.php | 12 ++++++------ bureau/class/m_ftp.php | 11 +++++------ bureau/class/m_hta.php | 16 ++++++++-------- 6 files changed, 21 insertions(+), 24 deletions(-) diff --git a/bureau/admin/ftp_list.php b/bureau/admin/ftp_list.php index 2e24849d..baef58e8 100644 --- a/bureau/admin/ftp_list.php +++ b/bureau/admin/ftp_list.php @@ -84,7 +84,7 @@ while (list($key,$val)=each($r)) ]' value='' > - user['login'])+3) ?> + user['login']; diff --git a/bureau/class/m_bro.php b/bureau/class/m_bro.php index a6e20923..03d825aa 100644 --- a/bureau/class/m_bro.php +++ b/bureau/class/m_bro.php @@ -570,7 +570,7 @@ class m_bro { * @return boolean != 0 on error */ function ExtractFile($file, $dest=null) { - global $err,$cuid,$mem,$L_ALTERNC_LOC; + global $err,$cuid,$mem; $file = $this->convertabsolute($file,0); if (is_null($dest)) { $dest = dirname($file); @@ -889,7 +889,7 @@ class m_bro { * @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs */ function DownloadZ($dir="") { - global $mem,$L_ALTERNC_LOC; + global $mem; header("Content-Disposition: attachment; filename=".$mem->user["login"].".Z"); header("Content-Type: application/x-Z"); header("Content-Transfer-Encoding: binary"); @@ -905,7 +905,7 @@ class m_bro { * @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs */ function DownloadTGZ($dir="") { - global $mem,$L_ALTERNC_LOC; + global $mem; header("Content-Disposition: attachment; filename=".$mem->user["login"].".tgz"); header("Content-Type: application/x-tgz"); header("Content-Transfer-Encoding: binary"); @@ -921,7 +921,7 @@ class m_bro { * @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs */ function DownloadTBZ($dir="") { - global $mem,$L_ALTERNC_LOC; + global $mem; header("Content-Disposition: attachment; filename=".$mem->user["login"].".tar.bz2"); header("Content-Type: application/x-bzip2"); header("Content-Transfer-Encoding: binary"); @@ -937,7 +937,7 @@ class m_bro { * @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs */ function DownloadZIP($dir="") { - global $mem,$L_ALTERNC_LOC; + global $mem; header("Content-Disposition: attachment; filename=".$mem->user["login"].".zip"); header("Content-Type: application/x-zip"); header("Content-Transfer-Encoding: binary"); @@ -1012,7 +1012,7 @@ class m_bro { *@param : le chemin destination du tarball produit. */ function alternc_export_data($dir){ - global $mem,$L_ALTERNC_LOC,$err; + global $mem,$err; $err->log("bro","export_data"); $dir.="html/"; if(!is_dir($dir)){ diff --git a/bureau/class/m_ftp.php b/bureau/class/m_ftp.php index 5f3f7a4c..4a3d0862 100644 --- a/bureau/class/m_ftp.php +++ b/bureau/class/m_ftp.php @@ -106,15 +106,12 @@ class m_ftp { * @return array Retourne le tableau des comptes ou FALSE si une erreur s'est produite. */ function get_list() { - global $db,$err,$cuid; + global $db,$err,$cuid, $bro; $err->log("ftp","get_list"); $r=array(); $db->query("SELECT id, name, homedir FROM ftpusers WHERE uid='$cuid' ORDER BY name;"); if ($db->num_rows()) { while ($db->next_record()) { - // On passe /var/alternc/html/u/user - // FIXME: utiliser getuserpath() - $tr=preg_match("/^\/var\/alternc\/html\/.\/[^\/]*\/(.*)$/", $db->f("homedir"),$match); /* " */ $r[]=array( "id"=>$db->f("id"), "login"=>$db->f("name"), @@ -142,8 +139,10 @@ class m_ftp { $db->query("SELECT id, name, homedir FROM ftpusers WHERE uid='$cuid' AND id='$id';"); if ($db->num_rows()) { $db->next_record(); - // FIXME: utiliser getuserpath - $tr=preg_match("/^\/var\/alternc\/html\/.\/[^\/]*\/(.*)$/", $db->f("homedir"),$match); + + $regexp="/^".preg_quote(getuserpath(),"/")."\/(.*)$/"; + $tr=preg_match($regexp, $db->f("homedir"),$match); + $lg=explode("_",$db->f("name")); if ((!is_array($lg)) || (count($lg)!=2)) { $lg[0]=$db->f("name"); diff --git a/bureau/class/m_hta.php b/bureau/class/m_hta.php index bbf14f52..e67c7e2a 100644 --- a/bureau/class/m_hta.php +++ b/bureau/class/m_hta.php @@ -74,7 +74,7 @@ class m_hta { * @return boolean TRUE if the folder has been protected, or FALSE if an error occurred */ function CreateDir($dir) { - global $mem,$bro,$err,$L_ALTERNC_LOC; + global $mem,$bro,$err; $err->log("hta","createdir",$dir); $absolute=$bro->convertabsolute($dir,0); if (!$absolute) { @@ -117,16 +117,16 @@ class m_hta { */ function ListDir(){ - global$err,$mem,$L_ALTERNC_LOC; + global$err,$mem; $err->log("hta","listdir"); $sortie=array(); - $absolute="$L_ALTERNC_LOC/html/".substr($mem->user["login"],0,1)."/".$mem->user["login"]; + $absolute=ALTERNC_HTML."/".substr($mem->user["login"],0,1)."/".$mem->user["login"]; exec("find $absolute -name .htpasswd|sort",$sortie); if(!count($sortie)){ $err->raise("hta",_("No protected folder")); return false; } - $pattern="/^".preg_quote($L_ALTERNC_LOC,"/")."\/html\/.\/[^\/]*\/(.*)\/\.htpasswd/"; + $pattern="/^".preg_quote(ALTERNC_HTML,"/")."\/.\/[^\/]*\/(.*)\/\.htpasswd/"; for($i=0;$ilog("hta","is_protected",$dir); - $absolute="$L_ALTERNC_LOC/html/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/$dir"; + $absolute=ALTERNC_HTML."/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/$dir"; $sortie=array(); if (file_exists("$absolute/.htpasswd")){ return true; @@ -162,9 +162,9 @@ class m_hta { * @return array An array containing the list of logins from the .htpasswd file, or FALSE */ function get_hta_detail($dir) { - global $mem,$err,$L_ALTERNC_LOC; + global $mem,$err; $err->log("hta","get_hta_detail"); - $absolute="$L_ALTERNC_LOC/html/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/$dir"; + $absolute=ALTERNC_HTML."/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/$dir"; if (file_exists("$absolute/.htaccess")) { /* if (!_reading_htaccess($absolute)) { return false;