国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > ASP > 正文

asp最簡(jiǎn)單最實(shí)用的計(jì)數(shù)器

2024-05-04 10:57:50
字體:
供稿:網(wǎng)友
剛才找一個(gè)計(jì)數(shù)器,由于網(wǎng)站的訪問量太少,放個(gè)計(jì)數(shù)器在那里確實(shí)有點(diǎn)寒酸了,于是呼只能搞一個(gè)簡(jiǎn)單點(diǎn)的,可以訪問一次就記錄一次的來?yè)螕伍T面先。本來以前我有一個(gè),但是郁悶的是居然找不到了,在網(wǎng)上SO了一圈,總算是搞定了,具體程序代碼如下。
  count.asp的代碼為: 

復(fù)制代碼 代碼如下:

<% 
    option explicit 
  dim fs,filename,txt,content,total,counter_lenth 
  counter_lenth=1  '設(shè)置顯示數(shù)據(jù)的最小長(zhǎng)度,如果小于實(shí)際長(zhǎng)度則以實(shí)際長(zhǎng)度為準(zhǔn) 
  set fs=Server.CreateObject("Scripting.FileSystemObject") 
  filename=server.MapPath("count.txt") 
  if not fs.FileExists(filename) then 
    fs.CreateTextFile filename,True,True 
    set txt=fs.OpenTextFile(filename,2,true) 
    txt.write 0 '如不存在保存數(shù)據(jù)的文件則創(chuàng)建新文件并寫入數(shù)據(jù)0 
    set fs=nothing 
  end if 

  set txt=fs.OpenTextFile(filename) 
  If txt.AtEndOfStream Then 
    Application("Counter")=0 '如果文件中沒有數(shù)據(jù),則初始化Application("Counter")的值(為了容錯(cuò)) 
  else 
    Application("Counter")=txt.readline 
  end if 

  Application.Lock  
  Application("Counter") = Application("Counter") + 1 
  Application.UnLock 


  Function save_ '保存計(jì)數(shù)函數(shù) 
  set fs=Server.CreateObject("Scripting.FileSystemObject") 
  filename=server.MapPath("count.txt") 
  content=Application("Counter") 
  set txt=fs.OpenTextFile(filename,2,true) 
  txt.write content 
  set fs=nothing 
  End Function 

  save_  '調(diào)用保存函數(shù)保存數(shù)據(jù) 

  Function Digital ( counter )  '顯示數(shù)據(jù)函數(shù) 
    Dim i,MyStr,sCounter 
     sCounter = CStr(counter) 
    For i = 1 To counter_lenth - Len(sCounter) 
      MyStr = MyStr & "0" 
    'MyStr = MyStr & "<IMG SRC=改成你自己的圖片存放的相對(duì)目錄/0.gif>" '如有圖片,可用此語(yǔ)句調(diào)用 
    Next 
    For i = 1 To Len(sCounter) 
      MyStr = MyStr & Mid(sCounter, i, 1) 
    'MyStr = MyStr & "<IMG SRC=改成你自己的圖片存放的相對(duì)目錄/" & Mid(sCounter, i, 1) & ".gif>" '如有圖片,可用此語(yǔ)句調(diào)用 
    Next 
    Digital = MyStr 
  End Function 
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 墨玉县| 天门市| 兴山县| 海林市| 奉贤区| 黄平县| 南川市| 闽侯县| 公安县| 德江县| 恭城| 永修县| 嘉定区| 望城县| 东安县| 福泉市| 灌南县| 繁峙县| 阳东县| 城市| 武穴市| 板桥市| 博兴县| 博湖县| 集贤县| 东安县| 濉溪县| 理塘县| 普定县| 六安市| 绥阳县| 武冈市| 麻阳| 东安县| 师宗县| 新沂市| 建昌县| 松滋市| 京山县| 德兴市| 神农架林区|