<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="inc/conndb.asa"-->
<!--#include file="inc/function.asp"-->
<%

'调用方法:将复制到首页合适地方

'###简要设置### 
'所有的设置中，1 是 0 否

'#1,是否显示发表者'
const view_user=0 

'#2,是否显示更多' 1 显示 0 不显示
const view_more=0

'#3,是否显示时间' 1 显示 0 不显示
const view_date=1 

'字体大小,12是标准的大小
const font_size="13px" 

dim tds
tds=1
if view_user=1 then tds=tds+1
if view_date=1 then tds=tds+1
dim db%>
<%
call toplist()

'######## 首页调用 ########
'
Sub toplist()
dim tlen,boardid,diaoact,diaoisup
boardid=request.QueryString("boardid")
diaoact=request.QueryString("diaoact")
diaoisup=request.QueryString("diaoisup")
	if diaoisup="" then diaoisup=0
tlen=request.QueryString("tlen")
	if tlen="" then tlen=30 
num=request.QueryString("num") 
	if num="" then num=10

tlen=int(tlen)
num=int(num)
if num>100 then num=100
dim url1,url2,url
url1=request.servervariables("server_name")
url2=request.servervariables("url")
url="http://"&url1&url2
url=replace(url,"diao.asp","show.asp")
url22=replace(url,"show.asp","index.asp")

	If boardid=0 Then
		fl=" ischeck>0 "
	Else 
		fl=" ischeck>0 and boardid="&boardid
	End If 

's数据读取条件
Select Case diaoact
	Case "jinghua"'精华
		jh=" and isgood=1"
	Case "zhiding"
		zhidings="istop desc,"
End Select 

Select Case diaoisup
	Case "0"'不根据最后回复时间排序
		isups="[addtime] desc,[id]"
	Case "1" '根据最后回复时间排序
		isups="[retime] desc,[id]"
End Select 

Set rs=conn.Execute("select top "&num&" * from "&bbstable&" where "&fl&" "&jh&" ORDER BY "&zhidings&" "&isups&" DESC",0,1)
%>
document.write("<table width='99%' border='0' align='left' cellpadding='0' cellspacing='0' style='font-size: <%=font_size%>;'>")
<% do while not rs.eof 
title=LeftTrue(DropFuckWords(CStr(rs("title"))),tlen)
		if Rs("TitleColor")<>"" Then title="<font color="&Rs("TitleColor")&">"&title&"</font>"
		'Add by zidone for Version 1.1 Dev
		if CInt(Rs("titleBold"))=1 Then title="<B>" & title & "</B>"
		if Rs("isTop")=1 Then title="<font color=#ff0000>[置顶]</font>"&title
		if Rs("isGood")=1 Then title=title&"<font color=#ff0000>[精华]</font>"

%>     
document.write("<tr><td height='22'>&nbsp;<font face=webdings color='#FF6600'>4</font>&nbsp;<a href='<%=url%>?id=<%=Rs("id")%>' target='_blank'><%=title%></a></td>")
<%if view_user=1 then%>
document.write("<td><%=Rs("username")%></td>")
<%end if
if view_date=1 then
%>
document.write("<td><font color='#999999'>(<%=month(Rs("addtime"))&"/"&day(Rs("addtime"))%>)</font></td></tr>")
<%end if%>
document.write("<tr><td height='1' colspan='<%=tds%>' bgcolor='#E4F2FA'></td></tr>") 
<%
rs.movenext
loop 
rs.close
set rs=nothing
conn.close
set conn=nothing
if view_more=1 then
%>
document.write("<tr><td colspan='<%=tds%>' align='right'><a href='<%=url22%>' target='_blank'> >>更多</a></td></tr>")
<%
end if
%>
document.write("</table>")
<%
'response.end
End Sub
Function LeftTrue(str,n)
dim i
  If Len(str) <= (n/2) Then
   LeftTrue = str
  Else
   Dim TStr, l, t, c
   l = Len(str) : TStr="" : t=0
   For i = 1 To l
    c = Asc(Mid(str,i,1))
    If c < 0 Then c = c + 65536
    If c > 255 Then
     t = t + 2
    Else
     t = t + 1
    End If
    If t > n Then Exit For
    TStr = TStr & (Mid(str,i,1))
    Next
   LeftTrue = TStr
  End If
End Function
%>

