www.gusucode.com > 易心博客[圣诞版] 3.5手动安装码程序 > Ex_Cls/Ex_RefreshCls.asp
<% '********************************************************* '文件名称: Ex_RefreshCls.asp '功能描述: 易心博客静态页生成类 '程序制作:易心 '官方网站: http://www.ex123.net '论坛支持:http://bbs.ex123.net '程序演示:http://exblog.ex123.net 'Copyright (C) 2007 ex123.net All rights reserved. 'LastUpdate: 2009-4-19 '********************************************************* Class Ex_RefreshCls Private ExComm,ExSkin,ExFso,Show_Logids,show_blogkeyword Private Skin1,Skin2,Skin3 Private Sub class_initialize Set ExComm=new Ex_CommonCls Set ExFso=new Ex_FsoCls Set ExSkin=new Ex_SkinCls Show_LogIds="" ExComm.GetConfigCache("runmode,ShowName,CmtPageSize,IsCheckCode,cmtmsgcheckre,iscmtmsgcheck,LogNum,blogname,BlogDescription,BlogKeyWord,IndexAddWord,blogurl,logourl,DefaultSkin,HtmlListPerPage,HtmlViewPerNum,CopyRight") Skin1=ExSkin.GetTxtSkin("Default.html") If ExComm.IsOblogSkin=False Then Skin3=ExSkin.GetTxtSkin("show_logcmt.html") End If End Sub Private Sub class_terminate Set ExComm=Nothing Set ExFso=Nothing Set ExSkin=Nothing End Sub '********************************* '作用:生成分页html代码 '参数:total--总页数 size--每页信息条数 page--当前页数 strpage--分页连接前导 '********************************* Private Function show(total,size,page,ClassId,Id) Dim i Show="共有"&total&"页 每页"&size&"条 " If CInt(page)=1 Then Show=show&"[首页] [上一页] " Else show=show&"<a href="""&ExComm.CreateUrl(ClassId,Id,"")&""">[首页]</a> <a href="""&ExComm.CreateUrl(ClassId,Id,"_"&Page-1)&""">[上一页]</a> " End If For i=((cint(page)-1) \ 5)*5+1 to ((cint(page)-1) \ 5)*5+5 if cint(i)<=cint(total) then if cint(page)<>cint(i) then show=show&"<a href="""&ExComm.CreateUrl(ClassId,Id,"_"&I)&""">["&i&"]</a> " else show=show&"<b>"&i&"</b> " end if end if Next If CInt(Page)=CInt(TOTAL) Then show=show&"[下一页] [尾页]" Else show=show&"<a href="""&ExComm.CreateUrl(ClassId,Id,"_"&Page+1)&""">[下一页]</a> <a href="""&ExComm.CreateUrl(ClassId,Id,"_"&Total)&""">[尾页]</a>" End if End Function '****************************************** '生成日志上一篇 下一篇代码 'id--当前日志的id '****************************************** Function proNext(id) dim rs,strsql set rs=server.CreateObject("adodb.recordset") strsql="select top 1 id,title,classid,ishide,textnum,logpass from Ex_log where id>"&id&" and textnum<>0 and datediff('d','"&now&"',submittime)<=0 order by submittime asc" rs.open strsql,Conn,1,1 if not rs.eof and not rs.bof Then If Rs("ishide")="游客" And Rs("textnum")<>0 And (Trim(Rs("logpass"))="" Or IsNull(Rs("logpass"))) Then proNext="上一篇: "&"<a href="""&ExComm.CreateUrl(ExComm.GetClassFolder(Rs("classid")),ExComm.GetLogName(Rs("id")),"")&""">"&rs("title")&"</a> <br>" Else proNext="上一篇: "&"<a href="""&Application(sn&"blogurl")&"blogview.asp?id="&rs("id")&""">"&rs("title")&"</a> <br>" End if end if rs.close strsql="select top 1 id,classid,title,ishide,textnum,logpass from Ex_log where id<"&id&" and textnum<>0 and datediff('d','"&now&"',submittime)<=0 order by submittime desc" rs.open strsql,Conn,1,1 if not rs.eof and not rs.bof Then If Rs("ishide")="游客" And Rs("textnum")<>0 And (Trim(Rs("logpass"))="" Or IsNull(Rs("logpass"))) Then proNext=proNext&"下一篇: "&"<a href="""&ExComm.CreateUrl(ExComm.GetClassFolder(Rs("classid")),ExComm.GetLogName(Rs("id")),"")&""">"&rs("title")&"</a> <br>" Else proNext=proNext&"下一篇: "&"<a href="""&Application(sn&"blogurl")&"blogview.asp?id="&rs("id")&""">"&rs("title")&"</a> <br>" End If end if rs.close set rs=nothing end function '****************************************** '显示日志内容 '参数:id-要生成日志的id '****************************************** Private Sub Show_LogMore(ByVal id) Dim sql,Rs Dim show_logtext,show_topic,show_loginfo,show_more,show_logcyc,iscmt,show_copyright,show_author,show_addtime Dim show_topictxt,show_emot,show_logcls,show_topicurl,logName,Html,LogHtml,CmtHtml,classid,title,BlogViewUrl Id=Trim(Id) Show_logids=id Set Rs=server.CreateObject("adodb.recordset") sql="select * from Ex_log where id="&id Rs.open Sql,Conn,1,1 if not rs.eof And not rs.bof Then BlogViewUrl=ExComm.CreateUrl(ExComm.GetClassFolder(Rs("classid")),ExComm.GetLogName(Rs("id")),"") logName=rs("title") iscmt=rs("iscmt") classid=Rs("classid") '如果适合生成静态 If Rs("ishide")="游客" And Rs("textnum")<>0 And (Trim(Rs("logpass"))="" Or IsNull(Rs("logpass"))) Then If rs("copyright")=True Then show_copyright=Application(sn&"copyright") Else show_copyright="" End if '构造$show_topic$ show_topic="<a href=index.asp?classid="&Rs("classid")&">["&ExComm.GetClassName(rs("classid"))&"]</a>" show_logcls=Replace(show_topic,"[","") show_logcls=Replace(show_logcls,"]","") show_topic=show_topic&"<a href="&BlogViewUrl&" >"&rs("title")&"</a>" show_topicurl=BlogViewUrl '构造$show_loginfo$ show_loginfo=""&Application(sn&"ShowName")&" 发表于 "&rs("log_postyear")&"-"&rs("log_postmonth")&"-"&rs("log_postday")&" "&Hour(Rs("submittime"))&":"&Minute(Rs("submittime"))&":"&Second(Rs("submittime")) '构造$show_logtext$ Dim tags,tags_start,tags_end,tags_str tags=rs("tags") show_blogKeyword=Replace(tags&" "," ",",") If tags<>"" then tags=Split(tags," ") tags_end=UBound(tags) For tags_start=0 To tags_end tags_str= tags_str&"<a href="&Application(sn&"blogurl")&"index.asp?action=search&selecttype=tags&keyword="&server.urlencode(tags(tags_start))&"&classid="&rs("classid")&">"&tags(tags_start)&"</a> " Next End if show_logtext=rs("content") show_logtext=show_logText&"<br>相关日志:"&tags_str show_logtext=show_logText&"<br>"&proNext(rs("id")) '构造$show_more$ 此标记为js调用显示 show_more="<span id="""&Rs("Id")&"""></span>" '构造$show_emot$ show_emot="<img src="&Application(sn&"blogurl")&"images/emotion/em0"&rs("emotion")&".gif >" '构造$show_author$ show_author=Application(sn&"showname") '构造$show_addtime$ show_addtime=rs("log_postyear")&"-"&rs("log_postmonth")&"-"&rs("log_postday")&" "&Hour(Rs("submittime"))&":"&Minute(Rs("submittime"))&":"&Second(Rs("submittime")) '构造$show_topictxt$ show_topictxt=rs("title") Title=show_topictxt '辅模板替换开始 show_logcyc=replace(Skin2,"$show_topic$",show_topic) show_logcyc=replace(show_logcyc,"$show_loginfo$",show_loginfo) show_logcyc=replace(show_logcyc,"$show_more$",show_more) show_logcyc=replace(show_logcyc,"$show_emot$",show_emot) show_logcyc=replace(show_logcyc,"$show_author$",show_author) show_logcyc=replace(show_logcyc,"$show_addtime$",show_addtime) show_logcyc=replace(show_logcyc,"$show_topictxt$",show_topictxt) show_logcyc=replace(show_logcyc,"$show_logtext$",show_logtext) show_logcyc=replace(show_logcyc,"$show_logcls$",show_logcls) show_logcyc=replace(show_logcyc,"$show_topicurl$",show_topicurl) show_logcyc=replace(show_logcyc,"$show_copyright$",show_copyright) LogHtml=show_logcyc Rs.close '回复部分显示 Dim page,per Sql="select * from Ex_Comment where parentid="&id&" and isshow='是' order by id desc" Rs.open Sql,conn,1,1 If Not Rs.eof And Not Rs.bof Then '如果有回复内容 Rs.PageSize=Application(sn&"CmtPageSize") For page=1 To Rs.PageCount Rs.Absolutepage=page CmtHtml="" per=Application(sn&"CmtPageSize") Do While Not rs.eof And per>0 '构造$show_topic$ show_topic=rs("cmttitle") '构造$show_loginfo$ if trim(rs("userhome"))<>"" and trim(rs("userhome"))<>"http://" then show_loginfo="<a href="""&rs("userhome")&""" target=""_blank"" title=""查看主页"">"&rs("username")&"</a>"&"于"&rs("addtime")&"发表" else show_loginfo=rs("username")&"于"&rs("addtime")&"发表" end If '构造$show_logtext$ show_logtext=rs("cmtcomment") '构造$show_more$ show_more="<span id=""cmt"&rs("id")&"""></span><script src="&Application(sn&"blogurl")&"JsInHtml.asp?action=cmtmore&id="&rs("id")&"&parentid="&rs("parentid")&"&uname="&rs("username")&"></script>" '构造$show_emot$ show_emot="" '构造$show_author$ show_author=rs("username") '构造$show_addtime$ show_addtime=rs("addtime") '构造$show_topictxt$ show_topictxt=rs("cmttitle") If ExComm.IsOblogSkin Then show_logcyc=Skin2 Else show_logcyc=Skin3 End If show_logcyc=replace(show_logcyc,"$show_topic$",show_topic) show_logcyc=replace(show_logcyc,"$show_loginfo$",show_loginfo) show_logcyc=replace(show_logcyc,"$show_logtext$",show_logtext) show_logcyc=replace(show_logcyc,"$show_more$",show_more) show_logcyc=replace(show_logcyc,"$show_emot$",show_emot) show_logcyc=replace(show_logcyc,"$show_author$",show_author) show_logcyc=replace(show_logcyc,"$show_addtime$",show_addtime) show_logcyc=replace(show_logcyc,"$show_topictxt$",show_topictxt) show_logcyc=replace(show_logcyc,"$show_cmtid$",Rs("id")) rs.movenext per=per-1 CmtHtml=CmtHtml&show_logcyc Loop Dim showpage showpage="<div align=center>"&show(Rs.PageCount,Rs.PageSize,page,ExComm.GetClassFolder(classid),ExComm.GetLogName(id))&"</div>" '分页结束 CmtHtml=CmtHtml&showpage If IsCmt="游客" Then Html=LogHtml&"<a name=""#cmttop""></a>"&CmtHtml&CmtPost(id,logname) ElseIf IsCmt="会员" Then Html=LogHtml&"<a name=""#cmttop""></a>"&CmtHtml&"<br><center>此文章只有会员才可以回复,如果您是会员请登陆</center>" Else Html=LogHtml&"<a name=""#cmttop""></a>"&CmtHtml&"<br><center>此文章禁止回复</center>" End If CreateViewHtml id,classid,page,html,title Next Else '没有回复内容时 If IsCmt="游客" Then Html=LogHtml&CmtPost(id,logname) ElseIf IsCmt="会员" Then Html=LogHtml&"<br><center>此文章只有会员才可以回复,如果您是会员请登陆</center>" Else Html=LogHtml&"<br><center>此文章禁止回复</center>" End If CreateViewHtml id,classid,"1",html,title End If Else '不适合生成静态 就把已经生成的静态页面删除 Rs.Close Sql="select id from Ex_Comment where parentid="&id&" and isshow='是' order by id desc" Rs.open Sql,conn,1,1 If Not Rs.eof And Not Rs.bof Then Rs.PageSize=Application(sn&"CmtPageSize") If Rs.PageCount=1 Then ExFso.DelFile Replace(BlogViewUrl,Application(Sn&"blogurl"),"") Exit Sub End If For page=2 To Rs.PageCount ExFso.DelFile Replace(ExComm.CreateUrl(ExComm.GetClassFolder(ClassId),ExComm.GetLogName(Id),"-"&page),Application(Sn&"blogurl"),"") Next End If End If End If End Sub '*************************** '日志回复框 '*************************** Private Function CmtPost(id,logname) Dim Temp temp=temp&"<a name=""#cmtpost""></a> <div align=""center"">" temp=temp&" <table border=""0"" width=""60%"" id=""Ex_cmttab"" align=""center"">" temp=temp&"<form method=""POST"" action="""&Application(sn&"blogurl")&"blogview.asp?action=save&id="&id&""" id=""Ex_cmt"">" temp=temp&" <tr>" temp=temp&" <td width=""17%"">昵称:<font color=""red"">*</font></td>" temp=temp&" <td width=""83%"" style=""text-align:left;""><input type=""text"" name=""username"" size=""20"" value="""" align=""left""></td>" temp=temp&" </tr>" temp=temp&" <tr>" temp=temp&" <td width=""17%"">密码:</td>" temp=temp&" <td width=""83%"" style=""text-align:left;""><input type=""password"" name=""userpass"" id=""password"" size=""20"" value=""""><font color=red> [游客不必填写]</font></td>" temp=temp&" </tr>" temp=temp&" <tr>" temp=temp&" <td width=""17%"">主页:</td>" temp=temp&" <td width=""83%"" style=""text-align:left;""><input type=""text"" name=""homepage"" size=""20"" value=""""></td>" temp=temp&" </tr>" temp=temp&" <tr>" temp=temp&" <td width=""17%"">验证码:<font color=""red"">*</font></td>" temp=temp&" <td width=""83%"" style=""text-align:left;""><input type=""text"" name=""checkcode"" id=""checkcode"" size=""10""><img src=""inc/checkcode.asp"" style=""cursor:hand"" onclick=""this.src='"&Application(sn&"blogurl")&"inc/checkcode.asp';"" alt=""看不清?点一下"" /></td>" temp=temp&" </tr>" '获取用户登录信息开始 temp=temp&"<script>"&vbcrlf temp=temp&"var v;"&vbcrlf temp=temp&"v=RequestCookies('"&Md5(sn)&"').get('uname');"&vbcrlf temp=temp&"if(v!=null&&v!=''){"&vbcrlf temp=temp&"document.getElementById('username').value=DecodeCookie(v);"&vbcrlf temp=temp&"}"&vbcrlf temp=temp&"v=RequestCookies('"&Md5(sn)&"').get('upwd');"&vbcrlf temp=temp&"if(v!=null&&v!=''){"&vbcrlf temp=temp&"document.getElementById('userpass').value=DecodeCookie(v);"&vbcrlf temp=temp&"}"&vbcrlf temp=temp&"v=RequestCookies('"&Md5(sn)&"').get('homepage');"&vbcrlf temp=temp&"if(v!=null&&v!=''){"&vbcrlf temp=temp&"document.getElementById('homepage').value=DecodeCookie(v);"&vbcrlf temp=temp&"}"&vbcrlf temp=temp&"</script>"&vbcrlf '获取用户登录信息结束 temp=temp&" <tr style=""display:none"">" temp=temp&" <td width=""17%"">标题:<font color=""red"">*</font></td>" temp=temp&" <td width=""83%""><input type=""text"" name=""cmttitle"" size=""35"" value=""re:"&logName&"""></td>" temp=temp&"</tr>" temp=temp&" <tr>"&vbcrlf temp=temp&" <td width=""100%"" colspan=""2"">" temp=temp&"<textarea id='aBody' name='aBody' style=""width:300px;height:100px""></textarea>" temp=temp&"<script>KE.show({id : 'aBody',items : ['undo', 'redo', 'fontname', 'fontsize', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline','removeformat', 'justifyleft', 'justifycenter', 'justifyright', 'emoticons','insertorderedlist'],height : '150px', width:'420px'});</script>" temp=temp&"</td></tr>" temp=temp&" <tr>" temp=temp&" <td width=""100%"" colspan=""2""><input type=""submit"" value=""提交"" name=""B1"" onclick=""KE.event.ready('doSubmit()')""></td>" temp=temp&"<script>"&vbcrlf&"function doSubmit(){document.getElementById(""aBody"").value=KE.util.getData('aBody');document.getElementById(""Ex_cmt"").submit()}"&vbcrlf&"</script>" temp=temp&" </tr></form>" temp=temp&" </table>" temp=temp&" </div>" temp=temp&"<br>提示:代<font color=""red"">*</font>的和内容必须填写!!" CmtPost=Temp End Function '***************** '生成日志内容静态页 '参数:classid--生成的类id '***************** Private Sub CreateViewHtml(id,classid,ByVal page,ByVal html,ByVal Title) '主模板标记替换开始 Dim Head,Body,Bottom,BlogViewUrl If CInt(Page)=1 Then Page="" Else Page="_"&page End If BlogViewUrl=Replace(ExComm.CreateUrl(ExComm.GetClassFolder(classid),ExComm.GetLogName(id),Page),Application(Sn&"blogurl"),"") ExFso.CreateRoute ExComm.GetClassFolder(classid) Body=Replace(Skin1,"$show_logid$",id) Body=Replace(Body,"$show_classid$",classid) Body=Replace(Body,"$show_tags$",show_blogKeyword) Body=Replace(Body,"$show_log$",html) Body=Replace(Body,"$show_logids$",show_logids) Bottom=ExComm.BottomInfo '输出内容 Head=Head&"<html xmlns=""http://www.w3.org/1999/xhtml"">"&vbcrlf Head=Head&"<head>"&vbcrlf Head=Head&"<meta http-equiv=""content-type"" content=""text/html; charset=gb2312"">"&vbcrlf Head=Head&"<meta name=""Description"" content="""&Title&""">"&vbcrlf Head=Head&"<meta name=""Keywords"" content="""&show_blogkeyword&""">"&vbcrlf Head=Head&"<title>"&title&Application(sn&"IndexAddWord")&"</title>"&vbcrlf Head=Head&"<script src=""inc/Main.js""></script>"&vbcrlf Head=Head&"<script src=""inc/UserInfo.js""></script>"&vbcrlf Head=Head&"<link href=""inc/OblogSkin.Css"" rel=""stylesheet"" type=""text/css"" />"&vbcrlf Head=Head&"</head>"&vbcrlf Head=Head&"<body>"&vbcrlf If ExComm.IsOblogSkin Then ExFso.CreateFile BlogViewUrl,ExComm.DoUrl(Head)&ExComm.DoUrl(Body)&"</body></html>" Else Body=Replace(Body,"$show_logids$",show_logids) Body=Replace(Body,"$show_blogtitle$",title&Application(sn&"TitleAddWord")) Body=Replace(Body,"$show_blogkeyword$",show_blogKeyword) Body=Replace(Body,"$show_blogdescription$",Title) ExFso.CreateFile BlogViewUrl,ExComm.DoUrl(Body) End If End Sub '***************** '生成日志内容页 '参数:id '***************** Public Sub CreateView(id) Skin2=ExSkin.GetTxtSkin("show_logmore.html") Dim Rs,I,Page If id<>"" Then Show_LogMore(id) Else Set Rs=server.CreateObject("adodb.recordset") Rs.open "select id from Ex_log order by id asc",conn,1,1 If Not Rs.eof And not Rs.bof Then Rs.pagesize=1 Page=Request.Cookies(md5(Sn))("Page") If Trim(Page)="" Then Response.Cookies(md5(Sn))("Page")="1" Page=1 Rs.absolutepage=1 Else Rs.absolutepage=Page End If Response.Cookies(md5(Sn))("PageTotal")=Rs.PageCount I=Application(sn&"HtmlViewPerNum") Do While not Rs.eof And I>0 Show_LogMore(Rs("id")) Response.Cookies(md5(Sn))("Page")=CInt(Request.Cookies(md5(Sn))("Page"))+1 'Response.Write(Request.Cookies(md5(Sn))("Page")) Rs.movenext I=I-1 Loop End If End If End Sub End Class %>