保存该页面为任意名称.asp,这里假设visit.asp;在需要统计点击、阅览的页面里加上<script src="visit.asp"></script> <% Option Explicit Const adCmdText=1 Const adStateClosed=0 Dim CON_STR CON_STR="provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("Visit.mdb") Const SCIRIPT_NAME_MAX_LENGTH=255 Function add (strName) Dim objCon,objAdxCat,objRst Dim lngAffected Dim strSafeName strSafeName=Replace(Left(strName,SCIRIPT_NAME_MAX_LENGTH),"'","''") Set objCon=CreateObject("adodb.connection") 'Open DB, if failed, then try to create new db On Error Resume Next objCon.Open CON_STR If Err.number<>0 Then Err.clear Set objAdxCat=CreateObject("adox.catalog") objAdxCat.create CON_STR Set objCon=objAdxCat.activeConnection Set objAdxCat=Nothing objCon.execute "CREATE TABLE tblVisit(strName TEXT(" & SCIRIPT_NAME_MAX_LENGTH & ") PRIMARY KEY, lngCount INTEGER)" If Err.number<>0 Then On Error goto 0 Set objCon=Nothing Err.raise vbObjectError,"add()","Can't open or create db,maybe db file error." End If End If On Error goto 0 'find script_path in db and add visit count , if the script_path doesn't exist , then create a new record. objCon.Execute "UPDATE tblVisit SET lngCount=lngCount+1 where strName='" & strSafeName &"'",lngAffected,adCmdText If lngAffected=0 Then objCon.Execute "INSERT INTO tblVisit (strName,lngCount) VALUES ('" & strSafeName & "',1)" If objCon.State<>adStateClosed Then objCon.close Set objCon=Nothing add="ok" End function main:Sub main() Dim strRefUrl strRefUrl=Trim(request.servervariables("HTTP_REFERER")) If strRefUrl<>"" And strRefUrl<>session("LastVisitedPage") Then Call add(strRefUrl) session("LastVisitedPage")=strRefUrl End If End Sub %>
csdn的在线编辑器,真JB烂!!!!!!
保存该页面为任意名称.asp,这里假设visit.asp;在需要统计点击、阅览的页面里加上<script src="visit.asp"></script>