From 1a91ae71b90d60d633ee953aa948178213db7c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=91=A8=E9=83=A8=E8=90=BD?= Date: Sun, 20 Jun 2021 21:12:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20CDN=20=E9=87=87=E7=94=A8?= =?UTF-8?q?=20HTTP=20=E5=9B=9E=E6=BA=90=E6=97=B6=E7=9A=84=20HTTPS=20?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- upload/api/db/dbbak.php | 17 ++++++++++++----- upload/index.php | 17 ++++++++++++----- upload/install/include/install_function.php | 17 ++++++++++++----- .../source/class/discuz/discuz_application.php | 17 ++++++++++++----- upload/uc_server/admin.php | 17 ++++++++++++----- upload/uc_server/api/dbbak.php | 17 ++++++++++++----- upload/uc_server/avatar.php | 17 ++++++++++++----- upload/uc_server/index.php | 17 ++++++++++++----- utility/restore.php | 17 ++++++++++++----- 9 files changed, 108 insertions(+), 45 deletions(-) diff --git a/upload/api/db/dbbak.php b/upload/api/db/dbbak.php index 7cc64d288..4960cb02e 100644 --- a/upload/api/db/dbbak.php +++ b/upload/api/db/dbbak.php @@ -916,19 +916,26 @@ function send_mime_type_header($type = 'application/xml') { } function is_https() { - if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) != "off") { + // PHP 标准服务器变量 + if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') { return true; } - if (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && strtolower($_SERVER["HTTP_X_FORWARDED_PROTO"]) == "https") { + // X-Forwarded-Proto 事实标准头部, 用于反代透传 HTTPS 状态 + if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') { return true; } - if (isset($_SERVER["HTTP_SCHEME"]) && strtolower($_SERVER["HTTP_SCHEME"]) == "https") { + // 阿里云全站加速私有 HTTPS 状态头部 + // Git 意见反馈 https://gitee.com/Discuz/DiscuzX/issues/I3W5GP + if(isset($_SERVER['HTTP_X_CLIENT_SCHEME']) && strtolower($_SERVER['HTTP_X_CLIENT_SCHEME']) == 'https') { return true; } - if (isset($_SERVER["HTTP_FROM_HTTPS"]) && strtolower($_SERVER["HTTP_FROM_HTTPS"]) != "off") { + // 西部数码建站助手私有 HTTPS 状态头部 + // 官网意见反馈 https://www.discuz.net/thread-3849819-1-1.html + if(isset($_SERVER['HTTP_FROM_HTTPS']) && strtolower($_SERVER['HTTP_FROM_HTTPS']) != 'off') { return true; } - if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] == 443) { + // 服务器端口号兜底判断 + if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) { return true; } return false; diff --git a/upload/index.php b/upload/index.php index 49663b824..374da65d1 100644 --- a/upload/index.php +++ b/upload/index.php @@ -162,19 +162,26 @@ function checkholddomain($domain) { } function is_https() { - if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) != "off") { + // PHP 标准服务器变量 + if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') { return true; } - if (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && strtolower($_SERVER["HTTP_X_FORWARDED_PROTO"]) == "https") { + // X-Forwarded-Proto 事实标准头部, 用于反代透传 HTTPS 状态 + if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') { return true; } - if (isset($_SERVER["HTTP_SCHEME"]) && strtolower($_SERVER["HTTP_SCHEME"]) == "https") { + // 阿里云全站加速私有 HTTPS 状态头部 + // Git 意见反馈 https://gitee.com/Discuz/DiscuzX/issues/I3W5GP + if(isset($_SERVER['HTTP_X_CLIENT_SCHEME']) && strtolower($_SERVER['HTTP_X_CLIENT_SCHEME']) == 'https') { return true; } - if (isset($_SERVER["HTTP_FROM_HTTPS"]) && strtolower($_SERVER["HTTP_FROM_HTTPS"]) != "off") { + // 西部数码建站助手私有 HTTPS 状态头部 + // 官网意见反馈 https://www.discuz.net/thread-3849819-1-1.html + if(isset($_SERVER['HTTP_FROM_HTTPS']) && strtolower($_SERVER['HTTP_FROM_HTTPS']) != 'off') { return true; } - if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] == 443) { + // 服务器端口号兜底判断 + if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) { return true; } return false; diff --git a/upload/install/include/install_function.php b/upload/install/include/install_function.php index f6e828053..07c258f38 100644 --- a/upload/install/include/install_function.php +++ b/upload/install/include/install_function.php @@ -1813,19 +1813,26 @@ function send_mime_type_header($type = 'application/xml') { } function is_https() { - if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) != "off") { + // PHP 标准服务器变量 + if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') { return true; } - if (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && strtolower($_SERVER["HTTP_X_FORWARDED_PROTO"]) == "https") { + // X-Forwarded-Proto 事实标准头部, 用于反代透传 HTTPS 状态 + if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') { return true; } - if (isset($_SERVER["HTTP_SCHEME"]) && strtolower($_SERVER["HTTP_SCHEME"]) == "https") { + // 阿里云全站加速私有 HTTPS 状态头部 + // Git 意见反馈 https://gitee.com/Discuz/DiscuzX/issues/I3W5GP + if(isset($_SERVER['HTTP_X_CLIENT_SCHEME']) && strtolower($_SERVER['HTTP_X_CLIENT_SCHEME']) == 'https') { return true; } - if (isset($_SERVER["HTTP_FROM_HTTPS"]) && strtolower($_SERVER["HTTP_FROM_HTTPS"]) != "off") { + // 西部数码建站助手私有 HTTPS 状态头部 + // 官网意见反馈 https://www.discuz.net/thread-3849819-1-1.html + if(isset($_SERVER['HTTP_FROM_HTTPS']) && strtolower($_SERVER['HTTP_FROM_HTTPS']) != 'off') { return true; } - if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] == 443) { + // 服务器端口号兜底判断 + if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) { return true; } return false; diff --git a/upload/source/class/discuz/discuz_application.php b/upload/source/class/discuz/discuz_application.php index 0ce5b1b4b..8a900646d 100644 --- a/upload/source/class/discuz/discuz_application.php +++ b/upload/source/class/discuz/discuz_application.php @@ -390,19 +390,26 @@ class discuz_application extends discuz_base{ } private function _is_https() { - if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) != "off") { + // PHP 标准服务器变量 + if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') { return true; } - if (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && strtolower($_SERVER["HTTP_X_FORWARDED_PROTO"]) == "https") { + // X-Forwarded-Proto 事实标准头部, 用于反代透传 HTTPS 状态 + if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') { return true; } - if (isset($_SERVER["HTTP_SCHEME"]) && strtolower($_SERVER["HTTP_SCHEME"]) == "https") { + // 阿里云全站加速私有 HTTPS 状态头部 + // Git 意见反馈 https://gitee.com/Discuz/DiscuzX/issues/I3W5GP + if(isset($_SERVER['HTTP_X_CLIENT_SCHEME']) && strtolower($_SERVER['HTTP_X_CLIENT_SCHEME']) == 'https') { return true; } - if (isset($_SERVER["HTTP_FROM_HTTPS"]) && strtolower($_SERVER["HTTP_FROM_HTTPS"]) != "off") { + // 西部数码建站助手私有 HTTPS 状态头部 + // 官网意见反馈 https://www.discuz.net/thread-3849819-1-1.html + if(isset($_SERVER['HTTP_FROM_HTTPS']) && strtolower($_SERVER['HTTP_FROM_HTTPS']) != 'off') { return true; } - if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] == 443) { + // 服务器端口号兜底判断 + if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) { return true; } return false; diff --git a/upload/uc_server/admin.php b/upload/uc_server/admin.php index ac1514278..4f85f444a 100644 --- a/upload/uc_server/admin.php +++ b/upload/uc_server/admin.php @@ -127,19 +127,26 @@ function dhtmlspecialchars($string, $flags = null) { } function is_https() { - if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) != "off") { + // PHP 标准服务器变量 + if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') { return true; } - if (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && strtolower($_SERVER["HTTP_X_FORWARDED_PROTO"]) == "https") { + // X-Forwarded-Proto 事实标准头部, 用于反代透传 HTTPS 状态 + if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') { return true; } - if (isset($_SERVER["HTTP_SCHEME"]) && strtolower($_SERVER["HTTP_SCHEME"]) == "https") { + // 阿里云全站加速私有 HTTPS 状态头部 + // Git 意见反馈 https://gitee.com/Discuz/DiscuzX/issues/I3W5GP + if(isset($_SERVER['HTTP_X_CLIENT_SCHEME']) && strtolower($_SERVER['HTTP_X_CLIENT_SCHEME']) == 'https') { return true; } - if (isset($_SERVER["HTTP_FROM_HTTPS"]) && strtolower($_SERVER["HTTP_FROM_HTTPS"]) != "off") { + // 西部数码建站助手私有 HTTPS 状态头部 + // 官网意见反馈 https://www.discuz.net/thread-3849819-1-1.html + if(isset($_SERVER['HTTP_FROM_HTTPS']) && strtolower($_SERVER['HTTP_FROM_HTTPS']) != 'off') { return true; } - if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] == 443) { + // 服务器端口号兜底判断 + if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) { return true; } return false; diff --git a/upload/uc_server/api/dbbak.php b/upload/uc_server/api/dbbak.php index 684cc4087..ff41add98 100644 --- a/upload/uc_server/api/dbbak.php +++ b/upload/uc_server/api/dbbak.php @@ -912,19 +912,26 @@ function send_mime_type_header($type = 'application/xml') { } function is_https() { - if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) != "off") { + // PHP 标准服务器变量 + if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') { return true; } - if (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && strtolower($_SERVER["HTTP_X_FORWARDED_PROTO"]) == "https") { + // X-Forwarded-Proto 事实标准头部, 用于反代透传 HTTPS 状态 + if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') { return true; } - if (isset($_SERVER["HTTP_SCHEME"]) && strtolower($_SERVER["HTTP_SCHEME"]) == "https") { + // 阿里云全站加速私有 HTTPS 状态头部 + // Git 意见反馈 https://gitee.com/Discuz/DiscuzX/issues/I3W5GP + if(isset($_SERVER['HTTP_X_CLIENT_SCHEME']) && strtolower($_SERVER['HTTP_X_CLIENT_SCHEME']) == 'https') { return true; } - if (isset($_SERVER["HTTP_FROM_HTTPS"]) && strtolower($_SERVER["HTTP_FROM_HTTPS"]) != "off") { + // 西部数码建站助手私有 HTTPS 状态头部 + // 官网意见反馈 https://www.discuz.net/thread-3849819-1-1.html + if(isset($_SERVER['HTTP_FROM_HTTPS']) && strtolower($_SERVER['HTTP_FROM_HTTPS']) != 'off') { return true; } - if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] == 443) { + // 服务器端口号兜底判断 + if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) { return true; } return false; diff --git a/upload/uc_server/avatar.php b/upload/uc_server/avatar.php index f6306b49e..26b4f24cf 100644 --- a/upload/uc_server/avatar.php +++ b/upload/uc_server/avatar.php @@ -86,19 +86,26 @@ function _get_script_url() { } function is_https() { - if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) != "off") { + // PHP 标准服务器变量 + if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') { return true; } - if (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && strtolower($_SERVER["HTTP_X_FORWARDED_PROTO"]) == "https") { + // X-Forwarded-Proto 事实标准头部, 用于反代透传 HTTPS 状态 + if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') { return true; } - if (isset($_SERVER["HTTP_SCHEME"]) && strtolower($_SERVER["HTTP_SCHEME"]) == "https") { + // 阿里云全站加速私有 HTTPS 状态头部 + // Git 意见反馈 https://gitee.com/Discuz/DiscuzX/issues/I3W5GP + if(isset($_SERVER['HTTP_X_CLIENT_SCHEME']) && strtolower($_SERVER['HTTP_X_CLIENT_SCHEME']) == 'https') { return true; } - if (isset($_SERVER["HTTP_FROM_HTTPS"]) && strtolower($_SERVER["HTTP_FROM_HTTPS"]) != "off") { + // 西部数码建站助手私有 HTTPS 状态头部 + // 官网意见反馈 https://www.discuz.net/thread-3849819-1-1.html + if(isset($_SERVER['HTTP_FROM_HTTPS']) && strtolower($_SERVER['HTTP_FROM_HTTPS']) != 'off') { return true; } - if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] == 443) { + // 服务器端口号兜底判断 + if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) { return true; } return false; diff --git a/upload/uc_server/index.php b/upload/uc_server/index.php index 718d63131..b330100da 100644 --- a/upload/uc_server/index.php +++ b/upload/uc_server/index.php @@ -146,19 +146,26 @@ function dhtmlspecialchars($string, $flags = null) { } function is_https() { - if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) != "off") { + // PHP 标准服务器变量 + if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') { return true; } - if (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && strtolower($_SERVER["HTTP_X_FORWARDED_PROTO"]) == "https") { + // X-Forwarded-Proto 事实标准头部, 用于反代透传 HTTPS 状态 + if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') { return true; } - if (isset($_SERVER["HTTP_SCHEME"]) && strtolower($_SERVER["HTTP_SCHEME"]) == "https") { + // 阿里云全站加速私有 HTTPS 状态头部 + // Git 意见反馈 https://gitee.com/Discuz/DiscuzX/issues/I3W5GP + if(isset($_SERVER['HTTP_X_CLIENT_SCHEME']) && strtolower($_SERVER['HTTP_X_CLIENT_SCHEME']) == 'https') { return true; } - if (isset($_SERVER["HTTP_FROM_HTTPS"]) && strtolower($_SERVER["HTTP_FROM_HTTPS"]) != "off") { + // 西部数码建站助手私有 HTTPS 状态头部 + // 官网意见反馈 https://www.discuz.net/thread-3849819-1-1.html + if(isset($_SERVER['HTTP_FROM_HTTPS']) && strtolower($_SERVER['HTTP_FROM_HTTPS']) != 'off') { return true; } - if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] == 443) { + // 服务器端口号兜底判断 + if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) { return true; } return false; diff --git a/utility/restore.php b/utility/restore.php index 4400f99cc..3bb9bc52b 100644 --- a/utility/restore.php +++ b/utility/restore.php @@ -672,19 +672,26 @@ function syntablestruct($sql, $version, $dbcharset) { } function is_https() { - if (isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) != "off") { + // PHP 标准服务器变量 + if(isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') { return true; } - if (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && strtolower($_SERVER["HTTP_X_FORWARDED_PROTO"]) == "https") { + // X-Forwarded-Proto 事实标准头部, 用于反代透传 HTTPS 状态 + if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https') { return true; } - if (isset($_SERVER["HTTP_SCHEME"]) && strtolower($_SERVER["HTTP_SCHEME"]) == "https") { + // 阿里云全站加速私有 HTTPS 状态头部 + // Git 意见反馈 https://gitee.com/Discuz/DiscuzX/issues/I3W5GP + if(isset($_SERVER['HTTP_X_CLIENT_SCHEME']) && strtolower($_SERVER['HTTP_X_CLIENT_SCHEME']) == 'https') { return true; } - if (isset($_SERVER["HTTP_FROM_HTTPS"]) && strtolower($_SERVER["HTTP_FROM_HTTPS"]) != "off") { + // 西部数码建站助手私有 HTTPS 状态头部 + // 官网意见反馈 https://www.discuz.net/thread-3849819-1-1.html + if(isset($_SERVER['HTTP_FROM_HTTPS']) && strtolower($_SERVER['HTTP_FROM_HTTPS']) != 'off') { return true; } - if (isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] == 443) { + // 服务器端口号兜底判断 + if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) { return true; } return false; -- Gitee