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 "
If isEmpty(Session("blnCounterSet")) = True Then
strSQL = strSQL + (", sessions = sessions +1 ")
end if
strSQL = strSQL + (" WHERE statYear = " & statCurrYear & " AND statMonth = " & statCurrMonth & " AND statDay = " & statCurrDay & " AND statHour = " & statCurrHour)
rsCommon.open strSQL, adoCon
'TOTAL SESSIONS COUNT
If isEmpty(Session("blnCounterSet")) = True Then
strSQL = "UPDATE tblConfiguration SET sessions = " & lngSessions + 1
rscommon.open strSQL, adoCon
Session("blnCounterSet") = True
End if
'TOTAL PAGE VIEWS COUNT
strSQL = "UPDATE tblConfiguration SET pageviews = " & lngPageViews + 1
rscommon.open strSQL, adoCon