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') {
13 $sOutQuery = (isset($_GET['lat'])?$_GET['lat']:'').'/';
14 if (isset($_GET['lon'])) $sOutQuery .= $_GET['lon'];
15 if (isset($_GET['zoom'])) $sOutQuery .= '/'.$_GET['zoom'];
21 date('Y-m-d H:i:s',$aStartTime[0]).'.'.$aStartTime[1],
22 $_SERVER["REMOTE_ADDR"],
23 $_SERVER['QUERY_STRING'],
30 if (isset($_GET['email']))
31 $sUserAgent = $_GET['email'];
32 elseif (isset($_SERVER['HTTP_REFERER']))
33 $sUserAgent = $_SERVER['HTTP_REFERER'];
34 elseif (isset($_SERVER['HTTP_USER_AGENT']))
35 $sUserAgent = $_SERVER['HTTP_USER_AGENT'];
36 else $sUserAgent = '';
37 $sSQL = 'insert into new_query_log (type,starttime,query,ipaddress,useragent,language,format,searchterm)';
38 $sSQL .= ' values ('.getDBQuoted($sType).','.getDBQuoted($hLog[0]).','.getDBQuoted($hLog[2]);
39 $sSQL .= ','.getDBQuoted($hLog[1]).','.getDBQuoted($sUserAgent).','.getDBQuoted(join(',',$aLanguageList)).','.getDBQuoted($sOutputFormat).','.getDBQuoted($hLog[3]).')';
46 function logEnd(&$oDB, $hLog, $iNumResults)
48 $fEndTime = microtime(true);
51 $aEndTime = explode('.', $fEndTime);
52 if (!$aEndTime[1]) $aEndTime[1] = '0';
53 $sEndTime = date('Y-m-d H:i:s',$aEndTime[0]).'.'.$aEndTime[1];
55 $sSQL = 'update new_query_log set endtime = '.getDBQuoted($sEndTime).', results = '.$iNumResults;
56 $sSQL .= ' where starttime = '.getDBQuoted($hLog[0]);
57 $sSQL .= ' and ipaddress = '.getDBQuoted($hLog[1]);
58 $sSQL .= ' and query = '.getDBQuoted($hLog[2]);
63 $aOutdata = sprintf("[%s] %.4f %d %s \"%s\"\n",
64 $hLog[0], $fEndTime-$hLog[5], $iNumResults,
66 file_put_contents(CONST_Log_File, $aOutdata, FILE_APPEND | LOCK_EX);