--- php-5.3.1/ext/oci8/oci8.c	2009-10-09 16:44:43.000000000 +0200
+++ active-3.1/ext/oci8/oci8.c	2009-12-02 15:57:34.000000000 +0100
@@ -12,7 +12,7 @@
    | obtain it through the world-wide-web, please send a note to          |
    | license@php.net so we can mail you a copy immediately.               |
    +----------------------------------------------------------------------+
-   | Authors: Stig Sęther Bakken <ssb@php.net>                            |
+   | Authors: Stig S?ther Bakken <ssb@php.net>                            |
    |          Thies C. Arntzen <thies@thieso.net>                         |
    |          Maxim Maletsky <maxim@maxim.cx>                             |
    |                                                                      |
@@ -1768,7 +1768,7 @@
 		smart_str_append_unsigned_ex(&hashed_details, charsetid_nls_lang, 0);
 	}
 
-	timestamp = time(NULL);
+	timestamp = sapi_get_request_time(TSRMLS_C);
 
 	smart_str_append_unsigned_ex(&hashed_details, session_mode, 0);
 	smart_str_0(&hashed_details);
@@ -2213,7 +2213,7 @@
 {
 	int result = 0;
 	zend_bool in_call_save = OCI_G(in_call);
-	time_t timestamp = time(NULL);
+	time_t timestamp = sapi_get_request_time(TSRMLS_C);
 
 	if (connection->is_stub) {
 		return 0;
@@ -2527,7 +2527,7 @@
 	time_t timestamp;
 	php_oci_connection *connection;
 
-	timestamp = time(NULL);
+	timestamp = sapi_get_request_time(TSRMLS_C);
 
 	/* Persistent connection stubs are also counted as they have private session pools */
 	if (le->type == le_pconnection) {
@@ -2886,7 +2886,7 @@
 #if (OCI_MAJOR_VERSION > 10)
 	ub4 purity = -2;				/* Illegal value to initialize */
 #endif
-	time_t timestamp = time(NULL);
+	time_t timestamp = sapi_get_request_time(TSRMLS_C);
 	ub4 statement_cache_size = (OCI_G(statement_cache_size) > 0) ? OCI_G(statement_cache_size) : 0;
 
 	/* Persistent connections have private session pools */
@@ -3103,7 +3103,7 @@
 	}
 
 	if (OCI_G(ping_interval) >= 0) {
-		time_t timestamp = time(NULL);
+		time_t timestamp = sapi_get_request_time(TSRMLS_C);
 		*next_pingp = timestamp + OCI_G(ping_interval);
 	} else {
 		*next_pingp = 0;
--- php-5.3.1/ext/sqlite/sess_sqlite.c	2008-12-31 12:15:49.000000000 +0100
+++ active-3.1/ext/sqlite/sess_sqlite.c	2009-12-02 15:58:51.000000000 +0100
@@ -144,7 +144,7 @@
 	int binlen;
 	int rv;
 	
-	t = time(NULL);
+	t = sapi_get_request_time(TSRMLS_C);
 
 	binary = safe_emalloc(1 + vallen / 254, 257, 3);
 	binlen = sqlite_encode_binary((const unsigned char*)val, vallen, binary);
@@ -173,7 +173,7 @@
 {
 	PS_SQLITE_DATA;
 	int rv;
-	time_t t = time(NULL);
+	time_t t = sapi_get_request_time(TSRMLS_C);
 
 	rv = sqlite_exec_printf(db, 
 			"DELETE FROM session_data WHERE (%d - updated) > %d", 
--- php-5.3.1/ext/ftp/ftp.c	2009-10-09 16:20:17.000000000 +0200
+++ active-3.1/ext/ftp/ftp.c	2009-12-02 15:59:45.000000000 +0100
@@ -1010,7 +1010,7 @@
 	tm.tm_isdst = -1;
 
 	/* figure out the GMT offset */
-	stamp = time(NULL);
+	stamp = sapi_get_request_time(TSRMLS_C);
 	gmt = php_gmtime_r(&stamp, &tmbuf);
 	if (!gmt) {
 		return -1;
--- php-5.3.1/ext/calendar/cal_unix.c	2008-12-31 12:15:49.000000000 +0100
+++ active-3.1/ext/calendar/cal_unix.c	2009-12-02 16:00:19.000000000 +0100
@@ -36,7 +36,7 @@
 	}	
 
 	if (!ts) {
-		ts = time(NULL);
+		ts = sapi_get_request_time(TSRMLS_C);
 	} else if (ts < 0) {
 		RETURN_FALSE;
 	}
--- php-5.3.1/ext/standard/filestat.c	2008-12-31 12:15:49.000000000 +0100
+++ active-3.1/ext/standard/filestat.c	2009-12-02 16:01:08.000000000 +0100
@@ -665,7 +665,7 @@
 #ifdef HAVE_UTIME_NULL
 			newtime = NULL;
 #else
-			newtime->modtime = newtime->actime = time(NULL);
+			newtime->modtime = newtime->actime = sapi_get_request_time(TSRMLS_C);
 #endif
 			break;
 		case 2:
--- php-5.3.1/ext/standard/head.c	2009-07-29 15:44:16.000000000 +0200
+++ active-3.1/ext/standard/head.c	2009-12-02 16:02:38.000000000 +0100
@@ -117,7 +117,7 @@
 		 * so in order to force cookies to be deleted, even on MSIE, we
 		 * pick an expiry date 1 year and 1 second in the past
 		 */
-		time_t t = time(NULL) - 31536001;
+		time_t t = sapi_get_request_time(TSRMLS_C) - 31536001;
 		dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, t, 0 TSRMLS_CC);
 		snprintf(cookie, len + 100, "Set-Cookie: %s=deleted; expires=%s", name, dt);
 		efree(dt);
--- php-5.3.1/ext/standard/info.c	2009-10-09 19:15:46.000000000 +0200
+++ active-3.1/ext/standard/info.c	2009-12-02 16:03:19.000000000 +0100
@@ -1298,7 +1298,7 @@
 	time_t the_time;
 	struct tm *ta, tmbuf;
 
-	the_time = time(NULL);
+	the_time = sapi_get_request_time(TSRMLS_C);
 	ta = php_localtime_r(&the_time, &tmbuf);
 
 	if (ta && (ta->tm_mon==3) && (ta->tm_mday==1)) {
--- php-5.3.1/ext/standard/ftp_fopen_wrapper.c	2008-12-31 12:15:49.000000000 +0100
+++ active-3.1/ext/standard/ftp_fopen_wrapper.c	2009-12-02 16:03:57.000000000 +0100
@@ -823,7 +823,7 @@
 		tm.tm_isdst = -1;
 
 		/* figure out the GMT offset */
-		stamp = time(NULL);
+		stamp = sapi_get_request_time(TSRMLS_C);
 		gmt = php_gmtime_r(&stamp, &tmbuf);
 		if (!gmt) {
 			goto mdtm_error;
--- php-5.3.1/ext/date/php_date.c	2009-10-27 11:41:45.000000000 +0100
+++ active-3.1/ext/date/php_date.c	2009-12-02 16:07:36.000000000 +0100
@@ -774,7 +774,7 @@
  *   "All date-times in RSS conform to the Date and Time Specification of RFC 822,
  *   with the exception that the year may be expressed with two characters or four characters (four preferred)"
  */
-	REGISTER_STRING_CONSTANT("DATE_RSS",     DATE_FORMAT_RFC1123, CONST_CS | CONST_PERSISTENT);
+	REGISTER_STRING_CONSTANT("DATE_RSS",     DATE_FORMAT_RFC822, CONST_CS | CONST_PERSISTENT);
 	REGISTER_STRING_CONSTANT("DATE_W3C",     DATE_FORMAT_RFC3339, CONST_CS | CONST_PERSISTENT);
 
 	REGISTER_LONG_CONSTANT("SUNFUNCS_RET_TIMESTAMP", SUNFUNCS_RET_TIMESTAMP, CONST_CS | CONST_PERSISTENT);
@@ -874,7 +874,7 @@
 		time_t     the_time;
 		char      *tzid = NULL;
 		
-		the_time = time(NULL);
+		the_time = sapi_get_request_time(TSRMLS_C);
 		ta = php_localtime_r(&the_time, &tmbuf);
 		if (ta) {
 			tzid = timelib_timezone_id_from_abbr(ta->tm_zone, ta->tm_gmtoff, ta->tm_isdst);
@@ -1032,7 +1032,7 @@
 			offset->offset = (t->z) * -60;
 			offset->leap_secs = 0;
 			offset->is_dst = 0;
-			offset->abbr = malloc(9); /* GMT±xxxx\0 */
+			offset->abbr = malloc(9); /* GMT?xxxx\0 */
 			snprintf(offset->abbr, 9, "GMT%c%02d%02d", 
 			                          localtime ? ((offset->offset < 0) ? '-' : '+') : '+',
 			                          localtime ? abs(offset->offset / 3600) : 0,
@@ -1172,7 +1172,7 @@
 		RETURN_FALSE;
 	}
 	if (ZEND_NUM_ARGS() == 1) {
-		ts = time(NULL);
+		ts = sapi_get_request_time(TSRMLS_C);
 	}
 
 	string = php_format_date(format, format_len, ts, localtime TSRMLS_CC);
@@ -1241,7 +1241,7 @@
 			offset->offset = (t->z - (t->dst * 60)) * -60;
 			offset->leap_secs = 0;
 			offset->is_dst = t->dst;
-			offset->abbr = malloc(9); /* GMT±xxxx\0 */
+			offset->abbr = malloc(9); /* GMT?xxxx\0 */
 			snprintf(offset->abbr, 9, "GMT%c%02d%02d", 
 			                          !localtime ? ((offset->offset < 0) ? '-' : '+') : '+',
 			                          !localtime ? abs(offset->offset / 3600) : 0,
@@ -1338,7 +1338,7 @@
 	}
 
 	if (ZEND_NUM_ARGS() == 1) {
-		ts = time(NULL);
+		ts = sapi_get_request_time(TSRMLS_C);
 	}
 
 	ret = php_idate(format[0], ts, 0);
@@ -1413,7 +1413,7 @@
 		now = timelib_time_ctor();
 		now->tz_info = tzi;
 		now->zone_type = TIMELIB_ZONETYPE_ID;
-		timelib_unixtime2local(now, (timelib_sll) time(NULL));
+		timelib_unixtime2local(now, (timelib_sll) sapi_get_request_time(TSRMLS_C));
 	} else {
 		RETURN_FALSE;
 	}
@@ -1457,12 +1457,12 @@
 	/* Initialize structure with current time */
 	now = timelib_time_ctor();
 	if (gmt) {
-		timelib_unixtime2gmt(now, (timelib_sll) time(NULL));
+		timelib_unixtime2gmt(now, (timelib_sll) sapi_get_request_time(TSRMLS_C));
 	} else {
 		tzi = get_timezone_info(TSRMLS_C);
 		now->tz_info = tzi;
 		now->zone_type = TIMELIB_ZONETYPE_ID;
-		timelib_unixtime2local(now, (timelib_sll) time(NULL));
+		timelib_unixtime2local(now, (timelib_sll) sapi_get_request_time(TSRMLS_C));
 	}
 	/* Fill in the new data */
 	switch (ZEND_NUM_ARGS()) {
@@ -1582,7 +1582,7 @@
 	timelib_tzinfo      *tzi;
 	timelib_time_offset *offset = NULL;
 
-	timestamp = (long) time(NULL);
+	timestamp = (long) sapi_get_request_time(TSRMLS_C);
 
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &format, &format_len, &timestamp) == FAILURE) {
 		RETURN_FALSE;
@@ -1674,7 +1674,7 @@
    Return current UNIX timestamp */
 PHP_FUNCTION(time)
 {
-	RETURN_LONG((long)time(NULL));
+	RETURN_LONG((long)sapi_get_request_time(TSRMLS_C));
 }
 /* }}} */
 
@@ -1682,7 +1682,7 @@
    Returns the results of the C system call localtime as an associative array if the associative_array argument is set to 1 other wise it is a regular array */
 PHP_FUNCTION(localtime)
 {
-	long timestamp = (long)time(NULL);
+	long timestamp = (long)sapi_get_request_time(TSRMLS_C);
 	zend_bool associative = 0;
 	timelib_tzinfo *tzi;
 	timelib_time   *ts;
@@ -1729,7 +1729,7 @@
    Get date/time information */
 PHP_FUNCTION(getdate)
 {
-	long timestamp = (long)time(NULL);
+	long timestamp = (long)sapi_get_request_time(TSRMLS_C);
 	timelib_tzinfo *tzi;
 	timelib_time   *ts;
 
@@ -1954,7 +1954,7 @@
 	REGISTER_DATE_CLASS_CONST_STRING("RFC1123", DATE_FORMAT_RFC1123);
 	REGISTER_DATE_CLASS_CONST_STRING("RFC2822", DATE_FORMAT_RFC2822);
 	REGISTER_DATE_CLASS_CONST_STRING("RFC3339", DATE_FORMAT_RFC3339);
-	REGISTER_DATE_CLASS_CONST_STRING("RSS",     DATE_FORMAT_RFC1123);
+	REGISTER_DATE_CLASS_CONST_STRING("RSS",     DATE_FORMAT_RFC822);
 	REGISTER_DATE_CLASS_CONST_STRING("W3C",     DATE_FORMAT_RFC3339);
 
 
@@ -2427,7 +2427,7 @@
 			now->tz_abbr = new_abbr;
 			break;
 	}
-	timelib_unixtime2local(now, (timelib_sll) time(NULL));
+	timelib_unixtime2local(now, (timelib_sll) sapi_get_request_time(TSRMLS_C));
 
 	timelib_fill_holes(dateobj->time, now, TIMELIB_NO_CLONE);
 	timelib_update_ts(dateobj->time, tzi);
--- php-5.3.1/ext/phar/tar.c	2009-11-12 18:43:23.000000000 +0100
+++ active-3.1/ext/phar/tar.c	2009-12-02 16:09:05.000000000 +0100
@@ -914,7 +914,7 @@
 	char *buf, *signature, sigbuf[8];
 
 	entry.flags = PHAR_ENT_PERM_DEF_FILE;
-	entry.timestamp = time(NULL);
+	entry.timestamp = sapi_get_request_time(TSRMLS_C);
 	entry.is_modified = 1;
 	entry.is_crc_checked = 1;
 	entry.is_tar = 1;
--- php-5.3.1/ext/phar/zip.c	2009-07-26 03:03:47.000000000 +0200
+++ active-3.1/ext/phar/zip.c	2009-12-02 16:09:51.000000000 +0100
@@ -126,7 +126,7 @@
 	struct tm *tm, tmbuf;
 	time_t now;
 
-	now = time(NULL);
+	now = sapi_get_request_time(TSRMLS_C);
 	tm = php_localtime_r(&now, &tmbuf);
 
 	tm->tm_year = ((ddate>>9)&127) + 1980 - 1900;
@@ -1178,7 +1178,7 @@
 
 	pass.error = &temperr;
 	entry.flags = PHAR_ENT_PERM_DEF_FILE;
-	entry.timestamp = time(NULL);
+	entry.timestamp = sapi_get_request_time(TSRMLS_C);
 	entry.is_modified = 1;
 	entry.is_zip = 1;
 	entry.phar = phar;
--- php-5.3.1/ext/phar/phar.c	2009-07-26 03:03:47.000000000 +0200
+++ active-3.1/ext/phar/phar.c	2009-12-02 16:10:21.000000000 +0100
@@ -3031,7 +3031,7 @@
 			4: metadata-len
 			+: metadata
 		*/
-		mytime = time(NULL);
+		mytime = sapi_get_request_time(TSRMLS_C);
 		phar_set_32(entry_buffer, entry->uncompressed_filesize);
 		phar_set_32(entry_buffer+4, mytime);
 		phar_set_32(entry_buffer+8, entry->compressed_filesize);
--- php-5.3.1/sapi/cgi/cgi_main.c	2009-10-20 14:57:44.000000000 +0200
+++ active-3.1/sapi/cgi/cgi_main.c	2009-12-02 16:23:09.000000000 +0100
@@ -680,6 +680,16 @@
 	}
 }
 
+static time_t sapi_cgi_request_time(TSRMLS_D)
+{
+	char *rq_time = sapi_cgibin_getenv("RAW_TIME", sizeof("RAW_TIME") - 1 TSRMLS_CC);
+	if (rq_time) {
+		return atol(rq_time);
+	} else {
+		return 0;
+	}
+}
+
 static void sapi_cgi_log_message(char *message)
 {
 	TSRMLS_FETCH();
@@ -907,7 +917,7 @@
 
 	sapi_cgi_register_variables,	/* register server variables */
 	sapi_cgi_log_message,			/* Log message */
-	NULL,							/* Get request time */
+	sapi_cgi_request_time,			/* Get request time */
 	NULL,							/* Child terminate */
 
 	STANDARD_SAPI_MODULE_PROPERTIES
