逐梦论坛's Archiver

shillan 发表于 2006-9-11 21:49

[蚂蚁][教材]leadbbs for 3.14 [frame-区-版]名称外部调用

frame无疑为页面框架形式,但框架形式不是一种你需要的最后技术,而是leadbbs的某些调用才为你所关心的,例如:纯区名称的调用,纯版名称的调用。其实,leadbbs已经给了你答案,下面,让我们一起来了解这个答案。

区和版的形式在leadbbs的原版文件:boardnav.asp已经说得很清楚了,现在我们将这个文件分为俩部分,也就是将这个文件分别分为区名称文件和版名称文件,暂且将这俩个文件命名为:qu.asp和ban.asp。通过分析boardnav.asp文件,我们得出qu.asp和ban.asp文件内容分别如下:

qu.asp

<!--------------------------------qu.asp源码---------------------------------------------->
<!-- #include file=inc/bbssetup.asp -->
<!-- #include file=inc/board_popfun.asp -->
<!-- 仅显示详细区块名称模板 蚂蚁 www.748202.com -->
<%sitehead("   ")%>
<meta http-equiv=content-type content="text/html; charset=gb2312">
<style type=text/css>td {
     font-size: 12px}

.line {
     padding-left: 10px; font-size: 12px; line-height: 12pt
}
.top {
     font-size: 12px}
</style>

</body>
<body bgcolor="eeeeee" leftmargin=0 topmargin=0 marginwidth="0" marginheight="0" class=tbframebg>
<table width=100% height=100% color=bgcolor=eeeeee class=tbframebg height=12 border=0 cellspacing=0 cellpadding=0>
<tr><td width=150 valign=top align=center>
     <br><img src=images/blank.gif height=5 width=2><br>
                 <%displayboardlist%>
        </td></tr></table>
</body></html>


<%
function displayboardlist

     opendatabase
     dim rs,getdata,boardnum
     set rs = server.createobject("adodb.recordset")
     rs.open "select boardid,boardassort,boardname,leadbbs_assort.assortname from leadbbs_boards inner join leadbbs_assort on leadbbs_assort.assortid=leadbbs_boards.boardassort where leadbbs_boards.hiddenflag = 0 order by leadbbs_assort.assortid,leadbbs_boards.orderid asc",con,1,1
     gbl_dbnum = gbl_dbnum + 1
     if not rs.eof then
           getdata = rs.getrows(-1)
           boardnum = ubound(getdata,2)
     else
           boardnum = -1
     end if
     rs.close
     set rs = nothing

     if boardnum = -1 then
     else
           dim currentassosrt,n
           currentassosrt = -1183
           dim lastassosrt,writestr
           lastassosrt = ccur(getdata(1,boardnum))
           dim lastflag
           for n = 0 to boardnum
                 if currentassosrt<>ccur(getdata(1,n)) then
                       currentassosrt = ccur(getdata(1,n))
                       if lastassosrt = currentassosrt then
                             response.write "</div>"
                       else
                             response.write "</div>"
                       end if
                       %>
<img class=level1 id=out<%=n+1%>i height=9 src="images/<%=gbl_defineimage%>frame/plus.gif" width=9 border=0>      <a href=boards.asp?assort=<%=getdata(1,n)%> target="b"><%=writestr & getdata(3,n)%></a>
                 <br>
<%

                 end if
                 %>
               <%
           next
           response.write "</div>"
     end if
     closedatabase

end function%>
<!---------------------------------------qu.asp完---------------------------->


ban.asp

<!--------------------------------ban.asp源码---------------------------------------------->
<!-- #include file=inc/bbssetup.asp -->
<!-- #include file=inc/board_popfun.asp -->
<!-- 仅显示详细版块名称模板 蚂蚁 www.748202.com -->
<%sitehead("   ")%>
<meta http-equiv=content-type content="text/html; charset=gb2312">
<style type=text/css>td {
     font-size: 12px}

