--- C:\Users\Edward\Webs\drupal\includes\bootstrap.inc 2008-01-15 23:25:59.136000000 -0500 +++ C:\Users\Edward\Webs\drupal\includes\bootstrap.inc.formatted 2008-01-16 00:04:03.396000000 -0500 @@ -1,6 +1,7 @@ 0; $i--) { for ($j = count($server); $j > 0; $j--) { $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i)); @@ -272,15 +284,15 @@ */ function conf_init() { global $base_url, $base_path, $base_root; - + // Export the following settings.php variables to the global namespace global $db_url, $db_prefix, $cookie_domain, $conf, $installed_profile, $update_free_access; $conf = array(); - + if (file_exists('./'. conf_path() .'/settings.php')) { include_once './'. conf_path() .'/settings.php'; } - + if (isset($base_url)) { // Parse fixed base URL from settings.php. $parts = parse_url($base_url); @@ -294,11 +306,11 @@ else { // Create base URL $base_root = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; - + // As $_SERVER['HTTP_HOST'] is user input, ensure it only contains // characters allowed in hostnames. $base_url = $base_root .= '://'. preg_replace('/[^a-z0-9-:._]/i', '', $_SERVER['HTTP_HOST']); - + // $_SERVER['SCRIPT_NAME'] can, in contrast to $_SERVER['PHP_SELF'], not // be modified by a visitor. if ($dir = trim(dirname($_SERVER['SCRIPT_NAME']), '\,/')) { @@ -310,7 +322,7 @@ $base_path = '/'; } } - + if ($cookie_domain) { // If the user specifies the cookie domain, also use it for session name. $session_name = $cookie_domain; @@ -318,7 +330,7 @@ else { // Otherwise use $base_url as session name, without the protocol // to use the same session identifiers across http and https. - list( , $session_name) = explode('://', $base_url, 2); + list(, $session_name) = explode('://', $base_url, 2); // We escape the hostname because it can be modified by a visitor. if (!empty($_SERVER['HTTP_HOST'])) { $cookie_domain = check_plain($_SERVER['HTTP_HOST']); @@ -369,11 +381,11 @@ */ function drupal_get_filename($type, $name, $filename = NULL) { static $files = array(); - + if (!isset($files[$type])) { $files[$type] = array(); } - + if (!empty($filename) && file_exists($filename)) { $files[$type][$name] = $filename; } @@ -391,9 +403,9 @@ // Fallback to searching the filesystem if the database connection is // not established or the requested file is not found. $config = conf_path(); - $dir = (($type == 'theme_engine') ? 'themes/engines' : "${type}s"); - $file = (($type == 'theme_engine') ? "$name.engine" : "$name.$type"); - + $dir = (($type == 'theme_engine') ? 'themes/engines' : "${type}s"); + $file = (($type == 'theme_engine') ? "$name.engine" : "$name.$type"); + foreach (array("$config/$dir/$file", "$config/$dir/$name/$file", "$dir/$file", "$dir/$name/$file") as $file) { if (file_exists($file)) { $files[$type][$name] = $file; @@ -401,7 +413,7 @@ } } } - + if (isset($files[$type][$name])) { return $files[$type][$name]; } @@ -426,11 +438,11 @@ } cache_set('variables', $variables); } - + foreach ($conf as $name => $value) { $variables[$name] = $value; } - + return $variables; } @@ -441,12 +453,13 @@ * The name of the variable to return. * @param $default * The default value to use if this variable has never been set. + * * @return * The value of the variable. */ function variable_get($name, $default) { global $conf; - + return isset($conf[$name]) ? $conf[$name] : $default; } @@ -461,15 +474,15 @@ */ function variable_set($name, $value) { global $conf; - + $serialized_value = serialize($value); db_query("UPDATE {variable} SET value = '%s' WHERE name = '%s'", $serialized_value, $name); if (!db_affected_rows()) { @db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, $serialized_value); } - + cache_clear_all('variables', 'cache'); - + $conf[$name] = $value; } @@ -481,14 +494,13 @@ */ function variable_del($name) { global $conf; - + db_query("DELETE FROM {variable} WHERE name = '%s'", $name); cache_clear_all('variables', 'cache'); - + unset($conf[$name]); } - /** * Retrieve the current page from the cache. * @@ -497,17 +509,17 @@ */ function page_get_cache() { global $user, $base_root; - + $cache = NULL; - + if (!$user->uid && $_SERVER['REQUEST_METHOD'] == 'GET' && count(drupal_set_message()) == 0) { $cache = cache_get($base_root . request_uri(), 'cache_page'); - + if (empty($cache)) { ob_start(); } } - + return $cache; } @@ -538,20 +550,20 @@ */ function drupal_load($type, $name) { static $files = array(); - + if (isset($files[$type][$name])) { return TRUE; } - + $filename = drupal_get_filename($type, $name); - + if ($filename) { include_once "./$filename"; $files[$type][$name] = TRUE; - + return TRUE; } - + return FALSE; } @@ -584,28 +596,30 @@ // Set default values: $last_modified = gmdate('D, d M Y H:i:s', $cache->created) .' GMT'; $etag = '"'. md5($last_modified) .'"'; - + // See if the client has provided the required HTTP headers: $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE; $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : FALSE; - + if ($if_modified_since && $if_none_match - && $if_none_match == $etag // etag must match - && $if_modified_since == $last_modified) { // if-modified-since must match + // etag must match + && $if_none_match == $etag + // if-modified-since must match + && $if_modified_since == $last_modified) { header('HTTP/1.1 304 Not Modified'); // All 304 responses must send an etag if the 200 response for the same object contained an etag header("Etag: $etag"); exit(); } - + // Send appropriate response: header("Last-Modified: $last_modified"); header("ETag: $etag"); - + // The following headers force validation of cache: header("Expires: Sun, 19 Nov 1978 05:00:00 GMT"); header("Cache-Control: must-revalidate"); - + if (variable_get('page_compression', TRUE)) { // Determine if the browser accepts gzipped data. if (@strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === FALSE && function_exists('gzencode')) { @@ -616,7 +630,7 @@ header('Content-Encoding: gzip'); } } - + // Send the original request's headers. We send them one after // another so PHP's header() function can deal with duplicate // headers. @@ -624,7 +638,7 @@ foreach ($headers as $header) { header($header); } - + print $cache->data; } @@ -699,6 +713,7 @@ * * @param $text * The text to check. + * * @return * TRUE if the text is valid UTF-8, FALSE if not. */ @@ -714,7 +729,7 @@ * generate an equivalent using other environment variables. */ function request_uri() { - + if (isset($_SERVER['REQUEST_URI'])) { $uri = $_SERVER['REQUEST_URI']; } @@ -729,7 +744,7 @@ $uri = $_SERVER['SCRIPT_NAME']; } } - + return $uri; } @@ -755,21 +770,21 @@ */ function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL) { global $user, $base_root; - + // Prepare the fields to be logged $log_message = array( - 'type' => $type, - 'message' => $message, - 'variables' => $variables, - 'severity' => $severity, - 'link' => $link, - 'user' => $user, + 'type' => $type, + 'message' => $message, + 'variables' => $variables, + 'severity' => $severity, + 'link' => $link, + 'user' => $user, 'request_uri' => $base_root . request_uri(), - 'referer' => referer_uri(), - 'ip' => ip_address(), - 'timestamp' => time(), - ); - + 'referer' => referer_uri(), + 'ip' => ip_address(), + 'timestamp' => time(), + ); + // Call the logging hooks to log/process the message foreach (module_implements('watchdog', TRUE) as $module) { module_invoke($module, 'watchdog', $log_message); @@ -799,16 +814,16 @@ if (!isset($_SESSION['messages'])) { $_SESSION['messages'] = array(); } - + if (!isset($_SESSION['messages'][$type])) { $_SESSION['messages'][$type] = array(); } - + if ($repeat || !in_array($message, $_SESSION['messages'][$type])) { $_SESSION['messages'][$type][] = $message; } } - + // messages not set when DB connection fails return isset($_SESSION['messages']) ? $_SESSION['messages'] : NULL; } @@ -820,6 +835,7 @@ * (optional) Only return messages of this type. * @param $clear_queue * (optional) Set to FALSE if you do not want to clear the messages queue + * * @return * An associative array, the key is the message type, the value an array * of messages. If the $type parameter is passed, you get only that type, @@ -861,6 +877,7 @@ * @param $mask string * String or mask to test: '_' matches any character, '%' matches any * number of characters. + * * @return bool * TRUE if access is denied, FALSE if access is allowed. */ @@ -912,7 +929,7 @@ */ function drupal_bootstrap($phase) { static $phases = array(DRUPAL_BOOTSTRAP_CONFIGURATION, DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE, DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_ACCESS, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE, DRUPAL_BOOTSTRAP_LANGUAGE, DRUPAL_BOOTSTRAP_PATH, DRUPAL_BOOTSTRAP_FULL), $phase_index = 0; - + while ($phase >= $phase_index && isset($phases[$phase_index])) { $current_phase = $phases[$phase_index]; unset($phases[$phase_index++]); @@ -922,9 +939,8 @@ function _drupal_bootstrap($phase) { global $conf; - + switch ($phase) { - case DRUPAL_BOOTSTRAP_CONFIGURATION: drupal_unset_globals(); // Start a page timer: @@ -932,7 +948,7 @@ // Initialize the configuration conf_init(); break; - + case DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE: // Allow specifying special cache handlers in settings.php, like // using memcached or files for storing cache information. @@ -945,13 +961,13 @@ exit; } break; - + case DRUPAL_BOOTSTRAP_DATABASE: // Initialize the default database. require_once './includes/database.inc'; db_set_active(); break; - + case DRUPAL_BOOTSTRAP_ACCESS: // Deny access to hosts which were banned - t() is not yet available. if (drupal_is_denied('host', ip_address())) { @@ -960,13 +976,13 @@ exit(); } break; - + case DRUPAL_BOOTSTRAP_SESSION: require_once variable_get('session_inc', './includes/session.inc'); session_set_save_handler('sess_open', 'sess_close', 'sess_read', 'sess_write', 'sess_destroy_sid', 'sess_gc'); session_start(); break; - + case DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE: // Initialize configuration variables, using values from settings.php if available. $conf = variable_init(isset($conf) ? $conf : array()); @@ -992,17 +1008,17 @@ // Prepare for non-cached page workflow. drupal_page_header(); break; - + case DRUPAL_BOOTSTRAP_LANGUAGE: drupal_init_language(); break; - + case DRUPAL_BOOTSTRAP_PATH: require_once './includes/path.inc'; // Initialize $_GET['q'] prior to loading modules and invoking hook_init(). drupal_init_path(); break; - + case DRUPAL_BOOTSTRAP_FULL: require_once './includes/common.inc'; _drupal_bootstrap_full(); @@ -1040,7 +1056,7 @@ */ function drupal_init_language() { global $language, $user; - + // Ensure the language is correctly returned, even without multilanguage support. // Useful for eg. XML/HTML 'lang' attributes. if (variable_get('language_count', 1) == 1) { @@ -1060,12 +1076,12 @@ */ function language_list($field = 'language', $reset = FALSE) { static $languages = NULL; - + // Reset language list if ($reset) { $languages = NULL; } - + // Init language list if (!isset($languages)) { if (variable_get('language_count', 1) > 1 || module_exists('locale')) { @@ -1080,7 +1096,7 @@ $languages['language'][$default->language] = $default; } } - + // Return the array indexed by the right field if (!isset($languages[$field])) { $languages[$field] = array(); @@ -1104,7 +1120,7 @@ * Optional property of the language object to return */ function language_default($property = NULL) { - $language = variable_get('language_default', (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '')); + $language = variable_get('language_default', (object)array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '')); return $property ? $language->$property : $language; } @@ -1118,7 +1134,7 @@ */ function ip_address() { static $ip_address = NULL; - + if (!isset($ip_address)) { $ip_address = $_SERVER['REMOTE_ADDR']; if (variable_get('reverse_proxy', 0) && array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) { @@ -1132,6 +1148,7 @@ } } } - + return $ip_address; } +