<!-- #include file="../conn.asp" -->
<!-- #include file="../cls_main.asp" -->
<!-- #include file="../cls_md5.asp" -->
<% MyDbPath = "../"
dim obj
set obj = New admin_siteLink
	call obj.AspInit()
set obj = nothing


Class admin_siteLink

	Private isEdit, y, Mesky
	Private Sub Class_Initialize()
		Set Mesky = New Cls_Main
	End Sub
	Private Sub Class_Terminate()
		Set Mesky = Nothing
	End Sub
	Public Sub AspInit()
		Response.Write "<HTML><HEAD><TITLE>友情链接管理</TITLE>" & vbCrLf
		Response.Write "<META http-equiv=Content-Type content=""text/html; charset=gb2312"">" & vbCrLf
		Response.Write "<LINK href=""admin.css"" type=text/css rel=stylesheet>" & vbCrLf
		Response.Write "</HEAD>" & vbCrLf
		Response.Write "<BODY leftmargin=""1"" topmargin=""1"">" & vbCrLf
		isEdit = False
			If Mesky.adminName = "" Then
				Mesky.strMsg = "<li>非法操作：登录超时或你没有以管理员身份登录系统，<a href=""../admin_login.asp"" target=_top>点此进入管理员登录界面</a>。"
				Call Mesky.SystemMsg
			ElseIf Mesky.checkPermission(Mesky.adminName, "53") = False Then
				Mesky.strMsg = "<li>非法操作：你没有权限进行此项操作，请联系管理员！"
				Call Mesky.SystemMsg
			Else
				Call admin_nav
				Call Main
			End If
		Response.Write "</BODY></HTML>" & vbCrLf
	End Sub

	Private Sub Main()
		Select Case Request("action")
		Case "saveadd"
			Call SaveAdd
		Case "modify"
			Call SaveModify
		Case "orders"
			Call orders
		Case "saveorders"
			Call saveorders
		Case "edit"
			isEdit = True
			Call myform
		Case "add"
			isEdit = False
			Call myform
		Case "del"
			Call del
		Case Else
			Call ViewList
		End Select
	End Sub
	Sub saveorders()
		Dim i, arrID, arrorders
		arrID = Split(Trim(Request.Form("orders_id")), ",")
		arrorders = Split(Trim(Request.Form("orders")), ",")
		For i = 0 To UBound(arrID)
		Mesky.Execute ("Update Mesky_SiteLinks set orders=" & arrorders(i) & " where ID=" & arrID(i) & "")
		Next
		Mesky.strMsg = "设置类排序操作成功。"
		Call Mesky.SystemMsg
	End Sub
	Private Sub del()
		Mesky.Execute ("delete from Mesky_SiteLinks where id=" & CLng(Request.QueryString("ID")))
		Call ViewList
	End Sub
	Private Sub SaveModify()
		Dim Rs, sql
		   
		If Not IsObject(Conn) Then ConnectionDatabase
		Set Rs = Server.CreateObject("adodb.recordset")
		sql = "select * from Mesky_SiteLinks where ID=" & CLng(Request.Form("ID"))
		Rs.open sql, Conn, 1, 3
		Rs("SiteName") = Trim(Request.Form("SiteName"))
		Rs("SiteURL") = Trim(Request.Form("SiteURL"))
		Rs("SiteLogo") = Trim(Request.Form("Logo"))
		Rs("SiteAdmin") = Trim(Request.Form("SiteAdmin"))
		Rs("Email") = Trim(Request.Form("Email"))
		If Request.Form("Password") <> Rs("Password") Then Rs("Password") = MD5(Trim(Request.Form("Password")), 16)
		Rs("Description") = Trim(Request.Form("Description"))
		Rs("LinkType") = Request.Form("LinkType")
		If Request.Form("isHot") = "yes" Then
			Rs("isHot") = 1
		Else
			Rs("isHot") = 0
		End If
		Rs("isAuditing") = Request.Form("isAuditing")
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		Mesky.strMsg = "<li>保存修改操作成功！<li><a href=""admin_siteLink.asp"">返回友情链接管理列表</a></li>"
		Call Mesky.SystemMsg
	End Sub
	Private Sub SaveAdd()
	
		Dim Rs, sql
		If Not IsObject(Conn) Then ConnectionDatabase
		Set Rs = Server.CreateObject("adodb.recordset")
		sql = "select * from Mesky_SiteLinks where (ID is null)"
		Rs.open sql, Conn, 1, 3
		Rs.AddNew
		Rs("SiteName") = Trim(Request.Form("SiteName"))
		Rs("SiteURL") = Trim(Request.Form("SiteURL"))
		Rs("SiteLogo") = Trim(Request.Form("Logo"))
		Rs("SiteAdmin") = Trim(Request.Form("SiteAdmin"))
		Rs("Email") = Trim(Request.Form("Email"))
		Rs("Password") = MD5(Trim(Request.Form("Password")), 16)
		Rs("Description") = Trim(Request.Form("Description"))
		Rs("LinkType") = Request.Form("LinkType")
		If Request.Form("isHot") = "yes" Then
			Rs("isHot") = 1
		Else
			Rs("isHot") = 0
		End If
		Rs("isAuditing") = Request.Form("isAuditing")
		Rs("Hits") = 0
		Rs("DateAndTime") = Now()
		Rs("orders") = Mesky.Execute("select Max(ID) from Mesky_SiteLinks Where LinkType=" & Request.Form("LinkType") & "")(0) + 1
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		Mesky.strMsg = "<li>添加友情操作成功！<li><a href=""?action=add"">继续添加新的友情链接。</a></li>"
		Call Mesky.SystemMsg
	End Sub
	Private Sub admin_nav()
		Response.Write "<fieldset><legend align=""center""></legend>" & vbCrLf
		Response.Write "<table width=""100%""  border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1"">" & vbCrLf
		Response.Write "<tr>" & vbCrLf
		Response.Write "  <td class=""tdbg2""><STRONG>管理快捷方式：</STRONG> <a href=""?action=add"">添加友情链接</a> | <a href=""?action=orders&LinkType=1"">图片链接排序</a> | <a href=""?action=orders&LinkType=0"">文本链接排序</a>  </td>" & vbCrLf
		Response.Write "</tr>" & vbCrLf
		Response.Write "</table>" & vbCrLf
		Response.Write "</fieldset><br>" & vbCrLf
	End Sub
	Private Sub orders()
		Dim Rs
		Response.Write "<fieldset><legend>网站友情链接管理：</legend>" & vbCrLf
		Response.Write "      <table width=""100%"" border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1"">" & vbCrLf
		Response.Write "  <COLGROUP>" & vbCrLf
		Response.Write "  <COL width=20>" & vbCrLf
		Response.Write "  <COL width=40>" & vbCrLf
		Response.Write "  <COL width=*>" & vbCrLf
		Response.Write "  <COL width=*>" & vbCrLf
		Response.Write "  <COL width=60>" & vbCrLf
		Response.Write "  <COL width=50>" & vbCrLf
		Response.Write "  <COL width=60>" & vbCrLf
		Response.Write "  <COL width=150>" & vbCrLf
		Response.Write "        <tr style=""font-weight: bold;"" align=""center"" class=""tdbg1""> " & vbCrLf
		Response.Write "          <td>ID</td>" & vbCrLf
		Response.Write "          <td>排序</td>" & vbCrLf
		Response.Write "          <td>名 称</td>" & vbCrLf
		Response.Write "          <td>描 述</td>" & vbCrLf
		Response.Write "          <td>站长</td>" & vbCrLf
		Response.Write "          <td>人气</td>" & vbCrLf
		Response.Write "          <td>链接类型</td>" & vbCrLf
		Response.Write "          <td>常规操作</td>" & vbCrLf
		Response.Write "        </tr>" & vbCrLf
		Response.Write "        <form action=""admin_SiteLink.asp"" method=""post"" name=""viewlist"">" & vbCrLf
		Response.Write "        <input name=""action"" type=""hidden"" value=""saveorders"">" & vbCrLf
		Set Rs = Mesky.Execute("select * from Mesky_SiteLinks where LinkType=" & Request("LinkType") & " order by orders asc,hits desc ")
		If Not (Rs.EOF And Rs.BOF) Then
			Do While Not Rs.EOF
			Response.Write "          <tr class=""tdbg2""> " & vbCrLf
			Response.Write "            <td align=""center"">" & Rs("ID") & "</td>" & vbCrLf
			Response.Write "            <td><input name=""orders_id"" type=""hidden"" value=""" & Rs("ID") & """>"
			Response.Write "            <input name=""orders"" type=""text"" id=""orders"" size=""5"" maxlength=""3"" value=""" & Rs("orders") & """></td>" & vbCrLf
			Response.Write "            <td><a href=""" & Rs("SiteURL") & """ target=""_blank"">" & Rs("SiteName") & "</a></td>" & vbCrLf
			Response.Write "            <td>" & Rs("Description") & "</td>" & vbCrLf
			Response.Write "            <td><a href=""mailto:" & Rs("email") & """>" & Rs("SiteAdmin") & "</a></td>" & vbCrLf
			Response.Write "            <td align=""center"">" & Rs("Hits") & "</td>" & vbCrLf
			Response.Write "            <td align=""center""> "
			If Rs("LinkType") = 1 Then
				Response.Write ("图片链接")
			Else
	
				Response.Write ("文本链接")
			End If
			Response.Write "            </td>" & vbCrLf
			Response.Write "            <td align=""center"">"
			Response.Write ("<a href=""?action=edit&id=" & Rs("id") & """>修改</a> | ")
			Response.Write ("<a href=""?action=del&id=" & Rs("id") & """>删除</a>")
			Response.Write "</td>" & vbCrLf
			Response.Write "          </tr>" & vbCrLf
			Rs.MoveNext
			Loop
			Response.Write "<tr><td><input name=""submit"" type=""submit"" value=""修改排序""></td></tr>"
		Else
			Response.Write ("<tr class=""tdbg3""><td colspan=""8"">没有找到任何记录！</td></tr>")
		End If
		Set Rs = Nothing
		
		Response.Write "        </form>" & vbCrLf
		Response.Write "      </table>" & vbCrLf
		Response.Write "</fieldset>" & vbCrLf
		
	End Sub
	Private Sub ViewList()
		Dim Rs
		Response.Write "<fieldset><legend>网站友情链接管理：</legend>" & vbCrLf
		Response.Write "      <table width=""100%"" border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1"">" & vbCrLf
		Response.Write "  <COLGROUP>" & vbCrLf
		Response.Write "  <COL width=20>" & vbCrLf
		Response.Write "  <COL width=*>" & vbCrLf
		Response.Write "  <COL width=*>" & vbCrLf
		Response.Write "  <COL width=60>" & vbCrLf
		Response.Write "  <COL width=50>" & vbCrLf
		Response.Write "  <COL width=60>" & vbCrLf
		Response.Write "  <COL width=150>" & vbCrLf
		Response.Write "        <tr style=""font-weight: bold;"" align=""center"" class=""tdbg1""> " & vbCrLf
		Response.Write "          <td>ID</td>" & vbCrLf
		Response.Write "          <td>名 称</td>" & vbCrLf
		Response.Write "          <td>描 述</td>" & vbCrLf
		Response.Write "          <td>站长</td>" & vbCrLf
		Response.Write "          <td>人气</td>" & vbCrLf
		Response.Write "          <td>链接类型</td>" & vbCrLf
		Response.Write "          <td>常规操作</td>" & vbCrLf
		Response.Write "        </tr>" & vbCrLf
		Response.Write "        <form action=""admin_SiteLink.asp"" method=""post"" name=""viewlist"">" & vbCrLf
		Set Rs = Mesky.Execute("select * from Mesky_SiteLinks order by orders asc,hits desc ")
		If Not (Rs.EOF And Rs.BOF) Then
		Do While Not Rs.EOF
			Response.Write "          <tr class=""tdbg2""> " & vbCrLf
			Response.Write "            <td align=""center"">" & Rs("ID") & "</td>" & vbCrLf
			Response.Write "            <td><a href=""" & Rs("SiteURL") & """ target=""_blank"">" & Rs("SiteName") & "</a></td>" & vbCrLf
			Response.Write "            <td>" & Rs("Description") & "</td>" & vbCrLf
			Response.Write "            <td><a href=""mailto:" & Rs("email") & """>" & Rs("SiteAdmin") & "</a></td>" & vbCrLf
			Response.Write "            <td align=""center"">" & Rs("Hits") & "</td>" & vbCrLf
			Response.Write "            <td align=""center"">"
			If Rs("LinkType") = 1 Then
				Response.Write ("图片链接")
			Else
				Response.Write ("文本链接")
			End If
			Response.Write "            </td>" & vbCrLf
			Response.Write "            <td align=""center""> "
			Response.Write ("<a href=""?action=edit&id=" & Rs("id") & """>修改</a> | ")
			Response.Write ("<a href=""?action=del&id=" & Rs("id") & """>删除</a>")
			Response.Write "</td>" & vbCrLf
			Response.Write "          </tr>" & vbCrLf
		Rs.MoveNext
		Loop
		Else
			Response.Write ("<tr class=""tdbg3""><td colspan=""6"">没有找到任何记录！</td></tr>")
		End If
		Set Rs = Nothing
		Response.Write "        </form>" & vbCrLf
		Response.Write "      </table>" & vbCrLf
		Response.Write "</fieldset>" & vbCrLf
	End Sub
	Private Sub myform()
		Dim Rs
		Response.Write "<fieldset><legend>" & vbCrLf
		If isEdit Then
			Set Rs = Mesky.Execute("select * from Mesky_SiteLinks where id=" & CLng(Request.QueryString("id")))
			Response.Write ("修改友情链接")
		Else
			Response.Write ("添加友情链接")
		End If
		Response.Write "：</legend>" & vbCrLf
		Response.Write "      <table width=""100%"" border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1"">" & vbCrLf
		Response.Write "        <form action=""Admin_SiteLink.asp"" method=""post"" name=""myform"">" & vbCrLf
		If isEdit Then
			Response.Write ("<input type=""Hidden"" name=""action"" value=""modify"">")
			Response.Write ("<input type=""Hidden"" name=""ID"" value=""" & Trim(Request.QueryString("id")) & """>")
		Else
			Response.Write ("<input type=""Hidden"" name=""action"" value=""saveadd"">")
		End If
		Response.Write "          <tr class=""tdbg2""> " & vbCrLf
		Response.Write "            <td align=""right"">网站名称</td>" & vbCrLf
		Response.Write "            <td > <input name=""SiteName"" type=""text"" value="""
		If isEdit Then Response.Write Trim(Rs("SiteName"))
		Response.Write """ size=""40"" maxlength=""50""> </td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg3""> " & vbCrLf
		Response.Write "            <td align=""right"">网站URL</td>" & vbCrLf
		Response.Write "            <td><input name=""SiteURL"" type=""text"" value="""
		If isEdit Then Response.Write Trim(Rs("SiteURL"))
		Response.Write """ size=""40"" maxlength=""100""> </td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg2""> " & vbCrLf
		Response.Write "            <td align=""right"">网站LOGO</td>" & vbCrLf
		Response.Write "            <td><input name=""SiteLogo"" type=""text"" value="""
		If isEdit Then Response.Write Trim(Rs("SiteLogo"))
		
		Response.Write """ size=""40"" maxlength=""100""> </td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg3"">" & vbCrLf
		Response.Write "            <td align=""right"">站 长</td>" & vbCrLf
		Response.Write "            <td><input name=""SiteAdmin"" type=""text"" value="""
	
		If isEdit Then Response.Write Trim(Rs("SiteAdmin"))
		Response.Write """ size=""40"" maxlength=""50""></td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg2"">" & vbCrLf
		Response.Write "            <td align=""right"">邮 箱</td>" & vbCrLf
		Response.Write "            <td><input name=""Email"" type=""text"" value="""
		If isEdit Then Response.Write Trim(Rs("Email"))
		Response.Write """ size=""40"" maxlength=""50""></td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg3"">" & vbCrLf
		Response.Write "            <td align=""right"">管理密码</td>" & vbCrLf
		Response.Write "            <td><input name=""Password"" type=""password"" value="""
		If isEdit Then Response.Write Trim(Rs("Password"))
		Response.Write """ size=""40"" maxlength=""50""></td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg2""> " & vbCrLf
		Response.Write "            <td align=""right"">网站简介<br> </td>" & vbCrLf
		Response.Write "            <td> <textarea name=""Description"" cols=""50"" rows=""7"">" & vbCrLf
		If isEdit Then Response.Write (Rs("Description"))
		Response.Write "</textarea> " & vbCrLf
		Response.Write "            </td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg3"">" & vbCrLf
		Response.Write "            <td align=""right"">链接方式</td>" & vbCrLf
		Response.Write "            <td>" & vbCrLf
		Response.Write "              <input type=""radio"" name=""LinkType"" value=""0"" "
		If isEdit Then
			If Rs("LinkType") = 0 Then Response.Write "checked"
		Else
			Response.Write "checked"
		End If
		Response.Write ">文字连接             " & vbCrLf
		Response.Write "              <input type=""radio"" name=""LinkType"" value=""1"" "
		If isEdit Then
			If Rs("LinkType") = 1 Then Response.Write "checked"
		End If
		Response.Write ">LOGO连接 </td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg2"">" & vbCrLf
		Response.Write "            <td align=""right"">审 核</td>" & vbCrLf
		Response.Write "            <td><input type=""radio"" name=""isAuditing"" value=""0"" "
		If isEdit Then
			If Rs("isAuditing") = 1 Then Response.Write "checked"
		Else
			Response.Write "checked"
		End If
		Response.Write ">是           " & vbCrLf
		Response.Write "              <input type=""radio"" name=""isAuditing"" value=""1"" "
		If isEdit Then
			If Rs("isAuditing") = 0 Then Response.Write "checked"
		End If
		Response.Write ">否</td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg3"">" & vbCrLf
		Response.Write "            <td align=""right"">推荐站点</td>" & vbCrLf
		Response.Write "            <td><input name=""checkbox"" type=""checkbox"" value=""yes"" "
		If isEdit Then
			If Rs("isHot") = 1 Then Response.Write ("checked")
		End If
		Response.Write "></td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg2""> " & vbCrLf
		Response.Write "            <td align=""right"">&nbsp;</td>" & vbCrLf
		Response.Write "            <td> <input type=""submit"" name=""Submit"" value=""提交""> <input type=""reset"" name=""Submit2"" value=""重置""></td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "        </form>" & vbCrLf
		Response.Write "      </table>" & vbCrLf
		Response.Write "</fieldset>" & vbCrLf
		If isEdit Then Set Rs = Nothing
	End Sub
	Public Sub OnEndPage()
		Response.Write Mesky.CopyRight
	End Sub ' OnEndPage

End Class
 %>