global $dbg; if ($dbg) { print "{$msg}\n"; } } function dbg($msg) { global $dbg; if ($dbg) { if (is_array($msg) || is_object($msg)) { print "<pre class='dbg'>"; print_r($msg); print "</pre>\n"; } else { print "<span class='dbg'>{$msg}</span><br>\n"; } } } $dbg = isset($_COOKIE["dbg"]) && $_COOKIE["dbg"] == "true" ? true : false; if (isset($_GET["dbg"])) { if ($_GET["dbg"] == "on") { dbg_sc("dbg", "true"); $dbg = true; dbg("Debug mode enabled"); } else { if ($_GET["dbg"] == "off") { dbg_sc("dbg", ""); $dbg = false; } } }
function here() { fdbg(__FILE__ . ":" . __LINE__); } // Convert errors into Exceptions function exception_error_handler($errno, $errstr, $errfile, $errline) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } set_error_handler("exception_error_handler", E_ALL ^ E_NOTICE); if (isset($_COOKIE["dbg"])) { $dbg = $_COOKIE["dbg"] == "true" ? true : false; } if (isset($_GET["dbg"])) { $pass_required = substr($_SERVER["SERVER_NAME"], 0, 4); $pass_given = $_GET["dbg"]; if ($pass_given == $pass_required) { dbg_sc("dbg", "true"); $dbg = true; dbg("Debug mode enabled"); } else { if ($_GET["dbg"] == "off") { dbg_sc("dbg", "false"); $dbg = false; } } } if (isset($dbg) && $dbg) { ini_set('display_errors', 1); error_reporting(E_ALL ^ E_NOTICE); }