其实php对gzip解压很简单,用内置的gzdecode函数就可以了,不过很可惜我配置了半天也无法支持gzdecode函数,所以只好变通一下: <div class="codetitle"><a style="CURSOR: pointer" data="72155" class="copybut" id="copybut72155" onclick="doCopy('code72155')"> 代码如下:<div class="codebody" id="code72155"> if(!function_exists('gzdecode')){ functiongzdecode($data){ $flags=ord(substr($data,3,1)); $headerlen=10; $extralen=0; $filenamelen=0; if($flags&4){ $extralen=unpack('v',substr($data,10,2)); $extralen=$extralen[1]; $headerlen+=2+$extralen; } if($flags&8)//Filename $headerlen=strpos($data,chr(0),$headerlen)+1; if($flags&16)//Comment $headerlen=strpos($data,$headerlen)+1; if($flags&2)//CRCatendoffile $headerlen+=2; $unpacked=@gzinflate(substr($data,$headerlen)); if($unpacked===FALSE) $unpacked=$data; return$unpacked; } } 调用方法很简单: <div class="codetitle"><a style="CURSOR: pointer" data="63869" class="copybut" id="copybut63869" onclick="doCopy('code63869')"> 代码如下:<div class="codebody" id="code63869"> $f=@file_get_contents("//www.52php.cn"); echogzdecode($f);
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|