<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <% Option Explicit %> Hit Counter <% Dim bgc,fgc,font,size If Trim(Request.QueryString("bgc")) <> "" Then bgc = Trim(Request.QueryString("bgc")) Else bgc = "white" End If If Trim(Request.QueryString("fgc")) <> "" Then fgc = Trim(Request.QueryString("fgc")) Else fgc = "black" End If If Trim(Request.QueryString("font")) <> "" Then font = Trim(Request.QueryString("font")) Else font = "verdana" End If If Trim(Request.QueryString("size")) <> "" Then size = Trim(Request.QueryString("size")) Else size = "2" End If %> > <% If Trim(Request.QueryString("id")) <> "" Then On Error Resume Next Dim objConn ' Variable to store DATABASE CONNECTION as OBJECT Dim objRs ' Variable to store DATABASE RECORDSET as OBJECT Dim strcurDir ' Variable to store DB Directory Path as string Dim siteID ' Variable to store Site ID as numeric Dim temp_hit ' Temp Variable to store old hits numeric ' Storing the site id from querystring siteID = Trim(Request.QueryString("id")) ' creating database objects Set objConn = Server.CreateObject("ADODB.Connection") Set objRs = Server.CreateObject("ADODB.Recordset") strcurDir = Server.MapPath("counter.mdb") ' RETRIVEING THE DATABASE PATH objConn.Open "DBQ="& strcurDir &";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;" ' taking the current hits of the requested site objRs.Open "SELECT hits.siteid,hits.counter FROM hits WHERE hits.siteid = "& siteID ,objConn,1,3 messge="You have visited one time Please close then open" If NOT objRs.EOF Then '------------------ if that id found in database If session("ip") <> "" then Response.Redirect("counter.asp?message="&messge) Else Response.Write(Session("ip")) temp_hit = Int(objRs("counter")) ' storing the current hit to the temp variable ' updating the hit with the current hit objConn.Execute("UPDATE hits SET counter = "& (temp_hit + 1) &" WHERE siteid = "& siteID) session("ip") = trim(Request.ServerVariables("REMOTE_ADDR")) ' checking whether the requested site needs picture of text counter If Request.QueryString("pict") <> "1" Then Response.Write("") If Trim(Request.QueryString("text")) <> "0" Then Response.Write("Hits : ") Response.Write((temp_hit + 1)) ' printing the current hit Response.Write("") Else Dim temp_num,i,pfgc,psize temp_hit = temp_hit + 1 If UCase(Trim(Request.QueryString("pfgc"))) = "BLACK" Then pfgc = "black" ElseIf UCase(Trim(Request.QueryString("pfgc"))) = "WHITE" Then pfgc = "white" Else pfgc = "white" End If If Trim(Request.QueryString("psize")) = "1" Then psize = "small" ElseIf Trim(Request.QueryString("psize")) = "2" Then psize = "large" Else psize = "small" End If For i=1 To Len(CStr(temp_hit)) temp_num = Mid(CStr(temp_hit),i,1) Response.Write(""& temp_num &"") Next End If End If'----------------session end Else '------------------ if that id not found in database Dim cdo Dim mailBody Set cdo = Server.CreateObject("CDONTS.Newmail") ' CDONTS object to send mail cdo.To = "mail@oranjdot.com" cdo.From = "mail@oranjdot.com" cdo.Cc = "binu_m_r@yahoo.com" cdo.Subject = "Invalid Site ID passed" ' making the mail message with id and called page mailBody = "=========================================================================" & vbCrLf & vbCrLf & vbCrLf mailBody = mailBody & ">>>>>>>>>> Invalid Site ID passed to counter page. <<<<<<<<<<" & vbCrLf & vbCrLf mailBody = mailBody & " Invalid Site ID = " & siteID & vbCrLf & vbCrLf mailBody = mailBody & " Caller Site = " & Request.ServerVariables("HTTP_REFERER") & vbCrLf & vbCrLf mailBody = mailBody & vbCrLf & vbCrLf & vbCrLf & "=========================================================================" cdo.Body = mailBody cdo.Send Set cdo = Nothing ' showing the link to oranjdot coz the given id is invalid 'Response.Write("Oranjdot") End If ' destroying the objects objRs.Close() objConn.Close() Set objRs = Nothing Set objConn = Nothing End If %>