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)';
40 $sSQL .= join(',', $oDB->getDBQuotedList(array(
46 join(',', $aLanguageList),
57 function logEnd(&$oDB, $hLog, $iNumResults)
59 $fEndTime = microtime(true);
62 $aEndTime = explode('.', $fEndTime);
63 if (!$aEndTime[1]) $aEndTime[1] = '0';
64 $sEndTime = date('Y-m-d H:i:s', $aEndTime[0]).'.'.$aEndTime[1];
66 $sSQL = 'update new_query_log set endtime = '.$oDB->getDBQuoted($sEndTime).', results = '.$iNumResults;
67 $sSQL .= ' where starttime = '.$oDB->getDBQuoted($hLog[0]);
68 $sSQL .= ' and ipaddress = '.$oDB->getDBQuoted($hLog[1]);
69 $sSQL .= ' and query = '.$oDB->getDBQuoted($hLog[2]);
75 "[%s] %.4f %d %s \"%s\"\n",
82 file_put_contents(CONST_Log_File, $aOutdata, FILE_APPEND | LOCK_EX);