This program lets you track hits to your web pages. You can track multiple pages.

Documentation:
webhits.zip

The webhits.bas program logs web hits to the webhits.txt file in the webhits project.
This is the program that is called from your web pages.
It logs;
1. Date
2. Time
3. ip
4. The page hit ID you define in your web page
5. Platform
6. User infor for browser and OS

You can use your favoriate text editor to edit the file


The webhitsLog.bas program reads the webhist.txt file and reports the data.
You can:
1. Sort the data to farious formats
2. Drill down with wild card searches on any data item
3. Display Graphs on drilled down data

This program has security. You can change the user/pass by changing lines 5 and 6:
keyUser$ = "admin"keyPass$ = "admin"
As you can see the default is admin/admin

This is the html you place in your web pages. You can track multiple pages by changing the ??? to any name you like. That name is tracked in the log.
<iframe
 src="http://www.yourip.com:8008/seaside/go/runbasicpersonal?app=webhits&???" frameborder="no" height="1" width="1">
</iframe>
 

This is the webhits.bas program called by your web pages. It resides in the webhits project
' ---------------------------------
' log user hits
' ---------------------------------
yourDir$        = "../webhits_project/"        ' need your directory
projectDir$     = "webhits_project"        ' need your project directory
webhitsFile$    = DefaultDir$ + "\projects\" + projectDir$ + "\webhits.txt"
 
open webhitsFile$ for append as #f
print #f, date$("yyyy-mm-dd");" || ";time$();" || ";UserAddress$;"    || ";word$(UrlKeys$,2,"&");" || ";Platform$;" || ";UserInfo$
close #f
' thats all folks
end

This is the webhitslog.bas program. You can call it whatever you like. Currently it is in the webhistlog project.
' ***********************************************************
' webhits log
' ***********************************************************
call SetCSS
keyUser$ = "admin"
keyPass$ = "admin"
canMaint$ = "Y"
dbWhere$ = ""
groupBy$ = ""
dbJoin$  = ""
q$   = "','"
global #sql
line0bg$    = "#FAF0E6"
line1bg$    = "#FFE4C4"
fields$     = "logDate,logTime,logIp,logPage,logPlatform,logInfo,logOs,logBrowser"
tblFields$  = "log.logDate,log.logTime,log.logIp,log.logPage,log.logPlatform,log.logInfo,log.logOs,log.logBrowser"
bf$      = "<SPAN STYLE='font-family:Arial; font-weight:700; font-size:10pt'>"
fc$    = "<FONT COLOR=green>"
 
' --------------------------------------
' create in memory database
' --------------------------------------
sqliteconnect #sql, ":memory:"
sql$    = "CREATE TABLE log (
  logDate   date,
  logTime   varchar(10),
  logIp         text,
  logPage       varchar(10),
  logPlatform   text,
  logInfo       text,
  logOs         text,
  logBrowser    text
);
    CREATE INDEX IDXlogDate ON log(logDate,logTime);
    CREATE INDEX IDXlogPage ON tree(logIp)"
    #sql execute(sql$)
 
projectDir$     = "webhits_project"         ' need your project directory
webhitsFile$    = DefaultDir$ + "\projects\" + projectDir$ + "\webhits.txt"
 
