<?php 
/*
**文件及目錄操作函數集**
*/


//列表目錄
function get_dir_name($parent_dir) {
	$str = "";
	if ($handle = opendir($parent_dir)) {
		while (false != ($dir = readdir($handle))) {
			if (($dir != ".") && ($dir != "..")) {
				$str .= "<input type=\"radio\" name=\"template\" value=\"$dir\">$dir"."<br \>\n";	
			}
		}
	}
	return $str;
}

//生成文件
function create_html($path,$content) {
	$content = preg_replace("/{[^ \t\r\n}]+}/","",$content);
	$fp = fopen($path."index.htm",'w');
	if ($fp) {
		flock($fp,LOCK_EX);
		fwrite($fp,$content);
		flock($fp,LOCK_UN);
	}
	fclose($fp);
}

//生成圖片
function create_image($image_path) {
	$image_size = getimagesize($image_path);
	$str = "<img src=\"$image_path\" width=\"60\" height=\"60\">";
	return $str;
}
?>