<!--#include file="setup.asp"-->
<%
Dim keyword,readme,Tlink,strurl
Dim totalPut,totalnumber,CurrentPage,maxpagecount,maxperpage
Dim TotalPages,PageName,pagestart,pageend,pubUserName
Dim j, ii, n, face, i
NC_Admin.AdminChk = "51"
NC_Admin.Check
DownsysClass.admin_header
Call Linkmain
DownsysClass.admin_footer
NothingObject
Private Sub Linkmain()
	If Request("action") = "add" Then
		Call addlink
		ElseIf Request("action") = "edit" Then
		Call editlink
		ElseIf Request("action") = "savenew" Then
		Call savenew
		ElseIf Request("action") = "savedit" Then
		Call savedit
		ElseIf Request("action") = "del" Then
		Call del
		ElseIf Request("action") = "lock" Then
		Call locklink
		ElseIf Request("action") = "free" Then
		Call freelink
	Else
		Call linkinfo
	End If
	If Founderr = True Then
		Call NC_Admin.Error_Msg(ErrMsg)
	End If
End Sub


Private Sub addlink()
	Response.Write "<form action=""?action=savenew"" method = post>" & vbCrLf
	Response.Write "<table width=""95%"" border=""0"" cellspacing=""1"" cellpadding=""3"" align=center class=""tableBorder"">" & vbCrLf
	Response.Write " <tr> " & vbCrLf
	Response.Write " <th width=""100%"" colspan=2 height=25>添加友情链接 </th>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr> " & vbCrLf
	Response.Write " <td width=""40%"" height=25 class=forumrow>主页名称 </td>" & vbCrLf
	Response.Write " <td width=""60%"" height=25 class=forumrow> " & vbCrLf
	Response.Write " <input type=""text"" name=""name"" size=40>" & vbCrLf
	Response.Write " </td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr> " & vbCrLf
	Response.Write " <td width=""40%"" height=25 class=forumrow>连接URL </td>" & vbCrLf
	Response.Write " <td width=""60%"" class=forumrow> " & vbCrLf
	Response.Write " <input type=""text"" name=""url"" value=""http://"" size=40>" & vbCrLf
	Response.Write " </td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr> " & vbCrLf
	Response.Write " <td width=""40%"" height=25 class=forumrow>连接LOGO地址 </td>" & vbCrLf
	Response.Write " <td width=""60%"" class=forumrow> " & vbCrLf
	Response.Write " <input type=""text"" name=""logo"" value=""http://"" size=40>" & vbCrLf
	Response.Write " </td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr> " & vbCrLf
	Response.Write " <td width=""40%"" height=25 class=forumrow>简介 </td>" & vbCrLf
	Response.Write " <td width=""60%"" class=forumrow> " & vbCrLf
	Response.Write " <input type=""text"" name=""readme"" size=40>" & vbCrLf
	Response.Write " </td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr> " & vbCrLf
	Response.Write " <td width=""40%"" height=25 class=forumrow>在首页是文字连接还是LOGO连接 </td>" & vbCrLf
	Response.Write " <td width=""60%"" class=forumrow> " & vbCrLf
	Response.Write " 文字连接<input type=""radio"" name=""islogo"" value=0 checked>&nbsp;&nbsp;LOGO连接<input type=""radio"" name=""islogo"" value=1>" & vbCrLf
	Response.Write " </td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr> " & vbCrLf
	Response.Write " <td height=""15"" align=center colspan=""2"" class=forumrow> "
	Response.Write " <input type=""button"" name=""Submit1"" onclick=""javascript:history.go(-1)"" value=""返回上一页"" class=button>　" & vbCrLf
	Response.Write " <input type=""submit"" name=""Submit"" class=""button"" value=""添 加"">" & vbCrLf
	Response.Write " </td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write "</table>" & vbCrLf
	Response.Write "</form>" & vbCrLf
End Sub


