Support Forums
PHP Image: How To Show A User Their IP In Your Signature. - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21)
+---- Thread: PHP Image: How To Show A User Their IP In Your Signature. (/showthread.php?tid=22062)



PHP Image: How To Show A User Their IP In Your Signature. - BreShiE - 09-08-2011

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


RE: PHP Image: How To Show A User Their IP In Your Signature. - Fox - 09-13-2011

This is a very nice tutorial.
I tried this and it works perfectly. Big Grin


RE: PHP Image: How To Show A User Their IP In Your Signature. - SaNƹ - 09-13-2011

Interesting tutorial. I've always wondered how to do something like this. I'll be keeping these pieces of code as reference. Thanks.


RE: PHP Image: How To Show A User Their IP In Your Signature. - ₠o™ - 09-14-2011

Yeah this is really nice tutorial and I will try this out later.


RE: PHP Image: How To Show A User Their IP In Your Signature. - Kom - 09-14-2011

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?


RE: PHP Image: How To Show A User Their IP In Your Signature. - Fragma - 09-14-2011

Very useful. Thanks for sharing.
I probably won't use it but it's nice to know how to do it anyway.


RE: PHP Image: How To Show A User Their IP In Your Signature. - BreShiE - 09-14-2011

(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.


RE: PHP Image: How To Show A User Their IP In Your Signature. - Gaijin - 09-17-2011

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


RE: PHP Image: How To Show A User Their IP In Your Signature. - alabama - 10-15-2011

The HF background should be RGB: 51, 51, 51 instead of 102, 102, 102. Nice tutorial nonetheless, similar to my text image in php


RE: PHP Image: How To Show A User Their IP In Your Signature. - Contribution - 11-08-2011

Nice to know. Very useful.
I might edit the script to keep logs in the future Devlish.