Skip to content

Commit

Permalink
Merge pull request #206 from helloxz/dev
Browse files Browse the repository at this point in the history
fix bug
  • Loading branch information
helloxz authored Dec 17, 2024
2 parents d1c39eb + 3839deb commit b67d521
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
40 changes: 33 additions & 7 deletions class/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -2693,17 +2693,43 @@ public function batch_check_links(){
// 获取当前时间戳
$last_checked_time = date('Y-m-d H:i:s');

// 判断链接是否有效,HTTP状态码大于400视为异常,超时或其他错误也视为异常
// 定义 Web 服务器列表
$web_servers = [
'cloudflare',
'waf',
// 可以根据需要添加更多的 Web 服务器类型
'AkamaiGHost',
'JDCloudStarshield'
];

// 假设 $error 和 $http_code 已经定义
// 假设 $server_header 已经从响应头中获取

if ($error || $http_code >= 400) {
// 判断Server头中是否包含cloudflare和waf,不区分大小写
if (stripos($server_header, 'cloudflare') !== false || stripos($server_header, 'waf') !== false) {
$check_status = 3; // 未知
} else {
$check_status = 2; // 异常
// 默认状态为异常
$check_status = 2; // 异常
// 遍历 Web 服务器列表,检查是否包含任何已知的 Web 服务器标识
foreach ($web_servers as $server) {
if (stripos($server_header, $server) !== false) {
// 如果找到匹配的服务器,设置为未知状态
$check_status = 3; // 未知
break; // 一旦找到匹配的服务器,跳出循环
}
}
// 如果没有匹配到任何已知的 Web 服务器,则认为是异常
if ($check_status == 2) {
// 错误数量+1
$error_num++;
}
} else {
}
else if( $http_code === 0 ) {
// HTTP 状态码为 0,表示链接超时,或者SSL证书过期
$check_status = 2; // 异常
// 错误数量+1
$error_num++;
}
else {
// HTTP 状态码小于 400,表示正常
$check_status = 1; // 正常
}

Expand Down
3 changes: 3 additions & 0 deletions controller/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// 载入辅助函数
require('functions/helper.php');

// 检查明文密码
unSafe();

//检查认证
check_auth($site_setting['user'],$site_setting['password']);

Expand Down
2 changes: 2 additions & 0 deletions controller/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

// 载入辅助函数
require('functions/helper.php');
// 检查明文密码
unSafe();

$username = $site_setting['user'];
// 加密后的密码
Expand Down
2 changes: 1 addition & 1 deletion functions/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,6 @@ function unSafe() {
$password = PASSWORD;

if( isset($password) && $password !== 'PASSWORD' ) {
exit("由于安全升级,请删除站点目录下的 data/config.php 文件后,重新完成初始化!");
exit("由于安全升级,请删除站点目录下的 data/config.php 文件后,重新完成初始化,此操作不会影响数据");
}
}
2 changes: 1 addition & 1 deletion templates/admin/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</form>
<div style = "padding-left:30px;"> <a style="color:#FFFFFF;" href="https://dwz.ovh/isbyv" target = "_blank" rel = "nofollow">忘记密码?</a> </div>
</div>
<footer>© 2023 Powered by <a style = "color:#FFFFFF;padding-left:6px;" href = "https://www.onenav.top/" target = "_blank" title = "开源免费书签管理系统"> OneNav</a></footer>
<footer>© 2025 Powered by <a style = "color:#FFFFFF;padding-left:6px;" href = "https://www.onenav.top/" target = "_blank" title = "开源免费书签管理系统"> OneNav</a></footer>
</body>
<script>
//自己封装的弹出框
Expand Down

0 comments on commit b67d521

Please sign in to comment.