菜鸡源码,专注精品下载!
当前位置:首页 > 建站教程 > 建站知识

PHP源码:123网盘直连解析下载

发布时间:2024-01-05  栏目:建站知识   浏览:   分类:php教程 123网盘 直连解析 解析下载

123网盘直连解析下载PHP源码是一种用于从123网盘直接下载文件的PHP代码。这种代码通常包括一个HTML页面和一个PHP脚本,用户可以通过访问HTML页面来输入要下载的文件的分享链接,然后PHP脚本会解析这个链接并直接从123网盘下载文件。这种方法可以绕过123网盘的下载限制,实现高速下载。但是,由于涉及到版权问题,使用这种方法可能会违反相关法律法规,因此不建议使用。此外,这种方法的安全性也无法得到保证,可能会导致用户的个人信息泄露。

一段123网盘直连解析下载源码,CSS样式都有,界面也很不错,复制到PHP环境即可运行。

<!DOCTYPEhtml><html><head><title>123解析</title><style>body{font-family:"HelveticaNeue",Arial,sans-serif;background-color:#f5f5f7;margin:0;padding:0;display:flex;align-items:center;justify-content:center;min-height:100vh;}.container{max-width:600px;padding:20px;box-sizing:border-box;text-align:center;}h1{font-size:32px;font-weight:bold;color:#333333;margin-bottom:40px;margin-top:40px;}form{margin-bottom:40px;}label{display:block;font-size:20px;font-weight:bold;color:#333333;margin-bottom:10px;}input[type="text"]{width:100%;padding:12px;font-size:16px;border:1pxsolid#cccccc;box-sizing:border-box;margin-bottom:20px;}input[type="submit"]{padding:12px24px;font-size:18px;font-weight:bold;color:#ffffff;background-color:#0070c9;border:none;cursor:pointer;}.download-link{margin-top:20px;display:flex;align-items:center;justify-content:center;}.error-icon{margin-right:10px;color:#ff0000;font-size:24px;}.success-icon{margin-right:10px;color:#009900;font-size:24px;}a{display:inline-block;padding:12px24px;font-size:18px;font-weight:bold;color:#ffffff;background-color:#0070c9;text-decoration:none;}a:hover{background-color:#0057a0;}</style></head><body><divclass="container"><h1>123解析</h1><formmethod="post"action=""><labelfor="shareUrl">分享链接:</label><inputtype="text"id="shareUrl"name="shareUrl"required><inputtype="submit"name="submit"value="解析"></form><?phpif(isset($_POST['submit'])&&isset($redirectUrl)):?><?phpendif;?><?phpif(isset($_POST['submit'])){$shareUrl=$_POST['shareUrl'];$shareCode="";$pattern="/(?<=\/s\/)[^\/.]+/";preg_match($pattern,$shareUrl,$match);if($match){$shareId=$match[0];$extractCodePattern="/提取码:(\w+)/";preg_match($extractCodePattern,$shareUrl,$extractCodeMatch);if($extractCodeMatch){$shareCode=$extractCodeMatch[1];}//GetuserinformationgetInfo($shareId,$shareCode);}else{echo'<spanclass="error-icon">✗</span>'."错误:123panURL未找到!";}}functiongetInfo($shareId,$shareCode){$requestUrl="https://www.123pan.com/b/api/share/get?limit=100&next=1&orderBy=share_id&orderDirection=desc&shareKey=".$shareId."&SharePwd=".$shareCode."&ParentFileId=0&Page=1";$opts=array('http'=>array('header'=>"User-Agent:Mozilla/5.0(WindowsNT6.1;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/109.0.0.0Safari/537.36Edg/109.0.1518.100\r\n"));$context=stream_context_create($opts);$responseText=file_get_contents($requestUrl,false,$context);parseInfo($responseText,$shareId);}functionparseInfo($str,$shareId){$data=json_decode($str,true);if($data['code']==0){$type=$data['data']['InfoList'][0]['Type'];if($type==0){$fileId=$data['data']['InfoList'][0]['FileId'];$size=$data['data']['InfoList'][0]['Size'];$s3KeyFlag=$data['data']['InfoList'][0]['S3KeyFlag'];$etag=$data['data']['InfoList'][0]['Etag'];//PerformsecondstepcombinedData($shareId,$fileId,$size,$s3KeyFlag,$etag);}else{echo"错误:Folderparsingiscurrentlynotsupported.";}}else{$code=$data['code'];$message=$data['message'];echo'<spanclass="error-icon">✗</span>'."错误:错误码".$code."//".$message;}}functioncombinedData($shareId,$fileId,$size,$s3KeyFlag,$etag){$requestUrl="https://www.123pan.com/b/api/share/download/info";$postData=json_encode(array("ShareKey"=>$shareId,"FileID"=>$fileId,"S3keyFlag"=>$s3KeyFlag,"Size"=>$size,"Etag"=>$etag));$opts=array('http'=>array('header'=>"User-Agent:Mozilla/5.0(WindowsNT6.1;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/109.0.0.0Safari/537.36Edg/109.0.1518.100\r\n"."Content-Type:application/json;charset=UTF-8\r\n",'method'=>'POST','content'=>$postData));$context=stream_context_create($opts);$response=file_get_contents($requestUrl,false,$context);parseDownloadURL($response);}functionparseDownloadURL($str){$data=json_decode($str,true);if($data['code']==0){$downloadURL=$data['data']['DownloadURL'];$downloadURL=extractDownloadLink($downloadURL);getDirectLink($downloadURL);}else{$code=$data['code'];$message=$data['message'];echo'<spanclass="error-icon">✗</span>'."错误:错误码".$code."//".$message;}}functionextractDownloadLink($str){$pattern="/params=([^&]+)/";preg_match($pattern,$str,$match);if($match){$paramsValue=$match[1];$decodedString=base64_decode($paramsValue);//Checkifauto_redirectparameterexistsif(strpos($decodedString,'auto_redirect')===false){if(strpos($decodedString,'?')!==false){$decodedString.="&auto_redirect=0";}else{$decodedString.="?auto_redirect=0";}}return$decodedString;}else{echo"FailedtoextractDownloadURL";}}functiongetDirectLink($requestUrl){$opts=array('http'=>array('header'=>"User-Agent:Mozilla/5.0(WindowsNT6.1;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/109.0.0.0Safari/537.36Edg/109.0.1518.100\r\n"));$context=stream_context_create($opts);$responseText=file_get_contents($requestUrl,false,$context);parseDirectLink($responseText);}functionparseDirectLink($str){$data=json_decode($str,true);if($data['code']==0){$redirectUrl=$data['data']['redirect_url'];echo'<spanclass="success-icon">✓</span><ahref="'.$redirectUrl.'">点击下载</a>';}else{$code=$data['code'];$message=$data['message'];echo'<spanclass="error-icon">✗</span>'."错误:错误码".$code."//".$message;}}?></div></body></html>
评论
建站知识
建站知识
使用技巧
调试安装
运营推广