From 8213f5b2627a6b63db9f84b572918bd7e3254dff Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 6 Apr 2001 14:14:16 +0000 Subject: 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 --- modules/watchdog.module | 67 ++++++++++--------------------------------------- 1 file changed, 13 insertions(+), 54 deletions(-) (limited to 'modules/watchdog.module') diff --git a/modules/watchdog.module b/modules/watchdog.module index c912ee85b..18279db1b 100644 --- a/modules/watchdog.module +++ b/modules/watchdog.module @@ -2,7 +2,6 @@ $module = array("help" => "watchdog_help", "cron" => "watchdog_cron", - "conf" => "watchdog_conf", "admin" => "watchdog_admin"); function watchdog_help() { @@ -13,44 +12,24 @@ function watchdog_help() { } function watchdog_cron() { - watchdog_clean(); + db_query("DELETE FROM watchdog WHERE ". time() ." - timestamp > ". variable_get(watchdog_clear, "302400")); } function watchdog_overview($order = "date") { - $colors = array("#D8BFD8", "#6495ED", "#6A5ADF", "#FFFFFF", "#FFA500", "#FF3C3C"); - $fields = array("date" => "id DESC", "username" => "user", "location" => "location", "message" => "message DESC", "level" => "level DESC"); + $colors = array(message => "#FFFFFF", special => "#836FFF", warning => "#FFAA22", error => "#EE2C2C"); - // Perform query: - $result = db_query("SELECT l.*, u.userid FROM watchdog l LEFT JOIN users u ON l.user = u.id ORDER BY l.$fields[$order]"); + $result = db_query("SELECT w.*, u.userid FROM watchdog w LEFT JOIN users u ON w.user = u.id"); - // Generate output: $output .= "\n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - + $output .= " \n"; while ($watchdog = db_fetch_object($result)) { - $output .= " level] ."\">\n"; + if ($color = $colors[$watchdog->type]) { + $output .= " \n"; + } } - $output .= "
\n"; - $output .= "
\n"; - $output .= " \n"; - $output .= " \n"; - $output .= "
\n"; - $output .= "
datemessageuseroperations
datetypemessageuseroperations
". format_date($watchdog->timestamp) ."". substr(check_output($watchdog->message), 0, 44) ."". format_username($watchdog->userid) ."id\">details
". format_date($watchdog->timestamp) ."$watchdog->link". substr(check_output($watchdog->message), 0, 50) ."". format_username($watchdog->userid) ."id\">details
\n"; - print $output; + return $output; } function watchdog_view($id) { @@ -58,33 +37,16 @@ function watchdog_view($id) { if ($watchdog = db_fetch_object($result)) { $output .= "\n"; - $output .= " \n"; + $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= "
Level:". check_output($watchdog->level) ."
Type:". check_output($watchdog->type) ."
Date:". format_date($watchdog->timestamp, "large") ."
User:". format_username($watchdog->userid) ."
Location:". check_output($watchdog->location). "
Message:". check_output($watchdog->message) ."
Hostname:". check_output($watchdog->hostname) ."
\n"; - print $output; - } -} - -function watchdog_conf() { - global $conf; - $rate = array(1 => "maximum 1 every second", 5 => "maximum 1 every 5 seconds", 15 => "maximum 1 every 15 seconds", 30 => "maximum 1 every 30 seconds", 60 => "maximum 1 every minute", 300 => "maximum 1 every 5 minutes", 900 => "maximum 1 every 15 minutes", 1800 => "maximum 1 every 30 minutes", 3600 => "maximum 1 every hour", 21600 => "maximum 1 every 6 hour", 43200 => "maximum 1 every 12 hour"); - - $output .= "Maximum node rate:
\n"; - foreach ($rate as $key=>$value) $options1 .= " \n"; - $output .= "
\n"; - $output .= "The maximum submission rate for nodes. Its purpose is to stop denial of service attacks.

\n"; - - $output .= "Maximum comment rate:
\n"; - foreach ($rate as $key=>$value) $options2 .= " \n"; - $output .= "