/
bootstrap.inc.php
74 lines (59 loc) · 1.9 KB
/
bootstrap.inc.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
<?php
/**
* @file bootstrap.inc.php
*
* Initialize the application (there is no link with the Twitter Boostrap stuff
* though).
*
* NOTE:
* Be careful to avoid global environment pollution (in other word, do NOT
* set any variable).
*
* @author
* Alexandre Perrin <alexandre.perrin@netoxygen.ch>
*/
// define some constants for local paths
define('PROJECTDIR', dirname(__FILE__));
define('APPDIR', PROJECTDIR . '/app');
define('WEBDIR', PROJECTDIR . '/web');
// self-explanatory
require_once(PROJECTDIR . '/compat/all.inc.php');
// load Composer stuff
require_once(PROJECTDIR . '/vendor/autoload.php');
// initialize no2 framework.
require_once(PROJECTDIR . '/no2/no2.inc.php');
// get the config stuff
require_once(APPDIR . '/config.class.php');
AppConfig::parse(PROJECTDIR . '/config/config.yml',
array(
'{{APPDIR}}' => APPDIR,
'{{PROJECTDIR}}' => PROJECTDIR,
'{{WEBDIR}}' => WEBDIR,
)
);
// load the application's models.
require_once(APPDIR . '/models/user.class.php');
// load the application's helpers.
require_once(APPDIR . '/help.inc.php');
// set the timezone
date_default_timezone_set(AppConfig::get('l10n.default_timezone'));
// start the logger
if (!No2_Logger::setup(AppConfig::get('logger'))) {
error_log('unable to setup Logger');
}
// connect to the database.
No2_SQLQuery::setup(AppConfig::get('database'));
// try our best to hide the fact that we still use PHP in the 21th century.
if (function_exists('header_remove')) {
header_remove('X-Powered-By'); // PHP 5.3+
} else {
@ini_set('expose_php', 'off');
}
// start the session
session_set_cookie_params(
0, /* http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime */
dirname($_SERVER['SCRIPT_NAME'])
);
session_start() or die('session_start()');
// setup the translation stuff (must be after the session stuff!)
create_translator(current_locale());