<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->

<% 
 '===========================================================================================
	'软件名称：126 cms 视频影视管理系统
	'程序版权：126电影               '咨询QQ：479025
	'开发作者：magicblack(479025)    '官方网站：http://www.126oo.com/
	'Copyright (C) 2009 - ... 126oo.com  All Rights Reserved.
	'郑重声明:
	'    1、免费版本请在程序首页保留版权信息，并做上本站LOGO友情连接,商业版本无此要求;
	'    2、任何个人或组织不得以盈利为目的发布,修改,本软件及其他副本上一切关于版权的信息；
	'    3、126电影保留此软件的法律追究权利；
'==========================================================================================
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>批量数据替换 - 后台管理中心 - 126电影程序CMS</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="images/css_body.css" type=text/css rel=stylesheet>
<script language="javascript" src="images/admin.js"></script>
</HEAD>
<BODY>
<DIV class=bodytitle>
<DIV class=bodytitleleft></DIV>
<DIV class=bodytitletxt>日文内存溢出修复</DIV>
<DIV class=bodytitletxt2></DIV>
</DIV>
<%
response.Charset="GBK"
Dim action
action=SafeData("RQ","action",0)

Select Case action
Case "re"
	Call re
Case Else
	Call main
End Select

Sub main
%>
<TABLE width="96%" border=0 align=center cellpadding="5" cellSpacing=1 class=tbtitle style="BACKGROUND: #cad9ea;">
  <form method="post" action="?action=re">
    <TR bgColor="#f5fafe">
      <td width="100%" height="380" valign="top" class="hback"><br>
        将字段：
          <select name="D_Source">
          <option value="D_Name" selected>名称(D_Name)</option>
          <option value="D_State">状态(D_State)</option>
          <option value="D_Pic">图片(D_Pic)</option>
          <option value="D_Starring">主演(D_Starring)</option>
          <option value="D_Directed">导演(D_Directed)</option>
          <option value="D_Year">年代(D_Year)</option>
		  <option value="D_Level">推荐值(1或2)(D_Level)</option>
          <option value="D_Hits">点击量(D_Hits)</option>
          <option value="D_Content">内容简介(D_Content)</option>
        </select>
        中的字符：
        <input type="text" name="D_Str" />
        &nbsp; 替换成：
        <input type="text" name="D_Target" />
        <input name="submit" type="submit" value="确认替换" />
        <br />
        <font color=#FF0000><br>
          <strong><br>
          注意：操作前请先备份数据库!<br>
          <br>
          程序遇到待替换的字符就会立即替换且不可恢复，请小心处理。</strong><br>
      </font></td>
    </tr>
  </form>
</table>

  <%
end Sub

Sub re
dim D_Source,D_Str,D_Target,d_id,temp_1,stat,d_name

D_Source=SafeData("RF","D_Source",0)
D_Str=SafeData("RF","D_Str",0)
D_Target=SafeData("RF","D_Target",0)

If D_Source="" Or IsNull(D_Source) Then 
response.write"<a href="""&request.ServerVariables("HTTP_REFERER")&""">没有待替换数据，程序终止运行，请返回</a>"
response.End 
end if

Dim rs : Set rs = Database.GetRecord("Tbl_Datas:D_ID,D_Name,"&D_Source,D_Source&" like '%" &D_Str&"%'","D_id asc")  

response.Write ("<TABLE width=""96%"" border=""0"" align=""center""  cellpadding=""5"" cellSpacing= ""1"" class= "" tbtitle"" style=""BACKGROUND: #cad9ea;"">")

Response.Write("<TR bgColor=""#f5fafe"">")&vbnewline
        Response.Write("<td>编号</td><td>标题</td><td>状态</td>")&vbnewline
		Response.Write("</tr>")&vbnewline
		
while not rs.eof
d_id=Rs("d_id")
d_name = Rs("d_name")
temp_1=rs(""&D_Source&"")
temp_1=Replace(temp_1,D_Str,D_Target)

Dim result : result = DataBase.UpdateRecord("Tbl_Datas","D_ID = "& d_id ,Array(D_Source&":"&temp_1))  
		If result <> 0 Then  
			stat = "成功"
		else
			stat = "失败"
		end if
		Response.Write("<tr bgcolor=""#FFFFFF"">")&vbnewline
        Response.Write("<td align=""center"">" & d_id & "</td><td>" & d_name & "</td><td><font color=""blue"">"&stat&"</font></td>")&vbnewline
		Response.Write("</tr>")&vbnewline
rs.movenext
wend
Database.C(rs)
response.write "<tr bgColor=""#f5fafe""><td colspan=3>"
response.write"&nbsp;任务已经全部完成</td></tr>"
response.write"</table>"
End Sub 
%>
</body>
</html>