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'])) {
20 $sOutQuery .= $_GET['lon'];
22 if (isset($_GET['zoom'])) {
23 $sOutQuery .= '/'.$_GET['zoom'];
30 date('Y-m-d H:i:s', $aStartTime[0]).'.'.$aStartTime[1],
31 $_SERVER['REMOTE_ADDR'],
32 $_SERVER['QUERY_STRING'],
39 if (isset($_GET['email'])) {
40 $sUserAgent = $_GET['email'];
41 } elseif (isset($_SERVER['HTTP_REFERER'])) {
42 $sUserAgent = $_SERVER['HTTP_REFERER'];
43 } elseif (isset($_SERVER['HTTP_USER_AGENT'])) {
44 $sUserAgent = $_SERVER['HTTP_USER_AGENT'];
48 $sSQL = 'insert into new_query_log (type,starttime,query,ipaddress,useragent,language,format,searchterm)';
50 $sSQL .= join(',', $oDB->getDBQuotedList(array(
56 join(',', $aLanguageList),
67 function logEnd(&$oDB, $hLog, $iNumResults)
69 $fEndTime = microtime(true);
72 $aEndTime = explode('.', $fEndTime);
76 $sEndTime = date('Y-m-d H:i:s', $aEndTime[0]).'.'.$aEndTime[1];
78 $sSQL = 'update new_query_log set endtime = '.$oDB->getDBQuoted($sEndTime).', results = '.$iNumResults;
79 $sSQL .= ' where starttime = '.$oDB->getDBQuoted($hLog[0]);
80 $sSQL .= ' and ipaddress = '.$oDB->getDBQuoted($hLog[1]);
81 $sSQL .= ' and query = '.$oDB->getDBQuoted($hLog[2]);
87 "[%s] %.4f %d %s \"%s\"\n",
94 file_put_contents(CONST_Log_File, $aOutdata, FILE_APPEND | LOCK_EX);