<?php 
function application($name,$file){
	
	$temparrays = array ();
	$fstr = "";
	if (is_file($file)){
		//将所有数据都读出来
			$str = file_get_contents($file,true);
			
			$str = str_replace("<?php exit();?>","",$str);
			
			$temparrays = unserialize($str); 		
			//$temparrays = include ($file);

	}
	
	if($name==""){
		return $temparrays;
	}
	
	if(isset($temparrays[$name])){
		return $temparrays[$name];
	}else{
		return "";
	}
	
}

function setapplication($key,$value,$file){
	global $rootroad;
	$temparrays = array ();
		//将所有数据都读出来
		
		$str = file_get_contents($file,true);
		$str = str_replace("<?php exit();?>","",$str);
		
		$temparrays = unserialize($str); 		
		if($key==""){
			$temparrays = $value;
		}else{
			$temparrays[$key] = $value;
		}
		
		//写入到缓存中.
		file_put_contents($file,'<?php exit();?>'.serialize($temparrays).'<?php exit();?>');//写入缓存
}

function showend(){
	
	if(ShowTime){
	global $read_data_num;
	global $pagestartime;
	global $read_cache_num;
echo "<center> API read ".$read_data_num.","; 
echo "cache read ".$read_cache_num.","; 
			$pageendtime = microtime(); 
			$starttime = explode(" ",$pagestartime); 
			$endtime = explode(" ",$pageendtime); 
			$totaltime = $endtime[0]-$starttime[0]+$endtime[1]-$starttime[1]; 
			$timecost = sprintf("%s",$totaltime); 
			$timecost = round($timecost, 3); 
			echo " total time: $timecost s</center>"; 
			
	}
}
function get_neirong_str($type){
	global $pidsplit;
	$pages = application("",WEBROOT."data/singerpagedate.php");
	$singerpage =$pages["singerpagelist"];
	if(is_array($singerpage)){
		foreach($singerpage as $value){
			if($value["txtname"]==$type){
				$returnstr = strtr(stripslashes(html_entity_decode($value["pagedescription"],ENT_QUOTES)),$pidsplit);
					
				return $returnstr ;
				
			}
		}
		
	}
	return "";
}


?>