-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
134 lines (99 loc) · 2.91 KB
/
index.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* =================================================================================
*
* VIZU CMS
* Simple, dependency-free CMS system that allows for quick implementation of
* simple one-pages without having to configure anything in the administration panel.
*
* ---------------------------------------------------------------------------------
*
* @see https://github.com/peronczyk/vizu
* @author Bartosz Perończyk <[email protected]>
*
* =================================================================================
*/
define('VIZU_VERSION', '2.0.2');
define('__ROOT__', __DIR__);
/**
* Load application base configuration
*/
(file_exists('config.php'))
? require_once 'config.php'
: die('Configuration file does not exist.');
if (file_exists('config-override.php')) {
require_once 'config-override.php';
}
if (file_exists('config-override-dev.php')) {
require_once 'config-override-dev.php';
}
/**
* Class autoloader
*/
require_once Config::$APP_DIR . 'autoload.php';
/**
* Start core libraries
*/
$core = new Core();
$router = new Router();
/**
* Load theme configuration
*/
$theme_configuration_file = Config::$THEMES_DIR . Config::$THEME_NAME . '/config-theme.php';
if (!file_exists($theme_configuration_file)) {
Core::error('Theme configuration file is missing', __FILE__, __LINE__, debug_backtrace());
}
$theme_config = require_once $theme_configuration_file;
/**
* Redirects based on configuration and enviroment
*/
if (Config::$REDIRECT_TO_WWW) {
$router->redirectToWww();
}
/**
* Load configured database handler library.
*/
switch (Config::$DB_TYPE) {
case 'SQLite':
$db = new SQLite(
Config::$STORAGE_DIR . 'database/' . Config::$SQLITE_FILE_NAME,
Core::isDebugMode()
);
break;
case 'MySQL':
$db = new MySQL(Config::$MYSQL_HOST, Config::$MYSQL_USER, Config::$MYSQL_PASS, Config::$MYSQL_NAME);
break;
default:
Core::error('Unknown database handler: ' . Config::$DB_NAME);
}
/**
* Setup dependancy container
*/
$dependency_container = new DependencyContainer();
$dependency_container
->add($router)
->add($db);
/**
* Start language library and set active language If user is not in installation process.
*/
if (!in_array($router->getFirstRequest(), ['admin', 'install'])) {
try {
$result = $db->query('SELECT * FROM `languages`');
$lang_list = $db->fetchAll($result);
}
catch (Exception $e) {
Core::error('Languages database table does not exist. Probably application was not installed properly. Please run <a href="' . $router->site_path . '/install/">installation</a> process.', __FILE__, __LINE__, debug_backtrace());
}
$lang = new Language($router, $db);
$lang->setList($lang_list);
$lang->autoSetLanguage();
$lang->loadThemeTranslations();
$dependency_container->add($lang);
}
/**
* Load the module based on the page address
*/
$module_to_load = $router->getModuleToLoad();
if ($module_to_load) {
require_once $module_to_load;
}