Hi,
habe mir mal ein PHP gZIP Komprimier Skript geschrieben, aber da gibts ein Problem, hier erstmal das Script:
[code]<?php
$file = $_GET[‘file’];
if (!$file or !file_exists($file) )
{
echo “Error!”;
exit();
}
$known_content_types = array(
“htm” => “text/html”,
“html” => “text/html”,
“js” => “text/javascript”,
“css” => “text/css”,
“xml” => “text/xml”,
“gif” => “image/gif”,
“jpg” => “image/jpeg”,
“jpeg” => “image/jpeg”,
“png” => “image/png”,
“txt” => “text/plain”
);
$content_type = $known_content_types[file_extension($file)];
function file_extension($filename)
{
return end(explode(".", $filename));
}
// Include this function on your pages
function print_gzipped_page() {
global $HTTP_ACCEPT_ENCODING;
if( headers_sent() ){
$encoding = false;
}elseif( strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false ){
$encoding = 'x-gzip';
}elseif( strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false ){
$encoding = 'gzip';
}else{
$encoding = false;
}
if( $encoding ){
$contents = ob_get_contents();
ob_end_clean();
header('Content-Encoding: '.$encoding);
header("Content-Type: " . $content_type );
print("\x1f\x8b\x08\x00\x00\x00\x00\x00");
$size = strlen($contents);
$contents = gzcompress($contents, 9);
$contents = substr($contents, 0, $size);
print($contents);
exit();
}else{
ob_end_flush();
exit();
}
}
// At the beginning of each page call these two functions
ob_start();
ob_implicit_flush(0);
// Then do everything you want to do on the page
include($file);
// Call this function to output everything as gzipped content.
print_gzipped_page();
?> [/code]
Ich denke mal, das include() ist das Problem…
Parse error: syntax error, unexpected '>' in /users/dhmh/www/forum/styles/AeroBlue/theme/logo.png on line 230
(Es funktioniert noch nicht überall, nur bei javascript )
Gibts ne alternative zu include ?