资源描述:
《php读取torrent种子文件内容的方法(测试可用)_》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、php读取torrent种子文件内容的方法(测试可用)_这篇文章主要介绍了php读取torrent种子文件内容的方法,可实现读取并显示torrent种子文件内容的功能,简洁有用,需要的伴侣可以参考下?php/***ClassxBEncoder*Author:Angus.Fenying*Version:0.1*Date:2021-06-03**ThisclasshelpsstringifyorparseBENC*codes.**AllCopyrights2021-2021FenyingStudioReserved.*/classxBEncoder{constREADY=0;constREAD_
2、STR=1;constREAD_DICT=2;constREAD_LIST=3;constREAD_INT=4;constREAD_KEY=5;public$y;protected$z,$m,$n;protected$stat;protected$stack;/***Thismethodsavesthestatusofcurrent*encode/decodework.*/protectedfunctionpush($newY,$newStat){array_push($this-stack,array($this-y,$this-z,$this-m,$this-n,$this-stat))
3、;list($this-y,$this-z,$this-m,$this-n,$this-stat)=array($newY,0,0,0,$newStat);}/***Thismethodrestorethesavedstatusofcurrent*encode/decodework.*/protectedfunctionpop(){$t=array_pop($this-stack);if($t){if($t[4]==self::READ_DICT){$t[0]-{$t[1]}=$this-y;$t[1]=0;}elseif($t[4]==self::READ_LIST)$t[0][]=$th
4、is-y;list($this-y,$this-z,$this-m,$this-n,$this-stat)=$t;}}/***Thismethodinitializesthestatusofwork.*YOUSHOULDCALLTHISMETHODBEFOREEVERYTHING.*/publicfunctioninit(){$this-stat=self::READY;$this-stack=array();$this-z=$this-m=$this-n=0;}/***Thismethoddecode$s($laslength).*Youcanget$obj-yastheresult.*/
5、publicfunctiondecode($s,$l){$this-y=0;for($i=0;$i$l;++$i){switch($this-stat){caseself::READY:if($s[$i]=='d'){$this-y=newxBDict();$this-stat=self::READ_DICT;}elseif($s[$i]=='l'){$this-y=array();$this-stat=self::READ_LIST;}break;caseself::READ_INT:if($s[$i]=='e'){$this-y-val=substr($s,$this-m,$i-$thi
6、s-m);$this-pop();}break;caseself::READ_STR:if(xBInt::isNum($s[$i]))continue;if($s[$i]=':'){$this-z=substr($s,$this-m,$i-$this-m);$this-y=substr($s,$i+1,$this-z+0);$i+=$this-z;$this-pop();}break;caseself::READ_KEY:if(xBInt::isNum($s[$i]))continue;if($s[$i]=':'){$this-n=substr($s,$this-m,$i-$this-m);
7、$this-z=substr($s,$i+1,$this-n+0);$i+=$this-n;$this-stat=self::READ_DICT;}break;caseself::READ_DICT:if($s[$i]=='e'){$this-pop();break;}elseif(!$this-z){$this-m=$i;$this-stat=self::READ_KEY;break;}caseself::