// Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . global $HTTP_POST_VARS, $HTTP_GET_VARS; $publicAccess = false; $allowNevrax = true; include('authenticate.php'); include('request_interface.php'); include_once('las_connection.php'); if (!isset($_POST) && isset($HTTP_POST_VARS)) $_POST = &$HTTP_POST_VARS; if (!isset($_GET) && isset($HTTP_GET_VARS)) $_GET = &$HTTP_GET_VARS; function importParam($var) { global $_POST, $_GET; if (isset($_POST[$var])) $GLOBALS[$var] = $_POST[$var]; else if (isset($_GET[$var])) $GLOBALS[$var] = $_GET[$var]; else unset($GLOBALS[$var]); } htmlProlog($_SERVER['PHP_SELF'], "Log Analysis"); // look for LAS $las_query = "*.*.LAS.State"; $qstate = nel_query($las_query, $result); unset($availableLAS); if ($qstate) { $arr = explode(' ', $result); $numRes = count($arr); $numRows = current($arr); $numLines = ($numRes-$numRows-2)/$numRows; next($arr); for ($i=0; $i<$numRows; ++$i) { $vars[] = current($arr); next($arr); } unset($shards); for ($i=0; $i<$numLines; ++$i) { unset($l); foreach($vars as $var) { $l[$var] = current($arr); next($arr); } $sql_query = "SELECT * FROM server WHERE name='".$l['server']."'"; $sql_res = sqlquery($sql_query); if ($sql_res && ($sql_arr = sqlfetch($sql_res))) $l['address'] = $sql_arr['address']; $availableLAS[] = $l; } } /* echo "
";
	print_r($availableLAS);
	echo "
