Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
更新内容见 README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
lc6464 committed Aug 14, 2020
1 parent f19d942 commit 2214db2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# baiduwp-php
PanDownload 网页复刻版,PHP 语言版<br/>
本项目是依据 [baiduwp](https://github.com/TkzcM/baiduwp) 的 JavaScript 版本改写而来,仅供大家学习参考<br/>
另外使用的时候能不能保留一下作者信息呀(就是菜单栏的 Made by Yuan_Tuo),谢~
本项目是依据 [baiduwp](https://github.com/TkzcM/baiduwp "baiduwp") 的 JavaScript 版本改写而来,仅供大家学习参考<br/>
希望在使用时能够保留导航栏的 Made by Yuan_Tuo 和 Optimized by LC,感谢!
- 原作者 [Yuan_Tuo](https://github.com/yuantuo666 "Yuantuo")
-[LC](https://github.com/lc6464 "LC") 优化

## Demo
[已加密,暂不开放!](https://imwcr.cn/api/bdwp/)
Expand All @@ -26,18 +28,21 @@ define('Password', '请在这里填写密码啦!ヾ(≧▽≦*)o');
- [PNL 下载方式](https://www.lanzous.com/u/pnl "PNL 下载方式")

## New Changes
- 以下修改由 [LC](https://github.com/lc6464 "LC") 完成:2020-8-14
- 配置、函数与程序分离(`php`
- 当前版本:`1.2.2`
- 更新日期:2020-8-14
- 以下修改由 [LC](https://github.com/lc6464 "LC") 完成
- 配置、函数与程序分离(`后端`
- 修复 POST 方法访问 `?download` 参数不齐全出错的问题
- 修复未配置或配置了普通用户的 `BDUSS``STOKEN` 时显示空链接的问题
- 样式、JavaScript 与页面分离(`前端`
- 优化数据传输
- 优化用户体验
- 优化打开文件夹的表现(原来直接提示不可用,现在跳转到百度网盘官方的分享页面)
- 优化程序效率
- 使用函数减少重复工作的代码量
- 增加注释
- 优化前端代码
- 优化后端逻辑和效率
- 优化用户体验
- 优化发生错误时的用户体验

## 坑或不确定
- `static/functions.js`
Expand Down
4 changes: 2 additions & 2 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* 请不要使用弱密码!否则后果自负!
* 若只在局域网开放,则可根据个人喜好开启或关闭密码。
*
* @version 1.2.1
* @version 1.2.2
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
Expand All @@ -22,7 +22,7 @@
* @link https://lcwebsite.cn/
* @link https://space.bilibili.com/52618445
*/
if (!defined('init')){ http_response_code(403); header('Content-Type: text/plain; charset=utf-8'); die('想啥呢?访问这个文件'); } // 直接访问处理程序
if (!defined('init')){ http_response_code(403); header('Content-Type: text/plain; charset=utf-8'); header('Refresh: 3;url=./'); die('想啥呢?直接访问这个文件'); } // 直接访问处理程序

define('BDUSS', ''); // 你的 SVIP BDUSS
define('STOKEN', ''); // 你的 SVIP STOKEN
Expand Down
12 changes: 6 additions & 6 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* 请勿随意修改此文件!如需更改相关配置请到 config.php !
*
* @version 1.2.1
* @version 1.2.2
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
Expand All @@ -16,7 +16,7 @@
* @link https://lcwebsite.cn/
* @link https://space.bilibili.com/52618445
*/
if (!defined('init')){ http_response_code(403); header('Content-Type: text/plain; charset=utf-8'); die('想啥呢?访问这个文件'); } // 直接访问处理程序
if (!defined('init')){ http_response_code(403); header('Content-Type: text/plain; charset=utf-8'); header('Refresh: 3;url=./'); die('想啥呢?直接访问这个文件'); } // 直接访问处理程序

// main
function post($url, $data, array $headerArray) {
Expand Down Expand Up @@ -48,9 +48,9 @@ function head($url, array $headerArray) { // curl 获取响应头
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // 忽略ssl
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // TRUE 将curl_exec()获取的信息以字符串返回,而不是直接输出
curl_setopt($ch, CURLOPT_HEADER, true); // 返回 response header 默认 false 只会获得响应的正文
curl_setopt($ch, CURLOPT_NOBODY, true); // 有时候为了节省带宽及时间,只需要响应头
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // TRUE 将 curl_exec() 获取的信息以字符串返回,而不是直接输出
curl_setopt($ch, CURLOPT_HEADER, true); // 返回 response header
curl_setopt($ch, CURLOPT_NOBODY, true); // 为了节省带宽及时间,只需要响应头
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
$response = curl_exec($ch);
Expand All @@ -68,7 +68,7 @@ function getSubstr($str, $leftStr, $rightStr) {
function formatSize($b, $times = 0) { // 格式化size显示
if ($b > 1024) {
$temp = $b / 1024;
return formatSize($temp, $times + 1);
return formatSize($temp, $times + 1); // 递归处理
} else {
switch ($times) {
case '0':
Expand Down
21 changes: 8 additions & 13 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* 此项目 GitHub 地址:https://github.com/yuantuo666/baiduwp-php
*
* @version 1.2.1
* @version 1.2.2
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
Expand All @@ -22,19 +22,13 @@
*/
// 导入配置和函数
define('init', true);
if (file_exists('config.php')) {
require('config.php');
if (file_exists('config.php') && file_exists('functions.php')) {
require('config.php'); require('functions.php');
} else {
http_response_code(503); header('Content-Type: text/plain; charset=utf-8');
die('缺少配置文件!无法正常运行程序!
请重新 Clone 项目并配置!');
}
if (file_exists('functions.php')) {
require('functions.php');
} else {
http_response_code(503); header('Content-Type: text/plain; charset=utf-8');
die('缺少函数定义文件!无法正常运行程序!
请重新 Clone 项目并配置!');
http_response_code(503); header('Content-Type: text/plain; charset=utf-8'); header('Refresh: 7;url=https://github.com/lc6464/baiduwp-php');
die('缺少相关配置和定义文件!无法正常运行程序!
请重新 Clone 项目并配置!
将在七秒内跳转到 GitHub 储存库!');
}
// 通用响应头
header('Content-Type: text/html; charset=utf-8');
Expand Down Expand Up @@ -72,6 +66,7 @@
<li class="nav-item"><a class="nav-link" href="https://pandownload.com/" target="_blank">度盘下载器</a></li>
<li class="nav-item"><a class="nav-link" href="https://github.com/yuantuo666/baiduwp-php" target="_blank">GitHub 仓库</a></li>
<li class="nav-item"><a class="nav-link" href="https://imwcr.cn/" target="_blank">Made by Yuan_Tuo</a></li>
<li class="nav-item"><a class="nav-link" href="https://lcwebsite.cn/" target="_blank">Optimized by LC</a></li>
</ul>
</div>
</div>
Expand Down

0 comments on commit 2214db2

Please sign in to comment.