3 function logStart(&$oDB, $sType = '', $sQuery = '', $aLanguageList = array())
5 $aStartTime = explode('.',microtime(true));
6 if (!isset($aStartTime[1])) $aStartTime[1] = '0';
9 if (isset($_GET['format'])) $sOutputFormat = $_GET['format'];
12 date('Y-m-d H:i:s',$aStartTime[0]).'.'.$aStartTime[1],
13 $_SERVER["REMOTE_ADDR"],
14 $_SERVER['QUERY_STRING'],
20 if (isset($_GET['email']))
21 $sUserAgent = $_GET['email'];
22 elseif (isset($_SERVER['HTTP_REFERER']))
23 $sUserAgent = $_SERVER['HTTP_REFERER'];
25 $sUserAgent = $_SERVER['HTTP_USER_AGENT'];
26 $sSQL = 'insert into new_query_log (type,starttime,query,ipaddress,useragent,language,format,searchterm)';
27 $sSQL .= ' values ('.getDBQuoted($sType).','.getDBQuoted($hLog[0]).','.getDBQuoted($hLog[2]);
28 $sSQL .= ','.getDBQuoted($hLog[1]).','.getDBQuoted($sUserAgent).','.getDBQuoted(join(',',$aLanguageList)).','.getDBQuoted($sOutputFormat).','.getDBQuoted($hLog[3]).')';
32 if (CONST_Log_File && CONST_Log_File_ReverseLog != '')
34 if ($sType == 'reverse')
36 $aStartTime = explode('.',$hLog[0]);
37 file_put_contents(CONST_Log_File_ReverseLog,
38 $aStartTime[0].','.$aStartTime[1].','.
40 '"'.addslashes(isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:'').'",'.
41 '"'.addslashes($hLog[1]).'",'.
45 '"'.addslashes($_SERVER['HTTP_USER_AGENT']).'",'.
46 '"'.addslashes($sOutputFormat).'"'."\n",
54 function logEnd(&$oDB, $hLog, $iNumResults)
56 $aEndTime = explode('.',microtime(true));
57 if (!$aEndTime[1]) $aEndTime[1] = '0';
58 $sEndTime = date('Y-m-d H:i:s',$aEndTime[0]).'.'.$aEndTime[1];
62 $sSQL = 'update new_query_log set endtime = '.getDBQuoted($sEndTime).', results = '.$iNumResults;
63 $sSQL .= ' where starttime = '.getDBQuoted($hLog[0]);
64 $sSQL .= ' and ipaddress = '.getDBQuoted($hLog[1]);
65 $sSQL .= ' and query = '.getDBQuoted($hLog[2]);
69 if (CONST_Log_File && CONST_Log_File_SearchLog != '')
71 $aStartTime = explode('.',$hLog[0]);
72 file_put_contents(CONST_Log_File_SearchLog,
73 $aStartTime[0].','.$aStartTime[1].','.
75 '"'.addslashes(isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:'').'",'.
76 '"'.addslashes($hLog[1]).'",'.
77 '"'.addslashes($hLog[3]).'",'.
78 '"'.addslashes($_SERVER['HTTP_USER_AGENT']).'",'.
79 '"'.addslashes((isset($_GET['format']))?$_GET['format']:'').'",'.