| px | top | add code | search | signup | login | help |
<?
// andi\'s image handler
// © 2001 by andi (andi@syntex.at
$gz_possible = isset($HTTP_SERVER_VARS[\"HTTP_ACCEPT_ENCODING\"]) && eregi(\"gzip, deflate\",$HTTP_SERVER_VARS[\"HTTP_ACCEPT_ENCODING\"]);
ob_start();
$lerl = getimagesize(\"images/$pic\");
if($lerl[2] == 1) {
header(\"Content-type: image/gif\");
} elseif($lerl[2] == 2) {
header(\"Content-type: image/jpg\");
} elseif($lerl[2] == 3) {
header(\"Content-type: image/png\");
}
$fd = fopen (\"images/$pic\", \"r\");
$contents = fread ($fd, filesize (\"images/$pic\"));
echo $contents;
$buffer=ob_get_contents();
ob_end_clean();
if (!$gz_possible)
{
echo $buffer;
return;
} else {
header(\"Content-Encoding: gzip\");
echo \"\\x1f\\x8b\\x08\\x00\\x00\\x00\\x00\\x00\";
}
$Size = strlen($buffer);
$Crc = crc32($buffer);
$buffer = gzcompress($buffer, 9);
$buffer = substr($buffer, 0, strlen($buffer) - 4);
echo $buffer;
fclose ($fd);
?>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.