Commit
…s script is intended to be used same as common.inc.php, but at the end of each script. Signed-off-by: Dhananjay Nakrani <dhananjaynakrani@gmail.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/** | ||
* block attempts to directly run this script | ||
*/ | ||
if (getcwd() == dirname(__FILE__)) { | ||
die('Attack stopped'); | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
JayNakrani
Author
Owner
|
||
|
||
/** if there were any errors currently write them to a log file. | ||
* Later it will be changed to submit them to the error reporting server. | ||
*/ | ||
if($GLOBALS['error_handler']->hasErrors()) { | ||
// then log them in a local file. | ||
$path = "./pma_error_log.txt"; | ||
$fp = fopen($path, "w"); | ||
This comment has been minimized.
Sorry, something went wrong.
nijel
|
||
|
||
// for each errors in the list | ||
foreach($GLOBALS['error_handler']->getCurrentErrors() as $errObj ) { | ||
/** | ||
* Following check is to avoid error reported by PMA_warnMissingExtension(); | ||
* | ||
*/ | ||
if ($errObj->getLine() && $errObj->getType()) { | ||
$str = "\n\n".$errObj->getFile() . "(#" . $errObj->getLine() . ")\n\t". $errObj->getTitle(); | ||
// for stack trace | ||
// ------------------------------------------------------------------------------------------ | ||
$backtrace = $errObj->getBacktrace(); | ||
$error_str= ""; | ||
foreach($backtrace as $i=>$stack_frame) | ||
{ | ||
$error_str .= "\n \t\t\t Frame[".$i."]: \tfile:".$stack_frame["file"]."\tline:".$stack_frame["line"]."\tfunction:".$stack_frame["function"]."("; | ||
foreach($stack_frame["args"] as $j=>$arg) | ||
{ | ||
if($j != 0) | ||
{ | ||
$error_str .= ", "; | ||
} | ||
|
||
$error_str .= "arg[".$j."] = ".$arg; | ||
} | ||
$error_str .= ")"; | ||
|
||
if($i >= 5) // MAX 5 of stack frames. | ||
{ | ||
break; | ||
} | ||
} | ||
// ------------------------------------------------------------------------------------------ | ||
$retVal = fwrite ($fp , $str); | ||
$retVal = fwrite ($fp , $error_str); | ||
} | ||
} | ||
fclose($fp); | ||
} | ||
?> |
3 comments
on commit 7bdad8e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
common_error_reporting.inc.php
is supposed to be included at the end of every php scripts the same way common.inc.php
is included at the beginning. common.inc.php
already does the initialization of the error handler and everything. And that's why all the errors occurred during the php script execution are stored in an object of PMA_Error_Handler
pointed by $GLOBALS['error_handler']
.
At the end, simple inclusion of common_error_reporting.inc.php
script will report all the stored errors. Currently it dumps them to a local log file named pma_error_log.txt
which will not be needed in the actual code and hence will be removed shortly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit is using tab character for indentation instead of spaces, what is mandated by phpMyAdmin. Please check our Developer guidelines for more information.
Offending files: libraries/common_error_reporting.inc.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit contains trailing whitespace, what is prohibited in phpMyAdmin. Please check our Developer guidelines for more information.
Offending files: libraries/common_error_reporting.inc.php
Please use the standard way we use in other libraries (if(defined('PHPMYADMIN'))...)