| 1 |
<?php
|
| 2 |
# Script to include Drupal in the CLI
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Include Drupal!
|
| 6 |
*/
|
| 7 |
function installer_include_drupal($site = NULL) {
|
| 8 |
global $drupal_dir, $argv;
|
| 9 |
unset($GLOBALS['base_url']);
|
| 10 |
|
| 11 |
if ($site) {
|
| 12 |
$_SERVER['HTTP_HOST'] = $site;
|
| 13 |
}
|
| 14 |
elseif ($site_arg = parse_dash_arguments('site')) {
|
| 15 |
$_SERVER['HTTP_HOST'] = $site_arg;
|
| 16 |
}
|
| 17 |
else {
|
| 18 |
return FALSE;
|
| 19 |
}
|
| 20 |
|
| 21 |
$php_self_tmp = $_SERVER['PHP_SELF'];
|
| 22 |
$script_name_tmp = $_SERVER['SCRIPT_NAME'];
|
| 23 |
|
| 24 |
$_SERVER['PHP_SELF'] = '/index.php'; //set the domain
|
| 25 |
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
| 26 |
|
| 27 |
$cwd = getcwd();
|
| 28 |
chdir($drupal_dir);
|
| 29 |
include_once('includes/bootstrap.inc');
|
| 30 |
//test if the domain is existing!
|
| 31 |
if (function_exists('conf_init')) {
|
| 32 |
if(strstr(conf_init(),'default')) {
|
| 33 |
//We do not have a proer domain. And we should not test the default instalation on failure
|
| 34 |
return FALSE;
|
| 35 |
}
|
| 36 |
//Drupal included sucessfull!
|
| 37 |
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
|
| 38 |
$here_i_am = $drupal_dir . base_path();
|
| 39 |
}
|
| 40 |
|
| 41 |
chdir($cwd);
|
| 42 |
$_SERVER['PHP_SELF'] = $php_self_tmp;
|
| 43 |
$_SERVER['SCRIPT_NAME'] = $script_name_tmp;
|
| 44 |
|
| 45 |
return $here_i_am;
|
| 46 |
}
|
| 47 |
|
| 48 |
return installer_include_drupal();
|
| 49 |
?>
|