Commit e8ea2ab8 authored by Dries's avatar Dries
Browse files

- large batch of updated files featuring various changes: big, small and
  new stuff!
parent 2a4c9cc9
......@@ -167,6 +167,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 @@ function info_display() {
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 @@ function info_display() {
break;
case "delete":
ban_delete($id);
ban_display($category);
break;
default:
ban_display($category);
}
......@@ -676,6 +757,9 @@ function info_display() {
watchdog_display();
}
break;
case "cron":
cron_display();
break;
case "stats":
stats_display();
break;
......
......@@ -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">
<?
}
......
......@@ -4,11 +4,13 @@
"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'.");
......
......@@ -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_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
?>
......@@ -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));
......
......@@ -4,6 +4,7 @@
include "includes/database.inc";
include "includes/watchdog.inc";
include "includes/function.inc";
include "includes/blob.inc";
include "includes/widget.inc";
include "includes/user.inc";
......
......@@ -71,4 +71,8 @@ function user_setHistory(&$user, $field, $value) {
db_query($query);
}
function user_clean() {
// todo - called by cron job
}
?>
......@@ -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");
}
?>
......@@ -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();
}
......
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