Commit 04ad9b8a authored by Dries's avatar Dries

- fixed issue depricated call-by-reference issues
- fixed small visual glitch in includes/function.inc
- changed SQL tables around a bit to be more consistent
  (result: small changes to a lot of different files)
- improved robustness of includes/node.inc
- improved output of cron.module
- improved output of node.php
parent 57eb908a
drupal x.xx, xx/xx/xxxx drupal x.xx, xx/xx/xxxx
----------------------- -----------------------
- major overhaul of the underlying design: - major overhaul of the entire underlying design:
* everything is based on nodes * everything is based on nodes
* introduced links / drupal tags * introduced links/drupal tags
- refactored submission / moderation queue - rewrote submission/moderation queue:
- added a "wiki module" * renamed submission.module to moderation.module
* updated submission forms
- added a "book module":
* merged documentation and FAQ module into a book module
- various updates: - various updates:
* added preview functionality when submitting new content (such as a story) from the administration pages. * 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. * made the administration section only show those links a user has access to.
* improved account module
* improved comment module
* improved story module:
+ stories can now be permanently deleted
* improved themes:
+ W3C validation on a best effort basis
+ added goofy theme
- revised documentation
drupal 2.00, 15/03/2001 drupal 2.00, 15/03/2001
----------------------- -----------------------
...@@ -45,7 +56,7 @@ drupal 2.00, 15/03/2001 ...@@ -45,7 +56,7 @@ drupal 2.00, 15/03/2001
* improved database abstraction layer * improved database abstraction layer
* improved themes: * improved themes:
+ W3C validation on a best effort basis + W3C validation on a best effort basis
+ added example theme for theme designers + added example theme
* added CREDITS file * added CREDITS file
* added directory "misc" * added directory "misc"
* added new scripts to directory "scripts" * added new scripts to directory "scripts"
......
...@@ -254,7 +254,7 @@ function module($name, $module, $username) { ...@@ -254,7 +254,7 @@ function module($name, $module, $username) {
$block1 .= "</TABLE>\n"; $block1 .= "</TABLE>\n";
/* /*
$result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.timestamp, n.title AS node FROM comments c LEFT JOIN users u ON u.id = c.author LEFT JOIN nodes ON n.id = c.lid WHERE u.userid = '$uname' AND n.status = '$status[posted]' AND s.timestamp > ". (time() - 1209600) ." ORDER BY cid DESC LIMIT 10"); $result = db_query("SELECT c.cid, c.pid, c.lid, c.subject, c.timestamp, n.title AS node FROM comments c LEFT JOIN users u ON u.id = c.author LEFT JOIN node ON n.id = c.lid WHERE u.userid = '$uname' AND n.status = '$status[posted]' AND s.timestamp > ". (time() - 1209600) ." ORDER BY cid DESC LIMIT 10");
while ($comment = db_fetch_object($result)) { while ($comment = db_fetch_object($result)) {
$block2 .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n"; $block2 .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
$block2 .= " <TR><TD ALIGN=\"right\"><B>". t("Comment") .":</B></TD><TD><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD></TR>\n"; $block2 .= " <TR><TD ALIGN=\"right\"><B>". t("Comment") .":</B></TD><TD><A HREF=\"node.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD></TR>\n";
...@@ -406,7 +406,7 @@ function account_password($min_length=6) { ...@@ -406,7 +406,7 @@ function account_password($min_length=6) {
function account_track_comments() { function account_track_comments() {
global $theme, $user; global $theme, $user;
$sresult = db_query("SELECT n.nid, n.title, COUNT(n.nid) AS count FROM comments c LEFT JOIN nodes n ON c.lid = n.nid WHERE c.author = '$user->id' GROUP BY n.nid DESC LIMIT 5"); $sresult = db_query("SELECT n.nid, n.title, COUNT(n.nid) AS count FROM comments c LEFT JOIN node n ON c.lid = n.nid WHERE c.author = '$user->id' GROUP BY n.nid DESC LIMIT 5");
while ($node = db_fetch_object($sresult)) { while ($node = db_fetch_object($sresult)) {
$output .= "<LI>". format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." `<A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>`:</LI>\n"; $output .= "<LI>". format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." `<A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>`:</LI>\n";
...@@ -427,7 +427,7 @@ function account_track_comments() { ...@@ -427,7 +427,7 @@ function account_track_comments() {
function account_track_nodes() { function account_track_nodes() {
global $status, $theme, $user; global $status, $theme, $user;
$result = db_query("SELECT n.nid, n.type, n.title, n.timestamp, COUNT(c.cid) AS count FROM nodes n LEFT JOIN comments c ON c.lid = n.nid WHERE n.status = '$status[posted]' AND n.author = '$user->id' GROUP BY n.nid DESC LIMIT 25"); $result = db_query("SELECT n.nid, n.type, n.title, n.timestamp, COUNT(c.cid) AS count FROM node n LEFT JOIN comments c ON c.lid = n.nid WHERE n.status = '$status[posted]' AND n.author = '$user->id' GROUP BY n.nid DESC LIMIT 25");
while ($node = db_fetch_object($result)) { while ($node = db_fetch_object($result)) {
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n"; $output .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
...@@ -448,7 +448,7 @@ function account_track_site() { ...@@ -448,7 +448,7 @@ function account_track_site() {
$period = 259200; // 3 days $period = 259200; // 3 days
$sresult = db_query("SELECT n.title, n.nid, COUNT(c.lid) AS count FROM comments c LEFT JOIN nodes n ON c.lid = n.nid WHERE n.status = '$status[posted]' AND ". time() ." - n.timestamp < $period GROUP BY c.lid ORDER BY n.timestamp DESC LIMIT 10"); $sresult = db_query("SELECT n.title, n.nid, COUNT(c.lid) AS count FROM comments c LEFT JOIN node n ON c.lid = n.nid WHERE n.status = '$status[posted]' AND ". time() ." - n.timestamp < $period GROUP BY c.lid ORDER BY n.timestamp DESC LIMIT 10");
while ($node = db_fetch_object($sresult)) { while ($node = db_fetch_object($sresult)) {
$output .= "<LI>". format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." '<A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>':</LI>"; $output .= "<LI>". format_plural($node->count, "comment", "comments") ." ". t("attached to node") ." '<A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>':</LI>";
......
...@@ -10,10 +10,7 @@ function cron_run() { ...@@ -10,10 +10,7 @@ function cron_run() {
$result = db_query("SELECT * FROM crons WHERE $time - timestamp > scheduled"); $result = db_query("SELECT * FROM crons WHERE $time - timestamp > scheduled");
while ($task = db_fetch_object($result)) { while ($task = db_fetch_object($result)) {
if ($repository[$task->module]["cron"]) { if ($repository[$task->module]["cron"]) $repository[$task->module]["cron"]();
watchdog("message", "cron: executed '". $task->module ."_cron()'");
$repository[$task->module]["cron"]();
}
} }
db_query("UPDATE crons SET timestamp = $time WHERE $time - timestamp > scheduled"); db_query("UPDATE crons SET timestamp = $time WHERE $time - timestamp > scheduled");
......
...@@ -18,7 +18,8 @@ function ban_match($mask, $category) { ...@@ -18,7 +18,8 @@ function ban_match($mask, $category) {
return db_fetch_object($result); return db_fetch_object($result);
} }
function ban_add($mask, $category, $reason, $message = "") { // TODO --> $message by reference
function ban_add($mask, $category, $reason, $message = 0) {
global $index2type; global $index2type;
if (empty($mask)) { if (empty($mask)) {
......
...@@ -128,14 +128,14 @@ function comment_post($pid, $id, $subject, $comment) { ...@@ -128,14 +128,14 @@ function comment_post($pid, $id, $subject, $comment) {
$duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE pid = '$pid' AND lid = '$id' AND subject = '$subject' AND comment = '$comment'"), 0); $duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE pid = '$pid' AND lid = '$id' AND subject = '$subject' AND comment = '$comment'"), 0);
if ($duplicate != 0) { if ($duplicate != 0) {
watchdog("error", "comment: attempt to insert duplicate comment"); watchdog("warning", "comment: duplicate '$subject'");
} }
else { else {
// Validate subject: // Validate subject:
$subject = ($subject) ? $subject : substr($comment, 0, 29); $subject = ($subject) ? $subject : substr($comment, 0, 29);
// Add watchdog entry: // Add watchdog entry:
watchdog("comment", "comment: added comment with subject '$subject'"); watchdog("comment", "comment: added '$subject'");
// Add comment to database: // 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) ."')"); 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) ."')");
......
...@@ -48,7 +48,7 @@ function format_interval($timestamp) { ...@@ -48,7 +48,7 @@ function format_interval($timestamp) {
$timestamp = $timestamp % 3600; $timestamp = $timestamp % 3600;
} }
if ($timestamp >= 60) { if ($timestamp >= 60) {
$output .= " ". floor($timestamp / 60) ."min"; $output .= " ". floor($timestamp / 60) ." min";
$timestamp = $timestamp % 60; $timestamp = $timestamp % 60;
} }
if ($timestamp > 0) { if ($timestamp > 0) {
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
$status = array(dumped => 0, expired => 1, queued => 2, posted => 3, scheduled => 4); $status = array(dumped => 0, expired => 1, queued => 2, posted => 3, scheduled => 4);
function _node_get($field, $value) { function _node_get($field, $value) {
$result = db_query("SELECT lid, type FROM nodes WHERE $field = '$value'"); $result = db_query("SELECT lid, type FROM node WHERE $field = '$value'");
if ($node = db_fetch_object($result)) { if ($node = db_fetch_object($result)) {
return db_query("SELECT n.*, l.*, u.userid FROM nodes n LEFT JOIN $node->type l ON n.lid = l.id AND l.node = n.nid LEFT JOIN users u ON n.author = u.id WHERE n.$field = '$value' ORDER BY n.timestamp DESC"); return db_query("SELECT n.*, l.*, u.userid FROM node n LEFT JOIN $node->type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN users u ON n.author = u.id WHERE n.$field = '$value' ORDER BY n.timestamp DESC");
} }
} }
...@@ -21,8 +21,9 @@ function node_del($field, $value) { ...@@ -21,8 +21,9 @@ function node_del($field, $value) {
global $status; global $status;
if ($node = node_get_object($field, $value)) { if ($node = node_get_object($field, $value)) {
if ($node->status == $status[dumped]) { if ($node->status == $status[dumped]) {
db_query("DELETE FROM nodes WHERE nid = '$node->nid'"); db_query("DELETE FROM node WHERE nid = '$node->nid'");
db_query("DELETE FROM $node->type WHERE node = '$node->nid'"); db_query("DELETE FROM $node->type WHERE lid = '$node->lid' AND nid = '$node->nid'");
db_query("DELETE FROM comments WHERE lid = '$node->nid'");
watchdog("message", "node: deleted '$node->title'"); watchdog("message", "node: deleted '$node->title'");
return $node; return $node;
} }
...@@ -50,8 +51,8 @@ function node_save($node) { ...@@ -50,8 +51,8 @@ function node_save($node) {
$u1 = implode(", ", $u1); $u1 = implode(", ", $u1);
$u2 = implode(", ", $u2); $u2 = implode(", ", $u2);
db_query("UPDATE nodes SET $u1 WHERE nid = '$node[nid]'"); db_query("UPDATE node SET $u1 WHERE nid = '$node[nid]'");
db_query("UPDATE $node[type] SET $u2 WHERE node = '$node[nid]'"); db_query("UPDATE $node[type] SET $u2 WHERE nid = '$node[nid]'");
watchdog("message", "node: modified '$node[title]'"); watchdog("message", "node: modified '$node[title]'");
} }
...@@ -59,7 +60,7 @@ function node_save($node) { ...@@ -59,7 +60,7 @@ function node_save($node) {
$duplicate = node_get_object("title", $node[title]); $duplicate = node_get_object("title", $node[title]);
if ($duplicate && (time() - $duplicate->timestamp < 300)) { if ($duplicate && (time() - $duplicate->timestamp < 300)) {
watchdog("warning", "node: duplicate node '$node[title]'"); watchdog("warning", "node: duplicate '$node[title]'");
} }
else { else {
// setup default values: // setup default values:
...@@ -87,14 +88,14 @@ function node_save($node) { ...@@ -87,14 +88,14 @@ function node_save($node) {
$f2 = implode(", ", $f2); $f2 = implode(", ", $f2);
$v2 = implode(", ", $v2); $v2 = implode(", ", $v2);
db_query("INSERT INTO nodes ($f1) VALUES ($v1)"); db_query("INSERT INTO node ($f1) VALUES ($v1)");
if ($nid = db_insert_id()) { if ($nid = db_insert_id()) {
$lid = db_query("INSERT INTO $node[type] ($f2, node) VALUES ($v2, $nid)"); $lid = db_query("INSERT INTO $node[type] ($f2, nid) VALUES ($v2, $nid)");
if ($lid = db_insert_id()) { if ($lid = db_insert_id()) {
db_query("UPDATE nodes SET lid = '$lid' WHERE nid = '$nid'"); db_query("UPDATE node SET lid = '$lid' WHERE nid = '$nid'");
} }
else { else {
db_query("DELETE FROM nodes WHERE nid = '$nid'"); db_query("DELETE FROM node WHERE nid = '$nid'");
} }
} }
...@@ -103,7 +104,7 @@ function node_save($node) { ...@@ -103,7 +104,7 @@ function node_save($node) {
} }
if (($node[pid]) && ($node[status] == $status[posted])) { if (($node[pid]) && ($node[status] == $status[posted])) {
db_query("UPDATE nodes SET status = '$status[expired]' WHERE nid = '$node[pid]'"); db_query("UPDATE node SET status = '$status[expired]' WHERE nid = '$node[pid]'");
} }
} }
......
...@@ -11,7 +11,7 @@ function search_form($keys) { ...@@ -11,7 +11,7 @@ function search_form($keys) {
function search_data($keys, $type) { function search_data($keys, $type) {
if ($keys && $type) { if ($keys && $type) {
$result = module_execute($type, "find", $keys); $result = module_execute($type, "find", check_input($keys));
foreach ($result as $entry) { foreach ($result as $entry) {
$output .= "<P>\n"; $output .= "<P>\n";
$output .= " <B><U><A HREF=\"$entry[link]\">$entry[title]</A></U></B><BR>"; $output .= " <B><U><A HREF=\"$entry[link]\">$entry[title]</A></U></B><BR>";
......
...@@ -18,7 +18,7 @@ function theme_link($separator = " | ") { ...@@ -18,7 +18,7 @@ function theme_link($separator = " | ") {
"<A HREF=\"submit.php\">". t("submit") ."</A>", "<A HREF=\"submit.php\">". t("submit") ."</A>",
"<A HREF=\"module.php?mod=diary\">". t("diary") ."</A>", "<A HREF=\"module.php?mod=diary\">". t("diary") ."</A>",
"<A HREF=\"account.php\">". t("account") ."</A>", "<A HREF=\"account.php\">". t("account") ."</A>",
"<A HREF=\"module.php?mod=book\">". t("help") ."</A>"); "<A HREF=\"module.php?mod=book\">". t("handbook") ."</A>");
return implode($separator, $links); return implode($separator, $links);
} }
...@@ -80,7 +80,7 @@ function theme_blocks($region, $theme) { ...@@ -80,7 +80,7 @@ function theme_blocks($region, $theme) {
switch (strrchr($PHP_SELF, "/")) { switch (strrchr($PHP_SELF, "/")) {
case "/node.php": case "/node.php":
if ($region != "left") { if ($region != "left") {
if ($user->id) $node = db_fetch_object(db_query("SELECT * FROM nodes WHERE nid = '$id'")); if ($user->id) $node = db_fetch_object(db_query("SELECT * FROM node WHERE nid = '$id'"));
if ($node->status == $status[queued]) theme_moderation_results($theme, $node); if ($node->status == $status[queued]) theme_moderation_results($theme, $node);
// else theme_new_headlines($theme); // else theme_new_headlines($theme);
} }
...@@ -118,7 +118,7 @@ function theme_moderation_results($theme, $node) { ...@@ -118,7 +118,7 @@ function theme_moderation_results($theme, $node) {
// depricated -> new block strategy // depricated -> new block strategy
// //
function theme_new_headlines($theme, $num = 10) { function theme_new_headlines($theme, $num = 10) {
$result = db_query("SELECT nid, title FROM nodes WHERE status = 2 AND type = 'story' ORDER BY nid DESC LIMIT $num"); $result = db_query("SELECT nid, title FROM node WHERE status = 2 AND type = 'story' ORDER BY nid DESC LIMIT $num");
while ($node = db_fetch_object($result)) $content .= "<LI><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></LI>\n"; while ($node = db_fetch_object($result)) $content .= "<LI><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></LI>\n";
$theme->box(t("Latest headlines"), $content); $theme->box(t("Latest headlines"), $content);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
$date = ($date > 0) ? $date : time(); $date = ($date > 0) ? $date : time();
// Perform query: // Perform query:
$result = db_query("SELECT n.*, s.*, u.userid, COUNT(c.lid) AS comments FROM nodes n LEFT JOIN story s ON n.nid = s.node LEFT JOIN comments c ON n.nid = c.lid LEFT JOIN users u ON n.author = u.id WHERE n.status = '$status[posted]' AND n.type = 'story' ". ($section ? "AND s.section = '$section' " : "") ."AND n.timestamp <= $date GROUP BY n.nid ORDER BY n.timestamp DESC LIMIT $number"); $result = db_query("SELECT n.*, s.*, u.userid, COUNT(c.lid) AS comments FROM node n LEFT JOIN story s ON n.nid = s.nid LEFT JOIN comments c ON n.nid = c.lid LEFT JOIN users u ON n.author = u.id WHERE n.status = '$status[posted]' AND n.type = 'story' ". ($section ? "AND s.section = '$section' " : "") ."AND n.timestamp <= $date GROUP BY n.nid ORDER BY n.timestamp DESC LIMIT $number");
// Display nodes: // Display nodes:
$theme->header(); $theme->header();
......
...@@ -59,7 +59,7 @@ function account_blocks($id) { ...@@ -59,7 +59,7 @@ function account_blocks($id) {
} }
function account_nodes($id) { function account_nodes($id) {
$result = db_query("SELECT * FROM nodes WHERE author = $id ORDER BY timestamp DESC"); $result = db_query("SELECT * FROM node WHERE author = $id ORDER BY timestamp DESC");
while ($node = db_fetch_object($result)) { while ($node = db_fetch_object($result)) {
$output .= "<LI><A HREF=\"node.php?id=$node->nid\">$node->title</A> ($node->type)</LI>\n"; $output .= "<LI><A HREF=\"node.php?id=$node->nid\">$node->title</A> ($node->type)</LI>\n";
} }
......
...@@ -53,7 +53,7 @@ class backend { ...@@ -53,7 +53,7 @@ class backend {
$url = parse_url($this->file); $url = parse_url($this->file);
// Retrieve data from website: // Retrieve data from website:
$fp = fsockopen($url[host], ($url[port] ? $url[port] : 80), &$errno, &$errstr, $timout); $fp = fsockopen($url[host], ($url[port] ? $url[port] : 80), $errno, $errstr, $timout);
if ($fp) { if ($fp) {
// Request data via URL: // Request data via URL:
......
...@@ -29,7 +29,7 @@ function ban_help() { ...@@ -29,7 +29,7 @@ function ban_help() {
} }
function ban_admin_new($mask, $category, $reason) { function ban_admin_new($mask, $category, $reason) {
ban_add($mask, $category, $reason, &$message); ban_add($mask, $category, $reason, $message);
$output .= "$message\n"; $output .= "$message\n";
print $output; print $output;
} }
......
...@@ -19,8 +19,8 @@ function Book($nid, $userid, $title, $body, $parent, $weight, $timestamp) { ...@@ -19,8 +19,8 @@ function Book($nid, $userid, $title, $body, $parent, $weight, $timestamp) {
function book_navigation($node) { function book_navigation($node) {
if ($node->nid) { if ($node->nid) {
$next = db_fetch_object(db_query("SELECT n.nid, n.title FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE b.parent = '$node->parent' AND b.weight > $node->weight ORDER BY b.weight ASC")); $next = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = '$node->parent' AND b.weight > $node->weight ORDER BY b.weight ASC"));
$prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE b.parent = '$node->parent' AND b.weight < $node->weight ORDER BY b.weight DESC")); $prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = '$node->parent' AND b.weight < $node->weight ORDER BY b.weight DESC"));
} }
$output .= "<HR>"; $output .= "<HR>";
...@@ -62,7 +62,7 @@ function book_view($node, $page = 1) { ...@@ -62,7 +62,7 @@ function book_view($node, $page = 1) {
function book_find($keys) { function book_find($keys) {
global $status, $user; global $status, $user;
$find = array(); $find = array();
$result = db_query("SELECT n.*, u.userid FROM nodes n LEFT JOIN book b ON n.nid = b.node LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20"); $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20");
while ($node = db_fetch_object($result)) { while ($node = db_fetch_object($result)) {
array_push($find, array("title" => check_output($node->title), "link" => (user_access($user, "book") ? "admin.php?mod=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp)); array_push($find, array("title" => check_output($node->title), "link" => (user_access($user, "book") ? "admin.php?mod=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp));
} }
...@@ -77,7 +77,7 @@ function book_search() { ...@@ -77,7 +77,7 @@ function book_search() {
function book_toc($parent = 0, $offset = 0, $toc = array()) { function book_toc($parent = 0, $offset = 0, $toc = array()) {
global $status; global $status;
$result = db_query("SELECT n.*, b.* FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight"); $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
while ($node = db_fetch_object($result)) { while ($node = db_fetch_object($result)) {
$toc[$node->nid] = ($offset ? $offset : "") ."". ++$number .". $node->title"; $toc[$node->nid] = ($offset ? $offset : "") ."". ++$number .". $node->title";
$toc = book_toc($node->nid, ($offset ? "$offset." : "") ."$number.", $toc); $toc = book_toc($node->nid, ($offset ? "$offset." : "") ."$number.", $toc);
...@@ -165,7 +165,7 @@ function book_delete($id) { ...@@ -165,7 +165,7 @@ function book_delete($id) {
function book_overview($parent = "", $offset = "") { function book_overview($parent = "", $offset = "") {
global $PHP_SELF, $status; global $PHP_SELF, $status;
$result = db_query("SELECT n.*, b.* FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight"); $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
$output .= "<DL>"; $output .= "<DL>";
while ($node = db_fetch_object($result)) { while ($node = db_fetch_object($result)) {
...@@ -182,7 +182,7 @@ function book_overview($parent = "", $offset = "") { ...@@ -182,7 +182,7 @@ function book_overview($parent = "", $offset = "") {
function book_history() { function book_history() {
global $status; global $status;
$result = db_query("SELECT n.*, b.* FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE n.type = 'book' AND n.status != '$status[expired]' ORDER BY n.timestamp DESC"); $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status != '$status[expired]' ORDER BY n.timestamp DESC");
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>node</TH><TH>status</TH><TH>date</TH><TH COLSPAN=\"3\">operations</TH></TR>\n"; $output .= " <TR><TH>node</TH><TH>status</TH><TH>date</TH><TH COLSPAN=\"3\">operations</TH></TR>\n";
......
...@@ -19,8 +19,8 @@ function Book($nid, $userid, $title, $body, $parent, $weight, $timestamp) { ...@@ -19,8 +19,8 @@ function Book($nid, $userid, $title, $body, $parent, $weight, $timestamp) {
function book_navigation($node) { function book_navigation($node) {
if ($node->nid) { if ($node->nid) {
$next = db_fetch_object(db_query("SELECT n.nid, n.title FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE b.parent = '$node->parent' AND b.weight > $node->weight ORDER BY b.weight ASC")); $next = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = '$node->parent' AND b.weight > $node->weight ORDER BY b.weight ASC"));
$prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE b.parent = '$node->parent' AND b.weight < $node->weight ORDER BY b.weight DESC")); $prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE b.parent = '$node->parent' AND b.weight < $node->weight ORDER BY b.weight DESC"));
} }
$output .= "<HR>"; $output .= "<HR>";
...@@ -62,7 +62,7 @@ function book_view($node, $page = 1) { ...@@ -62,7 +62,7 @@ function book_view($node, $page = 1) {
function book_find($keys) { function book_find($keys) {
global $status, $user; global $status, $user;
$find = array(); $find = array();
$result = db_query("SELECT n.*, u.userid FROM nodes n LEFT JOIN book b ON n.nid = b.node LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20"); $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid LEFT JOIN users u ON n.author = u.id WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20");
while ($node = db_fetch_object($result)) { while ($node = db_fetch_object($result)) {
array_push($find, array("title" => check_output($node->title), "link" => (user_access($user, "book") ? "admin.php?mod=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp)); array_push($find, array("title" => check_output($node->title), "link" => (user_access($user, "book") ? "admin.php?mod=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->userid, "date" => $node->timestamp));
} }
...@@ -77,7 +77,7 @@ function book_search() { ...@@ -77,7 +77,7 @@ function book_search() {
function book_toc($parent = 0, $offset = 0, $toc = array()) { function book_toc($parent = 0, $offset = 0, $toc = array()) {
global $status; global $status;
$result = db_query("SELECT n.*, b.* FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight"); $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
while ($node = db_fetch_object($result)) { while ($node = db_fetch_object($result)) {
$toc[$node->nid] = ($offset ? $offset : "") ."". ++$number .". $node->title"; $toc[$node->nid] = ($offset ? $offset : "") ."". ++$number .". $node->title";
$toc = book_toc($node->nid, ($offset ? "$offset." : "") ."$number.", $toc); $toc = book_toc($node->nid, ($offset ? "$offset." : "") ."$number.", $toc);
...@@ -165,7 +165,7 @@ function book_delete($id) { ...@@ -165,7 +165,7 @@ function book_delete($id) {
function book_overview($parent = "", $offset = "") { function book_overview($parent = "", $offset = "") {
global $PHP_SELF, $status; global $PHP_SELF, $status;
$result = db_query("SELECT n.*, b.* FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight"); $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
$output .= "<DL>"; $output .= "<DL>";
while ($node = db_fetch_object($result)) { while ($node = db_fetch_object($result)) {
...@@ -182,7 +182,7 @@ function book_overview($parent = "", $offset = "") { ...@@ -182,7 +182,7 @@ function book_overview($parent = "", $offset = "") {
function book_history() { function book_history() {
global $status; global $status;
$result = db_query("SELECT n.*, b.* FROM nodes n LEFT JOIN book b ON n.nid = b.node WHERE n.type = 'book' AND n.status != '$status[expired]' ORDER BY n.timestamp DESC"); $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid AND n.lid = b.lid WHERE n.type = 'book' AND n.status != '$status[expired]' ORDER BY n.timestamp DESC");
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>node</TH><TH>status</TH><TH>date</TH><TH COLSPAN=\"3\">operations</TH></TR>\n"; $output .= " <TR><TH>node</TH><TH>status</TH><TH>date</TH><TH COLSPAN=\"3\">operations</TH></TR>\n";
......
...@@ -33,10 +33,10 @@ function cron_display() { ...@@ -33,10 +33,10 @@ function cron_display() {
// Generate output: // Generate output:
$output .= "<FORM ACTION=\"admin.php?mod=cron\" METHOD=\"post\">\n"; $output .= "<FORM ACTION=\"admin.php?mod=cron\" METHOD=\"post\">\n";
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>module</TH><TH>period</TH><TH>last execution</TH><TH>operations</TH></TR>\n"; $output .= " <TR><TH>module</TH><TH>period</TH><TH>last run</TH><TH>next run</TH><TH>operations</TH></TR>\n";
while ($cron = db_fetch_object($result)) { while ($cron = db_fetch_object($result)) {
foreach ($intervals as $value) $period .= "<OPTION VALUE=\"$value\"". (($cron->scheduled == $value) ? " SELECTED" : "") .">every ". format_interval($value) ."</OPTION>\n"; foreach ($intervals as $value) $period .= "<OPTION VALUE=\"$value\"". (($cron->scheduled == $value) ? " SELECTED" : "") .">every ". format_interval($value) ."</OPTION>\n";
$output .= " <TR><TD>". check_output($cron->module) ."</TD><TD><SELECT NAME=\"edit[$cron->module]\">$period</SELECT></TD><TD ALIGN=\"center\">". ($cron->timestamp ? format_interval(time() - $cron->timestamp) ." ago" : "never" )."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=cron&op=execute&name=$cron->module\">execute</A></TD></TR>\n"; $output .= " <TR><TD>". check_output($cron->module) ."</TD><TD><SELECT NAME=\"edit[$cron->module]\">$period</SELECT></TD><TD>". ($cron->timestamp ? format_interval(time() - $cron->timestamp) ." ago" : "never") ."</TD><TD>". ($cron->timestamp ? format_interval($cron->timestamp + $cron->scheduled - time()) ." left" : "never") ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=cron&op=execute&name=$cron->module\">execute</A></TD></TR>\n";
unset($period); unset($period);
} }
$output .= "</TABLE>\n"; $output .= "</TABLE>\n";
......
...@@ -207,7 +207,7 @@ function headline_export($uri) { ...@@ -207,7 +207,7 @@ function headline_export($uri) {
print " <description>$site_name</description>\n"; print " <description>$site_name</description>\n";
print "</channel>\n"; print "</channel>\n";
$result = db_query("SELECT * FROM nodes WHERE type = 'story' AND status = '$status[posted]' ORDER BY timestamp DESC LIMIT 10"); $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)) { while ($node = db_fetch_object($result)) {
print "<item>\n"; print "<item>\n";
......
...@@ -32,7 +32,7 @@ function headlineRSS10_export($uri) { ...@@ -32,7 +32,7 @@ function headlineRSS10_export($uri) {
print " <items>\n"; print " <items>\n";
print " <rdf:Seq>\n"; print " <rdf:Seq>\n";
$result = db_query("SELECT * FROM nodes WHERE type = 'story' AND status = '$status[posted]' ORDER BY timestamp DESC LIMIT 10"); $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)) { while ($node = db_fetch_object($result)) {
print " <rdf:li resource=\"". $site_url ."node.php?id=$node->nid\" />\n"; print " <rdf:li resource=\"". $site_url ."node.php?id=$node->nid\" />\n";
......
...@@ -12,12 +12,12 @@ function moderation_menu() { ...@@ -12,12 +12,12 @@ function moderation_menu() {
function moderation_count() { function moderation_count() {
global $status; global $status;
$result = db_query("SELECT COUNT(nid) FROM nodes WHERE status = '$status[queued]'"); $result = db_query("SELECT COUNT(nid) FROM node WHERE status = '$status[queued]'");
return ($result) ? db_result($result, 0) : 0; return ($result) ? db_result($result, 0) : 0;
} }
function moderation_score($id) { function moderation_score($id) {
$result = db_query("SELECT score FROM nodes WHERE nid = '$id'"); $result = db_query("SELECT score FROM node WHERE nid = '$id'");
return ($result) ? db_result($result, 0) : 0; return ($result) ? db_result($result, 0) : 0;
} }
...@@ -26,7 +26,7 @@ function moderation_vote($id, $vote) { ...@@ -26,7 +26,7 @@ function moderation_vote($id, $vote) {
if (!user_get($user, "history", "n$id")) { if (!user_get($user, "history", "n$id")) {
// Update submission's score- and votes-field: // Update submission's score- and votes-field:
db_query("UPDATE nodes SET score = score $vote, votes = votes + 1 WHERE nid = $id"); db_query("UPDATE node SET score = score $vote, votes = votes + 1 WHERE nid = $id");
// Update user's history record: // Update user's history record:
$user = user_set($user, "history", "n$id", $vote); $user = user_set($user, "history", "n$id", $vote);
...@@ -51,7 +51,7 @@ function moderation_vote($id, $vote) { ...@@ -51,7 +51,7 @@ function moderation_vote($id, $vote) {
function moderation_overview() { function moderation_overview() {
global $status, $theme, $user; global $status, $theme, $user;
$result = db_query("SELECT n.*, u.userid FROM nodes n LEFT JOIN users u ON n.author = u.id WHERE n.status = '$status[queued]'"); $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.status = '$status[queued]'");
$content .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n"; $content .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
$content .= " <TR BGCOLOR=\"$bgcolor1\"><TH>". t("Subject") ."</TH><TH>". t("Author") ."</TH><TH>". t("Type") ."</TH><TH>". t("Score") ."</TH></TR>\n"; $content .= " <TR BGCOLOR=\"$bgcolor1\"><TH>". t("Subject") ."</TH><TH>". t("Author") ."</TH><TH>". t("Type") ."</TH><TH>". t("Score") ."</TH></TR>\n";
......
...@@ -16,12 +16,12 @@ function rating_cron() { ...@@ -16,12 +16,12 @@ function rating_cron() {
while ($rating = db_fetch_object($r1)) { while ($rating = db_fetch_object($r1)) {
unset($bonus); unset($votes); unset($score); unset($value); unset($weight); unset($bonus); unset($votes); unset($score); unset($value); unset($weight);
$r2 = db_query("SELECT COUNT(nid) AS number FROM nodes WHERE author = '$rating->id' AND (". time() ." - timestamp < $period) AND status = '$status[posted]'"); $r2 = db_query("SELECT COUNT(nid) AS number FROM node WHERE author = '$rating->id' AND (". time() ." - timestamp < $period) AND status = '$status[posted]'");
if ($story = db_fetch_object($r2)) { if ($story = db_fetch_object($r2)) {
$bonus += $story->number / 2; $bonus += $story->number / 2;
} }
$r3 = db_query("SELECT COUNT(nid) AS number FROM nodes WHERE author = '$rating->id' AND (". time() ." - timestamp < $period) AND status = '$status[dumped]'"); $r3 = db_query("SELECT COUNT(nid) AS number FROM node WHERE author = '$rating->id' AND (". time() ." - timestamp < $period) AND status = '$status[dumped]'");
if ($story = db_fetch_object($r3)) { if ($story = db_fetch_object($r3)) {
$bonus -= $story->number / 2; $bonus -= $story->number / 2;
} }
......
...@@ -22,16 +22,16 @@ function Story($userid, $title, $abstract, $body, $section, $timestamp) { $th ...@@ -22,16 +22,16 @@ function Story($userid, $title, $abstract, $body, $section, $timestamp) { $th