forked from avecms/AVE.cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·154 lines (126 loc) · 4.11 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
/**
* AVE.cms
*
* @package AVE.cms
* @version 3.x
* @filesource
* @copyright © 2007-2016 AVE.cms, http://www.ave-cms.ru
*
* @license GPL v.2
*/
define('START_MICROTIME', microtime());
define('START_MEMORY', memory_get_usage());
define('BASE_DIR', str_replace("\\", "/", dirname(__FILE__)));
// Проверяем уставлена ли CMS
if (! @filesize(BASE_DIR . '/inc/db.config.php'))
{
header('Location:install/index.php');
exit;
}
// Если в запросе пришел вызов thumbnail
// подключаем файл обработки thumbnail
if (! empty($_REQUEST['thumb']))
{
require(BASE_DIR . '/inc/thumb.php');
exit;
}
ob_start();
// Подключаем файл определения мобильных устройств
// далее пользуемся $MDetect
require_once(BASE_DIR . '/lib/mobile_detect/Mobile_Detect.php');
$MDetect = new Mobile_Detect;
// Подключаем файл инициализации
require(BASE_DIR . '/inc/init.php');
unset($GLOBALS['CMS_CONFIG']);
// Проверяем нет ли в запросе папки UPLOADS_DIR
// подключаем файл для работы thumbsnail
if (strpos($_SERVER['REQUEST_URI'], ABS_PATH . UPLOAD_DIR . '/') === 0)
{
require(BASE_DIR . '/inc/thumb.php');
exit;
}
// Папка с шаблонами для Smarty
$AVE_Template = new AVE_Template(BASE_DIR . '/templates/');
// Подключаем ядро системы
require(BASE_DIR . '/class/class.core.php');
$AVE_Core = new AVE_Core;
// Проверям на вызов внешних модулей и системных блоков
if (empty($_REQUEST['module']) || empty($_REQUEST['sysblock']) || empty($_REQUEST['request']))
$AVE_Core->coreUrlParse($_SERVER['REQUEST_URI']);
$GLOBALS['page_id'] = array((isset($_REQUEST['id'])
? $_REQUEST['id']
: '')
=> array('apage' => floatval(0)));
// Если пришел вызов на показ ревизии документа
if (! empty($_REQUEST['revission']))
{
$res = $AVE_DB->Query("
SELECT
doc_data
FROM
" . PREFIX . "_document_rev
WHERE
doc_id = '" . (int)$_REQUEST['id'] . "'
AND
doc_revision = '" . (int)$_REQUEST['revission'] . "'
LIMIT 1
")->GetCell();
$res = @unserialize($res);
$flds = get_document_fields((int)$_REQUEST['id'], $res);
}
// Собираем страницу
$AVE_Core->coreSiteFetch(get_current_document_id());
$content = ob_get_clean();
ob_start();
eval('?>' . $content . '<?');
$render = ob_get_clean();
unset($content);
// Ловим 404 ошибку
if (isset($_REQUEST['id']) AND ($_REQUEST['id']) == PAGE_NOT_FOUND_ID)
{
report404();
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true);
}
// Постраничка
if (
empty($_REQUEST['module']) &&
(
(
isset($_REQUEST['page'])
&& is_numeric($_REQUEST['page'])
&& ($_REQUEST['page'] < 2 OR ($_REQUEST['page'] > @$GLOBALS['page_id'][$_REQUEST['id']]['page']))
)
OR
(
isset($_REQUEST['apage'])
&& is_numeric($_REQUEST['apage'])
&& ($_REQUEST['apage'] < 2 OR ($_REQUEST['apage'] > @$GLOBALS['page_id'][$_REQUEST['id']]['apage']))
)
OR
(
isset($_REQUEST['artpage'])
&& is_numeric($_REQUEST['artpage'])
&& ($_REQUEST['artpage'] < 2 OR ($_REQUEST['artpage'] > @$GLOBALS['page_id'][$_REQUEST['id']]['artpage']))
)
)
)
{
if ($_REQUEST['id'] == 1)
header('Location:' . ABS_PATH);
else
header('Location:' . ABS_PATH . $AVE_Core->curentdoc->document_alias . URL_SUFF);
exit;
}
// Тут заменяем [tag:rubheader]
// на собранный $GLOBALS["user_header"]
$rubheader = (empty($GLOBALS["user_header"])
? ""
: implode(chr(10), $GLOBALS["user_header"]));
$render = str_replace('[tag:rubheader]', $rubheader, $render);
//Вывод конечного результата
echo $render;
//Вывод статистики загрузки и запросов SQL (только для администраторов)
if (! defined('ONLYCONTENT') && UGROUP == 1 && defined('PROFILING') && PROFILING)
echo get_statistic(1, 1, 1, 1);
?>