diff -r'uNF^f' -x CVS includes/bootstrap.inc drupal.new/includes/bootstrap.inc
--- includes/bootstrap.inc	2005-05-04 19:50:21.597409456 +0200
+++ drupal.new/includes/bootstrap.inc	2005-05-04 19:08:58.928832448 +0200
@@ -17,57 +17,6 @@
 define('WATCHDOG_WARNING', 1);
 define('WATCHDOG_ERROR', 2);
 
-
-/**
- * Locate the appropriate configuration file.
- *
- * Try finding a matching configuration directory by stripping the
- * website's hostname from left to right and pathname from right to
- * left.  The first configuration file found will be used, the
- * remaining will ignored.  If no configuration file is found,
- * return a default value '$confdir/default'.
- *
- * Example for a fictitious site installed at
- * http://www.drupal.org/mysite/test/ the 'settings.php' is
- * searched in the following directories:
- *
- *  1. $confdir/www.drupal.org.mysite.test
- *  2. $confdir/drupal.org.mysite.test
- *  3. $confdir/org.mysite.test
- *
- *  4. $confdir/www.drupal.org.mysite
- *  5. $confdir/drupal.org.mysite
- *  6. $confdir/org.mysite
- *
- *  7. $confdir/www.drupal.org
- *  8. $confdir/drupal.org
- *  9. $confdir/org
- *
- * 10. $confdir/default
- */
-function conf_init() {
-  static $conf = '';
-
-  if ($conf) {
-    return $conf;
-  }
-
-  $confdir = 'sites';
-  $uri = explode('/', $_SERVER['PHP_SELF']);
-  $server = explode('.', rtrim($_SERVER['HTTP_HOST'], '.'));
-  for ($i = count($uri) - 1; $i > 0; $i--) {
-    for ($j = count($server); $j > 0; $j--) {
-      $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i));
-      if (file_exists("$confdir/$dir/settings.php")) {
-        $conf = "$confdir/$dir";
-        return $conf;
-      }
-    }
-  }
-  $conf = "$confdir/default";
-  return $conf;
-}
-
 /**
  * Returns and optionally sets the filename for a system item (module,
  * theme, etc.).  The filename, whether provided, cached, or retrieved
@@ -690,15 +639,4 @@ function drupal_get_messages() {
   return $messages;
 }
 
-unset($conf);
-$config = conf_init();
-
-include_once "$config/settings.php";
-include_once 'includes/database.inc';
-include_once 'includes/session.inc';
-include_once 'includes/module.inc';
-
-// Initialize configuration variables, using values from conf.php if available.
-$conf = variable_init(isset($conf) ? $conf : array());
-
 ?>
diff -r'uNF^f' -x CVS includes/common.inc drupal.new/includes/common.inc
--- includes/common.inc	2005-05-04 19:50:21.607407936 +0200
+++ drupal.new/includes/common.inc	2005-05-04 19:08:58.929832296 +0200
@@ -1860,55 +1860,7 @@ function drupal_get_path($type, $name) {
   return dirname(drupal_get_filename($type, $name));
 }
 
-/**
- * Provide a substitute clone() function for PHP4.
- */
-if (version_compare(phpversion(), '5.0') < 0) {
-  eval('
-    function clone($object) {
-      return $object;
-    }
-  ');
+function drupal_clone($object) {
+  return version_compare(phpversion(), '5.0') < 0 ? $object : clone($object);
 }
-
-// Set the Drupal custom error handler.
-set_error_handler('error_handler');
-
-include_once 'includes/theme.inc';
-include_once 'includes/pager.inc';
-include_once 'includes/menu.inc';
-include_once 'includes/tablesort.inc';
-include_once 'includes/file.inc';
-include_once 'includes/xmlrpc.inc';
-include_once 'includes/image.inc';
-
-// Emit the correct charset HTTP header.
-drupal_set_header('Content-Type: text/html; charset=utf-8');
-
-// Initialize $_GET['q'] prior to loading modules and invoking hook_init().
-if (!empty($_GET['q'])) {
-  $_GET['q'] = drupal_get_normal_path(trim($_GET['q'], '/'));
-}
-else {
-  $_GET['q'] = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
-}
-
-// Initialize all enabled modules.
-module_init();
-
-if (!user_access('bypass input data check')) {
-  // We can't use $_REQUEST because it consists of the contents of $_POST,
-  // $_GET and $_COOKIE: if any of the input arrays share a key, only one
-  // value will be verified.
-  if (!valid_input_data($_GET)
-   || !valid_input_data($_POST)
-   || !valid_input_data($_COOKIE)
-   || !valid_input_data($_FILES)) {
-    die('Terminated request because of suspicious input data.');
-  }
-}
-
-// Initialize the localization system.
-$locale = locale_initialize();
-
 ?>
diff -r'uNF^f' -x CVS includes/database.inc drupal.new/includes/database.inc
--- includes/database.inc	2005-05-04 19:50:21.610407480 +0200
+++ drupal.new/includes/database.inc	2005-05-04 19:08:58.929832296 +0200
@@ -279,7 +279,4 @@ function db_rewrite_sql($query, $primary
  * @} End of "defgroup database".
  */
 
-// Initialize the default database.
-db_set_active();
-
 ?>
diff -r'uNF^f' -x CVS includes/init.inc drupal.new/includes/init.inc
--- includes/init.inc	1970-01-01 01:00:00.000000000 +0100
+++ drupal.new/includes/init.inc	2005-05-04 19:17:44.133989128 +0200
@@ -0,0 +1,117 @@
+<?php
+
+/**
+ * Locate the appropriate configuration file.
+ *
+ * Try finding a matching configuration directory by stripping the
+ * website's hostname from left to right and pathname from right to
+ * left.  The first configuration file found will be used, the
+ * remaining will ignored.  If no configuration file is found,
+ * return a default value '$confdir/default'.
+ *
+ * Example for a fictitious site installed at
+ * http://www.drupal.org/mysite/test/ the 'settings.php' is
+ * searched in the following directories:
+ *
+ *  1. $confdir/www.drupal.org.mysite.test
+ *  2. $confdir/drupal.org.mysite.test
+ *  3. $confdir/org.mysite.test
+ *
+ *  4. $confdir/www.drupal.org.mysite
+ *  5. $confdir/drupal.org.mysite
+ *  6. $confdir/org.mysite
+ *
+ *  7. $confdir/www.drupal.org
+ *  8. $confdir/drupal.org
+ *  9. $confdir/org
+ *
+ * 10. $confdir/default
+ */
+
+function conf_init() {
+  static $conf = '';
+
+  if ($conf) {
+    return $conf;
+  }
+
+  $confdir = 'sites';
+  $uri = explode('/', $_SERVER['PHP_SELF']);
+  $server = explode('.', rtrim($_SERVER['HTTP_HOST'], '.'));
+  for ($i = count($uri) - 1; $i > 0; $i--) {
+    for ($j = count($server); $j > 0; $j--) {
+      $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i));
+      if (file_exists("$confdir/$dir/settings.php")) {
+        $conf = "$confdir/$dir";
+        return $conf;
+      }
+    }
+  }
+  $conf = "$confdir/default";
+  return $conf;
+}
+
+function drupal_bootstrap($phase = 0) {
+  global $conf;
+  static $done = -1;
+
+  if (!is_numeric($phase)) {
+    $phase = array_search($phase, array('database', 'session', 'common'));
+  }
+  if (!isset($db_url)) {
+    unset($conf);
+    include_once conf_init() .'/settings.php';
+  }
+  for (; $done <= $phase; $done++) {
+    _drupal_bootstrap($done);
+  }
+}
+
+function _drupal_bootstrap($phase) {
+  switch ($phase) {
+    case 0:
+      include_once 'includes/database.inc';
+      include_once 'includes/bootstrap.inc';
+      $conf = variable_init(isset($conf) ? $conf : array());
+      // Initialize the default database.
+      db_set_active();
+      break;
+    case 1:
+      include_once conf_init() .'/settings_ini_set.php';
+      include_once 'includes/session.inc';
+      session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc");
+      session_start();
+      break;
+    case 2:
+      include_once 'includes/common.inc';
+      // Set the Drupal custom error handler.
+      set_error_handler('error_handler');
+      // Emit the correct charset HTTP header.
+      drupal_set_header('Content-Type: text/html; charset=utf-8');
+      // Initialize $_GET['q'] prior to loading modules and invoking hook_init().
+      if (!empty($_GET['q'])) {
+        $_GET['q'] = drupal_get_normal_path(trim($_GET['q'], '/'));
+      }
+      else {
+        $_GET['q'] = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
+      }
+      // Initialize all enabled modules.
+      module_init();
+      if (!user_access('bypass input data check')) {
+        // We can't use $_REQUEST because it consists of the contents of $_POST,
+        // $_GET and $_COOKIE: if any of the input arrays share a key, only one
+        // value will be verified.
+        if (!valid_input_data($_GET)
+        || !valid_input_data($_POST)
+        || !valid_input_data($_COOKIE)
+        || !valid_input_data($_FILES)) {
+          die('Terminated request because of suspicious input data.');
+        }
+      }
+      // Initialize the localization system.
+      $locale = locale_initialize();
+      break;
+  }
+}
+
+?>
\ No newline at end of file
diff -r'uNF^f' -x CVS includes/session.inc drupal.new/includes/session.inc
--- includes/session.inc	2005-05-04 19:50:21.614406872 +0200
+++ drupal.new/includes/session.inc	2005-05-04 19:08:58.931831992 +0200
@@ -6,9 +6,6 @@
  * User session handling functions.
  */
 
