<?php
// cricetus, 2005/10/21, hide@address.com
require_once('base.php');
$time_start = get_microtime();
require('web_header.php');
set_title('system.logs.database');
switch(check_options())
{
case 0:
break;
case 1:
if(get_admin()!=1)
{
display_message(1,'Errors in system options!','The other system options are not set ' .
'correctly. Please ask the administrator of this system to fix that.','Go back','history.back()');
}
else
{
display_message(1,'Errors in system options!','The other system options are not set ' .
'correctly. Please set them correctly before continuing.','Set other system options',
'load_href(\'options_other.php\')');
}
exit;
break;
case 2:
if(get_admin()!=1)
{
display_message(1,'Errors in system options!','The logging system options are not set ' .
'correctly. Please ask the administrator of this system to fix that.','Go back','history.back()');
}
else
{
display_message(1,'Errors in system options!','The logging system options are not set ' .
'correctly. Please set them correctly before continuing.','Set logging system options',
'load_href(\'options_logging.php\')');
}
exit;
break;
default:
if(get_admin()!=1)
{
display_message(1,'Internal error #001','Please ask the administrator of this system ' .
'to report this error to the developer.','Go back','history.back()');
}
else
{
display_message(1,'Internal error #001','Please report this error to the developer.',
'Go back','history.back()');
}
exit;
break;
}
if($_POST['service']=='search')
{
screen_logging('Preparing...');
$_SESSION['cricetus_logs_db_severity'] = $_POST['severity'];
$_SESSION['cricetus_logs_db_severitymode'] = $_POST['severitymode'];
$_SESSION['cricetus_logs_db_datetime'] = $_POST['datetime'];
if((isset($_POST['hourfrom']))&&
(isset($_POST['minfrom']))&&
(isset($_POST['secfrom']))&&
(isset($_POST['monthfrom']))&&
(isset($_POST['dayfrom']))&&
(isset($_POST['yearfrom'])))
{
$_SESSION['cricetus_logs_db_timestampfrom'] = mktime($_POST['hourfrom'],$_POST['minfrom'],$_POST['secfrom'],
$_POST['monthfrom'],$_POST['dayfrom'],$_POST['yearfrom']);
}
else
{
if((isset($_POST['hourfrom']))&&
(isset($_POST['minfrom']))&&
(isset($_POST['secfrom'])))
{
if($_POST['searchtype']==0)
{
$_SESSION['cricetus_logs_db_timestampfrom'] = mktime($_POST['hourfrom'],$_POST['minfrom'],$_POST['secfrom'],
$_POST['month'],$_POST['day'],$_POST['year']);
}
else
{
$_SESSION['cricetus_logs_db_timestampfrom'] = 0;
}
}
else
{
$_SESSION['cricetus_logs_db_timestampfrom'] = 0;
}
}
if((isset($_POST['hourto']))&&
(isset($_POST['minto']))&&
(isset($_POST['secto']))&&
(isset($_POST['monthto']))&&
(isset($_POST['dayto']))&&
(isset($_POST['yearto'])))
{
$_SESSION['cricetus_logs_db_timestampto'] = mktime($_POST['hourto'],$_POST['minto'],$_POST['secto'],
$_POST['monthfrom'],$_POST['dayto'],$_POST['yearto']);
}
else
{
if((isset($_POST['hourto']))&&
(isset($_POST['minto']))&&
(isset($_POST['secto'])))
{
if($_POST['searchtype']==0)
{
$_SESSION['cricetus_logs_db_timestampto'] = mktime($_POST['hourto'],$_POST['minto'],$_POST['secto'],
$_POST['month'],$_POST['day'],$_POST['year']);
}
else
{
$_SESSION['cricetus_logs_db_timestampto'] = 2147483647;
}
}
else
{
$_SESSION['cricetus_logs_db_timestampto'] = 2147483647;
}
}
$_SESSION['cricetus_logs_db_records'] = $_POST['records'];
$_SESSION['cricetus_logs_db_sort'] = $_POST['sort'];
$_SESSION['cricetus_logs_db_order'] = $_POST['order'];
$_SESSION['cricetus_logs_db_search1'] = $_POST['search1'];
$_SESSION['cricetus_logs_db_operator1'] = $_POST['operator1'];
$_SESSION['cricetus_logs_db_case1'] = $_POST['case1'];
$_SESSION['cricetus_logs_db_exclude1'] = $_POST['exclude1'];
$_SESSION['cricetus_logs_db_regexp1'] = $_POST['regexp1'];
$_SESSION['cricetus_logs_db_search2'] = $_POST['search2'];
$_SESSION['cricetus_logs_db_operator2'] = $_POST['operator2'];
$_SESSION['cricetus_logs_db_case2'] = $_POST['case2'];
$_SESSION['cricetus_logs_db_exclude2'] = $_POST['exclude2'];
$_SESSION['cricetus_logs_db_regexp2'] = $_POST['regexp2'];
$_SESSION['cricetus_logs_db_search3'] = $_POST['search3'];
$_SESSION['cricetus_logs_db_case3'] = $_POST['case3'];
$_SESSION['cricetus_logs_db_exclude3'] = $_POST['exclude3'];
$_SESSION['cricetus_logs_db_regexp3'] = $_POST['regexp3'];
// increase execution time for long grep processes
ini_set('max_execution_time',3600);
// start queries
screen_logging('Searching for:');
echo '<table class="disp">';
echo '<tr>';
$verbose = '<b>' . $_POST['search1'] . '</b> (';
$logs = 'SEARCHING for "' . $_POST['search1'] . '" (';
if($_POST['case1']==1)
{
$verbose = $verbose . 'case sensitive, ';
$logs = $logs . 'case sensitive, ';
}
if($_POST['exclude1']==1)
{
$verbose = $verbose . 'exclude, ';
$logs = $logs . 'exclude, ';
}
if($_POST['regexp1']==1)
{
$verbose = $verbose . 'regexp ';
$logs = $logs . 'regexp ';
}
if(substr($verbose,-1)=='(')
{
$verbose = substr($verbose,0,-2);
$logs = substr($logs,0,-2);
}
else
{
$verbose = substr($verbose,0,-2) . ')';
$logs = substr($logs,0,-2) . ')';
}
echo '<td> </td>';
echo '<td>' . $verbose . '</td>';
echo '</tr>';
if(!empty($_POST['search2']))
{
echo '<tr>';
echo '<td>';
$ar = $_POST['operator1'];
if($ar[0]=='OR')
{
echo 'OR:';
$logs = $logs . ' OR ';
}
else
{
echo 'AND:';
$logs = $logs . ' AND ';
}
echo '</td>';
$verbose = '<b>' . $_POST['search2'] . '</b> (';
$logs = $logs . '"' . $_POST['search2'] . '" (';
if($_POST['case2']==1)
{
$verbose = $verbose . 'case sensitive, ';
$logs = $logs . 'case sensitive, ';
}
if($_POST['exclude2']==1)
{
$verbose = $verbose . 'exclude, ';
$logs = $logs . 'exclude, ';
}
if($_POST['regexp2']==1)
{
$verbose = $verbose . 'regexp ';
$logs = $logs . 'regexp ';
}
if(substr($verbose,-1)=='(')
{
$verbose = substr($verbose,0,-2);
$logs = substr($logs,0,-2);
}
else
{
$verbose = substr($verbose,0,-2) . ')';
$logs = substr($logs,0,-2) . ')';
}
echo '<td>' . $verbose . '</td>';
echo '</tr>';
}
if(!empty($_POST['search3']))
{
echo '<tr>';
echo '<td>';
$ar = $_POST['operator2'];
if($ar[0]=='OR')
{
echo 'OR:';
$logs = $logs . ' OR ';
}
else
{
echo 'AND:';
$logs = $logs . ' AND ';
}
echo '</td>';
echo '<td>';
$verbose = '<b>' . $_POST['search3'] . '</b> (';
$logs = $logs . '"' . $_POST['search3'] . '" )';
if($_POST['case3']==1)
{
$verbose = $verbose . 'case sensitive, ';
$logs = $logs . 'case sensitive, ';
}
if($_POST['exclude3']==1)
{
$verbose = $verbose . 'exclude, ';
$logs = $logs . 'exclude, ';
}
if($_POST['regexp3']==1)
{
$verbose = $verbose . 'regexp ';
$logs = $logs . 'regexp ';
}
if(substr($verbose,-1)=='(')
{
$verbose = substr($verbose,0,-2);
$logs = substr($logs,0,-2);
}
else
{
$verbose = substr($verbose,0,-2) . ')';
$logs = substr($logs,0,-2) . ')';
}
echo $verbose;
echo '</td>';
echo '</tr>';
}
echo '</table>';
screen_logging('Please be patient...');
logging('info',$logs);
// or/and
if(!empty($grep3))
{
$ar = $_POST['operator1'];
if($ar[0]=='OR')
{
$ar = $_POST['operator2'];
if($ar[0]=='OR')
{
$arr4 = array_unique(array_merge($arr2,$arr3));
$grep = array_unique(array_merge($arr4,$arr1));
}
else
{
$arr4 = array_intersect($arr2,$arr3);
$grep = array_unique($arr4,$arr1);
}
}
else
{
$arr4 = array_intersect($arr1,$arr2);
$ar = $_POST['operator2'];
if($ar[0]=='OR')
{
$grep = array_unique(array_merge($arr4,$arr3));
}
else
{
$grep = array_intersect($arr4,$arr3);
}
}
}
else
{
if(!empty($grep2))
{
$ar = $_POST['operator1'];
if($ar[0]=='OR')
{
$grep = array_unique(array_merge($arr1,$arr2));
}
else
{
$grep = array_intersect($arr1,$arr2);
}
}
else
{
$grep = $arr1;
}
}
$c = count($grep) - 1;
logging('info','found ' . $c . ' lines');
echo '<pre>';
foreach($grep as $val)
{
$p = strpos($val,$_POST['dir']);
if($p!==FALSE)
{
if($p==0)
{
$val = substr($val,strlen($_POST['dir']));
}
}
echo htmlspecialchars($val);
}
echo '</pre>';
} // if search
make_footer($time_start);
?>
</body>
</html>