[Openfirst-cvscommit] base/includes/functions debug.php,1.3,1.4
Brought to you by:
xtimg
From: Astronouth7303 <ast...@us...> - 2005-06-30 02:31:00
|
Update of /cvsroot/openfirst/base/includes/functions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12705/includes/functions Modified Files: debug.php Log Message: added backtrace to non-commiting debug message. Index: debug.php =================================================================== RCS file: /cvsroot/openfirst/base/includes/functions/debug.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** debug.php 27 May 2005 00:02:23 -0000 1.3 --- debug.php 30 Jun 2005 02:30:45 -0000 1.4 *************** *** 1,132 **** ! <?php ! /* ! * openFIRST.base - config/functions/debug.php ! * ! * Copyright (C) 2003, ! * openFIRST Project ! * Original Author: Tim Ginn <tim...@po...> ! * ! * This program is free software; you can redistribute it and/or modify ! * it under the terms of the GNU General Public License as published by ! * the Free Software Foundation; either version 2 of the License, or ! * (at your option) any later version. ! * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License ! * along with this program; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! * ! */ ! // Purpose: Provide some useful features for debugging certain problems. ! // This entire process is optional, of course. Anyone may easily ! // simply remove this file in order to eliminate the debugging. ! ! set_error_handler("ofirst_error_handler"); ! if (!isset($NO_ADD_BUG)) $NO_ADD_BUG = false; ! ! // Handles errors by displaying a message and contacting openFIRST ! // developers for assistance. ! function ofirst_error_handler($errno,$error,$file,$line,$context) { ! global $DBaseType, $Encryption, $Title, $Version, $sqlServer, $sqlUser, $sqlPassword, $sqlDatabase, ! $sqlConnection, $PassSaveDisabled, $regEnabled, $Server, $BasePath, $fBasePath, $Home, ! $StylePath, $fStylePath, $Header, $Footer, $MailNotify, $MailFrom; ! global $osType, $currentmodule, $user, $lastquery, $usingPHP5; ! global $NO_ADD_BUG; ! $dberrno = ofirst_dberrno(); ! $dberror = ofirst_dberror(); ! ! if(! function_exists("md5_file")) { ! $checksum = "na"; ! } else { ! if (isset($_SERVER['SCRIPT_FILENAME'])) { ! $checksum = md5_file($_SERVER['SCRIPT_FILENAME']); ! } ! } ! ! if ($usingPHP5 && $errno == 2048) return; ! ! $details = "MD5: $checksum ! Database Type: $DBaseType ! Operating System: $osType ! SQL Server: $sqlServer ! Current Module: $currentmodule ! Error Number: $errno"; ! ! $specifics = "PHP_SELF: {$_SERVER['PHP_SELF']} ! HTTP Host: {$_SERVER['HTTP_HOST']}"; ! ! if (isset($_SERVER['HTTP_REFERER'])) { ! $specifics .= " ! HTTP Referer: {$_SERVER['HTTP_REFERER']}"; ! } ! $specifics .= " ! Translated Path: {$_SERVER['SCRIPT_FILENAME']}"; ! if (isset($user) ) { ! $specifics .= " ! User: {$user->user} ! User Access Level: {$user->membertype}"; ! } ! $specifics .= " ! Error Description: {$error} in {$file} on line {$line}"; ! if ($dberrno != 0) { ! $specifics .= " ! DB Error Number: {$dberrno} ! DB Error: ".ofirst_dberror()." ! Last Query: {$lastquery}"; ! } ! ! if ($NO_ADD_BUG) ! { ! echo "<br /><div class=\"error\"><h2>Error:</h2><dl>"; ! echo "<dt>Details:</dt><dd><pre>"; ! echo $details; ! echo "</pre></dd>"; ! echo "<dt>Specifics:</dt><dd><pre>"; ! echo $specifics; ! echo "</pre></dd></dl></div>"; ! } else { ! // Notify the appropriate local contact ! mail($mailnotify, "$error in $file on line $line", "Error Description: $error in $file on line $line ! ! There is additional information regarding this bug stored on ! the openFIRST Bugzilla Server at: ! ! http://bugzilla.openfirst.org/", "From: $mailfrom"); ! ! // Attempt to contact the openFIRST Bugzilla Server ! $bugzilla = fopen( "http://bugzilla.openfirst.org/openfirst/". ! "?module=$currentmodule". ! "&uri=" . urlencode($_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]). ! "&details=".urlencode($details). ! "&specifics=".urlencode($specifics) . ! ($NO_ADD_BUG ? "&no-commit=true" : ""), "r"); ! ! if(! $bugzilla) { ! // If a connection cannot be established to the Bugzilla server ! echo("Could not contact the openFIRST Bugzilla server."); ! echo("<h3><strong>$errno</strong> - <strong>$error</strong> in ! <strong>$file</strong> on line <strong>$line</strong></h3> ! <p><strong>The openFIRST system has encountered an error. This ! may be due to a misconfiguration on the behalf of the person installing it, ! or an error in the openFIRST code.</strong></p> ! <p>Debugging may be disabled by removing (config/functions/debug.php)"); ! ! } else { ! // If a connection is established to the Bugzilla server then rely ! // completely on it for the appropriate error message to show. ! while(!feof($bugzilla)) { ! $line = fgets($bugzilla, 2048); ! echo $line; ! } ! } ! } ! } ! ?> --- 1,137 ---- ! <?php ! /* ! * openFIRST.base - config/functions/debug.php ! * ! * Copyright (C) 2003, ! * openFIRST Project ! * Original Author: Tim Ginn <tim...@po...> ! * ! * This program is free software; you can redistribute it and/or modify ! * it under the terms of the GNU General Public License as published by ! * the Free Software Foundation; either version 2 of the License, or ! * (at your option) any later version. ! * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License ! * along with this program; if not, write to the Free Software ! * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ! * ! */ ! // Purpose: Provide some useful features for debugging certain problems. ! // This entire process is optional, of course. Anyone may easily ! // simply remove this file in order to eliminate the debugging. ! ! set_error_handler("ofirst_error_handler"); ! if (!isset($NO_ADD_BUG)) $NO_ADD_BUG = false; ! ! // Handles errors by displaying a message and contacting openFIRST ! // developers for assistance. ! function ofirst_error_handler($errno,$error,$file,$line,$context) { ! global $DBaseType, $Encryption, $Title, $Version, $sqlServer, $sqlUser, $sqlPassword, $sqlDatabase, ! $sqlConnection, $PassSaveDisabled, $regEnabled, $Server, $BasePath, $fBasePath, $Home, ! $StylePath, $fStylePath, $Header, $Footer, $MailNotify, $MailFrom, $ofDB; ! global $osType, $currentmodule, $user, $lastquery, $usingPHP5; ! global $NO_ADD_BUG; ! $dberrno = $ofDB->errorNumber(); ! $dberror = $ofDB->errorString(); ! ! if(! function_exists("md5_file")) { ! $checksum = "na"; ! } else { ! if (isset($_SERVER['SCRIPT_FILENAME'])) { ! $checksum = md5_file($_SERVER['SCRIPT_FILENAME']); ! } ! } ! ! if ($usingPHP5 && $errno == 2048) return; ! ! $details = "MD5: $checksum ! Database Type: $DBaseType ! Operating System: $osType ! SQL Server: $sqlServer ! Current Module: $currentmodule ! Error Number: $errno"; ! ! $specifics = "PHP_SELF: {$_SERVER['PHP_SELF']} ! HTTP Host: {$_SERVER['HTTP_HOST']}"; ! ! if (isset($_SERVER['HTTP_REFERER'])) { ! $specifics .= " ! HTTP Referer: {$_SERVER['HTTP_REFERER']}"; ! } ! $specifics .= " ! Translated Path: {$_SERVER['SCRIPT_FILENAME']}"; ! if (isset($user) ) { ! $specifics .= " ! User: {$user->user} ! User Access Level: {$user->membertype}"; ! } ! $specifics .= " ! Error Description: {$error} in {$file} on line {$line}"; ! if ($dberrno != 0) { ! $specifics .= " ! DB Error Number: {$dberrno} ! DB Error: {$dberror} ! Last Query: {$lastquery}"; ! } ! ! if ($NO_ADD_BUG) ! { ! echo "<br /><div class=\"error\"><h2>Error:</h2><dl>"; ! echo "<dt>Details:</dt><dd><pre>"; ! echo $details; ! echo "</pre></dd>\n"; ! echo "<dt>Specifics:</dt><dd><pre>"; ! echo $specifics; ! echo "</pre></dd>\n"; ! echo "<dt>Backtrace:</dt><dd><pre>"; ! debug_print_backtrace(); ! echo "</pre></dd>\n"; ! echo "</dl>"; ! echo "</div>"; ! } else { ! // Notify the appropriate local contact ! mail($mailnotify, "$error in $file on line $line", "Error Description: $error in $file on line $line ! ! There is additional information regarding this bug stored on ! the openFIRST Bugzilla Server at: ! ! http://bugzilla.openfirst.org/", "From: $mailfrom"); ! ! // Attempt to contact the openFIRST Bugzilla Server ! $bugzilla = fopen( "http://bugzilla.openfirst.org/openfirst/". ! "?module=$currentmodule". ! "&uri=" . urlencode($_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]). ! "&details=".urlencode($details). ! "&specifics=".urlencode($specifics) . ! ($NO_ADD_BUG ? "&no-commit=true" : ""), "r"); ! ! if(! $bugzilla) { ! // If a connection cannot be established to the Bugzilla server ! echo("Could not contact the openFIRST Bugzilla server."); ! echo("<h3><strong>$errno</strong> - <strong>$error</strong> in ! <strong>$file</strong> on line <strong>$line</strong></h3> ! <p><strong>The openFIRST system has encountered an error. This ! may be due to a misconfiguration on the behalf of the person installing it, ! or an error in the openFIRST code.</strong></p> ! <p>Debugging may be disabled by removing (config/functions/debug.php)"); ! ! } else { ! // If a connection is established to the Bugzilla server then rely ! // completely on it for the appropriate error message to show. ! while(!feof($bugzilla)) { ! $line = fgets($bugzilla, 2048); ! echo $line; ! } ! } ! } ! } ! ?> |