Forum •
PHP Tutorials • Add a users IP address to an image
|
Access: Admin
Total posts: 174
Status: Offline
| |
|
Add a users IP address to an image
|
|
PHP Code:
<?php $ip = $_SERVER['REMOTE_ADDR']; #get the users IP address
$font = 'arial'; #load the font file (make sure arial.ttf is in the same directory)
$size = imagettfbbox(10,0,$font,$ip); #get the height and width of the IP address $width = $size[2] + $size[0] + 3; $height = abs($size[1]) + abs($size[7]);
$im = imagecreate($width, $height); #create an image the same height/width of the text $bg = imagecolorallocate($im, 255, 255, 255); #image background color $color = imagecolorallocate($im, 0, 0, 0); #color used for the text
imagettftext($im, 10, 0, 0, 10, $color, $font, $ip); #write the IP address to the image
header('Content-type: image/jpeg'); imagejpeg($im); imagedestroy($im); ?>
This is a simple script showing you how to create an image then write the IP address of the user viewing it to that image.
|
| 06:06pm 28th Jun 06
| _______________ Chris - Network-13 Last edited by Chris at 11:07pm 8th Jul 06 |
|
Access: Member
Total posts: 17
Status: Offline
| |
|
Add a users IP address to an image
|
|
Hey how do you make the font size smaller, because if you used the same principle to make the security thingy you made, wouldn't it be the same size?
http://network-13.com/image
Cause that looks smaller. what would i do to the script to make it smaller.
|
| 12:09pm 28th Aug 08
| _______________ -Tyler |
|
Access: Member
Total posts: 17
Status: Offline
| |
|
Add a users IP address to an image
|
|
Never mind, i figured it out =PPP, i was thinking to hard, and looking for something complicated, but it was simple.
|
| 12:56pm 28th Aug 08
| _______________ -Tyler |