A graph displays the PHP code of the IP address. Let's first read the code sunip. php and copy the code as follows :? Phpheader (Content-type: imagegif); $ imimagecreate (255,255,255); $ background_colorImageColorAllocate ($ im,); unset ($ ip); read the code first
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 '];
}
$ Col = imagecolorallocate ($ im, 0, 51,102 );
Imagestring ($ im, 3, 5, 1, $ ip, $ col );
Imagegif ($ im );
Imagedestroy ($ im );
?>
Next I will explain it one by one
I am not an expert at all.
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 (255,255,255); $ background_color = ImageColorAllocate ($ im ); unset ($ ip );...