Commit 0f5a60e1 authored by Dries's avatar Dries
Browse files

IMPORANT - IMPORTANT - :)
=========================

Wulp.  I did a major upgrade by (a) breaking a lot of stuff and (b) by
re-doing those things in a much better way.  I redesigned the stories
and submissions SQL tables, the way they work and the way they co-
operate together.

In addition, I changed the way parameters are passed to
$theme->abstract() and $theme->article().  Instead of passing a
sh!tload of parameters that only cluttered the code and required too
much pre-processing on the engine-side, we now pass a singly object
$story.  $story has more variables then the paramaters we used to pass,
so it allows for better theming (if you feel like it).

I'm not finished yet but I decided to upload my changes so you can
start patching and updating your themes: PLEASE update your themes
ASAP!  I don't plan making heavy changes like this again, so don't
get intimiated. ;)  You mainly have to update article() and abstract()
as well as a minor update of footer():

article(), abstract():
----------------------
 - use the $story object - see my theme!
 - the morelink can now be themed.  Currently you can use the function
   morelink_bytes() in function.inc to `render' the old morelink.  The
   idea is to make a morelink_words() or morelink_lines() sooner or
   later because "188 bytes in body" is not half as clear as "52 words
   in body".  Clearly, "52 words" is much more informative. ;-)

footer():
---------
 - in the article-part, you need to update the displayRelatedLinks():
   instead of passing it $sid, you need to pass it $story (after you
   globaled $story).

Everything should display correct on the following pages:
 - main page
 - article page (follow a `read more | xxx bytes in bdoy | x comments' link)
 - submission queue
