summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2000-07-06 09:37:30 +0000
committerDries Buytaert <dries@buytaert.net>2000-07-06 09:37:30 +0000
commit4e132c9fd5ee53b5ad7317de6899f1ea2207ab09 (patch)
treea14f584c7dcedf2782d2b4232f90fac117b72c3c
parent14b12b3a6a97f0b927a3cf6b4dc8c197536d6a4f (diff)
downloadbrdo-4e132c9fd5ee53b5ad7317de6899f1ea2207ab09.tar.gz
brdo-4e132c9fd5ee53b5ad7317de6899f1ea2207ab09.tar.bz2
* _Major_ update of the comments and moderation system: it's a lot more
stream-lined and more compact. There are a few parts I like to optimize prior to heading towards comment moderation. Please test, report bugs and update the footer()-part of your themes a bit (see my theme)!!! -- Dries
-rw-r--r--article.php21
-rw-r--r--comments.php302
-rw-r--r--database.inc4
-rw-r--r--functions.inc37
-rw-r--r--search.php4
-rw-r--r--submission.inc9
-rw-r--r--submission.php45
7 files changed, 61 insertions, 361 deletions
diff --git a/article.php b/article.php
deleted file mode 100644
index 63c2277f4..000000000
--- a/article.php
+++ /dev/null
@@ -1,21 +0,0 @@
-<?
-
- include "config.inc";
- include "functions.inc";
- include "theme.inc";
-
- if ($save) {
- db_query("UPDATE users SET umode='$mode', uorder='$order', thold='$thold' where id='$user->id'");
- $user->rehash();
- }
-
- if ($op == "reply") Header("Location: comments.php?op=reply&pid=0&sid=$sid&mode=$mode&order=$order&thold=$thold");
-
- $result = db_query("SELECT stories.*, users.userid FROM stories LEFT JOIN users ON stories.author = users.id WHERE stories.status = 2 AND stories.id = $id");
- $story = db_fetch_object($result);
-
- $theme->header();
- $theme->article($story, "[ <A HREF=\"\"><FONT COLOR=\"$theme->hlcolor2\">home</FONT></A> | <A HREF=\"comments.php?op=reply&pid=0&sid=$story->id\"><FONT COLOR=\"$theme->hlcolor2\">add a comment</FONT></A> ]");
- include "comments.php";
- $theme->footer();
-?> \ No newline at end of file
diff --git a/comments.php b/comments.php
deleted file mode 100644
index de7e66ba1..000000000
--- a/comments.php
+++ /dev/null
@@ -1,302 +0,0 @@
-<?
-
-function comments_kids ($cid, $mode, $order = 0, $thold = 0, $level = 0, $dummy = 0) {
- global $user, $theme;
-
- include "config.inc";
- $comments = 0;
-
- $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");
-
- if ($mode == "nested") {
- while ($comment = db_fetch_object($result)) {
- if ($$comment->score >= $thold) {
- if ($level && !$comments) print "<UL>";
- $comments++;
-
- $link = "<A HREF=\"comments.php?op=reply&pid=$comment->cid&sid=$comment->sid&mode=$mode&order=$order&thold=$thold\"><FONT COLOR=\"$theme->hlcolor2\">reply to this comment</FONT></A>";
- $theme->comment($comment->userid, $comment->subject, $comment->comment, $comment->timestamp, $comment->url, $comment->femail, $comment->score, $comment->cid, $link);
-
- comments_kids($comment->cid, $mode, $order, $thold, $level + 1, $dummy + 1);
- }
- }
- }
- elseif ($mode == "flat") {
- while ($comment = db_fetch_object($result)) {
- if ($comment->score >= $thold) {
- $link = "<A HREF=\"comments.php?op=reply&pid=$comment->cid&sid=$comment->sid&mode=$mode&order=$order&thold=$thold\"><FONT COLOR=\"$theme->hlcolor2\">reply to this comment</FONT></A>";
- $theme->comment($comment->userid, $comment->subject, $comment->comment, $comment->timestamp, $comment->url, $comment->femail, $comment->score, $comment->cid, $link);
- }
- comments_kids($comment->cid, $mode, $order, $thold);
- }
- }
- elseif ($mode == "disabled") {
- // do nothing
- }
- else {
- print "ERROR: we should not get here!";
- }
-
- if ($level && $comments) {
- print "</UL>";
- }
-}
-
-function comments_childs($cid, $mode, $order, $thold, $level = 0, $thread) {
- global $theme, $user;
-
- ### Perform SQL query:
- $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");
-
- if ($level == 0) $thread = "";
- $comments = 0;
-
- while ($comment = db_fetch_object($result)) {
- if ($level && !$comments) {
- $thread .= "<UL>";
- }
-
- $comments++;
-
- ### Compose link:
- $thread .= "<LI><A HREF=\"comments.php?op=show&cid=$comment->cid&pid=$comment->pid&sid=$comment->sid";
- $thread .= ($mode) ? "&mode=$mode" : "&mode=threaded";
- $thread .= ($order) ? "&order=$order" : "&order=0";
- $thread .= ($thold) ? "&thold=$thold" : "&thold=0";
- $thread .= "\">$comment->subject</A> by $comment->userid <SMALL>(". date("D, M d, Y - H:i:s", $comment->timestamp) .")<SMALL></LI>";
-
- ### Recursive:
- comments_childs($comment->cid, $mode, $order, $thold, $level + 1, &$thread);
- }
-
- if ($level && $comments) {
- $thread .= "</UL>";
- }
-
- return $thread;
-}
-
-function comments_display ($sid = 0, $pid = 0, $cid = 0, $mode = "threaded", $order = 0, $thold = 0, $level = 0, $nokids = 0) {
- global $user, $theme;
-
- ### Display `comment control'-box:
- $theme->commentControl($sid, $title, $thold, $mode, $order);
-
- ### Compose query:
- $query = "SELECT c.*, u.* FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.sid = $sid AND c.pid = $pid";
- if ($mode == 'threaded' || mode == 'nested') {
- if ($thold != "") $query .= " AND score >= $thold";
- else $query .= " AND score >= 0";
- }
- if ($order == 1) $query .= " ORDER BY timestamp DESC";
- if ($order == 2) $query .= " ORDER BY score DESC";
- $result = db_query("$query");
-
- ### Display the comments:
- while ($comment = db_fetch_object($result)) {
- ### Dynamically compose the `reply'-link:
- if ($pid != 0) {
- list($pid) = mysql_fetch_row(mysql_query("SELECT pid FROM comments WHERE cid = $comment->pid"));
- $link = "<A HREF=\"comments.php?op=show&pid=$pid&sid=$comment->sid&mode=$mode&order=$order&thold=$thold\"><FONT COLOR=\"$theme->hlcolor2\">return to parent</FONT></A> | <A HREF=\"comments.php?op=reply&pid=$comment->cid&sid=$comment->sid&mode=$mode&order=$order&thold=$thold\"><FONT COLOR=\"$theme->hlcolor2\">reply to this comment</FONT></A>";
- }
- else {
- $link = "<A HREF=\"comments.php?op=reply&pid=$comment->cid&sid=$comment->sid&mode=$mode&order=$order&thold=$thold\"><FONT COLOR=\"$theme->hlcolor2\">reply to this comment</FONT></A> ";
- }
-
- ### Display the comments:
- if ($mode == "threaded") {
- $thread = comments_childs($comment->cid, $mode, $order, $thold);
- $theme->comment($comment->userid, $comment->subject, $comment->comment, $comment->timestamp, $comment->url, $comment->femail, $comment->score, $comment->cid, $link, $thread);
- }
- else {
- $theme->comment($comment->userid, $comment->subject, $comment->comment, $comment->timestamp, $comment->url, $comment->femail, $comment->score, $comment->cid, $link);
- comments_kids($comment->cid, $mode, $order, $thold, $level);
- }
- }
-}
-
-function comments_reply($pid, $sid, $mode, $order, $thold) {
- global $user, $theme;
-
- ### 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($item->userid, $item->subject, $item->comment, $item->timestamp, $item->url, $item->femail, $item->score, $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 = 2 AND stories.id = $sid"));
- $theme->article($item, "");
- }
-
- ### Build reply form:
- $output .= "<FORM ACTION=\"comments.php\" METHOD=\"post\">\n";
-
- ### Name field:
- if ($user) {
- $output .= "<P>\n";
- $output .= " <B>Your name:</B><BR>\n";
- $output .= " <A HREF=\"account.php\">$user->userid</A> &nbsp; &nbsp; <FONT SIZE=\"2\">[ <A HREF=\"account.php?op=logout\">logout</A> ]</FONT>\n";
- $output .= "</P>\n";
- }
- else {
- $output .= "<P>\n";
- $output .= " <B>Your name:</B><BR>\n";
- $output .= " $anonymous\n";
- $output .= "</P>\n";
- }
-
- ### Subject field:
- $output .= "<P>\n";
- $output .= " <B>Subject:</B><BR>\n";
- if (!eregi("Re:",$item->subject)) $item->subject = "Re: $item->subject";
- // Only one 'Re:' will just do fine. ;)
- $output .= " <INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"$item->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\">$user->signature</TEXTAREA><BR>\n";
- $output .= "</P>\n";
-
- ### Hidden fields:
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"pid\" VALUE=\"$pid\">\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"sid\" VALUE=\"$sid\">\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"mode\" VALUE=\"$mode\">\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"order\" VALUE=\"$order\">\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"thold\" VALUE=\"$thold\">\n";
-
- ### Preview button:
- $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview comment\"> (You must preview at least once before you can submit.)\n";
- $output .= "</FORM>\n";
-
- $theme->box("Reply", $output);
-}
-
-function comment_preview($pid, $sid, $subject, $comment, $mode, $order, $thold) {
- global $user, $theme;
-
- ### Preview comment:
- if ($user) $theme->comment("", $subject, $comment, time(), "", "", "na", "", "reply to this comment");
- else $theme->comment($user->userid, $subject, $comment, time(), $user->url, $user->femail, "na", "", "reply to this comment");
-
- ### Build reply form:
- $output .= "<FORM ACTION=\"comments.php\" METHOD=\"post\">\n";
-
- ### Name field:
- if ($user) {
- $output .= "<P>\n";
- $output .= " <B>Your name:</B><BR>\n";
- $output .= " <A HREF=\"account.php\">$user->userid</A> &nbsp; &nbsp; <FONT SIZE=\"2\">[ <A HREF=\"account.php?op=logout\">logout</A> ]</FONT>\n";
- $output .= "</P>\n";
- }
- else {
- $output .= "<P>\n";
- $output .= " <B>Your name:</B><BR>\n";
- $output .= " $anonymous\n";
- $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=\"$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\">$comment</TEXTAREA><BR>\n";
- $output .= "</P>\n";
-
- ### Hidden fields:
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"pid\" VALUE=\"$pid\">\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"sid\" VALUE=\"$sid\">\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"mode\" VALUE=\"$mode\">\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"order\" VALUE=\"$order\">\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"thold\" VALUE=\"$thold\">\n";
-
- ### Preview and submit buttons:
- 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";
- $output .= "<P>\n";
- $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview comment\">\n";
- $output .= "</P>\n";
- }
- else {
- $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview comment\">\n";
- $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Post comment\">\n";
- $output .= "</FORM>\n";
- }
-
- $theme->box("Reply", $output);
-}
-
-function comment_post($pid, $sid, $subject, $comment, $mode, $order, $thold) {
- global $user, $theme;
-
- ### Check for fake threads:
- $fake = db_result(db_query("SELECT COUNT(*) FROM stories WHERE id = $sid"), 0);
-
- ### Check for duplicate comments:
- $duplicate = db_result(db_query("SELECT COUNT(*) FROM comments WHERE pid = '$pid' AND sid = '$sid' AND subject = '". addslashes($subject) ."' AND comment = '". addslashes($comment) ."'"), 0);
-
- if ($fake != 1) {
- $theme->box("fake comment", "fake comment: $fake");
- }
- elseif ($duplicate != 0) {
- $theme->box("duplicate comment", "duplicate comment: $duplicate");
- }
- else {
- if ($user) {
- ### Add comment to database:
- db_query("INSERT INTO comments (pid, sid, author, subject, comment, hostname, timestamp) VALUES ($pid, $sid, $user->id, '". addslashes($subject) ."', '". addslashes($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."')");
-
- ### Compose header:
- $header = "article.php?id=$sid";
- $header .= ($mode) ? "&mode=$mode" : "&mode=threaded";
- $header .= ($order) ? "&order=$order" : "&order=0";
- $header .= ($thold) ? "&thold=$thold" : "&thold=0";
- }
- else {
- ### Add comment to database:
- db_query("INSERT INTO comments (pid, sid, subject, comment, hostname, timestamp) VALUES ($pid, $sid, '". addslashes($subject) ."', '". addslashes($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."')");
-
- ### Compose header:
- $header .= "article.php?id=$sid&mode=threaded&order=1&thold=0";
- }
- header("Location: $header");
- }
-}
-
-if (strstr($PHP_SELF, "comments.php")) {
- include "theme.inc";
- include "functions.inc";
-}
-
-switch($op) {
- case "Preview comment":
- $theme->header();
- comment_preview($pid, $sid, $subject, $comment, $mode, $order, $thold);
- $theme->footer();
- break;
- case "Post comment":
- comment_post($pid, $sid, $subject, $comment, $mode, $order, $thold);
- break;
- case "reply":
- $theme->header();
- comments_reply($pid, $sid, $mode, $order, $thold);
- $theme->footer();
- break;
- case "show":
- $theme->header();
- comments_display($sid, $pid, $cid, $mode, $order, $thold);
- $theme->footer();
- break;
- default:
- comments_display($id, 0, 0, $mode, $order, $thold);
-}
-
-?> \ No newline at end of file
diff --git a/database.inc b/database.inc
index 83da9e602..4311873b1 100644
--- a/database.inc
+++ b/database.inc
@@ -7,10 +7,6 @@
* just adjust the handlers to your needs.
*/
-///////////////////////////////////////////////////////////////////////////
-// NOTE: these functions are under construction and in no way finilized! //
-///////////////////////////////////////////////////////////////////////////
-
function db_connect() {
include "config.inc";
mysql_pconnect($dbhost, $dbuname, $dbpass) or die(mysql_Error());
diff --git a/functions.inc b/functions.inc
index e118e98c5..fde0bc37c 100644
--- a/functions.inc
+++ b/functions.inc
@@ -30,13 +30,13 @@ function morelink_bytes($theme, $story) {
### Compose more-link:
$morelink = "[ ";
if ($story->article) {
- $morelink .= "<A HREF=\"article.php?id=$story->id";
+ $morelink .= "<A HREF=\"discussion.php?id=$story->id";
$morelink .= ($user->umode) ? "&mode=$user->umode" : "&mode=threaded";
$morelink .= ($user->uorder) ? "&order=$user->uorder" : "&order=0";
$morelink .= ($user->thold) ? "&thold=$user->thold" : "&thold=0";
$morelink .= "\"><FONT COLOR=\"$theme->hlcolor2\"><B>read more</B></FONT></A> | $bytes bytes in body | ";
}
- $morelink .= "<A HREF=\"article.php?id=$story->id";
+ $morelink .= "<A HREF=\"discussion.php?id=$story->id";
$morelink .= ($user->umode) ? "&mode=$user->umode" : "&mode=threaded";
$morelink .= ($user->uorder) ? "&order=$user->uorder" : "&order=0";
$morelink .= ($user->thold) ? "&thold=$user->thold" : "&thold=0";
@@ -96,9 +96,32 @@ function addRefer($url) {
}
}
+function id2story($id) {
+ ### Perform query:
+ $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.id = $id");
+ return db_fetch_object($result);
+}
+
+function displayModerationResults($theme, $story) {
+ global $user;
+
+ if ($user->id && $story->id && $vote = $user->getHistory("s$story->id")) {
+ $output .= "<P><B>You voted `$vote'.</B></P>\n";
+ $output .= "<P>\n";
+ $output .= "<B>Other people voted:</B><BR>\n";
+
+ $result = db_query("SELECT * FROM users WHERE history LIKE '%s$story->id%'");
+ while ($account = db_fetch_object($result)) {
+ $output .= "<A HREF=\"account.php?op=info&uname=$account->userid\">$account->userid</A> voted `". getHistory($account->history, "s$story->id") ."'.<BR>";
+ }
+
+ $theme->box("Moderation results", $output);
+ }
+}
+
function displayRelatedLinks($theme, $story) {
### Parse story for <A HREF="">-tags:
- $text = "$story->abstract $story->editorial $story->article";
+ $text = "$story->abstract $story->updates $story->article";
while ($text = stristr($text, "<A HREF=")) {
$link = substr($text, 0, strpos(strtolower($text), "</a>") + 4);
$text = stristr($text, "</A>");
@@ -125,14 +148,14 @@ function displayOldHeadlines($theme, $num = 10) {
}
if ($user->userid) {
- $content .= "<LI><A HREF=\"article.php?id=$story->id";
+ $content .= "<LI><A HREF=\"discussion.php?id=$story->id";
$content .= ($user->umode) ? "&mode=$user->umode" : "&mode=threaded";
$content .= ($user->uorder) ? "&order=$user->uorder" : "&order=0";
$content .= ($user->thold) ? "&thold=$user->thold" : "&thold=0";
$content .= "\">$story->subject</A></LI>";
}
else {
- $content .= "<LI><A HREF=\"article.php?id=$story->id&mode=threaded&order=1&thold=0\">$story->subject</A></LI>";
+ $content .= "<LI><A HREF=\"discussion.php?id=$story->id&mode=threaded&order=1&thold=0\">$story->subject</A></LI>";
}
}
$content .= "<P ALIGN=\"right\">[ <A HREF=\"search.php\"><FONT COLOR=\"$theme->hlcolor2\">more</FONT></A> ]</P>";
@@ -147,14 +170,14 @@ function displayNewHeadlines($theme, $num = 10) {
$result = db_query("SELECT id, subject FROM stories WHERE status = 2 ORDER BY id DESC LIMIT $num");
while ($story = db_fetch_object($result)) {
if ($user->userid) {
- $content .= "<LI><A HREF=\"article.php?id=$story->id";
+ $content .= "<LI><A HREF=\"discussion.php?id=$story->id";
$content .= ($user->umode) ? "&mode=$user->umode" : "&mode=threaded";
$content .= ($user->uorder) ? "&order=$user->uorder" : "&order=0";
$content .= ($user->thold) ? "&thold=$user->thold" : "&thold=0";
$content .= "\">$story->subject</A></LI>";
}
else {
- $content .= "<LI><A HREF=\"article.php?id=$story->id&mode=threaded&order=1&thold=0\">$story->subject</A></LI>";
+ $content .= "<LI><A HREF=\"discussion.php?id=$story->id&mode=threaded&order=1&thold=0\">$story->subject</A></LI>";
}
}
$content .= "<P ALIGN=\"right\">[ <A HREF=\"search.php\"><FONT COLOR=\"$theme->hlcolor2\">more</FONT></A> ]</P>";
diff --git a/search.php b/search.php
index 48e761c0e..c9568165b 100644
--- a/search.php
+++ b/search.php
@@ -57,14 +57,14 @@
$num++;
if ($user) {
- $link = "<A HREF=\"article.php?id=$entry->id";
+ $link = "<A HREF=\"discussion.php?id=$entry->id";
if (isset($user->umode)) { $link .= "&mode=$user->umode"; } else { $link .= "&mode=threaded"; }
if (isset($user->uorder)) { $link .= "&order=$user->uorder"; } else { $link .= "&order=0"; }
if (isset($user->thold)) { $link .= "&thold=$user->thold"; } else { $link .= "&thold=0"; }
$link .= "\">$entry->subject</A>";
}
else {
- $link = "<A HREF=\"article.php?id=$entry->id&mode=threaded&order=1&thold=0\">$entry->subject</A>";
+ $link = "<A HREF=\"discussion.php?id=$entry->id&mode=threaded&order=1&thold=0\">$entry->subject</A>";
}
$output .= "<P>$num) <B>$link</B><BR><SMALL>by <B><A HREF=\"account.php?op=info&uname=$entry->userid\">$entry->userid</A></B>, posted on ". date("l, F d, Y - H:i A", $entry->timestamp) .".</SMALL></P>\n";
diff --git a/submission.inc b/submission.inc
index 55f85e051..8dc60e3c8 100644
--- a/submission.inc
+++ b/submission.inc
@@ -10,7 +10,7 @@ function submission_score($id) {
return ($result) ? mysql_result($result, 0) : 0;
}
-function submission_vote($id, $vote) {
+function submission_vote($id, $vote, $comment) {
global $user;
include "config.inc";
@@ -19,6 +19,9 @@ function submission_vote($id, $vote) {
### Update submission's score- and votes-field:
db_query("UPDATE stories SET score = score $vote, votes = votes + 1 WHERE id = $id");
+ ### Update the comments (if required):
+ db_query("INSERT INTO comments (sid, subject, comment, hostname, timestamp) VALUES($id, '". addslashes(substr($comment, 0, 29)) ." ...', '". addslashes($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."')");
+
### Update user's history record:
$user->setHistory("s$id", "$vote"); // s = submission
$user->save();
@@ -26,8 +29,8 @@ function submission_vote($id, $vote) {
### Update story table (if required):
$result = db_query("SELECT * FROM stories WHERE id = $id");
if ($submission = db_fetch_object($result)) {
- if ($submission->score >= $submission_post_threshold) db_query("UPDATE stories SET status = 2, timestamp = '". time() ."' WHERE id = $id");
- if ($submission->score <= $submission_dump_threshold) db_query("UPDATE stories SET status = 0, timestamp = '". time() ."' WHERE id = $id");
+# if ($submission->score >= $submission_post_threshold) db_query("UPDATE stories SET status = 2, timestamp = '". time() ."' WHERE id = $id");
+# if ($submission->score <= $submission_dump_threshold) db_query("UPDATE stories SET status = 0, timestamp = '". time() ."' WHERE id = $id");
}
}
}
diff --git a/submission.php b/submission.php
index fd967db25..a734e1433 100644
--- a/submission.php
+++ b/submission.php
@@ -30,33 +30,34 @@ function submission_displayMain() {
function submission_displayItem($id) {
global $PHP_SELF, $theme, $user;
- include "config.inc";
+ if ($vote = getHistory($user->history, "s$id")) {
+ header("Location: discussion.php?id=$id");
+ }
+ else {
+ include "config.inc";
- $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.id = $id");
- $submission = db_fetch_object($result);
+ $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.id = $id");
+ $submission = db_fetch_object($result);
- $theme->header();
- $theme->article($submission, "[ <A HREF=\"$PHP_SELF\"><FONT COLOR=\"$theme->hlcolor2\">back</FONT></A> ]");
+ $theme->header();
+ $theme->article($submission, "[ <A HREF=\"$PHP_SELF\"><FONT COLOR=\"$theme->hlcolor2\">back</FONT></A> ]");
+
+ print "<FORM ACTION=\"$PHP_SELF\" METHOD=\"post\">\n";
- if ($vote = getHistory($user->history, "s$submission->id")) {
- print "<P><B>You voted `$vote' for this story!</B><BR><B>Score:</B> $submission->score<BR><B>Votes:</B> $submission->votes</P>\n";
print "<P>\n";
- print "<B>Other people voted:</B><BR>\n";
-
- $result = db_query("SELECT * FROM users WHERE history LIKE '%s$submission->id%'");
- while ($account = db_fetch_object($result)) {
- print "<A HREF=\"account.php?op=userinfo&uname=$account->userid\">$account->userid</A> voted `". getHistory($account->history, "s$submission->id") ."'.<BR>";
- }
- }
- else {
- print "<FORM ACTION=\"$PHP_SELF\" METHOD=\"post\">\n";
+ print " <B>Vote:</B><BR>\n";
print " <SELECT NAME=\"vote\">\n";
- foreach ($submission_votes as $key=>$value) {
- print " <OPTION VALUE=\"$value\">". $key ."</OPTION>\n";
- }
+ foreach ($submission_votes as $key=>$value) print " <OPTION VALUE=\"$value\">". $key ."</OPTION>\n";
print " </SELECT>\n";
- print " <INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$submission->id\">\n";
- print " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Vote\">\n";
+ print "</P>\n";
+
+ print "<P>\n";
+ print " <B>Comment:</B><BR>\n";
+ print " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"7\" NAME=\"comment\"></TEXTAREA>\n";
+ print "</P>\n";
+
+ print "<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$submission->id\">\n";
+ print "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Vote\">\n";
print "</FORM>\n";
}
@@ -69,7 +70,7 @@ if ($user) {
submission_displayItem($id);
break;
case "Vote";
- submission_vote($id, $vote);
+ submission_vote($id, $vote, $comment);
submission_displayItem($id);
break;
default: