Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
首页安装后状态提示完善 #76 #81
Browse files Browse the repository at this point in the history
账号拉黑提示 #83 #84 #86
兼容老方法获取randsk(BDCLND) #84
根页面获取失败提示完善
安装页面未处理默认情况丢失前缀 #76
修复aria2文件名问题 #78 Thanks to kwxiaozhu
  • Loading branch information
yuantuo666 committed Mar 14, 2021
1 parent fd582b6 commit b96a76e
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 24 deletions.
4 changes: 2 additions & 2 deletions api.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @link https://space.bilibili.com/88197958
*
*/
$programVersion_API = '2.1.0';
$programVersion_API = '2.1.3';
session_start();
define('init', true);
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
Expand Down Expand Up @@ -256,7 +256,7 @@
"sviptips" => $SvipTips
));
} else {
EchoInfo(-1, array("msg" => "数据库中没有数据", "sviptips" => "Unknown"));
EchoInfo(-1, array("msg" => "数据库中没有状态数据,请解析一次大于50MB文件以刷新账号状态", "sviptips" => "Unknown"));//防止产生误解,把提示写完全
}
} else {
// 未开启数据库
Expand Down
44 changes: 36 additions & 8 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @link https://space.bilibili.com/88197958
*
*/
$programVersion_Functions = '2.1.0';
$programVersion_Functions = '2.1.3';
if (!defined('init')) { // 直接访问处理程序
header('Content-Type: text/plain; charset=utf-8');
if (!file_exists('config.php')) {
Expand Down Expand Up @@ -159,16 +159,26 @@ function getSign(string $surl, $randsk)
// 如果不修改这里,则要修改配置文件ini
$result = get($url, $header);
if (preg_match('/yunData.setData\((\{.*?\})\);/', $result, $matches)) {
$result = json_decode($matches[1], true, 512, JSON_BIGINT_AS_STRING);
$result_decode = json_decode($matches[1], true, 512, JSON_BIGINT_AS_STRING);
if (DEBUG) {
echo '<pre>getSign():';
var_dump($result);
var_dump($result_decode);
echo '</pre>';
}
return $result;
return $result_decode;
} else {
//有可能是账号被百度拉黑,导致获取到的页面不同 #83 #86
if (DEBUG) {
echo '<pre>getSign():no match</pre>';
var_dump(htmlspecialchars($result));
}

if (strstr($result, "neglect:1") != false) {
dl_error("根目录yunData获取失败", "当前账号已经被百度拉入黑名单<br />无法正常获取文件名及文件内容,请联系站长更换config.php中普通账号的BDUSS和STOKEN<br />此错误出现与会员账号及后台设置无关");
exit;
} else {
dl_error("根目录yunData获取失败", "页面未正常加载,或者百度已经升级页面,无法正常获取根目录yunData数据。");
// exit;
}
return 1;
}
Expand Down Expand Up @@ -268,11 +278,29 @@ function get_BDCLND($surl, $Pwd)
return $bdclnd;
} else {
if (DEBUG) {
echo '<pre>get_BDCLND():';
var_dump($header);
echo '<pre>【获取bdclnd失败,可能是不需要此参数】get_BDCLND():';
var_dump($result);
echo '</pre>';
}
return '';
echo '<script>Swal.fire("使用提示","检测到当前链接异常,保存到网盘重新分享后可获得更好的体验~","info");</script>';
// 尝试使用老方法获取
$header = head("https://pan.baidu.com/s/" . $surl, []);
$bdclnd = preg_match('/BDCLND=(.+?);/', $header, $matches);
if ($bdclnd) {
if (DEBUG) {
echo '<pre>【老版本方法】get_BDCLND():';
var_dump($matches[1]);
echo '</pre>';
}
return $matches[1];
} else {
if (DEBUG) {
echo '<pre>【老版本方法】get_BDCLND():';
var_dump($header);
echo '</pre>';
}
return '';
}
}
}
function connectdb(bool $isAPI = false)
Expand Down Expand Up @@ -305,7 +333,7 @@ function GetList(string $Shorturl, string $Dir, bool $IsRoot, string $Password)

$Root = ($IsRoot) ? "1" : "0";
$Dir = urlencode($Dir);
$Data = "shorturl=$Shorturl&dir=$Dir&root=$Root&pwd=$Password&page=1&num=2000&order=time";
$Data = "shorturl=$Shorturl&dir=$Dir&root=$Root&pwd=$Password&page=1&num=1000&order=time";
$header = array("User-Agent: netdisk", "Referer: https://pan.baidu.com/disk/home");
$result = json_decode(post($Url, $Data, $header), true);
if (DEBUG) {
Expand Down
10 changes: 5 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
*
* 此项目 GitHub 地址:https://github.com/yuantuo666/baiduwp-php
*
* @version 2.1.0
* @version 2.1.3
*
* @author Yuan_Tuo <yuantuo666@gmail.com>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
*
*/
$programVersion_Index = "2.1.0";
$programVersion_Index = "2.1.3";
session_start();
define('init', true);
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
Expand Down Expand Up @@ -160,7 +160,7 @@ function confirmdl(fs_id, timestamp, sign, randsk, share_id, uk, bdstoken, files
$pwd = (!empty($_POST["pwd"])) ? $_POST["pwd"] : "";
$dir = (!empty($_POST["dir"])) ? $_POST["dir"] : "";
$IsRoot = ($dir == "") ? true : false;
$Filejson = GetList($surl, $dir, $IsRoot, $pwd); // 解析子目录时,需添加1
// $Filejson = GetList($surl, $dir, $IsRoot, $pwd); // 解析子目录时,需添加1
// if ($Filejson["errno"] == 0) { // 一种新的解析方法,暂未完工
// // 解析正常
// } else {
Expand Down Expand Up @@ -201,7 +201,7 @@ function confirmdl(fs_id, timestamp, sign, randsk, share_id, uk, bdstoken, files
$filecontent .= '<li class="breadcrumb-item"><a href="javascript:OpenDir(\'' . $fullsrc . '\',\'' . $pwd . '\',\'' . $shareid . '\',\'' . $uk . '\',\'' . $surl . '\',\'' . urlencode($randsk) . '\',\'' . $sign . '\',\'' . $timestamp . '\',\'' . $bdstoken . '\');">' . $dir_list[$i] . '</a></li>';
}
$filecontent .= '<li class="breadcrumb-item active">' . $dir_list[$i] . '</li>'
. '<li class="ml-auto">已全部加载,共' . count($filejson["list"]) . '</li></ol></nav>';
. '<li class="ml-auto">已加载' . count($filejson["list"]) . '个文件</li></ol></nav>';

$filecontent .= '<div><ul class="list-group">';
for ($i = 0; $i < count($filejson["list"]); $i++) { // 开始输出文件列表
Expand Down Expand Up @@ -247,7 +247,7 @@ function confirmdl(fs_id, timestamp, sign, randsk, share_id, uk, bdstoken, files
}
echo $filecontent . "</ul></div>";
}
} else dl_error("解析错误", "解析根页面时出错!\r\n可能原因:①提取码错误;②文件失效;③服务器未连接互联网;④服务器未安装curl(或其php插件);⑤服务器IP被百度封禁。");
} else dl_error("解析错误", "解析根页面时出错!<br />可能原因:①提取码错误文件失效:尝试保存到自己网盘后重新分享解析;<br />②服务器未连接互联网 或 IP被百度封禁:检查网络链接,尝试ping百度网站;<br />③服务器未安装curl(或其php插件);<br />④网络状况不好:稍后重试。<br /><br />如果以上问题排除后仍无法解决,可能是百度网盘升级了页面,请按下方提示操作:",true);
}
} elseif (isset($_GET["download"])) { // 解析下载地址页面
if (!CheckPassword(true)) {
Expand Down
17 changes: 15 additions & 2 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* 此项目 GitHub 地址:https://github.com/yuantuo666/baiduwp-php
*
* @version 2.1.0
* @version 2.1.3
*
* @author Yuan_Tuo <yuantuo666@gmail.com>
* @link https://imwcr.cn/
Expand Down Expand Up @@ -141,6 +141,13 @@ function getDbConfig(&$var, string $key)
getDbConfig($DBPassword, 'DBPassword');
getDbConfig($dbname, 'dbname');
getDbConfig($dbtable, 'dbtable');
} else {
//未处理默认情况 #76
$servername = "127.0.0.1";
$username = "";
$DBPassword = "";
$dbname = "";
$dbtable = "bdwp";
}
?>
<!-- 设置页面 -->
Expand Down Expand Up @@ -336,6 +343,7 @@ function getDbConfig(&$var, string $key)
<a href="javascript:CheckForm();" class="btn btn-primary">提交</a>
<small class="form-text">TIPS:1. 由于新版本可能更新了css和js文件,如果你的网站有缓存,请在清理后访问首页(一般CDN会提供此功能);如果浏览器存在缓存,请按下Ctrl+F5强制刷新,或进入设置页面删除缓存,否则可能遇到无法使用的问题。</small>
<small class="form-text">2. 你可以手动在当前目录下新建一个 notice.html 文件,当加载首页时会自动引用该文件。</small>
<small class="form-text">3. 如果点击此页面任何按钮都没有反应,可能是相关的JavaScript文件加载失败,刷新页面即可。</small>
<br><br>


Expand Down Expand Up @@ -437,6 +445,11 @@ function CheckMySQLConnect() {
dbname = $("input[name='DbConfig_dbname']").val();
dbtable = $("input[name='DbConfig_dbtable']").val();

if(dbtable==""){
Swal.fire("数据库表名前缀设置错误", "请检查你的数据库设置,数据库表名前缀不能为空!<br />你可以设置为bdwp或其他有效字符串。", "error");
return;
}

body = `servername=${servername}&username=${username}&DBPassword=${DBPassword}&dbname=${dbname}&dbtable=${dbtable}`;

postAPI('CheckMySQLConnect', body).then(function(response) {
Expand Down Expand Up @@ -600,4 +613,4 @@ function CheckForm() {

</body>

</html>
</html>
4 changes: 2 additions & 2 deletions install/config_raw
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* PanDownload 网页复刻版,PHP 语言版配置文件
* !!!请勿修改本文件,如果手动修改后再在后台设置,可能导致config.php文件被清空!!!
*
* @version 2.1.0
* @version 2.1.3
* @author Yuan_Tuo <yuantuo666@gmail.com>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
*/
const programVersion = '2.1.0';
const programVersion = '2.1.3';
if (!defined('init')) {
http_response_code(403); header('Content-Type: text/plain; charset=utf-8'); header('Refresh: 3;url=./');
die("HTTP 403 禁止访问!\r\n此文件是 PanDownload 网页复刻版 PHP 语言版项目版本 " . programVersion . " 的配置文件!\r\n禁止直接访问!");
Expand Down
2 changes: 1 addition & 1 deletion settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @link https://space.bilibili.com/88197958
*
*/
$programVersion_Settings = '2.1.0';
$programVersion_Settings = '2.1.3';
session_start();
define('init', true);
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
Expand Down
6 changes: 3 additions & 3 deletions static/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* 许多函数来源于github,详见项目里的Thanks
*
* @version 1.4.5
* @version 2.1.3
*
* @author Yuan_Tuo <yuantuo666@gmail.com>
* @link https://imwcr.cn/
Expand Down Expand Up @@ -144,7 +144,7 @@ async function addUri() {
id: 'baiduwp',
params: ['token:' + token]
})
post = JSON.stringify({ jsonrpc: '2.0', id: 'baiduwp', method: 'aria2.addUri', params: ["token:" + token, [httpurl, httpsurl], { header: headerOption ,out:filename}] })
post = JSON.stringify({ jsonrpc: '2.0', id: 'baiduwp', method: 'aria2.addUri', params: ["token:" + token, [httpurl, httpsurl], { header: headerOption, out: filename }] })//修复aria2文件名问题
}
else {
postVer = JSON.stringify({
Expand All @@ -153,7 +153,7 @@ async function addUri() {
id: 'baiduwp',
params: []
})
post = JSON.stringify({ jsonrpc: '2.0', id: 'baiduwp', method: 'aria2.addUri', params: [[httpurl, httpsurl], { header: headerOption ,out:filename}] })
post = JSON.stringify({ jsonrpc: '2.0', id: 'baiduwp', method: 'aria2.addUri', params: [[httpurl, httpsurl], { header: headerOption, out: filename }] })//修复aria2文件名问题
}
const getVer = await fetch(aria2url, {
body: postVer,
Expand Down
2 changes: 1 addition & 1 deletion usersettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @link https://space.bilibili.com/88197958
*
*/
$programVersion_UserSettings = '2.1.0';
$programVersion_UserSettings = '2.1.3';
if (!defined('init')) { // 直接访问处理程序
header('Content-Type: text/plain; charset=utf-8');
if (!file_exists('config.php')) {
Expand Down

0 comments on commit b96a76e

Please sign in to comment.