mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
- Reverted r296062 and r296065
This commit is contained in:
parent
ea539c8b88
commit
af49e58f51
108 changed files with 3603 additions and 4297 deletions
|
@ -1,142 +0,0 @@
|
|||
$Id: README.NEW-OUTPUT-API 219039 2006-08-30 07:39:09Z mike $
|
||||
|
||||
|
||||
API adjustment to the old output control code:
|
||||
|
||||
Everything now resides beneath the php_output namespace,
|
||||
and there's an API call for every output handler op.
|
||||
|
||||
Checking output control layers status:
|
||||
// Using OG()
|
||||
php_output_get_status(TSRMLS_C);
|
||||
|
||||
Starting the default output handler:
|
||||
// php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC);
|
||||
php_output_start_default(TSRMLS_C);
|
||||
|
||||
Starting an user handler by zval:
|
||||
// php_start_ob_buffer(zhandler, chunk_size, erase TSRMLS_CC);
|
||||
php_output_start_user(zhandler, chunk_size, flags TSRMLS_CC);
|
||||
|
||||
Starting an internal handler whithout context:
|
||||
// php_ob_set_internal_handler(my_php_output_handler_func_t, buffer_size, "output handler name", erase TSRMLS_CC);
|
||||
php_output_start_internal(handler_name_zval, my_php_output_handler_func_t, chunk_size, flags TSRMLS_CC);
|
||||
|
||||
Starting an internal handler with context:
|
||||
// not possible with old API
|
||||
php_output_handler *h;
|
||||
h = php_output_handler_create_internal(handler_name_zval, my_php_output_handler_context_func_t, chunk_size, flags TSRMLS_CC);
|
||||
php_output_handler_set_context(h, my_context, my_context_dtor);
|
||||
php_output_handler_start(h TSRMLS_CC);
|
||||
|
||||
Testing whether a certain output handler has already been started:
|
||||
// php_ob_handler_used("output handler name" TSRMLS_CC);
|
||||
php_output_handler_started(handler_name_zval TSRMLS_CC);
|
||||
|
||||
Flushing one output buffer:
|
||||
// php_ob_end_buffer(1, 1 TSRMLS_CC);
|
||||
php_output_flush(TSRMLS_C);
|
||||
|
||||
Flushing all output buffers:
|
||||
// not possible with old API
|
||||
php_output_flush_all(TSRMLS_C);
|
||||
|
||||
Cleaning one output buffer:
|
||||
// php_ob_end_buffer(0, 1 TSRMLS_CC);
|
||||
php_output_clean(TSRMLS_C);
|
||||
|
||||
Cleaning all output buffers:
|
||||
// not possible with old API
|
||||
php_output_clean_all(TSRMLS_C);
|
||||
|
||||
Discarding one output buffer:
|
||||
// php_ob_end_buffer(0, 0 TSRMLS_CC);
|
||||
php_output_discard(TSRMLS_C);
|
||||
|
||||
Discarding all output buffers:
|
||||
// php_ob_end_buffers(0 TSRMLS_CC);
|
||||
php_output_discard_all(TSRMLS_C);
|
||||
|
||||
Stopping (and dropping) one output buffer:
|
||||
// php_ob_end_buffer(1, 0 TSRMLS_CC)
|
||||
php_output_end(TSRMLS_C);
|
||||
|
||||
Stopping (and dropping) all output buffers:
|
||||
// php_ob_end_buffers(1, 0 TSRMLS_CC);
|
||||
php_output_end_all(TSRMLS_C);
|
||||
|
||||
Retrieving output buffers contents:
|
||||
// php_ob_get_buffer(zstring TSRMLS_CC);
|
||||
php_output_get_contents(zstring TSRMLS_CC);
|
||||
|
||||
Retrieving output buffers length:
|
||||
// php_ob_get_length(zlength TSRMLS_CC);
|
||||
php_output_get_length(zlength TSRMLS_CC);
|
||||
|
||||
Retrieving output buffering level:
|
||||
// OG(nesting_level);
|
||||
php_output_get_level(TSRMLS_C);
|
||||
|
||||
Issue a warning because of an output handler conflict:
|
||||
// php_ob_init_conflict("to be started handler name", "to be tested if already started handler name" TSRMLS_CC);
|
||||
php_output_handler_conflict(new_handler_name_zval, set_handler_name_zval TSRMLS_CC);
|
||||
|
||||
Registering a conflict checking function, which will be checked prior starting the handler:
|
||||
// not possible with old API, unless hardcoding into output.c
|
||||
php_output_handler_conflict_register(handler_name_zval, my_php_output_handler_conflict_check_t TSRMLS_CC);
|
||||
|
||||
Registering a reverse conflict checking function, which will be checked prior starting the specified foreign handler:
|
||||
// not possible with old API
|
||||
php_output_handler_reverse_conflict_register(foreign_handler_name_zval, my_php_output_handler_conflict_check_t TSRMLS_CC);
|
||||
|
||||
Facilitating a context from within an output handler callable with ob_start():
|
||||
// not possible with old API
|
||||
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ, (void *) &custom_ctx_ptr_ptr TSRMLS_CC);
|
||||
|
||||
Disabling of the output handler by itself:
|
||||
//not possible with old API
|
||||
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_DISABLE, NULL TSRMLS_CC);
|
||||
|
||||
Marking an output handler immutable by itself because of irreversibility of its operation:
|
||||
// not possible with old API
|
||||
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC);
|
||||
|
||||
Restarting the output handler because of a CLEAN operation:
|
||||
// not possible with old API
|
||||
if (flags & PHP_OUTPUT_HANDLER_CLEAN) { ... }
|
||||
|
||||
Recognizing by the output handler itself if it gets discarded:
|
||||
// not possible with old API
|
||||
if ((flags & PHP_OUTPUT_HANDLER_CLEAN) && (flags & PHP_OUTPUT_HANDLER_FINAL)) { ... }
|
||||
|
||||
|
||||
Output handler hooks
|
||||
|
||||
The output handler can change its abilities at runtime. Eg. the gz handler can
|
||||
remove the CLEANABLE and REMOVABLE bits when the first output has passed through it;
|
||||
or handlers implemented in C to be used with ob_start() can contain a non-global
|
||||
context:
|
||||
PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ
|
||||
pass a void*** pointer as second arg to receive the address of a pointer
|
||||
pointer to the opaque field of the output handler context
|
||||
PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS
|
||||
pass a int* pointer as second arg to receive the flags set for the output handler
|
||||
PHP_OUTPUT_HANDLER_HOOK_GET_LEVEL
|
||||
pass a int* pointer as second arg to receive the level of this output handler
|
||||
(starts with 0)
|
||||
PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE
|
||||
the second arg is ignored; marks the output handler to be neither cleanable
|
||||
nor removable
|
||||
PHP_OUTPUT_HANDLER_HOOK_DISABLE
|
||||
the second arg is ignored; marks the output handler as disabled
|
||||
|
||||
|
||||
Open questions
|
||||
|
||||
Should the userland API be adjusted and unified?
|
||||
|
||||
Many bits of the manual (and very first implementation) do not comply
|
||||
with the behaviour of the current (to be obsoleted) code, thus should
|
||||
the manual or the behaviour be adjusted?
|
||||
|
||||
END
|
|
@ -26,7 +26,7 @@
|
|||
#include "zend_ptr_stack.h"
|
||||
#include "zend_globals.h"
|
||||
|
||||
ZEND_API void zend_html_putc(char c) /* {{{ */
|
||||
ZEND_API void zend_html_putc(char c)
|
||||
{
|
||||
switch (c) {
|
||||
case '\n':
|
||||
|
@ -52,9 +52,9 @@ ZEND_API void zend_html_putc(char c) /* {{{ */
|
|||
break;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API void zend_html_puts(const char *s, uint len TSRMLS_DC) /* {{{ */
|
||||
|
||||
ZEND_API void zend_html_puts(const char *s, uint len TSRMLS_DC)
|
||||
{
|
||||
const char *ptr=s, *end=s+len;
|
||||
|
||||
|
@ -85,9 +85,9 @@ ZEND_API void zend_html_puts(const char *s, uint len TSRMLS_DC) /* {{{ */
|
|||
}
|
||||
#endif /* ZEND_MULTIBYTE */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC) /* {{{ */
|
||||
|
||||
ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC)
|
||||
{
|
||||
zval token;
|
||||
int token_type;
|
||||
|
@ -97,7 +97,7 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
|
|||
zend_printf("<code>");
|
||||
zend_printf("<span style=\"color: %s\">\n", last_color);
|
||||
/* highlight stuff coming back from zendlex() */
|
||||
Z_TYPE(token) = 0;
|
||||
token.type = 0;
|
||||
while ((token_type=lex_scan(&token TSRMLS_CC))) {
|
||||
switch (token_type) {
|
||||
case T_INLINE_HTML:
|
||||
|
@ -121,11 +121,11 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
|
|||
break;
|
||||
case T_WHITESPACE:
|
||||
zend_html_puts(LANG_SCNG(yy_text), LANG_SCNG(yy_leng) TSRMLS_CC); /* no color needed */
|
||||
Z_TYPE(token) = 0;
|
||||
token.type = 0;
|
||||
continue;
|
||||
break;
|
||||
default:
|
||||
if (Z_TYPE(token) == 0) {
|
||||
if (token.type == 0) {
|
||||
next_color = syntax_highlighter_ini->highlight_keyword;
|
||||
} else {
|
||||
next_color = syntax_highlighter_ini->highlight_default;
|
||||
|
@ -145,7 +145,7 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
|
|||
|
||||
zend_html_puts(LANG_SCNG(yy_text), LANG_SCNG(yy_leng) TSRMLS_CC);
|
||||
|
||||
if (Z_TYPE(token) == IS_STRING) {
|
||||
if (token.type == IS_STRING) {
|
||||
switch (token_type) {
|
||||
case T_OPEN_TAG:
|
||||
case T_OPEN_TAG_WITH_ECHO:
|
||||
|
@ -155,13 +155,13 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
|
|||
case T_DOC_COMMENT:
|
||||
break;
|
||||
default:
|
||||
efree(Z_STRVAL(token));
|
||||
efree(token.value.str.val);
|
||||
break;
|
||||
}
|
||||
} else if (token_type == T_END_HEREDOC) {
|
||||
efree(Z_STRVAL(token));
|
||||
efree(token.value.str.val);
|
||||
}
|
||||
Z_TYPE(token) = 0;
|
||||
token.type = 0;
|
||||
}
|
||||
|
||||
if (last_color != syntax_highlighter_ini->highlight_html) {
|
||||
|
@ -170,15 +170,14 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
|
|||
zend_printf("</span>\n");
|
||||
zend_printf("</code>");
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API void zend_strip(TSRMLS_D) /* {{{ */
|
||||
ZEND_API void zend_strip(TSRMLS_D)
|
||||
{
|
||||
zval token;
|
||||
int token_type;
|
||||
int prev_space = 0;
|
||||
|
||||
Z_TYPE(token) = 0;
|
||||
token.type = 0;
|
||||
while ((token_type=lex_scan(&token TSRMLS_CC))) {
|
||||
switch (token_type) {
|
||||
case T_WHITESPACE:
|
||||
|
@ -189,19 +188,19 @@ ZEND_API void zend_strip(TSRMLS_D) /* {{{ */
|
|||
/* lack of break; is intentional */
|
||||
case T_COMMENT:
|
||||
case T_DOC_COMMENT:
|
||||
Z_TYPE(token) = 0;
|
||||
token.type = 0;
|
||||
continue;
|
||||
|
||||
|
||||
case T_END_HEREDOC:
|
||||
zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
|
||||
efree(Z_STRVAL(token));
|
||||
efree(token.value.str.val);
|
||||
/* read the following character, either newline or ; */
|
||||
if (lex_scan(&token TSRMLS_CC) != T_WHITESPACE) {
|
||||
zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
|
||||
}
|
||||
zend_write("\n", sizeof("\n") - 1);
|
||||
prev_space = 1;
|
||||
Z_TYPE(token) = 0;
|
||||
token.type = 0;
|
||||
continue;
|
||||
|
||||
default:
|
||||
|
@ -209,7 +208,7 @@ ZEND_API void zend_strip(TSRMLS_D) /* {{{ */
|
|||
break;
|
||||
}
|
||||
|
||||
if (Z_TYPE(token) == IS_STRING) {
|
||||
if (token.type == IS_STRING) {
|
||||
switch (token_type) {
|
||||
case T_OPEN_TAG:
|
||||
case T_OPEN_TAG_WITH_ECHO:
|
||||
|
@ -220,14 +219,13 @@ ZEND_API void zend_strip(TSRMLS_D) /* {{{ */
|
|||
break;
|
||||
|
||||
default:
|
||||
efree(Z_STRVAL(token));
|
||||
efree(token.value.str.val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
prev_space = Z_TYPE(token) = 0;
|
||||
prev_space = token.type = 0;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
|
@ -236,3 +234,4 @@ ZEND_API void zend_strip(TSRMLS_D) /* {{{ */
|
|||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
|
||||
|
|
|
@ -30,10 +30,11 @@
|
|||
#define zendtext LANG_SCNG(yy_text)
|
||||
#define zendleng LANG_SCNG(yy_leng)
|
||||
|
||||
static void handle_whitespace(unsigned int *emit_whitespace) /* {{{ */
|
||||
|
||||
static void handle_whitespace(int *emit_whitespace)
|
||||
{
|
||||
unsigned char c;
|
||||
unsigned int i;
|
||||
int i;
|
||||
|
||||
for (c=0; c<128; c++) {
|
||||
if (emit_whitespace[c]>0) {
|
||||
|
@ -44,29 +45,29 @@ static void handle_whitespace(unsigned int *emit_whitespace) /* {{{ */
|
|||
}
|
||||
memset(emit_whitespace, 0, sizeof(int)*256);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API void zend_indent(void) /* {{{ */
|
||||
|
||||
ZEND_API void zend_indent()
|
||||
{
|
||||
zval token;
|
||||
int token_type;
|
||||
int in_string=0;
|
||||
unsigned int nest_level=0;
|
||||
unsigned int emit_whitespace[256];
|
||||
unsigned int i;
|
||||
int nest_level=0;
|
||||
int emit_whitespace[256];
|
||||
int i;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
memset(emit_whitespace, 0, sizeof(int)*256);
|
||||
|
||||
/* highlight stuff coming back from zendlex() */
|
||||
Z_TYPE(token) = 0;
|
||||
token.type = 0;
|
||||
while ((token_type=lex_scan(&token TSRMLS_CC))) {
|
||||
switch (token_type) {
|
||||
case T_INLINE_HTML:
|
||||
zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
|
||||
break;
|
||||
case T_WHITESPACE: {
|
||||
Z_TYPE(token) = 0;
|
||||
token.type = 0;
|
||||
/* eat whitespace, emit newlines */
|
||||
for (i=0; i<LANG_SCNG(yy_leng); i++) {
|
||||
emit_whitespace[(unsigned char) LANG_SCNG(yy_text)[i]]++;
|
||||
|
@ -78,7 +79,7 @@ ZEND_API void zend_indent(void) /* {{{ */
|
|||
in_string = !in_string;
|
||||
/* break missing intentionally */
|
||||
default:
|
||||
if (Z_TYPE(token)==0) {
|
||||
if (token.type==0) {
|
||||
/* keyword */
|
||||
switch (token_type) {
|
||||
case ',':
|
||||
|
@ -131,21 +132,20 @@ dflt_printout:
|
|||
}
|
||||
break;
|
||||
}
|
||||
if (Z_TYPE(token) == IS_STRING) {
|
||||
if (token.type == IS_STRING) {
|
||||
switch (token_type) {
|
||||
case T_OPEN_TAG:
|
||||
case T_CLOSE_TAG:
|
||||
case T_WHITESPACE:
|
||||
break;
|
||||
default:
|
||||
efree(Z_STRVAL(token));
|
||||
efree(token.value.str.val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Z_TYPE(token) = 0;
|
||||
token.type = 0;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
|
|
|
@ -112,6 +112,11 @@ ZEND_BEGIN_ARG_INFO(arginfo_iconv, 0)
|
|||
ZEND_ARG_INFO(0, str)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_ob_iconv_handler, 0)
|
||||
ZEND_ARG_INFO(0, contents)
|
||||
ZEND_ARG_INFO(0, status)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_iconv_set_encoding, 0)
|
||||
ZEND_ARG_INFO(0, type)
|
||||
ZEND_ARG_INFO(0, charset)
|
||||
|
@ -127,6 +132,7 @@ ZEND_END_ARG_INFO()
|
|||
*/
|
||||
const zend_function_entry iconv_functions[] = {
|
||||
PHP_RAW_NAMED_FE(iconv,php_if_iconv, arginfo_iconv)
|
||||
PHP_FE(ob_iconv_handler, arginfo_ob_iconv_handler)
|
||||
PHP_FE(iconv_get_encoding, arginfo_iconv_get_encoding)
|
||||
PHP_FE(iconv_set_encoding, arginfo_iconv_set_encoding)
|
||||
PHP_FE(iconv_strlen, arginfo_iconv_strlen)
|
||||
|
@ -208,10 +214,6 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
|
|||
|
||||
static php_iconv_err_t php_iconv_stream_filter_register_factory(TSRMLS_D);
|
||||
static php_iconv_err_t php_iconv_stream_filter_unregister_factory(TSRMLS_D);
|
||||
|
||||
static int php_iconv_output_conflict(zval *handler_name TSRMLS_DC);
|
||||
static php_output_handler *php_iconv_output_handler_init(zval *name, size_t chunk_size, int flags TSRMLS_DC);
|
||||
static int php_iconv_output_handler(void **nothing, php_output_context *output_context);
|
||||
/* }}} */
|
||||
|
||||
/* {{{ static globals */
|
||||
|
@ -276,9 +278,6 @@ PHP_MINIT_FUNCTION(miconv)
|
|||
return FAILURE;
|
||||
}
|
||||
|
||||
PHP_OUTPUT_ALIAS_REGISTER("ob_iconv_handler", php_iconv_output_handler_init);
|
||||
PHP_OUTPUT_CONFLICT_REGISTER("ob_iconv_handler", php_iconv_output_conflict);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -313,60 +312,6 @@ PHP_MINFO_FUNCTION(miconv)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
static int php_iconv_output_conflict(zval *handler_name TSRMLS_DC)
|
||||
{
|
||||
if (php_output_get_level(TSRMLS_C)) {
|
||||
PHP_OUTPUT_CONFLICT("ob_iconv_handler", return FAILURE);
|
||||
PHP_OUTPUT_CONFLICT("mb_output_handler", return FAILURE);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
static php_output_handler *php_iconv_output_handler_init(zval *handler_name, size_t chunk_size, int flags TSRMLS_DC)
|
||||
{
|
||||
return php_output_handler_create_internal(handler_name, php_iconv_output_handler, chunk_size, flags TSRMLS_CC);
|
||||
}
|
||||
|
||||
static int php_iconv_output_handler(void **nothing, php_output_context *output_context)
|
||||
{
|
||||
char *s, *content_type, *mimetype = NULL;
|
||||
int output_status, mimetype_len = 0;
|
||||
PHP_OUTPUT_TSRMLS(output_context);
|
||||
|
||||
if (output_context->op & PHP_OUTPUT_HANDLER_START) {
|
||||
output_status = php_output_get_status(TSRMLS_C);
|
||||
if (output_status & PHP_OUTPUT_SENT) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if (SG(sapi_headers).mimetype && !strncasecmp(SG(sapi_headers).mimetype, "text/", 5)) {
|
||||
if ((s = strchr(SG(sapi_headers).mimetype,';')) == NULL){
|
||||
mimetype = SG(sapi_headers).mimetype;
|
||||
} else {
|
||||
mimetype = SG(sapi_headers).mimetype;
|
||||
mimetype_len = s - SG(sapi_headers).mimetype;
|
||||
}
|
||||
} else if (SG(sapi_headers).send_default_content_type) {
|
||||
mimetype = SG(default_mimetype) ? SG(default_mimetype) : SAPI_DEFAULT_MIMETYPE;
|
||||
}
|
||||
|
||||
if (mimetype != NULL && !(output_context->op & PHP_OUTPUT_HANDLER_CLEAN)) {
|
||||
int len = spprintf(&content_type, 0, "Content-Type: %.*s; charset=%s", mimetype_len?mimetype_len:strlen(mimetype), mimetype, ICONVG(output_encoding));
|
||||
if (content_type && SUCCESS == sapi_add_header(content_type, len, 0)) {
|
||||
SG(sapi_headers).send_default_content_type = 0;
|
||||
php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (output_context->in.used) {
|
||||
output_context->out.free = 1;
|
||||
_php_iconv_show_error(php_iconv_string(output_context->in.data, output_context->in.used, &output_context->out.data, &output_context->out.used, ICONVG(output_encoding), ICONVG(internal_encoding)), ICONVG(output_encoding), ICONVG(internal_encoding) TSRMLS_CC);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/* {{{ _php_iconv_appendl() */
|
||||
static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l, iconv_t cd)
|
||||
{
|
||||
|
@ -406,7 +351,7 @@ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l,
|
|||
}
|
||||
#else
|
||||
if (prev_in_left == in_left) {
|
||||
return PHP_ICONV_ERR_UNKNOWN;
|
||||
return PHP_ICONV_ERR_UNKNOWN;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -437,7 +382,7 @@ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l,
|
|||
#else
|
||||
if (out_left != 0) {
|
||||
return PHP_ICONV_ERR_UNKNOWN;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
(d)->len += (buf_growth - out_left);
|
||||
|
@ -483,21 +428,21 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
|
|||
in_size = in_len;
|
||||
|
||||
cd = iconv_open(out_charset, in_charset);
|
||||
|
||||
|
||||
if (cd == (iconv_t)(-1)) {
|
||||
return PHP_ICONV_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
out_buffer = (char *) emalloc(out_size + 1);
|
||||
out_p = out_buffer;
|
||||
|
||||
|
||||
#ifdef NETWARE
|
||||
result = iconv(cd, (char **) &in_p, &in_size, (char **)
|
||||
#else
|
||||
result = iconv(cd, (const char **) &in_p, &in_size, (char **)
|
||||
#endif
|
||||
&out_p, &out_left);
|
||||
|
||||
|
||||
if (result == (size_t)(-1)) {
|
||||
efree(out_buffer);
|
||||
return PHP_ICONV_ERR_UNKNOWN;
|
||||
|
@ -564,7 +509,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
|
|||
out_p = out_buf = tmp_buf;
|
||||
out_p += out_size;
|
||||
out_left = bsz - out_size;
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -583,7 +528,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
|
|||
if (errno == E2BIG) {
|
||||
bsz += 16;
|
||||
tmp_buf = (char *) erealloc(out_buf, bsz);
|
||||
|
||||
|
||||
out_p = out_buf = tmp_buf;
|
||||
out_p += out_size;
|
||||
out_left = bsz - out_size;
|
||||
|
@ -726,12 +671,12 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval,
|
|||
|
||||
unsigned int cnt;
|
||||
int total_len;
|
||||
|
||||
|
||||
err = _php_iconv_strlen(&total_len, str, nbytes, enc);
|
||||
if (err != PHP_ICONV_ERR_SUCCESS) {
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
if (len < 0) {
|
||||
if ((len += (total_len - offset)) < 0) {
|
||||
return PHP_ICONV_ERR_SUCCESS;
|
||||
|
@ -763,7 +708,7 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval,
|
|||
smart_str_0(pretval);
|
||||
return PHP_ICONV_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
cd1 = iconv_open(GENERIC_SUPERSET_NAME, enc);
|
||||
|
||||
if (cd1 == (iconv_t)(-1)) {
|
||||
|
@ -848,7 +793,7 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval,
|
|||
|
||||
if (cd2 != (iconv_t)NULL) {
|
||||
iconv_close(cd2);
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -1033,7 +978,7 @@ static php_iconv_err_t _php_iconv_strpos(unsigned int *pretval,
|
|||
if (ndl_buf) {
|
||||
efree(ndl_buf);
|
||||
}
|
||||
|
||||
|
||||
iconv_close(cd);
|
||||
|
||||
return err;
|
||||
|
@ -1286,7 +1231,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn
|
|||
goto out;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
err = PHP_ICONV_ERR_UNKNOWN;
|
||||
goto out;
|
||||
|
@ -1363,7 +1308,7 @@ out:
|
|||
}
|
||||
if (encoded != NULL) {
|
||||
efree(encoded);
|
||||
}
|
||||
}
|
||||
if (buf != NULL) {
|
||||
efree(buf);
|
||||
}
|
||||
|
@ -1421,7 +1366,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
|
|||
break;
|
||||
|
||||
case '\n':
|
||||
scan_stat = 8;
|
||||
scan_stat = 8;
|
||||
break;
|
||||
|
||||
case '=': /* first letter of an encoded chunk */
|
||||
|
@ -1461,7 +1406,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
|
|||
csname = p1 + 1;
|
||||
scan_stat = 2;
|
||||
break;
|
||||
|
||||
|
||||
case 2: /* expecting a charset name */
|
||||
switch (*p1) {
|
||||
case '?': /* normal delimiter: encoding scheme follows */
|
||||
|
@ -1572,7 +1517,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 4: /* expecting a delimiter */
|
||||
if (*p1 != '?') {
|
||||
if ((mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR)) {
|
||||
|
@ -1780,7 +1725,7 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
|
|||
break;
|
||||
|
||||
case '\n':
|
||||
scan_stat = 8;
|
||||
scan_stat = 8;
|
||||
break;
|
||||
|
||||
case '=': /* first letter of an encoded chunk */
|
||||
|
@ -2205,7 +2150,7 @@ PHP_FUNCTION(iconv_mime_decode)
|
|||
char *charset = ICONVG(internal_encoding);
|
||||
int charset_len = 0;
|
||||
long mode = 0;
|
||||
|
||||
|
||||
smart_str retval = {0};
|
||||
|
||||
php_iconv_err_t err;
|
||||
|
@ -2246,7 +2191,7 @@ PHP_FUNCTION(iconv_mime_decode_headers)
|
|||
char *charset = ICONVG(internal_encoding);
|
||||
int charset_len = 0;
|
||||
long mode = 0;
|
||||
|
||||
|
||||
php_iconv_err_t err = PHP_ICONV_ERR_SUCCESS;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls",
|
||||
|
@ -2314,14 +2259,14 @@ PHP_FUNCTION(iconv_mime_decode_headers)
|
|||
zend_hash_update(Z_ARRVAL_P(return_value), header_name, header_name_len, (void *)&new_elem, sizeof(new_elem), NULL);
|
||||
|
||||
elem = &new_elem;
|
||||
}
|
||||
}
|
||||
add_next_index_stringl(*elem, header_value, header_value_len, 1);
|
||||
} else {
|
||||
add_assoc_stringl_ex(return_value, header_name, header_name_len, header_value, header_value_len, 1);
|
||||
}
|
||||
}
|
||||
encoded_str_len -= next_pos - encoded_str;
|
||||
encoded_str = next_pos;
|
||||
encoded_str = next_pos;
|
||||
|
||||
smart_str_free(&decoded_header);
|
||||
}
|
||||
|
@ -2342,7 +2287,7 @@ PHP_NAMED_FUNCTION(php_if_iconv)
|
|||
size_t out_len;
|
||||
int in_charset_len = 0, out_charset_len = 0, in_buffer_len;
|
||||
php_iconv_err_t err;
|
||||
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss",
|
||||
&in_charset, &in_charset_len, &out_charset, &out_charset_len, &in_buffer, &in_buffer_len) == FAILURE)
|
||||
return;
|
||||
|
@ -2363,6 +2308,58 @@ PHP_NAMED_FUNCTION(php_if_iconv)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string ob_iconv_handler(string contents, int status)
|
||||
Returns str in output buffer converted to the iconv.output_encoding character set */
|
||||
PHP_FUNCTION(ob_iconv_handler)
|
||||
{
|
||||
char *out_buffer, *content_type, *mimetype = NULL, *s;
|
||||
zval *zv_string;
|
||||
size_t out_len;
|
||||
int mimetype_alloced = 0;
|
||||
long status;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zl", &zv_string, &status) == FAILURE)
|
||||
return;
|
||||
|
||||
convert_to_string(zv_string);
|
||||
|
||||
if (SG(sapi_headers).mimetype &&
|
||||
strncasecmp(SG(sapi_headers).mimetype, "text/", 5) == 0) {
|
||||
if ((s = strchr(SG(sapi_headers).mimetype,';')) == NULL){
|
||||
mimetype = SG(sapi_headers).mimetype;
|
||||
} else {
|
||||
mimetype = estrndup(SG(sapi_headers).mimetype, s-SG(sapi_headers).mimetype);
|
||||
mimetype_alloced = 1;
|
||||
}
|
||||
} else if (SG(sapi_headers).send_default_content_type) {
|
||||
mimetype =(SG(default_mimetype) ? SG(default_mimetype) : SAPI_DEFAULT_MIMETYPE);
|
||||
}
|
||||
if (mimetype != NULL) {
|
||||
php_iconv_err_t err = php_iconv_string(Z_STRVAL_P(zv_string),
|
||||
Z_STRLEN_P(zv_string), &out_buffer, &out_len,
|
||||
ICONVG(output_encoding), ICONVG(internal_encoding));
|
||||
_php_iconv_show_error(err, ICONVG(output_encoding), ICONVG(internal_encoding) TSRMLS_CC);
|
||||
if (out_buffer != NULL) {
|
||||
int len = spprintf(&content_type, 0, "Content-Type:%s; charset=%s", mimetype, ICONVG(output_encoding));
|
||||
if (content_type && sapi_add_header(content_type, len, 0) != FAILURE) {
|
||||
SG(sapi_headers).send_default_content_type = 0;
|
||||
}
|
||||
if (mimetype_alloced) {
|
||||
efree(mimetype);
|
||||
}
|
||||
RETURN_STRINGL(out_buffer, out_len, 0);
|
||||
}
|
||||
if (mimetype_alloced) {
|
||||
efree(mimetype);
|
||||
}
|
||||
}
|
||||
|
||||
zval_dtor(return_value);
|
||||
*return_value = *zv_string;
|
||||
zval_copy_ctor(return_value);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto bool iconv_set_encoding(string type, string charset)
|
||||
Sets internal encoding and output encoding for ob_iconv_handler() */
|
||||
PHP_FUNCTION(iconv_set_encoding)
|
||||
|
@ -2491,7 +2488,7 @@ static int php_iconv_stream_filter_append_bucket(
|
|||
char *pd, *pt;
|
||||
size_t ocnt, prev_ocnt, icnt, tcnt;
|
||||
size_t initial_out_buf_size;
|
||||
|
||||
|
||||
if (ps == NULL) {
|
||||
initial_out_buf_size = 64;
|
||||
icnt = 1;
|
||||
|
@ -2787,7 +2784,7 @@ static php_stream_filter *php_iconv_stream_filter_factory_create(const char *nam
|
|||
pefree(inst, persistent);
|
||||
}
|
||||
|
||||
return retval;
|
||||
return retval;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
|
@ -1165,8 +1165,8 @@ static int php_session_cache_limiter(TSRMLS_D) /* {{{ */
|
|||
if (PS(cache_limiter)[0] == '\0') return 0;
|
||||
|
||||
if (SG(headers_sent)) {
|
||||
char *output_start_filename = php_output_get_start_filename(TSRMLS_C);
|
||||
int output_start_lineno = php_output_get_start_lineno(TSRMLS_C);
|
||||
char *output_start_filename = php_get_output_start_filename(TSRMLS_C);
|
||||
int output_start_lineno = php_get_output_start_lineno(TSRMLS_C);
|
||||
|
||||
if (output_start_filename) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot send session cache limiter - headers already sent (output started at %s:%d)", output_start_filename, output_start_lineno);
|
||||
|
@ -1205,8 +1205,8 @@ static void php_session_send_cookie(TSRMLS_D) /* {{{ */
|
|||
char *e_session_name, *e_id;
|
||||
|
||||
if (SG(headers_sent)) {
|
||||
char *output_start_filename = php_output_get_start_filename(TSRMLS_C);
|
||||
int output_start_lineno = php_output_get_start_lineno(TSRMLS_C);
|
||||
char *output_start_filename = php_get_output_start_filename(TSRMLS_C);
|
||||
int output_start_lineno = php_get_output_start_lineno(TSRMLS_C);
|
||||
|
||||
if (output_start_filename) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot send session cookie - headers already sent by (output started at %s:%d)", output_start_filename, output_start_lineno);
|
||||
|
|
102
ext/soap/soap.c
102
ext/soap/soap.c
|
@ -1650,7 +1650,7 @@ PHP_METHOD(SoapServer, handle)
|
|||
|
||||
ALLOC_INIT_ZVAL(retval);
|
||||
|
||||
if (php_output_start_default(TSRMLS_C) != SUCCESS) {
|
||||
if (php_start_ob_buffer(NULL, 0, 0 TSRMLS_CC) != SUCCESS) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_ERROR,"ob_start failed");
|
||||
}
|
||||
|
||||
|
@ -1737,7 +1737,7 @@ PHP_METHOD(SoapServer, handle)
|
|||
|
||||
#ifdef ZEND_ENGINE_2
|
||||
if (EG(exception)) {
|
||||
php_output_discard(TSRMLS_C);
|
||||
php_end_ob_buffer(0, 0 TSRMLS_CC);
|
||||
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
|
||||
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
|
||||
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
|
||||
|
@ -1791,7 +1791,7 @@ PHP_METHOD(SoapServer, handle)
|
|||
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error calling constructor");
|
||||
}
|
||||
if (EG(exception)) {
|
||||
php_output_discard(TSRMLS_C);
|
||||
php_end_ob_buffer(0, 0 TSRMLS_CC);
|
||||
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
|
||||
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
|
||||
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
|
||||
|
@ -1823,7 +1823,7 @@ PHP_METHOD(SoapServer, handle)
|
|||
}
|
||||
#ifdef ZEND_ENGINE_2
|
||||
if (EG(exception)) {
|
||||
php_output_discard(TSRMLS_C);
|
||||
php_end_ob_buffer(0, 0 TSRMLS_CC);
|
||||
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
|
||||
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
|
||||
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
|
||||
|
@ -1902,14 +1902,14 @@ PHP_METHOD(SoapServer, handle)
|
|||
Z_TYPE_PP(tmp) != IS_NULL) {
|
||||
headerfault = *tmp;
|
||||
}
|
||||
php_output_discard(TSRMLS_C);
|
||||
php_end_ob_buffer(0, 0 TSRMLS_CC);
|
||||
soap_server_fault_ex(function, &h->retval, h TSRMLS_CC);
|
||||
efree(fn_name);
|
||||
if (service->type == SOAP_CLASS && soap_obj) {zval_ptr_dtor(&soap_obj);}
|
||||
goto fail;
|
||||
#ifdef ZEND_ENGINE_2
|
||||
} else if (EG(exception)) {
|
||||
php_output_discard(TSRMLS_C);
|
||||
php_end_ob_buffer(0, 0 TSRMLS_CC);
|
||||
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
|
||||
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
|
||||
zval *headerfault = NULL, **tmp;
|
||||
|
@ -1959,7 +1959,7 @@ PHP_METHOD(SoapServer, handle)
|
|||
|
||||
#ifdef ZEND_ENGINE_2
|
||||
if (EG(exception)) {
|
||||
php_output_discard(TSRMLS_C);
|
||||
php_end_ob_buffer(0, 0 TSRMLS_CC);
|
||||
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
|
||||
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
|
||||
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
|
||||
|
@ -1981,7 +1981,7 @@ PHP_METHOD(SoapServer, handle)
|
|||
|
||||
if (Z_TYPE_P(retval) == IS_OBJECT &&
|
||||
instanceof_function(Z_OBJCE_P(retval), soap_fault_class_entry TSRMLS_CC)) {
|
||||
php_output_discard(TSRMLS_C);
|
||||
php_end_ob_buffer(0, 0 TSRMLS_CC);
|
||||
soap_server_fault_ex(function, retval, NULL TSRMLS_CC);
|
||||
goto fail;
|
||||
}
|
||||
|
@ -2002,7 +2002,7 @@ PHP_METHOD(SoapServer, handle)
|
|||
|
||||
#ifdef ZEND_ENGINE_2
|
||||
if (EG(exception)) {
|
||||
php_output_discard(TSRMLS_C);
|
||||
php_end_ob_buffer(0, 0 TSRMLS_CC);
|
||||
if (Z_TYPE_P(EG(exception)) == IS_OBJECT &&
|
||||
instanceof_function(Z_OBJCE_P(EG(exception)), soap_fault_class_entry TSRMLS_CC)) {
|
||||
soap_server_fault_ex(function, EG(exception), NULL TSRMLS_CC);
|
||||
|
@ -2021,7 +2021,7 @@ PHP_METHOD(SoapServer, handle)
|
|||
#endif
|
||||
|
||||
/* Flush buffer */
|
||||
php_output_discard(TSRMLS_C);
|
||||
php_end_ob_buffer(0, 0 TSRMLS_CC);
|
||||
|
||||
if (doc_return) {
|
||||
/* xmlDocDumpMemoryEnc(doc_return, &buf, &size, XML_CHAR_ENCODING_UTF8); */
|
||||
|
@ -2039,14 +2039,39 @@ PHP_METHOD(SoapServer, handle)
|
|||
|
||||
xmlFreeDoc(doc_return);
|
||||
|
||||
if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) {
|
||||
sapi_add_header("Connection: close", sizeof("Connection: close")-1, 1);
|
||||
} else {
|
||||
if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0) &&
|
||||
zend_hash_exists(EG(function_table), "ob_gzhandler", sizeof("ob_gzhandler"))) {
|
||||
zval nm_ob_gzhandler;
|
||||
zval str;
|
||||
zval mode;
|
||||
zval result;
|
||||
zval *params[2];
|
||||
|
||||
INIT_ZVAL(result);
|
||||
ZVAL_STRINGL(&nm_ob_gzhandler, "ob_gzhandler", sizeof("ob_gzhandler") - 1, 0);
|
||||
INIT_PZVAL(&str);
|
||||
ZVAL_STRINGL(&str, (char*)buf, size, 0);
|
||||
params[0] = &str;
|
||||
INIT_PZVAL(&mode);
|
||||
ZVAL_LONG(&mode, PHP_OUTPUT_HANDLER_START | PHP_OUTPUT_HANDLER_END);
|
||||
params[1] = &mode;
|
||||
if (call_user_function(CG(function_table), NULL, &nm_ob_gzhandler, &result, 2, params TSRMLS_CC) != FAILURE &&
|
||||
Z_TYPE(result) == IS_STRING &&
|
||||
zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_compression"), "0", sizeof("0")-1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME) == SUCCESS) {
|
||||
xmlFree(buf);
|
||||
buf = NULL;
|
||||
snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", Z_STRLEN(result));
|
||||
sapi_add_header(cont_len, strlen(cont_len), 1);
|
||||
php_write(Z_STRVAL(result), Z_STRLEN(result) TSRMLS_CC);
|
||||
}
|
||||
zval_dtor(&result);
|
||||
}
|
||||
if (buf) {
|
||||
snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);
|
||||
sapi_add_header(cont_len, strlen(cont_len), 1);
|
||||
php_write(buf, size TSRMLS_CC);
|
||||
xmlFree(buf);
|
||||
}
|
||||
php_write(buf, size TSRMLS_CC);
|
||||
xmlFree(buf);
|
||||
} else {
|
||||
sapi_add_header("HTTP/1.1 202 Accepted", sizeof("HTTP/1.1 202 Accepted")-1, 1);
|
||||
sapi_add_header("Content-Length: 0", sizeof("Content-Length: 0")-1, 1);
|
||||
|
@ -2185,22 +2210,47 @@ static void soap_server_fault_ex(sdlFunctionPtr function, zval* fault, soapHeade
|
|||
if (use_http_error_status) {
|
||||
sapi_add_header("HTTP/1.1 500 Internal Service Error", sizeof("HTTP/1.1 500 Internal Service Error")-1, 1);
|
||||
}
|
||||
if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0)) {
|
||||
sapi_add_header("Connection: close", sizeof("Connection: close")-1, 1);
|
||||
} else {
|
||||
snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);
|
||||
sapi_add_header(cont_len, strlen(cont_len), 1);
|
||||
}
|
||||
if (soap_version == SOAP_1_2) {
|
||||
sapi_add_header("Content-Type: application/soap+xml; charset=utf-8", sizeof("Content-Type: application/soap+xml; charset=utf-8")-1, 1);
|
||||
} else {
|
||||
sapi_add_header("Content-Type: text/xml; charset=utf-8", sizeof("Content-Type: text/xml; charset=utf-8")-1, 1);
|
||||
}
|
||||
|
||||
php_write(buf, size TSRMLS_CC);
|
||||
if (zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"), 0) &&
|
||||
zend_hash_exists(EG(function_table), "ob_gzhandler", sizeof("ob_gzhandler"))) {
|
||||
zval nm_ob_gzhandler;
|
||||
zval str;
|
||||
zval mode;
|
||||
zval result;
|
||||
zval *params[2];
|
||||
|
||||
INIT_ZVAL(result);
|
||||
ZVAL_STRINGL(&nm_ob_gzhandler, "ob_gzhandler", sizeof("ob_gzhandler") - 1, 0);
|
||||
INIT_PZVAL(&str);
|
||||
ZVAL_STRINGL(&str, (char*)buf, size, 0);
|
||||
params[0] = &str;
|
||||
INIT_PZVAL(&mode);
|
||||
ZVAL_LONG(&mode, PHP_OUTPUT_HANDLER_START | PHP_OUTPUT_HANDLER_END);
|
||||
params[1] = &mode;
|
||||
if (call_user_function(CG(function_table), NULL, &nm_ob_gzhandler, &result, 2, params TSRMLS_CC) != FAILURE &&
|
||||
Z_TYPE(result) == IS_STRING &&
|
||||
zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_compression"), "0", sizeof("0")-1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME) == SUCCESS) {
|
||||
xmlFree(buf);
|
||||
buf = NULL;
|
||||
snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", Z_STRLEN(result));
|
||||
sapi_add_header(cont_len, strlen(cont_len), 1);
|
||||
php_write(Z_STRVAL(result), Z_STRLEN(result) TSRMLS_CC);
|
||||
}
|
||||
zval_dtor(&result);
|
||||
}
|
||||
if (buf) {
|
||||
snprintf(cont_len, sizeof(cont_len), "Content-Length: %d", size);
|
||||
sapi_add_header(cont_len, strlen(cont_len), 1);
|
||||
php_write(buf, size TSRMLS_CC);
|
||||
xmlFree(buf);
|
||||
}
|
||||
|
||||
xmlFreeDoc(doc_return);
|
||||
xmlFree(buf);
|
||||
zend_clear_exception(TSRMLS_C);
|
||||
}
|
||||
|
||||
|
@ -2363,11 +2413,11 @@ static void soap_error_handler(int error_num, const char *error_filename, const
|
|||
}
|
||||
|
||||
/* Get output buffer and send as fault detials */
|
||||
if (php_output_get_length(&outbuflen TSRMLS_CC) != FAILURE && Z_LVAL(outbuflen) != 0) {
|
||||
if (php_ob_get_length(&outbuflen TSRMLS_CC) != FAILURE && Z_LVAL(outbuflen) != 0) {
|
||||
ALLOC_INIT_ZVAL(outbuf);
|
||||
php_output_get_contents(outbuf TSRMLS_CC);
|
||||
php_ob_get_buffer(outbuf TSRMLS_CC);
|
||||
}
|
||||
php_output_discard(TSRMLS_C);
|
||||
php_end_ob_buffer(0, 0 TSRMLS_CC);
|
||||
|
||||
}
|
||||
INIT_ZVAL(fault_obj);
|
||||
|
|
|
@ -5137,7 +5137,7 @@ ZEND_API void php_get_highlight_struct(zend_syntax_highlighter_ini *syntax_highl
|
|||
PHP_FUNCTION(highlight_file)
|
||||
{
|
||||
char *filename;
|
||||
int filename_len, ret;
|
||||
int filename_len;
|
||||
zend_syntax_highlighter_ini syntax_highlighter_ini;
|
||||
zend_bool i = 0;
|
||||
|
||||
|
@ -5154,23 +5154,32 @@ PHP_FUNCTION(highlight_file)
|
|||
}
|
||||
|
||||
if (i) {
|
||||
php_output_start_default(TSRMLS_C);
|
||||
php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
|
||||
}
|
||||
|
||||
php_get_highlight_struct(&syntax_highlighter_ini);
|
||||
|
||||
ret = highlight_file(filename, &syntax_highlighter_ini TSRMLS_CC);
|
||||
|
||||
if (ret == FAILURE) {
|
||||
if (highlight_file(filename, &syntax_highlighter_ini TSRMLS_CC) == FAILURE) {
|
||||
if (i) {
|
||||
php_output_end(TSRMLS_C);
|
||||
int res = php_ob_get_buffer(return_value TSRMLS_CC);
|
||||
|
||||
/* flush the buffer only if there is something to flush */
|
||||
if (res == SUCCESS && Z_STRLEN_P(return_value) > 0) {
|
||||
php_end_ob_buffer (1, 0 TSRMLS_CC);
|
||||
zval_dtor(return_value);
|
||||
} else {
|
||||
php_end_ob_buffer (0, 0 TSRMLS_CC);
|
||||
if (res == SUCCESS) {
|
||||
zval_dtor(return_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (i) {
|
||||
php_output_get_contents(return_value TSRMLS_CC);
|
||||
php_output_discard(TSRMLS_C);
|
||||
php_ob_get_buffer (return_value TSRMLS_CC);
|
||||
php_end_ob_buffer (0, 0 TSRMLS_CC);
|
||||
} else {
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
@ -5190,26 +5199,25 @@ PHP_FUNCTION(php_strip_whitespace)
|
|||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
php_output_start_default(TSRMLS_C);
|
||||
|
||||
file_handle.type = ZEND_HANDLE_FILENAME;
|
||||
file_handle.filename = filename;
|
||||
file_handle.free_filename = 0;
|
||||
file_handle.opened_path = NULL;
|
||||
zend_save_lexical_state(&original_lex_state TSRMLS_CC);
|
||||
if (open_file_for_scanning(&file_handle TSRMLS_CC) == FAILURE) {
|
||||
if (open_file_for_scanning(&file_handle TSRMLS_CC)==FAILURE) {
|
||||
zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
|
||||
php_output_end(TSRMLS_C);
|
||||
RETURN_EMPTY_STRING();
|
||||
}
|
||||
|
||||
php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC);
|
||||
|
||||
zend_strip(TSRMLS_C);
|
||||
|
||||
zend_destroy_file_handle(&file_handle TSRMLS_CC);
|
||||
zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
|
||||
|
||||
php_output_get_contents(return_value TSRMLS_CC);
|
||||
php_output_discard(TSRMLS_C);
|
||||
php_ob_get_buffer(return_value TSRMLS_CC);
|
||||
php_end_ob_buffer(0, 0 TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -5229,7 +5237,7 @@ PHP_FUNCTION(highlight_string)
|
|||
convert_to_string_ex(expr);
|
||||
|
||||
if (i) {
|
||||
php_output_start_default(TSRMLS_C);
|
||||
php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
|
||||
}
|
||||
|
||||
EG(error_reporting) = E_ERROR;
|
||||
|
@ -5242,7 +5250,7 @@ PHP_FUNCTION(highlight_string)
|
|||
efree(hicompiled_string_description);
|
||||
EG(error_reporting) = old_error_reporting;
|
||||
if (i) {
|
||||
php_output_end(TSRMLS_C);
|
||||
php_end_ob_buffer (1, 0 TSRMLS_CC);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -5251,8 +5259,8 @@ PHP_FUNCTION(highlight_string)
|
|||
EG(error_reporting) = old_error_reporting;
|
||||
|
||||
if (i) {
|
||||
php_output_get_contents(return_value TSRMLS_CC);
|
||||
php_output_discard(TSRMLS_C);
|
||||
php_ob_get_buffer (return_value TSRMLS_CC);
|
||||
php_end_ob_buffer (0, 0 TSRMLS_CC);
|
||||
} else {
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
@ -5509,14 +5517,14 @@ PHP_FUNCTION(print_r)
|
|||
}
|
||||
|
||||
if (do_return) {
|
||||
php_output_start_default(TSRMLS_C);
|
||||
php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
|
||||
}
|
||||
|
||||
zend_print_zval_r(var, 0 TSRMLS_CC);
|
||||
|
||||
if (do_return) {
|
||||
php_output_get_contents(return_value TSRMLS_CC);
|
||||
php_output_discard(TSRMLS_C);
|
||||
php_ob_get_buffer (return_value TSRMLS_CC);
|
||||
php_end_ob_buffer (0, 0 TSRMLS_CC);
|
||||
} else {
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
|
|
@ -139,10 +139,8 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_
|
|||
}
|
||||
|
||||
if (type == 1) {
|
||||
int ob_level;
|
||||
|
||||
PHPWRITE(buf, bufl);
|
||||
if ((php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_GET_LEVEL, &ob_level TSRMLS_CC) == SUCCESS) && ob_level < 1) {
|
||||
if (OG(ob_nesting_level) < 1) {
|
||||
sapi_flush(TSRMLS_C);
|
||||
}
|
||||
} else if (type == 2) {
|
||||
|
|
|
@ -64,7 +64,7 @@ PHP_FUNCTION(header_remove)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
PHPAPI int php_header(TSRMLS_D) /* {{{ */
|
||||
PHPAPI int php_header(TSRMLS_D)
|
||||
{
|
||||
if (sapi_send_headers(TSRMLS_C)==FAILURE || SG(request_info).headers_only) {
|
||||
return 0; /* don't allow output */
|
||||
|
@ -72,10 +72,9 @@ PHPAPI int php_header(TSRMLS_D) /* {{{ */
|
|||
return 1; /* allow output */
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, time_t expires, char *path, int path_len, char *domain, int domain_len, int secure, int url_encode, int httponly TSRMLS_DC) /* {{{ */
|
||||
PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, time_t expires, char *path, int path_len, char *domain, int domain_len, int secure, int url_encode, int httponly TSRMLS_DC)
|
||||
{
|
||||
char *cookie, *encoded_value = NULL;
|
||||
int len=sizeof("Set-Cookie: ");
|
||||
|
@ -168,7 +167,7 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
|
|||
efree(cookie);
|
||||
return result;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* php_set_cookie(name, value, expires, path, domain, secure) */
|
||||
/* {{{ proto bool setcookie(string name [, string value [, int expires [, string path [, string domain [, bool secure[, bool httponly]]]]]])
|
||||
|
@ -230,8 +229,8 @@ PHP_FUNCTION(headers_sent)
|
|||
return;
|
||||
|
||||
if (SG(headers_sent)) {
|
||||
line = php_output_get_start_lineno(TSRMLS_C);
|
||||
file = php_output_get_start_filename(TSRMLS_C);
|
||||
line = php_get_output_start_lineno(TSRMLS_C);
|
||||
file = php_get_output_start_filename(TSRMLS_C);
|
||||
}
|
||||
|
||||
switch(ZEND_NUM_ARGS()) {
|
||||
|
|
|
@ -38,15 +38,16 @@
|
|||
#include <sys/utsname.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
|
||||
typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);
|
||||
|
||||
# include "winver.h"
|
||||
|
||||
# if _MSC_VER < 1300
|
||||
# define OSVERSIONINFOEX php_win_OSVERSIONINFOEX
|
||||
# endif
|
||||
#if _MSC_VER < 1300
|
||||
# define OSVERSIONINFOEX php_win_OSVERSIONINFOEX
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if HAVE_MBSTRING
|
||||
|
@ -60,7 +61,7 @@ ZEND_EXTERN_MODULE_GLOBALS(iconv)
|
|||
#endif
|
||||
|
||||
#define SECTION(name) if (!sapi_module.phpinfo_as_text) { \
|
||||
php_info_print("<h2>" name "</h2>\n"); \
|
||||
PUTS("<h2>" name "</h2>\n"); \
|
||||
} else { \
|
||||
php_info_print_table_start(); \
|
||||
php_info_print_table_header(1, name); \
|
||||
|
@ -70,99 +71,29 @@ ZEND_EXTERN_MODULE_GLOBALS(iconv)
|
|||
PHPAPI extern char *php_ini_opened_path;
|
||||
PHPAPI extern char *php_ini_scanned_path;
|
||||
PHPAPI extern char *php_ini_scanned_files;
|
||||
|
||||
static int php_info_print_html_esc(const char *str, int len) /* {{{ */
|
||||
|
||||
static int php_info_write_wrapper(const char *str, uint str_length)
|
||||
{
|
||||
int new_len, written;
|
||||
char *new_str;
|
||||
char *elem_esc;
|
||||
|
||||
TSRMLS_FETCH();
|
||||
|
||||
new_str = php_escape_html_entities((char *) str, len, &new_len, 0, ENT_QUOTES, "utf-8" TSRMLS_CC);
|
||||
written = php_output_write(new_str, new_len TSRMLS_CC);
|
||||
efree(new_str);
|
||||
|
||||
elem_esc = php_escape_html_entities((unsigned char *)str, str_length, &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
|
||||
|
||||
written = php_body_write(elem_esc, new_len TSRMLS_CC);
|
||||
|
||||
efree(elem_esc);
|
||||
|
||||
return written;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int php_info_printf(const char *fmt, ...) /* {{{ */
|
||||
{
|
||||
char *buf;
|
||||
int len, written;
|
||||
va_list argv;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
va_start(argv, fmt);
|
||||
len = vspprintf(&buf, 0, fmt, argv);
|
||||
va_end(argv);
|
||||
|
||||
written = php_output_write(buf, len TSRMLS_CC);
|
||||
efree(buf);
|
||||
return written;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void php_info_print_request_uri(TSRMLS_D) /* {{{ */
|
||||
{
|
||||
if (SG(request_info).request_uri) {
|
||||
php_info_print_html_esc(SG(request_info).request_uri, strlen(SG(request_info).request_uri));
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int php_info_print(const char *str) /* {{{ */
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
return php_output_write(str, strlen(str) TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void php_info_print_stream_hash(const char *name, HashTable *ht TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
char *key;
|
||||
uint len;
|
||||
int type;
|
||||
|
||||
if (ht) {
|
||||
if (zend_hash_num_elements(ht)) {
|
||||
HashPosition pos;
|
||||
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_printf("<tr class=\"v\"><td>Registered %s</td><td>", name);
|
||||
} else {
|
||||
php_info_printf("\nRegistered %s => ", name);
|
||||
}
|
||||
|
||||
zend_hash_internal_pointer_reset_ex(ht, &pos);
|
||||
while (zend_hash_get_current_key_ex(ht, &key, &len, NULL, 0, &pos) == HASH_KEY_IS_STRING)
|
||||
{
|
||||
php_info_print(key);
|
||||
zend_hash_move_forward_ex(ht, &pos);
|
||||
if (zend_hash_get_current_key_ex(ht, &key, &len, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
|
||||
php_info_print(", ");
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("</td></tr>\n");
|
||||
}
|
||||
} else {
|
||||
char reg_name[128];
|
||||
snprintf(reg_name, sizeof(reg_name), "Registered %s", name);
|
||||
php_info_print_table_row(2, reg_name, "none registered");
|
||||
}
|
||||
} else {
|
||||
php_info_print_table_row(2, name, "disabled");
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
PHPAPI void php_info_print_module(zend_module_entry *zend_module TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
if (zend_module->info_func || zend_module->version) {
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", zend_module->name, zend_module->name);
|
||||
php_printf("<h2><a name=\"module_%s\">%s</a></h2>\n", zend_module->name, zend_module->name);
|
||||
} else {
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_header(1, zend_module->name);
|
||||
|
@ -178,9 +109,9 @@ PHPAPI void php_info_print_module(zend_module_entry *zend_module TSRMLS_DC) /* {
|
|||
}
|
||||
} else {
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_printf("<tr><td>%s</td></tr>\n", zend_module->name);
|
||||
php_printf("<tr><td>%s</td></tr>\n", zend_module->name);
|
||||
} else {
|
||||
php_info_printf("%s\n", zend_module->name);
|
||||
php_printf("%s\n", zend_module->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -220,66 +151,70 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
|
|||
zend_hash_internal_pointer_reset(Z_ARRVAL_PP(data));
|
||||
while (zend_hash_get_current_data(Z_ARRVAL_PP(data), (void **) &tmp) == SUCCESS) {
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("<tr>");
|
||||
php_info_print("<td class=\"e\">");
|
||||
PUTS("<tr>");
|
||||
PUTS("<td class=\"e\">");
|
||||
|
||||
}
|
||||
|
||||
php_info_print(name);
|
||||
php_info_print("[\"");
|
||||
PUTS(name);
|
||||
PUTS("[\"");
|
||||
|
||||
switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(data), &string_key, &string_len, &num_key, 0, NULL)) {
|
||||
case HASH_KEY_IS_STRING:
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print_html_esc(string_key, string_len-1);
|
||||
php_info_html_esc_write(string_key, string_len - 1 TSRMLS_CC);
|
||||
} else {
|
||||
php_info_print(string_key);
|
||||
}
|
||||
PHPWRITE(string_key, string_len - 1);
|
||||
}
|
||||
break;
|
||||
case HASH_KEY_IS_LONG:
|
||||
php_info_printf("%ld", num_key);
|
||||
php_printf("%ld", num_key);
|
||||
break;
|
||||
}
|
||||
php_info_print("\"]");
|
||||
PUTS("\"]");
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("</td><td class=\"v\">");
|
||||
PUTS("</td><td class=\"v\">");
|
||||
} else {
|
||||
php_info_print(" => ");
|
||||
PUTS(" => ");
|
||||
}
|
||||
if (Z_TYPE_PP(tmp) == IS_ARRAY) {
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("<pre>");
|
||||
zend_print_zval_r_ex((zend_write_func_t) php_info_print_html_esc, *tmp, 0 TSRMLS_CC);
|
||||
php_info_print("</pre>");
|
||||
PUTS("<pre>");
|
||||
zend_print_zval_r_ex((zend_write_func_t) php_info_write_wrapper, *tmp, 0 TSRMLS_CC);
|
||||
PUTS("</pre>");
|
||||
} else {
|
||||
zend_print_zval_r(*tmp, 0 TSRMLS_CC);
|
||||
}
|
||||
} else {
|
||||
} else if (Z_TYPE_PP(tmp) != IS_STRING) {
|
||||
tmp2 = **tmp;
|
||||
switch (Z_TYPE_PP(tmp)) {
|
||||
default:
|
||||
tmp = NULL;
|
||||
zval_copy_ctor(&tmp2);
|
||||
convert_to_string(&tmp2);
|
||||
case IS_STRING:
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
if (Z_STRLEN(tmp2) == 0) {
|
||||
php_info_print("<i>no value</i>");
|
||||
} else {
|
||||
php_info_print_html_esc(Z_STRVAL(tmp2), Z_STRLEN(tmp2));
|
||||
}
|
||||
} else {
|
||||
php_info_print(Z_STRVAL(tmp2));
|
||||
}
|
||||
}
|
||||
if (!tmp) {
|
||||
zval_dtor(&tmp2);
|
||||
}
|
||||
zval_copy_ctor(&tmp2);
|
||||
convert_to_string(&tmp2);
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
if (Z_STRLEN(tmp2) == 0) {
|
||||
PUTS("<i>no value</i>");
|
||||
} else {
|
||||
php_info_html_esc_write(Z_STRVAL(tmp2), Z_STRLEN(tmp2) TSRMLS_CC);
|
||||
}
|
||||
} else {
|
||||
PHPWRITE(Z_STRVAL(tmp2), Z_STRLEN(tmp2));
|
||||
}
|
||||
zval_dtor(&tmp2);
|
||||
} else {
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
if (Z_STRLEN_PP(tmp) == 0) {
|
||||
PUTS("<i>no value</i>");
|
||||
} else {
|
||||
php_info_html_esc_write(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp) TSRMLS_CC);
|
||||
}
|
||||
} else {
|
||||
PHPWRITE(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp));
|
||||
}
|
||||
}
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("</td></tr>\n");
|
||||
PUTS("</td></tr>\n");
|
||||
} else {
|
||||
php_info_print("\n");
|
||||
}
|
||||
PUTS("\n");
|
||||
}
|
||||
zend_hash_move_forward(Z_ARRVAL_PP(data));
|
||||
}
|
||||
}
|
||||
|
@ -290,9 +225,21 @@ static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
|
|||
*/
|
||||
void php_info_print_style(TSRMLS_D)
|
||||
{
|
||||
php_info_printf("<style type=\"text/css\">\n");
|
||||
php_printf("<style type=\"text/css\">\n");
|
||||
php_info_print_css(TSRMLS_C);
|
||||
php_info_printf("</style>\n");
|
||||
php_printf("</style>\n");
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_info_html_esc_write
|
||||
*/
|
||||
PHPAPI void php_info_html_esc_write(char *string, int str_len TSRMLS_DC)
|
||||
{
|
||||
int new_len;
|
||||
char *ret = php_escape_html_entities((unsigned char *)string, str_len, &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
|
||||
|
||||
PHPWRITE(ret, new_len);
|
||||
efree(ret);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -301,13 +248,13 @@ void php_info_print_style(TSRMLS_D)
|
|||
PHPAPI char *php_info_html_esc(char *string TSRMLS_DC)
|
||||
{
|
||||
int new_len;
|
||||
return php_escape_html_entities(string, strlen(string), &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
|
||||
return php_escape_html_entities((unsigned char *)string, strlen(string), &new_len, 0, ENT_QUOTES, NULL TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
/* {{{ */
|
||||
|
||||
char* php_get_windows_name()
|
||||
{
|
||||
OSVERSIONINFOEX osvi;
|
||||
|
@ -402,9 +349,9 @@ char* php_get_windows_name()
|
|||
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 ) {
|
||||
if (GetSystemMetrics(SM_SERVERR2))
|
||||
major = "Windows Server 2003 R2";
|
||||
else if (osvi.wSuiteMask==VER_SUITE_STORAGE_SERVER)
|
||||
else if (osvi.wSuiteMask == VER_SUITE_STORAGE_SERVER)
|
||||
major = "Windows Storage Server 2003";
|
||||
else if (osvi.wSuiteMask==VER_SUITE_WH_SERVER)
|
||||
else if (osvi.wSuiteMask == VER_SUITE_WH_SERVER)
|
||||
major = "Windows Home Server";
|
||||
else if (osvi.wProductType == VER_NT_WORKSTATION &&
|
||||
si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64) {
|
||||
|
@ -630,18 +577,54 @@ PHPAPI char *php_get_uname(char mode)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ php_print_info_htmlhead
|
||||
*/
|
||||
PHPAPI void php_print_info_htmlhead(TSRMLS_D)
|
||||
{
|
||||
php_info_print("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n");
|
||||
php_info_print("<html>");
|
||||
php_info_print("<head>\n");
|
||||
|
||||
/*** none of this is needed now ***
|
||||
|
||||
const char *charset = NULL;
|
||||
|
||||
if (SG(default_charset)) {
|
||||
charset = SG(default_charset);
|
||||
}
|
||||
|
||||
#if HAVE_MBSTRING
|
||||
if (php_ob_handler_used("mb_output_handler" TSRMLS_CC)) {
|
||||
if (MBSTRG(current_http_output_encoding) == mbfl_no_encoding_pass) {
|
||||
charset = "US-ASCII";
|
||||
} else {
|
||||
charset = mbfl_no2preferred_mime_name(MBSTRG(current_http_output_encoding));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAVE_ICONV
|
||||
if (php_ob_handler_used("ob_iconv_handler" TSRMLS_CC)) {
|
||||
charset = ICONVG(output_encoding);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!charset || !charset[0]) {
|
||||
charset = "US-ASCII";
|
||||
}
|
||||
|
||||
*** none of that is needed now ***/
|
||||
|
||||
|
||||
PUTS("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"DTD/xhtml1-transitional.dtd\">\n");
|
||||
PUTS("<html>");
|
||||
PUTS("<head>\n");
|
||||
php_info_print_style(TSRMLS_C);
|
||||
php_info_print("<title>phpinfo()</title>");
|
||||
php_info_print("<meta name=\"ROBOTS\" content=\"NOINDEX,NOFOLLOW,NOARCHIVE\" />");
|
||||
php_info_print("</head>\n");
|
||||
php_info_print("<body><div class=\"center\">\n");
|
||||
PUTS("<title>phpinfo()</title>");
|
||||
PUTS("<meta name=\"ROBOTS\" content=\"NOINDEX,NOFOLLOW,NOARCHIVE\" />");
|
||||
/*
|
||||
php_printf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%s\" />\n", charset);
|
||||
*/
|
||||
PUTS("</head>\n");
|
||||
PUTS("<body><div class=\"center\">\n");
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -667,8 +650,8 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
|
|||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_print_info_htmlhead(TSRMLS_C);
|
||||
} else {
|
||||
php_info_print("phpinfo()\n");
|
||||
}
|
||||
PUTS("phpinfo()\n");
|
||||
}
|
||||
|
||||
if (flag & PHP_INFO_GENERAL) {
|
||||
char *zend_version = get_zend_version();
|
||||
|
@ -682,17 +665,21 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
|
|||
}
|
||||
|
||||
if (expose_php && !sapi_module.phpinfo_as_text) {
|
||||
php_info_print("<a href=\"http://www.php.net/\"><img border=\"0\" src=\"");
|
||||
php_info_print_request_uri(TSRMLS_C);
|
||||
php_info_print("?=");
|
||||
PUTS("<a href=\"http://www.php.net/\"><img border=\"0\" src=\"");
|
||||
if (SG(request_info).request_uri) {
|
||||
char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
|
||||
PUTS(elem_esc);
|
||||
efree(elem_esc);
|
||||
}
|
||||
PUTS("?=");
|
||||
logo_guid = php_logo_guid();
|
||||
php_info_print(logo_guid);
|
||||
PUTS(logo_guid);
|
||||
efree(logo_guid);
|
||||
php_info_print("\" alt=\"PHP Logo\" /></a>");
|
||||
PUTS("\" alt=\"PHP Logo\" /></a>");
|
||||
}
|
||||
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_printf("<h1 class=\"p\">PHP Version %s</h1>\n", PHP_VERSION);
|
||||
php_printf("<h1 class=\"p\">PHP Version %s</h1>\n", PHP_VERSION);
|
||||
} else {
|
||||
php_info_print_table_row(2, "PHP Version", PHP_VERSION);
|
||||
}
|
||||
|
@ -762,24 +749,139 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
|
|||
#else
|
||||
php_info_print_table_row(2, "IPv6 Support", "disabled" );
|
||||
#endif
|
||||
|
||||
php_info_print_stream_hash("PHP Streams", php_stream_get_url_stream_wrappers_hash() TSRMLS_CC);
|
||||
php_info_print_stream_hash("Stream Socket Transports", php_stream_xport_get_hash() TSRMLS_CC);
|
||||
php_info_print_stream_hash("Stream Filters", php_get_stream_filters_hash() TSRMLS_CC);
|
||||
{
|
||||
HashTable *url_stream_wrappers_hash;
|
||||
char *stream_protocol, *stream_protocols_buf = NULL;
|
||||
int stream_protocol_len, stream_protocols_buf_len = 0;
|
||||
ulong num_key;
|
||||
|
||||
if ((url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash())) {
|
||||
HashPosition pos;
|
||||
for (zend_hash_internal_pointer_reset_ex(url_stream_wrappers_hash, &pos);
|
||||
zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, (uint *)&stream_protocol_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING;
|
||||
zend_hash_move_forward_ex(url_stream_wrappers_hash, &pos)) {
|
||||
stream_protocols_buf = erealloc(stream_protocols_buf, stream_protocols_buf_len + stream_protocol_len + 2 + 1);
|
||||
memcpy(stream_protocols_buf + stream_protocols_buf_len, stream_protocol, stream_protocol_len - 1);
|
||||
stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len - 1] = ',';
|
||||
stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len] = ' ';
|
||||
stream_protocols_buf_len += stream_protocol_len + 1;
|
||||
}
|
||||
if (stream_protocols_buf) {
|
||||
stream_protocols_buf[stream_protocols_buf_len - 2] = ' ';
|
||||
stream_protocols_buf[stream_protocols_buf_len] = 0;
|
||||
php_info_print_table_row(2, "Registered PHP Streams", stream_protocols_buf);
|
||||
efree(stream_protocols_buf);
|
||||
} else {
|
||||
/* Any chances we will ever hit this? */
|
||||
php_info_print_table_row(2, "Registered PHP Streams", "no streams registered");
|
||||
}
|
||||
} else {
|
||||
/* Any chances we will ever hit this? */
|
||||
php_info_print_table_row(2, "PHP Streams", "disabled"); /* ?? */
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
HashTable *stream_xport_hash;
|
||||
char *xport_name, *xport_buf = NULL;
|
||||
int xport_name_len, xport_buf_len = 0, xport_buf_size = 0;
|
||||
ulong num_key;
|
||||
|
||||
if ((stream_xport_hash = php_stream_xport_get_hash())) {
|
||||
HashPosition pos;
|
||||
for(zend_hash_internal_pointer_reset_ex(stream_xport_hash, &pos);
|
||||
zend_hash_get_current_key_ex(stream_xport_hash, &xport_name, (uint *)&xport_name_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING;
|
||||
zend_hash_move_forward_ex(stream_xport_hash, &pos)) {
|
||||
if (xport_buf_len + xport_name_len + 2 > xport_buf_size) {
|
||||
while (xport_buf_len + xport_name_len + 2 > xport_buf_size) {
|
||||
xport_buf_size += 256;
|
||||
}
|
||||
if (xport_buf) {
|
||||
xport_buf = erealloc(xport_buf, xport_buf_size);
|
||||
} else {
|
||||
xport_buf = emalloc(xport_buf_size);
|
||||
}
|
||||
}
|
||||
if (xport_buf_len > 0) {
|
||||
xport_buf[xport_buf_len++] = ',';
|
||||
xport_buf[xport_buf_len++] = ' ';
|
||||
}
|
||||
memcpy(xport_buf + xport_buf_len, xport_name, xport_name_len - 1);
|
||||
xport_buf_len += xport_name_len - 1;
|
||||
xport_buf[xport_buf_len] = '\0';
|
||||
}
|
||||
if (xport_buf) {
|
||||
php_info_print_table_row(2, "Registered Stream Socket Transports", xport_buf);
|
||||
efree(xport_buf);
|
||||
} else {
|
||||
/* Any chances we will ever hit this? */
|
||||
php_info_print_table_row(2, "Registered Stream Socket Transports", "no transports registered");
|
||||
}
|
||||
} else {
|
||||
/* Any chances we will ever hit this? */
|
||||
php_info_print_table_row(2, "Stream Socket Transports", "disabled"); /* ?? */
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
HashTable *stream_filter_hash;
|
||||
char *filter_name, *filter_buf = NULL;
|
||||
int filter_name_len, filter_buf_len = 0, filter_buf_size = 0;
|
||||
ulong num_key;
|
||||
|
||||
if ((stream_filter_hash = php_get_stream_filters_hash())) {
|
||||
HashPosition pos;
|
||||
for(zend_hash_internal_pointer_reset_ex(stream_filter_hash, &pos);
|
||||
zend_hash_get_current_key_ex(stream_filter_hash, &filter_name, (uint *)&filter_name_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING;
|
||||
zend_hash_move_forward_ex(stream_filter_hash, &pos)) {
|
||||
if (filter_buf_len + filter_name_len + 2 > filter_buf_size) {
|
||||
while (filter_buf_len + filter_name_len + 2 > filter_buf_size) {
|
||||
filter_buf_size += 256;
|
||||
}
|
||||
if (filter_buf) {
|
||||
filter_buf = erealloc(filter_buf, filter_buf_size);
|
||||
} else {
|
||||
filter_buf = emalloc(filter_buf_size);
|
||||
}
|
||||
}
|
||||
if (filter_buf_len > 0) {
|
||||
filter_buf[filter_buf_len++] = ',';
|
||||
filter_buf[filter_buf_len++] = ' ';
|
||||
}
|
||||
memcpy(filter_buf + filter_buf_len, filter_name, filter_name_len - 1);
|
||||
filter_buf_len += filter_name_len - 1;
|
||||
filter_buf[filter_buf_len] = '\0';
|
||||
}
|
||||
if (filter_buf) {
|
||||
php_info_print_table_row(2, "Registered Stream Filters", filter_buf);
|
||||
efree(filter_buf);
|
||||
} else {
|
||||
/* Any chances we will ever hit this? */
|
||||
php_info_print_table_row(2, "Registered Stream Filters", "no filters registered");
|
||||
}
|
||||
} else {
|
||||
/* Any chances we will ever hit this? */
|
||||
php_info_print_table_row(2, "Stream Filters", "disabled"); /* ?? */
|
||||
}
|
||||
}
|
||||
|
||||
php_info_print_table_end();
|
||||
|
||||
/* Zend Engine */
|
||||
php_info_print_box_start(0);
|
||||
if (expose_php && !sapi_module.phpinfo_as_text) {
|
||||
php_info_print("<a href=\"http://www.zend.com/\"><img border=\"0\" src=\"");
|
||||
php_info_print_request_uri(TSRMLS_C);
|
||||
php_info_print("?="ZEND_LOGO_GUID"\" alt=\"Zend logo\" /></a>\n");
|
||||
PUTS("<a href=\"http://www.zend.com/\"><img border=\"0\" src=\"");
|
||||
if (SG(request_info).request_uri) {
|
||||
char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
|
||||
PUTS(elem_esc);
|
||||
efree(elem_esc);
|
||||
}
|
||||
PUTS("?="ZEND_LOGO_GUID"\" alt=\"Zend logo\" /></a>\n");
|
||||
}
|
||||
php_info_print("This program makes use of the Zend Scripting Language Engine:");
|
||||
php_info_print(!sapi_module.phpinfo_as_text?"<br />":"\n");
|
||||
PUTS("This program makes use of the Zend Scripting Language Engine:");
|
||||
PUTS(!sapi_module.phpinfo_as_text?"<br />":"\n");
|
||||
if (sapi_module.phpinfo_as_text) {
|
||||
php_info_print(zend_version);
|
||||
PUTS(zend_version);
|
||||
} else {
|
||||
zend_html_puts(zend_version, strlen(zend_version) TSRMLS_CC);
|
||||
}
|
||||
|
@ -789,11 +891,15 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
|
|||
|
||||
if ((flag & PHP_INFO_CREDITS) && expose_php && !sapi_module.phpinfo_as_text) {
|
||||
php_info_print_hr();
|
||||
php_info_print("<h1><a href=\"");
|
||||
php_info_print_request_uri(TSRMLS_C);
|
||||
php_info_print("?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000\">");
|
||||
php_info_print("PHP Credits");
|
||||
php_info_print("</a></h1>\n");
|
||||
PUTS("<h1><a href=\"");
|
||||
if (SG(request_info).request_uri) {
|
||||
char *elem_esc = php_info_html_esc(SG(request_info).request_uri TSRMLS_CC);
|
||||
PUTS(elem_esc);
|
||||
efree(elem_esc);
|
||||
}
|
||||
PUTS("?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000\">");
|
||||
PUTS("PHP Credits");
|
||||
PUTS("</a></h1>\n");
|
||||
}
|
||||
|
||||
zend_ini_sort_entries(TSRMLS_C);
|
||||
|
@ -801,7 +907,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
|
|||
if (flag & PHP_INFO_CONFIGURATION) {
|
||||
php_info_print_hr();
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("<h1>Configuration</h1>\n");
|
||||
PUTS("<h1>Configuration</h1>\n");
|
||||
} else {
|
||||
SECTION("Configuration");
|
||||
}
|
||||
|
@ -881,108 +987,103 @@ PHPAPI void php_print_info(int flag TSRMLS_DC)
|
|||
if (!sapi_module.phpinfo_as_text) {
|
||||
SECTION("PHP License");
|
||||
php_info_print_box_start(0);
|
||||
php_info_print("<p>\n");
|
||||
php_info_print("This program is free software; you can redistribute it and/or modify ");
|
||||
php_info_print("it under the terms of the PHP License as published by the PHP Group ");
|
||||
php_info_print("and included in the distribution in the file: LICENSE\n");
|
||||
php_info_print("</p>\n");
|
||||
php_info_print("<p>");
|
||||
php_info_print("This program is distributed in the hope that it will be useful, ");
|
||||
php_info_print("but WITHOUT ANY WARRANTY; without even the implied warranty of ");
|
||||
php_info_print("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
||||
php_info_print("</p>\n");
|
||||
php_info_print("<p>");
|
||||
php_info_print("If you did not receive a copy of the PHP license, or have any questions about ");
|
||||
php_info_print("PHP licensing, please contact license@php.net.\n");
|
||||
php_info_print("</p>\n");
|
||||
PUTS("<p>\n");
|
||||
PUTS("This program is free software; you can redistribute it and/or modify ");
|
||||
PUTS("it under the terms of the PHP License as published by the PHP Group ");
|
||||
PUTS("and included in the distribution in the file: LICENSE\n");
|
||||
PUTS("</p>\n");
|
||||
PUTS("<p>");
|
||||
PUTS("This program is distributed in the hope that it will be useful, ");
|
||||
PUTS("but WITHOUT ANY WARRANTY; without even the implied warranty of ");
|
||||
PUTS("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
||||
PUTS("</p>\n");
|
||||
PUTS("<p>");
|
||||
PUTS("If you did not receive a copy of the PHP license, or have any questions about ");
|
||||
PUTS("PHP licensing, please contact license@php.net.\n");
|
||||
PUTS("</p>\n");
|
||||
php_info_print_box_end();
|
||||
} else {
|
||||
php_info_print("\nPHP License\n");
|
||||
php_info_print("This program is free software; you can redistribute it and/or modify\n");
|
||||
php_info_print("it under the terms of the PHP License as published by the PHP Group\n");
|
||||
php_info_print("and included in the distribution in the file: LICENSE\n");
|
||||
php_info_print("\n");
|
||||
php_info_print("This program is distributed in the hope that it will be useful,\n");
|
||||
php_info_print("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
|
||||
php_info_print("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
||||
php_info_print("\n");
|
||||
php_info_print("If you did not receive a copy of the PHP license, or have any\n");
|
||||
php_info_print("questions about PHP licensing, please contact license@php.net.\n");
|
||||
PUTS("\nPHP License\n");
|
||||
PUTS("This program is free software; you can redistribute it and/or modify\n");
|
||||
PUTS("it under the terms of the PHP License as published by the PHP Group\n");
|
||||
PUTS("and included in the distribution in the file: LICENSE\n");
|
||||
PUTS("\n");
|
||||
PUTS("This program is distributed in the hope that it will be useful,\n");
|
||||
PUTS("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
|
||||
PUTS("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
||||
PUTS("\n");
|
||||
PUTS("If you did not receive a copy of the PHP license, or have any\n");
|
||||
PUTS("questions about PHP licensing, please contact license@php.net.\n");
|
||||
}
|
||||
}
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("</div></body></html>");
|
||||
PUTS("</div></body></html>");
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
PHPAPI void php_info_print_table_start(void) /* {{{ */
|
||||
|
||||
PHPAPI void php_info_print_table_start(void)
|
||||
{
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("<table border=\"0\" cellpadding=\"3\" width=\"600\">\n");
|
||||
php_printf("<table border=\"0\" cellpadding=\"3\" width=\"600\">\n");
|
||||
} else {
|
||||
php_info_print("\n");
|
||||
php_printf("\n");
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
PHPAPI void php_info_print_table_end(void) /* {{{ */
|
||||
PHPAPI void php_info_print_table_end(void)
|
||||
{
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("</table><br />\n");
|
||||
php_printf("</table><br />\n");
|
||||
}
|
||||
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
PHPAPI void php_info_print_box_start(int flag) /* {{{ */
|
||||
PHPAPI void php_info_print_box_start(int flag)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
if (flag) {
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("<tr class=\"h\"><td>\n");
|
||||
php_printf("<tr class=\"h\"><td>\n");
|
||||
}
|
||||
} else {
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("<tr class=\"v\"><td>\n");
|
||||
php_printf("<tr class=\"v\"><td>\n");
|
||||
} else {
|
||||
php_info_print("\n");
|
||||
php_printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
PHPAPI void php_info_print_box_end(void) /* {{{ */
|
||||
PHPAPI void php_info_print_box_end(void)
|
||||
{
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("</td></tr>\n");
|
||||
php_printf("</td></tr>\n");
|
||||
}
|
||||
php_info_print_table_end();
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
PHPAPI void php_info_print_hr(void) /* {{{ */
|
||||
PHPAPI void php_info_print_hr(void)
|
||||
{
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("<hr />\n");
|
||||
php_printf("<hr />\n");
|
||||
} else {
|
||||
php_info_print("\n\n _______________________________________________________________________\n\n");
|
||||
php_printf("\n\n _______________________________________________________________________\n\n");
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
PHPAPI void php_info_print_table_colspan_header(int num_cols, char *header) /* {{{ */
|
||||
PHPAPI void php_info_print_table_colspan_header(int num_cols, char *header)
|
||||
{
|
||||
int spaces;
|
||||
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_printf("<tr class=\"h\"><th colspan=\"%d\">%s</th></tr>\n", num_cols, header );
|
||||
php_printf("<tr class=\"h\"><th colspan=\"%d\">%s</th></tr>\n", num_cols, header );
|
||||
} else {
|
||||
spaces = (74 - strlen(header));
|
||||
php_info_printf("%*s%s%*s\n", (int)(spaces/2), " ", header, (int)(spaces/2), " ");
|
||||
php_printf("%*s%s%*s\n", (int)(spaces/2), " ", header, (int)(spaces/2), " ");
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_info_print_table_header
|
||||
*/
|
||||
|
@ -992,9 +1093,11 @@ PHPAPI void php_info_print_table_header(int num_cols, ...)
|
|||
va_list row_elements;
|
||||
char *row_element;
|
||||
|
||||
TSRMLS_FETCH();
|
||||
|
||||
va_start(row_elements, num_cols);
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("<tr class=\"h\">");
|
||||
php_printf("<tr class=\"h\">");
|
||||
}
|
||||
for (i=0; i<num_cols; i++) {
|
||||
row_element = va_arg(row_elements, char *);
|
||||
|
@ -1002,21 +1105,21 @@ PHPAPI void php_info_print_table_header(int num_cols, ...)
|
|||
row_element = " ";
|
||||
}
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("<th>");
|
||||
php_info_print(row_element);
|
||||
php_info_print("</th>");
|
||||
PUTS("<th>");
|
||||
PUTS(row_element);
|
||||
PUTS("</th>");
|
||||
} else {
|
||||
php_info_print(row_element);
|
||||
PUTS(row_element);
|
||||
if (i < num_cols-1) {
|
||||
php_info_print(" => ");
|
||||
PUTS(" => ");
|
||||
} else {
|
||||
php_info_print("\n");
|
||||
}
|
||||
}
|
||||
PUTS("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("</tr>\n");
|
||||
}
|
||||
php_printf("</tr>\n");
|
||||
}
|
||||
|
||||
va_end(row_elements);
|
||||
}
|
||||
|
@ -1029,41 +1132,49 @@ static void php_info_print_table_row_internal(int num_cols,
|
|||
{
|
||||
int i;
|
||||
char *row_element;
|
||||
char *elem_esc = NULL;
|
||||
/*
|
||||
int elem_esc_len;
|
||||
*/
|
||||
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("<tr>");
|
||||
php_printf("<tr>");
|
||||
}
|
||||
for (i=0; i<num_cols; i++) {
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_printf("<td class=\"%s\">",
|
||||
php_printf("<td class=\"%s\">",
|
||||
(i==0 ? "e" : value_class )
|
||||
);
|
||||
}
|
||||
row_element = va_arg(row_elements, char *);
|
||||
if (!row_element || !*row_element) {
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print( "<i>no value</i>" );
|
||||
PUTS( "<i>no value</i>" );
|
||||
} else {
|
||||
php_info_print( " " );
|
||||
PUTS( " " );
|
||||
}
|
||||
} else {
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print_html_esc(row_element, strlen(row_element));
|
||||
elem_esc = php_info_html_esc(row_element TSRMLS_CC);
|
||||
PUTS(elem_esc);
|
||||
efree(elem_esc);
|
||||
} else {
|
||||
php_info_print(row_element);
|
||||
PUTS(row_element);
|
||||
if (i < num_cols-1) {
|
||||
php_info_print(" => ");
|
||||
PUTS(" => ");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print(" </td>");
|
||||
php_printf(" </td>");
|
||||
} else if (i == (num_cols - 1)) {
|
||||
php_info_print("\n");
|
||||
PUTS("\n");
|
||||
}
|
||||
}
|
||||
if (!sapi_module.phpinfo_as_text) {
|
||||
php_info_print("</tr>\n");
|
||||
php_printf("</tr>\n");
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -1127,9 +1238,9 @@ PHP_FUNCTION(phpinfo)
|
|||
}
|
||||
|
||||
/* Andale! Andale! Yee-Hah! */
|
||||
php_output_start_default(TSRMLS_C);
|
||||
php_start_ob_buffer(NULL, 4096, 0 TSRMLS_CC);
|
||||
php_print_info(flag TSRMLS_CC);
|
||||
php_output_end(TSRMLS_C);
|
||||
php_end_ob_buffer(1, 0 TSRMLS_CC);
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
@ -1140,18 +1251,20 @@ PHP_FUNCTION(phpinfo)
|
|||
Return the current PHP version */
|
||||
PHP_FUNCTION(phpversion)
|
||||
{
|
||||
char *ext_name = NULL;
|
||||
int ext_name_len = 0;
|
||||
zval **arg;
|
||||
const char *version;
|
||||
int argc = ZEND_NUM_ARGS();
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &ext_name, &ext_name_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ext_name) {
|
||||
if (argc == 0) {
|
||||
RETURN_STRING(PHP_VERSION, 1);
|
||||
} else {
|
||||
const char *version;
|
||||
version = zend_get_module_version(ext_name);
|
||||
if (zend_parse_parameters(argc TSRMLS_CC, "Z", &arg) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
convert_to_string_ex(arg);
|
||||
version = zend_get_module_version(Z_STRVAL_PP(arg));
|
||||
|
||||
if (version == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -1175,6 +1288,7 @@ PHP_FUNCTION(phpcredits)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ php_logo_guid
|
||||
*/
|
||||
PHPAPI char *php_logo_guid(void)
|
||||
|
@ -1202,6 +1316,7 @@ PHPAPI char *php_logo_guid(void)
|
|||
Return the special ID used to request the PHP logo in phpinfo screens*/
|
||||
PHP_FUNCTION(php_logo_guid)
|
||||
{
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
@ -1214,6 +1329,7 @@ PHP_FUNCTION(php_logo_guid)
|
|||
Return the special ID used to request the PHP logo in phpinfo screens*/
|
||||
PHP_FUNCTION(php_real_logo_guid)
|
||||
{
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
@ -1269,7 +1385,6 @@ PHP_FUNCTION(php_uname)
|
|||
{
|
||||
char *mode = "a";
|
||||
int modelen = sizeof("a")-1;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &mode, &modelen) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,5 @@ var_dump( ob_get_flush() );
|
|||
|
||||
Warning: ob_get_flush() expects exactly 0 parameters, 1 given in %s on line %d
|
||||
NULL
|
||||
|
||||
Notice: ob_get_flush(): failed to delete and flush buffer. No buffer to delete or flush in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
|
|
|
@ -37,7 +37,6 @@ Thread Safety => %s
|
|||
Zend Memory Manager => %s
|
||||
Zend Multibyte Support => %s
|
||||
IPv6 Support => %s
|
||||
|
||||
Registered PHP Streams => %s
|
||||
Registered Stream Socket Transports => %s
|
||||
Registered Stream Filters => %s
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* Generated by re2c 0.13.5 on Tue Dec 8 14:00:51 2009 */
|
||||
/* Generated by re2c 0.13.5 on Mon Jul 27 02:20:40 2009 */
|
||||
#line 1 "ext/standard/url_scanner_ex.re"
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 6 |
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2006 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
|
@ -993,7 +993,7 @@ static void php_url_scanner_output_handler(char *output, uint output_len, char *
|
|||
size_t len;
|
||||
|
||||
if (BG(url_adapt_state_ex).url_app.len != 0) {
|
||||
*handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END | PHP_OUTPUT_HANDLER_CONT | PHP_OUTPUT_HANDLER_FLUSH | PHP_OUTPUT_HANDLER_FINAL) ? 1 : 0) TSRMLS_CC);
|
||||
*handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END | PHP_OUTPUT_HANDLER_CONT) ? 1 : 0) TSRMLS_CC);
|
||||
if (sizeof(uint) < sizeof(size_t)) {
|
||||
if (len > UINT_MAX)
|
||||
len = UINT_MAX;
|
||||
|
@ -1024,15 +1024,11 @@ PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int va
|
|||
char *encoded;
|
||||
int encoded_len;
|
||||
smart_str val;
|
||||
zval *ob_name;
|
||||
|
||||
if (! BG(url_adapt_state_ex).active) {
|
||||
MAKE_STD_ZVAL(ob_name);
|
||||
ZVAL_STRING(ob_name, "URL-Rewriter", 1);
|
||||
php_url_scanner_ex_activate(TSRMLS_C);
|
||||
php_output_start_internal(ob_name, php_url_scanner_output_handler, 0, PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC);
|
||||
php_ob_set_internal_handler(php_url_scanner_output_handler, 0, "URL-Rewriter", 1 TSRMLS_CC);
|
||||
BG(url_adapt_state_ex).active = 1;
|
||||
zval_ptr_dtor(&ob_name);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 6 |
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2006 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
|
@ -431,7 +431,7 @@ static void php_url_scanner_output_handler(char *output, uint output_len, char *
|
|||
size_t len;
|
||||
|
||||
if (BG(url_adapt_state_ex).url_app.len != 0) {
|
||||
*handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END | PHP_OUTPUT_HANDLER_CONT | PHP_OUTPUT_HANDLER_FLUSH | PHP_OUTPUT_HANDLER_FINAL) ? 1 : 0) TSRMLS_CC);
|
||||
*handled_output = url_adapt_ext(output, output_len, &len, (zend_bool) (mode & (PHP_OUTPUT_HANDLER_END | PHP_OUTPUT_HANDLER_CONT) ? 1 : 0) TSRMLS_CC);
|
||||
if (sizeof(uint) < sizeof(size_t)) {
|
||||
if (len > UINT_MAX)
|
||||
len = UINT_MAX;
|
||||
|
@ -462,15 +462,11 @@ PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int va
|
|||
char *encoded;
|
||||
int encoded_len;
|
||||
smart_str val;
|
||||
zval *ob_name;
|
||||
|
||||
if (! BG(url_adapt_state_ex).active) {
|
||||
MAKE_STD_ZVAL(ob_name);
|
||||
ZVAL_STRING(ob_name, "URL-Rewriter", 1);
|
||||
php_url_scanner_ex_activate(TSRMLS_C);
|
||||
php_output_start_internal(ob_name, php_url_scanner_output_handler, 0, PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC);
|
||||
php_ob_set_internal_handler(php_url_scanner_output_handler, 0, "URL-Rewriter", 1 TSRMLS_CC);
|
||||
BG(url_adapt_state_ex).active = 1;
|
||||
zval_ptr_dtor(&ob_name);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -453,14 +453,14 @@ PHP_FUNCTION(var_export)
|
|||
}
|
||||
|
||||
if (return_output) {
|
||||
php_output_start_default(TSRMLS_C);
|
||||
php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
|
||||
}
|
||||
|
||||
php_var_export(&var, 1 TSRMLS_CC);
|
||||
|
||||
if (return_output) {
|
||||
php_output_get_contents(return_value TSRMLS_CC);
|
||||
php_output_discard(TSRMLS_C);
|
||||
php_ob_get_buffer (return_value TSRMLS_CC);
|
||||
php_end_ob_buffer (0, 0 TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -36,7 +36,6 @@ extern zend_module_entry tidy_module_entry;
|
|||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(tidy)
|
||||
char *default_config;
|
||||
zend_bool clean_output;
|
||||
ZEND_END_MODULE_GLOBALS(tidy)
|
||||
|
||||
#ifdef ZTS
|
||||
|
|
492
ext/tidy/tidy.c
492
ext/tidy/tidy.c
File diff suppressed because it is too large
Load diff
|
@ -1,2 +1,2 @@
|
|||
Zlib
|
||||
Rasmus Lerdorf, Stefan Roehrich, Zeev Suraski, Jade Nicoletti, Michael Wallner
|
||||
Rasmus Lerdorf, Stefan Roehrich, Zeev Suraski, Jade Nicoletti
|
||||
|
|
|
@ -41,17 +41,10 @@ if test "$PHP_ZLIB" != "no" || test "$PHP_ZLIB_DIR" != "no"; then
|
|||
*) ac_extra=-L$ZLIB_DIR/$PHP_LIBDIR ;;
|
||||
esac
|
||||
|
||||
AC_MSG_CHECKING([for zlib version >= 1.2.0.4])
|
||||
ZLIB_VERSION=`$EGREP "define ZLIB_VERSION" $ZLIB_DIR/include/zlib.h | $SED -e 's/[[^0-9\.]]//g'`
|
||||
AC_MSG_RESULT([$ZLIB_VERSION])
|
||||
if test `echo $ZLIB_VERSION | $SED -e 's/[[^0-9]]/ /g' | $AWK '{print $1*1000000 + $2*10000 + $3*100 + $4}'` -lt 1020004; then
|
||||
AC_MSG_ERROR([libz version greater or equal to 1.2.0.4 required])
|
||||
fi
|
||||
|
||||
PHP_CHECK_LIBRARY(z, gzgets, [
|
||||
AC_DEFINE(HAVE_ZLIB,1,[ ])
|
||||
],[
|
||||
AC_MSG_ERROR(ZLIB extension requires gzgets in zlib)
|
||||
AC_MSG_ERROR(ZLIB extension requires zlib >= 1.0.9)
|
||||
],[
|
||||
$ac_extra
|
||||
])
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
+----------------------------------------------------------------------+
|
||||
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
|
||||
| Stefan Röhrich <sr@linux.de> |
|
||||
| Michael Wallner <mike@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
@ -25,50 +24,39 @@
|
|||
|
||||
#include <zlib.h>
|
||||
|
||||
#define PHP_ZLIB_ENCODING_RAW -0xf
|
||||
#define PHP_ZLIB_ENCODING_GZIP 0x1f
|
||||
#define PHP_ZLIB_ENCODING_DEFLATE 0x0f
|
||||
|
||||
#define PHP_ZLIB_ENCODING_ANY 0x2f
|
||||
|
||||
#define PHP_ZLIB_OUTPUT_HANDLER_NAME "zlib output compression"
|
||||
#define PHP_ZLIB_BUFFER_SIZE_GUESS(in_len) (((size_t) ((double) in_len * (double) 1.015)) + 10 + 8 + 4 + 1)
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(zlib)
|
||||
/* variables for transparent gzip encoding */
|
||||
int compression_coding;
|
||||
z_stream stream;
|
||||
uLong crc;
|
||||
int ob_gzhandler_status;
|
||||
long output_compression;
|
||||
long output_compression_level;
|
||||
char *output_handler;
|
||||
ZEND_END_MODULE_GLOBALS(zlib);
|
||||
ZEND_END_MODULE_GLOBALS(zlib)
|
||||
|
||||
typedef struct _php_zlib_buffer {
|
||||
char *data;
|
||||
char *aptr;
|
||||
size_t used;
|
||||
size_t free;
|
||||
size_t size;
|
||||
} php_zlib_buffer;
|
||||
PHPAPI ZEND_EXTERN_MODULE_GLOBALS(zlib)
|
||||
|
||||
typedef struct _php_zlib_context {
|
||||
z_stream Z;
|
||||
php_zlib_buffer buffer;
|
||||
} php_zlib_context;
|
||||
|
||||
php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
|
||||
extern php_stream_ops php_stream_gzio_ops;
|
||||
extern php_stream_wrapper php_stream_gzip_wrapper;
|
||||
extern php_stream_filter_factory php_zlib_filter_factory;
|
||||
extern zend_module_entry php_zlib_module_entry;
|
||||
#define zlib_module_ptr &php_zlib_module_entry
|
||||
#define phpext_zlib_ptr zlib_module_ptr
|
||||
|
||||
int php_ob_gzhandler_check(TSRMLS_D);
|
||||
|
||||
php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
|
||||
extern php_stream_wrapper php_stream_gzip_wrapper;
|
||||
|
||||
#ifdef ZTS
|
||||
# define ZLIBG(v) TSRMG(zlib_globals_id, zend_zlib_globals *, v)
|
||||
#define ZLIBG(v) TSRMG(zlib_globals_id, zend_zlib_globals *, v)
|
||||
#else
|
||||
# define ZLIBG(v) (zlib_globals.v)
|
||||
#define ZLIBG(v) (zlib_globals.v)
|
||||
#endif
|
||||
|
||||
#define phpext_zlib_ptr zlib_module_ptr
|
||||
|
||||
#define CODING_GZIP 1
|
||||
#define CODING_DEFLATE 2
|
||||
|
||||
#endif /* PHP_ZLIB_H */
|
||||
|
||||
/*
|
||||
|
|
|
@ -28,7 +28,7 @@ var_dump(gzuncompress("", 9));
|
|||
|
||||
var_dump(gzuncompress($data1));
|
||||
var_dump(gzuncompress($data2));
|
||||
$data2[4] = 0;
|
||||
$data2{4} = 0;
|
||||
var_dump(gzuncompress($data2));
|
||||
|
||||
echo "Done\n";
|
||||
|
|
|
@ -48,8 +48,6 @@ string(%d) "%a"
|
|||
|
||||
Warning: gzinflate() expects at least 1 parameter, 0 given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: gzinflate(): data error in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gzinflate(): data error in %s on line %d
|
||||
|
|
|
@ -11,8 +11,8 @@ var_dump(gzencode("", -10));
|
|||
var_dump(gzencode("", 100));
|
||||
var_dump(gzencode("", 1, 100));
|
||||
|
||||
var_dump(gzencode("", -1, ZLIB_ENCODING_GZIP));
|
||||
var_dump(gzencode("", 9, ZLIB_ENCODING_DEFLATE));
|
||||
var_dump(gzencode("", -1, 1));
|
||||
var_dump(gzencode("", 9, 2));
|
||||
|
||||
$string = "Light of my sun
|
||||
Light in this temple
|
||||
|
@ -21,8 +21,8 @@ Lies in the darkness";
|
|||
|
||||
var_dump(gzencode($string, 9, 3));
|
||||
|
||||
var_dump(gzencode($string, -1, ZLIB_ENCODING_GZIP));
|
||||
var_dump(gzencode($string, 9, ZLIB_ENCODING_DEFLATE));
|
||||
var_dump(gzencode($string, -1, 1));
|
||||
var_dump(gzencode($string, 9, 2));
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
|
@ -33,18 +33,18 @@ NULL
|
|||
Warning: gzencode() expects at most 3 parameters, 4 given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: gzencode(): compression level (-10) must be within -1..9 in %s on line %d
|
||||
Warning: gzencode(): compression level(-10) must be within -1..9 in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gzencode(): compression level (100) must be within -1..9 in %s on line %d
|
||||
Warning: gzencode(): compression level(100) must be within -1..9 in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gzencode(): encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d
|
||||
Warning: gzencode(): encoding mode must be FORCE_GZIP or FORCE_DEFLATE in %s on line %d
|
||||
bool(false)
|
||||
string(%d) "%s"
|
||||
string(%d) "%s"
|
||||
|
||||
Warning: gzencode(): encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d
|
||||
Warning: gzencode(): encoding mode must be FORCE_GZIP or FORCE_DEFLATE in %s on line %d
|
||||
bool(false)
|
||||
string(%d) "%s"
|
||||
string(%d) "%s"
|
||||
|
|
|
@ -8,7 +8,7 @@ if (!extension_loaded("zlib")) {
|
|||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string gzcompress(string data [, int level, [int encoding]])
|
||||
/* Prototype : string gzcompress(string data [, int level])
|
||||
* Description: Gzip-compress a string
|
||||
* Source code: ext/zlib/zlib.c
|
||||
* Alias to functions:
|
||||
|
@ -63,7 +63,7 @@ int(0)
|
|||
string(32) "c2e070f4320d1f674965eaab95b53d9c"
|
||||
int(0)
|
||||
-- Compression level 2 --
|
||||
string(32) "36922f486410d08209d0d0d21b26030e"
|
||||
string(32) "400a53d19ca337727f8cd362f5cd3ee0"
|
||||
int(0)
|
||||
-- Compression level 3 --
|
||||
string(32) "a441a2f5169bb303cd45b860a5a9dbf9"
|
||||
|
@ -122,4 +122,4 @@ int(0)
|
|||
|
||||
-- Testing with no specified compression level --
|
||||
string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb"
|
||||
===Done===
|
||||
===Done===
|
|
@ -8,7 +8,7 @@ if (!extension_loaded("zlib")) {
|
|||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string gzcompress(string data [, int level, [int encoding]])
|
||||
/* Prototype : string gzcompress(string data [, int level])
|
||||
* Description: Gzip-compress a string
|
||||
* Source code: ext/zlib/zlib.c
|
||||
* Alias to functions:
|
||||
|
@ -28,30 +28,26 @@ var_dump( gzcompress() );
|
|||
echo "\n-- Testing gzcompress() function with more than expected no. of arguments --\n";
|
||||
$data = 'string_val';
|
||||
$level = 2;
|
||||
$encoding = ZLIB_ENCODING_RAW;
|
||||
$extra_arg = 10;
|
||||
var_dump( gzcompress($data, $level, $encoding, $extra_arg) );
|
||||
var_dump( gzcompress($data, $level, $extra_arg) );
|
||||
|
||||
echo "\n-- Testing with incorrect compression level --\n";
|
||||
$bad_level = 99;
|
||||
var_dump(gzcompress($data, $bad_level));
|
||||
|
||||
echo "\n-- Testing with invalid encoding --\n";
|
||||
$data = 'string_val';
|
||||
$encoding = 99;
|
||||
var_dump(gzcompress($data, $level, $encoding));
|
||||
|
||||
echo "\n-- Testing with incorrect parameters --\n";
|
||||
|
||||
class Tester {
|
||||
function Hello() {
|
||||
echo "Hello\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo "\n-- Testing with incorrect parameters --\n";
|
||||
$testclass = new Tester();
|
||||
var_dump(gzcompress($testclass));
|
||||
|
||||
var_dump(gzcompress($data, $testclass));
|
||||
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
|
@ -64,7 +60,7 @@ NULL
|
|||
|
||||
-- Testing gzcompress() function with more than expected no. of arguments --
|
||||
|
||||
Warning: gzcompress() expects at most 3 parameters, 4 given in %s on line %d
|
||||
Warning: gzcompress() expects at most 2 parameters, 3 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing with incorrect compression level --
|
||||
|
@ -72,13 +68,11 @@ NULL
|
|||
Warning: gzcompress(): compression level (99) must be within -1..9 in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing with invalid encoding --
|
||||
|
||||
Warning: gzcompress(): encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing with incorrect parameters --
|
||||
|
||||
Warning: gzcompress() expects parameter 1 to be string, object given in %s on line %d
|
||||
NULL
|
||||
===Done===
|
||||
|
||||
Warning: gzcompress() expects parameter 2 to be long, object given in %s on line %d
|
||||
NULL
|
||||
===Done===
|
|
@ -8,7 +8,7 @@ if (!extension_loaded("zlib")) {
|
|||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string gzcompress(string data [, int level, [int encoding]])
|
||||
/* Prototype : string gzcompress(string data [, int level])
|
||||
* Description: Gzip-compress a string
|
||||
* Source code: ext/zlib/zlib.c
|
||||
* Alias to functions:
|
||||
|
@ -18,6 +18,8 @@ include(dirname(__FILE__) . '/data.inc');
|
|||
|
||||
echo "*** Testing gzcompress() : variation ***\n";
|
||||
|
||||
|
||||
|
||||
echo "\n-- Testing multiple compression --\n";
|
||||
$output = gzcompress($data);
|
||||
var_dump( md5($output));
|
||||
|
@ -31,4 +33,4 @@ var_dump(md5(gzcompress($output)));
|
|||
-- Testing multiple compression --
|
||||
string(32) "764809aef15bb34cb73ad49ecb600d99"
|
||||
string(32) "eba942bc2061f23ea8688cc5101872a4"
|
||||
===Done===
|
||||
===Done===
|
|
@ -8,7 +8,7 @@ if (!extension_loaded("zlib")) {
|
|||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string gzdeflate(string data [, int level, [int encoding]])
|
||||
/* Prototype : proto string gzdeflate(string data [, int level])
|
||||
* Description: Gzip-compress a string
|
||||
* Source code: ext/zlib/zlib.c
|
||||
* Alias to functions:
|
||||
|
|
|
@ -8,7 +8,7 @@ if (!extension_loaded("zlib")) {
|
|||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string gzdeflate(string data [, int level, [int encoding]])
|
||||
/* Prototype : string gzdeflate(string data [, int level])
|
||||
* Description: Gzip-compress a string
|
||||
* Source code: ext/zlib/zlib.c
|
||||
* Alias to functions:
|
||||
|
@ -28,18 +28,13 @@ var_dump( gzdeflate() );
|
|||
echo "\n-- Testing gzdeflate() function with more than expected no. of arguments --\n";
|
||||
$data = 'string_val';
|
||||
$level = 2;
|
||||
$encoding = ZLIB_ENCODING_RAW;
|
||||
$extra_arg = 10;
|
||||
var_dump( gzdeflate($data, $level, $encoding, $extra_arg) );
|
||||
var_dump( gzdeflate($data, $level, $extra_arg) );
|
||||
|
||||
echo "\n-- Testing with incorrect compression level --\n";
|
||||
$bad_level = 99;
|
||||
var_dump(gzdeflate($data, $bad_level));
|
||||
|
||||
echo "\n-- Testing with incorrect encoding --\n";
|
||||
$bad_encoding = 99;
|
||||
var_dump(gzdeflate($data, $level, $bad_encoding));
|
||||
|
||||
class Tester {
|
||||
function Hello() {
|
||||
echo "Hello\n";
|
||||
|
@ -63,7 +58,7 @@ NULL
|
|||
|
||||
-- Testing gzdeflate() function with more than expected no. of arguments --
|
||||
|
||||
Warning: gzdeflate() expects at most 3 parameters, 4 given in %s on line %d
|
||||
Warning: gzdeflate() expects at most 2 parameters, 3 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing with incorrect compression level --
|
||||
|
@ -71,11 +66,6 @@ NULL
|
|||
Warning: gzdeflate(): compression level (99) must be within -1..9 in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing with incorrect encoding --
|
||||
|
||||
Warning: gzdeflate(): encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing with incorrect parameters --
|
||||
|
||||
Warning: gzdeflate() expects parameter 1 to be string, object given in %s on line %d
|
||||
|
@ -83,4 +73,4 @@ NULL
|
|||
|
||||
Warning: gzdeflate() expects parameter 2 to be long, object given in %s on line %d
|
||||
NULL
|
||||
===Done===
|
||||
===Done===
|
|
@ -18,6 +18,8 @@ include(dirname(__FILE__) . '/data.inc');
|
|||
|
||||
echo "*** Testing gzdeflate() : variation ***\n";
|
||||
|
||||
|
||||
|
||||
echo "\n-- Testing multiple compression --\n";
|
||||
$output = gzdeflate($data);
|
||||
var_dump( md5($output));
|
||||
|
|
|
@ -51,13 +51,6 @@ for($i = -1; $i < 10; $i++) {
|
|||
var_dump(md5($output));
|
||||
}
|
||||
|
||||
// Calling gzencode() with mandatory arguments
|
||||
echo "\n-- Testing with no specified compression level --\n";
|
||||
var_dump(bin2hex(gzencode($smallstring)));
|
||||
|
||||
echo "\n-- Testing gzencode with mode specified --\n";
|
||||
var_dump(bin2hex(gzencode($smallstring, -1, FORCE_GZIP)));
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
|
@ -65,9 +58,9 @@ var_dump(bin2hex(gzencode($smallstring, -1, FORCE_GZIP)));
|
|||
-- Compression level -1 --
|
||||
string(32) "d9ede02415ce91d21e5a94274e2b9c42"
|
||||
-- Compression level 0 --
|
||||
string(32) "bbf32d5508e5f1f4e6d42790489dae15"
|
||||
string(32) "67aaf60426bb2cbd86d7fe530cb12306"
|
||||
-- Compression level 1 --
|
||||
string(32) "0bfaaa7a5a57f8fb533074fca6c85eeb"
|
||||
string(32) "bce9c439cf767c1988ff4881b287d1ce"
|
||||
-- Compression level 2 --
|
||||
string(32) "7ddbfed63a76c42808722b66f1c133fc"
|
||||
-- Compression level 3 --
|
||||
|
@ -83,13 +76,13 @@ string(32) "d9ede02415ce91d21e5a94274e2b9c42"
|
|||
-- Compression level 8 --
|
||||
string(32) "d9ede02415ce91d21e5a94274e2b9c42"
|
||||
-- Compression level 9 --
|
||||
string(32) "0f220a09e9895bcb3a1308d2bc99cfdf"
|
||||
string(32) "d9ede02415ce91d21e5a94274e2b9c42"
|
||||
-- Compression level -1 --
|
||||
string(32) "f77bd31e1e4dd11d12828fb661a08010"
|
||||
-- Compression level 0 --
|
||||
string(32) "9c5005db88490d6fe102ea2c233b2872"
|
||||
string(32) "36220d650930849b67e8e0622f9bf270"
|
||||
-- Compression level 1 --
|
||||
string(32) "d24ff7c4c20cef69b9c3abd603368db9"
|
||||
string(32) "f77bd31e1e4dd11d12828fb661a08010"
|
||||
-- Compression level 2 --
|
||||
string(32) "f77bd31e1e4dd11d12828fb661a08010"
|
||||
-- Compression level 3 --
|
||||
|
@ -105,11 +98,5 @@ string(32) "f77bd31e1e4dd11d12828fb661a08010"
|
|||
-- Compression level 8 --
|
||||
string(32) "f77bd31e1e4dd11d12828fb661a08010"
|
||||
-- Compression level 9 --
|
||||
string(32) "8849e9a1543c04b3f882b5ce20839ed2"
|
||||
|
||||
-- Testing with no specified compression level --
|
||||
string(94) "1f8b08000000000000%c%c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200edc4e40b1b000000"
|
||||
|
||||
-- Testing gzencode with mode specified --
|
||||
string(94) "1f8b08000000000000%c%c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200edc4e40b1b000000"
|
||||
===Done===
|
||||
string(32) "f77bd31e1e4dd11d12828fb661a08010"
|
||||
===Done===
|
|
@ -71,12 +71,12 @@ NULL
|
|||
|
||||
-- Testing with incorrect compression level --
|
||||
|
||||
Warning: gzencode(): compression level (99) must be within -1..9 in %s on line %d
|
||||
Warning: gzencode(): compression level(99) must be within -1..9 in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing with incorrect encoding_mode --
|
||||
|
||||
Warning: gzencode(): encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d
|
||||
Warning: gzencode(): encoding mode must be FORCE_GZIP or FORCE_DEFLATE in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing with incorrect parameters --
|
||||
|
@ -87,7 +87,7 @@ NULL
|
|||
Warning: gzencode() expects parameter 2 to be long, object given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: gzencode(): encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d
|
||||
Warning: gzencode(): encoding mode must be FORCE_GZIP or FORCE_DEFLATE in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: gzencode() expects parameter 3 to be long, object given in %s on line %d
|
||||
|
@ -95,4 +95,4 @@ NULL
|
|||
|
||||
Warning: gzencode() expects parameter 2 to be long, string given in %s on line %d
|
||||
NULL
|
||||
===Done===
|
||||
===Done===
|
|
@ -3,10 +3,6 @@ Test gzencode() function : variation
|
|||
--SKIPIF--
|
||||
<?php
|
||||
|
||||
if( substr(PHP_OS, 0, 3) == "WIN" ) {
|
||||
die("skip.. Do not run on Windows");
|
||||
}
|
||||
|
||||
if (!extension_loaded("zlib")) {
|
||||
print "skip - ZLIB extension not loaded";
|
||||
}
|
||||
|
@ -34,4 +30,4 @@ var_dump(bin2hex(gzencode($output)));
|
|||
|
||||
-- Testing multiple compression --
|
||||
string(3658) "1f8b0800000000000003010e07f1f81f8b08000000000000036d574d6fe4c80dbdeb57d4ad2f3dfe01eb83e1ec22980e309b4562c067b64449159754dafab0b6e7d7e73d96da1e4c72184c4b2ab2c8f7c847fa25baabba98dc1a8b2b7c38bb324b713ee37f757f56cdc5c7f5b17b9d152f923b157c5ae335e0b75fedd0e2d781c6b98ea3a6ee05affe1dfc3a6527f8f09c52dcb38ba38bb5249934d6ecfe1e53a9ab76ff4c342cf2a64ed2028349fc9a8b139755685352acb82b9fbb67f8bade5cdcb698e1fcec94b7ceba3cb897e806cfc8114350dd1ebbdfa35b62d2478b0056d23ed809b9b95d696d91ce2aa97c911e3fa539c43f84c887554a4d125c9e63ff96711cc08c0866263cb37a0bbe2122ae8f6baecb2284abfb4ddf916db8354cddeef37c1afe5fa02fc7afb3db34f5b3acbdf2eb905490d8f38d7468d253a323d5ebb903760d7944d3b2024e834a99ddce77669bdd823cfbb8e899d4ad4c799677452e6029e80023a03b2374005590641f7d3877df2ad09f3c0e82a54d6a5644fd63049a37ed4bc362016fd9f51264f1e5c630727421ae930b7ed416e93e47b7c71a400390361ffbecb7561bb98f69b5da289e91becc27f08b3b724cb8704f9144d366431d0cb870c56b205deaa2e17636063761a911039fb7e4bf9f06c4f0aecd2ec80e8b41831ca7515e31286166458ea3ef71f2ce7cde2ae269c96d60525724a9c9170b713ed5750758f3cd2a361fc8b288fc92358ce884692e8ea0fe59bd969a0da2eed5831b715749eaae7178f3ebd30fb88c92105f367cce2c882955dc6bf8eca0d5d57540b3092894743ba0fd5b2dad021836191f1afc0bba14dde1642cb0b1aa6879c38907dcefa0720082b801bec61417469219175267dfa047df35b0bd1332001c28cdfafd3bcabe91e74368cdd8d8478e494c190e7ee90c67f2bde288e68ab6b15e883c995be4f8feb6c6dda4278e4f38578ddbdc7be36788daf0c3cb1d1819c73822f7000a0d1813fa94153b572315e51343b536bc64977dff163cebfd8418773261f524017e251fccc60ae29a5770ae097594d52e9c1229d87ce967a36401c46b69945afb249d101c9d420ffa9a123e232c20e76467d5d169202a2dd4c582949e013e745df7958d4b0cc4fd4377a737cd4feea7974070000f314d423e0634cb9a618fdf5dc64fd422181fd59c9230c9f6f9d18dc8fc23e9cccbc7188733b04aa57de83ebea0be3633cff5fa1ff83269be7f44f5a8d84550cc703255fd345dd402034d0b3e11a73ec6e3d4a77f4f685b614329f1b3132ae7af33d02e1e55e291fa6574b758d1f0200e7423dbc852211818043a7c9ce80aa9d59fce0401959f5ea2cf71fde90824f8c9192dbe9d329db143794675ddcf257dd7755273b67340414e3ccad12e3f661f8aad9cf9957dc1275d10a51d3934fa81e68dc6768fb8ee23e373936c8e13feab8b0f50d227f7af76f561fb0950f3d099bbc316c3892a42fb36806d8660e800fa4f43fd4b962d2097d71933a54b77ff948677848eb17bb3a88b621682cfb3bbb49cf42fed6b3944124ad8358ca688aa44dd5f2144c7c9ab16f25b9aca9654ef357ec9ad55c40d324d6cc3d9e3920b863c231d31a95d937fb5520f9c816c79b7dcecc593fb9593cc05a51ebb1eeddd5b49eb437769738d0f64adc579d372b8b7f7c0208487ee3915ebf5766e148ebd77cf4e01f3ec285047011e55838968b6494d517fe29224777b24dd3ddf933101695b102e87db805eef291b74dcfd91628fb2a53f93dbd2968ef2e598746c9204f89fba1f0246fc671610a0591806e46a1346f77c40d910a47c5e20ffb23f003c04b648327a4ed98032c1965bd35bb0044f5344248f56fdb99aa61d6451d68e33489a83bffbe6573541b2da5f64681ea12090f778b2075374778810f73965fa3626a9d41f4df2f83f7c34658cec921b5a9bde49dd5007ec882b02adc514f81aa85898b5cc98e1b137733c0a8789b7f5648d2d231b80bf74978f25d61ce08a8abd11801fd8f995e066676307192ff7641f1cc6e0dee68565b8b22ac3889cd067bf732754a6b270af1044c6a8776811a4f6d8bd0477a9f516064201b920b92d7cd4dc7eee13e6b3eb3528a82f9abb3f388ebe6a8f871393461b73816ec54c99d604174bc5a6801de13908f86aea6a7d0fea107d682bcf1ec348b83872e6b8a316ecd02eb8f8dc86a609bf59a2dd03f1dfa4079436d55e24617be1a2854d008b2b2b1705e2078a7f3946318df1c24f6bf70d4b456eca286ec2b585b28262cc048a098c3e2d5f325a92bb36f691afdc14c822da1b116c9c1c07bb362eb0a04b78834c812134230ebf2044ac2e3c0e3ad00f848dc5010f3bf917ec2fc700b7bf26dacea8440620e04f90f4d97d6dd77cfde8a05c7d3930f1e5811fb8ec5c70964dcc8187ec90e32fdd6b64eec7586413b7d55bed65c4cce39a9b6c15e70e9da94e53fc904e6286f01f5b5562c94211befbc23507e01b2a3865e2f45b5d7b591f290087a5605b82495b4e393f31aa5b37211ec40241a746d903c5eebf117a4d3ddb0d00007b64cbc70e070000"
|
||||
===Done===
|
||||
===Done===
|
|
@ -1,42 +0,0 @@
|
|||
--TEST--
|
||||
Test gzencode() function : variation - verify header contents with all encoding modes
|
||||
--XFAIL--
|
||||
Test will fail until bug #47178 resolved; missing gzip headers whne FORCE_DEFLATE specified
|
||||
--SKIPIF--
|
||||
<?php
|
||||
|
||||
if( substr(PHP_OS, 0, 3) != "WIN" ) {
|
||||
die("skip.. only for Windows");
|
||||
}
|
||||
|
||||
if (!extension_loaded("zlib")) {
|
||||
print "skip - ZLIB extension not loaded";
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
/* Prototype : string gzencode ( string $data [, int $level [, int $encoding_mode ]] )
|
||||
* Description: Gzip-compress a string
|
||||
* Source code: ext/zlib/zlib.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing gzencode() : variation ***\n";
|
||||
|
||||
$data = "A small string to encode\n";
|
||||
|
||||
echo "\n-- Testing with each encoding_mode --\n";
|
||||
var_dump(bin2hex(gzencode($data, -1)));
|
||||
var_dump(bin2hex(gzencode($data, -1, FORCE_GZIP)));
|
||||
var_dump(bin2hex(gzencode($data, -1, FORCE_DEFLATE)));
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
*** Testing gzencode() : variation ***
|
||||
|
||||
-- Testing with each encoding_mode --
|
||||
string(90) "1f8b080000000000000b735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200d7739de519000000"
|
||||
string(90) "1f8b080000000000000b735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200d7739de519000000"
|
||||
string(86) "1f8b080000000000000b789c735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200735808cd"
|
||||
===DONE===
|
|
@ -1,14 +1,8 @@
|
|||
--TEST--
|
||||
Test gzencode() function : variation - verify header contents with all encoding modes
|
||||
--XFAIL--
|
||||
Test will fail until bug #47178 resolved; missing gzip headers whne FORCE_DEFLATE specified
|
||||
--SKIPIF--
|
||||
<?php
|
||||
|
||||
if( substr(PHP_OS, 0, 3) == "WIN" ) {
|
||||
die("skip.. Do not run on Windows");
|
||||
}
|
||||
|
||||
if (!extension_loaded("zlib")) {
|
||||
print "skip - ZLIB extension not loaded";
|
||||
}
|
||||
|
@ -39,4 +33,4 @@ var_dump(bin2hex(gzencode($data, -1, FORCE_DEFLATE)));
|
|||
string(90) "1f8b0800000000000003735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200d7739de519000000"
|
||||
string(90) "1f8b0800000000000003735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200d7739de519000000"
|
||||
string(86) "1f8b0800000000000003789c735428ce4dccc951282e29cacc4b5728c95748cd4bce4f49e50200735808cd"
|
||||
===DONE===
|
||||
===DONE===
|
|
@ -116,4 +116,4 @@ array(6) {
|
|||
string(39) "and I know that it descends down on me
|
||||
"
|
||||
}
|
||||
===DONE===
|
||||
===DONE===
|
|
@ -5,7 +5,7 @@ gzfile(), gzreadfile()
|
|||
if (!extension_loaded("zlib")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$original = b<<<EOD
|
||||
$original = <<<EOD
|
||||
blah blah blah blah blah blah blah
|
||||
blah blah blah blah blah blah blah
|
||||
blah blah blah blah blah blah blah
|
||||
|
|
|
@ -5,8 +5,8 @@ Bug #42663 (gzinflate() try to allocate all memory with truncated $data)
|
|||
--FILE--
|
||||
<?php
|
||||
// build a predictable string
|
||||
$string = '';
|
||||
for($i=0; $i<30000; ++$i) $string .= $i . ' ';
|
||||
$string = b'';
|
||||
for($i=0; $i<30000; ++$i) $string .= (binary)$i . b' ';
|
||||
var_dump(strlen($string));
|
||||
// deflate string
|
||||
$deflated = gzdeflate($string,9);
|
||||
|
@ -15,12 +15,9 @@ var_dump(strlen($deflated));
|
|||
$truncated = substr($deflated, 0, 65535);
|
||||
var_dump(strlen($truncated));
|
||||
// inflate $truncated string (check if it will not eat all memory)
|
||||
var_dump(gzinflate($truncated));
|
||||
gzinflate($truncated);
|
||||
?>
|
||||
--EXPECTF--
|
||||
--EXPECT--
|
||||
int(168890)
|
||||
int(66743)
|
||||
int(65535)
|
||||
|
||||
Warning: gzinflate(): data error in %s on line %d
|
||||
bool(false)
|
||||
|
|
|
@ -4,7 +4,7 @@ gzinflate() and $length argument
|
|||
<?php if (!extension_loaded("zlib")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$original = 'aaaaaaaaaaaaaaa';
|
||||
$original = b'aaaaaaaaaaaaaaa';
|
||||
$packed=gzdeflate($original);
|
||||
echo strlen($packed)." ".strlen($original)."\n";
|
||||
$unpacked=gzinflate($packed, strlen($original));
|
||||
|
|
|
@ -36,7 +36,7 @@ rmdir($thisTestDir);
|
|||
function runtest() {
|
||||
$tmpfile = 'gzopen_variation5.tmp';
|
||||
$h = gzopen($tmpfile, "w", true);
|
||||
fwrite($h, b"This is the test file");
|
||||
fwrite($h, "This is the test file");
|
||||
fclose($h);
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ if (!extension_loaded("zlib")) {
|
|||
|
||||
echo "*** Testing gzopen() : variation ***\n";
|
||||
|
||||
$data = b<<<EOT
|
||||
$data = <<<EOT
|
||||
Here is some plain
|
||||
text to be read
|
||||
and displayed.
|
||||
|
|
|
@ -11,7 +11,7 @@ if (!extension_loaded("zlib")) {
|
|||
|
||||
$filename = "temp.txt.gz";
|
||||
$h = gzopen($filename, 'w');
|
||||
$str = b"Here is the string to be written. ";
|
||||
$str = "Here is the string to be written. ";
|
||||
var_dump(gzread($h, 100));
|
||||
gzwrite( $h, $str);
|
||||
var_dump(gzread($h, 100));
|
||||
|
|
|
@ -5,7 +5,7 @@ gzopen(), gzread(), gzwrite()
|
|||
if (!extension_loaded("zlib")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$original = str_repeat(b"hallo php",4096);
|
||||
$original = str_repeat("hallo php",4096);
|
||||
$filename = tempnam("/tmp", "phpt");
|
||||
|
||||
$fp = gzopen($filename, "wb");
|
||||
|
@ -15,12 +15,7 @@ var_dump(gztell($fp));
|
|||
fclose($fp);
|
||||
|
||||
$fp = gzopen($filename, "rb");
|
||||
|
||||
$data = '';
|
||||
while ($buf = gzread($fp, 8092)) {
|
||||
$data .= $buf;
|
||||
}
|
||||
|
||||
$data = gzread($fp, strlen($original));
|
||||
if ($data == $original) {
|
||||
echo "Strings are equal\n";
|
||||
} else {
|
||||
|
|
|
@ -5,7 +5,7 @@ gzopen(), gzread(), gzwrite() for non-compressed data
|
|||
if (!extension_loaded("zlib")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$original = str_repeat(b"hallo php",4096);
|
||||
$original = str_repeat("hallo php",4096);
|
||||
$filename = tempnam("/tmp", "phpt");
|
||||
|
||||
$fp = fopen($filename, "wb");
|
||||
|
@ -15,12 +15,7 @@ var_dump(ftell($fp));
|
|||
fclose($fp);
|
||||
|
||||
$fp = gzopen($filename, "rb");
|
||||
|
||||
$data = '';
|
||||
while ($buf = gzread($fp, 8192)) {
|
||||
$data .= $buf;
|
||||
}
|
||||
|
||||
$data = gzread($fp, strlen($original));
|
||||
if ($data == $original) {
|
||||
echo "Strings are equal\n";
|
||||
} else {
|
||||
|
@ -29,11 +24,7 @@ if ($data == $original) {
|
|||
}
|
||||
|
||||
gzseek($fp, strlen($original) / 2);
|
||||
|
||||
$data = '';
|
||||
while ($buf = gzread($fp, 8192)) {
|
||||
$data .= $buf;
|
||||
}
|
||||
$data = gzread($fp, strlen($original));
|
||||
|
||||
var_dump(strlen($data));
|
||||
if ($data == substr($original, strlen($original) / 2)) {
|
||||
|
|
|
@ -27,7 +27,7 @@ var_dump(strcmp($data, gzuncompress($compressed)));
|
|||
|
||||
|
||||
$length = 3547;
|
||||
echo "\n-- Calling gzuncompress() with all max length of $length --\n";
|
||||
echo "\n-- Calling gzuncompress() with max length of $length --\n";
|
||||
echo "Result length is ". strlen(gzuncompress($compressed, $length)) . "\n";
|
||||
|
||||
?>
|
||||
|
@ -38,6 +38,6 @@ echo "Result length is ". strlen(gzuncompress($compressed, $length)) . "\n";
|
|||
-- Basic decompress --
|
||||
int(0)
|
||||
|
||||
-- Calling gzuncompress() with all max length of 3547 --
|
||||
-- Calling gzuncompress() with max length of 3547 --
|
||||
Result length is 3547
|
||||
===DONE===
|
||||
===DONE===
|
|
@ -14,6 +14,8 @@ if (!extension_loaded("zlib")) {
|
|||
* Alias to functions:
|
||||
*/
|
||||
|
||||
|
||||
|
||||
echo "*** Testing gzuncompress() : error conditions ***\n";
|
||||
|
||||
// Zero arguments
|
||||
|
@ -27,12 +29,14 @@ $length = 10;
|
|||
$extra_arg = 10;
|
||||
var_dump( gzuncompress($data, $length, $extra_arg) );
|
||||
|
||||
|
||||
echo "\n-- Testing with a buffer that is too small --\n";
|
||||
$short_len = strlen($data) - 1;
|
||||
$compressed = gzcompress($data);
|
||||
|
||||
var_dump(gzuncompress($compressed, $short_len));
|
||||
|
||||
|
||||
echo "\n-- Testing with incorrect arguments --\n";
|
||||
var_dump(gzuncompress(123));
|
||||
|
||||
|
@ -64,7 +68,7 @@ NULL
|
|||
|
||||
-- Testing with a buffer that is too small --
|
||||
|
||||
Warning: gzuncompress(): insufficient memory in %s on line %d
|
||||
Warning: gzuncompress(): buffer error in %s on line %d
|
||||
bool(false)
|
||||
|
||||
-- Testing with incorrect arguments --
|
||||
|
@ -77,4 +81,4 @@ NULL
|
|||
|
||||
Warning: gzuncompress() expects parameter 2 to be long, string given in %s on line %d
|
||||
NULL
|
||||
===DONE===
|
||||
===DONE===
|
|
@ -11,7 +11,7 @@ if (!extension_loaded("zlib")) {
|
|||
|
||||
$filename = "temp.txt.gz";
|
||||
$h = gzopen($filename, 'w');
|
||||
$str = b"Here is the string to be written. ";
|
||||
$str = "Here is the string to be written. ";
|
||||
$length = 10;
|
||||
var_dump(gzwrite( $h, $str ) );
|
||||
var_dump(gzwrite( $h, $str, $length ) );
|
||||
|
|
|
@ -11,7 +11,7 @@ if (!extension_loaded("zlib")) {
|
|||
|
||||
$filename = dirname(__FILE__)."/004.txt.gz";
|
||||
$h = gzopen($filename, 'r');
|
||||
$str = b"Here is the string to be written. ";
|
||||
$str = "Here is the string to be written. ";
|
||||
$length = 10;
|
||||
var_dump(gzwrite( $h, $str ) );
|
||||
var_dump(gzread($h, 10));
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
--TEST--
|
||||
zlib.output_compression
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("zlib")) die("skip need ext/zlib");
|
||||
if (false === stristr(PHP_SAPI, "cgi")) die("skip need sapi/cgi");
|
||||
?>
|
||||
--GET--
|
||||
a=b
|
||||
--INI--
|
||||
zlib.output_compression=1
|
||||
--ENV--
|
||||
HTTP_ACCEPT_ENCODING=gzip
|
||||
--FILE--
|
||||
<?php
|
||||
echo "hi\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
‹%s
|
|
@ -1,17 +0,0 @@
|
|||
--TEST--
|
||||
zlib.output_compression
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("zlib")) die("skip need ext/zlib");
|
||||
?>
|
||||
--INI--
|
||||
zlib.output_compression=1
|
||||
--ENV--
|
||||
HTTP_ACCEPT_ENCODING=gzip
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("zlib.output_compression", 0);
|
||||
echo "hi\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
hi
|
|
@ -1,25 +0,0 @@
|
|||
--TEST--
|
||||
zlib.output_compression
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("zlib")) die("skip need ext/zlib");
|
||||
if (false === stristr(PHP_SAPI, "cgi")) die("skip need sapi/cgi");
|
||||
?>
|
||||
--INI--
|
||||
zlib.output_compression=0
|
||||
--ENV--
|
||||
HTTP_ACCEPT_ENCODING=gzip
|
||||
--POST--
|
||||
dummy=42
|
||||
--FILE--
|
||||
<?php
|
||||
ini_set("zlib.output_compression", 1);
|
||||
echo "hi\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
%s
|
||||
Content-Encoding: gzip
|
||||
Vary: Accept-Encoding
|
||||
%s
|
||||
|
||||
‹%s
|
|
@ -1,25 +0,0 @@
|
|||
--TEST--
|
||||
ob_gzhandler
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("zlib")) die("skip need ext/zlib");
|
||||
if (false === stristr(PHP_SAPI, "cgi")) die("skip need sapi/cgi");
|
||||
?>
|
||||
--INI--
|
||||
zlib.output_compression=0
|
||||
--ENV--
|
||||
HTTP_ACCEPT_ENCODING=gzip
|
||||
--POST--
|
||||
dummy=42
|
||||
--FILE--
|
||||
<?php
|
||||
ob_start("ob_gzhandler");
|
||||
echo "hi\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
%s
|
||||
Content-Encoding: gzip
|
||||
Vary: Accept-Encoding
|
||||
%s
|
||||
|
||||
‹%s
|
|
@ -1,21 +0,0 @@
|
|||
--TEST--
|
||||
ob_gzhandler
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("zlib")) die("skip need ext/zlib");
|
||||
if (false === stristr(PHP_SAPI, "cgi")) die("skip need sapi/cgi");
|
||||
?>
|
||||
--INI--
|
||||
zlib.output_compression=0
|
||||
--ENV--
|
||||
HTTP_ACCEPT_ENCODING=gzip
|
||||
--POST--
|
||||
dummy=42
|
||||
--FILE--
|
||||
<?php
|
||||
ob_start("ob_gzhandler");
|
||||
ini_set("zlib.output_compression", 0);
|
||||
echo "hi\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
%shi
|
|
@ -64,4 +64,4 @@ Destiny who cares
|
|||
as it turns around
|
||||
and I know that it descends down on me
|
||||
int(176)
|
||||
===DONE===
|
||||
===DONE===
|
|
@ -41,4 +41,4 @@ NULL
|
|||
|
||||
Warning: readgzfile() expects parameter 2 to be long, string given in %s on line %d
|
||||
NULL
|
||||
===DONE===
|
||||
===DONE===
|
|
@ -26,18 +26,9 @@ foreach ( $variation as $var ) {
|
|||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
Warning: readgzfile(10.5): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: readgzfile(-10.5): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: readgzfile(123456789000): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: readgzfile(-123456789000): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: readgzfile(0.5): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
|
|
|
@ -25,15 +25,8 @@ foreach ( $variation as $var ) {
|
|||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
Warning: readgzfile(0): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: readgzfile(1): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: readgzfile(12345): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: readgzfile(-2345): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
===DONE===
|
|
@ -43,7 +43,6 @@ foreach ( $variation as $var ) {
|
|||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Error: 2 - readgzfile(Class A object): failed to open stream: No such file or directory, %s(%d)
|
||||
bool(false)
|
||||
Error: 2 - readgzfile() expects parameter 1 to be string, object given, %s(%d)
|
||||
NULL
|
|
@ -29,15 +29,8 @@ foreach ( $variation_array as $var ) {
|
|||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
Warning: readgzfile(string): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: readgzfile(string): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: readgzfile(sTrInG): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: readgzfile(hello world): failed to open stream: No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
|
|
|
@ -6,7 +6,7 @@ zlib.inflate of gzip-encoded stream
|
|||
<?php /* $Id$ */
|
||||
|
||||
$a = gzopen(dirname(__FILE__) . '/test.txt.gz', 'w');
|
||||
fwrite($a, b"This is quite the thing ain't it\n");
|
||||
fwrite($a, "This is quite the thing ain't it\n");
|
||||
fclose($a);
|
||||
|
||||
$fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r');
|
||||
|
@ -38,4 +38,4 @@ fclose($fp);
|
|||
2
|
||||
This is quite the thing ain't it
|
||||
3
|
||||
This is quite the thing ain't it
|
||||
This is quite the thing ain't it
|
|
@ -8,7 +8,7 @@ if (!extension_loaded("zlib")) {
|
|||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$org_data = b<<<EOT
|
||||
$org_data = <<<EOT
|
||||
uncompressed contents of 004.txt.gz is:
|
||||
When you're taught through feelings
|
||||
Destiny flying high above
|
||||
|
|
1625
ext/zlib/zlib.c
1625
ext/zlib/zlib.c
File diff suppressed because it is too large
Load diff
|
@ -80,11 +80,8 @@ static php_stream_filter_status_t php_zlib_inflate_filter(
|
|||
while (buckets_in->head) {
|
||||
size_t bin = 0, desired;
|
||||
|
||||
bucket = buckets_in->head;
|
||||
|
||||
bucket = php_stream_bucket_make_writeable(buckets_in->head TSRMLS_CC);
|
||||
|
||||
while (bin < (unsigned int) bucket->buflen) {
|
||||
while (bin < bucket->buflen) {
|
||||
|
||||
if (data->finished) {
|
||||
consumed += bucket->buflen;
|
||||
|
@ -110,6 +107,7 @@ static php_stream_filter_status_t php_zlib_inflate_filter(
|
|||
desired -= data->strm.avail_in; /* desired becomes what we consumed this round through */
|
||||
data->strm.next_in = data->inbuf;
|
||||
data->strm.avail_in = 0;
|
||||
consumed += desired;
|
||||
bin += desired;
|
||||
|
||||
if (data->strm.avail_out < data->outbuf_len) {
|
||||
|
@ -125,9 +123,7 @@ static php_stream_filter_status_t php_zlib_inflate_filter(
|
|||
php_stream_bucket_delref(bucket TSRMLS_CC);
|
||||
return PSFS_PASS_ON;
|
||||
}
|
||||
|
||||
}
|
||||
consumed += bucket->buflen;
|
||||
php_stream_bucket_delref(bucket TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
@ -206,11 +202,9 @@ static php_stream_filter_status_t php_zlib_deflate_filter(
|
|||
while (buckets_in->head) {
|
||||
size_t bin = 0, desired;
|
||||
|
||||
bucket = buckets_in->head;
|
||||
bucket = php_stream_bucket_make_writeable(buckets_in->head TSRMLS_CC);
|
||||
|
||||
bucket = php_stream_bucket_make_writeable(bucket TSRMLS_CC);
|
||||
|
||||
while (bin < (unsigned int) bucket->buflen) {
|
||||
while (bin < bucket->buflen) {
|
||||
desired = bucket->buflen - bin;
|
||||
if (desired > data->inbuf_len) {
|
||||
desired = data->inbuf_len;
|
||||
|
@ -227,6 +221,7 @@ static php_stream_filter_status_t php_zlib_deflate_filter(
|
|||
desired -= data->strm.avail_in; /* desired becomes what we consumed this round through */
|
||||
data->strm.next_in = data->inbuf;
|
||||
data->strm.avail_in = 0;
|
||||
consumed += desired;
|
||||
bin += desired;
|
||||
|
||||
if (data->strm.avail_out < data->outbuf_len) {
|
||||
|
@ -240,7 +235,6 @@ static php_stream_filter_status_t php_zlib_deflate_filter(
|
|||
exit_status = PSFS_PASS_ON;
|
||||
}
|
||||
}
|
||||
consumed += bucket->buflen;
|
||||
php_stream_bucket_delref(bucket TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
@ -264,7 +258,6 @@ static php_stream_filter_status_t php_zlib_deflate_filter(
|
|||
if (bytes_consumed) {
|
||||
*bytes_consumed = consumed;
|
||||
}
|
||||
|
||||
return exit_status;
|
||||
}
|
||||
|
||||
|
@ -298,7 +291,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
|
|||
/* Create this filter */
|
||||
data = pecalloc(1, sizeof(php_zlib_filter_data), persistent);
|
||||
if (!data) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", sizeof(php_zlib_filter_data));
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes.", sizeof(php_zlib_filter_data));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -310,14 +303,14 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
|
|||
data->strm.avail_out = data->outbuf_len = data->inbuf_len = 2048;
|
||||
data->strm.next_in = data->inbuf = (Bytef *) pemalloc(data->inbuf_len, persistent);
|
||||
if (!data->inbuf) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", data->inbuf_len);
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes.", data->inbuf_len);
|
||||
pefree(data, persistent);
|
||||
return NULL;
|
||||
}
|
||||
data->strm.avail_in = 0;
|
||||
data->strm.next_out = data->outbuf = (Bytef *) pemalloc(data->outbuf_len, persistent);
|
||||
if (!data->outbuf) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", data->outbuf_len);
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes.", data->outbuf_len);
|
||||
pefree(data->inbuf, persistent);
|
||||
pefree(data, persistent);
|
||||
return NULL;
|
||||
|
@ -416,7 +409,7 @@ factory_setlevel:
|
|||
}
|
||||
break;
|
||||
default:
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid filter parameter, ignored");
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid filter parameter, ignored.");
|
||||
}
|
||||
}
|
||||
status = deflateInit2(&(data->strm), level, Z_DEFLATED, windowBits, memLevel, 0);
|
||||
|
|
|
@ -96,7 +96,7 @@ static int php_gziop_flush(php_stream *stream TSRMLS_DC)
|
|||
return gzflush(self->gz_file, Z_SYNC_FLUSH);
|
||||
}
|
||||
|
||||
php_stream_ops php_stream_gzio_ops = {
|
||||
static php_stream_ops php_stream_gzio_ops = {
|
||||
php_gziop_write, php_gziop_read,
|
||||
php_gziop_close, php_gziop_flush,
|
||||
"ZLIB",
|
||||
|
|
|
@ -532,8 +532,8 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
|
|||
int http_response_code;
|
||||
|
||||
if (SG(headers_sent) && !SG(request_info).no_headers) {
|
||||
char *output_start_filename = php_output_get_start_filename(TSRMLS_C);
|
||||
int output_start_lineno = php_output_get_start_lineno(TSRMLS_C);
|
||||
char *output_start_filename = php_get_output_start_filename(TSRMLS_C);
|
||||
int output_start_lineno = php_get_output_start_lineno(TSRMLS_C);
|
||||
|
||||
if (output_start_filename) {
|
||||
sapi_module.sapi_error(E_WARNING, "Cannot modify header information - headers already sent by (output started at %s:%d)",
|
||||
|
|
241
main/main.c
241
main/main.c
|
@ -167,6 +167,7 @@ static PHP_INI_MH(OnChangeMemoryLimit)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ php_disable_functions
|
||||
*/
|
||||
static void php_disable_functions(TSRMLS_D)
|
||||
|
@ -255,99 +256,6 @@ static PHP_INI_MH(OnUpdateTimeout)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
#define PHP_INI_OPTION_HEADERS_SENT(option_name) \
|
||||
if (SG(headers_sent)) { \
|
||||
char *output_start_filename = php_output_get_start_filename(TSRMLS_C); \
|
||||
int output_start_lineno = php_output_get_start_lineno(TSRMLS_C); \
|
||||
if (output_start_filename) { \
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Option " #option_name " cannot be changed after headers have been sent (output started at %s:%d)", \
|
||||
output_start_filename, output_start_lineno); \
|
||||
} else { \
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Option " #option_name " cannot be changed after headers have been sent"); \
|
||||
} \
|
||||
return FAILURE; \
|
||||
}
|
||||
|
||||
/* {{{ PHP_INI_MH
|
||||
*/
|
||||
static PHP_INI_MH(OnUpdateDefaultCharset)
|
||||
{
|
||||
if (stage == PHP_INI_STAGE_RUNTIME && !SG(request_info).no_headers) {
|
||||
sapi_header_line ctr = {0};
|
||||
int mimetype_len;
|
||||
|
||||
PHP_INI_OPTION_HEADERS_SENT(default_charset)
|
||||
|
||||
mimetype_len = SG(default_mimetype) ? strlen(SG(default_mimetype)) : 0;
|
||||
|
||||
if (new_value_length) {
|
||||
ctr.line = emalloc( sizeof("Content-type: ")-1 + mimetype_len + sizeof("; charset=")-1 + new_value_length + 1);
|
||||
|
||||
memcpy(ctr.line, "Content-type: ", sizeof("Content-type: "));
|
||||
memcpy(ctr.line + sizeof("Content-type: ")-1, SG(default_mimetype), mimetype_len);
|
||||
memcpy(ctr.line + sizeof("Content-type: ")-1 + mimetype_len, "; charset=", sizeof("; charset="));
|
||||
memcpy(ctr.line + sizeof("Content-type: ")-1 + mimetype_len + sizeof("; charset=")-1, new_value, new_value_length);
|
||||
|
||||
ctr.line_len = sizeof("Content-type: ")-1 + mimetype_len + sizeof("; charset=")-1 + new_value_length;
|
||||
} else {
|
||||
ctr.line = emalloc( sizeof("Content-type: ")-1 + mimetype_len + 1);
|
||||
|
||||
memcpy(ctr.line, "Content-type: ", sizeof("Content-type: "));
|
||||
memcpy(ctr.line + sizeof("Content-type: ")-1, SG(default_mimetype), mimetype_len);
|
||||
|
||||
ctr.line_len = sizeof("Content-type: ")-1 + mimetype_len;
|
||||
}
|
||||
ctr.line[ctr.line_len] = 0;
|
||||
|
||||
sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
|
||||
efree(ctr.line);
|
||||
}
|
||||
|
||||
OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_INI_MH
|
||||
*/
|
||||
static PHP_INI_MH(OnUpdateDefaultMimetype)
|
||||
{
|
||||
if (stage == PHP_INI_STAGE_RUNTIME && !SG(request_info).no_headers) {
|
||||
sapi_header_line ctr = {0};
|
||||
int charset_len;
|
||||
|
||||
PHP_INI_OPTION_HEADERS_SENT(default_mimetype)
|
||||
|
||||
charset_len = SG(default_charset) ? strlen(SG(default_charset)) : 0;
|
||||
|
||||
if (charset_len) {
|
||||
ctr.line = emalloc( sizeof("Content-type: ")-1 + new_value_length + sizeof("; charset=")-1 + charset_len + 1);
|
||||
|
||||
memcpy(ctr.line, "Content-type: ", sizeof("Content-type: "));
|
||||
memcpy(ctr.line + sizeof("Content-type: ")-1, new_value, new_value_length);
|
||||
memcpy(ctr.line + sizeof("Content-type: ")-1 + new_value_length, "; charset=", sizeof("; charset="));
|
||||
memcpy(ctr.line + sizeof("Content-type: ")-1 + new_value_length + sizeof("; charset=")-1, SG(default_charset), charset_len);
|
||||
|
||||
ctr.line_len = sizeof("Content-type: ")-1 + new_value_length + sizeof("; charset=")-1 + new_value_length;
|
||||
} else {
|
||||
ctr.line = emalloc( sizeof("Content-type: ")-1 + new_value_length + 1);
|
||||
|
||||
memcpy(ctr.line, "Content-type: ", sizeof("Content-type: "));
|
||||
memcpy(ctr.line + sizeof("Content-type: ")-1, new_value, new_value_length);
|
||||
|
||||
ctr.line_len = sizeof("Content-type: ")-1 + new_value_length;
|
||||
}
|
||||
ctr.line[ctr.line_len] = 0;
|
||||
|
||||
sapi_header_op(SAPI_HEADER_REPLACE, &ctr TSRMLS_CC);
|
||||
efree(ctr.line);
|
||||
}
|
||||
|
||||
OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_get_display_errors_mode() helper function
|
||||
*/
|
||||
static int php_get_display_errors_mode(char *value, int value_length)
|
||||
|
@ -374,6 +282,7 @@ static int php_get_display_errors_mode(char *value, int value_length)
|
|||
mode = PHP_DISPLAY_ERRORS_STDOUT;
|
||||
}
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -449,6 +358,7 @@ static PHP_INI_MH(OnUpdateErrorLog)
|
|||
if (PG(open_basedir) && php_check_open_basedir(new_value TSRMLS_CC)) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
|
||||
return SUCCESS;
|
||||
|
@ -468,13 +378,13 @@ static PHP_INI_MH(OnUpdateMailLog)
|
|||
if (PG(open_basedir) && php_check_open_basedir(new_value TSRMLS_CC)) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ PHP_INI_MH
|
||||
*/
|
||||
static PHP_INI_MH(OnChangeMailForceExtra)
|
||||
|
@ -500,7 +410,7 @@ static PHP_INI_MH(OnChangeMailForceExtra)
|
|||
*/
|
||||
|
||||
#ifndef PHP_SAFE_MODE_EXEC_DIR
|
||||
# define PHP_SAFE_MODE_EXEC_DIR ""
|
||||
# define PHP_SAFE_MODE_EXEC_DIR ""
|
||||
#endif
|
||||
|
||||
/* Windows and Netware use the internal mail */
|
||||
|
@ -572,8 +482,8 @@ PHP_INI_BEGIN()
|
|||
STD_PHP_INI_ENTRY("auto_append_file", NULL, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateString, auto_append_file, php_core_globals, core_globals)
|
||||
STD_PHP_INI_ENTRY("auto_prepend_file", NULL, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateString, auto_prepend_file, php_core_globals, core_globals)
|
||||
STD_PHP_INI_ENTRY("doc_root", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, doc_root, php_core_globals, core_globals)
|
||||
STD_PHP_INI_ENTRY("default_charset", SAPI_DEFAULT_CHARSET, PHP_INI_ALL, OnUpdateDefaultCharset, default_charset, sapi_globals_struct,sapi_globals)
|
||||
STD_PHP_INI_ENTRY("default_mimetype", SAPI_DEFAULT_MIMETYPE, PHP_INI_ALL, OnUpdateDefaultMimetype, default_mimetype, sapi_globals_struct,sapi_globals)
|
||||
STD_PHP_INI_ENTRY("default_charset", SAPI_DEFAULT_CHARSET, PHP_INI_ALL, OnUpdateString, default_charset, sapi_globals_struct,sapi_globals)
|
||||
STD_PHP_INI_ENTRY("default_mimetype", SAPI_DEFAULT_MIMETYPE, PHP_INI_ALL, OnUpdateString, default_mimetype, sapi_globals_struct,sapi_globals)
|
||||
STD_PHP_INI_ENTRY("error_log", NULL, PHP_INI_ALL, OnUpdateErrorLog, error_log, php_core_globals, core_globals)
|
||||
STD_PHP_INI_ENTRY("extension_dir", PHP_EXTENSION_DIR, PHP_INI_SYSTEM, OnUpdateStringUnempty, extension_dir, php_core_globals, core_globals)
|
||||
STD_PHP_INI_ENTRY("include_path", PHP_INCLUDE_PATH, PHP_INI_ALL, OnUpdateStringUnempty, include_path, php_core_globals, core_globals)
|
||||
|
@ -735,11 +645,11 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
|
|||
int buffer_len = 0;
|
||||
char *space = "";
|
||||
char *class_name = "";
|
||||
char *function;
|
||||
int origin_len;
|
||||
char *function = NULL;
|
||||
char *origin;
|
||||
char *message;
|
||||
char *stage = "Unknown";
|
||||
int is_function = 0;
|
||||
|
||||
/* get error text into buffer and escape for html if necessary */
|
||||
buffer_len = vspprintf(&buffer, 0, format, args);
|
||||
|
@ -753,9 +663,9 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
|
|||
|
||||
/* which function caused the problem if any at all */
|
||||
if (php_during_module_startup()) {
|
||||
stage = "PHP Startup";
|
||||
function = "PHP Startup";
|
||||
} else if (php_during_module_shutdown()) {
|
||||
stage = "PHP Shutdown";
|
||||
function = "PHP Shutdown";
|
||||
} else if (EG(current_execute_data) &&
|
||||
EG(current_execute_data)->opline &&
|
||||
EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL
|
||||
|
@ -763,37 +673,42 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
|
|||
switch (EG(current_execute_data)->opline->op2.u.constant.value.lval) {
|
||||
case ZEND_EVAL:
|
||||
function = "eval";
|
||||
is_function = 1;
|
||||
break;
|
||||
case ZEND_INCLUDE:
|
||||
function = "include";
|
||||
is_function = 1;
|
||||
break;
|
||||
case ZEND_INCLUDE_ONCE:
|
||||
function = "include_once";
|
||||
is_function = 1;
|
||||
break;
|
||||
case ZEND_REQUIRE:
|
||||
function = "require";
|
||||
is_function = 1;
|
||||
break;
|
||||
case ZEND_REQUIRE_ONCE:
|
||||
function = "require_once";
|
||||
is_function = 1;
|
||||
break;
|
||||
default:
|
||||
stage = "Unknown";
|
||||
function = "Unknown";
|
||||
}
|
||||
} else {
|
||||
function = get_active_function_name(TSRMLS_C);
|
||||
if (!function || !strlen(function)) {
|
||||
stage = "Unknown";
|
||||
function = NULL;
|
||||
function = "Unknown";
|
||||
} else {
|
||||
is_function = 1;
|
||||
class_name = get_active_class_name(&space TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
|
||||
/* if we still have memory then format the origin */
|
||||
if (function) {
|
||||
if (is_function) {
|
||||
origin_len = spprintf(&origin, 0, "%s%s%s(%s)", class_name, space, function, params);
|
||||
} else {
|
||||
origin_len = spprintf(&origin, 0, "%s", stage);
|
||||
origin_len = spprintf(&origin, 0, "%s", function);
|
||||
}
|
||||
|
||||
if (PG(html_errors)) {
|
||||
|
@ -810,7 +725,7 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
|
|||
}
|
||||
|
||||
/* no docref given but function is known (the default) */
|
||||
if (!docref && function) {
|
||||
if (!docref && is_function) {
|
||||
int doclen;
|
||||
if (space[0] == '\0') {
|
||||
doclen = spprintf(&docref_buf, 0, "function.%s", function);
|
||||
|
@ -827,7 +742,7 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
|
|||
* - we show erroes in html mode OR
|
||||
* - the user wants to see the links anyway
|
||||
*/
|
||||
if (docref && function && (PG(html_errors) || strlen(PG(docref_root)))) {
|
||||
if (docref && is_function && (PG(html_errors) || strlen(PG(docref_root)))) {
|
||||
if (strncmp(docref, "http://", 7)) {
|
||||
/* We don't have 'http://' so we use docref_root */
|
||||
|
||||
|
@ -880,7 +795,6 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
|
|||
}
|
||||
if (EG(active_symbol_table)) {
|
||||
zval *tmp;
|
||||
|
||||
ALLOC_INIT_ZVAL(tmp);
|
||||
ZVAL_STRINGL(tmp, buffer, buffer_len, 1);
|
||||
zend_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) &tmp, sizeof(zval *), NULL);
|
||||
|
@ -936,8 +850,7 @@ PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1,
|
|||
|
||||
#ifdef PHP_WIN32
|
||||
#define PHP_WIN32_ERROR_MSG_BUFFER_SIZE 512
|
||||
PHPAPI void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2 TSRMLS_DC)
|
||||
{
|
||||
PHPAPI void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2 TSRMLS_DC) {
|
||||
if (error == 0) {
|
||||
php_error_docref2(NULL TSRMLS_CC, param1, param2, E_WARNING, "%s", strerror(errno));
|
||||
} else {
|
||||
|
@ -1088,7 +1001,15 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
|
|||
php_log_err(log_buffer TSRMLS_CC);
|
||||
efree(log_buffer);
|
||||
}
|
||||
if (PG(display_errors) && ((module_initialized && !PG(during_request_startup)) || (PG(display_startup_errors)))) {
|
||||
|
||||
if (PG(display_errors)
|
||||
&& ((module_initialized && !PG(during_request_startup))
|
||||
|| (PG(display_startup_errors)
|
||||
&& (OG(php_body_write)==php_default_output_func || OG(php_body_write)==php_ub_body_write_no_header || OG(php_body_write)==php_ub_body_write)
|
||||
)
|
||||
)
|
||||
) {
|
||||
|
||||
if (PG(xmlrpc_errors)) {
|
||||
php_printf("<?xml version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>%ld</int></value></member><member><name>faultString</name><value><string>%s:%s in %s on line %d</string></value></member></struct></value></fault></methodResponse>", PG(xmlrpc_error_number), error_type_str, buffer, error_filename, error_lineno);
|
||||
} else {
|
||||
|
@ -1184,18 +1105,19 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
|
|||
efree(buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
if (PG(track_errors) && module_initialized) {
|
||||
if (!EG(active_symbol_table)) {
|
||||
zend_rebuild_symbol_table(TSRMLS_C);
|
||||
}
|
||||
if (EG(active_symbol_table)) {
|
||||
zval *tmp;
|
||||
|
||||
ALLOC_INIT_ZVAL(tmp);
|
||||
ZVAL_STRINGL(tmp, buffer, buffer_len, 1);
|
||||
zend_hash_update(EG(active_symbol_table), "php_errormsg", sizeof("php_errormsg"), (void **) & tmp, sizeof(zval *), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
efree(buffer);
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -1358,11 +1280,11 @@ static void php_message_handler_for_zend(long message, void *data TSRMLS_DC)
|
|||
|
||||
snprintf(memory_leak_buf, 512, "Last leak repeated %ld time%s\n", leak_count, (leak_count>1?"s":""));
|
||||
}
|
||||
# if defined(PHP_WIN32)
|
||||
# if defined(PHP_WIN32)
|
||||
OutputDebugString(memory_leak_buf);
|
||||
# else
|
||||
# else
|
||||
fprintf(stderr, "%s", memory_leak_buf);
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
@ -1372,11 +1294,11 @@ static void php_message_handler_for_zend(long message, void *data TSRMLS_DC)
|
|||
char memory_leak_buf[512];
|
||||
|
||||
snprintf(memory_leak_buf, 512, "=== Total %d memory leaks detected ===\n", *((zend_uint *) data));
|
||||
# if defined(PHP_WIN32)
|
||||
# if defined(PHP_WIN32)
|
||||
OutputDebugString(memory_leak_buf);
|
||||
# else
|
||||
# else
|
||||
fprintf(stderr, "%s", memory_leak_buf);
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
@ -1395,24 +1317,24 @@ static void php_message_handler_for_zend(long message, void *data TSRMLS_DC)
|
|||
} else {
|
||||
snprintf(memory_leak_buf, sizeof(memory_leak_buf), "[null] Script: '%s'\n", SAFE_FILENAME(SG(request_info).path_translated));
|
||||
}
|
||||
# if defined(PHP_WIN32)
|
||||
# if defined(PHP_WIN32)
|
||||
OutputDebugString(memory_leak_buf);
|
||||
# else
|
||||
# else
|
||||
fprintf(stderr, "%s", memory_leak_buf);
|
||||
#endif
|
||||
# endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void php_on_timeout(int seconds TSRMLS_DC) /* {{{ */
|
||||
|
||||
void php_on_timeout(int seconds TSRMLS_DC)
|
||||
{
|
||||
PG(connection_status) |= PHP_CONNECTION_TIMEOUT;
|
||||
zend_set_timeout(EG(timeout_seconds), 1);
|
||||
if(PG(exit_on_timeout)) sapi_terminate_process(TSRMLS_C);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#if PHP_SIGCHILD
|
||||
/* {{{ sigchld_handler
|
||||
|
@ -1431,7 +1353,7 @@ static int php_start_sapi(TSRMLS_D)
|
|||
{
|
||||
int retval = SUCCESS;
|
||||
|
||||
if (!SG(sapi_started)) {
|
||||
if(!SG(sapi_started)) {
|
||||
zend_try {
|
||||
PG(during_request_startup) = 1;
|
||||
|
||||
|
@ -1501,16 +1423,15 @@ int php_request_startup(TSRMLS_D)
|
|||
}
|
||||
|
||||
if (PG(output_handler) && PG(output_handler)[0]) {
|
||||
zval *oh;
|
||||
|
||||
MAKE_STD_ZVAL(oh);
|
||||
ZVAL_STRING(oh, PG(output_handler), 1);
|
||||
php_output_start_user(oh, 0, PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC);
|
||||
zval_ptr_dtor(&oh);
|
||||
php_start_ob_buffer_named(PG(output_handler), 0, 1 TSRMLS_CC);
|
||||
} else if (PG(output_buffering)) {
|
||||
php_output_start_user(NULL, PG(output_buffering) > 1 ? PG(output_buffering) : 0, PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC);
|
||||
if (PG(output_buffering)>1) {
|
||||
php_start_ob_buffer(NULL, PG(output_buffering), 1 TSRMLS_CC);
|
||||
} else {
|
||||
php_start_ob_buffer(NULL, 0, 1 TSRMLS_CC);
|
||||
}
|
||||
} else if (PG(implicit_flush)) {
|
||||
php_output_set_implicit_flush(1 TSRMLS_CC);
|
||||
php_start_implicit_flush(TSRMLS_C);
|
||||
}
|
||||
|
||||
/* We turn this off in php_execute_script() */
|
||||
|
@ -1546,6 +1467,7 @@ int php_request_startup(TSRMLS_D)
|
|||
|
||||
zend_try {
|
||||
PG(during_request_startup) = 1;
|
||||
php_output_activate(TSRMLS_C);
|
||||
if (PG(expose_php)) {
|
||||
sapi_add_header(SAPI_PHP_VERSION_HEADER, sizeof(SAPI_PHP_VERSION_HEADER)-1, 1);
|
||||
}
|
||||
|
@ -1668,22 +1590,14 @@ void php_request_shutdown(void *dummy)
|
|||
/* 3. Flush all output buffers */
|
||||
zend_try {
|
||||
zend_bool send_buffer = SG(request_info).headers_only ? 0 : 1;
|
||||
|
||||
if (CG(unclean_shutdown) && PG(last_error_type) == E_ERROR &&
|
||||
PG(memory_limit) < zend_memory_usage(1 TSRMLS_CC)
|
||||
) {
|
||||
OG(ob_nesting_level) && !OG(active_ob_buffer).chunk_size && PG(memory_limit) < zend_memory_usage(1 TSRMLS_CC)) {
|
||||
send_buffer = 0;
|
||||
}
|
||||
|
||||
if (!send_buffer) {
|
||||
php_output_discard_all(TSRMLS_C);
|
||||
} else {
|
||||
php_output_end_all(TSRMLS_C);
|
||||
}
|
||||
php_output_deactivate(TSRMLS_C);
|
||||
php_end_ob_buffers(send_buffer TSRMLS_CC);
|
||||
} zend_end_try();
|
||||
|
||||
/* 4. Send the set HTTP headers (note: This must be done AFTER php_output_discard_all() / php_output_end_all() !!) */
|
||||
/* 4. Send the set HTTP headers (note: This must be done AFTER php_end_ob_buffers() !!) */
|
||||
zend_try {
|
||||
sapi_send_headers(TSRMLS_C);
|
||||
} zend_end_try();
|
||||
|
@ -1765,12 +1679,12 @@ PHPAPI void php_com_initialize(TSRMLS_D)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_output_wrapper
|
||||
/* {{{ php_body_write_wrapper
|
||||
*/
|
||||
static int php_output_wrapper(const char *str, uint str_length)
|
||||
static int php_body_write_wrapper(const char *str, uint str_length)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
return php_output_write(str, str_length TSRMLS_CC);
|
||||
return php_body_write(str, str_length TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -1923,7 +1837,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
|
|||
|
||||
zuf.error_function = php_error_cb;
|
||||
zuf.printf_function = php_printf;
|
||||
zuf.write_function = php_output_wrapper;
|
||||
zuf.write_function = php_body_write_wrapper;
|
||||
zuf.fopen_function = php_fopen_wrapper_for_zend;
|
||||
zuf.message_handler = php_message_handler_for_zend;
|
||||
zuf.block_interruptions = sapi_module.block_interruptions;
|
||||
|
@ -1999,18 +1913,18 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
|
|||
le_index_ptr = zend_register_list_destructors_ex(NULL, NULL, "index pointer", 0);
|
||||
|
||||
/* Register constants */
|
||||
#ifdef ZTS
|
||||
REGISTER_MAIN_LONG_CONSTANT("PHP_ZTS", 1, CONST_PERSISTENT | CONST_CS);
|
||||
#else
|
||||
REGISTER_MAIN_LONG_CONSTANT("PHP_ZTS", 0, CONST_PERSISTENT | CONST_CS);
|
||||
#endif
|
||||
REGISTER_MAIN_STRINGL_CONSTANT("PHP_VERSION", PHP_VERSION, sizeof(PHP_VERSION)-1, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_LONG_CONSTANT("PHP_MAJOR_VERSION", PHP_MAJOR_VERSION, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_LONG_CONSTANT("PHP_MINOR_VERSION", PHP_MINOR_VERSION, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_LONG_CONSTANT("PHP_RELEASE_VERSION", PHP_RELEASE_VERSION, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_STRINGL_CONSTANT("PHP_EXTRA_VERSION", PHP_EXTRA_VERSION, sizeof(PHP_EXTRA_VERSION) - 1, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_LONG_CONSTANT("PHP_VERSION_ID", PHP_VERSION_ID, CONST_PERSISTENT | CONST_CS);
|
||||
#ifdef ZTS
|
||||
REGISTER_MAIN_LONG_CONSTANT("PHP_ZTS", 1, CONST_PERSISTENT | CONST_CS);
|
||||
#else
|
||||
REGISTER_MAIN_LONG_CONSTANT("PHP_ZTS", 0, CONST_PERSISTENT | CONST_CS);
|
||||
#endif
|
||||
REGISTER_MAIN_LONG_CONSTANT("PHP_DEBUG", PHP_DEBUG, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_STRINGL_CONSTANT("PHP_VERSION", PHP_VERSION, sizeof(PHP_VERSION)-1, CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_STRINGL_CONSTANT("PHP_OS", php_os, strlen(php_os), CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_STRINGL_CONSTANT("PHP_SAPI", sapi_module.name, strlen(sapi_module.name), CONST_PERSISTENT | CONST_CS);
|
||||
REGISTER_MAIN_STRINGL_CONSTANT("DEFAULT_INCLUDE_PATH", PHP_INCLUDE_PATH, sizeof(PHP_INCLUDE_PATH)-1, CONST_PERSISTENT | CONST_CS);
|
||||
|
@ -2235,22 +2149,17 @@ void php_module_shutdown(TSRMLS_D)
|
|||
#ifndef ZTS
|
||||
zend_ini_shutdown(TSRMLS_C);
|
||||
shutdown_memory_manager(CG(unclean_shutdown), 1 TSRMLS_CC);
|
||||
#else
|
||||
zend_ini_global_shutdown(TSRMLS_C);
|
||||
#endif
|
||||
|
||||
php_output_shutdown();
|
||||
php_shutdown_temporary_directory();
|
||||
|
||||
module_initialized = 0;
|
||||
|
||||
#ifndef ZTS
|
||||
core_globals_dtor(&core_globals TSRMLS_CC);
|
||||
gc_globals_dtor(TSRMLS_C);
|
||||
#else
|
||||
zend_ini_global_shutdown(TSRMLS_C);
|
||||
ts_free_id(core_globals_id);
|
||||
#endif
|
||||
|
||||
php_shutdown_temporary_directory();
|
||||
|
||||
module_initialized = 0;
|
||||
|
||||
#if defined(PHP_WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
if (old_invalid_parameter_handler == NULL) {
|
||||
_set_invalid_parameter_handler(old_invalid_parameter_handler);
|
||||
|
@ -2411,7 +2320,7 @@ PHPAPI void php_handle_aborted_connection(void)
|
|||
TSRMLS_FETCH();
|
||||
|
||||
PG(connection_status) = PHP_CONNECTION_ABORTED;
|
||||
php_output_set_status(PHP_OUTPUT_DISABLED TSRMLS_CC);
|
||||
php_output_set_status(0 TSRMLS_CC);
|
||||
|
||||
if (!PG(ignore_user_abort)) {
|
||||
zend_bailout();
|
||||
|
@ -2429,7 +2338,7 @@ PHPAPI int php_handle_auth_data(const char *auth TSRMLS_DC)
|
|||
char *pass;
|
||||
char *user;
|
||||
|
||||
user = (char*)php_base64_decode((unsigned char*)auth + 6, strlen(auth) - 6, NULL);
|
||||
user = php_base64_decode(auth + 6, strlen(auth) - 6, NULL);
|
||||
if (user) {
|
||||
pass = strchr(user, ':');
|
||||
if (pass) {
|
||||
|
|
2209
main/output.c
2209
main/output.c
File diff suppressed because it is too large
Load diff
13
main/php.h
13
main/php.h
|
@ -386,7 +386,20 @@ END_EXTERN_C()
|
|||
|
||||
/* Output support */
|
||||
#include "main/php_output.h"
|
||||
#define PHPWRITE(str, str_len) php_body_write((str), (str_len) TSRMLS_CC)
|
||||
#define PUTS(str) do { \
|
||||
const char *__str = (str); \
|
||||
php_body_write(__str, strlen(__str) TSRMLS_CC); \
|
||||
} while (0)
|
||||
|
||||
#define PUTC(c) (php_body_write(&(c), 1 TSRMLS_CC), (c))
|
||||
#define PHPWRITE_H(str, str_len) php_header_write((str), (str_len) TSRMLS_CC)
|
||||
#define PUTS_H(str) do { \
|
||||
const char *__str = (str); \
|
||||
php_header_write(__str, strlen(__str) TSRMLS_CC); \
|
||||
} while (0)
|
||||
|
||||
#define PUTC_H(c) (php_header_write(&(c), 1 TSRMLS_CC), (c))
|
||||
|
||||
#include "php_streams.h"
|
||||
#include "php_memory_streams.h"
|
||||
|
|
|
@ -85,7 +85,7 @@ int php_info_logos(const char *logo_string TSRMLS_DC)
|
|||
content_header[len] = '\0';
|
||||
sapi_add_header(content_header, len, 0);
|
||||
|
||||
PHPWRITE((char*)logo_image->data, logo_image->size);
|
||||
PHPWRITE(logo_image->data, logo_image->size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -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. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Michael Wallner <mike@php.net> |
|
||||
| Author: Zeev Suraski <zeev@zend.com> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
@ -21,265 +21,35 @@
|
|||
#ifndef PHP_OUTPUT_H
|
||||
#define PHP_OUTPUT_H
|
||||
|
||||
#define PHP_OUTPUT_NEWAPI 1
|
||||
|
||||
/* handler ops */
|
||||
#define PHP_OUTPUT_HANDLER_WRITE 0x00 /* standard passthru */
|
||||
#define PHP_OUTPUT_HANDLER_START 0x01 /* start */
|
||||
#define PHP_OUTPUT_HANDLER_CLEAN 0x02 /* restart */
|
||||
#define PHP_OUTPUT_HANDLER_FLUSH 0x04 /* pass along as much as possible */
|
||||
#define PHP_OUTPUT_HANDLER_FINAL 0x08 /* finalize */
|
||||
#define PHP_OUTPUT_HANDLER_CONT PHP_OUTPUT_HANDLER_WRITE
|
||||
#define PHP_OUTPUT_HANDLER_END PHP_OUTPUT_HANDLER_FINAL
|
||||
|
||||
/* handler types */
|
||||
#define PHP_OUTPUT_HANDLER_INTERNAL 0x0000
|
||||
#define PHP_OUTPUT_HANDLER_USER 0x0001
|
||||
|
||||
/* handler ability flags */
|
||||
#define PHP_OUTPUT_HANDLER_CLEANABLE 0x0010
|
||||
#define PHP_OUTPUT_HANDLER_FLUSHABLE 0x0020
|
||||
#define PHP_OUTPUT_HANDLER_REMOVABLE 0x0040
|
||||
#define PHP_OUTPUT_HANDLER_STDFLAGS 0x0070
|
||||
|
||||
/* handler status flags */
|
||||
#define PHP_OUTPUT_HANDLER_STARTED 0x1000
|
||||
#define PHP_OUTPUT_HANDLER_DISABLED 0x2000
|
||||
|
||||
/* handler op return values */
|
||||
typedef enum _php_output_handler_status_t {
|
||||
PHP_OUTPUT_HANDLER_FAILURE,
|
||||
PHP_OUTPUT_HANDLER_SUCCESS,
|
||||
PHP_OUTPUT_HANDLER_NO_DATA,
|
||||
} php_output_handler_status_t;
|
||||
|
||||
/* php_output_stack_pop() flags */
|
||||
#define PHP_OUTPUT_POP_TRY 0x000
|
||||
#define PHP_OUTPUT_POP_FORCE 0x001
|
||||
#define PHP_OUTPUT_POP_DISCARD 0x010
|
||||
#define PHP_OUTPUT_POP_SILENT 0x100
|
||||
|
||||
/* real global flags */
|
||||
#define PHP_OUTPUT_IMPLICITFLUSH 0x01
|
||||
#define PHP_OUTPUT_DISABLED 0x02
|
||||
#define PHP_OUTPUT_WRITTEN 0x04
|
||||
#define PHP_OUTPUT_SENT 0x08
|
||||
/* supplementary flags for php_output_get_status() */
|
||||
#define PHP_OUTPUT_ACTIVE 0x10
|
||||
#define PHP_OUTPUT_LOCKED 0x20
|
||||
|
||||
/* handler hooks */
|
||||
typedef enum _php_output_handler_hook_t {
|
||||
PHP_OUTPUT_HANDLER_HOOK_GET_OPAQ,
|
||||
PHP_OUTPUT_HANDLER_HOOK_GET_FLAGS,
|
||||
PHP_OUTPUT_HANDLER_HOOK_GET_LEVEL,
|
||||
PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE,
|
||||
PHP_OUTPUT_HANDLER_HOOK_DISABLE,
|
||||
/* unused */
|
||||
PHP_OUTPUT_HANDLER_HOOK_LAST,
|
||||
} php_output_handler_hook_t;
|
||||
|
||||
#define PHP_OUTPUT_HANDLER_INITBUF_SIZE(s) \
|
||||
( (s) ? \
|
||||
(s) + PHP_OUTPUT_HANDLER_ALIGNTO_SIZE - ((s) % (PHP_OUTPUT_HANDLER_ALIGNTO_SIZE)) : \
|
||||
PHP_OUTPUT_HANDLER_DEFAULT_SIZE \
|
||||
)
|
||||
#define PHP_OUTPUT_HANDLER_ALIGNTO_SIZE 0x1000
|
||||
#define PHP_OUTPUT_HANDLER_DEFAULT_SIZE 0x4000
|
||||
|
||||
typedef struct _php_output_buffer {
|
||||
char *data;
|
||||
size_t size;
|
||||
size_t used;
|
||||
uint free:1;
|
||||
uint _res:31;
|
||||
} php_output_buffer;
|
||||
|
||||
typedef struct _php_output_context {
|
||||
int op;
|
||||
php_output_buffer in;
|
||||
php_output_buffer out;
|
||||
#ifdef ZTS
|
||||
void ***tsrm_ls;
|
||||
#endif
|
||||
} php_output_context;
|
||||
|
||||
#define PHP_OUTPUT_TSRMLS(ctx) TSRMLS_FETCH_FROM_CTX((ctx)->tsrm_ls)
|
||||
|
||||
/* old-style, stateless callback */
|
||||
typedef void (*php_output_handler_func_t)(char *output, uint output_len, char **handled_output, uint *handled_output_len, int mode TSRMLS_DC);
|
||||
/* new-style, opaque context callback */
|
||||
typedef int (*php_output_handler_context_func_t)(void **handler_context, php_output_context *output_context);
|
||||
/* output handler context dtor */
|
||||
typedef void (*php_output_handler_context_dtor_t)(void *opaq TSRMLS_DC);
|
||||
/* conflict check callback */
|
||||
typedef int (*php_output_handler_conflict_check_t)(zval *handler_name TSRMLS_DC);
|
||||
/* ctor for aliases */
|
||||
typedef struct _php_output_handler *(*php_output_handler_alias_ctor_t)(zval *handler_name, size_t chunk_size, int flags TSRMLS_DC);
|
||||
|
||||
typedef struct _php_output_handler_user_func_t {
|
||||
zend_fcall_info fci;
|
||||
zend_fcall_info_cache fcc;
|
||||
zval *zoh;
|
||||
} php_output_handler_user_func_t;
|
||||
|
||||
typedef struct _php_output_handler {
|
||||
zval *name;
|
||||
int flags;
|
||||
int level;
|
||||
size_t size;
|
||||
php_output_buffer buffer;
|
||||
|
||||
void *opaq;
|
||||
void (*dtor)(void *opaq TSRMLS_DC);
|
||||
|
||||
union {
|
||||
php_output_handler_user_func_t *user;
|
||||
php_output_handler_context_func_t internal;
|
||||
} func;
|
||||
} php_output_handler;
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(output)
|
||||
int flags;
|
||||
zend_stack *handlers;
|
||||
php_output_handler *active;
|
||||
php_output_handler *running;
|
||||
char *output_start_filename;
|
||||
int output_start_lineno;
|
||||
zval *default_output_handler_name;
|
||||
zval *devnull_output_handler_name;
|
||||
ZEND_END_MODULE_GLOBALS(output);
|
||||
|
||||
/* there should not be a need to use OG() from outside of output.c */
|
||||
#ifdef ZTS
|
||||
# define OG(v) TSRMG(output_globals_id, zend_output_globals *, v)
|
||||
#else
|
||||
# define OG(v) (output_globals.v)
|
||||
#endif
|
||||
|
||||
/* convenience macros */
|
||||
#define PHPWRITE(str, str_len) php_output_write((str), (str_len) TSRMLS_CC)
|
||||
#define PHPWRITE_H(str, str_len) php_output_write_unbuffered((str), (str_len) TSRMLS_CC)
|
||||
|
||||
#define PUTC(c) (php_output_write(&(c), 1 TSRMLS_CC), (c))
|
||||
#define PUTC_H(c) (php_output_write_unbuffered(&(c), 1 TSRMLS_CC), (c))
|
||||
|
||||
#define PUTS(str) do { \
|
||||
const char *__str = (str); \
|
||||
php_output_write(__str, strlen(__str) TSRMLS_CC); \
|
||||
} while (0)
|
||||
#define PUTS_H(str) do { \
|
||||
const char *__str = (str); \
|
||||
php_output_write_unbuffered(__str, strlen(__str) TSRMLS_CC); \
|
||||
} while (0)
|
||||
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
#define php_output_tearup() \
|
||||
php_output_startup(); \
|
||||
php_output_activate(TSRMLS_C)
|
||||
#define php_output_teardown() \
|
||||
php_output_end_all(TSRMLS_C); \
|
||||
php_output_deactivate(TSRMLS_C); \
|
||||
php_output_shutdown()
|
||||
|
||||
/* MINIT */
|
||||
PHPAPI void php_output_startup(void);
|
||||
/* MSHUTDOWN */
|
||||
PHPAPI void php_output_shutdown(void);
|
||||
|
||||
PHPAPI void php_output_activate(TSRMLS_D);
|
||||
PHPAPI void php_output_set_status(zend_bool status TSRMLS_DC);
|
||||
PHPAPI void php_output_register_constants(TSRMLS_D);
|
||||
|
||||
/* RINIT */
|
||||
PHPAPI int php_output_activate(TSRMLS_D);
|
||||
/* RSHUTDOWN */
|
||||
PHPAPI void php_output_deactivate(TSRMLS_D);
|
||||
|
||||
PHPAPI zval *php_output_get_default_handler_name(TSRMLS_D);
|
||||
PHPAPI zval *php_output_get_devnull_handler_name(TSRMLS_D);
|
||||
|
||||
PHPAPI void php_output_set_status(int status TSRMLS_DC);
|
||||
PHPAPI int php_output_get_status(TSRMLS_D);
|
||||
PHPAPI void php_output_set_implicit_flush(int flush TSRMLS_DC);
|
||||
PHPAPI char *php_output_get_start_filename(TSRMLS_D);
|
||||
PHPAPI int php_output_get_start_lineno(TSRMLS_D);
|
||||
|
||||
PHPAPI int php_output_write_unbuffered(const char *str, size_t len TSRMLS_DC);
|
||||
PHPAPI int php_output_write(const char *str, size_t len TSRMLS_DC);
|
||||
|
||||
PHPAPI int php_output_flush(TSRMLS_D);
|
||||
PHPAPI void php_output_flush_all(TSRMLS_D);
|
||||
PHPAPI int php_output_clean(TSRMLS_D);
|
||||
PHPAPI void php_output_clean_all(TSRMLS_D);
|
||||
PHPAPI int php_output_end(TSRMLS_D);
|
||||
PHPAPI void php_output_end_all(TSRMLS_D);
|
||||
PHPAPI int php_output_discard(TSRMLS_D);
|
||||
PHPAPI void php_output_discard_all(TSRMLS_D);
|
||||
|
||||
PHPAPI int php_output_get_contents(zval *p TSRMLS_DC);
|
||||
PHPAPI int php_output_get_length(zval *p TSRMLS_DC);
|
||||
PHPAPI int php_output_get_level(TSRMLS_D);
|
||||
|
||||
PHPAPI int php_output_start_default(TSRMLS_D);
|
||||
PHPAPI int php_output_start_devnull(TSRMLS_D);
|
||||
|
||||
PHPAPI int php_output_start_user(zval *output_handler, size_t chunk_size, int flags TSRMLS_DC);
|
||||
PHPAPI int php_output_start_internal(zval *name, php_output_handler_func_t output_handler, size_t chunk_size, int flags TSRMLS_DC);
|
||||
|
||||
PHPAPI php_output_handler *php_output_handler_create_user(zval *handler, size_t chunk_size, int flags TSRMLS_DC);
|
||||
PHPAPI php_output_handler *php_output_handler_create_internal(zval *name, php_output_handler_context_func_t handler, size_t chunk_size, int flags TSRMLS_DC);
|
||||
|
||||
PHPAPI void php_output_handler_set_context(php_output_handler *handler, void *opaq, void (*dtor)(void* TSRMLS_DC) TSRMLS_DC);
|
||||
PHPAPI int php_output_handler_start(php_output_handler *handler TSRMLS_DC);
|
||||
PHPAPI int php_output_handler_started(zval *name TSRMLS_DC);
|
||||
PHPAPI int php_output_handler_hook(php_output_handler_hook_t type, void *arg TSRMLS_DC);
|
||||
PHPAPI void php_output_handler_dtor(php_output_handler *handler TSRMLS_DC);
|
||||
PHPAPI void php_output_handler_free(php_output_handler **handler TSRMLS_DC);
|
||||
|
||||
PHPAPI int php_output_handler_conflict(zval *handler_new, zval *handler_set TSRMLS_DC);
|
||||
PHPAPI int php_output_handler_conflict_register(zval *handler_name, php_output_handler_conflict_check_t check_func TSRMLS_DC);
|
||||
PHPAPI int php_output_handler_reverse_conflict_register(zval *handler_name, php_output_handler_conflict_check_t check_func TSRMLS_DC);
|
||||
|
||||
#define PHP_OUTPUT_CONFLICT_REGISTER(name, func) \
|
||||
{ \
|
||||
zval tmp_z; \
|
||||
char *tmp_s = (name); \
|
||||
INIT_PZVAL(&tmp_z); \
|
||||
ZVAL_STRING(&tmp_z, tmp_s, 1); \
|
||||
php_output_handler_conflict_register(&tmp_z, func TSRMLS_CC); \
|
||||
zval_dtor(&tmp_z); \
|
||||
}
|
||||
|
||||
#define PHP_OUTPUT_CONFLICT(check_name, action) \
|
||||
{ \
|
||||
int tmp_i; \
|
||||
zval tmp_z; \
|
||||
char *tmp_s = (check_name); \
|
||||
INIT_PZVAL(&tmp_z); \
|
||||
ZVAL_STRING(&tmp_z, tmp_s, 1); \
|
||||
tmp_i = php_output_handler_conflict(handler_name, &tmp_z TSRMLS_CC); \
|
||||
zval_dtor(&tmp_z); \
|
||||
if (tmp_i) { \
|
||||
action; \
|
||||
} \
|
||||
}
|
||||
|
||||
PHPAPI php_output_handler_alias_ctor_t *php_output_handler_alias(zval *handler_name TSRMLS_DC);
|
||||
PHPAPI int php_output_handler_alias_register(zval *handler_name, php_output_handler_alias_ctor_t func TSRMLS_DC);
|
||||
|
||||
#define PHP_OUTPUT_ALIAS_REGISTER(name, func) \
|
||||
{ \
|
||||
zval tmp_z; \
|
||||
char *tmp_s = (name); \
|
||||
INIT_PZVAL(&tmp_z); \
|
||||
ZVAL_STRING(&tmp_z, tmp_s, 1); \
|
||||
php_output_handler_alias_register(&tmp_z, func TSRMLS_CC); \
|
||||
zval_dtor(&tmp_z); \
|
||||
}
|
||||
|
||||
PHPAPI int php_default_output_func(const char *str, uint str_len TSRMLS_DC);
|
||||
PHPAPI int php_ub_body_write(const char *str, uint str_length TSRMLS_DC);
|
||||
PHPAPI int php_ub_body_write_no_header(const char *str, uint str_length TSRMLS_DC);
|
||||
PHPAPI int php_body_write(const char *str, uint str_length TSRMLS_DC);
|
||||
PHPAPI int php_header_write(const char *str, uint str_length TSRMLS_DC);
|
||||
PHPAPI int php_start_ob_buffer(zval *output_handler, uint chunk_size, zend_bool erase TSRMLS_DC);
|
||||
PHPAPI int php_start_ob_buffer_named(const char *output_handler_name, uint chunk_size, zend_bool erase TSRMLS_DC);
|
||||
PHPAPI void php_end_ob_buffer(zend_bool send_buffer, zend_bool just_flush TSRMLS_DC);
|
||||
PHPAPI void php_end_ob_buffers(zend_bool send_buffer TSRMLS_DC);
|
||||
PHPAPI int php_ob_get_buffer(zval *p TSRMLS_DC);
|
||||
PHPAPI int php_ob_get_length(zval *p TSRMLS_DC);
|
||||
PHPAPI void php_start_implicit_flush(TSRMLS_D);
|
||||
PHPAPI void php_end_implicit_flush(TSRMLS_D);
|
||||
PHPAPI char *php_get_output_start_filename(TSRMLS_D);
|
||||
PHPAPI int php_get_output_start_lineno(TSRMLS_D);
|
||||
PHPAPI void php_ob_set_internal_handler(php_output_handler_func_t internal_output_handler, uint buffer_size, char *handler_name, zend_bool erase TSRMLS_DC);
|
||||
PHPAPI int php_ob_handler_used(char *handler_name TSRMLS_DC);
|
||||
PHPAPI int php_ob_init_conflict(char *handler_new, char *handler_set TSRMLS_DC);
|
||||
PHPAPI int php_ob_get_buffer(zval *p TSRMLS_DC);
|
||||
PHPAPI int php_ob_get_length(zval *p TSRMLS_DC);
|
||||
END_EXTERN_C()
|
||||
|
||||
|
||||
PHP_FUNCTION(ob_start);
|
||||
PHP_FUNCTION(ob_flush);
|
||||
PHP_FUNCTION(ob_clean);
|
||||
|
@ -294,16 +64,51 @@ PHP_FUNCTION(ob_get_status);
|
|||
PHP_FUNCTION(ob_implicit_flush);
|
||||
PHP_FUNCTION(ob_list_handlers);
|
||||
|
||||
typedef struct _php_ob_buffer {
|
||||
char *buffer;
|
||||
uint size;
|
||||
uint text_length;
|
||||
int block_size;
|
||||
uint chunk_size;
|
||||
int status;
|
||||
zval *output_handler;
|
||||
php_output_handler_func_t internal_output_handler;
|
||||
char *internal_output_handler_buffer;
|
||||
uint internal_output_handler_buffer_size;
|
||||
char *handler_name;
|
||||
zend_bool erase;
|
||||
} php_ob_buffer;
|
||||
|
||||
typedef struct _php_output_globals {
|
||||
int (*php_body_write)(const char *str, uint str_length TSRMLS_DC); /* string output */
|
||||
int (*php_header_write)(const char *str, uint str_length TSRMLS_DC); /* unbuffer string output */
|
||||
php_ob_buffer active_ob_buffer;
|
||||
unsigned char implicit_flush;
|
||||
char *output_start_filename;
|
||||
int output_start_lineno;
|
||||
zend_stack ob_buffers;
|
||||
int ob_nesting_level;
|
||||
zend_bool ob_lock;
|
||||
zend_bool disable_output;
|
||||
} php_output_globals;
|
||||
|
||||
#ifdef ZTS
|
||||
#define OG(v) TSRMG(output_globals_id, php_output_globals *, v)
|
||||
ZEND_API extern int output_globals_id;
|
||||
#else
|
||||
#define OG(v) (output_globals.v)
|
||||
ZEND_API extern php_output_globals output_globals;
|
||||
#endif
|
||||
|
||||
#define PHP_OUTPUT_HANDLER_START (1<<0)
|
||||
#define PHP_OUTPUT_HANDLER_CONT (1<<1)
|
||||
#define PHP_OUTPUT_HANDLER_END (1<<2)
|
||||
|
||||
#define PHP_OUTPUT_HANDLER_INTERNAL 0
|
||||
#define PHP_OUTPUT_HANDLER_USER 1
|
||||
|
||||
PHP_FUNCTION(output_add_rewrite_var);
|
||||
PHP_FUNCTION(output_reset_rewrite_vars);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
#endif /* PHP_OUTPUT_H */
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <string.h> /* memset */
|
||||
#include <string.h> /* memset */
|
||||
extern char _edata, _end ; /* end of DATA (start of BSS), end of BSS */
|
||||
#endif
|
||||
|
||||
|
@ -41,15 +41,15 @@ int _lib_start()
|
|||
{
|
||||
/* printf("Inside _lib_start\n");*/
|
||||
#ifdef __GNUC__
|
||||
memset (&_edata, 0, &_end - &_edata);
|
||||
memset (&_edata, 0, &_end - &_edata);
|
||||
#endif
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _lib_stop()
|
||||
{
|
||||
/* printf("Inside _lib_stop\n");*/
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* NETWARE */
|
||||
|
|
|
@ -95,7 +95,7 @@ static void php_save_umask(void)
|
|||
static int sapi_apache_ub_write(const char *str, uint str_length TSRMLS_DC)
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
|
||||
if (SG(server_context)) {
|
||||
ret = rwrite(str, str_length, (request_rec *) SG(server_context));
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ static int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC)
|
|||
if (!SG(read_post_bytes) && !ap_should_client_block(r)) {
|
||||
return total_read_bytes;
|
||||
}
|
||||
|
||||
|
||||
handler = signal(SIGPIPE, SIG_IGN);
|
||||
while (total_read_bytes<count_bytes) {
|
||||
hard_timeout("Read POST information", r); /* start timeout timer */
|
||||
|
@ -148,7 +148,7 @@ static int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC)
|
|||
}
|
||||
total_read_bytes += read_bytes;
|
||||
}
|
||||
signal(SIGPIPE, handler);
|
||||
signal(SIGPIPE, handler);
|
||||
return total_read_bytes;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -332,15 +332,15 @@ static void php_apache_request_shutdown(void *dummy)
|
|||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
php_output_set_status(PHP_OUTPUT_DISABLED TSRMLS_CC);
|
||||
php_output_set_status(0 TSRMLS_CC);
|
||||
if (AP(in_request)) {
|
||||
AP(in_request) = 0;
|
||||
php_request_shutdown(dummy);
|
||||
}
|
||||
SG(server_context) = NULL;
|
||||
/*
|
||||
* The server context (request) is NOT invalid by the time
|
||||
* run_cleanups() is called
|
||||
SG(server_context) = NULL;
|
||||
/*
|
||||
* The server context (request) is NOT invalid by the time
|
||||
* run_cleanups() is called
|
||||
*/
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -349,7 +349,7 @@ static void php_apache_request_shutdown(void *dummy)
|
|||
*/
|
||||
static int php_apache_sapi_activate(TSRMLS_D)
|
||||
{
|
||||
request_rec *r = (request_rec *) SG(server_context);
|
||||
request_rec *r = (request_rec *) SG(server_context);
|
||||
|
||||
/*
|
||||
* For the Apache module version, this bit of code registers a cleanup
|
||||
|
@ -357,7 +357,7 @@ static int php_apache_sapi_activate(TSRMLS_D)
|
|||
* We need this because at any point in our code we can be interrupted
|
||||
* and that may happen before we have had time to free our memory.
|
||||
* The php_request_shutdown function needs to free all outstanding allocated
|
||||
* memory.
|
||||
* memory.
|
||||
*/
|
||||
block_alarms();
|
||||
register_cleanup(r->pool, NULL, php_apache_request_shutdown, php_request_shutdown_for_exec);
|
||||
|
@ -401,7 +401,7 @@ static int sapi_apache_get_fd(int *nfd TSRMLS_DC)
|
|||
int fd;
|
||||
|
||||
fd = r->connection->client->fd;
|
||||
|
||||
|
||||
if (fd >= 0) {
|
||||
if (nfd) *nfd = fd;
|
||||
return SUCCESS;
|
||||
|
@ -416,9 +416,9 @@ static int sapi_apache_get_fd(int *nfd TSRMLS_DC)
|
|||
static int sapi_apache_force_http_10(TSRMLS_D)
|
||||
{
|
||||
request_rec *r = SG(server_context);
|
||||
|
||||
|
||||
r->proto_num = HTTP_VERSION(1,0);
|
||||
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -464,7 +464,7 @@ static void sapi_apache_child_terminate(TSRMLS_D)
|
|||
static sapi_module_struct apache_sapi_module = {
|
||||
"apache", /* name */
|
||||
"Apache", /* pretty name */
|
||||
|
||||
|
||||
php_apache_startup, /* startup */
|
||||
php_module_shutdown_wrapper, /* shutdown */
|
||||
|
||||
|
@ -579,8 +579,8 @@ static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry TSRMLS_
|
|||
*/
|
||||
static char *php_apache_get_default_mimetype(request_rec *r TSRMLS_DC)
|
||||
{
|
||||
|
||||
char *mimetype;
|
||||
|
||||
if (SG(default_mimetype) || SG(default_charset)) {
|
||||
/* Assume output will be of the default MIME type. Individual
|
||||
scripts may change this later. */
|
||||
|
@ -628,7 +628,7 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
|
|||
if (per_dir_conf) {
|
||||
zend_hash_apply((HashTable *) per_dir_conf, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);
|
||||
}
|
||||
|
||||
|
||||
/* If PHP parser engine has been turned off with an "engine off"
|
||||
* directive, then decline to handle this request
|
||||
*/
|
||||
|
@ -696,8 +696,9 @@ static int send_parsed_php(request_rec * r)
|
|||
{
|
||||
int result = send_php(r, 0, NULL);
|
||||
TSRMLS_FETCH();
|
||||
|
||||
ap_table_setn(r->notes, "mod_php_memory_usage", ap_psprintf(r->pool, "%lu", zend_memory_peak_usage(1 TSRMLS_CC)));
|
||||
|
||||
ap_table_setn(r->notes, "mod_php_memory_usage",
|
||||
ap_psprintf(r->pool, "%lu", zend_memory_peak_usage(1 TSRMLS_CC)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -859,7 +860,7 @@ static CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *
|
|||
bool_val[0] = '0';
|
||||
}
|
||||
bool_val[1] = 0;
|
||||
|
||||
|
||||
return php_apache_value_handler_ex(cmd, conf, arg1, bool_val, mode);
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -925,7 +926,7 @@ static void apache_php_module_shutdown_wrapper(void)
|
|||
|
||||
#if MODULE_MAGIC_NUMBER >= 19970728
|
||||
/* This function is only called on server exit if the apache API
|
||||
* child_exit handler exists, so shutdown globally
|
||||
* child_exit handler exists, so shutdown globally
|
||||
*/
|
||||
sapi_shutdown();
|
||||
#endif
|
||||
|
|
|
@ -93,6 +93,8 @@ ZEND_END_ARG_INFO()
|
|||
ZEND_BEGIN_ARG_INFO(arginfo_apache_reset_timeout, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
|
||||
|
||||
const zend_function_entry apache_functions[] = {
|
||||
PHP_FE(virtual, arginfo_apache_virtual)
|
||||
PHP_FE(apache_request_headers, arginfo_apache_request_headers)
|
||||
|
@ -108,6 +110,7 @@ const zend_function_entry apache_functions[] = {
|
|||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
PHP_INI_BEGIN()
|
||||
STD_PHP_INI_ENTRY("xbithack", "0", PHP_INI_ALL, OnUpdateLong, xbithack, php_apache_info_struct, php_apache_info)
|
||||
STD_PHP_INI_ENTRY("engine", "1", PHP_INI_ALL, OnUpdateLong, engine, php_apache_info_struct, php_apache_info)
|
||||
|
@ -115,11 +118,14 @@ PHP_INI_BEGIN()
|
|||
STD_PHP_INI_ENTRY("child_terminate", "0", PHP_INI_ALL, OnUpdateLong, terminate_child, php_apache_info_struct, php_apache_info)
|
||||
PHP_INI_END()
|
||||
|
||||
|
||||
|
||||
static void php_apache_globals_ctor(php_apache_info_struct *apache_globals TSRMLS_DC)
|
||||
{
|
||||
apache_globals->in_request = 0;
|
||||
}
|
||||
|
||||
|
||||
static PHP_MINIT_FUNCTION(apache)
|
||||
{
|
||||
#ifdef ZTS
|
||||
|
@ -131,6 +137,7 @@ static PHP_MINIT_FUNCTION(apache)
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static PHP_MSHUTDOWN_FUNCTION(apache)
|
||||
{
|
||||
UNREGISTER_INI_ENTRIES();
|
||||
|
@ -139,13 +146,13 @@ static PHP_MSHUTDOWN_FUNCTION(apache)
|
|||
|
||||
zend_module_entry apache_module_entry = {
|
||||
STANDARD_MODULE_HEADER,
|
||||
"apache",
|
||||
apache_functions,
|
||||
PHP_MINIT(apache),
|
||||
PHP_MSHUTDOWN(apache),
|
||||
NULL,
|
||||
NULL,
|
||||
PHP_MINFO(apache),
|
||||
"apache",
|
||||
apache_functions,
|
||||
PHP_MINIT(apache),
|
||||
PHP_MSHUTDOWN(apache),
|
||||
NULL,
|
||||
NULL,
|
||||
PHP_MINFO(apache),
|
||||
NO_VERSION_YET,
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
|
@ -171,6 +178,7 @@ PHP_MINFO_FUNCTION(apache)
|
|||
|
||||
serv = ((request_rec *) SG(server_context))->server;
|
||||
|
||||
|
||||
php_info_print_table_start();
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
|
@ -188,7 +196,7 @@ PHP_MINFO_FUNCTION(apache)
|
|||
|
||||
if (apv && *apv) {
|
||||
php_info_print_table_row(2, "Apache Version", apv);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef APACHE_RELEASE
|
||||
snprintf(output_buf, sizeof(output_buf), "%d", APACHE_RELEASE);
|
||||
|
@ -214,7 +222,7 @@ PHP_MINFO_FUNCTION(apache)
|
|||
php_info_print_table_row(2, "Server Root", server_root);
|
||||
|
||||
strcpy(modulenames, "");
|
||||
for (modp = top_module; modp; modp = modp->next) {
|
||||
for(modp = top_module; modp; modp = modp->next) {
|
||||
strlcpy(name, modp->name, sizeof(name));
|
||||
if ((p = strrchr(name, '.'))) {
|
||||
*p='\0'; /* Cut off ugly .c extensions on module names */
|
||||
|
@ -240,14 +248,14 @@ PHP_MINFO_FUNCTION(apache)
|
|||
r = ((request_rec *) SG(server_context));
|
||||
arr = table_elts(r->subprocess_env);
|
||||
elts = (table_entry *)arr->elts;
|
||||
|
||||
|
||||
SECTION("Apache Environment");
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_header(2, "Variable", "Value");
|
||||
for (i=0; i < arr->nelts; i++) {
|
||||
php_info_print_table_row(2, elts[i].key, elts[i].val);
|
||||
}
|
||||
php_info_print_table_end();
|
||||
php_info_print_table_end();
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -255,7 +263,7 @@ PHP_MINFO_FUNCTION(apache)
|
|||
table_entry *env;
|
||||
int i;
|
||||
request_rec *r;
|
||||
|
||||
|
||||
r = ((request_rec *) SG(server_context));
|
||||
SECTION("HTTP Headers Information");
|
||||
php_info_print_table_start();
|
||||
|
@ -271,7 +279,7 @@ PHP_MINFO_FUNCTION(apache)
|
|||
php_info_print_table_colspan_header(2, "HTTP Response Headers");
|
||||
env_arr = table_elts(r->headers_out);
|
||||
env = (table_entry *)env_arr->elts;
|
||||
for (i = 0; i < env_arr->nelts; ++i) {
|
||||
for(i = 0; i < env_arr->nelts; ++i) {
|
||||
if (env[i].key) {
|
||||
php_info_print_table_row(2, env[i].key, env[i].val);
|
||||
}
|
||||
|
@ -345,37 +353,34 @@ PHP_FUNCTION(virtual)
|
|||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!(rr = sub_req_lookup_uri (filename, ((request_rec *) SG(server_context))))) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - URI lookup failed", filename);
|
||||
if (rr) {
|
||||
if (rr)
|
||||
destroy_sub_req (rr);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (rr->status != 200) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - error finding URI", filename);
|
||||
if (rr) {
|
||||
if (rr)
|
||||
destroy_sub_req (rr);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
php_output_end_all(TSRMLS_C);
|
||||
php_end_ob_buffers(1 TSRMLS_CC);
|
||||
php_header(TSRMLS_C);
|
||||
|
||||
if (run_sub_req(rr)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include '%s' - request execution failed", filename);
|
||||
if (rr) {
|
||||
if (rr)
|
||||
destroy_sub_req (rr);
|
||||
}
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (rr) {
|
||||
if (rr)
|
||||
destroy_sub_req (rr);
|
||||
}
|
||||
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -404,7 +409,7 @@ PHP_FUNCTION(apache_request_headers)
|
|||
if (add_assoc_string(return_value, tenv[i].key, (tenv[i].val==NULL) ? "" : tenv[i].val, 1)==FAILURE) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -441,10 +446,8 @@ PHP_FUNCTION(apache_setenv)
|
|||
return;
|
||||
}
|
||||
|
||||
while (top) {
|
||||
if (r->prev) {
|
||||
r = r->prev;
|
||||
}
|
||||
while(top) {
|
||||
if(r->prev) r = r->prev;
|
||||
else break;
|
||||
}
|
||||
|
||||
|
@ -477,16 +480,16 @@ PHP_FUNCTION(apache_lookup_uri)
|
|||
add_property_string(return_value,"the_request", rr->the_request, 1);
|
||||
}
|
||||
if (rr->status_line) {
|
||||
add_property_string(return_value,"status_line", (char *)rr->status_line, 1);
|
||||
add_property_string(return_value,"status_line", (char *)rr->status_line, 1);
|
||||
}
|
||||
if (rr->method) {
|
||||
add_property_string(return_value,"method", (char *)rr->method, 1);
|
||||
add_property_string(return_value,"method", (char *)rr->method, 1);
|
||||
}
|
||||
if (rr->content_type) {
|
||||
add_property_string(return_value,"content_type", (char *)rr->content_type, 1);
|
||||
}
|
||||
if (rr->handler) {
|
||||
add_property_string(return_value,"handler", (char *)rr->handler, 1);
|
||||
add_property_string(return_value,"handler", (char *)rr->handler, 1);
|
||||
}
|
||||
if (rr->uri) {
|
||||
add_property_string(return_value,"uri", rr->uri, 1);
|
||||
|
@ -516,11 +519,11 @@ PHP_FUNCTION(apache_lookup_uri)
|
|||
if (rr->unparsed_uri) {
|
||||
add_property_string(return_value,"unparsed_uri", rr->unparsed_uri, 1);
|
||||
}
|
||||
if (rr->mtime) {
|
||||
if(rr->mtime) {
|
||||
add_property_long(return_value,"mtime", rr->mtime);
|
||||
}
|
||||
#endif
|
||||
if (rr->request_time) {
|
||||
if(rr->request_time) {
|
||||
add_property_long(return_value,"request_time", rr->request_time);
|
||||
}
|
||||
|
||||
|
@ -543,7 +546,7 @@ PHP_FUNCTION(apache_exec_uri)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!(rr = ap_sub_req_lookup_uri(filename, ((request_rec *) SG(server_context))))) {
|
||||
if(!(rr = ap_sub_req_lookup_uri(filename, ((request_rec *) SG(server_context))))) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "URI lookup failed", filename);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
@ -573,16 +576,16 @@ PHP_FUNCTION(apache_get_modules)
|
|||
{
|
||||
int n;
|
||||
char *p;
|
||||
|
||||
|
||||
array_init(return_value);
|
||||
|
||||
|
||||
for (n = 0; ap_loaded_modules[n]; ++n) {
|
||||
char *s = (char *) ap_loaded_modules[n]->name;
|
||||
if ((p = strchr(s, '.'))) {
|
||||
add_next_index_stringl(return_value, s, (p - s), 1);
|
||||
} else {
|
||||
add_next_index_string(return_value, s, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
|
||||
{
|
||||
int retval = OK;
|
||||
int retval = OK;
|
||||
zend_file_handle file_handle;
|
||||
|
||||
if (php_request_startup(TSRMLS_C) == FAILURE) {
|
||||
|
@ -35,7 +35,7 @@ int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
|
|||
}
|
||||
/* sending a file handle to another dll is not working
|
||||
so let zend open it. */
|
||||
|
||||
|
||||
if (display_source_mode) {
|
||||
zend_syntax_highlighter_ini syntax_highlighter_ini;
|
||||
|
||||
|
@ -54,11 +54,11 @@ int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
|
|||
}
|
||||
|
||||
AP(in_request) = 0;
|
||||
|
||||
|
||||
zend_try {
|
||||
php_request_shutdown(NULL);
|
||||
} zend_end_try();
|
||||
|
||||
|
||||
return retval;
|
||||
}
|
||||
/* }}} */
|
||||
|
|
|
@ -91,7 +91,7 @@ PHP_FUNCTION(virtual)
|
|||
}
|
||||
|
||||
/* Flush everything. */
|
||||
php_output_end_all(TSRMLS_C);
|
||||
php_end_ob_buffers(1 TSRMLS_CC);
|
||||
php_header(TSRMLS_C);
|
||||
|
||||
/* Ensure that the ap_r* layer for the main request is flushed, to
|
||||
|
|
|
@ -53,9 +53,10 @@ static void php_child_exit_handler(server_rec *s, pool *p);
|
|||
#define CONST_PREFIX
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct _sapi_stack {
|
||||
int top, max, persistent;
|
||||
void **elements;
|
||||
int top, max, persistent;
|
||||
void **elements;
|
||||
} sapi_stack;
|
||||
|
||||
typedef struct _php_per_dir_config {
|
||||
|
@ -75,6 +76,7 @@ typedef struct _php_per_server_config {
|
|||
sapi_stack requires;
|
||||
} php_per_server_config;
|
||||
|
||||
|
||||
static CONST_PREFIX char *php_apache_value_handler_ex(cmd_parms *cmd, HashTable *conf, char *arg1, char *arg2, int mode);
|
||||
static CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1, char *arg2);
|
||||
static CONST_PREFIX char *php_apache_admin_value_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1, char *arg2);
|
||||
|
@ -106,68 +108,68 @@ typedef struct _php_per_dir_entry {
|
|||
*/
|
||||
|
||||
/* This code is ripped part and parcel from zend_stack.[ch]. Assuming that the
|
||||
patch supporting zend_stack_init_ex is applied, all but the bottom two
|
||||
patch supporting zend_stack_init_ex is applied, all but the bottom two
|
||||
module-specific iterators will be removed
|
||||
*/
|
||||
|
||||
int sapi_stack_init_ex(sapi_stack *stack, int persistent)
|
||||
{
|
||||
stack->top = 0;
|
||||
stack->persistent = persistent;
|
||||
stack->elements = (void **) pemalloc(sizeof(void **) * STACK_BLOCK_SIZE, persistent);
|
||||
if (!stack->elements) {
|
||||
return FAILURE;
|
||||
} else {
|
||||
stack->max = STACK_BLOCK_SIZE;
|
||||
return SUCCESS;
|
||||
}
|
||||
stack->top = 0;
|
||||
stack->persistent = persistent;
|
||||
stack->elements = (void **) pemalloc(sizeof(void **) * STACK_BLOCK_SIZE, persistent);
|
||||
if (!stack->elements) {
|
||||
return FAILURE;
|
||||
} else {
|
||||
stack->max = STACK_BLOCK_SIZE;
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
int sapi_stack_push(sapi_stack *stack, void *element)
|
||||
{
|
||||
if (stack->top >= stack->max) { /* we need to allocate more memory */
|
||||
stack->elements = (void **) perealloc(stack->elements, (sizeof(void **) * (stack->max += STACK_BLOCK_SIZE)), stack->persistent);
|
||||
if (!stack->elements) {
|
||||
return FAILURE;
|
||||
if (stack->top >= stack->max) { /* we need to allocate more memory */
|
||||
stack->elements = (void **) perealloc(stack->elements,
|
||||
(sizeof(void **) * (stack->max += STACK_BLOCK_SIZE)), stack->persistent);
|
||||
if (!stack->elements) {
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
stack->elements[stack->top] = (void *) element;
|
||||
return stack->top++;
|
||||
stack->elements[stack->top] = (void *) element;
|
||||
return stack->top++;
|
||||
}
|
||||
|
||||
void* sapi_stack_pop(sapi_stack *stack)
|
||||
{
|
||||
if (stack->top == 0) {
|
||||
void* sapi_stack_pop(sapi_stack *stack) {
|
||||
if(stack->top == 0) {
|
||||
return NULL;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return stack->elements[--stack->top];
|
||||
}
|
||||
}
|
||||
|
||||
int sapi_stack_destroy(sapi_stack *stack)
|
||||
{
|
||||
return SUCCESS;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int sapi_stack_apply_with_argument_all(sapi_stack *stack, int type, int (*apply_function)(void *element, void *arg), void *arg)
|
||||
{
|
||||
int i, retval;
|
||||
int i, retval;
|
||||
|
||||
switch (type) {
|
||||
case ZEND_STACK_APPLY_TOPDOWN:
|
||||
for (i=stack->top-1; i>=0; i--) {
|
||||
retval = apply_function(stack->elements[i], arg);
|
||||
}
|
||||
break;
|
||||
case ZEND_STACK_APPLY_BOTTOMUP:
|
||||
for (i=0; i<stack->top; i++) {
|
||||
retval = apply_function(stack->elements[i], arg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return retval;
|
||||
switch (type) {
|
||||
case ZEND_STACK_APPLY_TOPDOWN:
|
||||
for (i=stack->top-1; i>=0; i--) {
|
||||
retval = apply_function(stack->elements[i], arg);
|
||||
}
|
||||
break;
|
||||
case ZEND_STACK_APPLY_BOTTOMUP:
|
||||
for (i=0; i<stack->top; i++) {
|
||||
retval = apply_function(stack->elements[i], arg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
int sapi_stack_apply_with_argument_stop_if_equals(sapi_stack *stack, int type, int (*apply_function)(void *element, void *arg), void *arg, int stopval)
|
||||
{
|
||||
int i;
|
||||
|
@ -222,7 +224,7 @@ void php_handler_stack_destroy(sapi_stack *stack)
|
|||
free(ph);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_save_umask
|
||||
*/
|
||||
|
@ -238,7 +240,7 @@ static void php_save_umask(void)
|
|||
static int sapi_apache_ub_write(const char *str, uint str_length TSRMLS_DC)
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
|
||||
if (SG(server_context)) {
|
||||
ret = rwrite(str, str_length, (request_rec *) SG(server_context));
|
||||
}
|
||||
|
@ -280,7 +282,7 @@ static int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC)
|
|||
if (!SG(read_post_bytes) && !ap_should_client_block(r)) {
|
||||
return total_read_bytes;
|
||||
}
|
||||
|
||||
|
||||
handler = signal(SIGPIPE, SIG_IGN);
|
||||
while (total_read_bytes<count_bytes) {
|
||||
hard_timeout("Read POST information", r); /* start timeout timer */
|
||||
|
@ -291,7 +293,7 @@ static int sapi_apache_read_post(char *buffer, uint count_bytes TSRMLS_DC)
|
|||
}
|
||||
total_read_bytes += read_bytes;
|
||||
}
|
||||
signal(SIGPIPE, handler);
|
||||
signal(SIGPIPE, handler);
|
||||
return total_read_bytes;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -310,8 +312,7 @@ static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_head
|
|||
{
|
||||
char *header_name, *header_content, *p;
|
||||
request_rec *r = (request_rec *) SG(server_context);
|
||||
|
||||
if (!r) {
|
||||
if(!r) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -362,15 +363,15 @@ static int sapi_apache_header_handler(sapi_header_struct *sapi_header, sapi_head
|
|||
*/
|
||||
static int sapi_apache_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
|
||||
{
|
||||
if (SG(server_context) == NULL) { /* server_context is not here anymore */
|
||||
if(SG(server_context) == NULL) { /* server_context is not here anymore */
|
||||
return SAPI_HEADER_SEND_FAILED;
|
||||
}
|
||||
|
||||
((request_rec *) SG(server_context))->status = SG(sapi_headers).http_response_code;
|
||||
/* check that we haven't sent headers already, we use our own
|
||||
* headers_sent since we may send headers at anytime
|
||||
* headers_sent since we may send headers at anytime
|
||||
*/
|
||||
if (!AP(headers_sent)) {
|
||||
if(!AP(headers_sent)) {
|
||||
send_http_header((request_rec *) SG(server_context));
|
||||
AP(headers_sent) = 1;
|
||||
}
|
||||
|
@ -454,16 +455,15 @@ static void php_apache_log_message(char *message)
|
|||
static void php_apache_request_shutdown(void *dummy)
|
||||
{
|
||||
TSRMLS_FETCH();
|
||||
|
||||
AP(current_hook) = AP_CLEANUP;
|
||||
php_output_set_status(PHP_OUTPUT_DISABLED TSRMLS_CC);
|
||||
php_output_set_status(0 TSRMLS_CC);
|
||||
SG(server_context) = NULL; /* The server context (request) is invalid by the time run_cleanups() is called */
|
||||
if (SG(sapi_started)) {
|
||||
if(SG(sapi_started)) {
|
||||
php_request_shutdown(dummy);
|
||||
SG(sapi_started) = 0;
|
||||
}
|
||||
AP(in_request) = 0;
|
||||
if (AP(setup_env)) {
|
||||
if(AP(setup_env)) {
|
||||
AP(setup_env) = 0;
|
||||
}
|
||||
AP(current_hook) = AP_WAITING_FOR_REQUEST;
|
||||
|
@ -475,7 +475,7 @@ static void php_apache_request_shutdown(void *dummy)
|
|||
*/
|
||||
static int php_apache_sapi_activate(TSRMLS_D)
|
||||
{
|
||||
request_rec *r = (request_rec *) SG(server_context);
|
||||
request_rec *r = (request_rec *) SG(server_context);
|
||||
|
||||
/*
|
||||
* For the Apache module version, this bit of code registers a cleanup
|
||||
|
@ -483,7 +483,7 @@ static int php_apache_sapi_activate(TSRMLS_D)
|
|||
* We need this because at any point in our code we can be interrupted
|
||||
* and that may happen before we have had time to free our memory.
|
||||
* The php_request_shutdown function needs to free all outstanding allocated
|
||||
* memory.
|
||||
* memory.
|
||||
*/
|
||||
block_alarms();
|
||||
register_cleanup(r->pool, NULL, php_apache_request_shutdown, php_request_shutdown_for_exec);
|
||||
|
@ -519,7 +519,7 @@ static char *php_apache_getenv(char *name, size_t name_len TSRMLS_DC)
|
|||
static sapi_module_struct apache_sapi_module = {
|
||||
"apache", /* name */
|
||||
"Apache", /* pretty name */
|
||||
|
||||
|
||||
php_apache_startup, /* startup */
|
||||
php_module_shutdown_wrapper, /* shutdown */
|
||||
|
||||
|
@ -560,6 +560,7 @@ static sapi_module_struct apache_sapi_module = {
|
|||
NULL, /* exe location */
|
||||
0, /* ini ignore */
|
||||
NULL
|
||||
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
|
@ -597,20 +598,20 @@ static void init_request_info(TSRMLS_D)
|
|||
SG(request_info).auth_password = NULL;
|
||||
|
||||
if (authorization && !auth_type(r)) {
|
||||
if (!strcasecmp(getword(r->pool, &authorization, ' '), "Basic")) {
|
||||
tmp = uudecode(r->pool, authorization);
|
||||
tmp_user = getword_nulls_nc(r->pool, &tmp, ':');
|
||||
if (tmp_user) {
|
||||
r->connection->user = pstrdup(r->connection->pool, tmp_user);
|
||||
r->connection->ap_auth_type = "Basic";
|
||||
SG(request_info).auth_user = estrdup(tmp_user);
|
||||
}
|
||||
if (tmp) {
|
||||
SG(request_info).auth_password = estrdup(tmp);
|
||||
}
|
||||
} else if (!strcasecmp(getword(r->pool, &authorization, ' '), "Digest")) {
|
||||
r->connection->ap_auth_type = "Digest";
|
||||
SG(request_info).auth_digest = estrdup(authorization);
|
||||
if (!strcasecmp(getword(r->pool, &authorization, ' '), "Basic")) {
|
||||
tmp = uudecode(r->pool, authorization);
|
||||
tmp_user = getword_nulls_nc(r->pool, &tmp, ':');
|
||||
if (tmp_user) {
|
||||
r->connection->user = pstrdup(r->connection->pool, tmp_user);
|
||||
r->connection->ap_auth_type = "Basic";
|
||||
SG(request_info).auth_user = estrdup(tmp_user);
|
||||
}
|
||||
if (tmp) {
|
||||
SG(request_info).auth_password = estrdup(tmp);
|
||||
}
|
||||
} else if (!strcasecmp(getword(r->pool, &authorization, ' '), "Digest")) {
|
||||
r->connection->ap_auth_type = "Digest";
|
||||
SG(request_info).auth_digest = estrdup(authorization);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -629,8 +630,8 @@ static int php_apache_alter_ini_entries(php_per_dir_entry *per_dir_entry TSRMLS_
|
|||
*/
|
||||
static char *php_apache_get_default_mimetype(request_rec *r TSRMLS_DC)
|
||||
{
|
||||
|
||||
char *mimetype;
|
||||
|
||||
if (SG(default_mimetype) || SG(default_charset)) {
|
||||
/* Assume output will be of the default MIME type. Individual
|
||||
scripts may change this later. */
|
||||
|
@ -652,7 +653,6 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
|
|||
int retval;
|
||||
php_per_dir_config *per_dir_conf;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (AP(in_request)) {
|
||||
zend_file_handle fh;
|
||||
|
||||
|
@ -724,16 +724,16 @@ static int send_php(request_rec *r, int display_source_mode, char *filename)
|
|||
hard_timeout("send", r);
|
||||
|
||||
SG(server_context) = r;
|
||||
|
||||
|
||||
php_save_umask();
|
||||
if (!AP(setup_env)) {
|
||||
if(!AP(setup_env)) {
|
||||
AP(setup_env) = 1;
|
||||
add_common_vars(r);
|
||||
add_cgi_vars(r);
|
||||
}
|
||||
init_request_info(TSRMLS_C);
|
||||
apache_php_module_main(r, display_source_mode TSRMLS_CC);
|
||||
|
||||
|
||||
/* Done, restore umask, turn off timeout, close file and return */
|
||||
php_restore_umask();
|
||||
kill_timeout(r);
|
||||
|
@ -749,8 +749,9 @@ static int send_parsed_php(request_rec * r)
|
|||
{
|
||||
int result = send_php(r, 0, NULL);
|
||||
TSRMLS_FETCH();
|
||||
|
||||
ap_table_setn(r->notes, "mod_php_memory_usage", ap_psprintf(r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC)));
|
||||
|
||||
ap_table_setn(r->notes, "mod_php_memory_usage",
|
||||
ap_psprintf(r->pool, "%u", zend_memory_peak_usage(1 TSRMLS_CC)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -764,6 +765,7 @@ static int send_parsed_php_source(request_rec * r)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ destroy_per_dir_entry
|
||||
*/
|
||||
static void destroy_per_dir_entry(php_per_dir_entry *per_dir_entry)
|
||||
|
@ -819,7 +821,7 @@ static void php_destroy_per_server_info(php_per_server_config *conf)
|
|||
|
||||
/* {{{ php_destroy_per_dir_info
|
||||
*/
|
||||
static void php_destroy_per_dir_info(php_per_dir_config *conf)
|
||||
static void php_destroy_per_dir_info(php_per_dir_config *conf)
|
||||
{
|
||||
zend_hash_destroy(conf->ini_settings);
|
||||
php_handler_stack_destroy(&conf->response_handlers);
|
||||
|
@ -841,19 +843,20 @@ static void *php_create_server(pool *p, char *dummy)
|
|||
php_per_server_config *conf;
|
||||
conf = (php_per_server_config *) malloc(sizeof(php_per_server_config));
|
||||
register_cleanup(p, (void *) conf, (void (*)(void *)) php_destroy_per_server_info, (void (*)(void *)) php_destroy_per_server_info);
|
||||
|
||||
|
||||
sapi_stack_init_ex(&conf->requires, 1);
|
||||
sapi_stack_init_ex(&conf->uri_handlers, 1);
|
||||
return conf;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ php_create_dir
|
||||
*/
|
||||
static void *php_create_dir(pool *p, char *dummy)
|
||||
{
|
||||
php_per_dir_config *conf;
|
||||
|
||||
conf = (php_per_dir_config *) malloc(sizeof(php_per_dir_config));
|
||||
conf->ini_settings = (HashTable *) malloc(sizeof(HashTable));
|
||||
zend_hash_init_ex(conf->ini_settings, 5, NULL, (void (*)(void *)) destroy_per_dir_entry, 1, 0);
|
||||
|
@ -866,9 +869,10 @@ static void *php_create_dir(pool *p, char *dummy)
|
|||
sapi_stack_init_ex(&conf->logger_handlers, 1);
|
||||
sapi_stack_init_ex(&conf->post_read_handlers, 1);
|
||||
register_cleanup(p, (void *) conf, (void (*)(void *)) php_destroy_per_dir_info, (void (*)(void *)) php_destroy_per_dir_info);
|
||||
|
||||
|
||||
return conf;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_merge_dir
|
||||
|
@ -987,7 +991,7 @@ static CONST_PREFIX char *php_set_dir_handler(php_per_dir_config *conf, char *ar
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* {{{ php_set_uri_handler
|
||||
/* {{{ php_set_uri_handler
|
||||
*/
|
||||
static CONST_PREFIX char *php_set_uri_handler(cmd_parms *cmd, void *dummy, char *arg1)
|
||||
{
|
||||
|
@ -1014,7 +1018,7 @@ static CONST_PREFIX char *php_set_header_handler_code(cmd_parms *cmd, php_per_di
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_set_auth_handler
|
||||
/* {{{ php_set_auth_handler
|
||||
*/
|
||||
static CONST_PREFIX char *php_set_auth_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1)
|
||||
{
|
||||
|
@ -1024,6 +1028,7 @@ static CONST_PREFIX char *php_set_auth_handler_code(cmd_parms *cmd, php_per_dir_
|
|||
{
|
||||
return php_set_dir_handler(conf, arg1, AP_AUTHENTICATION, AP_HANDLER_TYPE_METHOD);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_set_access_handler
|
||||
|
@ -1036,6 +1041,7 @@ static CONST_PREFIX char *php_set_access_handler_code(cmd_parms *cmd, php_per_di
|
|||
{
|
||||
return php_set_dir_handler(conf, arg1, AP_ACCESS_CONTROL, AP_HANDLER_TYPE_METHOD);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_set_type_handler
|
||||
|
@ -1048,6 +1054,7 @@ static CONST_PREFIX char *php_set_type_handler_code(cmd_parms *cmd, php_per_dir_
|
|||
{
|
||||
return php_set_dir_handler(conf, arg1, AP_TYPE_CHECKING, AP_HANDLER_TYPE_METHOD);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_set_fixup_handler
|
||||
|
@ -1072,7 +1079,8 @@ static CONST_PREFIX char *php_set_logger_handler_code(cmd_parms *cmd, php_per_di
|
|||
{
|
||||
return php_set_dir_handler(conf, arg1, AP_LOGGING, AP_HANDLER_TYPE_METHOD);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_set_post_read_handler
|
||||
*/
|
||||
|
@ -1084,10 +1092,13 @@ static CONST_PREFIX char *php_set_post_read_handler_code(cmd_parms *cmd, php_per
|
|||
{
|
||||
return php_set_dir_handler(conf, arg1, AP_POST_READ, AP_HANDLER_TYPE_METHOD);
|
||||
}
|
||||
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_set_require
|
||||
*/
|
||||
|
||||
static CONST_PREFIX char *php_set_require(cmd_parms *cmd, void *dummy, char *arg1)
|
||||
{
|
||||
return php_set_server_handler(cmd->server, arg1, 0, AP_HANDLER_TYPE_FILE);
|
||||
|
@ -1105,7 +1116,7 @@ static CONST_PREFIX char *php_set_response_handler_code(cmd_parms *cmd, php_per_
|
|||
return php_set_dir_handler(conf, arg1, AP_RESPONSE, AP_HANDLER_TYPE_METHOD);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ php_apache_value_handler
|
||||
*/
|
||||
static CONST_PREFIX char *php_apache_value_handler(cmd_parms *cmd, php_per_dir_config *conf, char *arg1, char *arg2)
|
||||
|
@ -1134,7 +1145,7 @@ static CONST_PREFIX char *php_apache_flag_handler_ex(cmd_parms *cmd, HashTable *
|
|||
bool_val[0] = '0';
|
||||
}
|
||||
bool_val[1] = 0;
|
||||
|
||||
|
||||
return php_apache_value_handler_ex(cmd, conf, arg1, bool_val, mode);
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -1182,7 +1193,7 @@ static int php_xbithack_handler(request_rec * r)
|
|||
if (conf) {
|
||||
zend_hash_apply((HashTable *) conf->ini_settings, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);
|
||||
}
|
||||
if (!AP(xbithack)) {
|
||||
if(!AP(xbithack)) {
|
||||
r->allowed |= (1 << METHODS) - 1;
|
||||
zend_try {
|
||||
zend_ini_deactivate(TSRMLS_C);
|
||||
|
@ -1202,7 +1213,7 @@ static void apache_php_module_shutdown_wrapper(void)
|
|||
|
||||
#if MODULE_MAGIC_NUMBER >= 19970728
|
||||
/* This function is only called on server exit if the apache API
|
||||
* child_exit handler exists, so shutdown globally
|
||||
* child_exit handler exists, so shutdown globally
|
||||
*/
|
||||
sapi_shutdown();
|
||||
#endif
|
||||
|
@ -1256,9 +1267,10 @@ static int php_run_hook(php_handler *handler, request_rec *r)
|
|||
{
|
||||
zval *ret = NULL;
|
||||
php_per_dir_config *conf;
|
||||
|
||||
TSRMLS_FETCH();
|
||||
|
||||
if (!AP(apache_config_loaded)) {
|
||||
if(!AP(apache_config_loaded)) {
|
||||
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
|
||||
if (conf)
|
||||
zend_hash_apply((HashTable *)conf->ini_settings, (apply_func_t) php_apache_alter_ini_entries TSRMLS_CC);
|
||||
|
@ -1284,16 +1296,16 @@ static int php_run_hook(php_handler *handler, request_rec *r)
|
|||
}
|
||||
return HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
|
||||
static int php_uri_translation(request_rec *r)
|
||||
{
|
||||
{
|
||||
php_per_server_config *conf;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
AP(current_hook) = AP_URI_TRANS;
|
||||
conf = (php_per_server_config *) get_module_config(r->server->module_config, &php5_module);
|
||||
return sapi_stack_apply_with_argument_stop_if_equals(&conf->uri_handlers,
|
||||
ZEND_STACK_APPLY_BOTTOMUP,
|
||||
return sapi_stack_apply_with_argument_stop_if_equals(&conf->uri_handlers,
|
||||
ZEND_STACK_APPLY_BOTTOMUP,
|
||||
(int (*)(void *element, void *)) php_run_hook, r, OK);
|
||||
}
|
||||
|
||||
|
@ -1301,7 +1313,6 @@ static int php_header_hook(request_rec *r)
|
|||
{
|
||||
php_per_dir_config *conf;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
AP(current_hook) = AP_HEADER_PARSE;
|
||||
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
|
||||
return sapi_stack_apply_with_argument_stop_if_http_error(&conf->headers_handlers,
|
||||
|
@ -1313,11 +1324,10 @@ static int php_auth_hook(request_rec *r)
|
|||
{
|
||||
php_per_dir_config *conf;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
AP(current_hook) = AP_AUTHENTICATION;
|
||||
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
|
||||
return sapi_stack_apply_with_argument_stop_if_equals(&conf->auth_handlers,
|
||||
ZEND_STACK_APPLY_BOTTOMUP,
|
||||
return sapi_stack_apply_with_argument_stop_if_equals(&conf->auth_handlers,
|
||||
ZEND_STACK_APPLY_BOTTOMUP,
|
||||
(int (*)(void *element, void *)) php_run_hook, r, OK);
|
||||
}
|
||||
|
||||
|
@ -1326,7 +1336,6 @@ static int php_access_hook(request_rec *r)
|
|||
php_per_dir_config *conf;
|
||||
int status = DECLINED;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
AP(current_hook) = AP_ACCESS_CONTROL;
|
||||
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
|
||||
status = sapi_stack_apply_with_argument_stop_if_http_error(&conf->access_handlers,
|
||||
|
@ -1340,7 +1349,6 @@ static int php_type_hook(request_rec *r)
|
|||
{
|
||||
php_per_dir_config *conf;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
AP(current_hook) = AP_TYPE_CHECKING;
|
||||
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
|
||||
return sapi_stack_apply_with_argument_stop_if_equals(&conf->type_handlers,
|
||||
|
@ -1353,7 +1361,6 @@ static int php_fixup_hook(request_rec *r)
|
|||
{
|
||||
php_per_dir_config *conf;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
AP(current_hook) = AP_FIXUP;
|
||||
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
|
||||
return sapi_stack_apply_with_argument_stop_if_http_error(&conf->fixup_handlers,
|
||||
|
@ -1366,7 +1373,6 @@ static int php_logger_hook(request_rec *r)
|
|||
{
|
||||
php_per_dir_config *conf;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
AP(current_hook) = AP_LOGGING;
|
||||
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
|
||||
return sapi_stack_apply_with_argument_stop_if_http_error(&conf->logger_handlers,
|
||||
|
@ -1374,16 +1380,15 @@ static int php_logger_hook(request_rec *r)
|
|||
(int (*)(void *element, void *)) php_run_hook,
|
||||
r);
|
||||
}
|
||||
|
||||
|
||||
static int php_post_read_hook(request_rec *r)
|
||||
{
|
||||
php_per_dir_config *conf;
|
||||
php_per_server_config *svr;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
AP(current_hook) = AP_POST_READ;
|
||||
svr = get_module_config(r->server->module_config, &php5_module);
|
||||
if (ap_is_initial_req(r)) {
|
||||
if(ap_is_initial_req(r)) {
|
||||
sapi_stack_apply_with_argument_all(&svr->requires, ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_run_hook, r);
|
||||
}
|
||||
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
|
||||
|
@ -1396,7 +1401,6 @@ static int php_response_handler(request_rec *r)
|
|||
{
|
||||
php_per_dir_config *conf;
|
||||
TSRMLS_FETCH();
|
||||
|
||||
AP(current_hook) = AP_RESPONSE;
|
||||
conf = (php_per_dir_config *) get_module_config(r->per_dir_config, &php5_module);
|
||||
return sapi_stack_apply_with_argument_all(&conf->response_handlers, ZEND_STACK_APPLY_BOTTOMUP, (int (*)(void *element, void *)) php_run_hook, r);
|
||||
|
@ -1409,7 +1413,7 @@ handler_rec php_handlers[] =
|
|||
{"application/x-httpd-php", send_parsed_php},
|
||||
{"application/x-httpd-php-source", send_parsed_php_source},
|
||||
{"text/html", php_xbithack_handler},
|
||||
{"php-script", php_response_handler},
|
||||
{"php-script", php_response_handler},
|
||||
{NULL}
|
||||
};
|
||||
/* }}} */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -34,7 +34,7 @@ int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
|
|||
}
|
||||
/* sending a file handle to another dll is not working
|
||||
so let zend open it. */
|
||||
|
||||
|
||||
if (display_source_mode) {
|
||||
zend_syntax_highlighter_ini syntax_highlighter_ini;
|
||||
|
||||
|
@ -53,7 +53,7 @@ int apache_php_module_main(request_rec *r, int display_source_mode TSRMLS_DC)
|
|||
(void) php_execute_script(&file_handle TSRMLS_CC);
|
||||
}
|
||||
AP(in_request) = 0;
|
||||
|
||||
|
||||
return (OK);
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -64,58 +64,59 @@ int apache_php_module_hook(request_rec *r, php_handler *handler, zval **ret TSRM
|
|||
{
|
||||
zend_file_handle file_handle;
|
||||
zval *req;
|
||||
char *tmp;
|
||||
char *tmp;
|
||||
|
||||
#if PHP_SIGCHILD
|
||||
signal(SIGCHLD, sigchld_handler);
|
||||
#endif
|
||||
if (AP(current_hook) == AP_RESPONSE) {
|
||||
if (php_request_startup_for_hook(TSRMLS_C) == FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
} else {
|
||||
if (php_request_startup_for_hook(TSRMLS_C) == FAILURE) {
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
if(AP(current_hook) == AP_RESPONSE) {
|
||||
if (php_request_startup_for_hook(TSRMLS_C) == FAILURE)
|
||||
return FAILURE;
|
||||
}
|
||||
else {
|
||||
if (php_request_startup_for_hook(TSRMLS_C) == FAILURE)
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
req = php_apache_request_new(r);
|
||||
if (PG(register_globals)) {
|
||||
php_register_variable_ex("request", req, NULL TSRMLS_CC);
|
||||
} else {
|
||||
php_register_variable_ex("request", req, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC);
|
||||
}
|
||||
switch(handler->type) {
|
||||
case AP_HANDLER_TYPE_FILE:
|
||||
php_register_variable("PHP_SELF_HOOK", handler->name, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC);
|
||||
memset(&file_handle, 0, sizeof(file_handle));
|
||||
file_handle.type = ZEND_HANDLE_FILENAME;
|
||||
file_handle.filename = handler->name;
|
||||
(void) php_execute_simple_script(&file_handle, ret TSRMLS_CC);
|
||||
break;
|
||||
case AP_HANDLER_TYPE_METHOD:
|
||||
if ( (tmp = strstr(handler->name, "::")) != NULL && *(tmp+2) != '\0' ) {
|
||||
zval *class;
|
||||
zval *method;
|
||||
*tmp = '\0';
|
||||
ALLOC_ZVAL(class);
|
||||
ZVAL_STRING(class, handler->name, 1);
|
||||
ALLOC_ZVAL(method);
|
||||
ZVAL_STRING(method, tmp +2, 1);
|
||||
*tmp = ':';
|
||||
call_user_function_ex(EG(function_table), &class, method, ret, 0, NULL, 0, NULL TSRMLS_CC);
|
||||
zval_dtor(class);
|
||||
zval_dtor(method);
|
||||
} else {
|
||||
php_error(E_ERROR, "Unable to call %s - not a Class::Method\n", handler->name);
|
||||
/* not a class::method */
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* not a valid type */
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
if(PG(register_globals)) {
|
||||
php_register_variable_ex("request", req, NULL TSRMLS_CC);
|
||||
}
|
||||
else {
|
||||
php_register_variable_ex("request", req, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC);
|
||||
}
|
||||
switch(handler->type) {
|
||||
case AP_HANDLER_TYPE_FILE:
|
||||
php_register_variable("PHP_SELF_HOOK", handler->name, PG(http_globals)[TRACK_VARS_SERVER] TSRMLS_CC);
|
||||
memset(&file_handle, 0, sizeof(file_handle));
|
||||
file_handle.type = ZEND_HANDLE_FILENAME;
|
||||
file_handle.filename = handler->name;
|
||||
(void) php_execute_simple_script(&file_handle, ret TSRMLS_CC);
|
||||
break;
|
||||
case AP_HANDLER_TYPE_METHOD:
|
||||
if( (tmp = strstr(handler->name, "::")) != NULL && *(tmp+2) != '\0' ) {
|
||||
zval *class;
|
||||
zval *method;
|
||||
*tmp = '\0';
|
||||
ALLOC_ZVAL(class);
|
||||
ZVAL_STRING(class, handler->name, 1);
|
||||
ALLOC_ZVAL(method);
|
||||
ZVAL_STRING(method, tmp +2, 1);
|
||||
*tmp = ':';
|
||||
call_user_function_ex(EG(function_table), &class, method, ret, 0, NULL, 0, NULL TSRMLS_CC);
|
||||
zval_dtor(class);
|
||||
zval_dtor(method);
|
||||
}
|
||||
else {
|
||||
php_error(E_ERROR, "Unable to call %s - not a Class::Method\n", handler->name);
|
||||
/* not a class::method */
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* not a valid type */
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
zval_dtor(req);
|
||||
AP(in_request) = 0;
|
||||
|
||||
|
|
|
@ -1634,8 +1634,9 @@ int main(int argc, char *argv[])
|
|||
* in case some server does something different than above */
|
||||
(!CGIG(redirect_status_env) || !getenv(CGIG(redirect_status_env)))
|
||||
) {
|
||||
SG(sapi_headers).http_response_code = 400;
|
||||
PUTS("<b>Security Alert!</b> The PHP CGI cannot be accessed directly.\n\n\
|
||||
zend_try {
|
||||
SG(sapi_headers).http_response_code = 400;
|
||||
PUTS("<b>Security Alert!</b> The PHP CGI cannot be accessed directly.\n\n\
|
||||
<p>This PHP CGI binary was compiled with force-cgi-redirect enabled. This\n\
|
||||
means that a page will only be served up if the REDIRECT_STATUS CGI variable is\n\
|
||||
set, e.g. via an Apache Action directive.</p>\n\
|
||||
|
@ -1644,6 +1645,8 @@ manual page for CGI security</a>.</p>\n\
|
|||
<p>For more information about changing this behaviour or re-enabling this webserver,\n\
|
||||
consult the installation file that came with this distribution, or visit \n\
|
||||
<a href=\"http://php.net/install.windows\">the manual page</a>.</p>\n");
|
||||
} zend_catch {
|
||||
} zend_end_try();
|
||||
#if defined(ZTS) && !defined(PHP_DEBUG)
|
||||
/* XXX we're crashing here in msvc6 debug builds at
|
||||
* php_message_handler_for_zend:839 because
|
||||
|
@ -1806,9 +1809,11 @@ consult the installation file that came with this distribution, or visit \n\
|
|||
case '?':
|
||||
fcgi_shutdown();
|
||||
no_headers = 1;
|
||||
php_output_startup();
|
||||
php_output_activate(TSRMLS_C);
|
||||
SG(headers_sent) = 1;
|
||||
php_cgi_usage(argv[0]);
|
||||
php_output_end_all(TSRMLS_C);
|
||||
php_end_ob_buffers(1 TSRMLS_CC);
|
||||
exit_status = 0;
|
||||
goto out;
|
||||
}
|
||||
|
@ -1882,13 +1887,15 @@ consult the installation file that came with this distribution, or visit \n\
|
|||
if (script_file) {
|
||||
efree(script_file);
|
||||
}
|
||||
php_output_startup();
|
||||
php_output_activate(TSRMLS_C);
|
||||
SG(headers_sent) = 1;
|
||||
php_printf("[PHP Modules]\n");
|
||||
print_modules(TSRMLS_C);
|
||||
php_printf("\n[Zend Modules]\n");
|
||||
print_extensions(TSRMLS_C);
|
||||
php_printf("\n");
|
||||
php_output_end_all(TSRMLS_C);
|
||||
php_end_ob_buffers(1 TSRMLS_CC);
|
||||
exit_status = 0;
|
||||
goto out;
|
||||
|
||||
|
@ -2035,13 +2042,16 @@ consult the installation file that came with this distribution, or visit \n\
|
|||
*/
|
||||
if (cgi || fastcgi || SG(request_info).path_translated) {
|
||||
if (php_fopen_primary_script(&file_handle TSRMLS_CC) == FAILURE) {
|
||||
if (errno == EACCES) {
|
||||
SG(sapi_headers).http_response_code = 403;
|
||||
PUTS("Access denied.\n");
|
||||
} else {
|
||||
SG(sapi_headers).http_response_code = 404;
|
||||
PUTS("No input file specified.\n");
|
||||
}
|
||||
zend_try {
|
||||
if (errno == EACCES) {
|
||||
SG(sapi_headers).http_response_code = 403;
|
||||
PUTS("Access denied.\n");
|
||||
} else {
|
||||
SG(sapi_headers).http_response_code = 404;
|
||||
PUTS("No input file specified.\n");
|
||||
}
|
||||
} zend_catch {
|
||||
} zend_end_try();
|
||||
/* we want to serve more requests if this is fastcgi
|
||||
* so cleanup and continue, request shutdown is
|
||||
* handled later */
|
||||
|
@ -2104,7 +2114,7 @@ consult the installation file that came with this distribution, or visit \n\
|
|||
if (open_file_for_scanning(&file_handle TSRMLS_CC) == SUCCESS) {
|
||||
zend_strip(TSRMLS_C);
|
||||
zend_file_handle_dtor(&file_handle TSRMLS_CC);
|
||||
php_output_teardown();
|
||||
php_end_ob_buffers(1 TSRMLS_CC);
|
||||
}
|
||||
return SUCCESS;
|
||||
break;
|
||||
|
@ -2119,7 +2129,7 @@ consult the installation file that came with this distribution, or visit \n\
|
|||
goto fastcgi_request_done;
|
||||
}
|
||||
zend_file_handle_dtor(&file_handle TSRMLS_CC);
|
||||
php_output_teardown();
|
||||
php_end_ob_buffers(1 TSRMLS_CC);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
@ -2130,7 +2140,6 @@ consult the installation file that came with this distribution, or visit \n\
|
|||
open_file_for_scanning(&file_handle TSRMLS_CC);
|
||||
zend_indent();
|
||||
zend_file_handle_dtor(&file_handle TSRMLS_CC);
|
||||
php_output_teardown();
|
||||
return SUCCESS;
|
||||
break;
|
||||
#endif
|
||||
|
|
|
@ -797,7 +797,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
request_started = 1;
|
||||
php_cli_usage(argv[0]);
|
||||
php_output_end_all(TSRMLS_C);
|
||||
php_end_ob_buffers(1 TSRMLS_CC);
|
||||
exit_status=0;
|
||||
goto out;
|
||||
|
||||
|
@ -807,7 +807,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
request_started = 1;
|
||||
php_print_info(0xFFFFFFFF TSRMLS_CC);
|
||||
php_output_end_all(TSRMLS_C);
|
||||
php_end_ob_buffers(1 TSRMLS_CC);
|
||||
exit_status=0;
|
||||
goto out;
|
||||
|
||||
|
@ -821,7 +821,7 @@ int main(int argc, char *argv[])
|
|||
php_printf("\n[Zend Modules]\n");
|
||||
print_extensions(TSRMLS_C);
|
||||
php_printf("\n");
|
||||
php_output_end_all(TSRMLS_C);
|
||||
php_end_ob_buffers(1 TSRMLS_CC);
|
||||
exit_status=0;
|
||||
goto out;
|
||||
|
||||
|
@ -844,7 +844,7 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
get_zend_version()
|
||||
);
|
||||
php_output_end_all(TSRMLS_C);
|
||||
php_end_ob_buffers(1 TSRMLS_CC);
|
||||
exit_status=0;
|
||||
goto out;
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ class test { /* {{{ */
|
|||
|
||||
file_put_contents($filename, $code);
|
||||
|
||||
var_dump(`"$php" -n -w "$filename"`);
|
||||
var_dump(`"$php" -n -w "wrong"`);
|
||||
var_dump(`$php -n -w "$filename"`);
|
||||
var_dump(`$php -n -w "wrong"`);
|
||||
var_dump(`echo "<?php /* comment */ class test {\n // comment \n function foo() {} } ?>" | $php -n -w`);
|
||||
|
||||
@unlink($filename);
|
||||
|
@ -45,8 +45,8 @@ string(81) "
|
|||
<?php
|
||||
class test { public $var = "test"; private $pri; function foo() { } } ?>
|
||||
"
|
||||
string(33) "Could not open input file: wrong
|
||||
"
|
||||
Could not open input file: wrong
|
||||
NULL
|
||||
string(43) "<?php class test { function foo() {} } ?>
|
||||
"
|
||||
Done
|
||||
|
|
|
@ -26,8 +26,8 @@ var_dump(test::$pri);
|
|||
|
||||
file_put_contents($filename, $code);
|
||||
|
||||
var_dump(`"$php" -n -f "$filename"`);
|
||||
var_dump(`"$php" -n -f "wrong"`);
|
||||
var_dump(`$php -n -f "$filename"`);
|
||||
var_dump(`$php -n -f "wrong"`);
|
||||
|
||||
@unlink($filename);
|
||||
|
||||
|
@ -38,6 +38,6 @@ string(%d) "
|
|||
|
||||
Fatal error: Cannot access private property test::$pri in %s on line %d
|
||||
"
|
||||
string(33) "Could not open input file: wrong
|
||||
"
|
||||
Could not open input file: wrong
|
||||
NULL
|
||||
Done
|
||||
|
|
|
@ -13,8 +13,8 @@ var_dump(`$php -n -r "echo hello;" -a`);
|
|||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(57) "Either execute direct code, process stdin or use a file.
|
||||
"
|
||||
string(57) "Either execute direct code, process stdin or use a file.
|
||||
"
|
||||
Either execute direct code, process stdin or use a file.
|
||||
NULL
|
||||
Either execute direct code, process stdin or use a file.
|
||||
NULL
|
||||
Done
|
||||
|
|
|
@ -49,8 +49,8 @@ echo "Done\n";
|
|||
--EXPECTF--
|
||||
string(%d) "No syntax errors detected in %s011.test.php
|
||||
"
|
||||
string(40) "Could not open input file: some.unknown
|
||||
"
|
||||
Could not open input file: some.unknown
|
||||
NULL
|
||||
string(%d) "
|
||||
Parse error: %s expecting %s{%s in %s on line %d
|
||||
Errors parsing %s011.test.php
|
||||
|
|
|
@ -19,20 +19,20 @@ var_dump(`"$php" -n -r '' -r ''`);
|
|||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(32) "You can use -R or -F only once.
|
||||
"
|
||||
string(32) "You can use -R or -F only once.
|
||||
"
|
||||
string(32) "You can use -R or -F only once.
|
||||
"
|
||||
string(32) "You can use -R or -F only once.
|
||||
"
|
||||
string(26) "You can use -f only once.
|
||||
"
|
||||
string(26) "You can use -B only once.
|
||||
"
|
||||
string(26) "You can use -E only once.
|
||||
"
|
||||
string(26) "You can use -r only once.
|
||||
"
|
||||
You can use -R or -F only once.
|
||||
NULL
|
||||
You can use -R or -F only once.
|
||||
NULL
|
||||
You can use -R or -F only once.
|
||||
NULL
|
||||
You can use -R or -F only once.
|
||||
NULL
|
||||
You can use -f only once.
|
||||
NULL
|
||||
You can use -B only once.
|
||||
NULL
|
||||
You can use -E only once.
|
||||
NULL
|
||||
You can use -r only once.
|
||||
NULL
|
||||
Done
|
||||
|
|
|
@ -39,6 +39,6 @@ string(1478) "<code><span style="color: #000000">
|
|||
<br /><span style="color: #0000BB"><?php<br />$test </span><span style="color: #007700">= </span><span style="color: #DD0000">"var"</span><span style="color: #007700">; </span><span style="color: #FF8000">//var<br />/* test class */<br /></span><span style="color: #007700">class </span><span style="color: #0000BB">test </span><span style="color: #007700">{<br /> private </span><span style="color: #0000BB">$var </span><span style="color: #007700">= array();<br /><br /> public static function </span><span style="color: #0000BB">foo</span><span style="color: #007700">(</span><span style="color: #0000BB">Test $arg</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"hello"</span><span style="color: #007700">;<br /> </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">);<br /> }<br />}<br /><br /></span><span style="color: #0000BB">$o </span><span style="color: #007700">= new </span><span style="color: #0000BB">test</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?><br /></span>
|
||||
</span>
|
||||
</code>"
|
||||
string(35) "Could not open input file: unknown
|
||||
"
|
||||
Could not open input file: unknown
|
||||
NULL
|
||||
Done
|
||||
|
|
|
@ -823,7 +823,7 @@ ZEND_END_ARG_INFO()
|
|||
|
||||
/* {{{ milter_functions[]
|
||||
*/
|
||||
static const zend_function_entry milter_functions[] = {
|
||||
const static zend_function_entry milter_functions[] = {
|
||||
PHP_FE(smfi_setflags, arginfo_smfi_setflags)
|
||||
PHP_FE(smfi_settimeout, arginfo_smfi_settimeout)
|
||||
PHP_FE(smfi_getsymval, arginfo_smfi_getsymval)
|
||||
|
@ -1040,10 +1040,11 @@ int main(int argc, char *argv[])
|
|||
while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) {
|
||||
switch (c) {
|
||||
case '?':
|
||||
php_output_tearup();
|
||||
php_output_startup();
|
||||
php_output_activate(TSRMLS_C);
|
||||
SG(headers_sent) = 1;
|
||||
php_milter_usage(argv[0]);
|
||||
php_output_teardown();
|
||||
php_end_ob_buffers(1 TSRMLS_CC);
|
||||
exit(1);
|
||||
break;
|
||||
}
|
||||
|
@ -1087,10 +1088,11 @@ int main(int argc, char *argv[])
|
|||
|
||||
case 'h': /* help & quit */
|
||||
case '?':
|
||||
php_output_tearup();
|
||||
php_output_startup();
|
||||
php_output_activate(TSRMLS_C);
|
||||
SG(headers_sent) = 1;
|
||||
php_milter_usage(argv[0]);
|
||||
php_output_teardown();
|
||||
php_end_ob_buffers(1 TSRMLS_CC);
|
||||
exit(1);
|
||||
break;
|
||||
|
||||
|
@ -1110,7 +1112,7 @@ int main(int argc, char *argv[])
|
|||
SG(headers_sent) = 1;
|
||||
SG(request_info).no_headers = 1;
|
||||
php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2010 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version());
|
||||
php_output_teardown();
|
||||
php_end_ob_buffers(1 TSRMLS_CC);
|
||||
exit(1);
|
||||
break;
|
||||
|
||||
|
|
|
@ -347,7 +347,7 @@ PHP_FUNCTION(nsapi_virtual)
|
|||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to include uri '%s' - Sub-requests do not work with zlib.output_compression", uri);
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
php_output_end_all(TSRMLS_C);
|
||||
php_end_ob_buffers(1 TSRMLS_CC);
|
||||
php_header(TSRMLS_C);
|
||||
|
||||
/* do the sub-request */
|
||||
|
|
|
@ -18,10 +18,10 @@ echo 'Done';
|
|||
?>
|
||||
--EXPECTF--
|
||||
[callback:1]Attempt to flush unerasable buffer - should fail...
|
||||
Notice: ob_flush(): failed to flush buffer of callback (0) in %s on line %d
|
||||
Notice: ob_flush(): failed to flush buffer callback. in %s on line %d
|
||||
bool(false)
|
||||
string(%d) "Attempt to flush unerasable buffer - should fail...
|
||||
Notice: ob_flush(): failed to flush buffer of callback (0) in %s on line %d
|
||||
Notice: ob_flush(): failed to flush buffer callback. in %s on line %d
|
||||
bool(false)
|
||||
"
|
||||
Done
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--
|
||||
output buffering - fatalism
|
||||
--XFAIL--
|
||||
This test will fail until the fix in revision r214155 is backported from php 6
|
||||
--FILE--
|
||||
<?php
|
||||
function obh($s)
|
||||
|
|
|
@ -37,69 +37,67 @@ Array
|
|||
)
|
||||
Array
|
||||
(
|
||||
[name] => d
|
||||
[level] => 5
|
||||
[type] => 1
|
||||
[flags] => 4209
|
||||
[level] => 4
|
||||
[chunk_size] => %d
|
||||
[buffer_size] => 16384
|
||||
[buffer_used] => 96
|
||||
[status] => 1
|
||||
[name] => d
|
||||
[del] => 1
|
||||
)
|
||||
Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[chunk_size] => 0
|
||||
[size] => 40960
|
||||
[block_size] => 10240
|
||||
[type] => 1
|
||||
[status] => 0
|
||||
[name] => default output handler
|
||||
[type] => 0
|
||||
[flags] => 112
|
||||
[level] => 0
|
||||
[chunk_size] => %d
|
||||
[buffer_size] => 16384
|
||||
[buffer_used] => 0
|
||||
[del] => 1
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[name] => a
|
||||
[chunk_size] => 0
|
||||
[size] => 40960
|
||||
[block_size] => 10240
|
||||
[type] => 1
|
||||
[flags] => 113
|
||||
[level] => 1
|
||||
[chunk_size] => %d
|
||||
[buffer_size] => 16384
|
||||
[buffer_used] => 0
|
||||
[status] => 0
|
||||
[name] => a
|
||||
[del] => 1
|
||||
)
|
||||
|
||||
[2] => Array
|
||||
(
|
||||
[name] => b
|
||||
[chunk_size] => 0
|
||||
[size] => 40960
|
||||
[block_size] => 10240
|
||||
[type] => 1
|
||||
[flags] => 113
|
||||
[level] => 2
|
||||
[chunk_size] => %d
|
||||
[buffer_size] => 16384
|
||||
[buffer_used] => 0
|
||||
[status] => 0
|
||||
[name] => b
|
||||
[del] => 1
|
||||
)
|
||||
|
||||
[3] => Array
|
||||
(
|
||||
[name] => c
|
||||
[chunk_size] => 0
|
||||
[size] => 40960
|
||||
[block_size] => 10240
|
||||
[type] => 1
|
||||
[flags] => 113
|
||||
[level] => 3
|
||||
[chunk_size] => %d
|
||||
[buffer_size] => 16384
|
||||
[buffer_used] => 4
|
||||
[status] => 0
|
||||
[name] => c
|
||||
[del] => 1
|
||||
)
|
||||
|
||||
[4] => Array
|
||||
(
|
||||
[name] => d
|
||||
[chunk_size] => 0
|
||||
[size] => 40960
|
||||
[block_size] => 10240
|
||||
[type] => 1
|
||||
[flags] => 4209
|
||||
[level] => 4
|
||||
[chunk_size] => %d
|
||||
[buffer_size] => 16384
|
||||
[buffer_used] => %d
|
||||
[status] => 1
|
||||
[name] => d
|
||||
[del] => 1
|
||||
)
|
||||
|
||||
)
|
||||
)
|
|
@ -24,11 +24,11 @@ yes!
|
|||
yes!
|
||||
Array
|
||||
(
|
||||
[0] => 1: yes
|
||||
[1] => 4: !
|
||||
[0] => 3: yes
|
||||
[1] => 2: !
|
||||
|
||||
[2] => 2:
|
||||
[3] => 0: yes!
|
||||
[2] => 2: no
|
||||
[3] => 2: yes!
|
||||
|
||||
[4] => 10:
|
||||
)
|
||||
[4] => 4: no
|
||||
)
|
|
@ -29,8 +29,8 @@ echo "Done";
|
|||
|
||||
-- Testing ob_clean() function with Zero arguments --
|
||||
|
||||
Notice: ob_clean(): failed to delete buffer. No buffer to delete in %s on line 12
|
||||
Notice: ob_clean(): failed to delete buffer. No buffer to delete. in %s on line 12
|
||||
bool(false)
|
||||
string(61) "bool(true)
|
||||
Ensure the buffer is still active after the clean."
|
||||
Done
|
||||
Done
|
|
@ -21,11 +21,11 @@ var_dump(ob_end_clean());
|
|||
?>
|
||||
--EXPECTF--
|
||||
|
||||
Notice: ob_end_clean(): failed to delete buffer. No buffer to delete in %s on line 7
|
||||
Notice: ob_end_clean(): failed to delete buffer. No buffer to delete. in %s on line 7
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(true)
|
||||
|
||||
Notice: ob_end_clean(): failed to delete buffer. No buffer to delete in %s on line 16
|
||||
Notice: ob_end_clean(): failed to delete buffer. No buffer to delete. in %s on line 16
|
||||
bool(false)
|
||||
|
||||
|
|
|
@ -30,12 +30,12 @@ echo "Done";
|
|||
|
||||
-- Testing ob_end_flush() function with Zero arguments --
|
||||
|
||||
Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush in %s on line 12
|
||||
Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in %s on line 12
|
||||
bool(false)
|
||||
bool(true)
|
||||
Hello
|
||||
bool(true)
|
||||
|
||||
Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush in %s on line 21
|
||||
Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in %s on line 21
|
||||
bool(false)
|
||||
Done
|
||||
Done
|
|
@ -30,10 +30,10 @@ echo "Done";
|
|||
|
||||
-- Testing ob_flush() function with Zero arguments --
|
||||
|
||||
Notice: ob_flush(): failed to flush buffer. No buffer to flush in %s on line 12
|
||||
Notice: ob_flush(): failed to flush buffer. No buffer to flush. in %s on line 12
|
||||
bool(false)
|
||||
This should get flushed.
|
||||
bool(true)
|
||||
Ensure the buffer is still active after the flush.
|
||||
bool(true)
|
||||
Done
|
||||
Done
|
|
@ -14,6 +14,5 @@ echo "Hello World";
|
|||
var_dump(ob_get_clean());
|
||||
?>
|
||||
--EXPECTF--
|
||||
Notice: ob_get_clean(): failed to delete buffer. No buffer to delete in %s on line 7
|
||||
bool(false)
|
||||
string(11) "Hello World"
|
|
@ -42,6 +42,6 @@ int(2)
|
|||
int(1)
|
||||
int(0)
|
||||
|
||||
Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush in %s on line 26
|
||||
Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in %s on line 26
|
||||
int(0)
|
||||
Done
|
||||
Done
|
|
@ -15,19 +15,20 @@ var_dump($status);
|
|||
array(1) {
|
||||
[0]=>
|
||||
array(7) {
|
||||
["name"]=>
|
||||
string(22) "default output handler"
|
||||
["type"]=>
|
||||
int(0)
|
||||
["flags"]=>
|
||||
int(112)
|
||||
["level"]=>
|
||||
int(0)
|
||||
["chunk_size"]=>
|
||||
int(0)
|
||||
["buffer_size"]=>
|
||||
int(16384)
|
||||
["buffer_used"]=>
|
||||
["size"]=>
|
||||
int(40960)
|
||||
["block_size"]=>
|
||||
int(10240)
|
||||
["type"]=>
|
||||
int(1)
|
||||
["status"]=>
|
||||
int(0)
|
||||
["name"]=>
|
||||
string(22) "default output handler"
|
||||
["del"]=>
|
||||
bool(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
--TEST--
|
||||
ob_start() chunk_size: confirm buffer is flushed after any output call that causes its length to equal or exceed chunk_size.
|
||||
ob_start() chunk_size: confirm buffer is flushed after any output call that causes its length to equal or exceed chunk_size.
|
||||
--FILE--
|
||||
<?php
|
||||
/*
|
||||
* proto bool ob_start([ string|array user_function [, int chunk_size [, bool erase]]])
|
||||
* Function is implemented in main/output.c
|
||||
*/
|
||||
// In HEAD, $chunk_size value of 1 should not have any special behaviour (http://marc.info/?l=php-internals&m=123476465621346&w=2).
|
||||
|
||||
function callback($string) {
|
||||
global $callback_invocations;
|
||||
$callback_invocations++;
|
||||
|
@ -40,15 +40,7 @@ f[call:1; len:8]12345678
|
|||
f[call:1; len:8]12345678
|
||||
|
||||
----( chunk_size: 1, output append size: 1 )----
|
||||
f[call:1; len:1]1
|
||||
f[call:2; len:1]2
|
||||
f[call:3; len:1]3
|
||||
f[call:4; len:1]4
|
||||
f[call:5; len:1]5
|
||||
f[call:6; len:1]6
|
||||
f[call:7; len:1]7
|
||||
f[call:8; len:1]8
|
||||
f[call:9; len:0]
|
||||
f[call:1; len:8]12345678
|
||||
|
||||
----( chunk_size: 2, output append size: 1 )----
|
||||
f[call:1; len:2]12
|
||||
|
@ -93,9 +85,7 @@ f[call:1; len:8]12345678
|
|||
f[call:1; len:8]12345678
|
||||
|
||||
----( chunk_size: 1, output append size: 4 )----
|
||||
f[call:1; len:4]1234
|
||||
f[call:2; len:4]5678
|
||||
f[call:3; len:0]
|
||||
f[call:1; len:8]12345678
|
||||
|
||||
----( chunk_size: 2, output append size: 4 )----
|
||||
f[call:1; len:4]1234
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
--TEST--
|
||||
ob_start(): ensure multiple buffer initialization with a single call using arrays is not supported on PHP6 (http://bugs.php.net/42641)
|
||||
ob_start(): multiple buffer initialization with a single call, using arrays.
|
||||
--FILE--
|
||||
<?php
|
||||
/*
|
||||
|
@ -72,37 +72,46 @@ var_dump(ob_start(array('f', 'C::g', array(array($c, "g"), array($c, "h")))));
|
|||
checkAndClean();
|
||||
?>
|
||||
--EXPECTF--
|
||||
|
||||
---> Test arrays:
|
||||
|
||||
Notice: ob_start(): failed to create buffer in %s on line 44
|
||||
bool(false)
|
||||
f[call:1; len:34] - bool(true)
|
||||
Array
|
||||
(
|
||||
[0] => f
|
||||
)
|
||||
|
||||
Notice: ob_start(): failed to create buffer in %s on line 47
|
||||
bool(false)
|
||||
f[call:3; len:68] - f[call:2; len:47] - bool(true)
|
||||
Array
|
||||
(
|
||||
[0] => f
|
||||
[1] => f
|
||||
)
|
||||
|
||||
Notice: ob_start(): failed to create buffer in %s on line 50
|
||||
bool(false)
|
||||
|
||||
f[call:5; len:150] - C::g[call:2; len:125] - f[call:4; len:103] - C::g[call:1; len:79] - bool(true)
|
||||
Array
|
||||
(
|
||||
[0] => f
|
||||
[1] => C::g
|
||||
[2] => f
|
||||
[3] => C::g
|
||||
)
|
||||
|
||||
Notice: ob_start(): failed to create buffer in %s on line 53
|
||||
bool(false)
|
||||
|
||||
|
||||
|
||||
f[call:6; len:35] - bool(false)
|
||||
Array
|
||||
(
|
||||
[0] => f
|
||||
)
|
||||
|
||||
Notice: ob_start(): failed to create buffer in %s on line 56
|
||||
bool(false)
|
||||
f[call:7; len:35] - bool(false)
|
||||
Array
|
||||
(
|
||||
[0] => f
|
||||
)
|
||||
|
||||
C::h[call:1; len:37; id:originalID] - bool(true)
|
||||
Array
|
||||
(
|
||||
|
@ -115,9 +124,11 @@ Array
|
|||
[0] => C::h
|
||||
)
|
||||
|
||||
|
||||
Notice: ob_start(): failed to create buffer in %s on line 68
|
||||
bool(false)
|
||||
f[call:8; len:175] - C::g[call:4; len:150] - C::g[call:3; len:125] - C::h[call:3; len:82; id:changedIDagain] - bool(true)
|
||||
Array
|
||||
(
|
||||
)
|
||||
[0] => f
|
||||
[1] => C::g
|
||||
[2] => C::g
|
||||
[3] => C::h
|
||||
)
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue