Support Forums

Full Version: PHP Image: How To Show A User Their IP In Your Signature.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
First of all, I found this on http://www.thesitewizard.com/ so credits go to them for that but I'm writing this out myself.

Requirements:
  • A Domain
  • Hosting For It
  • Patience
  • Spare 20 Minutes On Your Hands

Okay first of go to your public_html in your cPanel, make a new directory called "img".

Make a file called "index.php" (this then becomes the default page for the img directory)

Inside the index.php, enter this following code:

PHP Code:
<?php
$ip 
$_SERVER['REMOTE_ADDR'];
$my_img imagecreate25080 );
$background imagecolorallocate$my_img102102102 );
$text_colour imagecolorallocate$my_img255255);
$line_colour imagecolorallocate$my_img128255);
imagestring$my_img43025"Your IP Is: $ip",
  
$text_colour );
imagesetthickness $my_img);
imageline$my_img304522045$line_colour );

header"Content-type: image/png" );
imagepng$my_img );
imagecolordeallocate$line_color );
imagecolordeallocate$text_color );
imagecolordeallocate$background );
imagedestroy$my_img );
?>

Make Sure You Save It!

Okay, that should be done, now go to http://www.YourDomain.com/img and you should see your IP.

Go onto the forum of which you want this is your signature, go to the UserCP and click "Edit Signature".

In your signature enter this following BBCode:

Code:
[img]http://www.YourDomainHere.com/img/index.php[/img]

If you want to get the exact colours for the backgrounds of forums. so it looks just like the text then edit this:

PHP Code:
$background imagecolorallocate$my_img102102102 ); 

Change it to:

HackForums
PHP Code:
$background imagecolorallocate$my_img102102102 ); 

SupportForums
PHP Code:
$background imagecolorallocate$my_img878787 ); 
(Want any other forum codes just request them (post forum you want the code for) )



You're Done! Congratulations!

Now Go Freak Out Some People Big Grin
This is a very nice tutorial.
I tried this and it works perfectly. Big Grin
Interesting tutorial. I've always wondered how to do something like this. I'll be keeping these pieces of code as reference. Thanks.
Yeah this is really nice tutorial and I will try this out later.
How would you go about putting this into an image? Like if I were to make an avatar or a signature and want it to spit out the Ip? Any ideas?
Very useful. Thanks for sharing.
I probably won't use it but it's nice to know how to do it anyway.
(09-14-2011, 03:10 AM)Kom Wrote: [ -> ]How would you go about putting this into an image? Like if I were to make an avatar or a signature and want it to spit out the Ip? Any ideas?

This code does create it into an image, if afterwards, once you've done this, go visit the link and you'll see the exact same of what's in my signature.
I've posted quite few GD tutorials on here, lurk for them...
Anyway, this is nothing new or original, the one thread on here is original...
http://www.supportforums.net/showthread.php?tid=1664
The HF background should be RGB: 51, 51, 51 instead of 102, 102, 102. Nice tutorial nonetheless, similar to my text image in php
Nice to know. Very useful.
I might edit the script to keep logs in the future Devlish.