From 4572760eb3bd2a9454660bf187d17c7258e04bfd Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 3 Jan 2001 21:23:58 +0000 Subject: [PATCH] A batch of preparations for release candidate 2: - expanded documentation (written by Jeroen) - fixed bug in includes/module.inc - fixed bug in modules/backend.class - renamed some of the SQL tables (!) - started making the diary.module truly modular (not finished yet) - renamed "admin_blocks" to "boxes" - added new functionality to "boxes": apart from PHP boxes, you can now create ASCII boxes as well as HTML boxes for those who are not confident with PHP. (requested by stalor) - added drupal-site module to keep track of known drupal sites - added small Perl script to generate encrypted CVS passwords --- account.php | 15 +- database/database.mysql | 29 ++- includes/module.inc | 8 +- modules/admin-block.module | 151 --------------- ...affiliate.module => affiliate-site.module} | 8 +- modules/backend.class | 2 +- modules/box.module | 172 ++++++++++++++++++ modules/diary.module | 16 ++ modules/documentation.module | 20 +- modules/drupal-site.module | 94 ++++++++++ scripts/cvs-pass.pl | 9 + 11 files changed, 342 insertions(+), 182 deletions(-) delete mode 100644 modules/admin-block.module rename modules/{affiliate.module => affiliate-site.module} (93%) create mode 100644 modules/box.module create mode 100644 modules/drupal-site.module create mode 100644 scripts/cvs-pass.pl diff --git a/account.php b/account.php index 070eb3fa7a4..42ac229ed57 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 .= "\n"; $output .= " \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 .= "
". date("l, F jS", $diary->timestamp) .":

". check_output($diary->text) ."

[ more ]

\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 cecc968f770..14e8325ba01 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 826e415b4ca..e52f612e15e 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -1,9 +1,9 @@ $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 7f7f44ffafa..00000000000 --- a/modules/admin-block.module +++ /dev/null @@ -1,151 +0,0 @@ - "ab_help", - "block" => "ab_block", - "admin" => "ab_admin"); - -function ab_help() { - ?> -

The content of the site can be almost entirely altered through blocks. Simply put, admin blocks 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.

-

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.

-

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.

-

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.

-

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.

-

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.

-

You can use the return statement to return the actual content of the block as well.

-

A basic example:

-

Given the admin block with subject "Welcome", used to create a Welcome-block. The content for this admin block could be created by using:

-
-   return "Welcome visitor, ... welcome message goes here ...";
-  
-

If we are however dealing with a registered user, we can customize the message by using: -

-   if ($user) {
-     return "Welcome $user->userid, ... welcome message goes here ...";
-   }
-   else {
-     return "Welcome visitor, ... welcome message goes here ...";
-   }
-  
-

For a more in-depth example, we recommend you check the existing default admin blocks and use them as a start.

-

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.

- 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 .= "
User ID:$user->userid
\n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= "
Subject:". check_output($block->subject) ."
Content:". nl2br(htmlentities($block->content)) ."
Information:". check_output($block->info) ."
Link:". format_url($block->link) ."
Operations:id\">edit, id\">delete
\n"; - $output .= "

\n"; - } - - $output .= "
\n"; - $output .= "\n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= "
Subject:
Content:
Information:
Link:
Operations:
\n"; - $output .= "
\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 .= "
\n"; - - $output .= "

\n"; - $output .= " Subject:
\n"; - $output .= " subject) ."\">\n"; - $output .= "

\n"; - $output .= "

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

\n"; - $output .= "Information:
\n"; - $output .= "info\">\n"; - $output .= "

\n"; - $output .= "

\n"; - $output .= "Link:
\n"; - $output .= "link\">\n"; - $output .= "

\n"; - $output .= "

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

