种子文件下载后是forum(1).php,手机通过网页下载BT种子到路由器优盘 (Transmission的一个小方案 )...

date_default_timezone_set('Asia/Shanghai');

header('Content-type: text/html; charset=utf-8');

define('CACHE', "cache/");

if(!file_exists(CACHE))mkdir(CACHE,0777);

echo '

body{background:#f9f9f9;}

body,ul,li{margin:0;padding:0;list-style-type:none;}

li{position:relative;padding:.7em 15px;border-bottom:1px solid #ccc;background-image:linear-gradient(#fff,#eee)}

li a{font-size:1rem;color:#2f3e46;text-decoration:none;}

li:after{position:absolute;right:3px;top:1rem;font-size:1rem;content:">";display:inline-block;width:20px;height:20px;line-height:20px;text-align:center;background:#222;color:#ddd;border-radius:50%;}

div{padding:20px;background-image:linear-gradient(#f9f9f9,#eee);word-wrap:break-word ;}

';

btbtt();

function btbtt(){

$domain="http://www.btbtt.net/";

if($torrent=get("torrent")){

$url=$domain.$torrent;

$html=read($url);

$name=md5($url).'.torrent';

if(stripos($_SERVER['HTTP_HOST'],':81')!==false)$folder='/mnt/transmission/watch/';

else $folder='';

file_put_contents($folder.$name,$html);

echo '


导入种子 ok
';

exit();

}elseif($page=get("page")){

$html=read($domain.$page);

$A=dom($html);

echo "

网址: ".$domain.$page."
内容:";

//主题内容提取

$html=substring($html,'post_td','');

$html=preg_replace("/]*>/s","\n",$html);

$html=str_replace(array("

","\r",'" valign="top">'),"\n",$html);

$html=strip_tags($html,'');

$html=preg_replace("/\n\s+|BAIDU_CLB_SLOT_ID = "\d+";|\-\-\>|\#1楼/s","\n",$html);

$html=preg_replace("/\n+/s","
",$html);

$html=str_replace("网盘下载:","网盘下载:",$html);

echo $html."

";

foreach($A as $r){

$url=$r['url'];

if(stripos($url,'attach-dialog')!==false){

$downurl=str_replace("dialog",'download',$url);

$file=CACHE.md5(strtolower($domain.$downurl));

$tishi=file_exists($file)?'你已经导入过,再次':'';

echo "

".$tishi."点击这里导入种子: ".$r['html']."";

}

}

exit();

}

//列表页

$page=get("pid");

if($page<1)$page=1;

$html=read($domain."forum-index-fid-951-page-".$page.".htm",36000);

$A=dom($html);

echo "

  • ";

foreach($A as $r){

$url=$r['url'];

if(stripos($url,'thread-index-fid-')===false

|| stripos($url,'fid-2-')!==false

|| strlen($r['html'])<10

|| stripos($r['css'],'thread-digest')!==false

)continue;

echo '

'.$r['title']."";

}

echo "

";

for($i=1;$i<=10;$i++)echo "P".$i." - ";

echo "

";

}

function curl($url){

$curl = curl_init();

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($curl, CURLOPT_URL, $url);

curl_setopt($curl, CURLOPT_HEADER, 0);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$data = curl_exec($curl);

curl_close($curl);

if(strlen($data)<3000)die("cURL - Error - ".$url);

return $data;

}

function read($url,$timeout=8640000){

$file=CACHE.md5(strtolower($url));

if(file_exists($file) && $timeout){

if((time()-filemtime($file))

return file_get_contents($file);

exit();

}

}

$html=curl($url);

file_put_contents($file,$html);

return $html;

}

function dom($html=''){

if(!$html)die("DOM Error");

$dom = new DOMdocument();

@$dom->loadHTML(''.$html);

$A=$dom->getElementsByTagName("a");

$lis=array();

foreach($A as $a){

$lis[]=array(

'url'=>$a->getAttribute("href"),

'title'=>$a->getAttribute("title"),

'html'=>$a->nodeValue,

'css'=>$a->getAttribute("class"),

);

}

return $lis;

}

function substring($msg,$a,$b,$c=0){

$i=$a==""?0:intval(stripos($msg,$a));

if($i<1)return "";

if($c<1)$i+=strlen($a);

$msg=substr($msg,$i);

$j=$b==""?strlen($msg):stripos($msg,$b);

$msg=substr($msg,0,$j);

return $msg;

}

function get($k){

$str=isset($_GET[$k])?$_GET[$k]:"";

if(stripos($k,'id')!==false)$str=intval($str);

$str=str_replace(array('"',"'",'?','',"\r","\n","\"),'',$str);

return trim($str);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值