.line {
     padding-left: 10px; font-size: 12px; line-height: 12pt
}
.top {
     font-size: 12px}
</style>
</body>
<table width=100% bgcolor=eeeeee border=0 cellspacing=0 cellpadding=0 background=img/link1.gif>
<tr><td width=100% align=center height="20">
<%displayboardlist%>
        </td></tr></table>
</body></html>


<%
function displayboardlist

     opendatabase
     dim rs,getdata,boardnum
     set rs = server.createobject("adodb.recordset")
     rs.open "select boardid,boardassort,boardname,leadbbs_assort.assortname from leadbbs_boards inner join leadbbs_assort on leadbbs_assort.assortid=leadbbs_boards.boardassort where leadbbs_boards.hiddenflag = 0 order by leadbbs_assort.assortid,leadbbs_boards.orderid asc",con,1,1
     gbl_dbnum = gbl_dbnum + 1
     if not rs.eof then
           getdata = rs.getrows(-1)
           boardnum = ubound(getdata,2)
     else
           boardnum = -1
     end if
     rs.close
     set rs = nothing

     if boardnum = -1 then
     else
           dim currentassosrt,n
           currentassosrt = -1183
           dim lastassosrt,writestr
           lastassosrt = ccur(getdata(1,boardnum))
           dim lastflag
           for n = 0 to boardnum
                 if currentassosrt<>ccur(getdata(1,n)) then
                       currentassosrt = ccur(getdata(1,n))
                       if lastassosrt = currentassosrt then
                       else

                       end if
                 end if
                 %>
<img src=images/9p_1.gif border=0 width=5 height=20 align=absmiddle><a href="board/board.asp?boardid=<%=getdata(0,n)%>" onclick="parent.leftb.location.href='board/_board.asp?boardid=<%=getdata(0,n)%>'" target="right"><font color=#ffffff><%=writestr & getdata(2,n)%></font></a>
<%
'注意以上这段,我采用了一个链接同时打开俩个frame窗口,frame窗口的name值分别为leftb和right。
           next
     end if
     closedatabase

end function%>
<!---------------------------------------ban.asp完---------------------------->

通过以上的区和版的分别显示源码,我们很容易通过frame的值来控制frame窗口。当然,有时候我们希望版的显示更详细一点,可以通过boards.asp文件来修改,例如:ban.asp又可用以下代码来完成:

ban.asp
<!--------------------------------ban.asp源码---------------------------------------------->
<!-- #include file=inc/bbssetup.asp -->
<!-- #include file=inc/board_popfun.asp -->
<!-- 仅显示详细版块名称和其他加强说明模板 蚂蚁 www.748202.com -->
<%sitehead("   ")%>
<meta http-equiv=content-type content="text/html; charset=gb2312">
<style type=text/css>td {
     font-size: 12px}

.line {
     padding-left: 10px; font-size: 12px; line-height: 12pt
}
.top {
     font-size: 12px}
</style>
</body>
<body bgcolor="eeeeee" leftmargin=0 topmargin=0 marginwidth="0" marginheight="0" class=tbbgbody>
<%
dim gbl_req_assort,gbl_topicnum,gbl_announcenum,gbl_goodnum,gbl_todayannounce,gbl_startboard

dim gbl_onlineusernum,gbl_usercount,gbl_maxonline,gbl_onlinetime,gbl_maxoltime,gbl_pagecount,gbl_uploadnum
dim gbl_maxannounce,gbl_maxanctime,gbl_yesterdayanc

dim blist,boardnum
blist = application(def_mastercookies & "blist")

