Skip to content

Commit

Permalink
Merge pull request #184 from huankong233/dev
Browse files Browse the repository at this point in the history
[*] 为新模式做铺垫
  • Loading branch information
huankong233 committed Aug 10, 2024
2 parents 39c2faa + de60a55 commit a3934de
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ MAIL_FROM_NAME=Example
MAIL_TO_ADDRESS=[email protected]
MAIL_TO_NAME=Example

_94LIST_VERSION=1.3.28
_94LIST_VERSION=1.3.29
_94LIST_SLEEP=3
_94LIST_MAX_ONCE=20
_94LIST_PASSWORD=""
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 2024

### 08-11 v1.3.29

- [*] 为新模式做铺垫

### 08-06 v1.3.28

- [*] 去除限流措施,与cdn存在不兼容问题(待解决后恢复)
Expand Down
92 changes: 47 additions & 45 deletions app/Http/Controllers/ParseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,11 @@ public function getDownloadLinks(Request $request)
// 检查文件数量是否符合用户组配额
if (count($request["fs_ids"]) > $checkLimitData["data"]["count"]) return ResponseController::groupQuotaCountIsNotEnough();

// 检查链接是否有效
$valid = self::getFileList($request);
$validData = $valid->getData(true);
if ($validData["code"] !== 200) return $valid;

