Commit 5512af5b authored by Marius Burkard's avatar Marius Burkard

- lock write access (except delete/drop/truncate) for databases exceeding quota (Fixes #3764)

parent 6f138add
......@@ -220,3 +220,5 @@ ALTER TABLE `client_template` ADD COLUMN `limit_directive_snippets` ENUM( 'n', '
ALTER TABLE `sys_user`
ADD COLUMN `lost_password_hash` VARCHAR(50) NOT NULL DEFAULT '',
ADD COLUMN `lost_password_reqtime` DATETIME NULL default NULL;
ALTER TABLE `web_database` ADD COLUMN `quota_exceeded` enum('n','y') NOT NULL DEFAULT 'n' AFTER `database_quota`;
......@@ -1856,6 +1856,7 @@ CREATE TABLE `web_database` (
`database_name` varchar(64) DEFAULT NULL,
`database_name_prefix` varchar(50) NOT NULL default '',
`database_quota` int(11) unsigned DEFAULT NULL,
`quota_exceeded` enum('n','y') NOT NULL DEFAULT 'n',
`last_quota_notification` date NULL default NULL,
`database_user_id` int(11) unsigned DEFAULT NULL,
`database_ro_user_id` int(11) unsigned DEFAULT NULL,
......
......@@ -262,7 +262,6 @@ class page_action extends tform_actions {
}
unset($tmp);
}
}
} else {
// check if client of database parent domain is client of db user!
......
......@@ -78,16 +78,29 @@ class cronjob_monitor_database_size extends cronjob {
$state = 'ok';
/** Fetch the data of all databases into an array */
$databases = $app->db->queryAllRecords("SELECT database_name, sys_groupid FROM web_database WHERE server_id = ? GROUP BY sys_groupid, database_name ASC", $server_id);
$databases = $app->db->queryAllRecords("SELECT database_id, database_name, sys_groupid, database_quota, quota_exceeded FROM web_database WHERE server_id = ? GROUP BY sys_groupid, database_name ASC", $server_id);
if(is_array($databases) && !empty($databases)) {
$data = array();
for ($i = 0; $i < sizeof($databases); $i++) {
$data[$i]['database_name']= $databases[$i]['database_name'];
$data[$i]['size'] = $app->db->getDatabaseSize($databases[$i]['database_name']);
$data[$i]['sys_groupid'] = $databases[$i]['sys_groupid'];
$rec = $databases[$i];
$data[$i]['database_name']= $rec['database_name'];
$data[$i]['size'] = $app->db->getDatabaseSize($rec['database_name']);
$data[$i]['sys_groupid'] = $rec['sys_groupid'];
$quota = $rec['database_quota'] * 1024 * 1024;
if (!is_numeric($quota)) continue;
if($quota < 0 || $quota > $data[$i]['size']) {
if($rec['quota_exceeded'] == 'y') {
$app->dbmaster->datalogUpdate('web_database', array('quota_exceeded' => 'n'), 'database_id', $rec['database_id']);
}
} elseif($rec['quota_exceeded'] == 'n') {
$app->dbmaster->datalogUpdate('web_database', array('quota_exceeded' => 'y'), 'database_id', $rec['database_id']);
}
}
$res = array();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment