<!--#include file="../../conn.asp"-->
<!--#include file="../inc/setup.asp"-->
<!--#include file="../inc/const.asp"-->
<!--#include file="../inc/check.asp"-->
<%
Admin_header
'=====================================================================
' 软件名称：新云网站管理系统
' 当前版本：NewAsp Content Management System Version 4.0
' 文件名称：admin_config.asp
' 更新日期：2008-05-16
' 官方网站：新云网络(www.newasp.net www.newasp.cn) QQ：94022511
'=====================================================================
' Copyright 2003-2008 newasp.net - All Rights Reserved.
' newasp is a trademark of newasp.net
'=====================================================================
%>
<table class="table1" cellspacing="1" cellpadding="3" align="center" border="0">
	<tr>
		<td class="tableline linetitle" width="200" align="left">后台管理设置</td>
		<td class="tableline" width="*" align="right"><a href="admin_setting.asp">基本设置</a>
			 - <a href="admin_setting.asp?action=upload">上传设置</a>
			 - <a href="admin_setting.asp?action=editkey">内容关键字管理</a>
			 - <a href="admin_lockip.asp">IP限制管理</a>
			 - <a href="admin_badword.asp">过滤字符管理</a>
		</td>
	</tr>
</table>
<%
Dim Action
If Not ChkAdmin("9999") Then
	Call Transfer_error()
End If
Action = LCase(Request("action"))
Select Case Trim(Action)
	Case "save"
		Call SaveAdminSetting
	Case Else
		Call showmain
End Select
If FoundErr = True Then
	ReturnError(ErrMsg)
End If
Admin_footer
SaveLogInfo(AdminName)
NewAsp.PageEnd
Sub showmain()
%>
<table id="tablehovered1" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
<form name="myform" method="post" action="?action=save">
<tr>
	<th colspan="2">后台管理设置 -- 管理 <span class="clicksubmit" onclick="document.myform.submit();">[保存设置]</span></th>
</tr>
<tr>
	<td class="tablerow1" width="20%" align="right"><u>后台默认风格</u>：</td>
	<td class="tablerow1" width="80%">
	<select name="defaultadminskin">
		<option style="background:blue;color:#fff;" value="0"<%If DefaultAdminSkin=0 Then Response.Write " selected"%>>默认风格</option>
		<option style="background:blue;color:#fff;" value="1"<%If DefaultAdminSkin=1 Then Response.Write " selected"%>>风格一</option>
		<option style="background:green;color:#fff;" value="2"<%If DefaultAdminSkin=2 Then Response.Write " selected"%>>风格二</option>
		<option style="background:red;color:#fff;" value="3"<%If DefaultAdminSkin=3 Then Response.Write " selected"%>>风格三</option>
		<option style="background:red;color:#fff;" value="6"<%If DefaultAdminSkin=6 Then Response.Write " selected"%>>风格四</option>
		<option style="background:red;color:#fff;" value="5"<%If DefaultAdminSkin=5 Then Response.Write " selected"%>>风格五</option>
	</select>&nbsp;&nbsp; <font color="blue">* 清空浏览器Cookies后才会生效</font>
	</td>
</tr>
<tr>
	<td class="tablerow2" align="right"><u>后台管理Cookies功能</u>：</td>
	<td class="tablerow2">
	<input type="radio" name="admincookies" value="false"<%
	If Not UseAdminCookies Then Response.Write " checked"
	%>> 关闭&nbsp;&nbsp;
	<input type="radio" name="admincookies" value="true"<%
	If UseAdminCookies Then Response.Write " checked"
	%>> 开启&nbsp;&nbsp; <font color="blue">* 如果你的后台经常出现超时现象请打开此功能</font>
	</td>
</tr>
<tr>
	<td class="tablerow1" align="right"><u>后台管理Cookies名称</u>：</td>
	<td class="tablerow1"><input type="text" name="admincookiesname" size="35" value="<%=AdminCookiesName%>">
		<font color="red">* 建议修改Cookies名称,英文+数字。</font>
	</td>
</tr>
<tr>
	<td class="tablerow2" align="right"><u>管理员登录验证码</u>：</td>
	<td class="tablerow2">
	<input type="radio" name="admincheckcode" value="false"<%
	If Not IsAdminCheckCode Then Response.Write " checked"
	%>> 关闭&nbsp;&nbsp;
	<input type="radio" name="admincheckcode" value="true"<%
	If IsAdminCheckCode Then Response.Write " checked"
	%>> 开启&nbsp;&nbsp; <font color="red"></font>
	</td>
