3 function logStart(&$oDB, $sType = '', $sQuery = '', $aLanguageList = array())
5 $fStartTime = microtime(true);
6 $aStartTime = explode('.', $fStartTime);
7 if (!isset($aStartTime[1])) $aStartTime[1] = '0';
10 if (isset($_GET['format'])) $sOutputFormat = $_GET['format'];
12 if ($sType == 'reverse')
14 $sOutQuery = (isset($_GET['lat'])?$_GET['lat']:'').'/';
15 if (isset($_GET['lon'])) $sOutQuery .= $_GET['lon'];
16 if (isset($_GET['zoom'])) $sOutQuery .= '/'.$_GET['zoom'];
22 date('Y-m-d H:i:s',$aStartTime[0]).'.'.$aStartTime[1],
23 $_SERVER["REMOTE_ADDR"],
24 $_SERVER['QUERY_STRING'],
32 if (isset($_GET['email']))
33 $sUserAgent = $_GET['email'];
34 elseif (isset($_SERVER['HTTP_REFERER']))
35 $sUserAgent = $_SERVER['HTTP_REFERER'];
36 elseif (isset($_SERVER['HTTP_USER_AGENT']))
37 $sUserAgent = $_SERVER['HTTP_USER_AGENT'];
40 $sSQL = 'insert into new_query_log (type,starttime,query,ipaddress,useragent,language,format,searchterm)';
41 $sSQL .= ' values ('.getDBQuoted($sType).','.getDBQuoted($hLog[0]).','.getDBQuoted($hLog[2]);
42 $sSQL .= ','.getDBQuoted($hLog[1]).','.getDBQuoted($sUserAgent).','.getDBQuoted(join(',',$aLanguageList)).','.getDBQuoted($sOutputFormat).','.getDBQuoted($hLog[3]).')';
49 function logEnd(&$oDB, $hLog, $iNumResults)
51 $fEndTime = microtime(true);
55 $aEndTime = explode('.', $fEndTime);
56 if (!$aEndTime[1]) $aEndTime[1] = '0';
57 $sEndTime = date('Y-m-d H:i:s',$aEndTime[0]).'.'.$aEndTime[1];
59 $sSQL = 'update new_query_log set endtime = '.getDBQuoted($sEndTime).', results = '.$iNumResults;
60 $sSQL .= ' where starttime = '.getDBQuoted($hLog[0]);
61 $sSQL .= ' and ipaddress = '.getDBQuoted($hLog[1]);
62 $sSQL .= ' and query = '.getDBQuoted($hLog[2]);
68 $aOutdata = sprintf("[%s] %.4f %d %s \"%s\"\n",
69 $hLog[0], $fEndTime-$hLog[5], $iNumResults,
71 file_put_contents(CONST_Log_File, $aOutdata, FILE_APPEND);