-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap.php
89 lines (71 loc) · 2.68 KB
/
bootstrap.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
<?php
/*
* This file is part of CM5 <http://code.0x0lab.org/p/cm5>.
*
* Copyright (c) 2010 Sque.
*
* CM5 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CM5 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with CM5. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Sque - initial API and implementation
*/
require_once __DIR__ . '/lib/vendor/phplibs/ClassLoader.class.php';
require_once __DIR__ . '/lib/tools.lib.php';
/**
* Here you can write code that will be executed at the begining of each page instance
*/
// We are 100% UTF-8
mb_internal_encoding('UTF-8');
// Autoloader for local and phplibs classes
$phplibs_loader = new ClassLoader(
array(
__DIR__ . '/lib/vendor/phplibs',
__DIR__ . '/lib/vendor',
__DIR__ . '/lib/local'
));
$phplibs_loader->set_file_extension('.class.php');
$phplibs_loader->register();
// Zend
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/lib/vendor');
$zend_loader = new ClassLoader(array(__DIR__ . '/lib/vendor'));
$zend_loader->register();
// Load static library for HTML
require_once __DIR__ . '/lib/vendor/phplibs/Output/html.lib.php';
// Load urls library
require_once __DIR__ . '/lib/urls.lib.php';
// Preload enviroment
require_once __DIR__ . '/lib/vendor/phplibs/DB/Conn.class.php';
require_once __DIR__ . '/lib/vendor/CM5/Core.class.php';
// Load configuration file
CM5_Config::$default_config = array(
'module' => array(),
'enabled_modules' => '',
);
CM5_Config::$config_file = __DIR__ . '/config.inc.php';
CM5_Config::load();
$config = CM5_Config::getInstance();
// Database connection
DB_Conn::connect($config->db->host, $config->db->user, $config->db->pass, $config->db->schema, true);
DB_Conn::query('SET NAMES utf8;');
DB_Conn::query("SET time_zone='+0:00';");
DB_Conn::events()->connect('error',
function($e){ error_log( $e->arguments["message"]);
CM5_Logger::getInstance()->crit($e->arguments["message"]); });
//DB_Conn::events()->connect('stmt.executed',
// create_function('$e', ' error_log( $e->arguments[0]); '));
// PHP TimeZone
date_default_timezone_set($config->site->timezone);
// Initialize CMS
$cache_engine = new Cache_File($config->site->cache_folder, 'pages_');
CM5_Core::initialize($cache_engine);