-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.php
More file actions
128 lines (102 loc) · 3.89 KB
/
init.php
File metadata and controls
128 lines (102 loc) · 3.89 KB
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
<?php
/** эксцепшены **/
require_once ENGINE_PATH.'/classes/rException.class.php';
/** цепляем, если есть, файл с описанием исключений для сайта **/
if(file_exists(SITE_PATH.'/lib/exceptions.php'))
include_once(SITE_PATH.'/lib/exceptions.php');
if(file_exists(__DIR__.'/vendor/autoload.php')) require_once __DIR__.'/vendor/autoload.php';
require_once(__DIR__.'/init/errorhook.php');
/**
пагнали подключать все необходимое
**/
try{
if(defined('MEMCACHE_PORT') && class_exists('Memcache')){
$_MEMCACHE = new Memcache;
$_MEMCACHE->connect('localhost', MEMCACHE_PORT);
function cache_Memcache($key, $value){
global $_MEMCACHE;
if($value !== null){
$_MEMCACHE->set($key, $value);
}
if($value === null){
return $_MEMCACHE->get($key);
}
}
}
require_once 'core/baseTableModel.class.php';
require_once 'core/baseListModel.class.php';
require_once 'core/baseTreeModel.class.php';
// автоподключение классов
spl_autoload_register(function($class){
if(substr($class, 0, 3) == 'rMy'){
$file2include = $class.'.class.php';
if(file_exists(SITE_PATH.'/lib/'.$file2include))
include_once SITE_PATH.'/lib/'.$file2include;
else
include_once ENGINE_PATH.'/lib/'.$file2include;
}elseif (substr($class, 0, 10) == 'basemodel_') {
$file2include = substr($class, 10).'.class.php';
if(file_exists(SITE_PATH.'/models/base/'.$file2include)){
include_once SITE_PATH.'/models/base/'.$file2include;
return;
}elseif(file_exists(ENGINE_PATH.'/models/base/'.$file2include))
{
include_once ENGINE_PATH.'/models/base/'.$file2include;
return;
} //else echo 'FILE NOT FOUND '.SITE_PATH.'/models/base/'.$file2include;
exit;
}elseif (substr($class, 0, 6) == 'model_') {
$file2include = substr($class, 6).'.class.php';
if(file_exists(SITE_PATH.'/models/'.$file2include)){
include_once SITE_PATH.'/models/'.$file2include;
return;
}elseif(file_exists(ENGINE_PATH.'/models/'.$file2include))
{
include_once ENGINE_PATH.'/models/'.$file2include;
return;
}
}
if(strpos($class, '\\')){
// используем неймспейсы (разложено по каталогам)
$parts = explode('\\', $class);
$file2include = str_replace('\\', DIRECTORY_SEPARATOR, $class).'.class.php';
if(substr(end($parts), 0, 3) == 'rMy'){
if(file_exists(SITE_PATH.'/lib/'.$file2include))
{
include_once SITE_PATH.'/lib/'.$file2include;
}
elseif(file_exists(ENGINE_PATH.'/lib/'.$file2include))
{
include_once ENGINE_PATH.'/lib/'.$file2include;
}
}else{
if (file_exists(ENGINE_PATH.'/classes/'.$file2include)) {
include_once ENGINE_PATH.'/classes/'.$file2include;
}
}
}
});
require_once 'core/rURLHandler.class.php';
require_once 'core/router.class.php';
require_once 'core/dates.class.php';
}catch(dbException $e){
header("Content-Type: text/html; charset=UTF-8");
$info = $e->getInfo();
rSiteNotifier::outputError($info['message'], $info, TEMPLATES_PATH.'/errors/fatal.tpl', 'E_DB_ERROR', true);
}
function formatDateTime($date = 0, $params = array())
{
return ble\Dates::getInstance()->formatDateTime($date, $params);
}
function make_get_string($url, $var, $val = null){
$path = explode('?', $url);
if (!empty($path[1])){
if (preg_match('/'.$var.'(=[^&]*)?/', $path[1])){
$path[1] = preg_replace('/'.$var.'(=[^&]*)?/', $var.(!empty($val) ? '='.$val : ''), $path[1]);
}else{
$path[1] .= '&'.$var.(!empty($val) ? '='.$val : '');
}
return $path[0].'?'.$path[1];
}
return $url.'?'.$var.'='.$val;
}