diff options
author | Dries Buytaert <dries@buytaert.net> | 2000-10-10 10:52:19 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2000-10-10 10:52:19 +0000 |
commit | 4a6c6de758960a2f98ba58f20a1c17c6ee67111c (patch) | |
tree | d0466a04feb29ce5769d90ffb8041b78412faa82 /includes/submission.inc | |
parent | 73077e8778cfd890f51023f6683e70904317cc6f (diff) | |
download | brdo-4a6c6de758960a2f98ba58f20a1c17c6ee67111c.tar.gz brdo-4a6c6de758960a2f98ba58f20a1c17c6ee67111c.tar.bz2 |
Huge update - I don't have time to write everything down but the directory
structure changes, some sections are expanded. Take a look at the source
code or ask me to elaborate on certain issues/topics.
Diffstat (limited to 'includes/submission.inc')
-rw-r--r-- | includes/submission.inc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/includes/submission.inc b/includes/submission.inc new file mode 100644 index 000000000..376c84059 --- /dev/null +++ b/includes/submission.inc @@ -0,0 +1,35 @@ +<? + +function submission_count() { + $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 stories WHERE id = $id"); + return ($result) ? mysql_result($result, 0) : 0; +} + +function submission_vote($id, $vote, $comment) { + global $user, $submission_post_threshold, $submission_dump_threshold; + + if (!user_getHistory($user->history, "s$id")) { + ### 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): + if ($comment) db_query("INSERT INTO comments (sid, author, subject, comment, hostname, timestamp) VALUES($id, $user->id, '". addslashes(substr($comment, 0, 29)) ." ...', '". addslashes($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."')"); + + ### Update user's history record: + user_setHistory($user, "s$id", $vote); // s = submission + + ### 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"); + } + } +} + +?>
\ No newline at end of file |