auth->check_module_permissions('monitor'); // Loading the template $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); $app->tpl->setInclude('content_tpl','templates/logview.htm'); // Importing the GET values $refresh = intval($_GET["refresh"]); $logfile_id = $_GET["log"]; // Creating the array with the refresh intervals $refresh_values = array('0' => '- No Refresh -','2' => '2','5' => '5','10' => '10','15' => '15','30' => '30','60' => '60'); $tmp = ''; foreach($refresh_values as $key => $val) { if($key == $refresh) { $tmp .= ""; } else { $tmp .= ""; } } $app->tpl->setVar("refresh",$tmp); // Selecting the logfile switch($logfile_id) { case 'mail_log': $logfile = '/var/log/mail.log'; break; case 'mail_warn': $logfile = '/var/log/mail.warn'; break; case 'mail_err': $logfile = '/var/log/mail.err'; break; case 'messages': $logfile = '/var/log/messages'; break; case 'freshclam': $logfile = '/var/log/clamav/freshclam.log'; break; case 'clamav': $logfile = '/var/log/clamav/clamav.log'; break; default: $logfile = ''; break; } // Getting the logfile content if($logfile != '') { $logfile = escapeshellcmd($logfile); if(stristr($logfile,';')) die('Logfile path error.'); $log = ''; if(is_readable($logfile)) { if($fd = popen("tail -n 30 $logfile", 'r')) { while (!feof($fd)) { $log .= fgets($fd, 4096); $n++; if($n > 1000) break; } fclose($fd); } } else { $log = 'Unable to read '.$logfile; } } $log = nl2br($log); $app->tpl->setVar("log",$log); $app->tpl->setVar("logfile",$logfile); $app->tpl->setVar("logfile_id",$logfile_id); $app->tpl_defaults(); $app->tpl->pparse(); ?>