<?PHP
// +----------------------------------------------------------------------
// 最便捷的php框架
// +----------------------------------------------------------------------
// | Copyright (c) 2011 http://www.ky53.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.ky53.net )
// +----------------------------------------------------------------------

/**
 
 * @author   qq:974005652(zhx626@126.com) by老顽童
 * @version  1.0
 +------------------------------------------------------------------------------
 */
class temp{
   var $dbcharset='gbk';
   function  tempwrite($file,$ftxt,$povaule){
      global $urlarr;
	  if(!defined("CONFIG_PATH"))define('CONFIG_PATH', 'inc');
	  if(!defined("TEMP_PATH"))define('TEMP_PATH', 'temp');
      if(!$file)$file='data.bat';
      if(!$ftxt)$ftxt='<?php '.chr(13).'//科亿php'.chr(13).'$conf=require APP_PATH."/'.CONFIG_PATH.'/config.php";if($conf[\'DB_TYPE\']==\'mssql\'){require KY_PATH."/kydata/mssql_class.php";$mysql=new MYSQL_DB();}else{require KY_PATH."/kyclass/mysql_class.php";
'.chr(13).'$mysql=new MYSQL_DB();'.chr(13).chr(13).'$dbcharset=$conf[\'DB_CHARSET\'];$mysql->connect($conf[\'DB_HOST\'],$conf[\'DB_USER\'],$conf[\'DB_PWD\'],$conf[\'DB_NAME\'],"");}'.chr(13).'require KY_PATH."/kyclass/action_class.php";'.chr(13).' $dbpre=$conf[\'DB_PREFIX\'];define(\'DB_PRE\',$dbpre);?>';
     $temp_dir=APP_PATH.'/'.TEMP_PATH;
     if(!@file_exists($temp_dir))mkdir($temp_dir);
	 if(!@file_exists($temp_dir.'/cahe'))mkdir($temp_dir.'/cahe');
     $file_name = $temp_dir."/$file"; 
	 
     $po="w";
	 
	     if(!@file_exists($file_name)){
		 /*
		 $po="r";
		   $filesize=@filesize($file_name);
		   $file_pointer = fopen($file_name, "r");		  
		   if(!strstr(fread($file_pointer,$filesize),$ftxt)){
		    $po="w";
			
		     }	*/	    		  
		
		 if($povaule)$po=$povaule;
		
	 $file_pointer = fopen($file_name, $po);   
	
		
     fwrite($file_pointer, $ftxt); 
     fclose($file_pointer); 
      }
   }
   function read_cahe($file){
      if(!@file_exists($file)){
	   $file_pointer = fopen($file, "w");		 
	   fwrite($file_pointer,'<?php //科亿php Copyright (c) 2011 http://www.ky53.net All rights reserved ?>'); 
       fclose($file_pointer); 
	  }else{
	  $filep= fopen($file, "r");
	  $filesize=@filesize($file);
	  return fread($filep,$filesize);
	  }
   }
   function read($file){
   global $lable,$list,$volist,$data_list,$data;
   if($data){
   foreach($data as $datakey=>$datavalue){
		$$datakey=$datavalue;	
	}
	}
     @require $file;
	 
	/*
	$filep= fopen($file, "r");
	$filesize=@filesize($file);
	return fread($filep,$filesize);
	 */
   }

}
?>