summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/standard/basic_functions.c2
-rw-r--r--main/output.c50
-rw-r--r--main/php_output.h2
3 files changed, 54 insertions, 0 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 5512154e84..28b7203200 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -750,6 +750,8 @@ function_entry basic_functions[] = {
PHP_FE(ob_clean, NULL)
PHP_FE(ob_end_flush, NULL)
PHP_FE(ob_end_clean, NULL)
+ PHP_FE(ob_get_flush, NULL)
+ PHP_FE(ob_get_clean, NULL)
PHP_FE(ob_get_length, NULL)
PHP_FE(ob_get_level, NULL)
PHP_FE(ob_get_status, NULL)
diff --git a/main/output.c b/main/output.c
index 35e8988a33..8b1c8bc680 100644
--- a/main/output.c
+++ b/main/output.c
@@ -821,6 +821,56 @@ PHP_FUNCTION(ob_end_clean)
}
/* }}} */
+/* {{{ proto bool ob_get_flush(void)
+ Get current buffer contents, flush (send) the output buffer, and delete current output buffer */
+PHP_FUNCTION(ob_get_flush)
+{
+ if (ZEND_NUM_ARGS() != 0)
+ WRONG_PARAM_COUNT;
+
+ /* get contents */
+ if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) {
+ RETURN_FALSE;
+ }
+ /* error checks */
+ if (!OG(ob_nesting_level)) {
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush.");
+ RETURN_FALSE;
+ }
+ if (OG(ob_nesting_level) && !OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", OG(active_ob_buffer).handler_name);
+ RETURN_FALSE;
+ }
+ /* flush */
+ php_end_ob_buffer(1, 0 TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ proto bool ob_get_clean(void)
+ Get current buffer contents and delete current output buffer */
+PHP_FUNCTION(ob_get_clean)
+{
+ if (ZEND_NUM_ARGS() != 0)
+ WRONG_PARAM_COUNT;
+
+ /* get contents */
+ if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) {
+ RETURN_FALSE;
+ }
+ /* error checks */
+ if (!OG(ob_nesting_level)) {
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete.");
+ RETURN_FALSE;
+ }
+ if (OG(ob_nesting_level) && !OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", OG(active_ob_buffer).handler_name);
+ RETURN_FALSE;
+ }
+ /* delete buffer */
+ php_end_ob_buffer(0, 0 TSRMLS_CC);
+}
+/* }}} */
+
/* {{{ proto string ob_get_contents(void)
Return the contents of the output buffer */
PHP_FUNCTION(ob_get_contents)
diff --git a/main/php_output.h b/main/php_output.h
index 0c485e834c..99810802ca 100644
--- a/main/php_output.h
+++ b/main/php_output.h
@@ -47,6 +47,8 @@ PHP_FUNCTION(ob_flush);
PHP_FUNCTION(ob_clean);
PHP_FUNCTION(ob_end_flush);
PHP_FUNCTION(ob_end_clean);
+PHP_FUNCTION(ob_get_flush);
+PHP_FUNCTION(ob_get_clean);
PHP_FUNCTION(ob_get_contents);
PHP_FUNCTION(ob_get_length);
PHP_FUNCTION(ob_get_level);