fixing error messages in MySQL and Mem
This commit is contained in:
parent
a7a43f6bee
commit
e865f4e906
|
@ -357,7 +357,7 @@ class m_mem {
|
|||
return false;
|
||||
}
|
||||
if ($newpass!=$newpass2) {
|
||||
$err->raise("mem",_("The new passwords are differents, please retry."));
|
||||
$err->raise("mem",_("The new passwords are differents, please retry"));
|
||||
return false;
|
||||
}
|
||||
$db->query("SELECT login FROM membres WHERE uid='$cuid';");
|
||||
|
|
|
@ -148,7 +148,7 @@ class m_mysql {
|
|||
$err->log("mysql","php_myadmin_connect");
|
||||
$db->query("SELECT name,password FROM dbusers WHERE uid='$cuid' and enable='ADMIN';");
|
||||
if (!$db->num_rows()) {
|
||||
$err->raise("mysql",_("Cannot connect to PhpMyadmin"));
|
||||
$err->raise("mysql",_("Cannot connect to PhpMyAdmin"));
|
||||
return false;
|
||||
}
|
||||
$db->next_record();
|
||||
|
@ -189,7 +189,7 @@ class m_mysql {
|
|||
$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';");
|
||||
if (!$db->num_rows()) {
|
||||
$err->raise("mysql",_("The database %s not found"),$dbn);
|
||||
$err->raise("mysql",_("Database %s not found"),$dbn);
|
||||
return array("enabled"=>false);
|
||||
}
|
||||
$c=array();
|
||||
|
@ -216,7 +216,7 @@ class m_mysql {
|
|||
$err->log("mysql","add_db",$dbn);
|
||||
$password_user="";
|
||||
if (!$quota->cancreate("mysql")) {
|
||||
$err->raise("mysql",_("Your databases quota is over. You cannot create more databases."));
|
||||
$err->raise("mysql",_("Your databases quota is over. You cannot create more databases"));
|
||||
return false;
|
||||
}
|
||||
$pos=strpos($dbn,'_');
|
||||
|
@ -228,18 +228,18 @@ class m_mysql {
|
|||
$dbn=$dbncomp[1];
|
||||
}
|
||||
if (!preg_match("#^[0-9a-z]*$#",$dbn)) {
|
||||
$err->raise("mysql",_("Database name can only only letters and numbers."));
|
||||
$err->raise("mysql",_("Database name can contain only letters and numbers"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (strlen($dbname) > 64) {
|
||||
$err->raise("mysql",_("Database name cannot exceed 64 characters."));
|
||||
$err->raise("mysql",_("Database name cannot exceed 64 characters"));
|
||||
return false;
|
||||
}
|
||||
$db->query("SELECT * FROM db WHERE db='$dbname';");
|
||||
if ($db->num_rows()) {
|
||||
$err->raise("mysql",_("Database %s already exists."),$dbn);
|
||||
$err->raise("mysql",_("Database %s already exists"),$dbn);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ class m_mysql {
|
|||
$myadm=$db->f("name");
|
||||
$password=$db->f("password");
|
||||
}else{
|
||||
$err->raise("mysql",_("There is a problem with the special PhpMyadmin user. Contact the administrator."));//FIXME error code
|
||||
$err->raise("mysql",_("There is a problem with the special PhpMyAdmin user. Contact the administrator"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ class m_mysql {
|
|||
return true;
|
||||
} else {
|
||||
$err->log("mysql","add_db",$dbn);
|
||||
$err->raise("mysql",_("An error occured. The database could not be created."));
|
||||
$err->raise("mysql",_("An error occured. The database could not be created"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ class m_mysql {
|
|||
$dbname=addslashes($dbn);
|
||||
$db->query("SELECT uid FROM db WHERE db='$dbname';");
|
||||
if (!$db->num_rows()) {
|
||||
$err->raise("mysql",_("The database was not found. Suppression failed."));
|
||||
$err->raise("mysql",_("The database was not found. I can't delete it"));
|
||||
return false;
|
||||
}
|
||||
$db->next_record();
|
||||
|
@ -336,13 +336,13 @@ class m_mysql {
|
|||
$dbn=$dbncomp[1];
|
||||
}
|
||||
if (!preg_match("#^[0-9a-z]*$#",$dbn)) {
|
||||
$err->raise("mysql",_("Database name can contain only letters and numbers."));
|
||||
$err->raise("mysql",_("Database name can contain only letters and numbers"));
|
||||
return false;
|
||||
}
|
||||
printvar("SELECT * FROM db WHERE uid='$cuid' AND db='$dbname';");
|
||||
$db->query("SELECT * FROM db WHERE uid='$cuid' AND db='$dbname';");
|
||||
if (!$db->num_rows()) {
|
||||
$err->raise("mysql",_("Database %s not found."),$dbn);
|
||||
$err->raise("mysql",_("Database %s not found"),$dbn);
|
||||
return false;
|
||||
}
|
||||
$db->next_record();
|
||||
|
@ -355,11 +355,11 @@ class m_mysql {
|
|||
if (!$bck_mode)
|
||||
$bck_mode="0";
|
||||
if (!$bck_history) {
|
||||
$err->raise("mysql",_("You have to choose how many backups you want to keep."));
|
||||
$err->raise("mysql",_("You have to choose how many backups you want to keep"));
|
||||
return false;
|
||||
}
|
||||
if (($bck_dir=$bro->convertabsolute($bck_dir,0))===false) { // return a full path or FALSE
|
||||
$err->raise("mysql",_("Directory does not exists."));
|
||||
$err->raise("mysql",_("Directory does not exist"));
|
||||
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';");
|
||||
|
@ -377,19 +377,19 @@ class m_mysql {
|
|||
$err->log("mysql","put_mysql_details");
|
||||
$db->query("SELECT * FROM db WHERE uid='$cuid';");
|
||||
if (!$db->num_rows()) {
|
||||
$err->raise("mysql",_("Database not found."));
|
||||
$err->raise("mysql",_("Database not found"));
|
||||
return false;
|
||||
}
|
||||
$db->next_record();
|
||||
$login=$db->f("login");
|
||||
|
||||
if (!$password) {
|
||||
$err->raise("mysql",_("You have to set a new password."));
|
||||
$err->raise("mysql",_("The password is mandatory"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strlen($password)>16) {
|
||||
$err->raise("mysql",_("Mysql password cannot exceed 16 characters."));
|
||||
$err->raise("mysql",_("MySQL password cannot exceed 16 characters"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -419,28 +419,28 @@ class m_mysql {
|
|||
$err->log("mysql","grant",$base."-".$user);
|
||||
|
||||
if(!preg_match("#^[0-9a-z_\\*\\\\]*$#",$base)){
|
||||
$err->raise("mysql",_("Database name can only contain letters and numbers."));
|
||||
$err->raise("mysql",_("Database name can contain only letters and numbers"));
|
||||
return false;
|
||||
}elseif(!$db->query("select db from db where db='$base';")){
|
||||
$err->raise("mysql","query base fail");
|
||||
} elseif (!$db->query("select db from db where db='$base';")){
|
||||
$err->raise("mysql","Database not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
if($rights==null){
|
||||
$rights='ALL PRIVILEGES';
|
||||
}elseif(!preg_match("#^[a-zA-Z,\s]*$#",$rights)){
|
||||
$err->raise("mysql",_("Databases rights are not correct."));
|
||||
$err->raise("mysql",_("Databases rights are not correct"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!preg_match("#^[0-9a-z_-]*$#",$user)) {
|
||||
$err->raise("mysql",_("Database username can contain only letters numbers hyphen and underscores"));
|
||||
if (!preg_match("#^[0-9a-z]#",$user)) {
|
||||
$err->raise("mysql",_("The username can contain only letters and numbers."));
|
||||
return false;
|
||||
}
|
||||
$db->query("select name from dbusers where name='".$user."' ;");
|
||||
|
||||
if(!$db->num_rows()){
|
||||
$err->raise("mysql","Database user not found.");
|
||||
$err->raise("mysql","Database user not found");
|
||||
return false;
|
||||
}
|
||||
if($rights == "FILE"){
|
||||
|
@ -455,7 +455,7 @@ class m_mysql {
|
|||
$grant .= ";";
|
||||
}
|
||||
if(!$this->dbus->query($grant)){
|
||||
$err->raise("mysql",_("Could not grant rights."));
|
||||
$err->raise("mysql",_("Could not grant rights"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -477,7 +477,7 @@ class m_mysql {
|
|||
return false;
|
||||
}
|
||||
if (!($fi=$bro->convertabsolute($file,0))) {
|
||||
$err->raise("mysql",_("File not found."));
|
||||
$err->raise("mysql",_("File not found"));
|
||||
return false;
|
||||
}
|
||||
if (substr($fi,-3)==".gz") {
|
||||
|
@ -655,31 +655,31 @@ class m_mysql {
|
|||
$pass=addslashes($password);
|
||||
|
||||
if (!$usern) {
|
||||
$err->raise("mysql",_("You have to input a username."));
|
||||
$err->raise("mysql",_("The username is mandatory"));
|
||||
return false;
|
||||
}
|
||||
if (!$pass) {
|
||||
$err->raise("mysql",_("You have to input a password."));
|
||||
$err->raise("mysql",_("The password is mandatory"));
|
||||
return false;
|
||||
}
|
||||
if (!preg_match("#^[0-9a-z]#",$usern)) {
|
||||
$err->raise("mysql",_("The username can contain only letters and numbers."));
|
||||
$err->raise("mysql",_("The username can contain only letters and numbers"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// We check the length of the COMPLETE username, not only the part after _
|
||||
if (strlen($user) > 16) {
|
||||
$err->raise("mysql",_("Mysql username cannot exceed 16 characters."));
|
||||
$err->raise("mysql",_("MySQL username cannot exceed 16 characters"));
|
||||
return false;
|
||||
}
|
||||
$db->query("SELECT * FROM dbusers WHERE name='$user';");
|
||||
if ($db->num_rows()) {
|
||||
$err->raise("mysql",_("The database user was not found."));
|
||||
$err->raise("mysql",_("The database user was not found"));
|
||||
return false;
|
||||
}
|
||||
if ($password != $passconf || !$password) {
|
||||
$err->raise("mysql",_("The passwords do not match."));
|
||||
$err->raise("mysql",_("The passwords do not match"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -711,13 +711,9 @@ class m_mysql {
|
|||
|
||||
$usern=trim($usern);
|
||||
$user=addslashes($usern);
|
||||
if(!preg_match("#^[0-9a-zA-Z_]*$#",$password)) {
|
||||
$err->raise("mysql",_("Database password can contain only letters numbers and underscore."));
|
||||
return false;
|
||||
}
|
||||
$pass=addslashes($password);
|
||||
if ($password != $passconf || !$password) {
|
||||
$err->raise("mysql",_("The passwords do not match."));
|
||||
$err->raise("mysql",_("The passwords do not match"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -744,12 +740,12 @@ class m_mysql {
|
|||
global $db,$err,$mem,$cuid,$L_MYSQL_DATABASE;
|
||||
$err->log("mysql","del_user",$user);
|
||||
if (!preg_match("#^[0-9a-z]#",$user)) {
|
||||
$err->raise("mysql",_("The username can contain only letters and numbers."));
|
||||
$err->raise("mysql",_("The username can contain only letters and numbers"));
|
||||
return false;
|
||||
}
|
||||
$db->query("SELECT name FROM dbusers WHERE name='".$user."' and enable not in ('ADMIN','HIDDEN');");
|
||||
if (!$db->num_rows()) {
|
||||
$err->raise("mysql",_("The username was not found."));
|
||||
$err->raise("mysql",_("The username was not found"));
|
||||
return false;
|
||||
}
|
||||
$db->next_record();
|
||||
|
|
Loading…
Reference in New Issue