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

Commit

Permalink
SQL 注入问题、更新提示问题、响应头问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lc6464 committed Jul 22, 2021
1 parent e3433f9 commit 5e60ec5
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 51 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# 配置文件
config.php
# 配置文件等
.vscode/
config.php
update.json
config/
cache/
update/

# 用户文件
notice.html
Expand Down
30 changes: 10 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,14 @@ PanDownload 网页复刻版,PHP 语言版<br/>
**SVIP账号**中可设置**SVIP账号****BDUSS****STOKEN**,添加账号后记得进入**会员账号切换模式**将模式改成**顺序模式****轮换模式**。<br />

## 📦New Changes
- 当前版本: `2.1.9`
- 更新日期:2021-07-14
- 当前版本: `2.1.9.1`
- 更新日期:2021-07-22
- 修改内容:
- 新增功能
- 下载链接生成二维码 #123
- 自动检查更新
- 功能优化
- 在跟随浏览器模式下,颜色模式随浏览器设置实时更新
- 优化颜色模式逻辑
- 优化用户设置页面前端逻辑
- 优化二维码生成
- 优化样式表加载
- 优化 JS 逻辑和加载
- 错误修复
- 修复了正则表达式有误导致的子域名无法正常使用 Aira2 下载问题 #137
- 其它
- 更新 .gitignore
- 格式化代码
- 安全性更新
- 修复 API SQL 注入问题 #148
- 问题修复
- 修复 `install``settings` 页面更新提示有误的问题
- 修复 `install` 写入 HTTP 响应正文后仍写入响应头的 bug(取消了自动跳转功能)


