Portions created by the Initial Developer are Copyright (C) 2008-2020 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //set the include path $conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE); set_include_path(parse_ini_file($conf[0])['document.root']); //includes files 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 (empty($_POST['line_number'])) { $_POST['line_number'] = 0; } if (!empty($_POST['sort']) && $_POST['sort'] != 'asc' && $_POST['sort'] != 'desc') { $_POST['sort'] = 'asc'; } if (empty($_POST['lines'])) { $_POST['lines'] = '10'; } if (empty($_POST['filter'])) { $_POST['filter'] = ''; } //include the header $document['title'] = $text['title-server_errors']; require_once "resources/header.php"; //show the content $error_file = $_SESSION['server']['error']['text'].(!empty($_POST['log']) && $_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 "
".$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']." : ".count($file_lines)." ".$text['label-lines']; echo button::create(['type'=>'submit','label'=>$text['button-reload'],'icon'=>$_SESSION['theme']['button_icon_reload'],'style'=>'margin-left: 15px;','name'=>'submit']); echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; if (!empty($file_lines) && sizeof($file_lines) > 0) { echo "\n"; if (!empty($_POST['filter'])) { foreach ($file_lines as $index => $line) { if (strpos($line, $_POST['filter']) == false) { unset($file_lines[$index]); } } } if (!empty($_POST['lines'])) { $file_lines = array_slice($file_lines, -$_POST['lines'], $_POST['lines'], true); } if (!empty($_POST['sort']) && $_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']); $filter_beg = ''; $filter_end = ''; if ($pos !== false){ $filter_beg = ""; $line = str_replace($_POST['filter'],"".$_POST['filter']."", $line); $filter_end = ""; } } $line_num = ''; 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 (!empty($_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 (!empty($_POST['sort']) && $_POST['sort'] != 'desc') { echo "\n"; } //include the footer require_once "resources/footer.php"; ?>