Return an error when attempting to connect to PHPMyAdmin with no DBs

Refs #335
This commit is contained in:
Kienan Stewart 2019-05-14 12:14:25 -04:00
parent f6860ed2be
commit 70184caa3a
No known key found for this signature in database
GPG Key ID: 075A846E78FE47EA
1 changed files with 7 additions and 1 deletions

View File

@ -157,9 +157,15 @@ class m_mysql {
function php_myadmin_connect() { function php_myadmin_connect() {
global $db, $cuid, $msg; global $db, $cuid, $msg;
$msg->log("mysql", "php_myadmin_connect"); $msg->log("mysql", "php_myadmin_connect");
$db->query("SELECT count(0) as count from db where uid = ?;", array($cuid));
$db->next_record();
if ($db->f('count') == 0) {
$msg->raise("ERROR", "mysql", _("Cannot connect to PhpMyAdmin, no databases for user {$cuid}"));
return false;
}
$db->query("SELECT dbu.name,dbu.password, dbs.host FROM dbusers dbu, db_servers dbs, membres m WHERE dbu.uid= ? and enable='ADMIN' and dbs.id=m.db_server_id and m.uid= ? ;", array($cuid, $cuid)); $db->query("SELECT dbu.name,dbu.password, dbs.host FROM dbusers dbu, db_servers dbs, membres m WHERE dbu.uid= ? and enable='ADMIN' and dbs.id=m.db_server_id and m.uid= ? ;", array($cuid, $cuid));
if (!$db->num_rows()) { if (!$db->num_rows()) {
$msg->raise("ERROR", "mysql", _("Cannot connect to PhpMyAdmin")); $msg->raise("ERROR", "mysql", _("Cannot connect to PhpMyAdmin, no admin user for uid {$cuid}"));
return false; return false;
} }
$db->next_record(); $db->next_record();