Index: branches/unlabeled/unlabeled-1.155.2/core/kernel/application.php =================================================================== diff -u -r5506 -r5629 --- branches/unlabeled/unlabeled-1.155.2/core/kernel/application.php (.../application.php) (revision 5506) +++ branches/unlabeled/unlabeled-1.155.2/core/kernel/application.php (.../application.php) (revision 5629) @@ -189,6 +189,8 @@ { if($this->InitDone) return false; + ob_start(); // collect any output from method (other then tags) into buffer + if(defined('DEBUG_MODE') && $this->isDebugMode() && constOn('DBG_PROFILE_MEMORY')) { $this->Debugger->appendMemoryUsage('Application before Init:'); } @@ -258,7 +260,12 @@ $this->HandleEvent( new kEvent('visits:OnRegisterVisit') ); $this->ValidateLogin(); - + + if ($this->UseOutputCompression()) { + header('Content-Encoding: gzip'); + safeDefine('DBG_COMPRESS_OUTPUT', 1); + } + if($this->isDebugMode()) { $this->Debugger->profileFinish('kernel4_startup'); } @@ -676,8 +683,14 @@ } //eval("?".">".$this->HTML); - - echo $this->HTML; + + $this->HTML = ob_get_clean().$this->HTML; + if ($this->isDebugMode()) { + $this->HTML .= $this->Debugger->printReport(true); + } + + echo $this->UseOutputCompression() ? gzencode($this->HTML) : $this->HTML; + $this->UpdateCache(); flush(); @@ -695,6 +708,17 @@ //$this->SaveBlocksCache(); } + /** + * Checks if output compression options is available + * + * @return string + */ + function UseOutputCompression() + { +// return false; + return $this->ConfigValue('UseOutputCompression') && function_exists('gzencode') && strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'); + } + function SaveBlocksCache() { /*if (constOn('EXPERIMENTAL_PRE_PARSE')) { Index: branches/unlabeled/unlabeled-1.70.2/admin/install/inportal_data.sql =================================================================== diff -u -r5448 -r5629 --- branches/unlabeled/unlabeled-1.70.2/admin/install/inportal_data.sql (.../inportal_data.sql) (revision 5448) +++ branches/unlabeled/unlabeled-1.70.2/admin/install/inportal_data.sql (.../inportal_data.sql) (revision 5629) @@ -60,6 +60,7 @@ INSERT INTO ConfigurationAdmin VALUES ('MaxImportCategoryLevels', 'la_Text_General', 'la_prompt_max_import_category_levels', 'text', '', '', 10.08, 0, 1); INSERT INTO ConfigurationAdmin VALUES ('UseCronForRegularEvent', 'la_Text_Website', 'la_UseCronForRegularEvent', 'checkbox', NULL, NULL, 10.15, 0, 0); INSERT INTO ConfigurationAdmin VALUES ('NoPermissionTemplate', 'la_Text_Website', 'la_config_nopermission_template', 'text', '', '', 10.17, 0, 0); +INSERT INTO ConfigurationAdmin (VariableName, heading, prompt, element_type, validation, ValueList, DisplayOrder, GroupDisplayOrder, Install) VALUES ('UseOutputCompression', 'la_Text_Website', 'la_config_UseOutputCompression', 'checkbox', '', '', 10.18, 0, 1); INSERT INTO ConfigurationValues VALUES (NULL, 'Columns_Category', '2', 'In-Portal', 'Categories') INSERT INTO ConfigurationValues VALUES (NULL, 'DomainSelect','1','In-Portal','in-portal:configure_general') @@ -192,6 +193,7 @@ INSERT INTO ConfigurationValues VALUES (NULL, 'MaxImportCategoryLevels', '10', 'In-Portal', 'in-portal:configure_categories'); INSERT INTO ConfigurationValues VALUES (NULL, 'UseCronForRegularEvent', '0', 'In-Portal', 'in-portal:configure_general'); INSERT INTO ConfigurationValues VALUES (NULL, 'NoPermissionTemplate', 'no_permission', 'In-Portal', 'in-portal:configure_general'); +INSERT INTO ConfigurationValues (VariableName, VariableValue, ModuleOwner, Section) VALUES ('UseOutputCompression', '1', 'In-Portal', 'in-portal:configure_general'); INSERT INTO Events VALUES (30, 'USER.ADD', 1, 0, 'In-Portal:Users', 'la_event_user.add', 0) INSERT INTO Events VALUES (32, 'USER.ADD', 2, 0, 'In-Portal:Users', 'la_event_user.add', 1) Index: branches/unlabeled/unlabeled-1.8.2/admin/install/upgrades/inportal_upgrade_v1.2.1.sql =================================================================== diff -u -r5552 -r5629 --- branches/unlabeled/unlabeled-1.8.2/admin/install/upgrades/inportal_upgrade_v1.2.1.sql (.../inportal_upgrade_v1.2.1.sql) (revision 5552) +++ branches/unlabeled/unlabeled-1.8.2/admin/install/upgrades/inportal_upgrade_v1.2.1.sql (.../inportal_upgrade_v1.2.1.sql) (revision 5629) @@ -68,4 +68,7 @@ ALTER TABLE CategoryItems ADD `ItemPrefix` VARCHAR( 50 ) NOT NULL AFTER `PrimaryCat`, ADD `Filename` VARCHAR( 255 ) NOT NULL AFTER `ItemPrefix` ; ALTER TABLE CategoryItems ADD INDEX `Filename` ( `Filename` ( 4 ) ); +INSERT INTO ConfigurationAdmin (VariableName, heading, prompt, element_type, validation, ValueList, DisplayOrder, GroupDisplayOrder, Install) VALUES ('UseOutputCompression', 'la_Text_Website', 'la_config_UseOutputCompression', 'checkbox', '', '', 10.18, 0, 1); +INSERT INTO ConfigurationValues (VariableName, VariableValue, ModuleOwner, Section) VALUES ('UseOutputCompression', '1', 'In-Portal', 'in-portal:configure_general'); + UPDATE Modules SET Version = '1.2.1' WHERE Name = 'In-Portal'; \ No newline at end of file Index: branches/unlabeled/unlabeled-1.59.2/core/kernel/utility/debugger.php =================================================================== diff -u -r5566 -r5629 --- branches/unlabeled/unlabeled-1.59.2/core/kernel/utility/debugger.php (.../debugger.php) (revision 5566) +++ branches/unlabeled/unlabeled-1.59.2/core/kernel/utility/debugger.php (.../debugger.php) (revision 5629) @@ -639,13 +639,13 @@ */ function printReport($returnResult = false, $clean_output_buffer = true) { - $this->profileFinish('script_runtime'); - - $this->breakOutofBuffering(); if ($this->reportDone) { - // don't print same report twice + // don't print same report twice (in case if shutdown function used + compression + fatal error) return ''; } + + $this->profileFinish('script_runtime'); + $this->breakOutofBuffering(); $debugger_start = memory_get_usage(); @@ -731,6 +731,7 @@ if ($skip_reporting) { // let debugger write report and then don't output anything + $this->reportDone = true; return ''; } @@ -773,7 +774,7 @@ if ($returnResult) { $ret = ob_get_contents(); if ($clean_output_buffer) { - ob_clean(); + ob_end_clean(); } $ret .= $this->getShortReport($memory_used); @@ -827,11 +828,10 @@ break; } } - + return '
'.$ret.'
'; } - /** * User-defined error handler * @@ -873,26 +873,27 @@ $this->ProfilerData['error_handling']['ends'] = memory_get_usage(); $this->profilerAddTotal('error_handling', 'error_handling'); if (substr($errorType, 0, 5) == 'Fatal') { - $this->breakOutofBuffering(false); $this->IsFatalError = true; - if (ob_get_level()) ob_flush(); - if (!$this->constOn('DBG_USE_SHUTDOWN_FUNC')) { - $this->printReport(); - } + // append debugger report to data in buffer & clean buffer afterwards + $buffer_content = $this->breakOutofBuffering(false) . $this->printReport(true); + echo $this->constOn('DBG_COMPRESS_OUTPUT') ? gzencode($buffer_content) : $buffer_content; exit; } } function breakOutofBuffering($flush = true) { + $buffer_content = Array(); while (ob_get_level()) { if ($flush) { ob_end_flush(); } else { - ob_end_clean(); + $buffer_content[] = ob_get_clean(); +// ob_end_clean(); } } + return implode('', array_reverse($buffer_content)); } function saveToFile($msg)