Skip to content

Commit 4487860

Browse files
committed
Turn on all warnings and errors for non-Production mode
1 parent befda41 commit 4487860

6 files changed

+107
-4
lines changed

cl_expenses.php

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
<!DOCTYPE HTML>
22
<html>
33
<?php
4+
require_once 'config.php';
5+
if ('Production' != constant('DEPLOY_MODE')) {
6+
echo '<h3>Site is running in ' . constant('DEPLOY_MODE') . ': all warnings and errors will be displayed!</h3>';
7+
echo "<pre>";
8+
require 'dump-errors.php';
9+
echo "</pre>";
10+
}
411

512
require_once('functions.php');
613

cl_income.php

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
<html>
33
<?php
44

5+
require_once 'config.php';
6+
if ('Production' != constant('DEPLOY_MODE')) {
7+
echo '<h3>Site is running in ' . constant('DEPLOY_MODE') . ': all warnings and errors will be displayed!</h3>';
8+
echo "<pre>";
9+
require 'dump-errors.php';
10+
echo "</pre>";
11+
}
12+
513
require_once('functions.php');
614
LogPostValuesToLog($_POST['this_log'], 'cl_expenses');
715
$this_log = $_POST['this_log'];

cl_infos.php

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
include("config.php");
55

66
require_once('functions.php');
7+
if ('Production' != constant('DEPLOY_MODE')) {
8+
echo '<h3>Site is running in ' . constant('DEPLOY_MODE') . ': all warnings and errors will be displayed!</h3>';
9+
echo "<pre>";
10+
require 'dump-errors.php';
11+
echo "</pre>";
12+
}
13+
714
$whoisdis = $_SERVER['REMOTE_USER'];
815

916
?>

cl_results.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
<html>
33
<?php
44
include("config.php");
5+
if ('Production' != constant('DEPLOY_MODE')) {
6+
echo '<h3>Site is running in ' . constant('DEPLOY_MODE') . ': all warnings and errors will be displayed!</h3>';
7+
echo "<pre>";
8+
require 'dump-errors.php';
9+
echo "</pre>";
10+
}
511

612
require_once('functions.php');
713
LogPostValuesToLog($_POST['this_log'], 'cl_income');
@@ -256,9 +262,6 @@
256262

257263
<?php
258264

259-
260-
261-
262265
?>
263266
</p>
264267
<hr class="org-hr">

dump-errors.php

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
// ----------------------------------------------------------------------------------------------------
4+
// - Display Errors
5+
// ----------------------------------------------------------------------------------------------------
6+
ini_set('display_errors', 'On');
7+
ini_set('html_errors', 0);
8+
9+
// ----------------------------------------------------------------------------------------------------
10+
// - Error Reporting
11+
// ----------------------------------------------------------------------------------------------------
12+
error_reporting(-1);
13+
14+
// ----------------------------------------------------------------------------------------------------
15+
// - Shutdown Handler
16+
// ----------------------------------------------------------------------------------------------------
17+
function ShutdownHandler()
18+
{
19+
if(@is_array($error = @error_get_last()))
20+
{
21+
return(@call_user_func_array('ErrorHandler', $error));
22+
};
23+
24+
return(TRUE);
25+
};
26+
27+
register_shutdown_function('ShutdownHandler');
28+
29+
// ----------------------------------------------------------------------------------------------------
30+
// - Error Handler
31+
// ----------------------------------------------------------------------------------------------------
32+
function ErrorHandler($type, $message, $file, $line)
33+
{
34+
$_ERRORS = Array(
35+
0x0001 => 'E_ERROR',
36+
0x0002 => 'E_WARNING',
37+
0x0004 => 'E_PARSE',
38+
0x0008 => 'E_NOTICE',
39+
0x0010 => 'E_CORE_ERROR',
40+
0x0020 => 'E_CORE_WARNING',
41+
0x0040 => 'E_COMPILE_ERROR',
42+
0x0080 => 'E_COMPILE_WARNING',
43+
0x0100 => 'E_USER_ERROR',
44+
0x0200 => 'E_USER_WARNING',
45+
0x0400 => 'E_USER_NOTICE',
46+
0x0800 => 'E_STRICT',
47+
0x1000 => 'E_RECOVERABLE_ERROR',
48+
0x2000 => 'E_DEPRECATED',
49+
0x4000 => 'E_USER_DEPRECATED'
50+
);
51+
52+
if(!@is_string($name = @array_search($type, @array_flip($_ERRORS))))
53+
{
54+
$name = 'E_UNKNOWN';
55+
};
56+
57+
return(print(@sprintf("%s Error in file \"%s\" at line %d: %s\n", $name, @basename($file), $line, $message)));
58+
};
59+
60+
$old_error_handler = set_error_handler("ErrorHandler");
61+
62+
// other php code
63+
64+
?>

index.php

+15-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
<?php require 'welcome.php'; ?>
1+
<?php
2+
require 'welcome.php';
3+
require_once 'config.php';
4+
require_once 'dump-errors.php';
5+
?>
6+
7+
8+
<?php
9+
if ('Production' != constant('DEPLOY_MODE')) {
10+
echo '<h3>Site is running in ' . constant('DEPLOY_MODE') . ': all warnings and errors will be displayed!</h3>';
11+
echo "<pre>";
12+
require 'dump-errors.php';
13+
echo "</pre>";
14+
}
15+
?>

0 commit comments

Comments
 (0)