AVE.CMS v3.28
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
4.6 KiB

8 years ago
<?php
/**
* AVE.cms
*
* @package AVE.cms
* @version 3.x
* @filesource
4 years ago
* @copyright © 2007-2020 AVE.cms, https://ave-cms.ru
8 years ago
*
* @license GPL v.2
*/
5 years ago
define ('START_MICROTIME', microtime(true));
7 years ago
define ('START_MEMORY', memory_get_usage());
define ('BASE_DIR', str_replace("\\", "/", dirname(__FILE__)));
8 years ago
7 years ago
//-- Проверяем уставлена ли CMS
if (! @filesize(BASE_DIR . '/config/db.config.php'))
8 years ago
{
7 years ago
header ('Location:install/index.php');
8 years ago
exit;
}
7 years ago
//-- Если в запросе пришел вызов thumbnail
//-- подключаем файл обработки thumbnail
8 years ago
if (! empty($_REQUEST['thumb']))
{
7 years ago
require (BASE_DIR . '/inc/thumb.php');
8 years ago
exit;
}
ob_start();
7 years ago
//-- Подключаем файл определения мобильных устройств
5 years ago
//-- далее пользуемся $MobileDetect
7 years ago
require_once (BASE_DIR . '/lib/mobile_detect/Mobile_Detect.php');
5 years ago
$MobileDetect = new Mobile_Detect;
$init_start = microtime(true);
8 years ago
7 years ago
//-- Подключаем файл инициализации
7 years ago
require (BASE_DIR . '/inc/init.php');
8 years ago
5 years ago
$GLOBALS['block_generate']['INIT']['END'] = number_format(microtime_diff($init_start, microtime()), 3, ',', ' ') . ' sec';
8 years ago
7 years ago
//-- Проверяем нет ли в запросе папки UPLOADS_DIR
//-- подключаем файл для работы thumbsnail
7 years ago
if (strpos ($_SERVER['REQUEST_URI'], ABS_PATH . UPLOAD_DIR . '/') === 0)
8 years ago
{
7 years ago
require (BASE_DIR . '/inc/thumb.php');
8 years ago
exit;
}
7 years ago
//-- Папка с шаблонами для Smarty
8 years ago
$AVE_Template = new AVE_Template(BASE_DIR . '/templates/');
7 years ago
//-- Подключаем ядро системы
7 years ago
require (BASE_DIR . '/class/class.core.php');
8 years ago
$AVE_Core = new AVE_Core;
7 years ago
//-- Проверям на вызов внешних модулей и системных блоков
if (
empty ($_REQUEST['module'])
||
empty ($_REQUEST['sysblock'])
||
empty ($_REQUEST['request'])
)
8 years ago
$AVE_Core->coreUrlParse($_SERVER['REQUEST_URI']);
$GLOBALS['page_id'] = array((isset($_REQUEST['id'])
? $_REQUEST['id']
: '')
5 years ago
=> ['page' => floatval(0)]);
8 years ago
7 years ago
//-- Если пришел вызов на показ ревизии документа
8 years ago
if (! empty($_REQUEST['revission']))
{
5 years ago
$sql = "
8 years ago
SELECT
doc_data
FROM
" . PREFIX . "_document_rev
WHERE
doc_id = '" . (int)$_REQUEST['id'] . "'
AND
doc_revision = '" . (int)$_REQUEST['revission'] . "'
LIMIT 1
5 years ago
";
$res = $AVE_DB->Query($sql)->GetCell();
8 years ago
$res = @unserialize($res);
$flds = get_document_fields((int)$_REQUEST['id'], $res);
}
7 years ago
//-- Собираем страницу
8 years ago
$AVE_Core->coreSiteFetch(get_current_document_id());
5 years ago
Debug::startTime('CONTENT');
8 years ago
$content = ob_get_clean();
7 years ago
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && (defined('GZIP_COMPRESSION') && GZIP_COMPRESSION))
7 years ago
ob_start('ob_gzhandler');
else
ob_start();
8 years ago
7 years ago
eval (' '.'?>' . $content . '<?'.'php ');
8 years ago
$render = ob_get_clean();
7 years ago
unset ($content);
8 years ago
4 years ago
Registry::clean();
7 years ago
//-- Ловим 404 ошибку
8 years ago
if (isset($_REQUEST['id']) AND ($_REQUEST['id']) == PAGE_NOT_FOUND_ID)
{
report404();
7 years ago
header ($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true);
8 years ago
}
7 years ago
//-- Постраничка
8 years ago
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)
7 years ago
header ('Location:' . ABS_PATH);
8 years ago
else
7 years ago
header ('Location:' . ABS_PATH . $AVE_Core->curentdoc->document_alias . URL_SUFF);
8 years ago
exit;
}
7 years ago
//-- Тут заменяем [tag:rubheader]
//-- на собранный $GLOBALS["user_header"]
7 years ago
$rubheader = (empty($GLOBALS['user_header'])
? ''
: implode(chr(10), $GLOBALS['user_header']));
8 years ago
7 years ago
//-- Тут заменяем [tag:rubfooter]
//-- на собранный $GLOBALS["user_footer"]
7 years ago
$rubfooter = (empty($GLOBALS['user_footer'])
? ''
: implode(chr(10), $GLOBALS['user_footer']));
5 years ago
$render = str_replace(['[tag:rubheader]', '[tag:rubfooter]'], [$rubheader, $rubfooter], $render);
7 years ago
unset ($rubheader, $rubfooter);
5 years ago
$GLOBALS['block_generate']['DOCUMENT']['CONTENT'] = Debug::endTime('CONTENT');
7 years ago
//-- Вывод конечного результата
7 years ago
output_compress($render);