Beispiel #1
0
/* {{{ php_register_server_variables
 */
static inline void php_register_server_variables(void)
{
	zval_ptr_dtor(&PG(http_globals)[TRACK_VARS_SERVER]);
	array_init(&PG(http_globals)[TRACK_VARS_SERVER]);

	/* Server variables */
	if (sapi_module.register_server_variables) {
		sapi_module.register_server_variables(&PG(http_globals)[TRACK_VARS_SERVER]);
	}

	/* PHP Authentication support */
	if (SG(request_info).auth_user) {
		php_register_variable("PHP_AUTH_USER", SG(request_info).auth_user, &PG(http_globals)[TRACK_VARS_SERVER]);
	}
	if (SG(request_info).auth_password) {
		php_register_variable("PHP_AUTH_PW", SG(request_info).auth_password, &PG(http_globals)[TRACK_VARS_SERVER]);
	}
	if (SG(request_info).auth_digest) {
		php_register_variable("PHP_AUTH_DIGEST", SG(request_info).auth_digest, &PG(http_globals)[TRACK_VARS_SERVER]);
	}
	/* store request init time */
	{
		zval request_time_float, request_time_long;
		ZVAL_DOUBLE(&request_time_float, sapi_get_request_time());
		php_register_variable_ex("REQUEST_TIME_FLOAT", &request_time_float, &PG(http_globals)[TRACK_VARS_SERVER]);
		ZVAL_LONG(&request_time_long, zend_dval_to_lval(Z_DVAL(request_time_float)));
		php_register_variable_ex("REQUEST_TIME", &request_time_long, &PG(http_globals)[TRACK_VARS_SERVER]);
	}

}
Beispiel #2
0
static int lsapi_activate_user_ini_walk_down_the_path(_lsapi_activate_user_ini_ctx *ctx,
                                                      void* next)
{
    time_t request_time = sapi_get_request_time();
    uint32_t docroot_len;
    int rc = SUCCESS;
    fn_activate_user_ini_chain_t *fn_next = next;

    if (!ctx->entry->expires || request_time > ctx->entry->expires)
    {
        docroot_len = ctx->doc_root && ctx->doc_root[0]
                    ? pathlen_without_trailing_slash(ctx->doc_root)
                    : 0;

        int is_outside_of_docroot = !docroot_len ||
                ctx->path_len < docroot_len ||
                strncmp(ctx->path, ctx->doc_root, docroot_len) != 0;

        if (is_outside_of_docroot) {
            php_parse_user_ini_file(ctx->path, PG(user_ini_filename),
                                    &ctx->entry->user_config);
        } else {
            walk_down_the_path(ctx->doc_root, ctx->path,
                               &walk_down_the_path_callback, ctx);
        }

        ctx->entry->expires = request_time + PG(user_ini_cache_ttl);
    }

    if (*fn_next) {
        rc = (*fn_next)(ctx, fn_next + 1);
    }

    return rc;
}
Beispiel #3
0
/* {{{ php_register_server_variables
 */
static inline void php_register_server_variables(void)
{
	zval tmp;
	zval *arr = &PG(http_globals)[TRACK_VARS_SERVER];
	HashTable *ht;

	zval_ptr_dtor_nogc(arr);
	array_init(arr);

	/* Server variables */
	if (sapi_module.register_server_variables) {
		sapi_module.register_server_variables(arr);
	}
	ht = Z_ARRVAL_P(arr);

	/* PHP Authentication support */
	if (SG(request_info).auth_user) {
		ZVAL_STRING(&tmp, SG(request_info).auth_user);
		php_register_variable_quick("PHP_AUTH_USER", sizeof("PHP_AUTH_USER")-1, &tmp, ht);
	}
	if (SG(request_info).auth_password) {
		ZVAL_STRING(&tmp, SG(request_info).auth_password);
		php_register_variable_quick("PHP_AUTH_PW", sizeof("PHP_AUTH_PW")-1, &tmp, ht);
	}
	if (SG(request_info).auth_digest) {
		ZVAL_STRING(&tmp, SG(request_info).auth_digest);
		php_register_variable_quick("PHP_AUTH_DIGEST", sizeof("PHP_AUTH_DIGEST")-1, &tmp, ht);
	}

	/* store request init time */
	ZVAL_DOUBLE(&tmp, sapi_get_request_time());
	php_register_variable_quick("REQUEST_TIME_FLOAT", sizeof("REQUEST_TIME_FLOAT")-1, &tmp, ht);
	ZVAL_LONG(&tmp, zend_dval_to_lval(Z_DVAL(tmp)));
	php_register_variable_quick("REQUEST_TIME", sizeof("REQUEST_TIME")-1, &tmp, ht);
}
Beispiel #4
0
static inline PS_READ_FUNC(apcu) 
{
    apc_cache_entry_t* entry;
    time_t now = sapi_get_request_time();
    
	if ((entry = apc_cache_find(apc_ps_cache, (char*)key, strlen(key)+1, now TSRMLS_CC))) {
	    *val = estrndup(
	        Z_STRVAL_P(entry->val),
	        *vallen = Z_STRLEN_P(entry->val)
	    );
	} else {
	    return FAILURE;
	}
    
    return SUCCESS;
}
Beispiel #5
0
size_t php_http_boundary(char *buf, size_t buf_len)
{
	return snprintf(buf, buf_len, "%15.15F", sapi_get_request_time() * php_combined_lcg());
}
Beispiel #6
0
};
/* }}} */

int http_module_number;

/* {{{ http_globals */
static void http_globals_init_once(zend_http_globals *G)
{
	memset(G, 0, sizeof(zend_http_globals));
}

#define http_globals_init(g) _http_globals_init((g) TSRMLS_CC)
static inline void _http_globals_init(zend_http_globals *G TSRMLS_DC)
{
#ifdef HTTP_HAVE_SAPI_RTIME
	G->request.time = sapi_get_request_time(TSRMLS_C);
#else
	G->request.time = time(NULL);
#endif
	G->send.buffer_size = 0;
	G->read_post_data = 0;
}

#define http_globals_free(g) _http_globals_free((g) TSRMLS_CC)
static inline void _http_globals_free(zend_http_globals *G TSRMLS_DC)
{
	if (G->request.headers) {
		zend_hash_destroy(G->request.headers);
		FREE_HASHTABLE(G->request.headers);
		G->request.headers = NULL;
	}
Beispiel #7
0
/* {{{ */
static inline time_t php_memoize_time(void) {
	return MG(ini.debug) ? time(NULL) : sapi_get_request_time();
} /* }}} */