diff --git a/app/errors/app_config.php b/app/errors/app_config.php new file mode 100644 index 0000000000..f4b972f573 --- /dev/null +++ b/app/errors/app_config.php @@ -0,0 +1,48 @@ + \ No newline at end of file diff --git a/app/errors/app_languages.php b/app/errors/app_languages.php new file mode 100644 index 0000000000..3711a5e347 --- /dev/null +++ b/app/errors/app_languages.php @@ -0,0 +1,284 @@ + \ No newline at end of file diff --git a/app/errors/app_menu.php b/app/errors/app_menu.php new file mode 100644 index 0000000000..e87cfda758 --- /dev/null +++ b/app/errors/app_menu.php @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/app/errors/errors.php b/app/errors/errors.php new file mode 100644 index 0000000000..2310ba5a34 --- /dev/null +++ b/app/errors/errors.php @@ -0,0 +1,152 @@ + + 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"; + +?> diff --git a/app/errors/root.php b/app/errors/root.php new file mode 100644 index 0000000000..6fdf32f37b --- /dev/null +++ b/app/errors/root.php @@ -0,0 +1,90 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + umask(2); + if (!defined("PATH_SEPARATOR")) { + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } + } + + if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html'; + + // make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]); + if(PHP_SAPI == 'cli'){ + chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME)); + $script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]); + $dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME)); + if (file_exists('/project_root.php')) { + $path = '/'; + } else { + $i = 1; + $path = ''; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + } + $_SERVER["DOCUMENT_ROOT"] = $path; + }else{ + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + } + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) { + define('PROJECT_PATH', '/fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + if(!file_exists($path. '/project_root.php')){ + die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance"); + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); + } + +?> \ No newline at end of file