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

Commit

Permalink
fix 3 bugs, improve 2 points
Browse files Browse the repository at this point in the history
fix detect limitted account; fix copy in unsecure site;
fix setting page svip check; improve translation;
improve error msg showing in settings
  • Loading branch information
yuantuo666 committed Apr 7, 2023
1 parent 8a0f6e2 commit b742faf
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 67 deletions.
2 changes: 1 addition & 1 deletion common/Parse.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public static function download($fs_id, $timestamp, $sign, $randsk, $share_id, $
$realLink = trim($realLink); // delete space

// 1. 使用 dlink 下载文件 2. dlink 有效期为8小时 3. 必需要设置 User-Agent 字段 4. dlink 存在 HTTP 302 跳转
if (!$realLink || strlen($realLink) < 20 || strstr($realLink, "//qdall01")) {
if (!$realLink || strlen($realLink) < 20 || strstr($realLink, "qdall01")) {
if ($id != "-1" && (SVIPSwitchMod === 1 || SVIPSwitchMod === 2)) {
//限速进行标记 并刷新页面重新解析
$sql = "UPDATE `{$dbtable}_svip` SET `state`= -1 WHERE `id`=$id";
Expand Down
86 changes: 43 additions & 43 deletions common/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
<div class="col-lg-6 col-md-9 mx-auto mb-5 input-card page" id="index" style="display: none;">
<div class="card">
<div class="card-header bg-dark text-light">
<text id="parsingtooltip" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-html="true" data-bs-title="请稍等,正在连接服务器查询信息"><?php echo Language["IndexTitle"]; ?></text>
<span style="float: right;" id="sviptooltip" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-html="true" data-bs-title="请稍等,正在连接服务器查询SVIP账号状态"><span class="point point-lg" id="svipstate-point"></span><span id="svipstate">Loading...</span></span>
<text id="parsingtooltip" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-html="true" data-bs-title="<?php t("Connecting") ?>"><?php t("IndexTitle") ?></text>
<span style="float: right;" id="sviptooltip" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-html="true" data-bs-title="<?php t("Connecting") ?>"><span class="point point-lg" id="svipstate-point"></span><span id="svipstate">Loading...</span></span>
</div>
<div class="card-body">
<div class="form-group my-2"><input type="text" class="form-control" name="surl" placeholder="<?php echo Language["ShareLink"]; ?>" oninput="Getpw()"></div>
<div class="form-group my-4"><input type="text" class="form-control" name="pwd" placeholder="<?php echo Language["SharePassword"]; ?>"></div>
<div class="form-group my-4" id="password" style="display: none;"><input type="text" class="form-control" name="password" placeholder="请输入密码"></div>
<div class="form-group my-2"><input type="text" class="form-control" name="surl" placeholder="<?php t("ShareLink") ?>" oninput="Getpw()"></div>
<div class="form-group my-4"><input type="text" class="form-control" name="pwd" placeholder="<?php t("SharePassword") ?>"></div>
<div class="form-group my-4" id="password" style="display: none;"><input type="text" class="form-control" name="password" placeholder="<?php t("PassWord") ?>"></div>
<div class="form-group mt-4 mb-3 d-grid">
<button onclick="SubmitLink()" class="btn btn-primary"><?php echo Language["Submit"]; ?></button>
<button onclick="SubmitLink()" class="btn btn-primary"><?php t("Submit") ?></button>
</div>
</div>
</div>
Expand Down Expand Up @@ -73,7 +73,7 @@
break;
case 2:
// 密码正确
$("#password").html("您的设备在短期内已经验证过,无需再次输入密码。");
$("#password").html("<?php t("PassWordVerified") ?>");
$("#password").show();
break;
}
Expand All @@ -85,7 +85,7 @@
<div id="list" class="page" style="display: none;">
<nav class="breadcrumb my-4" aria-label="breadcrumb">
<ol class="breadcrumb my-3" id="dir-list">
<li class="breadcrumb-item active">正在连接服务器......</li>
<li class="breadcrumb-item active"><?php t("Connecting") ?></li>
</ol>
</nav>
<div>
Expand All @@ -98,22 +98,22 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">成功获取下载地址</h5>
<h5 class="modal-title"><?php t("DownloadLinkSuccess") ?></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div id="downloadlinkdiv">

</div>
<h5 class="text-danger" id="limit-tip" style="display: none;">当前 SVIP 账号已被限速,请更换账号。</h5>
<h5 class="text-danger" id="limit-tip" style="display: none;"><?php t("LimittedDownload") ?></h5>
<p class="card-text">
<a class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#SendToAria2">发送到 Aira2 / Motrix</a>
<a class="btn btn-outline-primary" href="" id="filecxx" style="display: none;">发送到 文件蜈蚣</a>
<a class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#SendToAria2"><?php t("SendToAria2") ?> / Motrix</a>
<a class="btn btn-outline-primary" href="" id="filecxx" style="display: none;"><?php t("SendToFilecxx") ?></a>
</p>
<p class="card-text"><a class="btn btn-outline-secondary" href="./#/help" target="_blank">下载帮助(必读)</a></p>
<p class="card-text"><a class="btn btn-outline-secondary" href="./#/help" target="_blank"><?php t("DownloadHelp") ?></a></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php t("Close") ?></button>
</div>
</div>
</div>
Expand All @@ -123,7 +123,7 @@
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">发送到 Aria2/Motrix Json-RPC</h5>
<h5 class="modal-title"><?php t("SendToAria2") ?> / Motrix Json-RPC</h5>
<button type="button" class="btn-close" data-bs-toggle="modal" data-bs-target="#downloadpage"></button>
</div>
<div class="modal-body">
Expand All @@ -141,8 +141,8 @@
<small>填写的信息在推送成功后将会被自动保存。</small>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="addUri()" data-bs-toggle="modal" data-bs-target="#downloadpage">发送</button>
<button type="button" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#downloadpage">返回</button>
<button type="button" class="btn btn-primary" onclick="addUri()" data-bs-toggle="modal" data-bs-target="#downloadpage"><?php t("Send") ?></button>
<button type="button" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#downloadpage"><?php t("Return") ?></button>
</div>
</div>
</div>
Expand Down Expand Up @@ -181,67 +181,67 @@
</style>

<div class="card page" id="usersettings" style="display: none;">
<div class="card-header"><?php echo Language["UserSettings"]; ?></div>
<div class="card-header"><?php t("UserSettings") ?></div>
<div class="card-body">
<div class="card-item">
<h3><?php echo Language["ColorMode"]; ?></h3>
<h3><?php t("ColorMode") ?></h3>
<div id="ColorMode-Setting-View">
<span class="SaveTime"><?php echo Language["SaveForever"]; ?></span>
<span><?php echo Language["BrowserSettings"]; ?></span><span id="Browser-ColorMode"></span>
<span><?php echo Language["CurrentSetting"]; ?></span><span id="Setting-ColorMode"></span>
<span class="SaveTime"><?php t("SaveForever") ?></span>
<span><?php t("BrowserSettings") ?></span><span id="Browser-ColorMode"></span>
<span><?php t("CurrentSetting") ?></span><span id="Setting-ColorMode"></span>
</div>
<select id="ColorMode-Select" class="form-control">
<option value="auto"><?php echo Language["FollowBrowser"]; ?></option>
<option value="dark"><?php echo Language["DarkMode"]; ?></option>
<option value="light"><?php echo Language["LightMode"]; ?></option>
<option value="auto"><?php t("FollowBrowser") ?></option>
<option value="dark"><?php t("DarkMode") ?></option>
<option value="light"><?php t("LightMode") ?></option>
</select>
</div>
<div class="card-item">
<h3><?php echo Language["LanguageChoose"]; ?></h3>
<h3><?php t("LanguageChoose") ?></h3>
<div id="LanguageChoose">
<span class="SaveTime"><?php echo Language["Save365"]; ?></span>
<span><?php echo Language["BrowserSettings"]; ?></span><span id="Browser-Language"><?php echo BrowserLanguage; ?></span>
<span><?php echo Language["CurrentDisplayed"]; ?></span><span id="Displayed-Language"><?php echo Lang; ?></span>
<span class="SaveTime"><?php t("Save365") ?></span>
<span><?php t("BrowserSettings") ?></span><span id="Browser-Language"><?php echo BrowserLanguage; ?></span>
<span><?php t("CurrentDisplayed") ?></span><span id="Displayed-Language"><?php echo Lang; ?></span>
</div>
<select id="Language-Select" class="form-control">
<option value="auto"><?php echo Language["FollowBrowser"]; ?></option>
<option value="auto"><?php t("FollowBrowser") ?></option>
<option value="zh-CN">简体中文</option>
<option value="en">English</option>
</select>
</div>
<div class="card-item">
<h3><?php echo Language["UpdateTip"]; ?></h3>
<h3><?php t("UpdateTip") ?></h3>
<div id="UpdateTips">
<?php echo Language["UpdateTips"]; ?>
<?php t("UpdateTips") ?>
</div>
<select id="UpdateTips-Select" class="form-control">
<option value="true"><?php echo Language["Enable"]; ?></option>
<option value="false"><?php echo Language["Disable"]; ?></option>
<option value="true"><?php t("Enable") ?></option>
<option value="false"><?php t("Disable") ?></option>
</select>
</div>
</div>
</div>

<script>
if (localStorage.getItem('colorMode') === null) { // 判断用户设置的颜色
$('#Setting-ColorMode').text('<?php echo Language["FollowBrowser"]; ?>'); // 跟随浏览器
$('#Setting-ColorMode').text('<?php t("FollowBrowser") ?>'); // 跟随浏览器
$('#ColorMode-Select option[value=auto]')[0].selected = true;
} else if (localStorage.getItem('colorMode') === 'dark') { // 深色模式
$('#Setting-ColorMode').text('<?php echo Language["DarkMode"]; ?>');
$('#Setting-ColorMode').text('<?php t("DarkMode") ?>');
$('#ColorMode-Select option[value=dark]')[0].selected = true;
} else if (localStorage.getItem('colorMode') === 'light') { // 浅色模式
$('#Setting-ColorMode').text('<?php echo Language["LightMode"]; ?>');
$('#Setting-ColorMode').text('<?php t("LightMode") ?>');
$('#ColorMode-Select option[value=light]')[0].selected = true;
}
const LanguageSetting = '<?php echo $_COOKIE['Language'] ?? ''; ?>';
if (LanguageSetting === '') { // 判断用户设置的语言
$('#Language-Select option[value=auto]').text('<?php echo Language["CurrentSetting"]; ?>' + $('#Language-Select option[value=auto]').text());
$('#Language-Select option[value=auto]').text('<?php t("CurrentSetting") ?>' + $('#Language-Select option[value=auto]').text());
$('#Language-Select option[value=auto]')[0].selected = true;
} else if (LanguageSetting === 'zh-CN') { // zh-CN
$('#Language-Select option[value="zh-CN"]').text('<?php echo Language["CurrentSetting"]; ?>' + $('#Language-Select option[value="zh-CN"]').text());
$('#Language-Select option[value="zh-CN"]').text('<?php t("CurrentSetting") ?>' + $('#Language-Select option[value="zh-CN"]').text());
$('#Language-Select option[value="zh-CN"]')[0].selected = true;
} else if (LanguageSetting === 'en') { // en
$('#Language-Select option[value="en"]').text('<?php echo Language["CurrentSetting"]; ?>' + $('#Language-Select option[value="en"]').text());
$('#Language-Select option[value="en"]').text('<?php t("CurrentSetting") ?>' + $('#Language-Select option[value="en"]').text());
$('#Language-Select option[value="en"]')[0].selected = true;
}

Expand All @@ -250,9 +250,9 @@

function changeColorMode() { // 更改颜色模式显示
if (dark.matches) { // 获取浏览器设置
$('#Browser-ColorMode').text('<?php echo Language["DarkMode"]; ?>'); // 深色模式
$('#Browser-ColorMode').text('<?php t("DarkMode") ?>'); // 深色模式
} else if (light.matches) { // 获取浏览器设置
$('#Browser-ColorMode').text('<?php echo Language["LightMode"]; ?>'); // 浅色模式
$('#Browser-ColorMode').text('<?php t("LightMode") ?>'); // 浅色模式
}
}

Expand Down Expand Up @@ -294,5 +294,5 @@ function changeColorMode() { // 更改颜色模式显示
</script>

<div id="help" class="page" style="display: none;">
<?php echo Language["HelpPage"]; ?>
<?php t("HelpPage") ?>
</div>
16 changes: 15 additions & 1 deletion common/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"ConfirmTitle" => "继续解析?",
"ConfirmText" => "为保证服务稳定,每个IP每天有" . DownloadTimes . "次免费解析次数,是否继续?",
"ConfirmmButtonText" => "确定",
"Connecting" => "请稍等,正在连接服务器...",
"IndexButton" => "首页",
"HelpButton" => "使用帮助",
"TipTitle" => "提示",
Expand All @@ -35,11 +36,13 @@
"NotSupportWithUA" => "暂不支持当前文件。",
"NotSupportWithoutUA" => "目前只支持 <b>50MB以下文件</b> 或 <b>设置UA</b> 后使用在线预览功能。",
"DownloadLink" => "下载链接",
"DownloadHelp" => "下载帮助(必读)",
"DownloadTip" => "Tips: 电脑端右键即可复制下载链接,手机端长按可复制下载链接。推荐使用 Aria2、Motrix 下载,速度更快,使用方法请访问帮助页面。",
"SendToAria2" => "发送到 Aria2",
"SendToFilecxx" => "发送到 文件蜈蚣",
"Send" => "发送",
"Close" => "关闭",
"Return" => "返回",
"IndexTitle" => "百度网盘在线解析",
"ShareLink" => "请输入分享链接(可输入带提取码链接)",
"SharePassword" => "请输入提取码(没有留空)",
Expand All @@ -54,6 +57,7 @@
"DarkMode" => "深色模式",
"LightMode" => "浅色模式",
"LanguageChoose" => "选择语言",
"LimittedDownload" => "当前 SVIP 账号已被限速,请更换账号。",
"SaveForever" => '将会永久保存。',
"Save365" => '将会保存 365 天,每次访问此项目会自动续期。',
"CurrentDisplayed" => "当前显示:",
Expand Down Expand Up @@ -153,6 +157,7 @@
"ConfirmTitle" => "Continue?",
"ConfirmText" => "You have " . DownloadTimes . " download times, continue?",
"ConfirmmButtonText" => "Yes",
"Connecting" => "Connecting to server, please wait...",
"IndexButton" => "Home",
"HelpButton" => "Using Help",
"TipTitle" => "Tip",
Expand All @@ -169,11 +174,13 @@
"NotSupportWithUA" => "The type is not support",
"NotSupportWithoutUA" => "The type is not support",
"DownloadLink" => "Download Link",
"DownloadHelp" => "Download Help (MUST READ)",
"DownloadTip" => "Tips: Copy the download link and put it in your download apps.",
"SendToAria2" => "Send to aria2",
"SendToFilecxx" => "Send to File Centipede",
"Send" => "Send",
"Close" => "Close",
"Return" => "Return",
"IndexTitle" => "Get Download Link of pan.baidu.com",
"ShareLink" => "Please enter the share link",
"SharePassword" => "Please enter the share link password",
Expand All @@ -188,6 +195,7 @@
"DarkMode" => "Dark mode",
"LightMode" => "Light mode",
"LanguageChoose" => "Choose a language",
"LimittedDownload" => "Current SVIP account in the system was limmited, wait website owner to fix it.",
"SaveForever" => 'Will be saved forever.',
"Save365" => 'It will be saved for 365 days and will be automatically renewed every time you visit this item.',
"CurrentDisplayed" => "Current displayed: ",
Expand Down Expand Up @@ -344,5 +352,11 @@ function setLanguage()
}
}

define("Language", $lang[Lang]); // 定义使用的语言
// define("Language", $lang[Lang]); // 定义使用的语言
header('Content-Language: ' . Lang); // 输出响应头

function t($key)
{
global $lang;
echo $lang[Lang][$key];
}
14 changes: 3 additions & 11 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
header('Refresh: 5;url=https://github.com/yuantuo666/baiduwp-php');
die("HTTP 503 服务不可用!\r\n配置错误,未启用数据库无法使用其他会员模式!无法正常运行程序!\r\n请重新 Clone 项目并配置!\r\n将在五秒内跳转到 GitHub 储存库!");
}
// 保存启动时间
$system_start_time = microtime(true);
// 导入配置和函数
require('./common/language.php');
require('./common/functions.php');
Expand Down Expand Up @@ -101,9 +99,9 @@
<button class="navbar-toggler border-0" type="button" data-bs-toggle="collapse" data-bs-target="#collpase-bar"><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="collpase-bar">
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link" href="javascript:navigate('index')"><?php echo Language["IndexButton"]; ?></a></li>
<li class="nav-item"><a class="nav-link" href="javascript:navigate('help')"><?php echo Language["HelpButton"]; ?></a></li>
<li class="nav-item"><a class="nav-link" href="javascript:navigate('usersettings')"><?php echo Language["UserSettings"]; ?></a></li>
<li class="nav-item"><a class="nav-link" href="javascript:navigate('index')"><?php t("IndexButton") ?></a></li>
<li class="nav-item"><a class="nav-link" href="javascript:navigate('help')"><?php t("HelpButton") ?></a></li>
<li class="nav-item"><a class="nav-link" href="javascript:navigate('usersettings')"><?php t("UserSettings") ?></a></li>
<li class="nav-item"><a class="nav-link" href="https://github.com/yuantuo666/baiduwp-php" target="_blank">Github</a></li>
</ul>
</div>
Expand All @@ -120,12 +118,6 @@
echo Footer;
?>
</div>

<?php
$system_end_time = microtime(true);
$system_runningtime = $system_end_time - $system_start_time;
echo "<script>console.log('后端计算时间 $system_runningtime 秒');</script>";
?>
</body>

</html>
5 changes: 3 additions & 2 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
$PasswordError = true;
}
}
if ($is_login) connectdb();
?>

