Interesting PHP Logo and Zend Logo images in the phpinfo function (original)
Yu Chao yuchao86@gmail.com
Open the php source code. When you try to find the logo.gif file but cannot find it, how does the PHPlogo output by phpinfo. php survive ??
View the source code corresponding to the phpinfo. php file. can only see such a link phpinfo. php? = PHPE9568F34-D428-11d2-A769-00AA001ACF42, how was it generated?
In the./main/logos. h file, the PHP and Zend labels are saved using the zend_logo and php_logo arrays. You cannot find the zend.gif file in the issue package,
As follows:
# Define CONTEXT_TYPE_IMAGE_GIF "Content-Type: image/gif"
Static const unsigned char zend_logo [] = {
71, 73, 70, 56, 57, 97,113, 0, 72, 0,
213, 0, 0, 13, 13, 14, 1, 3, 6, 2,
// Omitting the intermediate part
46,143,167, 96,131, 23,221,120,200, 72,
214, 74, 16, 0, 0, 59 };
Static const unsigned char php_logo [] = {
71, 73, 70, 56, 57, 97,120, 0, 67, 0,
230,106, 0,127,130,184, 57, 55, 71, 40,
// Omitting the intermediate part
21,116,187,251,221,240,142,119,188, 3,
1, 0, 59, 0 };
Static const unsigned char php_egg_logo [] = {
71, 73, 70, 56, 57, 97,120, 0, 67, 0,
231,255, 0, 18, 25, 33, 32, 30, 34, 28,
// The middle part is omitted. This is the egg logo sent by Fool's Day.
54,240, 3, 66,148, 6,228,178, 11,192,
192, 4,236,158,239, 2, 17, 16, 0, 59 };
Maybe you have another question ?? How do these numbers generate images?
See the following program:
<? PHP
$ Filename = "logo-small.gif ";
$ Fp = fopen ($ filename, "rb ");
$ Buffer = fread ($ FP, filesize ($ filename ));
Fclose ($ FP );
$ Len = strlen ($ buffer );
$ Fp = fopen ("logo-small.h", "WB ");
Fwrite ($ FP, "unsigned char php_logo [] = {");
For ($ I = 0; $ I <= $ Len; $ I ++ ){
If ($ I % 10 = 0 ){
Fwrite ($ FP, "\ n \ t ");
}
If ($ I = $ Len ){
$ STR = str_pad (ord (substr ($ buffer, $ I, 1), 3, "", str_pad_left );
} Else {
$ STR = str_pad (ord (substr ($ buffer, $ I, 1), 3, "", str_pad_left ).",";
}
Fwrite ($ FP, $ Str );
}
Fwrite ($ fp, "}; \ n ");
Fclose ($ fp );
?>
This is the inverse process of the previous process. It is to convert a GIF image into an array of C language and put it in the. h header file,
After conversion, you can also obtain an array as follows:
Unsigned char php_logo [] = {
71, 73, 70, 56, 55, 97, 51, 0, 51, 0,
244, 0, 0,251,121, 34,251,129, 48,252,
138, 62,252,146, 76,252,155, 89,252,163,
103,253,171,117,253,180,131,253,188,145,
253,197,159,254,205,173,254,213,187,254,
222,200,254,230,214,255,239,228,255,247,
242,255,255,255, 0, 0, 0, 0, 0, 0,
......................};
Replace the corresponding array content in./main/logos. h with this array to replace the logo,
The ord function is converted to the corresponding ASCII code, while the str_pad function uses array alignment, and the STR_PAD_LEFT parameter is left alignment.
Finally, recompile the PHP source code to modify the LOGO and ZENDLOGO in phpinfo.
In addition, you can use the php_logo_guid () and zend_logo_guid () functions as follows to generate PHPlogo and ZENDlogo
Echo ''? = '. Php_logo_guid ().' "alt =" PHP Logo! "/> ';
I found through execution that the guid value is always one and determined during compilation.
Refer:
Http://www.webhostingtalk.com/showthread.php? T = 254983
Http://bytes.com/topic/php/answers/561086-phpinfo-how-does-generates-php-logo
Http://hk2.php.net/php_logo_guid
Http://hk2.php.net/zend_logo_guid