10-17-2009, 01:21 AM
I just wrote a script quickly (under 30 minutes) to generate a unique image from your IP Address. Later I hope to make a decoder and clean up the code.
Related file: wm.png (mirror)
Your IP Address encoded with this would look like:
PHP Code:
<?php
//tell the browser we are a png image
header("Content-type: image/png");
//Get Information
$usrIP = $_SERVER['REMOTE_ADDR'];
//$usrIP = "123.456.789.123";
//Colours
$colourR[0] = 54; $colourG[0] = 100; $colourB[0] = 139;
$colourR[1] = 79; $colourG[1] = 148; $colourB[1] = 205;
$colourR[2] = 92; $colourG[2] = 172; $colourB[2] = 238;
$colourR[3] = 99; $colourG[3] = 184; $colourB[3] = 255;
$colourR[4] = 70; $colourG[4] = 130; $colourB[4] = 180;
$colourR[5] = 240; $colourG[5] = 248; $colourB[5] = 255;
$colourR[6] = 16; $colourG[6] = 78; $colourB[6] = 139;
$colourR[7] = 24; $colourG[7] = 116; $colourB[7] = 205;
$colourR[8] = 28; $colourG[8] = 134; $colourB[8] = 238;
$colourR[9] = 30; $colourG[9] = 144; $colourB[9] = 255;
//create GD Image or exit on error
$im = @imagecreate(180,15)
or die("Cannot Initialise new GD image stream");
//set background colour to white
$background_colour = imagecolorallocate($im, 255, 255, 255);
//Grab our watermark
$watermark = imagecreatefrompng('wm.png');
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
//Sort Data - FIX THIS MESS
$ipBlock = explode(".", $usrIP, 4);
if(strlen($ipBlock[0])==2) {$ipBlock[0] = "0" . $ipBlock[0];}
if(strlen($ipBlock[0])==1) {$ipBlock[0] = "00" . $ipBlock[0];}
if(strlen($ipBlock[1])==2) {$ipBlock[1] = "0" . $ipBlock[1];}
if(strlen($ipBlock[1])==1) {$ipBlock[1] = "00" . $ipBlock[1];}
if(strlen($ipBlock[2])==2) {$ipBlock[2] = "0" . $ipBlock[2];}
if(strlen($ipBlock[2])==1) {$ipBlock[2] = "00" . $ipBlock[2];}
if(strlen($ipBlock[3])==2) {$ipBlock[3] = "0" . $ipBlock[3];}
if(strlen($ipBlock[3])==1) {$ipBlock[3] = "00" . $ipBlock[3];}
$fullIP = $ipBlock[0] . $ipBlock[1] . $ipBlock[2] . $ipBlock[3];
//Draw our data on the image
for ($i = 0; $i <= 11; $i++){
$curI = substr($fullIP,$i,1);
imagefilledrectangle($im,($i*15),0,(($i*15)+15),15,imagecolorallocate($im,$colourR[$curI],$colourG[$curI],$colourB[$curI]));
}
//Add our Watermark
imagecopymerge($im, $watermark, 0, 0, 0, 0, $watermark_width, $watermark_height, 100);
//create our PNG Image and send it to the browser
imagepng($im);
//Free up the memory used to make the image
imagedestroy($im);
?>
Related file: wm.png (mirror)
Your IP Address encoded with this would look like: