<!--#include file="../include/hf_conn.asp"-->
<!--#include file="checkadmin.asp"-->
<script language=javascript src=../include/mouse_on_title.js></script>
<%call checkmanage("11")%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="manage.css" type="text/css">
</head>
<BODY background="../images/admin/back.gif">
<%
action=request("ren")
if action="" then
%>
<table width="98%" border="1" style="border-collapse: collapse; border-style: dotted; border-width: 0px" 
bordercolor="#333333" cellspacing="0" cellpadding="2">
<form action=safe6.asp method=post name=backup>
<tr class=backs><td colspan=2 class=td height=18>数据库在线改名</td></tr>
<input type=hidden name="oldname" value="<%=replace(db,left(db,InStrRev(db,"/")),"")%>">
<tr><td width=20% align=right height="18">请输入新的文件名</td>
<td><input type="text" name="newname" size="30" value="" maxlength=30> [建议使用.asp为后缀，请勿包含&*%/:?"|\等特殊符号]</td></tr>
</td></tr>
<tr><td colspan=2>
<input title='对网站正在使用的数据库文件更名' type="submit" name="Submit" value="在线更名" onClick="{if(confirm('为数据库文件改个文件名，可防止数据库文件被恶意下载。\n\n 此操作实际上是系统分两步自动完成的（先复制再删除）。\n\n如果在线更名过程中出错，请通过原始方法修改（即FTP登陆后修改）。\n\n单击确定继续，单击取消返回。')){this.document.backup.submit();return true;}return false;}"> 
<input type="hidden" name="ren" value="ok">
</td></tr>
</form>
</table>
<br><font color=red>※提示：</font><br><br>
此操作需FSO功能支持。<br>
执行此操作前，请先关闭其它网页窗口，断开FTP连接。<br>
提交后，请耐心等待<font color=red>（请不要重复点击上面的按钮），</font>完成时间视网络状况而定。<br>
请在网络空闲时进行此操作，<b>执行此操作可能导致服务器变慢或不稳定</b>。
<% 
elseif action="ok" then
newname=trim(request("newname"))
oldname=trim(request("oldname"))
if newname="" then
response.write "<script language='javascript'>"
response.write "alert('出错了，未填写新的数据库文件名。');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if
if oldname=newname then
response.write "<script language='javascript'>"
response.write "alert('新旧文件名相同，未作修改！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if
if instr(newname,".")<=0 then
response.write "<script language='javascript'>"
response.write "alert('出错了，新的文件名中没有输入扩展名。');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if
if instr(lcase(newname)," ")>0 or instr(lcase(newname),"o.f")>0 or instr(lcase(newname),"e.b")>0 or instr(lcase(newname),"n.t")>0 or instr(lcase(newname),"r.m")>0 or instr(lcase(newname),"o.asp")>0 or instr(lcase(newname),"t.asp")>0 or instr(lcase(newname),"s.asp")>0 then
response.write "<script language='javascript'>"
response.write "alert('出错了，新的文件名中包含与系统相冲突的字符，请使用其它名称。');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if
if checktext(request("newname"))<>request("newname") then
response.write "<script language='javascript'>"
response.write "alert('出错了，文件名中含有非法字符，请检查后重新输入！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if
oldpath=server.mappath(db)
newpath=replace(oldpath,oldname,newname)
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.fileexists(oldpath) then
fso.CopyFile oldpath,newpath
else
response.write "<script language='javascript'>"
response.write "alert('操作失败，请刷新后重试！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if
set fso=nothing
Set fso = CreateObject("Scripting.FileSystemObject")
set connold=Fso.OpenTextFile(server.mappath("../include/hf_conn.asp"))
conntxt=replace(connold.readall,oldname,newname)
Connold.close
set connnew=Fso.OpenTextFile(server.mappath("../include/hf_conn.asp"),2)
connnew.write(conntxt)
Connnew.close
set fso=nothing
response.write "<script language='javascript'>"
response.write "location.href='safe6.asp?del="&oldname&"';"
response.write "</script>"
response.end
end if
if request("del")<>"" then
oldname=request("del")
newname=replace(db,left(db,InStrRev(db,"/")),"")
newpath=server.mappath(db)
oldpath=replace(newpath,newname,oldname)
Set fso = CreateObject("Scripting.FileSystemObject")
if fso.fileexists(oldpath) then
fso.DeleteFile(oldpath)
response.write "<script language='javascript'>"
response.write "alert('操作成功，数据库文件改名成功！');"
response.write "location.href='safe6.asp';"
response.write "</script>"
response.end
else
response.write "<script language='javascript'>"
response.write "alert('操作失败，请刷新后重试！');"
response.write "location.href='javascript:history.go(-1)';"
response.write "</script>"
response.end
end if
set fso=nothing
end if
%>