Check if they work with your theme: they should as they work fine for
me (theme `Dries') ...  If you got stuck, just look at my theme or ask
for a hand on the list!


Hopefully you can update your themes asap.  Thanks in advance.
parent 8a7690af
<?PHP
if(!isset($sid) && !isset($tid)) { exit(); }
<?
include "config.inc";
include "functions.inc";
include "theme.inc";
dbconnect();
if ($save) {
mysql_query("UPDATE users SET umode='$mode', uorder='$order', thold='$thold' where id='$user->id'");
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");
if ($op == "reply") Header("Location: comments.php?op=reply&pid=0&sid=$sid&mode=$mode&order=$order&thold=$thold");
$result = mysql_query("SELECT * FROM stories WHERE sid = $sid");
list($sid, $aid, $subject, $time, $abstract, $comments, $article, $category, $informant, $department) = mysql_fetch_row($result);
$result = db_query("SELECT * FROM stories WHERE id = $id");
$story = db_fetch_object($result);
$theme->header();
$reply = "[ <A HREF=\"\"><FONT COLOR=\"$theme->hlcolor2\">home</FONT></A> | <A HREF=\"comments.php?op=reply&pid=0&sid=$story->sid\"><FONT COLOR=\"$theme->hlcolor2\">add a comment</FONT></A> ]";
$theme->article($story, $reply);
$reply = "[ <A HREF=\"\"><FONT COLOR=\"$theme->hlcolor2\">home</FONT></A> | <A HREF=\"comments.php?op=reply&pid=0&sid=$sid\"><FONT COLOR=\"$theme->hlcolor2\">add a comment</FONT></A> ]";
$theme->article($aid, $informant, $time, stripslashes($subject), $department, stripslashes($abstract), stripslashes($comments), stripslashes($article), $reply);
if ($mode != "nocomments") include "comments.php";
// if ($mode != "nocomments") include "comments.php";
// 21/06/2000 - temporary disabled commnents
$theme->footer();
?>
\ No newline at end of file
......@@ -24,8 +24,30 @@ function dbconnect() {
mysql_select_db("$dbname") or die ("Unable to select database");
}
function counter() {
db_query("UPDATE vars SET value=value+1 where name='totalhits'");
function morelink_bytes($theme, $story) {
### Compose more-link:
$morelink = "[ ";
if ($story->article) {
$morelink .= "<A HREF=\"article.php?id=$story->id";
if (isset($user->umode)) { $morelink .= "&mode=$user->umode"; } else { $morelink .= "&mode=threaded"; }
if (isset($user->uorder)) { $morelink .= "&order=$user->uorder"; } else { $morelink .= "&order=0"; } $bytes = strlen($story->article);
$morelink .= "\"><FONT COLOR=\"$theme->hlcolor2\"><B>read more</B></FONT></A> | $bytes bytes in body | ";
}
$morelink .= "<A HREF=\"article.php?id=$story->id";
if (isset($user->umode)) { $morelink .= "&mode=$user->umode"; } else { $morelink .= "&mode=threaded"; }
if (isset($user->uorder)) { $morelink .= "&order=$user->uorder"; } else { $morelink .= "&order=0"; }
if (isset($user->thold)) { $morelink .= "&thold=$user->thold"; } else { $morelink .= "&thold=0"; }
$morelink .= "\"><FONT COLOR=\"$theme->hlcolor2\">$story->comments comments</FONT></A> ]";
return $morelink;
}
function morelink_words($theme, $story) {
// todo
}
function morelink_lines($theme, $story) {
// todo
}
function FixQuotes ($what = "") {
......@@ -71,48 +93,43 @@ function addRefer($url) {
}
}
function displayRelatedLinks($theme, $sid = 0) {
$result = db_query("SELECT * FROM stories WHERE sid = $sid");
if ($story = db_fetch_object($result)) {
### parse story for A HREF-tags:
$text = "$story->abstract $story->comments $story->article";
while ($text = stristr($text, "<A HREF=")) {
$link = substr($text, 0, strpos(strtolower($text), "</a>") + 4);
$text = stristr($text, "</A>");
if (!stristr($link, "mailto:")) $content .= "<LI>$link</LI>";
}
function displayRelatedLinks($theme, $story) {
### Parse story for <A HREF="">-tags:
$text = "$story->abstract $story->editorial $story->article";
while ($text = stristr($text, "<A HREF=")) {
$link = substr($text, 0, strpos(strtolower($text), "</a>") + 4);
$text = stristr($text, "</A>");
if (!stristr($link, "mailto:")) $content .= "<LI>$link</LI>";
}
### default related links:
$content .= " <LI>More about <A HREF=\"search.php?category=$story->category\">$story->category</A>.</LI>";
$content .= " <LI>Also by <A HREF=\"search.php?author=$story->aid\">$story->aid</A>.</LI>";
### Default related links:
$content .= " <LI>More about <A HREF=\"search.php?category=$story->category\">$story->category</A>.</LI>";
$content .= " <LI>Also by <A HREF=\"search.php?author=$story->aid\">$story->userid</A>.</LI>";
$theme->box("Related links", $content);
}
$theme->box("Related links", $content);
}
function displayOldHeadlines($theme, $num = 10) {
global $user;
if ($user->storynum) $result = db_query("SELECT sid, subject, time FROM stories WHERE status = 1 ORDER BY time DESC LIMIT $user->storynum, $num");
else $result = db_query("SELECT sid, subject, time FROM stories WHERE status = 1 ORDER BY time DESC LIMIT $num, $num");
while ($story = db_fetch_object($result)) {
if ($time != date("F jS", $story->time)) {
$content .= "<P><B>". date("l, F jS", $story->time) ."</B></P>";
$time = date("F jS", $story->time);
if ($user->storynum) $result = db_query("SELECT id, subject, timestamp FROM stories WHERE status = 2 ORDER BY timestamp DESC LIMIT $user->storynum, $num");
else $result = db_query("SELECT id, subject, timestamp FROM stories WHERE status = 2 ORDER BY timestamp DESC LIMIT $num, $num");
while ($story = db_fetch_object($result)) {
if ($time != date("F jS", $story->timestamp)) {
$content .= "<P><B>". date("l, F jS", $story->timestamp) ."</B></P>";
$time = date("F jS", $story->timestamp);
}
if ($user) {
$content .= "<LI><A HREF=\"article.php?sid=$story->sid";
$content .= "<LI><A HREF=\"article.php?id=$story->id";
if (isset($user->umode)) { $content .= "&mode=$user->umode"; } else { $content .= "&mode=threaded"; }
if (isset($user->uorder)) { $content .= "&order=$user->uorder"; } else { $content .= "&order=0"; }
if (isset($user->thold)) { $content .= "&thold=$user->thold"; } else { $content .= "&thold=0"; }
$content .= "\">$story->subject</A></LI>";
}
else {
$content .= "<LI><A HREF=\"article.php?sid=$story->sid&mode=threaded&order=1&thold=0\">$story->subject</A></LI>";
$content .= "<LI><A HREF=\"article.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>";
......@@ -124,17 +141,17 @@ function displayNewHeadlines($theme, $num = 10) {
global $user;
$content = "";
$result = db_query("SELECT sid, subject FROM stories WHERE status = 1 ORDER BY sid DESC LIMIT $num");
while(list($sid, $subject) = mysql_fetch_row($result)) {
$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) {
$content .= "<LI><A HREF=\"article.php?sid=$sid";
$content .= "<LI><A HREF=\"article.php?id=$story->id";
if (isset($user->umode)) { $content .= "&mode=$user->umode"; } else { $content .= "&mode=threaded"; }
if (isset($user->uorder)) { $content .= "&order=$user->uorder"; } else { $content .= "&order=0"; }
if (isset($user->uorder)) { $content .= "&order=$user->uorder"; } else { $content .= "&order=0"; }
if (isset($user->thold)) { $content .= "&thold=$user->thold"; } else { $content .= "&thold=0"; }
$content .= "\">$subject</A></LI>";
$content .= "\">$story->subject</A></LI>";
}
else {
$content .= "<LI><A HREF=\"article.php?sid=$sid&mode=threaded&order=1&thold=0\">$subject</A></LI>";
$content .= "<LI><A HREF=\"article.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>";
......
......@@ -3,44 +3,25 @@
include "functions.inc";
include "theme.inc";
$theme->header();
### Initialize variables:
### Initialize/pre-process variables:
$number = ($user->storynum) ? $user->storynum : 10;
$date = ($date) ? $date : time();
### Perform query:
$result = db_query("SELECT stories.*, COUNT(comments.sid) AS comments FROM stories LEFT JOIN comments ON stories.sid = comments.sid WHERE stories.status = 1 AND stories.time <= $date GROUP BY stories.sid ORDER BY stories.sid DESC LIMIT $number");
// Note: we use a LEFT JOIN to retrieve the number of comments associated
// with each story. By retrieving this data now, we elimate a *lot*
// of individual queries that would otherwise be required inside the
// while-loop. If there is no matching record for the right table in
// the ON-part of the LEFT JOIN, a row with all columns set to NULL
// is used for the right table. This is required, as not every story
// has a counterpart in the comments table (at a given time).
$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.id DESC LIMIT $number");
// Note on performance:
// we use a LEFT JOIN to retrieve the number of comments associated
// with each story. By retrieving this data now (outside the while-
// loop), we elimate a *lot* of individual queries that would other-
// wise be required (inside the while-loop). If there is no matching
// record for the right table in the ON-part of the LEFT JOIN, a row
// with all columns set to NULL is used for the right table. This is
// required, as not every story has a counterpart in the comments
// table (at a given time).
### Display stories:
while ($story = db_fetch_object($result)) {
### Compose more-link:
$morelink = "[ ";
if ($story->article) {
$morelink .= "<A HREF=\"article.php?sid=$story->sid";
if (isset($user->umode)) { $morelink .= "&mode=$user->umode"; } else { $morelink .= "&mode=threaded"; }
if (isset($user->uorder)) { $morelink .= "&order=$user->uorder"; } else { $morelink .= "&order=0"; }
$bytes = strlen($story->article);
$morelink .= "\"><FONT COLOR=\"$theme->hlcolor2\"><B>read more</B></FONT></A> | $bytes bytes in body | ";
}
$morelink .= "<A HREF=\"article.php?sid=$story->sid";
if (isset($user->umode)) { $morelink .= "&mode=$user->umode"; } else { $morelink .= "&mode=threaded"; }
if (isset($user->uorder)) { $morelink .= "&order=$user->uorder"; } else { $morelink .= "&order=0"; }
if (isset($user->thold)) { $morelink .= "&thold=$user->thold"; } else { $morelink .= "&thold=0"; }
$morelink .= "\"><FONT COLOR=\"$theme->hlcolor2\">$story->comments comments</FONT></A> ]";
### Display story:
$theme->abstract($story->aid, $story->informant, $story->time, stripslashes($story->subject), stripslashes($story->abstract), stripslashes($story->comments), $story->category, $story->department, $morelink);
}
$theme->header();
while ($story = db_fetch_object($result)) $theme->abstract($story);
$theme->footer();
?>
......@@ -8,7 +8,6 @@
dbconnect();
$terms = stripslashes($terms);
$output .= "<TABLE WIDTH=\"100%\" BORDER=\"0\">";
$output .= " <TR VALIGN=\"center\">";
$output .= " <TD COLSPAN=3>";
......
<?
function submission_count() {
$result = db_query("SELECT COUNT(id) FROM submissions WHERE status = 1");
$result = db_query("SELECT COUNT(id) FROM stories WHERE status = 1");
return ($result) ? mysql_result($result, 0) : 0;
}
function submission_score($id) {
$result = db_query("SELECT score FROM submissions WHERE id = $id");
$result = db_query("SELECT score FROM stories WHERE id = $id");
return ($result) ? mysql_result($result, 0) : 0;
}
......@@ -16,27 +16,18 @@ function submission_vote($id, $vote) {
include "config.inc";
if (!$user->getHistory("s$id")) {
### Update submission table:
db_query("UPDATE submissions SET score = score $vote, votes = votes + 1 WHERE id = $id");
### Update submission's score- and votes-field:
db_query("UPDATE stories SET score = score $vote, votes = votes + 1 WHERE id = $id");
### Update user record:
### Update user's history record:
$user->setHistory("s$id", "$vote"); // s = submission
$user->save();
### Update story and submission table (if required):
$result = db_query("SELECT * FROM submissions WHERE id = $id");
### 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) {
### Hide submission from submission table:
db_query("UPDATE submissions SET status = 0 WHERE id = $id");
### Copy sumbission to news table:
db_query("INSERT INTO stories (aid, subject, time, abstract, article, category, informant, status) VALUES ('$submission->uid', '". addslashes($submission->subject) ."', '$submission->timestamp', '". addslashes($submission->abstract) ."', '". addslashes($submission->article) ."', '". addslashes($submission->category) ."', '". addslashes($submission->uname) ."', '1')");
}
if ($submission->score <= $submission_dump_threshold) {
### Hide submission from submission table:
db_query("UPDATE submissions SET status = 0 WHERE id = $id");
}
if ($submission->score >= $submission_post_threshold) db_query("UPDATE stories SET status = 2 WHERE id = $id");
if ($submission->score <= $submission_dump_threshold) db_query("UPDATE stories SET status = 0 WHERE id = $id");
}
}
}
......
......@@ -7,16 +7,18 @@
function submission_displayMain() {
global $PHP_SELF, $theme, $user;
include "config.inc";
### Perform query:
$result = db_query("SELECT * FROM submissions WHERE status = 1");
$result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.status = 1 ORDER BY s.id");
$content .= "<P>Anyone who happens by, and has some news or some thoughts they'd like to share, can <A HREF=\"submit.php\">submit</A> new content for consideration. After someone has submitted something, their story is added to a queue. All registered users can access this list of pending stories, that is, stories that have been submitted, but do not yet appear on the public front page. Those registered users can vote whether they think the story should be posted or not. When enough people vote to post a story, the story is pushed over the threshold and up it goes on the public page. On the other hand, when too many people voted to drop a story, the story will get trashed.</P><P>Basically, this means that you, the community, are truly the editors of this site as you have the final decision on the content of this site. It's you judging the overall quality of a story. But remember, vote on whether the story is interesting, not on whether you agree with it or not. If the story goes up, you can disagree all you want, but don't vote `no' because you think the ideas expressed are wrong. Instead, vote `no' when you think the story is plain boring.</P>";
$content .= "<TABLE BORDER=\"0\" CELLSPACING=\"2\" CELLPADDING=\"2\">\n";
$content .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
$content .= " <TR BGCOLOR=\"$bgcolor1\"><TH>Subject</TH><TH>Category</TH><TH>Date</TH><TH>Author</TH><TH>Score</TH></TR>\n";
while ($submission = db_fetch_object($result)) {
if ($user->getHistory("s$submission->id")) $content .= " <TR><TD WIDTH=\"100%\"><A HREF=\"$PHP_SELF?op=view&id=$submission->id\">$submission->subject</A></TD><TD>$submission->category</TD><TD NOWRAP>". date("Y-m-d h:m:s", $submission->timestamp) ."</TD><TD NOWRAP>$submission->uname</TD><TD ALIGN=\"center\">". submission_score($submission->id) ."</TD></TR>\n";
else $content .= " <TR><TD WIDTH=\"100%\"><A HREF=\"$PHP_SELF?op=view&id=$submission->id\">$submission->subject</A></TD><TD>$submission->category</TD><TD NOWRAP>". date("Y-m-d h:m:s", $submission->timestamp) ."</TD><TD NOWRAP>$submission->uname</TD><TD ALIGN=\"center\"><A HREF=\"$PHP_SELF?op=view&id=$submission->id\">vote</A></TD></TR>\n";
$submission->userid = ($submission->userid) ? $submission->userid : $anonymous;
if ($user->getHistory("s$submission->id")) $content .= " <TR><TD WIDTH=\"100%\"><A HREF=\"$PHP_SELF?op=view&id=$submission->id\">$submission->subject</A></TD><TD>$submission->category</TD><TD ALIGN=\"center\">". date("Y-m-d", $submission->timestamp) ."<BR>". date("H:m:s", $submission->timestamp) ."</TD><TD ALIGN=\"center\">$submission->userid</TD><TD ALIGN=\"center\">". submission_score($submission->id) ."</TD></TR>\n";
else $content .= " <TR><TD WIDTH=\"100%\"><A HREF=\"$PHP_SELF?op=view&id=$submission->id\">$submission->subject</A></TD><TD>$submission->category</TD><TD ALIGN=\"center\">". date("Y-m-d", $submission->timestamp) ."<BR>". date("H:m:s", $submission->timestamp) ."</TD><TD ALIGN=\"center\">$submission->userid</TD><TD ALIGN=\"center\"><A HREF=\"$PHP_SELF?op=view&id=$submission->id\">vote</A></TD></TR>\n";
}
$content .= "</TABLE>\n";
......@@ -30,11 +32,11 @@ function submission_displayItem($id) {
include "config.inc";
$result = mysql_query("SELECT * FROM submissions WHERE id = $id");
$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->uname, $submission->time, $submission->subject, "", $submission->abstract, "", $submission->article, "[ <A HREF=\"$PHP_SELF\"><FONT COLOR=\"$theme->hlcolor2\">back</FONT></A> ]");
$theme->article($submission, "[ <A HREF=\"$PHP_SELF\"><FONT COLOR=\"$theme->hlcolor2\">back</FONT></A> ]");
if ($vote = $user->getHistory("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";
......@@ -43,7 +45,7 @@ function submission_displayItem($id) {
$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>";
print "<A HREF=\"account.php?op=userinfo&$uname=$account->userid\">$account->userid</A> voted `". getHistory($account->history, "s$submission->id") ."'.<BR>";
}
}
else {
......
......@@ -8,7 +8,7 @@ function submit_enter() {
### Guidlines:
$output .= "<P>Got some news or some thoughts you would like to share? Fill out this form and they will automatically get whisked away to our submission queue where our moderators will frown at it, poke at it and hopefully post it. Every registered user is automatically a moderator and can vote whether or not your sumbission should be carried to the front page for discussion.</P>\n";
$output .= "<P>Note that we do not revamp or extend your submission so it is totally up to you to make sure it is well-written: if you don't care enough to be clear and complete, your submission is likely to be moderated down by our army of moderators. Try to be complete, aim for clarity, organize and structure your text, and try to carry out your statements with examples. It is also encouraged to extend your submission with arguments that flow from your unique intellectual capability and experience: offer some insight or explanation as to why you think your submission is interesting. Make sure your submission has some meat on it!</P>\n";
$output .= "<P>Note that we do not revamp or extend your submission so it is up to you to make sure your submission is well-written: if you don't care enough to be clear and complete, your submission is likely to be moderated down by our army of moderators. Try to be complete, aim for clarity, organize and structure your text, and try to carry out your statements with examples. It is also encouraged to extend your submission with arguments that flow from your unique intellectual capability and experience: offer some insight or explanation as to why you think your submission is interesting. Make sure your submission has some meat on it!</P>\n";
$output .= "<P>However, if you have bugs to report, complaints, personal questions or anything besides a public submission, we would prefer you to mail us instead, or your message is likely to get lost.</P><BR>\n";
### Submission form:
......@@ -58,7 +58,7 @@ function submit_enter() {
$theme->footer();
}
function submit_preview($name, $address, $subject, $abstract, $story, $category) {
function submit_preview($subject, $abstract, $story, $category) {
global $user;
include "functions.inc";
......@@ -99,10 +99,28 @@ function submit_preview($name, $address, $subject, $abstract, $story, $category)
$output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"story\">". stripslashes($story) ."</TEXTAREA><BR>\n";
$output .= " <SMALL><I>HTML is nice and dandy, but double check those URLs and HTML tags!</I></SMALL>\n";
$output .= "</P>\n";
$output .= "<P>\n";
$output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview submission\"> <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Submit submission\">\n";
$output .= "</P>\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";
$output .= "<P>\n";
$output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview submission\">\n";
$output .= "</P>\n";
}
else if (empty($abstract)) {
$output .= "<P>\n";
$output .= " <FONT COLOR=\"red\"><B>Warning:</B></FONT> you did not supply an <U>abstract</U>.\n";
$outout .= "</P>\n";
$output .= "<P>\n";
$output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview submission\">\n";
$output .= "</P>\n";
}
else {
$output .= "<P>\n";
$output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview submission\"> <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Submit submission\">\n";
$output .= "</P>\n";
}
$output .= "</FORM>\n";
......@@ -112,43 +130,33 @@ function submit_preview($name, $address, $subject, $abstract, $story, $category)
$theme->footer();
}
function submit_submit($name, $address, $subject, $abstract, $article, $category) {
function submit_submit($subject, $abstract, $article, $category) {
global $user;
include "functions.inc";
include "theme.inc";
### Add submission to SQL table:
db_query("INSERT INTO stories (author, subject, abstract, article, category, timestamp) VALUES ('$user->id', '$subject', '$abstract', '$article', '$category', '". time() ."')");
### Display confirmation message:
$theme->header();
$theme->box("Thanks for your submission.", "Thanks for your submission. The submission moderators in our basement will frown at it, poke at it, and vote for it!");
$theme->footer();
### Add submission to queue:
if ($user) {
$uid = $user->id;
$name = $user->userid;
}
else {
$uid = -1;
$name = $anonymous;
}
db_query("INSERT INTO submissions (uid, uname, subject, article, timestamp, category, abstract, score, votes) VALUES ('$uid', '$name', '$subject', '$article', '". time() ."', '$category', '$abstract', '0', '0')");
### Send e-mail notification (if enabled):
if ($notify) {
$message = "New submission:\n\nsubject...: $subject\nauthor....: $name\ncategory..: $category\nabstract..:\n$abstract\n\narticle...:\n$article";
$message = "New submission:\n\nsubject...: $subject\nauthor....: $user->userid <$user->email>\ncategory..: $category\nabstract..:\n$abstract\n\narticle...:\n$article";
mail($notify_email, "$notify_subject $subject", $message, "From: $notify_from\nX-Mailer: PHP/" . phpversion());
}
}
switch($op) {
case "Preview submission":
submit_preview($name, $address, $subject, $abstract, $story, $category);
submit_preview($subject, $abstract, $story, $category);
break;
case "Submit submission":
submit_submit($name, $address, $subject, $abstract, $story, $category);
submit_submit($subject, $abstract, $story, $category);
break;
default:
submit_enter();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment