<?php
	require("session_check.php");	
	
	//语言包引入
	$u_langpackage=new uilp;
	
	//数据表定义
	$t_config=$tablePreStr."config";
	
	//数据库连接
	$dbo=new dbex;
	dbtarget('w',$dbServs);
	
	$sql="select v from $t_config where k='templates'";
	$templ=$dbo->getRow($sql);
	$sql="select v from $t_config where k='skin'";
	$skin=$dbo->getRow($sql);
	$sql="select v from $t_config where k='tpl_compile_type'";
	$tpl_type=$dbo->getRow($sql);
	$serve_checked='';
	$debug_checked='';
	if($tpl_type['v']=='debug'){
		$debug_checked='checked=checked';
	}else{
		$serve_checked='checked=checked';
	}
?>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/right.css">
<script type='text/javascript'>
	function compile_action(tp_dir){
		document.getElementById('action').style.display='';
		document.getElementById('action').style.top=document.body.clientHeight/2-150+"px";
		document.getElementById('action').style.left=document.body.clientWidth/2-150+"px";		
		var compile_radio=document.getElementsByName('tpl_compile_type');
		for(i=0;i < compile_radio.length;i++){
			if(compile_radio[i].checked==true){
				var compile_type=compile_radio[i].value;
			}
		}
		window.location.href="action_comp.php?pro="+tp_dir+"&compile_type="+compile_type;
	}
	
	function change_compile(tp_dir){
		var is_compile=confirm("选择了新的模板编译方式后，必须重新编译模板设置才会生效。\n\n现在是否开始编译模板？");
		if(is_compile==true){
			if(confirm("<?php echo $u_langpackage->u_admin_con;?>")){
				compile_action(tp_dir);
			}
		}
	}
</script>
</head>
<body>
<div id='action' style='display:none;' class='ajax_window'>
	<div style='background-color:white;width:220px;height:50px'>
		<div style='margin-left:25px;width:220px;height:30px'>
			<div style='margin-top:15px;width:220px'><img src='images/loading.gif' style='float:left' />正在编译，请稍等...</div>
		</div>
	</div>
</div>
<div class="container">
	<div class="rs_head"><?php echo $u_langpackage->u_temp_admin?></div>
</div>
	<table class='main'>
		<tr>
			<th> <?php echo $u_langpackage->u_temp_list?> </th><th>  <?php echo $u_langpackage->u_amend_time?></th><th> <?php echo $u_langpackage->u_currently_apply?> </th> <th> 使用皮肤 </th> <th> <?php echo $u_langpackage->u_admin_handle?> </th>
		</tr>
		<?php
			$ref=opendir("../templates");
			while($tp_dir=readdir($ref)){
				if(!preg_match("/^\./",$tp_dir)){
					$act_time=date("Y-m-d H:i:s",filemtime("../templates/".$tp_dir));
					$selected="";
					$skin_select="";
					if($templ['v']==$tp_dir){
						$selected="√";
					}
					if(file_exists("../skin/".$tp_dir)){
						$skin_def=opendir("../skin/".$tp_dir);
						while($skin_dir=readdir($skin_def)){
							if(!preg_match("/^\./",$skin_dir)){
								if($templ['v']."/".$skin_dir==$skin['v']){
									$skin_select=$skin_dir;
								}
							}
						}
					}
					echo '<tr><td>'.$tp_dir.'</td> <td>'.$act_time.'</td> <td>'.$selected.'</td>';
					echo '
<td>'.$skin_select.'</td>';
					echo '<td>&nbsp|&nbsp<a href="javascript:compile_action(\''.$tp_dir.'\');" onclick=\'return confirm("'.$u_langpackage->u_admin_con.'");\'>'.$u_langpackage->u_app_temp.'</a>&nbsp|&nbsp<a href="tmp_list.php?loc='.$tp_dir.'">'.$u_langpackage->u_admin_temp.'</a>&nbsp|&nbsp';if($selected=="√"){echo '<a href="manage_skin.php">选择皮肤</a>&nbsp|&nbsp';} echo '</td></tr>';
					echo '<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>';
				}
			}
		?>
		<tr><td>模板编译方式：服务模式<input type='radio' value='serve' name='tpl_compile_type' <?php echo $serve_checked;?> /> &nbsp 调试模式<input type='radio' value='debug' name='tpl_compile_type' <?php echo $debug_checked;?> /> &nbsp <input type='button' class='top_button' value='启用' onclick=change_compile("<?php echo $templ['v'];?>") /></td></tr>
	</table>	
	
<div class="container">
	<div class="rs_head"><?php echo $u_langpackage->u_prompt_inf?></div>
</div>
<table class="main main_left">
	<tr>
		<td>
		<?php echo $u_langpackage->u_prompt_1?><br />
		<?php echo str_replace('{default}',$templ['v'],$u_langpackage->u_prompt_2)?><br />
		<?php echo $u_langpackage->u_prompt_3?><br />
		<?php echo $u_langpackage->u_prompt_4?><br />
		<?php echo $u_langpackage->u_prompt_5?><br />
		<?php echo $u_langpackage->u_prompt_6?><br />
		</td>
	</tr>
</table>
	
	
</body>
</html>		