Php implements code and comments for displaying IP addresses in graphics. Use the graphic display Ip address. the code for copying the file sunip. php is as follows :? Phpheader (Content-type: imagegif); $ imimagecreate (); $ background_colorImageColorAllocate ($ im, 2 use graphics to display Ip addresses, file sunip. php
The code is as follows:
Header ("Content-type: image/gif ");
$ Im = imagecreate (130,15 );
$ Background_color = ImageColorAllocate ($ instant, 255,255,255 );
Unset ($ ip );
If ($ _ SERVER ['http _ CLIENT_IP ']) {
$ Ip = $ _ SERVER ['http _ CLIENT_IP '];
} Else if ($ _ SERVER ['http _ X_FORWARDED_FOR ']) {
$ Ip = $ _ SERVER ['http _ X_FORWARDED_FOR '];
} Else {
$ Ip = $ _ SERVER ['remote _ ADDR '];
} // Www.jbxue.com
$ Col = imagecolorallocate ($ im, 0, 51,102 );
Imagestring ($ im, 3, 5, 1, $ ip, $ col );
Imagegif ($ im );
Imagedestroy ($ im );
?>
1.
2. header ("Content-type: image/gif ");
The second line declares that the browser header is output as a GIF image.
3. $ im = imagecreate (130,15 );
Create an image imagecreate () with and 15 representing the width and height respectively.
4. $ background_color = ImageColorAllocate ($ im, 255,255,255 );
Set the background color imagecolorallocate to assign a color ($ im, 255,255,255) to an image. im stands for the three 255 s after the new image mentioned above, and represents the 10-digit character of the ffffff color table.
5. unset ($ ip );
Useless
6. if ($ _ SERVER ['http _ CLIENT_IP ']) {
$ Ip = $ _ SERVER ['http _ CLIENT_IP '];
} Else if ($ _ SERVER ['http _ X_FORWARDED_FOR ']) {
$ Ip = $ _ SERVER ['http _ X_FORWARDED_FOR '];
} Else {
$ Ip = $ _ SERVER ['remote _ ADDR '];
}
If $ _ SERVER ['http _ CLIENT_IP '] can be used, use $ _ SERVER ['http _ CLIENT_IP'] to determine whether this segment is compatible with multiple SERVER settings.
7. $ col = imagecolorallocate ($ im, 0, 51,102 );
Define text color
8. imagestring ($ im, 3, 5, 1, $ ip, $ col );
Draw the obtained IP address to the newly created canvas imagestring ($ im, 3, 5, 1, $ ip, $ col), representing imagestring (graphical representation, character size: 1-5, X, Y, output IP, color)
9. imagegif ($ im );
Output GIF image
10. imagedestroy ($ im );
Release memory
11.?>
Program ended
The sunip. php code is as follows :? Php header ("Content-type: image/gif"); $ im = imagecreate (130,15); $ background_color = ImageColorAllocate ($ im, 2...