Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Устанавливаем уровень ошибок и стратуем сессии
- error_reporting(E_ALL &~E_NOTICE);
- session_start();
- ob_implicit_flush(0);
- //Создаем константы с путями
- define("BASE_DIR", $_SERVER['DOCUMENT_ROOT'] . "/"); //Индексный путь
- define("TPL_DIR", BASE_DIR . "template/"); //Путь к папке с шаблоном
- define("SYS_DIR", BASE_DIR . "system/"); //Путь к системной папке
- define("SYS_KEY", true); //Создаем ключ для того чтоб к чичтемным файлам не обратились на прямую
- $mod = $_GET['mod'];
- //Подключаем файлы настроек.
- require SYS_DIR . 'data/db.php';
- require SYS_DIR . 'data/config.php';
- //файл соеденения с БД
- require SYS_DIR . 'classes/mysql.class.php';
- //Экземпляр соеденения с БД
- $mysql = new mysql;
- //Подключаем файл роутера
- require SYS_DIR . 'router.php';
- //Подключаем файлы с классами
- require SYS_DIR . 'classes/template.class.php';
- require SYS_DIR . 'classes/bbcodes.class.php';
- $router = new router; //Создаем экземпляр роутера
- $template = new template; //Создаем экземпляр класса template
- $bbcode = new BBcode; //Создаем экземпляр класса BBcode
- $tpl['main'] = ''; //Перемменная с главным шаблоном сайта
- if(isset($_COOKIE['user_hash']))
- {
- $hash = htmlspecialchars($_COOKIE['user_hash']);
- $select_user = $mysql->query("SELECT `id` FROM `users` WHERE `hash`='". $hash ."' and `activation`='1'");
- if(mysql_num_rows($select_user) > 0)
- {
- $group = $router->user_group($_COOKIE['user_hash']);
- if($config['work_site'] == "off")
- {
- if($group['view_offsite'] == 0)
- {
- $tpl['main'] = $config['work_offsite_text'];
- }
- }
- $user = true;
- }
- else
- {
- if($config['work_site'] == "off")
- {
- $tpl['main'] = $config['work_offsite_text'];
- }
- $user = false;
- }
- }
- if(isset($mod))
- {
- switch($mod)
- {
- case "news":
- require SYS_DIR . 'classes/news.class.php';
- $news = new news;
- $main = $news->view($user);//Модуль показа новостей
- break;
- case "category":
- $main = $router->category($user,$mysql); //Модуль показа категории
- break;
- default:
- $main = $router->GetPage($_GET['mod'],$user,$mysql); //Если указан иной модуль то ищем в папке с модулями файл, с таким именем как у модуля
- break;
- }
- }
- else
- {
- $main = $router->index($user);
- }
- define("TPL_SCRIPTS", $router->get_scripts($mod));
- define("TPL_DESCRIPTION", $main['description']);
- define("TPL_KEYWORDS", $main['keywords']);
- define("TPL_CONTENT", $main['content']);
- define("TPL_TITLE", $main['title']);
- define("TPL_ARHIV", $template->load_usermodul("arhiv"));
- define("TPL_POPNEWS", $template->load_usermodul("pop_news"));
- define("TPL_LOGIN", $template->load_usermodul("login"));
- define("TPL_SEARCH", $template->load_usermodul("search"));
- define("TPL_POLL", $template->load_usermodul("poll"));
- //Создаем массив с кодом для замены блоков в шаблоне
- $tpl_replace = array
- (
- '{content}' => TPL_CONTENT,
- '{poll}' => TPL_POLL,
- '{popnews}' => TPL_POPNEWS,
- '{search}' => TPL_SEARCH,
- '{login}' => TPL_LOGIN,
- '{arhives}' => TPL_ARHIV,
- '{title}' => TPL_TITLE,
- '{engine_scripts}' => TPL_SCRIPTS,
- '{description}' => TPL_DESCRIPTION,
- '{keywords}' => TPL_KEYWORDS
- );
- if(empty($tpl['main']))
- {
- $tpl['main'] = $template->load_template("main.tpl", $tpl_replace);
- }
- //проверяем, были ли ошибки в результате выполнения скрипта?
- if(isset($_SESSION['engine_error'][0]))
- {
- exit($_SESSION['engine_error'][0]);
- }
- else
- {
- echo $tpl['main'];
- }
Advertisement
Add Comment
Please, Sign In to add comment