Project

General

Profile

Download (3.18 KB) Statistics
| Branch: | Tag: | Revision:
1 c06f0280 Andreas Kohlbecker
<?php
2
3
/**
4
 * This debug script can be used to debug multisite installations.
5
 * It will print out diagnostic information which can help debugging
6
 * site setup and configuration problems.
7
 * 
8
 * This script should be run with the drush scr (drush php-script) command
9
 * which allows the inclusion of a PHP script file to be loaded after the 
10
 * Drush bootstrap of the Drupal site.
11
 * 
12
 * INSTALLATION:
13
 * 	copy or link this file into the drupal root folder
14
 * 
15
 * USAGE:
16
 * 	In the drupal root folder execute the following drush command
17
 *  
18
 *   	drush -l ${site-ulr} scr ~/drupal_site_debug.php
19
 */
20
$NL="\n";
21
22
global $base_url, $base_path, $base_root;
23
24
require_once('includes/database/database.inc');
25
26
print("=============== GENERAL ===============" . $NL);
27
print("DRUPAL_ROOT: " . DRUPAL_ROOT . $NL);
28
print("base_url: " . $base_url . $NL);
29
print("base_path: " . $base_path . $NL);
30
print("base_root: " . $base_root . $NL);
31
32
$conf = false;
33
34
/* =============================================
35
   this section  is +/- a copy of conf_path()
36
   additional lines are marked with '// DEBUG customization'
37
*/
38
39
$confdir = 'sites';
40
$sites = array();
41
if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/sites.php')) {
42
  // This will overwrite $sites with the desired mappings.
43
  include(DRUPAL_ROOT . '/' . $confdir . '/sites.php');
44
}
45
46
print (">>> sites.php included". $NL);  // DEBUG customization
47
print_r($sites);                        // DEBUG customization
48
print (">>> finding site folder". $NL); // DEBUG customization
49
50
$uri = explode('/', $_SERVER['SCRIPT_NAME'] ? $_SERVER['SCRIPT_NAME'] : $_SERVER['SCRIPT_FILENAME']);
51
$server = explode('.', implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.')))));
52
for ($i = count($uri) - 1; $i > 0; $i--) {
53
  if($conf) break;                      // DEBUG customization
54
  for ($j = count($server); $j > 0; $j--) {
55
    $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i));
56
    if (isset($sites[$dir]) && file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $sites[$dir])) {
57
      $dir = $sites[$dir];
58
      print $NL . ("\ttrying dir $confdir/$dir") . $NL; // DEBUG customization
59
    }
60
61
    $site_folder = DRUPAL_ROOT . '/' . $confdir . '/' . $dir;  // DEBUG customization
62
    print "\t" . $site_folder . (file_exists($site_folder) ? ': OK' : ' : is missing!') . $NL; // DEBUG customization
63
    print "\t" . $site_folder . '/settings.php' . (file_exists($site_folder . '/settings.php') ? ': OK' : ' : is missing!') . $NL; // DEBUG customization
64
65
    if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $dir . '/settings.php') || (!$require_settings && file_exists(DRUPAL_ROOT . '/' . $confdir . '/' . $dir))) {
66
      $conf = "$confdir/$dir";
67
      print $NL . "\t site folder found: " . $conf; // DEBUG customization
68
      break;                                        // DEBUG customization
69
    }
70
  }
71
}
72
/* ============================================= */
73
74
print (">>> resulting site folder"  . $NL); // DEBUG customization
75
print("conf_path: " . conf_path(false) . $NL);
76
77
// TODO this is not working!
78
print "Database connection:" .$NL;
79
print_r(Database::getConnectionInfo());
80
81
82
print("=============== Request ===============" . $NL); 
83
print("q=" . $_REQUEST['q'] . $NL);