-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.php
61 lines (52 loc) · 1.74 KB
/
init.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
<?php
require_once 'core/Config.class.php';
$conf = new core\Config();
require_once 'config.php';
function &getConf(){global $conf; return $conf;}
require_once 'core/Messages.class.php';
$msgs = new core\Messages();
function &getMessages(){global $msgs; return $msgs;}
require_once 'core/ClassLoader.class.php';
$cloader = new core\ClassLoader();
function &getLoader() {global $cloader; return $cloader;}
require_once 'core/Router.class.php';
$router = new core\Router();
function &getRouter(): core\Router {global $router; return $router;}
$smarty = null;
function &getSmarty(){
global $smarty;
if (!isset($smarty)){
include_once 'lib/smarty/libs/Smarty.class.php';
$smarty = new Smarty();
$smarty->assign('conf',getConf());
$smarty->assign('msgs',getMessages());
$smarty->setTemplateDir(array(
'one' => getConf()->root_path.'/app/views',
'two' => getConf()->root_path.'/app/views/templates'
));
}
return $smarty;
}
$db = null; //przygotuj Medoo, twórz tylko raz - wtedy kiedy potrzeba
function &getDB() {
global $conf, $db;
if (!isset($db)) {
require_once 'lib/medoo/Medoo.php';
$db = new \Medoo\Medoo([
'database_type' => &$conf->db_type,
'server' => &$conf->db_server,
'database_name' => &$conf->db_name,
'username' => &$conf->db_user,
'password' => &$conf->db_pass,
'charset' => &$conf->db_charset,
'port' => &$conf->db_port,
'prefix' => &$conf->db_prefix,
'option' => &$conf->db_option
]);
}
return $db;
}
require_once 'core/functions.php';
session_start();
$conf->roles = isset($_SESSION['_roles']) ? unserialize($_SESSION['_roles']) : array();
$router->setAction( getFromRequest('action') );