Use php zlib to compress and decompress the swf file. The following example shows how to compress and compress a swf File. if the swf file is not compressed, the first byte of the file is F or C to compress the swf file. The following is an example of my compress and compress the swf file:
// If the swf file is not compressed, the first byte of the file is F or C.
Compress the swf file: // file name
$ Filename = "test.swf ";
// Open the file
$ Rs = fopen ($ filename, "r ");
// Read the file data
$ Str = fread ($ rs, filesize ($ filename ));
// Set the swf header file
$ Head = substr ($ str, 1, 8 );
$ Head = "C". $ head;
// Obtain the swf file content
$ Body = substr ($ str, 8 );
// Compress the file content with a maximum compression level of 9
$ Body = gzcompress ($ body, 9 );
// Merge the file header and content
$ Str = $ head. $ body;
// Close the read File Stream
Fclose ($ rs );
// Create a new file
$ Ws = fopen ("create.swf", "w ");
// Write an object
Fwrite ($ ws, $ str );
// Close File retention
Fclose ($ ws );
// ------ Http://soft.knowsky.com/Workshop /----------------------------------------------------------------------------------------------
?>
Decompress the swf file:
// Configure //----------------------------------------------------------------------------------------------------
// File name
$ Filename = "test.swf ";
// Open the file
$ Rs = fopen ($ filename, "r ");
// Read the file data
$ Str = fread ($ rs, filesize ($ filename ));
// Set the swf header file
$ Head = substr ($ str, 1, 8 );
$ Head = "F". $ head;
// Obtain the swf file content
$ Body = substr ($ str, 8 );
// Decompress the file content
$ Body = gzuncompress ($ body );
// Merge the file header and content
$ Str = $ head. $ body;
// Close the read File Stream
Fclose ($ rs );
// Create a new file
$ Ws = fopen ("create.swf", "w ");
// Write an object
Fwrite ($ ws, $ str );
// Close File retention
Fclose ($ ws );
// Configure //----------------------------------------------------------------------------------------------------
?>
Else // if the swf file is not compressed, you can determine whether to compress the swf file based on the first byte of the file F or C...