<!--#include file="../conns.asp"-->
<!--#include file="../inc/const.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../inc/classmenu.asp"-->
<%
Dim Rs, SQL, FoundErr,ErrMsg
Dim isLock,HtmlContent,ListContent
FoundErr = False

Newasp.PreventInfuse

Newasp.LoadTemplates 9999, 6, 0

HtmlContent = Newasp.HtmlContent
HtmlContent = Replace(HtmlContent,"{$InstallDir}", Newasp.InstallDir)
HtmlContent = Replace(HtmlContent, "{$ChannelID}", 0)
HtmlContent = Replace(HtmlContent,"{$PageTitle}","申请友情连接")

isLock = Newasp.ChkNumeric(Newasp.HtmlSetting(3))   '设置申请连接默认状态。0=正常显示，1=锁定

HtmlContent = ReadClassMenu(HtmlContent)
HtmlContent = ReadClassMenubar(HtmlContent)
ListContent = Newasp.CutFixContent(HtmlContent, "<!--ListBegin", "ListEnd-->", 1)
HtmlContent = Replace(HtmlContent, ListContent, Newasp.HtmlSetting(5))

If Newasp.CheckStr(LCase(Request.Form("action"))) = "save" Then
	Call FriendLinkSave
Else
	If CInt(Newasp.StopApplyLink) <> 0 Then
		Call OutAlertScript(Newasp.HtmlSetting(6))
	Else
		Response.Write HtmlContent
	End If
End If

Sub FriendLinkSave()
	Call PreventRefresh
	If CInt(Newasp.StopApplyLink) <> 0 Then
		Call OutAlertScript(Newasp.HtmlSetting(6))
		Founderr = True
	End If
	If Trim(Request.Form("LinkName")) = "" Then
		ErrMsg = ErrMsg + "网站名称不能为空\n"
		Founderr = True
	End If
	If Trim(Request.Form("LinkUrl")) = "" Then
		ErrMsg = ErrMsg + "网站URL不能为空\n"
		Founderr = True
	End If
	If Trim(Request.Form("Readme")) = "" Then
		ErrMsg = ErrMsg + "网站简介不能为空\n"
		Founderr = True
	End If
	If Trim(Request.Form("password1")) = "" Then
		ErrMsg = ErrMsg + "管理密码不能为空\n"
		Founderr = True
	End If
	If Trim(Request.Form("password2")) = "" Then
		ErrMsg = ErrMsg + "确认管理密码不能为空\n"
		Founderr = True
	End If
	If Newasp.IsValidPassword(Request("password2")) = False Then
		ErrMsg = ErrMsg + "管理密码中含有非法字符\n"
		Founderr = True
	End If
	If Trim(Request.Form("password1")) <> Trim(Request.Form("password2")) Then
		ErrMsg = ErrMsg + "管理密码和确认密码不一至，请重新输入管理密码\n"
		Founderr = True
	End If
	Set Rs = Newasp.Execute("SELECT LinkID FROM NC_Link WHERE LinkName='" & Replace(Request.Form("LinkName"), "'", "") & "' And LinkUrl='" & Replace(Request.Form("LinkUrl"), "'", "") & "'")
	If Not (Rs.EOF And Rs.BOF) Then
		ErrMsg = "您申请的友情连接已经存在！"
		Founderr = True
	End If
	Set Rs = Nothing
	If Founderr = True Then
		Call OutAlertScript(ErrMsg)
		Exit Sub
	End If
	Set Rs = Server.CreateObject("ADODB.Recordset")
	SQL = "SELECT * FROM NC_Link WHERE (LinkID is null)"
	Rs.Open SQL,Conn,1,3
	Rs.Addnew
		Rs("LinkName") = Newasp.FormEncode(Request.Form("LinkName"),50)
		Rs("LinkUrl") = Newasp.FormEncode(Request.Form("LinkUrl"),200)
		Rs("LogoUrl") = Newasp.FormEncode(Request.Form("LogoUrl"),200)
		Rs("Readme") = Newasp.FormEncode(Request.Form("Readme"),200)
		Rs("LinkTime") = Now()
		Rs("password") = md5(Request.Form("password2"))
		Rs("LinkHist") = 0
		Rs("isLogo") = Newasp.ChkNumeric(Request.Form("isLogo"))
		Rs("isIndex") = 0
		Rs("isLock") = isLock
	Rs.update
	Rs.Close:Set Rs = Nothing
	Call OutputScript(Newasp.HtmlSetting(7),"index.asp")
End Sub
CloseConn
%>