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

Commit

Permalink
fix #253; link & version change
Browse files Browse the repository at this point in the history
  • Loading branch information
yuantuo666 committed Apr 7, 2023
1 parent 3ceaadf commit e209f14
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 119 deletions.
96 changes: 94 additions & 2 deletions api.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
* 提供一些接口服务
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
* @link https://github.com/yuantuo666/baiduwp-php
*
*/
session_start();
Expand Down Expand Up @@ -80,10 +79,103 @@
EchoInfo(-1, array("msg" => "未登录"));
exit;
}
if (!USING_DB) {
EchoInfo(-1, array("msg" => "未启用数据库功能"));
exit;
}
connectdb();

$action = (!empty($_GET["act"])) ? $_GET["act"] : "";
switch ($action) {
case "AccountStatus":
// 普通账号
$return = "";
$BDUSS = getSubstr(Cookie, 'BDUSS=', ';');
$STOKEN = getSubstr(Cookie, 'STOKEN=', ';');
$cache_key = md5($BDUSS);
if (isset($_SESSION['cache'][$cache_key]) && $_SESSION['cache'][$cache_key]['time'] > time() - 3600) {
$Status = $_SESSION['cache'][$cache_key]['data'];
} else {
$Status = AccountStatus($BDUSS, $STOKEN);
$_SESSION['cache'][$cache_key] = [
'time' => time(),
'data' => $Status
];
}
if ($Status[0] == 0) {
//正常
$AccountName = $Status[2];
$return .= "账号名称:$AccountName<br />";
if ($Status[3] == 1)
$return .= "登录状态:<span class=\"text-success\">正常</span><br />";
else
$return .= "登录状态:<span class=\"text-danger\">异常</span><br />";

$AccountVIP = ["普通账号", "普通会员", "超级会员"][$Status[1]];
$return .= "会员状态:$AccountVIP<br />";
if ($Status[4] != 0) {
$AccountTime = time2Units($Status[4]);
if ($Status[4] <= 60480)
$return .= "剩余时间:<span class=\"text-danger\">$AccountTime</span><br />";
else
$return .= "剩余时间:$AccountTime<br />";
}
} elseif ($Status[0] == -6) {
$return .= "id为 $id 的SVIP账号已经失效<br />";
} else {
$return .= "出现位置错误代码:" . $Status[0] . "<br />";
}
$normal_account_msg = $return;
$return = "";

// SVIP账号
// 获取对应BDUSS
$DBSVIP = GetDBBDUSS();
$SVIP_BDUSS = $DBSVIP[0];
$id = $DBSVIP[1];
$SVIP_STOKEN = $DBSVIP[2];
if ($SVIP_STOKEN == "") {
$return .= "id为 $id 的SVIP账号没有设置对应STOKEN,无法检测<br />";
} else {
$cache_key = md5($SVIP_BDUSS);
if (isset($_SESSION['cache'][$cache_key]) && $_SESSION['cache'][$cache_key]['time'] > time() - 3600) {
$Status = $_SESSION['cache'][$cache_key]['data'];
} else {
$Status = AccountStatus($SVIP_BDUSS, $SVIP_STOKEN);
$_SESSION['cache'][$cache_key] = [
'time' => time(),
'data' => $Status
];
}
if ($Status[0] == 0) {
$AccountName = $Status[2];
$return .= "账号名称:$AccountName<br />";
if ($Status[3] == 1)
$return .= "登录状态:<span class=\"text-success\">正常</span><br />";
else
$return .= "登录状态:<span class=\"text-danger\">异常</span><br />";

$AccountVIP = ["普通账号", "普通会员", "超级会员"][$Status[1]];
$return .= "会员状态:$AccountVIP<br />";
if ($Status[4] != 0) {
$AccountTime = time2Units($Status[4]);
if ($Status[4] <= 60480)
$return .= "剩余时间:<span class=\"text-danger\">$AccountTime</span><br />";
else
$return .= "剩余时间:$AccountTime<br />";
}
} elseif ($Status[0] == -6) {
$return .= "id为 $id 的SVIP账号已经失效<br />";
} else {
$return .= "出现位置错误代码:" . $Status[0] . "<br />";
}
}

$svip_account_msg = $return;
header('Content-Type: application/json; charset=utf-8');
echo json_encode(array("error" => 0, "normal_msg" => $normal_account_msg, "svip_msg" => $svip_account_msg));
break;

case "AnalyseGetTable":
$page = (!empty($_GET["page"])) ? $_GET["page"] : "";
header('Content-Type: text/html; charset=utf-8');
Expand Down
3 changes: 1 addition & 2 deletions common/Parse.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* PanDownload 网页复刻版,PHP 语言版
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
* @link https://github.com/yuantuo666/baiduwp-php
*/
class Parse
{
Expand Down
3 changes: 1 addition & 2 deletions common/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
* 请勿随意修改此文件!如需更改相关配置请到 config.php !
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
* @link https://github.com/yuantuo666/baiduwp-php
*
*/
if (!init) require_once("./common/invalidCheck.php");
Expand Down
3 changes: 1 addition & 2 deletions common/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* 首页文件
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
* @link https://github.com/yuantuo666/baiduwp-php
*
*/
require_once("./common/invalidCheck.php");
Expand Down
3 changes: 1 addition & 2 deletions common/invalidCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* 检查是否初始化
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
* @link https://github.com/yuantuo666/baiduwp-php
*
*/
if (!defined('init')) { // 直接访问处理程序
Expand Down
5 changes: 1 addition & 4 deletions common/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
*
* 功能描述:为一些页面添加必要的语言翻译
*
* 此项目 GitHub 地址:https://github.com/yuantuo666/baiduwp-php
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
* @link https://github.com/yuantuo666/baiduwp-php
*
*/
require_once("./common/invalidCheck.php");
Expand Down
2 changes: 1 addition & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# baiduwp-php

> v3.0.1
> v3.0.2
Base URLs:

Expand Down
13 changes: 13 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# Update
### `3.0.2` 版本:
- 更新日期:2023-04-07
- 修改内容:
- ⚠错误修复
- 修复限速账号检查
- 修复不安全网站无法复制下载地址
- 修复后台无法获取SVIP账号状态
- ♻代码优化
- 改进后台管理错误提示
- 改进翻译函数
- 后端账号状态分离至API接口
- 代码中版权信息改为项目地址

### `3.0.1` 版本:
- 更新日期:2023-04-05
- 修改内容:
Expand Down
9 changes: 2 additions & 7 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,11 @@
*
* 功能描述:使用百度 SVIP 账号获取真实下载地址,与 Pandownload 原版无关。
*
* 希望在使用时能够保留导航栏的 Github 感谢!
*
* 此项目 GitHub 地址:https://github.com/yuantuo666/baiduwp-php
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
* @link https://github.com/yuantuo666/baiduwp-php
*
*/
$programVersion_Index = "3.0.1";
$programVersion_Index = "3.0.2";
session_start();
define('init', true);
if (!file_exists('./common/invalidCheck.php')) {
Expand Down
6 changes: 1 addition & 5 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@
*
* 功能描述:安装PanDownload 网页复刻版
*
* 此项目 GitHub 地址:https://github.com/yuantuo666/baiduwp-php
*
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
* @link https://github.com/yuantuo666/baiduwp-php
*
*/
define('init', true);
Expand Down
5 changes: 2 additions & 3 deletions install/config_raw
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
* !!!请勿修改本文件,如果手动修改后再在后台设置,可能导致config.php文件被清空!!!
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
* @link https://github.com/yuantuo666/baiduwp-php
*/
require_once "./common/invalidCheck.php";

const programVersion = '3.0.1';
const programVersion = '3.0.2';
const Sitename = '<Sitename>';

const Cookie = '<Cookie>';
Expand Down
103 changes: 16 additions & 87 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
* 设置及后台功能
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
*
* @link https://github.com/yuantuo666/baiduwp-php
*/
session_start();
define('init', true);
Expand Down Expand Up @@ -513,99 +511,30 @@ function IPLoadmore() {
<div class="row">
<div class="col-md-6 col-sm-12 card-item">
<h5>普通账号状态</h5>
<p class="card-text">
<?php
// 添加缓存 #253
// TODO: 后台也进行前后端分离
$BDUSS = getSubstr(Cookie, 'BDUSS=', ';');
$STOKEN = getSubstr(Cookie, 'STOKEN=', ';');
$cache_key = md5($BDUSS);
if (isset($_SESSION['cache'][$cache_key]) && $_SESSION['cache'][$cache_key]['time'] > time() - 3600) {
$Status = $_SESSION['cache'][$cache_key]['data'];
} else {
$Status = AccountStatus($BDUSS, $STOKEN);
$_SESSION['cache'][$cache_key] = [
'time' => time(),
'data' => $Status
];
}
if ($Status[0] == 0) {
//正常
$AccountName = $Status[2];
echo "账号名称:$AccountName<br />";
if ($Status[3] == 1)
echo "登录状态:<span class=\"text-success\">正常</span><br />";
else
echo "登录状态:<span class=\"text-danger\">异常</span><br />";

$AccountVIP = ["普通账号", "普通会员", "超级会员"][$Status[1]];
echo "会员状态:$AccountVIP<br />";
if ($Status[4] != 0) {
$AccountTime = time2Units($Status[4]);
if ($Status[4] <= 60480)
echo "剩余时间:<span class=\"text-danger\">$AccountTime</span><br />";
else
echo "剩余时间:$AccountTime<br />";
}
} elseif ($Status[0] == -6) {
echo "id为 $id 的SVIP账号已经失效<br />";
} else {
echo "出现位置错误代码:" . $Status[0] . "<br />";
}
?>
<p class="card-text" id="normal_msg">
正在获取账号状态...
</p>
<br />
</div>
<div class="col-md-6 col-sm-12 card-item">
<h5>会员账号状态</h5>
<p class="card-text">
<?php
// 获取对应BDUSS
$DBSVIP = GetDBBDUSS();
$SVIP_BDUSS = $DBSVIP[0];
$id = $DBSVIP[1];
$SVIP_STOKEN = $DBSVIP[2];
if ($SVIP_STOKEN == "") {
echo "id为 $id 的SVIP账号没有设置对应STOKEN,无法检测<br />";
} else {
$cache_key = md5($SVIP_BDUSS);
if (isset($_SESSION['cache'][$cache_key]) && $_SESSION['cache'][$cache_key]['time'] > time() - 3600) {
$Status = $_SESSION['cache'][$cache_key]['data'];
} else {
$Status = AccountStatus($SVIP_BDUSS, $SVIP_STOKEN);
$_SESSION['cache'][$cache_key] = [
'time' => time(),
'data' => $Status
];
}
if ($Status[0] == 0) {
$AccountName = $Status[2];
echo "账号名称:$AccountName<br />";
if ($Status[3] == 1)
echo "登录状态:<span class=\"text-success\">正常</span><br />";
else
echo "登录状态:<span class=\"text-danger\">异常</span><br />";

$AccountVIP = ["普通账号", "普通会员", "超级会员"][$Status[1]];
echo "会员状态:$AccountVIP<br />";
if ($Status[4] != 0) {
$AccountTime = time2Units($Status[4]);
if ($Status[4] <= 60480)
echo "剩余时间:<span class=\"text-danger\">$AccountTime</span><br />";
else
echo "剩余时间:$AccountTime<br />";
}
} elseif ($Status[0] == -6) {
echo "id为 $id 的SVIP账号已经失效<br />";
} else {
echo "出现位置错误代码:" . $Status[0] . "<br />";
}
}
?>
<p class="card-text" id="svip_msg">
正在获取账号状态...
</p>
<br />
</div>
</div>
<script>
$.get(`api.php?m=ADMINAPI&act=AccountStatus`, function(data, status) {
if (data.error == 0) {
$("#normal_msg").html(data.normal_msg);
$("#svip_msg").html(data.svip_msg);
} else {
$("#normal_msg").html("获取失败");
$("#svip_msg").html("获取失败");
}
});
</script>
</div>
</div>

Expand Down
3 changes: 1 addition & 2 deletions static/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* 许多函数来源于github,详见项目里的Thanks
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
* @link https://github.com/yuantuo666/baiduwp-php
*
*/
addEventListener('DOMContentLoaded', function () {
Expand Down

0 comments on commit e209f14

Please sign in to comment.