function locate_root in Production check & Production monitor 6
Same name and namespace in other branches
- 7 prod_check.dbconnect.php \locate_root()
Locate the actual Drupal root. Based on drush_locate_root().
1 call to locate_root()
- prod_check.dbconnect.php in ./
prod_check.dbconnect.php - Simple database connection check that can be placed anywhere within a Drupal installation. Does NOT need to be in the root where index.php resides!
File
- ./
prod_check.dbconnect.php, line 12 - Simple database connection check that can be placed anywhere within a Drupal installation. Does NOT need to be in the root where index.php resides!
Code
function locate_root() {
$drupal_root = FALSE;
$start_path = isset($_SERVER['PWD']) ? $_SERVER['PWD'] : '';
if (empty($start_path)) {
$start_path = getcwd();
}
foreach (array(
TRUE,
FALSE,
) as $follow_symlinks) {
$path = $start_path;
if ($follow_symlinks && is_link($path)) {
$path = realpath($path);
}
// Check the start path.
if (valid_root($path)) {
$drupal_root = $path;
break;
}
else {
// Move up dir by dir and check each.
while ($path = shift_path_up($path)) {
if ($follow_symlinks && is_link($path)) {
$path = realpath($path);
}
if (valid_root($path)) {
$drupal_root = $path;
break 2;
}
}
}
}
return $drupal_root;
}