From e8ea2ab88ec843905f307566a1e576f87a3d65ef Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 10 Dec 2000 16:22:50 +0000 Subject: - large batch of updated files featuring various changes: big, small and new stuff! --- admin.php | 112 +++++++++++++++++++++++++++++++++++++++++++------- includes/admin.inc | 13 +++--- includes/ban.inc | 8 ++-- includes/config.inc | 23 ++++------- includes/function.inc | 4 ++ includes/theme.inc | 1 + includes/user.inc | 4 ++ includes/watchdog.inc | 9 ++-- submit.php | 6 +-- 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 @@ -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 .= "\n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= "
Name:". check_output($cron->name) ."
Help:". check_output($cron->help) ."
Code:". nl2br($cron->code) ."
Last run:". format_date($cron->timestamp) ."
Scheduled:every $cron->scheduled seconds
\n"; + $output .= "

\n"; + } + + print $output; +} + /* * Ban administration: */ @@ -231,7 +253,7 @@ function ban_display($category = "") { } $output .= "

\n"; $output .= "Reason:
\n"; - $output .= "

\n"; + $output .= "

\n"; $output .= "
\n"; $output .= "\n"; $output .= "


\n"; @@ -439,22 +461,66 @@ function home_display() { } /* - * Misc administration: + * Blob administration: */ -function misc_display() { - print "Upcoming features:"; - print "\n"; + +function blob_display() { + $result = db_query("SELECT * FROM blobs"); + + ### Generate output: + while ($block = db_fetch_object($result)) { + $output .= "\n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= "
Name:". check_output($block->name) ."
Help:". check_output($block->help) ."
Code:". nl2br(htmlentities($block->code)) ."
Operations:id\">edit, id\">delete
\n"; + $output .= "

\n"; + } + + $output .= "

Add new block:

\n"; + $output .= "
\n"; + $output .= "Name:
\n"; + $output .= "

\n"; + $output .= "Help:
\n"; + $output .= "

\n"; + $output .= "Code:
\n"; + $output .= "

\n"; + $output .= "
\n"; + $output .= "

\n"; + $output .= "

\n"; + + print $output; +} + +function blob_edit($id) { + $result = db_query("SELECT * FROM blobs WHERE id = $id"); + + if ($block = db_fetch_object($result)) { + $output .= "
\n"; + $output .= "Name:
\n"; + $output .= "name) ."\" SIZE=\"35\">

\n"; + $output .= "Help:
\n"; + $output .= "

\n"; + $output .= "Code:
\n"; + $output .= "

\n"; + $output .= "\n"; + $output .= "
\n"; + $output .= "

\n"; + $output .= "

\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; } - +
- + - + -

administration center

 
+ 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.

\n"; + $message = "failed: empty banmasks are not allowed.

\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'.

\n"; + $message = "failed: ban is already matched by '$ban->mask'.

\n"; } else { $result = db_query("INSERT INTO bans (mask, type, reason, timestamp) VALUES ('$mask', '$category', '$reason', '". time() ."')"); - $message = "Added new ban with mask `$mask'.

\n"; + $message = "added new ban with mask `$mask'.

\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 .= "

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.

\n"; - $output .= "

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!

\n"; - $output .= "

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.


\n"; + $output .= block_get("submit_information"); ### Submission form: $output .= "
\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(); } -- cgit v1.2.3