</tr>
<tr>
	<td class="tablerow1" align="right"><u>后台管理Session名称</u>：</td>
	<td class="tablerow1"><input type="text" name="AdminSessionName" size="35" value="<%=AdminSessionName%>">
		<font color="blue">* 建议修改Session名称,英文+数字。</font>
	</td>
</tr>
<tr>
	<td class="tablerow2" align="right"><u>管理员登录认证功能</u>：</td>
	<td class="tablerow2">
	<input type="radio" name="adminvalidate" value="false"<%
	If Not IsAdminValidate Then Response.Write " checked"
	%>> 关闭&nbsp;&nbsp;
	<input type="radio" name="adminvalidate" value="true"<%
	If IsAdminValidate Then Response.Write " checked"
	%>> 开启&nbsp;&nbsp; <font color="red">* 为了系统安全建议开启</font>
	</td>
</tr>
<tr>
	<td class="tablerow1" align="right"><u>设置管理登陆认证码</u>：</td>
	<td class="tablerow1"><input type="text" name="adminvalidatecode" size="35" value="<%=AdminValidateCode%>">
		<font color="blue">* 管理员登陆使用的认证码。</font>
	</td>
</tr>
<tr>
	<td class="tablerow2" align="right"><u>后台操作日志</u>：</td>
	<td class="tablerow2">
	<input type="radio" name="adminlogstop" value="1"<%
	If AdminLogstop=1 Then Response.Write " checked"
	%>> 关闭&nbsp;&nbsp;
	<input type="radio" name="adminlogstop" value="0"<%
	If AdminLogstop=0 Then Response.Write " checked"
	%>> 开启&nbsp;&nbsp;
	</td>
</tr>
<tr>
	<td class="tablerow1" align="right"><u>后台数据统计</u>：</td>
	<td class="tablerow1">
	<input type="radio" name="datacount" value="0"<%
	If AdminDataCount=0 Then Response.Write " checked"
	%>> 关闭&nbsp;&nbsp;
	<input type="radio" name="datacount" value="1"<%
	If AdminDataCount=1 Then Response.Write " checked"
	%>> 开启&nbsp;&nbsp;
	</td>
</tr>
<tr>
	<td class="tablerow2" align="right"><u>后台搜索自动完成</u>：</td>
	<td class="tablerow2">
	<input type="radio" name="AutoCompleteQuery" value="True"<%
	If AutoCompleteQuery=True Then Response.Write " checked"
	%>> 开启&nbsp;&nbsp;
	<input type="radio" name="AutoCompleteQuery" value="False"<%
	If AutoCompleteQuery=False Then Response.Write " checked"
	%>> 关闭&nbsp;&nbsp;
	</td>
</tr>
<tr>
	<td class="tablerow1" align="right"><u>搜索自动完成限制</u>：</td>
	<td class="tablerow1">标题长度：<input type="text" name="AutoCompletestrlen" size="5" value="<%=AutoCompletestrlen%>">&nbsp;&nbsp;
		最多结果：<input type="text" name="AutoCompletemaxnum" size="5" value="<%=AutoCompletemaxnum%>">&nbsp;&nbsp;</font>
	</td>
</tr>

<tr>
	<td class="tablerow2" align="right"><u>提示信息是否自动返回</u>：</td>
	<td class="tablerow2">
	<input type="radio" name="IsTimeoutInfo" value="True"<%
	If IsTimeoutInfo=True Then Response.Write " checked"
	%>> 是&nbsp;&nbsp;
	<input type="radio" name="IsTimeoutInfo" value="False"<%
	If IsTimeoutInfo=False Then Response.Write " checked"
	%>> 否&nbsp;&nbsp;
	</td>
</tr>
<tr>
	<td class="tablerow1" align="right"><u>是否禁止代理IP访问后台</u>：</td>
	<td class="tablerow1">
	<input type="radio" name="BanProxyAdmin" value="True"<%
	If BanProxyAdmin=True Then Response.Write " checked"
	%>> 是&nbsp;&nbsp;
	<input type="radio" name="BanProxyAdmin" value="False"<%
	If BanProxyAdmin=False Then Response.Write " checked"
	%>> 否&nbsp;&nbsp;
	</td>
</tr>

<tr>
	<td class="tablerow2" align="right"><u>后台IP限制类型</u>：</td>
	<td class="tablerow2">
	<input type="radio" name="checkiptype" value="0"<%
	If CheckIPType=0 Then Response.Write " checked"
	%>> 关闭IP限制&nbsp;&nbsp;
	<input type="radio" name="checkiptype" value="1"<%
	If CheckIPType=1 Then Response.Write " checked"
	%>> 限制登陆后台的IP&nbsp;&nbsp;
	<input type="radio" name="checkiptype" value="2"<%
	If CheckIPType=2 Then Response.Write " checked"
	%>> 允许登陆后台的IP&nbsp;&nbsp;
	</td>
