]> git.pld-linux.org Git - packages/php.git/blame - php-mail.patch
cleanups
[packages/php.git] / php-mail.patch
CommitLineData
d51e0cbd
ER
1--- php-5.2.0/ext/standard/mail.c 2006-12-01 14:20:27.881416250 +0100
2+++ php-5.2.4/ext/standard/mail.c 2007-08-31 19:25:50.777713042 +0300
5316c927
AF
3@@ -21,6 +21,8 @@
4 #include <stdlib.h>
5 #include <ctype.h>
6 #include <stdio.h>
7+#include <syslog.h>
8+#include <string.h>
9 #include "php.h"
804cfcec 10 #include "ext/standard/info.h"
8135bbee 11
d51e0cbd
ER
12@@ -35,6 +37,8 @@
13 #include "php_ini.h"
804cfcec
AM
14 #include "safe_mode.h"
15 #include "exec.h"
804cfcec 16+#include "zend_operators.h"
804cfcec 17+#include "zend_globals.h"
d51e0cbd 18
804cfcec
AM
19 #ifdef PHP_WIN32
20 #include "win32/sendmail.h"
d51e0cbd 21@@ -107,6 +111,18 @@
16fd5964
ER
22 return;
23 }
24
fa59626a 25+ /* search for To: and Subject: headers which should be specified in proper mail() parameters, not in additional headers */
16fd5964
ER
26+ if (headers != NULL) {
27+ if (strncasecmp(headers, "to:", sizeof("to:") - 1) == 0 || strcasestr(headers, "\nto:")) {
fa59626a
AM
28+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "To: headers aren't allowed in the additional_headers parameter. Use $to parameter for that. Mail not sent.");
29+ RETURN_FALSE;
30+ }
31+ if (strncasecmp(headers, "subject:", sizeof("subject:") - 1) == 0 || strcasestr(headers, "\nsubject:")) {
32+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Subject: headers aren't allowed in the additional_headers parameter. Use $subject parameter for that. Mail not sent.");
16fd5964
ER
33+ RETURN_FALSE;
34+ }
16fd5964
ER
35+ }
36+
37 if (to_len > 0) {
38 to_r = estrndup(to, to_len);
39 for (; to_len; to_len--) {
d51e0cbd 40@@ -231,8 +247,42 @@
8135bbee
JB
41 return 0;
42 }
43 #endif
5316c927
AF
44- fprintf(sendmail, "To: %s\n", to);
45- fprintf(sendmail, "Subject: %s\n", subject);
b9a39e32 46+ TSRMLS_FETCH();
edf77de8 47+
5316c927
AF
48+ if ((to != NULL) && (strlen(to)!=0)) {
49+ fprintf(sendmail, "To: %s\n", to);
50+ }
51+ if ((subject != NULL) && (strlen(subject)!=0)) {
52+ fprintf(sendmail, "Subject: %s\n", subject);
53+ }
544f6151 54+ zend_is_auto_global(ZEND_STRL("_SERVER") TSRMLS_CC);
804cfcec
AM
55+ if (PG(http_globals)[TRACK_VARS_SERVER]) {
56+ zval **remote_addr, **server_name, **server_port,
bfb8a2ed 57+ **script_name, **http_user_agent;
804cfcec
AM
58+
59+ if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "REMOTE_ADDR", sizeof("REMOTE_ADDR"), (void **) &remote_addr)==SUCCESS) {
60+ convert_to_string_ex(remote_addr);
61+ fprintf(sendmail, "HTTP-Posting-Client: %s\n", Z_STRVAL_PP(remote_addr));
62+ }
63+ if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name)==SUCCESS) {
64+ convert_to_string_ex(server_name);
b4e19d31 65+ fprintf(sendmail, "HTTP-Posting-URI: %s", Z_STRVAL_PP(server_name));
804cfcec
AM
66+ if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_PORT", sizeof("SERVER_PORT"), (void **) &server_port)==SUCCESS) {
67+ convert_to_string_ex(server_port);
68+ fprintf(sendmail, ":%s", Z_STRVAL_PP(server_port));
69+ }
18e705dd 70+ if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &script_name)==SUCCESS) {
bfb8a2ed
AM
71+ convert_to_string_ex(script_name);
72+ fprintf(sendmail, "%s", Z_STRVAL_PP(script_name));
804cfcec
AM
73+ }
74+ fprintf(sendmail, "\n");
75+ }
76+ if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"), (void **) &http_user_agent)==SUCCESS) {
77+ convert_to_string_ex(http_user_agent);
78+ fprintf(sendmail, "HTTP-Posting-User-Agent: %s\n", Z_STRVAL_PP(http_user_agent));
79+ }
80+ }
81+
b45729b9
AM
82 if (hdr != NULL) {
83 fprintf(sendmail, "%s\n", hdr);
5316c927 84 }
This page took 0.05666 seconds and 4 git commands to generate.