summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-04-05 20:33:36 +0000
committerDries Buytaert <dries@buytaert.net>2001-04-05 20:33:36 +0000
commit048664f2786fce9bd049f39eea39a2a7fe2868f0 (patch)
treebc017dc66a48bec52fea486a6b7ec52ad5ff8e1f
parent7fac91c2cc4ca3dedf4459f9cdf9955e33be0f42 (diff)
downloadbrdo-048664f2786fce9bd049f39eea39a2a7fe2868f0.tar.gz
brdo-048664f2786fce9bd049f39eea39a2a7fe2868f0.tar.bz2
- a bunch of various updates
-rw-r--r--INSTALL2
-rw-r--r--includes/comment.inc6
-rw-r--r--includes/common.inc2
-rw-r--r--includes/hostname.conf22
-rw-r--r--includes/node.inc12
-rw-r--r--includes/user.inc2
-rw-r--r--includes/watchdog.inc4
-rw-r--r--modules/book.module14
-rw-r--r--modules/book/book.module14
-rw-r--r--modules/moderation.module19
-rw-r--r--modules/rating.module13
-rw-r--r--modules/story.module14
-rw-r--r--modules/story/story.module14
-rw-r--r--modules/watchdog.module25
-rw-r--r--modules/watchdog/watchdog.module25
-rw-r--r--updates/2.00-to-x.xx.sql8
16 files changed, 128 insertions, 68 deletions
diff --git a/INSTALL b/INSTALL
index 3be4e3b95..b77689159 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 b15cee23b..4e1a74f2c 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 2d24df5a5..3dece2c39 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 7decbdb7d..871110493 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 d894c6749..462fc7a47 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 5c97cb02d..18f48ce52 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 2d221c842..9b28f3904 100644
--- a/includes/watchdog.inc
+++ b/includes/watchdog.inc
@@ -1,7 +1,7 @@
<?php
-$watchdog = array("comment" => 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 62662ee8f..4a8603ad8 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 62662ee8f..4a8603ad8 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 b322f2ed4..9f7a7049f 100644
--- a/modules/moderation.module
+++ b/modules/moderation.module
@@ -1,11 +1,18 @@
<?php
+#
+# 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.
+$moderation_votes = array("neutral (+0)" => "+ 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("<A HREF=\"module.php?mod=moderation\">". t("moderation queue") ."</A> (<FONT COLOR=\"red\">". moderation_count() ."</FONT>)");
}
@@ -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 a78df4ce3..0330422f4 100644
--- a/modules/rating.module
+++ b/modules/rating.module
@@ -15,17 +15,8 @@ function rating_cron() {
function rating_help() {
?>
- <H3>User rating</H3>
- <P>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 <A HREF="http://slashcode.com/">SlashCode</A>'s karma and is - in fact - even more similar to <A HREF="http://scoop.kuro5hin.org/">Scoop</A>'s mojo implementation.</P>
- <P>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:</P>
- <OL>
- <LI>that comments with a lot of votes count more then comments with only one or two votes.</LI>
- <LI>that newer comments count for more then older comments.</LI>
- </OL>
- <P>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.</P>
- <P>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.</P>
- <P>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.</P>
- <?php
+ <P>The rating cron will periodically calculate each user's gravity, the overall time-weighted rating of each user's contributions.</P>
+ <?
}
function rating_list($limit) {
diff --git a/modules/story.module b/modules/story.module
index fbe8a12f4..d83557456 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 fbe8a12f4..d83557456 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 0252d5105..c912ee85b 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 .= "<B>Maximum node rate:</B><BR>\n";
+ foreach ($rate as $key=>$value) $options1 .= " <OPTION VALUE=\"$key\"". (($conf[max_node_rate] == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
+ $output .= "<SELECT NAME=\"edit[max_node_rate]\">$options1</SELECT><BR>\n";
+ $output .= "<I><SMALL>The maximum submission rate for nodes. Its purpose is to stop denial of service attacks.</SMALL></I><P>\n";
+
+ $output .= "<B>Maximum comment rate:</B><BR>\n";
+ foreach ($rate as $key=>$value) $options2 .= " <OPTION VALUE=\"$key\"". (($conf[max_comment_rate] == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
+ $output .= "<SELECT NAME=\"edit[max_comment_rate]\"$options2</SELECT><BR>\n";
+ $output .= "<I><SMALL>The maximum submission rate for comments. Its purpose is to stop denial of service attacks.</SMALL></I><P>\n";
+
+ return $output;
+}
+
function watchdog_admin() {
global $op, $id, $order;
@@ -81,10 +100,10 @@ function watchdog_admin() {
watchdog_view(check_input($id));
break;
case "Update":
- watchdog_display(check_input($order));
+ watchdog_overview(check_input($order));
break;
default:
- watchdog_display();
+ watchdog_overview();
}
}
diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module
index 0252d5105..c912ee85b 100644
--- a/modules/watchdog/watchdog.module
+++ b/modules/watchdog/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 .= "<B>Maximum node rate:</B><BR>\n";
+ foreach ($rate as $key=>$value) $options1 .= " <OPTION VALUE=\"$key\"". (($conf[max_node_rate] == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
+ $output .= "<SELECT NAME=\"edit[max_node_rate]\">$options1</SELECT><BR>\n";
+ $output .= "<I><SMALL>The maximum submission rate for nodes. Its purpose is to stop denial of service attacks.</SMALL></I><P>\n";
+
+ $output .= "<B>Maximum comment rate:</B><BR>\n";
+ foreach ($rate as $key=>$value) $options2 .= " <OPTION VALUE=\"$key\"". (($conf[max_comment_rate] == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
+ $output .= "<SELECT NAME=\"edit[max_comment_rate]\"$options2</SELECT><BR>\n";
+ $output .= "<I><SMALL>The maximum submission rate for comments. Its purpose is to stop denial of service attacks.</SMALL></I><P>\n";
+
+ return $output;
+}
+
function watchdog_admin() {
global $op, $id, $order;
@@ -81,10 +100,10 @@ function watchdog_admin() {
watchdog_view(check_input($id));
break;
case "Update":
- watchdog_display(check_input($order));
+ watchdog_overview(check_input($order));
break;
default:
- watchdog_display();
+ watchdog_overview();
}
}
diff --git a/updates/2.00-to-x.xx.sql b/updates/2.00-to-x.xx.sql
index 2e9309519..ae894d654 100644
--- a/updates/2.00-to-x.xx.sql
+++ b/updates/2.00-to-x.xx.sql
@@ -1,3 +1,11 @@
+# 05/04/2001:
+
+CREATE TABLE variable (
+ name varchar(32) DEFAULT '' NOT NULL,
+ value varchar(128) DEFAULT '' NOT NULL,
+ PRIMARY KEY (name)
+);
+
# 01/04/2001:
CREATE TABLE access (