-
Notifications
You must be signed in to change notification settings - Fork 2
/
bootstrap.inc
49 lines (39 loc) · 1.34 KB
/
bootstrap.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
use Drupal\Core\DrupalKernel;
require_once 'core/includes/bootstrap.inc';
unl_bootstrap($request);
function unl_bootstrap($request) {
unl_bootstrap_multisite_without_symlinks($request);
}
function unl_bootstrap_multisite_without_symlinks($request) {
$original_script_name = $request->server->get('SCRIPT_NAME');
$php_file = basename($original_script_name);
$request_uri = parse_url($request->server->get('REQUEST_URI'));
$path_parts = explode('/', $request_uri['path']);
foreach ($path_parts as $path_index => $path_part) {
if (!$path_part) {
unset($path_parts[$path_index]);
}
}
$previous_conf_path = '';
$previous_script_name = '';
for ($i = count($path_parts); $i >= 0; $i--) {
if ($i == 0) {
$script_name = '/' . $php_file;
}
else {
$script_name = '/' . implode('/', array_slice($path_parts, 0, $i)) . '/' . $php_file;
}
$request->server->set('SCRIPT_NAME', $script_name);
$conf_path = DrupalKernel::findSitePath($request);
if ($previous_conf_path && ($conf_path != $previous_conf_path)) {
$request->server->set('SCRIPT_NAME', $previous_script_name);
break;
}
if ($request->server->get('SCRIPT_NAME') == $original_script_name) {
break;
}
$previous_conf_path = $conf_path;
$previous_script_name = $request->server->get('SCRIPT_NAME');
}
}