forked from flack/openpsa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrootfile.php
117 lines (95 loc) · 2.89 KB
/
rootfile.php
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
$GLOBALS['midcom_config_local'] = array();
// Check that the environment is a working one
if (extension_loaded('midgard2'))
{
if (!class_exists('midgard_topic'))
{
throw new Exception('You need to install OpenPSA MgdSchemas from the "schemas" directory to the Midgard2 schema directory');
}
// Initialize the $_MIDGARD superglobal
$_MIDGARD = array
(
'argv' => array(),
'user' => 0,
'admin' => false,
'root' => false,
'auth' => false,
'cookieauth' => false,
// General host setup
'page' => 0,
'debug' => false,
'host' => 0,
'style' => 0,
'author' => 0,
'config' => array
(
'prefix' => '',
'quota' => false,
'unique_host_name' => 'openpsa',
'auth_cookie_id' => 1,
),
'schema' => array
(
),
);
$GLOBALS['midcom_config_local']['person_class'] = 'openpsa_person';
$midgard = midgard_connection::get_instance();
// Workaround for https://github.com/midgardproject/midgard-php5/issues/49
if (!$midgard->is_connected())
{
$config = new midgard_config();
$config->read_file_at_path(ini_get('midgard.configuration_file'));
$midgard->open_config($config);
}
if (method_exists($midgard, 'enable_workspace'))
{
$midgard->enable_workspace(false);
}
// workaround for segfaults that might have something to do with https://bugs.php.net/bug.php?id=51091
// see also https://github.com/midgardproject/midgard-php5/issues/50
if ( function_exists('gc_enabled')
&& gc_enabled())
{
gc_disable();
}
}
else if (!extension_loaded('midgard'))
{
throw new Exception("OpenPSA requires Midgard PHP extension to run");
}
// Path to the MidCOM environment
define('MIDCOM_ROOT', __DIR__ . '/lib');
$prefix = dirname($_SERVER['SCRIPT_NAME']) . '/';
if (strpos($_SERVER['REQUEST_URI'], $prefix) !== 0)
{
$prefix = '/';
}
define('OPENPSA2_PREFIX', $prefix);
header('Content-Type: text/html; charset=utf-8');
$GLOBALS['midcom_config_local']['theme'] = 'OpenPsa2';
if (file_exists(MIDCOM_ROOT . '/../config.inc.php'))
{
include MIDCOM_ROOT . '/../config.inc.php';
}
else
{
//TODO: Hook in an installation wizard here, once it is written
include MIDCOM_ROOT . '/../config-default.inc.php';
}
if (! defined('MIDCOM_STATIC_URL'))
{
define('MIDCOM_STATIC_URL', '/openpsa2-static');
}
if (file_exists(MIDCOM_ROOT . '/../themes/' . $GLOBALS['midcom_config_local']['theme'] . '/config.inc.php'))
{
include MIDCOM_ROOT . '/../themes/' . $GLOBALS['midcom_config_local']['theme'] . '/config.inc.php';
}
// Include the MidCOM environment for running OpenPSA
require MIDCOM_ROOT . '/midcom.php';
// Start request processing
$midcom = midcom::get();
$midcom->codeinit();
$midcom->content();
$midcom->finish();
?>