diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | main/SAPI.c | 13 | ||||
-rw-r--r-- | main/SAPI.h | 3 | ||||
-rw-r--r-- | sapi/apache/mod_php5.c | 9 | ||||
-rw-r--r-- | sapi/apache2filter/sapi_apache2.c | 10 | ||||
-rw-r--r-- | sapi/apache2handler/sapi_apache2.c | 8 |
6 files changed, 43 insertions, 1 deletions
@@ -1,6 +1,7 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2004, PHP 5.1.0 +- Add SAPI hook to get the current request time. (Rasmus) - Fixed bug #29522 (accessing properties without connection) (Georg) - Fixed bug #29335 (fetch functions now use MYSQLI_BOTH as default) (Georg) - Fixed bug #29311 (calling parent constructor in mysqli). (Georg) diff --git a/main/SAPI.c b/main/SAPI.c index b1e3488f06..6836a51a05 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -37,6 +37,9 @@ #ifdef ZTS #include "TSRM.h" #endif +#ifdef HAVE_SYS_TIME_H +#include <sys/time.h> +#endif #include "rfc1867.h" @@ -860,7 +863,6 @@ SAPI_API struct stat *sapi_get_stat(TSRMLS_D) } } - SAPI_API char *sapi_getenv(char *name, size_t name_len TSRMLS_DC) { if (sapi_module.getenv) { @@ -907,6 +909,15 @@ SAPI_API int sapi_get_target_gid(gid_t *obj TSRMLS_DC) } } +SAPI_API time_t sapi_get_request_time(TSRMLS_D) +{ + if (sapi_module.get_request_time) { + return sapi_module.get_request_time(TSRMLS_C); + } else { + if(!SG(global_request_time)) SG(global_request_time) = time(0); + return SG(global_request_time); + } +} /* * Local variables: diff --git a/main/SAPI.h b/main/SAPI.h index d740eb9061..32e69d2e8e 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -122,6 +122,7 @@ typedef struct _sapi_globals_struct { long post_max_size; int options; zend_bool sapi_started; + time_t global_request_time; } sapi_globals_struct; @@ -197,6 +198,7 @@ SAPI_API int sapi_force_http_10(TSRMLS_D); SAPI_API int sapi_get_target_uid(uid_t * TSRMLS_DC); SAPI_API int sapi_get_target_gid(gid_t * TSRMLS_DC); +SAPI_API time_t sapi_get_request_time(TSRMLS_D); END_EXTERN_C() struct _sapi_module_struct { @@ -225,6 +227,7 @@ struct _sapi_module_struct { void (*register_server_variables)(zval *track_vars_array TSRMLS_DC); void (*log_message)(char *message); + time_t (*get_request_time)(TSRMLS_D); char *php_ini_path_override; diff --git a/sapi/apache/mod_php5.c b/sapi/apache/mod_php5.c index 083cc8be56..ad2f3b3520 100644 --- a/sapi/apache/mod_php5.c +++ b/sapi/apache/mod_php5.c @@ -401,6 +401,14 @@ static int sapi_apache_get_target_gid(gid_t *obj TSRMLS_DC) } /* }}} */ +/* {{{ php_apache_get_request_time + */ +static time_t php_apache_get_request_time(TSRMLS_D) +{ + return ((request_rec *)SG(server_context))->request_time; +} +/* }}} */ + /* {{{ sapi_module_struct apache_sapi_module */ static sapi_module_struct apache_sapi_module = { @@ -429,6 +437,7 @@ static sapi_module_struct apache_sapi_module = { sapi_apache_register_server_variables, /* register server variables */ php_apache_log_message, /* Log message */ + php_apache_get_request_time, /* Get request time */ NULL, /* php.ini path override */ diff --git a/sapi/apache2filter/sapi_apache2.c b/sapi/apache2filter/sapi_apache2.c index cf6bec1933..cb4ed06586 100644 --- a/sapi/apache2filter/sapi_apache2.c +++ b/sapi/apache2filter/sapi_apache2.c @@ -299,6 +299,15 @@ php_apache_disable_caching(ap_filter_t *f) return OK; } +static time_t +php_apache_sapi_get_request_time(void) +{ + php_struct *ctx = SG(server_context); + TSRMLS_FETCH(); + + return ctx->r->request_time; +} + extern zend_module_entry php_apache_module; static int php_apache2_startup(sapi_module_struct *sapi_module) @@ -335,6 +344,7 @@ static sapi_module_struct apache2_sapi_module = { php_apache_sapi_register_variables, php_apache_sapi_log_message, /* Log message */ + php_apache_sapi_get_request_time, /* Get Request Time */ STANDARD_SAPI_MODULE_PROPERTIES }; diff --git a/sapi/apache2handler/sapi_apache2.c b/sapi/apache2handler/sapi_apache2.c index e7e9571044..78d3aa4133 100644 --- a/sapi/apache2handler/sapi_apache2.c +++ b/sapi/apache2handler/sapi_apache2.c @@ -277,6 +277,13 @@ static void php_apache_sapi_log_message_ex(char *msg, request_rec *r) } } +static time_t php_apache_sapi_get_request_time(void) { + php_struct *ctx = SG(server_context); + TSRMLS_FETCH(); + + return ctx->r->request_time; +} + extern zend_module_entry php_apache_module; static int php_apache2_startup(sapi_module_struct *sapi_module) @@ -313,6 +320,7 @@ static sapi_module_struct apache2_sapi_module = { php_apache_sapi_register_variables, php_apache_sapi_log_message, /* Log message */ + php_apache_sapi_get_request_time, /* Request Time */ STANDARD_SAPI_MODULE_PROPERTIES }; |