Portions created by the Initial Developer are Copyright (C) 2008-2018 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //includes include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (!permission_exists('errors_view')) { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //set defaults if (!is_numeric($_POST['line_number'])) { $_POST['line_number'] = 0; } if ($_POST['sort'] != 'asc' && $_POST['sort'] != 'desc') { $_POST['sort'] = 'asc'; } if (!is_numeric($_POST['lines'])) { $_POST['lines'] = '10'; } //include the header $document['title'] = $text['title-server_errors']; require_once "resources/header.php"; //show the content $error_file = $_SESSION['server']['error']['text'].($_POST['log'] == 'previous' ? '.1' : null); if (file_exists($error_file)) { //colored lines $x = 0; $filters[$x]['pattern'] = '[error]'; $filters[$x]['color'] = '#cc0000'; $x++; $filters[$x]['pattern'] = '[crit]'; $filters[$x]['color'] = 'gold'; $file_lines = file($error_file, FILE_SKIP_EMPTY_LINES); echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " ".$text['header-server_errors']."
\n"; echo "
\n"; echo "
\n"; echo " ".$text['label-log']; echo " \n"; echo " ".$text['label-filter']." "; echo " "; echo " "; echo " ".$text['label-display']." of ".count($file_lines)." ".$text['label-lines']; echo " "; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; if (is_array($file_lines) && sizeof($file_lines) > 0) { echo "\n"; if ($_POST['filter'] != '') { foreach ($file_lines as $index => $line) { if (strpos($line, $_POST['filter']) == false) { unset($file_lines[$index]); } } } if (is_numeric($_POST['lines']) && $_POST['lines'] > 0) { $file_lines = array_slice($file_lines, -$_POST['lines'], $_POST['lines'], true); } if ($_POST['sort'] == 'desc') { $file_lines = array_reverse($file_lines, true); } foreach ($file_lines as $index => $line) { foreach ($filters as $filter) { $pos = strpos($line, $filter['pattern']); if ($pos !== false){ $filter_beg = ""; $line = str_replace($_POST['filter'],"".$_POST['filter']."", $line); $filter_end = ""; } } if ($_POST['line_number']) { $line_num = "".($index + 1)."   "; } echo $line_num." ".$filter_beg.$line.$filter_end."

"; } echo "
\n"; } else { echo "

[ EMPTY FILE ]

"; } echo " \n"; echo "
\n"; } else { if ($_SESSION['server']['error']['text'] != '') { echo "Server error log file not found at: ".$_SESSION['server']['error']['text']; } else { echo "Server error log file path not defined in Settings."; } } // scroll to bottom of displayed lines, when appropriate if ($_POST['sort'] != 'desc') { echo "\n"; } //include the footer require_once "resources/footer.php"; ?>