Classes browser, ftp et hta n'ont plus alternc_html en dur

This commit is contained in:
Alan Garcia 2013-02-18 13:48:30 +00:00
parent 9ec9177350
commit 04462b0cf3
6 changed files with 21 additions and 24 deletions

View File

@ -84,7 +84,7 @@ while (list($key,$val)=each($r))
<td><label for="del_<?php echo $val["id"]; ?>"><?php echo $val["login"] ?></label>
<input type='hidden' name='names[<?php echo $val['id'];?>]' value='<?php echo $val["login"] ?>' >
</td>
<td><code><?php echo substr(str_replace(ALTERNC_HTML,'',$val["dir"]),strlen($mem->user['login'])+3) ?></code></td>
<td><code><?php echo str_replace(getuserpath(),'', $val["dir"]) ?></code></td>
</tr>
<?php
}

View File

@ -96,7 +96,7 @@ require_once(dirname(__FILE__)."/local.php");
// Define constants from vars of /etc/alternc/local.sh
// The you can't choose where is the AlternC Panel
define('ALTERNC_MAIL', "$L_ALTERNC_MAIL");
define('ALTERNC_HTML', "$L_ALTERNC_LOC");
define('ALTERNC_HTML', "$L_ALTERNC_HTML");
define('ALTERNC_LOGS', "$L_ALTERNC_LOGS");
define('ALTERNC_PANEL', "/usr/lib/alternc/panel");
define('ALTERNC_LOCALES', ALTERNC_PANEL."/locales");

View File

@ -218,10 +218,8 @@ function checkuserpath($path) {
* @args string $user the username, if null will use the global $mem. no
* security checks performed on path
* @returns string the actual absolute path
* @see $L_ALTERNC_LOC
*/
function getuserpath($user = null) {
global $L_ALTERNC_LOC;
if (is_null($user)) {
global $mem;
$user = $mem->user['login'];

View File

@ -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)){

View File

@ -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");

View File

@ -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;$i<count($sortie);$i++){
preg_match($pattern,$sortie[$i],$matches);
$tmpm=isset($matches[1])?$matches[1]:'';
@ -142,9 +142,9 @@ class m_hta {
* @return TRUE if the folder is protected, or FALSE if it is not
*/
function is_protected($dir){
global $mem,$err,$L_ALTERNC_LOC;
global $mem,$err;
$err->log("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;