FAILED' : 'PASSED'; return theme('image', drupal_get_path('module','subdomain') ."/images/icon_$file_suffix.png",NULL,NULL,array('style'=>"float:left;margin-right:5px;")) ." $suffix"; } function subdomain_check_server() { $output = "SUBDOMAIN TEST\n"; $output.= $_SERVER['HTTP_HOST'] ."\n"; $output.= ltrim(request_uri(),'/') ."\n"; // Use Drupal API's request URI, since REQUEST_URI Apache only $output.= ltrim($_SERVER['QUERY_STRING'], 'q=') ."\n"; $output.= $_SERVER['SCRIPT_FILENAME'] ."\n"; $output.= $_REQUEST['q']; print $output; exit; } function subdomain_check_apache_details($url, $results) { $rows[] = array('HTTP_HOST:', $results[1]); $rows[] = array('QUERY_STRING:', $results[2]); $rows[] = array('REQUEST_URI:', $results[3]); $rows[] = array('SCRIPT_FILENAME:', $results[4]); $rows[] = array('drupal_get_normal_path:', $results[5]); $output = "

HTTP request to $url returned the following result:

"; $output.= theme('table', array(), $rows); return $output; } function subdomain_check_watchdog_lastid() { return db_result(db_query("SELECT max(wid) FROM {watchdog}")); } function subdomain_check_server_results($results = NULL) { static $test_results; if (isset($results)) { $test_results = explode("\n", $results); } return $test_results; } function subdomain_check_apache() { $domain = subdomain_base_domain(); $host = "subdomain-test.$domain"; $url = "http://$host". parse_url($GLOBALS['base_url'], PHP_URL_PATH) .'/subdomain/test'; // Store watchdog count so we can check for errors after http attempt $old_watchdog_lastid = subdomain_check_watchdog_lastid(); $page = drupal_http_request($url); $page = $page->code == 200 ? $page->data : NULL; $lines = subdomain_check_server_results($page); // Check for any errors (assumes 1 error for now) $new_watchdog_lastid = subdomain_check_watchdog_lastid(); if ($new_watchdog_lastid > $old_watchdog_count) { $result = db_result(db_query("SELECT variables FROM {watchdog} WHERE wid = %d AND type = 'php'", $new_watchdog_lastid)); $error = unserialize($result); $error404 = strpos($error['%message'], '404') !== FALSE ? TRUE : FALSE; } $result = subdomain_check_apache_details($url, $lines); if ($lines[0] == 'SUBDOMAIN TEST' && $lines[1] == $host && $lines[3] == 'subdomain/test') { return array('error' => FALSE, 'output' => $result); } else { if ($lines[0] != 'SUBDOMAIN TEST') { if ($error404) { $output = "

$url returned a '404 Page not found' error.

"; } else { $output.= $result; } $output.= '

Your web server is not routing subdomains to your Drupal directory.

'; $output.= "Possible Solutions:"; $output.= ""; } elseif ($lines[1] != $host) { $output = $result; $output.= "Your web server erased the subdomain and rewrote $host as $domain."; $output.= "

Possible solutions:

"; $output.= "