Updating raise() error messages
This commit is contained in:
parent
3e17f3ea32
commit
367895b8da
|
@ -617,7 +617,7 @@ class m_mail {
|
||||||
$pass=mysql_escape_string($pass);
|
$pass=mysql_escape_string($pass);
|
||||||
$db->query("SELECT * FROM mxaccount WHERE login='$login'");
|
$db->query("SELECT * FROM mxaccount WHERE login='$login'");
|
||||||
if ($db->next_record()) {
|
if ($db->next_record()) {
|
||||||
$err->raise("mail",16);
|
$err->raise("mail",_("The MX account was not found."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("INSERT INTO mxaccount (login,pass) VALUES ('$login','$pass')");
|
$db->query("INSERT INTO mxaccount (login,pass) VALUES ('$login','$pass')");
|
||||||
|
|
|
@ -148,7 +148,7 @@ class m_mysql {
|
||||||
$err->log("mysql","php_myadmin_connect");
|
$err->log("mysql","php_myadmin_connect");
|
||||||
$db->query("SELECT name,password FROM dbusers WHERE uid='$cuid' and enable='ADMIN';");
|
$db->query("SELECT name,password FROM dbusers WHERE uid='$cuid' and enable='ADMIN';");
|
||||||
if (!$db->num_rows()) {
|
if (!$db->num_rows()) {
|
||||||
$err->raise("mysql",11);
|
$err->raise("mysql",_("Cannot connect to PhpMyadmin"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
|
@ -182,7 +182,7 @@ class m_mysql {
|
||||||
$size=$this->get_db_size($dbname);
|
$size=$this->get_db_size($dbname);
|
||||||
$db->query("SELECT login,pass,db, bck_mode, bck_gzip, bck_dir, bck_history FROM db WHERE uid='$cuid' AND db='$dbname';");
|
$db->query("SELECT login,pass,db, bck_mode, bck_gzip, bck_dir, bck_history FROM db WHERE uid='$cuid' AND db='$dbname';");
|
||||||
if (!$db->num_rows()) {
|
if (!$db->num_rows()) {
|
||||||
$err->raise("mysql",4);
|
$err->raise("mysql",_("The database %s not found"),$dbn);
|
||||||
return array("enabled"=>false);
|
return array("enabled"=>false);
|
||||||
}
|
}
|
||||||
$c=array();
|
$c=array();
|
||||||
|
@ -209,7 +209,7 @@ class m_mysql {
|
||||||
$err->log("mysql","add_db",$dbn);
|
$err->log("mysql","add_db",$dbn);
|
||||||
$password_user="";
|
$password_user="";
|
||||||
if (!$quota->cancreate("mysql")) {
|
if (!$quota->cancreate("mysql")) {
|
||||||
$err->raise("mysql",1);
|
$err->raise("mysql",_("Your databases quota is over. You cannot create more databases."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$pos=strpos($dbn,'_');
|
$pos=strpos($dbn,'_');
|
||||||
|
@ -221,18 +221,18 @@ class m_mysql {
|
||||||
$dbn=$dbncomp[1];
|
$dbn=$dbncomp[1];
|
||||||
}
|
}
|
||||||
if (!preg_match("#^[0-9a-z]*$#",$dbn)) {
|
if (!preg_match("#^[0-9a-z]*$#",$dbn)) {
|
||||||
$err->raise("mysql",2);
|
$err->raise("mysql",_("Database name can only only letters and numbers."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (strlen($dbname) > 64) {
|
if (strlen($dbname) > 64) {
|
||||||
$err->raise("mysql",12);
|
$err->raise("mysql",_("Database name cannot exceed 64 characters."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("SELECT * FROM db WHERE db='$dbname';");
|
$db->query("SELECT * FROM db WHERE db='$dbname';");
|
||||||
if ($db->num_rows()) {
|
if ($db->num_rows()) {
|
||||||
$err->raise("mysql",3);
|
$err->raise("mysql",_("Database %s already exists."),$dbn);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ class m_mysql {
|
||||||
$myadm=$db->f("name");
|
$myadm=$db->f("name");
|
||||||
$password=$db->f("password");
|
$password=$db->f("password");
|
||||||
}else{
|
}else{
|
||||||
$err->raise("mysql",3);//FIXME error code
|
$err->raise("mysql",_("There is a problem with the special PhpMyadmin user. Contact the administrator."));//FIXME error code
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ class m_mysql {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$err->log("mysql","add_db",$dbn);
|
$err->log("mysql","add_db",$dbn);
|
||||||
$err->raise("mysql",3);
|
$err->raise("mysql",_("An error occured. The database could not be created."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ class m_mysql {
|
||||||
$dbname=addslashes($dbn);
|
$dbname=addslashes($dbn);
|
||||||
$db->query("SELECT uid FROM db WHERE db='$dbname';");
|
$db->query("SELECT uid FROM db WHERE db='$dbname';");
|
||||||
if (!$db->num_rows()) {
|
if (!$db->num_rows()) {
|
||||||
$err->raise("mysql",4);
|
$err->raise("mysql",_("The database was not found. Suppression failed."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
|
@ -321,13 +321,13 @@ class m_mysql {
|
||||||
global $db,$err,$mem,$bro,$cuid;
|
global $db,$err,$mem,$bro,$cuid;
|
||||||
$err->log("mysql","put_mysql_backup");
|
$err->log("mysql","put_mysql_backup");
|
||||||
if (!preg_match("#^[0-9a-z]*$#",$dbn)) {
|
if (!preg_match("#^[0-9a-z]*$#",$dbn)) {
|
||||||
$err->raise("mysql",2);
|
$err->raise("mysql",_("Database name can contain only letters and numbers."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$dbname=$mem->user["login"].($dbn?"_":"").$dbn;
|
$dbname=$mem->user["login"].($dbn?"_":"").$dbn;
|
||||||
$db->query("SELECT * FROM db WHERE uid='$cuid' AND db='$dbname';");
|
$db->query("SELECT * FROM db WHERE uid='$cuid' AND db='$dbname';");
|
||||||
if (!$db->num_rows()) {
|
if (!$db->num_rows()) {
|
||||||
$err->raise("mysql",4);
|
$err->raise("mysql",_("Database %s not found."),$dbn);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
|
@ -340,11 +340,11 @@ class m_mysql {
|
||||||
if (!$bck_mode)
|
if (!$bck_mode)
|
||||||
$bck_mode="0";
|
$bck_mode="0";
|
||||||
if (!$bck_history) {
|
if (!$bck_history) {
|
||||||
$err->raise("mysql",5);
|
$err->raise("mysql",_("You have to choose how many backups you want to keep."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (($bck_dir=$bro->convertabsolute($bck_dir,0))===false) { // return a full path or FALSE
|
if (($bck_dir=$bro->convertabsolute($bck_dir,0))===false) { // return a full path or FALSE
|
||||||
$err->raise("mysql",6);
|
$err->raise("mysql",_("Directory does not exists."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("UPDATE db SET bck_mode='$bck_mode', bck_history='$bck_history', bck_gzip='$bck_gzip', bck_dir='$bck_dir' WHERE uid='$cuid' AND db='$dbname';");
|
$db->query("UPDATE db SET bck_mode='$bck_mode', bck_history='$bck_history', bck_gzip='$bck_gzip', bck_dir='$bck_dir' WHERE uid='$cuid' AND db='$dbname';");
|
||||||
|
@ -362,18 +362,19 @@ class m_mysql {
|
||||||
$err->log("mysql","put_mysql_details");
|
$err->log("mysql","put_mysql_details");
|
||||||
$db->query("SELECT * FROM db WHERE uid='$cuid';");
|
$db->query("SELECT * FROM db WHERE uid='$cuid';");
|
||||||
if (!$db->num_rows()) {
|
if (!$db->num_rows()) {
|
||||||
$err->raise("mysql",7);
|
$err->raise("mysql",_("Database not found."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
$login=$db->f("login");
|
$login=$db->f("login");
|
||||||
|
|
||||||
if (strlen($password)>16) {
|
if (!$password) {
|
||||||
$err->raise("mysql",8);
|
$err->raise("mysql",_("You have to set a new password."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!$password) {
|
|
||||||
$err->raise("mysql",20);
|
if (strlen($password)>16) {
|
||||||
|
$err->raise("mysql",_("Mysql password cannot exceed 16 characters."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +404,7 @@ class m_mysql {
|
||||||
$err->log("mysql","grant",$base."-".$user);
|
$err->log("mysql","grant",$base."-".$user);
|
||||||
|
|
||||||
if(!preg_match("#^[0-9a-z_\\*\\\\]*$#",$base)){
|
if(!preg_match("#^[0-9a-z_\\*\\\\]*$#",$base)){
|
||||||
$err->raise("mysql","base_not_match");
|
$err->raise("mysql",_("Database name can only contain letters and numbers."));
|
||||||
return false;
|
return false;
|
||||||
}elseif(!$db->query("select db from db where db='$base';")){
|
}elseif(!$db->query("select db from db where db='$base';")){
|
||||||
$err->raise("mysql","query base fail");
|
$err->raise("mysql","query base fail");
|
||||||
|
@ -413,18 +414,18 @@ class m_mysql {
|
||||||
if($rights==null){
|
if($rights==null){
|
||||||
$rights='ALL PRIVILEGES';
|
$rights='ALL PRIVILEGES';
|
||||||
}elseif(!preg_match("#^[a-zA-Z,\s]*$#",$rights)){
|
}elseif(!preg_match("#^[a-zA-Z,\s]*$#",$rights)){
|
||||||
$err->raise("mysql","rights_fail");
|
$err->raise("mysql",_("Databases rights are not correct."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!preg_match("#^[0-9a-z_]*$#",$user)) {
|
if(!preg_match("#^[0-9a-z_]*$#",$user)) {
|
||||||
$err->raise("mysql","user match");
|
$err->raise("mysql",_("Database username can contain only letters numbers and underscores"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("select name from dbusers where name='".$user."' ;");
|
$db->query("select name from dbusers where name='".$user."' ;");
|
||||||
|
|
||||||
if(!$db->num_rows()){
|
if(!$db->num_rows()){
|
||||||
$err->raise("mysql","num row 0:");
|
$err->raise("mysql","Database user not found.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if($rights == "FILE"){
|
if($rights == "FILE"){
|
||||||
|
@ -439,7 +440,7 @@ class m_mysql {
|
||||||
$grant .= ";";
|
$grant .= ";";
|
||||||
}
|
}
|
||||||
if(!$this->dbus->query($grant)){
|
if(!$this->dbus->query($grant)){
|
||||||
$err->raise("mysql","grant fail:".$grant);
|
$err->raise("mysql",_("Could not grant rights."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -461,7 +462,7 @@ class m_mysql {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!($fi=$bro->convertabsolute($file,0))) {
|
if (!($fi=$bro->convertabsolute($file,0))) {
|
||||||
$err->raise("mysql",9);
|
$err->raise("mysql",_("File not found."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (substr($fi,-3)==".gz") {
|
if (substr($fi,-3)==".gz") {
|
||||||
|
@ -639,31 +640,31 @@ class m_mysql {
|
||||||
$pass=addslashes($password);
|
$pass=addslashes($password);
|
||||||
|
|
||||||
if (!$usern) {
|
if (!$usern) {
|
||||||
$err->raise("mysql",21);
|
$err->raise("mysql",_("You have to input a username."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!$pass) {
|
if (!$pass) {
|
||||||
$err->raise("mysql",20);
|
$err->raise("mysql",_("You have to input a password."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!preg_match("#^[0-9a-z]#",$usern)) {
|
if (!preg_match("#^[0-9a-z]#",$usern)) {
|
||||||
$err->raise("mysql",14);
|
$err->raise("mysql",_("The username can contain only letters and numbers."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// We check the length of the COMPLETE username, not only the part after _
|
// We check the length of the COMPLETE username, not only the part after _
|
||||||
if (strlen($user) > 16) {
|
if (strlen($user) > 16) {
|
||||||
$err->raise("mysql",15);
|
$err->raise("mysql",_("Mysql username cannot exceed 16 characters."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("SELECT * FROM dbusers WHERE name='$user';");
|
$db->query("SELECT * FROM dbusers WHERE name='$user';");
|
||||||
if ($db->num_rows()) {
|
if ($db->num_rows()) {
|
||||||
$err->raise("mysql",16);
|
$err->raise("mysql",_("The database user was not found."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($password != $passconf || !$password) {
|
if ($password != $passconf || !$password) {
|
||||||
$err->raise("mysql",17);
|
$err->raise("mysql",_("The passwords do not match."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,7 +698,7 @@ class m_mysql {
|
||||||
$user=addslashes($usern);
|
$user=addslashes($usern);
|
||||||
$pass=addslashes($password);
|
$pass=addslashes($password);
|
||||||
if ($password != $passconf || !$password) {
|
if ($password != $passconf || !$password) {
|
||||||
$err->raise("mysql",17);
|
$err->raise("mysql",_("The passwords do not match."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -724,12 +725,12 @@ class m_mysql {
|
||||||
global $db,$err,$mem,$cuid,$L_MYSQL_DATABASE;
|
global $db,$err,$mem,$cuid,$L_MYSQL_DATABASE;
|
||||||
$err->log("mysql","del_user",$user);
|
$err->log("mysql","del_user",$user);
|
||||||
if (!preg_match("#^[0-9a-z]#",$user)) {
|
if (!preg_match("#^[0-9a-z]#",$user)) {
|
||||||
$err->raise("mysql",14);
|
$err->raise("mysql",_("The username can contain only letters and numbers."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->query("SELECT name FROM dbusers WHERE name='".$user."' and enable not in ('ADMIN','HIDDEN');");
|
$db->query("SELECT name FROM dbusers WHERE name='".$user."' and enable not in ('ADMIN','HIDDEN');");
|
||||||
if (!$db->num_rows()) {
|
if (!$db->num_rows()) {
|
||||||
$err->raise("mysql",18);
|
$err->raise("mysql",_("The username was not found."));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
|
@ -1005,7 +1006,7 @@ class m_mysql {
|
||||||
$dir.="sql/";
|
$dir.="sql/";
|
||||||
if(!is_dir($dir)){
|
if(!is_dir($dir)){
|
||||||
if(!mkdir($dir)){
|
if(!mkdir($dir)){
|
||||||
$err->raise('mysql',4);
|
$err->raise('mysql',_("The directory could not be created"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// on exporte toutes les bases utilisateur.
|
// on exporte toutes les bases utilisateur.
|
||||||
|
|
Loading…
Reference in New Issue