Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Your IP Address in Colour
#1
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.

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($im255255255);
    
    
//Grab our watermark
    
$watermark imagecreatefrompng('wm.png');
    
$watermark_width imagesx($watermark);
    
$watermark_height imagesy($watermark);
    
    
//Sort Data - FIX THIS MESS
    
$ipBlock explode("."$usrIP4);
    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$watermark0000$watermark_width$watermark_height100);
    
    
//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:

[Image: ip.php]
LockerZ Invite Required? PM Me.
Visit TechBeat for the latest Technology News
[Image: jamzasigniture.jpg]
Reply
#2
w0w, that's awsome... the image looks great..
Thank you man!

But the wm.png image isn't there anymore. Sad
Reply
#3
(10-17-2009, 02:20 AM)NinjaGeek Wrote: But the wm.png image isn't there anymore. Sad

Ah, yeah for some reason, its randomly appearing then dissapearing, so I added a mirror for it.
LockerZ Invite Required? PM Me.
Visit TechBeat for the latest Technology News
[Image: jamzasigniture.jpg]
Reply
#4
Proper and explicit, very nice script Smile
You could improve a bit the manner of how you get the IP :
PHP Code:
//Get Information
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) 
  
$usrIP $_SERVER['HTTP_X_FORWARDED_FOR']; 
elseif (isset(
$_SERVER['HTTP_CLIENT_IP']))
  
$usrIP $_SERVER['HTTP_CLIENT_IP'];
else 
$usrIP $_SERVER['REMOTE_ADDR']; 

It makes it available for more situations Smile
Keep up the good work!
Reply
#5
That's awesome, The colors are very nice, Keep up the good work dude. Smile
Reply
#6
Doesn't appear to be working for me.
Superman I am here to rescue you.
This is Support Forums not Support PMs.  Do not PM me for support unless it's private and site related.
Reply
#7
Nice, thanks for this.
|| Rules || Market ||
[Image: t6e147.gif]
Reply
#8
Hmm..thanks, i will use this, well try Smile
[Image: Untitled-1.png]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Format Web Address zone 0 543 11-08-2009, 08:40 AM
Last Post: zone

Forum Jump:


Users browsing this thread: 1 Guest(s)