--- modules/system.module.orig	2006-03-03 14:04:04.000000000 -0500
+++ modules/system.module	2006-03-03 14:06:40.000000000 -0500
@@ -929,6 +929,10 @@
     }
   }
 
+  if ($_POST == array()) {
+    include_once './includes/requirements.inc';
+    drupal_verify_requirements(drupal_get_module_requirements($status));
+  }
 
   // Handle status checkboxes, including overriding the generated
   // checkboxes for required modules.
@@ -979,18 +983,30 @@
 
 
 function system_modules_submit($form_id, $edit) {
-  db_query("UPDATE {system} SET status = 0, throttle = 0 WHERE type = 'module'");
-
+  include_once './includes/requirements.inc';
   $new_modules = array();
   foreach ($edit['status'] as $key => $choice) {
     if ($choice) {
-      db_query("UPDATE {system} SET status = 1 WHERE type = 'module' AND name = '%s'", $key);
       if (!module_exist($key)) {
-        $new_modules[] = $key;
+        if (drupal_verify_requirements(drupal_get_module_requirements(array($key)))) {
+          $new_modules[] = $key;
+        }
+        else {
+          drupal_set_message(t('We are unable to enable the %module module as the minimum requirements are not met.', array('%module' => $key)), 'error');
+          unset($edit['status']["$key"]);
+        }
       }
     }
   }
 
+  db_query("UPDATE {system} SET status = 0, throttle = 0 WHERE type = 'module'");
+
+  foreach ($edit['status'] as $key => $choice) {
+    if ($choice) {
+      db_query("UPDATE {system} SET status = 1 WHERE type = 'module' AND name = '%s'", $key);
+    }
+  }
+
   if (is_array($edit['throttle'])) {
     foreach ($edit['throttle'] as $key => $choice) {
       if ($choice) {
--- includes/requirements.inc.orig	2006-03-03 14:03:30.000000000 -0500
+++ includes/requirements.inc	2006-03-06 10:51:42.000000000 -0500
@@ -0,0 +1,530 @@
+<?php
+// $Id: requirements.inc $
+
+define('DRUPAL_MINIMUM_PHP',    '4.3.3');
+define('DRUPAL_MINIMUM_MEMORY', '8M');
+define('DRUPAL_MINIMUM_MYSQL',  '3.23.17'); // If using MySQL
+define('DRUPAL_MINIMUM_PGSQL',  '7.3');  // If using PostgreSQL
+define('DRUPAL_MINIMUM_APACHE', '1.3');  // If using Apache
+
+define('FILE_EXIST',          1);
+define('FILE_READABLE',       2);
+define('FILE_WRITABLE',       4);
+define('FILE_WRITEABLE',      4);
+define('FILE_EXECUTABLE',     8);
+define('FILE_NOT_EXIST',      16);
+define('FILE_NOT_READABLE',   32);
+define('FILE_NOT_WRITABLE',   64);
+define('FILE_NOT_WRITEABLE',  64);
+define('FILE_NOT_EXECUTABLE', 128);
+
+/**
+ * Reads the .install files for all module names passed in and builds an array
+ * of requirements for these modules.
+ *
+ * @param $modules
+ *  An array of modules.
+ *
+ * @return
+ *  An array containing the requirements of the modules.
+ */
+function drupal_get_module_requirements($modules = array()) {
+  $requirements = array();
+  foreach ($modules as $module) {
+    $install_file = './modules/'. $module .'.install';
+    if (file_exists($install_file)) {
+      include_once($install_file);
+      $requirements_function = $module .'_requirements';
+      if (function_exists("$requirements_function")) {
+        $requirements = _merge_requirements($requirements, $requirements_function());
+      }
+    }
+  }
+  return $requirements;
+}
+
+/**
+ * Call the appropriate requirement function. If the function is not 
+ * available, attempt to load the appropriate include file then try again.
+ *
+ * @param $requirements
+ *  An array of requirements.
+ *
+ * @return
+ *  TRUE/FALSE if requirements are met.
+ */
+function drupal_verify_requirements($requirements = array()) {
+  $valid = TRUE;
+  foreach ($requirements as $type => $data) {
+    $function = "drupal_verify_requirements_$type";
+    if (function_exists("$function")) {
+      if (!$function($data)) {
+        $valid = FALSE;
+      }
+    }
+    else {
+      $include = './includes/requirements.'. $type .'.inc';
+      if (file_exists($include)) {
+        require_once($include);
+        if (function_exists("$function")) {
+          $function($data);
+        }
+        else {
+          drupal_set_message(t('Unexpected error: function "%function" does not exist.', array('%function' => $function)), 'error');
+        }
+      }
+      else {
+        drupal_set_message(t('Unexpected error: unable to find file "%file", function "%function" does not exist.', array('%file' => $include, '%function' => $function)), 'error');
+      }
+    }
+  }
+  return $valid;
+}
+
+/**
+ * Verify the value of the specified configuration option as found in php.ini.
+ *
+ * @param $setting
+ *   An array with some or all of the following directives:
+ *    'value' = the required value of the configuration option
+ *    'shorthand'      = TRUE/FALSE whether the option is in shorthand notation
+ *    'operator'       = optional comparison operator
+ *    'message'        = message to display if comparison fails
+ *                       ("%value" and "%current_value" will be
+ *                        automatically replaced if included in the message
+ *                        text.)
+ *    'message_type'   = message type (ie, 'error', 'status')
+ */
+function drupal_verify_requirements_php($requirements = array()) {
+  $valid = TRUE;
+  foreach ($requirements as $requirement => $data) {
+    // Handle special case (not from php.ini)
+    if ($requirement == 'version') {
+      if (!drupal_verify_version_php($data)) {
+        $valid = FALSE;
+      }
+    }
+    else {
+      if ($data['shorthand']) {
+        $required = _shorthand_to_bytes($data['value']);
+        $current = _shorthand_to_bytes(ini_get($requirement));
+      }
+      else {
+        $required = $data['value'];
+        $current = ini_get($requirement);
+      }
+  
+      switch ($data['operator']) {
+        case '<':
+          $compare = ($current < $required);
+          break;
+        case '<=':
+          $compare = ($current <= $required);
+          break;
+        case '==':
+        default:
+          $compare = ($current == $required);
+          break;
+        case '>=':
+          $compare = ($current >= $required);
+          break;
+        case '>':
+          $compare = ($current > $required);
+          break;
+        case '!=':
+        case '<>':
+          $compare = ($current != $required);
+          break;
+        case '===':
+          $compare = ($current === $required);
+          break;
+        case '!==':
+          $compare = ($current !== $required);
+          break;
+      }
+
+      if (!$compare && isset($data['message'])) {
+        drupal_set_message(t($data['message'], array('%current_value' => ini_get($requirement), '%value' => $data['value'])), $data['required'] ? 'error' : 'status');
+      }
+      if (!$compare && $data['required']) {
+        $valid = FALSE;
+      }
+    }
+  }
+  return $valid;
+}
+
+/**
+ * Verify the state of the specified file.
+ *
+ * @param $requirements
+ *   An array with some or all of the following directives:
+ *    'required'     = whether or not this file is required
+ *    'mask'         = permissions information about the file
+ *    'type'         = file type (file, directory, link)
+ *    'message'      = message to display if something is wrong with file
+ */
+function drupal_verify_requirements_file($requirements = array()) {
+  $valid = TRUE;
+  foreach ($requirements as $file => $data) {
+    // Handle special case files (ie settings.php)
+    switch ($file) {
+      case '%settings.php':
+        $file = './'. conf_init() .'/settings.php';
+        break;
+    }
+
+    $err = FALSE;
+    // Check for files that shouldn't be there
+    if (isset($data['mask']) && $data['mask'] & FILE_NOT_EXIST) {
+      if (file_exists($file)) {
+        drupal_set_message(t('%type <em>%file</em> exists but should not. Please remove the %type %file.', array('%type' => $data['type'], '%file' => $file)), $data['required'] ? 'error' : 'status');
+        $err = TRUE;
+      }
+    }
+    else {
+      // Verfiy that the file is the type of file it is supposed to be
+      if (isset($data['type']) && file_exists($file)) {
+        switch ($data['type']) {
+          case 'file':
+            if (!is_file($file)) {
+              $err = TRUE;
+            }
+            break;
+          case 'directory':
+            if (!is_dir($file)) {
+              $err = TRUE;
+            }
+            break;
+          case 'link':
+            if (!is_link($file)) {
+              $err = TRUE;
+            }
+            break;
+        }
+        if ($err) {
+          drupal_set_message(t('<em>%file</em> exists but is not a %type. This can happen if, for example, you have created a file that has the same name as a directory that Drupal is expecting. Please remove the %type %file.', array('%type' => $data['type'], '%file' => $file)), $data['required'] ? 'error' : 'status');
+        }
+      }
+
+      // Verify file permissions
+      if (isset($data['mask'])) {
+        $filetype = ucfirst($data['type']);
+        $masks = array(FILE_EXIST, FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_EXIST, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
+        foreach ($masks as $mask) {
+          if ($data['mask'] & $mask && !$err) {
+            switch ($mask) {
+              case FILE_EXIST:
+                if (!file_exists($file)) {
+                  if ($filetype == 'Directory') {
+                    drupal_requirements_mkdir($file, $data['mask']);
+                  }
+                  if (!file_exists($file)) {
+                    drupal_set_message(t('%type <em>%file</em> does not exist.', array('%type' => $filetype, '%file' => $file)), $data['required'] ? 'error' : 'status');
+                    $err = TRUE;
+                  }
+                }
+                break;
+              case FILE_READABLE:
+                if (!is_readable($file) && !drupal_requirements_fix_file($file, $data['mask'])) {
+                  drupal_set_message(t('%type <em>%file</em> is not readable. On Unix-like systems, this can be fixed with the command: <code>chmod o+r %file</code>.', array('%type' => $filetype, '%file' => $file)), $data['required'] ? 'error' : 'status');
+                  $err = TRUE;
+                }
+                break;
+              case FILE_WRITABLE:
+                if (!is_writable($file) && !drupal_requirements_fix_file($file, $data['mask'])) {
+                  drupal_set_message(t('%type <em>%file</em> is not writable. On Unix-like systems, this can be fixed with the command: <code>chmod o+w %file</code>.', array('%type' => $filetype, '%file' => $file)), $data['required'] ? 'error' : 'status');
+                  $err = TRUE;
+                }
+                break;
+              case FILE_EXECUTABLE:
+                if (!is_executable($file) && !drupal_requirements_fix_file($file, $data['mask'])) {
+                  drupal_set_message(t('%type <em>%file</em> is not executable. On Unix-like systems, this can be fixed with the command: <code>chmod o+x %file</code>.', array('%type' => $filetype, '%file' => $file)), $data['required'] ? 'error' : 'status');
+                  $err = TRUE;
+                }
+                break;
+              case FILE_NOT_READABLE:
+                if (is_readable($file) && !drupal_requirements_fix_file($file, $data['mask'])) {
+                  drupal_set_message(t('%type <em>%file</em> is readable but should not be. On Unix-like systems, this can be fixed with the command: <code>chmod o-r %file</code>.', array('%type' => $filetype, '%file' => $file)), $data['required'] ? 'error' : 'status');
+                  $err = TRUE;
+                }
+                break;
+              case FILE_NOT_WRITABLE:
+                if (is_writable($file) && !drupal_requirements_fix_file($file, $data['mask'])) {
+                  drupal_set_message(t('%type <em>%file</em> is writable but should not be. On Unix-like systems, this can be fixed with the command: <code>chmod o-w %file</code>.', array('%type' => $filetype, '%file' => $file)), $data['required'] ? 'error' : 'status');
+                  $err = TRUE;
+                }
+                break;
+              case FILE_NOT_EXECUTABLE:
+                if (is_executable($file) && !drupal_requirements_fix_file($file, $data['mask'])) {
+                  drupal_set_message(t('%type <em>%file</em> is executable but should not be. On Unix-like systems, this can be fixed with the command: <code>chmod o-x %file</code>.', array('%type' => $filetype, '%file' => $file)), $data['required'] ? 'error' : 'status');
+                  $err = TRUE;
+                }
+                break;
+            }
+          }
+        }
+      }
+    }
+    if ($err && isset($data['message'])) {
+      drupal_set_message(strtr($data['message'], array('%path' => $file)), $data['required'] ? 'error' : 'status');
+    }
+    if ($err && $data['required']) {
+      $valid = FALSE;
+    }
+  }
+  return $valid;
+}
+
+/**
+ * Verify that a function exists.
+ *
+ * @param $requirements
+ *   An array with some or all of the following directives:
+ *    'message'  = message to display if the function does not exist.
+ *    'required' = true if the function is required
+ */
+function drupal_verify_requirements_function($requirements = array()) {
+  $valid = TRUE;
+  foreach ($requirements as $function => $data) {
+    if (!function_exists("$function")) {
+      drupal_set_message($data['message'], $data['required'] ? 'error' : 'status');
+      if ($data['required']) {
+        $valid = FALSE;
+      }
+    }
+  }
+  return $valid;
+}
+
+/**
+ * Detect all databases supported by Drupal that are compiled into the current
+ * PHP installation.
+ *
+ * @return
+ *  An array of database types compiled into PHP.
+ */
+function drupal_detect_database_types($type = NULL) {
+  $databases = array();
+
+  if (file_exists('./includes/requirements.mysql.inc')) {
+    include_once './includes/requirements.mysql.inc';
+    if (mysql_is_available()) {
+      if ($type == 'mysql') {
+        return TRUE;
+      }
+      $databases[] = 'mysql';
+    }
+  }
+  if (file_exists('./includes/requirements.mysqli.inc')) {
+    include_once './includes/requirements.mysqli.inc';
+    if (mysqli_is_available()) {
+      if ($type == 'mysqli') {
+        return TRUE;
+      }
+      $databases[] = 'mysqli';
+    }
+  }
+  if (file_exists('./includes/requirements.pgsql.inc')) {
+    include_once './includes/requirements.pgsql.inc';
+    if (pgsql_is_available()) {
+      if ($type == 'pgsql') {
+        return TRUE;
+      }
+      $databases[] = 'pgsql';
+    }
+  }
+
+  if (isset($type)) {
+    // requested database type not detected
+    return FALSE;
+  }
+  else {
+    return $databases;
+  }
+}
+
+/**
+ * Merge requirements arrays.
+ */
+function _merge_requirements($requirements_old, $requirements_new) {
+  foreach ($requirements_new as $new => $data) {
+    if (isset($requirements_old["$new"])) {
+      // Use largest version
+      if (isset($data['minimum_version'])) {
+        if (version_compare($requirements_old["$new"]['minimum_version'], $data['minimum_version']) < 0) {
+          $requirements_old["$new"] = $data;
+        }
+      }
+      // Use largest value
+      elseif (isset($data['value'])) {
+        if ($requirements_old["$new"]['value'] < $data['value']) {
+          $requirements_old["$new"] = $data;
+        }
+      }
+      elseif (is_array($data)) {
+        $requirements_old["$new"] = _merge_requirements($requirements_old["$new"], $data);
+      }
+    }
+    else {
+      $requirements_old["$new"] = $data;
+    }
+  }
+  return $requirements_old;
+}
+
+/**
+ * Some php.ini options are written in shorthand (ie 1K instead of 1024 bytes).
+ * This function converts php.ini shorthand into bytes.
+ *
+ * @param $shorthand
+ *  A memory string in php.ini shorthand notation (ie 1K, 8M, 10G)
+ *
+ * @return
+ *  The shorthand value converted to bytes.
+ */
+function _shorthand_to_bytes($shorthand) {
+  $result = trim($shorthand);
+  $modifier = strtolower($result{strlen($result)-1});
+  switch ($modifier) {
+    case 'g':
+      $result *= 1024;
+    case 'm':
+      $result *= 1024;
+    case 'k':
+      $result *= 1024;
+  }
+  return $result;
+}
+
+/**
+ * Verify that the installed version of PHP meets our minimum requirements.
+ *
+ * @param $version
+ *   An array with some or all of the following directives:
+ *    'minimum_version' = the minimum version of PHP
+ *    'required'        = whether or not the minimum version is required (error
+ *                        versus warning)
+ *    'message'         = message to display if version is invalid
+ *                       ("%minimum_version" and "%installed_version" will be
+ *                        automatically replaced if included in the message
+ *                        text.)
+ */
+function drupal_verify_version_php($version = array()) {
+  if (!function_exists(version_compare) || 
+      version_compare(phpversion(), $version['minimum_version'], '<')) {
+    // version_compare() was added in PHP 4.1.
+    drupal_set_message(t($version['message'], array('%minimum_version' => $version['minimum_version'], '%installed_version' => phpversion())), $version['required'] ? 'error' : 'status');
+    if ($version['required']) {
+      // invalid version of PHP
+      return FALSE;
+    }
+  }
+  // valid version of PHP, or we're just setting a warning.
+  return TRUE;
+}
+
+/**
+ * Create directory with specified mask.
+ *
+ * @param $file
+ *  The full path of the directory to create.
+ * @param $mask
+ *  The mask for the directory to create.
+ *
+ * @return
+ *  TRUE/FALSE of whether or not the directory was successfully created.
+ */
+function drupal_requirements_mkdir($file, $mask) {
+  $mod = 0;
+  $masks = array(FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
+  foreach ($masks as $m) {
+    if ($mask & $m) {
+      switch ($m) {
+        case FILE_READABLE:
+          $mod += 444;
+          break;
+        case FILE_WRITABLE:
+          $mod += 222;
+          break;
+        case FILE_EXECUTABLE:
+          $mod += 111;
+          break;
+      }
+    }
+  }
+
+  if (@mkdir($file, intval("0$mod", 8))) {
+    drupal_set_message(t('Automatically created directory <em>%file</em>.', array('%file' => $file)), 'status');
+    return TRUE;
+  }
+  else {
+    drupal_set_message(t('Failed to automatically create directory <em>%file</em>, insufficient privileges. Please manually create the %file directory.', array('%file' => $file)), 'status');
+    return FALSE;
+  }
+}
+
+/**
+ * Attempt to fix file permissions.
+ *
+ * @param $file
+ *  The name of the file with permissions to fix.
+ * @param $mask
+ *  The desired permissions for the file.
+ *
+ * @return
+ *  TRUE/FALSE whether or not we were able to fix the file's permissions.
+ */
+function drupal_requirements_fix_file($file, $mask) {
+  $mod = substr(sprintf('%o', fileperms($file)), -4);
+  $prefix = substr($mod, 0, 1);
+  $mod = substr($mod, 1 ,4);
+  $masks = array(FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
+  foreach ($masks as $m) {
+    if ($mask & $m) {
+      switch ($m) {
+        case FILE_READABLE:
+          if (!is_readable($file)) {
+            $mod += 444;
+          }
+          break;
+        case FILE_WRITABLE:
+          if (!is_writable($file)) {
+            $mod += 222;
+          }
+          break;
+        case FILE_EXECUTABLE:
+          if (!is_executable($file)) {
+            $mod += 111;
+          }
+          break;
+        case FILE_NOT_READABLE:
+          if (is_readable($file)) {
+            $mod -= 444;
+          }
+          break;
+        case FILE_NOT_WRITABLE:
+          if (is_writable($file)) {
+            $mod -= 222;
+          }
+          break;
+        case FILE_NOT_EXECUTABLE:
+          if (is_executable($file)) {
+            $mod -= 111;
+          }
+          break;
+      }
+    }
+  }
+
+  if (chmod($file, intval("$prefix$mod", 8))) {
+    drupal_set_message(t('Automatically fixed the permissions of file <em>%file</em>.', array('%file' => $file)), 'status');
+    return TRUE;
+  }
+  else {
+    drupal_set_message(t('Failed to automatically fix permissions of file <em>%file</em>, insufficient privileges. Please manually fix these permissions, using the commands outlined in previous messages.', array('%file' => $file)), 'status');
+    return FALSE;
+  }
+}
+
+?>
--- includes/requirements.apache.inc.orig	2006-03-03 14:03:22.000000000 -0500
+++ includes/requirements.apache.inc	2006-03-06 11:01:29.000000000 -0500
@@ -0,0 +1,80 @@
+<?php
+
+// Apache specific requirements functions
+
+/**
+ * Verify the current Apache installation.
+ *
+ * @param $requirements
+ *  An array containing Apache requirements. Supported arguments:
+ *   'version':  the required version of Apache
+ */
+function drupal_verify_requirements_apache($requirements = array()) {
+  if (!_using_apache()) {
+    // Don't perform Apache validations -- we're not using Apache
+    return;
+  }
+  foreach ($requirements as $requirement => $data) {
+    switch ($requirement) {
+      case 'version':
+        _drupal_verify_version_apache($data);
+        break;
+      case 'module':
+        _drupal_verify_modules_apache($data);
+        break;
+    }
+  }
+}
+
+/**
+ * Check if Apache is currently being used to serve Drupal pages.
+ *
+ * @return
+ *  0 = not Apache, 1 = Apache
+ */
+function _using_apache() {
+  return preg_match('/apache/i', $_SERVER['SERVER_SOFTWARE']);
+}
+
+/**
+ * Verify that the version of Apache that is currently being used meets our
+ * minimum requirements.
+ *
+ * @param $version
+ *  An array containing version information and a message if the installed
+ *  version of Apache doesn't meet the minimum requirements.
+ *   Recognized options:
+ *    - 'minimum_version': the required version of Apache
+ *    - 'message': message to display if insufficient version of Apache
+ *    - 'message_type': 'error' if critical, 'status' if warning
+ */
+function _drupal_verify_version_apache($version = array()) {
+  // TODO: Is it possible to verify Apache modules without using the function
+  //       apache_get_modules()?
+  if (function_exists('apache_get_version')) {
+    preg_match('!Apache/(.*) !U', apache_get_version(), $v);
+    $installed_version = $v[1];
+    if (version_compare($installed_version, $version['minimum_version'], '<')) {
+      drupal_set_message(strtr($version['message'], array('%minimum_version' => $version['minimum_version'], '%installed_version' => $installed_version)), $version['required'] ? 'error' : 'status');
+    }
+  }
+}
+
+/**
+ * Check to see if the required Apache modules are installed.
+ *
+ * @param @modules
+ *  An array of required modules.
+ */
+function _drupal_verify_modules_apache($modules = array()) {
+  // TODO: Is it possible to verify Apache modules without using the function
+  //       apache_get_modules()?
+  if (function_exists('apache_get_modules')) {
+    foreach ($modules as $module => $data) {
+      if (!in_array($module, apache_get_modules())) {
+        drupal_set_message($data['message'], $data['required'] ? 'error' : 'status');
+      }
+    }
+  }
+}
+?>
--- includes/requirements.mysql.inc.orig	2006-03-03 14:03:25.000000000 -0500
+++ includes/requirements.mysql.inc	2006-03-06 11:01:55.000000000 -0500
@@ -0,0 +1,106 @@
+<?php
+
+// MySQL specific requirements functions
+
+/**
+ * Verify the current MySQL installation.
+ *
+ * @param $requirements
+ *  An array containing MySQL requirements. Supported arguments:
+ *   'version':  the required version of MySQL
+ *
+ * @return
+ *  TRUE/FALSE if requirements are met
+ */
+function drupal_verify_requirements_mysql($requirements = array()) {
+  $valid = TRUE;
+  foreach ($requirements as $requirement => $data) {
+    switch ($requirement) {
+      case 'version':
+        if (!drupal_verify_version_mysql($data)) {
+          $valid = FALSE;
+        }
+      break;
+    }
+  }
+  return $valid;
+}
+
+/**
+ * Check if MySQL is available.
+ *
+ * @return
+ *  TRUE/FALSE
+ */
+function mysql_is_available() {
+  if (function_exists('mysql_connect')) {
+    return TRUE;
+  }
+  return FALSE;
+}
+
+/**
+ * Check if MySQL is currently being used.
+ *
+ * @return
+ *  0 = not MySQL, 1 = MySQL
+ */
+function _using_mysql() {
+  global $db_type;
+
+  if ($db_type == 'mysql') {
+    return 1;
+  }
+  else {
+    return 0;
+  }
+}
+
+/**
+ * Retrieve the version of MySQL that is currently being used.
+ *
+ * @param $version
+ *  An array containing version information and a message if the installed
+ *  version of MySQL doesn't meet the minimum requirements.
+ *   Recognized options:
+ *    - 'minimum_version': the required version of MySQL
+ *    - 'message': message to display if insufficient version of MySQL
+ *    - 'required'
+ *
+ * @return
+ *  TRUE/FALSE if requirements are met
+ */
+function drupal_verify_version_mysql($version = array()) {
+  global $active_db;
+
+  if (!_using_mysql()) {
+    return TRUE;
+  }
+
+  $err = FALSE;
+  if (!isset($active_db)) {
+    drupal_set_message('No connection to MySQL database, unable to verify MySQL version. Please verify your database configuration, double-check your spelling and ensure that you do not have caps lock enabled. If this problem persists, check with your hosting provider to determine the correct username, password, hostname, and database name for your MySQL server.', 'error');
+  }
+  else {
+    if (function_exists('mysql_get_server_info')) {
+      preg_match('/(\d+\.?)+/', mysql_get_server_info($active_db), $current_version);
+      if (version_compare($current_version[0], $version['minimum_version'], '<')) {
+        $err = TRUE;
+      }
+    }
+    else {
+      // mysql_get_server_info() added in 4.0.5
+      $current_version[0] = t('0.0 (unknown, pre-4.0.5)');
+      $err = TRUE;
+    }
+  }
+  if ($err && $version['required']) {
+    drupal_set_message(strtr($version['message'], array('%minimum_version' => $version['minimum_version'], '%installed_version' => $current_version[0])), $version['required'] ? 'error' : 'status');
+    return FALSE;
+  }
+  else {
+    return TRUE;
+  }
+}
+
+?>
--- includes/requirements.pgsql.inc.orig	2006-03-03 14:22:21.000000000 -0500
+++ includes/requirements.pgsql.inc	2006-03-06 10:51:02.000000000 -0500
@@ -0,0 +1,108 @@
+<?php
+
+// PostgreSQL specific requirements functions
+
+/**
+ * Verify the current PostgreSQL installation.
+ *
+ * @param $requirements
+ *  An array containing PostgreSQL requirements. Supported arguments:
+ *   'version':  the required version of PostgreSQL
+ *
+ * @return
+ *  TRUE/FALSE if requirements are met
+ */
+function drupal_verify_requirements_pgsql($requirements = array()) {
+  $valid = TRUE;
+  foreach ($requirements as $requirement => $data) {
+    switch ($requirement) {
+      case 'version':
+        if (!drupal_verify_version_pgsql($data)) {
+          $valid = FALSE;
+        }
+      break;
+    }
+  }
+  return $valid;
+}
+
+/**
+ * Check if PostgreSQL is available.
+ *
+ * @return
+ *  TRUE/FALSE
+ */
+function pgsql_is_available() {
+  if (function_exists('pgsql_connect')) {
+    return TRUE;
+  }
+  return FALSE;
+}
+
+/**
+ * Check if PostgreSQL is currently being used.
+ *
+ * @return
+ *  0 = not PostgreSQL, 1 = PostgreSQL
+ */
+function _using_pgsql() {
+  global $db_type;
+
+  if ($db_type == 'pgsql') {
+    return 1;
+  }
+  else {
+    return 0;
+  }
+}
+
+/**
+ * Retrieve the version of PostgreSQL that is currently being used.
+ *
+ * @param $version
+ *  An array containing version information and a message if the installed
+ *  version of PostgreSQL doesn't meet the minimum requirements.
+ *   Recognized options:
+ *    - 'minimum_version': the required version of PostgreSQL
+ *    - 'message': message to display if insufficient version of PostgreSQL
+ *    - 'required'
+ *
+ * @return
+ *  TRUE/FALSE if requirements are met
+ */
+function drupal_verify_version_pgsql($version = array()) {
+  global $active_db;
+  
+  if (!_using_pgsql()) {
+    return TRUE;
+  }
+
+  if (!isset($active_db)) {
+    drupal_set_message('No connection to PostgreSQL database, unable to verify PostgreSQL version. Please verify your database configuration, double-check your spelling and ensure that you do not have caps lock enabled. If this problem persists, check with your hosting provider to determine the correct username, password, hostname, and database name for your PostgreSQL server.', 'error');
+  }
+  elseif (function_exists('pg_version')) {
+    // pg_version() was added in PHP 5
+    $current_version = pg_version();
+    $pg_version = $current_version['server_version'];
+  }
+  else {
+    // VERSION() was added in PostgreSQL 6.4
+    if ($result = db_result(db_query('SELECT VERSION()'))) {
+      preg_match('/(\d+\.?)+/', $result, $current_version);
+      $pg_version = $current_version[0];
+    }
+    else {
+      $pg_version = t('0.0 (unknown, pre-6.4)');
+    }
+  }
+
+  if (version_compare($pg_version, $version['minimum_version'], '<')) {
+    drupal_set_message(strtr($version['message'], array('%minimum_version' => $version['minimum_version'], '%installed_version' => $pg_version)), $version['required'] ? 'error' : 'status');
+    if ($version['required']) {
+      return FALSE;
+    }
+  }
+  return TRUE;
+}
+
+?>
--- modules/system.install.orig	2006-03-03 14:03:45.000000000 -0500
+++ modules/system.install	2006-03-06 09:56:53.000000000 -0500
@@ -0,0 +1,84 @@
+<?php
+
+/**
+ * The _requirements hook for each module when an admin tries to enable the
+ * module. The system module currently defines the requirements for the Drupal
+ * core.
+ *
+ * @return
+ *  An array of requirements for the module.
+ */
+function system_requirements() {
+  $requirements = array();
+
+  // Verify version of PHP
+  $requirements['php']['version'] = array(
+    'minimum_version' => DRUPAL_MINIMUM_PHP,
+    'message'         => t('Drupal requires PHP version %minimum_version or greater. You are using PHP version %installed_version. PHP must be upgraded in order to continue. Please contact your web server administrator.'),
+    'required'        => TRUE
+  );
+
+  // Verify safe_mode
+  $requirements['php']['safe_mode'] = array(
+    'value'        => 0,
+    'message'      => t('PHP safe_mode is currently enabled. It is recommended that you disable safe_mode or Drupal may have problems, for example with handling file uploads and images. This can be done by setting the safe_mode variable in php.ini to "0". If you do not have access to the php.ini file, please contact your web server administrator.'),
+  );
+
+  // Verify register_globals
+  $requirements['php']['register_globals'] = array(
+    'value'        => 0,
+    'message'      => t('PHP register_globals is currently enabled. As of Drupal 4.2.0 it is advised that you disable register_globals, as it helps increase the security of your site. This can be done by setting the register_globals variable in php.ini to "0". If you do not have access to the php.ini file, please contact your web server administrator.')
+  );
+
+  // Verify PHP memory limits
+  if (function_exists(memory_get_usage)) {
+    // memory_get_usage() will only be defined if PHP is compiled with 
+    // the --enable-memory-limit configuration option.
+    $requirements['php']['memory_limit'] = array(
+      'value'     => DRUPAL_MINIMUM_MEMORY,
+      'operator'  => '>=',
+      'message'   => t('Your PHP installation limits Drupal to using only %current_value of RAM. It is suggested that you modify the memory_limit directive to allow at least %value of RAM. This can be done by setting the memory_limit variable in php.ini to "%value". If you do not have access to the php.ini file, please contact your web server administrator.'),
+      'shorthand' => TRUE
+    );
+  }
+
+  // %settings.php is a special case, Drupal will search for it...
+  $requirements['file']['%settings.php'] = array(
+      'type'     => 'file',
+      'mask'     => FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE,
+      'required' => TRUE,
+      'message'  => t('Your <em>settings.php</em> file is currently writable by the web server process. This is a security risk, and it is advised that you remove write permission from the file. On Unix-like systems, this can be done with the command: <code>chmod o-w %path</code>.')
+  );
+
+  // If using Apache to serve pages
+  $requirements['apache']['version'] = array(
+    'minimum_version' => DRUPAL_MINIMUM_APACHE,
+    'message'         => t('Drupal requires Apache version %minimum_version or greater. You are using Apache version %installed_version. Apache must be upgraded in order to continue. Please contact your web server administrator.'),
+    'required'        => TRUE
+  );
+
+  $requirements['apache']['module']['mod_rewrite'] = array(
+    'message' => t('Apache\'s mod_rewrite is not enabled. You will need to enable mod_rewrite if you wish to use Drupal\'s Clean URL functionality. Please contact your web server administrator.')
+  );
+
+  $requirements['function']['gzencode4'] = array(
+    'message' => t('For improved Drupal performance and reduced bandwidth consumption you can enable the PHP zlib extension. If enabled, Drupal will compress cached pages and serve these pre-compressed pages to web browsers that support gzip. Please contact your web server administrator.')
+  );
+
+  // if using MySQL
+  $requirements['mysql']['version'] = array(
+    'minimum_version' => DRUPAL_MINIMUM_MYSQL,
+    'message'         => t('Drupal requires MySQL version %minimum_version or greater. You are using MySQL version %installed_version. MySQL must be upgraded in order to continue. Please contact your web server administrator.'),
+    'required'        => TRUE
+  );
+
+  // if using PostgreSQL
+  $requirements['pgsql']['version'] = array(
+    'minimum_version' => DRUPAL_MINIMUM_PGSQL,
+    'message'         => t('Drupal requires PostgreSQL version %minimum_version or greater. You are using PostgreSQL version %installed_version. PostgreSQL must be upgraded in order to continue. Please contact your web server administrator.'),
+    'required'       => TRUE
+  );
+
+  return $requirements;
+}
+
