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

Commit

Permalink
Merge pull request #65 from yuantuo666/dev
Browse files Browse the repository at this point in the history
准备版本更新。
希望没问题,,
  • Loading branch information
yuantuo666 authored Feb 17, 2021
2 parents 8596473 + c748e7f commit 171a324
Show file tree
Hide file tree
Showing 9 changed files with 982 additions and 515 deletions.
59 changes: 34 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
PanDownload 网页复刻版,PHP 语言版<br/>
本项目仅供大家学习参考,严禁商业用途

### 实现原理
## 🔎实现原理
通过curl获取网盘文件信息,处理后显示在网页中。通过api接口以及SVIP账号的Cookie(BDUSS)获取高速下载链接。<br/>
本质就是用会员账号获取下载地址并发送给访客。

在使用时请保留导航栏的 Made by Yuan_Tuo ,感谢!
📢在使用时请保留导航栏的 Made by Yuan_Tuo ,感谢!

欢迎各位转发本项目到各大论坛,但请一定要标注原地址!
📢欢迎各位转发本项目到各大论坛,但请一定要标注原地址!

![speed.gif](https://i.loli.net/2020/10/01/2mEqkClnPev8ORd.gif)

## Donate
## 💴Donate
[捐赠作者](https://imwcr.cn/?donate)

## Blacklists
## 🚧Blacklists
<!-- - http://down.5nb.me/ 1.4.5版本(站长拒不修改) -->
- https://pan.xiaoshuyun.cn/ 1.4.3版本 无密码
- https://pan.qiafan.vip/ 1.4.5版本 无密码
Expand All @@ -39,7 +39,7 @@ PanDownload 网页复刻版,PHP 语言版<br/>
版权信息可添加**Github项目地址****我个人主页地址**,内容可自定,但访客**必须可见**。<br />
**那些把文字颜色和背景改成一样的站长,有意思吗?**

## Tips
## 📌Tips
- 使用了 `Curl`,使用前请确认安装了Curl及其PHP插件
- 使用了 `SESSION`,注意 **PHP 访问系统文件(夹)权限** 问题
- 仅支持 **PHP 7 和 7+**
Expand All @@ -56,34 +56,43 @@ PanDownload 网页复刻版,PHP 语言版<br/>
- `Google Chrome 88+` [点此访问 Chrome 官网](https://www.google.cn/chrome/)
- `Firefox 85+` [点此访问 Firefox 官网](https://www.firefox.com.cn/)

# Setting
# 🔧Setting
首先Clone项目或进入[Releases](https://github.com/yuantuo666/baiduwp-php/releases)下载项目文件。<br />
然后访问 `install.php` 文件并填写相关信息。<br />
如果使用数据库,则需要先点击 `检查数据库连接` 连接数据库,保证账号密码正确。<br />
最后点击提交即可。

## Demo
## 💻Demo
[暂不开放](http://imwcr.cn/api/bdwp/)<br />
因站长学习紧张加上精力有限,演示站没有时间维护,故暂时关闭。

## New Changes
- 当前版本:`2.0.0`
- 更新日期:2021-02-11
- 修改内容
- ✨增加深色模式
- 弹窗升级适应深色模式,改 `SweetAlert``SweetAlert2`
- 优化部分 PHP 和 JavaScript 代码
- 修复 SQL 文件中初始序号不为 1 的问题
- ✨新增用户设置页面,可手动设置**系统语言****色彩模式**
- 删除不必要的保护密码提醒(从项目启动时留下来的问题)
- 增加新的免登陆接口获取 50MB 以下文件 **(未完成)**
- ✨系统语言增加英语,可自动识别浏览器语言,也可手动切换
- ✨增加安装程序
- 丰富错误提示内容
- 修复一些历史遗留 bug
- 修复一些新发现/新出现的 bug
## 📦New Changes
- 当前版本:`2.1.0`
- 更新日期:2021-02-17
<!-- 同志们,写更新日志要细致啊,不要写笼统的! -->
- 修改内容:
- 💥新增功能
- 安装程序 `install.php` 自动检测旧版本配置文件 `config.php` 是否存在,若存在自动导入旧版本配置
- 增加选择是否取消下载次数提醒功能
- ✨安装时支持保留数据库数据
- ✨后台管理页面支持删除数据
- ✨增加四种SVIP账号切换模式
- 增加首页公告自定义功能
- 💪安全增强
- 安装程序 `install.php` 自动检测是否安装过,如果安装则需进入管理员页面登录
- ⚠错误修复
- 修复部分页面检查密码功能失效问题
- 修复首页小圆点无颜色错误
- 修复不支持色彩模式的浏览器无法显示 `Sweetalert2` 弹窗问题
- 修复解析数据一直为 `2.00GB` 问题
- 修复管理员密码错误不提示
- ♻代码优化
- ✨将 `settings.php` 内部分请求方式改为 `ajax` ,增加加载提示框 <!-- 搞了四个小时,累死 -->
- 优化提示文本(语法、严谨程度等),给一些提示框增加图标
- 增加部分配置异常的处理程序
- 优化部分 PHP 和 JavaScript 代码

## Thanks
## 🔔Thanks
- [baiduwp JavaScript 版](https://github.com/TkzcM/baiduwp "GitHub 项目")
- [PanDownload 网站](https://pandownload.com/ "PanDownload 网站")
- [Bootstrap 深色模式](https://github.com/vinorodrigues/bootstrap-dark "bootstrap-dark 项目")
217 changes: 203 additions & 14 deletions api.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* @link https://space.bilibili.com/88197958
*
*/
$programVersion_API = '2.1.0';
session_start();
define('init', true);
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
Expand All @@ -19,14 +20,29 @@
die("HTTP 503 服务不可用!\r\nPHP 版本过低!无法正常运行程序!\r\n请安装 7.0.0 或以上版本的 PHP!\r\n将在五秒内跳转到 PHP 官方下载页面!");
}
$method = (!empty($_GET["m"])) ? $_GET["m"] : ""; // 下一步判断是否引用config.php需用到
if ((!file_exists('functions.php')) or ($method != "CheckMySQLConnect" and !file_exists('functions.php'))) {
if (!file_exists('functions.php')) {
http_response_code(503);
header('Content-Type: text/plain; charset=utf-8');
header('Refresh: 5;url=https://github.com/yuantuo666/baiduwp-php');
die("HTTP 503 服务不可用!\r\n缺少相关文件!无法正常运行程序!\r\n请重新 Clone 项目并配置!\r\n将在五秒内跳转到 GitHub 储存库!");
}
// 导入配置和函数
if ($method != "CheckMySQLConnect") require('config.php'); // 如果是使用检查连接,还没有配置好文件,不能引用
if ($method != "CheckMySQLConnect") { // 如果是使用检查连接,还没有配置好文件,不能引用
if (!file_exists('config.php')) {
http_response_code(503);
header('Content-Type: text/plain; charset=utf-8');
header('Refresh: 5;url=install.php');
die("HTTP 503 服务不可用!\r\n暂未安装此程序!\r\n将在五秒内跳转到安装程序!");
} else {
require('config.php');
if ($programVersion_API !== programVersion) {
http_response_code(503);
header('Content-Type: text/plain; charset=utf-8');
header('Refresh: 5;url=install.php');
die("HTTP 503 服务不可用!\r\n配置文件版本异常!\r\n将在五秒内跳转到安装程序!\r\n若重新安装无法解决问题,请重新 Clone 项目并配置!");
}
}
}
require('functions.php');
// 通用响应头
header('Content-Type: text/html; charset=utf-8');
Expand All @@ -37,7 +53,187 @@
} else {
error_reporting(0); // 关闭错误报告
}
$is_login = (empty($_SESSION["admin_login"])) ? false : $_SESSION["admin_login"];
if ($method == "ADMINAPI") {
if (!$is_login) {
//没有登录管理员账号
EchoInfo(-1, array("msg" => "未登录"));
exit;
} else {
connectdb();
}
$action = (!empty($_GET["act"])) ? $_GET["act"] : "";
switch ($action) {
case "AnalyseGetTable":
$page = (!empty($_GET["page"])) ? $_GET["page"] : "";
echo GetAnalyseTablePage($page);
break;
case "SvipGetTable":
$page = (!empty($_GET["page"])) ? $_GET["page"] : "";
echo GetSvipTablePage($page);
break;
case "singleBDUSS":
// 先处理是否有新增加数据
$BDUSS = (!empty($_POST["BDUSS"])) ? trim($_POST["BDUSS"]) : "";
$STOKEN = (!empty($_POST["STOKEN"])) ? $_POST["STOKEN"] : "";
$name = (!empty($_POST["name"])) ? $_POST["name"] : "";
if ($BDUSS != "" and strlen($BDUSS) == 192) {
// 开始录入
$add_time = date("Y-m-d H:i:s");
$sql = "INSERT INTO `" . $dbtable . "_svip`( `name`, `svip_bduss`, `svip_stoken`, `add_time`, `state`, `is_using`) VALUES ('$name','$BDUSS','$STOKEN','$add_time',1,'')";
$Result = mysqli_query($conn, $sql);
if ($Result != false) EchoInfo(0, array("msg" => "新增成功", "detail" => "已经成功新增一条会员数据。3s后将刷新该页面。", "refresh" => true));
else {
$Error = addslashes(mysqli_error($conn));
EchoInfo(-1, array("msg" => "添加失败", "detail" => $Error));
}
} else {
EchoInfo(-1, array("msg" => "添加失败", "detail" => "请检查BDUSS是否填写正确"));
}
break;
case "multiBDUSS":
$BDUSS = (!empty($_POST["MULTI_BDUSS"])) ? trim($_POST["MULTI_BDUSS"]) : "";
$name = (!empty($_POST["name"])) ? $_POST["name"] : "";
if ($BDUSS != "") {
// 开始录入
$allsql = "";
$add_time = date("Y-m-d H:i:s");

$AllBduss = explode("\n", $BDUSS);
for ($i = 0; $i < count($AllBduss); $i++) {
$sql = "INSERT INTO `" . $dbtable . "_svip`( `name`, `svip_bduss`, `add_time`, `state`, `is_using`) VALUES ('$name-" . ($i + 1) . "','" . $AllBduss[$i] . "','$add_time',1,'');";
$allsql .= $sql;
}

$sccess_result = 0;
if (mysqli_multi_query($conn, $allsql)) {
do {
$sccess_result = $sccess_result + 1;
} while (mysqli_more_results($conn) && mysqli_next_result($conn));
}

$affect_row = mysqli_affected_rows($conn);
if ($affect_row == -1)
EchoInfo(-1, array("msg" => "导入失败", "detail" => "错误在" . $sccess_result . ""));
else EchoInfo(0, array("msg" => "导入成功", "detail" => "成功导入" . $sccess_result . "条数据。3s后将刷新该页面。", "refresh" => true));
} else EchoInfo(-1, array("msg" => "添加失败", "detail" => "请检查BDUSS是否填写正确"));
break;
case "SvipSettingFirstAccount":
$id = (!empty($_GET["id"])) ? $_GET["id"] : "";
if ($id == "") {
// 参数错误
EchoInfo(-1, array("msg" => "传入参数错误"));
} else {
// 开始处理
// 这里最新的时间表示可用账号,按顺序排序
$is_using = date("Y-m-d H:i:s");
$sql = "UPDATE `" . $dbtable . "_svip` SET `is_using`= '$is_using' WHERE `id`=$id";
$mysql_query = mysqli_query($conn, $sql);
if ($mysql_query != false) {
// 成功
EchoInfo(0, array("msg" => "ID为 $id 的账号已被设置为首选账号。3s后将刷新该页面。", "refresh" => true));
} else {
// 失败
EchoInfo(-1, array("msg" => "修改失败"));
}
}
break;
case "SvipSettingNormalAccount":
$id = (!empty($_GET["id"])) ? $_GET["id"] : "";
if ($id == "") {
// 参数错误
EchoInfo(-1, array("msg" => "传入参数错误"));
} else {
// 开始处理
$sql = "UPDATE `" . $dbtable . "_svip` SET `state`= 1 WHERE `id`=$id";
$mysql_query = mysqli_query($conn, $sql);
if ($mysql_query != false) {
// 成功
EchoInfo(0, array("msg" => "ID为 $id 的账号已被设置为正常账号。3s后将刷新该页面。", "refresh" => true));
} else {
// 失败
EchoInfo(-1, array("msg" => "修改失败"));
}
}
break;
case "IPGetTable":
$page = (!empty($_GET["page"])) ? $_GET["page"] : "";
echo GetIPTablePage($page);
break;
case "NewIp":
$ip = (!empty($_POST["ip"])) ? trim($_POST["ip"]) : "";
$remark = (!empty($_POST["remark"])) ? $_POST["remark"] : "";
$type = $_POST["type"];
if ($ip != "") {
// 开始录入
$add_time = date("Y-m-d H:i:s");
$sql = "INSERT INTO `" . $dbtable . "_ip`( `ip`, `remark`, `type`, `add_time`) VALUES ('$ip','$remark',$type,'$add_time')";
$Result = mysqli_query($conn, $sql);
if ($Result != false) EchoInfo(0, array("msg" => "新增成功", "detail" => "成功新增一条ip记录。3s后将刷新该页面。", "refresh" => true));
else {
$Error = addslashes(mysqli_error($conn));
EchoInfo(-1, array("msg" => "添加失败", "detail" => $Error));
}
} else EchoInfo(-1, array("msg" => "添加失败", "detail" => "请检查IP和账号种类是否填写正确"));
break;
case "setDownloadTimes":
$origin_config = file_get_contents("config.php");
$update_config = str_replace('const DownloadTimes = ' . DownloadTimes . ';', 'const DownloadTimes = ' . $_POST["DownloadTimes"] . ';', $origin_config);
$len = file_put_contents('config.php', $update_config);

if ($len != false) EchoInfo(0, array("msg" => "设置成功", "detail" => "成功写入 config.php 共 $len 个字符。3s后将刷新该页面。", "refresh" => true));
else EchoInfo(-1, array("msg" => "添加失败", "detail" => "请检查 config.php 文件状态及当前用户权限。或者手动修改 config.php 中相关设置。"));
break;
case "setSVIPSwitchMod":
$origin_config = file_get_contents("config.php");
$update_config = str_replace('const SVIPSwitchMod = ' . SVIPSwitchMod . ';', 'const SVIPSwitchMod = ' . $_POST["SVIPSwitchMod"] . ';', $origin_config);
$len = file_put_contents('config.php', $update_config);

if ($len != false) EchoInfo(0, array("msg" => "设置成功", "detail" => "成功写入 config.php 共 $len 个字符。3s后将刷新该页面。", "refresh" => true));
else EchoInfo(-1, array("msg" => "添加失败", "detail" => "请检查 config.php 文件状态及当前用户权限。或者手动修改 config.php 中相关设置。"));
break;
case "DeleteById":
//通过指定表格与ip删除对应行
$Type = (!empty($_GET["type"])) ? $_GET["type"] : "";
$Id = (!empty($_GET["id"])) ? $_GET["id"] : "";
if ($Type != "" and $Id != "") {
// 开始执行
// 生成SQL
switch ($Type) {
case 'AnalyseTable':
// 使用统计 分析表格 $dbtable
$Sql = "DELETE FROM `$dbtable` WHERE `id` = $Id";
break;
case 'SvipTable':
// 会员账号表格
$Sql = "DELETE FROM `" . $dbtable . "_svip` WHERE `id` = $Id";
break;
case 'IPTable':
// ip黑白名单
$Sql = "DELETE FROM `" . $dbtable . "_ip` WHERE `id` = $Id";
break;
default:
// 无匹配
EchoInfo(-1, array("msg" => "传入Type(删除种类)错误"));
exit;
break;
}
// 开始执行sql
$Result = mysqli_query($conn, $Sql);
if ($Result != false) {
EchoInfo(0, array("msg" => "成功删除id为 $Id 的数据。3s后将刷新该页面。", "refresh" => true)); //成功删除
} else {
$Error = addslashes(mysqli_error($conn));
EchoInfo(-1, array("msg" => "删除失败,返回信息:$Error"));
}
} else EchoInfo(-1, array("msg" => "未传入Type(删除种类)或Id(删除指定的id)"));
break;
default:
EchoInfo(-1, array("msg" => "没有参数传入"));
break;
}
exit;
}
switch ($method) {
case 'LastParse':
// 返回数据库中上一次解析的时间,及SVIP状态
Expand All @@ -60,7 +256,7 @@
"sviptips" => $SvipTips
));
} else {
EchoInfo(0, array("msg" => "数据库中没有数据"));
EchoInfo(-1, array("msg" => "数据库中没有数据", "sviptips" => "Unknown"));
}
} else {
// 未开启数据库
Expand All @@ -79,7 +275,7 @@
if ($Result = mysqli_fetch_assoc($mysql_query)) {
// 存在数据
$AllCount = $Result["AllCount"];
$AllSize = formatSize((int)$Result["AllSize"]); // 格式化获取到的文件大小
$AllSize = formatSize((float)$Result["AllSize"]); // 格式化获取到的文件大小
$ParseCountMsg = "累计解析 $AllCount 个,共 $AllSize";
} else {
EchoInfo(0, array("msg" => "当前数据库版本不支持此统计操作"));
Expand All @@ -91,7 +287,7 @@
if ($Result = mysqli_fetch_assoc($mysql_query)) {
// 存在数据
$AllCount = $Result["AllCount"];
$AllSize = formatSize((int)$Result["AllSize"]); // 格式化获取到的文件大小
$AllSize = formatSize((float)$Result["AllSize"]); // 格式化获取到的文件大小
$TodayParseCountMsg = "今日解析 $AllCount 个,共 $AllSize";
} else {
EchoInfo(0, array("msg" => "当前数据库版本不支持此统计操作"));
Expand All @@ -107,11 +303,11 @@
// 检查数据库连接是否正常
$servername = (!empty($_POST["servername"])) ? $_POST["servername"] : "";
$username = (!empty($_POST["username"])) ? $_POST["username"] : "";
$password = (!empty($_POST["password"])) ? $_POST["password"] : "";
$DBPassword = (!empty($_POST["DBPassword"])) ? $_POST["DBPassword"] : "";
$dbname = (!empty($_POST["dbname"])) ? $_POST["dbname"] : "";
$dbtable = (!empty($_POST["dbtable"])) ? $_POST["dbtable"] : "";

$conn = mysqli_connect($servername, $username, $password);
$conn = mysqli_connect($servername, $username, $DBPassword);
$GLOBALS['conn'] = $conn;
// Check connection
if (!$conn) {
Expand Down Expand Up @@ -141,10 +337,3 @@
EchoInfo(-1, array("msg" => "无传入数据"));
break;
}

function EchoInfo(int $error, array $Result)
{
$ReturnArray = array("error" => $error);
$ReturnArray += $Result;
echo json_encode($ReturnArray);
}
Loading

0 comments on commit 171a324

Please sign in to comment.