summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG3
-rw-r--r--account.php18
-rw-r--r--admin.php4
-rw-r--r--database/database.mysql140
-rw-r--r--error.php12
-rw-r--r--includes/comment.inc10
-rw-r--r--includes/common.inc20
-rw-r--r--includes/function.inc2
-rw-r--r--includes/hostname.conf12
-rw-r--r--includes/node.inc4
-rw-r--r--includes/search.inc2
-rw-r--r--includes/section.inc18
-rw-r--r--includes/theme.inc6
-rw-r--r--includes/variable.inc54
-rw-r--r--includes/watchdog.inc32
-rw-r--r--modules/backend.class4
-rw-r--r--modules/block.module13
-rw-r--r--modules/block/block.module13
-rw-r--r--modules/book.module8
-rw-r--r--modules/book/book.module8
-rw-r--r--modules/diary.module2
-rw-r--r--modules/headline.module10
-rw-r--r--modules/headlineRSS10.module17
-rw-r--r--modules/moderation.module9
-rw-r--r--modules/story.module6
-rw-r--r--modules/story/story.module6
-rw-r--r--modules/watchdog.module67
-rw-r--r--modules/watchdog/watchdog.module67
-rw-r--r--themes/example/example.theme4
-rw-r--r--themes/goofy/goofy.theme7
-rw-r--r--themes/jeroen/jeroen.theme6
-rw-r--r--themes/marvin/marvin.theme3
-rw-r--r--themes/unconed/unconed.theme9
-rw-r--r--updates/2.00-to-x.xx.sql14
34 files changed, 295 insertions, 315 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 2df4925d7..96229e6d1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,9 @@ drupal x.xx, xx/xx/xxxx
* allows collaborative book writing
- removed ban module and integrated it in account.module as "access control":
* access control is based on much more powerful regular expressions (regex) now rather than on MySQL pattern matching.
+- rewrote watchdog and submission throttle
+- added settings.module:
+ * moved most configuration options to the administration section
- various updates:
* added preview functionality when submitting new content (such as a story) from the administration pages.
* made the administration section only show those links a user has access to.
diff --git a/account.php b/account.php
index 0b066c0a0..a48ab8114 100644
--- a/account.php
+++ b/account.php
@@ -311,7 +311,7 @@ function account_validate($user) {
}
function account_email_submit($userid, $email) {
- global $theme, $site_name, $site_url;
+ global $theme;
$result = db_query("SELECT id FROM users WHERE userid = '$userid' AND real_email = '$email'");
@@ -322,9 +322,9 @@ function account_email_submit($userid, $email) {
db_query("UPDATE users SET passwd = PASSWORD('$passwd'), hash = '$hash', status = '$status' WHERE userid = '$userid'");
- $link = $site_url ."account.php?op=confirm&name=$userid&hash=$hash";
- $subject = strtr(t("Account details for %a"), array("%a" => $site_name));
- $message = strtr(t("%a,\n\n\nyou requested us to e-mail you a new password for your account at %b. You will need to re-confirm your account or you will not be able to login. To confirm your account updates visit the URL below:\n\n %c\n\nOnce confirmed you can login using the following username and password:\n\n username: %a\n password: %d\n\n\n-- %b team"), array("%a" => $userid, "%b" => $site_name, "%c" => $link, "%d" => $passwd));
+ $link = variable_get(site_url, "http://drupal/") ."account.php?op=confirm&name=$userid&hash=$hash";
+ $subject = strtr(t("Account details for %a"), array("%a" => variable_get(site_name, "drupal")));
+ $message = strtr(t("%a,\n\n\nyou requested us to e-mail you a new password for your account at %b. You will need to re-confirm your account or you will not be able to login. To confirm your account updates visit the URL below:\n\n %c\n\nOnce confirmed you can login using the following username and password:\n\n username: %a\n password: %d\n\n\n-- %b team"), array("%a" => $userid, "%b" => variable_get(site_name, "drupal"), "%c" => $link, "%d" => $passwd));
watchdog("message", "new password: `$userid' <$email>");
@@ -343,7 +343,7 @@ function account_email_submit($userid, $email) {
}
function account_create_submit($userid, $email) {
- global $theme, $site_name, $site_url;
+ global $theme;
$new[userid] = trim($userid);
$new[real_email] = trim($email);
@@ -359,9 +359,9 @@ function account_create_submit($userid, $email) {
$user = user_save("", array("userid" => $new[userid], "real_email" => $new[real_email], "passwd" => $new[passwd], "status" => 1, "hash" => $new[hash]));
- $link = $site_url ."account.php?op=confirm&name=$new[userid]&hash=$new[hash]";
- $subject = strtr(t("Account details for %a"), array("%a" => $site_name));
- $message = strtr(t("%a,\n\n\nsomeone signed up for a user account on %b and supplied this e-mail address as their contact. If it wasn't you, don't get your panties in a knot and simply ignore this mail. If this was you, you will have to confirm your account first or you will not be able to login. To confirm your account visit the URL below:\n\n %c\n\nOnce confirmed you can login using the following username and password:\n\n username: %a\n password: %d\n\n\n-- %b team\n"), array("%a" => $new[userid], "%b" => $site_name, "%c" => $link, "%d" => $new[passwd]));
+ $link = variable_get(site_url, "http://drupal/") ."account.php?op=confirm&name=$new[userid]&hash=$new[hash]";
+ $subject = strtr(t("Account details for %a"), array("%a" => variable_get(site_name, "drupal")));
+ $message = strtr(t("%a,\n\n\nsomeone signed up for a user account on %b and supplied this e-mail address as their contact. If it wasn't you, don't get your panties in a knot and simply ignore this mail. If this was you, you will have to confirm your account first or you will not be able to login. To confirm your account visit the URL below:\n\n %c\n\nOnce confirmed you can login using the following username and password:\n\n username: %a\n password: %d\n\n\n-- %b team\n"), array("%a" => $new[userid], "%b" => variable_get(site_name, "drupal"), "%c" => $link, "%d" => $new[passwd]));
watchdog("message", "new account: `$new[userid]' <$new[real_email]>");
@@ -453,7 +453,7 @@ function account_track_nodes() {
}
function account_track_site() {
- global $nstatus, $status, $theme, $user, $site_name;
+ global $nstatus, $status, $theme, $user;
$period = 259200; // 3 days
diff --git a/admin.php b/admin.php
index 9a4308063..c9085ea11 100644
--- a/admin.php
+++ b/admin.php
@@ -10,7 +10,7 @@ function status($message) {
}
function admin_page($mod) {
- global $repository, $site_name, $menu, $modules, $user;
+ global $repository, $menu, $modules, $user;
function module($name, $module) {
global $menu, $modules, $user;
@@ -21,7 +21,7 @@ function admin_page($mod) {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
- <HEAD><TITLE><?php echo $site_name; ?> administration</TITLE></HEAD>
+ <HEAD><TITLE><?php echo variable_get(site_name, "drupal"); ?> administration</TITLE></HEAD>
<STYLE>
body { font-family: helvetica, arial; }
h1 { font-size: 18pt; font-weight: bold; color: #990000; }
diff --git a/database/database.mysql b/database/database.mysql
index 7879bc379..3ad1199ac 100644
--- a/database/database.mysql
+++ b/database/database.mysql
@@ -1,4 +1,14 @@
+DROP TABLE IF EXISTS access;
+CREATE TABLE access (
+ id tinyint(10) DEFAULT '0' NOT NULL auto_increment,
+ mask varchar(255) DEFAULT '' NOT NULL,
+ type varchar(16) DEFAULT '' NOT NULL,
+ reason text NOT NULL,
+ UNIQUE mask (mask),
+ PRIMARY KEY (id)
+);
+DROP TABLE IF EXISTS affiliates;
CREATE TABLE affiliates (
id int(11) DEFAULT '0' NOT NULL auto_increment,
link varchar(255) DEFAULT '' NOT NULL,
@@ -8,6 +18,7 @@ CREATE TABLE affiliates (
PRIMARY KEY (id)
);
+DROP TABLE IF EXISTS blocks;
CREATE TABLE blocks (
name varchar(64) DEFAULT '' NOT NULL,
module varchar(64) DEFAULT '' NOT NULL,
@@ -19,6 +30,18 @@ CREATE TABLE blocks (
PRIMARY KEY (name)
);
+DROP TABLE IF EXISTS book;
+CREATE TABLE book (
+ lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
+ nid int(10) unsigned DEFAULT '0' NOT NULL,
+ body text NOT NULL,
+ section int(10) DEFAULT '0' NOT NULL,
+ parent int(10) DEFAULT '0' NOT NULL,
+ weight tinyint(3) DEFAULT '0' NOT NULL,
+ PRIMARY KEY (lid)
+);
+
+DROP TABLE IF EXISTS boxes;
CREATE TABLE boxes (
id tinyint(4) DEFAULT '0' NOT NULL auto_increment,
subject varchar(64) DEFAULT '' NOT NULL,
@@ -31,17 +54,7 @@ CREATE TABLE boxes (
PRIMARY KEY (id)
);
-CREATE TABLE bans (
- id tinyint(4) DEFAULT '0' NOT NULL auto_increment,
- mask varchar(255) DEFAULT '' NOT NULL,
- type tinyint(2) DEFAULT '0' NOT NULL,
- reason text NOT NULL,
- timestamp int(11),
- UNIQUE mask (mask),
- PRIMARY KEY (id)
-);
-
-
+DROP TABLE IF EXISTS channel;
CREATE TABLE channel (
id int(11) DEFAULT '0' NOT NULL auto_increment,
site varchar(255) DEFAULT '' NOT NULL,
@@ -55,11 +68,11 @@ CREATE TABLE channel (
PRIMARY KEY (id)
);
+DROP TABLE IF EXISTS comments;
CREATE TABLE comments (
cid int(6) DEFAULT '0' NOT NULL auto_increment,
pid int(6) DEFAULT '0' NOT NULL,
lid int(6) DEFAULT '0' NOT NULL,
- link varchar(16) DEFAULT '' NOT NULL,
author int(6) DEFAULT '0' NOT NULL,
subject varchar(64) DEFAULT '' NOT NULL,
comment text NOT NULL,
@@ -67,10 +80,11 @@ CREATE TABLE comments (
timestamp int(11) DEFAULT '0' NOT NULL,
score int(6) DEFAULT '0' NOT NULL,
votes int(6) DEFAULT '0' NOT NULL,
- INDEX lid_link (lid, link),
+ link varchar(16) DEFAULT '' NOT NULL,
PRIMARY KEY (cid)
);
+DROP TABLE IF EXISTS crons;
CREATE TABLE crons (
module varchar(64) DEFAULT '' NOT NULL,
scheduled int(11),
@@ -78,6 +92,7 @@ CREATE TABLE crons (
PRIMARY KEY (module)
);
+DROP TABLE IF EXISTS diaries;
CREATE TABLE diaries (
id int(5) DEFAULT '0' NOT NULL auto_increment,
author int(6) DEFAULT '0' NOT NULL,
@@ -86,6 +101,7 @@ CREATE TABLE diaries (
PRIMARY KEY (id)
);
+DROP TABLE IF EXISTS drupals;
CREATE TABLE drupals (
id int(11) DEFAULT '0' NOT NULL auto_increment,
link varchar(255) DEFAULT '' NOT NULL,
@@ -95,15 +111,7 @@ CREATE TABLE drupals (
PRIMARY KEY (id)
);
-CREATE TABLE faqs (
- id int(11) DEFAULT '0' NOT NULL auto_increment,
- question varchar(255) DEFAULT '' NOT NULL,
- answer text NOT NULL,
- weight tinyint(3) DEFAULT '0' NOT NULL,
- UNIQUE question (question),
- PRIMARY KEY (id)
-);
-
+DROP TABLE IF EXISTS headlines;
CREATE TABLE headlines (
id int(11) DEFAULT '0' NOT NULL,
title varchar(255) DEFAULT '' NOT NULL,
@@ -113,56 +121,74 @@ CREATE TABLE headlines (
UNIQUE link (link)
);
+DROP TABLE IF EXISTS layout;
CREATE TABLE layout (
user int(11) DEFAULT '0' NOT NULL,
block varchar(64) DEFAULT '' NOT NULL
);
+DROP TABLE IF EXISTS locales;
CREATE TABLE locales (
id int(11) DEFAULT '0' NOT NULL auto_increment,
location varchar(128) DEFAULT '' NOT NULL,
- string TEXT DEFAULT '' NOT NULL,
- da TEXT DEFAULT '' NOT NULL,
- fi TEXT DEFAULT '' NOT NULL,
- fr TEXT DEFAULT '' NOT NULL,
- en TEXT DEFAULT '' NOT NULL,
- es TEXT DEFAULT '' NOT NULL,
- nl TEXT DEFAULT '' NOT NULL,
- no TEXT DEFAULT '' NOT NULL,
- sw TEXT DEFAULT '' NOT NULL,
+ string text NOT NULL,
+ da text NOT NULL,
+ fi text NOT NULL,
+ fr text NOT NULL,
+ en text NOT NULL,
+ es text NOT NULL,
+ nl text NOT NULL,
+ no text NOT NULL,
+ sw text NOT NULL,
PRIMARY KEY (id)
);
+DROP TABLE IF EXISTS modules;
CREATE TABLE modules (
name varchar(64) DEFAULT '' NOT NULL,
PRIMARY KEY (name)
);
+DROP TABLE IF EXISTS node;
+CREATE TABLE node (
+ nid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
+ lid int(10) DEFAULT '0' NOT NULL,
+ pid int(10) DEFAULT '0' NOT NULL,
+ log text NOT NULL,
+ type varchar(16) DEFAULT '' NOT NULL,
+ title varchar(128) DEFAULT '' NOT NULL,
+ score int(11) DEFAULT '0' NOT NULL,
+ votes int(11) DEFAULT '0' NOT NULL,
+ author int(6) DEFAULT '0' NOT NULL,
+ status int(4) DEFAULT '1' NOT NULL,
+ timestamp int(11) DEFAULT '0' NOT NULL,
+ KEY type (lid,type),
+ KEY author (author),
+ KEY title (title,type),
+ PRIMARY KEY (nid)
+);
+
+DROP TABLE IF EXISTS sections;
CREATE TABLE sections (
name varchar(64) DEFAULT '' NOT NULL,
post tinyint(3) DEFAULT '0' NOT NULL,
dump tinyint(3) DEFAULT '0' NOT NULL,
- timout tinyint(3) DEFAULT '0' NOT NULL,
status tinyint(2) DEFAULT '0' NOT NULL,
+ timout tinyint(3) DEFAULT '0' NOT NULL,
PRIMARY KEY (name)
);
-CREATE TABLE stories (
- id int(11) DEFAULT '0' NOT NULL auto_increment,
- author int(6) DEFAULT '0' NOT NULL,
- subject varchar(255) DEFAULT '' NOT NULL,
+DROP TABLE IF EXISTS story;
+CREATE TABLE story (
+ lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
+ nid int(10) unsigned DEFAULT '0' NOT NULL,
abstract text NOT NULL,
- updates text NOT NULL,
- article text NOT NULL,
+ body text NOT NULL,
section varchar(64) DEFAULT '' NOT NULL,
- timestamp int(11) DEFAULT '0' NOT NULL,
- score int(11) DEFAULT '0' NOT NULL,
- votes int(11) DEFAULT '0' NOT NULL,
- status int(4) DEFAULT '1',
- UNIQUE subject (subject),
- PRIMARY KEY (id)
+ PRIMARY KEY (lid)
);
+DROP TABLE IF EXISTS users;
CREATE TABLE users (
id int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
name varchar(60) DEFAULT '' NOT NULL,
@@ -171,8 +197,8 @@ CREATE TABLE users (
real_email varchar(60) DEFAULT '' NOT NULL,
fake_email varchar(60) DEFAULT '' NOT NULL,
url varchar(100) DEFAULT '' NOT NULL,
- stories tinyint(2) DEFAULT '10',
- mode tinyint(1) DEFAULT '0',
+ nodes tinyint(2) DEFAULT '10',
+ mode tinyint(1) DEFAULT '0' NOT NULL,
sort tinyint(1) DEFAULT '0',
threshold tinyint(1) DEFAULT '0',
bio tinytext NOT NULL,
@@ -180,24 +206,32 @@ CREATE TABLE users (
signature varchar(255) DEFAULT '' NOT NULL,
last_access int(10) unsigned,
last_host varchar(255),
- access varchar(255) DEFAULT '' NOT NULL,
status tinyint(4) DEFAULT '0' NOT NULL,
history text NOT NULL,
hash varchar(12) DEFAULT '' NOT NULL,
- rating decimal(8,4) DEFAULT '0' NOT NULL,
- timezone varchar(8) DEFAULT '0' NOT NULL,
- language varchar(2) DEFAULT '0' NOT NULL,
+ timezone varchar(8),
+ rating decimal(8,4),
+ language char(2) DEFAULT '' NOT NULL,
+ access varchar(255) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
);
+DROP TABLE IF EXISTS variable;
+CREATE TABLE variable (
+ name varchar(32) DEFAULT '' NOT NULL,
+ value varchar(128) DEFAULT '' NOT NULL,
+ PRIMARY KEY (name)
+);
+
+DROP TABLE IF EXISTS watchdog;
CREATE TABLE watchdog (
id int(5) DEFAULT '0' NOT NULL auto_increment,
- level int(2) DEFAULT '0' NOT NULL,
- timestamp int(11) DEFAULT '0' NOT NULL,
user int(6) DEFAULT '0' NOT NULL,
+ type varchar(16) DEFAULT '' NOT NULL,
+ link varchar(16) DEFAULT '' NOT NULL,
message varchar(255) DEFAULT '' NOT NULL,
location varchar(128) DEFAULT '' NOT NULL,
hostname varchar(128) DEFAULT '' NOT NULL,
+ timestamp int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (id)
);
-
diff --git a/error.php b/error.php
index f4ffc1f52..6f2f1cfd2 100644
--- a/error.php
+++ b/error.php
@@ -1,9 +1,7 @@
<?php
-function error_flood() {
- global $site_email;
-
- print "WARNING: submission rate exceeded. We detected too much data or events from your IP. Please wait a few minutes and try again. If you think this is not justified, please contact us at <A HREF=\"mailto:$site_email\">$site_email</A>.";
+function error_throttle() {
+ print "WARNING: submission rate exceeded. We detected too much data or events from your IP. Please wait a few minutes and try again. If you believe this is not justified, please contact us at <A HREF=\"mailto:". variable_get(site_mail, "root@localhost") ."\">". variable_get(site_mail, "root@localhost") ."</A>.";
}
function error_httpd() {
@@ -42,11 +40,11 @@ function error_httpd() {
include_once "includes/common.inc";
switch ($op) {
- case "flood":
- error_flood();
+ case "throttle":
+ error_throttle();
break;
default:
error_httpd();
}
-?>
+?> \ No newline at end of file
diff --git a/includes/comment.inc b/includes/comment.inc
index 4e1a74f2c..23c79717a 100644
--- a/includes/comment.inc
+++ b/includes/comment.inc
@@ -124,6 +124,8 @@ function comment_preview($pid, $id, $subject, $comment) {
function comment_post($pid, $id, $subject, $comment) {
global $theme, $user;
+ throttle("post comment", variable_get(max_comment_rate, 60));
+
// Check for duplicate comments:
$duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE pid = '$pid' AND lid = '$id' AND subject = '$subject' AND comment = '$comment'"), 0);
@@ -135,7 +137,7 @@ function comment_post($pid, $id, $subject, $comment) {
$subject = ($subject) ? $subject : substr($comment, 0, 29);
// Add watchdog entry:
- watchdog("comment", "comment: added '$subject'");
+ watchdog("special", "comment: added '$subject'");
// Add comment to database:
db_query("INSERT INTO comments (lid, pid, author, subject, comment, hostname, timestamp, score) VALUES ('$id', '$pid', '$user->id', '$subject', '$comment', '". getenv("REMOTE_ADDR") ."', '". time() ."', '". ($user->userid ? 1 : 0) ."')");
@@ -281,9 +283,9 @@ function comment_render($lid, $cid) {
// Pre-process variables:
$lid = empty($lid) ? 0 : $lid;
$cid = empty($cid) ? 0 : $cid;
- $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);
+ $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 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";
diff --git a/includes/function.inc b/includes/function.inc
index 809fd4ed9..00a4a14f7 100644
--- a/includes/function.inc
+++ b/includes/function.inc
@@ -81,7 +81,7 @@ function format_date($timestamp, $type = "medium") {
function format_username($username) {
global $user;
if ($username) return (user_access($user, "account") ? "<A HREF=\"admin.php?mod=account&op=view&name=$username\">$username</A>" : "<A HREF=\"account.php?op=view&name=$username\">$username</A>");
- else { global $anonymous; return $anonymous; }
+ else return variable_get(anonymous, "Anonymous");
}
function format_email($address) {
diff --git a/includes/hostname.conf b/includes/hostname.conf
index 871110493..1c2528323 100644
--- a/includes/hostname.conf
+++ b/includes/hostname.conf
@@ -9,13 +9,6 @@ $db_pass = "password";
$db_name = "database";
#
-# Administrative information
-#
-$site_name = "site name";
-$site_url = "http://yourdomain.com/"; // add a trailing slash
-$site_email = "info@yourdomain.com";
-
-#
# Comment votes:
# The keys of this associative array are displayed in each comment's selection box whereas the corresponding values represent the mathematical calculation to be performed to update a comment's value.
#
@@ -34,11 +27,6 @@ $comment_votes = array("none" => "none",
$allowed_html = "<A><B><BLOCKQUOTE><CODE><DD><DL><DT><EM><HR><I><LI><SMALL><OL><U><UL>";
#
-# Name for anonymous users:
-#
-$anonymous = "Anonymous Chicken";
-
-#
# Themes:
# The first theme listed in this associative array will automatically become the default theme.
#
diff --git a/includes/node.inc b/includes/node.inc
index 462fc7a47..75b1fdc8c 100644
--- a/includes/node.inc
+++ b/includes/node.inc
@@ -52,7 +52,7 @@ function node_save($node) {
if ($u1 = implode(", ", $u1)) db_query("UPDATE node SET $u1 WHERE nid = '$node[nid]'");
if ($u2 = implode(", ", $u2)) db_query("UPDATE $n->type SET $u2 WHERE nid = '$node[nid]'");
- if ($n->pid && ($node[status] == $status[posted])) db_query("UPDATE node SET status = '$status[expired]' WHERE nid = '$node[pid]'");
+ if ($n->pid && ($node[status] == $status[posted])) db_query("UPDATE node SET status = '$status[expired]' WHERE nid = '$n->pid'");
watchdog("message", "node: modified '$n->title'");
}
@@ -63,6 +63,8 @@ function node_save($node) {
watchdog("warning", "node: duplicate '$node[title]'");
}
else {
+ throttle("post node", variable_get(max_node_rate, 900));
+
// setup default values:
$node = array_merge(array(title => "?", author => $user->id, type => "?", pid => 0, log => "node created", status => $status[queued], score => 0, votes => 0, timestamp => time()), $node);
diff --git a/includes/search.inc b/includes/search.inc
index cf47ebda8..851bc3a3a 100644
--- a/includes/search.inc
+++ b/includes/search.inc
@@ -15,7 +15,7 @@ function search_data($keys, $type) {
foreach ($result as $entry) {
$output .= "<P>\n";
$output .= " <B><U><A HREF=\"$entry[link]\">$entry[title]</A></U></B><BR>";
- $output .= " <SMALL>$site_url$entry[link]". ($entry[user] ? " - ". format_username($entry[user]) : "") ."". ($entry[date] ? " - ". format_date($entry[date], "small") : "") ."</SMALL>";
+ $output .= " <SMALL>$entry[link]". ($entry[user] ? " - ". format_username($entry[user]) : "") ."". ($entry[date] ? " - ". format_date($entry[date], "small") : "") ."</SMALL>";
$output .= "</P>\n";
}
}
diff --git a/includes/section.inc b/includes/section.inc
index c816818d4..ad25b179c 100644
--- a/includes/section.inc
+++ b/includes/section.inc
@@ -7,19 +7,19 @@ function section_get() {
return $array;
}
-function section_post_threshold($section, $threshold = 5) {
- $result = db_query("SELECT post FROM sections WHERE name = '". check_input($section) ."'");
- return ($result) ? db_result($result, 0) : $threshold;
+function section_post_threshold($section, $default) {
+ $section = db_fetch_object(db_query("SELECT post AS threshold FROM sections WHERE name = '". check_input($section) ."'"));
+ return $section->threshold ? $section->threshold : $default;
}
-function section_dump_threshold($section, $threshold = - 3) {
- $result = db_query("SELECT dump FROM sections WHERE name = '". check_input($section) ."'");
- return ($result) ? db_result($result, 0) : $threshold;
+function section_dump_threshold($section, $default) {
+ $section = db_fetch_object(db_query("SELECT dump AS threshold FROM sections WHERE name = '". check_input($section) ."'"));
+ return $section->threshold ? $section->threshold : $default;
}
-function section_timout_threshold($section, $threshold = 10) {
- $result = db_query("SELECT timout FROM sections WHERE name = '". check_input($section) ."'");
- return ($result) ? db_result($result, 0) : $threshold;
+function section_timout_threshold($section, $default) {
+ $section = db_fetch_object(db_query("SELECT timout AS threshold FROM sections WHERE name = '". check_input($section) ."'"));
+ return $section->threshold ? $section->threshold : $default;
}
?> \ No newline at end of file
diff --git a/includes/theme.inc b/includes/theme.inc
index ad2bbeebb..c973868b4 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -28,7 +28,7 @@ function theme_menu($name, $module) {
}
function theme_account($theme) {
- global $user, $site_name, $links, $menu;
+ global $user, $links, $menu;
if ($user->id) {
@@ -38,7 +38,7 @@ function theme_account($theme) {
// Display account settings:
$content .= "<LI><A HREF=\"account.php?op=track&topic=comments\">". t("track your comments") ."</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=track&topic=nodes\">". t("track your nodes") ."</A></LI>\n";
- $content .= "<LI><A HREF=\"account.php?op=track&topic=site\">". strtr(t("track %a"), array("%a" => $site_name)) ."</A></LI>\n";
+ $content .= "<LI><A HREF=\"account.php?op=track&topic=site\">". strtr(t("track %a"), array("%a" => variable_get(site_name, "drupal"))) ."</A></LI>\n";
$content .= "<P>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=user\">". t("edit your information") ."</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=site\">". t("edit your preferences") ."</A></LI>\n";
@@ -46,7 +46,7 @@ function theme_account($theme) {
$content .= "<P>\n";
if (user_access($user)) {
- $content .= "<LI><A HREF=\"admin.php\">administer ". $site_name ."</A></LI>\n";
+ $content .= "<LI><A HREF=\"admin.php\">administer ". variable_get(site_name, "drupal") ."</A></LI>\n";
$content .= "<P>\n";
}
diff --git a/includes/variable.inc b/includes/variable.inc
new file mode 100644
index 000000000..20beb5efd
--- /dev/null
+++ b/includes/variable.inc
@@ -0,0 +1,54 @@
+<?php
+
+function variable_init($conf = array()) {
+ $result = db_query("SELECT * FROM variable");
+ while ($variable = db_fetch_object($result)) $conf[$variable->name] = $variable->value;
+ return $conf;
+}
+
+function handler_post_threshold($node, $default) {
+ if ($node->type) {
+ $function = $node->type ."_post_threshold";
+ return $function($node, $default);
+ }
+ else {
+ return $default;
+ }
+}
+
+function handler_dump_threshold($node, $default) {
+ if ($node->type) {
+ $function = $node->type ."_dump_threshold";
+ return $function($node, $default);
+ }
+ else {
+ return $default;
+ }
+}
+
+function handler_timout_threshold($node, $default) {
+ if ($node->type) {
+ $function = $node->type ."_timout_threshold";
+ return $function($node, $default);
+ }
+ else {
+ return $default;
+ }
+}
+
+function variable_get($name, $default, $object = 0) {
+ global $conf;
+
+ switch ($name) {
+ case "post_threshold":
+ return handler_post_threshold($object, $default);
+ case "dump_threshold":
+ return handler_dump_threshold($object, $default);
+ case "timout_threshold":
+ return handler_timout_threshold($object, $default);
+ default:
+ return ($conf[$name] ? $conf[$name] : $default);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/includes/watchdog.inc b/includes/watchdog.inc
deleted file mode 100644
index 9b28f3904..000000000
--- a/includes/watchdog.inc
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-$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"));
-
-function watchdog($id, $message) {
- global $user, $watchdog, $watchdog_history;
-
- // flood protection:
- if ($watchdog[$id][1] && !user_access($user, "watchdog")) {
- if ($log = db_fetch_object(db_query("SELECT * FROM watchdog WHERE hostname = '". getenv("REMOTE_ADDR") ."' AND level = '". $watchdog[$id][0] ."'"))) {
- if (time() - $log->timestamp < $watchdog[$id][1]) {
- watchdog("warning", "'". getenv("REMOTE_ADDR") ."' exceeded '$id' submission rate");
- header("Location: error.php?op=flood");
- exit();
- }
- }
- }
-
- // perform query to add new watchdog entry:
- db_query("INSERT INTO watchdog (level, timestamp, user, message, location, hostname) VALUES ('". $watchdog[$id][0] ."', '". time() ."', '". check_input($user->id) ."', '". check_input(check_output($message)) ."', '". check_input(getenv("REQUEST_URI")) ."', '". check_input(getenv("REMOTE_ADDR")) ."')");
-}
-
-function watchdog_clean($history = 302400) {
- $timestamp = time() - $history;
- db_query("DELETE FROM watchdog WHERE timestamp < $timestamp");
-}
-
-?>
diff --git a/modules/backend.class b/modules/backend.class
index b31372fb5..6c0914d57 100644
--- a/modules/backend.class
+++ b/modules/backend.class
@@ -46,8 +46,6 @@ class backend {
}
function url2sql($timout = 10) {
- global $site_name;
-
if ($this->file) {
// Decode URL:
$url = parse_url($this->file);
@@ -57,7 +55,7 @@ class backend {
if ($fp) {
// Request data via URL:
- fputs($fp, "GET $url[path]?$url[query] HTTP/1.0\nUser-Agent: $site_name\nHost: $url[host]\nAccept: */*\n\n");
+ fputs($fp, "GET $url[path]?$url[query] HTTP/1.0\nUser-Agent: ". variable_get(site_name, "drupal") ."\nHost: $url[host]\nAccept: */*\n\n");
// Read data from socket:
while(!feof($fp)) $data .= fgets($fp, 128);
diff --git a/modules/block.module b/modules/block.module
index 73b6b7f55..c2b53240b 100644
--- a/modules/block.module
+++ b/modules/block.module
@@ -84,7 +84,6 @@ function block_admin_display() {
}
function block_admin_overview() {
- global $site_name;
$result = db_query("SELECT * FROM blocks WHERE status > 0 AND region = 0 ORDER BY weight");
$lblocks .= "<TABLE BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
@@ -98,9 +97,9 @@ function block_admin_overview() {
$output .= "<P><B>layout 1:</B></P>\n";
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
- $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"3\">$site_name header</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"3\">header</TD></TR>\n";
$output .= " <TR><TD>\n". ($lblocks ? $lblocks : "&nbsp;") ."</TD><TD WIDTH=\"300\">&nbsp;</TD><TD>\n". ($rblocks ? $rblocks : "&nbsp;") ."</TD></TR>\n";
- $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"3\">$site_name footer</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"3\">footer</TD></TR>\n";
$output .= "</TABLE>\n";
$result = db_query("SELECT * FROM blocks WHERE status > 0 ORDER BY weight");
@@ -110,16 +109,16 @@ function block_admin_overview() {
$output .= "<P><B>layout 2:</B></P>\n";
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
- $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">$site_name header</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">header</TD></TR>\n";
$output .= " <TR><TD WIDTH=\"400\">&nbsp;</TD><TD>\n". ($blocks ? $blocks : "&nbsp;") ."</TD></TR>\n";
- $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">$site_name footer</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">footer</TD></TR>\n";
$output .= "</TABLE>\n";
$output .= "<P><B>layout 3:</B></P>\n";
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
- $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">$site_name header</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">header</TD></TR>\n";
$output .= " <TR><TD>\n". ($blocks ? $blocks : "&nbsp;") ."</TD><TD WIDTH=\"400\">&nbsp;</TD></TR>\n";
- $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">$site_name footer</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">footer</TD></TR>\n";
$output .= "</TABLE>\n";
print $output;
diff --git a/modules/block/block.module b/modules/block/block.module
index 73b6b7f55..c2b53240b 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -84,7 +84,6 @@ function block_admin_display() {
}
function block_admin_overview() {
- global $site_name;
$result = db_query("SELECT * FROM blocks WHERE status > 0 AND region = 0 ORDER BY weight");
$lblocks .= "<TABLE BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
@@ -98,9 +97,9 @@ function block_admin_overview() {
$output .= "<P><B>layout 1:</B></P>\n";
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
- $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"3\">$site_name header</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"3\">header</TD></TR>\n";
$output .= " <TR><TD>\n". ($lblocks ? $lblocks : "&nbsp;") ."</TD><TD WIDTH=\"300\">&nbsp;</TD><TD>\n". ($rblocks ? $rblocks : "&nbsp;") ."</TD></TR>\n";
- $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"3\">$site_name footer</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"3\">footer</TD></TR>\n";
$output .= "</TABLE>\n";
$result = db_query("SELECT * FROM blocks WHERE status > 0 ORDER BY weight");
@@ -110,16 +109,16 @@ function block_admin_overview() {
$output .= "<P><B>layout 2:</B></P>\n";
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
- $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">$site_name header</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">header</TD></TR>\n";
$output .= " <TR><TD WIDTH=\"400\">&nbsp;</TD><TD>\n". ($blocks ? $blocks : "&nbsp;") ."</TD></TR>\n";
- $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">$site_name footer</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">footer</TD></TR>\n";
$output .= "</TABLE>\n";
$output .= "<P><B>layout 3:</B></P>\n";
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
- $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">$site_name header</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">header</TD></TR>\n";
$output .= " <TR><TD>\n". ($blocks ? $blocks : "&nbsp;") ."</TD><TD WIDTH=\"400\">&nbsp;</TD></TR>\n";
- $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">$site_name footer</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"2\">footer</TD></TR>\n";
$output .= "</TABLE>\n";
print $output;
diff --git a/modules/book.module b/modules/book.module
index 4a8603ad8..b2f09b84c 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -126,11 +126,9 @@ function book_form($edit = array()) {
$output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"edit[body]\" MAXLENGTH=\"20\">". check_textarea($edit[body]) ."</TEXTAREA><BR>\n";
$output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n";
- if ($edit[pid]) {
- $output .= "<B>". t("Log message") .":</B><BR>\n";
- $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"5\" NAME=\"edit[log]\" MAXLENGTH=\"20\">". check_textarea($edit[log]) ."</TEXTAREA><BR>\n";
- $output .= "<SMALL><I>". t("An explanation of the updates being made to help the group understand the changes.") ."</I></SMALL><P>\n";
- }
+ $output .= "<B>". t("Log message") .":</B><BR>\n";
+ $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"5\" NAME=\"edit[log]\" MAXLENGTH=\"20\">". check_textarea($edit[log]) ."</TEXTAREA><BR>\n";
+ $output .= "<SMALL><I>". t("An explanation of the additions or updates being made to help the group understand your motivations.") ."</I></SMALL><P>\n";
if (user_access($user, "book")) {
$output .= "<B>". t("Weight") .":</B><BR>\n";
diff --git a/modules/book/book.module b/modules/book/book.module
index 4a8603ad8..b2f09b84c 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -126,11 +126,9 @@ function book_form($edit = array()) {
$output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"edit[body]\" MAXLENGTH=\"20\">". check_textarea($edit[body]) ."</TEXTAREA><BR>\n";
$output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n";
- if ($edit[pid]) {
- $output .= "<B>". t("Log message") .":</B><BR>\n";
- $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"5\" NAME=\"edit[log]\" MAXLENGTH=\"20\">". check_textarea($edit[log]) ."</TEXTAREA><BR>\n";
- $output .= "<SMALL><I>". t("An explanation of the updates being made to help the group understand the changes.") ."</I></SMALL><P>\n";
- }
+ $output .= "<B>". t("Log message") .":</B><BR>\n";
+ $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"5\" NAME=\"edit[log]\" MAXLENGTH=\"20\">". check_textarea($edit[log]) ."</TEXTAREA><BR>\n";
+ $output .= "<SMALL><I>". t("An explanation of the additions or updates being made to help the group understand your motivations.") ."</I></SMALL><P>\n";
if (user_access($user, "book")) {
$output .= "<B>". t("Weight") .":</B><BR>\n";
diff --git a/modules/diary.module b/modules/diary.module
index a706a106f..a3b757d79 100644
--- a/modules/diary.module
+++ b/modules/diary.module
@@ -164,7 +164,7 @@ function diary_page_submit($text, $id = 0) {
db_query("UPDATE diaries SET text = '$text' WHERE id = '$id'");
}
else {
- watchdog("diary", "diary: new diary entry added");
+ watchdog("special", "diary: new diary entry added");
db_query("INSERT INTO diaries (author, text, timestamp) VALUES ('$user->id', '$text', '". time() ."')");
}
diff --git a/modules/headline.module b/modules/headline.module
index df525cac5..81a52e580 100644
--- a/modules/headline.module
+++ b/modules/headline.module
@@ -189,7 +189,7 @@ function headline_admin() {
}
function headline_export($uri) {
- global $site_name, $site_url, $status, $HTTP_REFERER, $HTTP_USER_AGENT;
+ global $status, $HTTP_REFERER, $HTTP_USER_AGENT;
if ($uri[1] == "headlines.rdf") {
watchdog("message", "grabbed 'headlines.rdf' - referring url: $HTTP_REFERER - user agent: $HTTP_USER_AGENT");
@@ -202,9 +202,9 @@ function headline_export($uri) {
print " xmlns=\"http://my.netscape.com/rdf/simple/0.9/\">\n";
print "<channel>\n";
- print " <title>$site_name</title>\n";
- print " <link>$site_url</link>\n";
- print " <description>$site_name</description>\n";
+ print " <title>". variable_get(site_name, "drupal") ."</title>\n";
+ print " <link>". variable_get(site_url, "http://drupal/") ."</link>\n";
+ print " <description>". variable_get(site_name, "drupal") ."</description>\n";
print "</channel>\n";
$result = db_query("SELECT * FROM node WHERE type = 'story' AND status = '$status[posted]' ORDER BY timestamp DESC LIMIT 10");
@@ -212,7 +212,7 @@ function headline_export($uri) {
while ($node = db_fetch_object($result)) {
print "<item>\n";
print " <title>". check_export($node->title) ."</title>\n";
- print " <link>". $site_url ."node.php?id=$node->nid</link>\n";
+ print " <link>". variable_get(site_url, "http://drupal/") ."node.php?id=$node->nid</link>\n";
print "</item>\n";
}
diff --git a/modules/headlineRSS10.module b/modules/headlineRSS10.module
index 5714ac9f2..1e15ceb1b 100644
--- a/modules/headlineRSS10.module
+++ b/modules/headlineRSS10.module
@@ -10,7 +10,7 @@ include_once "includes/common.inc";
include_once "modules/backend.class";
function headlineRSS10_export($uri) {
- global $site_name, $site_url, $status, $HTTP_REFERER, $HTTP_USER_AGENT;
+ global $status, $HTTP_REFERER, $HTTP_USER_AGENT;
if ($uri[1] == "headlinesRSS10.rdf") {
watchdog("message", "grabbed 'headlinesRSS10.rdf' - referring url: $HTTP_REFERER - user agent: $HTTP_USER_AGENT");
@@ -23,10 +23,10 @@ function headlineRSS10_export($uri) {
print "xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n";
print "xmlns=\"http://purl.org/rss/1.0/\">\n\n";
- print "<channel rdf:about=\"".$site_url."export/headlinesRSS10.rdf\">\n";
- print " <title>$site_name</title>\n";
- print " <link>$site_url</link>\n";
- print " <description>$site_name</description>\n";
+ print "<channel rdf:about=\"". variable_get(site_url, "http://drupal/") ."export/headlinesRSS10.rdf\">\n";
+ print " <title>". variable_get(site_name, "drupal") ."</title>\n";
+ print " <link>". variable_get(site_url, "http://drupal/") ."</link>\n";
+ print " <description>". variable_get(site_name, "drupal") ."</description>\n";
print " <items>\n";
@@ -35,8 +35,7 @@ function headlineRSS10_export($uri) {
$result = db_query("SELECT * FROM node WHERE type = 'story' AND status = '$status[posted]' ORDER BY timestamp DESC LIMIT 10");
while ($node = db_fetch_object($result)) {
- print " <rdf:li resource=\"". $site_url ."node.php?id=$node->nid\" />\n";
-
+ print " <rdf:li resource=\"". variable_get(site_url, "http://drupal/") ."node.php?id=$node->nid\" />\n";
}
print " </rdf:Seq>\n";
@@ -46,9 +45,9 @@ function headlineRSS10_export($uri) {
$result = db_query("SELECT * FROM node WHERE type = 'story' AND status = '$status[posted]' ORDER BY timestamp DESC LIMIT 10");
while ($node = db_fetch_object($result)) {
- print "<item rdf:about=\"".$site_url ."node.php?id=$node->nid\">\n";
+ print "<item rdf:about=\"". variable_get(site_url, "http://drupal/") ."node.php?id=$node->nid\">\n";
print " <title>". check_export($node->title) ."</title>\n";
- print " <link>". $site_url ."node.php?id=$node->nid</link>\n";
+ print " <link>". variable_get(site_url, "http://drupal/") ."node.php?id=$node->nid</link>\n";
if ($node->abstract)
print " <description>". check_output($node->abstract, 1) ."</description>\n";
diff --git a/modules/moderation.module b/modules/moderation.module
index 9f7a7049f..ac193c166 100644
--- a/modules/moderation.module
+++ b/modules/moderation.module
@@ -82,9 +82,12 @@ function moderation_node($id) {
header("Location: node.php?id=$node->nid");
}
else {
- if ($node->pid && $n = node_get_object("nid", $node->pid)) {
- if ($node->pid) $output .= " ". t("The above node is a suggested update for an existing node:") ." \"<A HREF=\"node.php?id=$n->nid\">". check_output($n->title) ."</A>\".";
- if ($node->log) $output .= " ". t("The log message to accompany this update is given below:") ."<P><I>". check_output($node->log, 1) ."</I></P>";
+ if ($n = node_get_object("nid", $node->pid)) {
+ $output .= " ". t("The above node is a proposed update of an existing node:") ." \"<A HREF=\"node.php?id=$n->nid\">". check_output($n->title) ."</A>\".";
+ }
+
+ if ($node->log) {
+ $output .= " ". t("The log message to accompany this submission is given below:") ."<P><I>". check_output($node->log, 1) ."</I></P>";
}
// moderation form:
diff --git a/modules/story.module b/modules/story.module
index d83557456..a750beffc 100644
--- a/modules/story.module
+++ b/modules/story.module
@@ -20,15 +20,15 @@ class Story {
}
function story_post_threshold($node, $default) {
- return $default;
+ return section_post_threshold($node->section, $default);
}
function story_dump_threshold($node, $default) {
- return $default;
+ return section_dump_threshold($node->section, $default);
}
function story_timout_threshold($node, $default) {
- return $default;
+ return section_timout_threshold($node->section, $default);
}
function story_find($keys) {
diff --git a/modules/story/story.module b/modules/story/story.module
index d83557456..a750beffc 100644
--- a/modules/story/story.module
+++ b/modules/story/story.module
@@ -20,15 +20,15 @@ class Story {
}
function story_post_threshold($node, $default) {
- return $default;
+ return section_post_threshold($node->section, $default);
}
function story_dump_threshold($node, $default) {
- return $default;
+ return section_dump_threshold($node->section, $default);
}
function story_timout_threshold($node, $default) {
- return $default;
+ return section_timout_threshold($node->section, $default);
}
function story_find($keys) {
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 .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
- $output .= " <TR>\n";
- $output .= " <TH ALIGN=\"right\" COLSPAN=\"4\">\n";
- $output .= " <FORM ACTION=\"admin.php?mod=watchdog\" METHOD=\"post\">\n";
- $output .= " <SELECT NAME=\"order\">\n";
- foreach ($fields as $key=>$value) {
- $output .= " <OPTION VALUE=\"$key\"". ($key == $order ? " SELECTED" : "") .">Sort by $key</OPTION>\n";
- }
- $output .= " </SELECT>\n";
- $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Update\">\n";
- $output .= " </FORM>\n";
- $output .= " </TH>\n";
- $output .= " </TR>\n";
- $output .= " <TR>\n";
- $output .= " <TH>date</TH>\n";
- $output .= " <TH>message</TH>\n";
- $output .= " <TH>user</TH>\n";
- $output .= " <TH>operations</TH>\n";
- $output .= " </TR>\n";
-
+ $output .= " <TR><TH>date</TH><TH>type</TH><TH>message</TH><TH>user</TH><TH>operations</TH></TR>\n";
while ($watchdog = db_fetch_object($result)) {
- $output .= " <TR BGCOLOR=\"". $colors[$watchdog->level] ."\"><TD>". format_date($watchdog->timestamp) ."</TD><TD>". substr(check_output($watchdog->message), 0, 44) ."</TD><TD ALIGN=\"center\">". format_username($watchdog->userid) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n";
+ if ($color = $colors[$watchdog->type]) {
+ $output .= " <TR BGCOLOR=\"$color\"><TD>". format_date($watchdog->timestamp) ."</TD><TD ALIGN=\"center\">$watchdog->link</TD><TD>". substr(check_output($watchdog->message), 0, 50) ."</TD><TD ALIGN=\"center\">". format_username($watchdog->userid) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n";
+ }
}
-
$output .= "</TABLE>\n";
- print $output;
+ return $output;
}
function watchdog_view($id) {
@@ -58,33 +37,16 @@ function watchdog_view($id) {
if ($watchdog = db_fetch_object($result)) {
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
- $output .= " <TR><TH>Level:</TH><TD>". check_output($watchdog->level) ."</TD></TR>\n";
+ $output .= " <TR><TH>Type:</TH><TD>". check_output($watchdog->type) ."</TD></TR>\n";
$output .= " <TR><TH>Date:</TH><TD>". format_date($watchdog->timestamp, "large") ."</TD></TR>\n";
$output .= " <TR><TH>User:</TH><TD>". format_username($watchdog->userid) ."</TD></TR>\n";
$output .= " <TR><TH>Location:</TH><TD>". check_output($watchdog->location). "</TD></TR>\n";
$output .= " <TR><TH>Message:</TH><TD>". check_output($watchdog->message) ."</TD></TR>\n";
$output .= " <TR><TH>Hostname:</TH><TD>". check_output($watchdog->hostname) ."</TD></TR>\n";
$output .= "</TABLE>\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 .= "<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;
+ return $output;
+ }
}
function watchdog_admin() {
@@ -97,13 +59,10 @@ function watchdog_admin() {
watchdog_help();
break;
case "view":
- watchdog_view(check_input($id));
- break;
- case "Update":
- watchdog_overview(check_input($order));
+ print watchdog_view(check_input($id));
break;
default:
- watchdog_overview();
+ print watchdog_overview();
}
}
diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module
index c912ee85b..18279db1b 100644
--- a/modules/watchdog/watchdog.module
+++ b/modules/watchdog/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 .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
- $output .= " <TR>\n";
- $output .= " <TH ALIGN=\"right\" COLSPAN=\"4\">\n";
- $output .= " <FORM ACTION=\"admin.php?mod=watchdog\" METHOD=\"post\">\n";
- $output .= " <SELECT NAME=\"order\">\n";
- foreach ($fields as $key=>$value) {
- $output .= " <OPTION VALUE=\"$key\"". ($key == $order ? " SELECTED" : "") .">Sort by $key</OPTION>\n";
- }
- $output .= " </SELECT>\n";
- $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Update\">\n";
- $output .= " </FORM>\n";
- $output .= " </TH>\n";
- $output .= " </TR>\n";
- $output .= " <TR>\n";
- $output .= " <TH>date</TH>\n";
- $output .= " <TH>message</TH>\n";
- $output .= " <TH>user</TH>\n";
- $output .= " <TH>operations</TH>\n";
- $output .= " </TR>\n";
-
+ $output .= " <TR><TH>date</TH><TH>type</TH><TH>message</TH><TH>user</TH><TH>operations</TH></TR>\n";
while ($watchdog = db_fetch_object($result)) {
- $output .= " <TR BGCOLOR=\"". $colors[$watchdog->level] ."\"><TD>". format_date($watchdog->timestamp) ."</TD><TD>". substr(check_output($watchdog->message), 0, 44) ."</TD><TD ALIGN=\"center\">". format_username($watchdog->userid) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n";
+ if ($color = $colors[$watchdog->type]) {
+ $output .= " <TR BGCOLOR=\"$color\"><TD>". format_date($watchdog->timestamp) ."</TD><TD ALIGN=\"center\">$watchdog->link</TD><TD>". substr(check_output($watchdog->message), 0, 50) ."</TD><TD ALIGN=\"center\">". format_username($watchdog->userid) ."</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=watchdog&op=view&id=$watchdog->id\">details</A></TD></TR>\n";
+ }
}
-
$output .= "</TABLE>\n";
- print $output;
+ return $output;
}
function watchdog_view($id) {
@@ -58,33 +37,16 @@ function watchdog_view($id) {
if ($watchdog = db_fetch_object($result)) {
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
- $output .= " <TR><TH>Level:</TH><TD>". check_output($watchdog->level) ."</TD></TR>\n";
+ $output .= " <TR><TH>Type:</TH><TD>". check_output($watchdog->type) ."</TD></TR>\n";
$output .= " <TR><TH>Date:</TH><TD>". format_date($watchdog->timestamp, "large") ."</TD></TR>\n";
$output .= " <TR><TH>User:</TH><TD>". format_username($watchdog->userid) ."</TD></TR>\n";
$output .= " <TR><TH>Location:</TH><TD>". check_output($watchdog->location). "</TD></TR>\n";
$output .= " <TR><TH>Message:</TH><TD>". check_output($watchdog->message) ."</TD></TR>\n";
$output .= " <TR><TH>Hostname:</TH><TD>". check_output($watchdog->hostname) ."</TD></TR>\n";
$output .= "</TABLE>\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 .= "<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;
+ return $output;
+ }
}
function watchdog_admin() {
@@ -97,13 +59,10 @@ function watchdog_admin() {
watchdog_help();
break;
case "view":
- watchdog_view(check_input($id));
- break;
- case "Update":
- watchdog_overview(check_input($order));
+ print watchdog_view(check_input($id));
break;
default:
- watchdog_overview();
+ print watchdog_overview();
}
}
diff --git a/themes/example/example.theme b/themes/example/example.theme
index e6ee46cf0..e78ce60d5 100644
--- a/themes/example/example.theme
+++ b/themes/example/example.theme
@@ -12,13 +12,11 @@
class Theme {
function header() {
- global $site_name;
-
?>
<HTML>
<HEAD>
- <TITLE><? echo $site_name; ?></TITLE>
+ <TITLE><? echo variable_get(site_name, "drupal"); ?></TITLE>
</HEAD>
<BODY>
<TABLE BORDER="1">
diff --git a/themes/goofy/goofy.theme b/themes/goofy/goofy.theme
index e145362b7..8acde2ae8 100644
--- a/themes/goofy/goofy.theme
+++ b/themes/goofy/goofy.theme
@@ -14,12 +14,11 @@
class Theme {
function header() {
- global $site_name;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
- <title><?php echo $site_name; ?></title>
+ <title><?php echo variable_get(site_name, "drupal"); ?></title>
<style type="text/css">
<!--
body { background-color: #FFFFFF; font-size: 10pt; font-family: tahoma,helvetica,arial; }
@@ -57,7 +56,7 @@
<body>
<table border="0" cellspacing="3" cellpadding="0" width="100%">
<tr>
- <td colspan="2" width="100%"><img src="themes/goofy/images/logo.png" alt="<?php echo $site_name; ?> logo"><br>
+ <td colspan="2" width="100%"><img src="themes/goofy/images/logo.png" alt=""><br>
<?php $this->linksbar(); ?>
</td>
</tr>
@@ -173,7 +172,7 @@
// Author:
echo " <tr>";
echo " <td valign=\"top\"><div align=\"right\">" . t("Author") . ":&nbsp;</div></td><td><b>" . format_username($comment->userid) . "</b>";
- if ($comment->userid != $anonymous) {
+ if ($comment->userid) {
// Display extra information line:
if ($comment->fake_email) $info .= format_email($comment->fake_email);
if (eregi("http://",$comment->url)) $info .= ($info?" | ":"") . format_url($comment->url);
diff --git a/themes/jeroen/jeroen.theme b/themes/jeroen/jeroen.theme
index ae54f04b3..e4d695fa6 100644
--- a/themes/jeroen/jeroen.theme
+++ b/themes/jeroen/jeroen.theme
@@ -22,15 +22,13 @@
*/
function header() {
- global $site_name;
-
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
- <title><?php echo $site_name; ?> - Tears of technology</title>
+ <title><?php echo variable_get(site_name, "drupal"); ?> - Tears of technology</title>
<style type="text/css">
<!--
BODY,P,DIV,LI,UL,td,EM,FONT,BLOCKQUOTE,FORM{font-size: 10pt; font-family:Helvetica,Lucida,sans-serif;}
@@ -207,7 +205,7 @@
// Author:
echo " <tr>";
echo " <td align=\"right\"><FONT COLOR=\"#FEFEFE\">". t("Author") .":</FONT></td><td><B>". format_username($comment->userid) ."</B> ";
- if ($comment->userid != $anonymous) {
+ if ($comment->userid) {
// Display extra information line:
if ($comment->fake_email) $info .= format_email($comment->fake_email);
if (eregi("http://",$comment->url)) $info .= " | " . format_url($comment->url);
diff --git a/themes/marvin/marvin.theme b/themes/marvin/marvin.theme
index 1bd4d7cf9..05e761e59 100644
--- a/themes/marvin/marvin.theme
+++ b/themes/marvin/marvin.theme
@@ -14,12 +14,11 @@
var $link = "#666699";
function header() {
- global $site_name;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<HTML>
<HEAD>
- <TITLE><?php print $site_name; ?></TITLE>
+ <TITLE><?php print variable_get(site_name, "drupal"); ?></TITLE>
</HEAD>
<STYLE type="text/css">
<!--
diff --git a/themes/unconed/unconed.theme b/themes/unconed/unconed.theme
index a0c32fec4..c7533dcdc 100644
--- a/themes/unconed/unconed.theme
+++ b/themes/unconed/unconed.theme
@@ -34,12 +34,11 @@
var $fgcolor3 = "#000000";
function header() {
- global $site_name;
srand((double)microtime()*1000000);
?>
<HTML>
<HEAD>
- <TITLE><?php echo $site_name; ?></TITLE>
+ <TITLE><?php echo variable_get(site_name, "drupal"); ?></TITLE>
<META NAME="description" CONTENT="drop.org">
<META NAME="keywords" CONTENT="drop, weblog, portal, community, news, article, announcements, stories, story, computer, science, space, hype, cult, geek, nerd, foo, bar">
</HEAD>
@@ -92,9 +91,7 @@
<?php
if ($story->section) { print "<TD WIDTH=\"70%\" BGCOLOR=\"$this->bgcolor2\">"; }
else { print "<TD COLSPAN=\"2\" BGCOLOR=\"$this->bgcolor2\">"; }
- if ($story->userid) { print "<SMALL>Posted by " . format_username($story->userid) . " on $timestamp"; }
- else { print "<SMALL>Posted by $anonymous on $timestamp"; }
-
+ print "<SMALL>Posted by " . format_username($story->userid) . " on $timestamp";
if ($story->section) { print "</TD><TD WIDTH=\"30%\" BGCOLOR=\"$this->bgcolor2\" ALIGN=\"center\"><B><A HREF=\"index.php?section=" . urlencode($story->section) . "\"><FONT COLOR=\"$this->sectioncolor\">". check_output($story->section) ."</FONT></A></B>"; }
?>
</TD>
@@ -149,7 +146,7 @@
// Author:
echo " <TR>";
echo " <TD ALIGN=\"right\" VALIGN=\"top\">Author:</TD><TD><B>" . format_username($comment->userid) . "</B> ";
- if ($comment->userid != $anonymous) {
+ if ($comment->userid) {
// Display extra information line:
if ($comment->fake_email) $info .= format_email($comment->fake_email);
if (eregi("http://",$comment->url)) $info .= ($info?" | ":"") . format_url($comment->url);
diff --git a/updates/2.00-to-x.xx.sql b/updates/2.00-to-x.xx.sql
index ae894d654..391d8af44 100644
--- a/updates/2.00-to-x.xx.sql
+++ b/updates/2.00-to-x.xx.sql
@@ -1,17 +1,27 @@
# 05/04/2001:
-
CREATE TABLE variable (
name varchar(32) DEFAULT '' NOT NULL,
value varchar(128) DEFAULT '' NOT NULL,
PRIMARY KEY (name)
);
+CREATE TABLE watchdog (
+ id int(5) DEFAULT '0' NOT NULL auto_increment,
+ user int(6) DEFAULT '0' NOT NULL,
+ type varchar(16) DEFAULT '' NOT NULL,
+ link varchar(16) DEFAULT '' NOT NULL,
+ message varchar(255) DEFAULT '' NOT NULL,
+ location varchar(128) DEFAULT '' NOT NULL,
+ hostname varchar(128) DEFAULT '' NOT NULL,
+ timestamp int(11) DEFAULT '0' NOT NULL,
+ PRIMARY KEY (id)
+);
+
# 01/04/2001:
CREATE TABLE access (
id tinyint(10) DEFAULT '0' NOT NULL auto_increment,
mask varchar(255) DEFAULT '' NOT NULL,
- type varchar(16) DEFAULT '' NOT NULL,
reason text NOT NULL,
UNIQUE mask (mask),
PRIMARY KEY (id)