function checkassort

     gbl_req_assort = left(request.querystring("assort"),14)
     if isnumeric(gbl_req_assort)=0 then gbl_req_assort=0
     gbl_req_assort = fix(ccur(gbl_req_assort))

     dim boardnum,n,temparray
     gbl_startboard = 0
     if gbl_req_assort > 0 and isarray(blist) = true then
           boardnum = ubound(blist,2)
           for n = 0 to boardnum
                 if gbl_req_assort = ccur(blist(1,n)) then
                       temparray = application(def_mastercookies & "boardinfo" & blist(0,n))
                       if isarray(temparray) = true then
                             gbl_board_boardassort = ccur(temparray(1,0))
                             gbl_board_assortname = temparray(14,0)
                             gbl_startboard = n
                             exit for
                       else
                             gbl_req_assort = 0
                             gbl_board_boardassort = 0
                             gbl_board_assortname = ""
                             exit for
                       end if
                 end if
           next
           if n > boardnum then gbl_req_assort = 0
     else
           gbl_req_assort = 0
           gbl_board_boardassort = 0
           gbl_board_assortname = ""
     end if
     if ccur(gbl_showbottomsure) = 0 and gbl_req_assort > 0 then gbl_sitebottomstring = ""

end function

function displayboard

     dim temp,flag
     flag = 0

     dim getdata
     if isarray(blist) = true then
           boardnum = ubound(blist,2)
     else
           reloadboardlistdata
           blist = application(def_mastercookies & "blist")
           if isarray(blist) = true then
                 boardnum = ubound(blist,2)
           else
                 boardnum = -1
           end if
     end if
     if boardnum = -1 then
     else%>
