'; echo var_dump(\DB::$DB,MYSQL_ADMIN,MYSQL_BASE); echo ''; */ // Потом проверяем, а какой у нас домен. //if(count($a)==2 and !in_array($_SERVER['HTTP_HOST'],['module.bz','cmsbuilder.in'])){ if(!$C) { if (count($a) == 2 || (count($a) == 3 && $a[0] == 'www') || (count($a) == 3 ) || (count($a) == 4 && is_numeric($a[3])) // Типа ip ) { if ((count($a) == 3 && $a[0] == 'www')) { array_shift($a); \Site::redirect301(self::$protocol . implode(".", $a).$_SERVER['REQUEST_URI']); } if (count($a) == 3 ) { $r = Domain::select([ \Query::WHERE => new \Where(\Where::_or([ \Where::_operator(Domain::$DOMAIN, '=', $a[1].'.'.$a[2]), //\Where::_operator(Domain::$DOMAIN, '=', $a[0].'.'.$a[1].'.'.$a[2]), ]) ), \Query::COUNT => 1, ], true); if ($r) { $id = array_pop($r)[Domain::$PORTAL]; if ($id) { $C = Portal::getByID($id); } } } // Если это главный портал, и если это админка, то идём в админку if ((in_array($_SERVER['HTTP_HOST'], ['module.bz', 'module.in']) and $arr[0] == Config::$ADMIN_PAGE) or $arr[0] == Config::$ADMIN_PAGE) { } else { $r = Domain::select([ \Query::WHERE => new \Where(\Where::_operator(Domain::$DOMAIN, '=', $_SERVER['HTTP_HOST'])), \Query::COUNT => 1, ], true); if ($r) { $id = array_pop($r)[Domain::$PORTAL]; if ($id) { $C = Portal::getByID($id); } } } } } if(in_array($_SERVER['HTTP_HOST'],\Core::$CLIENT_DOMAINS) and ($arr[0]!=Config::$ADMIN_PAGE) ){ $C = Portal::getByID($_SERVER['HTTP_HOST']=='module.bz'?10:1); } if($C) { self::$portal = $C; $portal = $C; self::$portal_id = $portal_id = $C[Portal::$ID]; // Тут получаем информацию о теме в зависимости от того, в каком мы разделе $section = null; if(isset($_POST['_section_path'])){ $section = Section::getByPath($_POST['_section_path'],$portal_id); } if(!$section) { $section = Section::getByPath($arr[0],$portal_id); } if(!$section) { $section = Section::getByPath("",$portal_id); } self::$section = $section; self::$section_id = $section[Section::$ID]; self::$owner_id = $section[Section::$ACCOUNT]; $theme = Theme::init( $section[Section::$THEME] , json_decode( $section[Section::$DATA] ,true ), self::$owner_id ); Profile::init($portal_id); self::$theme = $theme; self::$themeName = strtolower($theme::$name); self::$themeUrl = $theme::$themeUrl; self::$sectionUrl = '/'.(($c = $section[Section::$PATH])?$c.'/':''); if($section[Section::$PATH]){ array_shift($arr); } $theme::prepare(); //Profile::init($portal_id); //Theme::prepare(); //$theme::prepare(); } // Если это не портал if(! $portal ) { switch ($arr[0]) { case 'pm': //self::$theme = 'pm'; self::$themeUrl = '/pm/'; self::$sectionUrl = '/pm/'; array_shift($arr); break; case Config::$ADMIN_PAGE: //self::$theme = 'admin'; self::$themeUrl = '/admin/'; array_shift($arr); break; case 'msto': //self::$theme = 'msto'; self::$themeUrl = '/msto/'; array_shift($arr); break; case 'sova': //self::$theme = 'bws.sova'; self::$themeUrl = '/sova/'; array_shift($arr); break; } } } self::$URL = $arr; self::$absPath = Core::$FOLDER.'/content/' . self::$themeUrl . '/'; self::$themeAbsPath = '/content/' . self::$themeUrl . '/'; self::$themeIndex = self::$absPath . 'index.php'; if($portal) { $full_url = self::portalUrl( $_SERVER['REQUEST_URI'] ,true); $full_path = str_replace("?".$_SERVER['REDIRECT_QUERY_STRING'],"",$full_url); // Проверяем ссылку на редирект if($c = $portal[Portal::$REDIRECT]){ $a = explode("\n",$c); $redirects = []; foreach ($a as $v){ $v = str_replace("\t"," ",$v); $v = explode(" ",$v); $redirects[$v[0]] = $v[1]; } if($c = $redirects[$full_url]) {\Site::redirect301($c); exit;} if($c = $redirects[$full_path]) {\Site::redirect301($c); exit;} } // Проверяем ссылку switch (self::$URL[0]){ case 'robots.txt': header("Content-Type: text/plain"); echo $portal[Portal::$ROBOTS_TXT]; exit; case 'sitemap.xml': //* header("Content-Type: text/xml"); //header("Expires: Thu, 19 Feb 1998 13:24:18 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Cache-Control: post-check=0,pre-check=0"); header("Cache-Control: max-age=0"); header("Pragma: no-cache"); /**/ echo self::$theme->getSitemap(); exit; case 'yml.xml': //* header("Content-Type: text/xml"); //header("Expires: Thu, 19 Feb 1998 13:24:18 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Cache-Control: post-check=0,pre-check=0"); header("Cache-Control: max-age=0"); header("Pragma: no-cache"); /**/ echo self::$theme->getYML(); exit; case 'merchant.txt': self::$theme->echoMerchant(); exit; case 'merchant.xml': self::$theme->echoMerchantXML(); exit; case 'turbo.xml': self::$theme->getTurbo()->echoXml(); exit; case 'turbo_shop.xml': header("Content-Type: text/xml"); //header("Expires: Thu, 19 Feb 1998 13:24:18 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Cache-Control: post-check=0,pre-check=0"); header("Cache-Control: max-age=0"); header("Pragma: no-cache"); echo self::$theme->getTurboShop(); exit; } // Теперь проверим, вдруг это код верификации if(count($arr)==1 ) { $url = $arr[0]; $filename = ''; $v1 = substr($url,-5,5); if($v1=='.html') $filename = substr($url,0,-5); $v2 = substr($url,-4,4); $v3 = substr($url,-3,3); if($v2=='.htm') $filename = substr($url,0,-4); if($v2=='.xml') $filename = substr($url,0,-4); if($v2=='.txt') $filename = substr($url,0,-4); if($v1=='.json') $filename = substr($url,0,-5); if($v3=='.js') { header("Content-Type: application/javascript"); $filename = substr($url,0,-3); } $filename = (string)trim($filename); if($filename){ $r = Verify::select([ \Query::COUNT => 1, \Query::WHERE => new \Where(\Where::_and([ \Where::_operator(Verify::$PORTAL,'=',self::$portal_id), \Where::_operator(Verify::$FILENAME,'=',$filename), ])) ],true); if($r) { $l = array_pop($r); echo $l[Verify::$TEXT]; exit; } } } if($isModuleSite) { $domains = Domain::getByPortal($C[Portal::$ID]); if ($domains) { $domain = array_shift($domains); \Site::redirect301('http://' . $domain[Domain::$DOMAIN] . $_SERVER['REQUEST_URI']); exit; } } } } static function render(){ if(file_exists(self::$themeIndex)) { include_once(self::$themeIndex); } } }