PageRenderTime 51ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/lib/VideoUrlParser.php

https://github.com/GavinFoo/AniHere
PHP | 571 lines | 437 code | 31 blank | 103 comment | 21 complexity | c9c4c1ee003713ff8f5865283645bd09 MD5 | raw file
  1. <?php
  2. /**
  3. * Video
  4. *
  5. * @package
  6. * @version 1.2
  7. * @copyright 2005-2011 HDJ.ME
  8. * @author Dijia Huang <huangdijia@gmail.com>
  9. * @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
  10. *
  11. * Usage
  12. * require_once "VideoUrlParser.class.php";
  13. * $urls[] = "http://v.youku.com/v_show/id_XMjI4MDM4NDc2.html";
  14. * $urls[] = "http://www.tudou.com/playlist/p/l13087099.html";
  15. * $urls[] = "http://www.tudou.com/programs/view/ufg-A3tlcxk/";
  16. * $urls[] = "http://v.ku6.com/special/show_4926690/Klze2mhMeSK6g05X.html";
  17. * $urls[] = "http://www.56.com/u68/v_NjI2NTkxMzc.html";
  18. * $urls[] = "http://www.letv.com/ptv/vplay/1168109.html";
  19. * $urls[] = "http://video.sina.com.cn/v/b/46909166-1290055681.html";
  20. *
  21. * foreach($urls as $url){
  22. * $info = VideoUrlParser::parse($url);
  23. * //var_dump($info);
  24. * echo "<a href='{$info['url']}' target='_new'>{$info['title']}</a>";
  25. * echo "<br />";
  26. * echo $info['object'];
  27. * echo "<br />";
  28. * }
  29. *
  30. *
  31. *
  32. * //优酷
  33. * http://v.youku.com/v_show/id_XMjU0NjY4OTEy.html
  34. * <embed src="http://player.youku.com/player.php/sid/XMjU0NjY4OTEy/v.swf" quality="high" width="480" height="400" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"></embed>
  35. *
  36. * //酷六
  37. * http://v.ku6.com/special/show_3917484/x0BMXAbgZdQS6FqN.html
  38. * <embed src="http://player.ku6.com/refer/x0BMXAbgZdQS6FqN/v.swf" quality="high" width="480" height="400" align="middle" allowScriptAccess="always" allowfullscreen="true" type="application/x-shockwave-flash"></embed>
  39. *
  40. * //土豆
  41. * http://www.tudou.com/playlist/p/a65929.html?iid=74905844
  42. * <embed src="http://www.tudou.com/l/A_0urj-Geec/&iid=74905844/v.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="opaque" width="480" height="400"></embed>
  43. *
  44. * //56
  45. * http://www.56.com/u98/v_NTkyODY2NTU.html
  46. * <embed src="http://player.56.com/v_NTkyODY2NTU.swf" type="application/x-shockwave-flash" width="480" height="405" allowNetworking="all" allowScriptAccess="always"></embed>
  47. *
  48. * //新浪播客
  49. * http://video.sina.com.cn/v/b/46909166-1290055681.html
  50. * <embed src="http://you.video.sina.com.cn/api/sinawebApi/outplayrefer.php/vid=46909166_1290055681_b0K1GHEwDWbK+l1lHz2stqkP7KQNt6nki2O0u1ehIwZYQ0/XM5GdZNQH6SjQBtkEqDhAQJ42dfcn0Rs/s.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="ssss" allowFullScreen="true" allowScriptAccess="always" width="480" height="370"></embed>
  51. *
  52. * //乐视
  53. * http://www.letv.com/ptv/vplay/1168109.html
  54. * <embed src="http://i3.imgs.letv.com/player/swfPlayer.swf?id=1168109&host=app.letv.com&vstatus=1&AP=1&logoMask=0&isShowP2p=0&autoplay=true" quality="high" scale="NO_SCALE" wmode="opaque" bgcolor="#000000" width="480" height="388" name="FLV_player" align="middle" allowscriptaccess="always" allowfullscreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
  55. */
  56. class VideoUrlParser
  57. {
  58. const USER_AGENT = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko)
  59. Chrome/8.0.552.224 Safari/534.10";
  60. const CHECK_URL_VALID = "/(youku\.com|tudou\.com|ku6\.com|56\.com|letv\.com|video\.sina\.com\.cn|(my\.)?tv\.sohu\.com|v\.qq\.com)/";
  61. /**
  62. * parse
  63. *
  64. * @param string $url
  65. * @param mixed $createObject
  66. * @static
  67. * @access public
  68. * @return void
  69. */
  70. static public function parse($url='', $createObject=true){
  71. $lowerurl = strtolower($url);
  72. preg_match(self::CHECK_URL_VALID, $lowerurl, $matches);
  73. if(!$matches) return false;
  74. switch($matches[1]){
  75. case 'youku.com':
  76. $data = self::_parseYouku($url);
  77. break;
  78. case 'tudou.com':
  79. $data = self::_parseTudou($url);
  80. break;
  81. case 'ku6.com':
  82. $data = self::_parseKu6($url);
  83. break;
  84. case '56.com':
  85. $data = self::_parse56($url);
  86. break;
  87. case 'letv.com':
  88. $data = self::_parseLetv($url);
  89. break;
  90. case 'video.sina.com.cn':
  91. $data = self::_parseSina($url);
  92. break;
  93. case 'my.tv.sohu.com':
  94. case 'tv.sohu.com':
  95. case 'sohu.com':
  96. $data = self::_parseSohu($url);
  97. break;
  98. case 'v.qq.com':
  99. $data = self::_parseQq($url);
  100. break;
  101. default:
  102. $data = false;
  103. }
  104. if($data && $createObject) $data['object'] = "<embed src=\"{$data['swf']}\" wmode=\"opaque\" quality=\"high\" width=\"750\" height=\"443\" align=\"middle\" allowNetworking=\"all\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\"></embed>";
  105. return $data;
  106. }
  107. /**
  108. * 腾讯视频
  109. * http://v.qq.com/cover/o/o9tab7nuu0q3esh.html?vid=97abu74o4w3_0
  110. * http://v.qq.com/play/97abu74o4w3.html
  111. * http://v.qq.com/cover/d/dtdqyd8g7xvoj0o.html
  112. * http://v.qq.com/cover/d/dtdqyd8g7xvoj0o/9SfqULsrtSb.html
  113. * http://imgcache.qq.com/tencentvideo_v1/player/TencentPlayer.swf?_v=20110829&vid=97abu74o4w3&autoplay=1&list=2&showcfg=1&tpid=23&title=%E7%AC%AC%E4%B8%80%E7%8E%B0%E5%9C%BA&adplay=1&cid=o9tab7nuu0q3esh
  114. */
  115. private function _parseQq($url){
  116. if(preg_match("/\/play\//", $url)){
  117. $html = self::_fget($url);
  118. preg_match("/url=[^\"]+/", $html, $matches);
  119. if(!$matches); return false;
  120. $url = $matches[0];
  121. }
  122. preg_match("/vid=([^\_]+)/", $url, $matches);
  123. $vid = $matches[1];
  124. $html = self::_fget($url);
  125. // query
  126. preg_match("/flashvars\s=\s\"([^;]+)/s", $html, $matches);
  127. $query = $matches[1];
  128. if(!$vid){
  129. preg_match("/vid\s?=\s?vid\s?\|\|\s?\"(\w+)\";/i", $html, $matches);
  130. $vid = $matches[1];
  131. }
  132. $query = str_replace('"+vid+"', $vid, $query);
  133. parse_str($query, $output);
  134. $data['img'] = "http://vpic.video.qq.com/{$$output['cid']}/{$vid}_1.jpg";
  135. $data['url'] = $url;
  136. $data['title'] = $output['title'];
  137. $data['swf'] = "http://imgcache.qq.com/tencentvideo_v1/player/TencentPlayer.swf?".$query;
  138. return $data;
  139. }
  140. /**
  141. * 优酷网
  142. * http://v.youku.com/v_show/id_XMjI4MDM4NDc2.html
  143. * http://player.youku.com/player.php/sid/XMjU0NjI2Njg4/v.swf
  144. */
  145. private function _parseYouku($url){
  146. preg_match("#id\_(\w+)#", $url, $matches);
  147. if (empty($matches)){
  148. preg_match("#v_playlist\/#", $url, $mat);
  149. if(!$mat) return false;
  150. $html = self::_fget($url);
  151. preg_match("#videoId2\s*=\s*\'(\w+)\'#", $html, $matches);
  152. if(!$matches) return false;
  153. }
  154. $link = "http://v.youku.com/player/getPlayList/VideoIDS/{$matches[1]}/timezone/+08/version/5/source/out?password=&ran=2513&n=3";
  155. $retval = self::_cget($link);
  156. if ($retval) {
  157. $json = json_decode($retval, true);
  158. $data['img'] = $json['data'][0]['logo'];
  159. $data['title'] = $json['data'][0]['title'];
  160. $data['url'] = $url;
  161. $data['swf'] = "http://player.youku.com/player.php/sid/{$matches[1]}/v.swf";
  162. return $data;
  163. } else {
  164. return false;
  165. }
  166. }
  167. /**
  168. * 土豆网
  169. * http://www.tudou.com/programs/view/Wtt3FjiDxEE/
  170. * http://www.tudou.com/v/Wtt3FjiDxEE/v.swf
  171. *
  172. * http://www.tudou.com/playlist/p/a65718.html?iid=74909603
  173. * http://www.tudou.com/l/G5BzgI4lAb8/&iid=74909603/v.swf
  174. */
  175. private function _parseTudou($url){
  176. preg_match("#view/([-\w]+)/#", $url, $matches);
  177. if (empty($matches)) {
  178. if (strpos($url, "/playlist/") == false && strpos($url, "/listplay/") == false) return false;
  179. if(strpos($url, 'iid=') !== false){
  180. $quarr = explode("iid=", $lowerurl);
  181. if (empty($quarr[1])) return false;
  182. }elseif(preg_match("#p\/l(\d+).#", $lowerurl, $quarr)){
  183. if (empty($quarr[1])) return false;
  184. }
  185. $html = self::_fget($url);
  186. $html = iconv("GB2312", "UTF-8", $html);
  187. preg_match("/lid_code\s=\slcode\s=\s[\'\"]([^\'\"]+)/s", $html, $matches);
  188. $icode = $matches[1];
  189. preg_match("/iid\s=\s.*?\|\|\s(\d+)/sx", $html, $matches);
  190. $iid = $matches[1];
  191. preg_match("/listData\s=\s(\[\{.*\}\])/sx", $html, $matches);
  192. $find = array("/\n/", '/\s/', "/:[^\d\"]\w+[^\,]*,/i", "/(\{|,)(\w+):/");
  193. $replace = array("", "", ':"",', '\\1"\\2":');
  194. $str = preg_replace($find, $replace, $matches[1]);
  195. //var_dump($str);
  196. $json = json_decode($str);
  197. //var_dump($json);exit;
  198. if(is_array($json) || is_object($json) && !empty($json)){
  199. foreach ($json as $val) {
  200. if ($val->iid == $iid) {
  201. break;
  202. }
  203. }
  204. }
  205. $data['img'] = $val->pic;
  206. $data['title'] = $val->title;
  207. $data['url'] = $url;
  208. $data['swf'] = "http://www.tudou.com/l/{$icode}/&iid={$iid}/v.swf";
  209. return $data;
  210. }
  211. $host = "www.tudou.com";
  212. $path = "/v/{$matches[1]}/v.swf";
  213. $ret = self::_fsget($path, $host);
  214. if (preg_match("#\nLocation: (.*)\n#", $ret, $mat)) {
  215. parse_str(parse_url(urldecode($mat[1]), PHP_URL_QUERY));
  216. $data['img'] = $snap_pic;
  217. $data['title'] = $title;
  218. $data['url'] = $url;
  219. $data['swf'] = "http://www.tudou.com/v/{$matches[1]}/v.swf";
  220. return $data;
  221. }
  222. return false;
  223. }
  224. /**
  225. * 酷6网
  226. * http://v.ku6.com/film/show_520/3X93vo4tIS7uotHg.html
  227. * http://v.ku6.com/special/show_4926690/Klze2mhMeSK6g05X.html
  228. * http://v.ku6.com/show/7US-kDXjyKyIInDevhpwHg...html
  229. * http://player.ku6.com/refer/3X93vo4tIS7uotHg/v.swf
  230. */
  231. private function _parseKu6($url){
  232. if(preg_match("/show\_/", $url)){
  233. preg_match("#/([\w\.]*?)\.html#", $url, $matches);
  234. var_dump($matches);
  235. $url = "http://v.ku6.com/fetchVideo4Player/{$matches[1]}.html";
  236. $html = self::_fget($url);
  237. if ($html) {
  238. $json = json_decode($html, true);
  239. if(!$json) return false;
  240. $data['img'] = $json['data']['picpath'];
  241. $data['title'] = $json['data']['t'];
  242. $data['url'] = $url;
  243. $data['swf'] = "http://player.ku6.com/refer/{$matches[1]}/v.swf";
  244. return $data;
  245. } else {
  246. return false;
  247. }
  248. }elseif(preg_match("/show\//", $url, $matches)){
  249. $html = self::_fget($url);
  250. preg_match("/ObjectInfo\s?=\s?([^\n]*)};/si", $html, $matches);
  251. $str = $matches[1];
  252. // img
  253. preg_match("/cover\s?:\s?\"([^\"]+)\"/", $str, $matches);
  254. $data['img'] = $matches[1];
  255. // title
  256. preg_match("/title\"?\s?:\s?\"([^\"]+)\"/", $str, $matches);
  257. $jsstr = "{\"title\":\"{$matches[1]}\"}";
  258. $json = json_decode($jsstr, true);
  259. $data['title'] = $json['title'];
  260. // url
  261. $data['url'] = $url;
  262. // query
  263. preg_match("/\"(vid=[^\"]+)\"\sname=\"flashVars\"/s", $html, $matches);
  264. $query = str_replace("&amp;", '&', $matches[1]);
  265. preg_match("/\/\/player\.ku6cdn\.com[^\"\']+/", $html, $matches);
  266. $data['swf'] = 'http:'.$matches[0].'?'.$query;
  267. return $data;
  268. }
  269. }
  270. /**
  271. * 56网
  272. * http://www.56.com/u73/v_NTkzMDcwNDY.html
  273. * http://player.56.com/v_NTkzMDcwNDY.swf
  274. */
  275. private function _parse56($url){
  276. preg_match("#/v_(\w+)\.html#", $url, $matches);
  277. if (empty($matches)) return false;
  278. $link="http://vxml.56.com/json/{$matches[1]}/?src=out";
  279. $retval = self::_cget($link);
  280. if ($retval) {
  281. $json = json_decode($retval, true);
  282. $data['img'] = $json['info']['bimg'];
  283. $data['title'] = $json['info']['Subject'];
  284. $data['url'] = $url;
  285. $data['swf'] = "http://player.56.com/v_{$matches[1]}.swf";
  286. return $data;
  287. } else {
  288. return false;
  289. }
  290. }
  291. /**
  292. * 乐视网
  293. * http://www.letv.com/ptv/vplay/1168109.html
  294. * http://www.letv.com/player/x1168109.swf
  295. */
  296. private function _parseLetv($url){
  297. $html = self::_fget($url);
  298. preg_match("#http://v.t.sina.com.cn/([^'\"]*)#", $html, $matches);
  299. parse_str(parse_url(urldecode($matches[0]), PHP_URL_QUERY));
  300. preg_match("#vplay/(\d+)#", $url, $matches);
  301. $data['img'] = $pic;
  302. $data['title'] = $title;
  303. $data['url'] = $url;
  304. $data['swf'] = "http://www.letv.com/player/x{$matches[1]}.swf";
  305. return $data;
  306. }
  307. // 搜狐TV http://my.tv.sohu.com/u/vw/5101536
  308. private function _parseSohu($url){
  309. $html = self::_fget($url);
  310. $html = iconv("GB2312", "UTF-8", $html);
  311. preg_match_all("/og:(?:title|image|videosrc)\"\scontent=\"([^\"]+)\"/s", $html, $matches);
  312. $data['img'] = $matches[1][1];
  313. $data['title'] = $matches[1][0];
  314. $data['url'] = $url;
  315. $data['swf'] = $matches[1][2];
  316. return $data;
  317. }
  318. /*
  319. * 新浪播客
  320. * http://video.sina.com.cn/v/b/48717043-1290055681.html
  321. * http://you.video.sina.com.cn/api/sinawebApi/outplayrefer.php/vid=48717043_1290055681_PUzkSndrDzXK+l1lHz2stqkP7KQNt6nki2O0u1ehIwZYQ0/XM5GdatoG5ynSA9kEqDhAQJA4dPkm0x4/s.swf
  322. */
  323. private function _parseSina($url){
  324. preg_match("/(\d+)(?:\-|\_)(\d+)/", $url, $matches);
  325. $url = "http://video.sina.com.cn/v/b/{$matches[1]}-{$matches[2]}.html";
  326. $html = self::_fget($url);
  327. preg_match("/video\s?:\s?([^<]+)}/", $html, $matches);
  328. $find = array("/\n/", "/\s*/", "/\'/", "/\{([^:,]+):/", "/,([^:]+):/", "/:[^\d\"]\w+[^\,]*,/i");
  329. $replace = array('', '', '"', '{"\\1":', ',"\\1":', ':"",');
  330. $str = preg_replace($find, $replace, $matches[1]);
  331. $arr = json_decode($str, true);
  332. $data['img'] = $arr['pic'];
  333. $data['title'] = $arr['title'];
  334. $data['url'] = $url;
  335. $data['swf'] = $arr['swfOutsideUrl'];
  336. return $data;
  337. }
  338. /*
  339. * 通过 file_get_contents 获取内容
  340. */
  341. private function _fget($url=''){
  342. if(!$url) return false;
  343. $html = file_get_contents($url);
  344. // 判断是否gzip压缩
  345. if($dehtml = self::_gzdecode($html))
  346. return $dehtml;
  347. else
  348. return $html;
  349. }
  350. /*
  351. * 通过 fsockopen 获取内容
  352. */
  353. private function _fsget($path='/', $host='', $user_agent=''){
  354. if(!$path || !$host) return false;
  355. $user_agent = $user_agent ? $user_agent : self::USER_AGENT;
  356. $out = <<<HEADER
  357. GET $path HTTP/1.1
  358. Host: $host
  359. User-Agent: $user_agent
  360. Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  361. Accept-Language: zh-cn,zh;q=0.5
  362. Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7\r\n\r\n
  363. HEADER;
  364. $fp = @fsockopen($host, 80, $errno, $errstr, 10);
  365. if (!$fp) return false;
  366. if(!fputs($fp, $out)) return false;
  367. while ( !feof($fp) ) {
  368. $html .= fgets($fp, 1024);
  369. }
  370. fclose($fp);
  371. // 判断是否gzip压缩
  372. if($dehtml = self::_gzdecode($html))
  373. return $dehtml;
  374. else
  375. return $html;
  376. }
  377. /*
  378. * 通过 curl 获取内容
  379. */
  380. private function _cget($url='', $user_agent=''){
  381. if(!$url) return;
  382. $user_agent = $user_agent ? $user_agent : self::USER_AGENT;
  383. $ch = curl_init();
  384. curl_setopt($ch, CURLOPT_URL, $url);
  385. curl_setopt($ch, CURLOPT_HEADER, 0);
  386. if(strlen($user_agent)) curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
  387. ob_start();
  388. curl_exec($ch);
  389. $html = ob_get_contents();
  390. ob_end_clean();
  391. if(curl_errno($ch)){
  392. curl_close($ch);
  393. return false;
  394. }
  395. curl_close($ch);
  396. if(!is_string($html) || !strlen($html)){
  397. return false;
  398. }
  399. return $html;
  400. // 判断是否gzip压缩
  401. if($dehtml = self::_gzdecode($html))
  402. return $dehtml;
  403. else
  404. return $html;
  405. }
  406. private function _gzdecode($data) {
  407. $len = strlen ( $data );
  408. if ($len < 18 || strcmp ( substr ( $data, 0, 2 ), "\x1f\x8b" )) {
  409. return null; // Not GZIP format (See RFC 1952)
  410. }
  411. $method = ord ( substr ( $data, 2, 1 ) ); // Compression method
  412. $flags = ord ( substr ( $data, 3, 1 ) ); // Flags
  413. if ($flags & 31 != $flags) {
  414. // Reserved bits are set -- NOT ALLOWED by RFC 1952
  415. return null;
  416. }
  417. // NOTE: $mtime may be negative (PHP integer limitations)
  418. $mtime = unpack ( "V", substr ( $data, 4, 4 ) );
  419. $mtime = $mtime [1];
  420. $xfl = substr ( $data, 8, 1 );
  421. $os = substr ( $data, 8, 1 );
  422. $headerlen = 10;
  423. $extralen = 0;
  424. $extra = "";
  425. if ($flags & 4) {
  426. // 2-byte length prefixed EXTRA data in header
  427. if ($len - $headerlen - 2 < 8) {
  428. return false; // Invalid format
  429. }
  430. $extralen = unpack ( "v", substr ( $data, 8, 2 ) );
  431. $extralen = $extralen [1];
  432. if ($len - $headerlen - 2 - $extralen < 8) {
  433. return false; // Invalid format
  434. }
  435. $extra = substr ( $data, 10, $extralen );
  436. $headerlen += 2 + $extralen;
  437. }
  438. $filenamelen = 0;
  439. $filename = "";
  440. if ($flags & 8) {
  441. // C-style string file NAME data in header
  442. if ($len - $headerlen - 1 < 8) {
  443. return false; // Invalid format
  444. }
  445. $filenamelen = strpos ( substr ( $data, 8 + $extralen ), chr ( 0 ) );
  446. if ($filenamelen === false || $len - $headerlen - $filenamelen - 1 < 8) {
  447. return false; // Invalid format
  448. }
  449. $filename = substr ( $data, $headerlen, $filenamelen );
  450. $headerlen += $filenamelen + 1;
  451. }
  452. $commentlen = 0;
  453. $comment = "";
  454. if ($flags & 16) {
  455. // C-style string COMMENT data in header
  456. if ($len - $headerlen - 1 < 8) {
  457. return false; // Invalid format
  458. }
  459. $commentlen = strpos ( substr ( $data, 8 + $extralen + $filenamelen ), chr ( 0 ) );
  460. if ($commentlen === false || $len - $headerlen - $commentlen - 1 < 8) {
  461. return false; // Invalid header format
  462. }
  463. $comment = substr ( $data, $headerlen, $commentlen );
  464. $headerlen += $commentlen + 1;
  465. }
  466. $headercrc = "";
  467. if ($flags & 1) {
  468. // 2-bytes (lowest order) of CRC32 on header present
  469. if ($len - $headerlen - 2 < 8) {
  470. return false; // Invalid format
  471. }
  472. $calccrc = crc32 ( substr ( $data, 0, $headerlen ) ) & 0xffff;
  473. $headercrc = unpack ( "v", substr ( $data, $headerlen, 2 ) );
  474. $headercrc = $headercrc [1];
  475. if ($headercrc != $calccrc) {
  476. return false; // Bad header CRC
  477. }
  478. $headerlen += 2;
  479. }
  480. // GZIP FOOTER - These be negative due to PHP's limitations
  481. $datacrc = unpack ( "V", substr ( $data, - 8, 4 ) );
  482. $datacrc = $datacrc [1];
  483. $isize = unpack ( "V", substr ( $data, - 4 ) );
  484. $isize = $isize [1];
  485. // Perform the decompression:
  486. $bodylen = $len - $headerlen - 8;
  487. if ($bodylen < 1) {
  488. // This should never happen - IMPLEMENTATION BUG!
  489. return null;
  490. }
  491. $body = substr ( $data, $headerlen, $bodylen );
  492. $data = "";
  493. if ($bodylen > 0) {
  494. switch ($method) {
  495. case 8 :
  496. // Currently the only supported compression method:
  497. $data = gzinflate ( $body );
  498. break;
  499. default :
  500. // Unknown compression method
  501. return false;
  502. }
  503. } else {
  504. //...
  505. }
  506. if ($isize != strlen ( $data ) || crc32 ( $data ) != $datacrc) {
  507. // Bad format! Length or CRC doesn't match!
  508. return false;
  509. }
  510. return $data;
  511. }
  512. }