📄 js.asp
字号:
<!--#include file="conn.asp" -->
<%
dim kind, path,classID,NclassID
kind=1 '首页调用类型,1表示新文章,2表示热门文章
const dateNum=10 '列出多少天内的热门文章
const maxLen=30 '主题最多显示字数,字母算一个汉字算两个
const listNum=10 '显示多少个文章标题
const bullet="·" '标题前的图片或符号
const hitColor="red" '点击数的颜色
const new_color="red" '新文章日期的颜色
const old_color="gray" '旧文章日期的颜色
const showNclass=true '是否显示专题连接
ClassID=request.querystring("classid") '指定首页调用文章分类ID,全部分类不填
NclassID=request.querystring("nclassid")
dim rs,sql,str,str1,topicLen,topic
Path="http://"&request.servervariables("server_name")&replace(request.servervariables("script_name"),"js.asp","")
function gotTopic(str,strlen)
dim l,t,c, i
l=len(str)
t=0
for i=1 to l
c=Abs(Asc(Mid(str,i,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
gotTopic=left(str,i)&"..."
exit for
else
gotTopic=str
end if
next
end function
set rs=server.createObject("Adodb.recordset")
sql="select top "&listNum&" Productid,title,dateAndtime,hits,nclass,Product.nclassid,Product.classid from ANclass inner join Product on Product.nclassid=anclass.nclassid"
if NclassID<>"" then
sql=sql&" where Product.NclassID="&NclassID
elseif classID<>"" then
sql=sql&" where Product.classID="&classID
end if
if kind=2 then
if nclassid="" and classID="" then
sql=sql&" where"
else
sql=sql&" and"
end if
end if
select case kind
case "1" sql=sql&" order by Productid desc"
case "2" sql=sql&" DATEDIFF('d',dateandtime,Now())<="&dateNum&" order by hits desc,title"
end select
rs.open sql,conn,3,3
if rs.bof and rs.eof then
str=str+"没有符合条件的文章"
else
rs.movefirst
do while not rs.eof
topic=gotTopic(rs("title"),maxLen)
topic=replace(server.HTMLencode(topic)," "," ")
topic=replace(topic,"'"," ")
str=str+bullet
if showNclass then
str=str+"[<a href='"&path&"default.asp?classid="&rs("classid")&"&nclassid="&rs("nclassid")&"'>"&rs("nclass")&"</a>] "
end if
str=str+"<a href='"&Path&"Productview.asp?id="+Cstr(rs("Productid"))+"' target='_blank' title='["&rs("nclass")&"]"&replace(replace(server.HTMLencode(rs("title"))," "," "),"'"," ")&"') >"+Topic+"</a> ("
str=str & "<font color="
if rs("dateandtime")>=date then
str=str & new_color
else
str=str & old_color
end if
str=str &">" & Month(rs("DateAndTime"))&"月"&Day(rs("DateAndTime"))&"日</font>,<font color="& hitcolor &">"& rs("hits") &"</font>)<br>"
rs.moveNext
loop
end if
rs.close : conn.close
set rs=nothing : set conn=nothing
response.write "document.write ("&Chr(34)&str&Chr(34)&");"
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -