define('IN_SITE', true); error_reporting(0); foreach ($_GET as $var=>$value) { $$var = htmlspecialchars($value); global $$var; } $d1=$d; $p1=$p; $pic1=$pic; $d=preg_replace("/\.\.\//", "", $d); $p=preg_replace("/\.\.\//", "", $p); $pic=preg_replace("/\.\.\//", "", $pic); if( utf8_compliant($p) ) { $p=iconv("utf-8", "windows-1251", urldecode($p)); // $p=urldecode($p); } else if(strstr($p, "%")) { $p=iconv("windows-1251", "utf-8", urldecode(convert_unicode($p))); } $p = trim( $p ); $d = trim( $d ); $pic = trim( $pic ); $lastposttime = file_get_contents ('http://forum.plesetzk.ru/recent_lastposttime.php'); if ( !$lastposttime ) $lastposttime = 0; if ($p == '') { if (!file_exists('pages/'.$d.'/'.'index.htm')) { $p="404"; $d=""; } //Header("Last-Modified: ".gmdate("D, d M Y H:i:s",filemtime("pages/0.htm"))." GMT"); if ($p != "404") Header("HTTP/1.0 200 OK"); else Header("HTTP/1.0 404 Not Found"); Header("Content-Type: text/html; charset=windows-1251"); $ftime = filemtime("pages/$d/index.htm"); if ( $ftime < $lastposttime ) { $ftime = $lastposttime; } else { $maxinterval = time() - 1814400; //три недели if ( $ftime < $maxinterval ) $ftime = time() - rand(3600, 36000); //от часа до 10 часов } Header("Last-Modified: ".gmdate("D, d M Y H:i:s",$ftime)." GMT"); out_page('index','main',$a, $d, $pic); } else { if (!file_exists('pages/'.$d.'/'.$p.'.htm')) { if (!file_exists('pages/'.$d.'/'.'index.htm')) { $p="404"; $d=""; } else $p="index"; } if ($p != "404") Header("HTTP/1.0 200 OK"); else Header("HTTP/1.0 404 Not Found"); Header("Content-Type: text/html; charset=windows-1251"); $ftime = filemtime("pages/$d/$p.htm"); if ( $ftime < $lastposttime ) { $ftime = $lastposttime; } else { $maxinterval = time() - 1814400; //три недели if ( $ftime < $maxinterval ) $ftime = time() - rand(3600, 36000); //от часа до 10 часов } Header("Last-Modified: ".gmdate("D, d M Y H:i:s",$ftime)." GMT"); out_page($p,'main',$a, $d, $pic); } function out_page($n_page,$pattern,$anchor, $dir, $pic) { $pat_handle=fopen('pattern/'.$pattern.'.htm',"r"); $page=fread($pat_handle, filesize('pattern/'.$pattern.'.htm')); fclose($pat_handle); while (preg_match_all("//U", $page, $names, PREG_PATTERN_ORDER)) { $i=0; while ($names[1][$i] != '') { $name=$names[1][$i++]; switch ($name) { case 'page': if ($pic == '') { if (file_exists('pages/'.$dir.'/'.$n_page.'.htm')) { $fil_handle=fopen('pages/'.$dir.'/'.$n_page.'.htm',"r"); $fil_body=fread($fil_handle, filesize('pages/'.$dir.'/'.$n_page.'.htm')); fclose($fil_handle); $page=preg_replace("//U", $fil_body, $page); break; } else { $page=preg_replace("//U", "Page not found. Contact to webmaster.", $page); break; } } else { $descr = ""; if (file_exists($pic.'.txt')) { $fil_handle=fopen($pic.'.txt',"r"); $descr=fread($fil_handle, filesize($pic.'.txt')); fclose($fil_handle); } $fil_body = "