open webhitsFile$ for input as #f
while not(eof(#f))
    line input #f, a$
    logDate$        = trim$(word$(a$,1,"||"))
    logTime$        = trim$(word$(a$,2,"||"))
    logIp$          = word$(a$,3,"||")
    logPage$        = trim$(word$(a$,4,"||"))
    logPlatform$    = trim$(word$(a$,5,"||"))
    logInfo$        = trim$(word$(a$,6,"||"))
'print a$
if trim$(a$) = "" then goto [skipIt]
 
i = 1
x$ = ""
p$ = ""
logIp$  = strip$(logIp$)
logIp$  = trim$(logIp$)
while (word$(logIp$,i,".")) <> ""
 x$ = x$ + p$ + right$("000";word$(logIp$,i,"."),3)
i = i + 1
p$ = " "
wend
logIp$ = x$
 
aa$ = upper$(a$)
 
if instr(aa$,"MSIE") then
logOs$      = "Windows"
logBrowser$ = "MSIE"
end if
 
if instr(aa$,"LINUX") then
logOs$      = "Linux"
end if
 
if instr(aa$,"FIREFOX") then
logBrowser$ = "Firefox"
end if
 
if instr(aa$,"SAFARI") then
logBrowser$ = "Safari"
end if
 
if instr(aa$,"MACINTOSH") then
logOs$  = "Mac"
end if
 
sql$    = "INSERT INTO log (logDate,logTime,logPlatform,logInfo,logIp,logPage,logOs,logBrowser)
VALUES ('";logDate$;"','";logTime$;"','";logPlatform$;"','";logInfo$;"','";logIp$;"','";logPage$;"','";logOs$;"','";logBrowser$;"')"
'print logDate$
'print logTime$
'print sql$
'input xx
 
#sql execute(sql$)
[skipIt]
wend
close #f
 
' -------------------------------------------------------------
' Possible Sorts Array
' -------------------------------------------------------------
numSorts = 8
dim  sortDescr$(numSorts)
dim  sortSel$(numSorts)
sortDescr$(1)    = "Date"      : sortSel$(1) = "log.logDate,log.logTime"
sortDescr$(2)    = "Time"      : sortSel$(2) = "log.logTime,log.logDate"
sortDescr$(3)    = "Ip"        : sortSel$(3) = "log.logIp,log.logDate,log.logTime"
sortDescr$(4)    = "Page"      : sortSel$(4) = "log.logPage"
sortDescr$(5)    = "Platform"  : sortSel$(5) = "log.logPlatform,log.logDate,log.logTime"
sortDescr$(6)    = "Info"      : sortSel$(6) = "log.logInfo"
sortDescr$(7)    = "OS"        : sortSel$(7) = "log.logOs,log.logDate,log.logTime"
sortDescr$(8)    = "Browser"   : sortSel$(8) = "log.logBrowser,log.logDate,log.logTime"
 
' -------------------------------------------------------------
' Possible Search Array
' -------------------------------------------------------------
numSrch  = 8
dim  srchDescr$(numSrch)
dim  srchSel$(numSrch)
srchDescr$(1)    = "Date"     : srchSel$(1) = "log.logDate"
srchDescr$(2)    = "Time"     : srchSel$(2) = "log.logTime"
srchDescr$(3)    = "Ip"       : srchSel$(3) = "log.logIp"
srchDescr$(4)    = "Page"     : srchSel$(4) = "log.logPage"
srchDescr$(5)    = "Platform" : srchSel$(5) = "log.logPlatform"
srchDescr$(6)    = "Info"     : srchSel$(6) = "log.logInfo"
srchDescr$(7)    = "OS"       : srchSel$(7) = "log.logOs"
srchDescr$(8)    = "Browser"  : srchSel$(8) = "log.logBrowser"
 
' =================================================
' log List
' =================================================
[logList]
' ------------------------------------------------
' how many records
' ------------------------------------------------
 cls
[logList1]
if numRecords    = 0 then
 sql$    = "SELECT count(*) as numRecords FROM log" + dbJoin$ + dbWhere$
 #sql execute(sql$)
 result$ = #sql nextrow$(" |")
 numRecords  = val(word$(result$,1,"|"))
end if
 
gosub [logHeading]          ' display headin and message area
 
' -------------------------------------------------------------
' Record Heading
' -------------------------------------------------------------
html bf$;"<CENTER><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=2 bgcolor=brown width=100%>"
html "<TR bgcolor=#FFCC99 align=center>"
html "<TD width=3% align=center>Maint</TD>"
html "<TD>Date</TD>"
html "<TD>Time</TD>"
html "<TD>Ip</TD>"
html "<TD>Page</TD>"
html "<TD>Platform</TD>"
html "<TD>OS</TD>"
html "<TD>Browser</TD>"
html "<TD>Info</TD>"
html "</TR>"
 
preDate$        = ""
preTime$        = ""
preIp$          = ""
prePage$        = ""
prePlatform$    = ""
preInfo$        = ""
preOs$          = ""
preBrowser$     = ""
 
sql$ = "SELECT ";tblFields$;",log.rowid FROM log" + dbJoin$ +  dbWhere$ + orderBy$ + groupBy$ + limit$
dispLine = 0
#sql execute(sql$)
WHILE    #sql hasanswer()
 result$ = #sql nextrow$(" |")
 
 gosub [logGetData]
 
 dispLine = dispLine + 1
 if dispLine AND 1 then
      html "<TR align=center BGCOLOR=";line0bg$;">"
     else
      html "<TR align=center BGCOLOR=";line1bg$;">"
 end if
 html "<TD align=center>"
 if canMaint$ = "Y" then
      link   #chg, "Chg", [chglog]
         #chg setkey(rowid$)
         #chg cssclass("lBtn")
 
      link   #del, "Del", [dellog]
         #del setkey(rowid$)
         #del cssclass("lBtn")
     end if
      link   #vue, "View", [logVue]
         #vue setkey(rowid$)
         #vue cssclass("lBtn")
     html "</TD>"
if logDate$ <> preDate$ then
    html "<TD>";fc$;logDate$;"</TD>"
   else
    html "<TD>";logDate$;"</TD>"
end if
if left$(preTime$,2) <> left$(logTime$,2) then
    html "<TD>";fc$;logTime$;"</TD>"
   else
    html "<TD>";logTime$;"</TD>"
end if
if preIp$  <> logIp$  then
    html "<TD>";fc$;logIp$;"</TD>"
   else
    html "<TD>";logIp$;"</TD>"
end if
if prePage$ <> logPage$ then
    html "<TD>";fc$;logPage$;"</TD>"
   else
    html "<TD>";logPage$;"</TD>"
end if
if prePlatform$ <> logPlatform$ then
    html "<TD>";fc$;logPlatform$;"</TD>"
   else
    html "<TD>";logPlatform$;"</TD>"
end if
if preOs$ <> logOs$ then
    html "<TD>";fc$;logOs$;"</TD>"
   else
    html "<TD>";logOs$;"</TD>"
end if
if preBrowser$ <> logBrowser$ then
    html "<TD>";fc$;logBrowser$;"</TD>"
   else
    html "<TD>";logBrowser$;"</TD>"
end if
if preInfo$ <> logInfo$ then
    html "<TD align=left>";fc$;left$(logInfo$,35);"</TD>"
   else
    html "<TD align=left>";left$(logInfo$,35);"</TD>"
end if
 html "</TR>"
preDate$        = logDate$
preTime$        = logTime$
preIp$          = logIp$
prePage$        = logPage$
prePlatform$    = logPlatform$
preInfo$        = logInfo$
preOs$          = logOs$
preBrowser$     = logBrowser$
WEND
html "</TABLE>"
wait
 
' -----------------------------------
' Get data from database SQL command
' -----------------------------------
[logGetData]
logDate$        = trim$(word$(result$,1,"|"))
logTime$        = trim$(word$(result$,2,"|"))
logIp$          = trim$(word$(result$,3,"|"))
logPage$        = trim$(word$(result$,4,"|"))
logPlatform$    = trim$(word$(result$,5,"|"))
logInfo$        = trim$(word$(result$,6,"|"))
logOs$          = trim$(word$(result$,7,"|"))
logBrowser$     = trim$(word$(result$,8,"|"))
rowid$          = trim$(word$(result$,9,"|"))
RETURN
 
' ------------------------------------
' log Maintenance
' ------------------------------------
 
[logVue]
acd$ = "Vue"
goto [logMnt]
 
[chglog]
acd$ = "Chg"
goto [logMnt]
 
[dellog]
acd$ = "Delete"
goto [logMnt]
 
[addlog]
acd$ = "Add"
 
[logMnt]
thislogrowid$   = EventKey$
 
cls
gosub [HeadingMsg]
 
sql$ = "SELECT ";fields$;"
 FROM log WHERE rowid = '";thislogrowid$;"'"
#sql execute(sql$)
result$  = #sql nextrow$(" |")
gosub [logGetData]
if acd$ = "Add" then
 ' blank fields
 result$ = " | | | | | | | | |"
 gosub [logGetData]
 ' set default values
end if
 
if acd$ = "Vue" then goto [ViewIt]
 
html "<center><TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 bgcolor=wheat>
<TR align=center BGCOLOR=#FFCC99><TD colspan=4>log Maintenance</TD><TD></TR>"
html "<TR>"
html "<TD bgcolor=#FFCC99 align=right>LogDate</TD><TD>"
 textbox #logDate,logDate$,10
html "</TD>"
html "<TD bgcolor=#FFCC99 align=right>LogTime</TD><TD>"
 textbox #logTime,logTime$,10
html "</TD>"
html "</TR>"
html "<TR>"
html "<TD bgcolor=#FFCC99 align=right>LogIp</TD><TD>"
 textarea #logIp,logIp$,30,3
html "</TD>"
html "<TD bgcolor=#FFCC99 align=right>LogPage</TD><TD>"
 textbox #logPage,logPage$,10
html "</TD>"
html "</TR>"
html "<TR>"
html "<TD bgcolor=#FFCC99 align=right>LogPlatform</TD><TD>"
 textarea #logPlatform,logPlatform$,30,3
html "</TD>"
html "<TD bgcolor=#FFCC99 align=right>LogInfo</TD><TD>"
 textarea #logInfo,logInfo$,30,3
html "</TD>"
html "</TR>"
html "<TR>"
html "<TD bgcolor=#FFCC99 align=right>LogOs</TD><TD>"
 textarea #logOs,logOs$,30,3
html "</TD>"
html "<TD bgcolor=#FFCC99 align=right>LogBrowser</TD><TD>"
 textarea #logBrowser,logBrowser$,30,3
html "</TD>"
html "</TR>"
html "<TR bgcolor=#FFCC99><TD colspan=4 ALIGN=CENTER>"
if acd$ <> "" then
 button    #acd, acd$, [dologAcd]
     #acd setkey(thislogrowid$)
     #acd cssclass("lBtn")
end if
html "        "
 button    #a, "Exit", [logList]
     #a cssclass("lBtn")
 
html "</TD></TR></TABLE>"
wait
 
' ---------------------------------------------
' View Detail
' ---------------------------------------------
[ViewIt]
html bf$;"<center><TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 bgcolor=wheat>
<TR align=center BGCOLOR=#FFCC99><TD colspan=4>Web Hut Detail</TD><TD></TR>"
html "<TR><TD bgcolor=#FFCC99 align=right>Log Date</TD><TD>"
html logDate$
html "</TD><TD bgcolor=#FFCC99 align=right>Log Time</TD><TD>"
html logTime$
html "</TD></TR><TR><TD bgcolor=#FFCC99 align=right>Log Ip</TD><TD>"
html logIp$
html "</TD><TD bgcolor=#FFCC99 align=right>Log Page</TD><TD>"
html logPage$
html "</TD></TR><TR><TD bgcolor=#FFCC99 align=right>Log Platform</TD><TD>"
html logPlatform$
html "</TD><TD bgcolor=#FFCC99 align=right>Log Info</TD><TD>"
html logInfo$
html "</TD></TR><TR><TD bgcolor=#FFCC99 align=right>Log OS</TD><TD>"
html logOs$
html "</TD><TD bgcolor=#FFCC99 align=right>Log Browser</TD><TD>"
html logBrowser$
html "</TD></TR><TR bgcolor=#FFCC99><TD colspan=4 ALIGN=CENTER>"
 button    #a, "Exit", [logList]
     #a cssclass("lBtn")
 
html "</TD></TR></TABLE>"
wait
 
' =====================================
' Do requested Add Change Delete
' =====================================
[dologAcd]
 
if acd$  = "Delete" then
 sql$ = "DELETE FROM log WHERE rowid = '";thislogrowid$;"'"
 goto [execACD]
 wait
end if
 
dbFields$ = "logDate,logTime,logIp,logPage,logPlatform,logInfo,logOs,logBrowser"
 
' ---------------------------------------------
' Get data from the screen
' ---------------------------------------------
logDate$     = trim$(#logDate     contents$())
logTime$     = trim$(#logTime      contents$())
logIp$          = trim$(#logIp       contents$())
logPage$     = trim$(#logPage       contents$())
logPlatform$     = trim$(#logPlatform       contents$())
logInfo$     = trim$(#logInfo       contents$())
logOs$         = trim$(#logOs       contents$())
logBrowser$     = trim$(#logBrowser       contents$())
if errNum > 0 then
  gosub [doMsg]
  wait
end if
q$   = "','"
dbVals$  = "'";dblQuote$(logDate$);q$;dblQuote$(logTime$);q$;dblQuote$(logIp$);q$;dblQuote$(logPage$);q$;dblQuote$(logPlatform$);q$;dblQuote$(logInfo$);q$;dblQuote$(logOs$);q$;dblQuote$(logBrowser$);"'"
 
if acd$  = "Chg" then
  GOSUB [sqlSet]
  sql$   = "UPDATE log SET ";sql$;" WHERE rowid = '";thislogrowid$;"'"
END IF
if acd$ = "Add" then sql$ = "INSERT into log ("; dbFields$; ") VALUES ("; dbVals$ ; ")"
 
[execACD]
 #sql execute(sql$)
 
goto [logList]
wait
' ----------------------------
' They want Lines per page
' ----------------------------
[doLpp]
if lpp    = 0 then lpp = 20
lpp    = min(10,lpp)
goto [logList]
 
' ----------------------------
' They want next page
' ----------------------------
[doNext]
lastPageNum    = val(EventKey$)
pageNum        = val(#pageNum contents$())
if lastPageNum    = pageNum then pageNum = pageNum + 1
goto [logList]
 
' ----------------------------
' They want prev page
' ----------------------------
[doPrev]
lastPageNum    = val(EventKey$)
pageNum        = val(#pageNum contents$())
if lastPageNum    = pageNum then pageNum = pageNum - 1
if pageNum < 1 then pageNum  = 1
goto [logList]
 
' ---------------------------------------------
' User Search screen
' ---------------------------------------------
[logdoSearch]
 cls
wa$  = ""
html bf$;"<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 BGCOLOR=#FFCC99 WIDTH=100%>
<TR><TD ALIGN=CENTER>Search for log"
html "</TD></TR></TABLE>"
html "<table border=1 CELLPADDING=0 CELLSPACING=0 bgcolor=#FFCC99 width=100%><TR>"
for i = 1 to numSrch
 html "<TD align=right>";srchDescr$(i);"</TD><TD>"
 sVar$ = "#srch(";i;")"
 textbox #sVar$,""
 html "</TD>"
 if i mod 4 = 0 then html "</TR><TR>"
next i
html "</TR></TABLE>"
html "<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 WIDTH=100% BGCOLOR=#FFCC99><TR><TD ALIGN=CENTER>"
button #find, "Search", [doFind]
 #find cssclass("lBtn")
 
html "</TD><TD align=center>"
button #exit, "Exit", [logList]
 #exit cssclass("lBtn")
html "</TD></TR></TABLE>"
 
html "<CENTER><TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0>
 <TR><TD ALIGN=CENTER COLSPAN=2 BGCOLOR=#FFCC99 ALIGN=CENTER>Use wild card (*)</TD></TR>
 <TR><TD>*before</TD><TD>Search for ends with</TD></TR>
 <TR><TD>after*</TD><TD>Search for begins with</TD></TR>
 <TR><TD>*both*</TD><TD>Contains the value somewhere</TD></TR>
 <TR><TD>None</TD><TD>Must match</TD></TR>
 </TABLE>"
 
wait
 
[doFind]
dbWhere$ = ""
for i = 1 to numSrch
    oVar$    = "#srch(";i;")"
    srch$    = trim$(#oVar$ contents$())
if srch$ <> "" then
 wld$ = goWild$(srchSel$(i),srch$)
 dbWhere$ = dbWhere$ + wld$
end if
next i
if dbWhere$ <> "" then dbWhere$ = " WHERE " + dbWhere$
numRecords   = 0
goto [logList]
 
 FUNCTION goWild$(fld$,str$)
 global wa$
 goWild$ = trim$(str$)
 l   = len(goWild$)
 if l > 0 then
  if INSTR(goWild$,"*") <> 0 then wld$ = "Y"
  if INSTR(goWild$,"%") <> 0 then wld$ = "Y"
  if wld$ <> "Y" then goWild$ = goWild$ + "%"
  if right$(goWild$,1)   = "*" then goWild$ = left$(goWild$,l - 1) + "%"
  if left$(goWild$,1)    = "*" then goWild$ = "%" + mid$(goWild$,2)
  goWild$    = wa$;fld$;" LIKE ";"'";goWild$;"'"
  wa$    = " AND "
  else
  goWild$    = ""
 end if
 END FUNCTION
 
' ----------------------------
' They wanna sort
' ----------------------------
[logdoSort]
cls
html bf$;"<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0>"
html "<TR bgcolor=#FFCC99><TD align=center>Select Sort Method</TD></TR><TD align=center>"
 
 listbox #dds, sortDescr$(), numSorts
html "</TD></TR><TR bgcolor=#FFCC99><TD align=center>"
button #ssrt, "Select",[logdoSortSel]
       #ssrt setkey(sortNum)
       #ssrt cssclass("lBtn")
html "</TD></TR>"
html "</TABLE>"
WAIT
[logdoSortSel]
sortNum    = val(EventKey$)
ss$    =   #dds selection$()
if ss$ <> "" then
 for i    = 1 to numSorts
     if sortDescr$(i)    = ss$ then orderBy$ = " ORDER BY ";sortSel$(i)
 next i
end if
 
goto [logList]
 
WAIT
 
' ============================================
' List Heading
' ============================================
[logHeading]
' ---------------------------------------
' Did they change the lines per page lpp
' ---------------------------------------
x = #lpp ISNULL()
if x = 0 then lpp = val(#lpp contents$())
 
pageNum  = max(1,pageNum)    ' make user it has a page number
if lpp   < 1 then lpp = 20   ' lines per page must be specified
lpp      = max(5,lpp)        ' make sure it has a least 5 lines per page
lpp      = min(100,lpp)      ' don not allow over 100 lines per page
 
totPages = int(numRecords / lpp)
if lpp * totPages <> numRecords then totPages = totPages + 1
pageNum  = min(totPages,pageNum)
pageNum  = max(1,pageNum)
limitBeg = (pageNum * lpp) - lpp  'limit begin value
 
dispLine = 0
 
limit$   = " LIMIT " ; limitBeg ; "," ; lpp
 
html bf$;"<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 WIDTH=100% BGCOLOR=#FFCC99>"
html "<TR>"
 
if canMaint$ = "Y" then
html "<TD ALIGN=center>"
button #add, "Add",[addlog]
 #add setkey(0)
 #add cssclass("lBtn")
html "</TD>"
end if
 
html "<TD ALIGN=center>"
button #sort, "Sort",[logdoSort]
       #sort setkey(sortNum)
       #sort cssclass("lBtn")
html "</TD><TD ALIGN=center>"
button #help, "Help",[logdoHelp]
       #help cssclass("lBtn")
html "</TD><TD ALIGN=center>"
button #srch, "Search",[logdoSearch]
       #srch setkey(srchData$)
       #srch cssclass("lBtn")
html "</TD><TD ALIGN=center>"
button #srch, "Stats",[stats]
       #srch cssclass("lBtn")
html "</TD><TD ALIGN=center>"
button #exit, "Exit",[doExit]
       #exit cssclass("lBtn")
html "</TD><TD>Records:";numRecords
html "</TD><TD>Pages:";totPages
html "</TD><TD ALIGN=right>"
button #prev, "Prev",[doPrev]
       #prev setkey(pageNum)
       #prev cssclass("lBtn")
html "</TD><TD width=2%>"
 TEXTBOX #pageNum, pageNum
         #pageNum setid("len2")
html "</TD><TD>"
button #next, "Next",[doNext]
       #next setkey(pageNum)
       #next cssclass("lBtn")
html "<TD ALIGN=right><A title='Lines Per Page'>"
button #lpp, "Lpp",[doLpp]
       #lpp cssclass("lBtn")
html "</A></TD><TD>:"
 TEXTBOX #lpp, lpp
         #lpp setid("len2")
html "</TD></TR></TABLE>"
[HeadingMsg]
html "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 >"
html "<TR><TD BGCOLOR=red id=errMsg></TD></TR>"
html "<TR><TD BGCOLOR=yellow id=wrnMsg></TD></TR>"
html "<TR><TD BGCOLOR=lime id=infoMsg></TD></TR>"
html "</TABLE>"
gosub [doMsg]
RETURN
 
' ------------------------------------------------
' Stats
' ------------------------------------------------
[stats]
cls
gosub [logHeading]
html "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 width=100%><TR align=center><TD VALIGN=TOP>"
statHdr$    = "Day"
statBy$        = "strftime('%d',logDate)"
gosub [doStats]
 
statHdr$    = "Hour"
statBy$        = "substr(logTime,1,2)"
gosub [doStats]
 
statHdr$    = "Page"
statBy$        = "substr(logPage,1,3)"
gosub [doStats]
 
statHdr$    = "IP"
statBy$        = "substr(logIp,1,3)"
gosub [doStats]
 
statHdr$    = "Brows"
statBy$        = "logBrowser"
gosub [doStats]
 
statHdr$    = "OS"
statBy$        = "logOs"
gosub [doStats]
wait
 
[doStats]
sql$ = "
SELECT  count(*) as cnt
FROM    log ";dbWhere$;" GROUP BY ";statBy$;"
ORDER BY cnt desc LIMIT 1"
#sql execute(sql$)
result$    = #sql nextrow$(" |")
lgstCnt = val(word$(result$,1,"|"))
 
html bf$;"<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0>"
html "<TR BGCOLOR=#CCCCE5 ALIGN=CENTER>"
html "<TD>";statHdr$;"</TD>"
html "<TD>";"Count</TD>"
html "<TD>";"Graph</TD>"
html "</TR>"
 
'-- get counts by day
sql$ = "
SELECT  count(*) as cnt,";statBy$;"
FROM    log ";dbWhere$;" GROUP BY ";statBy$;"
ORDER BY cnt desc"
#sql execute(sql$)
 
WHILE    #sql hasanswer()
    result$ = #sql nextrow$(" |")
    cnt     = val(word$(result$,1,"|"))
    stat$   = trim$(word$(result$,2,"|"))
 
pcnt = (cnt / lgstCnt) * 100
html "<TR><TD align=center>";stat$;"</TD>"
html "<TD align=center>";cnt;"</TD>"
html "<TD><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=1 Width=";pcnt;" height=17 BGCOLOR=#3399FF>"
html "<TR><TD></TD></TR></TABLE></TD>"
html "</TR>"
WEND
html "</TABLE></TD><TD VALIGN=TOP>"
RETURN
 
html "</TD></TR></TABLE>"
 
wait
 
' -------------------------------
' Messages and error handling
' -------------------------------
[doMsg]
 html "<script> document.getElementById('infoMsg').innerHTML = '"
 br$ = ""
 for i = 1 to infoNum
     html br$;infoMsg$(i)
     br$ = "<BR>"
 next i
 html "';</script>"
 
 html "<script> document.getElementById('wrnMsg').innerHTML = '"
 br$ = ""
 for i = 1 to wrnNum
     html br$;wrnMsg$(i)
     br$ = "<BR>"
 next i
 html "';</script>"
 
 html "<script> document.getElementById('errMsg').innerHTML = '"
 br$ = ""
 for i = 1 to errNum
     html br$;errMsg$(i)
     br$ = "<BR>"
 next i
 html "';</script>"
 
infoNum  = 0
wrnNum   = 0
errNum   = 0
on error goto [handler]
RETURN
 
[handler]
errNum = errNum + 1
errMsg$(errNum) = "Err number:";Err;" Description:";Err$
gosub [doMsg]
on error goto [handler]
WAIT
[handler1]
on error goto [handler]
wait
 
' -----------------------------------------
' Get outta here
' -----------------------------------------
[doExit]
cls
print "Close Window (Y/N)";
input x$
if x$ = "Y" then
html "<script language='javascript' type='text/javascript'>
var a    = history.length;
a     = a - 1;
window.open('','_parent','');
window.close();
history.go(-a);
</script>"
end if
 
wait
 
' -------------------------------------
' help - please help me I can't get up
' -------------------------------------
[logdoHelp]
cls
numHelp  = 11    ' set number of help items
dim  helpItem$(numHelp)
if helpItem$(1) = "" then
helpItem$(1) = "[Add]|Use the [Add] or the [A]dd in the list to add a record"
helpItem$(2) = "[Sort]|You can sort in different sequences by selecting the field from the drop down list"
helpItem$(3) = "[Search]|This helps you find information. You can use any or all of them at once."
helpItem$(4) = "[Exit]|Leave the system"
helpItem$(5) = "[Prev]|Go to the previous page"
helpItem$(6) = "Page Num|Enter a page number to go directly to that page. Then use [Next]"
helpItem$(7) = "[Next]|Go to the next page"
helpItem$(8) = "LPP|Set Lines Per Page. The default is 20"
helpItem$(9) = "[View]|View record detail"
helpItem$(10)    = "[C]|Change a record"
helpItem$(11)    = "[D]|Delete a record"
end if
html "<center>
<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0>
<TR BGCOLOR=#FFCC99 ALIGN=CENTER>
<TD><B>Item</TD><TD><B>Description</TD></TR>"
for i = 1 to numHelp
 hitm$   = word$(helpItem$(i),1,"|")
 hdsc$   = word$(helpItem$(i),2,"|")
 html "<TR><TD BGCOLOR=#FFCC99 ALIGN=CENTER>";hitm$;"</TD><TD>";hdsc$;"</TD></TR>"
next i
html "<TR><TD BGCOLOR=#FFCC99 ALIGN=CENTER colspan=2>"
 button    #ex, "Return to List", [logList]
     #ex cssclass("lBtn")
html "</TD></TR></TABLE>"
 
wait
 
' -------------------------------------------------------
' Convert sql field and values notation to set notation
' -------------------------------------------------------
[sqlSet]
ix   = 1
sql$ = ""
qq$  = ""
cma$ = ""
while (word$(fields$,ix,",") <> "")
  sql$   = sql$ + cma$ + word$(fields$,ix,",") + " = " + qq$ + word$(dbVals$,ix,",'")
  cma$   = ", "
  qq$    = "'"
  ix = ix + 1
WEND
RETURN
 
' -----------------------------------------
' Convert single quotes to double quotes
' -----------------------------------------
FUNCTION dblQuote$(str$)
i    = 1
qq$  = ""
while (word$(str$,i,"'")) <> ""
 dblQuote$   = dblQuote$;qq$;word$(str$,i,"'")
 qq$ = "''"
 i   = i + 1
WEND
END FUNCTION
 
' ------------------------
' Numeric Check
' ------------------------
FUNCTION isNumeric(f$)
if str$(val(f$)) = f$ then
  isNumeric = 1
 else
  isNumeric = 0
end if
END FUNCTION
 
' -----------------------------------------
' strip junk
' -----------------------------------------
FUNCTION strip$(str$)
    strip$ = ""
    for i = 1 to len(str$)
        a$ = MID$(str$,i,1)
        a = ASC(a$)
        if a > 31 then
                   if a <  123 then
             if a$ <> "'" then
                       if a$ <> """" then
            strip$ = strip$ + a$
               end if
             end if
           end if
        end if
    next i
END FUNCTION
 
' -------------------------------------
' set CSS
' --------------------------------------
SUB SetCSS
 
CSSClass "a.lBtn", "{
Text-Align:Center;
Border-Width:1px;
Border-Style:solid;
background:#FDDD8C;
Border-Color:black;
Font-Size:10pt;
Font-Weight:Bold;
Font-Family:  Arial;
Text-Decoration:  None;
}"
cssid   #len2,"{ width: 20px }"
 
END SUB