<?php
require_once '../include/adminfunction.php';
checkadmin();
function updatesettext($text){
	if($text=="")
		return "";
	$text = htmlspecialchars(trim($text),ENT_QUOTES);
    return $text;
}


$action=var_request("action","");
$errmsg = "";
if($action=="ok"){

	$crootroad =			updatesettext(var_request("txtrootroad",""));
	
	if(strlen($crootroad)>=1 && substr($crootroad,strlen($crootroad)-1,1)=="/"){
		$crootroad = substr($crootroad,0,strlen($crootroad)-1);
	}

	
	$ctxtnick =			updatesettext(var_request("txtnick",""));
	$ctxtweijingtai =			updatesettext(var_request("txtweijingtai","0"));
	$ctxtpid =  			updatesettext(var_request("txtpid",""));
	$ctxtuserpiddp = str_replace("_0_0",'',str_replace("mm_",'',$ctxtpid));
	$ctxttitle =  		updatesettext(var_request("txttitle",""));
	$ctxturl =  			updatesettext(var_request("txturl",""));
	$ctxtkeyword =  		updatesettext(var_request("txtkeyword",""));
	$ctxtsitedesc =  	updatesettext(var_request("txtsitedesc",""));
	$ctxtbeian =  		updatesettext(var_request("txtbeian",""));
	$ctxtwebcontact =  	updatesettext(var_request("txtwebcontact",""));
	$ctxtcountjs =  		updatesettext(var_request("txtcountjs",""));
	$ctxthuancun =  		updatesettext(var_request("txthuancun",""));
	
	//配置的字段	
	$pagetext = '$rootroad = "'.$crootroad.'";   //网站所在目录'."\n";
	$pagetext = $pagetext.'$weijingtai="'.$ctxtweijingtai.'";  //开启伪静态'."\n";
	$pagetext = $pagetext.'$usernick="'.$ctxtnick.'";  //淘宝昵称'."\n";
	$pagetext = $pagetext.'$userpid="'.$ctxtpid.'";  //阿里妈妈PID'."\n";
	$pagetext = $pagetext.'$userpiddp="'.$ctxtuserpiddp.'";  //阿里妈妈小PID'."\n";
	$pagetext = $pagetext.'$sitetitle="'.$ctxttitle.'";  //网站TITLE'."\n";
	$pagetext = $pagetext.'$sitetitleurl="'.$ctxturl.'";  //网站域名'."\n";
	$pagetext = $pagetext.'$sitekey="'.$ctxtkeyword.'";  //SEO关键字'."\n";
	$pagetext = $pagetext.'$sitedesc="'.$ctxtsitedesc.'";  //SEO网页描述'."\n";
	$pagetext = $pagetext.'$beianxinxi="'.$ctxtbeian.'";  //备案信息号'."\n";
	$pagetext = $pagetext.'$webcontact="'.$ctxtwebcontact.'";  //站长联系方式'."\n";
	$pagetext = $pagetext.'$tongjidaima="'.$ctxtcountjs.'";  //统计脚本'."\n";
	$pagetext = $pagetext.'$setCacheTime="'.$ctxthuancun.'";  //缓存时间'."\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";
	$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("manageconfig.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="10" align=center></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="manageconfig.php?action=ok">
<table width="96%" border="0" cellpadding="3" cellspacing="1" bgcolor="#cccccc">
  <tr bgcolor="#c8ddf4">
    <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">网站所在目录：</td>
    <td align="left" bgcolor="#ffffff"><input type="text" name="txtrootroad" id="txtrootroad" value="<?php echo $rootroad ?>">
	<span class="paragraph">(温馨提示：如果站点放在根目录下为空即可 如果放在子目录 举例填写:/taodi)</span>
	</td>
  </tr>
  <tr bgcolor="#c8ddf4">
    <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">是否开启伪静态：</td>
    <td bgcolor="#ffffff">
    <label>
      <div align="left">
        <input type="radio" name="txtweijingtai" id="radio" value="1"<?php echo $weijingtai=="1"?" checked":"" ?>>
        开启 
        <input type="radio" name="txtweijingtai" id="radio" value="0"<?php echo $weijingtai=="0"?" checked":"" ?>>
        关闭
	  </div>
    </label>    </td>
  </tr>
  <tr bgcolor="#c8ddf4">
    <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">缓存时间：</td>
    <td align="left" bgcolor="#ffffff"><input type="text" name="txthuancun" id="txthuancun" value="<?php echo $setCacheTime ?>">
      <span class="paragraph">(温馨提示：默认0表示关闭缓存功能,单位为小时。开启会增加浏览速度，但会占用空间。)</span></td>
  </tr>
  <tr bgcolor="#c8ddf4">
    <td width="25%" align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">淘宝账号PID：</td>
    <td width="75%" align="left" bgcolor="#ffffff"><input type="text" name="txtpid" id="txtpid" value="<?php echo $userpid?>">
      <span class="paragraph">(必填项目：阿里妈妈网站用淘宝会员登录，可查看得到的PID。如果PID不是你的请<a href="http://www.cnmysoft.com/help/20.html" target="_blank">点击这里</a>)</span>
      </td>
  </tr>
  <tr bgcolor="#c8ddf4">
    <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">网站名称：</td>
    <td align="left" bgcolor="#ffffff"><input type="text" name="txttitle" id="txttitle" value="<?php echo $sitetitle ?>"></td>
  </tr>
  <tr bgcolor="#c8ddf4">
    <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">网站域名：</td>
    <td align="left" bgcolor="#ffffff"><input name="txturl" type="text" id="txturl" value="<?php echo $sitetitleurl?>" size="40">
	<span class="paragraph">(温馨提示：填写你网站的域名,格式为:<b>http://www.315aigo.com</b>,不能填子目录和<b>/</b>)</span>
	</td>
  </tr>
  <tr bgcolor="#c8ddf4">
    <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">网站关键词：</td>
    <td align="left" bgcolor="#ffffff"><input name="txtkeyword" type="text" id="txtkeyword" value="<?php echo $sitekey?>" size="60"></td>
  </tr>
  <tr bgcolor="#c8ddf4">
    <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">网站描述说明：</td>
    <td align="left" bgcolor="#ffffff"><textarea name="txtsitedesc" cols="60" rows="5" id="txtsitedesc"><?php echo $sitedesc?></textarea></td>
  </tr>
  <tr bgcolor="#c8ddf4">
    <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">网站备案号：</td>
    <td align="left" bgcolor="#ffffff"><input type="text" name="txtbeian" id="txtbeian" value="<?php echo $beianxinxi?>"></td>
  </tr>
  <tr bgcolor="#c8ddf4">
    <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">站长联系方式：</td>
    <td align="left" bgcolor="#ffffff"><input name="txtwebcontact" type="text" id="txtnick8" size="60" value="<?php echo $webcontact; ?>"></td>
  </tr>
  <tr bgcolor="#c8ddf4">
    <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">统计代码：</td>
    <td align="left" bgcolor="#ffffff"><textarea name="txtcountjs" cols="60" rows="3" id="txtcountjs"><?php echo stripslashes(html_entity_decode($tongjidaima,ENT_QUOTES));?></textarea>
	<span class="paragraph">(温馨提示：<a href="http://www.cnzz.com/" target="_blank">点击这里</a> 申请统计代码)</span>
	</td>
  </tr>
  <tr bgcolor="#c8ddf4">
    <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">&nbsp;</td>
    <td align="left" bgcolor="#ffffff"><label>
      <input type="submit" name="button" id="button" value="提交">
      <input type="reset" name="button2" id="button2" value="重置">
    </label></td>
  </tr>
</table>
</form>
</center>
</body>
</html>
