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.

173 lines
4.4 KiB

7 years ago
<?php
/**
* AVE.cms
*
* @package AVE.cms
* @version 3.x
* @filesource
4 years ago
* @copyright © 2007-2020 AVE.cms, https://ave-cms.ru
7 years ago
*
* @license GPL v.2
*/
4 years ago
define ('START_MICROTIME', microtime());
7 years ago
define ('START_MEMORY', memory_get_usage());
define ('BASE_DIR', str_replace("\\", "/", dirname(__FILE__)));
7 years ago
7 years ago
//-- Проверяем уставлена ли CMS
if (! @filesize(BASE_DIR . '/config/db.config.php'))
7 years ago
{
7 years ago
header ('Location:install/index.php');
7 years ago
exit;
}
7 years ago
//-- Если в запросе пришел вызов thumbnail
//-- подключаем файл обработки thumbnail
7 years ago
if (! empty($_REQUEST['thumb']))
{
7 years ago
require (BASE_DIR . '/inc/thumb.php');
7 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');
$MDetect = new Mobile_Detect;
5 years ago
4 years ago
$init_start = microtime();
7 years ago
7 years ago
//-- Подключаем файл инициализации
7 years ago
require (BASE_DIR . '/inc/init.php');
7 years ago
5 years ago
$GLOBALS['block_generate']['INIT']['END'] = number_format(microtime_diff($init_start, microtime()), 3, ',', ' ') . ' sec';
7 years ago
Debug::startTime('CODEEND');
7 years ago
//-- Проверяем нет ли в запросе папки UPLOADS_DIR
//-- подключаем файл для работы thumbsnail
7 years ago
if (strpos ($_SERVER['REQUEST_URI'], ABS_PATH . UPLOAD_DIR . '/') === 0)
7 years ago
{
7 years ago
require (BASE_DIR . '/inc/thumb.php');
7 years ago
exit;
}
7 years ago
//-- Папка с шаблонами для Smarty
7 years ago
$AVE_Template = new AVE_Template(BASE_DIR . '/templates/');
7 years ago
//-- Подключаем ядро системы
7 years ago
require (BASE_DIR . '/class/class.core.php');
4 years ago
7 years ago
$AVE_Core = new AVE_Core;
7 years ago
//-- Проверям на вызов внешних модулей и системных блоков
if (
empty ($_REQUEST['module'])
||
empty ($_REQUEST['sysblock'])
||
empty ($_REQUEST['request'])
)
7 years ago
$AVE_Core->coreUrlParse($_SERVER['REQUEST_URI']);
4 years ago
$GLOBALS['page_id'] = [(isset($_REQUEST['id'])
7 years ago
? $_REQUEST['id']
: '')
4 years ago
=> ['page' => floatval(0)]];
7 years ago
7 years ago
//-- Если пришел вызов на показ ревизии документа
7 years ago
if (! empty($_REQUEST['revission']))
{
5 years ago
$sql = "
7 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();
7 years ago
$res = @unserialize($res);
$flds = get_document_fields((int)$_REQUEST['id'], $res);
}
7 years ago
//-- Собираем страницу
7 years ago
$AVE_Core->coreSiteFetch(get_current_document_id());
5 years ago
Debug::startTime('CONTENT');
7 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();
7 years ago
Debug::$_document_content = $content;
Debug::startTime('EVALCONTENT');
7 years ago
eval (' '.'?>' . $content . '<?'.'php ');
7 years ago
$GLOBALS['block_generate']['DOCUMENT']['EVALCONTENT'] = Debug::endTime('EVALCONTENT');
7 years ago
$render = ob_get_clean();
7 years ago
unset ($content);
7 years ago
4 years ago
Registry::clean();
7 years ago
//-- Ловим 404 ошибку
7 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);
7 years ago
}
7 years ago
//-- Постраничка
7 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);
7 years ago
else
7 years ago
header ('Location:' . ABS_PATH . $AVE_Core->curentdoc->document_alias . URL_SUFF);
7 years ago
exit;
}
5 years ago
$GLOBALS['block_generate']['DOCUMENT']['CONTENT'] = Debug::endTime('CONTENT');
$GLOBALS['block_generate']['INIT']['CODEEND'] = Debug::endTime('CODEEND');
5 years ago
7 years ago
//-- Вывод конечного результата
4 years ago
output_compress($render);
$AVE_DB->Close();