Home >> Snippet List >> Snippet

Name
Unique IP-icture
Description
Creates a picture based on your IP address Is it useful? No! Is it cool? Yes!
PHP Snippet
<?PHP 
 
$your_ip  = GETENV ("REMOTE_ADDR"); 
$your_var = PREG_SPLIT("/\./",$your_ip); 
$oc1 = $your_var[0]; 
$oc2 = $your_var[1]; 
$oc3 = $your_var[2]; 
$oc4 = $your_var[3]; 
 
HEADER ("Content-type: image/png"); 
$your_image = ImageCreate (600, 600); 
$bg_grey  = ImageColorAllocate ($your_image, 169, 169, 255); 
 
IF($oc1 > 15 && $oc2 > 15 && $oc3 > 15 && $oc4 > 15){ 
 
    $your_poly = ARRAY( 
                    "0"  => $oc3 * RAND(1,20) * 0.1, 
                    "1"  => $oc4 * RAND(1,20) * 0.1, 
                    "2"  => $oc1 * RAND(1,20) * 0.1, 
                    "3"  => $oc2 * RAND(1,20) * 0.1, 
                    "4"  => $oc4 * RAND(1,20) * 0.1, 
                    "5"  => $oc2 * RAND(1,20) * 0.1, 
                    "6"  => $oc3 * RAND(1,20) * 0.1, 
                    "7"  => $oc3 * RAND(1,20) * 0.1, 
                    "8"  => $oc3 * RAND(1,20) * 0.1, 
                    "9"  => $oc3 * RAND(1,20) * 0.1, 
                    "10" => $oc3 * RAND(1,20) * 0.1, 
                    "11" => $oc3 * RAND(1,20) * 0.1, 
                        ); 
    $shape = "POLY"; 
 
} ELSE { 
 
    $clr1 = imagecolorallocate ($your_image, $oc4, $oc4, $oc3); 
    $clr2 = imagecolorallocate ($your_image, $oc3, $oc3, $oc2); 
    $clr3 = imagecolorallocate ($your_image, $oc2, $oc2, $oc1); 
    $clr4 = imagecolorallocate ($your_image, $oc1, $oc1, $oc4); 
 
    $shape = "CIRCLE"; 
 
} 
 
 
$black  = imagecolorallocate ($your_image, 0, 0, 0); 
$shp_clr  = ImageColorAllocate ($your_image, RAND($oc3,255), RAND($oc2,255), RAND(1,$oc1)); 
$font   = 5; 
$width  = ImageFontWidth($font) * STRLEN($your_ip); 
$height = ImageFontHeight($font); 
 
IF ($shape == "POLY"){ 
 
    ImageFilledPolygon ($your_image, $your_poly, 6, $shp_clr); 
} 
ELSE IF ($shape == "CIRCLE"){ 
 
    imagefilledarc ($your_image, $oc2 + RAND(80,600), $oc1 + RAND(80,600), $oc3 + RAND(40,400), $oc3 + RAND(40,400), 0, 359, $clr1, IMG_ARC_PIE); 
    imagefilledarc ($your_image, $oc3 + RAND(200,400), $oc4 + RAND(200,400), $oc2, $oc2, 0, 359, $clr2, IMG_ARC_PIE); 
    imagefilledarc ($your_image, $oc4 + RAND(100,500), $oc3 + RAND(100,500), $oc4 + RAND(20,40), $oc4 + RAND(20,40), 0, 359, $clr3, IMG_ARC_PIE); 
    imagefilledarc ($your_image, $oc1 + RAND(80,100), $oc2 + RAND(80,100), $oc1, $oc1, 0, 359, $clr4, IMG_ARC_PIE); 
 
} 
 
ImageString($your_image, $font, 0, 0, $your_ip, $black); 
ImagePng ($your_image); 
ImageDestroy ($your_image); 
 
?>