// 获取文件列表
$fileList = FileList::query()
->where([
Expand All @@ -559,11 +564,6 @@ public function getDownloadLinks(Request $request)
// 检查文件大小是否符合用户组配额
if (collect($fileList)->sum("size") > $checkLimitData["data"]["size"]) return ResponseController::groupQuotaSizeIsNotEnough();

// 检查链接是否有效
$valid = self::getFileList($request);
$validData = $valid->getData(true);
if ($validData["code"] !== 200) return $valid;

$parse_mode = config("94list.parse_mode");

$ua = config("94list.user_agent");
Expand Down Expand Up @@ -594,47 +594,49 @@ public function getDownloadLinks(Request $request)
$json["vcode_str"] = $request["vcode_str"];
}

// 插入会员账号
$json["cookie"] = [];

// 检查是否指定了账号管理员
if (isset($request["account_ids"]) && $request["account_ids"] !== "") {
$user_id = Auth::check() ? Auth::user()["id"] : 1;
$user = User::query()->find($user_id);
$role = $user["role"];
if ($role !== "admin") return ResponseController::permissionsDenied();

// 判断是否只是一个文件
if (count($request["fs_ids"]) > 1) return ResponseController::onlyOneFile();

$json["fsidlist"] = [];
$request["account_ids"] = explode(",", $request["account_ids"]);
foreach ($request["account_ids"] as $account_id) {
$account = Account::query()->find($account_id);
if (!$account) return ResponseController::accountNotExists();
$arr = ["id" => $account_id];
if (in_array($parse_mode, [5, 10])) {
if ($account["account_type"] !== "access_token") return ResponseController::accountTypeWrong($account_id);
$arr["access_token"] = $account["access_token"];
} else {
if ($account["account_type"] !== "cookie") return ResponseController::accountTypeWrong($account_id);
$arr["cookie"] = $account["cookie"];
if (!in_array($parse_mode, [11])) {
// 插入会员账号
$json["cookie"] = [];

// 检查是否指定了账号管理员
if (isset($request["account_ids"]) && $request["account_ids"] !== "") {
$user_id = Auth::check() ? Auth::user()["id"] : 1;
$user = User::query()->find($user_id);
$role = $user["role"];
if ($role !== "admin") return ResponseController::permissionsDenied();

// 判断是否只是一个文件
if (count($request["fs_ids"]) > 1) return ResponseController::onlyOneFile();

$json["fsidlist"] = [];
$request["account_ids"] = explode(",", $request["account_ids"]);
foreach ($request["account_ids"] as $account_id) {
$account = Account::query()->find($account_id);
if (!$account) return ResponseController::accountNotExists();
$arr = ["id" => $account_id];
if (in_array($parse_mode, [5, 10])) {
if ($account["account_type"] !== "access_token") return ResponseController::accountTypeWrong($account_id);
$arr["access_token"] = $account["access_token"];
} else {
if ($account["account_type"] !== "cookie") return ResponseController::accountTypeWrong($account_id);
$arr["cookie"] = $account["cookie"];
}
$json["cookie"][] = $arr;
$json["fsidlist"][] = $request["fs_ids"][0];
}
$json["cookie"][] = $arr;
$json["fsidlist"][] = $request["fs_ids"][0];
}
} else {
for ($i = 0; $i < count($request["fs_ids"]); $i++) {
$cookie = self::getRandomCookie();
$cookieData = $cookie->getData(true);
if ($cookieData["code"] !== 200) return $cookie;
$arr = ["id" => $cookieData["data"]["id"]];
if ($cookieData["data"]["account_type"] === "access_token") {
$arr["access_token"] = $cookieData["data"]["access_token"];
} else {
$arr["cookie"] = $cookieData["data"]["cookie"];
} else {
for ($i = 0; $i < count($request["fs_ids"]); $i++) {
$cookie = self::getRandomCookie();
$cookieData = $cookie->getData(true);
if ($cookieData["code"] !== 200) return $cookie;
$arr = ["id" => $cookieData["data"]["id"]];
if ($cookieData["data"]["account_type"] === "access_token") {
$arr["access_token"] = $cookieData["data"]["access_token"];
} else {
$arr["cookie"] = $cookieData["data"]["cookie"];
}
$json["cookie"][] = $arr;
}
$json["cookie"][] = $arr;
}
}

Expand Down Expand Up @@ -694,7 +696,7 @@ public function getDownloadLinks(Request $request)
$res["url"] = $server . "?data=" . self::xorEncrypt($json, $key);
}

$ck_id = $responseDatum["cookie_id"];
$ck_id = $responseDatum["cookie_id"] ?? 0;
$account = Account::query()->find($ck_id);

if (isset($responseDatum["msg"]) && $responseDatum["msg"] === "获取成功") {
Expand Down
16 changes: 16 additions & 0 deletions app/Http/Middleware/AutoUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Middleware;

use App\Models\Account;
use Closure;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Http\Request;
Expand Down Expand Up @@ -49,6 +50,21 @@ public function handle(Request $request, Closure $next): Response
});
}

// 1.3.29
$account = Account::query()->find(0);
if (!$account) {
Account::query()
->create([
"baidu_name" => "授权服务器提供",
"account_type" => "cookie",
"vip_type" => "普通用户",
"switch" => 0
])
->update([
"id" => 0
]);
}

return $next($request);
}
}
1 change: 1 addition & 0 deletions app/Models/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Account extends Model
use SoftDeletes;

protected $fillable = [
"id",
"baidu_name",
"account_type",
"cookie",
Expand Down
2 changes: 1 addition & 1 deletion config/94list.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"fake_wx_user_agent" => "Mozilla/5.0 (Linux; Android 7.1.1; MI 6 Build/NMF26X; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/6.2 TBS/043807 Mobile Safari/537.36 MicroMessenger/6.6.1.1220(0x26060135) NetType/4G Language/zh_CN MicroMessenger/6.6.1.1220(0x26060135) NetType/4G Language/zh_CN miniProgram",
"fake_cookie" => "BAIDUID=A4FDFAE43DDBF7E6956B02F6EF715373:FG=1; BAIDUID_BFESS=A4FDFAE43DDBF7E6956B02F6EF715373:FG=1; newlogin=1",

"version" => "1.3.28",
"version" => "1.3.29",
"sleep" => (int)env("_94LIST_SLEEP", 3),
"max_once" => (int)env("_94LIST_MAX_ONCE", 20),
"password" => env("_94LIST_PASSWORD", ""),
Expand Down

0 comments on commit a3934de

Please sign in to comment.