make Quota configurable, add Soft-/Hard-Quota [Min|Max]

pull/5/head
ChrisWi 6 years ago
parent c249a5cf49
commit f27e734fc0

@ -23,6 +23,7 @@
# Contributor(s):
# Daniel Triendl <daniel@pew.cc>
# balu
# Christian Wittmer <chris@computersalat.de>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@ -156,6 +157,15 @@ function write_config_file($dbt, $dbh, $dbn, $dbu, $dbp, $fsRoot) {
$cfg_content .= " define(\"BCRYPT\", true);\n";
$cfg_content .= " define(\"BCRYPT_ROUNDS\", 12);\n";
$cfg_content .= "\n";
$cfg_content .= " // you can enable logging to syslog for MINQUOTA_ERROR_OVER_QUOTA\n";
$cfg_content .= " // if (quota_used > MINQUOTA && quota_used < MAXQUOTA)\n";
$cfg_content .= " define(\"MINQUOTA_LOG_ERROR_OVER_QUOTA_ENABLE\", false);\n";
$cfg_content .= "\n";
$cfg_content .= " // set MinQuota and MaxQuota\n";
$cfg_content .= " define(\"MINQUOTA\", 30000);\n";
$cfg_content .= " define(\"MAXQUOTA\", 35000);\n";
$cfg_content .= "\n?>\n";
// now write everything

@ -21,6 +21,7 @@
# Contributor(s):
# Daniel Triendl <daniel@pew.cc>
# Mark Straver <moonchild@palemoon.org>
# Christian Wittmer <chris@computersalat.de>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@ -257,20 +258,29 @@
function check_quota(&$db)
{
// Checks the quota and if over limit, returns "over quota" to the user.
$auth_user = array_key_exists('PHP_AUTH_USER', $_SERVER) ? $_SERVER['PHP_AUTH_USER'] : null;
try {
// Checks the quota and if over limit, returns "over quota" to the user.
$auth_user = array_key_exists('PHP_AUTH_USER', $_SERVER) ? $_SERVER['PHP_AUTH_USER'] : null;
try {
$quota_used = $db->get_storage_total();
// log_quota("Debug quota: ".$auth_user." @ ".$quota_used." KB.");
} catch (Exception $e) {
log_error($e->getMessage(), $e->getCode());
}
if ($quota_used > 35000) {
log_quota("[!!] Over quota: ".$auth_user." @ ".$quota_used." KB.");
// HTTP 400 with body error code 14 means over quota.
report_problem(WEAVE_ERROR_OVER_QUOTA, 400);
}
if ((defined("MINQUOTA") && MINQUOTA) && (defined("MAXQUOTA") && MAXQUOTA)) {
if ($quota_used > MINQUOTA && $quota_used < MAXQUOTA) {
report_problem(WEAVE_ERROR_OVER_QUOTA, 400);
log_quota("[!!] Over quota [MINQUOTA:MAXQUOTA]: ".$auth_user." @ ".$quota_used." KB.");
if (defined(MINQUOTA_LOG_ERROR_OVER_QUOTA_ENABLE) && MINQUOTA_LOG_ERROR_OVER_QUOTA_ENABLE) {
log_error(" MinQUOTA exceeding: ".$quota_used." KB.");
}
}
if ($quota_used > MAXQUOTA) {
log_quota("[!!] Over quota: ".$auth_user." @ ".$quota_used." KB.");
// HTTP 400 with body error code 14 means over quota.
report_problem(WEAVE_ERROR_OVER_QUOTA, 400);
}
}
}
function check_timestamp($collection, &$db)

Loading…
Cancel
Save