1 | <?php
|
---|
2 | /*************************************************************************/
|
---|
3 | /* Вы можете копировать, распространять данный проект,
|
---|
4 | /* в соответствии с GNU GPL, однако любое изменение кода в целом
|
---|
5 | /* или части кода данного проекта,
|
---|
6 | /* желательно производить с согласования автора проекта.
|
---|
7 | /*
|
---|
8 | /* You may copy, spread the givenned project,
|
---|
9 | /* in accordance with GNU GPL, however any change
|
---|
10 | /* the code as a whole or a part of the code given project,
|
---|
11 | /* advisable produce with co-ordinations of the author of the project
|
---|
12 | /*
|
---|
13 | /* (c) Sasha aka LordSc. lordsc@yandex.ru
|
---|
14 | /*************************************************************************/
|
---|
15 | error_reporting(E_ERROR | E_PARSE | E_WARNING);
|
---|
16 | // error_reporting(E_ALL);
|
---|
17 | define('INCLUDED', true);
|
---|
18 |
|
---|
19 | $time_start = microtime(1);
|
---|
20 | $_SERVER['REQUEST_TIME'] = time();
|
---|
21 |
|
---|
22 | // Config file ...
|
---|
23 | require_once('config.php');
|
---|
24 | // Site functions & classes ...
|
---|
25 | require_once('core/common.php');
|
---|
26 | require_once('core/class.auth.php');
|
---|
27 | require_once('core/dbsimple/Generic.php');
|
---|
28 |
|
---|
29 | global $config;
|
---|
30 | $users_online=array();
|
---|
31 | $guests_online=0;
|
---|
32 | $messages = '';
|
---|
33 | $redirect = '';
|
---|
34 | $sidebarmessages = '';
|
---|
35 | $context_menu = array();
|
---|
36 | // Connetcts to DB
|
---|
37 | // DB layer documentation at http://en.dklab.ru/lib/DbSimple/
|
---|
38 | $DB = DbSimple_Generic::connect("".$config['db_type']."://".$config['db_username'].":".$config['db_password']."@".$config['db_host'].":".$config['db_port']."/".$config['db_name']."");
|
---|
39 | $DB->setErrorHandler('databaseErrorHandler');
|
---|
40 | function databaseErrorHandler($message, $info)
|
---|
41 | {
|
---|
42 | if (!error_reporting()) return;
|
---|
43 | output_message('alert',"SQL Error: $message<br><pre>".print_r($info, true)."</pre>");
|
---|
44 | }
|
---|
45 | $DB->query("SET NAMES ".$config['db_encoding']);
|
---|
46 | // Load settings from db or cache //
|
---|
47 | loadSettings();
|
---|
48 | // Build path vars //
|
---|
49 | $config['site_href'] = str_replace('//','/',str_replace('\\','/',dirname($_SERVER['SCRIPT_NAME']).'/'));
|
---|
50 | $config['site_domain'] = $_SERVER['HTTP_HOST'];
|
---|
51 | $config['base_href'] = 'http://'.$config['site_domain'].''.$config['site_href'];
|
---|
52 | $config['template_href'] = $config['site_href'].'templates/'.$config['template'].'/';
|
---|
53 | // Check lang ======================================
|
---|
54 | if(isset($_COOKIE['Language'])) $config['lang'] = $_COOKIE['Language'];
|
---|
55 | loadLanguages();
|
---|
56 | // ================================================
|
---|
57 |
|
---|
58 | // Load auth system //
|
---|
59 | $auth = new AUTH($DB,$config);
|
---|
60 | $user = $auth->user;
|
---|
61 | // ================== //
|
---|
62 | // Load cached permissions & menu or default...
|
---|
63 | if(file_exists('core/cache/comp_cache.php'))require_once('core/cache/comp_cache.php');
|
---|
64 | else require_once('core/default_components.php');
|
---|
65 |
|
---|
66 | if($user['g_is_admin']==1 || $user['g_is_supadmin']==1){
|
---|
67 | $allowed_ext[] = 'admin';
|
---|
68 | $context_menu[] = array('title'=>'[ Admin panel ]','link'=>'index.php?n=admin');
|
---|
69 | }
|
---|
70 |
|
---|
71 | // for mod_rewrite query_string fix //
|
---|
72 | global $_GETVARS;
|
---|
73 | $req_vars = parse_url($_SERVER['REQUEST_URI']);
|
---|
74 | if(isset($req_vars['query'])){
|
---|
75 | parse_str($req_vars['query'], $req_arr);
|
---|
76 | $_GETVARS = $req_arr;
|
---|
77 | }
|
---|
78 | unset($req_arr,$req_vars);
|
---|
79 | // ======================================================= //
|
---|
80 |
|
---|
81 | if(empty($_GET['p']) OR $_GET['p'] < 1)$p = 1;else $p = $_GET['p'];
|
---|
82 | $ext = (isset($_REQUEST['n'])?$_REQUEST['n']:$config['default_component']);
|
---|
83 | $sub = (isset($_REQUEST['sub'])?$_REQUEST['sub']:'index');
|
---|
84 | $req_tpl = false;
|
---|
85 |
|
---|
86 | if(in_array($ext,$allowed_ext)){
|
---|
87 | // load component
|
---|
88 | require_once('components/'.$ext.'/'.'main.php');
|
---|
89 | if($com_content[$ext]['index'][0] && $user[$com_content[$ext]['index'][0]]!=1)exit('<h2>Forbidden</h2><meta http-equiv=refresh content="3;url=\'./\'">');
|
---|
90 | // ==================== //
|
---|
91 | if(isset($_REQUEST['n']) && isset($lang[$com_content[$ext]['index'][1]]))$pathway_info[] = array('title'=>$lang[$com_content[$ext]['index'][1]],'link'=>$com_content[$ext]['index'][2]);
|
---|
92 | // ==================== //
|
---|
93 | foreach ($com_content[$ext] as $sub_name => $sub_conf){
|
---|
94 | if($sub_conf[4]==1){
|
---|
95 | if($sub_conf[0]){
|
---|
96 | if($user[$sub_conf[0]]==1){
|
---|
97 | $context_menu[] = array('title'=>$lang[$sub_conf[1]],'link'=>$sub_conf[2]);
|
---|
98 | }
|
---|
99 | }else{
|
---|
100 | if(isset($lang[$sub_conf[1]]))$context_menu[] = array('title'=>$lang[$sub_conf[1]],'link'=>$sub_conf[2]);
|
---|
101 | }
|
---|
102 | }
|
---|
103 | }
|
---|
104 | if($sub){
|
---|
105 | if($com_content[$ext][$sub]){
|
---|
106 | if($com_content[$ext][$sub][0]){
|
---|
107 | if($user[$com_content[$ext][$sub][0]]==1){
|
---|
108 | @require_once('components/'.$ext.'/'.$ext.'.'.$sub.'.php');
|
---|
109 | $req_tpl = $ext.'.'.$sub.'.php';
|
---|
110 | }
|
---|
111 | }else{
|
---|
112 | @require_once('components/'.$ext.'/'.$ext.'.'.$sub.'.php');
|
---|
113 | $req_tpl = $ext.'.'.$sub.'.php';
|
---|
114 | }
|
---|
115 | }
|
---|
116 | }
|
---|
117 |
|
---|
118 | if(empty($_GET['nobody'])){
|
---|
119 | require_once('templates/'.$config['template'].'/body_functions.php');
|
---|
120 | require_once('templates/'.$config['template'].'/body_header.php');
|
---|
121 |
|
---|
122 | // DEBUG //
|
---|
123 | if((bool)$config['debuginfo']){
|
---|
124 | output_message('debug','DEBUG://'.$DB->_statistics['count']);
|
---|
125 | output_message('debug','<pre>'.print_r($_SERVER,true).'</pre>');
|
---|
126 | }
|
---|
127 | // =======//
|
---|
128 | if($req_tpl){
|
---|
129 | if(file_exists('templates/'.$config['template'].'/'.$ext.'/'.$req_tpl))
|
---|
130 | require_once('templates/'.$config['template'].'/'.$ext.'/'.$req_tpl);
|
---|
131 | }
|
---|
132 | $time_end = microtime(1);
|
---|
133 | $exec_time = $time_end - $time_start;
|
---|
134 | require_once('templates/'.$config['template'].'/body_footer.php');
|
---|
135 | }else{
|
---|
136 | if(file_exists('templates/'.$config['template'].'/'.$ext.'/'.$req_tpl))
|
---|
137 | require_once('templates/'.$config['template'].'/'.$ext.'/'.$req_tpl);
|
---|
138 | }
|
---|
139 | }else{
|
---|
140 | echo'<h2>Forbidden</h2><meta http-equiv=refresh content="3;url=\'./\'">';
|
---|
141 | }
|
---|
142 | ?>
|
---|