strReferer = Request.servervariables("HTTP_REFERER")
statCurrYear = year(now())
statCurrMonth = month(now())
statCurrDay = day(now())
statCurrHour = hour(now())
'Do statistics
strSQL = "SELECT * from tblStats WHERE statYear = " & statCurrYear & " AND statMonth = " & statCurrMonth & " AND statDay = " & statCurrDay & " AND statHour = " & statCurrHour
rsCommon.open strSQL, adoCon
'Create if none exist
If rsCommon.eof or rsCommon.bof then
rsCommon.close
strSQL = "INSERT INTO tblStats (statYear,statMonth,StatDay,StatHour,sessions,pageViews) VALUES (" & statCurrYear & "," & statCurrMonth & "," & statCurrDay & "," & statCurrHour & ",0,0)"
rsCommon.open strSQL, adoCon
else
rsCommon.close
end if
'CURRENT HOUR SESSIONS/PAGE VIEWS
strSQL = "UPDATE tblStats SET pageViews = pageViews+1 WHERE statYear = " & statCurrYear & " AND statMonth = " & statCurrMonth & " AND statDay = " & statCurrDay & " AND statHour = " & statCurrHour
rsCommon.open strSQL, adoCon
If isEmpty(Session("blnCounterSet")) = True Then
strSQL = "UPDATE tblStats SET sessions=sessions+1 WHERE statYear = " & statCurrYear & " AND statMonth = " & statCurrMonth & " AND statDay = " & statCurrDay & " AND statHour = " & statCurrHour
rsCommon.open strSQL, adoCon
end if
'TOTAL SESSIONS COUNT
If isEmpty(Session("blnCounterSet")) = True Then
strSQL = "UPDATE tblConfiguration SET sessions = sessions + 1"
rscommon.open strSQL, adoCon
'TOTAL PAGE VIEWS COUNT
strSQL = "UPDATE tblConfiguration SET pageviews = pageviews + 1"
rscommon.open strSQL, adoCon
Session("blnCounterSet") = True
'If user is logged in award them a drumpoint
If lngLoggedInUserID
2 then
strSQL = "UPDATE tblAuthor set drum_points = drum_points + 1 WHERE author_ID = " & lngLoggedInUserID
rsCommon.open strSQL, adocon
end if
else
'TOTAL PAGE VIEWS COUNT
strSQL = "UPDATE tblConfiguration SET pageviews = pageviews + 1"
rscommon.open strSQL, adoCon
End if
If instr(strReferer,"drum-world.com") = 0 and strReferer
"" and isnull(strReferer) = False then
strSQL = "SELECT * From tblRefer WHERE URL = '" & strReferer & "'"
rscommon.open strSQL, adoCon
If rscommon.eof or rscommon.bof then
rscommon.close
strSQL = "INSERT into tblRefer (URL,visits) VALUES ('" & strReferer & "',1)"
rsCommon.open strSQL, adoCon
else
rscommon.close
strSQL = "UPDATE tblRefer SET visits = visits + 1 WHERE URL = '" & strReferer & "'"
rsCommon.open strSQL,adocon
end if
end if