Sinisterly
[PHP Image] Show IP - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: PHP (https://sinister.ly/Forum-PHP)
+--- Thread: [PHP Image] Show IP (/Thread-PHP-Image-Show-IP)

Pages: 1 2


[PHP Image] Show IP - EZiX_mybb_import9300 - 10-19-2012

Welcome HC,
today i will show how to create a php image file that will show your ip! Example:
[Image: ip.php]
So here it goes!


Requirements:
Webhost

• Open notepad and paste the following code:
PHP Code:
<?php $ip = $_SERVER['REMOTE_ADDR']; $my_img = imagecreate( 250, 18 ); $background = imagecolorallocate( $my_img, 35, 35, 35 ); $text_colour = imagecolorallocate( $my_img, 255, 255, 0 ); $line_colour = imagecolorallocate( $my_img, 128, 255, 0 ); imagestring( $my_img, 4, 5, 1, "Your IP Is: $ip", $text_colour ); imagesetthickness ( $my_img, 7 ); header( "Content-type: image/png" ); imagepng( $my_img ); imagecolordeallocate( $line_color ); imagecolordeallocate( $text_color ); imagecolordeallocate( $background ); imagedestroy( $my_img ); ?>

• Save it as .php format

• Upload the file to your webhosting site

• If you saved the file as example.php then your link should be
www.yourwebhost.com/example.php

• Done! Open it and it will show your ip in img format!

Note:
This can be used in everywhere.
And you can change the color of background according to what you like in this case it is darkgrey. How to edit the color? here is the answer: Edit the following part of the code
$background = imagecolorallocate( $my_img, 35, 35, 35 );
The numbers indicate the color RGB format!
You can do the same for texts as well!

Enjoy ~


[PHP Image] Show IP - EZiX_mybb_import9300 - 10-19-2012

Welcome HC,
today i will show how to create a php image file that will show your ip! Example:
[Image: ip.php]
So here it goes!


Requirements:
Webhost

• Open notepad and paste the following code:
PHP Code:
<?php $ip = $_SERVER['REMOTE_ADDR']; $my_img = imagecreate( 250, 18 ); $background = imagecolorallocate( $my_img, 35, 35, 35 ); $text_colour = imagecolorallocate( $my_img, 255, 255, 0 ); $line_colour = imagecolorallocate( $my_img, 128, 255, 0 ); imagestring( $my_img, 4, 5, 1, "Your IP Is: $ip", $text_colour ); imagesetthickness ( $my_img, 7 ); header( "Content-type: image/png" ); imagepng( $my_img ); imagecolordeallocate( $line_color ); imagecolordeallocate( $text_color ); imagecolordeallocate( $background ); imagedestroy( $my_img ); ?>

• Save it as .php format

• Upload the file to your webhosting site

• If you saved the file as example.php then your link should be
www.yourwebhost.com/example.php

• Done! Open it and it will show your ip in img format!

Note:
This can be used in everywhere.
And you can change the color of background according to what you like in this case it is darkgrey. How to edit the color? here is the answer: Edit the following part of the code
$background = imagecolorallocate( $my_img, 35, 35, 35 );
The numbers indicate the color RGB format!
You can do the same for texts as well!

Enjoy ~


RE: [PHP Image] Show IP - bluedog.tar.gz - 10-19-2012

Very cool, thanks for the tutorial. This will come in handy later!


RE: [PHP Image] Show IP - bluedog.tar.gz - 10-19-2012

Very cool, thanks for the tutorial. This will come in handy later!


RE: [PHP Image] Show IP - EZiX_mybb_import9300 - 10-19-2012

(10-19-2012, 02:41 PM)bluedog.tar.gz Wrote: Very cool, thanks for the tutorial. This will come in handy later!
you are welcome mate! enjoy Biggrin


RE: [PHP Image] Show IP - EZiX_mybb_import9300 - 10-19-2012

(10-19-2012, 02:41 PM)bluedog.tar.gz Wrote: Very cool, thanks for the tutorial. This will come in handy later!
you are welcome mate! enjoy Biggrin


RE: [PHP Image] Show IP - balmohan - 10-15-2013

Thanks works great just tried


RE: [PHP Image] Show IP - Anime_mybb_import13823 - 10-16-2013

ya bro working fine showing ip ver fine


RE: [PHP Image] Show IP - Hemin Michael - 10-18-2013

great job my brother


RE: [PHP Image] Show IP - Crime - 11-03-2013

ImageJPEG can also work, but people tend not to use it due to the fact of the image quality, and what people don't realize is that's fixable.

ImageJPEG($Image, NULL, 100);

Change 100 to 1 and you'll see what I mean.