<?php require_once('../../include/class.inc.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link rel="stylesheet" href="../inc/css.css" type="text/css" />
<title>无标题文档</title>
<style type="text/css">
<!--
.STYLE5 {color: #FFFFFF; font-weight: bold; }
-->
.selected{
border:2px solid #FF0000;
}
</style>
<script src="images/jquery.js" type="text/javascript"></script>
<script type="text/javascript" src="images/index.js"></script>
</head>

<body>
<?php
if ($_POST[tem_name]) {
	$tem_name=$_POST[tem_name];
	mysql_query("set names 'GBK'");
	$sql="update template  set `tdefault`='$tem_name'";
	mysql_query($sql);
	
	
	
	//删除编译文件
		$dir_url=$_SERVER['DOCUMENT_ROOT']."templates_c/";	
		$files=scandir($dir_url);			
		foreach ( $files as $v ) {
			if (is_dir($dir_url.$v)) {
				
			} else {
				unlink($dir_url.$v);
			}
			
		}	
	

	echo "<script>alert('更改成功');</script>";
	
	
	};

?>
<table width="1055" border="0" align="center" cellpadding="0" cellspacing="0">
 <tr>
    <td colspan="2"><div align="center"></div></td>
  </tr> <tr>
    <td width="960">&nbsp;</td>
    <td width="95"><a href="../news/news_add.php">添加新闻</a></td>
  </tr>
  <tr>
    <td colspan="2">
      
      
      <table width="1052" border="0" align="center" cellpadding="2" cellspacing="1" bordercolor="#799AE1" class="tableBorder">
        <tbody>
          <tr bgcolor="#CCCCCC">
            <td height="20" colspan="2" bgcolor="#4455aa" class="STYLE5">选择模板 </td>

          <tr bgcolor="#DEE5FA">
            <td width="102" align="center" class="txlrow">网站模板及风格</td>
            <td width="937" align="center" class="txlrow"><div align="left">
              
              </div></td>
          </tr>

          <tr bgcolor="#DEE5FA">
            <td><table><tr>
            
            <?php
		mysql_query("set names 'GBK'");
		$result=mysql_query("select * from template");
		if ($info=mysql_fetch_array($result)) {
		
			$dir_name=$info['tdefault'];
		}
			  $dp = opendir("./");
			  $n=0;
              while(($file = readdir($dp)) !== false) {
			  $n++;
                        if($file !="." && $file !="..") {
                                if(is_dir($file)) {
									if ($file == $dir_name) {
                                       echo "<td align='center'><img  id='selected' class='other' title='".$file."' src='images/red.jpg'>$file</td>";
									} else {
										if ($file == 'images') {
										continue;
										}else {
										echo "<td align='center'><img class='other' title='".$file."' src='images/red.jpg'>$file</td>";
										}
										
									}
								}
                        }
						if($n % 5 == 0) {
						echo "</tr><tr>";
						}
                }
              

 ?>
            
        
          </tr>
        
      </table>
          
    </td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>

</body>
</html>
