<?php  
//文件名
$filename = "test.swf";
//打开文件
$rs = fopen($filename,"r");
//读取文件的数据
$str = fread($rs,filesize($filename));
//check compress status
$check = substr($str,0,1);
if($check=="C")
{
	echo "这是一个压缩文件,下面解压";
//设置swf头文件
$head = substr($str,1,7);
$head = "F".$head;
//获取swf文件内容
$body = substr($str,8);
//解压缩文件内容
$body = gzuncompress($body);
//合并文件头和内容
$str = $head.$body;
//关闭读取的文件流
fclose($rs);
//创建一个新的文件
$ws = fopen("jieya.swf","w");
//写文件
fwrite($ws,$str);
}else if($check=="F")
{
	echo "这是一个没有压缩的文件,下面开始压缩";
	$head = substr($str,1,7);
$head = "C".$head; 
$body = substr($str,8); 
$body = gzcompress($body, 9);  
$str = $head.$body; 
fclose($rs);  
$ws = fopen("yasuo.swf","w");  
fwrite($ws,$str);  
}else
{
  echo "这不是一个合法的flash文件";
}
//关闭文件
fclose($ws);
?>