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

Class admin_down_site

	Private isEdit, ishion
	Private Sub Class_Initialize()
		Set ishion = New Cls_Main
	End Sub
	Private Sub Class_Terminate()
		Set ishion = 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=2>" & vbCrLf
		
			If ishion.adminName = "" Then
				ishion.strMsg = "<li>非法操作：登录超时或你没有以管理员身份登录系统，<a href=""../admin_login.asp"" target=_top>点此进入管理员登录界面</a>。"
				Call ishion.SystemMsg
			ElseIf ishion.checkPermission(ishion.adminName, 0) = False Then
				ishion.strMsg = "<li>非法操作：你没有权限进行此项操作，请联系管理员！"
				Call ishion.SystemMsg
			Else
				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 "edit"
		   isEdit = True
		   Call myform
	  Case "add"
		   isEdit = False
		   Call myform
	  Case "del"
		   Call del
	  'Case "isActive"
		   'Call isActive
	  Case Else
		   Call ViewList
	  End Select
	End Sub
	  
	Private Sub del()
		Conn.Execute ("delete from ishion_Down_SiteSetting where id=" & Trim(Request.QueryString("ID")))
		Call ViewList
	End Sub
		
		'sub isActive()
		'conn.execute("update ishion_Down_SiteSetting set isActive=0")
		'conn.execute("update ishion_Down_SiteSetting set isActive=1 where ID="&Trim(Request.Form("isActive")))
		'call Viewlist()
		'end sub
		
	Private Sub SaveModify()
		Dim Rs, sql, DownloadName, DownloadName_1, i
		Set Rs = Server.CreateObject("adodb.recordset")
		If Not IsObject(Conn) Then ConnectionDatabase
		sql = "select * from ishion_Down_SiteSetting where ID=" & CLng(Request.Form("ID"))
		Rs.open sql, Conn, 1, 3
		Rs("SiteName") = Trim(Request.Form("SiteName"))
		Rs("SiteURL") = Trim(Request.Form("SiteURL"))
		DownloadName = Split(Request.Form("DownloadName"), Chr(13) & Chr(10))
		For i = 0 To UBound(DownloadName)
			If Not (DownloadName(i) = "" Or DownloadName(i) = " ") Then
				If i <> UBound(DownloadName) Then
					DownloadName_1 = "" & DownloadName_1 & "" & DownloadName(i) & ","
				Else
					DownloadName_1 = "" & DownloadName_1 & "" & DownloadName(i) & ""
				End If
			End If
		Next
		Rs("DownloadName") = Trim(DownloadName_1)
		Dim DownloadURL, DownloadURL_1
		DownloadURL = Split(Request.Form("DownloadURL"), Chr(13) & Chr(10))
		For i = 0 To UBound(DownloadURL)
			If Not (DownloadURL(i) = "" Or DownloadURL(i) = " ") Then
				If i <> UBound(DownloadURL) Then
					DownloadURL_1 = "" & DownloadURL_1 & "" & DownloadURL(i) & ","
				Else
					DownloadURL_1 = "" & DownloadURL_1 & "" & DownloadURL(i) & ""
				End If
			End If
		Next
		Rs("DownloadURL") = Trim(DownloadURL_1)
		Rs("Description") = Trim(Request.Form("Description"))
		Rs("isLB") = Request.Form("isLB")
		Rs("isdefault") = Request.Form("isdefault")
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		ishion.strMsg = "<li>保存修改成功！"
		Call ishion.SystemMsg
	End Sub
		
	Private Sub SaveAdd()
		Dim Rs, sql, DownloadName, DownloadName_1, i
		If Not IsObject(Conn) Then ConnectionDatabase
		Set Rs = Server.CreateObject("adodb.recordset")
		sql = "select * from ishion_Down_SiteSetting where (ID is null)"
		Rs.open sql, Conn, 1, 3
		Rs.AddNew
		Rs("SiteName") = Trim(Request.Form("SiteName"))
		Rs("SiteURL") = Trim(Request.Form("SiteURL"))
		DownloadName = Split(Request.Form("DownloadName"), Chr(13) & Chr(10))
		For i = 0 To UBound(DownloadName)
			If Not (DownloadName(i) = "" Or DownloadName(i) = " ") Then
				If i <> UBound(DownloadName) Then
					DownloadName_1 = "" & DownloadName_1 & "" & DownloadName(i) & ","
				Else
					DownloadName_1 = "" & DownloadName_1 & "" & DownloadName(i) & ""
				End If
			End If
		Next
		Rs("DownloadName") = Trim(DownloadName_1)
		Dim DownloadURL, DownloadURL_1
		DownloadURL = Split(Request.Form("DownloadURL"), Chr(13) & Chr(10))
		For i = 0 To UBound(DownloadURL)
			If Not (DownloadURL(i) = "" Or DownloadURL(i) = " ") Then
				If i <> UBound(DownloadURL) Then
					DownloadURL_1 = "" & DownloadURL_1 & "" & DownloadURL(i) & ","
				Else
					DownloadURL_1 = "" & DownloadURL_1 & "" & DownloadURL(i) & ""
				End If
			End If
		Next
		Rs("DownloadURL") = Trim(DownloadURL_1)
		Rs("Description") = Trim(Request.Form("Description"))
		Rs("isLB") = Request.Form("isLB")
		Rs("isdefault") = Request.Form("isdefault")
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		ishion.strMsg = "<li>添加新站点预定义操作成功！</li>"
		Call ishion.SystemMsg
	End Sub
		'=================================
	Private Sub ViewList()
		Dim Rs, sql
		Response.Write "<fieldset><legend>下载站点预定义管理：[<a href=""?action=add"">添加</a>]</legend>" & vbCrLf
		Response.Write "   <table width=""100%""  border=""0"" align=""center"" cellpadding=""3"" cellspacing=""1"">" & vbCrLf
		Response.Write "     <COLGROUP>" & vbCrLf
		Response.Write "    <COL width=""25"">" & vbCrLf
		Response.Write "    <COL width=""*"">" & vbCrLf
		Response.Write "    <COL width=""*"">" & vbCrLf
		Response.Write "    <COL width=""150"">" & vbCrLf
		Response.Write "    <COL width=""150"">" & vbCrLf
		Response.Write "        <tr class=""tdbg1""> " & vbCrLf
		Response.Write "          <th>ID</th>" & vbCrLf
		Response.Write "          <th>名称</th>" & vbCrLf
		Response.Write "          <th>描述</th>" & vbCrLf
		Response.Write "          <th>负载均衡</th>" & vbCrLf
		Response.Write "          <th>编辑</th>" & vbCrLf
		Response.Write "        </tr>" & vbCrLf
		Response.Write "        <form action=""admin_down_site.asp"" method=""post"" name=""viewlist"">" & vbCrLf
		Set Rs = ishion.Execute("select * from ishion_Down_SiteSetting ")
		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 align=""center"">"
			If Rs("isLB") = 0 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") & """ onclick=""{if(confirm('执行此删除操作后该资源不能恢复，确定删除吗？')){return true;}return false;}"">删除</a> ）")
			Response.Write "            </td>" & vbCrLf
			Response.Write "          </tr>" & vbCrLf
			Rs.MoveNext
			Loop
		Else
			Response.Write ("<tr class=""tdbg3""><td colspan=""5"">没有找到任何记录！</td></tr>")
		End If
		Set Rs = Nothing
		Response.Write "        </form>" & vbCrLf
		Response.Write "</table></fieldset>" & vbCrLf
	End Sub
		 '================================
	Private Sub myform()
		If isEdit Then
			Dim Rs
			Set Rs = ishion.Execute("select * from ishion_Down_SiteSetting where id=" & CLng(Request.QueryString("id")))
		End If
		Response.Write "<fieldset><legend>" & vbCrLf
		If isEdit Then
			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 "  <COLGROUP>" & vbCrLf
		Response.Write "    <COL width=""120"">" & vbCrLf
		Response.Write "    <COL width=""*"">" & vbCrLf
		Response.Write "        <form action=""admin_down_site.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=""" & CLng(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""> " & 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><input name=""SiteURL"" type=""text"" value="""
		If isEdit Then Response.Write Trim(Rs("SiteURL"))
		Response.Write """ size=""40"" maxlength=""50""> " & vbCrLf
		Response.Write "            </td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg2""> " & vbCrLf
		Response.Write "            <td align=""right"">网站描述：<br> </td>" & vbCrLf
		Response.Write "            <td> <input name=""Description"" type=""text"" value="""
		If isEdit Then Response.Write (Rs("Description"))
		Response.Write """ size=""70""> " & vbCrLf
		Response.Write "            </td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg3""> " & vbCrLf
		Response.Write "            <td align=""right"">下载名称列表：<br>" & vbCrLf
		Response.Write "            每个名称用<strong>回车</strong>分开 </td>" & vbCrLf
		Response.Write "            <td><textarea name=""DownloadName"" cols=""70"" rows=""10"">"
		If isEdit Then Response.Write Replace(Rs("DownloadName"), ",", Chr(10))
		Response.Write "</textarea> " & vbCrLf
		Response.Write "            </td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg2""> " & vbCrLf
		Response.Write "            <td align=""right"">预定义URL列表：<br>" & vbCrLf
		Response.Write "            每个URL用<strong>回车</strong>分开</td>" & vbCrLf
		Response.Write "            <td><textarea name=""DownloadURL"" cols=""70"" rows=""10"">"
		If isEdit Then Response.Write Replace(Rs("DownloadURL"), ",", Chr(10))
		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=""isLB"" value=""1"" "
		If isEdit Then
			If Rs("isLB") = 1 Then Response.Write "checked"
		Else
			Response.Write "checked"
		End If
		Response.Write ">" & vbCrLf
		Response.Write "              显示全部分站" & vbCrLf
		Response.Write "              <input type=""radio"" name=""isLB"" value=""0"" "
		If isEdit Then
			If Rs("isLB") = 0 Then Response.Write "checked"
		End If
		Response.Write ">" & vbCrLf
		Response.Write "              不显示，自动负载均衡。</td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg2"">" & vbCrLf
		Response.Write "            <td align=""right"">设置默认：</td>" & vbCrLf
		Response.Write "            <td>" & vbCrLf
		Response.Write "<input type=""radio"" name=""isdefault"" value=""1"" "
		If isEdit Then
			If Rs("isdefault") = 1 Then Response.Write "checked"
		End If
		Response.Write ">是 " & vbCrLf
		Response.Write "              <input type=""radio"" name=""isdefault"" value=""0"" "
		If isEdit Then
			If Rs("isdefault") = 0 Then Response.Write "checked"
		Else
			Response.Write "checked"
		End If
		Response.Write ">否 </td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr class=""tdbg3""> " & 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></fieldset>" & vbCrLf
		If isEdit Then Set Rs = Nothing
	End Sub
	Public Sub OnEndPage()
		Response.Write ishion.CopyRight
	End Sub ' OnEndPage

End Class %>

