Skip to content

Instantly share code, notes, and snippets.

@h2ero
Created June 26, 2013 04:04
Show Gist options
  • Save h2ero/5864690 to your computer and use it in GitHub Desktop.
Save h2ero/5864690 to your computer and use it in GitHub Desktop.
<?php
/**
* POWER PHLOGGER Shared Library
* Pixel generation class
*
* output of 1 pixel transparent/color gif
* call this file directly in an IMG-tag.
* syntax: <img src="phpixel.php"> for a transparent pixel
* or: <img src="phpixel.php?c=FFFF00"> yellow
*
* @final
* @package lib
* @author Philip Iezzi <webmaster@phpee.com>
* @author original autor: Ulrich Babiak, Koeln 1999/11/30
* @copyright Copyright (c) 2000-2004 PHPEE.COM
*
* @version $Id$
*/
$c = @$_GET['c'];
// some headers to prevent caching
Header("Content-type: image/gif");
Header("Expires: Wed, 11 Nov 1998 11:11:11 GMT");
Header("Cache-Control: no-cache");
Header("Cache-Control: must-revalidate");
// HEX -> RGB
$r = hexdec(substr($c, 0, 2));
$g = hexdec(substr($c, 2, 2));
$b = hexdec(substr($c, 4, 2));
// colored pixel
if(@$c){
printf ("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",
71,73,70,56,57,97,1,0,1,0,128,0,0,$r,$g,$b,0,0,0,44,0,0,0,0,1,0,1,0,0,2,2,68,1,0,59);
// transparent pixel
} else {
printf ("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%",
71,73,70,56,57,97,1,0,1,0,128,255,0,192,192,192,0,0,0,33,249,4,1,0,0,0,0,44,0,0,0,0,1,0,1,0,0,2,2,68,1,0,59);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment