summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/ban.inc10
-rw-r--r--includes/common.inc4
-rw-r--r--includes/database.inc2
-rw-r--r--includes/function.inc6
-rw-r--r--includes/submission.inc8
-rw-r--r--includes/theme.inc47
-rw-r--r--includes/user.inc10
-rw-r--r--includes/widget.inc8
8 files changed, 45 insertions, 50 deletions
diff --git a/includes/ban.inc b/includes/ban.inc
index f31ef849a..fe8e6153a 100644
--- a/includes/ban.inc
+++ b/includes/ban.inc
@@ -12,10 +12,10 @@ $index2type = array(0x01 => "addresses",
function ban_match($mask, $category) {
- ### Perform query:
+ // Perform query:
$result = db_query("SELECT * FROM bans WHERE type = $category AND LOWER('$mask') LIKE LOWER(mask)");
- ### Return result:
+ // Return result:
return db_fetch_object($result);
}
@@ -32,7 +32,7 @@ function ban_add($mask, $category, $reason, $message = "") {
$result = db_query("INSERT INTO bans (mask, type, reason, timestamp) VALUES ('$mask', '$category', '$reason', '". time() ."')");
$message = "added new ban with mask `$mask'.<P>\n";
- ### Add log entry:
+ // Add log entry:
watchdog("message", "added new ban `$mask' to category `". $index2type[$category] ."' with reason `$reason'.");
}
}
@@ -43,10 +43,10 @@ function ban_delete($id) {
$result = db_query("SELECT * FROM bans WHERE id = $id");
if ($ban = db_fetch_object($result)) {
- ### Perform query:
+ // Perform query:
$result = db_query("DELETE FROM bans WHERE id = $id");
- ### Deleted log entry:
+ // Deleted log entry:
watchdog("message", "removed ban `$ban->mask' from category `". $index2type[$ban->type] ."'.");
}
}
diff --git a/includes/common.inc b/includes/common.inc
index f077658ee..22338070f 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -8,8 +8,8 @@ include_once "includes/module.inc";
include_once "includes/theme.inc";
include_once "includes/user.inc";
-global $user;
+session_start();
$theme = load_theme();
-?>
+?> \ No newline at end of file
diff --git a/includes/database.inc b/includes/database.inc
index 56e230003..a01912c7b 100644
--- a/includes/database.inc
+++ b/includes/database.inc
@@ -41,7 +41,7 @@ function db_fetch_array($qid) {
if ($qid) return mysql_fetch_array($qid);
}
-function db_result($qid, $field) {
+function db_result($qid, $field = 0) {
if ($qid) return mysql_result($qid, $field);
}
diff --git a/includes/function.inc b/includes/function.inc
index dc013683e..4ebb161e8 100644
--- a/includes/function.inc
+++ b/includes/function.inc
@@ -1,11 +1,5 @@
<?
-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 load_theme() {
global $user, $themes;
diff --git a/includes/submission.inc b/includes/submission.inc
index 1c7035069..b91d30de5 100644
--- a/includes/submission.inc
+++ b/includes/submission.inc
@@ -14,20 +14,20 @@ 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:
+ // 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):
+ // Update the comments (if required):
if ($comment) {
watchdog("comment", "moderation: added comment with subject '$subject'");
db_query("INSERT INTO comments (sid, author, subject, comment, hostname, timestamp) VALUES($id, $user->id, '". check_input(substr($comment, 0, 29)) ." ...', '". check_input($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."')");
}
- ### Update user's history record:
+ // Update user's history record:
user_setHistory($user, "s$id", $vote); // s = submission
- ### Update story table (if required):
+ // 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) {
diff --git a/includes/theme.inc b/includes/theme.inc
index 7c93ec775..75413bdfa 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -10,7 +10,7 @@ function theme_account($theme) {
return ($result) ? db_result($result, 0) : 0;
}
- ### Display account settings:
+ // Display account settings:
$content .= "<LI><A HREF=\"account.php?op=track&topic=comments\">track your comments</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=track&topic=stories\">track your stories</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=track&topic=site\">track $site_name</A></LI>\n";
@@ -99,7 +99,7 @@ function theme_moderation_results($theme, $story) {
}
function theme_related_links($theme, $story) {
- ### Parse story for <A HREF="">-tags:
+ // Parse story for <A HREF="">-tags:
$text = stripslashes("$story->abstract $story->updates $story->article");
while ($text = stristr($text, "<A HREF=")) {
$link = substr($text, 0, strpos(strtolower($text), "</a>") + 4);
@@ -107,33 +107,15 @@ function theme_related_links($theme, $story) {
if (!stristr($link, "mailto:")) $content .= "<LI>$link</LI>";
}
- ### Stories in the same category:
+ // Stories in the same category:
$content .= " <LI>More about <A HREF=\"search.php?category=". urlencode($story->category) ."\">$story->category</A>.</LI>";
- ### Stories from the same author:
+ // Stories from the same author:
if ($story->userid) $content .= " <LI>Also by <A HREF=\"search.php?author=". urlencode($story->userid) ."\">$story->userid</A>.</LI>";
$theme->box("Related links", $content);
}
-function theme_old_headlines($theme, $num = 10) {
- global $user;
-
- if ($user->stories) $result = db_query("SELECT id, subject, timestamp FROM stories WHERE status = 2 ORDER BY timestamp DESC LIMIT $user->stories, $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, M jS", $story->timestamp) ."</B></P>\n";
- $time = date("F jS", $story->timestamp);
- }
- $content .= "<LI><A HREF=\"discussion.php?id=$story->id\">$story->subject</A></LI>\n";
- }
- $content .= "<P ALIGN=\"right\">[ <A HREF=\"search.php\"><FONT COLOR=\"$theme->hlcolor2\">more</FONT></A> ]</P>";
-
- $theme->box("Older headlines", $content);
-}
-
function theme_comment_moderation($id, $author, $score, $votes) {
global $user, $comment_votes;
@@ -154,9 +136,28 @@ function theme_new_headlines($theme, $num = 10) {
$content = "";
$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\">$story->subject</A></LI>\n";
+ while ($story = db_fetch_object($result)) $content .= "<LI><A HREF=\"discussion.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>";
$theme->box("Latest headlines", $content);
}
+function theme_old_headlines($theme, $num = 10) {
+ global $user;
+
+ if ($user->stories) $result = db_query("SELECT id, subject, timestamp FROM stories WHERE status = 2 ORDER BY timestamp DESC LIMIT $user->stories, $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, M jS", $story->timestamp) ."</B></P>\n";
+ $time = date("F jS", $story->timestamp);
+ }
+ $content .= "<LI><A HREF=\"discussion.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>";
+
+ $theme->box("Older headlines", $content);
+}
+
+
?>
diff --git a/includes/user.inc b/includes/user.inc
index 7d04c785f..4c640a7c4 100644
--- a/includes/user.inc
+++ b/includes/user.inc
@@ -42,7 +42,7 @@ function user_setHistory(&$user, $field, $value) {
$history = $user->history;
if (!$value) {
- ### remove entry:
+ // remove entry:
$data = explode(";", $history);
for (reset($data); current($data); next($data)) {
$entry = explode(":", current($data));
@@ -50,7 +50,7 @@ function user_setHistory(&$user, $field, $value) {
}
}
else if (strstr($history, "$field:")) {
- ### found: update exsisting entry:
+ // found: update exsisting entry:
$data = explode(";", $history);
for (reset($data); current($data); next($data)) {
$entry = explode(":", current($data));
@@ -59,12 +59,12 @@ function user_setHistory(&$user, $field, $value) {
}
}
else {
- ### not found: add new entry:
+ // not found: add new entry:
$rval = "$history$field:$value;";
}
$user->history = $rval;
- ### save new history:
+ // save new history:
$query .= "UPDATE users SET ";
foreach ($user->field as $key=>$field) { $value = $user->$field; $query .= "$field = '". addslashes($value) ."', "; }
$query .= " id = $user->id WHERE id = $user->id";
@@ -75,4 +75,4 @@ function user_clean() {
// todo - called by cron job
}
-?>
+?> \ No newline at end of file
diff --git a/includes/widget.inc b/includes/widget.inc
index ffb883334..a42b11e54 100644
--- a/includes/widget.inc
+++ b/includes/widget.inc
@@ -10,7 +10,7 @@ function display_account($theme) {
return ($result) ? db_result($result, 0) : 0;
}
- ### Display account settings:
+ // Display account settings:
$content .= "<LI><A HREF=\"account.php?op=track&topic=comments\">track your comments</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=track&topic=stories\">track your stories</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=track&topic=site\">track $site_name</A></LI>\n";
@@ -91,7 +91,7 @@ function display_moderation_results($theme, $story) {
}
function display_related_links($theme, $story) {
- ### Parse story for <A HREF="">-tags:
+ // Parse story for <A HREF="">-tags:
$text = stripslashes("$story->abstract $story->updates $story->article");
while ($text = stristr($text, "<A HREF=")) {
$link = substr($text, 0, strpos(strtolower($text), "</a>") + 4);
@@ -99,10 +99,10 @@ function display_related_links($theme, $story) {
if (!stristr($link, "mailto:")) $content .= "<LI>$link</LI>";
}
- ### Stories in the same category:
+ // Stories in the same category:
$content .= " <LI>More about <A HREF=\"search.php?category=". urlencode($story->category) ."\">$story->category</A>.</LI>";
- ### Stories from the same author:
+ // Stories from the same author:
if ($story->userid) $content .= " <LI>Also by <A HREF=\"search.php?author=". urlencode($story->userid) ."\">$story->userid</A>.</LI>";
$theme->box("Related links", $content);