<% '******************************************************************* '* Program : Power-Stats | www.power-stats.com '* Version : 1.0 '* Authors : Ricardo Lerch, Rodrigo Alhadeff | authors@power-stats.com '* Date : March-2004 '* Details : Get parameters from JS inserted in HTML pages and save '* a new log record '******************************************************************* %> <% 'on error resume next dim mySQL, connTemp, pSearchEngine, pSearchKeywords ' Id Site to track pidSite = getUserInput(request("id"),10) ' js data pReferrer = getUserInput(request("referrer"),200) pLocationURL = getUserInput(request("LocationURL"),200) pResolutionC = getUserInput(request("ResolutionC"),20) ' color depth pResolutionWxH = getUserInput(request("ResolutionW") & "x" & request("ResolutionH"),20) 'width and height ' if JS data cannot be obtained, get data from ASP Server Variables if pReferrer="" then pReferrer = request.ServerVariables("HTTP_REFERER") if pLocationURL="" then pLocationURL = request.ServerVariables("HTTP_HOST")&request.ServerVariables("URL") ' server data pDay = Day(Date) pMonth = Month(Date) pYear = Year(Date) pLogTime = Time pUserIP = request.ServerVariables("REMOTE_HOST") pLanguage = request.ServerVariables("HTTP_ACCEPT_LANGUAGE") pBrowserOs = request.ServerVariables("HTTP_USER_AGENT") ' variables used for kwd and search engine parsing pSearchEngine ="" pSearchKeywords ="" parseReferrer = pReferrer call referrerParsing(parseReferrer, pSearchEngine, pSearchKeywords) ' parse pLanguage to be only en-us or en or es or en-gb... whatever if len(pLanguage) >= 5 then if mid(pLanguage,3,1) = "-" then pLanguage = mid(pLanguage,1,5) else pLanguage = mid(pLanguage,1,2) end if else if len(pLanguage) >= 2 then pLanguage = mid(pLanguage,1,2) end if end if pLanguage = lcase(pLanguage) 'all to lower case ie en-US to en-us ' parse browser and os if instr(pBrowserOs,"(")<>0 and instr(pBrowserOs,")")<>0 and instr(pBrowserOs,";")<>0 then pStartingPoint = instr(pBrowserOs,"(") pEndingPoint = instr(pBrowserOs,")") pBrowserOs = mid(pBrowserOs,pStartingPoint+1,pEndingPoint-pStartingPoint-1) pArrayBrowserOs = split(pBrowserOs,";") if instr(pBrowserOs,"AOL")<>0 or instr(pBrowserOs,"MSN")<>0 then pBrowser = pArrayBrowserOs(1) pOs = pArrayBrowserOs(3) else pBrowser = pArrayBrowserOs(1) pOs = pArrayBrowserOs(2) end if else pBrowser = "0" pOs = "0" end if ' verifications if pResolutionC = "" then pResolutionC = 0 if pReferrer = "" then pReferrer = "0" if pLocationURL = "" then pLocationURL = "0" if pUserIP = "" then pUserIP = "0.0.0.0" mySQL="INSERT INTO logs (idSite, locationURL, userIP, referrer, browser, os, resolutionWxH, resolutionC, logMonth, logDay, logYear, logTime, Language, browserOs, searchEngine, searchKeywords) VALUES (" &pidSite& ", '" &pLocationURL& "','" &pUserIP& "','" &pReferrer& "','" &pBrowser& "','" &pOs& "','" &pResolutionWxH& "','" &pResolutionC& "'," &pMonth& "," &pDay& "," &pYear& ",'" &pLogTime& "','" &pLanguage& "','" &pBrowserOs& "','" &pSearchEngine& "','" &pSearchKeywords& "')" 'response.write mysql call updateDatabase(mySQL, rstemp, "add") call closeDB() %>