summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2000-12-23 15:20:10 +0000
committerDries Buytaert <dries@buytaert.net>2000-12-23 15:20:10 +0000
commit60e1a60dd3661c79fee726e0d3407aee8b4038bf (patch)
tree7dff375f762db48825e9e9e7064d9b3ba775b26c
parent0cadc4e68340e02e6b51c29a672db7bb92386fa7 (diff)
downloadbrdo-60e1a60dd3661c79fee726e0d3407aee8b4038bf.tar.gz
brdo-60e1a60dd3661c79fee726e0d3407aee8b4038bf.tar.bz2
- intermediate updates
-rw-r--r--modules/backend.module29
-rw-r--r--modules/block.module53
-rw-r--r--modules/block/block.module53
-rw-r--r--modules/calendar.class76
-rw-r--r--modules/calendar.module77
-rw-r--r--modules/cron.module16
-rw-r--r--modules/development.module3
-rw-r--r--modules/diary.module20
-rw-r--r--modules/module.module56
-rw-r--r--modules/modules.module20
-rw-r--r--modules/wishlist.module1
11 files changed, 297 insertions, 107 deletions
diff --git a/modules/backend.module b/modules/backend.module
index 9c3b2bdcc..217762ac7 100644
--- a/modules/backend.module
+++ b/modules/backend.module
@@ -2,6 +2,7 @@
$module = array("page" => "backend_page",
"cron" => "backend_cron",
+ "block" => "backend_block",
"admin" => "backend_admin");
include "includes/theme.inc";
@@ -50,6 +51,24 @@ function backend_cron() {
}
}
+function backend_block() {
+ $result = db_query("SELECT * FROM channel");
+ while ($channel = db_fetch_object($result)) {
+ $backend = new Backend($channel->id);
+
+ $content = "";
+ for (reset($backend->headlines); $headline = current($backend->headlines); next($backend->headlines)) {
+ $content .= "<LI>$headline</LI>\n";
+ }
+
+ $blocks[$channel->id]["subject"] = $backend->site;
+ $blocks[$channel->id]["content"] = $content;
+ $blocks[$channel->id]["info"] = "$backend->site headlines";
+ $blocks[$channel->id]["link"] = $backend->url;
+ }
+ return $blocks;
+}
+
function backend_admin_main() {
global $theme;
@@ -57,7 +76,7 @@ function backend_admin_main() {
$result = db_query("SELECT * FROM channel ORDER BY id");
$output .= "<TABLE BORDER=\"1\" CELLSPADDING=\"2\" CELLSPACING=\"2\">\n";
- $output .= " <TH>site</TH><TH>contact</TH><TH>last updated</TH><TH COLSPAN=\"2\">operations</TH></TR>\n";
+ $output .= " <TH>site</TH><TH>contact</TH><TH>last update</TH><TH COLSPAN=\"2\">operations</TH></TR>\n";
while ($channel = db_fetch_object($result)) {
// Load backend from database:
@@ -66,7 +85,7 @@ function backend_admin_main() {
$output .= "<TR>\n";
$output .= " <TD><A HREF=\"$backend->url\">$backend->site</A></TD>\n";
$output .= " <TD><A HREF=\"mailto:$backend->contact\">$backend->contact</A></TD>\n";
- $output .= " <TD ALIGN=\"center\">". round((time() - $backend->timestamp) / 60) ." min. ago</TD>\n";
+ $output .= " <TD ALIGN=\"center\">". format_interval(time() - $backend->timestamp) ." ago</TD>\n";
$output .= " <TD ALIGN=\"center\"><A HREF=\"admin.php?mod=backend&op=refresh&id=$backend->id\">refresh</A></TD>\n";
$output .= " <TD ALIGN=\"center\"><A HREF=\"admin.php?mod=backend&op=delete&id=$backend->id\">delete</A></TD>\n";
$output .= "</TR>\n";
@@ -86,7 +105,7 @@ function backend_admin_main() {
$output .= " </P>\n";
$output .= " <P>\n";
$output .= " <B>Backend file:</B><BR>\n";
- $output .= " <INPUT TYPE=\"text\" NAME=\"file\" SIZE=\"50\">\n";
+ $output .= " <INPUT TYPE=\"text\" NAME=\"backend\" SIZE=\"50\">\n";
$output .= " </P>\n";
$output .= " <P>\n";
$output .= " <B>Contact information:</B><BR>\n";
@@ -99,7 +118,7 @@ function backend_admin_main() {
}
function backend_admin() {
- global $op, $id, $site, $url, $file, $contact;
+ global $op, $id, $site, $url, $backend, $contact;
switch($op) {
case "refresh":
@@ -114,7 +133,7 @@ function backend_admin() {
backend_admin_main();
break;
case "Add backend":
- $backend = new backend($id, $site, $url, $file, $contact);
+ $backend = new backend($id, $site, $url, $backend, $contact);
$backend->add();
// fall through:
default:
diff --git a/modules/block.module b/modules/block.module
new file mode 100644
index 000000000..b3b9be774
--- /dev/null
+++ b/modules/block.module
@@ -0,0 +1,53 @@
+<?
+
+$module = array("admin" => "block_admin");
+
+function block_admin_save($edit) {
+ foreach ($edit as $key=>$value) {
+ db_query("UPDATE blocks SET status = '$value' WHERE name = '$key'");
+ }
+}
+
+function block_admin_display() {
+ global $repository;
+
+ $result = db_query("SELECT * FROM blocks");
+
+ // Generate output:
+ $output .= "<FORM ACTION=\"admin.php?mod=block\" METHOD=\"post\">\n";
+ $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
+ $output .= " <TR><TH>block</TH><TH>module</TH><TH>status</TH></TR>\n";
+
+ while ($block = db_fetch_object($result)) {
+ $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 .= " <OPTION VALUE=\"1\"". (($block->status == 1) ? " SELECTED" : "") .">enabled</OPTION>\n";
+ $status .= " <OPTION VALUE=\"0\"". (($block->status == 0) ? " SELECTED" : "") .">disabled</OPTION>\n";
+ $status .= "</SELECT>\n";
+
+ $output .= " <TR><TD>". $block->name ."</TD><TD>$module</TD><TD>$status</TD></TR>\n";
+
+ unset($status);
+ }
+
+ $output .= "</TABLE>\n";
+ $output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Save blocks\">\n";
+ $output .= "</FORM>\n";
+
+ print $output;
+}
+
+function block_admin() {
+ global $op, $edit;
+
+ switch ($op) {
+ case "Save blocks":
+ block_admin_save($edit);
+ break;
+ }
+
+ block_admin_display();
+}
+
+?>
diff --git a/modules/block/block.module b/modules/block/block.module
new file mode 100644
index 000000000..b3b9be774
--- /dev/null
+++ b/modules/block/block.module
@@ -0,0 +1,53 @@
+<?
+
+$module = array("admin" => "block_admin");
+
+function block_admin_save($edit) {
+ foreach ($edit as $key=>$value) {
+ db_query("UPDATE blocks SET status = '$value' WHERE name = '$key'");
+ }
+}
+
+function block_admin_display() {
+ global $repository;
+
+ $result = db_query("SELECT * FROM blocks");
+
+ // Generate output:
+ $output .= "<FORM ACTION=\"admin.php?mod=block\" METHOD=\"post\">\n";
+ $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
+ $output .= " <TR><TH>block</TH><TH>module</TH><TH>status</TH></TR>\n";
+
+ while ($block = db_fetch_object($result)) {
+ $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 .= " <OPTION VALUE=\"1\"". (($block->status == 1) ? " SELECTED" : "") .">enabled</OPTION>\n";
+ $status .= " <OPTION VALUE=\"0\"". (($block->status == 0) ? " SELECTED" : "") .">disabled</OPTION>\n";
+ $status .= "</SELECT>\n";
+
+ $output .= " <TR><TD>". $block->name ."</TD><TD>$module</TD><TD>$status</TD></TR>\n";
+
+ unset($status);
+ }
+
+ $output .= "</TABLE>\n";
+ $output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Save blocks\">\n";
+ $output .= "</FORM>\n";
+
+ print $output;
+}
+
+function block_admin() {
+ global $op, $edit;
+
+ switch ($op) {
+ case "Save blocks":
+ block_admin_save($edit);
+ break;
+ }
+
+ block_admin_display();
+}
+
+?>
diff --git a/modules/calendar.class b/modules/calendar.class
new file mode 100644
index 000000000..1bd8b795e
--- /dev/null
+++ b/modules/calendar.class
@@ -0,0 +1,76 @@
+<?
+
+$module = array();
+
+class Calendar {
+ var $date;
+
+ function calendar($date) {
+ $this->date = $date;
+ }
+
+ function display() {
+ // Extract information from the given date:
+ $month = date("n", $this->date);
+ $year = date("Y", $this->date);
+ $day = date("d", $this->date);
+
+ // Extract first day of the month:
+ $first = date("w", mktime(0, 0, 0, $month, 1, $year));
+
+ // Extract last day of the month:
+ $last = date("t", mktime(0, 0, 0, $month, 1, $year));
+
+ // Calculate previous and next months dates:
+ $prev = mktime(0, 0, 0, $month - 1, $day, $year);
+ $next = mktime(0, 0, 0, $month + 1, $day, $year);
+
+ // Generate calendar header:
+ $output .= "\n<!-- calendar -->\n";
+ $output .= "<TABLE WIDTH=\"100%\" BORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"1\">\n";
+ $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"7\"><SMALL><A HREF=\"index.php?date=$prev\">&lt;</A> &nbsp; ". date("F Y", $this->date) ." &nbsp; <A HREF=\"index.php?date=$next\">&gt;</A></SMALL></TD></TR>\n";
+ $output .= " <TR><TD ALIGN=\"center\"><SMALL>S</SMALL></TD><TD ALIGN=\"center\"><SMALL>M</SMALL></TD><TD ALIGN=\"center\"><SMALL>T</SMALL></TD><TD ALIGN=\"center\"><SMALL>W</SMALL></TD><TD ALIGN=\"center\"><SMALL>T</SMALL></TD><TD ALIGN=\"center\"><SMALL>F</SMALL></TD><TD ALIGN=\"center\"><SMALL>S</SMALL></TD></TR>\n";
+
+ // Initialize temporary variables:
+ $nday = 1;
+ $sday = $first;
+
+ // Loop through all the days of the month:
+ while ($nday <= $last) {
+ // Set up blank days for first week of the month:
+ if ($first) {
+ $output .= " <TR><TD COLSPAN=\"$first\">&nbsp</TD>\n";
+ $first = 0;
+ }
+
+ // Start every week on a new line:
+ if ($sday == 0) $output .= " <TR>\n";
+
+ // Print one cell:
+ $date = mktime(24, 0, 0, $month, $nday, $year);
+ if ($nday == $day) $output .= " <TD ALIGN=\"center\"><SMALL><B>$nday</B></SMALL></TD>\n";
+ else if ($date > time()) $output .= " <TD ALIGN=\"center\"><SMALL>$nday</SMALL></TD>\n";
+ else $output .= " <TD ALIGN=\"center\"><SMALL><A HREF=\"index.php?date=$date\" STYLE=\"text-decoration: none;\">$nday</A></SMALL></TD>\n";
+
+ // Start every week on a new line:
+ if ($sday == 6) $output .= " </TR>\n";
+
+ // Update temporary variables:
+ $sday++;
+ $sday = $sday % 7;
+ $nday++;
+ }
+
+ // Complete the calendar:
+ if ($sday) {
+ $end = 7 - $sday;
+ $output .= " <TD COLSPAN=\"$end\">&nbsp;</TD>\n </TR>\n";
+ }
+ $output .= "</TABLE>\n\n";
+
+ // Return calendar:
+ return $output;
+ }
+}
+
+?>
diff --git a/modules/calendar.module b/modules/calendar.module
index d6c044389..fe79beea5 100644
--- a/modules/calendar.module
+++ b/modules/calendar.module
@@ -1,78 +1,19 @@
<?
-$module = array();
+$module = array("block" => "calendar_block");
-class Calendar {
- var $date;
+function calendar_block() {
+ global $date;
- function calendar($date) {
- $this->date = $date;
- }
+ include "modules/calendar.class";
- function display() {
- global $PHP_SELF;
+ $calendar = new Calendar($date);
- // Extract information from the given date:
- $month = date("n", $this->date);
- $year = date("Y", $this->date);
- $day = date("d", $this->date);
-
- // Extract first day of the month:
- $first = date("w", mktime(0, 0, 0, $month, 1, $year));
-
- // Extract last day of the month:
- $last = date("t", mktime(0, 0, 0, $month, 1, $year));
-
- // Calculate previous and next months dates:
- $prev = mktime(0, 0, 0, $month - 1, $day, $year);
- $next = mktime(0, 0, 0, $month + 1, $day, $year);
-
- // Generate calendar header:
- $output .= "\n<!-- calendar -->\n";
- $output .= "<TABLE WIDTH=\"100%\" BORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"1\">\n";
- $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"7\"><SMALL><A HREF=\"$PHP_SELF?date=$prev\">&lt;</A> &nbsp; ". date("F Y", $this->date) ." &nbsp; <A HREF=\"$PHP_SELF?date=$next\">&gt;</A></SMALL></TD></TR>\n";
- $output .= " <TR><TD ALIGN=\"center\"><SMALL>S</SMALL></TD><TD ALIGN=\"center\"><SMALL>M</SMALL></TD><TD ALIGN=\"center\"><SMALL>T</SMALL></TD><TD ALIGN=\"center\"><SMALL>W</SMALL></TD><TD ALIGN=\"center\"><SMALL>T</SMALL></TD><TD ALIGN=\"center\"><SMALL>F</SMALL></TD><TD ALIGN=\"center\"><SMALL>S</SMALL></TD></TR>\n";
+ $block[0]["subject"] = "Browse archives";
+ $block[0]["content"] = $calendar->display();
+ $block[0]["info"] = "calendar";
- // Initialize temporary variables:
- $nday = 1;
- $sday = $first;
-
- // Loop through all the days of the month:
- while ($nday <= $last) {
- // Set up blank days for first week of the month:
- if ($first) {
- $output .= " <TR><TD COLSPAN=\"$first\">&nbsp</TD>\n";
- $first = 0;
- }
-
- // Start every week on a new line:
- if ($sday == 0) $output .= " <TR>\n";
-
- // Print one cell:
- $date = mktime(24, 0, 0, $month, $nday, $year);
- if ($nday == $day) $output .= " <TD ALIGN=\"center\"><SMALL><B>$nday</B></SMALL></TD>\n";
- else if ($date > time()) $output .= " <TD ALIGN=\"center\"><SMALL>$nday</SMALL></TD>\n";
- else $output .= " <TD ALIGN=\"center\"><SMALL><A HREF=\"$PHP_SELF?date=$date\" STYLE=\"text-decoration: none;\">$nday</A></SMALL></TD>\n";
-
- // Start every week on a new line:
- if ($sday == 6) $output .= " </TR>\n";
-
- // Update temporary variables:
- $sday++;
- $sday = $sday % 7;
- $nday++;
- }
-
- // Complete the calendar:
- if ($sday) {
- $end = 7 - $sday;
- $output .= " <TD COLSPAN=\"$end\">&nbsp;</TD>\n </TR>\n";
- }
- $output .= "</TABLE>\n\n";
-
- // Return calendar:
- return $output;
- }
+ return $block;
}
?>
diff --git a/modules/cron.module b/modules/cron.module
index f0f091a9d..89ec2994a 100644
--- a/modules/cron.module
+++ b/modules/cron.module
@@ -4,14 +4,9 @@ $module = array("admin" => "cron_admin");
include_once "includes/function.inc";
-
-function cron_reset($name) {
- cron_delete($name);
-}
-
function cron_save($edit) {
foreach ($edit as $key=>$value) {
- db_query("UPDATE cron SET scheduled = '$value' WHERE module = '$key'");
+ db_query("UPDATE crons SET scheduled = '$value' WHERE module = '$key'");
}
}
@@ -19,15 +14,15 @@ function cron_display() {
$intervals = array(300, 900, 1800, 3600, 7200, 10800, 21600, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200);
// Perform query:
- $result = db_query("SELECT * FROM cron");
+ $result = db_query("SELECT * FROM crons");
// Generate output:
$output .= "<FORM ACTION=\"admin.php?mod=cron\" METHOD=\"post\">\n";
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
- $output .= " <TR><TH>module</TH><TH>period</TH><TH>last execution</TH><TH COLSPAN=\"2\">operations</TH></TR>\n";
+ $output .= " <TR><TH>module</TH><TH>period</TH><TH>last execution</TH><TH>operations</TH></TR>\n";
while ($cron = db_fetch_object($result)) {
foreach ($intervals as $value) $period .= "<OPTION VALUE=\"$value\"". (($cron->scheduled == $value) ? " SELECTED" : "") .">every ". format_interval($value) ."</OPTION>\n";
- $output .= " <TR><TD>". check_output($cron->module) ."</TD><TD><SELECT NAME=\"edit[$cron->module]\">$period</SELECT></TD><TD>". format_interval(time() - $cron->timestamp) ." ago</TD><TD ALIGN=\"center\"><A HREF=\"cron.php\">execute</A></TD><TD><A HREF=\"admin.php?mod=cron&op=reset&name=$cron->module\">reset</A></TD></TR>\n";
+ $output .= " <TR><TD>". check_output($cron->module) ."</TD><TD><SELECT NAME=\"edit[$cron->module]\">$period</SELECT></TD><TD>". format_interval(time() - $cron->timestamp) ." ago</TD><TD ALIGN=\"center\"><A HREF=\"cron.php\">execute</A></TD></TR>\n";
unset($period);
}
$output .= "</TABLE>\n";
@@ -40,9 +35,6 @@ function cron_admin() {
global $op, $edit, $name;
switch($op) {
- case "reset":
- cron_reset($name);
- break;
case "Save crons":
cron_save($edit);
break;
diff --git a/modules/development.module b/modules/development.module
index a379cf11e..3c96ff91a 100644
--- a/modules/development.module
+++ b/modules/development.module
@@ -113,5 +113,4 @@ function development_page() {
<?
}
-?>
-
+?> \ No newline at end of file
diff --git a/modules/diary.module b/modules/diary.module
index f26883477..7e49e03e6 100644
--- a/modules/diary.module
+++ b/modules/diary.module
@@ -1,6 +1,7 @@
<?
$module = array("page" => "diary_page",
+ "block" => "diary_block",
"admin" => "diary_admin");
@@ -191,6 +192,25 @@ function diary_page() {
}
}
+function diary_block() {
+ $result = db_query("SELECT u.userid, d.timestamp FROM diaries d LEFT JOIN users u ON d.author = u.id ORDER BY timestamp DESC LIMIT 20");
+
+ while ($diary = db_fetch_object($result)) {
+ if ($time != date("F jS", $diary->timestamp)) {
+ $content .= "<P><B>". date("l, M jS", $diary->timestamp) ."</B></P>\n";
+ $time = date("F jS", $diary->timestamp);
+ }
+ $content .= "<LI><A HREF=\"module.php?mod=diary&op=view&name=$diary->userid\">$diary->userid</A></LI>\n";
+ }
+
+ $block[0]["subject"] = "Recent diary entries";
+ $block[0]["content"] = $content;
+ $block[0]["info"] = "recent diary entries";
+ $block[0]["link"] = "module.php?mod=diary";
+
+ return $block;
+}
+
function diary_admin_edit($id) {
$result = db_query("SELECT d.*, u.userid FROM diaries d LEFT JOIN users u ON d.author = u.id WHERE d.id = $id");
diff --git a/modules/module.module b/modules/module.module
new file mode 100644
index 000000000..f07b46a68
--- /dev/null
+++ b/modules/module.module
@@ -0,0 +1,56 @@
+<?
+
+$module = array("admin" => "module_admin");
+
+function module_admin_rehash() {
+ global $repository;
+
+ $result = db_query("SELECT * FROM modules");
+ while ($module = db_fetch_object($result)) {
+ module_rehash($module->name);
+ }
+
+ foreach ($repository as $name=>$module) {
+ module_rehash($name);
+ }
+}
+
+function module_admin_display() {
+ global $output;
+
+ function module_row($name, $module) {
+ global $output;
+
+ $view = ($module["page"]) ? "<A HREF=\"module.php?mod=$name\">view</A>" : "&nbsp;";
+ $admin = ($module["admin"]) ? "<A HREF=\"admin.php?mod=$name\">admin</A>" : "&nbsp;";
+ $output .= " <TR><TD>$name</TD><TD>$view</TD><TD>$admin</TD><TD><A HREF=\"admin.php?mod=module&op=rehash&name=$name\">rehash</A></TD></TR>\n";
+ }
+
+ $output .= "<FORM ACTION=\"admin.php?mod=module\" METHOD=\"post\">\n";
+ $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
+ $output .= " <TR><TH>module</TH><TH COLSPAN=\"3\">operations</TH></TR>\n";
+
+ module_iterate("module_row");
+
+ $output .= "</TABLE>\n";
+ $output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Rehash modules\">\n";
+ $output .= "</FORM>\n";
+ print $output;
+}
+
+function module_admin() {
+ global $op, $name;
+
+ switch ($op) {
+ case "Rehash modules":
+ module_admin_rehash();
+ break;
+ case "rehash":
+ module_rehash($name);
+ break;
+ }
+
+ module_admin_display();
+}
+
+?>
diff --git a/modules/modules.module b/modules/modules.module
deleted file mode 100644
index 8e02bf5d9..000000000
--- a/modules/modules.module
+++ /dev/null
@@ -1,20 +0,0 @@
-<?
-
-$module = array("admin" => "modules_admin");
-
-function modules_admin() {
- $output .= "<P>Installed or available modules:</P>\n";
- $output .= " <UL>\n";
-
- $handle = opendir("modules");
- while ($file = readdir($handle)) {
- if ($name = substr($file, 0, strpos($file, ".module"))) $output .= "<LI><A HREF=\"module.php?mod=$name\">$name</A></LI>";
- }
- closedir($handle);
-
- $output .= "</UL>\n";
-
- print $output;
-}
-
-?>
diff --git a/modules/wishlist.module b/modules/wishlist.module
index d95c10d32..661e98973 100644
--- a/modules/wishlist.module
+++ b/modules/wishlist.module
@@ -75,3 +75,4 @@ function wishlist_page() {
}
?>
+