Размер файла: 4.25Kb
<?php
/*
* Основные компоненты
* SHCMS Engine
*/
if(!defined('SHCMS_ENGINE')) {
die ('Ошибка в доступе');
}
//Стартует сессия
session_name('SHCMS_Engine');
session_start();
define("H", $_SERVER["DOCUMENT_ROOT"].'/');
define("MODULE", '/modules/');
$autoload = opendir(H.'engine/classes/');
while($_autoload = readdir($autoload)) {
if(preg_match('/\.php$/',$_autoload)) {
include_once(H.'engine/classes/'.$_autoload);
}
}
//Проверка версии PHP
engine::php_version();
$filename = H.'engine/config/dbconfig.php';
if (file_exists($filename)) {
include_once H.'engine/config/dbconfig.php';
} else {
header("Location: /install.php");
}
//Установка времени
date_default_timezone_set('ETC/GMT'.-4);
define(PROFILE,'/modules/view.php');
function clean_url($url) {
if( $url == '' ) return;
$url = str_replace( "http://", "", strtolower( $url ) );
$url = str_replace( "https://", "", $url );
if( substr( $url, 0, 4 ) == 'www.' ) $url = substr( $url, 4 );
$url = explode( '/', $url );
$url = reset( $url );
$url = explode( ':', $url );
$url = reset( $url );
return $url;
}
$id_user = false;
$user_ps = false;
if(isset($_SESSION['user_id_shcms'])&& isset($_SESSION['password_shcms'])) {
//Auth SHCMS
$id_user = abs(intval($_SESSION['user_id_shcms']));
$user_ps = $_SESSION['password_shcms'];
}elseif(isset($_COOKIE['cuser_id_shcms']) && isset($_COOKIE['cpassword_shcms'])) {
//Auth COOKIE
$id_user = abs(intval(base64_decode(engine::trim($_COOKIE['cuser_id_shcms']))));
$_SESSION['user_id_shcms'] = $id_user;
$user_ps = engine::shgen(engine::trim($_COOKIE['cpassword_shcms']));
$_SESSION['password_shcms'] = $user_ps;
}
if ($id_user && $user_ps) {
$req = $db->query("SELECT * FROM `users` WHERE `id` = '".$id_user."' LIMIT 1");
if ($db->num_rows($req)) {
$datauser = $db->get_row($req);
if ($user_ps === $datauser['password']) {
$login = $datauser['nick'];
}else {
unset ($_SESSION['user_id_shcms']);
unset ($_SESSION['password_shcms']);
setcookie('user_id_shcms', '');
setcookie('password_shcms', '');
$id_user = false;
$user_ps = false;}
}else {
unset ($_SESSION['user_id_shcms']);
unset ($_SESSION['password_shcms']);
setcookie('user_id_shcms', '');
setcookie('password_shcms', '');
$id_user = false;
$user_ps = false;
}
}
//Системные настройки
$glob_core = $db->get_array($db->query("SELECT * FROM `system_settings`"));
//Выводим данные пользователя
$users = $db->get_array($db->query("SELECT * FROM `users` WHERE `id` = '".$id_user."'"));
$user = new user;
//Права пльзователя
$user_group = $user->users($id_user,array('group'));
if (!isset ( $act ) AND isset ($_REQUEST['act']) ) $act = engine::totranslit ( $_REQUEST['act'] ); elseif(isset ( $act )) $act = engine::totranslit ( $act ); else $act = "";
if (!isset ( $do ) AND isset ($_REQUEST['do']) ) $do = engine::totranslit ( $_REQUEST['do'] ); elseif(isset ( $do )) $do = engine::totranslit ( $do ); else $do = "";
if (!isset ( $active ) AND isset ($_REQUEST['active']) ) $active = engine::totranslit ( $_REQUEST['active'] ); elseif(isset ( $active )) $active = engine::totranslit ( $active ); else $active = "";
//Определение языка
Lang::setLang('ru');
//Если $id пользователь онлайн то каждый его переход будет время посещение сайта увеличится
$db->query('UPDATE `users` SET `lastdate` = "'.time().'" WHERE `id` = "'.$users['id'].'"');
user::limit_auth($glob_core['un_limit']);
@ob_start(); //Включение буферизации вывода
@ob_implicit_flush(0); // Выключение неявных сбросов
?>