The php tutorial reads the background color code for the High-width frames of flash files.
<? Php
/*
Example:
$ File = '/data/ad_files/5/5.swf ';
$ Flash = new flash ();
$ Flash = $ flash-> getswfinfo ($ file );
Echo"
The width and height of the file are: ". $ flash [" width "].": ". $ info [" height "];
Echo"
The file version is ". $ flash [" version "];
Echo"
The number of file frames is ". $ flash [" framecount "];
Echo"
The file frame rate is ". $ flash [" framerate "];
Echo"
The file background color is ". $ flash [" bgcolor "];
*/
Class flash
{
// Whether the background color is returned
Public $ need_back_color = false;
// Whether to return the version
Public $ need_version = false;
// Whether to return the Frame Rate
Public $ need_framerate = false;
// Whether to return the number of frames
Public $ need_framecount = false;
Public function _ construct ()
{
}
Public function getswfinfo ($ filename)
{
If (file_exists ($ filename )){
// Echo "file modification time:". date ("m d y h: I: s.", filemtime ($ filename ))."
";
} Else {
// Echo "the target file does not exist! ";
Return array ("error" => $ filename );
}
// Open the file
$ Rs = fopen ($ filename, "r ");
// Read the file data
$ Str = fread ($ rs, filesize ($ filename ));
///
If ($ str [0] = "f ")
{
// Echo"
The file is already decompressed :";
} Else {
$ First = substr ($ str, 0, 8 );
$ Last = substr ($ str, 8 );
//
$ Last = gzuncompress ($ last );
//
$ Str = $ first. $ last;
$ Str [0] = "f ";
// Echo"
Extracted file information :";
}
$ Info = $ this-> getinfo ($ str );
Fclose ($ rs );
Return $ info;
}
Private function mydecbin ($ str, $ index)
{
$ Fbin = decbin (ord ($ str [$ index]);
While (strlen ($ fbin) <8) $ fbin = "0". $ fbin;
Return $ fbin;
}
Private function colorhex ($ data)
{
$ Tmp = dechex ($ data );
If (strlen ($ tmp) <2 ){
$ Tmp = '0'. $ tmp;
}
Return $ tmp;
}
Private function getinfo ($ str)
{
// Convert to binary
$ Fbin = $ this-> mydecbin ($ str, 8 );
// Calculates the unit length of rec.
$ Slen = bindec (substr ($ fbin, 0, 5 ));
// Calculate the bytes of rec
$ Recsize = $ slen * 4 + 5;
$ Recsize = ceil ($ recsize/8 );
// Rec binary
$ Recbin = $ fbin;
For ($ I = 9; $ I <$ recsize + 8; $ I ++)
{
$ Recbin. = $ this-> mydecbin ($ str, $ I );
}
// Rec data
$ Rec = array ();
For ($ I = 0; $ I <4; $ I ++)
{
$ Rec [] = bindec (substr ($ recbin, 5 + $ I * $ slen, $ slen)/20;
}
If ($ this-> need_back_color ){
// Background color
For ($ I = $ recsize + 12; $ I <strlen ($ str); $ I ++)
{
If (ord ($ str [$ I]) = 67 & ord ($ str [$ I + 1]) = 2)
{
$ Bgcolor = $ this-> colorhex (ord ($ str [$ I + 2]). $ this-> colorhex (ord ($ str [$ I + 3]). $ this-> colorhex (ord ($ str [$ I + 4]);
Break;
}
}
}
If ($ this-> need_version ){
// Version
$ Version = ord ($ str [3]);
}
If ($ this-> need_framerate ){
// Frame Rate
$ Framerate = ord ($ str [$ recsize + 8])/256 + ord ($ str [$ recsize + 9]);
}
If ($ this-> need_framecount ){
// Number Of Frames
$ Framecount = ord ($ str [$ recsize + 11]) * 256 + ord ($ str [$ recsize + 10]);
}
Return array ("bgcolor" => $ bgcolor,
"Version" => $ version,
"Framerate" => $ framerate,
"Framecount" => $ framecount,
'Width' => $ rec [1],
'Height' => $ rec [3]
);
}
}
?>