From: Joe Presbrey Date: Wed, 30 Nov 2005 16:36:43 +0000 (+0000) Subject: bug: dropping database outside the interface stops interface for all users X-Git-Url: http://andersk.mit.edu/gitweb/sql-web.git/commitdiff_plain/e346f2b32932ef80fbb98b20d786ee52091f8728 bug: dropping database outside the interface stops interface for all users checkQuotas on login was checking everyone's quotas git-svn-id: svn://presbrey.mit.edu/sql/mitsql@81 a142d4bd-2cfb-0310-9673-cb33a7e74f58 --- diff --git a/global.act.php b/global.act.php index 1a9b64d..1a6a98d 100644 --- a/global.act.php +++ b/global.act.php @@ -48,7 +48,9 @@ if (isOnline()) { } if (isPost() || isset($i_refresh)) { - checkQuotas($UserId); + if (!empty($UserId)) { + checkQuotas($UserId); + } isset($i_refresh) && redirect('main'); } diff --git a/lib/dbaccess.lib.php b/lib/dbaccess.lib.php index a3211a1..696cdfe 100644 --- a/lib/dbaccess.lib.php +++ b/lib/dbaccess.lib.php @@ -32,8 +32,11 @@ function DBSet($sql) { DBInsert($sql); } function DBShow($sql) { return DBSlave($sql); } function calcDBSize($tdb) { + $sql_result = "SHOW DATABASES LIKE '".mysql_escape_string($tdb)."'"; + $result = DBShow($sql_result); + if (!mysql_num_rows($result)) return null; + $sql_result = "SHOW TABLE STATUS FROM `" .mysql_escape_string($tdb)."`"; -// $result = @mysql_db_query($tdb,$sql_result); $result = DBShow($sql_result); if($result) { diff --git a/lib/joe.lib.php b/lib/joe.lib.php index 5ea684a..0bf1fb0 100755 --- a/lib/joe.lib.php +++ b/lib/joe.lib.php @@ -68,6 +68,8 @@ function sessTime($query=null) { if (is_null($query)) { $timings[$key]['time'] = microtime(true)-$timings[$key]['time']; + if (mysql_error()) + $timings[$key]['error'] = mysql_error(); return true; } else { $timings[$key] = array(); diff --git a/lib/security.lib.php b/lib/security.lib.php index 86676fb..d345e61 100644 --- a/lib/security.lib.php +++ b/lib/security.lib.php @@ -3,8 +3,8 @@ require_once('mitsql.lib.php'); class Login { - var $id, $u, $p; - var $info; + private $id, $u, $p; + private $info; function Login($u, $p=null) { if (empty($u)) return; $this->u = $u; @@ -82,9 +82,9 @@ class Login { } class User { - var $userId; - var $info; - var $dblist; + private $userId; + private $info; + private $dblist; function User($userId) { $this->userId = $userId; $sql = sprintf("SELECT User.UserId, Username, Password, Name, Email, UL, bEnabled, nBytesSoft, nBytesHard, nBytes, nDatabases, nDatabasesHard, IF(nBytes>nBytesHard,1,0) AS bOverQuota @@ -222,7 +222,7 @@ function isLoggedIn($aLogin=null) { global $Login; $aLogin = $Login; } - return !empty($aLogin) && is_a($aLogin, 'Login') && $aLogin->canLogin(); + return !empty($aLogin) && ($aLogin instanceof Login) && $aLogin->canLogin(); } function isAdmin($aLogin=null) { @@ -230,7 +230,7 @@ function isAdmin($aLogin=null) { global $Login; $aLogin = $Login; } - return !empty($aLogin) && is_a($aLogin, 'Login') && $aLogin->getUL()>=100; + return !empty($aLogin) && ($aLogin instanceof Login) && $aLogin->getUL()>=100; } function isImpersonating() { diff --git a/main.php b/main.php index 8a6ac81..8fa2c3d 100644 --- a/main.php +++ b/main.php @@ -18,6 +18,8 @@ if (isPost()) { $err1[] = 'You are over your quota. You may not add more databases.'; } elseif (count($User->getDBList())>MAXDBS) { $err1[] = 'You have too many databases. You may not add more databases.'; + } elseif (empty($i_newdb)) { + $err1[] = 'Your database name may not be empty.'; } elseif (!$User->addDB($dbname)) { if (mysql_error()) { $err1[] = mysql_error();