<?php
// cricetus, 2005/10/21, hide@address.com
require_once('base.php');
$time_start = get_microtime();
require('web_header.php');
set_title('system.logs.file');
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\')');
}
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\')');
}
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()');
}
break;
}
if(get_admin()!=1)
{
display_message(1,'No administrative rights!','You have no administrative rights to view the log file. ' .
'Please consult an administrator of this system.','Go back','history.back()');
exit;
}
if(check_option('cricetus_en_file','')=='1')
{
$filename = check_option('cricetus_file_name','');
if(!empty($filename))
{
echo '<form name="logfileform" action="logs_file.php" method="POST">';
echo '<input type="hidden" name="service" value="viewlogfile">';
echo '<center>';
echo '<table class="search" cellspacing="20">';
echo '<tr>';
echo '<td>';
echo '<fieldset>';
echo '<legend><b>Log file</b></legend>';
echo '<table class="search">';
echo '<tr>';
echo '<td width=%5%">View:</td>';
echo '<td width="95%">';
echo '<select name="selectlogfile" size="1" onChange="this.form.submit();">';
$find = check_option('cricetus_exec_find','');
$sort = check_option('cricetus_exec_sort','');
$res = shell_exec($find . ' ' . $filename . '* -maxdepth 0 -type f -print | ' . $sort . ' -uf');
$array = explode("\n",$res);
foreach($array as $val)
{
if(strrpos($val,'/')!==FALSE)
{
if($_POST['service']=='viewlogfile')
{
if($val==$_POST['selectlogfile'])
{
echo '<option selected>' . $val . '</option>';
}
else
{
echo '<option>' . $val . '</option>';
}
}
else
{
if($val==$filename)
{
echo '<option selected>' . $val . '</option>';
}
else
{
echo '<option>' . $val . '</option>';
}
}
}
}
echo '</select> ';
// echo '<input type="submit" class="buttonmisc" name="viewbutton" value="View">';
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</fieldset>';
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</center>';
echo '</form>';
if($_POST['service']=='viewlogfile')
{
$filename = $_POST['selectlogfile'];
}
echo '<p><b>' . $filename . ':</b></p>';
$ar = file_in_array($filename);
echo '<pre>';
foreach($ar as $line)
{
echo $line;
}
echo '</pre>';
echo '<p><b>end of file.</b></p>';
}
else
{
display_message(1,'No log file specified!','You have not specified any log file in the options. ' .
'Please set that correctly in the logging options.','Go back','history.back()');
}
}
else
{
display_message(1,'File logging not enabled!','Logging to file is not enabled. Therefore ' .
'you cannot view any log files.','Go back','history.back()');
exit;
}
make_footer($time_start);
?>
</body>
</html>