]> granicus.if.org Git - php/commitdiff
added an option mbstring.func_overload to overload some function by multibyte enabled...
authorRui Hirokawa <hirokawa@php.net>
Sun, 16 Dec 2001 22:58:24 +0000 (22:58 +0000)
committerRui Hirokawa <hirokawa@php.net>
Sun, 16 Dec 2001 22:58:24 +0000 (22:58 +0000)
ext/mbstring/mbstring.c
ext/mbstring/mbstring.h

index cfca15cd41761675feee1fde57e1b7f9f6786aa3..7c3547876178b24b14ac6c95a56938a27fa3abe5 100644 (file)
@@ -373,11 +373,12 @@ static PHP_INI_MH(OnUpdate_mbstring_substitute_character)
 
 /* php.ini directive registration */
 PHP_INI_BEGIN()
-       PHP_INI_ENTRY("mbstring.detect_order", NULL, PHP_INI_ALL, OnUpdate_mbstring_detect_order)
-       PHP_INI_ENTRY("mbstring.http_input", NULL, PHP_INI_ALL, OnUpdate_mbstring_http_input)
-       PHP_INI_ENTRY("mbstring.http_output", NULL, PHP_INI_ALL, OnUpdate_mbstring_http_output)
-       PHP_INI_ENTRY("mbstring.internal_encoding", NULL, PHP_INI_ALL, OnUpdate_mbstring_internal_encoding)
-       PHP_INI_ENTRY("mbstring.substitute_character", NULL, PHP_INI_ALL, OnUpdate_mbstring_substitute_character)
+        PHP_INI_ENTRY("mbstring.detect_order", NULL, PHP_INI_ALL, OnUpdate_mbstring_detect_order)
+        PHP_INI_ENTRY("mbstring.http_input", NULL, PHP_INI_ALL, OnUpdate_mbstring_http_input)
+        PHP_INI_ENTRY("mbstring.http_output", NULL, PHP_INI_ALL, OnUpdate_mbstring_http_output)
+        PHP_INI_ENTRY("mbstring.internal_encoding", NULL, PHP_INI_ALL, OnUpdate_mbstring_internal_encoding)
+        PHP_INI_ENTRY("mbstring.substitute_character", NULL, PHP_INI_ALL, OnUpdate_mbstring_substitute_character)
+        STD_PHP_INI_ENTRY("mbstring.func_overload", "0", PHP_INI_SYSTEM, OnUpdateInt, func_overload, zend_mbstring_globals, mbstring_globals)
 PHP_INI_END()
 
 
@@ -406,6 +407,8 @@ php_mbstring_init_globals(zend_mbstring_globals *pglobals)
        pglobals->filter_illegal_substchar = 0x3f;      /* '?' */
        pglobals->current_filter_illegal_mode = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR;
        pglobals->current_filter_illegal_substchar = 0x3f;      /* '?' */
+       pglobals->func_overload = 0;
+       pglobals->orig_mail = (zend_function *)NULL;
        pglobals->outconv = NULL;
 }
 
@@ -467,6 +470,18 @@ PHP_RINIT_FUNCTION(mbstring)
                }
        }
 
+       /* override original mail() function with mb_send_mail(). */
+       if ((MBSTRG(func_overload) & MB_OVERLOAD_MAIL) == MB_OVERLOAD_MAIL &&
+               !MBSTRG(orig_mail)){ 
+               zend_hash_find(EG(function_table), "mb_send_mail", sizeof("mb_send_mail"), (void **)&func);
+               zend_hash_find(EG(function_table), "mail", sizeof("mail"), (void **)&MBSTRG(orig_mail));
+               if (zend_hash_del(EG(function_table), "mail",sizeof("mail")) != FAILURE) {
+                       zend_hash_add(EG(function_table), "mail",sizeof("mail"),func, sizeof(zend_function), NULL);
+               } else {
+                       zend_error(E_ERROR, "mbtring couldn't replace mail().");
+               }
+       }
+
        return SUCCESS;
 }
 
index 26321117406b33a746ac0164295174616b02c266..56cc557d9d1eec4d0714a6f934786f5aef0e6342 100644 (file)
@@ -55,6 +55,8 @@
 
 #include "mbfilter.h"
 
+#define MB_OVERLOAD_MAIL 1
+
 extern zend_module_entry mbstring_module_entry;
 #define mbstring_module_ptr &mbstring_module_entry
 
@@ -113,6 +115,8 @@ ZEND_BEGIN_MODULE_GLOBALS(mbstring)
        int filter_illegal_substchar;
        int current_filter_illegal_mode;
        int current_filter_illegal_substchar;
+       int func_overload;
+       zend_function *orig_mail;
        mbfl_buffer_converter *outconv;
 ZEND_END_MODULE_GLOBALS(mbstring);