Created
June 16, 2017 02:07
-
-
Save csf30816/ace7143e211cb899908c50ca0df50b13 to your computer and use it in GitHub Desktop.
Creates a simple PHP IP image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Function to get the client IP address | |
function get_client_ip() { | |
$ipaddress = ''; | |
if (isset($_SERVER['HTTP_CLIENT_IP'])) | |
$ipaddress = $_SERVER['HTTP_CLIENT_IP']; | |
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) | |
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; | |
else if(isset($_SERVER['HTTP_X_FORWARDED'])) | |
$ipaddress = $_SERVER['HTTP_X_FORWARDED']; | |
else if(isset($_SERVER['HTTP_FORWARDED_FOR'])) | |
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR']; | |
else if(isset($_SERVER['HTTP_FORWARDED'])) | |
$ipaddress = $_SERVER['HTTP_FORWARDED']; | |
else if(isset($_SERVER['REMOTE_ADDR'])) | |
$ipaddress = $_SERVER['REMOTE_ADDR']; | |
else | |
$ipaddress = 'UNKNOWN'; | |
return $ipaddress; | |
} | |
$my_img = imagecreate( 200, 80 ); | |
$background = imagecolorallocate( $my_img, 0, 0, 255 ); | |
$text_colour = imagecolorallocate( $my_img, 255, 255, 0 ); | |
$line_colour = imagecolorallocate( $my_img, 128, 255, 0 ); | |
imagestring( $my_img, 4, 30, 25, get_client_ip(), $text_colour ); | |
imagesetthickness ( $my_img, 5 ); | |
imageline( $my_img, 30, 45, 165, 45, $line_colour ); | |
header( "Content-type: image/png" ); | |
imagepng( $my_img ); | |
imagecolordeallocate( $line_color ); | |
imagecolordeallocate( $text_color ); | |
imagecolordeallocate( $background ); | |
imagedestroy( $my_img ); | |
?> |
@ateesdalejr I am guessing you are who I think you are so Your Welcome :)
yup I'm @theultimatum I just recently changed my git username.
how do u host php on the scratch forums?
@bob1171 You can't.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!