<?php header('Content-Type: text/html; charset=utf-8'); date_default_timezone_set('Europe/Moscow'); ini_set('display_errors', 'on'); define('BASE_DIRECTORY', dirname(__FILE__)); define('CACHE_DIRECTORY', dirname(__FILE__) . '/cache'); define('FSTAB', BASE_DIRECTORY . '/fstab.php'); define('ROUTE_FILE', BASE_DIRECTORY . '/etc/route.php'); function query_path() { if (isset($_SERVER['REQUEST_URI'])) { return $_SERVER['REQUEST_URI']; } } $_SERVER['REDIRECT_QUERY_STRING'] = query_path(); define('RAW_HTTP_STRING', $_SERVER['REDIRECT_QUERY_STRING']); function bu_getHostName() { if (isset($_SERVER['HTTP_HOST'])) { return $_SERVER['HTTP_HOST']; } return 'test'; } define('HTTP_HOST', bu_getHostName()); if (stristr(PHP_OS, 'WIN')) { set_include_path('.;' . BASE_DIRECTORY); } else { set_include_path('.:' . BASE_DIRECTORY); }
if (count($ext) > 1) { return $ext[count($ext) - 1]; } return ''; } function getMime($ext) { include 'boot/mime_types.php'; if (!array_key_exists($ext, $mimeTypes)) { $mime = 'application/octet-stream'; } else { $mime = $mimeTypes[$ext]; } return $mime; } $url = str_replace('/public', '', query_path()); $ext = getExt($url); $mime = getMime($ext); function getFile($url) { $hostDir = BuCore::fstab('staticHostDir') . '/' . HTTP_HOST; $prjDir = BuCore::fstab('staticPrj'); $coreDir = BuCore::fstab('staticCore'); foreach (array($hostDir, $prjDir, $coreDir) as $v) { if (file_exists($v . $url)) { return $v . $url; } } } $file = getFile($url); if ($file) {
require_once 'vendor/autoload.php'; ob_start(); require_once 'lib/prj/cache.php'; include 'base.php'; include 'boot/spyc.php'; #библиотека для парсинга конфигов include 'boot/bu_core.php'; include 'boot/bu_cache.php'; include 'boot/bu.php'; #магический класс который управляет всем-всем include 'boot/bu_route.php'; include 'boot/bu_loader.php'; include 'boot/bu_url.php'; include 'boot/bu_statistic.php'; include 'boot/bu_logger.php'; bu::timer('init', 'system'); bu::hook(['preload', 'blank']); BuLoader::setHttpString(RAW_HTTP_STRING); bu::timer('Aplication start.', 'system'); BuLoader::doIt(); bu::timer('Aplication end.', 'system'); bu::hook(['postload', 'blank']); $content = ob_get_contents(); ob_end_clean(); if (http_host() == 'local.bubujka.org:3000') { is_need_cache(false); } if (is_need_cache()) { cache_it(query_path(), $content); } echo $content;