0){ foreach($redir as $rule){ list($http_code, $source, $target) = explode(';',$rule); $test = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; if($test==$source){ switch($http_code){ case '301': header("HTTP/1.1 301 Moved Permanently"); header("Location: ".$target); die(); break; case '404': header("HTTP/1.1 404 Not Found"); die(); break; } } } } } if(is_dir($reqURL->uri_filename) && @file_exists($reqURL->uri_filename.'/index.cache.html')){ //echo 'poszlo:'.$reqURL->uri_filename.'/index.cache.html'; readfile($reqURL->uri_filename.'/index.cache.html'); exit(); } if(@file_exists($reqURL->uri_filename)){ //echo 'poszlo:'.$reqURL->uri_filename; readfile($reqURL->uri_filename); exit(); } /** * Jesli mamy Query Stringa wowczas robimy z niego hasha md5 i generujemy nowa nazwe pliku * */ if(isset($uri['query'])){ # hash dla QSA $hash = md5( $uri['query']); # skladamy nazwe pliku do kupy (pozbywamy sie przy okazji pierwszego slasha) $filename = substr($uri['path'].'.'.$hash,1); //echo '-> '.FILES_PATH.$filename.'[_html]'; if(file_exists($filename)){ if(DEBUG) echo 'READ FILE ('.__LINE__.'):'.md5($_GET["qsa"]).''; # czytamy zawartosc pliku readfile($filename); # koniec exit(); } elseif(file_exists(FILES_PATH.'index.html'.$filename)){ if(DEBUG) echo 'READ FILE ('.__LINE__.'): index.html.'.md5($_GET["qsa"]).''; # czytamy zawartosc pliku readfile('index.html'.$filename); # koniec exit(); } else{ # nie ma pliku wiec walimy 404 lub 302 if(!headers_sent()) header("HTTP/1.1 301 Moved Permanently"); if(DEBUG){ $msg = "
".__LINE__.' File '.$filename.' not found.'; $msg = "
".__LINE__.' File index.html'.$filename.' not found.'; die("HTTP/1.1 301 Moved Permanently".$msg); } if(!headers_sent()) header("Location: http://".$_SERVER['HTTP_HOST']); exit(); } } if(isset($uri['path'])){ # poprawka na sciezke $path = substr(trim($uri['path']), 1); if(@file_exists($path)){ # czytamy zawartosc pliku readfile($path); # koniec exit(); } $path = substr(trim($uri['path']), 1, -1); //echo '-> '.FILES_PATH.$path; //die('test:'.$path.' -> '.file_exists($path)); if(@file_exists($path)){ # czytamy zawartosc pliku readfile($path); # koniec exit(); } elseif(@file_exists($path.'._html')){ # czytamy zawartosc pliku readfile($path.'._html'); # koniec exit(); } } if(file_exists('index.php')){ # czytamy zawartosc pliku readfile('index.php'); # koniec exit(); } elseif(file_exists('index.cache.html')){ # czytamy zawartosc pliku readfile('index.cache.html'); # koniec exit(); } if(isset($_GET["qsa"])) { if(DEBUG) echo 'READ FILE ('.__LINE__.'):'.md5($_GET["qsa"]).''; readfile(md5($_GET["qsa"])); //Outputs the file. Do not use echo file_get_contents. exit(); } if(DEBUG) echo 'NOT FOUND!'; if(!headers_sent()) header("HTTP/1.1 704 Not Found"); exit(); ?>