-session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc");
-session_start();
-
 /*** Session functions *****************************************************/
 
 function sess_open($save_path, $session_name) {
diff -r'uNF^f' -x CVS includes/theme.inc drupal.new/includes/theme.inc
--- includes/theme.inc	2005-05-04 19:50:21.620405960 +0200
+++ drupal.new/includes/theme.inc	2005-05-04 19:08:58.931831992 +0200
@@ -34,6 +34,7 @@
 function init_theme() {
   global $user, $custom_theme, $theme_engine, $theme_key;
 
+  drupal_bootstrap('database');
   $themes = list_themes();
 
   // Only select the user selected theme if it is available in the
diff -r'uNF^f' -x CVS index.php drupal.new/index.php
--- index.php	2005-05-04 19:50:21.622405656 +0200
+++ drupal.new/index.php	2005-05-04 19:08:58.927832600 +0200
@@ -9,10 +9,18 @@
  * prints the appropriate page.
  */
 
-include_once 'includes/bootstrap.inc';
+include_once 'includes/init.inc';
+include_once 'includes/module.inc';
+drupal_bootstrap('session');
 drupal_page_header();
-include_once 'includes/common.inc';
-
+drupal_bootstrap('common');
+include_once 'includes/theme.inc';
+include_once 'includes/pager.inc';
+include_once 'includes/menu.inc';
+include_once 'includes/tablesort.inc';
+include_once 'includes/file.inc';
+include_once 'includes/xmlrpc.inc';
+include_once 'includes/image.inc';
 fix_gpc_magic();
 
 $return = menu_execute_active_handler();
diff -r'uNF^f' -x CVS sites/default/settings_ini_set.php drupal.new/sites/default/settings_ini_set.php
--- sites/default/settings_ini_set.php	1970-01-01 01:00:00.000000000 +0100
+++ drupal.new/sites/default/settings_ini_set.php	2005-05-04 19:06:56.158496376 +0200
@@ -0,0 +1,23 @@
+<?php
+/**
+ * PHP settings:
+ *
+ * To see what PHP settings are possible, including whether they can
+ * be set at runtime (ie., when ini_set() occurs), read the PHP
+ * documentation at http://www.php.net/manual/en/ini.php#ini.list
+ * and take a look at the .htaccess file to see which non-runtime
+ * settings are used there. Settings defined here should not be
+ * duplicated there so as to avoid conflict issues.
+ */
+ini_set('arg_separator.output',     '&amp;');
+ini_set('magic_quotes_runtime',     0);
+ini_set('magic_quotes_sybase',      0);
+ini_set('session.cache_expire',     200000);
+ini_set('session.cache_limiter',    'none');
+ini_set('session.cookie_lifetime',  2000000);
+ini_set('session.gc_maxlifetime',   200000);
+ini_set('session.save_handler',     'user');
+ini_set('session.use_only_cookies', 1);
+ini_set('session.use_trans_sid',    0);
+
+?>
\ No newline at end of file
diff -r'uNF^f' -x CVS sites/default/settings.php drupal.new/sites/default/settings.php
--- sites/default/settings.php	2005-04-14 20:34:31.000000000 +0200
+++ drupal.new/sites/default/settings.php	2005-05-04 19:49:45.840845280 +0200
@@ -35,11 +35,11 @@
 /**
  * Database settings:
  *
- * Note that the $db_url variable gets parsed using PHP's built-in
+ * Note that the $GLOBALS['db_url'] variable gets parsed using PHP's built-in
  * URL parser (i.e. using the "parse_url()" function) so make sure
  * not to confuse the parser. If your username, password
  * or database name contain characters used to delineate
- * $db_url parts, you can escape them via URI hex encodings:
+ * $GLOBALS['db_url'] parts, you can escape them via URI hex encodings:
  *
  *   : = %3a   / = %2f   @ = %40
  *   + = %2b   ( = %28   ) = %29
@@ -47,25 +47,25 @@
  *
  * To specify multiple connections to be used in your site (i.e. for
  * complex custom modules) you can also specify an associative array
- * of $db_url variables with the 'default' element used until otherwise
+ * of $GLOBALS['db_url'] variables with the 'default' element used until otherwise
  * requested.
  *
  * You can optionally set prefixes for some or all database table names
- * by using the $db_prefix setting. If a prefix is specified, the table
+ * by using the $GLOBALS['db_prefix'] setting. If a prefix is specified, the table
  * name will be prepended with its value. Be sure to use valid database
  * characters only, usually alphanumeric and underscore. If no prefixes
  * are desired, leave it as an empty string ''.
  *
- * To have all database names prefixed, set $db_prefix as a string:
+ * To have all database names prefixed, set $GLOBALS['db_prefix'] as a string:
  *
- *   $db_prefix = 'main_';
+ *   $GLOBALS['db_prefix'] = 'main_';
  *
- * To provide prefixes for specific tables, set $db_prefix as an array.
+ * To provide prefixes for specific tables, set $GLOBALS['db_prefix'] as an array.
  * The array's keys are the table names and the values are the prefixes.
  * The 'default' element holds the prefix for any tables not specified
  * elsewhere in the array. Example:
  *
- *   $db_prefix = array(
+ *   $GLOBALS['db_prefix'] = array(
  *     'default'   => 'main_',
  *     'users'     => 'shared_',
  *     'sessions'  => 'shared_',
@@ -75,11 +75,11 @@
  *   );
  *
  * Database URL format:
- * $db_url = 'mysql://username:password@localhost/database';
- * $db_url = 'pgsql://username:password@localhost/database';
+ * $GLOBALS['db_url'] = 'mysql://username:password@localhost/database';
+ * $GLOBALS['db_url'] = 'pgsql://username:password@localhost/database';
  */
-$db_url = 'mysql://username:password@localhost/database';
-$db_prefix = '';
+$GLOBALS['db_url'] = 'mysql://username:password@localhost/database';
+$GLOBALS['db_prefix'] = '';
 
 /**
  * Base URL:
@@ -87,7 +87,7 @@
  * The URL of your website's main page. It is not allowed to have
  * a trailing slash; Drupal will add it for you.
  */
-$base_url = 'http://localhost';
+$GLOBALS['base_url'] = 'http://localhost';
 
 /**
  * PHP settings:
@@ -119,7 +119,7 @@
  * the default settings.php. Any configuration setting from the 'variable'
  * table can be given a new value.
  */
-//$conf = array(
+//$GLOBALS['conf'] = array(
 //  'site_name' => 'My Drupal site',
 //  'theme_default' => 'pushbutton',
 //  'anonymous' => 'Visitor'
