This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ASLant
authored and
ASLant
committed
May 24, 2023
0 parents
commit b794186
Showing
4 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?php | ||
class d123pan{ | ||
private $UserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36'; | ||
protected $cachepath='cache/';//缓存目录 | ||
public $cache_time= 60;//缓存时间 0 为不缓存 | ||
public function getUrl($url,$pwd=''){ | ||
$return =array('status'=>0,'info'=>''); | ||
if(empty($url)){$return['info']= '请输入URL';return $return;} | ||
if($this->str_exists($url,'http')){ | ||
$urlarr = explode('/',str_replace('.html','',$url)); | ||
$shareKey = $urlarr[count($urlarr)-1]; | ||
}else{ | ||
$shareKey=$url; | ||
} | ||
if($this->cache_time>0){ | ||
$cachekey = $shareKey.$pwd; | ||
$cacheresult = $this->cache($cachekey); | ||
if($cacheresult && $cacheresult['expires_time']>time())return $cacheresult['data']; | ||
} | ||
if(empty($pwd)){ | ||
$url = 'https://www.123pan.com/s/'.$shareKey.'.html'; | ||
$softInfo = $this->curlget($url); | ||
preg_match("~window.g_initialProps(.*?)};~", $softInfo, $segment); | ||
$jsonstr = trim(trim($segment[1]),'=')."}"; | ||
$jsonarr = json_decode($jsonstr,1); | ||
if(empty($jsonarr)){$return['info']= '解析错误';return $return;} | ||
if($jsonarr['res']['data']['HasPwd']=='false'){$return['info']= '请输入提取码';return $return;} | ||
$softInfo = $jsonarr['reslist']; | ||
}else{ | ||
$url = 'https://www.123pan.com/b/api/share/get?limit=100&next=1&orderBy=share_id&orderDirection=desc&shareKey='.$shareKey.'&SharePwd='.$pwd.'&ParentFileId=0&Page=1'; | ||
$softInfo = json_decode($this->curlget($url),true); | ||
if($softInfo['code']>0){ | ||
$return['info']= $softInfo['message'];return $return; | ||
} | ||
} | ||
$url = 'https://www.123pan.com/b/api/share/download/info'; | ||
$info = $softInfo['data']['InfoList'][0]; | ||
$param=array( | ||
'Etag'=> $info['Etag'], | ||
'FileID'=> $info['FileId'], | ||
'S3keyFlag'=> $info['S3KeyFlag'], | ||
'ShareKey'=> $shareKey, | ||
'Size'=> $info['Size'], | ||
); | ||
$softInfo = json_decode($this->curlget($url,$param,'POST'),true); | ||
if($softInfo['code']>0){ | ||
$return['info']= $softInfo['message'];return $return; | ||
} | ||
$downUrl = $softInfo['data']['DownloadURL']; | ||
if(empty($downUrl)){$return['info']= '获取下载地址失败';return $return;} | ||
$return['status']=1; | ||
$return['info']=$downUrl; | ||
if($this->cache_time>0){ | ||
$cacheresult=array(); | ||
$cacheresult['data']=$return; | ||
$cacheresult['expires_time']=time()+$this->cache_time; | ||
$this->cache($cachekey,$cacheresult); | ||
} | ||
return $return; | ||
} | ||
public function cache($key,$value='',$time=''){ | ||
if(is_array($key))$key=md5(implode('',$key)); | ||
$filename=$this->cachepath.$key.'.cache'; | ||
if(empty($value)){ | ||
$data= @file_get_contents($filename);$this->clearcache(); | ||
return json_decode($data,1); | ||
}else{ | ||
if(!is_array($value))$value=array($value); | ||
file_put_contents($filename,json_encode($value)); | ||
} | ||
} | ||
//清空所有缓存 | ||
public function clearcache(){ | ||
$cachepath=$this->cachepath; | ||
$date=date('Y-m-d');$cachename='cachetime'.$date.'.c'; | ||
if(file_exists($cachepath.$cachename))return false; | ||
foreach(scandir($cachepath) as $fn) { | ||
if(strpos($cachename,'.c')>0)unlink($cachepath.$fn); | ||
}file_put_contents($cachepath.$cachename,'1'); | ||
return true; | ||
} | ||
/** | ||
* CURL发送HTTP请求 | ||
* @param string $url 请求URL | ||
* @param array $params 请求参数 | ||
* @param string $method 请求方法GET/POST | ||
* @param $header 头信息 | ||
* @param $multi 是否支付附件 | ||
* @param $debug 是否输出错误 | ||
* @param $optsother 附件项 | ||
* @return array $data 响应数据 | ||
*/ | ||
private function curlget($url, $params='', $method = 'GET', $header = array(), $UserAgent = false,$debug=false,$optsother='') { | ||
if(empty($UserAgent))$UserAgent=$this->UserAgent; | ||
$opts = array(CURLOPT_TIMEOUT => 10,CURLOPT_RETURNTRANSFER=> 1,CURLOPT_SSL_VERIFYPEER=> false,CURLOPT_SSL_VERIFYHOST=> false,CURLOPT_HTTPHEADER => $header,CURLOPT_USERAGENT=>$UserAgent); | ||
switch (strtoupper($method)) {/* 根据请求类型设置特定参数 */ | ||
case 'GET':$opts[CURLOPT_URL] = $params?$url.'?'.http_build_query($params):$url;break; | ||
case 'POST':$params = http_build_query($params);//判断是否传输文件 | ||
$opts[CURLOPT_URL] = $url;$opts[CURLOPT_POST] = 1;$opts[CURLOPT_POSTFIELDS] = $params;break; | ||
default:if($debug)echo ('不支持的请求方式!');break; | ||
}$ch = curl_init();if($optsother && is_array($optsother))$opts=$opts+$optsother;curl_setopt_array($ch, $opts);$data = curl_exec($ch);$error = curl_error($ch);curl_close($ch);/* 初始化并执行curl请求 */ | ||
if($error && $debug){echo ('请求发生错误:'.$error);} | ||
return $data; | ||
}//检测字符串中是否存在 | ||
private function str_exists($haystack, $needle){ | ||
return !(strpos(''.$haystack, ''.$needle) === FALSE); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# 123盘 | ||
|
||
#### 介绍 | ||
123盘直链带密码解析 下载地址解析API | ||
|
||
#### 软件架构 | ||
- 1.123盘直链带密码 | ||
- 2.支持带密码的文件分享链接但不支持分享的文件夹 | ||
- 3.支持生成直链或直接下载 | ||
- 4.支持缓存解析结果(一分钟) 提高解析速度,降低解析频率 | ||
- 5.支持自定义UserAgent | ||
|
||
|
||
#### 使用说明 | ||
|
||
url:123盘外链链接 | ||
|
||
type:是否直接下载 值:down | ||
|
||
pwd:外链密码 | ||
|
||
内部调用方法 | ||
``` | ||
include('D123pan.clsss.php'); | ||
$dp = new d123pan; | ||
//$dp->cache_time=60;//设置缓存时间 | ||
$res=$dp->getUrl($url,$pwd); | ||
``` | ||
直接下载: | ||
|
||
- 不带提取码: | ||
|
||
http://tool.bitefu.net/123pan/?url=https://www.123pan.com/s/poqA-CFWG3.html&type=down | ||
|
||
http://tool.bitefu.net/123pan/?url=poqA-CFWG3&type=down | ||
- 带提取码: | ||
|
||
http://tool.bitefu.net/123pan/?url=https://www.123pan.com/s/poqA-WFWG3.html&type=down&pwd=6cUF | ||
|
||
http://tool.bitefu.net/123pan/?url=poqA-WFWG3&type=down&pwd=6cUF | ||
|
||
输出直链: | ||
|
||
- 不带提取码: | ||
|
||
http://tool.bitefu.net/123pan/?url=https://www.123pan.com/s/poqA-WFWG3.html | ||
|
||
http://tool.bitefu.net/123pan/?url=poqA-WFWG3 | ||
|
||
- 带提取码: | ||
|
||
http://tool.bitefu.net/123pan/?url=https://www.123pan.com/s/poqA-WFWG3.html&pwd=6cUF | ||
|
||
http://tool.bitefu.net/123pan/?url=poqA-WFWG3&pwd=6cUF | ||
|
||
简网址 | ||
|
||
- 不带提取码:http://tool.bitefu.net/123pan/?d=poqA-CFWG3 | ||
|
||
- 带提取码:http://tool.bitefu.net/123pan/?d=poqA-WFWG3_6cUF | ||
|
||
|
||
#### 捐助我 | ||
|
||
捐助列表:http://tool.bitefu.net/pay/ | ||
|
||
<a href="http://tool.bitefu.net/pay/alipayred.jpg" target="_blank"><img height="300" src="https://oscimg.oschina.net/oscnet/69e93259cb3fa4f12a2c4e96dfc65984fb9.jpg" width="200" /></a> <a href="http://tool.bitefu.net/pay/wxpay.png" target="_blank"><img height="274" src="https://oscimg.oschina.net/oscnet/1118495c283edf13318ed999c1ad23c1614.jpg" width="200" /></a> <a href="http://tool.bitefu.net/pay/alipay.jpg" target="_blank"><img height="272" src="https://oscimg.oschina.net/oscnet/1adfcc1bdf40d6cf35bcc80f94678d52e98.jpg" width="200" /></a> | ||
|
||
#### 参与贡献 | ||
参考开源项目:https://gitee.com/web/lanzou |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
header('Access-Control-Allow-Origin:*');error_reporting("E_ALL");ini_set("display_errors", 1); | ||
|
||
$d = isset($_GET['d']) ? $_GET['d'] : ""; | ||
$url = isset($_GET['url']) ? $_GET['url'] : ""; | ||
$pwd = isset($_GET['pwd']) ? $_GET['pwd'] : ""; | ||
$type = isset($_GET['type']) ? $_GET['type'] : ""; | ||
include('D123pan.clsss.php'); | ||
if(!empty($d) && empty($url)){$arr = explode('_',$d);$url=$arr[0];$pwd=$arr[1];$type='down';} | ||
$dp = new d123pan; | ||
$res=$dp->getUrl($url,$pwd); | ||
if($res['status']==0)ajaxReturn($res); | ||
switch($type){ | ||
case "down": | ||
$urlarr = explode('?',$res['info']);parse_str($urlarr[1],$param_arr); | ||
$url = base64_decode($param_arr['params']); | ||
header("Location:".$url);die; | ||
break; | ||
default: | ||
header('Content-Type:application/json; charset=utf-8'); | ||
ajaxReturn($res); | ||
break; | ||
} | ||
|
||
function ajaxReturn($array){ | ||
$content=json_encode($array,JSON_UNESCAPED_UNICODE); | ||
if(empty($_GET['callback'])){ | ||
echo $content;exit; | ||
}else{ | ||
echo $_GET['callback']."(".$content.")";exit; | ||
} | ||
} | ||
?> |