</tr>
<tr>
	<td class="tablerow1" align="right"><u>限制或允许IP地址列表</u>：</td>
	<td class="tablerow1"><textarea name="AdminLockIPList" rows="10" cols="50"><%=ProcessNewline(AdminLockIPList,1)%></textarea><br>
	<b>说明：</b><font color="red">您可以添加多个限制或允许IP，每个IP用回车分隔，如：218.28.86.97或218.28.*.*；*.*.*.*将限制或者允许所有IP的访问。</font>
	</td>
</tr>
<tr>
	<td class="tablerow2" align="right"><u>后台定时开关</u>：</td>
	<td class="tablerow2">
	<input type="radio" name="admintimer" value="0"<%
	If AdminTimer=0 Then Response.Write " checked"
	%>> 关闭定时功能&nbsp;&nbsp;
	<input type="radio" name="admintimer" value="1"<%
	If AdminTimer=1 Then Response.Write " checked"
	%>> 定时关闭后台&nbsp;&nbsp;
	<input type="radio" name="admintimer" value="2"<%
	If AdminTimer=2 Then Response.Write " checked"
	%>> 定时只读&nbsp;&nbsp;
	</td>
</tr>
<tr>
	<td class="tablerow1" align="right"><u>后台定时设置</u>：</td>
	<td class="tablerow1">
<%
Dim ArrayTimerSetting,i
ArrayTimerSetting=split(TimerSetting,"|")
If UBound(ArrayTimerSetting)<2 Then
	TimerSetting="1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1|1"
	ArrayTimerSetting=split(TimerSetting,"|")
End If
For i= 0 to UBound(ArrayTimerSetting)
If i<10 Then Response.Write "&nbsp;"
%>
  <%=i%>点：<input type="checkbox" name="TimerSetting<%=i%>" value="1" <%If ArrayTimerSetting(i)="1" Then %>checked<%End If%>>开
 <%
 If (i+1) mod 4 = 0 Then Response.Write "<br>"
 Next
 %><b>注意：</b><font color="red">请小心设置，一但所有时间都打开，你将无法进行操作</font>
	</td>
</tr>
<tr>
	<td class="tablerow2" align="right">&nbsp;</td>
	<td class="tablerow2">
	<input type="button" name="Submit4" onclick="javascript:history.go(-1)" value="返回上一页" class="button">
	<input type="submit" value="保存设置" name="B1" class="button">
	<font color="blue">注意：如果后台被关闭不能进入，请使用管理员工具(adminkey.asp)修改后台设置</font>
	</td>
</tr>
</form>
</table>
<%

End Sub

