From 388b5a9461c3bd8a01bad02106a16ed6c801972b Mon Sep 17 00:00:00 2001 From: yuantuo666 Date: Mon, 15 Feb 2021 13:12:55 +0800 Subject: [PATCH 01/18] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- settings.php | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/settings.php b/settings.php index 342cbf87..28c56482 100644 --- a/settings.php +++ b/settings.php @@ -88,6 +88,42 @@ $page = (!empty($_GET["page"])) ? $_GET["page"] : ""; echo GetIPTablePage($page); 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: echo "

没有参数传入

"; break; @@ -116,7 +152,9 @@ function GetAnalyseTablePage(string $page) // 存在数据 $EachRow = " " . $Result["id"] . " - 暂未开发 +
+ 删除 +
" . $Result["userip"] . " " . $Result["filename"] . " " . formatSize((int)$Result["size"]) . " @@ -144,7 +182,10 @@ function GetSvipTablePage(string $page) $state = ($Result["state"] == -1) ? "限速" : "正常"; $EachRow = " " . $Result["id"] . " - 设为当前解析账号 +
+ 设为当前解析账号 + 删除 +
" . $is_using . " " . $Result["name"] . " " . $state . " @@ -171,6 +212,9 @@ function GetIPTablePage(string $page) $type = ($Result["type"] == -1) ? "黑名单" : "白名单"; $EachRow = " " . $Result["id"] . " +
+ 删除 +
" . $Result["ip"] . " " . $type . " " . $Result["remark"] . " @@ -204,6 +248,18 @@ function GetIPTablePage(string $page) + @@ -502,6 +558,7 @@ function SettingFirstAccount(id) { # + 操作 IP 账号状态 备注 From c49d72e9a72664b5ddaa81b2c60a9c46c5d1dfc8 Mon Sep 17 00:00:00 2001 From: yuantuo666 Date: Mon, 15 Feb 2021 17:55:11 +0800 Subject: [PATCH 02/18] =?UTF-8?q?install.php=E8=87=AA=E5=8A=A8=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=B7=B2=E7=BB=8F=E8=AE=BE=E7=BD=AE=E7=9A=84=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=EF=BC=8C=E6=8F=90=E4=BE=9B=E4=B8=8D=E6=B8=85=E7=A9=BA?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E5=AE=89=E8=A3=85=E9=80=89=E9=A1=B9?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E7=A4=BA=E6=A1=86=E5=A2=9E=E5=8A=A0=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=EF=BC=8C=E5=A2=9E=E5=8A=A0=E7=AD=89=E5=BE=85=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.php | 257 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 162 insertions(+), 95 deletions(-) diff --git a/install.php b/install.php index e9d6fba2..9c06b12e 100644 --- a/install.php +++ b/install.php @@ -41,7 +41,6 @@ PanDownload 复刻版 - 安装程序 - @@ -65,6 +64,49 @@ Swal.fire('提示','检测到你已安装过本程序
现已自动填入config.php中设置的数据','info');"; + } else { + $Sitename = ""; + $IsCheckPassword = true; + $Password = ""; + $ADMIN_PASSWORD = ""; + $DownloadTimes = "5"; + $IsConfirmDownload = true; + $Footer = ""; + + $BDUSS = ""; + $STOKEN = ""; + $SVIP_BDUSS = ""; + + $USING_DB = true; + $servername = "localhost"; + $username = ""; + $password = ""; //注意哦,小写为数据库的密码~ + $dbname = ""; + $dbtable = "bdwp"; + } + if (!isset($_POST["Sitename"])) { ?> @@ -78,7 +120,7 @@
- + 设置你的站点名称,将在首页标题处显示。
@@ -86,13 +128,13 @@
- + >
- + > @@ -100,24 +142,24 @@ 若开启,则在使用解析前必须输入设置的密码;若关闭(一般用于局域网搭建),则无需输入密码即可解析。
-
+
>
- + 在首页需要输入的密码,至少需要6位字符。
- + 用于登录管理后台(setting.php)的密码。
- + 设置每一个IP的下载次数。
@@ -125,13 +167,13 @@
- + >
- + > @@ -141,7 +183,7 @@
- + 通常用于设置隐藏的统计代码。
@@ -151,21 +193,21 @@
- + 用来获取文件列表及信息,不需要SVIP也可。
- + 用来获取文件列表及信息,不需要SVIP也可。
- + 用来获取文件告诉下载地址,必须为SVIP账号,否则将获取到限速地址。
@@ -175,13 +217,13 @@
- + >
- + > @@ -189,40 +231,46 @@ 如需使用记录解析数据、设置黑\白名单、自动切换限速SVIP账号等功能,需开启数据库。
-
+
>
- + 填入MySQL数据库的地址。
- +
- +
- + 如果此数据库不存在将会在检查连接时自动创建。
- + 一般情况无需修改
+ +
+ + + 如果勾选此选项,将不会执行导入数据库操作,但请保证安装的新版本数据结构与旧版本一致,否则可能出现不可预料的错误。 +
检查数据库连接

@@ -232,18 +280,43 @@

我同意在首页及其他页面保留作者版权信息

-
- - - 安装操作将会清空 MySQL数据库 及 本地config.php文件。如果你曾使用过本项目,请备份好数据后再点击提交。 -
+ 提交 - 1. 由于新版本更新了css和js文件,如果你的网站有缓存,请在清理后访问首页(一般CDN会提供此功能);如果浏览器存在缓存,请按下Ctrl+F5强制刷新,或进入设置页面删除缓存,否则可能遇到无法使用的问题。 + TIPS:1. 由于新版本可能更新了css和js文件,如果你的网站有缓存,请在清理后访问首页(一般CDN会提供此功能);如果浏览器存在缓存,请按下Ctrl+F5强制刷新,或进入设置页面删除缓存,否则可能遇到无法使用的问题。 2. 安装完成后请及时删除本安装文件。

@@ -408,49 +470,54 @@ function CheckForm() { // 处理post数据 $Sitename = (!empty($_POST["Sitename"])) ? $_POST["Sitename"] : ""; - $IsCheckPassword = (!empty($_POST["IsCheckPassword"])) ? $_POST["IsCheckPassword"] : ""; + $IsCheckPassword = (!empty($_POST["IsCheckPassword"])) ? $_POST["IsCheckPassword"] : "true"; $Password = (!empty($_POST["Password"])) ? $_POST["Password"] : ""; $ADMIN_PASSWORD = (!empty($_POST["ADMIN_PASSWORD"])) ? $_POST["ADMIN_PASSWORD"] : ""; $DownloadTimes = (!empty($_POST["DownloadTimes"])) ? $_POST["DownloadTimes"] : ""; - $IsConfirmDownload = (!empty($_POST["IsConfirmDownload"])) ? $_POST["IsConfirmDownload"] : ""; + $IsConfirmDownload = (!empty($_POST["IsConfirmDownload"])) ? $_POST["IsConfirmDownload"] : "true"; $Footer = (!empty($_POST["Footer"])) ? $_POST["Footer"] : ""; $BDUSS = (!empty($_POST["BDUSS"])) ? $_POST["BDUSS"] : ""; $STOKEN = (!empty($_POST["STOKEN"])) ? $_POST["STOKEN"] : ""; $SVIP_BDUSS = (!empty($_POST["SVIP_BDUSS"])) ? $_POST["SVIP_BDUSS"] : ""; - $USING_DB = (!empty($_POST["USING_DB"])) ? $_POST["USING_DB"] : ""; + $USING_DB = (!empty($_POST["USING_DB"])) ? $_POST["USING_DB"] : "false"; $servername = (!empty($_POST["DbConfig_servername"])) ? $_POST["DbConfig_servername"] : ""; $username = (!empty($_POST["DbConfig_username"])) ? $_POST["DbConfig_username"] : ""; $password = (!empty($_POST["DbConfig_password"])) ? $_POST["DbConfig_password"] : ""; $dbname = (!empty($_POST["DbConfig_dbname"])) ? $_POST["DbConfig_dbname"] : ""; $dbtable = (!empty($_POST["DbConfig_dbtable"])) ? $_POST["DbConfig_dbtable"] : ""; + $ReserveDBData = (!empty($_POST["ReserveDBData"])) ? $_POST["ReserveDBData"] : "false"; // 是否保存以前数据库数据 未选中不会提交 - if ($USING_DB == "true") { + if ($USING_DB == "true") { //注意判断要用string类型进行 // 连接数据库 $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("数据库连接错误,详细信息:" . mysqli_connect_error()); } - // 打开sql文件 - $SQLfile = file_get_contents("./install/bdwp.sql"); - if ($SQLfile == false) die("无法打开bdwp.sql文件"); - - $SQLfile = str_replace('', $dbtable, $SQLfile); - - $sccess_result = 0; - if (mysqli_multi_query($conn, $SQLfile)) { - 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) { - die("数据库导入出错,错误在" . $sccess_result . "行"); + if ($ReserveDBData == "true") { + echo "保存以前数据库数据
"; } else { - echo "数据库导入成功,成功导入" . $sccess_result . "条数据
"; + // 打开sql文件 + $SQLfile = file_get_contents("./install/bdwp.sql"); + if ($SQLfile == false) die("无法打开bdwp.sql文件"); + + $SQLfile = str_replace('', $dbtable, $SQLfile); + + $sccess_result = 0; + if (mysqli_multi_query($conn, $SQLfile)) { + 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) { + die("数据库导入出错,错误在" . $sccess_result . "行"); + } else { + echo "数据库导入成功,成功导入" . $sccess_result . "条数据
"; + } } } else { echo "不启用数据库
"; @@ -488,8 +555,8 @@ function CheckForm() { } else { die("写入 config.php 文件失败,请检查 config.php 文件状态及当前用户权限。"); } - header('Refresh: 3;url=./'); - echo "恭喜你!你的安装成功了~
浏览器将会在3s内自动跳转,若没有跳转可点此链接前往主页查看。"; + header('Refresh: 5;url=./'); + echo "恭喜你!你的安装成功了~
浏览器将会在5s内自动跳转,若没有跳转可点此链接前往主页查看。"; } ?>
From 6eb9f122b2bdaddf4add1468f95b6b0da0a1d31c Mon Sep 17 00:00:00 2001 From: yuantuo666 Date: Mon, 15 Feb 2021 23:04:01 +0800 Subject: [PATCH 03/18] =?UTF-8?q?install.php=E5=A2=9E=E5=8A=A0=E5=AF=B9?= =?UTF-8?q?=E6=97=A7=E7=89=88=E6=9C=AC=E5=8D=87=E7=BA=A7=E7=9A=84=E6=94=AF?= =?UTF-8?q?=E6=8C=81(=E5=BC=95=E7=94=A8=E4=B8=8D=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E7=9A=84=E5=B8=B8=E9=87=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/install.php b/install.php index 9c06b12e..86d473f5 100644 --- a/install.php +++ b/install.php @@ -72,7 +72,11 @@ $Password = Password; $ADMIN_PASSWORD = ADMIN_PASSWORD; $DownloadTimes = DownloadTimes; - $IsConfirmDownload = IsConfirmDownload; + if (defined('IsConfirmDownload')) { + $IsConfirmDownload = IsConfirmDownload; // 增加对旧版本升级的支持 + } else { + $IsConfirmDownload = ""; + } $Footer = Footer; $BDUSS = BDUSS; From 61fd1251b5337555d89f216b5ed826171e9c8154 Mon Sep 17 00:00:00 2001 From: lc6464 <64722907+lc6464@users.noreply.github.com> Date: Tue, 16 Feb 2021 00:28:03 +0800 Subject: [PATCH 04/18] =?UTF-8?q?=E5=87=86=E5=A4=87=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0=EF=BC=9A2.1.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 21 ++++--- api.php | 24 ++++++-- functions.php | 21 +++++-- index.php | 15 ++++- install.php | 134 +++++++++++++++++---------------------------- install/config_raw | 6 +- settings.php | 20 +++++-- usersettings.php | 14 ++++- 8 files changed, 138 insertions(+), 117 deletions(-) diff --git a/README.md b/README.md index 04904244..fbf8294f 100644 --- a/README.md +++ b/README.md @@ -67,19 +67,18 @@ PanDownload 网页复刻版,PHP 语言版
因站长学习紧张加上精力有限,演示站没有时间维护,故暂时关闭。 ## New Changes -- 当前版本:`2.0.0` -- 更新日期:2021-02-11 +- 当前版本:`2.1.0` +- 更新日期:2021-02-16 - 修改内容 - - ✨增加深色模式 - - 弹窗升级适应深色模式,改 `SweetAlert` 为 `SweetAlert2` + - 安装程序 `install.php` 自动检测旧版本配置是否存在,若存在自动导入 + - 安装时支持保留数据库数据,后台管理页面支持删除数据库数据 - 优化部分 PHP 和 JavaScript 代码 - - 修复 SQL 文件中初始序号不为 1 的问题 - - ✨新增用户设置页面,可手动设置**系统语言**和**色彩模式** - - 删除不必要的保护密码提醒(从项目启动时留下来的问题) - - 增加新的免登陆接口获取 50MB 以下文件 **(未完成)** - - ✨系统语言增加英语,可自动识别浏览器语言,也可手动切换 - - ✨增加安装程序 - - 丰富错误提示内容 + - 修复部分页面检查密码功能失效问题 + - 增加部分配置异常的处理程序 + - 优化提示文本(语法、严谨程度等),给一些提示框增加图标 + - 增加选择是否取消下载次数提醒功能 + - 修复首页小圆点无颜色错误 + - 安装页面提示、UI 优化 - 修复一些历史遗留 bug - 修复一些新发现/新出现的 bug diff --git a/api.php b/api.php index 904110e2..beaf9173 100644 --- a/api.php +++ b/api.php @@ -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', '<')) { @@ -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'); @@ -107,11 +123,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) { diff --git a/functions.php b/functions.php index 4729b3ac..8cba0165 100644 --- a/functions.php +++ b/functions.php @@ -12,12 +12,22 @@ * @link https://space.bilibili.com/88197958 * */ +$programVersion_Functions = '2.1.0'; if (!defined('init')) { // 直接访问处理程序 header('Content-Type: text/plain; charset=utf-8'); if (!file_exists('config.php')) { http_response_code(503); - header('Refresh: 5;url=https://github.com/yuantuo666/baiduwp-php'); - die("HTTP 503 服务不可用!\r\n缺少相关配置和定义文件!无法正常运行程序!\r\n请重新 Clone 项目并配置!\r\n将在五秒内跳转到 GitHub 储存库!"); + 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_Functions !== 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 项目并配置!"); + } } http_response_code(403); header('Refresh: 3;url=./'); @@ -236,8 +246,7 @@ function dl_error(string $title, string $content, bool $jumptip = false) } echo '
'; - return 0; + die('

'); } function get_BDCLND($surl, $Pwd) { @@ -267,10 +276,10 @@ function connectdb(bool $isAPI = false) { $servername = DbConfig["servername"]; $username = DbConfig["username"]; - $password = DbConfig["password"]; + $DBPassword = DbConfig["DBPassword"]; $dbname = DbConfig["dbname"]; $GLOBALS['dbtable'] = DbConfig["dbtable"]; - $conn = mysqli_connect($servername, $username, $password, $dbname); + $conn = mysqli_connect($servername, $username, $DBPassword, $dbname); $GLOBALS['conn'] = $conn; // Check connection if (!$conn) { diff --git a/index.php b/index.php index 9b16702b..aaf060ef 100644 --- a/index.php +++ b/index.php @@ -9,13 +9,14 @@ * * 此项目 GitHub 地址:https://github.com/yuantuo666/baiduwp-php * - * @version 2.0.0 + * @version 2.1.0 * * @author Yuan_Tuo * @link https://imwcr.cn/ * @link https://space.bilibili.com/88197958 * */ +$programVersion_Index = "2.1.0"; session_start(); define('init', true); if (version_compare(PHP_VERSION, '7.0.0', '<')) { @@ -28,7 +29,15 @@ 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将在五秒内跳转到安装程序"); + die("HTTP 503 服务不可用!\r\n暂未安装此程序!\r\n将在五秒内跳转到安装程序!"); +} else { + require('config.php'); + if ($programVersion_Index !== 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 项目并配置!"); + } } if (!(file_exists('functions.php') && file_exists('language.php'))) { http_response_code(503); @@ -39,7 +48,7 @@ // 保存启动时间 $system_start_time = microtime(true); // 导入配置和函数 -require('config.php'); + require('language.php'); require('functions.php'); // 通用响应头 diff --git a/install.php b/install.php index 86d473f5..272c761b 100644 --- a/install.php +++ b/install.php @@ -7,7 +7,7 @@ * * 此项目 GitHub 地址:https://github.com/yuantuo666/baiduwp-php * - * @version 2.0.0 + * @version 2.1.0 * * @author Yuan_Tuo * @link https://imwcr.cn/ @@ -64,54 +64,40 @@ Swal.fire('提示','检测到你已安装过本程序
现已自动填入config.php中设置的数据','info');"; - } else { - $Sitename = ""; - $IsCheckPassword = true; - $Password = ""; - $ADMIN_PASSWORD = ""; - $DownloadTimes = "5"; - $IsConfirmDownload = true; - $Footer = ""; - - $BDUSS = ""; - $STOKEN = ""; - $SVIP_BDUSS = ""; - - $USING_DB = true; - $servername = "localhost"; - $username = ""; - $password = ""; //注意哦,小写为数据库的密码~ - $dbname = ""; - $dbtable = "bdwp"; - } - if (!isset($_POST["Sitename"])) { + // 如果已经安装过一次,读取相关基本设置 + if (file_exists('config.php')) { + require('config.php'); + echo ""; + } + function getConfig(&$var, string $name, $default = '') + { + $var = defined($name) ? constant($name) : $default; + } + getConfig($Sitename, 'Sitename'); + getConfig($IsCheckPassword, 'IsCheckPassword', true); + getConfig($Password, 'Password'); + getConfig($ADMIN_PASSWORD, 'ADMIN_PASSWORD'); + getConfig($DownloadTimes, 'DownloadTimes', '5'); + getConfig($IsConfirmDownload, 'IsConfirmDownload', true); + getConfig($Footer, 'Footer'); + + getConfig($BDUSS, 'BDUSS'); + getConfig($STOKEN, 'STOKEN'); + getConfig($SVIP_BDUSS, 'SVIP_BDUSS'); + + getConfig($USING_DB, 'USING_DB', true); + if (defined('DbConfig')) { + function getDbConfig(&$var, string $key) + { + $var = isset(DbConfig[$key]) ? DbConfig[$key] : ''; + } + getDbConfig($servername, 'servername'); + getDbConfig($username, 'username'); + getDbConfig($DBPassword, 'DBPassword'); + getDbConfig($dbname, 'dbname'); + getDbConfig($dbtable, 'dbtable'); + } ?>
@@ -252,7 +238,7 @@
- +
@@ -287,7 +273,7 @@ 提交 TIPS:1. 由于新版本可能更新了css和js文件,如果你的网站有缓存,请在清理后访问首页(一般CDN会提供此功能);如果浏览器存在缓存,请按下Ctrl+F5强制刷新,或进入设置页面删除缓存,否则可能遇到无法使用的问题。 - 2. 安装完成后请及时删除本安装文件。 + 2. 安装完成后请及时删除本安装文件。

@@ -384,35 +370,27 @@ function CheckMySQLConnect() { Swal.showLoading() servername = $("input[name='DbConfig_servername']").val(); username = $("input[name='DbConfig_username']").val(); - password = $("input[name='DbConfig_password']").val(); + DBPassword = $("input[name='DbConfig_DBPassword']").val(); dbname = $("input[name='DbConfig_dbname']").val(); dbtable = $("input[name='DbConfig_dbtable']").val(); - body = `servername=${servername}&username=${username}&password=${password}&dbname=${dbname}&dbtable=${dbtable}`; + body = `servername=${servername}&username=${username}&DBPassword=${DBPassword}&dbname=${dbname}&dbtable=${dbtable}`; postAPI('CheckMySQLConnect', body).then(function(response) { if (response.success) { const data = response.data; if (data.error == 0) { // 连接成功 - Swal.fire({ - title: "数据库连接成功", - html: "请完成其他信息填写并提交。
详细信息:" + data.msg, - icon: "success" - }); + Swal.fire("数据库连接成功", "请完成其他信息填写并提交。
详细信息:" + data.msg, "success"); $("input[name='DbConfig_servername']").attr("readonly", true); // 禁用修改,防止提交后出错 $("input[name='DbConfig_username']").attr("readonly", true); - $("input[name='DbConfig_password']").attr("readonly", true); + $("input[name='DbConfig_DBPassword']").attr("readonly", true); $("input[name='DbConfig_dbname']").attr("readonly", true); SQLConnect = true; } else { ; // 连接失败 - Swal.fire({ - title: "数据库连接错误", - html: "请检查你的数据库设置,并重新提交。
详细信息:" + data.msg, - icon: "error" - }); + Swal.fire("数据库连接错误", "请检查你的数据库设置,并重新提交。
详细信息:" + data.msg, "error"); } } }); @@ -420,38 +398,26 @@ function CheckMySQLConnect() { } function CheckForm() { - Swal.fire("正在安装,请稍等"); - Swal.showLoading() + Swal.fire("正在安装,请稍等……"); + Swal.showLoading(); USING_DB = $("input[name='USING_DB']:checked").val(); ADMIN_PASSWORDLength = $("input[name='ADMIN_PASSWORD']").val().length; if (ADMIN_PASSWORDLength < 6) { // 密码过短 - Swal.fire({ - title: "密码过短", - html: "请检查你设置的密码,为保证站点安全,管理员密码必须为6位或6位以上。", - icon: "warning" - }) + Swal.fire("密码过短", "请检查你设置的密码,为保证站点安全,管理员密码必须为6位或6位以上。", "warning"); return 0; } if (USING_DB == "true") { if (!SQLConnect) { // 暂未连接数据库 - Swal.fire({ - title: "暂未连接数据库", - html: "请先点击检查数据库连接按钮,再提交数据。", - icon: "warning" - }) + Swal.fire("暂未连接数据库", "请先点击检查数据库连接按钮,再提交数据。", "warning"); return 0; } } AgreeCheck = $("#AgreeCheck").prop("checked"); if (AgreeCheck == false) { - Swal.fire({ - title: "请同意保留版权信息", - html: "请同意保留版权信息,再点击提交。", - icon: "warning" - }) + Swal.fire("请同意保留版权信息", "请同意保留版权信息,再点击提交。", "warning"); return 0; } $("#SettingForm").submit(); // 提交表格 @@ -488,14 +454,14 @@ function CheckForm() { $USING_DB = (!empty($_POST["USING_DB"])) ? $_POST["USING_DB"] : "false"; $servername = (!empty($_POST["DbConfig_servername"])) ? $_POST["DbConfig_servername"] : ""; $username = (!empty($_POST["DbConfig_username"])) ? $_POST["DbConfig_username"] : ""; - $password = (!empty($_POST["DbConfig_password"])) ? $_POST["DbConfig_password"] : ""; + $DBPassword = (!empty($_POST["DbConfig_DBPassword"])) ? $_POST["DbConfig_DBPassword"] : ""; $dbname = (!empty($_POST["DbConfig_dbname"])) ? $_POST["DbConfig_dbname"] : ""; $dbtable = (!empty($_POST["DbConfig_dbtable"])) ? $_POST["DbConfig_dbtable"] : ""; $ReserveDBData = (!empty($_POST["ReserveDBData"])) ? $_POST["ReserveDBData"] : "false"; // 是否保存以前数据库数据 未选中不会提交 if ($USING_DB == "true") { //注意判断要用string类型进行 // 连接数据库 - $conn = mysqli_connect($servername, $username, $password, $dbname); + $conn = mysqli_connect($servername, $username, $DBPassword, $dbname); // Check connection if (!$conn) { die("数据库连接错误,详细信息:" . mysqli_connect_error()); @@ -548,7 +514,7 @@ function CheckForm() { $update_config = str_replace('', $USING_DB, $update_config); $update_config = str_replace('', $servername, $update_config); $update_config = str_replace('', $username, $update_config); - $update_config = str_replace('', $password, $update_config); + $update_config = str_replace('', $DBPassword, $update_config); $update_config = str_replace('', $dbname, $update_config); $update_config = str_replace('', $dbtable, $update_config); @@ -560,7 +526,7 @@ function CheckForm() { die("写入 config.php 文件失败,请检查 config.php 文件状态及当前用户权限。"); } header('Refresh: 5;url=./'); - echo "恭喜你!你的安装成功了~
浏览器将会在5s内自动跳转,若没有跳转可点此链接前往主页查看。"; + echo "恭喜你!安装成功了~
浏览器将会在5s内自动跳转,若没有跳转可点此链接前往主页查看。"; } ?>
diff --git a/install/config_raw b/install/config_raw index 2caf2bac..7dfcd0cf 100644 --- a/install/config_raw +++ b/install/config_raw @@ -3,17 +3,17 @@ * PanDownload 网页复刻版,PHP 语言版配置文件 * !!!请勿修改本文件,如果手动修改后再在后台设置,可能导致config.php文件被清空!!! * - * @version 2.0.0 + * @version 2.1.0 * @author Yuan_Tuo * @link https://imwcr.cn/ * @link https://space.bilibili.com/88197958 */ -const programVersion = '2.0.0'; +const programVersion = '2.1.0'; 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禁止直接访问!"); } const Sitename = ''; const BDUSS = ''; const STOKEN = ''; const SVIP_BDUSS = ''; const IsCheckPassword = ; const Password = ''; const Footer = '
'; const APP_ID = '250528'; const DEBUG = false; const USING_DB = ; -const DbConfig = array("servername" => "", "username" => "", "password" => "", "dbname" => "", "dbtable" => ""); +const DbConfig = array("servername" => "", "username" => "", "DBPassword" => "", "dbname" => "", "dbtable" => ""); const ADMIN_PASSWORD = ''; const DownloadTimes = ; const IsConfirmDownload = ; \ No newline at end of file diff --git a/settings.php b/settings.php index 28c56482..5f300d6d 100644 --- a/settings.php +++ b/settings.php @@ -5,13 +5,12 @@ * * 设置及后台功能 * - * @version 2.0.0 - * * @author Yuan_Tuo * @link https://imwcr.cn/ * @link https://space.bilibili.com/88197958 * */ +$programVersion_Settings = '2.1.0'; session_start(); define('init', true); if (version_compare(PHP_VERSION, '7.0.0', '<')) { @@ -20,14 +19,27 @@ header('Refresh: 5;url=https://www.php.net/downloads.php'); die("HTTP 503 服务不可用!\r\nPHP 版本过低!无法正常运行程序!\r\n请安装 7.0.0 或以上版本的 PHP!\r\n将在五秒内跳转到 PHP 官方下载页面!"); } -if (!(file_exists('config.php') && 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 储存库!"); } // 导入配置和函数 -require('config.php'); +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_Settings !== 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'); diff --git a/usersettings.php b/usersettings.php index cbffc661..dc189a2c 100644 --- a/usersettings.php +++ b/usersettings.php @@ -10,12 +10,22 @@ * @link https://space.bilibili.com/88197958 * */ +$programVersion_UserSettings = '2.1.0'; if (!defined('init')) { // 直接访问处理程序 header('Content-Type: text/plain; charset=utf-8'); if (!file_exists('config.php')) { http_response_code(503); - header('Refresh: 5;url=https://github.com/yuantuo666/baiduwp-php'); - die("HTTP 503 服务不可用!\r\n缺少相关配置和定义文件!无法正常运行程序!\r\n请重新 Clone 项目并配置!\r\n将在五秒内跳转到 GitHub 储存库!"); + 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_UserSettings !== 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 项目并配置!"); + } } http_response_code(403); header('Refresh: 3;url=./'); From 5b8688659c9a02b4e5863d4c0bf09908b9a7ccde Mon Sep 17 00:00:00 2001 From: LC <64722907+lc6464@users.noreply.github.com> Date: Tue, 16 Feb 2021 00:41:17 +0800 Subject: [PATCH 05/18] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20install.php=20?= =?UTF-8?q?=E4=B8=AD=20JavaScript=20=E5=88=86=E5=8F=B7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 `install.php` 中 JavaScript 的分号问题。 --- install.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/install.php b/install.php index 272c761b..887f2a74 100644 --- a/install.php +++ b/install.php @@ -367,7 +367,7 @@ function getDbConfig(&$var, string $key) function CheckMySQLConnect() { Swal.fire("正在连接数据库,请稍等"); - Swal.showLoading() + Swal.showLoading(); servername = $("input[name='DbConfig_servername']").val(); username = $("input[name='DbConfig_username']").val(); DBPassword = $("input[name='DbConfig_DBPassword']").val(); @@ -388,7 +388,6 @@ function CheckMySQLConnect() { $("input[name='DbConfig_dbname']").attr("readonly", true); SQLConnect = true; } else { - ; // 连接失败 Swal.fire("数据库连接错误", "请检查你的数据库设置,并重新提交。
详细信息:" + data.msg, "error"); } @@ -536,4 +535,4 @@ function CheckForm() { - \ No newline at end of file + From bdb55c1d92d4af46c354991c167d03b791143379 Mon Sep 17 00:00:00 2001 From: yuantuo666 Date: Tue, 16 Feb 2021 11:08:22 +0800 Subject: [PATCH 06/18] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8D=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=89=B2=E5=BD=A9=E6=A8=A1=E5=BC=8F=E7=9A=84=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BASweetaler?= =?UTF-8?q?t=E5=BC=B9=E7=AA=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/color.js | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/static/color.js b/static/color.js index 3b01dde6..8bad9cd8 100644 --- a/static/color.js +++ b/static/color.js @@ -1,27 +1,16 @@ const colorMode = localStorage.getItem('colorMode'); // 获取色彩模式配置 if (colorMode === null) { // 若没有配置(跟随浏览器) - if (window.matchMedia('(prefers-color-scheme: dark)').matches) { // 深色模式 - document.querySelector('#ColorMode-Dark').disabled = false; - document.querySelector('#Swal2-Dark').disabled = false; - } else if (window.matchMedia('(prefers-color-scheme: light)').matches) { // 浅色模式 - document.querySelector('#ColorMode-Dark').disabled = true; - document.querySelector('#Swal2-Light').disabled = false; - } -} else if (colorMode === 'dark') { // 深色模式 - document.querySelector('#ColorMode-Dark').disabled = false; - document.querySelector('#Swal2-Dark').disabled = false; -} else if (colorMode === 'light') { // 浅色模式 - document.querySelector('#ColorMode-Dark').disabled = true; - document.querySelector('#Swal2-Light').disabled = false; -} else { // 配置错误时的自动纠正程序 + if (window.matchMedia('(prefers-color-scheme: dark)').matches) DarkMod(); // 深色模式 + else if (window.matchMedia('(prefers-color-scheme: light)').matches) LightMod();// 浅色模式 + else LightMod(); // 对于不支持选择的老版本浏览器,启用浅色模式 +} else if (colorMode === 'dark') DarkMod(); // 深色模式 +else if (colorMode === 'light') LightMod(); // 浅色模式 +else { // 配置错误时的自动纠正程序 localStorage.removeItem('colorMode'); - if (window.matchMedia('(prefers-color-scheme: dark)').matches) { - document.querySelector('#ColorMode-Dark').disabled = false; - document.querySelector('#Swal2-Dark').disabled = false; - } else if (window.matchMedia('(prefers-color-scheme: light)').matches) { - document.querySelector('#ColorMode-Dark').disabled = true; - document.querySelector('#Swal2-Light').disabled = false; - } + if (window.matchMedia('(prefers-color-scheme: dark)').matches) DarkMod(); + else if (window.matchMedia('(prefers-color-scheme: light)').matches) LightMod(); + else LightMod(); // 对于不支持选择的老版本浏览器,启用浅色模式 + document.addEventListener('DOMContentLoaded', function () { Swal.fire({ title: '错误', @@ -32,4 +21,13 @@ if (colorMode === null) { // 若没有配置(跟随浏览器) location.reload(); }); }); +} + +function LightMod() { + document.querySelector('#ColorMode-Dark').disabled = true; + document.querySelector('#Swal2-Light').disabled = false; +} +function DarkMod() { + document.querySelector('#ColorMode-Dark').disabled = false; + document.querySelector('#Swal2-Light').disabled = false; } \ No newline at end of file From 3280a557883dda5cea8b7fd90f1fd47b1b05d6af Mon Sep 17 00:00:00 2001 From: yuantuo666 Date: Tue, 16 Feb 2021 11:17:32 +0800 Subject: [PATCH 07/18] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddl=5Ferror()=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.php | 3 ++- static/color.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index 8cba0165..68e0b550 100644 --- a/functions.php +++ b/functions.php @@ -138,6 +138,7 @@ function CheckPassword(bool $IsReturnBool = false) } if (!$return) { // 若 $IsReturnBool 为 false 且验证失败,则执行 dl_error dl_error("密码错误", "请检查你输入的密码!"); + exit; // 结束进程 } } else { // 若不校验密码则永远 true return true; @@ -246,7 +247,7 @@ function dl_error(string $title, string $content, bool $jumptip = false) } echo '
'); + echo '

'; // 仅仅弹出提示框,并不结束进程 } function get_BDCLND($surl, $Pwd) { diff --git a/static/color.js b/static/color.js index 8bad9cd8..a793b758 100644 --- a/static/color.js +++ b/static/color.js @@ -29,5 +29,5 @@ function LightMod() { } function DarkMod() { document.querySelector('#ColorMode-Dark').disabled = false; - document.querySelector('#Swal2-Light').disabled = false; + document.querySelector('#Swal2-Dark').disabled = false; } \ No newline at end of file From 969bf3999bf7b12f5909574b7d613142a0a0d2b1 Mon Sep 17 00:00:00 2001 From: yuantuo666 Date: Tue, 16 Feb 2021 11:26:03 +0800 Subject: [PATCH 08/18] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E6=B2=A1=E6=9C=89=E6=95=B0=E6=8D=AE=E6=8F=90=E7=A4=BA?= =?UTF-8?q?Error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api.php b/api.php index beaf9173..c2bbd1ca 100644 --- a/api.php +++ b/api.php @@ -76,7 +76,7 @@ "sviptips" => $SvipTips )); } else { - EchoInfo(0, array("msg" => "数据库中没有数据")); + EchoInfo(-1, array("msg" => "数据库中没有数据", "sviptips" => "Unknown")); } } else { // 未开启数据库 From 279603abb13f31efa1801b6e4a7d8bd842d1cd74 Mon Sep 17 00:00:00 2001 From: lc6464 <64722907+lc6464@users.noreply.github.com> Date: Tue, 16 Feb 2021 13:55:35 +0800 Subject: [PATCH 09/18] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=97=B6=20html=20=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E4=B8=8D=E5=AE=8C=E6=95=B4=E7=9A=84=20bug;=20=E5=8E=8B?= =?UTF-8?q?=E7=BC=A9=E9=83=A8=E5=88=86=E5=8A=A8=E6=80=81=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E7=9A=84=20JavaScript=20=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.php | 23 ++++++++++++++++++++++- index.php | 49 +++++++++++++++++++++++++++++-------------------- 2 files changed, 51 insertions(+), 21 deletions(-) diff --git a/functions.php b/functions.php index 68e0b550..67c6cdc7 100644 --- a/functions.php +++ b/functions.php @@ -137,8 +137,10 @@ function CheckPassword(bool $IsReturnBool = false) return $return; } if (!$return) { // 若 $IsReturnBool 为 false 且验证失败,则执行 dl_error + global $system_start_time; dl_error("密码错误", "请检查你输入的密码!"); - exit; // 结束进程 + echo Footer; + die(''); } } else { // 若不校验密码则永远 true return true; @@ -313,3 +315,22 @@ function GetList(string $Shorturl, string $Dir, bool $IsRoot, string $Password) } return $result; } +$getConstant = function (string $name) { + return constant($name); +}; +$JSCode = array("get" => function (string $value) { + $value = preg_replace('# *//.*#', '', $value); + $value = preg_replace('#/\*.*?\*/#s', '', $value); + $value = preg_replace('#(\r?\n|\t| ){2,}#', '$1', $value); + $value = preg_replace('#([,;{])[ \t]*?\r?\n[ \t]*([^ \t])#', '$1 $2', $value); + $value = preg_replace('#(\r?\n|\t| ){2,}#', '$1', $value); + $value = preg_replace('#([^ \t])[ \t]*?\r?\n[ \t]*?\}#', '$1 }', $value); + $value = preg_replace('#(\r?\n|\t| ){2,}#', '$1', $value); + $value = preg_replace('#([,;{])\t+#', '$1 ', $value); + $value = preg_replace('#\t+\}#', ' }', $value); + $value = preg_replace('#(\r?\n|\t| ){2,}#', '$1', $value); + return $value; +}, "echo" => function (string $value) { + global $JSCode; + echo $JSCode['get']($value); +}); diff --git a/index.php b/index.php index aaf060ef..4d0d8393 100644 --- a/index.php +++ b/index.php @@ -87,26 +87,35 @@ - + }); +} +Function + ); + } else { + echo 'let confirmdl = dl;'; + } + echo ''; + } + ?> @@ -138,7 +147,7 @@ function confirmdl(fs_id, timestamp, sign, randsk, share_id, uk, bdstoken, files } elseif (isset($_GET["usersettings"])) { // 用户设置页面 require("usersettings.php"); } elseif (isset($_POST["surl"])) { // 解析链接页面 - echo ''; + echo ''; CheckPassword(); $surl = $_POST["surl"]; // 含有1 $pwd = (!empty($_POST["pwd"])) ? $_POST["pwd"] : ""; From 9632a67415c63540a3a6b8aa1a6b578d958e59ee Mon Sep 17 00:00:00 2001 From: yuantuo666 Date: Tue, 16 Feb 2021 17:50:43 +0800 Subject: [PATCH 10/18] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=80=E7=9B=B4=E4=B8=BA2.00GB=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20Close=20#67?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api.php | 4 ++-- index.php | 4 ++-- settings.php | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api.php b/api.php index c2bbd1ca..80c463be 100644 --- a/api.php +++ b/api.php @@ -95,7 +95,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" => "当前数据库版本不支持此统计操作")); @@ -107,7 +107,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" => "当前数据库版本不支持此统计操作")); diff --git a/index.php b/index.php index 4d0d8393..87618b90 100644 --- a/index.php +++ b/index.php @@ -201,7 +201,7 @@ function confirmdl(fs_id, timestamp, sign, randsk, share_id, uk, bdstoken, files $file = $filejson["list"][$i]; if ($file["isdir"] === 0) $filecontent .= '
  • ' . $file["server_filename"] . ' - ' . formatSize($file["size"]) . '
  • '; + ' . formatSize((float)$file["size"]) . ''; else $filecontent .= '
  • ' . $file["server_filename"] . '
  • '; } @@ -234,7 +234,7 @@ function confirmdl(fs_id, timestamp, sign, randsk, share_id, uk, bdstoken, files $file = $filejson["list"][$i]; if ($file["isdir"] === 0) $filecontent .= '
  • ' . $file["server_filename"] . ' - ' . formatSize($file["size"]) . '
  • '; + ' . formatSize((float)$file["size"]) . ''; else $filecontent .= '
  • ' . $file["server_filename"] . '
  • '; } diff --git a/settings.php b/settings.php index 5f300d6d..69a9bc7b 100644 --- a/settings.php +++ b/settings.php @@ -169,7 +169,7 @@ function GetAnalyseTablePage(string $page) " . $Result["userip"] . " " . $Result["filename"] . " - " . formatSize((int)$Result["size"]) . " + " . formatSize((float)$Result["size"]) . " " . $Result["path"] . " " . substr($Result["realLink"], 0, 35) . "…… " . $Result["ptime"] . "" . $Result["paccount"] . " @@ -438,7 +438,7 @@ function AnalyseLoadmore() { if ($Result = mysqli_fetch_assoc($Result)) { $AllCount = $Result["AllCount"]; - $AllSize = ($AllCount == "0") ? "无数据" : formatSize((int)$Result["AllSize"]); // 格式化获取到的文件大小 + $AllSize = ($AllCount == "0") ? "无数据" : formatSize((float)$Result["AllSize"]); // 格式化获取到的文件大小 $ParseCountMsg = "累计解析次数:$AllCount 个
    累计解析大小:$AllSize"; } @@ -691,7 +691,7 @@ function IPLoadmore() { $Result = mysqli_fetch_assoc(mysqli_query($conn, $sql)); // 存在数据 $AllCount = $Result["AllCount"]; - $AllSize = formatSize((int)$Result["AllSize"]); // 格式化获取到的文件大小 + $AllSize = formatSize((float)$Result["AllSize"]); // 格式化获取到的文件大小 echo "累计解析 $AllCount 个,共 $AllSize"; ?>
    @@ -700,7 +700,7 @@ function IPLoadmore() { $Result = mysqli_fetch_assoc(mysqli_query($conn, $sql)); // 存在数据 $AllCount = $Result["AllCount"]; - $AllSize = formatSize((int)$Result["AllSize"]); // 格式化获取到的文件大小 + $AllSize = formatSize((float)$Result["AllSize"]); // 格式化获取到的文件大小 echo "今日解析 $AllCount 个,共 $AllSize"; ?>

    From 7aca00f8c001ea773997550f1936731bfd604ae5 Mon Sep 17 00:00:00 2001 From: yuantuo666 Date: Tue, 16 Feb 2021 19:05:09 +0800 Subject: [PATCH 11/18] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 28 ++++++++++++++++------------ functions.php | 4 ++++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index fbf8294f..02f0016d 100644 --- a/README.md +++ b/README.md @@ -69,18 +69,22 @@ PanDownload 网页复刻版,PHP 语言版
    ## New Changes - 当前版本:`2.1.0` - 更新日期:2021-02-16 -- 修改内容 - - 安装程序 `install.php` 自动检测旧版本配置是否存在,若存在自动导入 - - 安装时支持保留数据库数据,后台管理页面支持删除数据库数据 - - 优化部分 PHP 和 JavaScript 代码 - - 修复部分页面检查密码功能失效问题 - - 增加部分配置异常的处理程序 - - 优化提示文本(语法、严谨程度等),给一些提示框增加图标 - - 增加选择是否取消下载次数提醒功能 - - 修复首页小圆点无颜色错误 - - 安装页面提示、UI 优化 - - 修复一些历史遗留 bug - - 修复一些新发现/新出现的 bug + +- 修改内容: + - 新增功能 + - 安装程序 `install.php` 自动检测旧版本配置文件 `config.php` 是否存在,若存在自动导入旧版本配置 + - 增加选择是否取消下载次数提醒功能 + - 安装时支持保留数据库数据 + - 后台管理页面支持删除数据库数据 + - 错误修复 + - 修复部分页面检查密码功能失效问题 + - 修复首页小圆点无颜色错误 + - 修复不支持色彩模式的浏览器无法显示Sweetalert弹窗问题 + - 修复解析数据一直为 `2.00GB` 问题 + - 代码优化 + - 优化提示文本(语法、严谨程度等),给一些提示框增加图标 + - 增加部分配置异常的处理程序 + - 优化部分 PHP 和 JavaScript 代码 ## Thanks - [baiduwp JavaScript 版](https://github.com/TkzcM/baiduwp "GitHub 项目") diff --git a/functions.php b/functions.php index 67c6cdc7..8d25989e 100644 --- a/functions.php +++ b/functions.php @@ -318,6 +318,10 @@ function GetList(string $Shorturl, string $Dir, bool $IsRoot, string $Password) $getConstant = function (string $name) { return constant($name); }; +/* + * 优化 JavaScript 代码体积 + * beta 版本 + */ $JSCode = array("get" => function (string $value) { $value = preg_replace('# *//.*#', '', $value); $value = preg_replace('#/\*.*?\*/#s', '', $value); From 9458a4cb93d853ee6a127e995acf02cfb312db6c Mon Sep 17 00:00:00 2001 From: yuantuo666 Date: Tue, 16 Feb 2021 22:19:50 +0800 Subject: [PATCH 12/18] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E4=BF=AE=E6=94=B9=20=E4=BF=AE=E5=A4=8D=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E5=AF=86=E7=A0=81=E9=94=99=E8=AF=AF=E4=B8=8D?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=EF=BC=9B=E5=B0=86settings.php=E5=86=85?= =?UTF-8?q?=E9=83=A8=E5=88=86=E8=AF=B7=E6=B1=82=E6=96=B9=E5=BC=8F=E6=94=B9?= =?UTF-8?q?=E4=B8=BAajax=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=A1=86=EF=BC=9B=20=E5=B0=86settings.php?= =?UTF-8?q?=E4=B8=ADapi=E6=93=8D=E4=BD=9C=E8=BD=AC=E7=A7=BB=E5=88=B0api.ph?= =?UTF-8?q?p=E4=B8=AD=EF=BC=9B=E5=B0=86settings.php=E4=B8=AD=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=87=BD=E6=95=B0=E7=A7=BB=E5=8A=A8=E5=88=B0functions?= =?UTF-8?q?.php=E4=B8=AD=20(=E7=B4=AF=E6=AD=BB=E4=BA=86,,=E6=95=B4?= =?UTF-8?q?=E4=BA=863=E5=B0=8F=E6=97=B6QAQ)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api.php | 181 +++++++++++++++++++++-- functions.php | 97 +++++++++++++ index.php | 3 +- settings.php | 386 +++++++++++++------------------------------------- 4 files changed, 369 insertions(+), 298 deletions(-) diff --git a/api.php b/api.php index 80c463be..96ae9189 100644 --- a/api.php +++ b/api.php @@ -53,7 +53,179 @@ } 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 "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状态 @@ -156,11 +328,4 @@ default: EchoInfo(-1, array("msg" => "无传入数据")); break; -} - -function EchoInfo(int $error, array $Result) -{ - $ReturnArray = array("error" => $error); - $ReturnArray += $Result; - echo json_encode($ReturnArray); -} +} \ No newline at end of file diff --git a/functions.php b/functions.php index 8d25989e..62bd87de 100644 --- a/functions.php +++ b/functions.php @@ -338,3 +338,100 @@ function GetList(string $Shorturl, string $Dir, bool $IsRoot, string $Password) global $JSCode; echo $JSCode['get']($value); }); +/* + * 将Settings.php里面的代码移到functionS.php里面来 + * 方便api调用 + */ +function EchoInfo(int $error, array $Result) +{ + $ReturnArray = array("error" => $error); + $ReturnArray += $Result; + echo json_encode($ReturnArray); +} +function GetAnalyseTablePage(string $page) +{ + if ($page <= 0) exit; + $EachPageNum = 10; + $conn = $GLOBALS['conn']; + $dbtable = $GLOBALS['dbtable']; + $AllRow = ""; + $StartNum = ((int)$page - 1) * $EachPageNum; + $sql = "SELECT * FROM `$dbtable` ORDER BY `ptime` DESC LIMIT $StartNum,$EachPageNum"; + $mysql_query = mysqli_query($conn, $sql); + while ($Result = mysqli_fetch_assoc($mysql_query)) { + // 存在数据 + $EachRow = " + " . $Result["id"] . " +
    + 删除 +
    + " . $Result["userip"] . " + " . $Result["filename"] . " + " . formatSize((float)$Result["size"]) . " + " . $Result["path"] . " + " . substr($Result["realLink"], 0, 35) . "…… + " . $Result["ptime"] . "" . $Result["paccount"] . " + "; + $AllRow .= $EachRow; + } + return $AllRow; +} +function GetSvipTablePage(string $page) +{ + if ($page <= 0) exit; + $EachPageNum = 10; + $conn = $GLOBALS['conn']; + $dbtable = $GLOBALS['dbtable']; + $AllRow = ""; + $StartNum = ((int)$page - 1) * $EachPageNum; + $sql = "SELECT * FROM `" . $dbtable . "_svip` ORDER BY `id` DESC LIMIT $StartNum,$EachPageNum"; + $mysql_query = mysqli_query($conn, $sql); + while ($Result = mysqli_fetch_assoc($mysql_query)) { + // 存在数据 + $is_using = ($Result["is_using"] != "0000-00-00 00:00:00") ? $Result["is_using"] : ""; + $state = ($Result["state"] == -1) ? "限速" : "正常"; + $EachRow = " + " . $Result["id"] . " + + " . $is_using . " + " . $Result["name"] . " + " . $state . " + " . $Result["add_time"] . " + " . substr($Result["svip_bduss"], 0, 20) . "…… + " . substr($Result["svip_stoken"], 0, 20) . "…… + "; + $AllRow .= $EachRow; + } + return $AllRow; +} // name 账号名称 svip_bduss 会员bduss svip_stoken 会员stoken add_time 会员账号加入时间 state 会员状态(0:正常,-1:限速) is_using 是否正在使用(非零表示真) +function GetIPTablePage(string $page) +{ + if ($page <= 0) exit; + $EachPageNum = 10; + $conn = $GLOBALS['conn']; + $dbtable = $GLOBALS['dbtable']; + $AllRow = ""; + $StartNum = ((int)$page - 1) * $EachPageNum; + $sql = "SELECT * FROM `" . $dbtable . "_ip` ORDER BY `id` DESC LIMIT $StartNum,$EachPageNum"; + $mysql_query = mysqli_query($conn, $sql); + while ($Result = mysqli_fetch_assoc($mysql_query)) { + // 存在数据 + $type = ($Result["type"] == -1) ? "黑名单" : "白名单"; + $EachRow = " + " . $Result["id"] . " +
    + 删除 +
    + " . $Result["ip"] . " + " . $type . " + " . $Result["remark"] . " + " . $Result["add_time"] . " + "; + $AllRow .= $EachRow; + } + return $AllRow; +} diff --git a/index.php b/index.php index 87618b90..797897e6 100644 --- a/index.php +++ b/index.php @@ -261,6 +261,7 @@ function getip() return $ip; } $ip = getip(); + $isipwhite = FALSE; //初始化 防止报错 if (USING_DB) { connectdb(); @@ -349,7 +350,7 @@ function getip() } // 获取SVIP BDUSS - $sql = "SELECT `id`,`svip_bduss` FROM `" . $dbtable . "_svip` WHERE `state`!=-1 ORDER BY `is_using` DESC LIMIT 0,1"; // 时间倒序输出第一项未被限速账号 + $sql = "SELECT `id`,`svip_bduss` FROM `" . $dbtable . "_svip` WHERE `state`!=-1 ORDER BY `is_using`,`id` DESC LIMIT 0,1"; // 时间倒序输出第一项未被限速账号 $Result = mysqli_query($conn, $sql); if ($Result = mysqli_fetch_assoc($Result)) { $SVIP_BDUSS = $Result["svip_bduss"]; diff --git a/settings.php b/settings.php index 69a9bc7b..a5cec5a3 100644 --- a/settings.php +++ b/settings.php @@ -61,182 +61,10 @@ } else { // 密码错误 $_SESSION["admin_login"] = false; - echo ""; + $PasswordError = true; } } if ($is_login) connectdb(); -if ($method == "API" and $is_login) { - $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 "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 "IPGetTable": - $page = (!empty($_GET["page"])) ? $_GET["page"] : ""; - echo GetIPTablePage($page); - 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: - echo "

    没有参数传入

    "; - break; - } - exit; -} - -function EchoInfo(int $error, array $Result) -{ - $ReturnArray = array("error" => $error); - $ReturnArray += $Result; - echo json_encode($ReturnArray); -} - -function GetAnalyseTablePage(string $page) -{ - if ($page <= 0) exit; - $EachPageNum = 10; - $conn = $GLOBALS['conn']; - $dbtable = $GLOBALS['dbtable']; - $AllRow = ""; - $StartNum = ((int)$page - 1) * $EachPageNum; - $sql = "SELECT * FROM `$dbtable` ORDER BY `ptime` DESC LIMIT $StartNum,$EachPageNum"; - $mysql_query = mysqli_query($conn, $sql); - while ($Result = mysqli_fetch_assoc($mysql_query)) { - // 存在数据 - $EachRow = " - " . $Result["id"] . " -
    - 删除 -
    - " . $Result["userip"] . " - " . $Result["filename"] . " - " . formatSize((float)$Result["size"]) . " - " . $Result["path"] . " - " . substr($Result["realLink"], 0, 35) . "…… - " . $Result["ptime"] . "" . $Result["paccount"] . " - "; - $AllRow .= $EachRow; - } - return $AllRow; -} -function GetSvipTablePage(string $page) -{ - if ($page <= 0) exit; - $EachPageNum = 10; - $conn = $GLOBALS['conn']; - $dbtable = $GLOBALS['dbtable']; - $AllRow = ""; - $StartNum = ((int)$page - 1) * $EachPageNum; - $sql = "SELECT * FROM `" . $dbtable . "_svip` ORDER BY `id` DESC LIMIT $StartNum,$EachPageNum"; - $mysql_query = mysqli_query($conn, $sql); - while ($Result = mysqli_fetch_assoc($mysql_query)) { - // 存在数据 - $is_using = ($Result["is_using"] != "0000-00-00 00:00:00") ? $Result["is_using"] : ""; - $state = ($Result["state"] == -1) ? "限速" : "正常"; - $EachRow = " - " . $Result["id"] . " - - " . $is_using . " - " . $Result["name"] . " - " . $state . " - " . $Result["add_time"] . " - " . substr($Result["svip_bduss"], 0, 20) . "…… - " . substr($Result["svip_stoken"], 0, 20) . "…… - "; - $AllRow .= $EachRow; - } - return $AllRow; -} // name 账号名称 svip_bduss 会员bduss svip_stoken 会员stoken add_time 会员账号加入时间 state 会员状态(0:正常,-1:限速) is_using 是否正在使用(非零表示真) -function GetIPTablePage(string $page) -{ - if ($page <= 0) exit; - $EachPageNum = 10; - $conn = $GLOBALS['conn']; - $dbtable = $GLOBALS['dbtable']; - $AllRow = ""; - $StartNum = ((int)$page - 1) * $EachPageNum; - $sql = "SELECT * FROM `" . $dbtable . "_ip` ORDER BY `id` DESC LIMIT $StartNum,$EachPageNum"; - $mysql_query = mysqli_query($conn, $sql); - while ($Result = mysqli_fetch_assoc($mysql_query)) { - // 存在数据 - $type = ($Result["type"] == -1) ? "黑名单" : "白名单"; - $EachRow = " - " . $Result["id"] . " -
    - 删除 -
    - " . $Result["ip"] . " - " . $type . " - " . $Result["remark"] . " - " . $Result["add_time"] . " - "; - $AllRow .= $EachRow; - } - return $AllRow; -} - ?> @@ -259,19 +87,8 @@ function GetIPTablePage(string $page) + - @@ -284,14 +101,24 @@ function DeleteById(Type, Id) {
    -
    Pandownload复刻版-后台登录
    +
    Pandownload复刻版 - 后台登录
    -
    +
    - 密码是中文,别想破解了~ + 忘记密码可进入config.php中查看~
    - + +
    +
    @@ -343,71 +170,23 @@ function DeleteById(Type, Id) { 加载更多 - Swal.fire('新增成功');"; - else { - $Error = addslashes(mysqli_error($conn)); - echo ""; - } - } else { - echo ""; - } - } - if (isset($_POST["MULTI_BDUSS"])) { - $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) { - $Msg = "错误在" . $sccess_result . "行"; - } else { - $Msg = "成功导入" . $sccess_result . "条数据"; - } - echo ""; - } else { - echo ""; - } - } - - ?> +