Application & nbsp; php4 & nbsp; acceleration & nbsp; web & nbsp; transmission
Last Update:2014-05-05
Source: Internet
Author: User
? /*************************************** ** Title .........: PHP4HTTPCompressionSpeedsuptheWeb ** Version .......: 1.10 ** Author ........: catoccatoc @ 16 /***************************************
** Title ......: PHP4 HTTP Compression Speeds up the Web
** Version ......: 1.10
** Author ......: catoc
** Filename...: gzdoc. php
** Last changed...: 25/08/2000
** Requirments...: PHP4> = 4.0.1
** PHP was configured with -- with-zlib [= DIR]
** Notes...: Dynamic Content Acceleration compresses
** The data transmission data on the fly
** Code by sun jin hu (catoc)
** Most newer browsers since 1998/1999 have
** Been equipped to support the HTTP 1.1
** Standard known as 'content-encoding .'
** Essentially the browser indicates to
** Server that it can accept 'content encoding'
** And if the server is capable it will then
** Compress the data and transmit it.
** Browser decompresses it and then renders
** The page.
** Useage ........:
** No space before the beginning of the first' ** ------------ Start of file ----------
** | ** | Include ('gzdoc. php ');
** | Print 'start output !! ';
** |?>
** |
** |... The page...
** |
** | ** | Gzdocout ();
** |?>
** ------------- End of file -----------
***************************************/
Ob_start ();
Ob_implicit_flush (0 );
Function GetHeader (){
$ Headers = getallheaders ();
While (list ($ header, $ value) = each ($ headers )){
$ Message. = '$ header: $ value
N ';
}
Return $ Message;
}
Function CheckCanGzip (){
Global $ HTTP_ACCEPT_ENCODING, $ PHP_SELF, $ Wget, $ REMOTE_ADDR, $ S_UserName;
If (connection_timeout () | connection_aborted ()){
Return 0;
}
If (strpos ('catoc '. $ HTTP_ACCEPT_ENCODING, 'gzip') | $ Wget = 'y '){
If (strpos ('catoc '. $ HTTP_ACCEPT_ENCODING, 'X-gzip ')){
$ ENCODING = 'x-gzip ';
$ Error_Msg = str_replace ('
', '', GetHeader ());
$ Error_Msg. = 'time: '. date ('Y-m-d H: I: s'). 'n ';
$ Error_Msg. = 'remote-Address: '. $ REMOTE_ADDR. 'n ';
// Mail ('your @ none.net ', 'user have x-gzip output in file $ PHP_SELF !!! ', $ Error_Msg );
} Else {
$ ENCODING = 'gzip ';
}
Return $ ENCODING;
} Else {
Return 0;
}
}
Function GzDocOut (){
Global $ PHP_SELF, $ CatocGz, $ REMOTE_ADDR, $ S_UserName;
$ ENCODING = CheckCanGzip ();
If ($ ENCODING ){
Print 'n' N ';
$ Contents = ob_get_contents ();
Ob_end_clean ();
If ($ CatocGz = 'y '){
Print 'not compress lenth: '. strlen ($ Contents ).'
';
Print 'compressed lenth: '. strlen (gzcompress ($ Contents )).'
';
Exit;
} Else {
Header ('content-Encoding: $ encoding ');
}
Print pack ('cccccccccccc', 0x1f, 0x8b, 0 x, 0 x, 0 x, 0 x );
$ Size = strlen ($ Contents );
$ Crc = crc32 ($ Contents );
$ Contents = gzcompress ($ Contents );
$ Contents = substr ($ Contents, 0, strlen ($ Contents)-4 );
Print $ Contents;
Print pack ('v', $ Crc );
Print pack ('v', $ Size );
Exit;
} Else {
Ob_end_flush ();
$ Error_Msg = str_replace ('
', '', GetHeader ());
$ Error_Msg. = 'time: '. date ('Y-m-d H: I: s'). 'n ';
$ Error_Msg. = 'remote-Address: '. $ REMOTE_ADDR. 'n ';
// Mail ('your @ none.net ', 'user can not use gzip output in file $ PHP_SELF !!! ', $ Error_Msg );
Exit;
}
}
?>