Sub SaveAdminSetting()
	Dim strTimerSetting,i
	Dim m_AdminValidate,m_strValidateCode
	Dim m_AdminCookies,m_strAdminCookiesName
	Dim m_AdminCheckCode,m_strAdminSessionName
	strTimerSetting=""
	On Error Resume Next

	For i=0 to  23
		If strTimerSetting="" Then
			If Request.Form("TimerSetting"&i)="1" Then
				strTimerSetting="1"
			Else
				strTimerSetting="0"
			End If
		Else
			If Request.Form("TimerSetting"&i)="1" Then
				strTimerSetting=strTimerSetting&"|1"
			Else
				strTimerSetting=strTimerSetting&"|0"
			End If
		End If
	Next
	m_AdminValidate = NewAsp.ChkBoolean(Request.Form("adminvalidate"))
	m_AdminCheckCode = NewAsp.ChkBoolean(Request.Form("admincheckcode"))
	m_strValidateCode = ChkRequestForm("adminvalidatecode")
	m_AdminCookies = NewAsp.ChkBoolean(Request.Form("admincookies"))
	m_strAdminCookiesName = ChkRequestForm("admincookiesname")
	m_strAdminSessionName = ChkRequestForm("adminsessionname")
	If m_strValidateCode = "0" Then m_strValidateCode = "admin"
	If m_strAdminCookiesName = "0" Then m_strAdminCookiesName = "NewAspCookies"
	If m_strAdminSessionName = "0" Then m_strAdminSessionName = "NewAspSession"

	Dim strTempCode
	strTempCode = Chr(60) & "%"& vbCrLf
	strTempCode = strTempCode & "Const DefaultAdminSkin		= "& ChkRequestForm("defaultadminskin") & vbCrLf
	strTempCode = strTempCode & "Const UseAdminCookies		= "& m_AdminCookies & vbCrLf
	strTempCode = strTempCode & "Const AdminCookiesName		= """& m_strAdminCookiesName &""""& vbCrLf
	strTempCode = strTempCode & "Const AdminSessionName		= """& m_strAdminSessionName &""""& vbCrLf
	strTempCode = strTempCode & "Const IsAdminValidate		= "& m_AdminValidate & vbCrLf
	strTempCode = strTempCode & "Const AdminValidateCode		= """& m_strValidateCode &""""& vbCrLf
	strTempCode = strTempCode & "Const IsAdminCheckCode		= "& m_AdminCheckCode & vbCrLf
	strTempCode = strTempCode & "Const AdminLogstop			= "& ChkRequestForm("adminlogstop") & vbCrLf
	strTempCode = strTempCode & "Const AdminLockIPList		= """& ProcessNewline(ChkRequestForm("AdminLockIPList"),0) &""""& vbCrLf
	strTempCode = strTempCode & "Const CheckIPType			= "& NewAsp.ChkNumeric(Request.Form("checkiptype")) & vbCrLf
	strTempCode = strTempCode & "Const AdminTimer			= "& NewAsp.ChkNumeric(Request.Form("admintimer")) & vbCrLf
	strTempCode = strTempCode & "Const TimerSetting			= """& strTimerSetting &""""& vbCrLf
	strTempCode = strTempCode & "Const AdminDataCount		= "& NewAsp.ChkNumeric(Request.Form("datacount")) & vbCrLf
	strTempCode = strTempCode & "Const BanProxyAdmin		= "& ChkRequestForm("BanProxyAdmin") & vbCrLf
	strTempCode = strTempCode & "Const IsTimeoutInfo		= "& ChkRequestForm("IsTimeoutInfo") & vbCrLf
	strTempCode = strTempCode & "Const AutoCompleteQuery	= "& ChkRequestForm("AutoCompleteQuery") & vbCrLf
	strTempCode = strTempCode & "Const AutoCompletestrlen	= "& NewAsp.ChkNumeric(Request.Form("AutoCompletestrlen")) & vbCrLf
	strTempCode = strTempCode & "Const AutoCompletemaxnum	= "& NewAsp.ChkNumeric(Request.Form("AutoCompletemaxnum")) & vbCrLf
	strTempCode = strTempCode & "%"& Chr(62)

	If m_AdminValidate Then
		Session("validate") = m_strValidateCode
		Response.Cookies(m_strAdminCookiesName)("validate") = m_strValidateCode
	Else
		Session("validate") = ""
		Response.Cookies(m_strAdminCookiesName)("validate") = ""
	End If

	writeTextFile "../inc/config.inc",strTempCode

	Succeed("<li>恭喜您！保存设置成功。</li>")
End Sub

Function writeTextFile(fileName,Text)
	NewAspStream.charset="GB2312"
	NewAspStream.Type = 2
	NewAspStream.Mode = 3
	NewAspStream.open()
	NewAspStream.WriteText(Text)
	NewAspStream.SaveToFile ChkMapPath(fileName),2
	NewAspStream.close()
End Function

Function ChkRequestForm(ByVal reform)
	Dim strForm
	strForm = Trim(Request.Form(reform))
	If IsNull(strForm) Then
		strForm = "0"
	Else
		strForm = Replace(strForm, Chr(0), vbNullString)
		strForm = Replace(strForm, Chr(34), vbNullString)
		strForm = Replace(strForm, Chr(255), vbNullString)
		strForm = Replace(strForm, "'", vbNullString)
		strForm = Replace(strForm, """", vbNullString)
	End If
	If strForm = "" Then strForm = "0"
	ChkRequestForm = strForm
End Function

Function ProcessNewline(str,stype)
	str = Trim(str&"")
	If Len(str) < 2 Then
		ProcessNewline = ""
		Exit Function
	End If
	str = Replace(str, vbNewline, "|")
	str = Replace(str, Chr(13), "")
	str = Replace(str, Chr(10), "|")
	Dim a,s,i
	a = Split(str, "|")
	For i = 0 To UBound(a)
		If Len(a(i)) > 0 Then
			s = s & a(i) & "|"
		End If
	Next
	s = Left(s,Len(s)-1)
	If stype = 1 Then
		ProcessNewline = Replace(s, "|", vbNewline)
	Else
		ProcessNewline = s
	End If
End Function

%>