www.gusucode.com > 仿MOP对开式论坛程序 1.0源码程序 > mytopic.asp
<%@Language="VBScript"%> <!--#include file="title.asp"--> <% Dim types,n,l,h,i,sql,mytopic,bbspath,rsa,tfsql,fid,tid types=Request.QueryString("types") n=Request.QueryString("n") if IsNumeric(n) then n=Abs(Clng(n)) else n=10 end if if n>50 then n=10 if n=0 then n=10 l=Request.QueryString("l") if IsNumeric(l) then l=Abs(Clng(l)) else l=20 end if if l>100 then n=20 if l=0 then l=20 fid=Request.QueryString("fid") if IsNumeric(fid) then fid=Abs(Clng(fid)) else fid=0 end if tid=Request.QueryString("tid") if IsNumeric(tid) then tid=Abs(Clng(tid)) else tid=0 end if bbspath="http://"& Request.ServerVariables("SERVER_NAME") & Replace(Request.ServerVariables("PATH_INFO"),"mytopic.asp","") Function tleft(str,l) Dim regex Set regex=New RegExp regex.Pattern="<(.*?)>(.*)</font>" regex.IgnoreCase=True regex.Global=True str=regex.Replace(str,"$2") Set regex=Nothing Dim i,t For i=1 to Len(str) tleft=tleft & Mid(str,i,1) if Asc(Mid(str,i,1))>0 then t=t+1 else t=t+2 end if if t>=l-3 then tleft=tleft &"…" Exit For end if Next end Function Function dfc(str) Dim regex Set regex=New RegExp regex.Pattern="<(.*?)>(.*)</font>" regex.IgnoreCase=True regex.Global=True dfc=regex.Replace(str,"$2") Set regex=Nothing end Function if tid>0 then rs.Open "forumtype Where id="& tid &" and typeshow=1",conn,1,1 if Not rs.Eof then Set rsa=Server.CreateObject("ADODB.Recordset") rsa.Open "forum Where forumtype="& rs("id") &" and forumshow=1",conn,1,1 if Not rsa.Eof then tfsql=tfsql &" and (" For h=1 to rsa.RecordCount if h=rsa.RecordCount then tfsql=tfsql &"forumid="& rsa("id") &")" else tfsql=tfsql &"forumid="& rsa("id") &" or " end if rsa.MoveNext Next end if rsa.Close Set rsa=Nothing end if rs.Close elseif fid>0 then rs.Open "forum Where id="& fid &" and forumshow=1",conn,1,1 if Not rs.Eof then tfsql=tfsql &" and forumid="& fid rs.Close end if if tfsql<>"" then sql=" Where deler is Null"& tfsql else sql=",forum,forumtype Where deler is Null and topic.forumid=forum.id and forum.forumshow=1 and forum.forumtype=forumtype.id and forumtype.typeshow=1" end if if types="new" then sql="Select Top "& n &" title,posttime as tt,link From topic"& sql &" Order by posttime Desc" elseif types="update" then sql="Select Top "& n &" title,lastupdate as tt,link From topic"& sql &" Order by lastupdate Desc" elseif types="reply" then sql="Select Top "& n &" title,reply as tt,link From topic"& sql &" Order by reply Desc" elseif types="help" then sql="Select Top "& n &" title,click as tt,link From topic"& sql &" and topictype=0 Order by posttime Desc" elseif types="elite" then sql="Select Top "& n &" title,click as tt,link From topic"& sql &" and topictype=1 Order by posttime Desc" else sql="Select Top "& n &" title,posttime as tt,link From topic"& sql &" Order by posttime Desc" end if rs.Open sql,conn,1,1 For i=1 to rs.RecordCount mytopic=mytopic &"<br> <a href="""& bbspath &"topic/"& rs("link") &""" title="""& dfc(rs("title")) &" ("& rs("tt") &")"">"& tleft(rs("title"),l) &"</a>" rs.MoveNext Next rs.Close call connclose Response.Write "document.write('"& mytopic &"');" Response.End %> <!--#include file="bottom.asp"-->