Genericité sur l'user dir, reste surement des bugs
This commit is contained in:
parent
0d04b6f719
commit
8f722bb00c
|
@ -74,7 +74,7 @@ function browseforfolder($curdir) {
|
||||||
return $brlist;
|
return $brlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
$root="/var/alternc/html/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/";
|
$root=getuserpath();
|
||||||
// pour utiliser 'la ou est browseforfolder', mettre dirname($HTTP_SERVER_VARS["PATH_TRANSLATED"]);
|
// pour utiliser 'la ou est browseforfolder', mettre dirname($HTTP_SERVER_VARS["PATH_TRANSLATED"]);
|
||||||
|
|
||||||
if (substr($file,0,1)!="/") $file="/".$file;
|
if (substr($file,0,1)!="/") $file="/".$file;
|
||||||
|
|
|
@ -37,7 +37,7 @@ require_once("../class/config.php");
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$MENUPATH="/var/alternc/bureau/admin/";
|
$MENUPATH=ALTERNC_PANEL."/admin/";
|
||||||
$file=file("/etc/alternc/menulist.txt", FILE_SKIP_EMPTY_LINES);
|
$file=file("/etc/alternc/menulist.txt", FILE_SKIP_EMPTY_LINES);
|
||||||
foreach($file as $v) {
|
foreach($file as $v) {
|
||||||
$v=trim($v);
|
$v=trim($v);
|
||||||
|
|
|
@ -46,6 +46,12 @@ Merci de revenir plus tard.";
|
||||||
*/
|
*/
|
||||||
ini_set('display_errors', true);
|
ini_set('display_errors', true);
|
||||||
|
|
||||||
|
// Some constant
|
||||||
|
define('ALTERNC_HTML', "/var/alternc/html");
|
||||||
|
define('ALTERNC_PANEL', "/var/alternc/bureau");
|
||||||
|
define('ALTERNC_LOGS', "/var/alternc/logs");
|
||||||
|
define('ALTERNC_LOCALES', "/var/alternc/bureau/locales");
|
||||||
|
|
||||||
// 1. Get a semaphore id for the alternc magic number (18577)
|
// 1. Get a semaphore id for the alternc magic number (18577)
|
||||||
$alternc_sem = sem_get ( 18577 );
|
$alternc_sem = sem_get ( 18577 );
|
||||||
// 2. Declare the shutdown function, that release the semaphore
|
// 2. Declare the shutdown function, that release the semaphore
|
||||||
|
@ -87,10 +93,10 @@ $host=getenv("HTTP_HOST");
|
||||||
/* Global variables (AlternC configuration) */
|
/* Global variables (AlternC configuration) */
|
||||||
require_once(dirname(__FILE__)."/local.php");
|
require_once(dirname(__FILE__)."/local.php");
|
||||||
/* PHPLIB inclusions : */
|
/* PHPLIB inclusions : */
|
||||||
$root=$L_ALTERNC_LOC."/bureau/";
|
$root=ALTERNC_PANEL."/";
|
||||||
|
|
||||||
require_once($root."class/db_mysql.php");
|
require_once($root."/class/db_mysql.php");
|
||||||
require_once($root."class/functions.php");
|
require_once($root."/class/functions.php");
|
||||||
require_once($root."class/variables.php");
|
require_once($root."class/variables.php");
|
||||||
|
|
||||||
// Redirection si appel à https://(!fqdn)/
|
// Redirection si appel à https://(!fqdn)/
|
||||||
|
|
|
@ -53,7 +53,7 @@ register_shutdown_function("alternc_shutdown");
|
||||||
sem_acquire( $alternc_sem );
|
sem_acquire( $alternc_sem );
|
||||||
|
|
||||||
/* PHPLIB inclusions : */
|
/* PHPLIB inclusions : */
|
||||||
$root="/var/alternc/bureau/";
|
$root=ALTERNC_PANEL."/";
|
||||||
/* Server Domain Name */
|
/* Server Domain Name */
|
||||||
$host=getenv("HTTP_HOST");
|
$host=getenv("HTTP_HOST");
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ closedir($c);
|
||||||
|
|
||||||
|
|
||||||
/* Language */
|
/* Language */
|
||||||
bindtextdomain("alternc", "/var/alternc/bureau/locales");
|
bindtextdomain("alternc", ALTERNC_LOCALES);
|
||||||
|
|
||||||
if (!$do_not_set_lang_env) {
|
if (!$do_not_set_lang_env) {
|
||||||
// setlang is on the link at the login page
|
// setlang is on the link at the login page
|
||||||
|
@ -157,4 +157,4 @@ for($i=0;$i<count($classes);$i++) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -209,13 +209,13 @@ function checkuserpath($path) {
|
||||||
if (substr($path,0,1)=="/")
|
if (substr($path,0,1)=="/")
|
||||||
$path="/".$path;
|
$path="/".$path;
|
||||||
|
|
||||||
$rpath = realpath("/var/alternc/html/$usar/$user$path");
|
$rpath = realpath(ALTERNC_HTML."/$usar/$user$path");
|
||||||
$userpath = realpath("/var/alternc/html/$usar/$user");
|
$userpath = getuserpath();
|
||||||
if(strpos($rpath,$userpath) === 0){
|
if(strpos($rpath,$userpath) === 0){
|
||||||
if (is_dir("/var/alternc/html/$usar/$user$path")) {
|
if (is_dir(ALTERNC_HTML."/$usar/$user$path")) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (is_file("/var/alternc/html/$usar/$user$path")) {
|
if (is_file(ALTERNC_HTML."/$usar/$user$path")) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ function getuserpath($user = null) {
|
||||||
global $mem;
|
global $mem;
|
||||||
$user = $mem->user['login'];
|
$user = $mem->user['login'];
|
||||||
}
|
}
|
||||||
return $L_ALTERNC_LOC . "/html/".substr($user,0,1)."/".$user;
|
return ALTERNC_HTML."/".substr($user,0,1)."/".$user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ECHOes checked="checked" only if the parameter is true
|
/* ECHOes checked="checked" only if the parameter is true
|
||||||
|
|
|
@ -21,7 +21,7 @@ if (isset($_REQUEST["setlang"])) {
|
||||||
$lang=$_REQUEST["setlang"];
|
$lang=$_REQUEST["setlang"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$langpath = bindtextdomain("alternc", "/var/alternc/bureau/locales");
|
$langpath = bindtextdomain("alternc", ALTERNC_LOCALES);
|
||||||
|
|
||||||
// Create or update a locale.php file if it is outdated.
|
// Create or update a locale.php file if it is outdated.
|
||||||
$locales = update_locale($langpath);
|
$locales = update_locale($langpath);
|
||||||
|
|
|
@ -122,7 +122,7 @@ class m_bro {
|
||||||
* @return string Returns the complete path to the root of the user's directory.
|
* @return string Returns the complete path to the root of the user's directory.
|
||||||
*/
|
*/
|
||||||
function get_user_root($login) {
|
function get_user_root($login) {
|
||||||
return "/var/alternc/html/".substr($login,0,1)."/".$login;
|
return getuserpath();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Retourne le chemin complet vers la racine du repertoire de l'utilisateur.
|
/** Retourne le chemin complet vers la racine du repertoire de l'utilisateur.
|
||||||
|
@ -377,7 +377,7 @@ class m_bro {
|
||||||
*/
|
*/
|
||||||
function DeleteFile($file_list,$R) {
|
function DeleteFile($file_list,$R) {
|
||||||
global $err, $mem;
|
global $err, $mem;
|
||||||
$root=realpath("/var/alternc/html/".substr($mem->user["login"],0,1)."/".$mem->user["login"]);
|
$root=realpath(getuserpath());
|
||||||
$absolute=$this->convertabsolute($R,0);
|
$absolute=$this->convertabsolute($R,0);
|
||||||
if (!$absolute && strpos($root,$absolute) === 0 && strlen($absolute) > (strlen($root)+1) ) {
|
if (!$absolute && strpos($root,$absolute) === 0 && strlen($absolute) > (strlen($root)+1) ) {
|
||||||
$err->raise("bro",1);
|
$err->raise("bro",1);
|
||||||
|
@ -556,8 +556,8 @@ class m_bro {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
$file = escapeshellarg($file);
|
$file = escapeshellarg($file);
|
||||||
$dest = escapeshellarg($dest);
|
$dest = escapeshellarg($dest);
|
||||||
$dest_to_fix=str_replace($L_ALTERNC_LOC."/html/".substr($mem->user["login"],0,1)."/".$mem->user["login"],'',$dest);
|
$dest_to_fix=str_replace(getuserpath(),'',$dest);
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -839,7 +839,7 @@ class m_bro {
|
||||||
header("Content-Transfer-Encoding: binary");
|
header("Content-Transfer-Encoding: binary");
|
||||||
$d=escapeshellarg(".".$this->convertabsolute($dir,1));
|
$d=escapeshellarg(".".$this->convertabsolute($dir,1));
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
passthru("/bin/tar -cZ -C ".$L_ALTERNC_LOC."/html/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/ $d");
|
passthru("/bin/tar -cZ -C ".getuserpath()."/".$mem->user["login"]."/ $d");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -855,7 +855,7 @@ class m_bro {
|
||||||
header("Content-Transfer-Encoding: binary");
|
header("Content-Transfer-Encoding: binary");
|
||||||
$d=escapeshellarg(".".$this->convertabsolute($dir,1));
|
$d=escapeshellarg(".".$this->convertabsolute($dir,1));
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
passthru("/bin/tar -cz -C ".$L_ALTERNC_LOC."/html/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/ $d");
|
passthru("/bin/tar -cz -C ".getuserpath()."/ $d");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -871,7 +871,7 @@ class m_bro {
|
||||||
header("Content-Transfer-Encoding: binary");
|
header("Content-Transfer-Encoding: binary");
|
||||||
$d=escapeshellarg(".".$this->convertabsolute($dir,1));
|
$d=escapeshellarg(".".$this->convertabsolute($dir,1));
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
passthru("/bin/tar -cj -C ".$L_ALTERNC_LOC."/html/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/ $d");
|
passthru("/bin/tar -cj -C ".getuserpath()."/ $d");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -964,7 +964,7 @@ function alternc_export_data($dir){
|
||||||
}
|
}
|
||||||
$timestamp=date("H:i:s");
|
$timestamp=date("H:i:s");
|
||||||
|
|
||||||
if(exec("/bin/tar cvf - ".$L_ALTERNC_LOC."/html/".substr($mem->user['login'],0,1)."/".$mem->user['login']."/ | gzip -9c > ".$dir."/".$mem->user['login']."_html_".$timestamp.".tar.gz")){
|
if(exec("/bin/tar cvf - ".getuserpath()."/ | gzip -9c > ".$dir."/".$mem->user['login']."_html_".$timestamp.".tar.gz")){
|
||||||
$err->log("bro","export_data_succes");
|
$err->log("bro","export_data_succes");
|
||||||
}else{
|
}else{
|
||||||
$err->log("bro","export_data_failed");
|
$err->log("bro","export_data_failed");
|
||||||
|
|
|
@ -91,6 +91,7 @@ class m_ftp {
|
||||||
if ($db->num_rows()) {
|
if ($db->num_rows()) {
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
// On passe /var/alternc/html/u/user
|
// On passe /var/alternc/html/u/user
|
||||||
|
// FIXME: utiliser getuserpath()
|
||||||
$tr=preg_match("/^\/var\/alternc\/html\/.\/[^\/]*\/(.*)$/", $db->f("homedir"),$match); /* " */
|
$tr=preg_match("/^\/var\/alternc\/html\/.\/[^\/]*\/(.*)$/", $db->f("homedir"),$match); /* " */
|
||||||
$r[]=array(
|
$r[]=array(
|
||||||
"id"=>$db->f("id"),
|
"id"=>$db->f("id"),
|
||||||
|
@ -119,6 +120,7 @@ class m_ftp {
|
||||||
$db->query("SELECT id, name, homedir FROM ftpusers WHERE uid='$cuid' AND id='$id';");
|
$db->query("SELECT id, name, homedir FROM ftpusers WHERE uid='$cuid' AND id='$id';");
|
||||||
if ($db->num_rows()) {
|
if ($db->num_rows()) {
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
|
// FIXME: utiliser getuserpath
|
||||||
$tr=preg_match("/^\/var\/alternc\/html\/.\/[^\/]*\/(.*)$/", $db->f("homedir"),$match);
|
$tr=preg_match("/^\/var\/alternc\/html\/.\/[^\/]*\/(.*)$/", $db->f("homedir"),$match);
|
||||||
$lg=explode("_",$db->f("name"));
|
$lg=explode("_",$db->f("name"));
|
||||||
if ((!is_array($lg)) || (count($lg)!=2)) {
|
if ((!is_array($lg)) || (count($lg)!=2)) {
|
||||||
|
@ -207,7 +209,7 @@ class m_ftp {
|
||||||
$err->raise("ftp",4);
|
$err->raise("ftp",4);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$absolute="/var/alternc/html/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/$dir";
|
$absolute=getuserpath()."/$dir";
|
||||||
if (!file_exists($absolute)) {
|
if (!file_exists($absolute)) {
|
||||||
system("/bin/mkdir -p $absolute");
|
system("/bin/mkdir -p $absolute");
|
||||||
}
|
}
|
||||||
|
@ -224,9 +226,9 @@ class m_ftp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$encrypted_password = crypt($pass,strrev(microtime(true)));
|
$encrypted_password = crypt($pass,strrev(microtime(true)));
|
||||||
$db->query("UPDATE ftpusers SET name='".$prefixe.$login."', password='', encrypted_password='$encrypted_password', homedir='/var/alternc/html/$l/$lo/$dir', uid='$cuid' WHERE id='$id';");
|
$db->query("UPDATE ftpusers SET name='".$prefixe.$login."', password='', encrypted_password='$encrypted_password', homedir='$absolute', uid='$cuid' WHERE id='$id';");
|
||||||
} else {
|
} else {
|
||||||
$db->query("UPDATE ftpusers SET name='".$prefixe.$login."', homedir='/var/alternc/html/$l/$lo/$dir', uid='$cuid' WHERE id='$id';");
|
$db->query("UPDATE ftpusers SET name='".$prefixe.$login."', homedir='$absolute', uid='$cuid' WHERE id='$id';");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -283,7 +285,7 @@ class m_ftp {
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
$lo=$db->f("login");
|
$lo=$db->f("login");
|
||||||
$l=substr($lo,0,1);
|
$l=substr($lo,0,1);
|
||||||
$absolute="/var/alternc/html/".substr($mem->user["login"],0,1)."/".$mem->user["login"]."/$dir";
|
$absolute=getuserpath()."/$dir";
|
||||||
if (!file_exists($absolute)) {
|
if (!file_exists($absolute)) {
|
||||||
system("/bin/mkdir -p $absolute");
|
system("/bin/mkdir -p $absolute");
|
||||||
}
|
}
|
||||||
|
@ -301,7 +303,7 @@ class m_ftp {
|
||||||
|
|
||||||
if ($quota->cancreate("ftp")) {
|
if ($quota->cancreate("ftp")) {
|
||||||
$encrypted_password = crypt($pass,strrev(microtime(true)));
|
$encrypted_password = crypt($pass,strrev(microtime(true)));
|
||||||
$db->query("INSERT INTO ftpusers (name,password, encrypted_password,homedir,uid) VALUES ('".$prefixe.$login."', '', '$encrypted_password', '/var/alternc/html/$l/$lo/$dir', '$cuid')");
|
$db->query("INSERT INTO ftpusers (name,password, encrypted_password,homedir,uid) VALUES ('".$prefixe.$login."', '', '$encrypted_password', '$absolute', '$cuid')");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$err->raise("ftp",5);
|
$err->raise("ftp",5);
|
||||||
|
@ -320,7 +322,7 @@ class m_ftp {
|
||||||
$lo=$mem->user["login"];
|
$lo=$mem->user["login"];
|
||||||
$l=substr($lo,0,1);
|
$l=substr($lo,0,1);
|
||||||
if (substr($dir,0,1)=="/") $dir=substr($dir,1);
|
if (substr($dir,0,1)=="/") $dir=substr($dir,1);
|
||||||
$db->query("SELECT id FROM ftpusers WHERE homedir='/var/alternc/html/$l/$lo/$dir';");
|
$db->query("SELECT id FROM ftpusers WHERE homedir='".getuserpath()."/$dir';");
|
||||||
if ($db->num_rows()) {
|
if ($db->num_rows()) {
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
return $db->f("id");
|
return $db->f("id");
|
||||||
|
|
|
@ -184,7 +184,7 @@ class m_mysql {
|
||||||
*/
|
*/
|
||||||
function get_mysql_details($dbn) {
|
function get_mysql_details($dbn) {
|
||||||
global $db,$err,$bro,$mem,$cuid;
|
global $db,$err,$bro,$mem,$cuid;
|
||||||
$root="/var/alternc/html/".substr($mem->user["login"],0,1)."/".$mem->user["login"];
|
$root=getuserpath();
|
||||||
$err->log("mysql","get_mysql_details");
|
$err->log("mysql","get_mysql_details");
|
||||||
$dbname=$mem->user["login"].($dbn?"_":"").$dbn;
|
$dbname=$mem->user["login"].($dbn?"_":"").$dbn;
|
||||||
$size=$this->get_db_size($dbname);
|
$size=$this->get_db_size($dbname);
|
||||||
|
|
|
@ -140,6 +140,7 @@ class m_sta2 {
|
||||||
if ($db->num_rows()) {
|
if ($db->num_rows()) {
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
// We skip /var/alternc/html/u/user
|
// We skip /var/alternc/html/u/user
|
||||||
|
// FIXME: utiliser ALTERNC_HTML au lieu de /var/alternc/html/
|
||||||
preg_match("/^\/var\/alternc\/html\/.\/[^\/]*\/(.*)/", $db->f("folder"),$match);
|
preg_match("/^\/var\/alternc\/html\/.\/[^\/]*\/(.*)/", $db->f("folder"),$match);
|
||||||
$r[]=array(
|
$r[]=array(
|
||||||
"id"=>$db->f("id"),
|
"id"=>$db->f("id"),
|
||||||
|
@ -173,6 +174,7 @@ class m_sta2 {
|
||||||
if ($db->num_rows()) {
|
if ($db->num_rows()) {
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
// We skip /var/alternc/html/u/user
|
// We skip /var/alternc/html/u/user
|
||||||
|
// FIXME: utiliser ALTERNC_HTML au lieu de /var/alternc/html/
|
||||||
preg_match("/^\/var\/alternc\/html\/.\/[^\/]*\/(.*)/", $db->f("folder"),$match);
|
preg_match("/^\/var\/alternc\/html\/.\/[^\/]*\/(.*)/", $db->f("folder"),$match);
|
||||||
return array(
|
return array(
|
||||||
"id"=>$db->f("id"),
|
"id"=>$db->f("id"),
|
||||||
|
@ -209,9 +211,7 @@ class m_sta2 {
|
||||||
if (substr($folder,0,1)=="/") {
|
if (substr($folder,0,1)=="/") {
|
||||||
$folder=substr($folder,1);
|
$folder=substr($folder,1);
|
||||||
}
|
}
|
||||||
$lo=$mem->user["login"];
|
$db->query("UPDATE stats2 SET folder='".getuserpath()."/$folder', mid='$cuid' WHERE id='$id';");
|
||||||
$l=substr($lo,0,1);
|
|
||||||
$db->query("UPDATE stats2 SET folder='/var/alternc/html/$l/$lo/$folder', mid='$cuid' WHERE id='$id';");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,10 +254,8 @@ class m_sta2 {
|
||||||
if (substr($dir,0,1)=="/") {
|
if (substr($dir,0,1)=="/") {
|
||||||
$dir=substr($dir,1);
|
$dir=substr($dir,1);
|
||||||
}
|
}
|
||||||
$lo=$mem->user["login"];
|
|
||||||
$l=substr($lo,0,1);
|
|
||||||
if ($quota->cancreate("sta2")) {
|
if ($quota->cancreate("sta2")) {
|
||||||
$db->query("INSERT INTO stats2 (hostname,folder,mid) VALUES ('$hostname','/var/alternc/html/$l/$lo/$dir','$cuid')");
|
$db->query("INSERT INTO stats2 (hostname,folder,mid) VALUES ('$hostname','".getuserpath()."/$dir','$cuid')");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$err->raise("sta2",1);
|
$err->raise("sta2",1);
|
||||||
|
|
Loading…
Reference in New Issue