summaryrefslogtreecommitdiff
path: root/ext/zlib/zlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/zlib/zlib.c')
-rw-r--r--ext/zlib/zlib.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 136bd5a268..fe2b4be374 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -890,6 +890,34 @@ PHP_FUNCTION(gzencode)
}
/* }}} */
+/* {{{ php_ob_gzhandler_check
+ */
+int php_ob_gzhandler_check(TSRMLS_DC)
+{
+ /* check for wrong usages */
+ if (OG(ob_nesting_level>0)) {
+ if (php_ob_handler_used("ob_gzhandler" TSRMLS_CC)) {
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler 'ob_gzhandler' cannot be used twice");
+ return FAILURE;
+ }
+ if (php_ob_handler_used("mb_output_handler" TSRMLS_CC)) {
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler 'ob_gzhandler' cannot be used after 'mb_output_handler'");
+ return FAILURE;
+ }
+ if (php_ob_handler_used("URL-Rewriter" TSRMLS_CC)) {
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler 'ob_gzhandler' cannot be used after 'URL-Rewriter'");
+ return FAILURE;
+ }
+ if (php_ob_init_conflict("ob_gzhandler", "zlib output compression" TSRMLS_CC)) {
+ return FAILURE;
+ }
+ }
+
+ return SUCCESS;
+}
+
+/* }}} */
+
/* {{{ proto string ob_gzhandler(string str, int mode)
Encode str based on accept-encoding setting - designed to be called from ob_start() */
PHP_FUNCTION(ob_gzhandler)
@@ -904,24 +932,6 @@ PHP_FUNCTION(ob_gzhandler)
ZEND_WRONG_PARAM_COUNT();
}
- /* check for wrong usages */
- if (OG(ob_nesting_level>1)) {
- if (php_ob_handler_used("ob_gzhandler" TSRMLS_CC)) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler 'ob_gzhandler' cannot be used twice");
- RETURN_FALSE;
- }
- if (php_ob_handler_used("mb_output_handler" TSRMLS_CC)) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler 'ob_gzhandler' cannot be used after 'mb_output_handler'");
- RETURN_FALSE;
- }
- if (php_ob_handler_used("URL-Rewriter" TSRMLS_CC)) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler 'ob_gzhandler' cannot be used after 'URL-Rewriter'");
- RETURN_FALSE;
- }
- if (php_ob_init_conflict("ob_gzhandler", "zlib output compression" TSRMLS_CC))
- RETURN_FALSE;
- }
-
if (ZLIBG(ob_gzhandler_status)==-1
|| zend_hash_find(&EG(symbol_table), "HTTP_SERVER_VARS", sizeof("HTTP_SERVER_VARS"), (void **) &data)==FAILURE
|| Z_TYPE_PP(data)!=IS_ARRAY