<?php
//
include("../../includes/config.php");
//
$ver_id=1743677491;
$userid=192;
$mod=84;
$exptime=20260906;
///////////////////////////////////////
$date = getdate();
$yy = $date['year'];
$dd= $date['mday'];
$mm= $date['mon'];
if($mm<10){
	$mm="0".$mm;
}
if($dd<10){
	$dd="0".$dd;
}
$nowtime=$yy.$mm.$dd;

////////////////////////////////////////
if($nowtime>$exptime && $LOOK!="ok"){
	header("location:../../exp.htm");
}
if($file==""){
	$file="index.php3";
}
if(isset($REF_PAGE)){
	$refpage=$REF_PAGE;
	$direct="N";
}else{
	$direct="Y";
}

//
$opendir="$baseurl/mod/$mod/";
$openfile=$opendir.$file;
$openfile=$openfile."?kdir=$kdir&nowdir=$nowdir&userid=$userid&id=$id&detail=$detail";
if($QUERY_STRING==""){
	$filestring="file=index.php3.htm";
}else{
	$filestring=$QUERY_STRING.".htm";
}

//
setcookie("REF_PAGE",$filestring);

//
$kk=3;
if(file_exists($filestring)){
	$fx=fopen($filestring,"r");
	$pp=fgets($fx,100);
	fclose($fx);

	if(trim($pp)=="<!-- $ver_id -->"){
		include($filestring);
	}else{
		$kk=1; 
	}
}else{
	if($filestring=="file=index.php3.htm"){
		$kk=1;
	}elseif($direct=="Y"){
		$kk=0;
	}else{
		if(file_exists($refpage)){
			//
			//$fp=fopen($refpage,"r");
			//$con=fread($fp,120000);
			//fclose($fd);
			
			//$con=file_get_contents($refpage);
			//ob_start();
			//include($refpage);
			//$con = ob_get_contents();
			//ob_end_clean();
			$con = file_get_contents($openfile);
			
			if(strstr($con,$QUERY_STRING.">")){
				$kk=1;
			}else{
				$kk=0;
			}
		}else{
			$kk=0;
		}
	}
}

if($kk==0){
	//$fd=fopen($openfile,"r");
	//$con = fread($fd,120000);
	
	//ob_start();
	//include($openfile);
	//$con = ob_get_contents();
	//ob_end_clean();
	$con = file_get_contents($openfile);
	
	$con=str_replace("images/","$opendir/images/",$con);
	$con=str_replace("<?","",$con);
	$con=str_replace("<%","",$con);
	$con=str_replace("language=php","",$con);
	$con=str_replace("language='php'","",$con);
	$con=str_replace('language="php"','',$con);
	//fclose($fd);
	
	echo "$con";
}


if($kk==1){
	//
	//$fd=fopen($openfile,"r");
	//$con = fread($fd,120000);
	//$con=str_replace("images/","$opendir/images/",$con);
	//fclose($fd);
	
	//$con = file_get_contents($openfile);
	//ob_start();
	//include($openfile);
	//$con = ob_get_contents();
	//ob_end_clean();
	$con = file_get_contents($openfile);
	
	$con=str_replace("images/","$opendir/images/",$con);
	$con=str_replace("<?","",$con);
	$con=str_replace("<%","",$con);
	$con=str_replace("language=php","",$con);
	$con=str_replace("language='php'","",$con);
	$con=str_replace('language="php"','',$con);
	
	echo "$con";
	
	
	$fp=fopen($filestring,"w");
	fwrite($fp,"<!-- $ver_id -->\n",100);
	$con=str_replace("\t","",$con);
	$con=str_replace("\r","",$con);
	$con = ereg_replace(">([ ]+)<", "><", $con);
	$con = ereg_replace("\n([ ]+)<", "\n<", $con);
	$con = ereg_replace("([\n]+)", "\n", $con);
	fwrite($fp,$con,strlen($con));
	fclose($fp);
	@chmod($filestring,0755);
}
?>