From 048664f2786fce9bd049f39eea39a2a7fe2868f0 Mon Sep 17 00:00:00 2001
From: Dries Buytaert
Date: Thu, 5 Apr 2001 20:33:36 +0000
Subject: [PATCH] - a bunch of various updates
---
INSTALL | 2 +-
includes/comment.inc | 6 +++---
includes/common.inc | 2 ++
includes/hostname.conf | 22 ----------------------
includes/node.inc | 12 ------------
includes/user.inc | 2 +-
includes/watchdog.inc | 4 ++--
modules/book.module | 14 +++++++++++++-
modules/book/book.module | 14 +++++++++++++-
modules/moderation.module | 19 +++++++++++++------
modules/rating.module | 13 ++-----------
modules/story.module | 14 +++++++++++++-
modules/story/story.module | 14 +++++++++++++-
modules/watchdog.module | 25 ++++++++++++++++++++++---
modules/watchdog/watchdog.module | 25 ++++++++++++++++++++++---
updates/2.00-to-x.xx.sql | 8 ++++++++
16 files changed, 128 insertions(+), 68 deletions(-)
diff --git a/INSTALL b/INSTALL
index 3be4e3b954c6..b7768915982b 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
-* http://drop.org/module.php?mod=documentation
+* http://drop.org/node.php?title=drupal+handbook
- online installation guidelines
* http://drop.org/module.php?mod=drupal
diff --git a/includes/comment.inc b/includes/comment.inc
index b15cee23b5cb..4e1a74f2c7a5 100644
--- a/includes/comment.inc
+++ b/includes/comment.inc
@@ -281,9 +281,9 @@ function comment_render($lid, $cid) {
// Pre-process variables:
$lid = empty($lid) ? 0 : $lid;
$cid = empty($cid) ? 0 : $cid;
- $mode = ($user->id) ? $user->mode : 4;
- $order = ($user->id) ? $user->sort : 1;
- $threshold = ($user->id) ? $user->threshold : 3;
+ $mode = ($user->id) ? $user->mode : variable_get("default_comment_mode", 4);
+ $order = ($user->id) ? $user->sort : variable_get("default_comment_order", 1);
+ $threshold = ($user->id) ? $user->threshold : variable_get("default_comment_threshold", 3);
if ($user->id) {
// Comment control:
diff --git a/includes/common.inc b/includes/common.inc
index 2d24df5a5ecd..3dece2c393b4 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -13,6 +13,7 @@ $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";
@@ -25,6 +26,7 @@ include_once "includes/node.inc";
user_init();
$locale = locale_init();
+$conf = variable_init();
$theme = theme_init();
?>
\ No newline at end of file
diff --git a/includes/hostname.conf b/includes/hostname.conf
index 7decbdb7d477..871110493651 100644
--- a/includes/hostname.conf
+++ b/includes/hostname.conf
@@ -56,26 +56,4 @@ $themes = array("UnConeD" => array(
#$language = array(); // = language support disabled
$languages = array("en" => "English");
-#
-# Submission moderation votes:
-# The keys of this associative array are displayed in each submission's selection box whereas the corresponding values represent the mathematical calculation to be performed to update a comment's value.
-# Warning: changing $moderation_votes will affect the integrity of all pending stories in the open submission queue. Do not change this setting unless there are no pending stories in the submission queue or unless you know what you are doing.
-$moderation_votes = array("neutral (+0)" => "+ 0",
- "post it (+1)" => "+ 1",
- "dump it (-1)" => "- 1");
-
-#
-# Submission rate:
-# Defines the submission rate for the different types of content submission. It is supposed to stop malicious attempts to screw with the database and to stop denial of service attacks.
-# Example: '"comment" => 60' means that there is only one new comment allowed from the same IP-address every 60 seconds.
-#
-$submission_rate = array("comment" => "60", // 60 seconds = 1 minute
- "node" => "300"); // 300 seconds = 5 minutes
-
-#
-# Submission size:
-# The maximum length (i.e. the maximum number of characters) a story, a diary entry, or a comment is allowed to be.
-#
-$submission_size = 12000; // 12.000 characters is appr. 300 lines
-
?>
diff --git a/includes/node.inc b/includes/node.inc
index d894c6749470..462fc7a47239 100644
--- a/includes/node.inc
+++ b/includes/node.inc
@@ -161,16 +161,4 @@ function node_visible($node) {
return ($node->status == $status[posted]) || ($node->status == $status[queued] && $user->id) || user_access($user, "node");
}
-function node_post_threshold($node, $threshold = 5) {
- return 3;
-}
-
-function node_dump_threshold($node, $threshold = - 3) {
- return -2;
-}
-
-function node_timout_threshold($node, $threshold = 10) {
- return 9;
-}
-
?>
diff --git a/includes/user.inc b/includes/user.inc
index 5c97cb02d4dd..18f48ce5210f 100644
--- a/includes/user.inc
+++ b/includes/user.inc
@@ -103,7 +103,7 @@ function user_ban($mask, $type) {
function user_gravity($id) {
global $status;
- $period = 5184000; // maximum 60 days
+ $period = 5184000; // maximum 60 days
$number = 30; // maximum 30 comments
$r1 = db_query("SELECT COUNT(nid) AS number FROM node WHERE author = '$id' AND (". time() ." - timestamp < $period) AND status = '$status[posted]'");
diff --git a/includes/watchdog.inc b/includes/watchdog.inc
index 2d221c842e7b..9b28f39047ec 100644
--- a/includes/watchdog.inc
+++ b/includes/watchdog.inc
@@ -1,7 +1,7 @@
array("0", $submission_rate["comment"]),
- "node" => array("1", $submission_rate["node"]),
+$watchdog = array("comment" => array("0", variable_get("max_comment_rate", 60)),
+ "node" => array("1", variable_get("max_node_rate", 900)),
"message" => array("3", "0"),
"warning" => array("4", "0"),
"error" => array("5", "0"));
diff --git a/modules/book.module b/modules/book.module
index 62662ee8f07a..4a8603ad824c 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -17,6 +17,18 @@ class Book {
}
}
+function book_post_threshold($node, $default) {
+ return $default;
+}
+
+function book_dump_threshold($node, $default) {
+ return $default;
+}
+
+function book_timout_threshold($node, $default) {
+ return $default;
+}
+
function book_location($node, $nodes = array()) {
$parent = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.nid = '$node->parent'"));
if ($parent->title) {
@@ -216,7 +228,7 @@ function book_update($id) {
return t("You can only update accepted pages: pages that are still queued or already expired can not be updated.");
}
else if (db_result(db_query("SELECT COUNT(nid) FROM node WHERE pid = '$node->nid' AND status = '$status[queued]'"))) {
- return t("There is already an update for this node queued: we can only process one update at the time.");
+ return t("There is already an update for this node in the queue: we can only process one update at once.");
}
else {
return book_form(array(nid => -1, pid => $id, title => $node->title, body => $node->body, parent => $node->parent));
diff --git a/modules/book/book.module b/modules/book/book.module
index 62662ee8f07a..4a8603ad824c 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -17,6 +17,18 @@ class Book {
}
}
+function book_post_threshold($node, $default) {
+ return $default;
+}
+
+function book_dump_threshold($node, $default) {
+ return $default;
+}
+
+function book_timout_threshold($node, $default) {
+ return $default;
+}
+
function book_location($node, $nodes = array()) {
$parent = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.nid = '$node->parent'"));
if ($parent->title) {
@@ -216,7 +228,7 @@ function book_update($id) {
return t("You can only update accepted pages: pages that are still queued or already expired can not be updated.");
}
else if (db_result(db_query("SELECT COUNT(nid) FROM node WHERE pid = '$node->nid' AND status = '$status[queued]'"))) {
- return t("There is already an update for this node queued: we can only process one update at the time.");
+ return t("There is already an update for this node in the queue: we can only process one update at once.");
}
else {
return book_form(array(nid => -1, pid => $id, title => $node->title, body => $node->body, parent => $node->parent));
diff --git a/modules/moderation.module b/modules/moderation.module
index b322f2ed48db..9f7a7049fbfb 100644
--- a/modules/moderation.module
+++ b/modules/moderation.module
@@ -1,11 +1,18 @@
"+ 0",
+ "post it (+1)" => "+ 1",
+ "dump it (-1)" => "- 1");
+
$module = array("menu" => "moderation_menu",
"page" => "moderation_page");
-include_once "includes/common.inc";
-include_once "includes/node.inc";
-
function moderation_menu() {
return array("". t("moderation queue") ." (". moderation_count() .")");
}
@@ -32,15 +39,15 @@ function moderation_vote($id, $vote) {
$user = user_set($user, "history", "n$id", $vote);
if ($node = node_get_object(nid, $id)) {
- if (node_post_threshold($node) <= $node->score) {
+ if (variable_get("post_threshold", 4, $node) <= $node->score) {
node_save(array(nid => $id, status => $status[posted]));
watchdog("message", "node: posted '$node->title' - moderation");
}
- else if (node_dump_threshold($node) >= $node->score) {
+ else if (variable_get("dump_threshold", -2, $node) >= $node->score) {
node_save(array(nid => $id, status => $status[dumped]));
watchdog("message", "node: dumped '$node->title' - moderation");
}
- else if (node_timout_threshold($node) <= $node->votes) {
+ else if (variable_get("timout_threshold", 8, $node) <= $node->votes) {
node_save(array(nid => $id, status => $status[expired]));
watchdog("message", "node: expired '$node->title' - moderation");
}
diff --git a/modules/rating.module b/modules/rating.module
index a78df4ce35dd..0330422f4ee7 100644
--- a/modules/rating.module
+++ b/modules/rating.module
@@ -15,17 +15,8 @@ function rating_cron() {
function rating_help() {
?>
-
User rating
-
The rating cron will periodically calculate an overall rating of each user's contributed value that is a time-weighted average of his or her comments ratings with an additional bonus for the nodes he or she contributed. The system can be best compared with SlashCode's karma and is - in fact - even more similar to Scoop's mojo implementation.
-
I won't elaborate on all the funny math involved and it suffices to say that the actual weighting is done in such a way:
-
-
that comments with a lot of votes count more then comments with only one or two votes.
-
that newer comments count for more then older comments.
-
-
The idea of (1) is that it favors comments that more people voted on, and thus whose rating is more likely to be accurate or justified.
-
The latter (2) makes the user rating that comes out of the calulations temporary, based on users' most recent activity and responsive to their current state. This is accomplished by taking each user's last 30 comments, or however many he or she posted in the last 60 days - whatever comes first.
-
Additionally, users that posted one or more succesful nodes in the last 60 days gain extra bonus points which will boost up their overall rating.
- The rating cron will periodically calculate each user's gravity, the overall time-weighted rating of each user's contributions.
+
}
function rating_list($limit) {
diff --git a/modules/story.module b/modules/story.module
index fbe8a12f408f..d83557456bce 100644
--- a/modules/story.module
+++ b/modules/story.module
@@ -19,6 +19,18 @@ class Story {
}
}
+function story_post_threshold($node, $default) {
+ return $default;
+}
+
+function story_dump_threshold($node, $default) {
+ return $default;
+}
+
+function story_timout_threshold($node, $default) {
+ return $default;
+}
+
function story_find($keys) {
global $status, $user;
$find = array();
@@ -44,7 +56,7 @@ function story_view($node, $page = 1) {
switch($op) {
case t("Preview comment"):
$theme->header();
- comment_preview(check_input($pid), check_input($id), ($subject ? check_output($subject) : ""), ($comment ? check_output($comment) : ""));
+ comment_preview(check_input($pid), check_input($id), $subject, $comment);
$theme->footer();
break;
case t("Post comment"):
diff --git a/modules/story/story.module b/modules/story/story.module
index fbe8a12f408f..d83557456bce 100644
--- a/modules/story/story.module
+++ b/modules/story/story.module
@@ -19,6 +19,18 @@ class Story {
}
}
+function story_post_threshold($node, $default) {
+ return $default;
+}
+
+function story_dump_threshold($node, $default) {
+ return $default;
+}
+
+function story_timout_threshold($node, $default) {
+ return $default;
+}
+
function story_find($keys) {
global $status, $user;
$find = array();
@@ -44,7 +56,7 @@ function story_view($node, $page = 1) {
switch($op) {
case t("Preview comment"):
$theme->header();
- comment_preview(check_input($pid), check_input($id), ($subject ? check_output($subject) : ""), ($comment ? check_output($comment) : ""));
+ comment_preview(check_input($pid), check_input($id), $subject, $comment);
$theme->footer();
break;
case t("Post comment"):
diff --git a/modules/watchdog.module b/modules/watchdog.module
index 0252d51054ff..c912ee85be7a 100644
--- a/modules/watchdog.module
+++ b/modules/watchdog.module
@@ -2,6 +2,7 @@
$module = array("help" => "watchdog_help",
"cron" => "watchdog_cron",
+ "conf" => "watchdog_conf",
"admin" => "watchdog_admin");
function watchdog_help() {
@@ -15,7 +16,7 @@ function watchdog_cron() {
watchdog_clean();
}
-function watchdog_display($order = "date") {
+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");
@@ -68,6 +69,24 @@ function watchdog_view($id) {
}
}
+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.