summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-01-06 11:39:43 +0000
committerDries Buytaert <dries@buytaert.net>2001-01-06 11:39:43 +0000
commit8511d9fb45bb2f5a016f0dd13b22a67d448c0d37 (patch)
treecde1eb77e8ef1f1f55818182a108d5997125f379
parentb604c438945f6d94472a470d2b09ad2b63c58651 (diff)
downloadbrdo-8511d9fb45bb2f5a016f0dd13b22a67d448c0d37.tar.gz
brdo-8511d9fb45bb2f5a016f0dd13b22a67d448c0d37.tar.bz2
A batch of patches:
- configuration: + renamed $db_name to $db_user + renamed $db_base to $db_name - fixed small diary glitch - fixed initial-comment-score problem - fixed comment rating bug: improved the API and updated the themes - removed some tabs from Steven ;) - fixed backend warnings and improved robustness I'm not happy yet with the headline grabber - it generates too many SQL errors. - some small cosmetic changes in comment.module - fixed minor glitch in format_interval()
-rw-r--r--discussion.php2
-rw-r--r--includes/database.inc8
-rw-r--r--includes/function.inc2
-rw-r--r--includes/hostname.conf8
-rw-r--r--includes/theme.inc21
-rw-r--r--modules/backend.class6
-rw-r--r--modules/comment.module4
-rw-r--r--modules/comment/comment.module4
-rw-r--r--modules/diary.module2
-rw-r--r--modules/drupal.module2
-rw-r--r--modules/drupal/drupal.module2
-rw-r--r--modules/headline.module23
-rw-r--r--themes/marvin/marvin.theme2
-rw-r--r--themes/unconed/unconed.theme2
14 files changed, 47 insertions, 41 deletions
diff --git a/discussion.php b/discussion.php
index bd795a6f7..52de6bdbb 100644
--- a/discussion.php
+++ b/discussion.php
@@ -265,7 +265,7 @@ function comment_post($pid, $sid, $subject, $comment) {
watchdog("comment", "discussion: added comment with subject '$subject'");
// Add comment to database:
- db_query("INSERT INTO comments (pid, sid, author, subject, comment, hostname, timestamp) VALUES ($pid, $sid, '$user->id', '". check_input($subject) ."', '". check_input($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."')");
+ db_query("INSERT INTO comments (pid, sid, author, subject, comment, hostname, timestamp, score) VALUES ($pid, $sid, '$user->id', '". check_input($subject) ."', '". check_input($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."', '". ($user->userid ? 1 : 0) ."')");
// Compose header:
header("Location: discussion.php?id=$sid");
diff --git a/includes/database.inc b/includes/database.inc
index ba708c87c..99d8391a4 100644
--- a/includes/database.inc
+++ b/includes/database.inc
@@ -7,9 +7,9 @@
* just adjust the handlers to your needs.
*/
-function db_connect($host, $name, $pass, $base) {
- mysql_pconnect($host, $name, $pass) or die(mysql_Error());
- mysql_select_db($base) or die ("unable to select database");
+function db_connect($host, $user, $pass, $name) {
+ mysql_pconnect($host, $user, $pass) or die(mysql_Error());
+ mysql_select_db($name) or die ("unable to select database");
// NOTE: we are using a persistent connection!
}
@@ -48,6 +48,6 @@ function db_result($qid, $field = 0) {
#
# Automatically connect to database:
#
-db_connect($db_host, $db_name, $db_pass, $db_base);
+db_connect($db_host, $db_user, $db_pass, $db_name);
?>
diff --git a/includes/function.inc b/includes/function.inc
index 4ebb161e8..a92d349d5 100644
--- a/includes/function.inc
+++ b/includes/function.inc
@@ -68,7 +68,7 @@ function format_interval($timestamp) {
$output .= floor($timestamp / 60) ." min ";
$timestamp = $timestamp % 60;
}
- if ($timestamp > 0) {
+ if ($timestamp >= 0) {
$output .= "$timestamp sec";
}
return $output;
diff --git a/includes/hostname.conf b/includes/hostname.conf
index 0f74e00f1..2b81c326b 100644
--- a/includes/hostname.conf
+++ b/includes/hostname.conf
@@ -3,12 +3,10 @@
#
# Database settings:
#
-
-### host: "http://localhost/":
$db_host = "localhost";
-$db_name = "name";
-$db_pass = "pass";
-$db_base = "base";
+$db_user = "username";
+$db_pass = "password";
+$db_name = "database";
#
diff --git a/includes/theme.inc b/includes/theme.inc
index 67ae4d4f9..c799a0f3c 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -27,15 +27,18 @@ function theme_account($theme) {
$content .= "<LI><A HREF=\"account.php?op=edit&topic=user\">edit your information</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=site\">edit your preferences</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=content\">edit site content</A></LI>\n";
- if (($user->id) && ($user->permissions == 1 || $user->id == 1)) {
- $content .= "<P>\n";
- $content .= "<LI><A HREF=\"admin.php\">administrate " . $site_name . "</A></LI>\n";
- }
$content .= "<P>\n";
- if (ksort($menu)) {
+
+ if (($user->id) && ($user->permissions == 1 || $user->id == 1)) {
+ $content .= "<LI><A HREF=\"admin.php\">administrate ". $site_name ."</A></LI>\n";
+ $content .= "<P>\n";
+ }
+
+ if ($menu && ksort($menu)) {
foreach ($menu as $link=>$url) $content .= "<LI><A HREF=\"$url\">$link</A></LI>\n";
$content .= "<P>\n";
}
+
$content .= "<LI><A HREF=\"account.php?op=logout\">logout</A></LI>\n";
$theme->box("$user->userid's configuration", "$content");
@@ -127,16 +130,16 @@ function theme_related_links($theme, $story) {
$theme->box("Related links", $content);
}
-function theme_comment_moderation($id, $author, $score, $votes) {
+function theme_comment_moderation($comment) {
global $user, $comment_votes;
- if ($user->id && $user->userid != $author && !user_getHistory($user->history, "c$id")) {
- $output .= "<SELECT NAME=\"moderate[$id]\">\n";
+ if ($user->id && $user->userid != $comment->userid && !user_getHistory($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";
}
else {
- $output .= "<TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"0\"><TR><TD>score:</TD><TD>". format_data($score) ."</TD></TR><TR><TD>votes:</TD><TD>". format_data($votes) ."</TR></TABLE>";
+ $output .= "<TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"1\"><TR><TD>score:</TD><TD>". format_data($comment->score) ."</TD></TR><TR><TD>votes:</TD><TD>". format_data($comment->votes) ."</TR></TABLE>";
}
return $output;
diff --git a/modules/backend.class b/modules/backend.class
index 888dcba0f..7869b6530 100644
--- a/modules/backend.class
+++ b/modules/backend.class
@@ -16,7 +16,7 @@ class backend {
// Contains the parsed rdf/rss/xml file:
var $headlines = array(); // latest headlines
- function backend($id, $site = "", $url = "", $file = "", $contact = "", $timout = 3600) {
+ function backend($id, $site = "", $url = "", $file = "", $contact = "", $timout = 10800) {
// Get channel info:
$result = db_query("SELECT * FROM channel WHERE id = '$id' OR site = '$site'");
@@ -153,7 +153,7 @@ class backend {
function add() {
// Add channel:
- $result = db_query("INSERT INTO channel (site, file, url, contact, timestamp) VALUES ('". check_input($this->site) ."', '". check_input($this->file) ."', '". check_input($this->url) ."', '". check_input($this->contact) ."', 42)");
+ $result = db_query("INSERT INTO channel (site, file, url, contact, timestamp) VALUES ('". check_input($this->site) ."', '". check_input($this->file) ."', '". check_input($this->url) ."', '". check_input($this->contact) ."', 1)");
}
function delete() {
@@ -169,7 +169,7 @@ class backend {
$result = db_query("DELETE FROM headlines WHERE id = $this->id");
// Mark channel as invalid to enforce an update:
- $result = db_query("UPDATE channel SET timestamp = 42 WHERE id = $this->id");
+ $result = db_query("UPDATE channel SET timestamp = 1 WHERE id = $this->id");
}
function dump() {
diff --git a/modules/comment.module b/modules/comment.module
index c3341442e..85b7b54dc 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -16,12 +16,12 @@ function comment_edit($id) {
$output .= "<P>\n";
$output .= " <B>Subject:</B><BR>\n";
- $output .= " <INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" VALUE=\"". check_output(check_field($comment->subject)) ."\"><BR>\n";
+ $output .= " <INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" VALUE=\"". check_output(check_field($comment->subject)) ."\">\n";
$output .= "</P>\n";
$output .= "<P>\n";
$output .= "<B>Comment:</B><BR>\n";
- $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"comment\">". check_output($comment->comment) ."</TEXTAREA><BR>\n";
+ $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"comment\">". check_output($comment->comment) ."</TEXTAREA>\n";
$output .= "</P>\n";
$output .= "<P>\n";
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index c3341442e..85b7b54dc 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -16,12 +16,12 @@ function comment_edit($id) {
$output .= "<P>\n";
$output .= " <B>Subject:</B><BR>\n";
- $output .= " <INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" VALUE=\"". check_output(check_field($comment->subject)) ."\"><BR>\n";
+ $output .= " <INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" VALUE=\"". check_output(check_field($comment->subject)) ."\">\n";
$output .= "</P>\n";
$output .= "<P>\n";
$output .= "<B>Comment:</B><BR>\n";
- $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"comment\">". check_output($comment->comment) ."</TEXTAREA><BR>\n";
+ $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"comment\">". check_output($comment->comment) ."</TEXTAREA>\n";
$output .= "</P>\n";
$output .= "<P>\n";
diff --git a/modules/diary.module b/modules/diary.module
index 27a74dea4..8c05ffffa 100644
--- a/modules/diary.module
+++ b/modules/diary.module
@@ -220,7 +220,7 @@ function diary_user($username, $section, $operation) {
function diary_menu() {
global $user;
- return array("edit your diary" => "module.php?mod=diary&op=edit", "view your diary" => "module.php?mod=diary&op=view");
+ return array("edit your diary" => "module.php?mod=diary&op=add", "view your diary" => "module.php?mod=diary&op=view");
}
function diary_block() {
diff --git a/modules/drupal.module b/modules/drupal.module
index 3eb6d4455..0417c11c3 100644
--- a/modules/drupal.module
+++ b/modules/drupal.module
@@ -22,7 +22,7 @@ function drupal_page() {
";
$handle = opendir("drupal");
- while ($file = readdir($handle)) if (ereg(".jpg", $file)) $output .= " <LI><SMALL><A HREF=\"drupal/$file\">$file</A></SMALL></LI>\n";
+ while ($file = readdir($handle)) if (ereg(".jpg", $file) || ereg(".gif", $file)) $output .= " <LI><SMALL><A HREF=\"drupal/$file\">$file</A></SMALL></LI>\n";
closedir($handle);
$theme->header();
diff --git a/modules/drupal/drupal.module b/modules/drupal/drupal.module
index 3eb6d4455..0417c11c3 100644
--- a/modules/drupal/drupal.module
+++ b/modules/drupal/drupal.module
@@ -22,7 +22,7 @@ function drupal_page() {
";
$handle = opendir("drupal");
- while ($file = readdir($handle)) if (ereg(".jpg", $file)) $output .= " <LI><SMALL><A HREF=\"drupal/$file\">$file</A></SMALL></LI>\n";
+ while ($file = readdir($handle)) if (ereg(".jpg", $file) || ereg(".gif", $file)) $output .= " <LI><SMALL><A HREF=\"drupal/$file\">$file</A></SMALL></LI>\n";
closedir($handle);
$theme->header();
diff --git a/modules/headline.module b/modules/headline.module
index 278043be1..358a1cc04 100644
--- a/modules/headline.module
+++ b/modules/headline.module
@@ -27,11 +27,13 @@ function headline_blocks() {
// Load backend from database:
$backend = new backend($channel->id);
-
- // Read headline from backend class:
- $content = "";
- for (reset($backend->headline); $headline = current($backend->headline); next($backend->headline)) {
- $content .= "<LI>$headline</LI>\n";
+
+ if ($backend->headlines) {
+ unset($content);
+ foreach ($backend->headlines as $headline) $content .= "<LI>$headline</LI>\n";
+ }
+ else {
+ $content = "no headlines available\n";
}
// Print backend box to screen:
@@ -79,13 +81,16 @@ function headline_block() {
$result = db_query("SELECT * FROM channel");
while ($channel = db_fetch_object($result)) {
$backend = new Backend($channel->id);
- $content = "";
- if ($backend->headline) {
- for (reset($backend->headline); $headline = current($backend->headline); next($backend->headline)) {
+ if ($backend->headlines) {
+ unset($content);
+ foreach ($backend->headlines as $headline) {
$content .= "<LI>$headline</LI>\n";
}
}
+ else {
+ $content = "no headlines available";
+ }
$blocks[$channel->id]["subject"] = $backend->site;
$blocks[$channel->id]["content"] = $content;
@@ -111,7 +116,7 @@ function headline_admin_main() {
$output .= "<TR>\n";
$output .= " <TD><A HREF=\"$backend->url\">$backend->site</A></TD>\n";
$output .= " <TD><A HREF=\"mailto:$backend->contact\">$backend->contact</A></TD>\n";
- $output .= " <TD ALIGN=\"center\">". format_interval(time() - $backend->timestamp) ." ago</TD>\n";
+ $output .= " <TD ALIGN=\"center\">". ($backend->timestamp == 1 ? "failed" : format_interval(time() - $backend->timestamp) ." ago") ."</TD>\n";
$output .= " <TD ALIGN=\"center\"><A HREF=\"admin.php?mod=headline&op=refresh&id=$backend->id\">refresh</A></TD>\n";
$output .= " <TD ALIGN=\"center\"><A HREF=\"admin.php?mod=headline&op=delete&id=$backend->id\">delete</A></TD>\n";
$output .= "</TR>\n";
diff --git a/themes/marvin/marvin.theme b/themes/marvin/marvin.theme
index a39c231ff..7e01cc2ba 100644
--- a/themes/marvin/marvin.theme
+++ b/themes/marvin/marvin.theme
@@ -168,7 +168,7 @@
// Moderation:
print " <TD ALIGN=\"right\" ROWSPAN=\"3\" VALIGN=\"middle\" WIDTH=\"15%\">\n";
- theme_comment_moderation($comment->cid, $comment->userid, $comment->score, $comment->votes);
+ print theme_comment_moderation($comment);
print " </TD>\n";
print " </TR>\n";
diff --git a/themes/unconed/unconed.theme b/themes/unconed/unconed.theme
index 7a386d18c..f91db81c3 100644
--- a/themes/unconed/unconed.theme
+++ b/themes/unconed/unconed.theme
@@ -224,7 +224,7 @@
// Moderation:
echo " <TD ALIGN=\"right\" ROWSPAN=\"3\" VALIGN=\"middle\" WIDTH=\"15%\">";
- theme_comment_moderation($comment->cid, $comment->userid, $comment->score, $comment->votes);
+ print theme_comment_moderation($comment);
echo " </TD>";
echo " </TR>";