3 function logStart(&$oDB, $sType = '', $sQuery = '', $aLanguageList = array())
5 $aStartTime = explode('.',microtime(true));
6 if (!isset($aStartTime[1])) $aStartTime[1] = '0';
8 if (isset($_GET['email']))
9 $sUserAgent = $_GET['email'];
10 elseif (isset($_SERVER['HTTP_REFERER']))
11 $sUserAgent = $_SERVER['HTTP_REFERER'];
12 elseif (isset($_SERVER['HTTP_USER_AGENT']))
13 $sUserAgent = $_SERVER['HTTP_USER_AGENT'];
18 if (isset($_GET['format'])) $sOutputFormat = $_GET['format'];
20 if ($sType == 'reverse')
22 $sOutQuery = (isset($_GET['lat'])?$_GET['lat']:'').'/';
23 if (isset($_GET['lon'])) $sOutQuery .= $_GET['lon'];
24 if (isset($_GET['zoom'])) $sOutQuery .= '/'.$_GET['zoom'];
30 date('Y-m-d H:i:s',$aStartTime[0]).'.'.$aStartTime[1],
31 $_SERVER["REMOTE_ADDR"],
32 $_SERVER['QUERY_STRING'],
41 if (isset($_GET['email']))
42 $sUserAgent = $_GET['email'];
43 elseif (isset($_SERVER['HTTP_REFERER']))
44 $sUserAgent = $_SERVER['HTTP_REFERER'];
45 elseif (isset($_SERVER['HTTP_USER_AGENT']))
46 $sUserAgent = $_SERVER['HTTP_USER_AGENT'];
49 $sSQL = 'insert into new_query_log (type,starttime,query,ipaddress,useragent,language,format,searchterm)';
50 $sSQL .= ' values ('.getDBQuoted($sType).','.getDBQuoted($hLog[0]).','.getDBQuoted($hLog[2]);
51 $sSQL .= ','.getDBQuoted($hLog[1]).','.getDBQuoted($sUserAgent).','.getDBQuoted(join(',',$aLanguageList)).','.getDBQuoted($sOutputFormat).','.getDBQuoted($hLog[3]).')';
58 function logEnd(&$oDB, $hLog, $iNumResults)
60 $aEndTime = explode('.',microtime(true));
61 if (!$aEndTime[1]) $aEndTime[1] = '0';
62 $sEndTime = date('Y-m-d H:i:s',$aEndTime[0]).'.'.$aEndTime[1];
66 $sSQL = 'update new_query_log set endtime = '.getDBQuoted($sEndTime).', results = '.$iNumResults;
67 $sSQL .= ' where starttime = '.getDBQuoted($hLog[0]);
68 $sSQL .= ' and ipaddress = '.getDBQuoted($hLog[1]);
69 $sSQL .= ' and query = '.getDBQuoted($hLog[2]);
75 array_unshift($hLog, $sEndTime);
76 $hLog[] = $iNumResults;
77 $fLog = fopen(CONST_Log_File, 'a');
78 flock($fLog, LOCK_EX);
79 fputcsv($fLog, $hLog);
81 flock($fLog, LOCK_UN);