php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch Add_timestamp_to_mail.log--probably_could_be_better_if_I_knew_any_php_internals for Mail related Bug #52126

Patch version 2010-06-19 20:27 UTC

Return to Bug #52126 | Download this patch
Patch Revisions:

Developer: mark@msapiro.net

--- ./ext/standard/mail.c.orig	2010-02-04 16:19:32.000000000 -0800
+++ ./ext/standard/mail.c	2010-06-19 11:08:32.000000000 -0700
@@ -21,6 +21,7 @@
 #include <stdlib.h>
 #include <ctype.h>
 #include <stdio.h>
+#include <time.h>
 #include "php.h"
 #include "ext/standard/info.h"
 #include "ext/standard/php_string.h"
@@ -217,7 +218,12 @@
 
 	if (mail_log) {
 		char *tmp;
-		int l = spprintf(&tmp, 0, "mail() on [%s:%d]: To: %s -- Headers: %s\n", zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), to, hdr ? hdr : "");
+		time_t tm;
+		char buf[26];
+		tm = time(NULL);
+		ctime_r(&tm, buf);
+                buf[20] = '\0';
+		int l = spprintf(&tmp, 0, "%smail() on [%s:%d]: To: %s -- Headers: %s\n", buf, zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), to, hdr ? hdr : "");
 		php_stream *stream = php_stream_open_wrapper(mail_log, "a", IGNORE_URL_WIN | REPORT_ERRORS | STREAM_DISABLE_OPEN_BASEDIR, NULL);
 
 		if (hdr) { /* find all \r\n instances and replace them with spaces, so a log line is always one line long */ 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 04:01:38 2024 UTC