<!DOCTYPE html>
Expand Down Expand Up @@ -119,6 +118,8 @@ function Sumbitform() {
</div>
<?php } else {
// 登录后操作
if (!USING_DB) dl_error("数据库未启用,无法使用后台功能", "请在 <code>config.php</code> 中启用并正确配置数据库");
connectdb();
?>
<div class="col-md-12 col-sm-12 col-12">
<?php if ($method == "analyse") { ?>
Expand Down Expand Up @@ -571,7 +572,7 @@ function IPLoadmore() {
if (isset($_SESSION['cache'][$cache_key]) && $_SESSION['cache'][$cache_key]['time'] > time() - 3600) {
$Status = $_SESSION['cache'][$cache_key]['data'];
} else {
$Status = AccountStatus($SVIP_BDUSS, $STOKEN);
$Status = AccountStatus($SVIP_BDUSS, $SVIP_STOKEN);
$_SESSION['cache'][$cache_key] = [
'time' => time(),
'data' => $Status
Expand Down
2 changes: 1 addition & 1 deletion static/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const colorMode = localStorage.getItem('colorMode'); // 获取色彩模式配置
title: '色彩配置有误',
html: '色彩模式配置出现错误,已重置配置!<br/>按 OK 刷新页面。',
icon: 'warning',
footer: '<a href="?usersettings" target="_blank">点此去修改颜色模式的页面</a>'
footer: '<a href="./#/usersettings" target="_blank">点此去修改颜色模式的页面</a>'
}).then(function () {
location.reload(); // 重载页面
});
Expand Down
29 changes: 21 additions & 8 deletions static/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,19 +535,32 @@ async function Download(index = 0) {

}
function CopyDownloadlink() {
navigator.clipboard.writeText($("input#downloadlink").val()).then(function () {
console.log('Copying to clipboard was successful!');
}, function (err) {
console.error('Could not copy text: ', err);
$("input#downloadlink").select();
document.execCommand("copy");
}).then(function () {
function Success() {
Swal.fire({
title: "成功复制下载链接",
html: "请设置下载器的 User-Agent 为 <b id='ua'>" + $("#ua").text() + "</b> 后下载,参考使用帮助",
timer: 3000,
timerProgressBar: true,
icon: "success"
});
});
}
function CopyDownloadlink_old() {
$("input#downloadlink").select();
document.execCommand("copy");
Success();
}

// In unsecure site will not work, add check
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText($("input#downloadlink").val()).then(function () {
console.log('Copying to clipboard was successful!');
}, function (err) {
console.error('Could not copy text: ', err);
CopyDownloadlink_old()
}).then(function () {
Success();
});
} else {
CopyDownloadlink_old()
}
}

0 comments on commit b742faf

Please sign in to comment.