<?php
//对应的模板文件路径;

$template_file_top = R_P.'template/'.$tpl_path.'/header.html' ;
$template_file_middle = R_P.'template/'.$tpl_path.'/'.$self_template.'.html' ;
$template_file_foot = R_P.'template/'.$tpl_path.'/footer.html' ;
 

//对应的图片文件路径;
$template_images = '/images/'.$tpl_path.'/' ;


function html_chk($path,$cache=3,$type=''){
	global $timestamp;
	$p_path = R_P.'html/'.$path.'.html';
	if ($cache) {
		$cachetime = $cache*60;
		if (file_exists($p_path) && (($timestamp - filemtime($p_path)) < $cachetime)) return $p_path;

	}else{
		if (file_exists($p_path) ) return $p_path;
	}
}

function html_exp($str,$str_rep,$content,$preg=0){
	$preg ? $ret_str = preg_replace($str,$str_rep,$content) : $ret_str = str_replace($str,$str_rep,$content);
	return $ret_str;
}


function html_write($path_name,$content,$chmod=1){

	$path = R_P.'html/'.$path_name.'.html';
	if (strpos($path_name,'/')) {
		$path_dir_exp = explode('/',$path_name);
		array_pop($path_dir_exp);
		$forea_path  = '';
		foreach ($path_dir_exp as $ks => $vs){
			!file_exists(R_P.'html/'.$forea_path.$vs) &&  (mkdir(R_P.'html/'.$forea_path.$vs)  || Showmsg('mkdir_err'));
			$forea_path .= $vs.'/';
		}

	}
	$fp=fopen($path,"wb+");
	fwrite($fp,$content) or Showmsg('html_write');
	fclose($fp);
	$chmod && chmod($filename,0777);
}

function html_content_del($type,$id){
	global $web_domin;
	$h_dir_id = substr($id,0,3);
	//$html_dir_name = R_P.'html/content/'.$type.'/'.$h_dir_id.'/contenttype='.$type.'&content_id='.$id.'.html';
	$html_dir_name = 'content/'.$type.'/'.$h_dir_id.'/'.$id.'.html';
	$url = 'http://'.$web_domin.'/require/delHtmlCache.php?path='.$html_dir_name;
	file_get_contents($url);
	return $html_dir_name;
}

function html_nummd($num,$unNum=1){
	$sunNum = 23;
	$unNum ? $num = $num*$sunNum : $num = $num/$sunNum;
	return $num;
}

function p_format($str){
	$str = str_replace(array('000000','00000','0000',),array('百万','0万','万',),$str);
	return $str;
}


?>