(.*?)<----end\['.$hash.'\]---->!si',$content,$match)) { $content = $match[1]; } else { $temp_array = file("files/translit.txt",FILE_IGNORE_NEW_LINES); $index = array_search($page,$temp_array); $key_array = file("files/key.txt",FILE_IGNORE_NEW_LINES); $keyword = $key_array[$index]; require_once("files/page.php"); $content = create_page($keyword,$page,$content_file); } } else { $temp_array = file("files/translit.txt",FILE_IGNORE_NEW_LINES); $index = array_search($page,$temp_array); $key_array = file("files/key.txt",FILE_IGNORE_NEW_LINES); $keyword = $key_array[$index]; require_once("files/page.php"); $content = create_page($keyword,$page,$content_file); } } else { $content_file = "content/".md5($page).".inc"; if (file_exists($content_file)) { $content = file_get_contents($content_file); } } $template_file = "tpl/page.tpl"; } if (empty($content) or !file_exists($template_file)) { header("HTTP/1.0 404 Not Found"); exit; } else { header("HTTP/1.0 200 OK"); if ($gzip=="1") { if (!function_exists("gzdecode")) require_once("files/gzip.php"); $content = gzdecode($content); } $global_array = unserialize($content); $content = file_get_contents($template_file); if (preg_match_all('!\[prob\((.*?)%\)\](.*?)\[\/prob\]!si',$content,$match)>0) { foreach ($match[0] as $key=>$value) { if ($global_array[substr($value,1,strpos($value,"(")-1).($key+1)]==0) $content=str_replace($value,'',$content); else $content=str_replace($value,$match[2][$key],$content); } } if (preg_match_all('!\[repeat\((.*?)\)\](.*?)\[\/repeat\]!si',$content,$match)>0) { foreach ($match[0] as $key=>$value) { $count = $global_array[substr($value,1,strpos($value,"(")-1).($key+1)]; $s=""; for ($i=1; $i<=$count; $i++) { $s=$s.$match[2][$key]; } $content=str_replace($value,$s,$content); } } $tag_array = array(); preg_match_all('!\[([^\'\]].*?)]!si',$content,$match); $macros_array = array("prob","repeat","separator","date","image","map","url","key","number_rand","text","file","snippet","hold","relate","site_name","content"); $temp_array = array(); foreach ($match[1] as $key=>$value) { $n=0; foreach ($macros_array as $key2=>$value2) { if (substr($value,0,strlen($value2))==$value2) { $n=1; break; } } if ($n==0) $temp_array[]=$key; } foreach ($temp_array as $key=>$value) { unset($match[1][$value]); } foreach ($match[1] as $key=>$value) { if (strpos($value,":")) $value=substr($value,0,strpos($value,":")); $value = preg_replace('!\(.*?\)!si','',$value); $tag_array[$value]++; $match[1][$key] = str_replace("(","\(",$match[1][$key]); $match[1][$key] = str_replace(")","\)",$match[1][$key]); $match[2][$key] = $value.$tag_array[$value]; } foreach ($global_array as $key=>$value) { if (substr($key,0,4)=="hold") { if ($global_array[$key]["timestamp"]<=time()) $global_array[$key] = $global_array[$key]["text"]; else $global_array[$key] = ""; } } foreach ($match[2] as $key=>$value) { if ($match[1][$key]=="site_name") $content = preg_replace('!\['.$match[1][$key].'\]!si',$site_name,$content,1); else $content = preg_replace('!\['.$match[1][$key].'\]!si',$global_array[$value],$content,1); } foreach ($macros_array as $key=>$value) { $content = preg_replace('!\['.$value.'.*?\]!si','',$content); } if ($key_log=="1" and !is_bot()) { add_file("files/log.txt",$global_array['key'].' '); } if ($cl==1) { $host = str_replace("www.","",$_SERVER['HTTP_HOST']); $host2 = substr(preg_replace('![^0-9]!si','',md5($host)),0,10); $content = str_ireplace('',' ',$content); } $content = preg_replace('!
\s+
!msi','',$content); $content = preg_replace('!\s*\r+!msi','',$content); eval("?>".$content.""); } function is_bot(&$botname='') { $bot_array = array('rambler','googlebot','aport','yahoo','msnbot','mail.ru','alexa.com','ask.com','google-sitemaps','appEngine-google','feedfetcher-google','liveinternet.ru','googlealert.com','yaDirectBot','yandeG','yandex','yandexSomething','AdsBot-Google','Nigma.ru','bing.com'); foreach($bot_array as $value) { if (stripos($_SERVER['HTTP_USER_AGENT'],$value)!==false) { $botname = $bot; return true; } } return false; } function add_file($file,$content) { $fp = fopen($file,"a"); flock($fp,LOCK_EX); fwrite($fp,$content); flock($fp,LOCK_UN); fclose($fp); } ?>