[enh] WIP bureau classes documentation
This commit is contained in:
parent
7b7a87515a
commit
67081465c0
|
@ -50,7 +50,7 @@ if (getenv("REMOTE_ADDR")!="127.0.0.1") {
|
||||||
Merci de revenir plus tard.";
|
Merci de revenir plus tard.";
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
/* */
|
|
||||||
|
|
||||||
/* Toutes les pages du bureau passent ici. On utilise une s<EFBFBD>maphore pour
|
/* Toutes les pages du bureau passent ici. On utilise une s<EFBFBD>maphore pour
|
||||||
s'assurer que personne ne pourra acc<EFBFBD>der <EFBFBD> 2 pages du bureau en m<EFBFBD>me temps.
|
s'assurer que personne ne pourra acc<EFBFBD>der <EFBFBD> 2 pages du bureau en m<EFBFBD>me temps.
|
||||||
|
@ -67,7 +67,7 @@ function alternc_shutdown() {
|
||||||
register_shutdown_function("alternc_shutdown");
|
register_shutdown_function("alternc_shutdown");
|
||||||
// 4. Acquire the semaphore : with that process,
|
// 4. Acquire the semaphore : with that process,
|
||||||
sem_acquire( $alternc_sem );
|
sem_acquire( $alternc_sem );
|
||||||
/* */
|
|
||||||
|
|
||||||
if (ini_get("safe_mode")) {
|
if (ini_get("safe_mode")) {
|
||||||
echo "SAFE MODE IS ENABLED for the web panel ! It's a bug in your php or apache configuration, please fix it !!";
|
echo "SAFE MODE IS ENABLED for the web panel ! It's a bug in your php or apache configuration, please fix it !!";
|
||||||
|
|
|
@ -172,7 +172,7 @@ class DB_Sql {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($debug_alternc)) {
|
if (isset($debug_alternc)) {
|
||||||
$debug_alternc->add("SQL Query : (".substr($debug_chrono_start,0,5)." ms)\t $Query_String");
|
$debug_alternc->add("SQL Query : (".substr($debug_chrono_start,0,5)." ms) $Query_String");
|
||||||
$debug_alternc->nb_sql_query++;
|
$debug_alternc->nb_sql_query++;
|
||||||
$debug_alternc->tps_sql_query += $debug_chrono_start;
|
$debug_alternc->tps_sql_query += $debug_chrono_start;
|
||||||
}
|
}
|
||||||
|
|
|
@ -476,7 +476,7 @@ function ssla($str) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Hashe un mot de passe en clair en MD5 avec un salt al<EFBFBD>atoire
|
/** Hashe un mot de passe en clair en MD5 avec un salt al<EFBFBD>atoire
|
||||||
* @param string $pass Mot de passe <EFBFBD> crypter (max 32 caract<EFBFBD>res)
|
* @param string $pass Mot de passe <EFBFBD> crypter (max 32 caract<EFBFBD>res)
|
||||||
* @return string Retourne le mot de passe crypt<EFBFBD>
|
* @return string Retourne le mot de passe crypt<EFBFBD>
|
||||||
|
@ -504,7 +504,7 @@ function split_mysql_database_name($dbname) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Echappe les caract<EFBFBD>res pouvant perturber un flux XML standard :
|
/** Echappe les caract<EFBFBD>res pouvant perturber un flux XML standard :
|
||||||
* @param string $string Chaine de caract<EFBFBD>re <EFBFBD> encoder en valeur xml.
|
* @param string $string Chaine de caract<EFBFBD>re <EFBFBD> encoder en valeur xml.
|
||||||
* @return string Retourne la cha<EFBFBD>ne modifi<EFBFBD>e si besoin.
|
* @return string Retourne la cha<EFBFBD>ne modifi<EFBFBD>e si besoin.
|
||||||
|
@ -514,7 +514,7 @@ function xml_entities($string) {
|
||||||
return str_replace("<","<",str_replace(">",">",str_replace("&","&",$string)));
|
return str_replace("<","<",str_replace(">",">",str_replace("&","&",$string)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Converti un nombre de mois en une chaine plus lisible
|
/** Converti un nombre de mois en une chaine plus lisible
|
||||||
* @param integer $months Nombre de mois
|
* @param integer $months Nombre de mois
|
||||||
* @return string Cha<EFBFBD>ne repr<EFBFBD>sentant le nombre de mois
|
* @return string Cha<EFBFBD>ne repr<EFBFBD>sentant le nombre de mois
|
||||||
|
@ -529,7 +529,7 @@ function pretty_months($months) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Fabrique un drop-down pour les dur<EFBFBD>es de comptes
|
/** Fabrique un drop-down pour les dur<EFBFBD>es de comptes
|
||||||
* @name string $name Nom pour le composasnt
|
* @name string $name Nom pour le composasnt
|
||||||
* @selected number Option selection<EFBFBD>e du composant
|
* @selected number Option selection<EFBFBD>e du composant
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class m_action {
|
class m_action {
|
||||||
/* --------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -222,7 +222,7 @@ class m_action {
|
||||||
* This seems to be unused ?
|
* This seems to be unused ?
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function get_old() {
|
function get_old() {
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage the AlternC's account administration (create/edit/delete)
|
* Manage the AlternC's account administration (create/edit/delete)
|
||||||
|
@ -31,12 +31,12 @@
|
||||||
class m_admin {
|
class m_admin {
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** $enabled tells if the logged user is super-admin or not
|
/** $enabled tells if the logged user is super-admin or not
|
||||||
*/
|
*/
|
||||||
var $enabled=0;
|
var $enabled=0;
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** List of the controls made for each TLD
|
/** List of the controls made for each TLD
|
||||||
*
|
*
|
||||||
* $tldmode is used by the administration panel, while choosing
|
* $tldmode is used by the administration panel, while choosing
|
||||||
|
@ -505,7 +505,7 @@ class m_admin {
|
||||||
* When the admin want to delegate a subdomain to an account
|
* When the admin want to delegate a subdomain to an account
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global m_dom $dom
|
* @global m_dom $dom
|
||||||
* @global m_mem $mem
|
* @global m_mem $mem
|
||||||
* @global int $cuid
|
* @global int $cuid
|
||||||
|
@ -541,7 +541,7 @@ class m_admin {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Creates a new hosted account
|
/** Creates a new hosted account
|
||||||
*
|
*
|
||||||
* Creates a new hosted account (in the tables <code>membres</code>
|
* Creates a new hosted account (in the tables <code>membres</code>
|
||||||
|
@ -549,7 +549,7 @@ class m_admin {
|
||||||
* the account $mid is not super-admin.
|
* the account $mid is not super-admin.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global m_quota $quota
|
* @global m_quota $quota
|
||||||
* @global array $classes
|
* @global array $classes
|
||||||
* @global int $cuid
|
* @global int $cuid
|
||||||
|
@ -668,7 +668,7 @@ class m_admin {
|
||||||
* AlternC's standard function called when a user is created
|
* AlternC's standard function called when a user is created
|
||||||
* This sends an email if configured through the interface.
|
* This sends an email if configured through the interface.
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global int $cuid
|
* @global int $cuid
|
||||||
* @global string $L_FQDN
|
* @global string $L_FQDN
|
||||||
* @global string $L_HOSTING
|
* @global string $L_HOSTING
|
||||||
|
@ -731,7 +731,7 @@ EOF;
|
||||||
* and <code>local</code>). Prevents any manipulation of the account if
|
* and <code>local</code>). Prevents any manipulation of the account if
|
||||||
* the account $mid is not super-admin.
|
* the account $mid is not super-admin.
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global int $cuid
|
* @global int $cuid
|
||||||
* @global m_quota $quota
|
* @global m_quota $quota
|
||||||
|
@ -790,7 +790,7 @@ EOF;
|
||||||
*
|
*
|
||||||
* Lock an account and prevent the user to access its account.
|
* Lock an account and prevent the user to access its account.
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @param int $uid The uid number of the account
|
* @param int $uid The uid number of the account
|
||||||
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
||||||
|
@ -819,7 +819,7 @@ EOF;
|
||||||
* UnLock an account and prevent the user to access its account.
|
* UnLock an account and prevent the user to access its account.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @param int $uid The uid number of the account
|
* @param int $uid The uid number of the account
|
||||||
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
||||||
|
@ -842,12 +842,12 @@ EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Deletes an account
|
/** Deletes an account
|
||||||
* Deletes the specified account. Prevents any manipulation of the account if
|
* Deletes the specified account. Prevents any manipulation of the account if
|
||||||
* the account $mid is not super-admin.
|
* the account $mid is not super-admin.
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global m_quota $quota
|
* @global m_quota $quota
|
||||||
* @global array $classes
|
* @global array $classes
|
||||||
* @global int $cuid
|
* @global int $cuid
|
||||||
|
@ -901,7 +901,7 @@ EOF;
|
||||||
*
|
*
|
||||||
* Renew an account for its duration
|
* Renew an account for its duration
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @param int $uid The uid number of the account
|
* @param int $uid The uid number of the account
|
||||||
* @param int $periods The new duration, in months, of the account
|
* @param int $periods The new duration, in months, of the account
|
||||||
|
@ -927,7 +927,7 @@ EOF;
|
||||||
/**
|
/**
|
||||||
* Update the duration information for an account
|
* Update the duration information for an account
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @param int $uid The uid number of the account
|
* @param int $uid The uid number of the account
|
||||||
* @param int $duration The new duration, in months, of the account
|
* @param int $duration The new duration, in months, of the account
|
||||||
|
@ -965,7 +965,7 @@ EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/**
|
/**
|
||||||
* Get the expiry status for an account
|
* Get the expiry status for an account
|
||||||
*
|
*
|
||||||
|
@ -1016,7 +1016,7 @@ EOF;
|
||||||
/**
|
/**
|
||||||
* Turns a common account into a super-admin account
|
* Turns a common account into a super-admin account
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @param int $uid The uid number of the account
|
* @param int $uid The uid number of the account
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
@ -1040,7 +1040,7 @@ EOF;
|
||||||
/**
|
/**
|
||||||
* Turns a super-admin account into a common account
|
* Turns a super-admin account into a common account
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @param int $uid The uid number of the account
|
* @param int $uid The uid number of the account
|
||||||
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
||||||
|
@ -1208,7 +1208,7 @@ EOF;
|
||||||
* from its account
|
* from its account
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $domain Domain name to lock / unlock
|
* @param string $domain Domain name to lock / unlock
|
||||||
* @return boolean TRUE if the domain has been locked/unlocked or FALSE if it does not exist.
|
* @return boolean TRUE if the domain has been locked/unlocked or FALSE if it does not exist.
|
||||||
*/
|
*/
|
||||||
|
@ -1228,7 +1228,7 @@ EOF;
|
||||||
* Add a new TLD to the list of the authorized TLDs
|
* Add a new TLD to the list of the authorized TLDs
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $tld top-level domain to add (org, com...)
|
* @param string $tld top-level domain to add (org, com...)
|
||||||
* @return boolean TRUE if the tld has been successfully added, FALSE if not.
|
* @return boolean TRUE if the tld has been successfully added, FALSE if not.
|
||||||
*/
|
*/
|
||||||
|
@ -1263,7 +1263,7 @@ EOF;
|
||||||
* on this TLD
|
* on this TLD
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $tld The TLD you want to delete
|
* @param string $tld The TLD you want to delete
|
||||||
* @return boolean returns true if the TLD has been deleted, or
|
* @return boolean returns true if the TLD has been deleted, or
|
||||||
* false if an error occured.
|
* false if an error occured.
|
||||||
|
@ -1280,7 +1280,7 @@ EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Add a TLD to the list of the authorized TLDs during the installation
|
/** Add a TLD to the list of the authorized TLDs during the installation
|
||||||
*
|
*
|
||||||
* <b>Note: </b> If you check in the whois, be sure that
|
* <b>Note: </b> If you check in the whois, be sure that
|
||||||
|
@ -1288,7 +1288,7 @@ EOF;
|
||||||
* domain!
|
* domain!
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $tld string TLD we want to authorize
|
* @param string $tld string TLD we want to authorize
|
||||||
* @param boolean $mode Controls to make on this TLD.
|
* @param boolean $mode Controls to make on this TLD.
|
||||||
* @return boolean TRUE if the TLD has been successfully
|
* @return boolean TRUE if the TLD has been successfully
|
||||||
|
@ -1319,7 +1319,7 @@ EOF;
|
||||||
* Modify a TLD of the list of the authorized TLDs
|
* Modify a TLD of the list of the authorized TLDs
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $tld TLD we want to modify
|
* @param string $tld TLD we want to modify
|
||||||
* @param int $mode Controls to make on this TLD.
|
* @param int $mode Controls to make on this TLD.
|
||||||
* @return boolean TRUE if the TLD has been successfully
|
* @return boolean TRUE if the TLD has been successfully
|
||||||
|
@ -1371,16 +1371,6 @@ EOF;
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
$tmp1[$db->Record["name"]]=$db->Record;
|
$tmp1[$db->Record["name"]]=$db->Record;
|
||||||
}
|
}
|
||||||
/* * /
|
|
||||||
foreach($classes as $c) {
|
|
||||||
if (method_exists($GLOBALS[$c],"alternc_password_policy")) {
|
|
||||||
$res=$GLOBALS[$c]->alternc_password_policy(); // returns an array
|
|
||||||
foreach($res as $k=>$v) {
|
|
||||||
$tmp2[$k]=$v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* */
|
|
||||||
$tmp3=$hooks->invoke("alternc_password_policy");
|
$tmp3=$hooks->invoke("alternc_password_policy");
|
||||||
foreach ($tmp3 as $v) {
|
foreach ($tmp3 as $v) {
|
||||||
foreach ($v as $l=>$m) {
|
foreach ($v as $l=>$m) {
|
||||||
|
@ -1441,7 +1431,7 @@ EOF;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $policy Name of the policy to check for
|
* @param string $policy Name of the policy to check for
|
||||||
* @param string $login The login that will be set
|
* @param string $login The login that will be set
|
||||||
* @param string $password The password we have to check
|
* @param string $password The password we have to check
|
||||||
|
|
|
@ -355,7 +355,7 @@ class m_authip {
|
||||||
* affectationt ip<=>ressource dont l'id est en parametre
|
* affectationt ip<=>ressource dont l'id est en parametre
|
||||||
*
|
*
|
||||||
* @global m_hooks $hooks
|
* @global m_hooks $hooks
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $function Nom de la fonction a rechercher et appeller dans les classes
|
* @param string $function Nom de la fonction a rechercher et appeller dans les classes
|
||||||
* @param integer $affectation_id Id de l'affectation correspondante
|
* @param integer $affectation_id Id de l'affectation correspondante
|
||||||
* @return boolean Retourne TRUE
|
* @return boolean Retourne TRUE
|
||||||
|
|
|
@ -192,7 +192,7 @@ class m_bro {
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global int $cuid
|
* @global int $cuid
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $dir Dossier relatif au dossier racine du compte du membre courant
|
* @param string $dir Dossier relatif au dossier racine du compte du membre courant
|
||||||
* @param boolean $showdirsize
|
* @param boolean $showdirsize
|
||||||
* @return array Le tableau contenant les fichiers de $dir, et
|
* @return array Le tableau contenant les fichiers de $dir, et
|
||||||
|
@ -387,7 +387,7 @@ class m_bro {
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global int $cuid
|
* @global int $cuid
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $dir Dossier dans lequel on veut crer un sous-dossier
|
* @param string $dir Dossier dans lequel on veut crer un sous-dossier
|
||||||
* @param string $file Nom du dossier à créer
|
* @param string $file Nom du dossier à créer
|
||||||
* @return boolean TRUE si le dossier a été créé, FALSE si une erreur s'est produite.
|
* @return boolean TRUE si le dossier a été créé, FALSE si une erreur s'est produite.
|
||||||
|
@ -415,7 +415,7 @@ class m_bro {
|
||||||
* Crée un fichier vide dans un dossier
|
* Crée un fichier vide dans un dossier
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global int $cuid
|
* @global int $cuid
|
||||||
* @param string $dir Dossier dans lequel on veut crer un sous-dossier
|
* @param string $dir Dossier dans lequel on veut crer un sous-dossier
|
||||||
* @param string $file Nom du dossier à créer
|
* @param string $file Nom du dossier à créer
|
||||||
|
@ -443,7 +443,7 @@ class m_bro {
|
||||||
/**
|
/**
|
||||||
* Efface les fichiers du tableau $file_list dans le dossier $R
|
* Efface les fichiers du tableau $file_list dans le dossier $R
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global m_mem $mem
|
* @global m_mem $mem
|
||||||
* @param array $file_list Liste des fichiers effacer.
|
* @param array $file_list Liste des fichiers effacer.
|
||||||
* @param string $R Dossier dans lequel on efface les fichiers
|
* @param string $R Dossier dans lequel on efface les fichiers
|
||||||
|
@ -470,7 +470,7 @@ class m_bro {
|
||||||
/**
|
/**
|
||||||
* Renomme les fichier de $old du dossier $R en $new
|
* Renomme les fichier de $old du dossier $R en $new
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $R Dossier dans lequel se trouve les fichiers renommer.
|
* @param string $R Dossier dans lequel se trouve les fichiers renommer.
|
||||||
* @param array $old Ancien nom des fichiers
|
* @param array $old Ancien nom des fichiers
|
||||||
* @param array $new Nouveau nom des fichiers
|
* @param array $new Nouveau nom des fichiers
|
||||||
|
@ -504,7 +504,7 @@ class m_bro {
|
||||||
/**
|
/**
|
||||||
* Déplace les fichier de $d du dossier $old vers $new
|
* Déplace les fichier de $d du dossier $old vers $new
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param array $d Liste des fichiers du dossier $old dplacer
|
* @param array $d Liste des fichiers du dossier $old dplacer
|
||||||
* @param string $old Dossier dans lequel se trouve les fichiers dplacer.
|
* @param string $old Dossier dans lequel se trouve les fichiers dplacer.
|
||||||
* @param string $new Dossier vers lequel seront dplacs les fichiers.
|
* @param string $new Dossier vers lequel seront dplacs les fichiers.
|
||||||
|
@ -545,7 +545,7 @@ class m_bro {
|
||||||
/**
|
/**
|
||||||
* Change les droits d'acces aux fichier de $d du dossier $R en $p
|
* Change les droits d'acces aux fichier de $d du dossier $R en $p
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $R Dossier dans lequel se trouve les fichiers renommer.
|
* @param string $R Dossier dans lequel se trouve les fichiers renommer.
|
||||||
* @param boolean $verbose Shall we 'echo' what we did ?
|
* @param boolean $verbose Shall we 'echo' what we did ?
|
||||||
* @return boolean TRUE Si les fichiers ont t renomms, FALSE si une erreur s'est produite.
|
* @return boolean TRUE Si les fichiers ont t renomms, FALSE si une erreur s'est produite.
|
||||||
|
@ -587,7 +587,7 @@ class m_bro {
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @global array $_FILES
|
* @global array $_FILES
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global int $cuid
|
* @global int $cuid
|
||||||
* @global m_action $action
|
* @global m_action $action
|
||||||
* @param string $R Dossier dans lequel on upload le fichier
|
* @param string $R Dossier dans lequel on upload le fichier
|
||||||
|
@ -640,7 +640,7 @@ class m_bro {
|
||||||
/**
|
/**
|
||||||
* Extract an archive by using GNU and non-GNU tools
|
* Extract an archive by using GNU and non-GNU tools
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global int $cuid
|
* @global int $cuid
|
||||||
* @global m_mem $mem
|
* @global m_mem $mem
|
||||||
* @global m_action $action
|
* @global m_action $action
|
||||||
|
@ -692,7 +692,7 @@ class m_bro {
|
||||||
/**
|
/**
|
||||||
* Copy many files from point A to point B
|
* Copy many files from point A to point B
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param array $d List of files to move
|
* @param array $d List of files to move
|
||||||
* @param string $old
|
* @param string $old
|
||||||
* @param string $new
|
* @param string $new
|
||||||
|
@ -731,7 +731,7 @@ class m_bro {
|
||||||
*
|
*
|
||||||
* Note that we assume that the inputs have been convertabsolute()'d
|
* Note that we assume that the inputs have been convertabsolute()'d
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $src Path or URL
|
* @param string $src Path or URL
|
||||||
* @param string $dest Absolute path inside the users directory
|
* @param string $dest Absolute path inside the users directory
|
||||||
* @return boolean false on error
|
* @return boolean false on error
|
||||||
|
@ -785,7 +785,7 @@ class m_bro {
|
||||||
* Affiche le contenu du fichier $file dans le dossier $R. Le contenu
|
* Affiche le contenu du fichier $file dans le dossier $R. Le contenu
|
||||||
* du fichier est reformat pour pouvoir entrer dans un champs TextArea
|
* du fichier est reformat pour pouvoir entrer dans un champs TextArea
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $R Dossier dans lequel on cherche le fichier
|
* @param string $R Dossier dans lequel on cherche le fichier
|
||||||
* @param string $file Fichier dont on souhaite obtenir le contenu.
|
* @param string $file Fichier dont on souhaite obtenir le contenu.
|
||||||
* @return string|false TRUE si le fichier a bien été mis sur
|
* @return string|false TRUE si le fichier a bien été mis sur
|
||||||
|
@ -868,7 +868,7 @@ class m_bro {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @global m_mem $mem
|
* @global m_mem $mem
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $dir
|
* @param string $dir
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return null|boolean
|
* @return null|boolean
|
||||||
|
@ -939,7 +939,7 @@ class m_bro {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $dir
|
* @param string $dir
|
||||||
* @param string $file
|
* @param string $file
|
||||||
*/
|
*/
|
||||||
|
@ -956,7 +956,7 @@ class m_bro {
|
||||||
/**
|
/**
|
||||||
* Echoes the content of the file $file located in directory $R
|
* Echoes the content of the file $file located in directory $R
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $R
|
* @param string $R
|
||||||
* @param string $file
|
* @param string $file
|
||||||
* @return null|false
|
* @return null|false
|
||||||
|
@ -981,7 +981,7 @@ class m_bro {
|
||||||
* le contenu est issu d'un textarea, et ne DOIT PAS contenir de \ ajouts
|
* le contenu est issu d'un textarea, et ne DOIT PAS contenir de \ ajouts
|
||||||
* automatiquement par addslashes
|
* automatiquement par addslashes
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $file Nom du fichier sauver. S'il existe déjà, il sera
|
* @param string $file Nom du fichier sauver. S'il existe déjà, il sera
|
||||||
* écrasé sans confirmation.
|
* écrasé sans confirmation.
|
||||||
* @param string $R Dossier dans lequel on modifie le fichier
|
* @param string $R Dossier dans lequel on modifie le fichier
|
||||||
|
@ -1124,7 +1124,7 @@ class m_bro {
|
||||||
* Produit en sorti un tableau formatté ( pour le moment) en HTML
|
* Produit en sorti un tableau formatté ( pour le moment) en HTML
|
||||||
*
|
*
|
||||||
* @global m_mysql $db
|
* @global m_mysql $db
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function alternc_export_conf() {
|
function alternc_export_conf() {
|
||||||
|
@ -1151,7 +1151,7 @@ class m_bro {
|
||||||
* Function d'exportation des données appelé par la classe m_export via un hooks
|
* Function d'exportation des données appelé par la classe m_export via un hooks
|
||||||
*
|
*
|
||||||
* @global m_mem $mem
|
* @global m_mem $mem
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $dir Le chemin destination du tarball produit
|
* @param string $dir Le chemin destination du tarball produit
|
||||||
* @return boolean|null
|
* @return boolean|null
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,12 +29,18 @@
|
||||||
class m_cron {
|
class m_cron {
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** Constructor
|
/** Constructor
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function m_cron() {
|
function m_cron() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function schedule() {
|
function schedule() {
|
||||||
return Array(
|
return Array(
|
||||||
Array('unit'=>1440, 'name'=>_("Daily")),
|
Array('unit'=>1440, 'name'=>_("Daily")),
|
||||||
|
@ -44,10 +50,16 @@ class m_cron {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** List the crontab for the current user.
|
/** List the crontab for the current user.
|
||||||
* @return array an hash for each crontab.
|
* @return array an hash for each crontab.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function lst_cron() {
|
function lst_cron() {
|
||||||
global $cuid,$db,$err;
|
global $cuid,$db,$err;
|
||||||
$err->log("cron","lst_cron");
|
$err->log("cron","lst_cron");
|
||||||
|
@ -67,6 +79,10 @@ class m_cron {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
$obj = array(
|
$obj = array(
|
||||||
'title' => _("Scheduled tasks"),
|
'title' => _("Scheduled tasks"),
|
||||||
|
@ -78,11 +94,15 @@ class m_cron {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** update the crontab
|
/** update the crontab
|
||||||
* @param $arr array the crontab information, including its ID
|
* @param $arr array the crontab information, including its ID
|
||||||
* @return boolean TRUE if the crontab has been edited
|
* @return boolean TRUE if the crontab has been edited
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $arr
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function update($arr) {
|
function update($arr) {
|
||||||
$ok=true;
|
$ok=true;
|
||||||
foreach ($arr as $a) {
|
foreach ($arr as $a) {
|
||||||
|
@ -96,11 +116,18 @@ class m_cron {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** delete a crontab
|
/** delete a crontab
|
||||||
* @param $id the id of the crontab to delete
|
* @param $id the id of the crontab to delete
|
||||||
* @return boolean TRUE if the crontab has been deleted
|
* @return boolean TRUE if the crontab has been deleted
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $id
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function delete_one($id) {
|
function delete_one($id) {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("cron","delete_one");
|
$err->log("cron","delete_one");
|
||||||
|
@ -108,10 +135,23 @@ class m_cron {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** update a crontab,
|
/** update a crontab,
|
||||||
* @return boolean TRUE if the crontab has been edited
|
* @return boolean TRUE if the crontab has been edited
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_quota $quota
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $url
|
||||||
|
* @param type $user
|
||||||
|
* @param type $password
|
||||||
|
* @param type $email
|
||||||
|
* @param type $schedule
|
||||||
|
* @param type $id
|
||||||
|
* @return boolean|string
|
||||||
|
*/
|
||||||
private function _update_one($url, $user, $password, $email, $schedule, $id=null) {
|
private function _update_one($url, $user, $password, $email, $schedule, $id=null) {
|
||||||
global $db,$err,$quota,$cuid;
|
global $db,$err,$quota,$cuid;
|
||||||
$err->log("cron","update_one");
|
$err->log("cron","update_one");
|
||||||
|
@ -159,11 +199,15 @@ class m_cron {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** validate a crontab schedule
|
/** validate a crontab schedule
|
||||||
* @param $s array schedule paramters
|
* @param $s array schedule paramters
|
||||||
* @return boolean TRUE if the schedule is valid
|
* @return boolean TRUE if the schedule is valid
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $s
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function valid_schedule($s) {
|
function valid_schedule($s) {
|
||||||
$s2 = intval($s);
|
$s2 = intval($s);
|
||||||
if ($s2 != $s) return false;
|
if ($s2 != $s) return false;
|
||||||
|
@ -174,9 +218,15 @@ class m_cron {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** hook for quota computation
|
/** hook for quota computation
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function hook_quota_get() {
|
function hook_quota_get() {
|
||||||
global $cuid,$db,$err;
|
global $cuid,$db,$err;
|
||||||
$err->log("cron","alternc_get_quota");
|
$err->log("cron","alternc_get_quota");
|
||||||
|
|
|
@ -1,44 +1,46 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class m_crypto
|
/**
|
||||||
{
|
*
|
||||||
function encrypt($sValue, $sSecretKey)
|
*/
|
||||||
{
|
class m_crypto {
|
||||||
return rtrim(
|
|
||||||
base64_encode(
|
|
||||||
mcrypt_encrypt(
|
|
||||||
MCRYPT_RIJNDAEL_256,
|
|
||||||
$sSecretKey, $sValue,
|
|
||||||
MCRYPT_MODE_ECB,
|
|
||||||
mcrypt_create_iv(
|
|
||||||
mcrypt_get_iv_size(
|
|
||||||
MCRYPT_RIJNDAEL_256,
|
|
||||||
MCRYPT_MODE_ECB
|
|
||||||
),
|
|
||||||
MCRYPT_RAND
|
|
||||||
)
|
|
||||||
)
|
|
||||||
), "\0"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function decrypt($sValue, $sSecretKey)
|
/**
|
||||||
{
|
*
|
||||||
return rtrim(
|
* @param type $sValue
|
||||||
mcrypt_decrypt(
|
* @param type $sSecretKey
|
||||||
MCRYPT_RIJNDAEL_256,
|
* @return type
|
||||||
$sSecretKey,
|
*/
|
||||||
base64_decode($sValue),
|
function encrypt($sValue, $sSecretKey) {
|
||||||
MCRYPT_MODE_ECB,
|
return rtrim(
|
||||||
mcrypt_create_iv(
|
base64_encode(
|
||||||
mcrypt_get_iv_size(
|
mcrypt_encrypt(
|
||||||
MCRYPT_RIJNDAEL_256,
|
MCRYPT_RIJNDAEL_256, $sSecretKey, $sValue, MCRYPT_MODE_ECB, mcrypt_create_iv(
|
||||||
MCRYPT_MODE_ECB
|
mcrypt_get_iv_size(
|
||||||
),
|
MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB
|
||||||
MCRYPT_RAND
|
), MCRYPT_RAND
|
||||||
)
|
)
|
||||||
), "\0"
|
)
|
||||||
);
|
), "\0"
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $sValue
|
||||||
|
* @param type $sSecretKey
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
|
function decrypt($sValue, $sSecretKey) {
|
||||||
|
return rtrim(
|
||||||
|
mcrypt_decrypt(
|
||||||
|
MCRYPT_RIJNDAEL_256, $sSecretKey, base64_decode($sValue), MCRYPT_MODE_ECB, mcrypt_create_iv(
|
||||||
|
mcrypt_get_iv_size(
|
||||||
|
MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB
|
||||||
|
), MCRYPT_RAND
|
||||||
|
)
|
||||||
|
), "\0"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,94 +1,120 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License (GPL)
|
modify it under the terms of the GNU General Public License (GPL)
|
||||||
as published by the Free Software Foundation; either version 2
|
as published by the Free Software Foundation; either version 2
|
||||||
of the License, or (at your option) any later version.
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Original Author of file: Camille Lafitte
|
||||||
|
Purpose of file: Manage hook system.
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
Original Author of file: Camille Lafitte
|
|
||||||
Purpose of file: Manage hook system.
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* This class manage debug.
|
* This class manage debug.
|
||||||
*
|
*
|
||||||
* @copyright AlternC-Team 2002-2005 http://alternc.org/
|
* @copyright AlternC-Team 2002-2005 http://alternc.org/
|
||||||
*/
|
*/
|
||||||
class m_debug_alternc {
|
class m_debug_alternc {
|
||||||
var $infos="";
|
|
||||||
var $status=false;
|
|
||||||
var $nb_sql_query=0;
|
|
||||||
var $tps_sql_query=0;
|
|
||||||
var $generation_started=null;
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
var $infos = "";
|
||||||
/** Constructor
|
var $status = false;
|
||||||
*/
|
var $nb_sql_query = 0;
|
||||||
function m_debug_alternc() {
|
var $tps_sql_query = 0;
|
||||||
if ( isset($_COOKIE['alternc_debugme']) && $_COOKIE['alternc_debugme'] ) {
|
var $generation_started = null;
|
||||||
$this->status=true;
|
|
||||||
ini_set('display_errors', '1');
|
/** Constructor
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function m_debug_alternc() {
|
||||||
|
if (isset($_COOKIE['alternc_debugme']) && $_COOKIE['alternc_debugme']) {
|
||||||
|
$this->status = true;
|
||||||
|
ini_set('display_errors', '1');
|
||||||
|
}
|
||||||
|
$this->nb_sql_query = 0;
|
||||||
|
$this->tps_sql_query = 0;
|
||||||
|
$this->generation_started = microtime(true);
|
||||||
}
|
}
|
||||||
$this->nb_sql_query=0;
|
|
||||||
$this->tps_sql_query=0;
|
|
||||||
$this->generation_started=microtime(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function activate() {
|
/**
|
||||||
setcookie('alternc_debugme','1', time()+3600); // expire in 1 hour
|
*
|
||||||
$this->status="";
|
* @return boolean
|
||||||
return true;
|
*/
|
||||||
}
|
function activate() {
|
||||||
|
setcookie('alternc_debugme', '1', time() + 3600); // expire in 1 hour
|
||||||
|
$this->status = "";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function desactivate() {
|
/**
|
||||||
setcookie('alternc_debugme','0');
|
*
|
||||||
$this->status=false;
|
* @return boolean
|
||||||
return true;
|
*/
|
||||||
}
|
function desactivate() {
|
||||||
|
setcookie('alternc_debugme', '0');
|
||||||
|
$this->status = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function add($txt) {
|
/**
|
||||||
$this->infos .= "\n$txt";
|
*
|
||||||
return true;
|
* @param type $txt
|
||||||
}
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function add($txt) {
|
||||||
|
$this->infos .= "\n$txt";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function dump() {
|
/**
|
||||||
global $cuid;
|
*
|
||||||
if ( $cuid!=2000 ) return false;
|
* @global m_mem $mem
|
||||||
if ( ! $this->status ) return false;
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function dump() {
|
||||||
|
global $cuid;
|
||||||
|
if ($cuid != 2000)
|
||||||
|
return false;
|
||||||
|
if (!$this->status)
|
||||||
|
return false;
|
||||||
|
|
||||||
$generation_time = (microtime(true) - $this->generation_started) * 1000;
|
$generation_time = (microtime(true) - $this->generation_started) * 1000;
|
||||||
|
|
||||||
echo "<fieldset style='background-color: silver;'>";
|
echo "<fieldset style='background-color: silver;'>";
|
||||||
echo "<pre>";
|
echo "<pre>";
|
||||||
echo "+++ BEGIN Debug Mode+++\n";
|
echo "+++ BEGIN Debug Mode+++\n";
|
||||||
echo "Total generation time : $generation_time ms\n";
|
echo "Total generation time : $generation_time ms\n";
|
||||||
print_r("\n--- Total SQL Query : ".$this->nb_sql_query." req / ".$this->tps_sql_query." ms ---\n");
|
print_r("\n--- Total SQL Query : " . $this->nb_sql_query . " req / " . $this->tps_sql_query . " ms ---\n");
|
||||||
print_r($this->infos);
|
print_r($this->infos);
|
||||||
echo "\n\n--- GET ---\n";
|
echo "\n\n--- GET ---\n";
|
||||||
print_r($_GET);
|
print_r($_GET);
|
||||||
echo "\n\n--- POST ---\n";
|
echo "\n\n--- POST ---\n";
|
||||||
print_r($_POST);
|
print_r($_POST);
|
||||||
echo "\n\n--- SESSION ---\n";
|
echo "\n\n--- SESSION ---\n";
|
||||||
@print_r($_SESSION);
|
@print_r($_SESSION);
|
||||||
echo "\n\n--- COOKIE ---\n";
|
echo "\n\n--- COOKIE ---\n";
|
||||||
print_r($_COOKIE);
|
print_r($_COOKIE);
|
||||||
echo "\n\n--- SERVER ---\n";
|
echo "\n\n--- SERVER ---\n";
|
||||||
print_r($_SERVER);
|
print_r($_SERVER);
|
||||||
echo "\n\n+++ END Debug Mode+++";
|
echo "\n\n+++ END Debug Mode+++";
|
||||||
echo "</pre>";
|
echo "</pre>";
|
||||||
echo "</fieldset>";
|
echo "</fieldset>";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* Class debug_alternc */
|
}
|
||||||
|
|
||||||
?>
|
/* Class debug_alternc */
|
File diff suppressed because it is too large
Load Diff
|
@ -61,6 +61,13 @@ class m_err {
|
||||||
* @return boolean TRUE si l'erreur est connue, FALSE sinon.
|
* @return boolean TRUE si l'erreur est connue, FALSE sinon.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $clsid
|
||||||
|
* @param type $error
|
||||||
|
* @param type $param
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function raise($clsid,$error,$param="") {
|
function raise($clsid,$error,$param="") {
|
||||||
/* Leve une exception. Si elle existe, sinon, stocke un message d'erreur sur erreur ...*/
|
/* Leve une exception. Si elle existe, sinon, stocke un message d'erreur sur erreur ...*/
|
||||||
if (_("err_".$clsid."_".$error)!="err_".$clsid."_".$error || is_string($error)) {
|
if (_("err_".$clsid."_".$error)!="err_".$clsid."_".$error || is_string($error)) {
|
||||||
|
@ -89,6 +96,11 @@ class m_err {
|
||||||
* @return string Chaine d'erreur.
|
* @return string Chaine d'erreur.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*
|
||||||
|
*/
|
||||||
function errstr() {
|
function errstr() {
|
||||||
if (is_string($this->error)) {
|
if (is_string($this->error)) {
|
||||||
// new way of handling errors: message directly in the class
|
// new way of handling errors: message directly in the class
|
||||||
|
@ -115,6 +127,10 @@ class m_err {
|
||||||
* Elle est appelée automatiquement par error
|
* Elle est appelée automatiquement par error
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
*/
|
||||||
function logerr() {
|
function logerr() {
|
||||||
global $mem;
|
global $mem;
|
||||||
@file_put_contents($this->logfile, date("d/m/Y H:i:s")." - ERROR - ".$mem->user["login"]." - ".$this->errstr(), FILE_APPEND );
|
@file_put_contents($this->logfile, date("d/m/Y H:i:s")." - ERROR - ".$mem->user["login"]." - ".$this->errstr(), FILE_APPEND );
|
||||||
|
@ -132,6 +148,15 @@ class m_err {
|
||||||
* @return boolean TRUE si le log a été ajouté, FALSE sinon
|
* @return boolean TRUE si le log a été ajouté, FALSE sinon
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $clsid
|
||||||
|
* @param type $function
|
||||||
|
* @param type $param
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function log($clsid,$function,$param="") {
|
function log($clsid,$function,$param="") {
|
||||||
global $mem,$cuid;
|
global $mem,$cuid;
|
||||||
return @file_put_contents($this->logfile,date("d/m/Y H:i:s")." - " .get_remote_ip(). " - CALL - ".$mem->user["login"]." - $clsid - $function - $param\n", FILE_APPEND );
|
return @file_put_contents($this->logfile,date("d/m/Y H:i:s")." - " .get_remote_ip(). " - CALL - ".$mem->user["login"]." - $clsid - $function - $param\n", FILE_APPEND );
|
||||||
|
@ -139,4 +164,3 @@ class m_err {
|
||||||
|
|
||||||
}; /* Classe m_err */
|
}; /* Classe m_err */
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -1,14 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** Constructor
|
/** Constructor
|
||||||
Classe d'export de compte Alternc.
|
Classe d'export de compte Alternc.
|
||||||
Cette classe ce contente d'invoquer les fonctions d'exportation de configuration et de données d'un compte,
|
Cette classe ce contente d'invoquer les fonctions d'exportation de configuration et de données d'un compte,
|
||||||
presentes dans les classes concernées.
|
presentes dans les classes concernées.
|
||||||
*/
|
*/
|
||||||
Class m_export {
|
Class m_export {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function m_export() {
|
function m_export() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_hooks $hooks
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function export_conf(){
|
function export_conf(){
|
||||||
global $hooks;
|
global $hooks;
|
||||||
$config=$hooks->invoke('alternc_export_conf');
|
$config=$hooks->invoke('alternc_export_conf');
|
||||||
|
@ -18,6 +25,12 @@ Class m_export {
|
||||||
/** le repertoire de base est passé en paramettre puis en construit une arborescence de la forme
|
/** le repertoire de base est passé en paramettre puis en construit une arborescence de la forme
|
||||||
<dir>/<user>/<timestamp/ qui contiendra les dossier de dump html et sql
|
<dir>/<user>/<timestamp/ qui contiendra les dossier de dump html et sql
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_hooks $hooks
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $dir
|
||||||
|
*/
|
||||||
function export_data($dir){
|
function export_data($dir){
|
||||||
global $hooks, $mem;
|
global $hooks, $mem;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classe de gestion des comptes FTP de l'hébergé.
|
* Classe de gestion des comptes FTP de l'h<EFBFBD>berg<EFBFBD>.
|
||||||
*/
|
*/
|
||||||
class m_ftp {
|
class m_ftp {
|
||||||
|
|
||||||
|
@ -34,6 +34,10 @@ class m_ftp {
|
||||||
/**
|
/**
|
||||||
* Constructeur
|
* Constructeur
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global string $L_FQDN
|
||||||
|
*/
|
||||||
function m_ftp() {
|
function m_ftp() {
|
||||||
global $L_FQDN;
|
global $L_FQDN;
|
||||||
$this->srv_name = variable_get('ftp_human_name', '%%FQDN%%','Human name for FTP server', array('desc'=>'Name','type'=>'string'));
|
$this->srv_name = variable_get('ftp_human_name', '%%FQDN%%','Human name for FTP server', array('desc'=>'Name','type'=>'string'));
|
||||||
|
@ -44,10 +48,19 @@ class m_ftp {
|
||||||
/**
|
/**
|
||||||
* Password kind used in this class (hook for admin class)
|
* Password kind used in this class (hook for admin class)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function alternc_password_policy() {
|
function alternc_password_policy() {
|
||||||
return array("ftp"=>"FTP accounts");
|
return array("ftp"=>"FTP accounts");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_quota $quota
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
global $quota;
|
global $quota;
|
||||||
$q = $quota->getquota("ftp");
|
$q = $quota->getquota("ftp");
|
||||||
|
@ -83,6 +96,10 @@ class m_ftp {
|
||||||
|
|
||||||
// Return the values needed to activate security access. See get_auth_class()
|
// Return the values needed to activate security access. See get_auth_class()
|
||||||
// in authip for more informations
|
// in authip for more informations
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
function authip_class() {
|
function authip_class() {
|
||||||
$c = Array();
|
$c = Array();
|
||||||
$c['name']="FTP";
|
$c['name']="FTP";
|
||||||
|
@ -99,6 +116,15 @@ class m_ftp {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch enabled status of an account
|
// Switch enabled status of an account
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $id
|
||||||
|
* @param type $status
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function switch_enabled($id,$status=null) {
|
function switch_enabled($id,$status=null) {
|
||||||
global $cuid, $db, $err;
|
global $cuid, $db, $err;
|
||||||
if (! $jj = $this->get_ftp_details($id)) {
|
if (! $jj = $this->get_ftp_details($id)) {
|
||||||
|
@ -123,14 +149,22 @@ class m_ftp {
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
/** Retourne la liste des comptes FTP du compte hébergé
|
/** Retourne la liste des comptes FTP du compte h<EFBFBD>berg<EFBFBD>
|
||||||
* Retourne la liste des comptes FTP sous forme de tableau indexé de
|
* Retourne la liste des comptes FTP sous forme de tableau index<EFBFBD> de
|
||||||
* tableaus associatifs comme suit :
|
* tableaus associatifs comme suit :
|
||||||
* $a["id"]= ID du compte ftp
|
* $a["id"]= ID du compte ftp
|
||||||
* $a["login"]= Nom de login du compte
|
* $a["login"]= Nom de login du compte
|
||||||
* $a["dir"]= Dossier relatif à la racine du compte de l'utilisateur
|
* $a["dir"]= Dossier relatif <EFBFBD> la racine du compte de l'utilisateur
|
||||||
* @return array Retourne le tableau des comptes
|
* @return array Retourne le tableau des comptes
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_bro $bro
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_list() {
|
function get_list() {
|
||||||
global $db,$err,$cuid, $bro;
|
global $db,$err,$cuid, $bro;
|
||||||
$err->log("ftp","get_list");
|
$err->log("ftp","get_list");
|
||||||
|
@ -154,11 +188,19 @@ class m_ftp {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
/** Retourne les détails d'un compte FTP (voir get_list)
|
/** Retourne les d<EFBFBD>tails d'un compte FTP (voir get_list)
|
||||||
* Le tableau est celui du compte d'id spécifié
|
* Le tableau est celui du compte d'id sp<EFBFBD>cifi<EFBFBD>
|
||||||
* @param integer $id Numéro du compte dont on souhaite obtenir les détails
|
* @param integer $id Num<EFBFBD>ro du compte dont on souhaite obtenir les d<EFBFBD>tails
|
||||||
* @return array Tableau associatif contenant les infos du comptes ftp
|
* @return array Tableau associatif contenant les infos du comptes ftp
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $id
|
||||||
|
* @return string|boolean
|
||||||
|
*/
|
||||||
function get_ftp_details($id) {
|
function get_ftp_details($id) {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("ftp","get_ftp_details",$id);
|
$err->log("ftp","get_ftp_details",$id);
|
||||||
|
@ -194,6 +236,13 @@ class m_ftp {
|
||||||
* @return array tableau contenant la liste des prefixes (domaines + login)
|
* @return array tableau contenant la liste des prefixes (domaines + login)
|
||||||
* du compte actuel.
|
* du compte actuel.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function prefix_list() {
|
function prefix_list() {
|
||||||
global $db,$mem,$cuid;
|
global $db,$mem,$cuid;
|
||||||
$r=array();
|
$r=array();
|
||||||
|
@ -210,6 +259,12 @@ class m_ftp {
|
||||||
*
|
*
|
||||||
* @param string $l
|
* @param string $l
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $l
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function check_login($l) {
|
function check_login($l) {
|
||||||
global $err;
|
global $err;
|
||||||
|
|
||||||
|
@ -233,11 +288,16 @@ class m_ftp {
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
/** Affiche (ECHO) la liste des prefixes disponibles sous forme de champs d'option
|
/** Affiche (ECHO) la liste des prefixes disponibles sous forme de champs d'option
|
||||||
* Les champs sont affichés sous la forme <option>prefixe</option>...
|
* Les champs sont affich<EFBFBD>s sous la forme <option>prefixe</option>...
|
||||||
* La valeur $current se voit affublée de la balise SELECTED.
|
* La valeur $current se voit affubl<EFBFBD>e de la balise SELECTED.
|
||||||
* @param string $current Prefixe sélectionné par défaut
|
* @param string $current Prefixe s<EFBFBD>lectionn<EFBFBD> par d<EFBFBD>faut
|
||||||
* @return boolean TRUE.
|
* @return boolean TRUE.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $current
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function select_prefix_list($current) {
|
function select_prefix_list($current) {
|
||||||
$r=$this->prefix_list();
|
$r=$this->prefix_list();
|
||||||
reset($r);
|
reset($r);
|
||||||
|
@ -249,14 +309,29 @@ class m_ftp {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
/** Modifie les paramètres du comptes FTP $id.
|
/** Modifie les param<EFBFBD>tres du comptes FTP $id.
|
||||||
* @param integer $id Numéro du compte dont on veut modifier les paramètres
|
* @param integer $id Num<EFBFBD>ro du compte dont on veut modifier les param<EFBFBD>tres
|
||||||
* @param string $prefixe Prefixe du compte FTP
|
* @param string $prefixe Prefixe du compte FTP
|
||||||
* @param string $login login ajouté au préfixe ($prefixe_$login)
|
* @param string $login login ajout<EFBFBD> au pr<EFBFBD>fixe ($prefixe_$login)
|
||||||
* @param string $pass mot de passe
|
* @param string $pass mot de passe
|
||||||
* @param string $dir Répertoire racine du compte
|
* @param string $dir R<EFBFBD>pertoire racine du compte
|
||||||
* @return boolean TRUE si le compte a été modifié, FALSE si une erreur est survenue.
|
* @return boolean TRUE si le compte a <EFBFBD>t<EFBFBD> modifi<EFBFBD>, FALSE si une erreur est survenue.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_bro $bro
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_admin $admin
|
||||||
|
* @param type $id
|
||||||
|
* @param type $prefixe
|
||||||
|
* @param type $login
|
||||||
|
* @param type $pass
|
||||||
|
* @param type $dir
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function put_ftp_details($id,$prefixe,$login,$pass,$dir) {
|
function put_ftp_details($id,$prefixe,$login,$pass,$dir) {
|
||||||
global $mem,$db,$err,$bro,$cuid,$admin;
|
global $mem,$db,$err,$bro,$cuid,$admin;
|
||||||
$err->log("ftp","put_ftp_details",$id);
|
$err->log("ftp","put_ftp_details",$id);
|
||||||
|
@ -311,10 +386,18 @@ class m_ftp {
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
/** Efface le compte ftp spécifié.
|
/** Efface le compte ftp sp<EFBFBD>cifi<EFBFBD>.
|
||||||
* @param integer $id Numéro du compte FTP à supprimer.
|
* @param integer $id Num<EFBFBD>ro du compte FTP <EFBFBD> supprimer.
|
||||||
* @return boolean TRUE si le compte a été effacé, FALSE sinon.
|
* @return boolean TRUE si le compte a <EFBFBD>t<EFBFBD> effac<EFBFBD>, FALSE sinon.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function delete_ftp($id) {
|
function delete_ftp($id) {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("ftp","delete_ftp",$id);
|
$err->log("ftp","delete_ftp",$id);
|
||||||
|
@ -330,14 +413,29 @@ class m_ftp {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
/** Crée un nouveau compte FTP.
|
/** Cr<EFBFBD>e un nouveau compte FTP.
|
||||||
* @param string $prefixe Prefixe au login
|
* @param string $prefixe Prefixe au login
|
||||||
* @param string $login Login ftp (login=prefixe_login)
|
* @param string $login Login ftp (login=prefixe_login)
|
||||||
* @param string $pass Mot de passe FTP
|
* @param string $pass Mot de passe FTP
|
||||||
* @param string $dir Répertoire racine du compte relatif à la racine du membre
|
* @param string $dir R<EFBFBD>pertoire racine du compte relatif <EFBFBD> la racine du membre
|
||||||
* @return boolean TRUE si le compte a été créé, FALSE sinon.
|
* @return boolean TRUE si le compte a <EFBFBD>t<EFBFBD> cr<EFBFBD><EFBFBD>, FALSE sinon.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_quota $quota
|
||||||
|
* @global m_bro $bro
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_admin $admin
|
||||||
|
* @param type $prefixe
|
||||||
|
* @param type $login
|
||||||
|
* @param type $pass
|
||||||
|
* @param type $dir
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function add_ftp($prefixe,$login,$pass,$dir) {
|
function add_ftp($prefixe,$login,$pass,$dir) {
|
||||||
global $mem,$db,$err,$quota,$bro,$cuid,$admin;
|
global $mem,$db,$err,$quota,$bro,$cuid,$admin;
|
||||||
$err->log("ftp","add_ftp",$prefixe."_".$login);
|
$err->log("ftp","add_ftp",$prefixe."_".$login);
|
||||||
|
@ -392,10 +490,18 @@ class m_ftp {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
/** Retourne TRUE si $dir possède un compte FTP
|
/** Retourne TRUE si $dir poss<EFBFBD>de un compte FTP
|
||||||
* @param string $dir Dossier à tester, relatif à la racine du compte courant
|
* @param string $dir Dossier <EFBFBD> tester, relatif <EFBFBD> la racine du compte courant
|
||||||
* @return boolean retourne TRUE si $dir à un compte FTP, FALSE sinon.
|
* @return boolean retourne TRUE si $dir <EFBFBD> un compte FTP, FALSE sinon.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $dir
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function is_ftp($dir) {
|
function is_ftp($dir) {
|
||||||
global $mem,$db,$err;
|
global $mem,$db,$err;
|
||||||
$err->log("ftp","is_ftp",$dir);
|
$err->log("ftp","is_ftp",$dir);
|
||||||
|
@ -410,10 +516,18 @@ class m_ftp {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
/** Fonction appellée par domains quand un domaine est supprimé pour le membre
|
/** Fonction appell<EFBFBD>e par domains quand un domaine est supprim<EFBFBD> pour le membre
|
||||||
* @param string $dom Domaine à détruire.
|
* @param string $dom Domaine <EFBFBD> d<EFBFBD>truire.
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $dom
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function alternc_del_domain($dom) {
|
function alternc_del_domain($dom) {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("ftp","alternc_del_domain",$dom);
|
$err->log("ftp","alternc_del_domain",$dom);
|
||||||
|
@ -422,9 +536,16 @@ class m_ftp {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
/** Fonction appellée par membres quand un membre est effacé.
|
/** Fonction appell<EFBFBD>e par membres quand un membre est effac<EFBFBD>.
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function alternc_del_member() {
|
function alternc_del_member() {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("ftp","alternc_del_member");
|
$err->log("ftp","alternc_del_member");
|
||||||
|
@ -439,6 +560,13 @@ class m_ftp {
|
||||||
* @return integer the number of service used or false if an error occured
|
* @return integer the number of service used or false if an error occured
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function hook_quota_get() {
|
function hook_quota_get() {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("ftp","getquota");
|
$err->log("ftp","getquota");
|
||||||
|
@ -457,6 +585,12 @@ class m_ftp {
|
||||||
* @access private
|
* @access private
|
||||||
* EXPERIMENTAL 'sid' function ;)
|
* EXPERIMENTAL 'sid' function ;)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function alternc_export_conf() {
|
function alternc_export_conf() {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$err->log("ftp","export");
|
$err->log("ftp","export");
|
||||||
|
@ -478,6 +612,10 @@ class m_ftp {
|
||||||
* @return array a key => value list of port protocol name mandatory values
|
* @return array a key => value list of port protocol name mandatory values
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function hook_upnp_list() {
|
function hook_upnp_list() {
|
||||||
return array(
|
return array(
|
||||||
"ftp" => array("port" => 21, "protocol" => "tcp", "mandatory" => 1),
|
"ftp" => array("port" => 21, "protocol" => "tcp", "mandatory" => 1),
|
||||||
|
|
|
@ -30,14 +30,15 @@
|
||||||
*/
|
*/
|
||||||
class m_hooks {
|
class m_hooks {
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** Constructor
|
/** Constructor
|
||||||
* hooks([$mid]) Constructeur de la classe hooks, ne fait rien pour le moment
|
* hooks([$mid]) Constructeur de la classe hooks, ne fait rien pour le moment
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function m_hooks() {
|
function m_hooks() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/**
|
/**
|
||||||
* invoke() permet de lancer une fonction donné en parametre dans toute les classes
|
* invoke() permet de lancer une fonction donné en parametre dans toute les classes
|
||||||
* connues de alternc, avec les parametres donnés.
|
* connues de alternc, avec les parametres donnés.
|
||||||
|
@ -46,6 +47,14 @@ class m_hooks {
|
||||||
* @param array|string $hclass tableau contenant les classes spécifique qu'on veux appeler (si on veux pas TOUTE les appeler)
|
* @param array|string $hclass tableau contenant les classes spécifique qu'on veux appeler (si on veux pas TOUTE les appeler)
|
||||||
* @return array with the return of each classes
|
* @return array with the return of each classes
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global array $classes
|
||||||
|
* @param type $hname
|
||||||
|
* @param type $hparam
|
||||||
|
* @param type $hclass
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function invoke($hname, $hparam = array(), $hclass = null) {
|
function invoke($hname, $hparam = array(), $hclass = null) {
|
||||||
|
|
||||||
// Si $hclass est defini, on veut appeler le hooks QUE pour UNE
|
// Si $hclass est defini, on veut appeler le hooks QUE pour UNE
|
||||||
|
@ -76,13 +85,18 @@ class m_hooks {
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/**
|
/**
|
||||||
* invoke each executable script of the directory (or the specified script)
|
* invoke each executable script of the directory (or the specified script)
|
||||||
* @param string $scripts a script or a directory
|
* @param string $scripts a script or a directory
|
||||||
* @param array $parameters parameters for the scripts
|
* @param array $parameters parameters for the scripts
|
||||||
* @return boolean TRUE
|
* @return boolean TRUE
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $scripts
|
||||||
|
* @param type $parameters
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function invoke_scripts($scripts, $parameters=array()) {
|
function invoke_scripts($scripts, $parameters=array()) {
|
||||||
|
|
||||||
// First, build the list of script we want to launch
|
// First, build the list of script we want to launch
|
||||||
|
|
|
@ -79,7 +79,7 @@ class m_hta {
|
||||||
*
|
*
|
||||||
* @global m_mem $mem
|
* @global m_mem $mem
|
||||||
* @global m_bro $bro
|
* @global m_bro $bro
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $dir
|
* @param string $dir
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
@ -123,7 +123,7 @@ class m_hta {
|
||||||
/**
|
/**
|
||||||
* Returns the list of all user folder currently protected by a .htpasswd file
|
* Returns the list of all user folder currently protected by a .htpasswd file
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global m_mem $mem
|
* @global m_mem $mem
|
||||||
* @return array Array containing user folder list
|
* @return array Array containing user folder list
|
||||||
*/
|
*/
|
||||||
|
@ -152,7 +152,7 @@ class m_hta {
|
||||||
* Tells if a folder is protected.
|
* Tells if a folder is protected.
|
||||||
*
|
*
|
||||||
* @global m_mem $mem
|
* @global m_mem $mem
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $dir Folder to check
|
* @param string $dir Folder to check
|
||||||
* @return boolean If the folder is protected, or FALSE if it is not
|
* @return boolean If the folder is protected, or FALSE if it is not
|
||||||
*/
|
*/
|
||||||
|
@ -172,7 +172,7 @@ class m_hta {
|
||||||
* Returns the list of login for a protected folder.
|
* Returns the list of login for a protected folder.
|
||||||
*
|
*
|
||||||
* @global m_mem $mem
|
* @global m_mem $mem
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $dir The folder to lookup (relative to user root)
|
* @param string $dir The folder to lookup (relative to user root)
|
||||||
* @return array An array containing the list of logins from the .htpasswd file, or FALSE
|
* @return array An array containing the list of logins from the .htpasswd file, or FALSE
|
||||||
*/
|
*/
|
||||||
|
@ -210,7 +210,7 @@ class m_hta {
|
||||||
*
|
*
|
||||||
* @global m_mem $mem
|
* @global m_mem $mem
|
||||||
* @global m_bro $bro
|
* @global m_bro $bro
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param string $dir Folder to unprotect, relative to user root
|
* @param string $dir Folder to unprotect, relative to user root
|
||||||
* @param boolean $skip For testing purpose mainly, skips the full user path search
|
* @param boolean $skip For testing purpose mainly, skips the full user path search
|
||||||
* @return boolean TRUE if the folder has been unprotected, or FALSE if an error occurred
|
* @return boolean TRUE if the folder has been unprotected, or FALSE if an error occurred
|
||||||
|
@ -271,7 +271,7 @@ class m_hta {
|
||||||
/**
|
/**
|
||||||
* Add a user to a protected folder
|
* Add a user to a protected folder
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global m_bro $bro
|
* @global m_bro $bro
|
||||||
* @global m_admin $admin
|
* @global m_admin $admin
|
||||||
* @param string $user
|
* @param string $user
|
||||||
|
@ -340,7 +340,7 @@ class m_hta {
|
||||||
* Delete a user from a protected folder.
|
* Delete a user from a protected folder.
|
||||||
*
|
*
|
||||||
* @global m_bro $bro
|
* @global m_bro $bro
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param array $lst An array with login to delete.
|
* @param array $lst An array with login to delete.
|
||||||
* @param string $dir The folder, relative to user root, where we want to delete users.
|
* @param string $dir The folder, relative to user root, where we want to delete users.
|
||||||
* @return boolean TRUE if users has been deleted, or FALSE if an error occurred.
|
* @return boolean TRUE if users has been deleted, or FALSE if an error occurred.
|
||||||
|
@ -388,7 +388,7 @@ class m_hta {
|
||||||
* Change the password of a user in a protected folder
|
* Change the password of a user in a protected folder
|
||||||
*
|
*
|
||||||
* @global m_bro $bro
|
* @global m_bro $bro
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @global m_admin $admin
|
* @global m_admin $admin
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $newpass
|
* @param string $newpass
|
||||||
|
@ -437,7 +437,7 @@ class m_hta {
|
||||||
/**
|
/**
|
||||||
* Check that a .htaccess file is valid (for authentication)
|
* Check that a .htaccess file is valid (for authentication)
|
||||||
*
|
*
|
||||||
* @global m_err $err
|
* @global m_err $err
|
||||||
* @param type $absolute
|
* @param type $absolute
|
||||||
* @param string $absolute Folder we want to check (relative to user root)
|
* @param string $absolute Folder we want to check (relative to user root)
|
||||||
* @return boolean TRUE is the .htaccess is protecting this folder, or FALSE else
|
* @return boolean TRUE is the .htaccess is protecting this folder, or FALSE else
|
||||||
|
|
|
@ -28,9 +28,19 @@
|
||||||
*/
|
*/
|
||||||
class m_log {
|
class m_log {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function m_log(){
|
function m_log(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $dir
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function list_logs_directory($dir){
|
function list_logs_directory($dir){
|
||||||
global $cuid,$err;
|
global $cuid,$err;
|
||||||
$err->log("log","list_logs_directory");
|
$err->log("log","list_logs_directory");
|
||||||
|
@ -54,6 +64,10 @@ class m_log {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
$obj = array(
|
$obj = array(
|
||||||
'title' => _("Logs"),
|
'title' => _("Logs"),
|
||||||
|
@ -65,6 +79,12 @@ class m_log {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $dirs
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function list_logs_directory_all($dirs){
|
function list_logs_directory_all($dirs){
|
||||||
global $err;
|
global $err;
|
||||||
$err->log("log","get_logs_directory_all");
|
$err->log("log","get_logs_directory_all");
|
||||||
|
@ -76,6 +96,13 @@ class m_log {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_err $err
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function get_logs_directory(){
|
function get_logs_directory(){
|
||||||
global $cuid,$mem,$err;
|
global $cuid,$mem,$err;
|
||||||
$err->log("log","get_logs_directory");
|
$err->log("log","get_logs_directory");
|
||||||
|
@ -88,6 +115,12 @@ class m_log {
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $file
|
||||||
|
*/
|
||||||
function download_link($file){
|
function download_link($file){
|
||||||
global $err,$mem;
|
global $err,$mem;
|
||||||
$err->log("log","download_link");
|
$err->log("log","download_link");
|
||||||
|
|
|
@ -44,6 +44,7 @@ class m_lxc implements vm {
|
||||||
/**
|
/**
|
||||||
* Constructor, initialize the class informations from AlternC's variables
|
* Constructor, initialize the class informations from AlternC's variables
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
function m_lxc() {
|
function m_lxc() {
|
||||||
$this->IP = variable_get('lxc_ip', '', "IP address of the Alternc's LXC server. If empty, no LXC server.", array('desc'=>'IP address','type'=>'ip'));
|
$this->IP = variable_get('lxc_ip', '', "IP address of the Alternc's LXC server. If empty, no LXC server.", array('desc'=>'IP address','type'=>'ip'));
|
||||||
$this->PORT = variable_get('lxc_port', '6504', "Port of the Alternc's LXC server", array('desc'=>'Port','type'=>'integer'));
|
$this->PORT = variable_get('lxc_port', '6504', "Port of the Alternc's LXC server", array('desc'=>'Port','type'=>'integer'));
|
||||||
|
@ -55,6 +56,7 @@ class m_lxc implements vm {
|
||||||
/**
|
/**
|
||||||
* HOOK: add the "Console Access" to AlternC's main menu
|
* HOOK: add the "Console Access" to AlternC's main menu
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
if ( empty($this->IP)) return ; // No menu if no server
|
if ( empty($this->IP)) return ; // No menu if no server
|
||||||
|
|
||||||
|
@ -72,6 +74,7 @@ class m_lxc implements vm {
|
||||||
/**
|
/**
|
||||||
* HOOK: remove VM history for AlternC account
|
* HOOK: remove VM history for AlternC account
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
function hook_admin_del_member() {
|
function hook_admin_del_member() {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("lxc","alternc_del_member");
|
$err->log("lxc","alternc_del_member");
|
||||||
|
|
|
@ -36,14 +36,14 @@
|
||||||
class m_mail {
|
class m_mail {
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** domain list for this account
|
/** domain list for this account
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $domains;
|
var $domains;
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** If an email has those chars, 'not nice in shell env' ;)
|
/** If an email has those chars, 'not nice in shell env' ;)
|
||||||
* we don't store the email in $mail/u/{user}_domain, but in $mail/_/{address_id}_domain
|
* we don't store the email in $mail/u/{user}_domain, but in $mail/_/{address_id}_domain
|
||||||
* @access private
|
* @access private
|
||||||
|
@ -51,7 +51,7 @@ class m_mail {
|
||||||
var $specialchars=array('"',"'",'\\','/');
|
var $specialchars=array('"',"'",'\\','/');
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** If an email has those chars, we will ONLY allow RECIPIENTS, NOT POP/IMAP for DOVECOT !
|
/** If an email has those chars, we will ONLY allow RECIPIENTS, NOT POP/IMAP for DOVECOT !
|
||||||
* Since Dovecot doesn't allow those characters
|
* Since Dovecot doesn't allow those characters
|
||||||
* @access private
|
* @access private
|
||||||
|
@ -59,7 +59,7 @@ class m_mail {
|
||||||
var $forbiddenchars=array('"',"'",'\\','/','?','!','*','$','|','#','+');
|
var $forbiddenchars=array('"',"'",'\\','/','?','!','*','$','|','#','+');
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Number of results for a pager display
|
/** Number of results for a pager display
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
|
@ -77,10 +77,13 @@ class m_mail {
|
||||||
|
|
||||||
var $cache_domain_mail_size = array();
|
var $cache_domain_mail_size = array();
|
||||||
var $enum_domains=array();
|
var $enum_domains=array();
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/**
|
/**
|
||||||
* Constructeur
|
* Constructeur
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function m_mail() {
|
function m_mail() {
|
||||||
$this->srv_submission = variable_get('mail_human_submission', '%%FQDN%%','Human name for mail server (submission protocol)', array('desc'=>'Name','type'=>'string'));
|
$this->srv_submission = variable_get('mail_human_submission', '%%FQDN%%','Human name for mail server (submission protocol)', array('desc'=>'Name','type'=>'string'));
|
||||||
$this->srv_smtp = variable_get('mail_human_smtp', '%%FQDN%%','Human name for mail server (SMTP protocol)', array('desc'=>'Name','type'=>'string'));
|
$this->srv_smtp = variable_get('mail_human_smtp', '%%FQDN%%','Human name for mail server (SMTP protocol)', array('desc'=>'Name','type'=>'string'));
|
||||||
|
@ -91,6 +94,10 @@ class m_mail {
|
||||||
$this->srv_pop3s = variable_get('mail_human_pop3s', '%%FQDN%%','Human name for POP3s mail server', array('desc'=>'Name','type'=>'string'));
|
$this->srv_pop3s = variable_get('mail_human_pop3s', '%%FQDN%%','Human name for POP3s mail server', array('desc'=>'Name','type'=>'string'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
$obj = array(
|
$obj = array(
|
||||||
'title' => _("Email Addresses"),
|
'title' => _("Email Addresses"),
|
||||||
|
@ -111,6 +118,12 @@ class m_mail {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @param type $domain
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function get_total_size_for_domain($domain) {
|
function get_total_size_for_domain($domain) {
|
||||||
global $db;
|
global $db;
|
||||||
if (empty($this->cache_domain_mail_size)) {
|
if (empty($this->cache_domain_mail_size)) {
|
||||||
|
@ -129,6 +142,13 @@ class m_mail {
|
||||||
/**
|
/**
|
||||||
* @param string $domain_id
|
* @param string $domain_id
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_dom $dom
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @param type $domain_id
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function catchall_getinfos($domain_id) {
|
function catchall_getinfos($domain_id) {
|
||||||
global $dom, $db;
|
global $dom, $db;
|
||||||
$rr=array(
|
$rr=array(
|
||||||
|
@ -159,6 +179,11 @@ class m_mail {
|
||||||
/**
|
/**
|
||||||
* @param string $domain_id
|
* @param string $domain_id
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $domain_id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function catchall_del($domain_id) {
|
function catchall_del($domain_id) {
|
||||||
$catch = $this->catchall_getinfos($domain_id);
|
$catch = $this->catchall_getinfos($domain_id);
|
||||||
if (empty($catch['mail_id'])) return false;
|
if (empty($catch['mail_id'])) return false;
|
||||||
|
@ -169,6 +194,13 @@ class m_mail {
|
||||||
* @param string $domain_id
|
* @param string $domain_id
|
||||||
* @param string $target
|
* @param string $target
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $domain_id
|
||||||
|
* @param type $target
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function catchall_set($domain_id, $target) {
|
function catchall_set($domain_id, $target) {
|
||||||
global $err;
|
global $err;
|
||||||
// target :
|
// target :
|
||||||
|
@ -190,13 +222,20 @@ class m_mail {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** get_quota (hook for quota class), returns the number of used
|
/** get_quota (hook for quota class), returns the number of used
|
||||||
* service for a quota-bound service
|
* service for a quota-bound service
|
||||||
* @param $name string the named quota we want
|
* @param $name string the named quota we want
|
||||||
* @return the number of used service for the specified quota,
|
* @return the number of used service for the specified quota,
|
||||||
* or false if I'm not the one for the named quota
|
* or false if I'm not the one for the named quota
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function hook_quota_get() {
|
function hook_quota_get() {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("mail","getquota");
|
$err->log("mail","getquota");
|
||||||
|
@ -209,19 +248,31 @@ class m_mail {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Password policy kind used in this class (hook for admin class)
|
/** Password policy kind used in this class (hook for admin class)
|
||||||
* @return array an array of policykey => "policy name (for humans)"
|
* @return array an array of policykey => "policy name (for humans)"
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function alternc_password_policy() {
|
function alternc_password_policy() {
|
||||||
return array("pop"=>_("Email account password"));
|
return array("pop"=>_("Email account password"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Returns the list of mail-hosting domains for a user
|
/** Returns the list of mail-hosting domains for a user
|
||||||
* @return array indexed array of hosted domains
|
* @return array indexed array of hosted domains
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $uid
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function enum_domains($uid=-1) {
|
function enum_domains($uid=-1) {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("mail","enum_domains");
|
$err->log("mail","enum_domains");
|
||||||
|
@ -250,12 +301,20 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** available: tells if an email address can be installed in the server
|
/** available: tells if an email address can be installed in the server
|
||||||
* check the domain part (is it mine too), the syntax, and the availability.
|
* check the domain part (is it mine too), the syntax, and the availability.
|
||||||
* @param $mail string email to check
|
* @param $mail string email to check
|
||||||
* @return boolean true if the email can be installed on the server
|
* @return boolean true if the email can be installed on the server
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_dom $dom
|
||||||
|
* @param type $mail
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function available($mail){
|
function available($mail){
|
||||||
global $db,$err,$dom;
|
global $db,$err,$dom;
|
||||||
$err->log("mail","available");
|
$err->log("mail","available");
|
||||||
|
@ -279,7 +338,7 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/* function used to list every mail address hosted on a domain.
|
/* function used to list every mail address hosted on a domain.
|
||||||
* @param $dom_id integer the domain id.
|
* @param $dom_id integer the domain id.
|
||||||
* @param $search string search that string in recipients or address.
|
* @param $search string search that string in recipients or address.
|
||||||
|
@ -287,6 +346,19 @@ ORDER BY
|
||||||
* @param $count integer return no more than THAT much emails. -1 for ALL. Offset is ignored then.
|
* @param $count integer return no more than THAT much emails. -1 for ALL. Offset is ignored then.
|
||||||
* @result an array of each mail hosted under the domain.
|
* @result an array of each mail hosted under the domain.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_hooks $hooks
|
||||||
|
* @param type $dom_id
|
||||||
|
* @param type $search
|
||||||
|
* @param type $offset
|
||||||
|
* @param type $count
|
||||||
|
* @param type $show_systemmails
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function enum_domain_mails($dom_id = null, $search="", $offset=0, $count=30, $show_systemmails=false){
|
function enum_domain_mails($dom_id = null, $search="", $offset=0, $count=30, $show_systemmails=false){
|
||||||
global $db,$err,$cuid,$hooks;
|
global $db,$err,$cuid,$hooks;
|
||||||
$err->log("mail","enum_domains_mail");
|
$err->log("mail","enum_domains_mail");
|
||||||
|
@ -321,12 +393,17 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $detail
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function hook_mail_get_details($detail) {
|
function hook_mail_get_details($detail) {
|
||||||
if ($detail['type']=='catchall') return _(sprintf("Special mail address for catch-all. <a href='mail_manage_catchall.php?domain_id=%s'>Click here to manage it.</a>",$detail['domain_id']));
|
if ($detail['type']=='catchall') return _(sprintf("Special mail address for catch-all. <a href='mail_manage_catchall.php?domain_id=%s'>Click here to manage it.</a>",$detail['domain_id']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Function used to insert a new mail into the db
|
/** Function used to insert a new mail into the db
|
||||||
* should be used by the web interface, not by third-party programs.
|
* should be used by the web interface, not by third-party programs.
|
||||||
*
|
*
|
||||||
|
@ -339,6 +416,20 @@ ORDER BY
|
||||||
* @return an hashtable containing the database id of the newly created mail,
|
* @return an hashtable containing the database id of the newly created mail,
|
||||||
* or false if an error occured ($err is filled accordingly)
|
* or false if an error occured ($err is filled accordingly)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_quota $quota
|
||||||
|
* @global m_dom $dom
|
||||||
|
* @global m_hooks $hooks
|
||||||
|
* @param type $dom_id
|
||||||
|
* @param type $mail
|
||||||
|
* @param type $type
|
||||||
|
* @param type $dontcheck
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function create($dom_id, $mail,$type="",$dontcheck=false){
|
function create($dom_id, $mail,$type="",$dontcheck=false){
|
||||||
global $err,$db,$cuid,$quota,$dom,$hooks;
|
global $err,$db,$cuid,$quota,$dom,$hooks;
|
||||||
$err->log("mail","create",$mail);
|
$err->log("mail","create",$mail);
|
||||||
|
@ -382,11 +473,20 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** function used to get every information we can on a mail
|
/** function used to get every information we can on a mail
|
||||||
* @param $mail_id integer
|
* @param $mail_id integer
|
||||||
* @return array a hashtable with all the informations for that email
|
* @return array a hashtable with all the informations for that email
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_hooks $hooks
|
||||||
|
* @param type $mail_id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function get_details($mail_id) {
|
function get_details($mail_id) {
|
||||||
global $db, $err, $cuid, $hooks;
|
global $db, $err, $cuid, $hooks;
|
||||||
$err->log("mail","get_details");
|
$err->log("mail","get_details");
|
||||||
|
@ -412,13 +512,21 @@ ORDER BY
|
||||||
|
|
||||||
private $isitmy_cache=array();
|
private $isitmy_cache=array();
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Check if an email is mine ...
|
/** Check if an email is mine ...
|
||||||
*
|
*
|
||||||
* @param $mail_id integer the number of the email to check
|
* @param $mail_id integer the number of the email to check
|
||||||
* @return string the complete email address if that's mine, false if not
|
* @return string the complete email address if that's mine, false if not
|
||||||
* ($err is filled accordingly)
|
* ($err is filled accordingly)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $mail_id
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function is_it_my_mail($mail_id){
|
function is_it_my_mail($mail_id){
|
||||||
global $err,$db,$cuid;
|
global $err,$db,$cuid;
|
||||||
$mail_id=intval($mail_id);
|
$mail_id=intval($mail_id);
|
||||||
|
@ -435,13 +543,18 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Hook called when the DOMAIN class will delete a domain.
|
/** Hook called when the DOMAIN class will delete a domain.
|
||||||
*
|
*
|
||||||
* @param $dom integer the number of the email to delete
|
* @param $dom integer the number of the email to delete
|
||||||
* @return boolean if the email has been properly deleted
|
* @return boolean if the email has been properly deleted
|
||||||
* or false if an error occured ($err is filled accordingly)
|
* or false if an error occured ($err is filled accordingly)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $dom_id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function hook_dom_del_mx_domain($dom_id) {
|
function hook_dom_del_mx_domain($dom_id) {
|
||||||
$list=$this->enum_domain_mails($dom_id,"",0,-1);
|
$list=$this->enum_domain_mails($dom_id,"",0,-1);
|
||||||
if (is_array($list)) {
|
if (is_array($list)) {
|
||||||
|
@ -453,6 +566,13 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the alternc account's ID of the mail_id
|
// return the alternc account's ID of the mail_id
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $mail_id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function get_account_by_mail_id($mail_id) {
|
function get_account_by_mail_id($mail_id) {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$db->query("select compte as uid from domaines d, address a where a.domain_id = d.id and a.id = $mail_id");
|
$db->query("select compte as uid from domaines d, address a where a.domain_id = d.id and a.id = $mail_id");
|
||||||
|
@ -463,7 +583,7 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Function used to delete a mail from the db
|
/** Function used to delete a mail from the db
|
||||||
* should be used by the web interface, not by third-party programs.
|
* should be used by the web interface, not by third-party programs.
|
||||||
*
|
*
|
||||||
|
@ -471,6 +591,17 @@ ORDER BY
|
||||||
* @return boolean if the email has been properly deleted
|
* @return boolean if the email has been properly deleted
|
||||||
* or false if an error occured ($err is filled accordingly)
|
* or false if an error occured ($err is filled accordingly)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_quota $quota
|
||||||
|
* @global m_dom $dom
|
||||||
|
* @global m_hooks $hooks
|
||||||
|
* @param type $mail_id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function delete($mail_id){
|
function delete($mail_id){
|
||||||
global $err,$db,$cuid,$quota,$dom,$hooks;
|
global $err,$db,$cuid,$quota,$dom,$hooks;
|
||||||
$err->log("mail","delete");
|
$err->log("mail","delete");
|
||||||
|
@ -517,7 +648,7 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Function used to undelete a pending deletion mail from the db
|
/** Function used to undelete a pending deletion mail from the db
|
||||||
* should be used by the web interface, not by third-party programs.
|
* should be used by the web interface, not by third-party programs.
|
||||||
*
|
*
|
||||||
|
@ -525,6 +656,17 @@ ORDER BY
|
||||||
* @return boolean if the email has been properly undeleted
|
* @return boolean if the email has been properly undeleted
|
||||||
* or false if an error occured ($err is filled accordingly)
|
* or false if an error occured ($err is filled accordingly)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_quota $quota
|
||||||
|
* @global m_dom $dom
|
||||||
|
* @global m_hooks $hooks
|
||||||
|
* @param type $mail_id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function undelete($mail_id){
|
function undelete($mail_id){
|
||||||
global $err,$db,$cuid,$quota,$dom,$hooks;
|
global $err,$db,$cuid,$quota,$dom,$hooks;
|
||||||
$err->log("mail","undelete");
|
$err->log("mail","undelete");
|
||||||
|
@ -569,12 +711,21 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** set the password of an email address.
|
/** set the password of an email address.
|
||||||
* @param $mail_id integer email ID
|
* @param $mail_id integer email ID
|
||||||
* @param $pass string the new password.
|
* @param $pass string the new password.
|
||||||
* @return boolean true if the password has been set, false else, raise an error.
|
* @return boolean true if the password has been set, false else, raise an error.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_admin $admin
|
||||||
|
* @param type $mail_id
|
||||||
|
* @param type $pass
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function set_passwd($mail_id,$pass){
|
function set_passwd($mail_id,$pass){
|
||||||
global $db,$err,$admin;
|
global $db,$err,$admin;
|
||||||
$err->log("mail","setpasswd");
|
$err->log("mail","setpasswd");
|
||||||
|
@ -586,11 +737,18 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Enables an email address.
|
/** Enables an email address.
|
||||||
* @param $mail_id integer Email ID
|
* @param $mail_id integer Email ID
|
||||||
* @return boolean true if the email has been enabled.
|
* @return boolean true if the email has been enabled.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $mail_id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function enable($mail_id){
|
function enable($mail_id){
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$err->log("mail","enable");
|
$err->log("mail","enable");
|
||||||
|
@ -600,11 +758,18 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Disables an email address.
|
/** Disables an email address.
|
||||||
* @param $mail_id integer Email ID
|
* @param $mail_id integer Email ID
|
||||||
* @return boolean true if the email has been enabled.
|
* @return boolean true if the email has been enabled.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $mail_id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function disable($mail_id){
|
function disable($mail_id){
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$err->log("mail","disable");
|
$err->log("mail","disable");
|
||||||
|
@ -614,7 +779,7 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Function used to update an email settings
|
/** Function used to update an email settings
|
||||||
* should be used by the web interface, not by third-party programs.
|
* should be used by the web interface, not by third-party programs.
|
||||||
*
|
*
|
||||||
|
@ -625,6 +790,22 @@ ORDER BY
|
||||||
* @return boolean if the email has been properly edited
|
* @return boolean if the email has been properly edited
|
||||||
* or false if an error occured ($err is filled accordingly)
|
* or false if an error occured ($err is filled accordingly)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_quota $quota
|
||||||
|
* @global m_dom $dom
|
||||||
|
* @global m_hooks $hooks
|
||||||
|
* @param type $mail_id
|
||||||
|
* @param type $islocal
|
||||||
|
* @param type $quotamb
|
||||||
|
* @param type $recipients
|
||||||
|
* @param type $delivery
|
||||||
|
* @param type $dontcheck
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function set_details($mail_id, $islocal, $quotamb, $recipients,$delivery="dovecot",$dontcheck=false) {
|
function set_details($mail_id, $islocal, $quotamb, $recipients,$delivery="dovecot",$dontcheck=false) {
|
||||||
global $err,$db,$cuid,$quota,$dom,$hooks;
|
global $err,$db,$cuid,$quota,$dom,$hooks;
|
||||||
$delivery=mysql_real_escape_string($delivery);
|
$delivery=mysql_real_escape_string($delivery);
|
||||||
|
@ -669,7 +850,7 @@ ORDER BY
|
||||||
$db->query("UPDATE mailbox SET quota=".intval($quotamb)." WHERE address_id=".$mail_id.";");
|
$db->query("UPDATE mailbox SET quota=".intval($quotamb)." WHERE address_id=".$mail_id.";");
|
||||||
}
|
}
|
||||||
|
|
||||||
$recipients=preg_replace('/[\r\t\s]/', "\n", $recipients); // Handle space AND new line
|
$recipients=preg_replace('/[\r \s]/', "\n", $recipients); // Handle space AND new line
|
||||||
$r=explode("\n",$recipients);
|
$r=explode("\n",$recipients);
|
||||||
$red="";
|
$red="";
|
||||||
foreach($r as $m) {
|
foreach($r as $m) {
|
||||||
|
@ -686,13 +867,22 @@ ORDER BY
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** A wrapper used by mailman class to create it's needed addresses
|
/** A wrapper used by mailman class to create it's needed addresses
|
||||||
* @ param : $dom_id , the domain id associated to a given address
|
* @ param : $dom_id , the domain id associated to a given address
|
||||||
* @ param : $m , the left part of the mail address being created
|
* @ param : $m , the left part of the mail address being created
|
||||||
* @ param : $delivery , the delivery used to deliver the mail
|
* @ param : $delivery , the delivery used to deliver the mail
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mail $mail
|
||||||
|
* @param type $dom_id
|
||||||
|
* @param type $m
|
||||||
|
* @param type $delivery
|
||||||
|
*/
|
||||||
function add_wrapper($dom_id,$m,$delivery){
|
function add_wrapper($dom_id,$m,$delivery){
|
||||||
global $err,$db,$mail;
|
global $err,$db,$mail;
|
||||||
$err->log("mail","add_wrapper","creating $delivery $m address");
|
$err->log("mail","add_wrapper","creating $delivery $m address");
|
||||||
|
@ -702,7 +892,7 @@ ORDER BY
|
||||||
// FIXME return error code
|
// FIXME return error code
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** A function used to create an alias for a specific address
|
/** A function used to create an alias for a specific address
|
||||||
* @ param : $dom_id , the domain sql identifier
|
* @ param : $dom_id , the domain sql identifier
|
||||||
* @ param : $m , the alias we want to create
|
* @ param : $m , the alias we want to create
|
||||||
|
@ -712,6 +902,17 @@ ORDER BY
|
||||||
* @param string $alias
|
* @param string $alias
|
||||||
* @param string $dom_id
|
* @param string $dom_id
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mail $mail
|
||||||
|
* @param type $dom_id
|
||||||
|
* @param type $m
|
||||||
|
* @param type $alias
|
||||||
|
* @param type $type
|
||||||
|
* @param type $dontcheck
|
||||||
|
*/
|
||||||
function create_alias($dom_id,$m,$alias,$type="",$dontcheck=false) {
|
function create_alias($dom_id,$m,$alias,$type="",$dontcheck=false) {
|
||||||
global $err,$db,$mail;
|
global $err,$db,$mail;
|
||||||
$err->log("mail","create_alias","creating $m alias for $alias type $type");
|
$err->log("mail","create_alias","creating $m alias for $alias type $type");
|
||||||
|
@ -723,22 +924,35 @@ ORDER BY
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** A wrapper used by mailman class to create it's needed addresses
|
/** A wrapper used by mailman class to create it's needed addresses
|
||||||
* @ param : $mail_id , the mysql id of the mail address we want to delete
|
* @ param : $mail_id , the mysql id of the mail address we want to delete
|
||||||
* of the email for the current acccount.
|
* of the email for the current acccount.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @param type $mail_id
|
||||||
|
*/
|
||||||
function del_wrapper($mail_id){
|
function del_wrapper($mail_id){
|
||||||
global $err,$db;
|
global $err,$db;
|
||||||
$err->log("mail","del_wrapper");
|
$err->log("mail","del_wrapper");
|
||||||
$this->delete($mail_id);
|
$this->delete($mail_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Export the mail information of an account
|
/** Export the mail information of an account
|
||||||
* @return: str, string containing the complete configuration
|
* @return: str, string containing the complete configuration
|
||||||
* of the email for the current acccount.
|
* of the email for the current acccount.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mail $mail_localbox
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function alternc_export_conf() {
|
function alternc_export_conf() {
|
||||||
global $db,$err,$mail_localbox;
|
global $db,$err,$mail_localbox;
|
||||||
$err->log("mail","export");
|
$err->log("mail","export");
|
||||||
|
@ -775,11 +989,17 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/**
|
/**
|
||||||
* Return the list of allowed slave accounts (secondary-mx)
|
* Return the list of allowed slave accounts (secondary-mx)
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function enum_slave_account() {
|
function enum_slave_account() {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$db->query("SELECT login,pass FROM mxaccount;");
|
$db->query("SELECT login,pass FROM mxaccount;");
|
||||||
|
@ -791,13 +1011,21 @@ ORDER BY
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/**
|
/**
|
||||||
* Check for a slave account (secondary mx)
|
* Check for a slave account (secondary mx)
|
||||||
* @param string $login the login to check
|
* @param string $login the login to check
|
||||||
* @param string $pass the password to check
|
* @param string $pass the password to check
|
||||||
* @return boolean TRUE if the password is correct, or FALSE if an error occurred.
|
* @return boolean TRUE if the password is correct, or FALSE if an error occurred.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $login
|
||||||
|
* @param type $pass
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function check_slave_account($login,$pass) {
|
function check_slave_account($login,$pass) {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$login=mysql_real_escape_string($login);
|
$login=mysql_real_escape_string($login);
|
||||||
|
@ -810,9 +1038,16 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Out (echo) the complete hosted domain list :
|
/** Out (echo) the complete hosted domain list :
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $format
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function echo_domain_list($format=null) {
|
function echo_domain_list($format=null) {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$db->query("SELECT domaine FROM domaines WHERE gesmx=1 ORDER BY domaine");
|
$db->query("SELECT domaine FROM domaines WHERE gesmx=1 ORDER BY domaine");
|
||||||
|
@ -838,13 +1073,21 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/**
|
/**
|
||||||
* Add a slave account that will be allowed to access the mxdomain list
|
* Add a slave account that will be allowed to access the mxdomain list
|
||||||
* @param string $login the login to add
|
* @param string $login the login to add
|
||||||
* @param string $pass the password to add
|
* @param string $pass the password to add
|
||||||
* @return boolean TRUE if the account has been created, or FALSE if an error occurred.
|
* @return boolean TRUE if the account has been created, or FALSE if an error occurred.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $login
|
||||||
|
* @param type $pass
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function add_slave_account($login,$pass) {
|
function add_slave_account($login,$pass) {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$login=mysql_real_escape_string($login);
|
$login=mysql_real_escape_string($login);
|
||||||
|
@ -859,11 +1102,18 @@ ORDER BY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/**
|
/**
|
||||||
* Remove a slave account
|
* Remove a slave account
|
||||||
* @param string $login the login to delete
|
* @param string $login the login to delete
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $login
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function del_slave_account($login) {
|
function del_slave_account($login) {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$login=mysql_real_escape_string($login);
|
$login=mysql_real_escape_string($login);
|
||||||
|
@ -871,7 +1121,7 @@ ORDER BY
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** hook function called by AlternC when a domain is created for
|
/** hook function called by AlternC when a domain is created for
|
||||||
* the current user account using the SLAVE DOMAIN feature
|
* the current user account using the SLAVE DOMAIN feature
|
||||||
* This function create a CATCHALL to the master domain
|
* This function create a CATCHALL to the master domain
|
||||||
|
@ -879,6 +1129,13 @@ ORDER BY
|
||||||
* @param string $target_domain Master domain
|
* @param string $target_domain Master domain
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $domain_id
|
||||||
|
* @param type $target_domain
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function hook_dom_add_slave_domain($domain_id,$target_domain) {
|
function hook_dom_add_slave_domain($domain_id,$target_domain) {
|
||||||
global $err;
|
global $err;
|
||||||
$err->log("mail","hook_dom_add_slave_domain",$domain_id);
|
$err->log("mail","hook_dom_add_slave_domain",$domain_id);
|
||||||
|
@ -886,7 +1143,7 @@ ORDER BY
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** hook function called by AlternC when a domain is created for
|
/** hook function called by AlternC when a domain is created for
|
||||||
* the current user account
|
* the current user account
|
||||||
* This function create a postmaster mail which is an alias to LOGIN @ FQDN
|
* This function create a postmaster mail which is an alias to LOGIN @ FQDN
|
||||||
|
@ -894,6 +1151,15 @@ ORDER BY
|
||||||
* @param string $domain_id Domain that has just been created
|
* @param string $domain_id Domain that has just been created
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global string $L_FQDN
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @param type $domain_id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function hook_dom_add_mx_domain($domain_id) {
|
function hook_dom_add_mx_domain($domain_id) {
|
||||||
global $err, $mem, $L_FQDN,$db;
|
global $err, $mem, $L_FQDN,$db;
|
||||||
$err->log("mail","hook_dom_add_mx_domain",$domain_id);
|
$err->log("mail","hook_dom_add_mx_domain",$domain_id);
|
||||||
|
@ -910,12 +1176,16 @@ ORDER BY
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** hook function called by AlternC-upnp to know which open
|
/** hook function called by AlternC-upnp to know which open
|
||||||
* tcp or udp ports this class requires or suggests
|
* tcp or udp ports this class requires or suggests
|
||||||
* @return array a key => value list of port protocol name mandatory values
|
* @return array a key => value list of port protocol name mandatory values
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function hook_upnp_list() {
|
function hook_upnp_list() {
|
||||||
return array(
|
return array(
|
||||||
"imap" => array("port" => 143, "protocol" => "tcp", "mandatory" => 1),
|
"imap" => array("port" => 143, "protocol" => "tcp", "mandatory" => 1),
|
||||||
|
|
|
@ -39,25 +39,34 @@ class m_mem {
|
||||||
var $user;
|
var $user;
|
||||||
/** Tableau contenant les champs de la table "local" du membre courant
|
/** Tableau contenant les champs de la table "local" du membre courant
|
||||||
* Ce tableau est utilisable globalement par toutes les classes filles.
|
* Ce tableau est utilisable globalement par toutes les classes filles.
|
||||||
* Note : les champs de "local" sont spécifiques à l'hébergeur.
|
* Note : les champs de "local" sont sp<EFBFBD>cifiques <EFBFBD> l'h<EFBFBD>bergeur.
|
||||||
*/
|
*/
|
||||||
var $local;
|
var $local;
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/**
|
/**
|
||||||
* Constructeur
|
* Constructeur
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function m_mem() {
|
function m_mem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/**
|
/**
|
||||||
* Password kind used in this class (hook for admin class)
|
* Password kind used in this class (hook for admin class)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function alternc_password_policy() {
|
function alternc_password_policy() {
|
||||||
return array("mem"=>"AlternC's account password");
|
return array("mem"=>"AlternC's account password");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
$obj = array(
|
$obj = array(
|
||||||
'title' => _("Settings"),
|
'title' => _("Settings"),
|
||||||
|
@ -69,15 +78,17 @@ class m_mem {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Check that the current user is an admnistrator.
|
/** Check that the current user is an admnistrator.
|
||||||
* @return boolean TRUE if we are super user, or FALSE if we are not.
|
* @return boolean TRUE if we are super user, or FALSE if we are not.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function checkright() {
|
function checkright() {
|
||||||
return ($this->user["su"]=="1");
|
return ($this->user["su"]=="1");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Start a session in the web desktop. Check username and password.
|
/** Start a session in the web desktop. Check username and password.
|
||||||
* <b>Note : </b>If the user entered a bas password, the failure will be logged
|
* <b>Note : </b>If the user entered a bas password, the failure will be logged
|
||||||
* and told to the corresponding user on next successfull login.
|
* and told to the corresponding user on next successfull login.
|
||||||
|
@ -85,11 +96,22 @@ class m_mem {
|
||||||
* @param $password string User Password.
|
* @param $password string User Password.
|
||||||
* @return boolean TRUE if the user has been successfully connected, or FALSE if an error occured.
|
* @return boolean TRUE if the user has been successfully connected, or FALSE if an error occured.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_authip $authip
|
||||||
|
* @global m_admin $admin
|
||||||
|
* @param type $username
|
||||||
|
* @param type $password
|
||||||
|
* @param type $restrictip
|
||||||
|
* @param type $authip_token
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function login($username,$password,$restrictip=0,$authip_token=false) {
|
function login($username,$password,$restrictip=0,$authip_token=false) {
|
||||||
global $db,$err,$cuid,$authip,$admin;
|
global $db,$err,$cuid,$authip,$admin;
|
||||||
$err->log("mem","login",$username);
|
$err->log("mem","login",$username);
|
||||||
// $username=addslashes($username);
|
|
||||||
// $password=addslashes($password);
|
|
||||||
$db->query("select * from membres where login='$username';");
|
$db->query("select * from membres where login='$username';");
|
||||||
if ($db->num_rows()==0) {
|
if ($db->num_rows()==0) {
|
||||||
$err->raise("mem",_("User or password incorrect"));
|
$err->raise("mem",_("User or password incorrect"));
|
||||||
|
@ -113,7 +135,6 @@ class m_mem {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthIP
|
|
||||||
$allowed_ip=false;
|
$allowed_ip=false;
|
||||||
if ( $authip_token ) $allowed_ip = $this->authip_tokencheck($authip_token);
|
if ( $authip_token ) $allowed_ip = $this->authip_tokencheck($authip_token);
|
||||||
|
|
||||||
|
@ -122,27 +143,21 @@ class m_mem {
|
||||||
if ( $authip->is_in_subnet(get_remote_ip(), $v['ip'], $v['subnet']) ) $allowed=true ;
|
if ( $authip->is_in_subnet(get_remote_ip(), $v['ip'], $v['subnet']) ) $allowed=true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error if there is rules, the IP is not allowed and it's not in the whitelisted IP
|
|
||||||
if ( sizeof($aga)>1 && !$allowed_ip && !$authip->is_wl(get_remote_ip()) ) {
|
if ( sizeof($aga)>1 && !$allowed_ip && !$authip->is_wl(get_remote_ip()) ) {
|
||||||
$err->raise("mem",_("Your IP isn't allowed to connect"));
|
$err->raise("mem",_("Your IP isn't allowed to connect"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// End AuthIP
|
|
||||||
|
|
||||||
if ($restrictip) {
|
if ($restrictip) {
|
||||||
$ip="'".get_remote_ip()."'";
|
$ip="'".get_remote_ip()."'";
|
||||||
} else $ip="''";
|
} else $ip="''";
|
||||||
/* Close sessions that are more than 2 days old. */
|
|
||||||
$db->query("DELETE FROM sessions WHERE DATE_ADD(ts,INTERVAL 2 DAY)<NOW();");
|
$db->query("DELETE FROM sessions WHERE DATE_ADD(ts,INTERVAL 2 DAY)<NOW();");
|
||||||
/* Delete old impersonation */
|
|
||||||
if ( isset($_COOKIE["oldid"]) ) setcookie('oldid','',0,'/');
|
if ( isset($_COOKIE["oldid"]) ) setcookie('oldid','',0,'/');
|
||||||
/* Open the session : */
|
|
||||||
$sess=md5(uniqid(mt_rand()));
|
$sess=md5(uniqid(mt_rand()));
|
||||||
$_REQUEST["session"]=$sess;
|
$_REQUEST["session"]=$sess;
|
||||||
$db->query("insert into sessions (sid,ip,uid) values ('$sess',$ip,'$cuid');");
|
$db->query("insert into sessions (sid,ip,uid) values ('$sess',$ip,'$cuid');");
|
||||||
setcookie("session",$sess,0,"/");
|
setcookie("session",$sess,0,"/");
|
||||||
$err->error=0;
|
$err->error=0;
|
||||||
/* Fill in $local */
|
|
||||||
$db->query("SELECT * FROM local WHERE uid='$cuid';");
|
$db->query("SELECT * FROM local WHERE uid='$cuid';");
|
||||||
if ($db->num_rows()) {
|
if ($db->num_rows()) {
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
|
@ -151,7 +166,6 @@ class m_mem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Start a session as another user from an administrator account.
|
/** Start a session as another user from an administrator account.
|
||||||
* This function is not the same as su. setid connect the current user in the destination
|
* This function is not the same as su. setid connect the current user in the destination
|
||||||
* account (for good), and su allow any user to become another account for some commands only.
|
* account (for good), and su allow any user to become another account for some commands only.
|
||||||
|
@ -160,6 +174,16 @@ class m_mem {
|
||||||
* @param $id integer User id where we will connect to.
|
* @param $id integer User id where we will connect to.
|
||||||
* @return boolean TRUE if the user has been successfully connected, FALSE else.
|
* @return boolean TRUE if the user has been successfully connected, FALSE else.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mysql $mysql
|
||||||
|
* @global m_quota $quota
|
||||||
|
* @param type $id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function setid($id) {
|
function setid($id) {
|
||||||
global $db,$err,$cuid,$mysql,$quota;
|
global $db,$err,$cuid,$mysql,$quota;
|
||||||
$err->log("mem","setid",$id);
|
$err->log("mem","setid",$id);
|
||||||
|
@ -171,7 +195,6 @@ class m_mem {
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
$this->user=$db->Record;
|
$this->user=$db->Record;
|
||||||
$cuid=$db->f("uid");
|
$cuid=$db->f("uid");
|
||||||
// And recreate the $db->dbus
|
|
||||||
$mysql->reload_dbus();
|
$mysql->reload_dbus();
|
||||||
|
|
||||||
$ip=get_remote_ip();
|
$ip=get_remote_ip();
|
||||||
|
@ -180,7 +203,6 @@ class m_mem {
|
||||||
$db->query("insert into sessions (sid,ip,uid) values ('$sess','$ip','$cuid');");
|
$db->query("insert into sessions (sid,ip,uid) values ('$sess','$ip','$cuid');");
|
||||||
setcookie("session",$sess,0,"/");
|
setcookie("session",$sess,0,"/");
|
||||||
$err->error=0;
|
$err->error=0;
|
||||||
/* Fill in $local */
|
|
||||||
$db->query("SELECT * FROM local WHERE uid='$cuid';");
|
$db->query("SELECT * FROM local WHERE uid='$cuid';");
|
||||||
if ($db->num_rows()) {
|
if ($db->num_rows()) {
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
|
@ -190,9 +212,13 @@ class m_mem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/** Suite <EFBFBD> la connexion de l'utilisateur, r<EFBFBD>initialise ses param<EFBFBD>tres de derni<EFBFBD>re connexion
|
||||||
/** Suite à la connexion de l'utilisateur, réinitialise ses paramètres de dernière connexion
|
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
*/
|
||||||
function resetlast() {
|
function resetlast() {
|
||||||
global $db,$cuid;
|
global $db,$cuid;
|
||||||
$ip=addslashes(getenv("REMOTE_HOST"));
|
$ip=addslashes(getenv("REMOTE_HOST"));
|
||||||
|
@ -200,6 +226,13 @@ class m_mem {
|
||||||
$db->query("UPDATE membres SET lastlogin=NOW(), lastfail=0, lastip='$ip' WHERE uid='$cuid';");
|
$db->query("UPDATE membres SET lastlogin=NOW(), lastfail=0, lastip='$ip' WHERE uid='$cuid';");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $bis
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function authip_token($bis=false) {
|
function authip_token($bis=false) {
|
||||||
global $db,$cuid;
|
global $db,$cuid;
|
||||||
$db->query("select pass from membres where uid='$cuid';");
|
$db->query("select pass from membres where uid='$cuid';");
|
||||||
|
@ -212,12 +245,22 @@ class m_mem {
|
||||||
/**
|
/**
|
||||||
* @param boolean $t
|
* @param boolean $t
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $t
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function authip_tokencheck($t) {
|
function authip_tokencheck($t) {
|
||||||
if ($t==$this->authip_token() || $t==$this->authip_token(true) ) return true;
|
if ($t==$this->authip_token() || $t==$this->authip_token(true) ) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Faut finir de l'implémenter :) * /
|
// Faut finir de l'impl<70>menter :) *
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function authip_class() {
|
function authip_class() {
|
||||||
global $cuid;
|
global $cuid;
|
||||||
$c = Array();
|
$c = Array();
|
||||||
|
@ -227,20 +270,26 @@ class m_mem {
|
||||||
|
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
/* */
|
// *
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/** V<EFBFBD>rifie que la session courante est correcte (cookie ok et ip valide).
|
||||||
/** Vérifie que la session courante est correcte (cookie ok et ip valide).
|
* Si besoin, et si r<EFBFBD>ception des champs username & password, cr<EFBFBD>e une nouvelle
|
||||||
* Si besoin, et si réception des champs username & password, crée une nouvelle
|
* session pour l'utilisateur annonc<EFBFBD>.
|
||||||
* session pour l'utilisateur annoncé.
|
* Cette fonction doit <EFBFBD>tre appell<EFBFBD>e <EFBFBD> chaque page devant <EFBFBD>tre authentifi<EFBFBD>e.
|
||||||
* Cette fonction doit être appellée à chaque page devant être authentifiée.
|
* et AVANT d'<EFBFBD>mettre des donn<EFBFBD>es. (un cookie peut <EFBFBD>tre envoy<EFBFBD>)
|
||||||
* et AVANT d'émettre des données. (un cookie peut être envoyé)
|
|
||||||
* @global string $session Le cookie de session eventuel
|
* @global string $session Le cookie de session eventuel
|
||||||
* @global string $username/password le login/pass de l'utilisateur
|
* @global string $username/password le login/pass de l'utilisateur
|
||||||
* @return boolean TRUE si la session est correcte, FALSE sinon.
|
* @return boolean TRUE si la session est correcte, FALSE sinon.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function checkid() {
|
function checkid() {
|
||||||
global $db,$err,$cuid,$restrictip,$authip;
|
global $db,$err,$cuid;
|
||||||
if (isset($_REQUEST["username"])) {
|
if (isset($_REQUEST["username"])) {
|
||||||
if ( empty($_REQUEST['password']) ) {
|
if ( empty($_REQUEST['password']) ) {
|
||||||
$err->raise("mem",_("Missing password"));
|
$err->raise("mem",_("Missing password"));
|
||||||
|
@ -279,7 +328,6 @@ class m_mem {
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
$this->user=$db->Record;
|
$this->user=$db->Record;
|
||||||
$err->error=0;
|
$err->error=0;
|
||||||
/* Remplissage de $local */
|
|
||||||
$db->query("SELECT * FROM local WHERE uid='$cuid';");
|
$db->query("SELECT * FROM local WHERE uid='$cuid';");
|
||||||
if ($db->num_rows()) {
|
if ($db->num_rows()) {
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
|
@ -288,11 +336,19 @@ class m_mem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/** Change l'identit<69> d'un utilisateur temporairement.
|
||||||
/** Change l'identité d'un utilisateur temporairement.
|
* @global string $uid Utilisateur dont on prends l'identit<EFBFBD>
|
||||||
* @global string $uid Utilisateur dont on prends l'identité
|
|
||||||
* @return TRUE si la session est correcte, FALSE sinon.
|
* @return TRUE si la session est correcte, FALSE sinon.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $mysql
|
||||||
|
* @param type $uid
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function su($uid) {
|
function su($uid) {
|
||||||
global $cuid,$db,$err,$mysql;
|
global $cuid,$db,$err,$mysql;
|
||||||
if (!$this->olduid)
|
if (!$this->olduid)
|
||||||
|
@ -306,33 +362,44 @@ class m_mem {
|
||||||
$this->user=$db->Record;
|
$this->user=$db->Record;
|
||||||
$cuid=$db->f("uid");
|
$cuid=$db->f("uid");
|
||||||
|
|
||||||
// And recreate the $db->dbus
|
|
||||||
$mysql->reload_dbus();
|
$mysql->reload_dbus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Retourne a l'identite d'origine de l'utilisateur apres su.
|
/** Retourne a l'identite d'origine de l'utilisateur apres su.
|
||||||
* @return boolean TRUE si la session est correcte, FALSE sinon.
|
* @return boolean TRUE si la session est correcte, FALSE sinon.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mysql $mysql
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function unsu() {
|
function unsu() {
|
||||||
global $cuid,$mysql;
|
global $cuid,$mysql;
|
||||||
if (!$this->olduid)
|
if (!$this->olduid)
|
||||||
return false;
|
return false;
|
||||||
$this->su($this->olduid);
|
$this->su($this->olduid);
|
||||||
$this->olduid=0;
|
$this->olduid=0;
|
||||||
// And recreate the $db->dbus
|
|
||||||
$mysql->reload_dbus();
|
$mysql->reload_dbus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Termine une session du bureau virtuel (logout)
|
/** Termine une session du bureau virtuel (logout)
|
||||||
* @return boolean TRUE si la session a bien été détruite, FALSE sinon.
|
* @return boolean TRUE si la session a bien <EFBFBD>t<EFBFBD> d<EFBFBD>truite, FALSE sinon.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global array $classes
|
||||||
|
* @global m_hooks $hooks
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function del_session() {
|
function del_session() {
|
||||||
global $db,$user,$err,$cuid,$classes,$hooks;
|
global $db,$err,$cuid,$classes,$hooks;
|
||||||
$_COOKIE["session"]=addslashes(isset($_COOKIE["session"])?$_COOKIE["session"]:'');
|
$_COOKIE["session"]=addslashes(isset($_COOKIE["session"])?$_COOKIE["session"]:'');
|
||||||
setcookie("session","",0,"/");
|
setcookie("session","",0,"/");
|
||||||
setcookie("oldid","",0,"/");
|
setcookie("oldid","",0,"/");
|
||||||
|
@ -360,13 +427,7 @@ class m_mem {
|
||||||
$err->error=0;
|
$err->error=0;
|
||||||
|
|
||||||
# Invoker le logout dans toutes les autres classes
|
# Invoker le logout dans toutes les autres classes
|
||||||
/*
|
|
||||||
foreach($classes as $c) {
|
|
||||||
if (method_exists($GLOBALS[$c],"alternc_del_session")) {
|
|
||||||
$GLOBALS[$c]->alternc_del_session();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
$hooks->invoke("alternc_del_session");
|
$hooks->invoke("alternc_del_session");
|
||||||
|
|
||||||
session_unset();
|
session_unset();
|
||||||
|
@ -374,13 +435,23 @@ class m_mem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Change le mot de passe de l'utilisateur courant.
|
/** Change le mot de passe de l'utilisateur courant.
|
||||||
* @param string $oldpass Ancien mot de passe.
|
* @param string $oldpass Ancien mot de passe.
|
||||||
* @param string $newpass Nouveau mot de passe
|
* @param string $newpass Nouveau mot de passe
|
||||||
* @param string $newpass2 Nouveau mot de passe (à nouveau)
|
* @param string $newpass2 Nouveau mot de passe (<EFBFBD> nouveau)
|
||||||
* @return boolean TRUE si le mot de passe a été changé, FALSE sinon.
|
* @return boolean TRUE si le mot de passe a <EFBFBD>t<EFBFBD> chang<EFBFBD>, FALSE sinon.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_admin $admin
|
||||||
|
* @param type $oldpass
|
||||||
|
* @param type $newpass
|
||||||
|
* @param type $newpass2
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function passwd($oldpass,$newpass,$newpass2) {
|
function passwd($oldpass,$newpass,$newpass2) {
|
||||||
global $db,$err,$cuid,$admin;
|
global $db,$err,$cuid,$admin;
|
||||||
$err->log("mem","passwd");
|
$err->log("mem","passwd");
|
||||||
|
@ -411,11 +482,18 @@ class m_mem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/** Change les pr<EFBFBD>f<EFBFBD>rences administrateur d'un compte
|
||||||
/** Change les préférences administrateur d'un compte
|
|
||||||
* @param integer $admlist Mode de visualisation des membres (0=large 1=courte)
|
* @param integer $admlist Mode de visualisation des membres (0=large 1=courte)
|
||||||
* @return boolean TRUE si les préférences ont été changées, FALSE sinon.
|
* @return boolean TRUE si les pr<EFBFBD>f<EFBFBD>rences ont <EFBFBD>t<EFBFBD> chang<EFBFBD>es, FALSE sinon.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $admlist
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function adminpref($admlist) {
|
function adminpref($admlist) {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("mem","admlist");
|
$err->log("mem","admlist");
|
||||||
|
@ -428,13 +506,21 @@ class m_mem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Envoie en mail le mot de passe d'un compte.
|
/** Envoie en mail le mot de passe d'un compte.
|
||||||
* <b>Note : </b>On ne peut demander le mot de passe qu'une seule fois par jour.
|
* <b>Note : </b>On ne peut demander le mot de passe qu'une seule fois par jour.
|
||||||
* TODO : Translate this mail into the localization program.
|
* TODO : Translate this mail into the localization program.
|
||||||
* TODO : Check this function's !
|
* TODO : Check this function's !
|
||||||
* @return boolean TRUE si le mot de passe a été envoyé avec succès, FALSE sinon.
|
* @return boolean TRUE si le mot de passe a <EFBFBD>t<EFBFBD> envoy<EFBFBD> avec succ<EFBFBD>s, FALSE sinon.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global string $L_HOSTING
|
||||||
|
* @global string $L_FQDN
|
||||||
|
* @param type $login
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function send_pass($login) {
|
function send_pass($login) {
|
||||||
global $err,$db,$L_HOSTING,$L_FQDN;
|
global $err,$db,$L_HOSTING,$L_FQDN;
|
||||||
$err->log("mem","send_pass");
|
$err->log("mem","send_pass");
|
||||||
|
@ -472,12 +558,21 @@ Cordially.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/** Change le mail d'un membre (premi<EFBFBD>re etape, envoi du CookiE)
|
||||||
/** Change le mail d'un membre (première etape, envoi du CookiE)
|
|
||||||
* TODO : insert this mail string into the localization system
|
* TODO : insert this mail string into the localization system
|
||||||
* @param string $newmail Nouveau mail souhaité pour le membre.
|
* @param string $newmail Nouveau mail souhait<EFBFBD> pour le membre.
|
||||||
* @return string le cookie si le mail a bien été envoyé, FALSE sinon
|
* @return string le cookie si le mail a bien <EFBFBD>t<EFBFBD> envoy<EFBFBD>, FALSE sinon
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global string $L_HOSTING
|
||||||
|
* @global string $L_FQDN
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $newmail
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function ChangeMail1($newmail) {
|
function ChangeMail1($newmail) {
|
||||||
global $err,$db,$L_HOSTING,$L_FQDN,$cuid;
|
global $err,$db,$L_HOSTING,$L_FQDN,$cuid;
|
||||||
$err->log("mem","changemail1",$newmail);
|
$err->log("mem","changemail1",$newmail);
|
||||||
|
@ -488,9 +583,7 @@ Cordially.
|
||||||
}
|
}
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
|
|
||||||
// un cookie de 20 caractères pour le mail
|
|
||||||
$COOKIE=substr(md5(uniqid(rand(), true)),0,20);
|
$COOKIE=substr(md5(uniqid(rand(), true)),0,20);
|
||||||
// et de 6 pour la clé à entrer. ca me semble suffisant...
|
|
||||||
$KEY=substr(md5(uniqid(rand(), true)),0,6);
|
$KEY=substr(md5(uniqid(rand(), true)),0,6);
|
||||||
$link="https://$L_FQDN/mem_cm.php?usr=$cuid&cookie=$COOKIE";
|
$link="https://$L_FQDN/mem_cm.php?usr=$cuid&cookie=$COOKIE";
|
||||||
$txt=sprintf(_("Hello,
|
$txt=sprintf(_("Hello,
|
||||||
|
@ -513,22 +606,30 @@ again, please contact your server's administrator.
|
||||||
Cordially.
|
Cordially.
|
||||||
"), $db->f("login"), $L_HOSTING, $link);
|
"), $db->f("login"), $L_HOSTING, $link);
|
||||||
mail($newmail,"Email modification request on $L_HOSTING",$txt,"From: postmaster@$L_FQDN\nReply-to: postmaster@$L_FQDN");
|
mail($newmail,"Email modification request on $L_HOSTING",$txt,"From: postmaster@$L_FQDN\nReply-to: postmaster@$L_FQDN");
|
||||||
// Supprime les demandes précédentes de ce compte !
|
|
||||||
$db->query("DELETE FROM chgmail WHERE uid='$cuid';");
|
$db->query("DELETE FROM chgmail WHERE uid='$cuid';");
|
||||||
$db->query("INSERT INTO chgmail (cookie,ckey,uid,mail,ts) VALUES ('$COOKIE','$KEY','$cuid','$newmail',".time().");");
|
$db->query("INSERT INTO chgmail (cookie,ckey,uid,mail,ts) VALUES ('$COOKIE','$KEY','$cuid','$newmail',".time().");");
|
||||||
// Supprime les cookies de la veille :)
|
|
||||||
$lts=time()-86400;
|
$lts=time()-86400;
|
||||||
$db->query("DELETE FROM chgmail WHERE ts<'$lts';");
|
$db->query("DELETE FROM chgmail WHERE ts<'$lts';");
|
||||||
return $KEY;
|
return $KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/** Change le mail d'un membre (seconde etape, CookiE+cl<EFBFBD> = application)
|
||||||
/** Change le mail d'un membre (seconde etape, CookiE+clé = application)
|
* @param string $COOKIE Cookie envoy<EFBFBD> par mail
|
||||||
* @param string $COOKIE Cookie envoyé par mail
|
* @param string $KEY cl<EFBFBD> affich<EFBFBD>e <EFBFBD> l'<EFBFBD>cran
|
||||||
* @param string $KEY clé affichée à l'écran
|
* @param integer $uid Utilisateur concern<EFBFBD> (on est hors session)
|
||||||
* @param integer $uid Utilisateur concerné (on est hors session)
|
* @return boolean TRUE si le mail a bien <EFBFBD>t<EFBFBD> modifi<EFBFBD>, FALSE sinon
|
||||||
* @return boolean TRUE si le mail a bien été modifié, FALSE sinon
|
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global string $L_HOSTING
|
||||||
|
* @global string $L_FQDN
|
||||||
|
* @param type $COOKIE
|
||||||
|
* @param type $KEY
|
||||||
|
* @param type $uid
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function ChangeMail2($COOKIE,$KEY,$uid) {
|
function ChangeMail2($COOKIE,$KEY,$uid) {
|
||||||
global $err,$db,$L_HOSTING,$L_FQDN;
|
global $err,$db,$L_HOSTING,$L_FQDN;
|
||||||
$err->log("mem","changemail2",$uid);
|
$err->log("mem","changemail2",$uid);
|
||||||
|
@ -539,39 +640,52 @@ Cordially.
|
||||||
}
|
}
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
|
|
||||||
// met à jour le compte :
|
|
||||||
$db->query("UPDATE membres SET mail='".$db->f("mail")."' WHERE uid='$uid';");
|
$db->query("UPDATE membres SET mail='".$db->f("mail")."' WHERE uid='$uid';");
|
||||||
|
|
||||||
$db->query("DELETE FROM chgmail WHERE uid='$uid';");
|
$db->query("DELETE FROM chgmail WHERE uid='$uid';");
|
||||||
// Supprime les cookies de la veille :)
|
|
||||||
$lts=time()-86400;
|
$lts=time()-86400;
|
||||||
$db->query("DELETE FROM chgmail WHERE ts<'$lts';");
|
$db->query("DELETE FROM chgmail WHERE ts<'$lts';");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/** Modifie le param<EFBFBD>tre d'aide en ligne (1/0)
|
||||||
/** Modifie le paramètre d'aide en ligne (1/0)
|
|
||||||
* @param integer $show Faut-il (1) ou non (0) afficher l'aide en ligne
|
* @param integer $show Faut-il (1) ou non (0) afficher l'aide en ligne
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $show
|
||||||
|
*/
|
||||||
function set_help_param($show) {
|
function set_help_param($show) {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("mem","set_help_param",$show);
|
$err->log("mem","set_help_param",$show);
|
||||||
$db->query("UPDATE membres SET show_help='$show' WHERE uid='$cuid';");
|
$db->query("UPDATE membres SET show_help='$show' WHERE uid='$cuid';");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/** Dit si l'aide en ligne est demand<EFBFBD>e
|
||||||
/** Dit si l'aide en ligne est demandée
|
* @return boolean TRUE si l'aide en ligne est demand<EFBFBD>e, FALSE sinon.
|
||||||
* @return boolean TRUE si l'aide en ligne est demandée, FALSE sinon.
|
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_help_param() {
|
function get_help_param() {
|
||||||
return $this->user["show_help"];
|
return $this->user["show_help"];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Affiche (echo) l'aide contextuelle
|
/** Affiche (echo) l'aide contextuelle
|
||||||
* @param integer $file Numéro de fichier d'aide à afficher.
|
* @param integer $file Num<EFBFBD>ro de fichier d'aide <EFBFBD> afficher.
|
||||||
* @return boolean TRUE si l'aide contextuelle a été trouvée, FALSE sinon
|
* @return boolean TRUE si l'aide contextuelle a <EFBFBD>t<EFBFBD> trouv<EFBFBD>e, FALSE sinon
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $file
|
||||||
|
* @param type $force
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function show_help($file,$force=false) {
|
function show_help($file,$force=false) {
|
||||||
global $err;
|
global $err;
|
||||||
if ($this->user["show_help"] || $force) {
|
if ($this->user["show_help"] || $force) {
|
||||||
|
@ -592,6 +706,13 @@ Cordially.
|
||||||
/**
|
/**
|
||||||
* @param integer $uid
|
* @param integer $uid
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $uid
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function get_creator_by_uid($uid) {
|
function get_creator_by_uid($uid) {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$err->log("dom","get_creator_by_uid");
|
$err->log("dom","get_creator_by_uid");
|
||||||
|
@ -602,11 +723,16 @@ Cordially.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/**
|
/**
|
||||||
* Exports all the personnal user related information for an account.
|
* Exports all the personnal user related information for an account.
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function alternc_export_conf() {
|
function alternc_export_conf() {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$err->log("mem","export");
|
$err->log("mem","export");
|
||||||
|
@ -626,6 +752,12 @@ Cordially.
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global int $uid
|
||||||
|
* @param type $v
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function session_tempo_params_get($v) {
|
function session_tempo_params_get($v) {
|
||||||
global $uid;
|
global $uid;
|
||||||
if (empty($_COOKIE['session'])) return false;
|
if (empty($_COOKIE['session'])) return false;
|
||||||
|
@ -641,6 +773,14 @@ Cordially.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global int $uid
|
||||||
|
* @param type $k
|
||||||
|
* @param type $v
|
||||||
|
* @param type $ecrase
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function session_tempo_params_set($k, $v, $ecrase=false) {
|
function session_tempo_params_set($k, $v, $ecrase=false) {
|
||||||
global $uid;
|
global $uid;
|
||||||
if (empty($_COOKIE['session'])) return false;
|
if (empty($_COOKIE['session'])) return false;
|
||||||
|
@ -658,6 +798,4 @@ Cordially.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* Classe Membre */
|
} /* Classe Membre */
|
||||||
|
|
||||||
?>
|
|
|
@ -30,13 +30,22 @@
|
||||||
*/
|
*/
|
||||||
class m_menu {
|
class m_menu {
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** Constructor
|
/** Constructor
|
||||||
* menu([$mid]) Constructeur de la classe menu, ne fait rien pour le moment
|
* menu([$mid]) Constructeur de la classe menu, ne fait rien pour le moment
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function m_menu() {
|
function m_menu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_hooks $hooks
|
||||||
|
* @global m_quota $quota
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function getmenu() {
|
function getmenu() {
|
||||||
global $hooks, $quota, $mem;
|
global $hooks, $quota, $mem;
|
||||||
|
|
||||||
|
@ -97,11 +106,23 @@ class m_menu {
|
||||||
return $lst;
|
return $lst;
|
||||||
} //getmenu
|
} //getmenu
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $a
|
||||||
|
* @param type $b
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function order_menu($a, $b) {
|
function order_menu($a, $b) {
|
||||||
// Use to order the menu with a usort
|
// Use to order the menu with a usort
|
||||||
return $a['pos'] > $b['pos'];
|
return $a['pos'] > $b['pos'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @global string $help_baseurl
|
||||||
|
* @global array $lang_translation
|
||||||
|
* @global array $locales
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function system_menu() {
|
function system_menu() {
|
||||||
// Here some needed menu who don't have a class
|
// Here some needed menu who don't have a class
|
||||||
global $help_baseurl, $lang_translation, $locales;
|
global $help_baseurl, $lang_translation, $locales;
|
||||||
|
|
|
@ -40,6 +40,13 @@ class DB_users extends DB_Sql {
|
||||||
/**
|
/**
|
||||||
* Creator
|
* Creator
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $empty
|
||||||
|
*/
|
||||||
function DB_users($empty=false) { // Sometimes we need to create this object with empty parameters, but by default we fill them with those of the current user's DB
|
function DB_users($empty=false) { // Sometimes we need to create this object with empty parameters, but by default we fill them with those of the current user's DB
|
||||||
global $cuid, $db, $err;
|
global $cuid, $db, $err;
|
||||||
|
|
||||||
|
@ -80,6 +87,10 @@ class m_mysql {
|
||||||
/** Constructor
|
/** Constructor
|
||||||
* m_mysql([$mid]) Constructeur de la classe m_mysql, initialise le membre concerne
|
* m_mysql([$mid]) Constructeur de la classe m_mysql, initialise le membre concerne
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
*/
|
||||||
function m_mysql() {
|
function m_mysql() {
|
||||||
global $cuid;
|
global $cuid;
|
||||||
if (!empty($cuid)) {
|
if (!empty($cuid)) {
|
||||||
|
@ -88,10 +99,18 @@ class m_mysql {
|
||||||
variable_get('sql_allow_users_backups', 1,'Set 1 to allow users to configure backup of their databases, 0 if you want do disable this feature. Warning: it will not stop configured backup made by sqlbackup.sh');
|
variable_get('sql_allow_users_backups', 1,'Set 1 to allow users to configure backup of their databases, 0 if you want do disable this feature. Warning: it will not stop configured backup made by sqlbackup.sh');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function reload_dbus() {
|
function reload_dbus() {
|
||||||
$this->dbus = new DB_users();
|
$this->dbus = new DB_users();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function list_db_servers() {
|
function list_db_servers() {
|
||||||
global $db;
|
global $db;
|
||||||
$db->query("select d.*, IFNULL(count(m.uid),0) as nb_users from db_servers d left join membres m on d.id = m.db_server_id group by d.id,m.db_server_id order by d.name,d.id;");
|
$db->query("select d.*, IFNULL(count(m.uid),0) as nb_users from db_servers d left join membres m on d.id = m.db_server_id group by d.id,m.db_server_id order by d.name,d.id;");
|
||||||
|
@ -102,6 +121,11 @@ class m_mysql {
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_quota $quota
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
global $quota;
|
global $quota;
|
||||||
$q = $quota->getquota("mysql");
|
$q = $quota->getquota("mysql");
|
||||||
|
@ -141,6 +165,10 @@ class m_mysql {
|
||||||
/**
|
/**
|
||||||
* Password kind used in this class (hook for admin class)
|
* Password kind used in this class (hook for admin class)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function alternc_password_policy() {
|
function alternc_password_policy() {
|
||||||
return array("mysql"=>"MySQL users");
|
return array("mysql"=>"MySQL users");
|
||||||
}
|
}
|
||||||
|
@ -152,6 +180,14 @@ class m_mysql {
|
||||||
* "dir" => Backup folder.
|
* "dir" => Backup folder.
|
||||||
* Returns an array (empty) if no databases
|
* Returns an array (empty) if no databases
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_bro $bro
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_dblist() {
|
function get_dblist() {
|
||||||
global $db,$err,$bro,$cuid;
|
global $db,$err,$bro,$cuid;
|
||||||
$err->log("mysql","get_dblist");
|
$err->log("mysql","get_dblist");
|
||||||
|
@ -170,6 +206,13 @@ class m_mysql {
|
||||||
* @return array returns an associative array with login and password
|
* @return array returns an associative array with login and password
|
||||||
* Returns FALSE if error
|
* Returns FALSE if error
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_err $err
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function php_myadmin_connect(){
|
function php_myadmin_connect(){
|
||||||
global $db,$cuid,$err;
|
global $db,$cuid,$err;
|
||||||
$err->log("mysql","php_myadmin_connect");
|
$err->log("mysql","php_myadmin_connect");
|
||||||
|
@ -201,6 +244,16 @@ class m_mysql {
|
||||||
* "gzip" => Does we compress the dumps ?
|
* "gzip" => Does we compress the dumps ?
|
||||||
* Returns FALSE if the user has no database of if the database does not exist.
|
* Returns FALSE if the user has no database of if the database does not exist.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_bro $bro
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $dbn
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_mysql_details($dbn) {
|
function get_mysql_details($dbn) {
|
||||||
global $db,$err,$bro,$mem,$cuid;
|
global $db,$err,$bro,$mem,$cuid;
|
||||||
$root=getuserpath();
|
$root=getuserpath();
|
||||||
|
@ -224,6 +277,13 @@ class m_mysql {
|
||||||
return array("enabled"=>true,"login"=>$db->f("login"),"db"=>$db->f("db"), "name"=>$dbn,"bck"=>$db->f("bck_mode"), "dir"=>substr($db->f("bck_dir"),strlen($root)), "size"=>$size, "pass"=>$db->f("pass"), "history"=>$db->f("bck_history"), "gzip"=>$db->f("bck_gzip"));
|
return array("enabled"=>true,"login"=>$db->f("login"),"db"=>$db->f("db"), "name"=>$dbn,"bck"=>$db->f("bck_mode"), "dir"=>substr($db->f("bck_dir"),strlen($root)), "size"=>$size, "pass"=>$db->f("pass"), "history"=>$db->f("bck_history"), "gzip"=>$db->f("bck_gzip"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $dbname
|
||||||
|
*/
|
||||||
function test_get_param($dbname){
|
function test_get_param($dbname){
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$db->query("SELECT ");
|
$db->query("SELECT ");
|
||||||
|
@ -237,6 +297,17 @@ class m_mysql {
|
||||||
* @return boolean if the database $user_$db has been successfully created, or FALSE if
|
* @return boolean if the database $user_$db has been successfully created, or FALSE if
|
||||||
* an error occured, such as over quota user.
|
* an error occured, such as over quota user.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_quota $quota
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_admin $admin
|
||||||
|
* @param type $dbn
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function add_db($dbn) {
|
function add_db($dbn) {
|
||||||
global $db,$err,$quota,$mem,$cuid,$admin;
|
global $db,$err,$quota,$mem,$cuid,$admin;
|
||||||
$err->log("mysql","add_db",$dbn);
|
$err->log("mysql","add_db",$dbn);
|
||||||
|
@ -318,6 +389,15 @@ class m_mysql {
|
||||||
* @return boolean if the database $user_$db has been successfully deleted, or FALSE if
|
* @return boolean if the database $user_$db has been successfully deleted, or FALSE if
|
||||||
* an error occured, such as db does not exist.
|
* an error occured, such as db does not exist.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $dbn
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function del_db($dbn) {
|
function del_db($dbn) {
|
||||||
global $db,$err,$mem,$cuid;
|
global $db,$err,$mem,$cuid;
|
||||||
$err->log("mysql","del_db",$dbn);
|
$err->log("mysql","del_db",$dbn);
|
||||||
|
@ -358,6 +438,20 @@ class m_mysql {
|
||||||
* @param $bck_dir string Directory relative to the user account where the backup will be stored
|
* @param $bck_dir string Directory relative to the user account where the backup will be stored
|
||||||
* @return boolean true if the backup parameters has been successfully changed, false if not.
|
* @return boolean true if the backup parameters has been successfully changed, false if not.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_bro $bro
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $dbn
|
||||||
|
* @param type $bck_mode
|
||||||
|
* @param type $bck_history
|
||||||
|
* @param type $bck_gzip
|
||||||
|
* @param type $bck_dir
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function put_mysql_backup($dbn,$bck_mode,$bck_history,$bck_gzip,$bck_dir) {
|
function put_mysql_backup($dbn,$bck_mode,$bck_history,$bck_gzip,$bck_dir) {
|
||||||
global $db,$err,$mem,$bro,$cuid;
|
global $db,$err,$mem,$bro,$cuid;
|
||||||
$err->log("mysql","put_mysql_backup");
|
$err->log("mysql","put_mysql_backup");
|
||||||
|
@ -411,6 +505,16 @@ class m_mysql {
|
||||||
* @param $password string new password (cleartext)
|
* @param $password string new password (cleartext)
|
||||||
* @return boolean TRUE if the password has been successfully changed, FALSE else.
|
* @return boolean TRUE if the password has been successfully changed, FALSE else.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_admin $admin
|
||||||
|
* @param type $password
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function put_mysql_details($password) {
|
function put_mysql_details($password) {
|
||||||
global $db,$err,$mem,$cuid,$admin;
|
global $db,$err,$mem,$cuid,$admin;
|
||||||
$err->log("mysql","put_mysql_details");
|
$err->log("mysql","put_mysql_details");
|
||||||
|
@ -453,6 +557,17 @@ class m_mysql {
|
||||||
* @pass : user password ( optional, if not given the pass stays the same, else it takes the new value )
|
* @pass : user password ( optional, if not given the pass stays the same, else it takes the new value )
|
||||||
* @table : sql tables to apply rights
|
* @table : sql tables to apply rights
|
||||||
**/
|
**/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @param string $base
|
||||||
|
* @param type $user
|
||||||
|
* @param string $rights
|
||||||
|
* @param type $pass
|
||||||
|
* @param type $table
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function grant($base,$user,$rights=null,$pass=null,$table='*'){
|
function grant($base,$user,$rights=null,$pass=null,$table='*'){
|
||||||
global $err,$db;
|
global $err,$db;
|
||||||
$err->log("mysql","grant",$base."-".$rights."-".$user);
|
$err->log("mysql","grant",$base."-".$rights."-".$user);
|
||||||
|
@ -509,6 +624,18 @@ class m_mysql {
|
||||||
* @param $id integer The ID of the database to dump to.
|
* @param $id integer The ID of the database to dump to.
|
||||||
* @return boolean TRUE if the database has been restored, or FALSE if an error occurred
|
* @return boolean TRUE if the database has been restored, or FALSE if an error occurred
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_bro $bro
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global string $L_MYSQL_HOST
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @param type $file
|
||||||
|
* @param type $stdout
|
||||||
|
* @param type $id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function restore($file,$stdout,$id) {
|
function restore($file,$stdout,$id) {
|
||||||
global $err,$bro,$mem,$L_MYSQL_HOST,$db;
|
global $err,$bro,$mem,$L_MYSQL_HOST,$db;
|
||||||
if (empty($file)) {
|
if (empty($file)) {
|
||||||
|
@ -557,6 +684,13 @@ class m_mysql {
|
||||||
* @return integer database size
|
* @return integer database size
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $dbname
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_db_size($dbname) {
|
function get_db_size($dbname) {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
|
|
||||||
|
@ -574,6 +708,15 @@ class m_mysql {
|
||||||
/**
|
/**
|
||||||
* Returns the list of database users of an account
|
* Returns the list of database users of an account
|
||||||
**/
|
**/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_bro $bro
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $all
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_userslist($all=null) {
|
function get_userslist($all=null) {
|
||||||
global $db,$err,$bro,$cuid;
|
global $db,$err,$bro,$cuid;
|
||||||
$err->log("mysql","get_userslist");
|
$err->log("mysql","get_userslist");
|
||||||
|
@ -596,6 +739,15 @@ class m_mysql {
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_bro $bro
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $dbn
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
function get_defaultsparam($dbn){
|
function get_defaultsparam($dbn){
|
||||||
global $db,$err,$bro,$cuid;
|
global $db,$err,$bro,$cuid;
|
||||||
$err->log("mysql","getdefaults");
|
$err->log("mysql","getdefaults");
|
||||||
|
@ -692,6 +844,19 @@ class m_mysql {
|
||||||
* @param string $passconf The password confirmation
|
* @param string $passconf The password confirmation
|
||||||
* @return boolean if the user has been created in MySQL or FALSE if an error occurred
|
* @return boolean if the user has been created in MySQL or FALSE if an error occurred
|
||||||
**/
|
**/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_quota $quota
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_admin $admin
|
||||||
|
* @param type $usern
|
||||||
|
* @param type $password
|
||||||
|
* @param type $passconf
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function add_user($usern,$password,$passconf) {
|
function add_user($usern,$password,$passconf) {
|
||||||
global $db,$err,$quota,$mem,$cuid,$admin;
|
global $db,$err,$quota,$mem,$cuid,$admin;
|
||||||
$err->log("mysql","add_user",$usern);
|
$err->log("mysql","add_user",$usern);
|
||||||
|
@ -756,6 +921,19 @@ class m_mysql {
|
||||||
* @param $passconf The password confirmation
|
* @param $passconf The password confirmation
|
||||||
* @return boolean if the password has been changed in MySQL or FALSE if an error occurred
|
* @return boolean if the password has been changed in MySQL or FALSE if an error occurred
|
||||||
**/
|
**/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_quota $quota
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_admin $admin
|
||||||
|
* @param type $usern
|
||||||
|
* @param type $password
|
||||||
|
* @param type $passconf
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function change_user_password($usern,$password,$passconf) {
|
function change_user_password($usern,$password,$passconf) {
|
||||||
global $db,$err,$quota,$mem,$cuid,$admin;
|
global $db,$err,$quota,$mem,$cuid,$admin;
|
||||||
$err->log("mysql","change_user_pass",$usern);
|
$err->log("mysql","change_user_pass",$usern);
|
||||||
|
@ -788,6 +966,16 @@ class m_mysql {
|
||||||
* @param integer $all
|
* @param integer $all
|
||||||
* @return boolean if the user has been deleted in MySQL or FALSE if an error occurred
|
* @return boolean if the user has been deleted in MySQL or FALSE if an error occurred
|
||||||
**/
|
**/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $user
|
||||||
|
* @param type $all
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function del_user($user,$all=null) {
|
function del_user($user,$all=null) {
|
||||||
global $db,$err,$mem,$cuid;
|
global $db,$err,$mem,$cuid;
|
||||||
$err->log("mysql","del_user",$user);
|
$err->log("mysql","del_user",$user);
|
||||||
|
@ -826,6 +1014,15 @@ class m_mysql {
|
||||||
* @return array An array of database name and rights
|
* @return array An array of database name and rights
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $user
|
||||||
|
* @return boolean|string
|
||||||
|
*/
|
||||||
function get_user_dblist($user){
|
function get_user_dblist($user){
|
||||||
global $db,$err,$mem,$cuid;
|
global $db,$err,$mem,$cuid;
|
||||||
|
|
||||||
|
@ -874,6 +1071,16 @@ class m_mysql {
|
||||||
* @return boolean TRUE if the rights has been applied or FALSE if an error occurred
|
* @return boolean TRUE if the rights has been applied or FALSE if an error occurred
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @param type $user
|
||||||
|
* @param type $dbn
|
||||||
|
* @param type $rights
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function set_user_rights($user,$dbn,$rights) {
|
function set_user_rights($user,$dbn,$rights) {
|
||||||
global $mem,$err,$db;
|
global $mem,$err,$db;
|
||||||
$err->log("mysql","set_user_rights");
|
$err->log("mysql","set_user_rights");
|
||||||
|
@ -881,7 +1088,7 @@ class m_mysql {
|
||||||
$usern=addslashes($user);
|
$usern=addslashes($user);
|
||||||
$dbname=addslashes($dbn);
|
$dbname=addslashes($dbn);
|
||||||
$dbname=str_replace('_','\_',$dbname);
|
$dbname=str_replace('_','\_',$dbname);
|
||||||
// On génère les droits en fonction du tableau de droits
|
// On g<EFBFBD>n<EFBFBD>re les droits en fonction du tableau de droits
|
||||||
$strrights="";
|
$strrights="";
|
||||||
for( $i=0 ; $i<count($rights) ; $i++ ) {
|
for( $i=0 ; $i<count($rights) ; $i++ ) {
|
||||||
switch ($rights[$i]) {
|
switch ($rights[$i]) {
|
||||||
|
@ -954,6 +1161,10 @@ class m_mysql {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function available_sql_rights(){
|
function available_sql_rights(){
|
||||||
return Array('select','insert','update','delete','create','drop','references','index','alter','create_tmp','lock','create_view','show_view','create_routine','alter_routine','execute','event','trigger');
|
return Array('select','insert','update','delete','create','drop','references','index','alter','create_tmp','lock','create_view','show_view','create_routine','alter_routine','execute','event','trigger');
|
||||||
|
|
||||||
|
@ -968,6 +1179,12 @@ class m_mysql {
|
||||||
* @return integer the number of service used or false if an error occured
|
* @return integer the number of service used or false if an error occured
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $params
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function hook_lxc_params($params) {
|
function hook_lxc_params($params) {
|
||||||
global $err;
|
global $err;
|
||||||
$err->log("mysql","alternc_get_quota");
|
$err->log("mysql","alternc_get_quota");
|
||||||
|
@ -987,6 +1204,13 @@ class m_mysql {
|
||||||
* @return integer the number of service used or false if an error occured
|
* @return integer the number of service used or false if an error occured
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function hook_quota_get() {
|
function hook_quota_get() {
|
||||||
global $err,$db,$cuid;
|
global $err,$db,$cuid;
|
||||||
$err->log("mysql","alternc_get_quota");
|
$err->log("mysql","alternc_get_quota");
|
||||||
|
@ -1003,6 +1227,14 @@ class m_mysql {
|
||||||
* AlternC's standard function that create a member
|
* AlternC's standard function that create a member
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function alternc_add_member() {
|
function alternc_add_member() {
|
||||||
global $db,$err,$cuid,$mem;
|
global $db,$err,$cuid,$mem;
|
||||||
$err->log("mysql","alternc_add_member");
|
$err->log("mysql","alternc_add_member");
|
||||||
|
@ -1030,6 +1262,13 @@ class m_mysql {
|
||||||
* AlternC's standard function that delete a member
|
* AlternC's standard function that delete a member
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function alternc_del_member() {
|
function alternc_del_member() {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("mysql","alternc_del_member");
|
$err->log("mysql","alternc_del_member");
|
||||||
|
@ -1054,6 +1293,9 @@ class m_mysql {
|
||||||
* We just remove the cookie created in admin/sql_admin.php
|
* We just remove the cookie created in admin/sql_admin.php
|
||||||
a @access private
|
a @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function alternc_del_session() {
|
function alternc_del_session() {
|
||||||
$_SESSION['PMA_single_signon_user'] = '';
|
$_SESSION['PMA_single_signon_user'] = '';
|
||||||
$_SESSION['PMA_single_signon_password'] = '';
|
$_SESSION['PMA_single_signon_password'] = '';
|
||||||
|
@ -1067,6 +1309,13 @@ class m_mysql {
|
||||||
* @access private
|
* @access private
|
||||||
* EXPERIMENTAL 'sid' function ;)
|
* EXPERIMENTAL 'sid' function ;)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function alternc_export_conf() {
|
function alternc_export_conf() {
|
||||||
//TODO don't work with separated sql server for dbusers
|
//TODO don't work with separated sql server for dbusers
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
|
@ -1099,6 +1348,14 @@ class m_mysql {
|
||||||
* @access private
|
* @access private
|
||||||
* EXPERIMENTAL 'sid' function ;)
|
* EXPERIMENTAL 'sid' function ;)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param string $dir
|
||||||
|
*/
|
||||||
function alternc_export_data ($dir){
|
function alternc_export_data ($dir){
|
||||||
global $db, $err, $cuid,$mem;
|
global $db, $err, $cuid,$mem;
|
||||||
$err->log("mysql","export_data");
|
$err->log("mysql","export_data");
|
||||||
|
@ -1126,6 +1383,17 @@ class m_mysql {
|
||||||
* @param $db_client the client to access the SQL db
|
* @param $db_client the client to access the SQL db
|
||||||
* @return an array associating the name of the databases to their sizes : array(dbname=>size)
|
* @return an array associating the name of the databases to their sizes : array(dbname=>size)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $db_name
|
||||||
|
* @param type $db_host
|
||||||
|
* @param type $db_login
|
||||||
|
* @param type $db_password
|
||||||
|
* @param type $db_client
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_dbus_size($db_name,$db_host,$db_login,$db_password,$db_client) {
|
function get_dbus_size($db_name,$db_host,$db_login,$db_password,$db_client) {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$err->log("mysql","get_dbus_size",$db_host);
|
$err->log("mysql","get_dbus_size",$db_host);
|
||||||
|
@ -1155,4 +1423,3 @@ class m_mysql {
|
||||||
|
|
||||||
} /* Class m_mysql */
|
} /* Class m_mysql */
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -32,6 +32,11 @@ class m_piwik {
|
||||||
var $alternc_users;
|
var $alternc_users;
|
||||||
var $alternc_sites;
|
var $alternc_sites;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_quota $quota
|
||||||
|
* @return boolean|int
|
||||||
|
*/
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
global $quota;
|
global $quota;
|
||||||
if ( empty($this->piwik_server_uri) || empty($this->piwik_admin_token)) return false;
|
if ( empty($this->piwik_server_uri) || empty($this->piwik_admin_token)) return false;
|
||||||
|
@ -50,9 +55,11 @@ class m_piwik {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** Constructor
|
/** Constructor
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function m_piwik() {
|
function m_piwik() {
|
||||||
$this->piwik_server_uri=variable_get('piwik_server_uri',null,'Remote Piwik server uri');
|
$this->piwik_server_uri=variable_get('piwik_server_uri',null,'Remote Piwik server uri');
|
||||||
$this->piwik_admin_token=variable_get('piwik_admin_token',null,'Remote Piwik super-admin token');
|
$this->piwik_admin_token=variable_get('piwik_admin_token',null,'Remote Piwik super-admin token');
|
||||||
|
@ -60,21 +67,31 @@ class m_piwik {
|
||||||
$this->alternc_sites = $this->get_alternc_sites();
|
$this->alternc_sites = $this->get_alternc_sites();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** hook called when an AlternC account is deleted
|
/** hook called when an AlternC account is deleted
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function hook_admin_del_member() {
|
function hook_admin_del_member() {
|
||||||
//FIXME : implement the hook_admin_del_member for piwik
|
//FIXME : implement the hook_admin_del_member for piwik
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Returns the used quota for the $name service for the current user.
|
/** Returns the used quota for the $name service for the current user.
|
||||||
* @param $name string name of the quota
|
* @param $name string name of the quota
|
||||||
* @return integer the number of service used or false if an error occured
|
* @return integer the number of service used or false if an error occured
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function hook_quota_get() {
|
function hook_quota_get() {
|
||||||
global $db, $cuid;
|
global $db, $cuid;
|
||||||
$db->query("SELECT COUNT(id) AS nb FROM piwik_users WHERE uid='$cuid'");
|
$db->query("SELECT COUNT(id) AS nb FROM piwik_users WHERE uid='$cuid'");
|
||||||
|
@ -86,6 +103,10 @@ class m_piwik {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function url() {
|
function url() {
|
||||||
return $this->piwik_server_uri;
|
return $this->piwik_server_uri;
|
||||||
}
|
}
|
||||||
|
@ -96,6 +117,16 @@ class m_piwik {
|
||||||
/***********************/
|
/***********************/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $user_login
|
||||||
|
* @param type $user_mail
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function user_add($user_login, $user_mail = null) {
|
function user_add($user_login, $user_mail = null) {
|
||||||
|
|
||||||
global $db, $mem, $cuid, $err;
|
global $db, $mem, $cuid, $err;
|
||||||
|
@ -120,15 +151,31 @@ class m_piwik {
|
||||||
|
|
||||||
|
|
||||||
// Edite un user
|
// Edite un user
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function user_edit() {
|
function user_edit() {
|
||||||
//FIXME
|
//FIXME
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $user_login
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_site_access($user_login) {
|
function get_site_access($user_login) {
|
||||||
return $this->call_privileged_page('API', 'UsersManager.getSitesAccessFromUser', array('userLogin' => $user_login));
|
return $this->call_privileged_page('API', 'UsersManager.getSitesAccessFromUser', array('userLogin' => $user_login));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $site_id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function get_users_access_from_site($site_id) {
|
function get_users_access_from_site($site_id) {
|
||||||
global $err, $cuid;
|
global $err, $cuid;
|
||||||
|
|
||||||
|
@ -157,6 +204,11 @@ class m_piwik {
|
||||||
/**
|
/**
|
||||||
* @param string $user_login
|
* @param string $user_login
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $user_login
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function get_user($user_login) {
|
function get_user($user_login) {
|
||||||
$api_data = $this->call_privileged_page('API', 'UsersManager.getUser', array('userLogin' => $user_login));
|
$api_data = $this->call_privileged_page('API', 'UsersManager.getUser', array('userLogin' => $user_login));
|
||||||
|
|
||||||
|
@ -166,6 +218,13 @@ class m_piwik {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @staticvar array $alternc_users
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
function get_alternc_users() {
|
function get_alternc_users() {
|
||||||
global $db, $cuid;
|
global $db, $cuid;
|
||||||
|
|
||||||
|
@ -178,6 +237,14 @@ class m_piwik {
|
||||||
}
|
}
|
||||||
// Supprime l'utilisateur Piwik passé en parametre
|
// Supprime l'utilisateur Piwik passé en parametre
|
||||||
// Ne le supprime pas localement tant que pas supprimé en remote
|
// Ne le supprime pas localement tant que pas supprimé en remote
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $piwik_user_login
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function user_delete($piwik_user_login) {
|
function user_delete($piwik_user_login) {
|
||||||
global $db, $cuid, $err;
|
global $db, $cuid, $err;
|
||||||
|
|
||||||
|
@ -199,6 +266,12 @@ class m_piwik {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function users_list() {
|
function users_list() {
|
||||||
global $db, $cuid;
|
global $db, $cuid;
|
||||||
$db->query("SELECT login FROM piwik_users WHERE uid = '$cuid'");
|
$db->query("SELECT login FROM piwik_users WHERE uid = '$cuid'");
|
||||||
|
@ -212,6 +285,11 @@ class m_piwik {
|
||||||
|
|
||||||
|
|
||||||
// Verifie que l'utilisateur existe bien dans piwik
|
// Verifie que l'utilisateur existe bien dans piwik
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $puser_id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function user_checkremote($puser_id) {
|
function user_checkremote($puser_id) {
|
||||||
//FIXME
|
//FIXME
|
||||||
return true;
|
return true;
|
||||||
|
@ -219,12 +297,20 @@ class m_piwik {
|
||||||
|
|
||||||
|
|
||||||
// Récupére un token pour le SSO avec piwik pour l'user
|
// Récupére un token pour le SSO avec piwik pour l'user
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function user_remoteauth() {
|
function user_remoteauth() {
|
||||||
//FIXME
|
//FIXME
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Montre la liste des site pour lesques un user à accés
|
// Montre la liste des site pour lesques un user à accés
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function user_access() {
|
function user_access() {
|
||||||
// FIXME
|
// FIXME
|
||||||
return true;
|
return true;
|
||||||
|
@ -239,6 +325,10 @@ class m_piwik {
|
||||||
/***********************/
|
/***********************/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return \stdClass|boolean
|
||||||
|
*/
|
||||||
function site_list() {
|
function site_list() {
|
||||||
$api_data = $this->call_privileged_page('API', 'SitesManager.getAllSites');
|
$api_data = $this->call_privileged_page('API', 'SitesManager.getAllSites');
|
||||||
$data = array();
|
$data = array();
|
||||||
|
@ -270,10 +360,22 @@ class m_piwik {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $site_id
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function site_js_tag($site_id) {
|
function site_js_tag($site_id) {
|
||||||
return $this->call_privileged_page('API', 'SitesManager.getJavascriptTag', array('idSite' => $site_id, 'piwikUrl' => $this->piwik_server_uri))->value;
|
return $this->call_privileged_page('API', 'SitesManager.getJavascriptTag', array('idSite' => $site_id, 'piwikUrl' => $this->piwik_server_uri))->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @staticvar array $alternc_sites
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
function get_alternc_sites() {
|
function get_alternc_sites() {
|
||||||
global $db, $cuid;
|
global $db, $cuid;
|
||||||
|
|
||||||
|
@ -285,12 +387,23 @@ class m_piwik {
|
||||||
return $alternc_sites;
|
return $alternc_sites;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_site_list()
|
function get_site_list()
|
||||||
{
|
{
|
||||||
return $this->call_privileged_page('API', 'SitesManager.getAllSites');
|
return $this->call_privileged_page('API', 'SitesManager.getAllSites');
|
||||||
}
|
}
|
||||||
// Ajoute un site à Piwik
|
// Ajoute un site à Piwik
|
||||||
// can't figure out how to pass multiple url through the API
|
// can't figure out how to pass multiple url through the API
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $siteName
|
||||||
|
* @param type $urls
|
||||||
|
* @param type $ecommerce
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function site_add($siteName, $urls, $ecommerce = FALSE) {
|
function site_add($siteName, $urls, $ecommerce = FALSE) {
|
||||||
$urls = is_array($urls) ? implode(',', $urls) : $urls;
|
$urls = is_array($urls) ? implode(',', $urls) : $urls;
|
||||||
$api_data = $this->call_privileged_page('API', 'SitesManager.addSite', array('siteName' => $siteName, 'urls' => $urls));
|
$api_data = $this->call_privileged_page('API', 'SitesManager.addSite', array('siteName' => $siteName, 'urls' => $urls));
|
||||||
|
@ -301,6 +414,14 @@ class m_piwik {
|
||||||
|
|
||||||
//SitesManager.deleteSite (idSite)
|
//SitesManager.deleteSite (idSite)
|
||||||
// Supprime un site de Piwik
|
// Supprime un site de Piwik
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $site_id
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function site_delete($site_id) {
|
function site_delete($site_id) {
|
||||||
global $db, $cuid, $err;
|
global $db, $cuid, $err;
|
||||||
|
|
||||||
|
@ -323,6 +444,14 @@ class m_piwik {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $site_id
|
||||||
|
* @param type $login
|
||||||
|
* @param type $right
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function site_set_user_right($site_id, $login, $right)
|
function site_set_user_right($site_id, $login, $right)
|
||||||
{
|
{
|
||||||
global $err;
|
global $err;
|
||||||
|
@ -337,6 +466,10 @@ class m_piwik {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Ajoute un alias sur un site existant
|
// Ajoute un alias sur un site existant
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function site_alias_add() {
|
function site_alias_add() {
|
||||||
// FIXME
|
// FIXME
|
||||||
return true;
|
return true;
|
||||||
|
@ -346,11 +479,19 @@ class m_piwik {
|
||||||
|
|
||||||
/* Helper code FIXME: rename those function using "private" + "_" prefix */
|
/* Helper code FIXME: rename those function using "private" + "_" prefix */
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $username
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function clean_user_name($username) {
|
function clean_user_name($username) {
|
||||||
return mysql_real_escape_string(trim($username));
|
return mysql_real_escape_string(trim($username));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function dev() {
|
function dev() {
|
||||||
// $this->call_page('module', 'method', array('user' => 'fser', 'pass' => 'toto'));
|
// $this->call_page('module', 'method', array('user' => 'fser', 'pass' => 'toto'));
|
||||||
// return $this->users_list();
|
// return $this->users_list();
|
||||||
|
@ -361,6 +502,15 @@ class m_piwik {
|
||||||
* @param string $module
|
* @param string $module
|
||||||
* @param string $method
|
* @param string $method
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $module
|
||||||
|
* @param type $method
|
||||||
|
* @param type $arguments
|
||||||
|
* @param type $output
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function call_page($module, $method, $arguments=array(), $output = 'JSON') {
|
function call_page($module, $method, $arguments=array(), $output = 'JSON') {
|
||||||
global $err;
|
global $err;
|
||||||
$url = sprintf('%s/?module=%s&method=%s&format=%s', $this->piwik_server_uri, $module, $method, $output);
|
$url = sprintf('%s/?module=%s&method=%s&format=%s', $this->piwik_server_uri, $module, $method, $output);
|
||||||
|
@ -391,6 +541,14 @@ class m_piwik {
|
||||||
* @param string $module
|
* @param string $module
|
||||||
* @param string $method
|
* @param string $method
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $module
|
||||||
|
* @param type $method
|
||||||
|
* @param array $arguments
|
||||||
|
* @param type $output
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function call_privileged_page($module, $method, $arguments=array(), $output = 'JSON') {
|
function call_privileged_page($module, $method, $arguments=array(), $output = 'JSON') {
|
||||||
$arguments['token_auth'] = $this->piwik_admin_token;
|
$arguments['token_auth'] = $this->piwik_admin_token;
|
||||||
return $this->call_page($module, $method, $arguments, $output);
|
return $this->call_page($module, $method, $arguments, $output);
|
||||||
|
|
|
@ -44,10 +44,13 @@ class m_quota {
|
||||||
var $clquota; // Which class manage which quota.
|
var $clquota; // Which class manage which quota.
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function m_quota() {
|
function m_quota() {
|
||||||
$this->disk_quota_enable = variable_get('disk_quota_enable', 1,'Are disk quota enabled for this server', array('desc'=>'Enabled','type'=>'boolean'));
|
$this->disk_quota_enable = variable_get('disk_quota_enable', 1,'Are disk quota enabled for this server', array('desc'=>'Enabled','type'=>'boolean'));
|
||||||
if ( $this->disk_quota_enable ) {
|
if ( $this->disk_quota_enable ) {
|
||||||
|
@ -60,6 +63,10 @@ class m_quota {
|
||||||
_("quota_web");
|
_("quota_web");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
$obj = array(
|
$obj = array(
|
||||||
'title' => _("Show my quotas"),
|
'title' => _("Show my quotas"),
|
||||||
|
@ -82,22 +89,33 @@ class m_quota {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Check if a user can use a ressource.
|
/** Check if a user can use a ressource.
|
||||||
* @param string $ressource the ressource name (a named quota)
|
* @param string $ressource the ressource name (a named quota)
|
||||||
* @Return TRUE if the user can create a ressource (= is there any quota left ?)
|
* @Return TRUE if the user can create a ressource (= is there any quota left ?)
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $ressource
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function cancreate($ressource="") {
|
function cancreate($ressource="") {
|
||||||
$t=$this->getquota($ressource);
|
$t=$this->getquota($ressource);
|
||||||
return $t["u"]<$t["t"];
|
return $t["u"]<$t["t"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** List the quota-managed services in the server
|
/** List the quota-managed services in the server
|
||||||
* @Return array the quota names and description (translated)
|
* @Return array the quota names and description (translated)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global array $classes
|
||||||
|
* @global m_hooks $hooks
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function qlist() {
|
function qlist() {
|
||||||
global $classes,$hooks;
|
global $classes,$hooks;
|
||||||
$qlist=array();
|
$qlist=array();
|
||||||
|
@ -122,6 +140,12 @@ class m_quota {
|
||||||
* If the quota entry doesn't exist for the user, create it with
|
* If the quota entry doesn't exist for the user, create it with
|
||||||
* the defaults value.
|
* the defaults value.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function synchronise_user_profile() {
|
function synchronise_user_profile() {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$err->log("quota","synchronise_user_profile");
|
$err->log("quota","synchronise_user_profile");
|
||||||
|
@ -135,6 +159,13 @@ class m_quota {
|
||||||
* when a new quota appear
|
* when a new quota appear
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_quota $quota
|
||||||
|
* @global m_err $err
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function create_missing_quota_profile() {
|
function create_missing_quota_profile() {
|
||||||
global $db,$quota,$err;
|
global $db,$quota,$err;
|
||||||
$err->log("quota","create_missing_quota_profile");
|
$err->log("quota","create_missing_quota_profile");
|
||||||
|
@ -148,11 +179,23 @@ class m_quota {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Return a ressource usage (u) and total quota (t)
|
/** Return a ressource usage (u) and total quota (t)
|
||||||
* @param string $ressource ressource to get quota of
|
* @param string $ressource ressource to get quota of
|
||||||
* @Return array the quota used and total for this ressource (or for all ressource if unspecified)
|
* @Return array the quota used and total for this ressource (or for all ressource if unspecified)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @global array $get_quota_cache
|
||||||
|
* @global m_hooks $hooks
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $ressource
|
||||||
|
* @param type $recheck
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function getquota($ressource="",$recheck=false) {
|
function getquota($ressource="",$recheck=false) {
|
||||||
global $db,$err,$cuid,$get_quota_cache,$hooks,$mem;
|
global $db,$err,$cuid,$get_quota_cache,$hooks,$mem;
|
||||||
$err->log("quota","getquota",$ressource);
|
$err->log("quota","getquota",$ressource);
|
||||||
|
@ -219,11 +262,20 @@ class m_quota {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Set the quota for a user (and for a ressource)
|
/** Set the quota for a user (and for a ressource)
|
||||||
* @param string $ressource ressource to set quota of
|
* @param string $ressource ressource to set quota of
|
||||||
* @param integer size of the quota (available or used)
|
* @param integer size of the quota (available or used)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $ressource
|
||||||
|
* @param string $size
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function setquota($ressource,$size) {
|
function setquota($ressource,$size) {
|
||||||
global $err,$db,$cuid;
|
global $err,$db,$cuid;
|
||||||
$err->log("quota","setquota",$ressource."/".$size);
|
$err->log("quota","setquota",$ressource."/".$size);
|
||||||
|
@ -249,10 +301,17 @@ class m_quota {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/**
|
/**
|
||||||
* Erase all quota information about the user.
|
* Erase all quota information about the user.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function delquotas() {
|
function delquotas() {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("quota","delquota");
|
$err->log("quota","delquota");
|
||||||
|
@ -261,10 +320,15 @@ class m_quota {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Get the default quotas as an associative array
|
/** Get the default quotas as an associative array
|
||||||
* @return array the array of the default quotas
|
* @return array the array of the default quotas
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function getdefaults() {
|
function getdefaults() {
|
||||||
global $db;
|
global $db;
|
||||||
$c=array();
|
$c=array();
|
||||||
|
@ -282,10 +346,16 @@ class m_quota {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Set the default quotas
|
/** Set the default quotas
|
||||||
* @param array associative array of quota (key=>val)
|
* @param array associative array of quota (key=>val)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @param type $newq
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function setdefaults($newq) {
|
function setdefaults($newq) {
|
||||||
global $db;
|
global $db;
|
||||||
$qlist=$this->qlist();
|
$qlist=$this->qlist();
|
||||||
|
@ -302,11 +372,18 @@ class m_quota {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Add an account type for quotas
|
/** Add an account type for quotas
|
||||||
* @param string $type account type to be added
|
* @param string $type account type to be added
|
||||||
* @return boolean true if all went ok
|
* @return boolean true if all went ok
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @param type $type
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function addtype($type) {
|
function addtype($type) {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$qlist=$this->qlist();
|
$qlist=$this->qlist();
|
||||||
|
@ -325,10 +402,15 @@ class m_quota {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** List for quotas
|
/** List for quotas
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function listtype() {
|
function listtype() {
|
||||||
global $db;
|
global $db;
|
||||||
$db->query("SELECT distinct(type) FROM defquotas ORDER by type");
|
$db->query("SELECT distinct(type) FROM defquotas ORDER by type");
|
||||||
|
@ -340,11 +422,17 @@ class m_quota {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Delete an account type for quotas
|
/** Delete an account type for quotas
|
||||||
* @param string $type account type to be deleted
|
* @param string $type account type to be deleted
|
||||||
* @return boolean true if all went ok
|
* @return boolean true if all went ok
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @param type $type
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function deltype($type) {
|
function deltype($type) {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
|
@ -357,10 +445,17 @@ class m_quota {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Create default quotas entries for a new user.
|
/** Create default quotas entries for a new user.
|
||||||
* The user we are talking about is in the global $cuid.
|
* The user we are talking about is in the global $cuid.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
function addquotas() {
|
function addquotas() {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$err->log("quota","addquota");
|
$err->log("quota","addquota");
|
||||||
|
@ -384,13 +479,19 @@ class m_quota {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Return a quota value with its unit (when it is a space quota)
|
/** Return a quota value with its unit (when it is a space quota)
|
||||||
* in MB, GB, TB ...
|
* in MB, GB, TB ...
|
||||||
* @param string $type The quota type
|
* @param string $type The quota type
|
||||||
* @param integer $value The quota value
|
* @param integer $value The quota value
|
||||||
* @return string a quota value with its unit.
|
* @return string a quota value with its unit.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $type
|
||||||
|
* @param type $value
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function display_val($type, $value) {
|
function display_val($type, $value) {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'bw_web':
|
case 'bw_web':
|
||||||
|
@ -404,6 +505,14 @@ class m_quota {
|
||||||
|
|
||||||
|
|
||||||
/* get size_xx function (filled by spoolsize.php) */
|
/* get size_xx function (filled by spoolsize.php) */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $sql
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function _get_sum_sql($sql) {
|
function _get_sum_sql($sql) {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$db->query($sql);
|
$db->query($sql);
|
||||||
|
@ -416,6 +525,14 @@ class m_quota {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $sql
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function _get_count_sql($sql) {
|
function _get_count_sql($sql) {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$db->query($sql);
|
$db->query($sql);
|
||||||
|
@ -428,6 +545,14 @@ class m_quota {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @global m_mem $mem
|
||||||
|
* @param type $sql
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function _get_size_and_record_sql($sql) {
|
function _get_size_and_record_sql($sql) {
|
||||||
global $db,$err,$cuid;
|
global $db,$err,$cuid;
|
||||||
$db->query($sql);
|
$db->query($sql);
|
||||||
|
@ -443,97 +568,186 @@ class m_quota {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of websites sizes from all users */
|
/* sum of websites sizes from all users */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_web_sum_all() {
|
function get_size_web_sum_all() {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web;");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of websites sizes from one user */
|
/* sum of websites sizes from one user */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $u
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_web_sum_user($u) {
|
function get_size_web_sum_user($u) {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web WHERE uid='$u';");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web WHERE uid='$u';");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of mailbox sizes from all domains */
|
/* sum of mailbox sizes from all domains */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_mail_sum_all() {
|
function get_size_mail_sum_all() {
|
||||||
return $this->_get_sum_sql("SELECT SUM(bytes) AS sum FROM mailbox;");
|
return $this->_get_sum_sql("SELECT SUM(bytes) AS sum FROM mailbox;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of mailbox sizes for one domain */
|
/* sum of mailbox sizes for one domain */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mail $mail
|
||||||
|
* @param type $dom
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_mail_sum_domain($dom) {
|
function get_size_mail_sum_domain($dom) {
|
||||||
global $mail;
|
global $mail;
|
||||||
return $mail->get_total_size_for_domain($dom);
|
return $mail->get_total_size_for_domain($dom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count of mailbox sizes from all domains */
|
/* count of mailbox sizes from all domains */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_mail_count_all() {
|
function get_size_mail_count_all() {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM mailbox;");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM mailbox;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count of mailbox for one domain */
|
/* count of mailbox for one domain */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $dom
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_mail_count_domain($dom) {
|
function get_size_mail_count_domain($dom) {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM dovecot_view WHERE user LIKE '%@{$dom}'");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM dovecot_view WHERE user LIKE '%@{$dom}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get list of mailbox alias and size for one domain */
|
/* get list of mailbox alias and size for one domain */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $dom
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_mail_details_domain($dom) {
|
function get_size_mail_details_domain($dom) {
|
||||||
return $this->_get_size_and_record_sql("SELECT user as alias,quota_dovecot as size FROM dovecot_view WHERE user LIKE '%@{$dom}' ORDER BY alias;");
|
return $this->_get_size_and_record_sql("SELECT user as alias,quota_dovecot as size FROM dovecot_view WHERE user LIKE '%@{$dom}' ORDER BY alias;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of mailman lists sizes from all domains */
|
/* sum of mailman lists sizes from all domains */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_mailman_sum_all() {
|
function get_size_mailman_sum_all() {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman;");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of mailman lists sizes for one domain */
|
/* sum of mailman lists sizes for one domain */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $dom
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_mailman_sum_domain($dom) {
|
function get_size_mailman_sum_domain($dom) {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman WHERE list LIKE '%@{$dom}'");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman WHERE list LIKE '%@{$dom}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of mailman lists for one user */
|
/* sum of mailman lists for one user */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $u
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_mailman_sum_user($u) {
|
function get_size_mailman_sum_user($u) {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman WHERE uid = '{$u}'");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman WHERE uid = '{$u}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count of mailman lists sizes from all domains */
|
/* count of mailman lists sizes from all domains */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_mailman_count_all() {
|
function get_size_mailman_count_all() {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman;");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count of mailman lists for one user */
|
/* count of mailman lists for one user */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $u
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_mailman_count_user($u) {
|
function get_size_mailman_count_user($u) {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman WHERE uid = '{$u}'");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman WHERE uid = '{$u}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get list of mailman list and size for one user */
|
/* get list of mailman list and size for one user */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $u
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_mailman_details_user($u) {
|
function get_size_mailman_details_user($u) {
|
||||||
return $this->_get_size_and_record_sql("SELECT s.size,CONCAT(m.list,'@',m.domain) as list FROM size_mailman s LEFT JOIN mailman m ON s.list=m.name WHERE s.uid='{$u}' ORDER BY s.list ASC");
|
return $this->_get_size_and_record_sql("SELECT s.size,CONCAT(m.list,'@',m.domain) as list FROM size_mailman s LEFT JOIN mailman m ON s.list=m.name WHERE s.uid='{$u}' ORDER BY s.list ASC");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of databases sizes from all users */
|
/* sum of databases sizes from all users */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_db_sum_all() {
|
function get_size_db_sum_all() {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_db;");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_db;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of databases sizes for one user */
|
/* sum of databases sizes for one user */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $u
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_db_sum_user($u) {
|
function get_size_db_sum_user($u) {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_db WHERE db = '{$u}' OR db LIKE '{$u}\_%'");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_db WHERE db = '{$u}' OR db LIKE '{$u}\_%'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count of databases from all users */
|
/* count of databases from all users */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_db_count_all() {
|
function get_size_db_count_all() {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db;");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count of databases for one user */
|
/* count of databases for one user */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $u
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_db_count_user($u) {
|
function get_size_db_count_user($u) {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db WHERE db = '{$u}' OR db LIKE '{$u}\_%'");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db WHERE db = '{$u}' OR db LIKE '{$u}\_%'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get list of databases name and size for one user */
|
/* get list of databases name and size for one user */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $u
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_db_details_user($u) {
|
function get_size_db_details_user($u) {
|
||||||
return $this->_get_size_and_record_sql("SELECT db,size FROM size_db WHERE db='{$u}' OR db LIKE '{$u}\_%';");
|
return $this->_get_size_and_record_sql("SELECT db,size FROM size_db WHERE db='{$u}' OR db LIKE '{$u}\_%';");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return appropriate value and unit of a size given in Bytes (e.g. 1024 Bytes -> return 1 KB) */
|
/* Return appropriate value and unit of a size given in Bytes (e.g. 1024 Bytes -> return 1 KB) */
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $size
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
function get_size_unit($size) {
|
function get_size_unit($size) {
|
||||||
$units=array(1073741824=>_("GB"), 1048576=>_("MB"), 1024=>_("KB"), 0=>_("B"));
|
$units=array(1073741824=>_("GB"), 1048576=>_("MB"), 1024=>_("KB"), 0=>_("B"));
|
||||||
foreach($units as $value=>$unit){
|
foreach($units as $value=>$unit){
|
||||||
|
@ -549,6 +763,11 @@ class m_quota {
|
||||||
// 0 = Pas de changement de couleur
|
// 0 = Pas de changement de couleur
|
||||||
// 1 = Progression du vert vers le rouge en fonction du porcentage
|
// 1 = Progression du vert vers le rouge en fonction du porcentage
|
||||||
// 2 = Progression du rouge vers le vert en fonction du porcentage
|
// 2 = Progression du rouge vers le vert en fonction du porcentage
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type $usage
|
||||||
|
* @param type $color_type
|
||||||
|
*/
|
||||||
function quota_displaybar($usage, $color_type=1) {
|
function quota_displaybar($usage, $color_type=1) {
|
||||||
if ($color_type == 1) {
|
if ($color_type == 1) {
|
||||||
$csscolor = " background-color:".PercentToColor($usage);
|
$csscolor = " background-color:".PercentToColor($usage);
|
||||||
|
@ -568,21 +787,28 @@ class m_quota {
|
||||||
|
|
||||||
/* ==== Hook functions ==== */
|
/* ==== Hook functions ==== */
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Hook function call when a user is deleted
|
/** Hook function call when a user is deleted
|
||||||
* AlternC's standard function called when a user is deleted
|
* AlternC's standard function called when a user is deleted
|
||||||
* globals $cuid is the appropriate user
|
* globals $cuid is the appropriate user
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
function hook_admin_del_member() {
|
function hook_admin_del_member() {
|
||||||
$this->delquotas();
|
$this->delquotas();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Hook function called when a user is created
|
/** Hook function called when a user is created
|
||||||
* This function initialize the user's quotas.
|
* This function initialize the user's quotas.
|
||||||
* globals $cuid is the appropriate user
|
* globals $cuid is the appropriate user
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_err $err
|
||||||
|
*/
|
||||||
function hook_admin_add_member() {
|
function hook_admin_add_member() {
|
||||||
global $err;
|
global $err;
|
||||||
$err->log("quota","hook_admin_add_member");
|
$err->log("quota","hook_admin_add_member");
|
||||||
|
@ -591,11 +817,17 @@ class m_quota {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** Exports all the quota related information for an account.
|
/** Exports all the quota related information for an account.
|
||||||
* @access private
|
* @access private
|
||||||
* EXPERIMENTAL function ;)
|
* EXPERIMENTAL function ;)
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @global m_mysql $db
|
||||||
|
* @global m_err $err
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function alternc_export_conf() {
|
function alternc_export_conf() {
|
||||||
global $db,$err;
|
global $db,$err;
|
||||||
$err->log("quota","export");
|
$err->log("quota","export");
|
||||||
|
|
|
@ -79,7 +79,7 @@ class m_variables {
|
||||||
* with variable_set() as well as those explicitly specified in the configuration
|
* with variable_set() as well as those explicitly specified in the configuration
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
* @global int $cuid
|
* @global int $cuid
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function variable_init() {
|
function variable_init() {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @todo Is this the right place for such a script
|
||||||
|
*/
|
||||||
include("config.php");
|
include("config.php");
|
||||||
|
|
||||||
if (!$admin->enabled) {
|
if (!$admin->enabled) {
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
interface vm {
|
interface vm {
|
||||||
|
/**
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
public function start();
|
public function start();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue