<?php
require_once '../include/adminfunction.php';
checkadmin();

$action=var_request("action","");


$errmsg = "";
$pagetext="";
if($action=="update"){
	$pagetext = '$rootroad = "'.$rootroad.'";   //网站所在目录'."\n";
	$pagetext = $pagetext.'$weijingtai="'.$weijingtai.'";  //开启伪静态'."\n";
	$pagetext = $pagetext.'$usernick="'.$usernick.'";  //淘宝昵称'."\n";
	$pagetext = $pagetext.'$userpid="'.$userpid.'";  //阿里妈妈PID'."\n";
	$pagetext = $pagetext.'$userpiddp="'.$userpiddp.'";  //阿里妈妈小PID'."\n";
	$pagetext = $pagetext.'$sitetitle="'.$sitetitle.'";  //网站TITLE'."\n";
	$pagetext = $pagetext.'$sitetitleurl="'.$sitetitleurl.'";  //网站域名'."\n";
	$pagetext = $pagetext.'$sitekey="'.$sitekey.'";  //SEO关键字'."\n";
	$pagetext = $pagetext.'$sitedesc="'.$sitedesc.'";  //SEO网页描述'."\n";
	$pagetext = $pagetext.'$beianxinxi="'.$beianxinxi.'";  //备案信息号'."\n";
	$pagetext = $pagetext.'$webcontact="'.$webcontact.'";  //站长联系方式'."\n";
	$pagetext = $pagetext.'$tongjidaima="'.$tongjidaima.'";  //统计脚本'."\n";
	$pagetext = $pagetext.'$setCacheTime="'.$setCacheTime.'";  //缓存时间'."\n";
	
	//原有的字段
	$pagetext = $pagetext.'$manage_adminname="'.$manage_adminname.'";  //管理员账号'."\n";
	$pagetext = $pagetext.'$manage_adminpass="'.$manage_adminpass.'";  //管理员密码'."\n";
	$pagetext = $pagetext.'$ArrayAppKey="'.$ArrayAppKey.'";  //AppKey'."\n";
	$pagetext = $pagetext.'$ArrayAppSecret="'.$ArrayAppSecret.'";  //AppSecret'."\n";
	
	
	
	$templatefolder = htmlentities(var_request("templatefolder","default"));
	$pagetext = $pagetext.'$templatefolder="'.$templatefolder.'";  //templatefolder'."\n";
	$pagetext = $pagetext.'define(\'ROOT\',dirname(__FILE__)."/");'."\n";



	//写入到缓存中.
	file_put_contents ( "../data/configdata.php", "<?php \n".$pagetext."\n?>");
	
	redirect_to("managestyle.php?add=ok");
	exit;
	
}



?>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>315爱购网</title>
	<link rel='stylesheet' href='images/order.css'>
    <style type="text/css">
<!--
.STYLE2 {color: #FF0000}
-->
    </style>
</head>

<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<center>
<table width="96%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30" align=center>
<br> 
<p>&nbsp;    </p>

      </td>
  </tr>
</table>
<?php if(var_request("add","")=="ok"){?>
<table width="96%" border="0" cellpadding="3" cellspacing="1" bgcolor="#cccccc">
  <tr>
    <td height="30" colspan="2" align="center" bgcolor="#FFFFCC"><a href="manageconfig.php"><span class="STYLE2">修改成功！</span></a> </td>
  </tr>
</table>
<?php }?>

  <form name="form1" method="post" action="managestyle.php?action=update" style=" margin:2px;">
    <table border="0" cellpadding="10" cellspacing="1" bgcolor="#cccccc">
    <?php
	$dir = WEBROOT."template";
	$dh=opendir($dir);
	
	while ($file=readdir($dh))
	{
		
		if($file!="." && $file!="..")
		{
			$fullpath=$dir."/".$file;
			
			if(is_dir($fullpath) && is_file($fullpath."/config.php"))
			{
				include($fullpath."/config.php");
				
				
				
				?>
      <tr bgcolor="#c8ddf4">
        <td width="180" height="30" align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669"><?php echo $temptitle;?><input type="radio" name="templatefolder" id="type" value="<?php echo $file;?>" <?php echo $templatefolder==$file?"checked":""?>><br></td>
        <td align="left" bgcolor="#ffffff"><?php echo $tempabout;?> 目录位置：(template/<?php echo $file;?>)</td>
       </tr>
				<?php
			}
		}
	}
	closedir($dh);
	
	?>
    
    
    
      <tr bgcolor="#c8ddf4">
        <td height="30" align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">&nbsp;</td>
        <td align="left" bgcolor="#ffffff"><input type="submit" name="button" id="button" value="修改"></td>
      </tr>
    </table>
  </form>



<table width="96%" height="91" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="1" bgcolor="#b2b2b2"></td>
  </tr>
  <tr>
    <td height="90" align=center>
<br> 
<p>&nbsp;    </p>

      </td>
  </tr>
</table>
</center>
</body>
</html>
