PDA

View Full Version : Source Code, Easy Implementation - No Ad's



I.am
11-20-2003, 06:32 AM
As I promised.

Many versions of this are floating out there. This is a different one. Use as you like.

Your host has to support php.
____________________________________________________________
Version 1:

You need three files for this.

.htaccess


<Files ipdisplay.jpg>
ForceType application/x-httpd-php
</Files>

ipdisplay.jpg


<?php
Header ('Content-type: image/jpeg');
Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
Header('Pragma: no-cache');

// Dimensions
$img_width = 280;
$img_height = 50;

// Image Creation
$image = imagecreate($img_width, $img_height);

// set the colours
$cool  = imagecolorallocate($image, 81, 86, 96);
$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 255, 255, 255);
$red   = imagecolorallocate($image, 255, 0, 0);
$grey  = imagecolorallocate($image, 204, 204, 204);
$green = imagecolorallocate($image, 206, 129, 18);
$blue  = imagecolorallocate($image, 0, 0, 255);

// set the background colour and border
imagefilledrectangle($image, 0, 0, $img_width, $img_height, $cool);

// set the font and print text
$font = '/ttf/font/path';

ImageTTFText ($image, 8, 0, 10, 17, $white, $font, "Your IP Address is... ".$REMOTE_ADDR);

// Display & Destroy
imagejpeg($image);
imagedestroy($image);

?>

and Your Font File.
You can play around with it to have your own custom background etc.
_______________________________________________________________

Version 2:

Using your own custom image:

Use font file as needed.

.htaccess

<Files ipdisplay.png>
ForceType application/x-httpd-php
</Files>


ipdisplay.png

<?php

Header ('Content-type: image/png');
Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
Header('Pragma: no-cache');

// Image Creation
$image = imagecreatefrompng("image-name.png");

// set the colours
$cool = imagecolorallocate($image, 87, 87, 87);
$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 255, 255, 255);
$red = imagecolorallocate($image, 255, 0, 0);
$grey = imagecolorallocate($image, 204, 204, 204);
$green = imagecolorallocate($image, 206, 129, 18);
$blue = imagecolorallocate($image, 0, 0, 255);

// Font Path
$font = '/ttf/font/path';

ImageTTFText ($image, 8, 0, 10, 17, $white, $font, "Your IP Address is... ".$REMOTE_ADDR);

// Display & Destroy
imagepng($image);
imagedestroy($image);

?>



Also, create a php file and put this in
<?php phpinfo(); ?>

Execute it on your server, scroll down to see if GD is enabled. It won't work if its not.

You need to find a host where php is enabled.
No ad's nothing like what you see in viper's sig ;) . Feel free to have fun with it. :lol:

Best wishes :)
I.am

ps: The instructions are clear enough. I am going to be out for a while working on another project. So wont be checking the thread that often. If I do drop in will definetly help you out otherwise many members must be knowing php they can help out quick questions. :)

I.am
11-20-2003, 06:35 AM
Forgot to add: the first version might look something like this
http://www.astromike.com/gd_stuff/ip/ipaddress.jpg

That is not my host or anything. Apparantly he has implemented a similar script. For the example above i have used similar colors.

I.am
11-25-2003, 07:43 AM
Btw, if you any of you do use this, leave a note here, so I know its actually coming to use. ;)