View file engine/system/core.php

File size: 3.83Kb
<?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(eregi('\.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');
		
	//Авторизация пользователя и получение его данных
	if (isset ($_SESSION['SESSION_ID']) && isset ($_SESSION['SESSION_PASS'])) {
    	$id_user = intval($_SESSION['SESSION_ID']);
    	$user_ps = $_SESSION['SESSION_PASS'];
	}elseif (isset ($_COOKIE['COOKIE_ID']) && isset ($_COOKIE['COOKIE_PASS'])) {
    	$id_user = intval(base64_decode($_COOKIE['COOKIE_ID']));
    	$_SESSION['SESSION_ID'] = $id_user;
    	$pass_user = md5($_COOKIE['COOKIE_PASS']);
    	$_SESSION['SESSION_PASS'] = $pass_user;
    	$cookauth = true;
	}
		if ($id_user && $pass_user) {
   			$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['SESSION_ID']);
            				unset ($_SESSION['SESSION_PASS']);
           					setcookie('COOKIE_ID', '');
           					setcookie('COOKIE_PASS', '');
           					$id_user = false;
          					$pass_user = false;}
    			}else {
        			unset ($_SESSION['SESSION_ID']);
        			unset ($_SESSION['SESSION_PASS']);
       				setcookie('COOKIE_ID', '');
       				setcookie('COOKIE_PASS', '');
      				$id_user = false;
       				$pass_user = 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); // Выключение неявных сбросов
   
  
   
   
   

?>