diff options
36 files changed, 166 insertions, 95 deletions
@@ -32,10 +32,9 @@ ErrorDocument 500 /error.php php_value magic_quotes_gpc 1 php_value magic_quotes_runtime 0 php_value magic_quotes_sybase 0 - php_value session.name DROPID php_value session.auto_start 0 php_value session.cookie_lifetime 2000000 php_value session.gc_maxlifetime 2000000 php_value session.cache_expire 200000 - php_value session.save_path /tmp/dropsessions + # php_value session.save_path /tmp/dropsessions </IfModule> @@ -1,12 +1,12 @@ GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble + Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is @@ -53,9 +53,9 @@ free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. - GNU GENERAL PUBLIC LICENSE + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND - MODIFICATION + MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms @@ -242,7 +242,7 @@ exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY + NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT @@ -271,4 +271,4 @@ PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS + END OF TERMS AND CONDITIONS diff --git a/account.php b/account.php index 1723b0abf..2528c17f2 100644 --- a/account.php +++ b/account.php @@ -1,6 +1,6 @@ <? -include "includes/common.inc"; +include_once "includes/common.inc"; function account_get_user($uname) { $result = db_query("SELECT * FROM users WHERE userid = '$uname'"); @@ -56,7 +56,6 @@ function account_session_start($userid, $passwd) { $user = new User($userid, $passwd); if ($user->id) { - session_start(); session_register("user"); watchdog("message", "session opened for user `$user->userid'"); } @@ -1,9 +1,9 @@ <? -include "includes/common.inc"; +include_once "includes/common.inc"; // validate user permission: -if (!($user->permissions == 1 || $user->id == 1)) exit(); +if (!user_permission($user)) exit(); function admin_page($mod) { global $repository, $site_name, $menu, $modules; @@ -1,6 +1,6 @@ <? -include "includes/common.inc"; +include_once "includes/common.inc"; function cron_run() { global $repository; diff --git a/database/database.mysql b/database/database.mysql index 362b7dff6..a6b22c6d2 100644 --- a/database/database.mysql +++ b/database/database.mysql @@ -15,6 +15,7 @@ CREATE TABLE blocks ( status tinyint(2) DEFAULT '0' NOT NULL, weight tinyint(1) DEFAULT '0' NOT NULL, region tinyint(1) DEFAULT '0' NOT NULL, + remove tinyint(1) DEFAULT '0' NOT NULL, PRIMARY KEY (name) ); @@ -39,7 +39,7 @@ function error_httpd() { print "</PRE>\n"; } -include "includes/common.inc"; +include_once "includes/common.inc"; switch ($op) { case "flood": @@ -1,10 +1,10 @@ <? -include "includes/common.inc"; +include_once "includes/common.inc"; function export($name, $module) { global $REQUEST_URI; - module_execute($name, "export", explode("/", $REQUEST_URI)); + module_execute($name, "export", explode("/", strrchr($REQUEST_URI, "/export"))); } module_iterate("export"); diff --git a/includes/comment.inc b/includes/comment.inc index 6e39ee2ba..4f9ee3ac5 100644 --- a/includes/comment.inc +++ b/includes/comment.inc @@ -8,7 +8,7 @@ if (strstr($id, " ") || strstr($pid, " ") || strstr($lid, " ") || strstr($mode, $cmodes = array(1 => "List - min", 2 => "List - max", 3 => "Threaded - min", 4 => "Threaded - max"); $corder = array(1 => "Date - new", 2 => "Date - old", 3 => "Rate - high", 4 => "Rate - low"); -$link = ($mod) ? $mod : substr($PHP_SELF, 1, strlen($PHP_SELF) - 5); +$link = ($mod) ? $mod : substr(strrchr($PHP_SELF, "/"), 1, strrchr($PHP_SELF, "/") - 4); class Comment { function Comment($userid, $subject, $comment, $timestamp, $url, $fake_email, $score, $votes, $cid, $lid) { @@ -32,12 +32,12 @@ function comment_moderate($moderate) { $none = $comment_votes[key($comment_votes)]; foreach ($moderate as $id=>$vote) { - if ($vote != $comment_votes[$none] && !user_getHistory($user->history, "c$id")) { + if ($vote != $comment_votes[$none] && !user_get_history($user->history, "c$id")) { // Update the comment's score: $result = db_query("UPDATE comments SET score = score $vote, votes = votes + 1 WHERE cid = $id"); // Update the user's history: - user_setHistory($user, "c$id", $vote); + user_set_history("c$id", $vote); } } } @@ -54,7 +54,7 @@ function comment_settings($mode, $order, $threshold) { } function comment_reply($pid, $id) { - global $allowed_html, $link, $theme, $user; + global $allowed_html, $link, $REQUEST_URI, $theme, $user; // Extract parent-information/data: if ($pid) { @@ -70,7 +70,7 @@ function comment_reply($pid, $id) { } // Build reply form: - $output .= "<FORM ACTION=\"". comment_uri() ."\" METHOD=\"post\">\n"; + $output .= "<FORM ACTION=\"$REQUEST_URI\" METHOD=\"post\">\n"; // Name field: $output .= "<P>\n"; @@ -105,13 +105,13 @@ function comment_reply($pid, $id) { } function comment_preview($pid, $id, $subject, $comment) { - global $allowed_html, $link, $theme, $user; + global $allowed_html, $link, $REQUEST_URI, $theme, $user; // Preview comment: $theme->comment(new Comment($user->userid, $subject, $comment, time(), $user->url, $user->fake_email, 0, 0, 0, 0), "reply to this comment"); // Build reply form: - $output .= "<FORM ACTION=\"". comment_uri() ."\" METHOD=\"post\">\n"; + $output .= "<FORM ACTION=\"$REQUEST_URI\" METHOD=\"post\">\n"; // Name field: $output .= "<P>\n"; @@ -160,7 +160,6 @@ function comment_post($pid, $id, $subject, $comment) { if ($duplicate != 0) { watchdog("error", "comment: attempt to insert duplicate comment"); - $theme->box("duplicate comment", "duplicate comment: $duplicate"); } else { // Validate subject: @@ -171,9 +170,6 @@ function comment_post($pid, $id, $subject, $comment) { // Add comment to database: db_query("INSERT INTO comments (link, lid, pid, author, subject, comment, hostname, timestamp, score) VALUES ('". check_input($link) ."', $id, $pid, '$user->id', '". check_input($subject) ."', '". check_input($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."', '". ($user->userid ? 1 : 0) ."')"); - - // Compose header: - header("Location: ". comment_uri("id=$id")); } } @@ -203,7 +199,7 @@ function comment_moderation($comment) { if ($op == "reply") { $output .= " "; } - else if ($user->id && $user->userid != $comment->userid && !user_getHistory($user->history, "c$comment->cid")) { + else if ($user->id && $user->userid != $comment->userid && !user_get_history($user->history, "c$comment->cid")) { $output .= "<SELECT NAME=\"moderate[$comment->cid]\">\n"; foreach ($comment_votes as $key=>$value) $output .= " <OPTION VALUE=\"$value\">$key</OPTION>\n"; $output .= "</SELECT>\n"; @@ -282,8 +278,8 @@ function comment_uri($args = 0) { function comment_link($comment, $return = 1) { global $link, $theme; - if ($return) return "<A HREF=\"". comment_uri("id=$comment->lid#$comment->cid") ."\"><FONT COLOR=\"$theme->hlcolor2\">return</FONT></A> | <A HREF=\"". comment_uri("op=reply&id=$comment->lid&pid=$comment->cid") ."\"><FONT COLOR=\"$theme->hlcolor2\">reply to this comment</FONT></A>"; - else return "<A HREF=\"". comment_uri("op=reply&id=$comment->lid&pid=$comment->cid") ."\"><FONT COLOR=\"$theme->hlcolor2\">reply to this comment</FONT></A>"; + if ($return) return "<A HREF=\"". comment_uri("id=$comment->lid#$comment->cid") ."\"><FONT COLOR=\"$theme->link\">return</FONT></A> | <A HREF=\"". comment_uri("op=reply&id=$comment->lid&pid=$comment->cid") ."\"><FONT COLOR=\"$theme->link\">reply to this comment</FONT></A>"; + else return "<A HREF=\"". comment_uri("op=reply&id=$comment->lid&pid=$comment->cid") ."\"><FONT COLOR=\"$theme->link\">reply to this comment</FONT></A>"; } function comment_comment($comment, $folded = 0) { diff --git a/includes/common.inc b/includes/common.inc index 392fc474b..f5ebc09d6 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1,7 +1,17 @@ <? -$cf = strtr($HTTP_HOST ."". substr($REQUEST_URI, 0, strrpos($REQUEST_URI, "/")), "/:", ".."); -include_once "includes/$cf.conf"; +function conf_load() { + global $HTTP_HOST, $REQUEST_URI; + $file = strtr($HTTP_HOST ."". substr($REQUEST_URI, 0, strrpos($REQUEST_URI, "/")), "/:", ".."); + while ($file && !file_exists("includes/$file.conf")) { + $file = substr($file, 0, strrpos($file, ".")); + } + return $file; +} + +$conf = conf_load(); + +include_once "includes/$conf.conf"; include_once "includes/database.inc"; include_once "includes/watchdog.inc"; include_once "includes/function.inc"; @@ -10,7 +20,7 @@ include_once "includes/locale.inc"; include_once "includes/theme.inc"; include_once "includes/user.inc"; -session_start(); +user_load(); $theme = theme_load(); diff --git a/includes/hostname.conf b/includes/hostname.conf index 62e4ae02a..e9b597b2e 100644 --- a/includes/hostname.conf +++ b/includes/hostname.conf @@ -16,7 +16,6 @@ $site_name = "site name"; $site_url = "http://yourdomain.com/"; $site_email = "info@yourdomain.com"; - # # Comment votes: # the keys of this associative array are displayed in each diff --git a/includes/module.inc b/includes/module.inc index 6c11a358d..c339ee8f7 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -24,12 +24,18 @@ function module_rehash_crons($name, $module) { } function module_rehash_blocks($name, $module) { - db_query("DELETE FROM blocks WHERE module = '$name'"); + db_query("UPDATE blocks SET remove = '1' WHERE module = '$name'"); if ($module["block"] && $blocks = $module["block"]()) { foreach ($blocks as $offset=>$block) { - db_query("INSERT INTO blocks (name, module, offset) VALUES ('". check_input($block["info"]) ."', '". check_input($name) ."', '". check_input($offset) ."')"); + if (!db_fetch_object(db_query("SELECT * FROM blocks WHERE module = '$name' AND name = '". check_input($block["info"]) ."'"))) { + db_query("INSERT INTO blocks (name, module, offset) VALUES ('". check_input($block["info"]) ."', '". check_input($name) ."', '". check_input($offset) ."')"); + } + else { + db_query("UPDATE blocks SET offset = '". check_input($offset) ."', remove = '0' WHERE module = '$name' AND name = '". check_input($block["info"]) ."'"); + } } } + db_query("DELETE FROM blocks WHERE module = '$name' AND remove = '1'"); } function module_rehash($name) { diff --git a/includes/story.inc b/includes/story.inc index 2ec39ca16..a1ba62796 100644 --- a/includes/story.inc +++ b/includes/story.inc @@ -11,4 +11,9 @@ class Story { } } +function story_visible($story) { + global $user; + return ($story->status == 1 && $user->id) || ($story->status == 2) || user_permission(); +} + ?>
\ No newline at end of file diff --git a/includes/submission.inc b/includes/submission.inc index 2b3cf7ebd..78027c109 100644 --- a/includes/submission.inc +++ b/includes/submission.inc @@ -13,7 +13,7 @@ function submission_score($id) { function submission_vote($id, $vote, $comment) { global $user; - if (!user_getHistory($user->history, "s$id")) { + if (!user_get_history($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"); @@ -24,7 +24,7 @@ function submission_vote($id, $vote, $comment) { } // Update user's history record: - user_setHistory($user, "s$id", $vote); + user_set_history("s$id", $vote); // Update story table (if required): $result = db_query("SELECT * FROM stories WHERE id = $id"); diff --git a/includes/theme.inc b/includes/theme.inc index f46c29e0b..e54de391c 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -41,7 +41,7 @@ function theme_account($theme) { $content .= "<LI><A HREF=\"account.php?op=edit&topic=content\">edit site content</A></LI>\n"; $content .= "<P>\n"; - if (($user->id) && ($user->permissions == 1 || $user->id == 1)) { + if (user_permission($user)) { $content .= "<LI><A HREF=\"admin.php\">administer ". $site_name ."</A></LI>\n"; $content .= "<P>\n"; } @@ -91,16 +91,16 @@ function theme_blocks($region, $theme) { } function theme_morelink($theme, $story) { - return ($story->article) ? "[ <A HREF=\"story.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\"><B>read more</B></FONT></A> | ". strlen($story->article) ." bytes | <A HREF=\"story.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]" : "[ <A HREF=\"story.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]"; + return ($story->article) ? "[ <A HREF=\"story.php?id=$story->id\"><FONT COLOR=\"$theme->link\"><B>read more</B></FONT></A> | ". strlen($story->article) ." bytes | <A HREF=\"story.php?id=$story->id\"><FONT COLOR=\"$theme->link\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]" : "[ <A HREF=\"story.php?id=$story->id\"><FONT COLOR=\"$theme->link\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]"; } function theme_moderation_results($theme, $story) { global $user; - if ($user->id && $story->id && ($user->id == $story->author || user_getHistory($user->history, "s$story->id"))) { + if ($user->id && $story->id && ($user->id == $story->author || user_get_history($user->history, "s$story->id"))) { $result = db_query("SELECT * FROM users WHERE history LIKE '%s$story->id%'"); while ($account = db_fetch_object($result)) { - $output .= format_username($account->userid) ." voted `". user_getHistory($account->history, "s$story->id") ."'.<BR>"; + $output .= format_username($account->userid) ." voted `". user_get_history($account->history, "s$story->id") ."'.<BR>"; } $theme->box("Moderation results", ($output ? $output : "This story has not been moderated yet.")); @@ -131,7 +131,6 @@ 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=\"story.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); } @@ -148,8 +147,6 @@ function theme_old_headlines($theme, $num = 10) { } $content .= "<LI><A HREF=\"story.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 90e1dc1e8..65a891cb9 100644 --- a/includes/user.inc +++ b/includes/user.inc @@ -1,7 +1,13 @@ <? class User { - function User($userid, $passwd = "") { + function User($userid) { + $result = db_query("SELECT * FROM users WHERE userid = '$userid' && STATUS = 2"); + if (db_num_rows($result) == 1) { + foreach (db_fetch_row($result) as $key=>$value) { $field = mysql_field_name($result, $key); $this->$field = stripslashes($value); $this->field[] = $field; } + } + } + function User($userid, $passwd) { $result = db_query("SELECT * FROM users WHERE LOWER(userid) = LOWER('$userid') && passwd = PASSWORD('$passwd') && STATUS = 2"); if (db_num_rows($result) == 1) { foreach (db_fetch_row($result) as $key=>$value) { $field = mysql_field_name($result, $key); $this->$field = stripslashes($value); $this->field[] = $field; } @@ -10,6 +16,12 @@ class User { } } +function user_load() { + global $db_name; + session_name($db_name); + session_start(); +} + function user_save($data, $id = 0) { global $user; @@ -29,7 +41,7 @@ function user_save($data, $id = 0) { } } -function user_getHistory($history, $field) { +function user_get_history($history, $field) { $data = explode(";", $history); for (reset($data); current($data); next($data)) { $entry = explode(":", current($data)); @@ -38,8 +50,8 @@ function user_getHistory($history, $field) { return $rval; } -function user_setHistory(&$user, $field, $value) { - +function user_set_history($field, $value) { + global $user; $history = $user->history; if (!$value) { // remove entry: @@ -71,4 +83,13 @@ function user_setHistory(&$user, $field, $value) { db_query($query); } +function user_rehash() { + global $user; + if ($user->id) $user = new User($user->userid); +} + +function user_permission($account) { + return ($account->permissions == 1 || $account->id == 1); +} + ?>
\ No newline at end of file diff --git a/includes/watchdog.inc b/includes/watchdog.inc index f50fab57e..6a5b66163 100644 --- a/includes/watchdog.inc +++ b/includes/watchdog.inc @@ -9,8 +9,8 @@ $watchdog = array("comment" => array("0", $submission_rate["comment"]), function watchdog($id, $message) { global $user, $watchdog, $watchdog_history; - - if ($watchdog[$id][1] && !($user->permissions == 1 || $user->id == 1)) { +/* + if ($watchdog[$id][1] && !user_permission()) { if ($log = db_fetch_object(db_query("SELECT * FROM watchdog WHERE hostname = '". getenv("REMOTE_ADDR") ."' AND level = '". $watchdog[$id][0] ."'"))) { if (time() - $log->timestamp < $watchdog[$id][1]) { watchdog("warning", "'". getenv("REMOTE_ADDR") ."' exceeded '$id' submission rate"); @@ -19,6 +19,7 @@ function watchdog($id, $message) { } } } +*/ // Perform query to add new watchdog entry: db_query("INSERT INTO watchdog (level, timestamp, user, message, location, hostname) VALUES ('". $watchdog[$id][0] ."', '". time() ."', '". check_input($user->id) ."', '". check_input($message) ."', '". check_input(getenv("REQUEST_URI")) ."', '". check_input(getenv("REMOTE_ADDR")) ."')"); @@ -1,6 +1,6 @@ <? -include "includes/common.inc"; +include_once "includes/common.inc"; // Initialize/pre-process variables: $number = ($user->stories) ? $user->stories : 10; diff --git a/modules/account.module b/modules/account.module index b4a278d2f..ddeada1c2 100644 --- a/modules/account.module +++ b/modules/account.module @@ -51,13 +51,13 @@ function account_display($order = "username") { $output .= " <TR>\n"; foreach ($show as $key=>$value) { switch($value = strtok($value, " ")) { - case "real_email": + case "real_email": $output .= " <TD>". format_email($account[$value]) ."</TD>\n"; break; case "last_access": $output .= " <TD>". format_interval(time() - $account[$value]) ." ago</TD>\n"; break; - case "status": + case "status": $output .= " <TD ALIGN=\"center\">". $stat[$account[$value]] ."</TD>\n"; break; case "permissions": @@ -69,7 +69,7 @@ function account_display($order = "username") { case "url": $output .= " <TD>". format_url($account[$value]) ."</TD>\n"; break; - case "userid": + case "userid": $output .= " <TD>". format_username($account[$value], 1) ."</TD>\n"; break; default: @@ -100,7 +100,7 @@ function account_comments($id) { return $output; } -function account_save($name, $edit) { +function account_edit_save($name, $edit) { foreach ($edit as $key=>$value) { $query .= "$key = '". addslashes($value) ."', "; } @@ -195,7 +195,7 @@ function account_admin() { account_view($name); break; case "Save account": - account_save($name, $edit); + account_edit_save($name, $edit); account_view($name); break; case "Update": diff --git a/modules/backend.class b/modules/backend.class index 04e25520d..2028c5d87 100644 --- a/modules/backend.class +++ b/modules/backend.class @@ -37,7 +37,6 @@ class backend { while ($headline = db_fetch_object($result)) { array_push($this->headlines, "<A HREF=\"$headline->link\">$headline->title</A>"); } - } else { $this->site = $site; @@ -94,9 +93,6 @@ class backend { $title = ereg_replace(".*<title>", "", $item); $title = ereg_replace("</title>.*", "", $title); - // Clean headlines: - $title = stripslashes($title); - // Count the number of stories: $number += 1; @@ -145,7 +141,6 @@ class backend { } // Add timestamp: $update = round((time() - $this->timestamp) / 60); - $content .= "<P ALIGN=\"right\">[ <A HREF=\"backend.php?op=reset&site=$this->site\"><FONT COLOR=\"$theme->hlcolor2\">reset</FONT></A> | updated $update min. ago ]</P>"; // Display box: $theme->box("$this->site", $content); diff --git a/modules/ban.module b/modules/ban.module index b14dc492e..862077a47 100644 --- a/modules/ban.module +++ b/modules/ban.module @@ -3,7 +3,7 @@ $module = array("help" => "ban_help", "admin" => "ban_admin"); -include "includes/ban.inc"; +include_once "includes/ban.inc"; function ban_help() { diff --git a/modules/cron.module b/modules/cron.module index 54d55c41b..cb3bbb1fa 100644 --- a/modules/cron.module +++ b/modules/cron.module @@ -17,6 +17,13 @@ function cron_save($edit) { } } +function cron_execute($name) { + global $repository; + watchdog("message", "cron: executed '". $name ."_cron()'"); + $repository[$name]["cron"](); + db_query("UPDATE crons SET timestamp = ". time() ." WHERE module = '$name'"); +} + function cron_display() { $intervals = array(300, 900, 1800, 3600, 7200, 10800, 21600, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200); @@ -29,7 +36,7 @@ function cron_display() { $output .= " <TR><TH>module</TH><TH>period</TH><TH>last execution</TH><TH>operations</TH></TR>\n"; while ($cron = db_fetch_object($result)) { foreach ($intervals as $value) $period .= "<OPTION VALUE=\"$value\"". (($cron->scheduled == $value) ? " SELECTED" : "") .">every ". format_interval($value) ."</OPTION>\n"; - $output .= " <TR><TD>". check_output($cron->module) ."</TD><TD><SELECT NAME=\"edit[$cron->module]\">$period</SELECT></TD><TD>". format_interval(time() - $cron->timestamp) ." ago</TD><TD ALIGN=\"center\"><A HREF=\"cron.php\">execute</A></TD></TR>\n"; + $output .= " <TR><TD>". check_output($cron->module) ."</TD><TD><SELECT NAME=\"edit[$cron->module]\">$period</SELECT></TD><TD ALIGN=\"center\">". ($cron->timestamp ? format_interval(time() - $cron->timestamp) ." ago" : "never" )."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=cron&op=execute&name=$cron->module\">execute</A></TD></TR>\n"; unset($period); } $output .= "</TABLE>\n"; @@ -47,6 +54,10 @@ function cron_admin() { case "help": cron_help(); break; + case "execute": + cron_execute($name); + cron_display(); + break; case "Save crons": cron_save($edit); // fall through diff --git a/modules/diary.module b/modules/diary.module index 584a51b8a..7b95f1072 100644 --- a/modules/diary.module +++ b/modules/diary.module @@ -8,7 +8,7 @@ $module = array("page" => "diary_page", "admin" => "diary_admin", "export" => "diary_export"); -include "includes/common.inc"; +include_once "includes/common.inc"; function diary_page_overview($num = 20) { global $theme, $user; diff --git a/modules/drupal.module b/modules/drupal.module index 990080f05..8ece0a6d9 100644 --- a/modules/drupal.module +++ b/modules/drupal.module @@ -50,6 +50,9 @@ function drupal_page() { break; case "Post comment": comment_post($pid, $id, $subject, $comment); + $theme->header(); + drupal_render($id, $cid); + $theme->footer(); break; case "reply": $theme->header(); diff --git a/modules/drupal/drupal.module b/modules/drupal/drupal.module index 990080f05..8ece0a6d9 100644 --- a/modules/drupal/drupal.module +++ b/modules/drupal/drupal.module @@ -50,6 +50,9 @@ function drupal_page() { break; case "Post comment": comment_post($pid, $id, $subject, $comment); + $theme->header(); + drupal_render($id, $cid); + $theme->footer(); break; case "reply": $theme->header(); diff --git a/modules/faq.module b/modules/faq.module index d4c0b1d81..811282a61 100644 --- a/modules/faq.module +++ b/modules/faq.module @@ -2,7 +2,7 @@ $module = array("page" => "faq_page"); -include "includes/common.inc"; +include_once "includes/common.inc"; function faq_page() { global $theme, $site_name, $site_email; diff --git a/modules/headline.module b/modules/headline.module index 8bb89d310..306944cea 100644 --- a/modules/headline.module +++ b/modules/headline.module @@ -7,9 +7,8 @@ $module = array("page" => "headline_page", "admin" => "headline_admin", "export" => "headline_export"); -include "includes/common.inc"; -include "modules/backend.class"; - +include_once "includes/common.inc"; +include_once "modules/backend.class"; function headline_blocks() { global $theme; @@ -37,7 +36,7 @@ function headline_blocks() { } // Print backend box to screen: - $theme->box($backend->site, "$content<P ALIGN=\"right\">[ <A HREF=\"$backend->url\">more</A> ]\n"); + $theme->box($backend->site, $content); print " </TD>\n"; if ($state % 3 == 2) print " </TR>\n"; @@ -185,8 +184,7 @@ function headline_admin() { function headline_export($uri) { global $site_name, $site_url, $HTTP_REFERER, $HTTP_USER_AGENT; - if ($uri[2] == "headlines.rdf") { - + if ($uri[1] == "headlines.rdf") { watchdog("message", "grabbed 'headlines.rdf' - referring url: $HTTP_REFERER - user agent: $HTTP_USER_AGENT"); header("Content-Type: text/plain"); diff --git a/modules/module.module b/modules/module.module index 9f905c159..4c32990f4 100644 --- a/modules/module.module +++ b/modules/module.module @@ -1,6 +1,13 @@ <? -$module = array("admin" => "module_admin"); +$module = array("help" => "module_help", + "admin" => "module_admin"); + +function module_help() { + ?> + The module administration page provide you a list of all available modules. Moreover, it allows you to "rehash" modules. Whenever you install a new module or when an existing module has been changed or updated, it requires "rehasing": when you rehash a module, the module is registered to the engine and properly initialized. + <? +} function module_admin_rehash() { global $repository; @@ -41,16 +48,23 @@ function module_admin_display() { function module_admin() { global $op, $name; + print "<SMALL><A HREF=\"admin.php?mod=module\">overview</A> | <A HREF=\"admin.php?mod=module&op=help\">help</A></SMALL><HR>\n"; + switch ($op) { - case "Rehash modules": - module_admin_rehash(); + case "help": + module_help(); break; case "rehash": module_rehash($name); + module_admin_display(); break; + case "Rehash modules": + module_admin_rehash(); + module_admin_display(); + break; + default: + module_admin_display(); } - - module_admin_display(); } ?> diff --git a/modules/section.module b/modules/section.module index 36642f418..2ee5869d9 100644 --- a/modules/section.module +++ b/modules/section.module @@ -12,8 +12,8 @@ $_section = array("status" => array(2 => "enabled: always", 1 => "enabled: custo function section_help() { ?> - <P>When submitting new stories, every story is assigned a section or category. These sections can be maintained from the administration pages.</P> - <P>For moderation purpose, you can specify a post, dump and expiration thresholds for each available section according to type and urgency level a section. Some section do not really "expire" and stay interesting and active as time passes by, whereas news-related stories are only considered "hot" over a short period of time.</P> + <P>When submitting new stories, every story is assigned a section or category. Sections can be maintained from the administration pages.</P> + <P>For moderation purpose, you can specify a post, dump and expiration thresholds for each available section according to type and urgency level of a section. This is useful considering the fact that some sections do not really "expire" and stay interesting and active as time passes by, whereas news-related stories are only considered "hot" over a short period of time.</P> <? } @@ -113,7 +113,7 @@ function section_admin() { switch($op) { case "add": - section_add($edit); + section_add(); break; case "help": section_help(); diff --git a/search.php b/search.php index 64d703dd7..f18c08e6c 100644 --- a/search.php +++ b/search.php @@ -1,5 +1,5 @@ <? - include "includes/common.inc"; + include_once "includes/common.inc"; $theme->header(); @@ -1,18 +1,19 @@ <? -include "includes/common.inc"; +include_once "includes/common.inc"; +include_once "includes/story.inc"; function story_render($id, $cid) { global $theme, $user; - $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.status != 0 AND s.id = $id"); + $story = db_fetch_object(db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.id = $id")); - if ($story = db_fetch_object($result)) { + if (story_visible($story)) { $theme->article($story, "[ <A HREF=\"story.php?op=reply&id=$id&pid=0\">reply to this story</A> ]"); comment_render($id, $cid); } else { - $theme->box("Warning message", "The story you requested is no longer available or does not exist."); + $theme->box("Warning message", "The story you requested is not available or does not exist."); } } @@ -24,6 +25,9 @@ switch($op) { break; case "Post comment": comment_post($pid, $id, $subject, $comment); + $theme->header(); + story_render($id, $cid); + $theme->footer(); break; case "Add comment": $theme->header(); diff --git a/submission.php b/submission.php index 070aa196b..481fbdc55 100644 --- a/submission.php +++ b/submission.php @@ -1,7 +1,7 @@ <? -include "includes/submission.inc"; -include "includes/common.inc"; +include_once "includes/submission.inc"; +include_once "includes/common.inc"; function submission_display_main() { global $theme, $user; @@ -13,8 +13,8 @@ function submission_display_main() { $content .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n"; $content .= " <TR BGCOLOR=\"$bgcolor1\"><TH>Subject</TH><TH>Section</TH><TH>Date</TH><TH>Author</TH><TH>Score</TH></TR>\n"; while ($submission = db_fetch_object($result)) { - if ($user->id == $submission->author || user_getHistory($user->history, "s$submission->id")) $content .= " <TR><TD WIDTH=\"100%\"><A HREF=\"submission.php?op=view&id=$submission->id\">". stripslashes($submission->subject) ."</A></TD><TD>$submission->section</TD><TD ALIGN=\"center\">". date("Y-m-d", $submission->timestamp) ."<BR>". date("H:m:s", $submission->timestamp) ."</TD><TD ALIGN=\"center\">". format_username($submission->userid) ."</TD><TD ALIGN=\"center\">". submission_score($submission->id) ."</TD></TR>\n"; - else $content .= " <TR><TD WIDTH=\"100%\"><A HREF=\"submission.php?op=view&id=$submission->id\">". stripslashes($submission->subject) ."</A></TD><TD>$submission->section</TD><TD ALIGN=\"center\">". date("Y-m-d", $submission->timestamp) ."<BR>". date("H:m:s", $submission->timestamp) ."</TD><TD ALIGN=\"center\">". format_username($submission->userid) ."</TD><TD ALIGN=\"center\"><A HREF=\"submission.php?op=view&id=$submission->id\">vote</A></TD></TR>\n"; + if ($user->id == $submission->author || user_get_history($user->history, "s$submission->id")) $content .= " <TR><TD WIDTH=\"100%\"><A HREF=\"submission.php?op=view&id=$submission->id\">". check_output($submission->subject) ."</A></TD><TD>$submission->section</TD><TD ALIGN=\"center\">". date("Y-m-d", $submission->timestamp) ."<BR>". date("H:m:s", $submission->timestamp) ."</TD><TD ALIGN=\"center\">". format_username($submission->userid) ."</TD><TD ALIGN=\"center\">". submission_score($submission->id) ."</TD></TR>\n"; + else $content .= " <TR><TD WIDTH=\"100%\"><A HREF=\"submission.php?op=view&id=$submission->id\">". check_output($submission->subject) ."</A></TD><TD>$submission->section</TD><TD ALIGN=\"center\">". date("Y-m-d", $submission->timestamp) ."<BR>". date("H:m:s", $submission->timestamp) ."</TD><TD ALIGN=\"center\">". format_username($submission->userid) ."</TD><TD ALIGN=\"center\"><A HREF=\"submission.php?op=view&id=$submission->id\">vote</A></TD></TR>\n"; } $content .= "</TABLE>\n"; @@ -29,19 +29,19 @@ function submission_display_item($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); - if ($user->id == $submission->author || user_getHistory($user->history, "s$id")) { + if ($user->id == $submission->author || user_get_history($user->history, "s$id")) { header("Location: story.php?id=$id"); } else { $theme->header(); - $theme->article($submission, "[ <A HREF=\"submission.php\"><FONT COLOR=\"$theme->hlcolor2\">back</FONT></A> ]"); + $theme->article($submission, "[ <A HREF=\"submission.php\"><FONT COLOR=\"$theme->link\">back</FONT></A> ]"); print "<FORM ACTION=\"submission.php\" METHOD=\"post\">\n"; print "<P>\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 "</P>\n"; print "<P>\n"; @@ -63,6 +63,9 @@ if (strstr($id, " ")) { } if ($user->id) { + + user_rehash(); + switch($op) { case "view": submission_display_item($id); diff --git a/submit.php b/submit.php index baf1b941e..8e9e56967 100644 --- a/submit.php +++ b/submit.php @@ -132,7 +132,7 @@ function submit_submit($subject, $abstract, $article, $section) { $theme->footer(); } -include "includes/common.inc"; +include_once "includes/common.inc"; switch($op) { case "Preview submission": diff --git a/themes/marvin/marvin.theme b/themes/marvin/marvin.theme index 5451ad5c6..287c8a524 100644 --- a/themes/marvin/marvin.theme +++ b/themes/marvin/marvin.theme @@ -1,6 +1,8 @@ <? class Theme { + var $link = "#666699"; + // color set #1: var $bgcolor1 = "#EAEAEA"; // background color var $fgcolor1 = "#404040"; // table body color @@ -40,7 +42,7 @@ <TD> </TD> </TR> <TR> - <TD ALIGN="right" COLSPAN="2"><SMALL><A HREF="/">home</A> | <A HREF="module.php?mod=faq">faq</A> | <A HREF="module.php?mod=diary">diary</A> | <A HREF="search.php">search</A> | <A HREF="submit.php">submit news</A> | <A HREF="account.php">user account</A></SMALL></TD> + <TD ALIGN="right" COLSPAN="2"><SMALL><A HREF="index.php">home</A> | <A HREF="module.php?mod=faq">faq</A> | <A HREF="module.php?mod=diary">diary</A> | <A HREF="search.php">search</A> | <A HREF="submit.php">submit news</A> | <A HREF="account.php">user account</A></SMALL></TD> </TR> <TR> <TD VALIGN="top" WIDTH="100%"> @@ -182,7 +184,7 @@ </TR> <TR> <TD ALIGN="center" COLSPAN="3"> - <SMALL>[ <A HREF="/">home</A> | <A HREF="module.php?mod=faq">faq</A> | <A HREF="module.php?mod=diary">diary</A> | <A HREF="search.php">search</A> | <A HREF="submit.php">submit news</A> | <A HREF="account.php">user account</A> ]</SMALL> + <SMALL>[ <A HREF="index.php">home</A> | <A HREF="module.php?mod=faq">faq</A> | <A HREF="module.php?mod=diary">diary</A> | <A HREF="search.php">search</A> | <A HREF="submit.php">submit news</A> | <A HREF="account.php">user account</A> ]</SMALL> </TD> </TR> </TABLE> diff --git a/themes/unconed/unconed.theme b/themes/unconed/unconed.theme index ee6e308ab..01f2834a7 100644 --- a/themes/unconed/unconed.theme +++ b/themes/unconed/unconed.theme @@ -1,6 +1,7 @@ <? class Theme { + var $link = "#000000"; var $themename = "unconed"; var $cl80 = "#8B8E95"; diff --git a/updates/1.00-to-1.xx b/updates/1.00-to-1.xx index 8c2c20bf1..b115a3845 100644 --- a/updates/1.00-to-1.xx +++ b/updates/1.00-to-1.xx @@ -7,3 +7,6 @@ update comments set link = 'article'; # 21/01/2001: section manager alter table stories change category section varchar(64) DEFAULT '' NOT NULL; + +# 31/01/2001: block rehashing +alter table blocks add remove tinyint(1) DEFAULT '0' NOT NULL; |