"; */ importParam('exec_query'); importParam('refresh_result'); importParam('query'); importParam('query_id'); importParam('page'); importParam('build_display_query'); importParam('build_eid_query'); importParam('database'); for ($i=0; $i<10; ++$i) importParam("eid_$i"); importParam('string'); importParam('start_date'); importParam('end_date'); $string = stripslashes($string); $query = stripslashes($query); // ------------------------------------------------------------------------------------------------------------------------ echo "
"; echo "\n"; echo "\n"; echo "\n"; $selectedLAS = ''; // mandatory information echo "\n"; // search by eid echo "\n"; echo "\n"; // search by string echo "\n"; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; echo "\n"; echo "\n"; echo "\n"; echo ""; echo "\n"; echo "\n"; echo "
\n"; echo "\n"; echo "\n"; echo ""; echo "\n"; echo ""; echo "\n"; echo ""; echo "\n"; echo ""; echo "
LAS Host
"; echo "\n"; echo "
Database
Start Date
End Date
\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "
EntityIds
\n"; for ($i=0; $i<10; ++$i) echo "
\n"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; echo ""; echo "
String
\n"; echo "
\n"; // ------------------------------------------------------------------------------------------------------------------------ echo "
\n"; if ($build_eid_query || $build_display_query) { $eids = array(); for ($i=0; $i<10; ++$i) if ($GLOBALS["eid_$i"] != '') $eids[] = $GLOBALS["eid_$i"]; if (count($eids) == 0 || $build_display_query) { $query = "displayLogs $database $start_date"; if ($end_date != '') $query .= " $end_date"; $exec_query = true; } else if (count($eids) > 1) { $query = "searchEIds $database ".join(' ', $eids)." - $start_date"; if ($end_date != '') $query .= " $end_date"; $exec_query = true; } else { $query = "searchEId $database ".$eids[0]." $start_date"; if ($end_date != '') $query .= " $end_date"; $exec_query = true; } } else if ($build_string_query) { if ($string != '') { $query = "searchString $database \"$string\" $start_date"; if ($end_date != '') $query .= " $end_date"; $exec_query = true; } } /* // display query input echo "\n"; echo "\n"; echo "\n"; echo ""; echo ""; echo "\n"; echo "\n"; echo "\n"; for ($i=0; $i<10; ++$i) echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Query
\n"; */ if ($display_queries && $selectedLAS['address']) { $success = displayLASQueries($selectedLAS['address'], $result); if ($success) { $a = explode("\n", $result); if (count($a) > 0) { echo "
"; echo "\n"; $i = 0; foreach ($a as $query) { if ($query == '') continue; $qa = explode(':', $query, 4); $bg = (($i & 1) == 0 ? '#F8F8FF' : '#F0F0F8'); ++$i; echo ""; if ($qa[1] == 2) { echo ""; $refstr = $_SERVER['PHP_SELF']."?refresh_result=1&las_address=".$selectedLAS['address']."&query_id=".$qa[0]."&query=".$qa[2]."&database=$database&string=$string&start_date=$start_date&end_date=$end_date"; echo ""; echo ""; } else if ($qa[1] == 1) { echo ""; echo ""; echo ""; } else { echo ""; echo ""; echo ""; } echo "\n"; } echo "
".$qa[0]."Display".$qa[3]."".$qa[0]."Processing ".$qa[2]."%".$qa[3]."".$qa[0]."Cancel".$qa[3]."
"; echo "
"; } } } else if ($exec_query && $query && $selectedLAS['address']) { $success = logQuery($selectedLAS['address'], $query, $result, $query_id); echo "

"; if ($success) { echo "Query '$query' successfully executed ($result)
\n"; echo "Please wait while result is being computed and click 'Refresh result' to display query result.
\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; for ($i=0; $i<10; ++$i) echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; } else { echo "Query '$query' failed: '$result'
\n"; } } else if ($refresh_result && isset($query_id) && $selectedLAS['address']) { $success = getQueryResult($selectedLAS['address'], $query_id, $result, $page, $numpages); echo "

"; if ($success) { echo "Query '$query' result:
\n"; echo ""; $refstr = $_SERVER['PHP_SELF']."?refresh_result=1&las_address=".$selectedLAS['address']."&query_id=$query_id&query=$query&database=$database&string=$string&start_date=$start_date&end_date=$end_date"; for ($i=0; $i<10; ++$i) if ($GLOBALS["eid_$i"] != '') $refstr .= "&eid_$i=".$GLOBALS["eid_$i"]; if ($page > 0) echo "<<\n "; else echo "<< "; if ($page > 0) echo "<\n"; else echo "<"; if ($page+1 < $numpages) echo " >\n"; else echo " >"; if ($page+1 < $numpages) echo " >>\n"; else echo " >>"; echo "\n"; if ($numpages < 20) { $minpage = 0; $maxpage = $numpages-1; } else { $minpage = $page-10; if ($minpage < 0) $minpage = 0; $maxpage = $minpage+20; if ($maxpage >= $numpages) $maxpage = $numpages-1; $minpage = $maxpage-20; } for ($p=$minpage; $p<=$maxpage; ++$p) { if ($p == $page) { echo " $page"; } else { echo " $p\n"; } } echo " [$numpages pages]"; echo "
\n"; $disp = htmlentities($result); echo "
"; echo "\n"; $a = explode("\n", $disp); $i = 0; foreach ($a as $l) { if (trim($l) == '') continue; $bg = (($i & 1) == 0 ? '#F8F8FF' : '#F0F0F8'); ++$i; $prefix = substr($l, 0, 3); echo ""; if ($prefix == '#! ') { echo ""; } else if ($prefix == '#? ') { echo ""; } else if ($prefix == '## ') { echo ""; } else if ($prefix == '#$ ') { $al = explode(':', substr($l, 3), 4); echo ""; echo ""; $d = str_repeat('- ', $al[1]).$al[3]; $d = ereg_replace('(\(0x[0-9a-fA-F]{10}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}\))', '\\1', $d); //$d = ereg_replace('(\(0x[0-9a-fA-F]{10}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}\))', '\\1', $d); echo ""; } else { echo ""; } echo "\n"; } echo "
"; echo substr($l, 3); echo ""; echo substr($l, 3); echo ""; echo substr($l, 3); echo "".$al[0]."".trim($al[2])."$d// $l
"; echo "
"; } else { echo "Failed to get query result: '$result'
\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; for ($i=0; $i<10; ++$i) echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; } } else if (($exec_query || $refresh_result) && (!$selectedLAS['address'])) { echo "No LAS Host selected, please restart query with a LAS Host specified.
\n"; } echo "
"; htmlEpilog(); ?>