Skip to content

Commit

Permalink
fixed bug, needed env var "ERRPAGE_JSON_PATH" to make test work
Browse files Browse the repository at this point in the history
  • Loading branch information
jxmot committed May 31, 2022
1 parent d104a93 commit 0b6387e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion errpages/httperror.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function isLive() {
define('ERROR_CODE', 1);
define('EXPLANATION', 2);

$errorcodes = json_decode(file_get_contents('./errpages/httperror.json'), true);
$errorcodes = json_decode(file_get_contents(getenv('ERRPAGE_JSON_PATH') . 'httperror.json'), true);

if(@$errorcodes["{$http_status}"]) {
$error_code = $errorcodes["{$http_status}"][ERROR_CODE];
Expand Down
6 changes: 6 additions & 0 deletions testhttperror.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
// this script is for testing ./errpages/httperror.php, just
// change the code below
$testcode = 401;
// NOTE: The version of httperror.php that uses a JSON file
// for error code content does not use this. Typically this
// was used only for 404 errors.
$_SERVER['REQUEST_URI'] = '/bad_path/no_resource';
// this just proves we can overwrite $_SERVER
$_SERVER['HTTPS'] = 'on';
$_SERVER['SERVER_PORT'] = 443;
// get the code to httperror.php...
putenv("REDIRECT_STATUS={$testcode}");
// test!
putenv("ERRPAGE_JSON_PATH=./errpages/");
require_once './errpages/httperror.php';
//require_once './errpages/_test.php';
?>

0 comments on commit 0b6387e

Please sign in to comment.