summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--account.php15
-rw-r--r--database/database.mysql29
-rw-r--r--includes/module.inc8
-rw-r--r--modules/admin-block.module151
-rw-r--r--modules/affiliate-site.module (renamed from modules/affiliate.module)8
-rw-r--r--modules/backend.class2
-rw-r--r--modules/box.module172
-rw-r--r--modules/diary.module16
-rw-r--r--modules/documentation.module20
-rw-r--r--modules/drupal-site.module94
-rw-r--r--scripts/cvs-pass.pl9
11 files changed, 342 insertions, 182 deletions
diff --git a/account.php b/account.php
index 070eb3fa7..42ac229ed 100644
--- a/account.php
+++ b/account.php
@@ -266,6 +266,13 @@ function account_content_save($edit) {
function account_user($uname) {
global $user, $theme;
+ function module($name, $module, $username) {
+ global $theme;
+ if ($module["user"] && $block = $module["user"]($username, "user", "view")) {
+ if ($block["content"]) $theme->box($block["subject"], $block["content"]);
+ }
+ }
+
if ($user->id && $user->userid == $uname) {
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TD ALIGN=\"right\"><B>User ID:</B></TD><TD>$user->userid</TD></TR>\n";
@@ -300,17 +307,11 @@ function account_user($uname) {
$comments++;
}
- $result = db_query("SELECT d.* FROM diaries d LEFT JOIN users u ON u.id = d.author WHERE u.userid = '$uname' AND d.timestamp > ". (time() - 1209600) ." ORDER BY id DESC LIMIT 2");
- while ($diary = db_fetch_object($result)) {
- $block3 .= "<DL><DT><B>". date("l, F jS", $diary->timestamp) .":</B></DT><DD><P>". check_output($diary->text) ."</P><P>[ <A HREF=\"module.php?mod=diary&op=view&name=$uname\">more</A> ]</P></DD></DL>\n";
- $diaries++;
- }
-
// Display account information:
$theme->header();
if ($block1) $theme->box("User information for $uname", $block1);
if ($block2) $theme->box("$uname has posted ". format_plural($comments, "comment", "comments") ." recently", $block2);
- if ($block3) $theme->box("$uname has posted ". format_plural($diaries, "diary entry", "diary entries") ." recently", $block3);
+ module_iterate("module", $uname);
$theme->footer();
}
else {
diff --git a/database/database.mysql b/database/database.mysql
index cecc968f7..14e8325ba 100644
--- a/database/database.mysql
+++ b/database/database.mysql
@@ -1,11 +1,3 @@
-CREATE TABLE admin_blocks (
- id tinyint(4) DEFAULT '0' NOT NULL auto_increment,
- subject varchar(64) DEFAULT '' NOT NULL,
- content text,
- info varchar(128) DEFAULT '' NOT NULL,
- link varchar(128) DEFAULT '' NOT NULL,
- PRIMARY KEY (id)
-);
CREATE TABLE affiliates (
id int(11) DEFAULT '0' NOT NULL auto_increment,
@@ -16,6 +8,18 @@ CREATE TABLE affiliates (
PRIMARY KEY (id)
);
+CREATE TABLE boxes (
+ id tinyint(4) DEFAULT '0' NOT NULL auto_increment,
+ subject varchar(64) DEFAULT '' NOT NULL,
+ content text,
+ info varchar(128) DEFAULT '' NOT NULL,
+ link varchar(128) DEFAULT '' NOT NULL,
+ type tinyint(2) DEFAULT '0' NOT NULL,
+ UNIQUE subject (subject),
+ UNIQUE info (info),
+ PRIMARY KEY (id)
+);
+
CREATE TABLE bans (
id tinyint(4) DEFAULT '0' NOT NULL auto_increment,
mask varchar(255) DEFAULT '' NOT NULL,
@@ -76,6 +80,15 @@ CREATE TABLE diaries (
PRIMARY KEY (id)
);
+CREATE TABLE drupals (
+ id int(11) DEFAULT '0' NOT NULL auto_increment,
+ link varchar(255) DEFAULT '' NOT NULL,
+ name varchar(255) DEFAULT '' NOT NULL,
+ contact varchar(255) DEFAULT '' NOT NULL,
+ UNIQUE link (link),
+ PRIMARY KEY (id)
+);
+
CREATE TABLE headlines (
id int(11) DEFAULT '0' NOT NULL,
title varchar(255) DEFAULT '' NOT NULL,
diff --git a/includes/module.inc b/includes/module.inc
index 826e415b4..e52f612e1 100644
--- a/includes/module.inc
+++ b/includes/module.inc
@@ -1,9 +1,9 @@
<?
-function module_iterate($function) {
+function module_iterate($function, $argument = "") {
global $repository;
foreach ($repository as $name=>$module) {
- $function($name, $module);
+ $function($name, $module, $argument);
}
}
@@ -25,8 +25,8 @@ function module_rehash_crons($name, $module) {
function module_rehash_blocks($name, $module) {
db_query("DELETE FROM blocks WHERE module = '$name'");
- if ($module["block"]) {
- foreach ($blocks = $module["block"]() as $offset=>$block) {
+ if ($module["block"] && $blocks = $module["block"]()) {
+ foreach ($blocks as $offset=>$block) {
db_query("INSERT INTO blocks (name, module, offset) VALUES ('". check_input($block["info"]) ."', '". check_input($name) ."', '". check_input($offset) ."')");
}
}
diff --git a/modules/admin-block.module b/modules/admin-block.module
deleted file mode 100644
index 7f7f44ffa..000000000
--- a/modules/admin-block.module
+++ /dev/null
@@ -1,151 +0,0 @@
-<?
-
-$module = array("help" => "ab_help",
- "block" => "ab_block",
- "admin" => "ab_admin");
-
-function ab_help() {
- ?>
- <P>The content of the site can be almost entirely altered through blocks. Simply put, <I>admin blocks</I> are small bits of PHP code which will get plugged into the site. Admin blocks are typically used to add custom blocks to the site.</P>
- <P>If you know how to script in PHP, admin blocks are pretty easy to create. Don't worry if you're no PHP-wizard: simply use the standard admin blocks (i.e. those available by default) as they are just fine or ask an expert 'admin blocker' to help you create custom admin blocks that fit your needs.</P>
- <P>Each admin block consists of a subject and an associated block of PHP code which can be as long as you want it to be and that will 'render' the content of the block. You can use any piece of PHP code to make up an admin block. An admin block's code is stored in the database and the engine will dynamically embed the PHP code just-in-time for execution.</P>
- <P>There are however some factors to keep in mind when using and creating admin blocks: admin blocks can be extremly useful and flexible, yet they can be dangerous and insecure if not properly used. If you are not familiar with PHP, SQL or even with the site engine for that matter, avoid experimenting with admin blocks because you can - and you probably will - corrupt your database or even render your site unusable! If you don't plan to do fancy stuff with admin blocks then you're probably safe though.</P>
- <P>Remember that the code within each admin block must be valid PHP code, including things like terminating statements with a semicolon so the parser won't die. Therefore, it is highly recommended to test your admin blocks seperatly using a simple test script on top of a test database before migrating to your production environment running your real database.</P>
- <P>Note that you can use global variables such as configuration parameters within the scope of an admin block. Also keep in mind that variables that have been given values in an admin block will retain these values in the engine or module afterwards.</P>
- <P>You can use the <CODE>return</CODE> statement to return the actual content of the block as well.</P>
- <P><U>A basic example:</U></P>
- <P>Given the admin block with subject "Welcome", used to create a Welcome-block. The content for this admin block could be created by using:</P>
- <PRE>
- return "Welcome visitor, ... welcome message goes here ...";
- </PRE>
- <P>If we are however dealing with a registered user, we can customize the message by using:
- <PRE>
- if ($user) {
- return "Welcome $user->userid, ... welcome message goes here ...";
- }
- else {
- return "Welcome visitor, ... welcome message goes here ...";
- }
- </PRE>
- <P>For a more in-depth example, we recommend you check the existing default admin blocks and use them as a start.</P>
- <P>As mentioned above, you can virtually use any piece of PHP code in an admin block: you can declare and use functions, consult the SQL database, access configuration settings and so on.</P>
- <?
-}
-
-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"] = 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
diff --git a/modules/affiliate.module b/modules/affiliate-site.module
index 7abef51cf..89f7b31ef 100644
--- a/modules/affiliate.module
+++ b/modules/affiliate-site.module
@@ -30,9 +30,9 @@ function affiliate_block() {
$content .= "</FORM>\n";
$content .= "</CENTER>\n";
- $blocks[0]["subject"] = "Affiliates";
+ $blocks[0]["subject"] = "Affiliate sites";
$blocks[0]["content"] = $content;
- $blocks[0]["info"] = "Affiliates (selection)";
+ $blocks[0]["info"] = "Affiliate sites (selection)";
unset($content);
@@ -41,9 +41,9 @@ function affiliate_block() {
$content .= "<LI><A HREF=\"$affiliate->link\">$affiliate->name</A></LI>\n";
}
- $blocks[1]["subject"] = "Affiliates";
+ $blocks[1]["subject"] = "Affiliate sites";
$blocks[1]["content"] = $content;
- $blocks[1]["info"] = "Affiliates (sequential)";
+ $blocks[1]["info"] = "Affiliate sites (sequential)";
return $blocks;
}
diff --git a/modules/backend.class b/modules/backend.class
index 35bcfeb0e..888dcba0f 100644
--- a/modules/backend.class
+++ b/modules/backend.class
@@ -16,7 +16,7 @@ class backend {
// Contains the parsed rdf/rss/xml file:
var $headlines = array(); // latest headlines
- function backend($id, $site, $url, $file, $contact, $timout = 3600) {
+ function backend($id, $site = "", $url = "", $file = "", $contact = "", $timout = 3600) {
// Get channel info:
$result = db_query("SELECT * FROM channel WHERE id = '$id' OR site = '$site'");
diff --git a/modules/box.module b/modules/box.module
new file mode 100644
index 000000000..a493b5a33
--- /dev/null
+++ b/modules/box.module
@@ -0,0 +1,172 @@
+<?
+
+$module = array("help" => "box_help",
+ "block" => "box_block",
+ "admin" => "box_admin");
+
+
+function box_help() {
+ ?>
+ <P>The content of the site can be almost entirely altered through boxes. Simply put, <I>boxes</I> are small bits of text, HTML or PHP code which will get plugged into the site just like any other block. Boxes are typically used to add custom blocks to the site.</P>
+ <P>Each box consists of a subject and an associated block of text, HTML or PHP code which can be as long as you want it to be and that will 'render' the content of the box.</P>
+ <H3>PHP boxes</H3>
+ <P>If you know how to script in PHP, PHP boxes are pretty easy to create. Don't worry if you're no PHP-wizard: simply use ASCII or HTML boxes instead.</P>
+ <P>You can use any piece of PHP code to make up the content of a PHP box: this implies that you can declare and use functions, consult the SQL database, access configuration settings and much more. A PHP box's code is stored in the database and the engine will dynamically embed the PHP code just-in-time for execution.</P>
+ <P>There are however some factors to keep in mind when using and creating PHP boxes: PHP boxes can be extremly useful and flexible, yet they can be dangerous and insecure if not properly used. If you are not familiar with PHP, SQL or even with the site engine for that matter, avoid experimenting with PHP boxes because you can - and you probably will - corrupt your database or even render your site unusable! If you don't plan to do fancy stuff with boxes then you're probably better off with ASCII or HTML boxes.</P>
+ <P>Remember that the code within each PHP box must be valid PHP code, including things like terminating statements with a semicolon so the parser won't die. Therefore, it is highly recommended to test your boxes seperatly using a simple test script on top of a test database before migrating to your production environment running your real database.</P>
+ <P>Note that you can use global variables such as configuration parameters within the scope of a PHP box. Also keep in mind that variables that have been given values in a PHP box will retain these values in the engine or module afterwards.</P>
+ <P>You can use the <CODE>return</CODE> statement to return the actual content for your block as well.</P>
+ <P><U>A basic example:</U></P>
+ <P>Given the box with subject "Welcome", used to create a "<I>Welcome</I>"-box. The content for this box could be created by using:</P>
+ <PRE>
+ return "Welcome visitor, ... welcome message goes here ...";
+ </PRE>
+ <P>If we are however dealing with a registered user, we can customize the message by using:
+ <PRE>
+ if ($user->userid) {
+ return "Welcome $user->userid, ... welcome message goes here ...";
+ }
+ else {
+ return "Welcome visitor, ... welcome message goes here ...";
+ }
+ </PRE>
+ <P>For a more in-depth example, we recommend you to check the existing boxes and to use them as a start.</P>
+ <?
+}
+
+function box_block() {
+ $result = db_query("SELECT * FROM boxes");
+ $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]["info"] = check_output($block->info);
+ $blocks[$i]["link"] = check_output($block->link);
+ $i++;
+ }
+
+ return $blocks;
+}
+
+function box_admin_display() {
+ $type = array(0 => "ASCII", 1 => "HTML", 2 => "PHP");
+
+ $result = db_query("SELECT * FROM boxes");
+
+ while ($block = db_fetch_object($result)) {
+ $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
+ $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>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";
+ }
+
+ foreach ($type as $key=>$value) {
+ $selection .= " <OPTION VALUE=\"$key\">$value</OPTION>\n";
+ }
+
+ $output .= "<FORM ACTION=\"admin.php?mod=box\" 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>Type:</TH><TD><SELECT NAME=\"type\">\n$selection</SELECT></TD></TR>\n";
+ $output .= " <TR><TH>Description:</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 box\"></TD></TR>\n";
+ $output .= "</TABLE>\n";
+ $output .= "</FORM>\n";
+
+ print $output;
+}
+
+function box_admin_add($subject, $content, $info, $link, $type) {
+ db_query("INSERT INTO boxes (subject, content, info, link, type) VALUES ('". check_input($subject) ."', '". check_code($content) ."', '". check_input($info) ."', '". check_input($link) ."', '". check_input($type) ."')");
+}
+
+function box_admin_delete($id) {
+ db_query("DELETE FROM boxes WHERE id = $id");
+}
+
+function box_admin_rehash() {
+ global $repository;
+ module_rehash_blocks("box", $repository["box"]);
+}
+
+function box_admin_edit($id) {
+ $type = array(0 => "ASCII", 1 => "HTML", 2 => "PHP");
+
+ $result = db_query("SELECT * FROM boxes WHERE id = $id");
+
+ if ($block = db_fetch_object($result)) {
+ $output .= "<FORM ACTION=\"admin.php?mod=box\" 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 .= "<P>\n";
+ $output .= " <B>Type:</B><BR>\n";
+ $output .= " <SELECT NAME=\"type\">\n";
+ foreach ($type as $key=>$value) {
+ $output .= " <OPTION VALUE=\"$key\"". (($block->type == $key) ? " SELECTED" : "") .">$value</OPTION>\n";
+ }
+ $output .= " </SELECT>\n";
+ $output .= "</P>\n";
+ $output .= "<P>\n";
+ $output .= " <B>Description:</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 box\"><BR>\n";
+ $output .= "</P>\n";
+ $output .= "</FORM>\n";
+ }
+
+ print $output;
+}
+
+function box_admin_save($id, $subject, $content, $info, $link, $type) {
+ db_query("UPDATE boxes SET subject = '". check_input($subject) ."', content = '". check_code($content) ."', info = '". check_input($info) ."', link = '". check_input($link) ."', type = '". check_input($type) ."' WHERE id = '$id'");
+ watchdog("message", "modified box `$subject'");
+}
+
+function box_admin() {
+ global $op, $id, $subject, $content, $info, $link, $type;
+
+ switch ($op) {
+ case "Add box":
+ box_admin_add($subject, $content, $info, $link, $type);
+ box_admin_display();
+ box_admin_rehash();
+ break;
+ case "Save box":
+ box_admin_save($id, $subject, $content, $info, $link, $type);
+ box_admin_display();
+ box_admin_rehash();
+ break;
+ case "edit":
+ box_admin_edit($id);
+ break;
+ case "delete":
+ box_admin_delete($id);
+ box_admin_rehash();
+ // fall through
+ default:
+ box_admin_display();
+ }
+}
+
+?> \ No newline at end of file
diff --git a/modules/diary.module b/modules/diary.module
index 63ebb8583..6a9f902e5 100644
--- a/modules/diary.module
+++ b/modules/diary.module
@@ -3,6 +3,7 @@
$module = array("page" => "diary_page",
"block" => "diary_block",
"help" => "diary_help",
+ "user" => "diary_user",
"admin" => "diary_admin",
"export" => "diary_export");
@@ -199,6 +200,21 @@ function diary_help() {
<?
}
+function diary_user($username, $section, $operation) {
+ if ($section == "user" && $operation == "view") {
+ $result = db_query("SELECT d.* FROM diaries d LEFT JOIN users u ON u.id = d.author WHERE u.userid = '$username' AND d.timestamp > ". (time() - 1209600) ." ORDER BY id DESC LIMIT 2");
+ while ($diary = db_fetch_object($result)) {
+ $content .= "<DL><DT><B>". date("l, F jS", $diary->timestamp) .":</B></DT><DD><P>". check_output($diary->text) ."</P><P>[ <A HREF=\"module.php?mod=diary&op=view&name=$username\">more</A> ]</P></DD></DL>\n";
+ $diaries++;
+ }
+
+ $block["subject"] = "$username has posted ". format_plural($diaries, "diary entry", "diary entries") ." recently";
+ $block["content"] = $content;
+
+ return $block;
+ }
+}
+
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");
diff --git a/modules/documentation.module b/modules/documentation.module
index b55397628..82a97d00a 100644
--- a/modules/documentation.module
+++ b/modules/documentation.module
@@ -22,20 +22,22 @@ function documentation() {
<H2>System requirements</H2>
- MySQL<BLOCKQUOTE><A HREF="http://mysql.com/">http://mysql.com/</A><BR>(development with version 3.22.32)</BLOCKQUOTE>
- PHP4<BLOCKQUOTE><A HREF="http://php.net/">http://php.net/</A><BR>(development with version 4.0.0 and 4.0.4)</BLOCKQUOTE>
- Apache<BLOCKQUOTE><A HREF="http://apache.org/">http://apache.org/</A><BR>(development with version 1.3.14)</BLOCKQUOTE>
+ MySQL:<BLOCKQUOTE><A HREF="http://mysql.com/">http://mysql.com/</A><BR>(development with version 3.22.32)</BLOCKQUOTE>
+ PHP4:<BLOCKQUOTE><A HREF="http://php.net/">http://php.net/</A><BR>(development with version 4.0.0 and 4.0.4)</BLOCKQUOTE>
+ Apache:<BLOCKQUOTE><A HREF="http://apache.org/">http://apache.org/</A><BR>(development with version 1.3.14)</BLOCKQUOTE>
<H2>Installation process</H2>
- <P>1. We assume that you have some working experience with Apache, MySQL and PHP. If you still need to install Apache, MySQL or PHP, please install them now. The installation of these required packages is beyond the scope of this document but make sure your Apache is setup to allow <CODE>.htaccess</CODE> files so that drupal can override Apache options from within the drupal directories.</P>
- <P>2. Unzip the distribution tarball into the directory you want to serve web files from:</P>
+ <P>1. Download the distribution tarball and unzip it into the directory you want to serve web files from:</P>
<BLOCKQUOTE>$ tar -zxvf drupal-x.x.x.tar.gz</BLOCKQUOTE>
+ <P>2. We assume that you have some working experience with Apache, MySQL and PHP. In order to set up your drupal site correctly, you'll first have to get Apache, MySQL and PHP working together. So if you still need to install Apache, MySQL or PHP, please install them now. Otherwise, head on to point 3. The installation of these required packages is beyond the scope of this document but what follows are some brief guidelines to get you started.</P>
+ <P>Installing MySQL shouldn't be too much of a burden, when using a Linux distribution that can handle RPMs. All you have to do is grab the RMPs from the MySQL website. Please do note that you'll also need the MySQL client RPM, not only the MySQL server one. Once MySQL has been installed, download Apache and PHP, and unpack them in the same directory. To install Apache together with PHP and MySQL, follow the "quick install"-instructions in the <CODE>INSTALL</CODE>-file located in your PHP directory. When configuring PHP do not forget to replace '<I>apache_1.3.x</I>' with your version of Apache. This may sound silly but it got me twice.</P>
+ <P>After the compilation process you have to set the <CODE>DocumentRoot</CODE> in Apache's <CODE>httpd.conf</CODE> to the path of your <CODE>drupal</CODE>-directory. Make sure your Apache is setup to allow <CODE>.htaccess</CODE> files so drupal can override Apache options from within the drupal directories. Therefore, set <CODE>AllowOverride</CODE> to "All" instead of "None". Somewhat down <CODE>httpd.conf</CODE> they ask you to set <CODE>Directory</CODE> to whatever you set <CODE>DocumentRoot</CODE> to. The last thing to do is to add <CODE>index.php</CODE> in <CODE>IfModule mod_dir.c</CODE> behind <CODE>DirectoryIndex</CODE>. Apache will then look for <CODE>index.php</CODE> in the <CODE>DocumentRoot</CODE> and will display it as its main page.</P>
<P>3. Create a MySQL database for your drupal site (if you haven't already):</P>
- <BLOCKQUOTE>$ mysqladmin create &lt;database&gt;</BLOCKQUOTE>
+ <BLOCKQUOTE>$ mysqladmin create <I>&lt;database&gt;</I></BLOCKQUOTE>
<P>Make sure to consult the MySQL documentation on how to setup the correct access rights and permissions in your MySQL grant tables.</P>
<P>4. Once you have a proper database, dump the required tables into your database:</P>
- <BLOCKQUOTE>$ mysql -h &lt;hostname&gt; -u &lt;username&gt; -p&lt;password&gt; &lt;database&gt; < database/database.mysql </BLOCKQUOTE>
+ <BLOCKQUOTE>$ mysql -h <I>&lt;hostname&gt;</I> -u <I>&lt;username&gt;</I> -p<I>&lt;password&gt; &lt;database&gt;</I> < database/database.mysql</BLOCKQUOTE>
<P>5. Copy the file <CODE>includes/hostname.conf</CODE> to match your server's hostname:</P>
<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>
@@ -168,6 +170,10 @@ function documentation() {
<TD VALIGN="top"><CODE>page</CODE></TD>
<TD VALIGN="top">If a module requires its own page it should provide a function named <CODE>module_page</CODE>. The page can then be publicly accessed via <CODE>http://yourdomain.com/module.php?mod=module</CODE> which will cause the engine to invoke <CODE>module_page</CODE> in order to generate the module's page.</TD>
</TR>
+ <TR>
+ <TD VALIGN="top"><CODE>user</CODE></TD>
+ <TD VALIGN="top"></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>
diff --git a/modules/drupal-site.module b/modules/drupal-site.module
new file mode 100644
index 000000000..8a50cb952
--- /dev/null
+++ b/modules/drupal-site.module
@@ -0,0 +1,94 @@
+<?
+
+$module = array("block" => "drupal_block",
+ "admin" => "drupal_admin");
+
+function drupal_block() {
+ global $site_url;
+
+ $result = db_query("SELECT * FROM drupals 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 .= "<CENTER>\n";
+ $content .= "<FORM ACTION=\"\" METHOD=\"post\">\n";
+ $content .= " <SELECT NAME=\"drupal\" ONCHANGE=\"gotosite(this.options[this.selectedIndex].value)\">\n";
+ $content .= " <OPTION VALUE=\"$site_url\">select a site</OPTION>\n";
+ while ($drupal = db_fetch_object($result)) {
+ $content .= " <OPTION VALUE=\"$drupal->link\">$drupal->name</OPTION>\n";
+ }
+
+ $content .= " </SELECT>\n";
+ $content .= "</FORM>\n";
+ $content .= "</CENTER>\n";
+
+ $blocks[0]["subject"] = "Drupal sites";
+ $blocks[0]["content"] = $content;
+ $blocks[0]["info"] = "Drupal sites (selection)";
+
+ unset($content);
+
+ $result = db_query("SELECT * FROM drupals ORDER BY name");
+ while ($drupal = db_fetch_object($result)) {
+ $content .= "<LI><A HREF=\"$drupal->link\">$drupal->name</A></LI>\n";
+ }
+
+ $blocks[1]["subject"] = "Drupal sites";
+ $blocks[1]["content"] = $content;
+ $blocks[1]["info"] = "Drupal sites (sequential)";
+
+ return $blocks;
+}
+
+function drupal_admin_add($name, $link, $contact) {
+ db_query("INSERT INTO drupals (name, link, contact) VALUES ('". check_input($name) ."', '". check_input($link) ."', '". check_input($contact) ."')");
+}
+
+function drupal_admin_del($id) {
+ db_query("DELETE FROM drupals WHERE id = '$id'");
+}
+
+function drupal_admin_display() {
+ $result = db_query("SELECT * FROM drupals ORDER BY name");
+
+ $output .= "<FORM ACTION=\"admin.php?mod=drupal\" 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 ($drupal = db_fetch_object($result)) {
+ $output .= " <TR><TD>$drupal->name</TD><TD>". format_url($drupal->link) ."</TD><TD>". format_email($drupal->contact) ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=drupal&op=delete&id=$drupal->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 drupal\"></TD></TR>\n";
+ $output .= "</TABLE>\n";
+ $output .= "</FORM>\n";
+
+ print $output;
+}
+
+function drupal_admin() {
+ global $op, $id, $name, $link, $contact;
+
+ switch($op) {
+ case "Add drupal":
+ drupal_admin_add($name, $link, $contact);
+ drupal_admin_display();
+ break;
+ case "delete":
+ drupal_admin_del($id);
+ drupal_admin_display();
+ break;
+ default:
+ drupal_admin_display();
+ }
+}
+
+?> \ No newline at end of file
diff --git a/scripts/cvs-pass.pl b/scripts/cvs-pass.pl
new file mode 100644
index 000000000..17f366b71
--- /dev/null
+++ b/scripts/cvs-pass.pl
@@ -0,0 +1,9 @@
+#!/usr/bin/perl
+
+srand (time());
+my $randletter = "(int (rand (26)) + (int (rand (1) + .5) % 2 ? 65 : 97))";
+my $salt = sprintf ("%c%c", eval $randletter, eval $randletter);
+my $plaintext = shift;
+my $crypttext = crypt ($plaintext, $salt);
+
+print "${crypttext}\n";