Skip to content

Commit

Permalink
Update index.php
Browse files Browse the repository at this point in the history
  • Loading branch information
5ime authored Aug 20, 2020
1 parent 686d9ea commit 870d831
Showing 1 changed file with 74 additions and 26 deletions.
100 changes: 74 additions & 26 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,46 @@
error_reporting(0);
$url = $_GET['url'];
$pwd = $_GET['pwd'];
if ($url != null) {
$error = curl($url);
if (strpos($error,'文件取消分享了') !== false) {
$Json = array(
"code" => 201,
"msg" => '文件取消分享了',
);
$Json = json_encode($Json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
echo stripslashes($Json);
return $Json;
}elseif ($url != null) {
if ($pwd == NULL) {
$b = 'com/';
$c = '/';
$id = GetBetween($url, $b, $c);
$d = 'https://www.lanzous.com/tp/' . $id;
$lanzouo = curl($d);
if (strpos($lanzouo,'输入密码') !== false) {
$Json = array(
"code" => 202,
"msg" => '请输入密码',
);
$Json = json_encode($Json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
echo stripslashes($Json);
return $Json;
}
preg_match_all("/<div class=\"md\">(.*?)<span class=\"mtt\">/", $lanzouo, $name);
preg_match_all('/时间:<\\/span>(.*?)<span class=\\"mt2\\">/', $lanzouo, $time);
preg_match_all('/发布者:<\\/span>(.*?)<span class=\\"mt2\\">/', $lanzouo, $author);
preg_match_all('/var domianloads = \'(.*?)\';/', $lanzouo, $down1);
preg_match_all('/var urlload = \'(.*?)\';/', $lanzouo, $down2);
preg_match_all('/<div class=\\"md\\">(.*?)<span class=\\"mtt\\">\\((.*?)\\)<\\/span><\\/div>/', $lanzouo, $size);
//var_dump($down2);
$download = getRedirect($down1[1][0] . $down2[1][0]);
$Json = array(
"code" => 200,
"data" => array(
"name" => $name[1][0],
"author" => $author[1][0],
"time" => $time[1][0],
"size" => $size[2][0],
"url" => $down1[1][0] . $down2[1][0]
"url" => $download
)
);
$Json = json_encode($Json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
Expand All @@ -50,15 +68,25 @@
preg_match_all('/sign\':\'(.*?)\'/', $lanzouo, $sign);
$post_data = array('action' => 'downprocess', 'sign' => $sign[1][0], 'p' => $pwd);
$pwdurl = send_post('https://wwa.lanzous.com/ajaxm.php', $post_data);
if(strpos($pwdurl,'"zt":0') !== false) {
$Json = array(
"code" => 202,
"msg" => '密码不正确',
);
$Json = json_encode($Json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
echo stripslashes($Json);
return $Json;
}
$obj = json_decode($pwdurl, true);
$download = getRedirect($obj['dom'] . '/file/' . $obj['url']);
$Json = array(
"code" => 200,
"data" => array(
"name" => $name[1][0],
"author" => $author[1][0],
"time" => $time[1][0],
"size" => $size[2][0],
"url" => $obj['dom'] . '/file/' . $obj['url']
"url" => $download
)
);
$Json = json_encode($Json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
Expand All @@ -80,28 +108,23 @@ function send_post($url, $post_data)
$result = file_get_contents($url, false, $context);
return $result;
}
function curl($url, $ua = 0)
{
$ch = curl_init();
$ip = rand(0, 255) . '.' . rand(0, 255) . '.' . rand(0, 255) . '.' . rand(0, 255);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$httpheader[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
$httpheader[] = "Accept-Encoding: gzip, deflate, sdch, br";
$httpheader[] = "Accept-Language: zh-CN,zh;q=0.8";
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
if ($ua) {
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
} else {
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25");
}
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_exec($ch);
curl_close($ch);
return $ret;

function curl($url){
$header[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
$header[] = "Accept-Encoding: gzip, deflate, sdch, br";
$header[] = "Accept-Language: zh-CN,zh;q=0.8";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); //设置传输的 url
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); //发送 http 报头
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"); //设置UA
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate'); // 解码压缩文件
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // 对认证证书来源的检查
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); // 从证书中检查SSL加密算法是否存在
curl_setopt($ch, CURLOPT_TIMEOUT, 5); // 设置超时限制防止死循环
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
function GetBetween($content, $start, $end)
{
Expand All @@ -112,3 +135,28 @@ function GetBetween($content, $start, $end)
}
return '';
}

function getRedirect($url,$ref=''){
$headers = array(
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Accept-Encoding: gzip, deflate',
'Accept-Language: zh-CN,zh;q=0.9',
'Cache-Control: no-cache',
'Connection: keep-alive',
'Pragma: no-cache',
'Upgrade-Insecure-Requests: 1',
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER,$headers);
if ($ref) {
curl_setopt($curl, CURLOPT_REFERER, $ref);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($curl);
$url=curl_getinfo($curl);
curl_close($curl);
return $url["redirect_url"];
}

0 comments on commit 870d831

Please sign in to comment.