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

Class admin_batch_replace

	Private ishion
	
	Private Sub Class_Initialize()
		Set ishion = New Cls_Main
	End Sub
	Private Sub Class_Terminate()
		Set ishion = Nothing
	End Sub
	
	Public Sub AspInit()
	Server.ScriptTimeout = 9999999
		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=""3"" topmargin=""0"">" & vbCrLf
		'Call ishion.LoadSetting
			
			If ishion.adminName = "" Then
				ishion.strMsg = "<li>非法操作：登录超时或你没有以管理员身份登录系统，<a href=""../admin_login.asp"" target=_top>点此进入管理员登录界面</a>。"
				Call ishion.SystemMsg
			Else
				Call Main
			End If
		Response.Write "</BODY></HTML>" & vbCrLf
	
	End Sub
	Private Function myPermission()
		myPermission = False
		If ishion.checkPermission(ishion.adminName, "11") Then myPermission = True: Exit Function
		If ishion.checkPermission(ishion.adminName, "12") Then myPermission = True: Exit Function
		'If ishion.checkPermission(ishion.adminName,"10") Then myPermission = False
	End Function
	Private Sub Main()
		Select Case Trim(Request.Form("action"))
		Case "replace_down_address"
			Call replace_down_address
		Case "search_down_address"
			Call search_down_address
		Case Else
			Call replacePage
		End Select
	End Sub
	Sub replace_down_address()
		Dim o_url, n_url, i, Rs, new_url
		o_url = ishion.checkStr(Trim(Request.Form("o_url")))
		n_url = ishion.checkStr(Trim(Request.Form("n_url")))
		Set Rs = ishion.Execute("select ID,url from ishion_Down_Address where url like '%" & o_url & "%'")
		If Not (Rs.EOF And Rs.BOF) Then
			i = 0
			Do While Not Rs.EOF
				new_url = Replace(Rs(1), o_url, n_url)
				ishion.Execute ("update ishion_Down_Address set url='" & new_url & "' where ID=" & Rs(0))
			Rs.MoveNext
			i = i + 1
			Loop
		End If
		Set Rs = Nothing
		ishion.strMsg = "<li>操作成功，共更新了 " & i & " 下载地址信息！</li>"
		Call ishion.SystemMsg
	End Sub
	Private Sub search_down_address()
		Response.Write "      <form name=""myform""  action="""" method=""post"">" & vbCrLf
		Response.Write "        <table cellpadding=""3"" cellspacing=""1"" border=""0"" width=""100%"" align=""center"">" & vbCrLf
		Response.Write "          <tr> " & vbCrLf
		Response.Write "            <th height=""22"" class=""tdbg1"">下载地址批量替换管理 " & vbCrLf
		Response.Write "              <input name=""action"" type=""hidden"" value=""replace_down_address""></th>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr> " & vbCrLf
		Response.Write "            <td height=""25"" align=""center"" class=""tdbg2""> " & vbCrLf
		Dim Rs
		Set Rs = ishion.Execute("select count(ID) from ishion_Down_Address where url like '%" & ishion.checkStr(Trim(Request.Form("url"))) & "%'")
		If Not (Rs.EOF And Rs.BOF) Then
			Response.Write ("本次搜索找到了 <b>" & Rs(0) & "</b> 个相关下载地址。")
			Response.Write ("<a href=""admin_batch_replace.asp"">返回重新查找</a>")
		Else
			Response.Write ("没有找到相关下载地址，<a href=""admin_batch_replace.asp"">返回重新查找</a>")
		End If
		Set Rs = Nothing
		Response.Write "            </td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr> " & vbCrLf
		Response.Write "            <td height=""25"" align=""center"" class=""tdbg2"">将字符 " & vbCrLf
		Response.Write "              <input name=""o_url"" type=""text"" value=""" & Trim(Request.Form("url")) & """ size=""45"" maxlength=""50""> " & vbCrLf
		Response.Write "            </td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr> " & vbCrLf
		Response.Write "            <td height=""25"" align=""center"" class=""tdbg2"">替换成 " & vbCrLf
		Response.Write "              <input name=""n_url"" type=""text"" value="""" size=""45"" maxlength=""50""> " & vbCrLf
		Response.Write "            </td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr> " & vbCrLf
		Response.Write "            <td height=""25"" align=""center"" class=""tdbg2"">" & vbCrLf
		Response.Write "<input type=""submit"" name=""Submit2"" value=""马上替换 ""></td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "        </table>" & vbCrLf
		Response.Write "      </form>" & vbCrLf
	End Sub
	Private Sub replacePage()
		Response.Write "<form name=""myform""  action="""" method=""post"">" & vbCrLf
		Response.Write "        <table cellpadding=""3"" cellspacing=""1"" border=""0"" width=""100%"" class=""tableBorder"" align=center>" & vbCrLf
		Response.Write "          <tr> " & vbCrLf
		Response.Write "            <th height=""22"" class=""tdbg1"">下载地址批量替换管理</th>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr> " & vbCrLf
		Response.Write "            <td height=""25"" align=""center"" class=""tdbg2"">下载地址中包含字符： " & vbCrLf
		Response.Write "              <input name=""action"" type=""hidden"" value=""search_down_address""> <input name=""url"" type=""text"" size=""45"" maxlength=""50""> " & vbCrLf
		Response.Write "              <input type=""submit"" name=""Submit"" value=""查找""> </td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "          <tr> " & vbCrLf
		Response.Write "            <td height=""25"" align=""center"" class=""tdbg2"">注意：单引号“'”将被自动过滤掉</td>" & vbCrLf
		Response.Write "          </tr>" & vbCrLf
		Response.Write "        </table>" & vbCrLf
		Response.Write "      </form>" & vbCrLf
	End Sub
	
	Public Sub OnEndPage()
		Response.Write ishion.CopyRight
	End Sub ' OnEndPage


End Class %>

