--- php-4.3.0/ext/standard/mail.c.orig Fri Nov 29 12:15:43 2002 +++ php-4.3.0/ext/standard/mail.c Thu Jan 2 12:37:54 2003 @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include "php.h" #include "ext/standard/info.h" @@ -36,6 +38,9 @@ #include "safe_mode.h" #include "exec.h" +#include "zend_operators.h" +#include "zend_globals.h" + #if HAVE_SENDMAIL #ifdef PHP_WIN32 #include "win32/sendmail.h" @@ -196,8 +201,42 @@ return 0; } #endif - fprintf(sendmail, "To: %s\n", to); - fprintf(sendmail, "Subject: %s\n", subject); + TSRMLS_FETCH(); + + if ((to != NULL) && (strlen(to)!=0)) { + fprintf(sendmail, "To: %s\n", to); + } + if ((subject != NULL) && (strlen(subject)!=0)) { + fprintf(sendmail, "Subject: %s\n", subject); + } + + if (PG(http_globals)[TRACK_VARS_SERVER]) { + zval **remote_addr, **server_name, **server_port, + **request_uri, **http_user_agent; + + if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "REMOTE_ADDR", sizeof("REMOTE_ADDR"), (void **) &remote_addr)==SUCCESS) { + convert_to_string_ex(remote_addr); + fprintf(sendmail, "HTTP-Posting-Client: %s\n", Z_STRVAL_PP(remote_addr)); + } + if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name)==SUCCESS) { + convert_to_string_ex(server_name); + fprintf(sendmail, "HTTP-Posting-URI: %s", Z_STRVAL_PP(server_name)); + if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_PORT", sizeof("SERVER_PORT"), (void **) &server_port)==SUCCESS) { + convert_to_string_ex(server_port); + fprintf(sendmail, ":%s", Z_STRVAL_PP(server_port)); + } + if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "REQUEST_URI", sizeof("REQUEST_URI"), (void **) &request_uri)==SUCCESS) { + convert_to_string_ex(request_uri); + fprintf(sendmail, "%s", Z_STRVAL_PP(request_uri)); + } + fprintf(sendmail, "\n"); + } + if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"), (void **) &http_user_agent)==SUCCESS) { + convert_to_string_ex(http_user_agent); + fprintf(sendmail, "HTTP-Posting-User-Agent: %s\n", Z_STRVAL_PP(http_user_agent)); + } + } + if (headers != NULL) { fprintf(sendmail, "%s\n", headers); }