-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Ban china browser, fix some language errors
- Loading branch information
1 parent
34b82f1
commit 50b67a8
Showing
7 changed files
with
205 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: ellermister | ||
* Date: 2023/11/17 | ||
* Time: 23:40 | ||
*/ | ||
|
||
namespace Libs\Redirects; | ||
|
||
|
||
class BanChinaBrowser extends Handler | ||
{ | ||
|
||
const KEYWORD_IN_USERAGENT = [ | ||
'bidubrowser', | ||
'metasr', | ||
'tencenttraveler', | ||
'MicroMessenger', | ||
'MiuiBrowser', | ||
'YodaoBot', | ||
'IqiyiApp', | ||
'Weibo', | ||
'qq', | ||
'QQBrowser', | ||
'Quark', | ||
'MetaSr', | ||
'SNEBUY-APP', | ||
'AlipayClient', | ||
'AliApp', | ||
'115Browser', | ||
'2345Explorer', | ||
'Mb2345Browser', | ||
'2345chrome', | ||
'QihooBrowser', | ||
'QHBrowser', | ||
'360Spider', | ||
'HaosouSpider', | ||
'BIDUBrowser', | ||
'baidubrowser', | ||
'baiduboxapp', | ||
'BaiduD', | ||
'DingTalk', | ||
'douban.frodo', | ||
'aweme', | ||
'HuaweiBrowser', | ||
'HUAWEI', | ||
'HONOR', | ||
'HBPC', | ||
'LBBROWSER', | ||
'LieBaoFast', | ||
'MZBrowser', | ||
'HeyTapBrowser', | ||
'OPPO', | ||
'Opera', | ||
'VivoBrowser', | ||
]; | ||
|
||
function getHandlerName(): string | ||
{ | ||
return "ban_china_browser"; | ||
} | ||
|
||
function requireAuthorize(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
function isAuthorize(): bool | ||
{ | ||
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? ''; | ||
$userAgent = strtolower($userAgent); | ||
foreach (self::KEYWORD_IN_USERAGENT as $value) { | ||
if (strpos($userAgent, strtolower($value)) !== false) { | ||
view('ban_china_browser', ['url' => $this->data['url']]); | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
function showPage(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!DOCTYPE html> | ||
<html lang="<?php echo get_lang() ?>"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>WARNING</title> | ||
<meta name="referrer" content="no-referrer" /> | ||
<style> | ||
.main-tips{ | ||
text-align: center; | ||
padding: 20px; | ||
flex-direction: column; | ||
align-items: center; | ||
display: flex; | ||
} | ||
.main-tips h2{ | ||
user-select: none; | ||
} | ||
.main-tips pre{ | ||
padding: 12px; | ||
background: #ccc; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div class="main-tips"> | ||
<h2><?php echo __('Please use a non-China browser');?></h2> | ||
<pre onclick="allSelectContent()" id="url"></pre> | ||
<label><?php echo __('Please copy this link to open in other browsers');?></label> | ||
</div> | ||
<script> | ||
let safeURL = new URL(location.href) | ||
safeURL.search = "" | ||
|
||
let url = document.getElementById('url') | ||
url.innerText = safeURL.href | ||
|
||
function allSelectContent(){ | ||
let url = document.getElementById('url') | ||
var selection = document.getSelection() | ||
|
||
var range = document.createRange() | ||
range.selectNode(url) | ||
|
||
selection.removeAllRanges() | ||
selection.addRange(range) | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.