Commit 048664f2 authored by Dries's avatar Dries

- a bunch of various updates
parent 7fac91c2
* 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
......
......@@ -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:
......
......@@ -13,6 +13,7 @@ function 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 @@ function conf_init() {
user_init();
$locale = locale_init();
$conf = variable_init();
$theme = theme_init();
?>
\ No newline at end of file
......@@ -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
?>
......@@ -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;
}
?>
......@@ -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]'");
......
<?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"));
......
......@@ -17,6 +17,18 @@ function Book($nid, $userid, $title, $body, $parent, $weight, $timestamp) {
}
}
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));
......
......@@ -17,6 +17,18 @@ function Book($nid, $userid, $title, $body, $parent, $weight, $timestamp) {
}
}
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));
......
<?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");
}
......
......@@ -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) {
......
......@@ -19,6 +19,18 @@ function Story($userid, $title, $abstract, $body, $section, $timestamp) { $th
}
}
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"):
......
......@@ -19,6 +19,18 @@ function Story($userid, $title, $abstract, $body, $section, $timestamp) { $th
}
}
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"):
......
......@@ -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();
}
}
......
......@@ -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();
}
}
......
# 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 (
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment