4 function logStart(&$oDB, $sType = '', $sQuery = '', $aLanguageList = array())
6 $fStartTime = microtime(true);
7 $aStartTime = explode('.', $fStartTime);
8 if (!isset($aStartTime[1])) {
13 if (isset($_GET['format'])) {
14 $sOutputFormat = $_GET['format'];
17 if ($sType == 'reverse') {
18 $sOutQuery = (isset($_GET['lat'])?$_GET['lat']:'').'/';
19 if (isset($_GET['lon'])) $sOutQuery .= $_GET['lon'];
20 if (isset($_GET['zoom'])) $sOutQuery .= '/'.$_GET['zoom'];
26 date('Y-m-d H:i:s', $aStartTime[0]).'.'.$aStartTime[1],
27 $_SERVER['REMOTE_ADDR'],
28 $_SERVER['QUERY_STRING'],
35 if (isset($_GET['email'])) {
36 $sUserAgent = $_GET['email'];
37 } elseif (isset($_SERVER['HTTP_REFERER'])) {
38 $sUserAgent = $_SERVER['HTTP_REFERER'];
39 } elseif (isset($_SERVER['HTTP_USER_AGENT'])) {
40 $sUserAgent = $_SERVER['HTTP_USER_AGENT'];
44 $sSQL = 'insert into new_query_log (type,starttime,query,ipaddress,useragent,language,format,searchterm)';
46 $sSQL .= join(',', $oDB->getDBQuotedList(array(
52 join(',', $aLanguageList),
63 function logEnd(&$oDB, $hLog, $iNumResults)
65 $fEndTime = microtime(true);
68 $aEndTime = explode('.', $fEndTime);
72 $sEndTime = date('Y-m-d H:i:s', $aEndTime[0]).'.'.$aEndTime[1];
74 $sSQL = 'update new_query_log set endtime = '.$oDB->getDBQuoted($sEndTime).', results = '.$iNumResults;
75 $sSQL .= ' where starttime = '.$oDB->getDBQuoted($hLog[0]);
76 $sSQL .= ' and ipaddress = '.$oDB->getDBQuoted($hLog[1]);
77 $sSQL .= ' and query = '.$oDB->getDBQuoted($hLog[2]);
83 "[%s] %.4f %d %s \"%s\"\n",
90 file_put_contents(CONST_Log_File, $aOutdata, FILE_APPEND | LOCK_EX);