<%
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 check()
{
  if (document.form.SiteName.value=="")
     {
      alert("请填写选课名称！")
      document.form.SiteName.focus()
      document.form.SiteName.select()
      return
     }
 
  if (document.form.Description.value=="")
     {
      alert("请填写选课描述！")
      document.form.Description.focus()
      document.form.Description.select()
      return
     }
 
  if (document.form.Copyright.value=="")
     {
      alert("请填写选课信息！")
      document.form.Copyright.focus()
      document.form.Copyright.select()
      return
     }
	 
     document.form.submit()
}
</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"></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"><input name="Stime" type="text" id="Stime" value="<%=Stime%>" size="10" maxlength="10">
			-<input name="Etime" type="text" id="Etime" value="<%=Etime%>" size="10" maxlength="10"> 
			2018-03-01 - 2018-03-30</td>
		</tr>
        <tr> 
          <td align="right" bgcolor="#FFFFFF">选修课程数：</td>
          <td bgcolor="#FFFFFF">1门 [商业版可设置多门，退选课程功能]</td>
        </tr>
        <tr> 
         <td align="right" bgcolor="#FFFFFF">选课系统介绍：</td>
         <td bgcolor="#FFFFFF"><textarea name="Description" cols="60" rows="6" id="Description"><%=Description%></textarea></td>
        </tr>
        <tr> 
         <td align="right" bgcolor="#FFFFFF">版权信息设置：</td>
         <td bgcolor="#FFFFFF"><textarea name="Copyright" cols="60" rows="3" id="Copyright"><%=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))'将"替换成',以便在向数据库里存放 
     IF instr(input,chr(60)&chr(37))>0 Then input=replace(input,chr(60)&chr(37),chr(9))
     IF instr(input,chr(37)&chr(62))>0 Then input=replace(input,chr(37)&chr(62),chr(9))
     IF instr(input,chr(10))>0 Then input=replace(input,chr(10),chr(9))
     InPutStr=input 
End function 
sub SaveConfig()
	If ObjInstalled=false Then
		FoundErr=true
		ErrMsg=ErrMsg & "<br><li>你的服务器不支持 FSO(Scripting.FileSystemObject)! </li>"
		exit sub
	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) & InPutStr(trim(request("SiteName"))) & chr(34) & "              '选课名称" & vbcrlf
	hf.write "Const ks=" & chr(34) & trim(request("ks")) & chr(34) & "                          '是否打开" & vbcrlf
	hf.write "Const Stime=" & chr(34) & trim(request("Stime")) & chr(34) & "                '开始时间" & vbcrlf
	hf.write "Const Etime=" & chr(34) & trim(request("Etime")) & chr(34) & "                '结束时间" & vbcrlf
	hf.write "Const Description=" & chr(34) & InPutStr(trim(request("Description"))) & 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
%>