Commit 3f2b0e0b authored by Dries's avatar Dries

Flushing my backlog (in case Natrak wants to make more changes):

 - tidied up some of the code
 - fixed a small problems
parent 6bb49b4b
......@@ -226,8 +226,8 @@ function account_user($uname) {
function module($name, $module, $username) {
global $theme;
if ($module["account"] && $block = $module["account"]($username, "account", "view")) {
if ($block["content"]) $theme->box($block["subject"], $block["content"]);
if ($module[account] && $block = $module[account]($username, "account", "view")) {
if ($block[content]) $theme->box($block[subject], $block[content]);
}
}
......
......@@ -7,7 +7,7 @@ function error_flood() {
}
function error_httpd() {
global $REDIRECT_STATUS, $REDIRECT_URL, $HTTP_REFERER, $HTTP_USER_AGENT, $site_url;
global $REDIRECT_STATUS, $REDIRECT_URL, $HTTP_REFERER, $HTTP_USER_AGENT;
switch($REDIRECT_STATUS) {
case 500:
......@@ -35,7 +35,7 @@ function error_httpd() {
print "<H1>Oops, an error occured!</H1>\n";
print "<B>Processed output:</B><BR>\n";
print " * $message<BR>\n";
print " * Return to the <A HREF=\"$site_url\">main page</A>.\n";
print " * Return to the <A HREF=\"index.php\">main page</A>.\n";
print "</PRE>\n";
}
......
......@@ -70,8 +70,7 @@ $moderation_votes = array("neutral (+0)" => "+ 0",
# Example: '"comment" => 60' means that there is only one new comment allowed from the same IP-address every 60 seconds.
#
$submission_rate = array("comment" => "60", // 60 seconds = 1 minute
"diary" => "300", // 300 seconds = 5 minutes
"story" => "300"); // 300 seconds = 5 minutes
"node" => "300") // 300 seconds = 5 minutes
#
# Submission size:
......
......@@ -41,7 +41,7 @@ function user_save($account, $array) {
else db_query("INSERT INTO users SET $query last_access = '". time() ."', last_host = '$GLOBALS[REMOTE_ADDR]'");
// return account:
return user_load(($account->userid ? $account->userid : $array["userid"]));
return user_load(($account->userid ? $account->userid : $array[userid]));
}
function user_get($account, $column, $field) {
......
<?php
$watchdog = array("comment" => array("0", $submission_rate["comment"]),
"diary" => array("1", $submission_rate["diary"]),
"story" => array("2", $submission_rate["story"]),
"node" => array("1", $submission_rate["node"]),
"message" => array("3", "0"),
"warning" => array("4", "0"),
"error" => array("5", "0"));
......
......@@ -87,7 +87,7 @@ function account_delete($name) {
function account_edit_save($name, $edit) {
foreach ($edit as $key=>$value) if ($key != "access") $query .= "$key = '". addslashes($value) ."', ";
db_query("UPDATE users SET $query access = '' WHERE userid = '$name'");
if ($edit["access"]) foreach ($edit["access"] as $key=>$value) user_set(user_load($name), "access", $value, 1);
if ($edit[access]) foreach ($edit[access] as $key=>$value) user_set(user_load($name), "access", $value, 1);
watchdog("message", "account: modified user '$name'");
}
......
......@@ -26,7 +26,7 @@ function rating_cron() {
$bonus -= $story->number / 2;
}
$r4 = db_query("SELECT score, votes FROM comments WHERE author = '$rating->id' AND (". time() ." - timestamp < $period) ORDER BY timestamp LIMIT $number");
$r4 = db_query("SELECT score, votes FROM comments WHERE author = '$rating->id' AND (". time() ." - timestamp < $period) ORDER BY timestamp LIMIT $number", 1);
while ($comment = db_fetch_object($r4)) {
$weight++;
$score += $weight * $comment->score;
......@@ -35,6 +35,7 @@ function rating_cron() {
if ($weight >= $offset && $votes > 0) {
$value = ($score + $weight) / $votes + $bonus;
print "update $rating->id : $value<BR>";
db_query("UPDATE users SET rating = '$value' WHERE id = '$rating->id'");
}
}
......@@ -74,9 +75,9 @@ function rating_page() {
}
function rating_block() {
$block[0]["subject"] = "Top 10:<BR>users";
$block[0]["content"] = rating_list(10);
$block[0]["info"] = "Top 10: users";
$block[0][subject] = "Top 10:<BR>users";
$block[0][content] = rating_list(10);
$block[0][info] = "Top 10: users";
return $block;
}
......
......@@ -23,9 +23,9 @@ function section_block() {
$content .= "<LI><A HREF=\"?section=". urlencode($_section->name) ."\">$_section->name</A> (". check_output($_section->stories, 0) .")</LI>\n";
}
$block[0]["subject"] = "Sections";
$block[0]["content"] = $content;
$block[0]["info"] = "Section list";
$block[0][subject] = "Sections";
$block[0][content] = $content;
$block[0][info] = "Section list";
return $block;
}
......
......@@ -193,9 +193,9 @@ function story_block() {
$content .= "<LI><A HREF=\"node.php?id=$story->id\">". check_output($story->title) ."</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
}
$blocks[0]["subject"] = "Top 10:<BR>all stories";
$blocks[0]["content"] = $content;
$blocks[0]["info"] = "Top 10: all stories";
$blocks[0][subject] = "Top 10:<BR>all stories";
$blocks[0][content] = $content;
$blocks[0][info] = "Top 10: all stories";
unset($content);
......@@ -204,9 +204,9 @@ function story_block() {
$content .= "<LI><A HREF=\"node.php?id=$story->id\">". check_output($story->title) ."</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
}
$blocks[1]["subject"] = "Top 10:<BR>recent stories";
$blocks[1]["content"] = $content;
$blocks[1]["info"] = "Top 10: recent stories";
$blocks[1][subject] = "Top 10:<BR>recent stories";
$blocks[1][content] = $content;
$blocks[1][info] = "Top 10: recent stories";
return $blocks;
*/
......
......@@ -193,9 +193,9 @@ function story_block() {
$content .= "<LI><A HREF=\"node.php?id=$story->id\">". check_output($story->title) ."</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
}
$blocks[0]["subject"] = "Top 10:<BR>all stories";
$blocks[0]["content"] = $content;
$blocks[0]["info"] = "Top 10: all stories";
$blocks[0][subject] = "Top 10:<BR>all stories";
$blocks[0][content] = $content;
$blocks[0][info] = "Top 10: all stories";
unset($content);
......@@ -204,9 +204,9 @@ function story_block() {
$content .= "<LI><A HREF=\"node.php?id=$story->id\">". check_output($story->title) ."</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
}
$blocks[1]["subject"] = "Top 10:<BR>recent stories";
$blocks[1]["content"] = $content;
$blocks[1]["info"] = "Top 10: recent stories";
$blocks[1][subject] = "Top 10:<BR>recent stories";
$blocks[1][content] = $content;
$blocks[1][info] = "Top 10: recent stories";
return $blocks;
*/
......
......@@ -27,6 +27,7 @@ function node_refers($node) {
$theme->footer();
break;
default:
if ($user->id) user_load($user->userid);
node_view($node, 1);
}
}
......
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