| 1 |
<?php |
<?php |
| 2 |
// $Id: boost.module,v 1.3.2.2.2.5.2.247 2009/11/13 23:07:32 mikeytown2 Exp $ |
// $Id: boost.module,v 1.3.2.2.2.5.2.248 2009/11/13 23:10:07 mikeytown2 Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 1251 |
*/ |
*/ |
| 1252 |
function _boost_ob_handler() { |
function _boost_ob_handler() { |
| 1253 |
$buffer = ob_get_contents(); |
$buffer = ob_get_contents(); |
| 1254 |
|
// If Compressed data was given to us decompress it |
| 1255 |
|
if (boost_headers_contain('gzip')) { |
| 1256 |
|
$decompressed_buffer = gzinflate(substr(substr($buffer, 10), 0, -8)); |
| 1257 |
|
} |
| 1258 |
|
else { |
| 1259 |
|
$decompressed_buffer = $buffer; |
| 1260 |
|
} |
| 1261 |
|
|
| 1262 |
// Ensure we're in the correct working directory, since some web servers (e.g. Apache) mess this up here. |
// Ensure we're in the correct working directory, since some web servers (e.g. Apache) mess this up here. |
| 1263 |
chdir(dirname($_SERVER['SCRIPT_FILENAME'])); |
chdir(dirname($_SERVER['SCRIPT_FILENAME'])); |
| 1289 |
// Check the currently set content type and the HTTP response code. only cache |
// Check the currently set content type and the HTTP response code. only cache |
| 1290 |
// 'text/*' pages that were output with a 200 OK status. If it didn't get a |
// 'text/*' pages that were output with a 200 OK status. If it didn't get a |
| 1291 |
// 200 then remove that entry from the cache. |
// 200 then remove that entry from the cache. |
| 1292 |
if (!empty($buffer)) { |
if (!empty($decompressed_buffer)) { |
| 1293 |
$status = boost_get_http_status(); |
$status = boost_get_http_status(); |
| 1294 |
$types = boost_get_content_type(); |
$types = boost_get_content_type(); |
| 1295 |
if (BOOST_VERBOSE >= 7) { |
if (BOOST_VERBOSE >= 7) { |
| 1301 |
if (BOOST_ASYNCHRONOUS_OUTPUT) { |
if (BOOST_ASYNCHRONOUS_OUTPUT) { |
| 1302 |
boost_async_opp($buffer, FALSE, 'text/javascript'); |
boost_async_opp($buffer, FALSE, 'text/javascript'); |
| 1303 |
} |
} |
| 1304 |
boost_cache_set($GLOBALS['_boost_path'], $buffer, BOOST_JSON_EXTENSION); |
boost_cache_set($GLOBALS['_boost_path'], $decompressed_buffer, BOOST_JSON_EXTENSION); |
| 1305 |
} |
} |
| 1306 |
elseif ($status == 404 || $status == 403) { |
elseif ($status == 404 || $status == 403) { |
| 1307 |
$filename = boost_file_path($GLOBALS['_boost_path'], TRUE, BOOST_JSON_EXTENSION); |
$filename = boost_file_path($GLOBALS['_boost_path'], TRUE, BOOST_JSON_EXTENSION); |
| 1312 |
if (BOOST_ASYNCHRONOUS_OUTPUT) { |
if (BOOST_ASYNCHRONOUS_OUTPUT) { |
| 1313 |
boost_async_opp($buffer, FALSE, 'text/xml'); |
boost_async_opp($buffer, FALSE, 'text/xml'); |
| 1314 |
} |
} |
| 1315 |
boost_cache_set($GLOBALS['_boost_path'], $buffer, BOOST_XML_EXTENSION); |
boost_cache_set($GLOBALS['_boost_path'], $decompressed_buffer, BOOST_XML_EXTENSION); |
| 1316 |
} |
} |
| 1317 |
elseif ($status == 404 || $status == 403) { |
elseif ($status == 404 || $status == 403) { |
| 1318 |
$filename = boost_file_path($GLOBALS['_boost_path'], TRUE, BOOST_XML_EXTENSION); |
$filename = boost_file_path($GLOBALS['_boost_path'], TRUE, BOOST_XML_EXTENSION); |
| 1323 |
if (BOOST_ASYNCHRONOUS_OUTPUT) { |
if (BOOST_ASYNCHRONOUS_OUTPUT) { |
| 1324 |
boost_async_opp($buffer, FALSE, 'text/html'); |
boost_async_opp($buffer, FALSE, 'text/html'); |
| 1325 |
} |
} |
| 1326 |
boost_cache_set($GLOBALS['_boost_path'], $buffer, BOOST_FILE_EXTENSION); |
boost_cache_set($GLOBALS['_boost_path'], $decompressed_buffer, BOOST_FILE_EXTENSION); |
| 1327 |
boost_cache_css_js_files($buffer); |
boost_cache_css_js_files($decompressed_buffer); |
| 1328 |
} |
} |
| 1329 |
elseif ($status == 404 || $status == 403) { |
elseif ($status == 404 || $status == 403) { |
| 1330 |
// Kill cache entry if it exists |
// Kill cache entry if it exists |
| 2074 |
return FALSE; |
return FALSE; |
| 2075 |
} |
} |
| 2076 |
|
|
|
// If Compressed data was given to us decompress it |
|
|
if (boost_headers_contain('gzip')) { |
|
|
$data = gzinflate(substr(substr($data, 10), 0, -8)); |
|
|
} |
|
|
|
|
| 2077 |
$cached_at = date('Y-m-d H:i:s', BOOST_TIME); |
$cached_at = date('Y-m-d H:i:s', BOOST_TIME); |
| 2078 |
// Code commenting style based on what is being cached. |
// Code commenting style based on what is being cached. |
| 2079 |
// Append the Boost footer with the relevant timestamps |
// Append the Boost footer with the relevant timestamps |