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. May 18th, 2012 at 10:34 | #1

    I would like to thank you for the efforts you’ve put in caligraphy this website. I’m hoping the same elevated-degree website column from you in the upcoming as well. Actually your creative caligraphy skills has encouraged me to get my own blog now. Actually the blogging is spreading its wings go hungry. Your scribble up is a profitable example of it.

  1. No trackbacks yet.