<!--#include file="QvodCms_Conn.asp"-->
<!--#include file="QvodCms_Check.asp"-->
<%Server.ScriptTimeOut=999999999%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<TITLE>替换管理页面</TITLE>
<link href="skins/css/jaja_main.css" rel="stylesheet" type="text/css" />
<style type="text/css">
input{ border:none}
h1{font-size:14px; color:#FF0000;}
td{text-align:left}
</style>
</head>
<body> 
<table width="100%" height="156" border="0" align="center" cellpadding="0" cellspacing="0" style="text-align:center;">
<%Dim Action,reurl,data_1,data_2,data_3
Action=Trim(Request.QueryString("action"))
Select Case Lcase(Action)
Case "rename"
	Call Rename()
Case Else
	Call Main()
End Select
Sub Rename()
	Call OpenConn()
    Dim data_id,data_4,upsql
	data_1=Trim(Request.Form("data_1"))
	data_2=Trim(Request.Form("data_2"))
	data_3=Trim(Request.Form("data_3"))
	If data_1="" Or IsNull(data_1) Or data_2="" Or data_3="" Then Call QvodCms_Err("参数不正确!")
	Set rs=Server.CreateObject("adodb.recordset")
		If Config(1)="SQL" Then
			sql="Select name_id,"&data_1&" from qvodcms_name where "&data_1&" Like '%"& data_2 &"%' order by name_id desc"
		Else
			sql="Select name_id,"&data_1&" from qvodcms_name where InStr(1,LCase("&data_1&"),LCase('"&data_2&"'),0)<>0 order by name_id desc"
		End If
		rs.open sql,conn,1,1
		If Not(rs.bof and rs.eof) Then
		    Response.Write "<tr><th colspan=2 class=""title"">&nbsp;共需要替换<<font color='red'>"&rs.recordcount&"</font>>个数据</th></tr>"
		    For i=1 to rs.recordcount
			Conn.Execute(" Update qvodcms_name Set "&data_1&"='"&ReplaceStr(rs(1),data_2,data_3)&"' where name_id="&rs("name_id")&" ")
			Response.Write "<tr><td class=""td1"">&nbsp;第<font color='red'>"&i&"</font>个 ID为"&rs(0)&"的数据替换成功!</td></tr>"
			Response.Flush()
			rs.movenext
			If rs.eof Then Exit For
		    Next
		Else
		    Response.Write "<h1>没有找到需要替换的关键字"&data_2&",3秒后自动返回上一页!>><meta http-equiv='refresh' content=3;url='QvodCms_Data_Re.asp'></h1>"
		End If		
	rs.close
	Set rs=Nothing	
	Call CloseConn()
    Response.Write "<tr><th colspan=2 class=""title""><h1><a href='QvodCms_Data_Re.asp'>返回上页</a> 替换操作执行时间："& GetRunTime&" 秒</h1></th></tr>"
End Sub
Sub Main()%> 
  <tr><th height="26" colspan=2 background="Skins/images/tdbg.gif" class="title">&nbsp;数据批量替换</th>
  </tr>
  <form method="post" action="?Action=rename"> 
  <tr ><td class="td1" style="text-align:left; padding-left:50px;">请选择：<select name="data_1">
	<option value="class_id">[栏目分类(数字)]</option>
	<option value="data_name" selected>[电影名称]</option>
	<option value="data_actor">[电影主演]</option>
	<option value="data_director">[电影导演]</option>
	<option value="data_erea">[影片产地]</option>
	<option value="data_intro">[电影简介]</option>
	</select></td>
  </tr>  
  <tr ><td class="td1" style="text-align:left; padding-left:50px">将字符：<input type="text" name="data_2" style="border:1px solid #999999"/></td></tr>
  <tr ><td class="td1" style="text-align:left; padding-left:50px">替换成：<input type="text" name="data_3" style="border:1px solid #999999"/></td></tr> 
  <tr ><td class="td1" style="text-align:left; padding-left:50px;"><input type="submit" id="提交" value="执行替换操作"> <font color=#FF0000>注意:批量替换非常消费资源,请在服务器空闲时使用,替换后将不可恢复，请小心处理。</font></td></tr>
  </form>
<%End Sub%>  
</table>
</body>
</html>