Is it possible to override internal function?

php.internals

Piotr Roszatycki

21 years ago
I'd like to create PECL module which could replace mail() function. The new function would use SMTP protocol. I can't call any external utilities so this is the only posibility to send the mails. The environment is shared hosting platform so there are some limits, like forbidding the calling suid-ed binaries (like /usr/sbin/sendmail) and low number of user processes. This have to be hidden implementation so the users won't need to change their code, especially calling of mail() function. Is it possible to override the internal function in additional module?
-- .''`. Piotr Roszatycki, Netia SA : :' : mailto:Piotr_Roszatycki@netia.net.pl `. `' mailto:dexter@debian.org `-

Johannes Schlueter

21 years ago
Hi, the funxtions are stored in the EG(function_table) hash table. So you could delete or rename the mail function from there and add a new one. APD has an override_function() and a rename_function() which can be used to replace/rename a function by a user defined one. Maybe the code of these help you a bit. http://lxr.php.net/source/pecl/apd/php_apd.c#608 For this being successfull it's important that your extension is loaded after the standard extension. Even though this works I doubt that you can can rely on it. (stability, changing APIs, ...) johannes Piotr Roszatycki wrote:
> I'd like to create PECL module which could replace mail() function. The > new function would use SMTP protocol. I can't call any external utilities > so this is the only posibility to send the mails. The environment is > shared hosting platform so there are some limits, like forbidding the > calling suid-ed binaries (like /usr/sbin/sendmail) and low number of user > processes. > > This have to be hidden implementation so the users won't need to change > their code, especially calling of mail() function. > > Is it possible to override the internal function in additional module? >
-- Johannes Schlüter Mayflower GmbH / ThinkPHP http://thinkphp.de http://blog.thinkphp.de