根据这个模板我修改了randomsort插件
其实PLUGIN\randomsort2 文件夹的内容基本和 PLUGIN\randomsort 一样,只是一个是用于输出top15 一个是随即文件
blog.htm 根据你的需求 选其一:复制内容到剪贴板
代码:
<!--最新文章-->
<!--最新文章2-->
<!--随机文章-->
<!--随机文章2-->
<!--本月评论排行-->
<!--本年评论排行-->
<!--本月排行-->
<!--本年排行-->把blog.asp修改如下(两个文件是一样的):复制内容到剪贴板
代码:
<%@ CODEPAGE=65001 %>
<% On Error Resume Next %>
<% Response.Charset="UTF-8" %>
<% Response.Buffer=True %>
<% Response.ContentType ="application/x-javascript" %>
<!-- #include file="../../c_option.asp" -->
<!-- #include file="../../function/c_function.asp" -->
<!-- #include file="../../function/c_function_md5.asp" -->
<!-- #include file="../../function/c_system_lib.asp" -->
<!-- #include file="../../function/c_system_base.asp" -->
<!-- #include file="../../function/c_system_event.asp" -->
<%
Function WriteBlogFile
Call GetReallyDirectory()
'输出文件地址
txtfilename =BlogPath & "PLUGIN\randomsort\" & "cache.htm"
'模板文件地址
templetfile =BlogPath & "PLUGIN\randomsort\" & "blog.htm"
intCutLen=20
If DateDiff("n", GetFileDate(txtfilename), Now) <= 2 Then '每隔20分钟生成一次目标文件
WriteBlogFile=LoadFromFile(txtfilename,"utf-8")
Exit Function
End if
Call System_Initialize()
txttemplet = LoadFromFile(templetfile,"utf-8")
Set objRS = CreateObject("ADODB.RECORDSET")
'最新文章
strSql = "select top 20 * from blog_Article WHERE ([log_ID]>0) AND ([log_Level]>2) order by log_ID desc "
objRS.Open strSql, objConn, 1, 1
strnew = " "
strnew2 = " "
lastid=objRS("log_ID")
For icount=1 To 20
If objRS.eof Then Exit For
Set objArticle=New TArticle
If objArticle.LoadInfoByArray(Array(objRS("log_ID"),objRS("log_Tag"),objRS("log_CateID"),objRS("log_Title"),objRS("log_Intro"),objRS("log_Content"),objRS("log_Level"),objRS("log_AuthorID"),objRS("log_PostTime"),objRS("log_CommNums"),objRS("log_ViewNums"),objRS("log_TrackBackNums"),objRS("log_Url"),objRS("log_Istop"))) Then
If icount<11 Then
strnew = strnew & "<li> <a href=""" & objArticle.Url & """>" & cutStr(objRS("log_Title"),intCutLen) & "</a></li>"
else
strnew2 = strnew2 & "<li> <a href=""" & objArticle.Url & """>" & cutStr(objRS("log_Title"),intCutLen) & "</a></li>"
End If
End If
objRS.movenext
next
objRS.Close
'随机文章
randomize
tempid=CStr(CInt(Rnd*CInt(lastid))+20)
strSql = "select top 20 * from blog_Article WHERE ([log_Level]>2) AND log_ID>" & tempid & " order by log_ID "
objRS.Open strSql, objConn, 1, 1
strtemp = " "
strtemp2 = " "
For icount=1 To 20
If objRS.eof Then Exit For
Set objArticle=New TArticle
If objArticle.LoadInfoByArray(Array(objRS("log_ID"),objRS("log_Tag"),objRS("log_CateID"),objRS("log_Title"),objRS("log_Intro"),objRS("log_Content"),objRS("log_Level"),objRS("log_AuthorID"),objRS("log_PostTime"),objRS("log_CommNums"),objRS("log_ViewNums"),objRS("log_TrackBackNums"),objRS("log_Url"),objRS("log_Istop"))) Then
If icount<11 Then
strtemp = strtemp & "<li><a href=""" & objArticle.Url & """>" & cutStr(objRS("log_Title"),intCutLen) & "</a></li>"
else
strtemp2 = strtemp2 & "<li><a href=""" & objArticle.Url & """>" & cutStr(objRS("log_Title"),intCutLen) & "</a></li>"
End If
End If
objRS.movenext
next
objRS.Close
'本月评论排行 实际是本季度的排行
strSql = "select top 10 * from blog_Article WHERE ([log_Level]>2) AND (log_ID>0) AND (log_PostTime>Now()-90) ORDER BY log_CommNums DESC "
objRS.Open strSql, objConn, 1, 1
strcommonth = " "
For icount=1 To 10
If objRS.eof Then Exit For
Set objArticle=New TArticle
If objArticle.LoadInfoByArray(Array(objRS("log_ID"),objRS("log_Tag"),objRS("log_CateID"),objRS("log_Title"),objRS("log_Intro"),objRS("log_Content"),objRS("log_Level"),objRS("log_AuthorID"),objRS("log_PostTime"),objRS("log_CommNums"),objRS("log_ViewNums"),objRS("log_TrackBackNums"),objRS("log_Url"),objRS("log_Istop"))) Then
strcommonth = strcommonth & "<li> <a href=""" & objArticle.Url & """>" & cutStr(objRS("log_Title"),intCutLen) & "</a></li>"
objRS.movenext
End If
next
objRS.Close
'本年评论排行
strSql = "select top 10 * from blog_Article WHERE ([log_Level]>2) AND (log_ID>0) AND (log_PostTime>Now()-360) ORDER BY log_CommNums DESC "
objRS.Open strSql, objConn, 1, 1
strcomyear = " "
For icount=1 To 10
If objRS.eof Then Exit For
Set objArticle=New TArticle
If objArticle.LoadInfoByArray(Array(objRS("log_ID"),objRS("log_Tag"),objRS("log_CateID"),objRS("log_Title"),objRS("log_Intro"),objRS("log_Content"),objRS("log_Level"),objRS("log_AuthorID"),objRS("log_PostTime"),objRS("log_CommNums"),objRS("log_ViewNums"),objRS("log_TrackBackNums"),objRS("log_Url"),objRS("log_Istop"))) Then
strcomyear = strcomyear & "<li><td align=""left""> <a href=""" & objArticle.Url & """>" & cutStr(objRS("log_Title"),intCutLen) & "</a></li>"
objRS.movenext
End If
next
objRS.Close
'本月排行
strSql = "select top 10 * from blog_Article WHERE ([log_Level]>2) AND (log_ID>0) AND (log_PostTime>Now()-30) ORDER BY log_ViewNums DESC "
objRS.Open strSql, objConn, 1, 1
strtopmonth = " "
For icount=1 To 10
If objRS.eof Then Exit For
Set objArticle=New TArticle
If objArticle.LoadInfoByArray(Array(objRS("log_ID"),objRS("log_Tag"),objRS("log_CateID"),objRS("log_Title"),objRS("log_Intro"),objRS("log_Content"),objRS("log_Level"),objRS("log_AuthorID"),objRS("log_PostTime"),objRS("log_CommNums"),objRS("log_ViewNums"),objRS("log_TrackBackNums"),objRS("log_Url"),objRS("log_Istop"))) Then
strtopmonth = strtopmonth & "<li><a href=""" & objArticle.Url & """>" & cutStr(objRS("log_Title"),intCutLen) & "</a></li>"
objRS.movenext
End If
next
objRS.Close
'本年排行
strSql = "select top 10 * from blog_Article WHERE ([log_Level]>2) AND (log_ID>0) AND (log_PostTime>Now()-360) ORDER BY log_ViewNums DESC "
objRS.Open strSql, objConn, 1, 1
strtopyear = " "
For icount=1 To 10
If objRS.eof Then Exit For
Set objArticle=New TArticle
If objArticle.LoadInfoByArray(Array(objRS("log_ID"),objRS("log_Tag"),objRS("log_CateID"),objRS("log_Title"),objRS("log_Intro"),objRS("log_Content"),objRS("log_Level"),objRS("log_AuthorID"),objRS("log_PostTime"),objRS("log_CommNums"),objRS("log_ViewNums"),objRS("log_TrackBackNums"),objRS("log_Url"),objRS("log_Istop"))) Then
strtopyear = strtopyear & "<li><a href=""" & objArticle.Url & """>" & cutStr(objRS("log_Title"),intCutLen) & "</a></li>"
objRS.movenext
End If
next
objRS.Close
'模板文件替换
txtout = txttemplet
txtout = Replace(txtout, "<!--最新文章-->", strnew)
txtout = Replace(txtout, "<!--最新文章2-->", strnew2)
txtout = Replace(txtout, "<!--随机文章-->", strtemp)
txtout = Replace(txtout, "<!--随机文章2-->", strtemp2)
txtout = Replace(txtout, "<!--本月评论排行-->", strcommonth)
txtout = Replace(txtout, "<!--本年评论排行-->", strcomyear)
txtout = Replace(txtout, "<!--本月排行-->", strtopmonth)
txtout = Replace(txtout, "<!--本年排行-->", strtopyear)
txtout = Replace(txtout, Chr(10), "")
txtout = Replace(txtout, Chr(13), "")
txtout = "document.write ('" & txtout & "');"
Call SaveToFile(txtfilename,txtout,"utf-8",False)
WriteBlogFile=txtout
End Function
Function cutStr(str,strlen)
dim i,l,t,c
l=len(str)
t=0
for i=1 to l
c=Abs(Asc(Mid(str,i,1)))
if c=1 then
t=t+2
else
t=t+1
end if
if t>=strlen then
cutStr=left(str,i)&".."
exit for
else
cutStr=str
end if
next
End Function
Function GetFileDate(filespec)
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(filespec) Then
Set f = fs.GetFile(filespec)
GetFileDate = f.DateLastModified
Set f=Nothing
Else
GetFileDate="2004-11-11 11:11:11"
End if
Set fs=Nothing
End Function
Function GetURL(url)
Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "GET", url, False, "", ""
.Send
GetURL = .ResponseText
End With
Set Retrieval = Nothing
End Function
Response.Write WriteBlogFile
%>