]> git.openstreetmap.org Git - nominatim.git/blob - lib/log.php
more partitioning work, os open data postcodes, country list fixes
[nominatim.git] / lib / log.php
1 <?php
2
3         function logStart(&$oDB, $sType = '', $sQuery = '', $aLanguageList = array())
4         {
5                 $aStartTime = explode('.',microtime(true));
6                 if (!$aStartTime[1]) $aStartTime[1] = '0';
7
8                 $hLog = array(
9                                 date('Y-m-d H:i:s',$aStartTime[0]).'.'.$aStartTime[1],
10                                 $_SERVER["REMOTE_ADDR"],
11                                 $_SERVER['QUERY_STRING'],
12                                 $sQuery
13                         );
14
15                 // Log
16                 if ($sType == 'search')
17                 {
18                         $oDB->query('insert into query_log values ('.getDBQuoted($hLog[0]).','.getDBQuoted($hLog[3]).','.getDBQuoted($hLog[1]).')');
19                 }
20
21                 $sSQL = 'insert into new_query_log (type,starttime,query,ipaddress,useragent,language,format)';
22                 $sSQL .= ' values ('.getDBQuoted($sType).','.getDBQuoted($hLog[0]).','.getDBQuoted($hLog[2]);
23                 $sSQL .= ','.getDBQuoted($hLog[1]).','.getDBQuoted($_SERVER['HTTP_USER_AGENT']).','.getDBQuoted(join(',',$aLanguageList)).','.getDBQuoted($_GET['format']).')';
24                 $oDB->query($sSQL);
25
26
27                 return $hLog;
28         }
29
30         function logEnd(&$oDB, $hLog, $iNumResults)
31         {
32                 $aEndTime = explode('.',microtime(true));
33                 if (!$aEndTime[1]) $aEndTime[1] = '0';
34                 $sEndTime = date('Y-m-d H:i:s',$aEndTime[0]).'.'.$aEndTime[1];
35
36                 $sSQL = 'update query_log set endtime = '.getDBQuoted($sEndTime).', results = '.$iNumResults;
37                 $sSQL .= ' where starttime = '.getDBQuoted($hLog[0]);
38                 $sSQL .= ' and ipaddress = '.getDBQuoted($hLog[1]);
39                 $sSQL .= ' and query = '.getDBQuoted($hLog[3]);
40                 $oDB->query($sSQL);
41
42                 $sSQL = 'update new_query_log set endtime = '.getDBQuoted($sEndTime).', results = '.$iNumResults;
43                 $sSQL .= ' where starttime = '.getDBQuoted($hLog[0]);
44                 $sSQL .= ' and ipaddress = '.getDBQuoted($hLog[1]);
45                 $sSQL .= ' and query = '.getDBQuoted($hLog[2]);
46                 $oDB->query($sSQL);
47         }