diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-06-13 21:37:19 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-06-13 21:37:19 +0000 |
commit | db92d73b6eb8ed3b0d40a9deaf50c3ad680dd872 (patch) | |
tree | a5fdab2dcfb9927b178291d0cacebe1b8ab704be /includes/common.inc | |
parent | 7d631fb606b816c8bfefb448a5708e44e8c0e932 (diff) | |
download | brdo-db92d73b6eb8ed3b0d40a9deaf50c3ad680dd872.tar.gz brdo-db92d73b6eb8ed3b0d40a9deaf50c3ad680dd872.tar.bz2 |
- Improved watchdog and submission throttle: removed redundant code,
streamlined the existing code, added new watchdog type called "httpd"
for Apache errors. The latter should make it easier to add watchdog
filters later on.
- Clarified some watchdog messages.
Diffstat (limited to 'includes/common.inc')
-rw-r--r-- | includes/common.inc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/includes/common.inc b/includes/common.inc index 1702ccb32..54e19bd6c 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -19,21 +19,19 @@ function error_handler($errno, $message, $filename, $line, $variables) { } function watchdog($type, $message) { - global $user, $watchdog, $PHP_SELF; - $link = ($mod) ? $mod : substr(strrchr($PHP_SELF, "/"), 1, strrchr($PHP_SELF, "/") - 4); - db_query("INSERT INTO watchdog (user, type, link, message, location, hostname, timestamp) VALUES ('$user->id', '". check_input($type) ."', '". check_input($link) ."', '". check_input($message) ."', '". check_input(getenv("REQUEST_URI")) ."', '". check_input(getenv("REMOTE_ADDR")) ."', '". time() ."')"); + global $user; + db_query("INSERT INTO watchdog (user, type, message, location, hostname, timestamp) VALUES ('$user->id', '". check_input($type) ."', '". check_input($message) ."', '". check_input(getenv("REQUEST_URI")) ."', '". check_input(getenv("REMOTE_ADDR")) ."', '". time() ."')"); } function throttle($type, $rate) { global $user; - if (!(user_access($user, "watchdog") || user_access($user, "comment") || user_access($user, "node"))) { + if (!user_access($user)) { if ($throttle = db_fetch_object(db_query("SELECT * FROM watchdog WHERE type = '$type' AND hostname = '". getenv("REMOTE_ADDR") ."' AND ". time() ." - timestamp < $rate"))) { watchdog("warning", "throttle: '". getenv("REMOTE_ADDR") ."' exceeded submission rate - $throttle->type"); - header("Location: error.php?op=throttle"); - die("submission rate exceeded"); + die(message_throttle()); } else { - watchdog($type, "throttle control"); + watchdog($type, "throttle"); } } } @@ -48,10 +46,14 @@ function path_img() { return "./images/"; } -function notice_account() { +function message_account() { return t("This page requires a valid user account. Please <A HREF=\"account.php\">create a user account</A> and <A HREF=\"account.php\">login</A> prior to accessing it."); } +function message_throttle() { + return t("You exceeded the submission rate exceeded. Please wait a few minutes and try again."); +} + function check_form($text) { return htmlspecialchars(stripslashes($text)); } |