diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-04-06 14:14:16 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-04-06 14:14:16 +0000 |
commit | 8213f5b2627a6b63db9f84b572918bd7e3254dff (patch) | |
tree | bdaa19d917ce2d0db1ba54ef884e22a69130846a /includes/common.inc | |
parent | 048664f2786fce9bd049f39eea39a2a7fe2868f0 (diff) | |
download | brdo-8213f5b2627a6b63db9f84b572918bd7e3254dff.tar.gz brdo-8213f5b2627a6b63db9f84b572918bd7e3254dff.tar.bz2 |
A lot of small changes (search-n-replace) make a big commit:
- fixed update bug in book.module
- provide a log message when both adding and updating book pages
- all configurable variables are now accessed through "variable_get()":
- rewrote watchdog and submission throttle and removed watchdog.inc
- improved robustness of sections.inc
- imporved story.module
- updated ./database/database.sql
Diffstat (limited to 'includes/common.inc')
-rw-r--r-- | includes/common.inc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/includes/common.inc b/includes/common.inc index 3dece2c39..81127c22c 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -9,12 +9,30 @@ function conf_init() { return $file; } +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() ."')"); +} + +function throttle($type, $rate) { + if (!(user_access($user, "watchdog") || user_access($user, "comment") || user_access($user, "node"))) { + 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"); + exit(); + } + else { + watchdog($type, "throttle control"); + } + } +} + $conf = conf_init(); include_once "includes/$conf.conf"; include_once "includes/database.inc"; include_once "includes/variable.inc"; -include_once "includes/watchdog.inc"; include_once "includes/function.inc"; include_once "includes/comment.inc"; include_once "includes/module.inc"; |