- updated/improved discussion engine: it needs additional fine-tuning

though but I think this is stable enough for public consumption and
  real-life testing.
   ==> a first big step towards a flexible comment engine.

IMPORTANT:
  - Required theme updatins:

    UnConeD: check your $theme->controls() as I added a very, very
             dummy implementation

  - Required database updates:

    alter table users modify mode tinyint(1) DEFAULT '' NOT NULL;
    alter table comments change sid lid int(6) DEFAULT '0' NOT NULL;
    alter table comments add link varchar(16) DEFAULT '' NOT NULL;
    update comments set link = 'story';
3-00
Dries Buytaert 2001-01-20 12:20:31 +00:00
parent 53b92a614a
commit 2952d16f78
19 changed files with 574 additions and 269 deletions

View File

@ -136,45 +136,39 @@ function account_user_save($edit) {
} }
function account_site_edit() { function account_site_edit() {
global $theme, $themes, $user; global $cmodes, $corder, $theme, $themes, $user;
if ($user->id) { if ($user->id) {
$output .= "<FORM ACTION=\"account.php\" METHOD=\"post\">\n"; $output .= "<FORM ACTION=\"account.php\" METHOD=\"post\">\n";
$output .= "<B>Theme:</B><BR>\n"; $output .= "<B>Theme:</B><BR>\n";
foreach ($themes as $key=>$value) { foreach ($themes as $key=>$value) {
$options1 .= " <OPTION VALUE=\"$key\"". (($user->theme == $key) ? " SELECTED" : "") .">$key - $value[1]</OPTION>\n"; $options1 .= " <OPTION VALUE=\"$key\"". (($user->theme == $key) ? " SELECTED" : "") .">$key - $value[1]</OPTION>\n";
} }
$output .= "<SELECT NAME=\"edit[theme]\">\n$options1</SELECT><BR>\n"; $output .= "<SELECT NAME=\"edit[theme]\">\n$options1</SELECT><BR>\n";
$output .= "<I>Selecting a different theme will change the look and feel of the site.</I><P>\n"; $output .= "<I>Selecting a different theme will change the look and feel of the site.</I><P>\n";
$output .= "<B>Timezone:</B><BR>\n"; $output .= "<B>Timezone:</B><BR>\n";
$date = time() - date("Z"); $date = time() - date("Z");
for ($zone = -43200; $zone <= 46800; $zone += 3600) { for ($zone = -43200; $zone <= 46800; $zone += 3600) {
$options2 .= " <OPTION VALUE=\"$zone\"". (($user->timezone == $zone) ? " SELECTED" : "") .">". date("l, F dS, Y - h:i A", $date + $zone) ." (GMT ". $zone / 3600 .")</OPTION>\n"; $options2 .= " <OPTION VALUE=\"$zone\"". (($user->timezone == $zone) ? " SELECTED" : "") .">". date("l, F dS, Y - h:i A", $date + $zone) ." (GMT ". $zone / 3600 .")</OPTION>\n";
} }
$output .= "<SELECT NAME=\"edit[timezone]\">\n$options2</SELECT><BR>\n"; $output .= "<SELECT NAME=\"edit[timezone]\">\n$options2</SELECT><BR>\n";
$output .= "<I>Select what time you currently have and your timezone settings will be set appropriate.</I><P>\n"; $output .= "<I>Select what time you currently have and your timezone settings will be set appropriate.</I><P>\n";
$output .= "<B>Maximum number of stories:</B><BR>\n"; $output .= "<B>Maximum number of stories:</B><BR>\n";
for ($stories = 10; $stories <= 30; $stories += 5) { for ($stories = 10; $stories <= 30; $stories += 5) {
$options3 .= "<OPTION VALUE=\"$stories\"". (($user->stories == $stories) ? " SELECTED" : "") .">$stories</OPTION>\n"; $options3 .= "<OPTION VALUE=\"$stories\"". (($user->stories == $stories) ? " SELECTED" : "") .">$stories</OPTION>\n";
} }
$output .= "<SELECT NAME=\"edit[stories]\">\n$options3</SELECT><BR>\n"; $output .= "<SELECT NAME=\"edit[stories]\">\n$options3</SELECT><BR>\n";
$output .= "<I>The maximum number of stories that will be displayed on the main page.</I><P>\n"; $output .= "<I>The maximum number of stories that will be displayed on the main page.</I><P>\n";
$options = "<OPTION VALUE=\"nested\"". ($user->mode == "nested" ? " SELECTED" : "") .">Nested</OPTION>"; foreach ($cmodes as $key=>$value) {
$options .= "<OPTION VALUE=\"flat\"". ($user->mode == "flat" ? " SELECTED" : "") .">Flat</OPTION>"; $options4 .= "<OPTION VALUE=\"$key\"". ($user->mode == $key ? " SELECTED" : "") .">$value</OPTION>\n";
$options .= "<OPTION VALUE=\"threaded\"". ($user->mode == "threaded" ? " SELECTED" : "") .">Threaded</OPTION>"; }
$output .= "<B>Comment display mode:</B><BR>\n"; $output .= "<B>Comment display mode:</B><BR>\n";
$output .= "<SELECT NAME=\"edit[mode]\">$options</SELECT><P>\n"; $output .= "<SELECT NAME=\"edit[mode]\">$options4</SELECT><P>\n";
$options = "<OPTION VALUE=\"0\"". ($user->sort == 0 ? " SELECTED" : "") .">Oldest first</OPTION>"; foreach ($corder as $key=>$value) {
$options .= "<OPTION VALUE=\"1\"". ($user->sort == 1 ? " SELECTED" : "") .">Newest first</OPTION>"; $options5 .= "<OPTION VALUE=\"$key\"". ($user->sort == $key ? " SELECTED" : "") .">$value</OPTION>\n";
$options .= "<OPTION VALUE=\"2\"". ($user->sort == 2 ? " SELECTED" : "") .">Highest scoring first</OPTION>"; }
$output .= "<B>Comment sort order:</B><BR>\n"; $output .= "<B>Comment sort order:</B><BR>\n";
$output .= "<SELECT NAME=\"edit[sort]\">$options</SELECT><P>\n"; $output .= "<SELECT NAME=\"edit[sort]\">$options5</SELECT><P>\n";
$options = "<OPTION VALUE=\"-1\"". ($user->threshold == -1 ? " SELECTED" : "") .">-1: Display uncut and raw comments.</OPTION>"; $options = "<OPTION VALUE=\"-1\"". ($user->threshold == -1 ? " SELECTED" : "") .">-1: Display uncut and raw comments.</OPTION>";
$options .= "<OPTION VALUE=\"0\"". ($user->threshold == 0 ? " SELECTED" : "") .">0: Display almost all comments.</OPTION>"; $options .= "<OPTION VALUE=\"0\"". ($user->threshold == 0 ? " SELECTED" : "") .">0: Display almost all comments.</OPTION>";
$options .= "<OPTION VALUE=\"1\"". ($user->threshold == 1 ? " SELECTED" : "") .">1: Display almost no anonymous comments.</OPTION>"; $options .= "<OPTION VALUE=\"1\"". ($user->threshold == 1 ? " SELECTED" : "") .">1: Display almost no anonymous comments.</OPTION>";
@ -185,8 +179,6 @@ function account_site_edit() {
$output .= "<B>Comment threshold:</B><BR>\n"; $output .= "<B>Comment threshold:</B><BR>\n";
$output .= "<SELECT NAME=\"edit[threshold]\">$options</SELECT><BR>\n"; $output .= "<SELECT NAME=\"edit[threshold]\">$options</SELECT><BR>\n";
$output .= "<I>Comments that scored less than this setting will be ignored. Anonymous comments start at 0, comments of people logged on start at 1 and moderators can add and subtract points.</I><P>\n"; $output .= "<I>Comments that scored less than this setting will be ignored. Anonymous comments start at 0, comments of people logged on start at 1 and moderators can add and subtract points.</I><P>\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save site settings\"><BR>\n"; $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save site settings\"><BR>\n";
$output .= "</FORM>\n"; $output .= "</FORM>\n";
@ -289,12 +281,12 @@ function account_user($uname) {
$block1 .= " <TR><TD ALIGN=\"right\"><B>Bio:</B></TD><TD>". format_data($account->bio) ."</TD></TR>\n"; $block1 .= " <TR><TD ALIGN=\"right\"><B>Bio:</B></TD><TD>". format_data($account->bio) ."</TD></TR>\n";
$block1 .= "</TABLE>\n"; $block1 .= "</TABLE>\n";
$result = db_query("SELECT c.cid, c.pid, c.sid, c.subject, c.timestamp, s.subject AS story FROM comments c LEFT JOIN users u ON u.id = c.author LEFT JOIN stories s ON s.id = c.sid WHERE u.userid = '$uname' AND s.status = 2 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, s.subject AS story FROM comments c LEFT JOIN users u ON u.id = c.author LEFT JOIN stories s ON s.id = c.lid WHERE u.userid = '$uname' AND s.status = 2 c.link = 'story' 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>Comment:</B></TD><TD><A HREF=\"discussion.php?id=$comment->sid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD></TR>\n"; $block2 .= " <TR><TD ALIGN=\"right\"><B>Comment:</B></TD><TD><A HREF=\"story.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>Date:</B></TD><TD>". format_date($comment->timestamp) ."</TD></TR>\n"; $block2 .= " <TR><TD ALIGN=\"right\"><B>Date:</B></TD><TD>". format_date($comment->timestamp) ."</TD></TR>\n";
$block2 .= " <TR><TD ALIGN=\"right\"><B>Story:</B></TD><TD><A HREF=\"discussion.php?id=$comment->sid\">". check_output($comment->story) ."</A></TD></TR>\n"; $block2 .= " <TR><TD ALIGN=\"right\"><B>Story:</B></TD><TD><A HREF=\"story.php?id=$comment->lid\">". check_output($comment->story) ."</A></TD></TR>\n";
$block2 .= "</TABLE>\n"; $block2 .= "</TABLE>\n";
$block2 .= "<P>\n"; $block2 .= "<P>\n";
$comments++; $comments++;
@ -441,15 +433,15 @@ function account_track_comments() {
$msg = "<P>This page might be helpful in case you want to keep track of your recent comments in any of the current discussions. You are presented an overview of your comments in each of the stories you participated in along with the number of replies each comment got.\n<P>\n"; $msg = "<P>This page might be helpful in case you want to keep track of your recent comments in any of the current discussions. You are presented an overview of your comments in each of the stories you participated in along with the number of replies each comment got.\n<P>\n";
$sresult = db_query("SELECT s.id, s.subject, COUNT(s.id) as count FROM comments c LEFT JOIN stories s ON c.sid = s.id WHERE c.author = $user->id GROUP BY s.id DESC LIMIT 5"); $sresult = db_query("SELECT s.id, s.subject, COUNT(s.id) as count FROM comments c LEFT JOIN stories s ON c.lid = s.id WHERE c.author = $user->id GROUP BY s.id DESC LIMIT 5");
while ($story = db_fetch_object($sresult)) { while ($story = db_fetch_object($sresult)) {
$output .= "<LI>". format_plural($story->count, comment, comments) ." attached to story `<A HREF=\"discussion.php?id=$story->id\">". check_output($story->subject) ."</A>`:</LI>\n"; $output .= "<LI>". format_plural($story->count, comment, comments) ." attached to story `<A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A>`:</LI>\n";
$output .= " <UL>\n"; $output .= " <UL>\n";
$cresult = db_query("SELECT * FROM comments WHERE author = $user->id AND sid = $story->id"); $cresult = db_query("SELECT * FROM comments WHERE author = $user->id AND lid = $story->id");
while ($comment = db_fetch_object($cresult)) { while ($comment = db_fetch_object($cresult)) {
$output .= " <LI><A HREF=\"discussion.php?id=$story->id&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A> - replies: ". discussion_num_replies($comment->cid) ." - score: ". discussion_score($comment) ."</LI>\n"; $output .= " <LI><A HREF=\"story.php?id=$story->id&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A> - replies: ". comment_num_replies($comment->cid) ." - score: ". comment_score($comment) ."</LI>\n";
} }
$output .= " </UL>\n"; $output .= " </UL>\n";
} }
@ -466,11 +458,11 @@ function account_track_stories() {
$msg = "<P>This page might be helpful in case you want to keep track of the stories you contributed. You are presented an overview of your stories along with the number of replies each story got.\n<P>\n"; $msg = "<P>This page might be helpful in case you want to keep track of the stories you contributed. You are presented an overview of your stories along with the number of replies each story got.\n<P>\n";
$result = db_query("SELECT s.id, s.subject, s.timestamp, s.category, COUNT(c.cid) as count FROM stories s LEFT JOIN comments c ON c.sid = s.id WHERE s.status = 2 AND s.author = $user->id GROUP BY s.id DESC"); $result = db_query("SELECT s.id, s.subject, s.timestamp, s.category, COUNT(c.cid) as count FROM stories s LEFT JOIN comments c ON c.lid = s.id WHERE s.status = 2 AND s.author = $user->id GROUP BY s.id DESC");
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n"; $output .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Subject:</B></TD><TD><A HREF=\"discussion.php?id=$story->id\">". check_output($story->subject) ."</A> (". format_plural($story->count, "comment", "comments") .")</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Subject:</B></TD><TD><A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A> (". format_plural($story->count, "comment", "comments") .")</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Category:</B></TD><TD><A HREF=\"search.php?category=". urlencode($story->category) ."\">". check_output($story->category) ."</A></TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Category:</B></TD><TD><A HREF=\"search.php?category=". urlencode($story->category) ."\">". check_output($story->category) ."</A></TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Date:</B></TD><TD>". format_date($story->timestamp) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Date:</B></TD><TD>". format_date($story->timestamp) ."</TD></TR>\n";
$output .= "</TABLE>\n"; $output .= "</TABLE>\n";
@ -485,13 +477,13 @@ function account_track_stories() {
function account_track_site() { function account_track_site() {
global $theme, $user, $site_name; global $theme, $user, $site_name;
$result1 = db_query("SELECT c.cid, c.pid, c.sid, c.subject, u.userid, s.subject AS story FROM comments c LEFT JOIN users u ON u.id = c.author LEFT JOIN stories s ON s.id = c.sid WHERE s.status = 2 ORDER BY cid DESC LIMIT 10"); $result1 = db_query("SELECT c.cid, c.pid, c.lid, c.subject, u.userid, s.subject AS story FROM comments c LEFT JOIN users u ON u.id = c.author LEFT JOIN stories s ON s.id = c.lid WHERE s.status = 2 ORDER BY cid DESC LIMIT 10");
while ($comment = db_fetch_object($result1)) { while ($comment = db_fetch_object($result1)) {
$block1 .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n"; $block1 .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
$block1 .= " <TR><TD ALIGN=\"right\"><B>Comment:</B></TD><TD><A HREF=\"discussion.php?id=$comment->sid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD></TR>\n"; $block1 .= " <TR><TD ALIGN=\"right\"><B>Comment:</B></TD><TD><A HREF=\"story.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD></TR>\n";
$block1 .= " <TR><TD ALIGN=\"right\"><B>Author:</B></TD><TD>". format_username($comment->userid) ."</TD></TR>\n"; $block1 .= " <TR><TD ALIGN=\"right\"><B>Author:</B></TD><TD>". format_username($comment->userid) ."</TD></TR>\n";
$block1 .= " <TR><TD ALIGN=\"right\"><B>Story:</B></TD><TD><A HREF=\"discussion.php?id=$comment->sid\">". check_output($comment->story) ."</A></TD></TR>\n"; $block1 .= " <TR><TD ALIGN=\"right\"><B>Story:</B></TD><TD><A HREF=\"story.php?id=$comment->lid\">". check_output($comment->story) ."</A></TD></TR>\n";
$block1 .= "</TABLE>\n"; $block1 .= "</TABLE>\n";
$block1 .= "<P>\n"; $block1 .= "<P>\n";
} }

View File

@ -57,7 +57,8 @@ CREATE TABLE channel (
CREATE TABLE comments ( CREATE TABLE comments (
cid int(6) DEFAULT '0' NOT NULL auto_increment, cid int(6) DEFAULT '0' NOT NULL auto_increment,
pid int(6) DEFAULT '0' NOT NULL, pid int(6) DEFAULT '0' NOT NULL,
sid 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, author int(6) DEFAULT '0' NOT NULL,
subject varchar(64) DEFAULT '' NOT NULL, subject varchar(64) DEFAULT '' NOT NULL,
comment text NOT NULL, comment text NOT NULL,
@ -137,7 +138,7 @@ CREATE TABLE users (
fake_email varchar(60) DEFAULT '' NOT NULL, fake_email varchar(60) DEFAULT '' NOT NULL,
url varchar(100) DEFAULT '' NOT NULL, url varchar(100) DEFAULT '' NOT NULL,
stories tinyint(2) DEFAULT '10', stories tinyint(2) DEFAULT '10',
mode varchar(10) DEFAULT '', mode tinyint(1) DEFAULT '0',
sort tinyint(1) DEFAULT '0', sort tinyint(1) DEFAULT '0',
threshold tinyint(1) DEFAULT '0', threshold tinyint(1) DEFAULT '0',
bio tinytext NOT NULL, bio tinytext NOT NULL,

View File

@ -1,5 +1,15 @@
<? <?
// Security check:
if (strstr($id, " ") || strstr($pid, " ") || strstr($lid, " ") || strstr($mode, " ") || strstr($order, " ") || strstr($threshold, " ")) {
watchdog("error", "discussion: attempt to provide malicious input through URI");
exit();
}
$cmodes = array(1 => "List - min", 2 => "List - max", 3 => "Threaded - min", 4 => "Threaded - max");
$corder = array(1 => "Date - new", 2 => "Date - old", 3 => "Rate - high");
$link = ($mod) ? $mod : substr($PHP_SELF, 1, strlen($PHP_SELF) - 5);
class Comment { class Comment {
function Comment($userid, $subject, $comment, $timestamp, $url, $fake_email, $score, $votes, $cid) { function Comment($userid, $subject, $comment, $timestamp, $url, $fake_email, $score, $votes, $cid) {
$this->userid = $userid; $this->userid = $userid;
@ -14,4 +24,365 @@ class Comment {
} }
} }
?> function comment_moderate($moderate) {
global $user, $comment_votes;
if ($user->id && $moderate) {
$none = $comment_votes[key($comment_votes)];
foreach ($moderate as $id=>$vote) {
if ($vote != $comment_votes[$none] && !user_getHistory($user->history, "c$id")) {
// Update the comment's score:
$result = db_query("UPDATE comments SET score = score $vote, votes = votes + 1 WHERE cid = $id");
// Update the user's history:
user_setHistory($user, "c$id", $vote);
}
}
}
}
function comment_settings($mode, $order, $threshold) {
global $user;
if ($user->id) {
$data[mode] = $mode;
$data[sort] = $order;
$data[threshold] = $threshold;
user_save($data, $user->id);
}
}
function comment_reply($pid, $id) {
global $allowed_html, $link, $theme, $user;
// Extract parent-information/data:
if ($pid) {
$item = db_fetch_object(db_query("SELECT comments.*, users.userid FROM comments LEFT JOIN users ON comments.author = users.id WHERE comments.cid = $pid"));
$theme->comment(new Comment($item->userid, $item->subject, $item->comment, $item->timestamp, $item->url, $item->fake_email, comment_score($comment), $comment->votes, $item->cid), "reply to this comment");
}
else {
$item = db_fetch_object(db_query("SELECT stories.*, users.userid FROM stories LEFT JOIN users ON stories.author = users.id WHERE stories.status != 0 AND stories.id = $id"));
$theme->article($item, "");
}
// Build reply form:
$output .= "<FORM ACTION=\"". comment_uri() ."\" METHOD=\"post\">\n";
// Name field:
$output .= "<P>\n";
$output .= " <B>Your name:</B><BR>\n";
$output .= format_username($user->userid);
$output .= "</P>\n";
// Subject field:
$output .= "<P>\n";
$output .= " <B>Subject:</B><BR>\n";
$output .= " <INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" MAXLENGTH=\"60\">\n";
$output .= "</P>\n";
// Comment field:
$output .= "<P>\n";
$output .= " <B>Comment:</B><BR>\n";
$output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"comment\">". check_textarea($user->signature) ."</TEXTAREA><BR>\n";
$output .= " <SMALL><I>Allowed HTML tags: ". htmlspecialchars($allowed_html) .".</I></SMALL>\n";
$output .= "</P>\n";
// Preview button:
$output .= "<P>\n";
$output .= " <SMALL><I>You must preview at least once before you can submit:</I></SMALL><BR>\n";
$output .= " <INPUT TYPE=\"hidden\" NAME=\"pid\" VALUE=\"$pid\">\n";
$output .= " <INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$id\">\n";
$output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview comment\"><BR>\n";
$output .= "</P>\n";
$output .= "</FORM>\n";
$theme->box("Reply", $output);
}
function comment_preview($pid, $id, $subject, $comment) {
global $allowed_html, $link, $theme, $user;
// Preview comment:
$theme->comment(new Comment($user->userid, $subject, $comment, time(), $user->url, $user->fake_email, "", "", ""), "reply to this comment");
// Build reply form:
$output .= "<FORM ACTION=\"". comment_uri() ."\" METHOD=\"post\">\n";
// Name field:
$output .= "<P>\n";
$output .= " <B>Your name:</B><BR>\n";
$output .= format_username($user->userid);
$output .= "</P>\n";
// Subject field:
$output .= "<P>\n";
$output .= " <B>Subject:</B><BR>\n";
$output .= " <INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_textfield($subject) ."\">\n";
$output .= "</P>\n";
// Comment field:
$output .= "<P>\n";
$output .= " <B>Comment:</B><BR>\n";
$output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"comment\">". check_textarea($comment) ."</TEXTAREA><BR>\n";
$output .= " <SMALL><I>Allowed HTML tags: ". htmlspecialchars($allowed_html) .".</I></SMALL>\n";
$output .= "</P>\n";
// Hidden fields:
$output .= "<INPUT TYPE=\"hidden\" NAME=\"pid\" VALUE=\"$pid\">\n";
$output .= "<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$id\">\n";
if (empty($subject)) {
$output .= "<P>\n";
$output .= " <FONT COLOR=\"red\"><B>Warning:</B></FONT> you did not supply a <U>subject</U>.\n";
$outout .= "</P>\n";
}
// Preview and submit button:
$output .= "<P>\n";
$output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview comment\">\n";
$output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Post comment\">\n";
$output .= " </FORM>\n";
$output .= "</P>\n";
$theme->box("Reply", $output);
}
function comment_post($pid, $id, $subject, $comment) {
global $theme, $link, $user;
// Check for duplicate comments:
$duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE link = '$link' AND pid = '$pid' AND lid = '$id' AND subject = '". check_input($subject) ."' AND comment = '". check_input($comment) ."'"), 0);
if ($duplicate != 0) {
watchdog("error", "discussion: attempt to insert duplicate comment");
$theme->box("duplicate comment", "duplicate comment: $duplicate");
}
else {
// Validate subject:
$subject = ($subject) ? $subject : substr($comment, 0, 29);
// Add watchdog entry:
watchdog("comment", "discussion: added comment with subject '$subject'");
// Add comment to database:
db_query("INSERT INTO comments (link, lid, pid, author, subject, comment, hostname, timestamp, score) VALUES ('". check_input($link) ."', $id, $pid, '$user->id', '". check_input($subject) ."', '". check_input($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."', '". ($user->userid ? 1 : 0) ."')");
// Compose header:
header("Location: ". comment_uri("id=$id"));
}
}
function comment_score($comment) {
$value = ($comment->votes) ? ($comment->score / $comment->votes) : (($comment->score) ? $comment->score : 0);
return ((strpos($value, ".")) ? substr($value ."00", 0, 4) : $value .".00");
}
function comment_num_replies($id, $count = 0) {
$result = db_query("SELECT COUNT(cid) FROM comments WHERE pid = $id");
return ($result) ? db_result($result, 0) : 0;
}
function comment_num_filtered($lid, $pid) {
global $user;
$threshold = ($user->id) ? $user->threshold : "0";
$pid = ($pid) ? $pid : 0;
$result = db_query("SELECT COUNT(cid) FROM comments WHERE lid = $lid AND pid = $pid AND ((votes = 0 AND score < $threshold) OR (score / votes < $threshold))");
return ($result) ? db_result($result, 0) : 0;
}
function comment_moderation($comment) {
global $comment_votes, $op, $user;
if ($op == "reply") {
$output .= "&nbsp;";
}
else if ($user->id && $user->userid != $comment->userid && !user_getHistory($user->history, "c$comment->cid")) {
$output .= "<SELECT NAME=\"moderate[$comment->cid]\">\n";
foreach ($comment_votes as $key=>$value) $output .= " <OPTION VALUE=\"$value\">$key</OPTION>\n";
$output .= "</SELECT>\n";
}
else {
$output .= "<TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"1\"><TR><TD>score:</TD><TD>". format_data($comment->score) ."</TD></TR><TR><TD>votes:</TD><TD>". format_data($comment->votes) ."</TR></TABLE>\n";
}
return $output;
}
function comment_controls($threshold, $mode, $order) {
global $REQUEST_URI;
$output .= "<FONT SIZE=\"2\">\n";
$output .= "<FORM METHOD=\"post\" ACTION=\"$REQUEST_URI\">\n";
$output .= comment_threshold($threshold);
$output .= comment_mode($mode);
$output .= comment_order($order);
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Update\">\n";
// $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Reply\">\n";
$output .= "</FORM>\n";
$output .= "</FONT>\n";
return $output;
}
function comment_threshold($threshold) {
$output .= "<SELECT NAME=\"threshold\">\n";
for ($i = -1; $i < 6; $i++) {
$output .= " <OPTION VALUE=\"$i\"". ($threshold == $i ? " SELECTED" : "") .">Threshold: $i</OPTION>";
}
$output .= "</SELECT>\n";
return $output;
}
function comment_mode($mode) {
global $cmodes;
$output .= "<SELECT NAME=\"mode\">\n";
foreach ($cmodes as $key=>$value) {
$output .= " <OPTION VALUE=\"$key\"". ($mode == $key ? " SELECTED" : "") .">$value</OPTION>\n";
}
$output .= "</SELECT>\n";
return $output;
}
function comment_order($order) {
global $corder;
$output .= "<SELECT NAME=\"order\">\n";
foreach ($corder as $key=>$value) {
$output .= " <OPTION VALUE=\"$key\"". ($order == $key ? " SELECTED" : "") .">$value</OPTION>\n";
}
$output .= "</SELECT>\n";
return $output;
}
function comment_query($link, $lid, $order, $pid = -1) {
$query .= "SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE link = '$link' AND c.lid = $lid";
if ($pid >= 0) $query .= " AND pid = $pid";
if ($order == 1) $query .= " ORDER BY c.timestamp DESC";
if ($order == 2) $query .= " ORDER BY c.score DESC";
return db_query($query);
}
function comment_visible($comment, $threshold = 0) {
if ($comment->votes == 0 && $comment->score >= $threshold) return 1;
else if ($comment->votes > 0 && $comment->score / $comment->votes >= $threshold) return 1;
else return 0;
}
function comment_uri($args = 0) {
global $link, $mod;
if ($args) return ($mod) ? "module.php?mod=$mod&$args" : $link .".php?$args";
else return ($mod) ? "module.php?mod=$mod" : $link .".php";
}
function comment_link($comment, $return = 1) {
global $link, $theme;
if ($return) return "<A HREF=\"". comment_uri("id=$comment->lid#$comment->cid") ."\"><FONT COLOR=\"$theme->hlcolor2\">return</FONT></A> | <A HREF=\"". comment_uri("op=reply&id=$comment->lid&pid=$comment->cid") ."\"><FONT COLOR=\"$theme->hlcolor2\">reply to this comment</FONT></A>";
else return "<A HREF=\"". comment_uri("op=reply&id=$comment->lid&pid=$comment->cid") ."\"><FONT COLOR=\"$theme->hlcolor2\">reply to this comment</FONT></A>";
}
function comment_comment($comment, $folded = 0) {
global $link, $theme;
if ($folded) $theme->comment($comment, $folded);
else print "<A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A> by ". format_username($comment->userid) ." <SMALL>(". $score = comment_score($comment) .")</SMALL></LI>";
}
function comment_thread_min($cid, $threshold) {
global $user, $theme;
$result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.pid = $cid ORDER BY c.timestamp, c.cid");
print "<UL>";
while ($comment = db_fetch_object($result)) {
comment_comment($comment);
comment_thread_min($comment->cid, $threshold);
}
print "</UL>";
}
function comment_thread_max($cid, $mode, $threshold, $level = 0, $dummy = 0) {
global $link, $theme, $user;
$result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE link = '$link' AND c.pid = $cid ORDER BY c.timestamp, c.cid");
print "<UL>";
while ($comment = db_fetch_object($result)) {
if (comment_visible($comment, $threshold)) {
$comment = new Comment($comment->userid, $comment->subject, $comment->comment, $comment->timestamp, $comment->url, $comment->fake_email, comment_score($comment), $comment->votes, $comment->cid);
$theme->comment($comment, comment_link($comment, 0));
}
else {
print "<P>";
comment_comment($comment);
print "</P>";
}
comment_thread_max($comment->cid, $mode, $threshold, $level + 1, $dummy + 1);
}
print "</UL>";
}
function comment_render($lid, $cid) {
global $link, $theme, $REQUEST_URI, $user;
// Pre-process variables:
$cid = empty($cid) ? 0 : $cid;
$mode = ($user->id) ? $user->mode : 4;
$order = ($user->id) ? $user->sort : 1;
$threshold = ($user->id) ? $user->threshold : 3;
if ($user->id) {
// Print moderation form:
print "<FORM METHOD=\"post\" ACTION=\"$REQUEST_URI\">\n";
}
if ($cid > 0) {
$result = db_query("SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE cid = $cid");
if ($comment = db_fetch_object($result)) {
$theme->comment($comment, comment_link($comment));
}
}
else {
if ($mode == 1) {
$result = comment_query($link, $lid, $order);
print "<TABLE BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
print " <TR><TH>Subject</TH><TH>Author</TH><TH>Date</TH><TH>Score</TH></TR>\n";
while ($comment = db_fetch_object($result)) {
if (comment_visible($comment, $threshold)) {
print " <TR><TD><A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A></TD><TD>". format_username($comment->userid) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD>". comment_score($comment) ."</TD></TR>\n";
}
}
print "</TABLE>\n";
}
else if ($mode == 2) {
$result = comment_query($link, $lid, $order);
while ($comment = db_fetch_object($result)) {
if (comment_visible($comment, $threshold)) {
$theme->comment($comment, comment_link($comment, 0));
}
}
}
else if ($mode == 3) {
$result = comment_query($link, $lid, $order, 0);
while ($comment = db_fetch_object($result)) {
comment_comment($comment);
comment_thread_min($comment->cid, $threshold);
}
}
else {
$result = comment_query($link, $lid, $order, 0);
while ($comment = db_fetch_object($result)) {
comment_comment($comment, (comment_visible($comment, $threshold) ? comment_link($comment, 0) : 0));
comment_thread_max($comment->cid, $mode, $threshold, $level + 1);
}
}
}
if ($user->id) {
// Print moderation form:
print " <INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$lid\">\n";
print " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Moderate comments\">\n";
print "</FORM>\n";
}
}
?>

View File

@ -12,11 +12,6 @@ function load_theme() {
return new Theme(); return new Theme();
} }
function discussion_score($comment) {
$value = ($comment->votes) ? ($comment->score / $comment->votes) : (($comment->score) ? $comment->score : 0);
return (strpos($value, ".")) ? substr($value ."00", 0, 4) : $value .".00";
}
function check_textfield($message) { function check_textfield($message) {
global $allowed_html; global $allowed_html;
return strip_tags(str_replace("\"", "&quot;", stripslashes($message)), $allowed_html); return strip_tags(str_replace("\"", "&quot;", stripslashes($message)), $allowed_html);
@ -42,21 +37,6 @@ function check_output($message, $nl2br = 0) {
else return strip_tags(stripslashes($message), $allowed_html); else return strip_tags(stripslashes($message), $allowed_html);
} }
function discussion_num_replies($id, $count = 0) {
$result = db_query("SELECT COUNT(cid) FROM comments WHERE pid = $id");
return ($result) ? db_result($result, 0) : 0;
}
function discussion_num_filtered($sid, $pid) {
global $user;
$threshold = ($user->id) ? $user->threshold : "0";
$pid = ($pid) ? $pid : 0;
$result = db_query("SELECT COUNT(cid) FROM comments WHERE sid = $sid AND pid = $pid AND (votes != 0 AND score / votes < $threshold)");
return ($result) ? db_result($result, 0) : 0;
}
function format_plural($count, $singular, $plural) { function format_plural($count, $singular, $plural) {
return ($count == 1) ? "$count $singular" : "$count $plural"; return ($count == 1) ? "$count $singular" : "$count $plural";
} }

View File

@ -11,7 +11,7 @@ function submission_score($id) {
} }
function submission_vote($id, $vote, $comment) { function submission_vote($id, $vote, $comment) {
global $user, $submission_post_threshold, $submission_dump_threshold; global $submission_post_threshold, $submission_dump_threshold, $user;
if (!user_getHistory($user->history, "s$id")) { if (!user_getHistory($user->history, "s$id")) {
// Update submission's score- and votes-field: // Update submission's score- and votes-field:
@ -21,7 +21,7 @@ function submission_vote($id, $vote, $comment) {
if ($comment) { if ($comment) {
watchdog("comment", "moderation: added comment with subject '$subject'"); watchdog("comment", "moderation: added comment with subject '$subject'");
db_query("INSERT INTO comments (sid, author, subject, comment, hostname, timestamp, score) VALUES($id, $user->id, '". check_input(substr($comment, 0, 29)) ." ...', '". check_input($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."', '" . ($user->userid ? 1 : 0) . "')"); db_query("INSERT INTO comments (lid, link, author, subject, comment, hostname, timestamp, score) VALUES($id, 'story', $user->id, '". check_input(substr($comment, 0, 29)) ." ...', '". check_input($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."', '1')");
} }
// Update user's history record: // Update user's history record:

View File

@ -79,7 +79,7 @@ function theme_blocks($region, $theme) {
} }
function theme_morelink($theme, $story) { function theme_morelink($theme, $story) {
return ($story->article) ? "[ <A HREF=\"discussion.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\"><B>read more</B></FONT></A> | ". strlen($story->article) ." bytes | <A HREF=\"discussion.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]" : "[ <A HREF=\"discussion.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]"; return ($story->article) ? "[ <A HREF=\"story.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\"><B>read more</B></FONT></A> | ". strlen($story->article) ." bytes | <A HREF=\"story.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]" : "[ <A HREF=\"story.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]";
} }
function theme_moderation_results($theme, $story) { function theme_moderation_results($theme, $story) {
@ -113,27 +113,12 @@ function theme_related_links($theme, $story) {
$theme->box("Related links", $content); $theme->box("Related links", $content);
} }
function theme_comment_moderation($comment) {
global $user, $comment_votes;
if ($user->id && $user->userid != $comment->userid && !user_getHistory($user->history, "c$comment->cid")) {
$output .= "<SELECT NAME=\"moderate[$comment->cid]\">\n";
foreach ($comment_votes as $key=>$value) $output .= " <OPTION VALUE=\"$value\">$key</OPTION>\n";
$output .= "</SELECT>\n";
}
else {
$output .= "<TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"1\"><TR><TD>score:</TD><TD>". format_data($comment->score) ."</TD></TR><TR><TD>votes:</TD><TD>". format_data($comment->votes) ."</TR></TABLE>";
}
return $output;
}
function theme_new_headlines($theme, $num = 10) { function theme_new_headlines($theme, $num = 10) {
global $user; global $user;
$content = ""; $content = "";
$result = db_query("SELECT id, subject FROM stories WHERE status = 2 ORDER BY id DESC LIMIT $num"); $result = db_query("SELECT id, subject FROM stories WHERE status = 2 ORDER BY id DESC LIMIT $num");
while ($story = db_fetch_object($result)) $content .= "<LI><A HREF=\"discussion.php?id=$story->id\">". check_output($story->subject) ."</A></LI>\n"; while ($story = db_fetch_object($result)) $content .= "<LI><A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A></LI>\n";
$content .= "<P ALIGN=\"right\">[ <A HREF=\"search.php\"><FONT COLOR=\"$theme->hlcolor2\">more</FONT></A> ]</P>"; $content .= "<P ALIGN=\"right\">[ <A HREF=\"search.php\"><FONT COLOR=\"$theme->hlcolor2\">more</FONT></A> ]</P>";
$theme->box("Latest headlines", $content); $theme->box("Latest headlines", $content);
} }
@ -149,12 +134,11 @@ function theme_old_headlines($theme, $num = 10) {
$content .= "<P><B>". date("l, M jS", $story->timestamp) ."</B></P>\n"; $content .= "<P><B>". date("l, M jS", $story->timestamp) ."</B></P>\n";
$time = date("F jS", $story->timestamp); $time = date("F jS", $story->timestamp);
} }
$content .= "<LI><A HREF=\"discussion.php?id=$story->id\">". check_output($story->subject) ."</A></LI>\n"; $content .= "<LI><A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A></LI>\n";
} }
$content .= "<P ALIGN=\"right\">[ <A HREF=\"search.php\"><FONT COLOR=\"$theme->hlcolor2\">more</FONT></A> ]</P>"; $content .= "<P ALIGN=\"right\">[ <A HREF=\"search.php\"><FONT COLOR=\"$theme->hlcolor2\">more</FONT></A> ]</P>";
$theme->box("Older headlines", $content); $theme->box("Older headlines", $content);
} }
?> ?>

View File

@ -13,7 +13,7 @@ $number = ($user->stories) ? $user->stories : 10;
$date = ($date) ? $date : time(); $date = ($date) ? $date : time();
// Perform query: // Perform query:
$result = db_query("SELECT stories.*, users.userid, COUNT(comments.sid) AS comments FROM stories LEFT JOIN comments ON stories.id = comments.sid LEFT JOIN users ON stories.author = users.id WHERE stories.status = 2 AND stories.timestamp <= $date GROUP BY stories.id ORDER BY stories.timestamp DESC LIMIT $number"); $result = db_query("SELECT stories.*, users.userid, COUNT(comments.lid) AS comments FROM stories LEFT JOIN comments ON stories.id = comments.lid LEFT JOIN users ON stories.author = users.id WHERE stories.status = 2 AND stories.timestamp <= $date GROUP BY stories.id ORDER BY stories.timestamp DESC LIMIT $number");
// Display stories: // Display stories:
$theme->header(); $theme->header();

View File

@ -87,15 +87,15 @@ function account_display($order = "username") {
function account_stories($id) { function account_stories($id) {
$result = db_query("SELECT * FROM stories WHERE author = $id ORDER BY timestamp DESC"); $result = db_query("SELECT * FROM stories WHERE author = $id ORDER BY timestamp DESC");
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
$output .= "<LI><A HREF=\"discussion.php?id=$story->id\">". check_output($story->subject) ."</A></LI>\n"; $output .= "<LI><A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A></LI>\n";
} }
return $output; return $output;
} }
function account_comments($id) { function account_comments($id) {
$result = db_query("SELECT * FROM comments WHERE author = $id ORDER BY timestamp DESC"); $result = db_query("SELECT * FROM comments WHERE link = 'story' AND author = $id ORDER BY timestamp DESC");
while ($comment = db_fetch_object($result)) { while ($comment = db_fetch_object($result)) {
$output .= "<LI><A HREF=\"discussion.php?id=$comment->sid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></LI>\n"; $output .= "<LI><A HREF=\"story.php?id=$comment->sid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></LI>\n";
} }
return $output; return $output;
} }

View File

@ -66,7 +66,7 @@ function comment_display($order = "date") {
$output .= " </TR>\n"; $output .= " </TR>\n";
while ($comment = db_fetch_object($result)) { while ($comment = db_fetch_object($result)) {
$output .= " <TR><TD><A HREF=\"discussion.php?id=$comment->sid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD><TD>". format_username($comment->userid, 1) ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit</A></TD></TR>\n"; $output .= " <TR><TD>". ($comment->link == "story" ? "<A HREF=\"story.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A>" : check_output($comment->subject)) ."</TD><TD>". format_username($comment->userid, 1) ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit</A></TD></TR>\n";
} }
$output .= "</TABLE>\n"; $output .= "</TABLE>\n";

View File

@ -66,7 +66,7 @@ function comment_display($order = "date") {
$output .= " </TR>\n"; $output .= " </TR>\n";
while ($comment = db_fetch_object($result)) { while ($comment = db_fetch_object($result)) {
$output .= " <TR><TD><A HREF=\"discussion.php?id=$comment->sid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></TD><TD>". format_username($comment->userid, 1) ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit</A></TD></TR>\n"; $output .= " <TR><TD>". ($comment->link == "story" ? "<A HREF=\"story.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A>" : check_output($comment->subject)) ."</TD><TD>". format_username($comment->userid, 1) ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=comment&op=edit&id=$comment->cid\">edit</A></TD></TR>\n";
} }
$output .= "</TABLE>\n"; $output .= "</TABLE>\n";

View File

@ -2,41 +2,80 @@
$module = array("page" => "drupal_page"); $module = array("page" => "drupal_page");
include "includes/common.inc"; include_once "includes/common.inc";
include_once "includes/comment.inc";
function drupal_page() { function drupal_render($id, $cid) {
global $theme; global $theme, $threshold, $mode, $order, $user;
$output .= " $output = " <P>Drupal is the English pronunciation for the Dutch word 'druppel' which stands for 'drop'. Drupal is a full-featured content management/discussion engine suitable to setup a news-driven community or portal site. Drupal aims towards easy installation, excessive configuration and fine-grained maintenance capabilities. Due to its modular design drupal is flexible and easy to adapt or extend.</P>\n";
<H2>Introduction</H2> $output .= " <P>Drupal is primarily written by Dries Buytaert (dries_at_drop.org) and build after Slash (<A HREF=\"http://slashcode.com/\">http://slashcode.com/</A>) and Scoop (<A HREF=\"http://scoop.kuro5hin.org/\">http://scoop.kuro5hin.org/</A>). The source code is available under terms of GNU General Public License (GPL).</P>\n";
<P>Drupal is the English pronunciation for the Dutch word 'druppel' which stands for 'drop'. Drupal is a full-featured content management/discussion engine suitable to setup a news-driven community or portal site. Drupal aims towards easy installation, excessive configuration and fine-grained maintenance capabilities. Due to its modular design drupal is flexible and easy to adapt or extend.</P> $output .= " <P>We don't have a real demo site yet but drupal is used by (and created for) <A HREF=\"http://drop.org/\">http://drop.org/</A>. Create an account, play with it for a bit, read the <A HREF=\"module.php?mod=documentation\">documentation</A> and spend some time getting used to it.</P>\n";
<P>Drupal is primarily written by Dries Buytaert (dries_at_drop.org) and build after Slash (<A HREF=\"http://slashcode.com/\">http://slashcode.com/</A>) and Scoop (<A HREF=\"http://scoop.kuro5hin.org/\">http://scoop.kuro5hin.org/</A>) and source code is available under terms of GNU General Public License (GPL).</P> $theme->box("Introduction", $output);
<H2>Download</H2>
<LI><A HREF=\"drupal/drupal-1.00.tgz\">drupal 1.00</A> (2000/01/15)</LI> $output = "<LI><A HREF=\"drupal/drupal-1.00.tgz\">drupal 1.00</A> (2000/01/15 - latest version)</LI>\n";
<LI><A HREF=\"drupal/drupal-1.00-rc2.tgz\">drupal 1.00-rc2</A> (2000/01/08)</LI> $output .= "<LI><A HREF=\"drupal/drupal-1.00-rc2.tgz\">drupal 1.00-rc2</A> (2000/01/08)</LI>\n";
<LI><A HREF=\"drupal/drupal-1.00-rc1.tgz\">drupal 1.00-rc1</A> (2000/01/01)</LI> $output .= "<LI><A HREF=\"drupal/drupal-1.00-rc1.tgz\">drupal 1.00-rc1</A> (2000/01/01)</LI>\n";
<H2>Screenshots</H2> $theme->box("Download", $output);
";
unset($output);
$handle = opendir("drupal"); $handle = opendir("drupal");
while ($file = readdir($handle)) if (ereg(".jpg", $file) || ereg(".gif", $file)) $output .= " <LI><SMALL><A HREF=\"drupal/$file\">$file</A></SMALL></LI>\n"; while ($file = readdir($handle)) if (ereg(".jpg", $file) || ereg(".gif", $file)) $output .= " <LI><SMALL><A HREF=\"drupal/$file\">$file</A></SMALL></LI>\n";
closedir($handle); closedir($handle);
$theme->box("Screenshots", $output);
$output = "<H2>Documentation</H2>\n";
$output .= " <LI><A HREF=\"module.php?mod=documentation\">documentation</A></LI>\n";
$output .= " <LI><A HREF=\"module.php?mod=wishlist\">wishlist</A></LI>\n";
$output .= "<H2>Mailing list</H2>\n";
$output .= " <P>The <CODE>drupal-support@drop.org</CODE> list discusses drupal development. All submissions relevant to that, such as bug reports, enhancement ideas, patches or reports that a patch fixed a bug are appropriate.</P>\n";
$output .= " <LI>To subscribe to the <CODE>drupal-support@drop.org</CODE> mailing list, send an e-mail to <A HREF=\"mailto:drupal-support-request@drop.org\">drupal-support-request@drop.org</A> with no subject and put <B>subscribe</B> in the body of your message.</LI>\n";
$output .= " <LI>To unsubscribe from the <CODE>drupal-support@drop.org</CODE> mailing list, send an e-mail to <A HREF=\"mailto:drupal-support-request@drop.org\">drupal-support-request@drop.org</A> and put <B>unsubscribe</B> in the body of your mail.\n";
$theme->box("Support and development", $output);
$output .= " print "<H3>Comments</H3>\n";
<H2>Demo</H2>
<P>We don't have a real demo site yet but drupal is used by (and created for) <A HREF=\"http://drop.org/\">http://drop.org/</A>. Create an account, play with it for a bit, read the <A HREF=\"module.php?mod=documentation\">documentation</A> and spend some time getting used to it.</P>
<H2>Documentation</H2>
<LI><A HREF=\"module.php?mod=documentation\">documentation</A></LI>
<LI><A HREF=\"module.php?mod=wishlist\">wishlist</A></LI>
<H2>Mailing list</H2>
<P>The <CODE>drupal-support@drop.org</CODE> list discusses drupal development. All submissions relevant to that, such as bug reports, enhancement ideas, patches or reports that a patch fixed a bug are appropriate.</P>
<LI>To subscribe to the <CODE>drupal-support@drop.org</CODE> mailing list, send an e-mail to <A HREF=\"mailto:drupal-support-request@drop.org\">drupal-support-request@drop.org</A> with no subject and put <B>subscribe</B> in the body of your message.</LI>
<LI>To unsubscribe from the <CODE>drupal-support@drop.org</CODE> mailing list, send an e-mail to <A HREF=\"mailto:drupal-support-request@drop.org\">drupal-support-request@drop.org</A> and put <B>unsubscribe</B> in the body of your mail.
";
$theme->header(); // Display 'comment control'-box:
$theme->box("Drupal", $output); if ($user->id) $theme->controls($threshold, $mode, $order);
$theme->footer();
// Display comments:
comment_render($id, $cid);
} }
?> function drupal_page() {
global $cid, $comment, $id, $op, $pid, $lid, $link, $mode, $order, $subject, $theme, $threshold;
switch($op) {
case "Preview comment":
$theme->header();
comment_preview($pid, $id, $subject, $comment);
$theme->footer();
break;
case "Post comment":
comment_post($pid, $id, $subject, $comment);
break;
case "reply":
$theme->header();
comment_reply($pid, $id);
$theme->footer();
break;
case "Update":
comment_settings($mode, $order, $threshold);
$theme->header();
drupal_render($id, $cid);
$theme->footer();
break;
case "Moderate comments":
comment_moderate($moderate);
$theme->header();
drupal_render($id, $cid);
$theme->footer();
break;
default:
$theme->header();
drupal_render(0, $cid);
$theme->footer();
}
}
?>

View File

@ -2,41 +2,80 @@
$module = array("page" => "drupal_page"); $module = array("page" => "drupal_page");
include "includes/common.inc"; include_once "includes/common.inc";
include_once "includes/comment.inc";
function drupal_page() { function drupal_render($id, $cid) {
global $theme; global $theme, $threshold, $mode, $order, $user;
$output .= " $output = " <P>Drupal is the English pronunciation for the Dutch word 'druppel' which stands for 'drop'. Drupal is a full-featured content management/discussion engine suitable to setup a news-driven community or portal site. Drupal aims towards easy installation, excessive configuration and fine-grained maintenance capabilities. Due to its modular design drupal is flexible and easy to adapt or extend.</P>\n";
<H2>Introduction</H2> $output .= " <P>Drupal is primarily written by Dries Buytaert (dries_at_drop.org) and build after Slash (<A HREF=\"http://slashcode.com/\">http://slashcode.com/</A>) and Scoop (<A HREF=\"http://scoop.kuro5hin.org/\">http://scoop.kuro5hin.org/</A>). The source code is available under terms of GNU General Public License (GPL).</P>\n";
<P>Drupal is the English pronunciation for the Dutch word 'druppel' which stands for 'drop'. Drupal is a full-featured content management/discussion engine suitable to setup a news-driven community or portal site. Drupal aims towards easy installation, excessive configuration and fine-grained maintenance capabilities. Due to its modular design drupal is flexible and easy to adapt or extend.</P> $output .= " <P>We don't have a real demo site yet but drupal is used by (and created for) <A HREF=\"http://drop.org/\">http://drop.org/</A>. Create an account, play with it for a bit, read the <A HREF=\"module.php?mod=documentation\">documentation</A> and spend some time getting used to it.</P>\n";
<P>Drupal is primarily written by Dries Buytaert (dries_at_drop.org) and build after Slash (<A HREF=\"http://slashcode.com/\">http://slashcode.com/</A>) and Scoop (<A HREF=\"http://scoop.kuro5hin.org/\">http://scoop.kuro5hin.org/</A>) and source code is available under terms of GNU General Public License (GPL).</P> $theme->box("Introduction", $output);
<H2>Download</H2>
<LI><A HREF=\"drupal/drupal-1.00.tgz\">drupal 1.00</A> (2000/01/15)</LI> $output = "<LI><A HREF=\"drupal/drupal-1.00.tgz\">drupal 1.00</A> (2000/01/15 - latest version)</LI>\n";
<LI><A HREF=\"drupal/drupal-1.00-rc2.tgz\">drupal 1.00-rc2</A> (2000/01/08)</LI> $output .= "<LI><A HREF=\"drupal/drupal-1.00-rc2.tgz\">drupal 1.00-rc2</A> (2000/01/08)</LI>\n";
<LI><A HREF=\"drupal/drupal-1.00-rc1.tgz\">drupal 1.00-rc1</A> (2000/01/01)</LI> $output .= "<LI><A HREF=\"drupal/drupal-1.00-rc1.tgz\">drupal 1.00-rc1</A> (2000/01/01)</LI>\n";
<H2>Screenshots</H2> $theme->box("Download", $output);
";
unset($output);
$handle = opendir("drupal"); $handle = opendir("drupal");
while ($file = readdir($handle)) if (ereg(".jpg", $file) || ereg(".gif", $file)) $output .= " <LI><SMALL><A HREF=\"drupal/$file\">$file</A></SMALL></LI>\n"; while ($file = readdir($handle)) if (ereg(".jpg", $file) || ereg(".gif", $file)) $output .= " <LI><SMALL><A HREF=\"drupal/$file\">$file</A></SMALL></LI>\n";
closedir($handle); closedir($handle);
$theme->box("Screenshots", $output);
$output = "<H2>Documentation</H2>\n";
$output .= " <LI><A HREF=\"module.php?mod=documentation\">documentation</A></LI>\n";
$output .= " <LI><A HREF=\"module.php?mod=wishlist\">wishlist</A></LI>\n";
$output .= "<H2>Mailing list</H2>\n";
$output .= " <P>The <CODE>drupal-support@drop.org</CODE> list discusses drupal development. All submissions relevant to that, such as bug reports, enhancement ideas, patches or reports that a patch fixed a bug are appropriate.</P>\n";
$output .= " <LI>To subscribe to the <CODE>drupal-support@drop.org</CODE> mailing list, send an e-mail to <A HREF=\"mailto:drupal-support-request@drop.org\">drupal-support-request@drop.org</A> with no subject and put <B>subscribe</B> in the body of your message.</LI>\n";
$output .= " <LI>To unsubscribe from the <CODE>drupal-support@drop.org</CODE> mailing list, send an e-mail to <A HREF=\"mailto:drupal-support-request@drop.org\">drupal-support-request@drop.org</A> and put <B>unsubscribe</B> in the body of your mail.\n";
$theme->box("Support and development", $output);
$output .= " print "<H3>Comments</H3>\n";
<H2>Demo</H2>
<P>We don't have a real demo site yet but drupal is used by (and created for) <A HREF=\"http://drop.org/\">http://drop.org/</A>. Create an account, play with it for a bit, read the <A HREF=\"module.php?mod=documentation\">documentation</A> and spend some time getting used to it.</P>
<H2>Documentation</H2>
<LI><A HREF=\"module.php?mod=documentation\">documentation</A></LI>
<LI><A HREF=\"module.php?mod=wishlist\">wishlist</A></LI>
<H2>Mailing list</H2>
<P>The <CODE>drupal-support@drop.org</CODE> list discusses drupal development. All submissions relevant to that, such as bug reports, enhancement ideas, patches or reports that a patch fixed a bug are appropriate.</P>
<LI>To subscribe to the <CODE>drupal-support@drop.org</CODE> mailing list, send an e-mail to <A HREF=\"mailto:drupal-support-request@drop.org\">drupal-support-request@drop.org</A> with no subject and put <B>subscribe</B> in the body of your message.</LI>
<LI>To unsubscribe from the <CODE>drupal-support@drop.org</CODE> mailing list, send an e-mail to <A HREF=\"mailto:drupal-support-request@drop.org\">drupal-support-request@drop.org</A> and put <B>unsubscribe</B> in the body of your mail.
";
$theme->header(); // Display 'comment control'-box:
$theme->box("Drupal", $output); if ($user->id) $theme->controls($threshold, $mode, $order);
$theme->footer();
// Display comments:
comment_render($id, $cid);
} }
?> function drupal_page() {
global $cid, $comment, $id, $op, $pid, $lid, $link, $mode, $order, $subject, $theme, $threshold;
switch($op) {
case "Preview comment":
$theme->header();
comment_preview($pid, $id, $subject, $comment);
$theme->footer();
break;
case "Post comment":
comment_post($pid, $id, $subject, $comment);
break;
case "reply":
$theme->header();
comment_reply($pid, $id);
$theme->footer();
break;
case "Update":
comment_settings($mode, $order, $threshold);
$theme->header();
drupal_render($id, $cid);
$theme->footer();
break;
case "Moderate comments":
comment_moderate($moderate);
$theme->header();
drupal_render($id, $cid);
$theme->footer();
break;
default:
$theme->header();
drupal_render(0, $cid);
$theme->footer();
}
}
?>

View File

@ -207,7 +207,7 @@ function headline_export($uri) {
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
print "<item>\n"; print "<item>\n";
print " <title>$story->subject</title>\n"; print " <title>$story->subject</title>\n";
print " <link>". $site_url ."discussion.php?id=$story->id</link>\n"; print " <link>". $site_url ."story.php?id=$story->id</link>\n";
print "</item>\n"; print "</item>\n";
} }

View File

@ -22,9 +22,9 @@ function story_help() {
} }
function story_block() { function story_block() {
$result = db_query("SELECT s.id, COUNT(s.id) AS comments, s.subject FROM stories s LEFT JOIN comments c ON s.id = c.sid WHERE s.status = 2 GROUP BY s.id ORDER BY comments DESC LIMIT 10"); $result = db_query("SELECT s.id, COUNT(s.id) AS comments, s.subject FROM stories s LEFT JOIN comments c ON s.id = c.lid WHERE s.status = 2 AND c.link = 'link' GROUP BY s.id ORDER BY comments DESC LIMIT 10");
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
$content .= "<LI><A HREF=\"discussion.php?id=$story->id\">$story->subject</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n"; $content .= "<LI><A HREF=\"story.php?id=$story->id\">$story->subject</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
} }
$blocks[0]["subject"] = "Top 10:<BR>all stories"; $blocks[0]["subject"] = "Top 10:<BR>all stories";
@ -33,9 +33,9 @@ function story_block() {
unset($content); unset($content);
$result = db_query("SELECT s.id, COUNT(s.id) AS comments, s.subject FROM stories s LEFT JOIN comments c ON s.id = c.sid WHERE s.status = 2 AND ". time() ." - s.timestamp < 2419200 GROUP BY s.id ORDER BY comments DESC LIMIT 10"); $result = db_query("SELECT s.id, COUNT(s.id) AS comments, s.subject FROM stories s LEFT JOIN comments c ON s.id = c.lid WHERE s.status = 2 AND c.link = 'story' AND ". time() ." - s.timestamp < 2419200 GROUP BY s.id ORDER BY comments DESC LIMIT 10");
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
$content .= "<LI><A HREF=\"discussion.php?id=$story->id\">$story->subject</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n"; $content .= "<LI><A HREF=\"story.php?id=$story->id\">$story->subject</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
} }
$blocks[1]["subject"] = "Top 10:<BR>recent stories"; $blocks[1]["subject"] = "Top 10:<BR>recent stories";
@ -175,28 +175,28 @@ function story_display() {
$result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 1 ORDER BY timestamp DESC"); $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 1 ORDER BY timestamp DESC");
$output .= " <TR><TH COLSPAN=\"4\">queued stories</TH></TR>\n"; $output .= " <TR><TH COLSPAN=\"4\">queued stories</TH></TR>\n";
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
$output .= " <TR><TD><A HREF=\"discussion.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>votes: $story->votes, score: $story->score</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n"; $output .= " <TR><TD><A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>votes: $story->votes, score: $story->score</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n";
} }
// Scheduled stories: // Scheduled stories:
$result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 3 ORDER BY timestamp"); $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 3 ORDER BY timestamp");
$output .= " <TR><TH COLSPAN=\"4\">scheduled stories</TH></TR>\n"; $output .= " <TR><TH COLSPAN=\"4\">scheduled stories</TH></TR>\n";
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
$output .= " <TR><TD><A HREF=\"discussion.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>". date("D, m/d/Y H:i", $story->timestamp) ." - ". format_interval($story->timestamp - time()) ." left</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n"; $output .= " <TR><TD><A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>". date("D, m/d/Y H:i", $story->timestamp) ." - ". format_interval($story->timestamp - time()) ." left</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n";
} }
// Dumped stories: // Dumped stories:
$result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 0 ORDER BY timestamp DESC LIMIT 5"); $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 0 ORDER BY timestamp DESC LIMIT 5");
$output .= " <TR><TH COLSPAN=\"4\">dumped stories</TTH></TR>\n"; $output .= " <TR><TH COLSPAN=\"4\">dumped stories</TTH></TR>\n";
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
$output .= " <TR><TD><A HREF=\"discussion.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>$story->category</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n"; $output .= " <TR><TD><A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>$story->category</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n";
} }
// Posted stories: // Posted stories:
$result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 2 ORDER BY timestamp DESC LIMIT 15"); $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 2 ORDER BY timestamp DESC LIMIT 15");
$output .= " <TR><TH COLSPAN=\"4\">posted stories</TH></TR>\n"; $output .= " <TR><TH COLSPAN=\"4\">posted stories</TH></TR>\n";
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
$output .= " <TR><TD><A HREF=\"discussion.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>$story->category</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n"; $output .= " <TR><TD><A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>$story->category</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n";
} }
$output .= "</TABLE>\n"; $output .= "</TABLE>\n";

View File

@ -22,9 +22,9 @@ function story_help() {
} }
function story_block() { function story_block() {
$result = db_query("SELECT s.id, COUNT(s.id) AS comments, s.subject FROM stories s LEFT JOIN comments c ON s.id = c.sid WHERE s.status = 2 GROUP BY s.id ORDER BY comments DESC LIMIT 10"); $result = db_query("SELECT s.id, COUNT(s.id) AS comments, s.subject FROM stories s LEFT JOIN comments c ON s.id = c.lid WHERE s.status = 2 AND c.link = 'link' GROUP BY s.id ORDER BY comments DESC LIMIT 10");
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
$content .= "<LI><A HREF=\"discussion.php?id=$story->id\">$story->subject</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n"; $content .= "<LI><A HREF=\"story.php?id=$story->id\">$story->subject</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
} }
$blocks[0]["subject"] = "Top 10:<BR>all stories"; $blocks[0]["subject"] = "Top 10:<BR>all stories";
@ -33,9 +33,9 @@ function story_block() {
unset($content); unset($content);
$result = db_query("SELECT s.id, COUNT(s.id) AS comments, s.subject FROM stories s LEFT JOIN comments c ON s.id = c.sid WHERE s.status = 2 AND ". time() ." - s.timestamp < 2419200 GROUP BY s.id ORDER BY comments DESC LIMIT 10"); $result = db_query("SELECT s.id, COUNT(s.id) AS comments, s.subject FROM stories s LEFT JOIN comments c ON s.id = c.lid WHERE s.status = 2 AND c.link = 'story' AND ". time() ." - s.timestamp < 2419200 GROUP BY s.id ORDER BY comments DESC LIMIT 10");
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
$content .= "<LI><A HREF=\"discussion.php?id=$story->id\">$story->subject</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n"; $content .= "<LI><A HREF=\"story.php?id=$story->id\">$story->subject</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
} }
$blocks[1]["subject"] = "Top 10:<BR>recent stories"; $blocks[1]["subject"] = "Top 10:<BR>recent stories";
@ -175,28 +175,28 @@ function story_display() {
$result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 1 ORDER BY timestamp DESC"); $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 1 ORDER BY timestamp DESC");
$output .= " <TR><TH COLSPAN=\"4\">queued stories</TH></TR>\n"; $output .= " <TR><TH COLSPAN=\"4\">queued stories</TH></TR>\n";
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
$output .= " <TR><TD><A HREF=\"discussion.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>votes: $story->votes, score: $story->score</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n"; $output .= " <TR><TD><A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>votes: $story->votes, score: $story->score</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n";
} }
// Scheduled stories: // Scheduled stories:
$result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 3 ORDER BY timestamp"); $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 3 ORDER BY timestamp");
$output .= " <TR><TH COLSPAN=\"4\">scheduled stories</TH></TR>\n"; $output .= " <TR><TH COLSPAN=\"4\">scheduled stories</TH></TR>\n";
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
$output .= " <TR><TD><A HREF=\"discussion.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>". date("D, m/d/Y H:i", $story->timestamp) ." - ". format_interval($story->timestamp - time()) ." left</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n"; $output .= " <TR><TD><A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>". date("D, m/d/Y H:i", $story->timestamp) ." - ". format_interval($story->timestamp - time()) ." left</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n";
} }
// Dumped stories: // Dumped stories:
$result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 0 ORDER BY timestamp DESC LIMIT 5"); $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 0 ORDER BY timestamp DESC LIMIT 5");
$output .= " <TR><TH COLSPAN=\"4\">dumped stories</TTH></TR>\n"; $output .= " <TR><TH COLSPAN=\"4\">dumped stories</TTH></TR>\n";
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
$output .= " <TR><TD><A HREF=\"discussion.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>$story->category</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n"; $output .= " <TR><TD><A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>$story->category</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n";
} }
// Posted stories: // Posted stories:
$result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 2 ORDER BY timestamp DESC LIMIT 15"); $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author WHERE s.status = 2 ORDER BY timestamp DESC LIMIT 15");
$output .= " <TR><TH COLSPAN=\"4\">posted stories</TH></TR>\n"; $output .= " <TR><TH COLSPAN=\"4\">posted stories</TH></TR>\n";
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
$output .= " <TR><TD><A HREF=\"discussion.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>$story->category</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n"; $output .= " <TR><TD><A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A></TD><TD>". format_username($story->userid, 1) ."</TD><TD>$story->category</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=story&op=edit&id=$story->id\">edit</A></TD></TR>\n";
} }
$output .= "</TABLE>\n"; $output .= "</TABLE>\n";

