Home > PHP > PHP - overloading system function, debugging…

PHP - overloading system function, debugging…

January 27th, 2010
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Today I needed to find a file where is called PHP system function, it was to find the place where the email is send. The problem was that the system is huge and messy. There is no wrapper (PHPMailer or something) which will be sending the emails. You will need to install APD, it’s a PECL extension. After that you can overload the mail function and with debug_backtrace get the stacktrace.


// code of the override function
$code=<<<'CODE'
$trace=debug_backtrace();
$caller=array_shift($trace);
echo 'mail() called by '.$caller['function']
if (isset($caller['class']))
echo 'in '.$caller['class'];
CODE;
//install override
override_function('mail', '$to,$subject,$msg,$hdrs,$params', $code);
Share and Bookmark:
  • Digg
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • blogmarks
  • DotNetKicks
  • E-mail this story to a friend!
  • Furl
  • Live
  • Reddit
  • Slashdot
Did you found this article helpful?
Buy me a coffee :)

PHP

  1. No comments yet.
  1. No trackbacks yet.