replacing raise(class,number) by raise(class,message), big commit ahead

This commit is contained in:
Benjamin Sonntag 2012-08-26 08:32:20 +00:00
parent 623b838125
commit 01b932870e
2 changed files with 86 additions and 116 deletions

View File

@ -25,13 +25,7 @@
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** /**
* Classe de gestion de l'administration du serveur par les super-admin. * Manage the AlternC's account administration (create/edit/delete)
*
* Cette classe permet de créer / modifier / détruire les comptes, ainsi que de
* modifier les paramètres du serveur.<br />
* Copyleft {@link http://alternc.net/ AlternC Team}
*
*
*/ */
class m_admin { class m_admin {
@ -51,7 +45,7 @@ class m_admin {
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Constructeur /** Constructor
*/ */
function m_admin() { function m_admin() {
global $db,$cuid; global $db,$cuid;
@ -80,19 +74,12 @@ class m_admin {
* @return an associative array containing all the fields of the * @return an associative array containing all the fields of the
* table <code>membres</code> and <code>local</code> of the corresponding account. * table <code>membres</code> and <code>local</code> of the corresponding account.
* Returns FALSE if an error occurs. * Returns FALSE if an error occurs.
*
* Retourne tout ce que l'on sait sur un membre (contenu des tables <code>membres et local</code>)
* vérifie que le compte appelant est super-admin
* @param integer $uid Numéro de l'utilisateur dont on veut les informations.
* @return array Retourne un tableau associatif contenant l'ensemble des champs des tables 'membres'
* et 'local' pour le membre demandé. Retourne FALSE si une erreur s'est produite.
*
*/ */
function get($uid) { function get($uid) {
global $err,$db; global $err,$db;
// $err->log("admin","get",$uid); // $err->log("admin","get",$uid);
if (!$this->enabled) { if (!$this->enabled) {
$err->raise("admin",1); $err->raise("admin",_("-- Only administrators can access this page! --"));
return false; return false;
} }
$db->query("SELECT m.*, parent.login as parentlogin FROM membres as m LEFT JOIN membres as parent ON (parent.uid = m.creator) WHERE m.uid='$uid';"); $db->query("SELECT m.*, parent.login as parentlogin FROM membres as m LEFT JOIN membres as parent ON (parent.uid = m.creator) WHERE m.uid='$uid';");
@ -100,7 +87,7 @@ class m_admin {
$db->next_record(); $db->next_record();
$c=$db->Record; $c=$db->Record;
} else { } else {
$err->raise("admin",2); $err->raise("admin",_("Account not found"));
return false; return false;
} }
$db->query("SELECT * FROM local WHERE uid='$uid';"); $db->query("SELECT * FROM local WHERE uid='$uid';");
@ -123,7 +110,7 @@ class m_admin {
global $err,$db; global $err,$db;
// $err->log("admin","get",$uid); // $err->log("admin","get",$uid);
if (!$this->enabled) { if (!$this->enabled) {
$err->raise("admin",1); $err->raise("admin",_("-- Only administrators can access this page! --"));
return false; return false;
} }
@ -133,7 +120,7 @@ class m_admin {
$db->next_record(); $db->next_record();
$c=$db->Record; $c=$db->Record;
} else { } else {
$err->raise("admin",2); $err->raise("admin",_("Account not found"));
return false; return false;
} }
@ -161,7 +148,8 @@ class m_admin {
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** @return TRUE if there's only ONE admin account /** @return TRUE if there's only ONE admin account
* Retourne true s'il n'existe qu'un seul compte administrateur * @return boolean TRUE if there is only one admin account
* (allow the program to prevent the destruction of the last admin account)
*/ */
function onesu() { function onesu() {
global $db; global $db;
@ -186,7 +174,7 @@ class m_admin {
global $err,$mem,$cuid; global $err,$mem,$cuid;
$err->log("admin","get_list"); $err->log("admin","get_list");
if (!$this->enabled) { if (!$this->enabled) {
$err->raise("admin",1); $err->raise("admin",_("-- Only administrators can access this page! --"));
return false; return false;
} }
$db=new DB_System(); $db=new DB_System();
@ -220,7 +208,7 @@ class m_admin {
global $err,$mem,$cuid,$db; global $err,$mem,$cuid,$db;
$err->log("admin","mailallmembers"); $err->log("admin","mailallmembers");
if (!$this->enabled) { if (!$this->enabled) {
$err->raise("admin",1); $err->raise("admin",_("-- Only administrators can access this page! --"));
return false; return false;
} }
$subject=trim($subject); $subject=trim($subject);
@ -228,12 +216,12 @@ class m_admin {
$from=trim($from); $from=trim($from);
if (empty($subject) || empty($message) || empty($from) ){ if (empty($subject) || empty($message) || empty($from) ){
$err->raise("admin",16); $err->raise("admin",_("The password is too long according to the password policy");
return false; return false;
} }
if (checkmail($from) != 0) { if (checkmail($from) != 0) {
$err->raise("admin",17); $err->raise("admin",_("The password policy prevents you to use your login name inside your password"));
return false; return false;
} }
@ -260,16 +248,11 @@ class m_admin {
$creators = array(); $creators = array();
$err->log("admin","get_reseller_list"); $err->log("admin","get_reseller_list");
if (!$this->enabled) { if (!$this->enabled || $cuid!=2000) {
$err->raise("admin",1); $err->raise("admin",_("-- Only administrators can access this page! --"));
return false; return false;
} }
if ($cuid != 2000) {
$err->raise("admin",1);
return $creators;
}
$db=new DB_System(); $db=new DB_System();
$db->query("SELECT distinct creator FROM membres WHERE creator <> 0 ORDER BY creator asc;"); $db->query("SELECT distinct creator FROM membres WHERE creator <> 0 ORDER BY creator asc;");
if ($db->num_rows()) { if ($db->num_rows()) {
@ -280,6 +263,7 @@ class m_admin {
return $creators; return $creators;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Check if I am the creator of the member $uid /** Check if I am the creator of the member $uid
* @param integer $uid a unique integer identifying the account * @param integer $uid a unique integer identifying the account
@ -293,7 +277,7 @@ class m_admin {
$db->query("SELECT creator FROM membres WHERE uid='$uid';"); $db->query("SELECT creator FROM membres WHERE uid='$uid';");
$db->next_record(); $db->next_record();
if ($db->Record["creator"]!=$cuid) { if ($db->Record["creator"]!=$cuid) {
$err->raise("admin",1); $err->raise("admin",_("-- Only administrators can access this page! --"));
return false; return false;
} }
return true; return true;
@ -320,41 +304,40 @@ class m_admin {
global $err,$quota,$classes,$cuid,$mem,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$hooks; global $err,$quota,$classes,$cuid,$mem,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$hooks;
$err->log("admin","add_mem",$login."/".$mail); $err->log("admin","add_mem",$login."/".$mail);
if (!$this->enabled) { if (!$this->enabled) {
$err->raise("admin",1); $err->raise("admin",_("-- Only administrators can access this page! --"));
return false; return false;
} }
if (($login=="")||($pass=="")) { if (($login=="")||($pass=="")) {
$err->raise("admin",6); $err->raise("admin",_("All fields are mandatory"));
return false; return false;
} }
if (!$force) { if (!$force) {
if ($mail=="") { if ($mail=="") {
$err->raise("admin",6); $err->raise("admin",_("All fields are mandatory"));
return false; return false;
} }
if (checkmail($mail)!=0){ if (checkmail($mail)!=0){
$err->raise("admin",5); $err->raise("admin",_("Please enter a valid email address"));
return false; return false;
} }
} }
// Vérification de la conformité du login
$login=strtolower($login); $login=strtolower($login);
if (!preg_match("#^[a-z0-9]*$#",$login)) { //$ if (!preg_match("#^[a-z0-9]*$#",$login)) { //$
$err->raise("admin", "Login can only contains characters a-z and 0-9"); $err->raise("admin", _("Login can only contains characters a-z and 0-9"));
return false; return false;
} }
if (strlen($login) > 16) { if (strlen($login) > 16) {
$err->raise("admin",13); $err->raise("admin",_("The login is too long (16 chars max)"));
return false; return false;
} }
// Il ne peut pas être égal au login ou au nom de base systeme ! // Some login are not allowed...
if ($login==$L_MYSQL_DATABASE || $login==$L_MYSQL_LOGIN || $login=="mysql" || $login=="root") { if ($login==$L_MYSQL_DATABASE || $login==$L_MYSQL_LOGIN || $login=="mysql" || $login=="root") {
$err->raise("admin",10); $err->raise("admin",_("Login can only contains characters a-z, 0-9 and -"));
return false; return false;
} }
$pass=_md5cr($pass); $pass=_md5cr($pass);
$db=new DB_System(); $db=new DB_System();
// vérification de l'inexistence du membre dans system.membres // Already exist?
$db->query("SELECT count(*) AS cnt FROM membres WHERE login='$login';"); $db->query("SELECT count(*) AS cnt FROM membres WHERE login='$login';");
$db->next_record(); $db->next_record();
if (!$db->f("cnt")) { if (!$db->f("cnt")) {
@ -365,12 +348,11 @@ class m_admin {
$uid=$db->Record["nextid"]; $uid=$db->Record["nextid"];
if ($uid<=2000) $uid=2000; if ($uid<=2000) $uid=2000;
} }
// on le créé ensuite dans system.membres et system.local
$db->query("INSERT INTO membres (uid,login,pass,mail,creator,canpass,type,created, notes) VALUES ('$uid','$login','$pass','$mail','$cuid','$canpass', '$type', NOW(), '$notes');"); $db->query("INSERT INTO membres (uid,login,pass,mail,creator,canpass,type,created, notes) VALUES ('$uid','$login','$pass','$mail','$cuid','$canpass', '$type', NOW(), '$notes');");
$db->query("INSERT INTO local(uid,nom,prenom) VALUES('$uid','$nom','$prenom');"); $db->query("INSERT INTO local(uid,nom,prenom) VALUES('$uid','$nom','$prenom');");
$this->renew_update($uid, $duration); $this->renew_update($uid, $duration);
exec("/usr/lib/alternc/mem_add ".$login." ".$uid); exec("/usr/lib/alternc/mem_add ".$login." ".$uid);
// Declenchons les autres classes. // Triggering hooks
$mem->su($uid); $mem->su($uid);
// TODO: old hook method FIXME: when unused remove this // TODO: old hook method FIXME: when unused remove this
foreach($classes as $c) { foreach($classes as $c) {
@ -378,15 +360,17 @@ class m_admin {
$GLOBALS[$c]->alternc_add_member(); $GLOBALS[$c]->alternc_add_member();
} }
} }
// New hook way
$hooks->invoke("hook_admin_add_member"); $hooks->invoke("hook_admin_add_member");
$mem->unsu(); $mem->unsu();
return $uid; return $uid;
} else { } else {
$err->raise("admin",3); $err->raise("admin",_("This login already exists"));
return false; return false;
} }
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** 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.
@ -463,7 +447,7 @@ EOF;
$err->log("admin","update_mem",$uid); $err->log("admin","update_mem",$uid);
if (!$this->enabled) { if (!$this->enabled) {
$err->raise("admin",1); $err->raise("admin",_("-- Only administrators can access this page! --"));
return false; return false;
} }
$db=new DB_System(); $db=new DB_System();
@ -481,7 +465,7 @@ EOF;
return true; return true;
} }
else { else {
$err->raise("admin",2); $err->raise("admin",_("Account not found"));
return false; return false;
} }
} }
@ -489,9 +473,7 @@ EOF;
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Lock an account /** Lock an account
*
* Lock an account and prevent the user to access its account. * Lock an account and prevent the user to access its account.
*
* @param $uid integer the uid number of the account we want to lock * @param $uid integer the uid number of the account we want to lock
* @return boolean Returns FALSE if an error occurs, TRUE if not. * @return boolean Returns FALSE if an error occurs, TRUE if not.
*/ */
@ -499,7 +481,7 @@ EOF;
global $err,$db; global $err,$db;
$err->log("admin","lock_mem",$uid); $err->log("admin","lock_mem",$uid);
if (!$this->enabled) { if (!$this->enabled) {
$err->raise("admin",1); $err->raise("admin",_("-- Only administrators can access this page! --"));
return false; return false;
} }
$db=new DB_System(); $db=new DB_System();
@ -507,7 +489,7 @@ EOF;
return true; return true;
} }
else { else {
$err->raise("admin",2); $err->raise("admin",_("Account not found"));
return false; return false;
} }
} }
@ -515,9 +497,7 @@ EOF;
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** UnLock an account /** UnLock an account
*
* UnLock an account and prevent the user to access its account. * UnLock an account and prevent the user to access its account.
*
* @param $uid integer the uid number of the account we want to unlock * @param $uid integer the uid number of the account we want to unlock
* @return boolean Returns FALSE if an error occurs, TRUE if not. * @return boolean Returns FALSE if an error occurs, TRUE if not.
*/ */
@ -525,7 +505,7 @@ EOF;
global $err,$db; global $err,$db;
$err->log("admin","unlock_mem",$uid); $err->log("admin","unlock_mem",$uid);
if (!$this->enabled) { if (!$this->enabled) {
$err->raise("admin",1); $err->raise("admin",_("-- Only administrators can access this page! --"));
return false; return false;
} }
$db=new DB_System(); $db=new DB_System();
@ -533,7 +513,7 @@ EOF;
return true; return true;
} }
else { else {
$err->raise("admin",2); $err->raise("admin",_("Account not found"));
return false; return false;
} }
} }
@ -541,10 +521,8 @@ 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.
*
* @param $uid integer the uid number of the account we want to delete * @param $uid integer the uid number of the account we want to delete
* @return boolean Returns FALSE if an error occurs, TRUE if not. * @return boolean Returns FALSE if an error occurs, TRUE if not.
*/ */
@ -553,7 +531,7 @@ EOF;
$err->log("admin","del_mem",$uid); $err->log("admin","del_mem",$uid);
if (!$this->enabled) { if (!$this->enabled) {
$err->raise("admin",1); $err->raise("admin",_("-- Only administrators can access this page! --"));
return false; return false;
} }
$db=new DB_System(); $db=new DB_System();
@ -581,7 +559,7 @@ EOF;
$db->query("UPDATE membres SET creator=2000 WHERE creator='$uid';"); $db->query("UPDATE membres SET creator=2000 WHERE creator='$uid';");
return true; return true;
} else { } else {
$err->raise("admin",2); $err->raise("admin",_("Account not found"));
$mem->unsu(); $mem->unsu();
return false; return false;
} }
@ -590,7 +568,6 @@ EOF;
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Renew an account /** Renew an account
*
* Renew an account for its duration * Renew an account for its duration
* @param $uid integer the uid number of the account we want to renew * @param $uid integer the uid number of the account we want to renew
* @param $periods integer the number of periods we renew for * @param $periods integer the number of periods we renew for
@ -607,7 +584,7 @@ EOF;
if ($db->query($query)) { if ($db->query($query)) {
return true; return true;
} else { } else {
$err->raise("admin",2); $err->raise("admin",_("Account not found"));
return false; return false;
} }
} }
@ -631,14 +608,13 @@ EOF;
return true; return true;
} }
$err->raise("admin",2); $err->raise("admin",_("Account not found"));
return false; return false;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Get the expiry date for an account /** Get the expiry date for an account
*
* @param $uid integer The uid number of the account * @param $uid integer The uid number of the account
* @return string The expiry date, a string as printed by MySQL * @return string The expiry date, a string as printed by MySQL
*/ */
@ -656,7 +632,6 @@ EOF;
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Get the expiry status for an account /** Get the expiry status for an account
*
* @param $uid integer The uid number of the account * @param $uid integer The uid number of the account
* @return integer The expiry status: * @return integer The expiry status:
* 0: account does not expire * 0: account does not expire
@ -716,11 +691,11 @@ EOF;
global $err,$db; global $err,$db;
$db->query("SELECT su FROM membres WHERE uid='$uid';"); $db->query("SELECT su FROM membres WHERE uid='$uid';");
if (!$db->next_record()) { if (!$db->next_record()) {
$err->raise("admin",2); $err->raise("admin",_("Account not found"));
return false; return false;
} }
if ($db->Record["su"]!=0) { if ($db->Record["su"]!=0) {
$err->raise("admin",8); $err->raise("admin",_("This account is ALREADY an administrator account"));
return false; return false;
} }
$db->query("UPDATE membres SET su=1 WHERE uid='$uid';"); $db->query("UPDATE membres SET su=1 WHERE uid='$uid';");
@ -730,7 +705,6 @@ EOF;
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Turns a super-admin account into a common account /** Turns a super-admin account into a common account
*
* @param $uid integer the uid number of the super-admin account we want to turn into a * @param $uid integer the uid number of the super-admin account we want to turn into a
* common account. * common account.
* @return boolean Returns FALSE if an error occurs, TRUE if not. * @return boolean Returns FALSE if an error occurs, TRUE if not.
@ -739,27 +713,26 @@ EOF;
global $err,$db; global $err,$db;
$db->query("SELECT su FROM membres WHERE uid='$uid';"); $db->query("SELECT su FROM membres WHERE uid='$uid';");
if (!$db->next_record()) { if (!$db->next_record()) {
$err->raise("admin",2); $err->raise("admin",_("Account not found"));
return false; return false;
} }
if ($db->Record["su"]!=1) { if ($db->Record["su"]!=1) {
$err->raise("admin",9); $err->raise("admin",_("This account is NOT an administrator account!"));
return false; return false;
} }
$db->query("UPDATE membres SET su=0 WHERE uid='$uid';"); $db->query("UPDATE membres SET su=0 WHERE uid='$uid';");
return true; return true;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** List of the authorized TLDs /** List of the authorized TLDs
*
* Returns the list of the authorized TLDs and also the way they are * Returns the list of the authorized TLDs and also the way they are
* authorized. A TLD is the last members (or the last two) of a * authorized. A TLD is the last members (or the last two) of a
* domain. For example, "com", "org" etc... AlternC keeps a table * domain. For example, "com", "org" etc... AlternC keeps a table
* containing the list of the TLDs authorized to be installed on the * containing the list of the TLDs authorized to be installed on the
* server with the instructions to validate the installation of a * server with the instructions to validate the installation of a
* domain for each TLD (if necessary). * domain for each TLD (if necessary).
*
* @return array An associative array like $r["tld"], $r["mode"] where tld * @return array An associative array like $r["tld"], $r["mode"] where tld
* is the tld and mode is the authorized mode. * is the tld and mode is the authorized mode.
*/ */
@ -772,10 +745,9 @@ EOF;
return $c; return $c;
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** /** List the hosted domains on this server
* List the hosted domains on this server
*
* Return the list of hosted domains on this server, (an array of associative arrays) * Return the list of hosted domains on this server, (an array of associative arrays)
* @param boolean $alsocheck Returns also errstr and errno telling the domains dig checks * @param boolean $alsocheck Returns also errstr and errno telling the domains dig checks
* @param boolean $forcecheck Force the check of dig domain even if a cache exists. * @param boolean $forcecheck Force the check of dig domain even if a cache exists.
@ -886,7 +858,7 @@ EOF;
global $db,$err; global $db,$err;
$db->query("SELECT compte FROM domaines WHERE domaine='$domain';"); $db->query("SELECT compte FROM domaines WHERE domaine='$domain';");
if (!$db->next_record()) { if (!$db->next_record()) {
$err->raise("dom",1); $err->raise("dom",_("Domain '%s' not found."),$domain);
return false; return false;
} }
$db->query("UPDATE domaines SET noerase=1-noerase WHERE domaine='$domain';"); $db->query("UPDATE domaines SET noerase=1-noerase WHERE domaine='$domain';");
@ -905,7 +877,7 @@ EOF;
global $db,$err; global $db,$err;
$db->query("SELECT mode FROM tld WHERE tld='$tld';"); $db->query("SELECT mode FROM tld WHERE tld='$tld';");
if (!$db->next_record()) { if (!$db->next_record()) {
$err->raise("admin",11); $err->raise("admin",_("This TLD does not exist"));
return false; return false;
} }
return $db->Record["mode"]; return $db->Record["mode"];
@ -929,7 +901,6 @@ EOF;
/** Deletes the specified tld in the list of the authorized TLDs /** Deletes the specified tld in the list of the authorized TLDs
* <b>Note</b> : This function does not delete the domains depending * <b>Note</b> : This function does not delete the domains depending
* on this TLD * on this TLD
*
* @param $tld string The TLD you want to delete * @param $tld string 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.
@ -938,7 +909,7 @@ EOF;
global $db,$err; global $db,$err;
$db->query("SELECT tld FROM tld WHERE tld='$tld';"); $db->query("SELECT tld FROM tld WHERE tld='$tld';");
if (!$db->next_record()) { if (!$db->next_record()) {
$err->raise("admin",11); $err->raise("admin",_("This TLD does not exist"));
return false; return false;
} }
$db->query("DELETE FROM tld WHERE tld='$tld';"); $db->query("DELETE FROM tld WHERE tld='$tld';");
@ -948,7 +919,6 @@ 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
*
* @param $tld string TLD we want to authorize * @param $tld string TLD we want to authorize
* @param $mode integer Controls to make on this TLD. * @param $mode integer Controls to make on this TLD.
* <b>Note: </b> If you check in the whois, be sure that * <b>Note: </b> If you check in the whois, be sure that
@ -960,12 +930,12 @@ EOF;
function addtld($tld,$mode) { function addtld($tld,$mode) {
global $db,$err; global $db,$err;
if (!$tld) { if (!$tld) {
$err->raise("admin",12); $err->raise("admin",_("The TLD name is mandatory"));
return false; return false;
} }
$db->query("SELECT tld FROM tld WHERE tld='$tld';"); $db->query("SELECT tld FROM tld WHERE tld='$tld';");
if ($db->next_record()) { if ($db->next_record()) {
$err->raise("admin",12); $err->raise("admin",_("This TLD already exist"));
return false; return false;
} }
if (substr($tld,0,1)==".") $tld=substr($tld,1); if (substr($tld,0,1)==".") $tld=substr($tld,1);
@ -987,7 +957,7 @@ EOF;
global $db,$err; global $db,$err;
$db->query("SELECT tld FROM tld WHERE tld='$tld';"); $db->query("SELECT tld FROM tld WHERE tld='$tld';");
if (!$db->next_record()) { if (!$db->next_record()) {
$err->raise("admin",11); $err->raise("admin",_("This TLD does not exist"));
return false; return false;
} }
$mode=intval($mode); $mode=intval($mode);
@ -998,8 +968,8 @@ EOF;
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** Donne le login du compte administrateur principal d'AlternC /** Get the login name of the main administrator account
* @return string Retourne le login du compte admin ou root. * @return string the login name of admin, like 'root' for older alterncs
*/ */
function getadmin() { function getadmin() {
global $db; global $db;
@ -1091,7 +1061,7 @@ EOF;
global $db,$err; global $db,$err;
$pol=$this->listPasswordPolicies(); $pol=$this->listPasswordPolicies();
if (!$pol[$policy]) { if (!$pol[$policy]) {
$err->raise("admin",14); $err->raise("admin",_("-- Program error -- The requested password policy does not exist!"));
return false; return false;
} }
$pol=$pol[$policy]; $pol=$pol[$policy];
@ -1099,12 +1069,12 @@ EOF;
$plen=strlen($password); $plen=strlen($password);
if ($plen<$pol["minsize"]) { if ($plen<$pol["minsize"]) {
$err->raise("admin",15); $err->raise("admin",_("The password length is too short according to the password policy"));
return false; return false;
} }
if ($plen>$pol["maxsize"]) { if ($plen>$pol["maxsize"]) {
$err->raise("admin",16); $err->raise("admin",_("The password is too long according to the password policy"));
return false; return false;
} }
@ -1138,13 +1108,13 @@ EOF;
} // foreach } // foreach
$clc=array_sum($cls); $clc=array_sum($cls);
if ($clc<$pol["classcount"]) { if ($clc<$pol["classcount"]) {
$err->raise("admin",18,$pol["classcount"],$clc); $err->raise("admin",_("Your password contains not enough different classes of character, between low-case, up-case, figures and special characters."));
return false; return false;
} }
} }
return true; // congratulations ! return true; // congratulations !
} }
} /* Classe ADMIN */ } /* Classe ADMIN */

View File

@ -173,7 +173,7 @@ class m_dom {
$id=intval($id); $id=intval($id);
// The name MUST contain only letter and digits, it's an identifier after all ... // The name MUST contain only letter and digits, it's an identifier after all ...
if (!preg_match("#^[a-z0-9]+$#",$name)) { if (!preg_match("#^[a-z0-9]+$#",$name)) {
$err->raise("dom", 26); $err->raise("dom", _("The name MUST contain only letter and digits."));
return false; return false;
} }
$name=mysql_real_escape_string($name); $description=mysql_real_escape_string($description); $target=mysql_real_escape_string($target); $name=mysql_real_escape_string($name); $description=mysql_real_escape_string($description); $target=mysql_real_escape_string($target);
@ -292,49 +292,49 @@ class m_dom {
// Locked ? // Locked ?
if (!$this->islocked) { if (!$this->islocked) {
$err->raise("dom",3); $err->raise("dom",_("--- Program error --- No lock on the domains!"));
return false; return false;
} }
// Verifie que le domaine est rfc-compliant // Verifie que le domaine est rfc-compliant
$domain=strtolower($domain); $domain=strtolower($domain);
$t=checkfqdn($domain); $t=checkfqdn($domain);
if ($t) { if ($t) {
$err->raise("dom",3+$t); $err->raise("dom",_("The domain name is syntaxically incorrect"));
return false; return false;
} }
// Interdit les domaines clés (table forbidden_domains) sauf en cas FORCE // Interdit les domaines clés (table forbidden_domains) sauf en cas FORCE
$db->query("SELECT domain FROM forbidden_domains WHERE domain='$domain'"); $db->query("SELECT domain FROM forbidden_domains WHERE domain='$domain'");
if ($db->num_rows() && !$force) { if ($db->num_rows() && !$force) {
$err->raise("dom",22); $err->raise("dom",_("The requested domain is forbidden in this server, please contact the administrator"));
return false; return false;
} }
if ($domain==$L_FQDN || $domain=="www.$L_FQDN") { if ($domain==$L_FQDN || $domain=="www.$L_FQDN") {
$err->raise("dom",18); $err->raise("dom",_("This domain is the server's domain! You cannot host it on your account!"));
return false; return false;
} }
$db->query("SELECT compte FROM domaines WHERE domaine='$domain';"); $db->query("SELECT compte FROM domaines WHERE domaine='$domain';");
if ($db->num_rows()) { if ($db->num_rows()) {
$err->raise("dom",8); $err->raise("dom",_("The domain already exist."));
return false; return false;
} }
$db->query("SELECT compte FROM `sub_domaines` WHERE sub != \"\" AND concat( sub, \".\", domaine )='$domain' OR domaine='$domain';"); $db->query("SELECT compte FROM `sub_domaines` WHERE sub != \"\" AND concat( sub, \".\", domaine )='$domain' OR domaine='$domain';");
if ($db->num_rows()) { if ($db->num_rows()) {
$err->raise("dom",8); $err->raise("dom",_("The domain already exist."));
return false; return false;
} }
$this->dns=$this->whois($domain); $this->dns=$this->whois($domain);
if (!$force) { if (!$force) {
$v=checkhostallow($domain,$this->dns); $v=checkhostallow($domain,$this->dns);
if ($v==-1) { if ($v==-1) {
$err->raise("dom",7); // TLD interdit $err->raise("dom",_("The last member of the domain name is incorrect or cannot be hosted in that server."));
return false; return false;
} }
if ($dns && $v==-2) { if ($dns && $v==-2) {
$err->raise("dom",12); // Domaine non trouvé dans le whois $err->raise("dom",_("The domain cannot be found in the whois database."));
return false; return false;
} }
if ($dns && $v==-3) { if ($dns && $v==-3) {
$err->raise("dom",23); // Domaine non trouvé dans le whois $err->raise("dom",_("The domain cannot be found in the whois database."));
return false; return false;
} }
@ -346,14 +346,14 @@ class m_dom {
if (!$dns) { if (!$dns) {
$v=checkhostallow_nodns($domain); $v=checkhostallow_nodns($domain);
if ($v) { if ($v) {
$err->raise("dom",22); $err->raise("dom",_("The requested domain is forbidden in this server, please contact the administrator"));
return false; return false;
} }
} }
} }
// Check the quota : // Check the quota :
if (!$quota->cancreate("dom")) { if (!$quota->cancreate("dom")) {
$err->raise("dom",10); $err->raise("dom",_("Your domain quota is over, you cannot create more domain names."));
return false; return false;
} }
if ($noerase) $noerase="1"; else $noerase="0"; if ($noerase) $noerase="1"; else $noerase="0";
@ -368,7 +368,7 @@ class m_dom {
$db->query("SELECT domaine FROM domaines WHERE compte='$cuid' AND domaine='$slavedom';"); $db->query("SELECT domaine FROM domaines WHERE compte='$cuid' AND domaine='$slavedom';");
$db->next_record(); $db->next_record();
if (!$db->Record["domaine"]) { if (!$db->Record["domaine"]) {
$err->raise("dom",1,$slavedom); $err->raise("dom",_("Domain '%s' not found."),$slavedom);
$isslave=false; $isslave=false;
} }
// Point to the master domain : // Point to the master domain :
@ -383,14 +383,14 @@ class m_dom {
if (! is_dir($dest_root . "/". $domshort)) { if (! is_dir($dest_root . "/". $domshort)) {
if(!mkdir($dest_root . "/". $domshort)){ if(!mkdir($dest_root . "/". $domshort)){
$err->raise("dom",1); $err->raise("dom",_("I can't write to the destination folder"));
return false; return false;
} }
} }
if (! is_dir($dest_root . "/tmp")) { if (! is_dir($dest_root . "/tmp")) {
if(!mkdir($dest_root . "/tmp")){ if(!mkdir($dest_root . "/tmp")){
$err->raise("dom",1); $err->raise("dom",_("I can't write to the destination folder"));
return false; return false;
} }
} }
@ -560,14 +560,14 @@ class m_dom {
} // while } // while
fclose($fp); fclose($fp);
} else { } else {
$err->raise("dom",11); $err->raise("dom",_("The Whois database is unavailable, please try again later."));
return false; return false;
} }
if ($found) { if ($found) {
return $server; return $server;
} else { } else {
$err->raise("dom",12); $err->raise("dom",_("The domain cannot be found in the whois database."));
return false; return false;
} }
} // whois } // whois
@ -638,18 +638,18 @@ class m_dom {
$err->log("dom","get_domain_all",$dom); $err->log("dom","get_domain_all",$dom);
// Locked ? // Locked ?
if (!$this->islocked) { if (!$this->islocked) {
$err->raise("dom",3); $err->raise("dom",_("--- Program error --- No lock on the domains!"));
return false; return false;
} }
$t=checkfqdn($dom); $t=checkfqdn($dom);
if ($t) { if ($t) {
$err->raise("dom",3+$t); $err->raise("dom",_("The domain name is syntaxically incorrect"));
return false; return false;
} }
$r["name"]=$dom; $r["name"]=$dom;
$db->query("SELECT * FROM domaines WHERE compte='$cuid' AND domaine='$dom'"); $db->query("SELECT * FROM domaines WHERE compte='$cuid' AND domaine='$dom'");
if ($db->num_rows()==0) { if ($db->num_rows()==0) {
$err->raise("dom",1,$dom); $err->raise("dom",1,_("Domain '%s' not found."),$dom);
return false; return false;
} }
$db->next_record(); $db->next_record();