View File

@ -39,7 +39,7 @@
$output .= " <TD>\n"; $output .= " <TD>\n";
// Compose and perform query: // Compose and perform query:
$query = "SELECT s.id, s.subject, u.userid, s.timestamp, COUNT(c.cid) AS comments FROM stories s LEFT JOIN users u ON s.author = u.id LEFT JOIN comments c ON s.id = c.sid WHERE s.status = 2 "; $query = "SELECT s.id, s.subject, u.userid, s.timestamp, COUNT(c.cid) AS comments FROM stories s LEFT JOIN users u ON s.author = u.id LEFT JOIN comments c ON s.id = c.lid WHERE s.status = 2 ";
$query .= ($author) ? "AND u.userid = '$author' " : ""; $query .= ($author) ? "AND u.userid = '$author' " : "";
$query .= ($terms) ? "AND (s.subject LIKE '%$terms%' OR s.abstract LIKE '%$terms%' OR s.updates LIKE '%$terms%') " : ""; $query .= ($terms) ? "AND (s.subject LIKE '%$terms%' OR s.abstract LIKE '%$terms%' OR s.updates LIKE '%$terms%') " : "";
$query .= ($category) ? "AND s.category = '$category' GROUP BY s.id " : "GROUP BY s.id "; $query .= ($category) ? "AND s.category = '$category' GROUP BY s.id " : "GROUP BY s.id ";
@ -51,7 +51,7 @@
while ($entry = db_fetch_object($result)) { while ($entry = db_fetch_object($result)) {
$num++; $num++;
$output .= "<P>$num) <B><A HREF=\"discussion.php?id=$entry->id\">". check_output($entry->subject) ."</A></B> (". format_plural($entry->comments, "comment", comments) .")<BR><SMALL>by ". format_username($entry->userid) ."</B>, posted on ". format_date($entry->timestamp) .".</SMALL></P>\n"; $output .= "<P>$num) <B><A HREF=\"story.php?id=$entry->id\">". check_output($entry->subject) ."</A></B> (". format_plural($entry->comments, "comment", comments) .")<BR><SMALL>by ". format_username($entry->userid) ."</B>, posted on ". format_date($entry->timestamp) .".</SMALL></P>\n";
} }
if ($num == 0) $output .= "<P>Your search did <B>not</B> match any articles in our database: <UL><LI>Try using fewer words.</LI><LI>Try using more general keywords.</LI><LI>Try using different keywords.</LI></UL></P>\n"; if ($num == 0) $output .= "<P>Your search did <B>not</B> match any articles in our database: <UL><LI>Try using fewer words.</LI><LI>Try using more general keywords.</LI><LI>Try using different keywords.</LI></UL></P>\n";