[查看更多](Update.md)
Expand All @@ -98,15 +88,15 @@ PanDownload 网页复刻版,PHP 语言版<br/>
- Telegram:
- [@yuantuo666](https://t.me/yuantuo666)
- [Telegram频道](https://t.me/baiduwp_php)
- 协作者:LC @lc6464
- 合作者:LC @lc6464
- [个人网站](https://lcwebsite.cn/ "LC的网站")
- [联系](https://lcwebsite.cn/web/contact.aspx "联系 LC")

**作者及合作者都是学生,因未来一段时间课余时间很少,对此项目维护将会减少。** #130<br />
如果遇到问题请先 **仔细阅读此文档** 、查看[视频教程](https://www.bilibili.com/video/BV1N5411A77n)
以及 [以前的议题](https://github.com/yuantuo666/baiduwp-php/issues)<br />
以及查看[以前的议题](https://github.com/yuantuo666/baiduwp-php/issues)<br />

如果是**设置账号的 Cookies(BDUSS 和 STOKEN)配置环境**相关的问题,请尽可能自行解决![Google](https://www.google.com/ "谷歌") [Bing](https://cn.bing.com/ "必应")<br />
如果是**设置账号的 Cookies(BDUSS 和 STOKEN)****配置环境**等方面的问题,请尽可能自行解决![Google](https://www.google.com/ "谷歌") [Bing](https://cn.bing.com/ "必应")<br />


## 🔔Thanks
Expand Down
9 changes: 9 additions & 0 deletions Update.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# Update
### `2.1.9.1` 版本:
- 更新日期:2021-07-22
- 修改内容:
- 安全性更新
- 修复 API SQL 注入问题 #148
- 问题修复
- 修复 `install``settings` 页面更新提示有误的问题
- 修复 `install` 写入 HTTP 响应正文后仍写入响应头的 bug(取消了自动跳转功能)

### `2.1.9` 版本:
- 更新日期:2021-07-14
- 修改内容:
Expand Down
32 changes: 16 additions & 16 deletions api.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
break;
case "singleBDUSS":
// 先处理是否有新增加数据
$BDUSS = (!empty($_POST["BDUSS"])) ? trim($_POST["BDUSS"]) : "";
$STOKEN = (!empty($_POST["STOKEN"])) ? $_POST["STOKEN"] : "";
$name = (!empty($_POST["name"])) ? $_POST["name"] : "";
$BDUSS = htmlspecialchars((!empty($_POST["BDUSS"])) ? trim($_POST["BDUSS"]) : "", ENT_QUOTES);
$STOKEN = htmlspecialchars((!empty($_POST["STOKEN"])) ? $_POST["STOKEN"] : "", ENT_QUOTES);
$name = htmlspecialchars((!empty($_POST["name"])) ? $_POST["name"] : "", ENT_QUOTES);
if ($BDUSS != "" and strlen($BDUSS) == 192) {
// 开始录入
$add_time = date("Y-m-d H:i:s");
Expand All @@ -86,15 +86,15 @@
break;
case "multiBDUSS":
$BDUSS = (!empty($_POST["MULTI_BDUSS"])) ? trim($_POST["MULTI_BDUSS"]) : "";
$name = (!empty($_POST["name"])) ? $_POST["name"] : "";
$name = htmlspecialchars((!empty($_POST["name"])) ? $_POST["name"] : "", ENT_QUOTES);
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,'');";
$sql = "INSERT INTO `" . $dbtable . "_svip`( `name`, `svip_bduss`, `add_time`, `state`, `is_using`) VALUES ('$name-" . ($i + 1) . "','" . htmlspecialchars($AllBduss[$i], ENT_QUOTES) . "','$add_time',1,'');";
$allsql .= $sql;
}

Expand All @@ -112,7 +112,7 @@
} else EchoInfo(-1, array("msg" => "添加失败", "detail" => "请检查BDUSS是否填写正确"));
break;
case "SvipSettingFirstAccount":
$id = (!empty($_GET["id"])) ? $_GET["id"] : "";
$id = htmlspecialchars((!empty($_GET["id"])) ? $_GET["id"] : "", ENT_QUOTES);
if ($id == "") {
// 参数错误
EchoInfo(-1, array("msg" => "传入参数错误"));
Expand All @@ -132,7 +132,7 @@
}
break;
case "SvipSettingNormalAccount":
$id = (!empty($_GET["id"])) ? $_GET["id"] : "";
$id = htmlspecialchars((!empty($_GET["id"])) ? $_GET["id"] : "", ENT_QUOTES);
if ($id == "") {
// 参数错误
EchoInfo(-1, array("msg" => "传入参数错误"));
Expand All @@ -154,9 +154,9 @@
echo GetIPTablePage($page);
break;
case "NewIp":
$ip = (!empty($_POST["ip"])) ? trim($_POST["ip"]) : "";
$remark = (!empty($_POST["remark"])) ? $_POST["remark"] : "";
$type = $_POST["type"];
$ip = htmlspecialchars((!empty($_POST["ip"])) ? trim($_POST["ip"]) : "", ENT_QUOTES);
$remark = htmlspecialchars((!empty($_POST["remark"])) ? $_POST["remark"] : "", ENT_QUOTES);
$type = htmlspecialchars($_POST["type"], ENT_QUOTES);
if ($ip != "") {
// 开始录入
$add_time = date("Y-m-d H:i:s");
Expand Down Expand Up @@ -188,7 +188,7 @@
case "DeleteById":
//通过指定表格与ip删除对应行
$Type = (!empty($_GET["type"])) ? $_GET["type"] : "";
$Id = (!empty($_GET["id"])) ? $_GET["id"] : "";
$Id = htmlspecialchars((!empty($_GET["id"])) ? $_GET["id"] : "", ENT_QUOTES);
if ($Type != "" and $Id != "") {
// 开始执行
// 生成SQL
Expand Down Expand Up @@ -294,11 +294,11 @@
break;
case "CheckMySQLConnect":
// 检查数据库连接是否正常
$servername = (!empty($_POST["servername"])) ? $_POST["servername"] : "";
$username = (!empty($_POST["username"])) ? $_POST["username"] : "";
$DBPassword = (!empty($_POST["DBPassword"])) ? $_POST["DBPassword"] : "";
$dbname = (!empty($_POST["dbname"])) ? $_POST["dbname"] : "";
$dbtable = (!empty($_POST["dbtable"])) ? $_POST["dbtable"] : "";
$servername = htmlspecialchars((!empty($_POST["servername"])) ? $_POST["servername"] : "", ENT_QUOTES);
$username = htmlspecialchars((!empty($_POST["username"])) ? $_POST["username"] : "", ENT_QUOTES);
$DBPassword = htmlspecialchars((!empty($_POST["DBPassword"])) ? $_POST["DBPassword"] : "", ENT_QUOTES);
$dbname = htmlspecialchars((!empty($_POST["dbname"])) ? $_POST["dbname"] : "", ENT_QUOTES);
$dbtable = htmlspecialchars((!empty($_POST["dbtable"])) ? $_POST["dbtable"] : "", ENT_QUOTES);
if (!function_exists('mysqli_connect')) {
EchoInfo(-2, array("msg" => "<br/>您未安装或未启用 mysqli 扩展,<br/>不能使用数据库功能。<br/>请自行关闭数据库功能。"));
}
Expand Down
3 changes: 2 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,13 @@ function EchoInfo(int $error, array $Result)
}
function GetAnalyseTablePage(string $page)
{
$page = (int)$page;
if ($page <= 0) exit;
$EachPageNum = 10;
$conn = $GLOBALS['conn'];
$dbtable = $GLOBALS['dbtable'];
$AllRow = "";
$StartNum = ((int)$page - 1) * $EachPageNum;
$StartNum = ($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)) {
Expand Down
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
*
* 此项目 GitHub 地址:https://github.com/yuantuo666/baiduwp-php
*
* @version 2.1.9
* @version 2.1.9.1
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
*
*/
$programVersion_Index = "2.1.9";
$programVersion_Index = "2.1.9.1";
session_start();
define('init', true);
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
Expand Down
9 changes: 4 additions & 5 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@
const div = document.createElement('div');
div.id = 'CheckUpdate';
div.style.margin = '0.3rem 1rem';
div.innerHTML = `Baiduwp-PHP 项目有新的版本:${data.version}(当前版本为${data.now_version})!请联系站长更新! &nbsp;
<a href="${data.page_url}" target="_blank">发行版页面</a> &nbsp; <a href="${data.file_url}" target="_blank">下载程序文件</a>`;
div.innerHTML = `Baiduwp-PHP 项目有新的版本:${data.version}(${data.isPreRelease ? '此版本为预发行版本,' : ''}当前版本为${data.now_version})!请联系站长更新!
&nbsp; <a href="${data.page_url}" target="_blank">发行版页面</a> &nbsp; <a href="${data.file_url}" target="_blank">下载程序文件</a>`;
document.body.insertAdjacentElement('beforeBegin', div);
}
} else if (data.code === 2) {
const div = document.createElement('div');
div.id = 'CheckUpdate';
div.style.margin = '0.3rem 1rem';
div.innerHTML = `Baiduwp-PHP 项目有新的版本:${data.version}${data.isPreRelease ? '此版本为预发行版本,' : ''}当前版本为${data.now_version})!请联系站长更新
div.innerHTML = `Baiduwp-PHP 项目版本异常!当前版本:${data.now_version},项目最新版本为:${data.version}${data.isPreRelease ? '(预发行版本)' : ''}!
&nbsp; <a href="${data.page_url}" target="_blank">发行版页面</a> &nbsp; <a href="${data.file_url}" target="_blank">下载程序文件</a>`;
document.body.insertAdjacentElement('beforeBegin', div);
} else if (data.code === 1) {
Expand Down Expand Up @@ -683,8 +683,7 @@ function CheckForm() {
} else {
die("写入 config.php 文件失败,请检查 config.php 文件状态及当前用户权限。");
}
header('Refresh: 5;url=./');
echo "恭喜你!安装成功了~<br />浏览器将会在5s内自动跳转,若没有跳转可<a href='./'>点此链接</a>前往主页查看。";
echo "恭喜你!安装成功了~<br /><a href='./'>点此链接</a>前往主页查看。";
}
?>
</div>
Expand Down
4 changes: 2 additions & 2 deletions install/config_raw
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* PanDownload 网页复刻版,PHP 语言版配置文件
* !!!请勿修改本文件,如果手动修改后再在后台设置,可能导致config.php文件被清空!!!
*
* @version 2.1.9
* @version 2.1.9.1
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
*/
const programVersion = '2.1.9';
const programVersion = '2.1.9.1';
if (!defined('init')) {
http_response_code(403); header('Content-Type: text/plain; charset=utf-8'); header('Refresh: 3;url=./');
die("HTTP 403 禁止访问!\r\n此文件是 PanDownload 网页复刻版 PHP 语言版项目版本 " . programVersion . " 的配置文件!\r\n禁止直接访问!");
Expand Down
6 changes: 3 additions & 3 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@
const div = document.createElement('div');
div.id = 'CheckUpdate';
div.style.margin = '0.3rem 1rem';
div.innerHTML = `Baiduwp-PHP 项目有新的版本:${data.version}(当前版本为${data.now_version})!请联系站长更新! &nbsp;
<a href="${data.page_url}" target="_blank">发行版页面</a> &nbsp; <a href="${data.file_url}" target="_blank">下载程序文件</a>`;
div.innerHTML = `Baiduwp-PHP 项目有新的版本:${data.version}(${data.isPreRelease ? '此版本为预发行版本,' : ''}当前版本为${data.now_version})!请联系站长更新!
&nbsp; <a href="${data.page_url}" target="_blank">发行版页面</a> &nbsp; <a href="${data.file_url}" target="_blank">下载程序文件</a>`;
document.body.insertAdjacentElement('beforeBegin', div);
}
} else if (data.code === 2) {
const div = document.createElement('div');
div.id = 'CheckUpdate';
div.style.margin = '0.3rem 1rem';
div.innerHTML = `Baiduwp-PHP 项目有新的版本:${data.version}${data.isPreRelease ? '此版本为预发行版本,' : ''}当前版本为${data.now_version})!请联系站长更新
div.innerHTML = `Baiduwp-PHP 项目版本异常!当前版本:${data.now_version},项目最新版本为:${data.version}${data.isPreRelease ? '(预发行版本)' : ''}!
&nbsp; <a href="${data.page_url}" target="_blank">发行版页面</a> &nbsp; <a href="${data.file_url}" target="_blank">下载程序文件</a>`;
document.body.insertAdjacentElement('beforeBegin', div);
} else if (data.code === 1) {
Expand Down
18 changes: 18 additions & 0 deletions updater.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/**
* PanDownload 网页复刻版,PHP 语言版程序下载及更新文件
*
* 功能描述:下载程序文件、更新程序
*
* 此项目 GitHub 地址:https://github.com/yuantuo666/baiduwp-php
*
* @version 2.1.9.1
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
*
*/

$programVersion_Updater = "2.1.9.1";

0 comments on commit 5e60ec5

Please sign in to comment.