From: pdontthink Date: Wed, 24 Sep 2008 03:24:08 +0000 (+0000) Subject: Add native output buffering capability. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=775a1f52b3e6224cba9fe8f32c9ff0527c6076e7;p=squirrelmail.git Add native output buffering capability. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13284 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/ChangeLog b/ChangeLog index dae32fc8..b8629051 100644 --- a/ChangeLog +++ b/ChangeLog @@ -262,6 +262,7 @@ Version 1.5.2 - SVN - Allow a different server address for the POP server to be configured when using POP before SMTP. - Seed random number generator in one place during script init. + - Add native output buffering. Version 1.5.1 (branched on 2006-02-12) -------------------------------------- diff --git a/config/conf.pl b/config/conf.pl index 84bd2ab4..771289b5 100755 --- a/config/conf.pl +++ b/config/conf.pl @@ -427,6 +427,7 @@ $aggressive_decoding = 'false' if ( !$aggressive_decoding ); # $advanced_tree = 'false' if ( !$advanced_tree ); $use_php_recode = 'false' if ( !$use_php_recode ); $use_php_iconv = 'false' if ( !$use_php_iconv ); +$buffer_output = 'false' if ( !$buffer_output ); # since 1.5.1 $use_icons = 'false' if ( !$use_icons ); @@ -855,11 +856,12 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) { print $WHT. "PHP tweaks\n" . $NRM; print "4. Use php recode functions : $WHT$use_php_recode$NRM\n"; print "5. Use php iconv functions : $WHT$use_php_iconv$NRM\n"; + print "6. Buffer all output : $WHT$buffer_output$NRM\n"; print "\n"; print $WHT. "Configuration tweaks\n" . $NRM; - print "6. Allow remote configtest : $WHT$allow_remote_configtest$NRM\n"; - print "7. Debug mode : $WHT$sm_debug_mode$NRM\n"; - print "8. Secured configuration mode : $WHT$secured_config$NRM\n"; + print "7. Allow remote configtest : $WHT$allow_remote_configtest$NRM\n"; + print "8. Debug mode : $WHT$sm_debug_mode$NRM\n"; + print "9. Secured configuration mode : $WHT$secured_config$NRM\n"; print "\n"; print "R Return to Main Menu\n"; } @@ -990,7 +992,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) { elsif ( $command == 17 ) { $only_secure_cookies = command319(); } } elsif ( $menu == 5 ) { if ( $command == 1 ) { $use_icons = commandB3(); } -# elsif ( $command == 3 ) { $icon_theme_def = commandB7(); } +# elsif ( $command == 3 ) { $icon_theme_def = command53(); } elsif ( $command == 2 ) { $default_fontsize = command_default_fontsize(); } elsif ( $command == 3 ) { $templateset_default = command_templates(); } elsif ( $command == 4 ) { command_userThemes(); } @@ -1034,9 +1036,10 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) { elsif ( $command == 2 ) { $ask_user_info = command_ask_user_info(); } elsif ( $command == 4 ) { $use_php_recode = commandB4(); } elsif ( $command == 5 ) { $use_php_iconv = commandB5(); } - elsif ( $command == 6 ) { $allow_remote_configtest = commandB6(); } - elsif ( $command == 7 ) { $sm_debug_mode = commandB8(); } - elsif ( $command == 8 ) { $secured_config = commandB9(); } + elsif ( $command == 6 ) { $buffer_output = commandB6(); } + elsif ( $command == 7 ) { $allow_remote_configtest = commandB7(); } + elsif ( $command == 8 ) { $sm_debug_mode = commandB8(); } + elsif ( $command == 9 ) { $secured_config = commandB9(); } } } } @@ -4440,8 +4443,37 @@ sub commandB5 { return $use_php_iconv; } -# configtest block +# buffer output sub commandB6 { + print "In some cases, buffering all output (holding it on the server until\n"; + print "the full page is ready to send to the browser) allows more complex\n"; + print "functionality, especially for plugins that want to add headers on hooks\n"; + print "that are beyond the point of output having been sent to the browser\n"; + print "otherwise. Most plugins that need this functionality will enable it\n"; + print "automatically on their own, but you can turn it on manually here. You'd\n"; + print "usually want to do this if you want to specify a custom output handler\n"; + print "for parsing the output - you can do that by specifying a value for\n"; + print "\$buffered_output_handler in config_local.php. Don't forget to define\n"; + print "a function of the same name as what \$buffered_output_handler is set to.\n"; + print "\n"; + + if ( lc($buffer_output) eq 'true' ) { + $default_value = "y"; + } else { + $default_value = "n"; + } + print "Buffer all output? (y/n) [$WHT$default_value$NRM]: $WHT"; + $buffer_output = ; + if ( ( $buffer_output =~ /^y\n/i ) || ( ( $buffer_output =~ /^\n/ ) && ( $default_value eq "y" ) ) ) { + $buffer_output = 'true'; + } else { + $buffer_output = 'false'; + } + return $buffer_output; +} + +# configtest block +sub commandB7 { print "Enable this option if you want to check SquirrelMail configuration\n"; print "remotely with configtest.php script.\n"; print "\n"; @@ -4462,7 +4494,7 @@ sub commandB6 { } # Default Icon theme -sub commandB7 { +sub command53 { print "You may change the path to the default icon theme to be used, if icons\n"; print "have been enabled. This theme will be used when an icon cannot be\n"; print "found in the current theme, or when no icon theme is specified. If\n"; @@ -4998,6 +5030,9 @@ sub save_data { print CF "\$use_php_iconv = $use_php_iconv;\n"; print CF "\n"; # boolean + print CF "\$buffer_output = $buffer_output;\n"; + print CF "\n"; + # boolean print CF "\$allow_remote_configtest = $allow_remote_configtest;\n"; print CF "\$secured_config = $secured_config;\n"; # (binary) integer or constant - convert integer diff --git a/config/config_default.php b/config/config_default.php index 1586533a..646e2aa4 100644 --- a/config/config_default.php +++ b/config/config_default.php @@ -1148,6 +1148,24 @@ $use_php_recode = false; */ $use_php_iconv = false; +/** + * Output Buffering + * + * In some cases, buffering all output allows more complex functionality, + * especially for plugins that want to add headers on hooks that are beyond + * the point of output having been sent to the browser otherwise (although + * most plugins that need this feature will turn it on automatically by + * themselves). + * + * It is also possible to define a custom output handler as needed by special + * environments. If $buffered_output_handler is non-empty, a function named + * the same as the value of $buffered_output_handler should be defined in + * config_local.php. + * + */ +$buffer_output = false; +$buffered_output_handler = ''; + /** * Controls remote configuration checks * @global boolean $allow_remote_configtest diff --git a/include/init.php b/include/init.php index 80962c35..b5176403 100644 --- a/include/init.php +++ b/include/init.php @@ -19,7 +19,6 @@ FIXME: disabling this for now, because we now have $sm_debug_mode, but the probl //error_reporting(E_ALL); - /** * Make sure we have a page name * @@ -447,6 +446,19 @@ if (! sqgetGlobalVar('squirrelmail_language',$squirrelmail_language,SQ_COOKIE)) } +/** + * In some cases, buffering all output allows more complex functionality, + * especially for plugins that want to add headers on hooks that are beyond + * the point of output having been sent to the browser otherwise. + * + * Note that we don't turn this on any earlier since we want to allow plugins + * to turn it on themselves via a configuration override on the prefs_backend + * hook. + * + */ +if ($buffer_output) ob_start(!empty($buffered_output_handler) ? $buffered_output_handler : NULL); + + /** * Do something special for some pages. This is based on the PAGE_NAME constant * set at the top of every page.