<script language=javascript>
     var num=0,currentassosrt = 0,flag=0;
     var gbl_tablebottomstring = "<%=replace(replace(replace(gbl_tablebottomstring,"\","\\"),"""","\"""),vbcrlf,"\n")%>";
     var gbl_tableheadstring = "<%=replace(replace(replace(gbl_tableheadstring,"\","\\"),"""","\"""),vbcrlf,"\n")%>";
     var def_bbs_screenwidth = "<%=def_bbs_screenwidth%>";
     var gbl_defineimage = "<%=gbl_defineimage%>";
<%
'模板屏蔽 代码修改提供:wensui

                 if getbinarybit(gbl_templetflag,1) = 1 and 1=2 then
           else
                 if getbinarybit(gbl_templetflag,2) = 1 then
                 else%>
/******************************************************************
仅使用以下模板 这里您可以修改为任意模板方式,
但始终所有页面都以这里的模板为识别方式 这里也是模板的最基础简单样式
*******************************************************************/
function displayboard(boardid,boardassort,boardname,boardintro)
{
           document.write("<table width=100% border=0 cellspacing=0 cellpadding=2 align=center bgcolor=#cccccc class=tbone><tr bgcolor=#666699><td colspan=2 class=tbhead><img src=images/blank.gif width=2 height=3><br>");
     document.write("<img src=images/ban.gif border=0 align=absmiddle> ");
     document.write("<a href=board/board.asp?boardid=" + boardid + ">" + boardname + "</a>");
//版块名称
     document.write("  <font color=#333333>");
     document.write(boardintro);//版块说明
     document.write("</font></td></tr>");
     document.write("<tr><td background=images/sq1_25.gif border=0 align=absmiddle height=1 class=tbhead>");//各版名称后分隔线
     document.write("</td></tr></table>");
}
<%
                 end if

     end if
           dim boardid,forumpass
           dim n
           gbl_topicnum = 0
           gbl_announcenum = 0
           gbl_goodnum = 0
           gbl_todayannounce = 0

           for n = gbl_startboard to boardnum
                 boardid = blist(0,n)
                 getdata = application(def_mastercookies & "boardinfo" & blist(0,n))
                 if isarray(getdata) = false then
                       reloadboardinfo(boardid)
                       getdata = application(def_mastercookies & "boardinfo" & blist(0,n))
                 end if
           if gbl_req_assort = 0 or (gbl_req_assort > 0 and gbl_req_assort = ccur(blist(1,n))) then
                       forumpass = getdata(7,0)
                       if forumpass <> "" then forumpass = "leadbbs"
                       getdata(9,0) = ccur(getdata(9,0))
                       response.write vbcrlf & "displayboard(" & boardid & "," & getdata(1,0) & ",""" & replace(replace(getdata(0,0),"\","\\"),"""","\""") & """,""" & replace(replace(replace(getdata(2,0),"\","\\"),"""","\"""),vbcrlf,"\n") & """,""" & replace(replace(getdata(3,0),"\","\\"),"""","\""") & """,""" & getdata(4,0) & """," & getdata(29,0) & "," & getdata(30,0) & ",""" & forumpass & """," & getdata(19,0) & ",""" & replace(replace(replace(getdata(20,0),"\","\\"),"""","\"""),"<","<") & """,""" & replace(replace(getdata(10,0),"\","\\"),"""","\""") & """," & getdata(9,0) & ",""" & replace(replace(getdata(14,0),"\","\\"),"""","\""") & """," & getdata(31,0) & "," & getdata(32,0) & ",""" & replace(replace(getdata(21,0),"\","\\"),"""","\""") & """,""" & getdata(22,0) & """,""" & getdata(23,0) & """,0,""" & getdata(27,0) & """);"
'以上有多余,但建议不要修改,因为在上面的基础模板中增强的话,就需要这里了
                 end if
                 gbl_topicnum = gbl_topicnum + ccur(getdata(29,0))
                 gbl_announcenum = gbl_announcenum + ccur(getdata(30,0))
                 gbl_goodnum = gbl_goodnum + ccur(getdata(32,0))
                 gbl_todayannounce = gbl_todayannounce + ccur(getdata(31,0))
           next
%>
</script>
     <%
     end if

end function

sub main

     opendatabase
     checkuseronline
     if gbl_checkpassdoneflag <> 1 then checkpass
     getactiveusernumber
     gbl_chk_tempstr = ""
     
     checkassort
     if gbl_chk_user = "" then displaytopinfo
     displayboard
     closedatabase

end sub

function getactiveusernumber

     if isnumeric(application(def_mastercookies & "activeusers")) = false then
           application.lock
           application(def_mastercookies & "activeusers") = 0
           application.unlock
     end if
     gbl_onlineusernum = ccur(application(def_mastercookies & "activeusers"))
     dim tmpdata
     if isarray(application(def_mastercookies & "statisticdata")) = false then reloadstatisticdata
     tmpdata = application(def_mastercookies & "statisticdata")
     gbl_onlinetime = ccur(tmpdata(0,0))
     gbl_usercount = ccur(tmpdata(1,0))
     gbl_maxonline = ccur(tmpdata(2,0))
     gbl_maxoltime = ccur(tmpdata(3,0))
     gbl_pagecount = ccur(tmpdata(4,0))
     gbl_uploadnum = ccur(tmpdata(5,0))
     gbl_maxannounce = ccur(tmpdata(6,0))
     gbl_maxanctime = ccur(tmpdata(7,0))
     gbl_yesterdayanc = ccur(tmpdata(8,0))
     if gbl_onlineusernum > gbl_maxonline then
           con.execute("update leadbbs_siteinfo set maxonline=" & gbl_onlineusernum & ",maxoltime=" & gettimevalue(def_now))
           updatestatisticdatainfo gbl_onlineusernum,2,0
           updatestatisticdatainfo gettimevalue(def_now),3,0
     end if

end function

main%>
<!---------------------------------------ban.asp完---------------------------->

将以上的qu.asp和ban.asp放入论坛根目录下,我们访问其地址,例如:http://******/bbs/qu.asp.就可以看出实际效果了。既然有区有版的分别显示法了。在frame中或外部首页调用中我们就可以任意发挥了,再也不怕将leadbbs制作成任意的首页模式了。
frameset中一个frame窗口的链接在另一个frame窗口显示内容只需要用[target=frame的name值]就可以实现了。同理,一个链接传递给俩个frame窗口的代码我也给出了。

原帖地址:http://w.leadbbs.com/a/a.asp?b=200&id=2423127

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.