Private Sub editlink()
	Set Rs = CreateObject("adodb.recordset")
	SQL = "select * from [NC_link] where linkid=" & Request("id")
	Rs.Open SQL, Conn, 1, 1
	Response.Write "<form action=""?action=savedit"" method=post>" & vbCrLf
	Response.Write "<input type=hidden name=id value="
	Response.Write Request("id")
	Response.Write ">" & vbCrLf
	Response.Write "<table width=""95%"" border=""0"" cellspacing=""1"" cellpadding=""3"" align=center class=""tableBorder"">" & vbCrLf
	Response.Write " <tr> " & vbCrLf
	Response.Write " <th width=""100%"" colspan=2 height=25>编辑友情链接</th>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr> " & vbCrLf
	Response.Write " <td width=""40%"" class=forumrow>主页名称：</td>" & vbCrLf
	Response.Write " <td width=""60%"" class=forumrow> " & vbCrLf
	Response.Write " <input type=""text"" name=""name"" size=40 value="
	Response.Write Rs("Linkname")
	Response.Write ">" & vbCrLf
	Response.Write " </td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr> " & vbCrLf
	Response.Write " <td width=""40%"" class=forumrow>连接URL： </td>" & vbCrLf
	Response.Write " <td width=""60%"" class=forumrow> " & vbCrLf
	Response.Write " <input type=""text"" name=""url"" size=40 value="
	Response.Write Rs("Lurl")
	Response.Write ">" & vbCrLf
	Response.Write " </td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr> " & vbCrLf
	Response.Write " <td width=""40%"" class=forumrow>连接LOGO地址： </td>" & vbCrLf
	Response.Write " <td width=""60%"" class=forumrow> " & vbCrLf
	Response.Write " <input type=""text"" name=""logo"" size=40 value="""
	Response.Write Rs("logo")
	Response.Write """>" & vbCrLf
	Response.Write " </td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr> " & vbCrLf
	Response.Write " <td width=""40%"" class=forumrow>简介：</td>" & vbCrLf
	Response.Write " <td width=""60%"" class=forumrow> " & vbCrLf
	Response.Write " <input type=""text"" name=""readme"" size=40 value="
	Response.Write Rs("readme")
	Response.Write ">" & vbCrLf
	Response.Write " </td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr> " & vbCrLf
	Response.Write " <td width=""40%"" height=25 class=forumrow>在首页是文字连接还是LOGO连接 </td>" & vbCrLf
	Response.Write " <td width=""60%"" class=forumrow> " & vbCrLf
	Response.Write " 文字连接<input type=""radio"" name=""islogo"" value=0 "
	If Rs("islogo") = 0 Then
		Response.Write "checked"
	End If
	Response.Write ">&nbsp;&nbsp;LOGO连接<input type=""radio"" name=""islogo"" value=1 "
	If Rs("islogo") = 1 Then
		Response.Write "checked"
	End If
	Response.Write ">" & vbCrLf
	Response.Write " </td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " <tr> " & vbCrLf
	Response.Write " <td height=""15"" align=center colspan=""2"" class=forumrow> " & vbCrLf
	Response.Write " <div align=""center"">"
	Response.Write " <input type=""button"" name=""Submit1"" onclick=""javascript:history.go(-1)"" value=""返回上一页"" class=button>　" & vbCrLf
	Response.Write " <input type=""submit"" name=""Submit"" class=""button"" value=""修 改"">" & vbCrLf
	Response.Write " </div>" & vbCrLf
	Response.Write " </td>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write "</table>" & vbCrLf
	Response.Write "</form>" & vbCrLf
	Rs.Close
	Set Rs = Nothing
End Sub


Private Sub linkinfo()
	keyword = Trim(Request("keyword"))
	If Not IsEmpty(Request("page")) Then
		CurrentPage = CInt(Request("page"))
	Else
		CurrentPage = 1
	End If
	maxperpage = 15 '###每页显示数
	PageName = "admin_link.asp"
	Set Rs = CreateObject("adodb.recordset")
	If Not IsNull(keyword) And keyword <> "" Then
		keyword = Replace(Replace(Replace(keyword, "'", "‘"), "<", "&lt;"), ">", "&gt;")
		SQL = "select * from [NC_link] where LinkName  like '%" & keyword & "%'"
		SQL = SQL & " order by linkid desc"
	Else
		SQL = " select * from [NC_link] order by linkid"
	End If
	DownsysClass.SqlQueryNum = DownsysClass.SqlQueryNum + 1
	Rs.Open SQL, Conn, 1, 1
	If Not (Rs.bof Or Rs.EOF) Then
		Rs.pagesize = maxperpage
		maxpagecount = Rs.pagecount '###记录总页数
		totalnumber = CInt(Rs.recordcount) '###记录总数
		Rs.absolutepage = CurrentPage '###当前页数
		ii = 0
		Rem #######显示多少页##########
		pagestart = CurrentPage - 3
		pageend = CurrentPage + 3
		Rem ##########################
		n = CurrentPage
		If pagestart < 1 Then
			pagestart = 1
		End If
		If pageend > maxpagecount Then
			pageend = maxpagecount
		End If
		If n < maxpagecount Then
			n = maxpagecount
		End If
		Response.Write "<table width=""95%"" border=""0"" cellspacing=""1"" cellpadding=""3"" align=center class=""tableBorder"">" & vbCrLf
		Response.Write " <tr> " & vbCrLf
		Response.Write " <th height=""22"" colspan=5>友情链接列表 | <a href=""admin_link.asp?action=add""><font color=#FFFFFF>增加新的友情链接</font></a></th>" & vbCrLf
		Response.Write " </tr>" & vbCrLf
		Response.Write " <tr> " & vbCrLf
		Response.Write " <td height=""22"" colspan=5 class=forumrow><form name=""searchsoft"" method=""POST"" action=""admin_link.asp"" target=""main"">" & vbCrLf
		Response.Write "按名称搜索：<input class=smallInput type=""text"" name=""keyword"" size=""25"" class=""kuang""> <input type=""submit"" value=""搜索链接"" name=""submit"" class=""kuang"">" & vbCrLf
		Response.Write " </td></form>" & vbCrLf
		Response.Write " </tr>" & vbCrLf
		Response.Write " <tr align=center>" & vbCrLf
		Response.Write " <td width=""10%"" height=25 class=""forumHeaderBackgroundAlternate""><B>序号</B></td>" & vbCrLf
		Response.Write " <td width=""30%"" class=""forumHeaderBackgroundAlternate""><B>名称</B></td>" & vbCrLf
		Response.Write " <td width=""20%"" class=""forumHeaderBackgroundAlternate""><B>链接类型</B></td>" & vbCrLf
		Response.Write " <td width=""30%"" class=""forumHeaderBackgroundAlternate""><B>操 作</B></td>" & vbCrLf
		Response.Write " <td width=""10%"" class=""forumHeaderBackgroundAlternate""><B>状 态</B></td>" & vbCrLf
		Response.Write " </tr>" & vbCrLf
		j = (CurrentPage - 1) * maxperpage + 1
		Do While Not Rs.EOF And ii < Rs.pagesize
			Response.Write " <tr align=center>" & vbCrLf
			Response.Write " <td height=25 class=forumrow><font color=red>"
			Response.Write j
			Response.Write "</font></td>" & vbCrLf
			Response.Write " <td class=forumrow><a href="
			Response.Write Rs("Lurl")
			Response.Write " target=_blank>"
			Response.Write Rs("Linkname")
			Response.Write "</a></td>" & vbCrLf
			Response.Write " <td class=forumrow>"
			If Rs("islogo") = 1 Then
				Response.Write "LOGO链接"
			Else
				Response.Write "文字链接"
			End If
			Response.Write "</td>" & vbCrLf
			Response.Write " <td class=forumrow> <a href=""admin_link.asp?action=edit&id="
			Response.Write Rs("Linkid")
			Response.Write """><u>编辑</u></a> | <a href=""admin_link.asp?action=lock&id="
			Response.Write Rs("linkid")
			Response.Write """><u>锁定</u></a> | <a href=""admin_link.asp?action=free&id="
			Response.Write Rs("linkid")
			Response.Write """><u>解锁</u></a> | <a href=""admin_link.asp?action=del&id="
			Response.Write Rs("linkid")
			Response.Write """ onclick=""{if(confirm('此操作将删除本友情连接\n 您确定执行此操作吗?')){this.document.myform.submit();return true;}return false;}""><u>删除</u></a></td>" & vbCrLf
			Response.Write " <td height=25 class=forumrow>"
			If Rs("isLock") = 0 Then
				Response.Write "正常"
			Else
				Response.Write "<font color=red>锁定</font>"
			End If
			Response.Write "</td>" & vbCrLf
			Response.Write " </tr>" & vbCrLf
			Rs.movenext
			j = j + 1
			ii = ii + 1
		Loop
		Rs.Close
		Set Rs = Nothing
	Else
		Response.Write ("暂时还没有任何友情连接")
	End If
	Response.Write "<tr><td colspan=5 class=forumRowHighlight>"
	Call showpage
	Response.Write "</td></tr>"
	Response.Write "</table>"
End Sub
Private Sub savenew()
	Dim linknum
	If Request("url") <> "" And Request("readme") <> "" And Request("name") <> "" Then
		Set Rs = CreateObject("adodb.recordset")
		SQL = "select * from [NC_link] order by Linkid desc"
		Rs.Open SQL, Conn, 1, 3
		If Rs.EOF And Rs.bof Then
			linknum = 1
		Else
			linknum = Rs("Linkid") + 1
		End If
		SQL = "insert into NC_link(Linkid,Linkname,readme,logo,Lurl,islogo,isLock) values(" & linknum & ",'" & Trim(Request.Form("name")) & "','" & Trim(Request.Form("readme")) & "','" & Trim(Request.Form("logo")) & "','" & Request.Form("url") & "','" & Request.Form("islogo") & "',0)"
		Conn.Execute (SQL)
		Rs.Close
		Set Rs = Nothing
		NC_Admin.Succeed_Msg("添加成功，请继续其他操作。")
	Else
		ErrMsg = ErrMsg + "<br>" + "请输入完整友情链接信息。"
		Founderr = True
		Exit Sub
	End If
End Sub

Private Sub savedit()
	Dim Rs,SQL
	Set Rs = CreateObject("adodb.recordset")
	SQL = "select * from [NC_Link] where Linkid=" & Request("id")
	Rs.Open SQL, Conn, 1, 3
		Rs("Linkname") =  Request.Form("name")
		Rs("readme") = Request.Form("readme")
		Rs("logo") = Request.Form("logo")
		Rs("Lurl") = Request.Form("url")
		Rs("islogo") = Request.Form("islogo")
		NC_Admin.Succeed_Msg ("更新成功，请继续其他操作。")
				Rs.Update
	Rs.Close
	Set Rs = Nothing
End Sub
Private Sub del()
	Dim id
	id = Request("id")
	SQL = "delete from [NC_link] where Linkid=" + id
	Conn.Execute (SQL)
	NC_Admin.Succeed_Msg ("删除成功，请继续其他操作。")
	Call cache_link
End Sub
Private Sub locklink()
	Dim id
	id = Request("id")
	Conn.Execute ("update [NC_link] set islock=1 where Linkid=" + id)
	NC_Admin.Succeed_Msg ("锁定操作成功，请继续其他操作。")
	Call cache_link
End Sub
Private Sub freelink()
	Dim id
	id = Request("id")
	Conn.Execute ("update [NC_link] set islock=0 where Linkid=" + id)
	NC_Admin.Succeed_Msg ("解除锁定操作成功，请继续其他操作。")
	Call cache_link
End Sub
Private Sub showpage()
	Response.Write "<table width=""96%"" border=""0"" align=""center"" cellpadding=""0"" cellspacing=""2"">" & vbCrLf
	Response.Write " <tr><form method=""POST"" action="""
	Response.Write PageName
	Response.Write """ >" & vbCrLf
	Response.Write " <td class=""td1"" align=""center"">共有"
	Response.Write totalnumber
	Response.Write "个 <a href="
	Response.Write PageName
	Response.Write "?page=1 title=返回第一页><font face=""Webdings"">97</font></a> "
	For i = pagestart To pageend
		If i = 0 Then
			i = 1
		End If
		strurl = "<a href=" & PageName & "?page=" & i & " title=第" & i & "页>[" & i & "]</a>"
		Response.Write strurl
		Response.Write " "
	Next
	Response.Write "<a href="
	Response.Write PageName
	Response.Write "?page="
	Response.Write maxpagecount
	Response.Write " title=尾页><font face=""Webdings"">8:</font></a> 页次:<font color=red>"
	Response.Write CurrentPage
	Response.Write "</font> / "
	Response.Write maxpagecount
	Response.Write "页 每页:"
	Response.Write maxperpage
	Response.Write " 转到:<select name='page' align=""absmiddle"" size='1' style=""font-size: 9pt"" onChange='javascript:submit()'>" & vbCrLf
	Response.Write " "
	For i = 1 To n
		Response.Write " <option value='"
		Response.Write i
		Response.Write "' "
		If CurrentPage = CInt(i) Then
			Response.Write " selected "
		End If
		Response.Write ">第"
		Response.Write i
		Response.Write "页</option>" & vbCrLf
		Response.Write " "
	Next
	Response.Write " </select>" & vbCrLf
	Response.Write " </td></form>" & vbCrLf
	Response.Write " </tr>" & vbCrLf
	Response.Write " </table>"
End Sub
%>
