summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2000-12-10 16:22:50 +0000
committerDries Buytaert <dries@buytaert.net>2000-12-10 16:22:50 +0000
commite8ea2ab88ec843905f307566a1e576f87a3d65ef (patch)
tree0f3403a09ac47ea86fa6aea4b05676ead8c24dfc
parent2a4c9cc97ba42107e55637dfc549c80c02238246 (diff)
downloadbrdo-e8ea2ab88ec843905f307566a1e576f87a3d65ef.tar.gz
brdo-e8ea2ab88ec843905f307566a1e576f87a3d65ef.tar.bz2
- large batch of updated files featuring various changes: big, small and
new stuff!
-rw-r--r--admin.php112
-rw-r--r--includes/admin.inc13
-rw-r--r--includes/ban.inc8
-rw-r--r--includes/config.inc23
-rw-r--r--includes/function.inc4
-rw-r--r--includes/theme.inc1
-rw-r--r--includes/user.inc4
-rw-r--r--includes/watchdog.inc9
-rw-r--r--submit.php6
9 files changed, 133 insertions, 47 deletions
diff --git a/admin.php b/admin.php
index 7aa5b4f75..d6acdd3f0 100644
--- a/admin.php
+++ b/admin.php
@@ -168,6 +168,28 @@ function watchdog_view($id) {
}
/*
+ * Cron administration:
+ */
+function cron_display() {
+ ### Perform query:
+ $result = db_query("SELECT * FROM cron");
+
+ ### Generate output:
+ while ($cron = db_fetch_object($result)) {
+ $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
+ $output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\">Name:</TD><TD>". check_output($cron->name) ."</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\">Help:</TD><TD>". check_output($cron->help) ."</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\">Code:</TD><TD><CODE>". nl2br($cron->code) ."</CODE></TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\">Last run:</TD><TD>". format_date($cron->timestamp) ."</TD></TR>\n";
+ $output .= " <TD><TD ALIGN=\"right\" VALIGN=\"top\">Scheduled:</TD><TD>every $cron->scheduled seconds</TD></TR>\n";
+ $output .= "</TABLE>\n";
+ $output .= "<BR><BR>\n";
+ }
+
+ print $output;
+}
+
+/*
* Ban administration:
*/
@@ -231,7 +253,7 @@ function ban_display($category = "") {
}
$output .= "</SELECT><P>\n";
$output .= "<B>Reason:</B><BR>\n";
- $output .= "<TEXTAREA NAME=\"reason\" COLS=\"35\" ROWS=\"5\"></TEXTAREA><P>\n";
+ $output .= "<TEXTAREA NAME=\"reason\" COLS=\"50\" ROWS=\"5\"></TEXTAREA><P>\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Add ban\"><BR>\n";
$output .= "</FORM>\n";
$output .= "<BR><HR>\n";
@@ -439,22 +461,66 @@ function home_display() {
}
/*
- * Misc administration:
+ * Blob administration:
*/
-function misc_display() {
- print "<BIG>Upcoming features:</BIG>";
- print "<UL>\n";
- print " <LI>backup functionality</LI>\n";
- print " <LI>thresholds settings</LI>\n";
- print " <LI>...</LI>\n";
- print "</UL>\n";
+
+function blob_display() {
+ $result = db_query("SELECT * FROM blobs");
+
+ ### Generate output:
+ while ($block = db_fetch_object($result)) {
+ $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
+ $output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\">Name:</TD><TD>". check_output($block->name) ."</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\">Help:</TD><TD>". check_output($block->help) ."</TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\">Code:</TD><TD><CODE>". nl2br(htmlentities($block->code)) ."</CODE></TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\">Operations:</TD><TD><A HREF=\"admin.php?section=blobs&op=edit&id=$block->id\">edit</A>, <A HREF=\"admin.php?section=blobs&op=delete&id=$block->id\">delete</A></TD></TR>\n";
+ $output .= "</TABLE>\n";
+ $output .= "<BR><BR>\n";
+ }
+
+ $output .= "<H3>Add new block:</H3>\n";
+ $output .= "<FORM ACTION=\"admin.php?section=blobs\" METHOD=\"post\">\n";
+ $output .= "<B>Name:</B><BR>\n";
+ $output .= "<INPUT TYPE=\"text\" NAME=\"name\" SIZE=\"35\"><P>\n";
+ $output .= "<B>Help:</B><BR>\n";
+ $output .= "<TEXTAREA NAME=\"help\" COLS=\"50\" ROWS=\"5\"></TEXTAREA><P>\n";
+ $output .= "<B>Code:</B><BR>\n";
+ $output .= "<TEXTAREA NAME=\"code\" COLS=\"50\" ROWS=\"5\"></TEXTAREA><P>\n";
+ $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Add block\"><BR>\n";
+ $output .= "</FORM>\n";
+ $output .= "<BR><HR>\n";
+
+ print $output;
+}
+
+function blob_edit($id) {
+ $result = db_query("SELECT * FROM blobs WHERE id = $id");
+
+ if ($block = db_fetch_object($result)) {
+ $output .= "<FORM ACTION=\"admin.php?section=blobs\" METHOD=\"post\">\n";
+ $output .= "<B>Name:</B><BR>\n";
+ $output .= "<INPUT TYPE=\"text\" NAME=\"name\" VALUE=\"". check_field($block->name) ."\" SIZE=\"35\"><P>\n";
+ $output .= "<B>Help:</B><BR>\n";
+ $output .= "<TEXTAREA NAME=\"help\" COLS=\"50\" ROWS=\"5\">$block->help</TEXTAREA><P>\n";
+ $output .= "<B>Code:</B><BR>\n";
+ $output .= "<TEXTAREA NAME=\"code\" COLS=\"50\" ROWS=\"5\">$block->code</TEXTAREA><P>\n";
+ $output .= "<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$id\">\n";
+ $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save block\"><BR>\n";
+ $output .= "</FORM>\n";
+ $output .= "<BR><HR>\n";
+ }
+
+ print $output;
}
+function blob_save($id, $name, $help, $code) {
+ db_query("UPDATE blobs SET name = '". check_input($name) ."', help = '". check_input($help) ."', code = '". check_code($code) ."' WHERE id = $id");
+ watchdog("message", "modified block `$name'.");
+}
/*
* Story administration:
*/
-
function story_edit($id) {
global $categories;
@@ -642,8 +708,25 @@ switch ($section) {
account_display();
}
break;
- case "misc":
- misc_display();
+ case "blobs":
+ include "includes/blob.inc";
+ switch ($op) {
+ case "Add block":
+ blob_add($name, $help, $code);
+ blob_display();
+ break;
+ case "Save block":
+ blob_save($id, $name, $help, $code);
+ blob_display();
+ break;
+ case "edit":
+ blob_edit($id);
+ break;
+ case "delete":
+ blob_delete($id);
+ default:
+ blob_display();
+ }
break;
case "bans":
include "includes/ban.inc";
@@ -658,8 +741,6 @@ switch ($section) {
break;
case "delete":
ban_delete($id);
- ban_display($category);
- break;
default:
ban_display($category);
}
@@ -676,6 +757,9 @@ switch ($section) {
watchdog_display();
}
break;
+ case "cron":
+ cron_display();
+ break;
case "stats":
stats_display();
break;
diff --git a/includes/admin.inc b/includes/admin.inc
index 2d13c7c17..2825d728f 100644
--- a/includes/admin.inc
+++ b/includes/admin.inc
@@ -23,27 +23,28 @@ function admin_header() {
td { font-family: helvetica, arial; }
</STYLE>
<BODY BGCOLOR="#FFFFFF" LINK="#006699" VLINK="#004499" ALINK="#FF0000">
- <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="780">
+ <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="2">
<TR><TD COLSPAN="10"><H1><? echo "$site_name"; ?> administration center</H1></TD></TR>
- <TR><TD BGCOLOR="#000000" COLSPAN="10" WIDTH="100%"><IMG SRC="images/pixel.gif" WIDTH="1" HEIGHT="1" ALT=""></TD></TR>
+ <TR><TD BGCOLOR="#000000" COLSPAN="11" WIDTH="100%"><IMG SRC="images/pixel.gif" WIDTH="1" HEIGHT="1" ALT=""></TD></TR>
<TR>
<?
admin_icon("stories");
admin_icon("comments");
admin_icon("diaries");
admin_icon("accounts");
- admin_icon("misc");
- admin_icon("bans");
admin_icon("watchdog");
+ admin_icon("blobs");
+ admin_icon("cron");
+ admin_icon("bans");
admin_icon("stats");
admin_icon("info");
admin_icon("home");
?>
</TR>
- <TR><TD BGCOLOR="#000000" COLSPAN="10" WIDTH="100%"><IMG SRC="images/pixel.gif" WIDTH="1" HEIGHT="0" ALT=""></TD></TR>
+ <TR><TD BGCOLOR="#000000" COLSPAN="11" WIDTH="100%"><IMG SRC="images/pixel.gif" WIDTH="1" HEIGHT="0" ALT=""></TD></TR>
<TR><TD COLSPAN="10">&nbsp;</TD></TR>
<TR>
- <TD COLSPAN="10">
+ <TD COLSPAN="11">
<?
}
diff --git a/includes/ban.inc b/includes/ban.inc
index 8a4045945..f31ef849a 100644
--- a/includes/ban.inc
+++ b/includes/ban.inc
@@ -4,11 +4,13 @@ $type2index = array("addresses" => 0x01,
"profanity" => 0x02,
"hostnames" => 0x03,
"usernames" => 0x04);
+
$index2type = array(0x01 => "addresses",
0x02 => "profanity",
0x03 => "hostnames",
0x04 => "usernames");
+
function ban_match($mask, $category) {
### Perform query:
$result = db_query("SELECT * FROM bans WHERE type = $category AND LOWER('$mask') LIKE LOWER(mask)");
@@ -21,14 +23,14 @@ function ban_add($mask, $category, $reason, $message = "") {
global $index2type;
if (empty($mask)) {
- $message = "Failed: empty banmasks are not allowed.<P>\n";
+ $message = "failed: empty banmasks are not allowed.<P>\n";
}
else if ($ban = db_fetch_object(db_query("SELECT * FROM bans WHERE type = $category AND '$mask' LIKE mask"))) {
- $message = "Failed: ban is already matched by '$ban->mask'.<P>\n";
+ $message = "failed: ban is already matched by '$ban->mask'.<P>\n";
}
else {
$result = db_query("INSERT INTO bans (mask, type, reason, timestamp) VALUES ('$mask', '$category', '$reason', '". time() ."')");
- $message = "Added new ban with mask `$mask'.<P>\n";
+ $message = "added new ban with mask `$mask'.<P>\n";
### Add log entry:
watchdog("message", "added new ban `$mask' to category `". $index2type[$category] ."' with reason `$reason'.");
diff --git a/includes/config.inc b/includes/config.inc
index a2ec3763f..87726021f 100644
--- a/includes/config.inc
+++ b/includes/config.inc
@@ -5,10 +5,10 @@
#
### host: "http://www.drop.org/":
-#$db_host = "zind.net";
-#$db_name = "droporg";
-#$db_pass = "DropIes";
-#$db_name = "droporg";
+$db_host = "zind.net";
+$db_name = "droporg";
+$db_pass = "DropIes";
+$db_name = "droporg";
### host: "http://beta.drop.org/":
#$db_host = "zind.net";
@@ -17,10 +17,10 @@
#$db_name = "dries";
### host: "http://localhost/":
-$db_host = "localhost";
-$db_name = "drop";
-$db_pass = "drop";
-$db_name = "drop";
+#$db_host = "localhost";
+#$db_name = "drop";
+#$db_pass = "drop";
+#$db_name = "drop";
#
# Administrative information
@@ -134,11 +134,4 @@ $submission_rate = array("comment" => "60", // 60 seconds = 1 minute
#
$submission_size = 12000; // 12.000 characters is more or less 300 lines
-#
-# Watchdog history:
-# how long we should store the log files generated by the
-# watchdog
-#
-$watchdog_history = 604800; // 604.800 seconds = 1 week
-
?>
diff --git a/includes/function.inc b/includes/function.inc
index 8f9336603..3d4f5253f 100644
--- a/includes/function.inc
+++ b/includes/function.inc
@@ -32,6 +32,10 @@ function check_input($message) {
return strip_tags(addslashes(substr($message, 0, $submission_size)), $allowed_html);
}
+function check_code($message) {
+ return $message;
+}
+
function check_output($message, $nl2br = 0) {
global $allowed_html;
if ($nl2br == 1) return nl2br(strip_tags(stripslashes($message), $allowed_html));
diff --git a/includes/theme.inc b/includes/theme.inc
index 4736f6c3d..70fa3ecc7 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -4,6 +4,7 @@ include "includes/config.inc";
include "includes/database.inc";
include "includes/watchdog.inc";
include "includes/function.inc";
+include "includes/blob.inc";
include "includes/widget.inc";
include "includes/user.inc";
diff --git a/includes/user.inc b/includes/user.inc
index 0db582121..75bd5cfaf 100644
--- a/includes/user.inc
+++ b/includes/user.inc
@@ -71,4 +71,8 @@ function user_setHistory(&$user, $field, $value) {
db_query($query);
}
+function user_clean() {
+ // todo - called by cron job
+}
+
?>
diff --git a/includes/watchdog.inc b/includes/watchdog.inc
index 0bc33dfbf..2a007e3ce 100644
--- a/includes/watchdog.inc
+++ b/includes/watchdog.inc
@@ -22,12 +22,11 @@ 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")) ."')");
+}
- // Periodically remove old watchdog entries:
- if (time() % 20 == 0) {
- $timestamp = time() - $watchdog_history;
- db_query("DELETE FROM watchdog WHERE timestamp < $timestamp");
- }
+function watchdog_clean($history = "604800") {
+ $timestamp = time() - $history;
+ db_query("DELETE FROM watchdog WHERE timestamp < $timestamp");
}
?>
diff --git a/submit.php b/submit.php
index 2d8309cdc..269faea16 100644
--- a/submit.php
+++ b/submit.php
@@ -4,9 +4,7 @@ function submit_enter() {
global $anonymous, $categories, $allowed_html, $theme, $user;
### Guidlines:
- $output .= "<P>Got some news or some thoughts you would like to share? Fill out this form and they will automatically get whisked away to our submission queue where our moderators will frown at it, poke at it and hopefully post it. Every registered user is automatically a moderator and can vote whether or not your sumbission should be carried to the front page for discussion.</P>\n";
- $output .= "<P>Note that we do not revamp or extend your submission so it is up to you to make sure your submission is well-written: if you don't care enough to be clear and complete, your submission is likely to be moderated down by our army of moderators. Try to be complete, aim for clarity, organize and structure your text, and try to carry out your statements with examples. It is also encouraged to extend your submission with arguments that flow from your unique intellectual capability and experience: offer some insight or explanation as to why you think your submission is interesting. Make sure your submission has some meat on it!</P>\n";
- $output .= "<P>However, if you have bugs to report, complaints, personal questions or anything besides a public submission, we would prefer you to mail us instead, or your message is likely to get lost.</P><BR>\n";
+ $output .= block_get("submit_information");
### Submission form:
$output .= "<FORM ACTION=\"submit.php\" METHOD=\"post\">\n";
@@ -137,7 +135,7 @@ function submit_submit($subject, $abstract, $article, $category) {
### Display confirmation message:
$theme->header();
- $theme->box("Thank you for your submission.", "Thank you for your submission. The submission moderators in our basement will frown at it, poke at it, and vote for it!");
+ $theme->box("Thank you for your submission.", block_get("sumbit_confirmation"));
$theme->footer();
}