Commit 554d9b08 authored by Dries's avatar Dries

- fixed 2 small bugs in account.php
- drastically improved administration section
- drastically revamped story administration:
  added new feature to schedule the publishing of stories
- applied correct naming conventions to submission.php
- fixed 1 small glitch in boxes
- somewhat expanded the documentation
= changed one SQL table
- updated the faq with info on drupal
- ... and more things I forgot about
parent 63a335e1
......@@ -461,7 +461,7 @@ function account_track_comments() {
$output .= " </UL>\n";
}
$output = ($output) ? "$msg $output" : "$info <CENTER><B>You have not posted any comments recently.</B></CENTER>\n";
$output = ($output) ? "$msg $output" : "$info <CENTER>You have not posted any comments recently.</CENTER>\n";
$theme->header();
$theme->box("Track your comments", $output);
......@@ -473,7 +473,7 @@ function account_track_stories() {
$msg = "<P>This page might be helpful in case you want to keep track of the stories you contributed. You are presented an overview of your stories along with the number of replies each story got.\n<P>\n";
$result = db_query("SELECT s.id, s.subject, s.timestamp, s.category, COUNT(s.id) as count FROM comments c LEFT JOIN stories s ON c.sid = s.id WHERE s.status = 2 AND s.author = $user->id GROUP BY s.id DESC");
$result = db_query("SELECT s.id, s.subject, s.timestamp, s.category, COUNT(c.cid) as count FROM stories s LEFT JOIN comments c ON c.sid = s.id WHERE s.status = 2 AND s.author = $user->id GROUP BY s.id DESC");
while ($story = db_fetch_object($result)) {
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
......@@ -484,10 +484,8 @@ function account_track_stories() {
$output .= "<P>\n";
}
$output = ($output) ? "$msg $output" : "$info <CENTER><B>You have not posted any stories.</B></CENTER>\n";
$theme->header();
$theme->box("Track your stories", $output);
$theme->box("Track your stories", ($output ? "$msg $output" : "$msg You have not posted any stories.\n"));
$theme->footer();
}
......@@ -504,6 +502,7 @@ function account_track_site() {
$block1 .= "</TABLE>\n";
$block1 .= "<P>\n";
}
$block1 = ($block1) ? $block1 : "<CENTER>You have not posted any comments recently.</CENTER>\n";
$users_total = db_result(db_query("SELECT COUNT(id) FROM users"));
......
......@@ -3,7 +3,7 @@
include "includes/common.inc";
// validate user permission:
if (!$user->id || ($user->permissions != 1 && $user->id > 1)) exit();
if (!($user->permissions == 1 || $user->id == 1)) exit();
function admin_page($mod) {
global $repository, $menu, $modules;
......@@ -17,7 +17,7 @@ function module($name, $module) {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD><TITLE><? echo $site_name; ?> administration center</TITLE></HEAD>
<HEAD><TITLE>Administration</TITLE></HEAD>
<STYLE>
body { font-family: helvetica, arial; }
h1 { font-size: 18pt; font-weight: bold; color: #990000; }
......@@ -27,7 +27,7 @@ function module($name, $module) {
td { font-family: helvetica, arial; }
</STYLE>
<BODY BGCOLOR="#FFFFFF" LINK="#005599" VLINK="#004499" ALINK="#FF0000">
<H1>Administration center</H1>
<H1>Administration</H1>
<?
ksort($repository);
......
......@@ -2,7 +2,7 @@
include "includes/common.inc";
function cron_run($cron) {
function cron_run() {
global $repository;
$time = time();
......
......@@ -122,6 +122,7 @@ CREATE TABLE stories (
score int(11) DEFAULT '0' NOT NULL,
votes int(11) DEFAULT '0' NOT NULL,
status int(4) DEFAULT '1',
UNIQUE subject (subject),
PRIMARY KEY (id)
);
......
......@@ -68,10 +68,10 @@ function format_interval($timestamp) {
$output .= floor($timestamp / 60) ." min ";
$timestamp = $timestamp % 60;
}
if ($timestamp >= 0) {
if ($timestamp > 0) {
$output .= "$timestamp sec";
}
return $output;
return ($output) ? $output : "0 sec";
}
function format_date($timestamp, $type = "medium") {
......
......@@ -10,7 +10,7 @@
function watchdog($id, $message) {
global $user, $watchdog, $watchdog_history;
if ($watchdog[$id][1]) {
if ($watchdog[$id][1] && !($user->permissions == 1 || $user->id == 1)) {
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");
......
......@@ -4,13 +4,8 @@
include "includes/ban.inc";
function ban_check($mask, $category) {
$ban = ban_match($mask, $category);
$output .= "". ($ban ? "Matched ban '<B>$ban->mask</B>' with reason: <I>$ban->reason</I>.<P>\n" : "No matching bans for '$mask'.<P>\n") ."";
print $output;
}
function ban_new($mask, $category, $reason) {
function ban_admin_new($mask, $category, $reason) {
ban_add($mask, $category, $reason, &$message);
$output .= "$message\n";
print $output;
......@@ -44,14 +39,17 @@ function ban_display($category = "") {
$output .= " <TH>reason</TH>\n";
$output .= " <TH>operations</TH>\n";
$output .= " </TR>\n";
while ($ban = db_fetch_object($result)) {
$output .= " <TR><TD>$ban->mask</TD><TD>$ban->reason</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=ban&op=delete&category=$category&id=$ban->id\">delete</A></TD></TR>\n";
}
$output .= " <TR><TD COLSPAN=\"3\"><SMALL>%: matches any number of characters, even zero characters.<BR>_: matches exactly one character.</SMALL></TD></TR>\n";
$output .= "</TABLE>\n";
$output .= "<BR><HR>\n";
print $output;
}
function ban_admin_add() {
global $type2index;
$output .= "<H3>Add new ban:</H3>\n";
$output .= "<FORM ACTION=\"admin.php?mod=ban\" METHOD=\"post\">\n";
......@@ -67,7 +65,18 @@ function ban_display($category = "") {
$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";
print $output;
}
function ban_check($mask, $category) {
$ban = ban_match($mask, $category);
$output .= "". ($ban ? "Matched ban '<B>$ban->mask</B>' with reason: <I>$ban->reason</I>.<P>\n" : "No matching bans for '$mask'.<P>\n") ."";
print $output;
}
function ban_admin_check() {
global $type2index;
$output .= "<H3>Ban check:</H3>\n";
$output .= "<FORM ACTION=\"admin.php?mod=ban\" METHOD=\"post\">\n";
......@@ -88,14 +97,21 @@ function ban_display($category = "") {
function ban_admin() {
global $op, $id, $mask, $category, $reason;
print "<SMALL><A HREF=\"admin.php?mod=ban&op=add\">add ban</A> | <A HREF=\"admin.php?mod=ban&op=check\">check ban</A> | <A HREF=\"admin.php?mod=ban\">overview</A></SMALL><HR>\n";
switch ($op) {
case "Add ban":
ban_new($mask, $category, $reason);
ban_admin_new($mask, $category, $reason);
ban_display($category);
break;
case "Check ban":
ban_check($mask, $category);
ban_display($category);
break;
case "add":
ban_admin_add();
break;
case "check":
ban_admin_check();
break;
case "delete":
ban_delete($id);
......
......@@ -39,7 +39,7 @@ function box_block() {
$i = 0;
while ($block = db_fetch_object($result)) {
$blocks[$i]["subject"] = check_output($block->subject);
$blocks[$i]["content"] = ($block->type == 2) ? eval($block->content) : check_output($block->content);
$blocks[$i]["content"] = ($block->type == 2) ? eval($block->content) : check_output($block->content, ($block->type == 1) ? 0 : 1);
$blocks[$i]["info"] = check_output($block->info);
$blocks[$i]["link"] = check_output($block->link);
$i++;
......@@ -58,13 +58,19 @@ function box_admin_display() {
$output .= " <TR><TH>Subject:</TH><TD>". format_data($block->subject) ."</TD></TR>\n";
$output .= " <TR><TH>Content:</TH><TD>". nl2br(htmlentities($block->content)) ."</TD></TR>\n";
$output .= " <TR><TH>Type:</TH><TD>". $type[$block->type] ."</TD></TR>\n";
$output .= " <TR><TH>Description:</TH><TD><I>". format_data($block->info) ."</I></TD></TR>\n";
$output .= " <TR><TH>Description:</TH><TD>". format_data($block->info) ."</TD></TR>\n";
$output .= " <TR><TH>Link:</TH><TD>". format_url($block->link) ."</TD></TR>\n";
$output .= " <TR><TH>Operations:</TH><TD><A HREF=\"admin.php?mod=box&op=edit&id=$block->id\">edit</A>, <A HREF=\"admin.php?mod=box&op=delete&id=$block->id\">delete</A></TD></TR>\n";
$output .= "</TABLE>\n";
$output .= "<BR><BR>\n";
}
print $output;
}
function box_admin_new() {
$type = array(0 => "ASCII", 1 => "HTML", 2 => "PHP");
foreach ($type as $key=>$value) {
$selection .= " <OPTION VALUE=\"$key\">$value</OPTION>\n";
}
......@@ -79,7 +85,6 @@ function box_admin_display() {
$output .= " <TR><TH>Operations:</TH><TD><INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Add box\"></TD></TR>\n";
$output .= "</TABLE>\n";
$output .= "</FORM>\n";
print $output;
}
......@@ -146,6 +151,8 @@ function box_admin_save($id, $subject, $content, $info, $link, $type) {
function box_admin() {
global $op, $id, $subject, $content, $info, $link, $type;
print "<SMALL><A HREF=\"admin.php?mod=box&op=add\">add new box</A> | <A HREF=\"admin.php?mod=box\">overview</A> | <A HREF=\"admin.php?mod=box&op=help\">help</A></SMALL><HR>\n";
switch ($op) {
case "Add box":
box_admin_add($subject, $content, $info, $link, $type);
......@@ -157,6 +164,12 @@ function box_admin() {
box_admin_display();
box_admin_rehash();
break;
case "help":
box_help();
break;
case "add":
box_admin_new();
break;
case "edit":
box_admin_edit($id);
break;
......
<?
$module = array("admin" => "cron_admin");
$module = array("help" => "cron_help",
"admin" => "cron_admin");
function cron_help() {
?>
<P>Cron (which stands for chronograph) is a periodic command scheduler: it executes commands at intervals specified in seconds. It can be used to control the execution of daily, weekly and monthly jobs (or anything with a period of n seconds). Automating tasks is one of the best ways to keep a system running smoothly, and if most of your administration does not require your direct involvement, cron is an ideal solution.</P>
<P>Note that cron does not guarantee that the commands will be executed at the specified interval. However, the engine will make sure that the commands are run at the specified intervals as closely as possible.</P>
<P>Check the <A HREF="admin.php?mod=documentation">documentation</A> for more information about cron and how to setup it correctly.</P>
<?
}
function cron_save($edit) {
foreach ($edit as $key=>$value) {
......@@ -32,13 +41,18 @@ function cron_display() {
function cron_admin() {
global $op, $edit, $name;
print "<SMALL><A HREF=\"admin.php?mod=cron\">overview</A> | <A HREF=\"admin.php?mod=cron&op=help\">help</A></SMALL><HR>\n";
switch($op) {
case "help":
cron_help();
break;
case "Save crons":
cron_save($edit);
break;
// fall through
default:
cron_display();
}
cron_display();
}
?>
......@@ -42,15 +42,16 @@ function documentation() {
<BLOCKQUOTE>$ cp includes/hostname.conf includes/www.yourdomain.com.conf</BLOCKQUOTE>
<P>6. Edit your configuration file to set the required settings such as the database options and to customize your site to your likings.</P>
<P>7. Launch your browser and point it to http://yourdomain.com/, create an account, log in and head on to http://yourdomain.com/admin.php. The first user will automatically have administrator permissions. Play with it for a bit and spend some time getting used to the administration interfaces.</P>
<P>8. Optionally (yet recommended for smooth operation) setup a crontab to periodically visit http://yourdomain.com/cron.php.</P>
<P>8. Optionally (yet recommended for smooth operation) edit the <CODE>.htaccess</CODE> file and set the values of the PHP variables to your likings: <CODE>session.name</CODE>, <CODE>session.cookie_lifetime</CODE>, <CODE>session.gc_maxlifetime</CODE>, <CODE>session.cache_expire</CODE> and <CODE>session.save_path</CODE>. Check your PHP reference manual for the exact purpose of each variable mentioned.</P>
<P>9. Optionally (yet recommended for smooth operation) setup a crontab to periodically visit http://yourdomain.com/cron.php.</P>
<P>Use a browser like lynx or wget but make sure the process terminates: either use /usr/bin/lynx -source http://yourdomain.com/cron.php or /usr/bin/wget -O /dev/null http://yourdomain.com/cron.php. Take a look at the example scripts in the <CODE>scripts</CODE>-directory and make sure to adjust them to your needs.</P>
<P>A good crontab-line to run the cron-script once every hour would be:</P>
<PRE>
00 * * * * /home/www/drupal/scripts/cron-lynx
</PRE>
<P>9. (optional) Create your site's theme or at least customize the existing themes. To get started, head on to the <CODE>themes</CODE>-directory and make a custom logo for each theme.
<P>10. (optional) Add and remove modules to customize the functionality of your site. Adding and removing modules is plain easy. You can add a module by copying the files into the <CODE>modules</CODE>-directory and you can remove a module by removing a module's file from the <CODE>modules</CODE>-directory. The drupal engine will then automatically include or exclude this module. If for some reason, this seems to fail, "manually" rehash the modules list from http://yourdomain.com/admin.php?mod=module.</P>
<P>11. If you get it to run, let us know at <A HREF="mailto:info@drop.org">info@drop.org</A> so we can add your site to our list of drupal sites. If you can't get it to run, you can find support at the drupal site or you can contact us by e-mail at <A HREF="mailto:info@drop.org">info@drop.org</A>.</P>
<P>10. Optionally create your site's theme or at least customize the existing themes. To get started, head on to the <CODE>themes</CODE>-directory and make a custom logo for each theme.
<P>11. Optionally add and remove modules to customize the functionality of your site. Adding and removing modules is plain easy. You can add a module by copying the files into the <CODE>modules</CODE>-directory and you can remove a module by removing a module's file from the <CODE>modules</CODE>-directory. The drupal engine will then automatically include or exclude this module. If for some reason, this seems to fail, "manually" rehash the modules list from http://yourdomain.com/admin.php?mod=module.</P>
<P>12. If you get it to run, let us know at <A HREF="mailto:info@drop.org">info@drop.org</A> so we can add your site to our list of drupal sites. If you can't get it to run, you can find support at the drupal site or you can contact us by e-mail at <A HREF="mailto:info@drop.org">info@drop.org</A>.</P>
<H2>More than one (sub)domain on one machine</H2>
......@@ -172,7 +173,7 @@ function documentation() {
</TR>
<TR>
<TD VALIGN="top"><CODE>user</CODE></TD>
<TD VALIGN="top"></TD>
<TD VALIGN="top">If a module requires to extend any of the setting pages available to individual users, it should implement the user hook. The function takes 3 parameters, resp.: <CODE>$username</CODE>, <CODE>$section</CODE> ("user", "site", "content") and <CODE>$operation</CODE> ("edit", "view", "save").</TD>
</TR>
</TABLE>
<P>Even though we aim towards modularity, a basic rule is to avoid defined interfaces. We are exceptionally careful when it comes down to adding hooks because once you give a hook to developers they will start coding to it and once somebody's using it, you are stuck with it.</P>
......
......@@ -55,7 +55,7 @@ function faq_page() {
<DD>Write us a bugreport or send us a patch! Writing a good bug report takes patience, but doing it right the first time saves both you and us time. It is most helpful when a good description of the problem is included in the bug report. That is, a good example of all the things you did that led to the problem and the problem itself exactly described. The best reports are those that include a full example showing how to reproduce the bug or problem.<P></DD>
<DT><B>Is the source code of this site available?</B></DT>
<DD>This site is powered by <A HREF=\"http://www.fsf.org/\">Free Software</A>; including <A HREF=\"http://www.apache.org/\">Apache</A>, <A HREF=\"http://www.php.net/\">PHP</A>, <A HREF=\"http://www.mysql.com/\">MySQL</A> and <A HREF=\"http://www.linux.com/\">Linux</A>, and is inspired by several <A HREF=\"http://www.fsf.org/\">Free Software</A> projects. Therefor we have decided to make the software engine of this site available under terms of GPL.<P>However, the sources are <B>not</B> available yet at this time, but will be released as soon we have a first, well-rounded source tree that has proven to be stable. If you can't wait or in case you have big plans (like `total domination') with the engine, don't hesitate to contact us and we might grant you CVS access.<P></DD>
<DD>This site is powered by <A HREF=\"http://www.fsf.org/\">Free Software</A>; including <A HREF=\"http://www.apache.org/\">Apache</A>, <A HREF=\"http://www.php.net/\">PHP</A>, <A HREF=\"http://www.mysql.com/\">MySQL</A> and <A HREF=\"http://www.linux.com/\">Linux</A>, and is inspired by several <A HREF=\"http://www.fsf.org/\">Free Software</A> projects. Therefor we have decided to make the software engine of this site, called <A HREF=\"module.php?mod=drupal\">drupal</A> available under terms of GPL.<P> The source code and more information about <A HREF=\"module.php?mod=drupal\">drupal</A> are available <A HREF=\"module.php?mod=drupal\">here</A>.<P></DD>
<DT><B>What features does the engine have?</B></DT>
<DD>
......
......@@ -100,7 +100,7 @@ function headline_block() {
return $blocks;
}
function headline_admin_main() {
function headline_admin_display() {
global $theme;
// Get channel info:
......@@ -123,8 +123,11 @@ function headline_admin_main() {
}
$output .= "</TABLE>\n";
$output .= "<BR><BR>\n";
$output .= "<HR>\n";
print $output;
}
function headline_admin_add() {
$output .= " <FORM ACTION=\"admin.php?mod=headline\" METHOD=\"post\">\n";
$output .= " <P>\n";
$output .= " <B>Site name:</B><BR>\n";
......@@ -151,23 +154,31 @@ function headline_admin_main() {
function headline_admin() {
global $op, $id, $site, $url, $backend, $contact;
print "<SMALL><A HREF=\"admin.php?mod=headline&op=add\">add new channel</A> | <A HREF=\"admin.php?mod=headline\">overview</A> | <A HREF=\"admin.php?mod=headline&op=help\">help</A></SMALL><HR>";
switch($op) {
case "refresh":
$backend = new backend($id);
$backend->refresh();
headline_admin_main();
case "add":
headline_admin_add();
break;
case "delete":
$backend = new backend($id);
$backend->delete();
headline_admin_main();
headline_admin_display();
break;
case "help":
headline_help();
break;
case "refresh":
$backend = new backend($id);
$backend->refresh();
headline_admin_display();
break;
case "Add backend":
$backend = new backend($id, $site, $url, $backend, $contact);
$backend->add();
// fall through:
default:
headline_admin_main();
headline_admin_display();
}
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -3,7 +3,7 @@
include "includes/submission.inc";
include "includes/common.inc";
function submission_displayMain() {
function submission_display_main() {
global $PHP_SELF, $theme, $user;
// Perform query:
......@@ -23,7 +23,7 @@ function submission_displayMain() {
$theme->footer();
}
function submission_displayItem($id) {
function submission_display_item($id) {
global $PHP_SELF, $theme, $user, $submission_votes;
if ($vote = user_getHistory($user->history, "s$id")) {
......@@ -67,14 +67,14 @@ function submission_displayItem($id) {
if ($user->id) {
switch($op) {
case "view":
submission_displayItem($id);
submission_display_item($id);
break;
case "Vote";
submission_vote($id, $vote, $comment);
submission_displayItem($id);
submission_display_item($id);
break;
default:
submission_displayMain();
submission_display_main();
break;
}
}
......
......@@ -130,7 +130,7 @@ function submit_submit($subject, $abstract, $article, $category) {
global $user, $theme;
// Add log entry:
watchdog("story", "added new story with subject `$subject'");
watchdog("story", "story: added '$subject'");
// Add submission to SQL table:
db_query("INSERT INTO stories (author, subject, abstract, article, category, timestamp) VALUES ('$user->id', '". check_input($subject) ."', '". check_input($abstract) ."', '". check_input($article) ."', '". check_input($category) ."', '". time() ."')");
......
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