<%
on error resume next
if err then
err.clear
end if
%>
<!--#include file="inc/right.asp"--> 
<!--#include file="inc/conn.asp"-->
<!--#include file="../inc/config.asp"-->
<!--#include file="inc/function.asp"-->
<%
dim ObjInstalled,Action,FoundErr,ErrMsg
ObjInstalled=IsObjInstalled("Scripting.FileSystemObject")
Action=trim(request("Action"))
if Action="" then
	Action="ShowInfo"
end if
%>
<html>
<head>
<title><%=sysConfig%></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/main.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
<!--
 function changeN()
 {
  add.spec.disabled=true;
 }
 function changeY()
 {
  add.spec.disabled=false;
 }
 function next()
 {
  if(event.keyCode==13)event.keyCode=9;
 }
-->
</script>
</head>
<body>
<%
if Action="SaveConfig" then
	call SaveConfig()
	Response.Redirect "SiteConfig.asp" 
else
	call ShowConfig()
end if
if FoundErr=true then
	call WriteErrMsg()
end if
sub ShowConfig()
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td bgcolor="#FFFFFF"><br>
     <form method="POST" action="SiteConfig.asp" id="form" name="form">
      <table width="96%"  border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#aec3de">
		<tr align="center" bgcolor="#F2FDFF">
          <td width="100" class="optiontitle" colspan="2">网站基本设置</td>	
        </tr>
        <tr> 
          <td align="right" bgcolor="#FFFFFF">评选投票站点名称：</td>
          <td bgcolor="#FFFFFF"><input name="SiteName" type="text" id="SiteName" value="<%=SiteName%>" size="40" maxlength="50" onKeyDown="next()"></td>
        </tr>
        <tr>
          <td align="right" bgcolor="#FFFFFF">24小时内同ip可投票次数：</td>
          <td bgcolor="#FFFFFF"><input name="gz" type="text" id="gz" value="<%=gz%>" size="10" maxlength="10" onKeyDown="next()">
          *24小时内，同一IP可以投票的数量</td>
        </tr>
          <tr>
          <td align="right" bgcolor="#FFFFFF">24小时内同ip相同选项可投票数：</td>
          <td bgcolor="#FFFFFF"><input name="xxps" type="text" id="gz" value="<%=xxps%>" size="10" maxlength="10" onKeyDown="next()">
          *24小时内同一IP对同一选项可投票的数量</td>
        </tr>
       
        <tr> 
          <td align="right" bgcolor="#FFFFFF">评选投票开关：</td>
          <td bgcolor="#FFFFFF"><input name="ks" type="radio" value="1"<%if ""&ks&""=1 then Response.Write("checked") end if%>>开
          <input name="ks" type="radio" value="0"<%if ""&ks&""=0 then Response.Write("checked") end if%>> 关</td>
        </tr>
        <tr>
          <td align="right" bgcolor="#FFFFFF">投票关闭说明：</td>
          <td bgcolor="#FFFFFF"><textarea name="kssm" cols="60" rows="3" id="kssm" onKeyDown="next()"><%=kssm%></textarea></td>
        </tr>
        <tr> 
         <td align="right" bgcolor="#FFFFFF">网站底部信息：</td>
         <td bgcolor="#FFFFFF"><textarea name="Copyright" cols="60" rows="3" id="Copyright" onKeyDown="next()"><%=Copyright%></textarea></td>
        </tr>
        <tr> 
         <td colspan="2" align="center" bgcolor="#FFFFFF"> <input name="Action" type="hidden" id="Action" value="SaveConfig"> 
<input name="cmdSave" type="submit" id="cmdSave" value=" 保存设置 " <% If ObjInstalled=false Then response.write "disabled" %>></td>
       </tr>
<%
If ObjInstalled=false Then
	Response.Write "<tr><td height='40' colspan='3'><b><font color=red>你的服务器不支持 FSO(Scripting.FileSystemObject)! 不能使用本功能。<br>请直接修改“Inc/config.asp”文件中的内容。</font></b></td></tr>"
End If
%>
      </table>
<%
end sub
%>
</form>
    </td>
  </tr>
</table>
</body>
</HTML>
<%
 Function InPutStr(Input)'向数据库中保存字符串时用 
     IF IsEmpty(Input) Then Input="" 
     IF IsNull(Input) Then Input="" 
     IF instr(input,chr(34))>0 Then input=replace(input,chr(34),chr(39))'将"替换成',以便在向数据库里存放 
     InPutStr=input 
End function 
sub SaveConfig()
	If ObjInstalled=false Then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>你的服务器不支持 FSO(Scripting.FileSystemObject)! </li>"
		exit sub
	end if
	IF IsNumeric(Cint(trim(request("gz"))))=false then
		Response.write("<script language='javascript'>alert('您已经投票，请稍后再来投票!');location.herf(-1)';</script>")
	end if
	
	dim fso,hf
	set fso=Server.CreateObject("Scripting.FileSystemObject")
	set hf=fso.CreateTextFile(Server.mappath("../inc/config.asp"),true)
	hf.write "<" & "%" & vbcrlf
	hf.write "Const SiteName=" & chr(34) & trim(request("SiteName")) & chr(34) & "             " & vbcrlf
	hf.write "Const ks=" & chr(34) & trim(request("ks")) & chr(34) & "                         " & vbcrlf
	hf.write "Const xxps=" & chr(34) & trim(request("xxps")) & chr(34) & "                         " & vbcrlf
	hf.write "Const kssm=" & chr(34) & trim(request("kssm")) & chr(34) & "                         " & vbcrlf
	hf.write "Const gz=" & chr(34) & trim(request("gz")) & chr(34) & "                         " & vbcrlf
	hf.write "Const glsj=" & chr(34) & trim(request("glsj")) & chr(34) & "                          " & vbcrlf
	hf.write "Const Copyright=" & chr(34) & InPutStr(trim(request("Copyright"))) & chr(34) & " " & vbcrlf
	hf.write "%" & ">"
	hf.close
	set hf=nothing
	set fso=nothing	
end sub
%>