All pastes #294463 Raw Edit

Miscellany

public text v1 · immutable
#294463 ·published 2006-12-28 14:46 UTC
rendered paste body
+	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 : "");
+		if (headers != NULL) {
+			spprintf(&tmp, 0, "%s\r\nX-PHP-Originating-Script: %ld:%s\r\n", headers, php_getuid(), f);
+		} else {
+			spprintf(&tmp, 0, "X-PHP-Originating-Script: %ld:%s\r\n", php_getuid(), f);
+		}
+		if (hdr) { /* find all \r\n instances and replace them with spaces, so a log line is always one line long */ 
+			char *p = tmp;
+			while ((p = strpbrk(p, "\r\n"))) {
+				*p = ' ';
+			}
+			tmp[l - 1] = '\n';
+		}
+		_php_error_log(3, tmp, mail_log, NULL TSRMLS_CC);
+		efree(tmp);
+	}