View File

@ -30,7 +30,7 @@ function submission_display_item($id) {
$submission = db_fetch_object($result); $submission = db_fetch_object($result);
if ($user->id == $submission->author || user_getHistory($user->history, "s$id")) { if ($user->id == $submission->author || user_getHistory($user->history, "s$id")) {
header("Location: discussion.php?id=$id"); header("Location: story.php?id=$id");
} }
else { else {
$theme->header(); $theme->header();

View File

@ -94,62 +94,15 @@
print "<BR><BR>\n\n"; print "<BR><BR>\n\n";
} }
function commentControl($sid, $title, $threshold, $mode, $order) { function controls($threshold, $mode, $order) {
global $user; print "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">\n";
print " <TR><TD BGCOLOR=\"#000000\"><IMG SRC=\"themes/marvin/images/pixel.gif\" WIDTH=\"100%\" HEIGHT=\"0\" ALT=\"\"></TD></TR>\n";
$query = db_query("SELECT sid FROM comments WHERE sid = $sid"); print " <TR><TD>". comment_controls($threshold, $mode, $order) ."</TD></TR>\n";
print " <TR><TD BGCOLOR=\"#000000\"><IMG SRC=\"themes/marvin/images/pixel.gif\" WIDTH=\"100%\" HEIGHT=\"0\" ALT=\"\"></TD></TR>\n";
if (!$query) $count = 0; else $count = db_num_rows($query); print "</TABLE>";
if (!isset($threshold)) $threshold = 0;
?>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR="#000000" WIDTH="100%">
<TR>
<TD>
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="2">
<TR>
<TD ALIGN="center" BGCOLOR="<? echo "$this->bgcolor2"; ?>"><FONT COLOR="<? echo "$this->bgcolor1" ?>"><B>Comment control</B></FONT></TD>
</TR>
<TR>
<TD ALIGN="center" BGCOLOR="<? echo "$this->bgcolor1"; ?>">
<FORM METHOD="post" ACTION="discussion.php">
<SMALL>
<INPUT TYPE="hidden" NAME="id" VALUE="<? echo "$sid"; ?>">
<SELECT NAME="threshold">
<OPTION VALUE="-1" <? if ($threshold == -1) { echo "SELECTED"; } ?>>Threshold: -1
<OPTION VALUE="0" <? if ($threshold == 0) { echo "SELECTED"; } ?>>Threshold: 0
<OPTION VALUE="1" <? if ($threshold == 1) { echo "SELECTED"; } ?>>Threshold: 1
<OPTION VALUE="2" <? if ($threshold == 2) { echo "SELECTED"; } ?>>Threshold: 2
<OPTION VALUE="3" <? if ($threshold == 3) { echo "SELECTED"; } ?>>Threshold: 3
<OPTION VALUE="4" <? if ($threshold == 4) { echo "SELECTED"; } ?>>Threshold: 4
<OPTION VALUE="5" <? if ($threshold == 5) { echo "SELECTED"; } ?>>Threshold: 5
</SELECT>
<SELECT NAME="mode">
<OPTION VALUE="nested" <? if ($mode == "nested") { echo "SELECTED"; } ?>>Nested
<OPTION VALUE="flat" <? if ($mode == "flat") { echo "SELECTED"; } ?>>Flat
<OPTION VALUE="threaded" <? if (!isset($mode) || $mode=='threaded' || $mode=="") { echo "SELECTED"; } ?>>Threaded
</SELECT>
<SELECT NAME="order">
<OPTION VALUE="0" <? if (!$order) { echo "SELECTED"; } ?>>Oldest first
<OPTION VALUE="1" <? if ($order==1) { echo "SELECTED"; } ?>>Newest first
<OPTION VALUE="2" <? if ($order==2) { echo "SELECTED"; } ?>>Highest scoring first
</SELECT>
<INPUT TYPE="submit" NAME="op" VALUE="Save">
</SMALL>
</FORM>
</TD>
</TR>
<TR>
<TD ALIGN="center" BGCOLOR="<? echo "$this->bgcolor2"; ?>"><SMALL><FONT COLOR="#C0C0C0">At least <? echo format_plural(discussion_num_filtered($sid, $pid), "comment", "comments"); ?> below your threshold.</FONT></SMALL></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<BR><BR>
<?
} }
function comment($comment, $link, $thread = "") { function comment($comment, $link = "", $thread = "") {
print "<A NAME=\"$comment->cid\">\n"; print "<A NAME=\"$comment->cid\">\n";
// Create comment header: // Create comment header:
@ -168,7 +121,7 @@
// Moderation: // Moderation:
print " <TD ALIGN=\"right\" ROWSPAN=\"3\" VALIGN=\"middle\" WIDTH=\"15%\">\n"; print " <TD ALIGN=\"right\" ROWSPAN=\"3\" VALIGN=\"middle\" WIDTH=\"15%\">\n";
print theme_comment_moderation($comment); print comment_moderation($comment);
print " </TD>\n"; print " </TD>\n";
print " </TR>\n"; print " </TR>\n";

View File

@ -140,64 +140,10 @@
<? <?
} }
function commentControl($sid, $title, $threshold, $mode, $order) { function controls($threshold, $mode, $order) {
global $user; print "<HR>";
$query = mysql_query("SELECT sid FROM comments WHERE sid = $sid"); print comment_controls($threshold, $mode, $order);
print "<HR>";
if (!$query) $count = 0; else $count = mysql_num_rows($query);
if (!isset($threshold)) $threshold = 0;
?>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR="<? echo $this->brcolor1; ?>" WIDTH="100%">
<TR><TD>
<?
print "<TABLE BORDER=\"0\" CELLPADDING=\"3\" CELLSPACING=\"1\" WIDTH=\"100%\">";
print " <TR><TD ALIGN=\"center\" BGCOLOR=\"$this->bgcolor1\"><FONT COLOR=\"$this->fgcolor1\"><B>Comment Control</B></FONT></TD></TR>";
print " <TR><TD BGCOLOR=\"$this->bgcolor2\">";
?>
<FORM METHOD="post" ACTION="discussion.php">
<FONT SIZE="2">
<SELECT NAME="threshold">
<OPTION VALUE="-1" <? if ($threshold == -1) { echo "SELECTED"; } ?>>Threshold: -1</OPTION>
<OPTION VALUE="0" <? if ($threshold == 0) { echo "SELECTED"; } ?>>Threshold: 0</OPTION>
<OPTION VALUE="1" <? if ($threshold == 1) { echo "SELECTED"; } ?>>Threshold: 1</OPTION>
<OPTION VALUE="2" <? if ($threshold == 2) { echo "SELECTED"; } ?>>Threshold: 2</OPTION>
<OPTION VALUE="3" <? if ($threshold == 3) { echo "SELECTED"; } ?>>Threshold: 3</OPTION>
<OPTION VALUE="4" <? if ($threshold == 4) { echo "SELECTED"; } ?>>Threshold: 4</OPTION>
<OPTION VALUE="5" <? if ($threshold == 5) { echo "SELECTED"; } ?>>Threshold: 5</OPTION>
</SELECT>
<SELECT NAME="mode">
<OPTION VALUE="nested" <? if ($mode == 'nested') { echo "SELECTED"; } ?>>Nested</OPTION>
<OPTION VALUE="flat" <? if ($mode == 'flat') { echo "SELECTED"; } ?>>Flat</OPTION>
<OPTION VALUE="threaded" <? if (!isset($mode) || $mode=='threaded' || $mode=="") { echo "SELECTED"; } ?>>Threaded</OPTION>
</SELECT>
<SELECT NAME="order">
<OPTION VALUE="0" <? if (!$order) { echo "SELECTED"; } ?>>Oldest first</OPTION>
<OPTION VALUE="1" <? if ($order == 1) { echo "SELECTED"; } ?>>Newest first</OPTION>
<OPTION VALUE="2" <? if ($order == 2) { echo "SELECTED"; } ?>>Highest scoring first</OPTION>
</SELECT>
<INPUT TYPE="hidden" NAME="id" VALUE="<? echo "$sid"; ?>">
<INPUT TYPE="submit" NAME="op" VALUE="Save">
</FONT>
<?
$number=discussion_num_filtered($sid, $pid);
if ($number>0)
{
?>
<BR><SMALL>There are at least <? echo format_plural($number, "comment", "comments"); ?> below your threshold.</SMALL>
<?
}
print "</TD></TR>";
print "</TABLE>";
?>
</TD></TR>
</TABLE><BR>
<?
} }
function comment($comment, $link, $thread = "") { function comment($comment, $link, $thread = "") {
@ -224,7 +170,7 @@
// Moderation: // Moderation:
echo " <TD ALIGN=\"right\" ROWSPAN=\"3\" VALIGN=\"middle\" WIDTH=\"15%\">"; echo " <TD ALIGN=\"right\" ROWSPAN=\"3\" VALIGN=\"middle\" WIDTH=\"15%\">";
print theme_comment_moderation($comment); print comment_moderation($comment);
echo " </TD>"; echo " </TD>";
echo " </TR>"; echo " </TR>";