\n"; - $output .= "
\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 similarity index 93% rename from modules/affiliate.module rename to modules/affiliate-site.module index 7abef51cf4a..89f7b31ef54 100644 --- a/modules/affiliate.module +++ b/modules/affiliate-site.module @@ -30,9 +30,9 @@ function affiliate_block() { $content .= "\n"; $content .= "\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 .= "
  • link\">$affiliate->name
  • \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 35bcfeb0ea8..888dcba0f67 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 00000000000..a493b5a33f1 --- /dev/null +++ b/modules/box.module @@ -0,0 +1,172 @@ + "box_help", + "block" => "box_block", + "admin" => "box_admin"); + + +function box_help() { + ?> +

    The content of the site can be almost entirely altered through boxes. Simply put, boxes 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.

    +

    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.

    +

    PHP boxes

    +

    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.

    +

    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.

    +

    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.

    +

    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.

    +

    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.

    +

    You can use the return statement to return the actual content for your block as well.

    +

    A basic example:

    +

    Given the box with subject "Welcome", used to create a "Welcome"-box. The content for this box could be created by using:

    +
    +   return "Welcome visitor, ... welcome message goes here ...";
    +  
    +

    If we are however dealing with a registered user, we can customize the message by using: +

    +   if ($user->userid) {
    +     return "Welcome $user->userid, ... welcome message goes here ...";
    +   }
    +   else {
    +     return "Welcome visitor, ... welcome message goes here ...";
    +   }
    +  
    +

    For a more in-depth example, we recommend you to check the existing boxes and to use them as a start.

    + 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 .= "\n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= "
    Subject:". format_data($block->subject) ."
    Content:". nl2br(htmlentities($block->content)) ."
    Type:". $type[$block->type] ."
    Description:". format_data($block->info) ."
    Link:". format_url($block->link) ."
    Operations:id\">edit, id\">delete
    \n"; + $output .= "

    \n"; + } + + foreach ($type as $key=>$value) { + $selection .= " \n"; + } + + $output .= "
    \n"; + $output .= "\n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= " \n"; + $output .= "
    Subject:
    Content:
    Type:
    Description:
    Link:
    Operations:
    \n"; + $output .= "
    \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 .= "
    \n"; + + $output .= "

    \n"; + $output .= " Subject:
    \n"; + $output .= " subject) ."\">\n"; + $output .= "

    \n"; + $output .= "

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

    \n"; + $output .= "

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

    \n"; + $output .= "

    \n"; + $output .= " Description:
    \n"; + $output .= " info\">\n"; + $output .= "

    \n"; + $output .= "

    \n"; + $output .= " Link:
    \n"; + $output .= " link\">\n"; + $output .= "

    \n"; + $output .= "

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

    \n"; + $output .= "
    \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 63ebb8583ac..6a9f902e5e0 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() { ". (time() - 1209600) ." ORDER BY id DESC LIMIT 2"); + while ($diary = db_fetch_object($result)) { + $content .= "
    ". date("l, F jS", $diary->timestamp) .":

    ". check_output($diary->text) ."

    [ more ]

    \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 b553976284f..82a97d00a0d 100644 --- a/modules/documentation.module +++ b/modules/documentation.module @@ -22,20 +22,22 @@ function documentation() {

    System requirements

    - MySQL
    http://mysql.com/
    (development with version 3.22.32)
    - PHP4
    http://php.net/
    (development with version 4.0.0 and 4.0.4)
    - Apache
    http://apache.org/
    (development with version 1.3.14)
    + MySQL:
    http://mysql.com/
    (development with version 3.22.32)
    + PHP4:
    http://php.net/
    (development with version 4.0.0 and 4.0.4)
    + Apache:
    http://apache.org/
    (development with version 1.3.14)

    Installation process

    -

    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 .htaccess files so that drupal can override Apache options from within the drupal directories.

    -

    2. Unzip the distribution tarball into the directory you want to serve web files from:

    +

    1. Download the distribution tarball and unzip it into the directory you want to serve web files from:

    $ tar -zxvf drupal-x.x.x.tar.gz
    +

    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.

    +

    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 INSTALL-file located in your PHP directory. When configuring PHP do not forget to replace 'apache_1.3.x' with your version of Apache. This may sound silly but it got me twice.

    +

    After the compilation process you have to set the DocumentRoot in Apache's httpd.conf to the path of your drupal-directory. Make sure your Apache is setup to allow .htaccess files so drupal can override Apache options from within the drupal directories. Therefore, set AllowOverride to "All" instead of "None". Somewhat down httpd.conf they ask you to set Directory to whatever you set DocumentRoot to. The last thing to do is to add index.php in IfModule mod_dir.c behind DirectoryIndex. Apache will then look for index.php in the DocumentRoot and will display it as its main page.

    3. Create a MySQL database for your drupal site (if you haven't already):

    -
    $ mysqladmin create <database>
    +
    $ mysqladmin create <database>

    Make sure to consult the MySQL documentation on how to setup the correct access rights and permissions in your MySQL grant tables.

    4. Once you have a proper database, dump the required tables into your database:

    -
    $ mysql -h <hostname> -u <username> -p<password> <database> < database/database.mysql
    +
    $ mysql -h <hostname> -u <username> -p<password> <database> < database/database.mysql

    5. Copy the file includes/hostname.conf to match your server's hostname:

    $ cp includes/hostname.conf includes/www.yourdomain.com.conf

    6. Edit your configuration file to set the required settings such as the database options and to customize your site to your likings.

    @@ -168,6 +170,10 @@ function documentation() { page If a module requires its own page it should provide a function named module_page. The page can then be publicly accessed via http://yourdomain.com/module.php?mod=module which will cause the engine to invoke module_page in order to generate the module's page. + + user + +

    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.

    diff --git a/modules/drupal-site.module b/modules/drupal-site.module new file mode 100644 index 00000000000..8a50cb9526a --- /dev/null +++ b/modules/drupal-site.module @@ -0,0 +1,94 @@ + "drupal_block", + "admin" => "drupal_admin"); + +function drupal_block() { + global $site_url; + + $result = db_query("SELECT * FROM drupals ORDER BY name"); + + $content .= "\n"; + + $content .= "
    \n"; + $content .= "
    \n"; + $content .= " \n"; + $content .= "
    \n"; + $content .= "
    \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 .= "
  • link\">$drupal->name
  • \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 .= "
    \n"; + $output .= "\n"; + $output .= " \n"; + + while ($drupal = db_fetch_object($result)) { + $output .= " \n"; + } + + $output .= " \n"; + $output .= "
    namelinkcontactoperations
    $drupal->name". format_url($drupal->link) ."". format_email($drupal->contact) ."id\">delete
    \n"; + $output .= "
    \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 00000000000..17f366b7112 --- /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";