sniper Sun Aug 7 18:06:29 2005 EDT Modified files: /php-src/ext/imap php_imap.c /php-src/ext/standard mail.c /php-src/win32 sendmail.c sendmail.h Log: - Fixed bug #29334 (mail() provides incorrect message time header)
http://cvs.php.net/diff.php/php-src/ext/imap/php_imap.c?r1=1.207&r2=1.208&ty=u Index: php-src/ext/imap/php_imap.c diff -u php-src/ext/imap/php_imap.c:1.207 php-src/ext/imap/php_imap.c:1.208 --- php-src/ext/imap/php_imap.c:1.207 Wed Aug 3 10:07:16 2005 +++ php-src/ext/imap/php_imap.c Sun Aug 7 18:06:27 2005 @@ -26,7 +26,7 @@ | PHP 4.0 updates: Zeev Suraski <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: php_imap.c,v 1.207 2005/08/03 14:07:16 sniper Exp $ */ +/* $Id: php_imap.c,v 1.208 2005/08/07 22:06:27 sniper Exp $ */ #define IMAP41 @@ -3346,7 +3346,7 @@ strcat(bufferHeader, headers); } - if (TSendMail(INI_STR("SMTP"), &tsm_err, &tsm_errmsg, bufferHeader, subject, bufferTo, message, bufferCc, bufferBcc, rpath) != SUCCESS) { + if (TSendMail(INI_STR("SMTP"), &tsm_err, &tsm_errmsg, bufferHeader, subject, bufferTo, message, bufferCc, bufferBcc, rpath TSRMLS_CC) != SUCCESS) { if (tsm_errmsg) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", tsm_errmsg); efree(tsm_errmsg); http://cvs.php.net/diff.php/php-src/ext/standard/mail.c?r1=1.86&r2=1.87&ty=u Index: php-src/ext/standard/mail.c diff -u php-src/ext/standard/mail.c:1.86 php-src/ext/standard/mail.c:1.87 --- php-src/ext/standard/mail.c:1.86 Wed Aug 3 10:08:08 2005 +++ php-src/ext/standard/mail.c Sun Aug 7 18:06:28 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mail.c,v 1.86 2005/08/03 14:08:08 sniper Exp $ */ +/* $Id: mail.c,v 1.87 2005/08/07 22:06:28 sniper Exp $ */ #include <stdlib.h> #include <ctype.h> @@ -185,7 +185,7 @@ if (!sendmail_path) { #if (defined PHP_WIN32 || defined NETWARE) /* handle old style win smtp sending */ - if (TSendMail(INI_STR("SMTP"), &tsm_err, &tsm_errmsg, headers, subject, to, message, NULL, NULL, NULL) == FAILURE) { + if (TSendMail(INI_STR("SMTP"), &tsm_err, &tsm_errmsg, headers, subject, to, message, NULL, NULL, NULL TSRMLS_CC) == FAILURE) { if (tsm_errmsg) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", tsm_errmsg); efree(tsm_errmsg); http://cvs.php.net/diff.php/php-src/win32/sendmail.c?r1=1.64&r2=1.65&ty=u Index: php-src/win32/sendmail.c diff -u php-src/win32/sendmail.c:1.64 php-src/win32/sendmail.c:1.65 --- php-src/win32/sendmail.c:1.64 Thu Jul 28 05:44:13 2005 +++ php-src/win32/sendmail.c Sun Aug 7 18:06:29 2005 @@ -17,7 +17,7 @@ * */ -/* $Id: sendmail.c,v 1.64 2005/07/28 09:44:13 hyanantha Exp $ */ +/* $Id: sendmail.c,v 1.65 2005/08/07 22:06:29 sniper Exp $ */ #include "php.h" /*php specific */ #include <stdio.h> @@ -42,23 +42,15 @@ #include "ext/pcre/php_pcre.h" #endif -#include "ext/standard/php_string.h" +#include "ext/standard/php_string.h" +#include "ext/date/php_date.h" -/* - extern int _daylight; - extern long _timezone; - */ /*enum { DO_CONNECT = WM_USER +1 }; */ -static char *days[] = -{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; -static char *months[] = -{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - /* '*error_message' has to be passed around from php_mail() */ #define SMTP_ERROR_RESPONSE_SPEC "SMTP server response: %s" /* Convinient way to handle error messages from the SMTP server. @@ -98,8 +90,6 @@ char *php_mailer = "PHP 4 NetWare"; #endif /* NETWARE */ -char *get_header(char *h, char *headers); - /* Error messages */ static char *ErrorMessages[] = { @@ -220,13 +210,12 @@ //********************************************************************/ PHPAPI int TSendMail(char *host, int *error, char **error_message, char *headers, char *Subject, char *mailTo, char *data, - char *mailCc, char *mailBcc, char *mailRPath) + char *mailCc, char *mailBcc, char *mailRPath TSRMLS_DC) { int ret; char *RPath = NULL; char *headers_lc = NULL; /* headers_lc is only created if we've a header at all */ char *pos1 = NULL, *pos2 = NULL; - TSRMLS_FETCH(); #ifndef NETWARE WinsockStarted = FALSE; @@ -311,7 +300,7 @@ MailHost, !INI_INT("smtp_port") ? 25 : INI_INT("smtp_port")); return FAILURE; } else { - ret = SendText(RPath, Subject, mailTo, mailCc, mailBcc, data, headers, headers_lc, error_message); + ret = SendText(RPath, Subject, mailTo, mailCc, mailBcc, data, headers, headers_lc, error_message TSRMLS_CC); TSMClose(); if (RPath) { efree(RPath); @@ -388,8 +377,8 @@ // Author/Date: jcar 20/9/96 // History: //*******************************************************************/ -int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailBcc, char *data, - char *headers, char *headers_lc, char **error_message) +static int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailBcc, char *data, + char *headers, char *headers_lc, char **error_message TSRMLS_DC) { int res; char *p; @@ -609,9 +598,9 @@ /* send message header */ if (Subject == NULL) { - res = PostHeader(RPath, "No Subject", mailTo, stripped_header); + res = PostHeader(RPath, "No Subject", mailTo, stripped_header TSRMLS_CC); } else { - res = PostHeader(RPath, Subject, mailTo, stripped_header); + res = PostHeader(RPath, Subject, mailTo, stripped_header TSRMLS_CC); } if (stripped_header) { efree(stripped_header); @@ -665,7 +654,8 @@ return (SUCCESS); } -int addToHeader(char **header_buffer, const char *specifier, char *string) { +static int addToHeader(char **header_buffer, const char *specifier, char *string) +{ if (NULL == (*header_buffer = erealloc(*header_buffer, strlen(*header_buffer) + strlen(specifier) + strlen(string) + 1))) { return 0; } @@ -684,16 +674,12 @@ // Author/Date: jcar 20/9/96 // History: //********************************************************************/ -int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders) +static int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders TSRMLS_DC) { - /* Print message header according to RFC 822 */ /* Return-path, Received, Date, From, Subject, Sender, To, cc */ - time_t tNow = time(NULL); - struct tm *tm = localtime(&tNow); - int zoneh = abs(_timezone); - int zonem, res; + int res; char *header_buffer; char *headers_lc = NULL; size_t i; @@ -711,21 +697,13 @@ efree(headers_lc); return OUT_OF_MEMORY; } - zoneh /= (60 * 60); - zonem = (abs(_timezone) / 60) - (zoneh * 60); - if(!xheaders || !strstr(headers_lc, "date:")){ - sprintf(header_buffer, "Date: %s, %02d %s %04d %02d:%02d:%02d %s%02d%02d\r\n", - days[tm->tm_wday], - tm->tm_mday, - months[tm->tm_mon], - tm->tm_year + 1900, - tm->tm_hour, - tm->tm_min, - tm->tm_sec, - (_timezone <= 0) ? "+" : (_timezone > 0) ? "-" : "", - zoneh, - zonem); + if (!xheaders || !strstr(headers_lc, "date:")) { + time_t tNow = time(NULL); + char *dt = php_format_date("r", 1, tNow, 1 TSRMLS_CC); + + sprintf(header_buffer, "Date: %s\r\n", dt); + efree(dt); } if (!headers_lc || !strstr(headers_lc, "from:")) { @@ -781,7 +759,7 @@ // Author/Date: jcar 20/9/96 // History: //********************************************************************/ -int MailConnect() +static int MailConnect() { int res; @@ -822,10 +800,6 @@ } - - - - /********************************************************************* // Name: Post // Input: @@ -834,7 +808,7 @@ // Author/Date: jcar 20/9/96 // History: //********************************************************************/ -int Post(LPCSTR msg) +static int Post(LPCSTR msg) { int len = strlen(msg); int slen; @@ -861,7 +835,7 @@ // Author/Date: jcar 20/9/96 // History: //********************************************************************/ -int Ack(char **server_response) +static int Ack(char **server_response) { static char buf[MAIL_BUFFER_SIZE]; int rlen; @@ -921,7 +895,7 @@ // Author/Date: jcar 20/9/96 // History: //********************************************************************/ -unsigned long GetAddr(LPSTR szHost) +static unsigned long GetAddr(LPSTR szHost) { LPHOSTENT lpstHost; u_long lAddr = INADDR_ANY; http://cvs.php.net/diff.php/php-src/win32/sendmail.h?r1=1.14&r2=1.15&ty=u Index: php-src/win32/sendmail.h diff -u php-src/win32/sendmail.h:1.14 php-src/win32/sendmail.h:1.15 --- php-src/win32/sendmail.h:1.14 Thu Jul 28 05:43:28 2005 +++ php-src/win32/sendmail.h Sun Aug 7 18:06:29 2005 @@ -36,15 +36,15 @@ PHPAPI int TSendMail(char *smtpaddr, int *returnerror, char **error_message, char *RPath, char *Subject, char *mailTo, char *data, - char *mailCc, char *mailBcc, char *mailRPath); + char *mailCc, char *mailBcc, char *mailRPath TSRMLS_DC); PHPAPI void TSMClose(void); -int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailBcc, char *data, - char *headers, char *headers_lc, char **error_message); +static int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char *mailBcc, char *data, + char *headers, char *headers_lc, char **error_message TSRMLS_DC); PHPAPI char *GetSMErrorText(int index); -int MailConnect(); -int PostHeader(char *, char *, char *, char *); -int Post(LPCSTR msg); -int Ack(char **server_response); -unsigned long GetAddr(LPSTR szHost); +static int MailConnect(); +static int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders TSRMLS_DC); +static int Post(LPCSTR msg); +static int Ack(char **server_response); +static unsigned long GetAddr(LPSTR szHost); #endif /* sendmail_h */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php