4 function logStart(&$oDB, $sType = '', $sQuery = '', $aLanguageList = array())
6 $fStartTime = microtime(true);
7 $aStartTime = explode('.', $fStartTime);
8 if (!isset($aStartTime[1])) $aStartTime[1] = '0';
11 if (isset($_GET['format'])) $sOutputFormat = $_GET['format'];
13 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'],
31 if (isset($_GET['email']))
32 $sUserAgent = $_GET['email'];
33 elseif (isset($_SERVER['HTTP_REFERER']))
34 $sUserAgent = $_SERVER['HTTP_REFERER'];
35 elseif (isset($_SERVER['HTTP_USER_AGENT']))
36 $sUserAgent = $_SERVER['HTTP_USER_AGENT'];
37 else $sUserAgent = '';
38 $sSQL = 'insert into new_query_log (type,starttime,query,ipaddress,useragent,language,format,searchterm)';
39 $sSQL .= ' values ('.getDBQuoted($sType).','.getDBQuoted($hLog[0]).','.getDBQuoted($hLog[2]);
40 $sSQL .= ','.getDBQuoted($hLog[1]).','.getDBQuoted($sUserAgent).','.getDBQuoted(join(',', $aLanguageList)).','.getDBQuoted($sOutputFormat).','.getDBQuoted($hLog[3]).')';
47 function logEnd(&$oDB, $hLog, $iNumResults)
49 $fEndTime = microtime(true);
52 $aEndTime = explode('.', $fEndTime);
53 if (!$aEndTime[1]) $aEndTime[1] = '0';
54 $sEndTime = date('Y-m-d H:i:s', $aEndTime[0]).'.'.$aEndTime[1];
56 $sSQL = 'update new_query_log set endtime = '.getDBQuoted($sEndTime).', results = '.$iNumResults;
57 $sSQL .= ' where starttime = '.getDBQuoted($hLog[0]);
58 $sSQL .= ' and ipaddress = '.getDBQuoted($hLog[1]);
59 $sSQL .= ' and query = '.getDBQuoted($hLog[2]);
65 "[%s] %.4f %d %s \"%s\"\n",
72 file_put_contents(CONST_Log_File, $aOutdata, FILE_APPEND | LOCK_EX);