expires > time()) { if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { foreach ($answer->Headers() as $header) { if (preg_match("/^Last-Modified: .*/i",$header,$match)) { require_once(CMS_FUNCTIONS_DIR.'date.inc.php'); $lmt = StringToUnixTime($match[1]); $ims = StringToUnixTime($_SERVER['HTTP_IF_MODIFIED_SINCE']); if ($lmt !== -1 && $ims !== -1 && $lmt<=$ims) { NotModifiedAnswer(); exit; } } } } ob_end_clean(); foreach($answer->Headers() as $header) header($header); // Logger($answer); if ($answer->size < 65536) { echo $answer->Content(); } else { $counter = 0; while ($answer->size > $counter) { echo $answer->Content($counter,65536); $counter += 65536; } } exit; } } } $class = PathToClass($path); //var_dump($class);exit; if (!is_object($class)) { NotFoundError($domain, $request); exit; } if (!$class->visitor_permissions['read']) { AccessError($domain, $request); exit; } if ($resource == '') { if (isset($class->resources['default'])) $resource = 'default'; // foreach ($class->resources as $name=>$item) { // $resource = $name; // break; // } if ($resource == '') { NotFoundError($domain, $request); exit; } } if ($resource!='' && !is_object($class->resources[$resource])) { NotFoundError($domain, $request); } $answer = $class->resources[$resource]->Request($class); if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { foreach ($answer->Headers() as $header) { if (preg_match("/^Last-Modified: (.*)/i", $header, $match)) { require_once(CMS_FUNCTIONS_DIR.'date.inc.php'); $lmt = StringToUnixTime($match[1]); $ims = StringToUnixTime($_SERVER['HTTP_IF_MODIFIED_SINCE']); if ($lmt !== -1 && $ims !== -1 && $lmt<=$ims) { NotModifiedAnswer(); if ($answer->expires>0) { CacheFile::Place($answer->combined, $cache_key, $class->path, serialize($answer)); } exit; } } } } ob_end_clean(); foreach($answer->Headers() as $header) header($header); // Logger($answer); if ($answer->size < 65536) { echo $answer->Content(); } else { $counter = 0; while ($answer->size > $counter) { echo $answer->Content($counter,65536); $counter += 65536; } } if ($answer->expires>0) { CacheFile::Place($answer->combined,$cache_key,$class->path,serialize($answer)); } unset($class); exit; function Logger($answer) { include_once('./cms/logger/hit.inc.php'); if (function_exists('loggerHit')) { $request = unquote_string($_SERVER['REDIRECT_URL']); $query = unquote_string($_SERVER['QUERY_STRING']); $url = 'http://vitebskbiker.info' . $request; if ($query != '') $url .= '?' . $query; $ref = unquote_string($_SERVER['HTTP_REFERER']); $ua = unquote_string($_SERVER['HTTP_USER_AGENT']); $ip = unquote_string($_SERVER['HTTP_X_REAL_IP']); $mimeType = 'text/html'; $title = ''; foreach($answer->Headers() as $header) { if (preg_match('/^Content-Type: ([\w-]+\/[\w-]+)/', $header, $match)) { $mimeType = $match[1]; } } if ($mimeType == 'text/html') { if (preg_match('/(.*?)<\/title>/', $answer->Content(0, 1024), $match)) $title = $match[1]; } loggerHit($url, $mimeType, $title, $ref, $ua, $ip); } } function NotModifiedAnswer() { ob_end_clean(); header('HTTP/1.0 304 Not Modified'); return true; } function SystemError() { ob_end_clean(); header ('HTTP/1.0 500 Internal Server Error'); header ('Content-type: text/html'); echo '<HTML>'; echo '<HEAD><TITLE>500 Internal Server Error'; echo ''; echo ''; echo '

Internal Server Error

The server encountered an internal error or'; echo 'misconfiguration and was unable to complete your request.'; echo '

Please contact the server administrator and'; echo 'inform them of the time the error occurred, and anything you might have done'; echo 'that may have caused the error.'; echo '

More information about this error may be available in the server error log.'; echo ''; return true; } function AccessError($domain,$path) { $domain_class = PathToClass('/domains/'.$domain); if (is_object($domain_class) && $domain_class->module == 'domain') { if ($domain_class->e403) { $error_class = PathToClass('/domains/'.$domain.'/'.$domain_class->e403); if ($error_class) { if ($error_class->module == 'html_doc' && isset($error_class->resources['default'])) { $answer = $error_class->resources['default']->Request($error_class); if (is_object($answer)) { ob_end_clean(); header ('HTTP/1.0 403 Forbidden'); foreach($answer->Headers() as $header) header($header); echo $answer->Content(); unset($answer); unset($error_class); unset($domain_class); return true; } } unset($error_class); } } unset($domain_class); } ob_end_clean(); header ('HTTP/1.0 403 Forbidden'); header ('Content-type: text/html'); echo ''; echo ''; echo '403 Forbidden'; echo ''; echo '

Forbidden

'; echo 'You don\'t have permission to access '.$path.' on this server.'; echo ''; return true; } function NotFoundError($domain,$path) { $domain_class = PathToClass('/domains/'.$domain); if (is_object($domain_class) && $domain_class->module == 'domain') { if ($domain_class->e404) { $error_class = PathToClass('/domains/'.$domain.'/'.$domain_class->e404); if ($error_class) { if ($error_class->module == 'html_doc' && isset($error_class->resources['default'])) { $answer = $error_class->resources['default']->Request($error_class); if (is_object($answer)) { ob_end_clean(); header ('HTTP/1.0 404 Not Found'); foreach($answer->Headers() as $header) header($header); echo $answer->Content(); unset($answer); unset($error_class); unset($domain_class); return true; } } unset($error_class); } } unset($domain_class); } ob_end_clean(); // header ('Location: http://vitebskbiker.info/'); // return true; header ('HTTP/1.0 404 Not Found'); header ('Content-type: text/html'); echo ''; echo ''; echo '404 Not Found'; echo ''; echo '

Not Found

'; echo '

The requested URL '.$path.' was not found on this server.

'; echo ''; return true; } function DomainsAliases() { $serialized = CacheDb::Get('domains_aliases','/domains'); if (!$serialized || !($aliases = unserialize($serialized))) { $aliases = array(); $domains = PathToClass('/domains'); if (!is_object($domains)) { SystemError(); exit; } foreach($domains->childrens as $children) { if($children->module == 'domain' && is_array($children->aliases) && count($children->aliases)>0) { foreach($children->aliases as $alias) { $aliases[$alias] = $children->name; } } } unset($domains); CacheDb::Place(CACHE_DB_COMBINED_CHAIN,'domains_aliases','/domains',serialize($aliases)); } return $aliases; } ?>