Commit fd641644 authored by Dries's avatar Dries

Surprise, surprise.  After nothing but code, a large batch of changes:
 - removed droplets
 - added (optional) admin_blocks module
 - added (optional) affiliate module
 - added (optional) about module (only placeholder, under construction)
 - fixed some tiny bugs (e.g. quote bug in search.php)
 - partionally rewrote some modules to be big, bad and better
 - partionally rewrote some modules to be more uniform
 - added GNU GPL license to CVS

Also:
 - installed PHP 4.0.4 on my localhost and now working
   towards PHP 4.0.4 compatibility.
 - I think I'll baptize the engine "drupal".  If you have a
   better idea, try convincing me ASAP.

Todo:
 - more testing (also with PHP 4.0.4)
 - make "project"-module: download, info, blah blah
 - complete documentation
parent 10381949
This diff is collapsed.
...@@ -20,8 +20,8 @@ function module($name, $module) { ...@@ -20,8 +20,8 @@ function module($name, $module) {
<HEAD><TITLE><? echo $site_name; ?> administration center</TITLE></HEAD> <HEAD><TITLE><? echo $site_name; ?> administration center</TITLE></HEAD>
<STYLE> <STYLE>
body { font-family: helvetica, arial; } body { font-family: helvetica, arial; }
h1 { font-size: 14pt; font-weight: bold; color: #990000; } h1 { font-size: 18pt; font-weight: bold; color: #990000; }
h2 { font-family: helvetica, arial; font-size: 12pt; font-weight: bold; } h2 { font-family: helvetica, arial; font-size: 18pt; font-weight: bold; }
h3 { font-family: helvetica, arial; font-size: 14pt; font-weight: bold; } h3 { font-family: helvetica, arial; font-size: 14pt; font-weight: bold; }
th { font-family: helvetica, arial; text-align: center; background-color: #CCCCCC; color: #995555; } th { font-family: helvetica, arial; text-align: center; background-color: #CCCCCC; color: #995555; }
td { font-family: helvetica, arial; } td { font-family: helvetica, arial; }
...@@ -29,7 +29,8 @@ function module($name, $module) { ...@@ -29,7 +29,8 @@ function module($name, $module) {
<BODY BGCOLOR="#FFFFFF" LINK="#005599" VLINK="#004499" ALINK="#FF0000"> <BODY BGCOLOR="#FFFFFF" LINK="#005599" VLINK="#004499" ALINK="#FF0000">
<H1>Administration center</H1> <H1>Administration center</H1>
<? <?
ksort($repository);
module_iterate("module"); module_iterate("module");
?> ?>
...@@ -39,8 +40,8 @@ function module($name, $module) { ...@@ -39,8 +40,8 @@ function module($name, $module) {
module_execute($mod, "admin"); module_execute($mod, "admin");
?> ?>
</BODY> </BODY>
</HTML> </HTML>
<? <?
} }
......
...@@ -8,4 +8,5 @@ function export($name, $module) { ...@@ -8,4 +8,5 @@ function export($name, $module) {
} }
module_iterate("export"); module_iterate("export");
?> ?>
\ No newline at end of file
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
include_once "includes/database.inc"; include_once "includes/database.inc";
include_once "includes/watchdog.inc"; include_once "includes/watchdog.inc";
include_once "includes/function.inc"; include_once "includes/function.inc";
include_once "includes/droplet.inc";
include_once "includes/module.inc"; include_once "includes/module.inc";
include_once "includes/theme.inc"; include_once "includes/theme.inc";
include_once "includes/user.inc"; include_once "includes/user.inc";
......
<?
function droplet_get($name) {
$result = db_query("SELECT * FROM droplets WHERE name = '$name'");
if ($droplet = db_fetch_object($result)) {
return eval($droplet->code);
}
else {
watchdog("error", "droplet '$name' does not exist");
}
}
function droplet_add($name, $help, $code, $message = "") {
$result = db_query("INSERT INTO droplets (name, help, code) VALUES ('". check_input($name) ."', '". check_input($help) ."', '". check_code($code) ."')");
}
function droplet_delete($id) {
$result = db_query("DELETE FROM droplets WHERE id = $id");
}
?>
...@@ -45,7 +45,7 @@ function submission_number() { ...@@ -45,7 +45,7 @@ function submission_number() {
function theme_main_blocks($theme) { function theme_main_blocks($theme) {
global $PHP_SELF, $user, $id; global $id, $PHP_SELF, $user;
switch (strtok($PHP_SELF, ".")) { switch (strtok($PHP_SELF, ".")) {
case "/discussion": case "/discussion":
...@@ -53,6 +53,14 @@ function theme_main_blocks($theme) { ...@@ -53,6 +53,14 @@ function theme_main_blocks($theme) {
if ($story->status == 1) theme_moderation_results($theme, $story); if ($story->status == 1) theme_moderation_results($theme, $story);
else theme_new_headlines($theme); else theme_new_headlines($theme);
break; break;
case "/index":
theme_account($theme);
$result = db_query("SELECT * FROM blocks WHERE status = 2");
while ($block = db_fetch_object($result)) {
$blocks = module_execute($block->module, "block");
$theme->box($blocks[$block->offset]["subject"], $blocks[$block->offset]["content"]);
}
break;
default: default:
theme_account($theme); theme_account($theme);
} }
...@@ -63,8 +71,8 @@ function theme_user_blocks($theme) { ...@@ -63,8 +71,8 @@ function theme_user_blocks($theme) {
if ($user->id && strstr($PHP_SELF, "index.php")) { if ($user->id && strstr($PHP_SELF, "index.php")) {
$result = db_query("SELECT * FROM layout l LEFT JOIN blocks b ON l.block = b.name WHERE l.user = '$user->id' AND l.weight > 0 AND b.status = '1' ORDER BY weight"); $result = db_query("SELECT * FROM layout l LEFT JOIN blocks b ON l.block = b.name WHERE l.user = '$user->id' AND l.weight > 0 AND b.status = '1' ORDER BY weight");
while ($block = db_fetch_object($result)) { while ($block = db_fetch_object($result)) {
$blocks = module_execute($block->module, "block"); $blocks = module_execute($block->module, "block");
$theme->box($blocks[$block->offset]["subject"], $blocks[$block->offset]["content"]); $theme->box($blocks[$block->offset]["subject"], $blocks[$block->offset]["content"]);
} }
} }
} }
......
<?
$module = array("admin" => "about_admin");
function about_admin() {
print "under construction";
}
?>
\ No newline at end of file
...@@ -17,7 +17,7 @@ function account_display($order = "username") { ...@@ -17,7 +17,7 @@ function account_display($order = "username") {
$result = db_query("SELECT u.id, u.userid, u.". strtok($sort[$order], " ") .", u.url FROM users u ORDER BY $sort[$order]"); $result = db_query("SELECT u.id, u.userid, u.". strtok($sort[$order], " ") .", u.url FROM users u ORDER BY $sort[$order]");
// Generate output: // Generate output:
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR>\n"; $output .= " <TR>\n";
$output .= " <TH ALIGN=\"right\" COLSPAN=\"". (sizeof($show) + 2) ."\">\n"; $output .= " <TH ALIGN=\"right\" COLSPAN=\"". (sizeof($show) + 2) ."\">\n";
$output .= " <FORM ACTION=\"admin.php?mod=account\" METHOD=\"post\">\n"; $output .= " <FORM ACTION=\"admin.php?mod=account\" METHOD=\"post\">\n";
......
<?
$module = array("block" => "ab_block",
"admin" => "ab_admin");
function ab_block() {
$result = db_query("SELECT * FROM admin_blocks");
$i = 0;
while ($block = db_fetch_object($result)) {
$blocks[$i]["subject"] = check_output($block->subject);
$blocks[$i]["content"] = check_output(eval($block->content));
$blocks[$i]["info"] = check_output($block->info);
$blocks[$i]["link"] = check_output($block->link);
$i++;
}
return $blocks;
}
function ab_admin_display() {
$result = db_query("SELECT * FROM admin_blocks");
while ($block = db_fetch_object($result)) {
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
$output .= " <TR><TH>Subject:</TH><TD>". check_output($block->subject) ."</TD></TR>\n";
$output .= " <TR><TH>Content:</TH><TD>". nl2br(htmlentities($block->content)) ."</TD></TR>\n";
$output .= " <TR><TH>Information:</TH><TD><I>". check_output($block->info) ."</I></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=admin-block&op=edit&id=$block->id\">edit</A>, <A HREF=\"admin.php?mod=admin-block&op=delete&id=$block->id\">delete</A></TD></TR>\n";
$output .= "</TABLE>\n";
$output .= "<BR><BR>\n";
}
$output .= "<FORM ACTION=\"admin.php?mod=admin-block\" METHOD=\"post\">\n";
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
$output .= " <TR><TH>Subject:</TH><TD><INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"35\"></TD></TR>\n";
$output .= " <TR><TH>Content:</TH><TD><TEXTAREA NAME=\"content\" COLS=\"50\" ROWS=\"5\"></TEXTAREA></TD></TR>\n";
$output .= " <TR><TH>Information:</TH><TD><INPUT TYPE=\"text\" NAME=\"info\" SIZE=\"35\"></TD></TR>\n";
$output .= " <TR><TH>Link:</TH><TD><INPUT TYPE=\"text\" NAME=\"link\" SIZE=\"35\"></TD></TR>\n";
$output .= " <TR><TH>Operations:</TH><TD><INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Add admin block\"></TD></TR>\n";
$output .= "</TABLE>\n";
$output .= "</FORM>\n";
print $output;
}
function ab_admin_add($subject, $content, $info, $link) {
db_query("INSERT INTO admin_blocks (subject, content, info, link) VALUES ('". check_input($subject) ."', '". check_code($content) ."', '". check_input($info) ."', '". check_input($link) ."')");
}
function ab_admin_delete($id) {
db_query("DELETE FROM admin_blocks WHERE id = $id");
}
function ab_admin_rehash() {
global $repository;
module_rehash_blocks("admin-block", $repository["admin-block"]);
}
function ab_admin_edit($id) {
$result = db_query("SELECT * FROM admin_blocks WHERE id = $id");
if ($block = db_fetch_object($result)) {
$output .= "<FORM ACTION=\"admin.php?mod=admin-block\" METHOD=\"post\">\n";
$output .= "<P>\n";
$output .= " <B>Subject:</B><BR>\n";
$output .= " <INPUT TYPE=\"text\" NAME=\"subject\" VALUE=\"". check_field($block->subject) ."\">\n";
$output .= "</P>\n";
$output .= "<P>\n";
$output .= "<B>Content:</B><BR>\n";
$output .= "<TEXTAREA NAME=\"content\" COLS=\"50\" ROWS=\"5\">$block->content</TEXTAREA>\n";
$output .= "</P>\n";
$output .= "<B>Information:</B><BR>\n";
$output .= "<INPUT TYPE=\"text\" NAME=\"info\" VALUE=\"$block->info\">\n";
$output .= "</P>\n";
$output .= "<P>\n";
$output .= "<B>Link:</B><BR>\n";
$output .= "<INPUT TYPE=\"text\" NAME=\"link\" VALUE=\"$block->link\">\n";
$output .= "</P>\n";
$output .= "<P>\n";
$output .= "<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$id\">\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save admin block\"><BR>\n";
$output .= "</P>\n";
$output .= "</FORM>\n";
}
print $output;
}
function ab_admin_save($id, $subject, $content, $info, $link) {
db_query("UPDATE admin_blocks SET subject = '". check_input($subject) ."', content = '". check_code($content) ."', info = '". check_input($info) ."', link = '". check_input($link) ."' WHERE id = '$id'");
watchdog("message", "modified admin block `$subject'");
}
function ab_admin() {
global $op, $id, $subject, $content, $info, $link;
switch ($op) {
case "Add admin block":
ab_admin_add($subject, $content, $info, $link);
ab_admin_display();
ab_admin_rehash();
break;
case "Save admin block":
ab_admin_save($id, $subject, $content, $info, $link);
ab_admin_display();
ab_admin_rehash();
break;
case "edit":
ab_admin_edit($id);
break;
case "delete":
ab_admin_delete($id);
ab_admin_rehash();
// fall through
default:
ab_admin_display();
}
}
?>
\ No newline at end of file
<?
$module = array("block" => "affiliate_block",
"admin" => "affiliate_admin");
function affiliate_block() {
global $site_url;
$result = db_query("SELECT * FROM affiliates ORDER BY name");
$content .= "<SCRIPT>\n";
$content .= " <!--//\n";
$content .= " function gotosite(site) {\n";
$content .= " if (site != \"\") {\n";
$content .= " parent.location = site\n";
$content .= " }\n";
$content .= " }\n";
$content .= " //-->\n";
$content .= "</SCRIPT>\n";
$content .= "<FORM ACTION=\"\" METHOD=\"post\">\n";
$content .= " <SELECT NAME=\"affiliate\" ONCHANGE=\"gotosite(this.options[this.selectedIndex].value)\">\n";
$content .= " <OPTION VALUE=\"$site_url\">select a site</OPTION>\n";
while ($affiliate = db_fetch_object($result)) {
$content .= " <OPTION VALUE=\"$affiliate->link\">$affiliate->name</OPTION>\n";
}
$content .= " </SELECT>\n";
$content .= "</FORM>\n";
$blocks[0]["subject"] = "Affiliates";
$blocks[0]["content"] = $content;
$blocks[0]["info"] = "Affiliates (selection)";
unset($content);
$result = db_query("SELECT * FROM affiliates ORDER BY name");
while ($affiliate = db_fetch_object($result)) {
$content .= "<LI><A HREF=\"$affiliate->link\">$affiliate->name</A></LI>\n";
}
$blocks[1]["subject"] = "Affiliates";
$blocks[1]["content"] = $content;
$blocks[1]["info"] = "Affiliates (sequential)";
return $blocks;
}
function affiliate_admin_add($name, $link, $contact) {
db_query("INSERT INTO affiliates (name, link, contact) VALUES ('". check_input($name) ."', '". check_input($link) ."', '". check_input($contact) ."')");
}
function affiliate_admin_del($id) {
db_query("DELETE FROM affiliates WHERE id = '$id'");
}
function affiliate_admin_display() {
$result = db_query("SELECT * FROM affiliates ORDER BY name");
$output .= "<FORM ACTION=\"admin.php?mod=affiliate\" METHOD=\"post\">\n";
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>name</TH><TH>link</TH><TH>contact</TH><TH>operations</TH></TR>\n";
while ($affiliate = db_fetch_object($result)) {
$output .= " <TR><TD>$affiliate->name</TD><TD>". format_url($affiliate->link) ."</TD><TD>". format_email($affiliate->contact) ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=affiliate&op=delete&id=$affiliate->id\">delete</A></TD></TR>\n";
}
$output .= " <TR><TD><INPUT TYPE=\"text\" NAME=\"name\"></TD><TD><INPUT TYPE=\"text\" NAME=\"link\"></TD><TD><INPUT TYPE=\"text\" NAME=\"contact\"></TD><TD><INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Add affiliate\"></TD></TR>\n";
$output .= "</TABLE>\n";
$output .= "</FORM>\n";
print $output;
}
function affiliate_admin() {
global $op, $id, $name, $link, $contact;
switch($op) {
case "Add affiliate":
affiliate_admin_add($name, $link, $contact);
affiliate_admin_display();
break;
case "delete":
affiliate_admin_del($id);
affiliate_admin_display();
break;
default:
affiliate_admin_display();
}
}
?>
\ No newline at end of file
...@@ -26,7 +26,7 @@ function ban_display($category = "") { ...@@ -26,7 +26,7 @@ function ban_display($category = "") {
$result = db_query("SELECT * FROM bans WHERE type = $category ORDER BY mask"); $result = db_query("SELECT * FROM bans WHERE type = $category ORDER BY mask");
// Generate output: // Generate output:
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR>\n"; $output .= " <TR>\n";
$output .= " <TH COLSPAN=\"3\">\n"; $output .= " <TH COLSPAN=\"3\">\n";
$output .= " <FORM ACTION=\"admin.php?mod=ban\" METHOD=\"post\">\n"; $output .= " <FORM ACTION=\"admin.php?mod=ban\" METHOD=\"post\">\n";
......
...@@ -43,7 +43,8 @@ function block_admin_display() { ...@@ -43,7 +43,8 @@ function block_admin_display() {
$module = ($repository[$block->module]["admin"]) ? "<A HREF=\"admin.php?mod=$block->module\">$block->module</A>" : $block->module; $module = ($repository[$block->module]["admin"]) ? "<A HREF=\"admin.php?mod=$block->module\">$block->module</A>" : $block->module;
$status .= "<SELECT NAME=\"edit[$block->name]\">\n"; $status .= "<SELECT NAME=\"edit[$block->name]\">\n";
$status .= " <OPTION VALUE=\"1\"". (($block->status == 1) ? " SELECTED" : "") .">enabled</OPTION>\n"; $status .= " <OPTION VALUE=\"2\"". (($block->status == 2) ? " SELECTED" : "") .">enabled: always</OPTION>\n";
$status .= " <OPTION VALUE=\"1\"". (($block->status == 1) ? " SELECTED" : "") .">enabled: custom</OPTION>\n";
$status .= " <OPTION VALUE=\"0\"". (($block->status == 0) ? " SELECTED" : "") .">disabled</OPTION>\n"; $status .= " <OPTION VALUE=\"0\"". (($block->status == 0) ? " SELECTED" : "") .">disabled</OPTION>\n";
$status .= "</SELECT>\n"; $status .= "</SELECT>\n";
......
...@@ -43,7 +43,8 @@ function block_admin_display() { ...@@ -43,7 +43,8 @@ function block_admin_display() {
$module = ($repository[$block->module]["admin"]) ? "<A HREF=\"admin.php?mod=$block->module\">$block->module</A>" : $block->module; $module = ($repository[$block->module]["admin"]) ? "<A HREF=\"admin.php?mod=$block->module\">$block->module</A>" : $block->module;
$status .= "<SELECT NAME=\"edit[$block->name]\">\n"; $status .= "<SELECT NAME=\"edit[$block->name]\">\n";
$status .= " <OPTION VALUE=\"1\"". (($block->status == 1) ? " SELECTED" : "") .">enabled</OPTION>\n"; $status .= " <OPTION VALUE=\"2\"". (($block->status == 2) ? " SELECTED" : "") .">enabled: always</OPTION>\n";
$status .= " <OPTION VALUE=\"1\"". (($block->status == 1) ? " SELECTED" : "") .">enabled: custom</OPTION>\n";
$status .= " <OPTION VALUE=\"0\"". (($block->status == 0) ? " SELECTED" : "") .">disabled</OPTION>\n"; $status .= " <OPTION VALUE=\"0\"". (($block->status == 0) ? " SELECTED" : "") .">disabled</OPTION>\n";
$status .= "</SELECT>\n"; $status .= "</SELECT>\n";
......
...@@ -45,9 +45,9 @@ function comment_display($order = "date") { ...@@ -45,9 +45,9 @@ function comment_display($order = "date") {
$result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON u.id = c.author ORDER BY c.$fields[$order] LIMIT 50"); $result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON u.id = c.author ORDER BY c.$fields[$order] LIMIT 50");
// Display comments: // Display comments:
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR>\n"; $output .= " <TR>\n";
$output .= " <TH ALIGN=\"right\" COLSPAN=\"5\">\n"; $output .= " <TH ALIGN=\"right\" COLSPAN=\"3\">\n";
$output .= " <FORM ACTION=\"admin.php?mod=comment\" METHOD=\"post\">\n"; $output .= " <FORM ACTION=\"admin.php?mod=comment\" METHOD=\"post\">\n";
$output .= " <SELECT NAME=\"order\">\n"; $output .= " <SELECT NAME=\"order\">\n";
foreach ($fields as $key=>$value) { foreach ($fields as $key=>$value) {
......
...@@ -45,9 +45,9 @@ function comment_display($order = "date") { ...@@ -45,9 +45,9 @@ function comment_display($order = "date") {
$result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON u.id = c.author ORDER BY c.$fields[$order] LIMIT 50"); $result = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON u.id = c.author ORDER BY c.$fields[$order] LIMIT 50");
// Display comments: // Display comments:
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR>\n"; $output .= " <TR>\n";
$output .= " <TH ALIGN=\"right\" COLSPAN=\"5\">\n"; $output .= " <TH ALIGN=\"right\" COLSPAN=\"3\">\n";
$output .= " <FORM ACTION=\"admin.php?mod=comment\" METHOD=\"post\">\n"; $output .= " <FORM ACTION=\"admin.php?mod=comment\" METHOD=\"post\">\n";
$output .= " <SELECT NAME=\"order\">\n"; $output .= " <SELECT NAME=\"order\">\n";
foreach ($fields as $key=>$value) { foreach ($fields as $key=>$value) {
......
...@@ -249,9 +249,9 @@ function diary_admin_display($order = "date") { ...@@ -249,9 +249,9 @@ function diary_admin_display($order = "date") {
$result = db_query("SELECT d.*, u.userid FROM diaries d LEFT JOIN users u ON u.id = d.author ORDER BY d.$fields[$order] LIMIT 50"); $result = db_query("SELECT d.*, u.userid FROM diaries d LEFT JOIN users u ON u.id = d.author ORDER BY d.$fields[$order] LIMIT 50");
// Display stories: // Display stories:
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR>\n"; $output .= " <TR>\n";
$output .= " <TH ALIGN=\"right\" COLSPAN=\"5\">\n"; $output .= " <TH ALIGN=\"right\" COLSPAN=\"3\">\n";
$output .= " <FORM ACTION=\"admin.php?mod=diary\" METHOD=\"post\">\n"; $output .= " <FORM ACTION=\"admin.php?mod=diary\" METHOD=\"post\">\n";
$output .= " <SELECT NAME=\"order\">\n"; $output .= " <SELECT NAME=\"order\">\n";
foreach ($fields as $key=>$value) { foreach ($fields as $key=>$value) {
......
<? <?
$module = array("page" => "documentation_page"); $module = array("page" => "documentation",
"admin" => "documentation");
function documentation_page() { function documentation() {
?> ?>
<H1>Documentation</H1>
<SMALL><I>$Id$</I></SMALL> <SMALL><I>$Id$</I></SMALL>
<H2>Chapter 1: installation guide</H2> <H2>Chapter 1: installation guide</H2>
......
<?
$module = array("admin" => "droplet_admin");
include_once "includes/droplet.inc";
function droplet_display() {
$result = db_query("SELECT * FROM droplets");
### 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?mod=droplet&op=edit&id=$block->id\">edit</A>, <A HREF=\"admin.php?mod=droplet&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?mod=droplet\" 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 droplet_edit($id) {
$result = db_query("SELECT * FROM droplets WHERE id = $id");
if ($block = db_fetch_object($result)) {
$output .= "<FORM ACTION=\"admin.php?mod=droplet\" 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 droplet_save($id, $name, $help, $code) {
db_query("UPDATE droplets SET name = '". check_input($name) ."', help = '". check_input($help) ."', code = '". check_code($code) ."' WHERE id = $id");
watchdog("message", "modified block `$name'.");
}
function droplet_admin() {
global $op, $id, $name, $help, $code;
switch ($op) {
case "Add block":
droplet_add($name, $help, $code);
droplet_display();
break;
case "Save block":
droplet_save($id, $name, $help, $code);
droplet_display();
break;
case "edit":
droplet_edit($id);
break;
case "delete":
droplet_delete($id);
// fall through
default:
droplet_display();
}
}
?>
\ No newline at end of file
...@@ -69,12 +69,14 @@ function headline_block() { ...@@ -69,12 +69,14 @@ function headline_block() {
$result = db_query("SELECT * FROM channel"); $result = db_query("SELECT * FROM channel");
while ($channel = db_fetch_object($result)) { while ($channel = db_fetch_object($result)) {
$backend = new Backend($channel->id); $backend = new Backend($channel->id);
$content = ""; $content = "";
for (reset($backend->headline); $headline = current($backend->headline); next($backend->headline)) {
$content .= "<LI>$headline</LI>\n"; if ($backend->headline) {
for (reset($backend->headline); $headline = current($backend->headline); next($backend->headline)) {
$content .= "<LI>$headline</LI>\n";
}
} }
$blocks[$channel->id]["subject"] = $backend->site; $blocks[$channel->id]["subject"] = $backend->site;
$blocks[$channel->id]["content"] = $content; $blocks[$channel->id]["content"] = $content;
$blocks[$channel->id]["info"] = "$backend->site headline"; $blocks[$channel->id]["info"] = "$backend->site headline";
...@@ -142,7 +144,6 @@ function headline_admin() { ...@@ -142,7 +144,6 @@ function headline_admin() {
break; break;
case "delete": case "delete":
$backend = new backend($id); $backend = new backend($id);
$backend->dump();
$backend->delete(); $backend->delete();
headline_admin_main(); headline_admin_main();
break; break;
...@@ -160,6 +161,8 @@ function headline_export($uri) { ...@@ -160,6 +161,8 @@ function headline_export($uri) {
if ($uri[2] == "headlines.rdf") { if ($uri[2] == "headlines.rdf") {
watchdog("message", "grabbed 'headlines.rdf'");
header("Content-Type: text/plain"); header("Content-Type: text/plain");
print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
......
...@@ -98,7 +98,7 @@ function story_display($order = "date") { ...@@ -98,7 +98,7 @@ function story_display($order = "date") {
$result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author ORDER BY s.$fields[$order]"); $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author ORDER BY s.$fields[$order]");
### Display stories: ### Display stories:
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR>\n"; $output .= " <TR>\n";
$output .= " <TH ALIGN=\"right\" COLSPAN=\"5\">\n"; $output .= " <TH ALIGN=\"right\" COLSPAN=\"5\">\n";
$output .= " <FORM ACTION=\"admin.php?mod=story\" METHOD=\"post\">\n"; $output .= " <FORM ACTION=\"admin.php?mod=story\" METHOD=\"post\">\n";
......
...@@ -98,7 +98,7 @@ function story_display($order = "date") { ...@@ -98,7 +98,7 @@ function story_display($order = "date") {
$result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author ORDER BY s.$fields[$order]"); $result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON u.id = s.author ORDER BY s.$fields[$order]");
### Display stories: ### Display stories:
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR>\n"; $output .= " <TR>\n";
$output .= " <TH ALIGN=\"right\" COLSPAN=\"5\">\n"; $output .= " <TH ALIGN=\"right\" COLSPAN=\"5\">\n";
$output .= " <FORM ACTION=\"admin.php?mod=story\" METHOD=\"post\">\n"; $output .= " <FORM ACTION=\"admin.php?mod=story\" METHOD=\"post\">\n";
......
...@@ -15,7 +15,7 @@ function watchdog_display($order = "date") { ...@@ -15,7 +15,7 @@ function watchdog_display($order = "date") {
$result = db_query("SELECT l.*, u.userid FROM watchdog l LEFT JOIN users u ON l.user = u.id ORDER BY l.$fields[$order]"); $result = db_query("SELECT l.*, u.userid FROM watchdog l LEFT JOIN users u ON l.user = u.id ORDER BY l.$fields[$order]");
### Generate output: ### Generate output:
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR>\n"; $output .= " <TR>\n";
$output .= " <TH ALIGN=\"right\" COLSPAN=\"4\">\n"; $output .= " <TH ALIGN=\"right\" COLSPAN=\"4\">\n";
$output .= " <FORM ACTION=\"admin.php?mod=watchdog\" METHOD=\"post\">\n"; $output .= " <FORM ACTION=\"admin.php?mod=watchdog\" METHOD=\"post\">\n";
......
...@@ -15,7 +15,7 @@ function watchdog_display($order = "date") { ...@@ -15,7 +15,7 @@ function watchdog_display($order = "date") {
$result = db_query("SELECT l.*, u.userid FROM watchdog l LEFT JOIN users u ON l.user = u.id ORDER BY l.$fields[$order]"); $result = db_query("SELECT l.*, u.userid FROM watchdog l LEFT JOIN users u ON l.user = u.id ORDER BY l.$fields[$order]");
### Generate output: ### Generate output:
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR>\n"; $output .= " <TR>\n";
$output .= " <TH ALIGN=\"right\" COLSPAN=\"4\">\n"; $output .= " <TH ALIGN=\"right\" COLSPAN=\"4\">\n";
$output .= " <FORM ACTION=\"admin.php?mod=watchdog\" METHOD=\"post\">\n"; $output .= " <FORM ACTION=\"admin.php?mod=watchdog\" METHOD=\"post\">\n";
......
...@@ -26,7 +26,6 @@ function wishlist_page() { ...@@ -26,7 +26,6 @@ function wishlist_page() {
<H3>Engine</H3> <H3>Engine</H3>
<UL>