define("ONSTART",true); define ("ERROR", E_USER_WARNING); session_start(); include_once($_SERVER['DOCUMENT_ROOT'].'/modules/main/classes/function.php'); set_error_handler("myError"); include_once($_SERVER['DOCUMENT_ROOT'].'/modules/main/classes/db_client.class.php'); $db = new db_client(); if(!$db->db_hadnle) { die('Ошибка соединения с базой данных.'); } include_once($_SERVER['DOCUMENT_ROOT'].'/modules/main/classes/user.class.php'); include_once($_SERVER['DOCUMENT_ROOT'].'/modules/main/classes/cash.class.php'); include_once($_SERVER['DOCUMENT_ROOT'].'/modules/main/classes/tree.class.php'); include_once($_SERVER['DOCUMENT_ROOT'].'/modules/main/classes/modules.class.php'); include_once($_SERVER['DOCUMENT_ROOT'].'/modules/main/classes/admin_panel.class.php'); $printable = false; if(isset($_GET['path']) && substr_count($_GET['path'], '/printableversion') ) { $_GET['path'] = str_replace('/printableversion','',$_GET['path']); $printable = true; } if(GetValueDB('lock_site') ) { include_once($_SERVER['DOCUMENT_ROOT'].'/admin/lock_site.php'); exit(); } $Module = new module(); $User = new user(); $AccessClass = new access(); $User->CookieAuth(); if(isset($_GET['logout'])) { user::Logout(); header('Location: /'); die(); } if(isset($_POST['act'])) { $User->Login($_POST['login'],$_POST['pass'],isset($_POST['cookie'])); } $AdminPanel = new admin_panel(); $treeClass = new tree(); if(!isset($_GET['path'])) { $path='/index'; } else { if(substr($_GET['path'],0,9)=='index.php') { $path='/index'.substr($_GET['path'],9); } else { $path='/'.$_GET['path']; } } $template_default = GetValueDB('template_default'); $__FULL_PATH=$path; $__PARAM = array(); $cur_page = $path; $pageInfo = $treeClass->getNodeByPath($cur_page, 1, array('type')); while (!($pageInfo || $cur_page == '')) { array_unshift($__PARAM,substr($cur_page,strrpos($cur_page,'/')+1)); $cur_page = substr($cur_page, 0, strrpos($cur_page,'/')); if(!strlen($cur_page)) break; $pageInfo = $treeClass->getNodeByPath($cur_page, 1, array('type')); if($pageInfo) { $path = $cur_page; } } if($pageInfo == false || !is_array($pageInfo)) { $pageAccess = 404; } else { $pageAccess = $AccessClass->GetAccesNode($pageInfo['id']); if($pageAccess === false) { $pageAccess = ACCESS_READ; } elseif($pageAccess == ACCESS_CLOSE) { $pageAccess = 404; } } $Content = ""; $Keywords = ""; $Description = ""; $Title = ""; $Name = ""; $H1 = ""; $TmplPath = ""; $edit_page = access::GetAccessMode('main','edit_page'); if($edit_page) { $AdminPanel->add_option_new('/admin/main.php?module=main&page=edit_page&edit_pid='.$pageInfo['id'].'&back=' .urlencode($_SERVER['REQUEST_URI']) ,'Создать страницу в текущем разделе'); } if($pageAccess != 404) { $pageContent = $db->get_one_line_assoc('SELECT html, nodes.title, name,h1, description, keywords,active,template,type_data, page_types.type ,page_types.module FROM nodes LEFT JOIN page_types ON page_types.id = nodes.type WHERE nodes.id='.$pageInfo['id']); if($pageContent['active'] == 1) { $Keywords = $pageContent['keywords']; $Description = $pageContent['description']; $Title = $pageContent['title']; $Name = $pageContent['name']; $H1 = $pageContent['h1']; $Property = array(); $res=$db->query('SELECT property_key,npv.value FROM node_property AS np LEFT JOIN node_property_value AS npv ON (npv.nodes_id='.$pageInfo['id'].' AND np.id=npv.property_id)'); while ($row = mysql_fetch_assoc($res)) { $Property[$row['property_key']] = $row['value']; } if($pageContent['template'] && $pageContent['template'] != 'NULL') { $template_default=$pageContent['template']; } if($pageContent['type'] == 'static') { $AdminPanel->add_option_edit('/admin/main.php?module=main&page=edit_page&edit_id='.$pageInfo['id'].'&back=' .urlencode($_SERVER['REQUEST_URI']) ,'Редактировать страницу'); if($edit_page) { $AdminPanel->add_html('  '); } if(isset($__PARAM[1]) && $__PARAM[0] == 'page') { $Content = delegate($pageContent['html'], $path, $__PARAM[1],$pageInfo['id']); } else { $Content = delegate($pageContent['html'], $path,0,$pageInfo['id']); } } else { function __loadModule($pageContent) { global $db,$_GET,$_POST,$__PARAM,$path,$template_default,$AdminPanel; if(is_file($_SERVER['DOCUMENT_ROOT'].'/modules/'.$pageContent['module'].'/type_page/'.$pageContent['type'].'.php')) { $module = $pageContent['module']; $page_template = $template_default; $pageContent['type_data']; ob_start_my(); $type_data = unserialize($pageContent['type_data']); include($_SERVER['DOCUMENT_ROOT'].'/modules/'.$pageContent['module'].'/type_page/'.$pageContent['type'].'.php'); $template_default = $page_template; return ob_stop_my(); } return false; } $AdminPanel->add_option_edit('/admin/main.php?module=main&page=type_page_edit&edit_id='.$pageInfo['id'].'&back=' .urlencode($_SERVER['REQUEST_URI']),'Редактировать типовую страницу'); $Content = __loadModule($pageContent); if($Content==false) { $pageAccess=404; } } if($pageAccess != 404) { $SiteName = GetValueDB('site_name'); $ImgAlt=$Title.' - '.$SiteName; $Panel=$AdminPanel->get_panel(); if($template_default!=''&&!$printable) { $TmplPath = '/templates/'.$template_default.'/'; } else { if(is_file($_SERVER['DOCUMENT_ROOT'].'/templates/'.$template_default.'/printableversion/template.php')) { $TmplPath = '/templates/'.$template_default.'/printableversion/'; } else { $TmplPath = '/modules/main/template/printableversion/'; } $MailAdmin = GetValueDB('mail_admin'); $SiteDomain = GetValueDB('site_domain'); $BackLink = $__FULL_PATH.'.html'; } $Keywords = ''; $Description = ''; $Title = ''.htmlspecialchars($Title).''; $H1 = '

'.htmlspecialchars($H1).'

'; $Name = htmlspecialchars($Name); $PrintLink = $__FULL_PATH.'/printableversion.html'; $Head= ' '.$Title.$Keywords.$Description.' '; $languages = '
  • Кыргыз тили
  • English language
  • Русский язык
  • '; $BootstrapJS= ' '; global $toHead; if (isset($toHead)) { foreach($toHead as $val) { $Head.=$val; } } include($_SERVER['DOCUMENT_ROOT'].$TmplPath.'template.php'); } } else { $pageAccess=404; } } if($pageAccess==404) { $Content = ""; $Keywords = ""; $Description = ""; $Title = ""; $Name = ""; $H1 = ""; $ImgAlt = ""; if(isset($Property) && is_array($Property)) array_walk($Property,create_function('&$item','$item=\'\';')); @header('HTTP/1.x 404 Not Found'); ob_start_my(); include_once($_SERVER['DOCUMENT_ROOT'].'/404.php'); $Content = ob_stop_my(); $TmplPath = '/templates/404/'; $PrintLink = $__FULL_PATH.'/printableversion.html'; $Panel=$AdminPanel->get_panel(); include($_SERVER['DOCUMENT_ROOT'].$TmplPath.'template.php'); print $AdminPanel->get_tpl_button(); }