📄 postdata.asp
字号:
dim myrs,maxannid,i,rs
for i=1 to ForNum
set rs=Dvbbs.Execute("select top "&TopNum&" topicid,title from dv_topic where PostTable='"&request.form("outtablename")&"' order by topicid "&orderby&"")
if rs.eof and rs.bof then
Errmsg=ErrMsg + "<BR><li>您所选择导出的数据表已经没有任何内容"
dvbbs_error()
exit sub
else
do while not rs.eof
'读取导出帖子数据表
set trs=Dvbbs.Execute("select * from "&request.form("outtablename")&" where rootid="&rs("topicid")&" order by Announceid")
if not (trs.eof and trs.bof) then
do while not trs.eof
'插入导入帖子数据表
If IsNull(trs("postuserid")) Or trs("postuserid")="" Then
PostUserID=0
Else
PostUserID=trs("postuserid")
End If
Dvbbs.Execute("insert into "&request("intablename")&"(Boardid,ParentID,username,topic,body,DateAndTime,length,rootid,layer,orders,ip,Expression,locktopic,signflag,emailflag,isbest,PostUserID,isagree,isupload,isaudit,PostBuyUser,UbbList) values ("&trs("boardid")&","&trs("parentid")&",'"&Dvbbs.checkstr(trs("username"))&"','"&Dvbbs.checkstr(trs("topic"))&"','"&Dvbbs.checkstr(trs("body"))&"','"&trs("dateandtime")&"',"&trs("length")&","&trs("rootid")&","&trs("layer")&","&trs("orders")&",'"&trs("ip")&"','"&trs("Expression")&"',"&trs("locktopic")&","&trs("signflag")&","&trs("emailflag")&","&trs("isbest")&","&PostUserID&",'"&trs("isagree")&"',"&trs("isupload")&","&trs("isaudit")&",'"&trs("PostBuyUser")&"','"&Dvbbs.checkstr(trs("UbbList"))&"')")
'更新精华'更新上传 'shinzeal add this in 2004/7/4
If ( Not IsNull(Trs("isbest")) And Trs("isbest")<>"" ) Or ( Not IsNull(Trs("isupload")) And Trs("isupload")<>"" ) Then
If Trs("isbest")=1 Or Trs("isupload")=1 Then
Set myrs=Dvbbs.Execute("select max(announceid) from "&Request.Form("intablename")&" where boardid="&Trs("BoardID"))
maxannid=myrs(0)
myrs.close
Set myrs=Nothing
If Trs("isbest")=1 Then Dvbbs.Execute("update dv_besttopic set AnnounceID="&maxannid&" where rootid="&rs("topicid"))
If Trs("isupload")=1 Then Dvbbs.Execute("update Dv_Upfile set F_AnnounceID='" & Rs("TopicID") & "|" & maxannid & "' where F_AnnounceID='" & Rs("TopicID") & "|" & Trs("AnnounceID") & "'")
End If
End If
trs.movenext
loop
end if
'删除导出帖子数据表对应数据
Dvbbs.Execute("delete from "&request.form("outTableName")&" where RootID="&rs("TopicID"))
'更新主题指定帖子表
Dvbbs.Execute("update dv_topic set PostTable='"&request.form("inTableName")&"' where TopicID="&rs("topicid"))
i=i+1
'If (i mod 100) = 0 Then
Response.Write "<script>img2.width=" & Fix((i/C1) * 400) & ";" & VbCrLf
Response.Write "txt2.innerHTML=""更新完"&Server.HtmlEncode(rs(1))&"的数据,正在更新下一个帖子数据," & FormatNumber(i/C1*100,4,-1) & """;" & VbCrLf
Response.Write "img2.title=""" & Server.HtmlEncode(Rs(1)) & "(" & i & ")"";</script>" & VbCrLf
Response.Flush
'End If
rs.movenext
loop
end if
next
set trs=nothing
set rs=nothing
Response.Write "<script>img2.width=400;txt2.innerHTML=""100"";</script>"
dv_suc("转移数据更新成功!")
end sub
sub search()
dim keyword
dim totalrec
dim n,rs,sql
dim currentpage,page_count,Pcount,PostUserID
currentPage=request("page")
if currentpage="" or not IsNumeric(currentpage) then
currentpage=1
else
currentpage=clng(currentpage)
end if
if request("keyword")="" then
Errmsg=ErrMsg + "<BR><li>请输入您要查询的关键字。"
dvbbs_error()
exit sub
else
keyword=replace(request("keyword"),"'","")
end if
if request("searchWhat")="username" then
Set Rs=Dvbbs.Execute("Select UserID From Dv_User Where UserName='"&keyword&"'")
If Rs.Eof And Rs.Bof Then
Errmsg=ErrMsg + "<BR><li>目标用户并不存在,请重新输入。"
dvbbs_error()
exit sub
Else
PostUserID=Rs(0)
End If
sql="select * from dv_topic where PostTable='"&request("tablename")&"' and PostUserID="&PostUserID&" order by LastPostTime desc"
elseif request("topic")="yes" then
sql="select * from dv_topic where PostTable='"&request("tablename")&"' and title like '%"&keyword&"%' order by LastPostTime desc"
else
Errmsg=ErrMsg + "<BR><li>请选择您查询的方式。"
dvbbs_error()
exit sub
end if
%>
<form method="POST" action="?action=update3">
<!--<input type=hidden name="topic" value="<%=request("topic")%>">
<input type=hidden name="username" value="<%=request("username")%>"> shinzeal add searchWhat in 2004/7/4-->
<input type=hidden name="searchWhat" value="<%=request("searchWhat")%>">
<input type=hidden name="keyword" value="<%=keyword%>">
<input type=hidden name="tablename" value="<%=request("tablename")%>">
<table width="100%" border="0" cellspacing="1" cellpadding="3" align="center">
<tr>
<td height="23" colspan="6" class=td1><B>说明</B>:<BR>您可以对下列的搜索结果进行转移数据表的操作,不能在相同表内进行转换操作。</td>
</tr>
<tr>
<th colspan="6">搜索<%=request("tablename")%>结果</th>
</tr>
<tr>
<td width="6%" align=center><b>状态<B></td>
<td width="45%" align=center><B>标题</B></td>
<td width="15%" align=center><B>作者</B></td>
<td width="6%" align=center><B>回复</B></td>
<td width="22%" align=center><B>时间</B></td>
<td width="6%" align=center><B>操作</B></td>
</tr>
<%
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.bof and rs.eof then
response.write "<tr> <td class=td1 colspan=6 height=25>没有搜索到相关内容。</td></tr>"
else
rs.PageSize = Dvbbs.Forum_Setting(11)
rs.AbsolutePage=currentpage
page_count=0
totalrec=rs.recordcount
while (not rs.eof) and (not page_count = rs.PageSize)
%>
<tr>
<td width="6%" class=td1 align=center>
<%
if rs("locktopic")=1 then
response.write "锁定"
elseif rs("isvote")=1 then
response.write "投票"
elseif rs("isbest")=1 then
response.write "精华"
else
response.write "正常"
end if
%>
</td>
<td width="45%" class=td1><%=dvbbs.htmlencode(rs("title"))%></td>
<td width="15%" class=td1 align=center><a href="user.asp?action=modify&userid=<%=rs("postuserid")%>"><%=dvbbs.htmlencode(rs("postusername"))%></a></td>
<td width="6%" class=td1 align=center><%=rs("child")%></td>
<td width="22%" class=td1><%=rs("dateandtime")%></td>
<td width="6%" class=td1 align=center><input type="checkbox" class="checkbox" name="topicid" value="<%=rs("topicid")%>"></td>
</tr>
<%
page_count = page_count + 1
rs.movenext
wend
dim endpage
Pcount=rs.PageCount
response.write "<tr><td valign=middle nowrap colspan=2 class=td1 height=25> 分页: "
if currentpage > 4 then
response.write "<a href=""?page=1&action=search&keyword="&keyword&"&searchWhat="&Request("searchWhat")&"&tablename="&request("tablename")&""">[1]</a> ..." 'shinzeal add searchWhat="&Request("searchWhat")&" in 2004/7/4
end if
if Pcount>currentpage+3 then
endpage=currentpage+3
else
endpage=Pcount
end if
Dim i
for i=currentpage-3 to endpage
if not i<1 then
if i = clng(currentpage) then
response.write " <font color="&Dvbbs.mainsetting(1)&">["&i&"]</font>"
else
response.write " <a href=""?page="&i&"&action=search&keyword="&keyword&"&searchWhat="&Request("searchWhat")&"&tablename="&request("tablename")&""">["&i&"]</a>" 'shinzeal add searchWhat="&Request("searchWhat")&" in 2004/7/4
end if
end if
next
if currentpage+3 < Pcount then
response.write "... <a href=""?page="&Pcount&"&action=search&keyword="&keyword&"&searchWhat="&Request("searchWhat")&"&tablename="&request("tablename")&""">["&Pcount&"]</a>" 'shinzeal add searchWhat="&Request("searchWhat")&" in 2004/7/4
end if
response.write "</td>"
response.write "<td colspan=3 class=td1>所有查询结果<input type=checkbox class=checkbox name=allsearch value=yes>"
response.write " <select name=toTablename>"
for i=0 to ubound(AllPostTable)
response.write "<option value="""&AllPostTable(i)&""">"&AllPostTableName(i)& "--" &AllPostTable(i)&"</option>"
next
response.write "</select> <input type=submit class=button name=submit value=转换>"
response.write "</td>"
response.write "<td class=td1 align=center><input type=checkbox class=checkbox name=chkall value=on onclick=""CheckAll(this.form)"">"
response.write "</td></tr>"
end if
rs.close
set rs=nothing
response.write "</table></form><BR><BR>"
end sub
'根据搜索结果更新
sub update3()
dim keyword,trs,PostUserID
Dim Rs,SQL,i
if request.form("tablename")=request.form("totablename") then
Errmsg=ErrMsg + "<BR><li>不能在相同数据表内进行数据转换。"
dvbbs_error()
exit sub
end if
if request.form("allsearch")="yes" then
if request("keyword")="" then
Errmsg=ErrMsg + "<BR><li>请输入您要查询的关键字。"
dvbbs_error()
exit sub
else
keyword=replace(request("keyword"),"'","")
end if
if request("searchWhat")="username" then 'shinzeal add searchWhat in 2004/7/4
Set Rs=Dvbbs.Execute("Select UserID From Dv_User Where UserName='"&keyword&"'")
If Rs.Eof And Rs.Bof Then
Errmsg=ErrMsg + "<BR><li>目标用户并不存在,请重新输入。"
dvbbs_error()
exit sub
Else
PostUserID=Rs(0)
End If
sql="select topicid,title from dv_topic where PostTable='"&request("tablename")&"' and PostUserID="&PostUserID&" order by LastPostTime desc"
elseif request("topic")="yes" then
sql="select topicid,title from dv_topic where PostTable='"&request("tablename")&"' and title like '%"&keyword&"%' order by LastPostTime desc"
else
Errmsg=ErrMsg + "<BR><li>请选择您查询的方式。"
dvbbs_error()
exit sub
end if
else
if request.form("topicid")="" then
Errmsg=ErrMsg + "<BR><li>请选择要转移的帖子。"
dvbbs_error()
exit sub
end if
sql="select topicid,title from dv_topic where PostTable='"&request("tablename")&"' and TopicID in ("&request.form("TopicID")&")"
end if
'set rs=Dvbbs.Execute(sql)
Set Rs=server.createobject("adodb.recordset")
Rs.Open SQL,Conn,1,1
Dim C1,myrs,maxannid
C1=Rs.ReCordCount
%>
<BR>
<table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
<tr><td colspan=2 class=td1>
下面开始转移论坛帖子资料,预计本次共有<%=C1%>个帖子需要更新
<table width="400" border="0" cellspacing="1" cellpadding="1">
<tr>
<td bgcolor=#000000>
<table width="400" border="0" cellspacing="0" cellpadding="1">
<tr>
<td bgcolor=#ffffff height=9><img src="../skins/default/bar/bar3.gif" width=0 height=16 id=img2 name=img2 align=absmiddle></td></tr></table>
</td></tr></table> <span id=txt2 name=txt2 style="font-size:9pt">0</span><span style="font-size:9pt">%</span></td></tr>
</table>
<%
Response.Flush
if rs.eof and rs.bof then
Errmsg=ErrMsg + "<BR><li>没有任何记录可转换。"
dvbbs_error()
exit sub
else
do while not rs.eof
'取出原表数据
set trs=Dvbbs.Execute("select * from "&request("tablename")&" where rootid="&rs("topicid")&" order by Announceid")
if not (trs.eof and trs.bof) then
'插入新表
do while not trs.eof
If IsNull(trs("postuserid")) Or trs("postuserid")="" Then
PostUserID=0
Else
PostUserID=trs("postuserid")
End If
Dvbbs.Execute("insert into "&request("totablename")&"(Boardid,ParentID,username,topic,body,DateAndTime,length,rootid,layer,orders,ip,Expression,locktopic,signflag,emailflag,isbest,PostUserID,isagree,isupload,isaudit,PostBuyUser,UbbList) values ("&trs("boardid")&","&trs("parentid")&",'"&Dvbbs.checkstr(trs("username"))&"','"&Dvbbs.checkstr(trs("topic"))&"','"&Dvbbs.checkstr(trs("body"))&"','"&trs("dateandtime")&"',"&trs("length")&","&trs("rootid")&","&trs("layer")&","&trs("orders")&",'"&trs("ip")&"','"&trs("Expression")&"',"&trs("locktopic")&","&trs("signflag")&","&trs("emailflag")&","&trs("isbest")&","&PostUserID&",'"&trs("isagree")&"',"&trs("isupload")&","&trs("isaudit")&",'"&trs("PostBuyUser")&"','"&Dvbbs.checkstr(trs("UbbList"))&"')")
'更新精华'更新上传 'shinzeal add this in 2004/7/4
If ( Not IsNull(Trs("isbest")) And Trs("isbest")<>"" ) Or ( Not IsNull(Trs("isupload")) And Trs("isupload")<>"" ) Then
If Trs("isbest")=1 Or Trs("isupload")=1 Then
Set myrs=Dvbbs.Execute("select max(announceid) from "&Request.Form("totablename")&" where boardid="&Trs("BoardID"))
maxannid=myrs(0)
myrs.close
Set myrs=Nothing
If Trs("isbest")=1 Then Dvbbs.Execute("update dv_besttopic set AnnounceID="&maxannid&" where rootid="&Rs("TopicID"))
If Trs("isupload")=1 Then Dvbbs.Execute("update Dv_Upfile set F_AnnounceID='" & Rs("TopicID") & "|" & maxannid & "' where F_AnnounceID='" & Rs("TopicID") & "|" & Trs("AnnounceID") & "'")
End If
end if
trs.movenext
loop
end if
'删除原表该帖子数据
Dvbbs.Execute("delete from "&request("tablename")&" where rootid="&rs("topicid"))
'更新该主题表名
Dvbbs.Execute("update dv_topic set PostTable='"&request("totablename")&"' where topicid="&rs("topicid"))
i=i+1
'If (i mod 100) = 0 Then
Response.Write "<script>img2.width=" & Fix((i/C1) * 400) & ";" & VbCrLf
Response.Write "txt2.innerHTML=""更新完"&Server.HtmlEncode(rs(1))&"的数据,正在更新下一个帖子数据," & FormatNumber(i/C1*100,4,-1) & """;" & VbCrLf
Response.Write "img2.title=""" & Server.HtmlEncode(Rs(1)) & "(" & i & ")"";</script>" & VbCrLf
Response.Flush
'End If
rs.movenext
loop
end if
set trs=nothing
set rs=nothing
Response.Write "<script>img2.width=400;txt2.innerHTML=""100"";</script>"
dv_suc("转移数据更新成功!")
end sub
Function TableSelectForm()
Dim i,Rs
TableSelectForm = ""
For i=0 To UBound(AllPostTable)
On Error Resume Next
Set Rs=Dvbbs.Execute("Select Top 1 * From "&AllPostTable(i))
If Err Then
Err.Clear
Else
TableSelectForm = TableSelectForm & "<option value="""&AllPostTable(i)&""">"&AllPostTableName(i)& "--" &AllPostTable(i)&"</option>"
End If
next
End Function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -