乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      生成sHTML靜態(tài)頁面的詳細(xì)過程及分析

       爪一o_0一斗 2013-05-13

      最近在做調(diào)用SHtml模板生成靜態(tài)頁面的項(xiàng)目二次開發(fā),找了點(diǎn)相關(guān)的資料。自己也在研究

      生成sHTML靜態(tài)頁面,同時(shí)調(diào)用模板,便于修改。
      過程如下:
      <%
      Action=Trim(Request("Action"))
      '變量ACTION=1為新增,ACTION=0為修改
      title=Trim(Request("title"))
      content=Trim(Request("content"))
      '....更多內(nèi)容來源

      if Action=0 then

      '修改sHTML文件
      id=Trim(Request("id"))
      '指定修改的文章
      response.buffer=true
      Response.Expires=0
      '清除緩存
      set rs=server.createobject("adodb.recordset")
      sql = "Select url From Docs where id="&id
      rs.Open sql,conn,1,1
      if not(rs.eof and rs.bof) then
      filepath =rs("url")
      '讀取文章路徑
      end if
      StaticFilePath = filepath
      '設(shè)定另一變量后用。
      filepath=replace(filepath,".shtml","")
      '轉(zhuǎn)換文件名后綴
      filepath="/a/"&filepath
      '得到完整文件路徑
      else

      '生成新sHTML文件

         d=year(date())&month(date())&date(date())
         t=hour(now())&minute(now())&second(now())
         randomize 
         '使用系統(tǒng)計(jì)時(shí)器來初始化亂數(shù)產(chǎn)生器
         t=rnd(t) 

      StaticFilePath= d &"/"& d & t &".shtml"
      folder = "/a/"& d &"/"
      '存儲在數(shù)據(jù)庫中的路徑,文件夾a為自定
      filepath = folder&t
      '得到完整文件路徑
      end if


      '保存數(shù)據(jù)到數(shù)據(jù)庫
      set rs=server.createobject("adodb.recordset")
      sql = "Select * From ......"
      '.............
      '過程不是這部份的,省略

      ContentStr=split(Content,"|||")
      '查找內(nèi)容中的分頁符
      PageNumber=ubound(ContentStr)
      For p = 0 to ubound(ContentStr)

      Dim fso,fin
      '創(chuàng)建文件系統(tǒng)對象
      Set fso=Server.CreateObject("Scripting.FileSystemObject")
      Model="/a/Template/index.shtml"
      'sHTML模板文件路徑
      Set fin=fso.OpenTextFile(Server.MapPath(""&Model&""))
      mb_code=fin.ReadAll
      fin.close
      '打開模板代碼,

      ' REM 轉(zhuǎn)換其中特殊代碼轉(zhuǎn)變?yōu)榻邮苤?開始
      mb_code=replace(mb_code,"$$Pagename$$",Pagename)
      mb_code=replace(mb_code,"$$Title$$",Title)
      mb_code=replace(mb_code,"$$Posttime$$",now())
      mb_code=replace(mb_code,"$$PinlunContent$$",PinlunContent)
      mb_code=replace(mb_code,"$$Content$$",ContentStr(p))

      if PageNumber>0 then
      If p = 0 and p < PageNumber Then 
      '分頁數(shù)大于一時(shí)
      '生成圖片翻頁鏈接 開始
      MyPagerTable="<div align=center><a href=""$UrlDown$""><img src=""/images/page_down.gif"" width=""69"" height=""21"" border=""0"" /></a></div>"
      MyPagerTable=replace(MyPagerTable,"$UrlDown$",fname&"_"&p+1&".shtml")
      ElseIf p = 1 and p < PageNumber Then 
      MyPagerTable="<div align=center><a href=""$UrlUp$""><img src=""/images/page_up.gif"" width=""69"" height=""21"" border=""0"" /></a> <a href=""$UrlDown$""><img src=""/images/page_down.gif"" width=""69"" height=""21"" border=""0"" /></a></div>" 
      MyPagerTable=replace(MyPagerTable,"$UrlUp$",fname&".shtml")
      MyPagerTable=replace(MyPagerTable,"$UrlDown$",fname&"_"&p+1&".shtml")
      Elseif p = 1 and p = PageNumber Then 
      MyPagerTable="<div align=center><a href=""$UrlUp$""><img src=""/images/page_up.gif"" width=""69"" height=""21"" border=""0"" /></a></div>" 
      MyPagerTable=replace(MyPagerTable,"$UrlUp$",fname&".shtml")
      Elseif p = PageNumber Then 
      MyPagerTable="<div align=center><a href=""$UrlUp$""><img src=""/images/page_up.gif"" width=""69"" height=""21"" border=""0"" /></a></div>" 
      MyPagerTable=replace(MyPagerTable,"$UrlUp$",fname&"_"&p-1&".shtml")
      else
      MyPagerTable="<div align=center><a href=""$UrlUp$""><img src=""/images/page_up.gif"" width=""69"" height=""21"" border=""0"" /></a> <a href=""$UrlDown$""><img src=""/images/page_down.gif"" width=""69"" height=""21"" border=""0"" /></a></div>" 
      MyPagerTable=replace(MyPagerTable,"$UrlUp$",fname&"_"&p-1&".shtml")
      MyPagerTable=replace(MyPagerTable,"$UrlDown$",fname&"_"&p+1&".shtml")   
      End If
      '生成圖片翻頁鏈接 結(jié)束 
      mb_code=replace(mb_code,"$$MyPager$$",MyPagerTable)
      '轉(zhuǎn)換分頁代碼
      else
      mb_code=replace(mb_code,"$$MyPager$$","")
      '只有一頁時(shí),分頁代碼為空
      end if

      '開始生成sHTML頁面
      On Error Resume Next 
      '容錯(cuò)處理
      if Action=0 then 
      Set fs = Server.CreateObject("Scripting.FileSystemObject")
         if p=0 then
         File = Server.MapPath(filepath&".shtml")
         else
         File = Server.MapPath(filepath&"_"&p&".shtml")
         end if
      On Error Resume Next 
      ' 若有錯(cuò)誤依然向下執(zhí)行
      fs.DeleteFile File, True
      end if
      fso.CreateFolder(Server.MapPath(folder))
      if p=0 then
      Set fout = fso.CreateTextFile(Server.MapPath(filepath&".shtml"))
      else
      Set fout = fso.CreateTextFile(Server.MapPath(filepath&"_"&p&".shtml"))
      end if
      fout.WriteLine mb_code
      fout.close
      next

      Response.Write("完成任務(wù)。")
      %>

      關(guān)于模板文件index.shtml的內(nèi)容按HTML設(shè)計(jì)好即可,注意要轉(zhuǎn)換的內(nèi)容中使用轉(zhuǎn)換標(biāo)識符。
      shtml文件可使用include file包含另一文件,但不能運(yùn)行ASP等動態(tài)內(nèi)容

        本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多