"CWF indicates that the entire file after the first 8 bytes (that is, after the FileLength field) has been compressed using the open standard ZLIB. The data format used by the ZLIB library is described by Request for Comments (RFCs) documents 1950 to 1952." I see ! How to decompress it ?
$filename="C:/AA.SWF";
$imgsize=GetSWFSize($filename);
echo $imgsize[0]." X ".$imgsize[1];function GetSWFSize($filename)
{
DEFINE('SWFBUFSIZE', 20);
@set_magic_quotes_runtime(0);
$fd = fopen($filename, 'rb');
$a = fread($fd, SWFBUFSIZE);
fclose($fd);
@set_magic_quotes_runtime(get_magic_quotes_gpc());
$whinfo=sprintf("%02X",ord($a[9])).sprintf("%02X",ord($a[10])).sprintf("%02X",ord($a[11])).sprintf("%02X",ord($a[12])).sprintf("%02X",ord($a[13])).sprintf("%02X",ord($a[14])).sprintf("%02X",ord($a[15])).sprintf("%02X",ord($a[16])).sprintf("%02X",ord($a[17]));
switch (ord($a[8])) {
case 0x50:
$swfsize[0] = hexdec(substr($whinfo,0,4))/10;
$swfsize[1] = hexdec(substr($whinfo,5,4))/10;
break;
case 0x58:
$swfsize[0] = hexdec(substr($whinfo,1,4))/40;
$swfsize[1] = hexdec(substr($whinfo,6,4))/10;
break;
case 0x60:
$swfsize[0] = hexdec(substr($whinfo,1,4))/10;
$swfsize[1] = hexdec(substr($whinfo,7,4))/10;
break;
case 0x68:
$swfsize[0] = hexdec(substr($whinfo,2,4))/40;
$swfsize[1] = hexdec(substr($whinfo,8,4))/10;
break;
case 0x70:
$swfsize[0] = hexdec(substr($whinfo,2,4))/10;
$swfsize[1] = hexdec(substr($whinfo,9,4))/10;
break;
case 0x78:
$swfsize[0] = hexdec(substr($whinfo,3,4))/40;
$swfsize[1] = hexdec(substr($whinfo,10,4))/10;
break;
case 0x80:
$swfsize[0] = hexdec(substr($whinfo,3,4))/10;
$swfsize[1] = hexdec(substr($whinfo,11,4))/10;
break;
case 0x88:
$swfsize[0] = hexdec(substr($whinfo,2,4))/40;
$swfsize[1] = hexdec(substr($whinfo,12,4))/10;
break;
}
return $swfsize;
}
?>
http://www.flash8.net/up/film/ds2003223181932.swf
http://download.macromedia.com/pub/flash/flash_file_format_specification.pdf:)愉快!
This class is Wolfgang Hamann's code
*/
class object {}
class swf
{ var $fh;
var $buffer;
var $bufbits;function swf($fname, $mode)
{ $this->fp = fopen($fname, $mode);
$this->buffer = 0;
$this->bufbits = 0;
}
function getc()
{ $buf = fread($this->fp, 1);
$this->buffer = ord($buf);
return $this->buffer;
}
function readnbits($n)
{ $ret = $this->buffer;
if($n == $this->bufbits)
{ $this->bufbits = 0;
$this->buffer = 0;
return $ret;
}
if($n > $this->bufbits)
{ $n -= $this->bufbits;
while($n > 8)
{ $ret <<= 8;
$ret += $this->getc();
$n -= 8;
}
$this->getc();
if($n > 0)
{ $ret <<= $n;
$this->bufbits = 8 - $n;
$ret += $this->buffer >> (8 - $n);
$this->buffer &= (1 << $this->bufbits)-1;
}
return $ret;
}
$ret = $this->buffer >> ($this->bufbits - $n);
$this->bufbits -= $n;
$this->buffer &= (1 << $this->bufbits)-1;
return $ret;
}
function bytealign()
{ $this->bufbits = 0;
$this->buffer = 0;
}
function readnSbits($n)
{ $res = $this->readnbits($n);
if($res & (1 << ($n-1)))
return $res - (1 << $n);
else
return $res;
}
function readheader()
{ $res = new object();
$buf = fread($this->fp, 3);
if($buf != "FWS") return null; //这里为什么只考虑了FWS标记???
$buf = fread($this->fp, 1);
$res->version = ord($buf);
$buf = fread($this->fp, 4);
$tmp = unpack("Vsize", $buf); $res->size = $tmp["size"];
$nbits = $this->readnbits(5);
$xl = $this->readnSbits($nbits); $xr = $this->readnSbits($nbits);
$yl = $this->readnSbits($nbits); $yr = $this->readnSbits($nbits);
$res->width = $xr - $xl;
$res->height = $yr - $yl;
$tmplen = ftell($this->fp)-8;
fseek($this->fp, 8);
$rect = fread($this->fp, $tmplen);
$res->rect = $rect;
$buf = fread($this->fp, 4);
$tmp = unpack("vrate/vframes", $buf);
$res->rate = $tmp["rate"];
$res->frames = $tmp["frames"];
return $res;
}
function readtag()
{ $this->bufbits = 0;
$this->buffer = 0;
$res = new object();
$buf = fread($this->fp, 2);
$res->tag = $buf;
$tmp = unpack("vx", $buf);
$val = $tmp["x"];
$res->typ = $val >> 6;
$res->nbytes = $val & 63;
if($res->nbytes == 63)
{ $buf = fread($this->fp, 4);
$res->tag .= $buf;
$tmp = unpack("Vx", $buf);
$res->nbytes = $tmp["x"];
}
return $res;
}
//function writeheader($hdr)
//{ $str = "FWS" . chr($hdr->version) . pack("V", $hdr->size) . $hdr->rect . pack("vv", $hdr->rate, $hdr->frames);
//fputs($this->fp, $str);
//}
//function puttag($typ, $nbytes)
//{ $val = $tag << 6;
//if($nbytes >= 63)
//{ $val += 63;
//fputs($this->fp, pack("vV", $val, $nbytes));
//}
//else
//{ $val += $nbytes;
//fputs($this->fp, pack("v", $val));
//}
//}
}// Function for better data returning
// Created by Armel GRIGNON - october, 30 2001
function get_swf_info($file) {
$ret = array();
$swf = new swf($file, "r");
$hdr = $swf->readheader();
foreach ($hdr as $var => $val) {
$ret[$var] = $val;
}
$ret[width]=$ret[width]/20;
$ret[height]=$ret[height]/20;
$ret[rate]=$ret[rate]/256;
return $ret;
}请多多指教!!在次感谢!!
I see !
How to decompress it ?
用gzinflate($str)或gzuncompress($str)函数,老出错....
是否必须要求$str的长度正好是一段zlib压缩数据块??