<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<?php //K0XA's SERVER CONF FILE

//&#1085;&#1091;&#1078;&#1085;&#1086; &#1090;&#1086;&#1083;&#1100;&#1082;&#1086; &#1076;&#1083;&#1103; &#1086;&#1075;&#1088;&#1072;&#1085;&#1080;&#1095;&#1077;&#1085;&#1080;&#1081; &#1087;&#1088;&#1077;&#1076;&#1087;&#1088;&#1086;&#1089;&#1084;&#1086;&#1090;&#1088;&#1072; &#1085;&#1072; &#1089;&#1077;&#1088;&#1074;&#1077;&#1088;&#1077;

//&#1077;&#1089;&#1083;&#1080; &#1074;&#1072;&#1089; &#1089;&#1084;&#1091;&#1097;&#1072;&#1077;&#1090;, &#1084;&#1086;&#1078;&#1077;&#1090;&#1077; &#1091;&#1073;&#1088;&#1072;&#1090;&#1100;

if (file_exists('/local/php/local_conf.php')) {

	include_once('/local/php/local_conf.php');
	include_once('/local/php/rtools_security.php');

}



$d = '.__route';

$assert['head']=file_exists("$d/head.txt")?file_get_contents("$d/head.txt"):'';

$assert['begin']=file_exists("$d/begin.txt")?file_get_contents("$d/begin.txt"):'';

$assert['end']=file_exists("$d/end.txt")?file_get_contents("$d/end.txt"):'';



$p = $_SERVER['QUERY_STRING'];



if (!$p) $p = 'index.html';

if (preg_match('#^(\/|\.\./)#', $p)||preg_match('#\./\.#',$p)) die_not_found($p);



if (!file_exists($p)  || is_dir($p)) {



	$routes = file_get_contents("$d/route.txt");

	$regex  = preg_quote($p).'\s*=><html><body><p>\s*(.*)';

//die($regex);

	if (preg_match("#\s/$regex#", $routes, $matches)) {

		$routed_file = trim($matches[1]);

		//sdie($routed_file);

		if (file_exists($routed_file)) {

			$page = file_get_contents($routed_file);

		} else {

			 die_not_found($p);

		}

	} else { 

		die_not_found($p);

	}

} else {



	$page = file_get_contents($p);



}







if ($assert['head']) $page = preg_replace('##i', $assert['head'].'', $page);

//if ($assert['begin']) $page = preg_replace('#</p>#i',''.$assert['begin'], $page);
if ($assert['begin']) $page = preg_replace('#()#i','${1}'.$assert['begin'], $page);

if ($assert['end']) $page = preg_replace('##i', $assert['end'].'', $page);







//SAPE &#1085;&#1072; &#1089;&#1077;&#1088;&#1074;&#1077;&#1088;&#1077; k0xa'&#1080; &#1085;&#1077;&#1083;&#1100;&#1079;&#1103; &#1087;&#1086;&#1076;&#1082;&#1083;&#1102;&#1095;&#1080;&#1090;&#1100; &#1074; &#1094;&#1077;&#1083;&#1103;&#1093; &#1073;&#1077;&#1079;&#1086;&#1087;&#1072;&#1089;&#1085;&#1086;&#1089;&#1090;&#1080; :)

//&#1091; &#1074;&#1072;&#1089; &#1078;&#1077; &#1074;&#1089;&#1077; &#1073;&#1091;&#1076;&#1077;&#1090; &#1088;&#1072;&#1073;&#1086;&#1090;&#1072;&#1090;&#1100; &#1054;&#1050;

if (!defined('K0XA_SERVER')) {



	if (file_exists($d.'/sape.php') &amp;&amp; file_exists($d.'/sape_conf.php')) {

		include_once($d.'/sape_conf.php');

		include_once($d.'/sape.php');
//              $sape = new SAPE_client(array('charset'=&gt;'utf-8', 'force_show_code' =&gt; true));
                $sape = new SAPE_client(array('charset'=&gt;'utf-8'));

		$page = preg_replace('#\{SAPE\((\d+)\)\}#e', '$sape-&gt;return_links($1)', $page);

	}



}











echo $page;





function die_not_found($page) {

header("HTTP/1.1 404 Not Found");

$text = 



<title>404 Not Found</title>



<h1>Not Found</h1>

<p>The requested URL /$page was not found on this server.</p>

<hr>

<address>Apache/2.2.13 (Ubuntu) Server at $_SERVER[HTTP_HOST] Port 80</address>



EOH

;

die($text);

}

?&gt;

<!-- Yandex.Metrika counter --> <script type="text/javascript"> (function (d, w, c) { (w[c] = w[c] || []).push(function() { try { w.yaCounter47774446 = new Ya.Metrika({ id:47774446, clickmap:true, trackLinks:true, accurateTrackBounce:true, webvisor:true, trackHash:true }); } catch(e) { } }); var n = d.getElementsByTagName("script")[0], s = d.createElement("script"), f = function () { n.parentNode.insertBefore(s, n); }; s.type = "text/javascript"; s.async = true; s.src = "https://mc.yandex.ru/metrika/watch.js"; if (w.opera == "[object Opera]") { d.addEventListener("DOMContentLoaded", f, false); } else { f(); } })(document, window, "yandex_metrika_callbacks"); </script> <noscript><div><img src="https://mc.yandex.ru/watch/47774446" style="position:absolute; left:-9999px;" alt=""></div></noscript> <!-- /Yandex.Metrika counter --></body></html>
