域名跳转:QQ/微信内访问检测及随机分配
$j46 = $conf['j46'];
$j47 = $conf['j47'];
if ($j47 == 1) {
$domains = explode(',', '$j46');
$chosen_domain = $domains[array_rand($domains)]; // 随机获取$j46里的一个值
if (!isset($_COOKIE['redirected'])) {
setcookie('redirected', 'true', time() + 10);
$current_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$new_url = 'http://' . $chosen_domain . $_SERVER['REQUEST_URI'];
header('Refresh: 2; URL=' . $new_url);
echo '<title>跳转中,请稍等 </title>
<style>
* {margin: 0; padding: 0; font-family: 'Microsoft YaHei'; color: #fff;}
body, div, form, input, li, ol, p, textarea, ul {margin: 0; padding: 0; font-family: 'Microsoft YaHei'; color: #fff;}
body {background: #fff; color: #3f3f3f; font-family: Apple LiGothic Medium, SimHei, Geneva, Arial, Helvetica, sans-serif; -webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; -webkit-appearance: none; width: 100%; font-size: 12px;}
body p {color: white; text-align: center; line-height: 25px;}
.spinner {margin: 100px auto; width: 40px; height: 20px; position: relative;}
.container1 > div, .container2 > div, .container3 > div {width: 6px; height: 6px; background-color: #333; border-radius: 100%; position: absolute; -webkit-animation: bouncedelay 1.2s infinite ease-in-out; animation: bouncedelay 1.2s infinite ease-in-out; -webkit-animation-fill-mode: both; animation-fill-mode: both;}
.spinner .spinner-container {position: absolute; width: 100%; height: 100%;}
.container2 {-webkit-transform: rotateZ(45deg); transform: rotateZ(45deg);}
.container3 {-webkit-transform: rotateZ(90deg); transform: rotateZ(90deg);}
.circle1 {top: 0; left: 0;}
.circle2 {top: 0; right: 0;}
.circle3 {right: 0; bottom: 0;}
.circle4 {left: 0; bottom: 0;}
.container2 .circle1 {-webkit-animation-delay: -1.1s; animation-delay: -1.1s;}
.container3 .circle1 {-webkit-animation-delay: -1.0s; animation-delay: -1.0s;}
.container1 .circle2 {-webkit-animation-delay: -0.9s; animation-delay: -0.9s;}
.container2 .circle2 {-webkit-animation-delay: -0.8s; animation-delay: -0.8s;}
.container3 .circle2 {-webkit-animation-delay: -0.7s; animation-delay: -0.7s;}
.container1 .circle3 {-webkit-animation-delay: -0.6s; animation-delay: -0.6s;}
.container2 .circle3 {-webkit-animation-delay: -0.5s; animation-delay: -0.5s;}
.container3 .circle3 {-webkit-animation-delay: -0.4s; animation-delay: -0.4s;}
.container1 .circle4 {-webkit-animation-delay: -0.3s; animation-delay: -0.3s;}
.container2 .circle4 {-webkit-animation-delay: -0.2s; animation-delay: -0.2s;}
.container3 .circle4 {-webkit-animation-delay: -0.1s; animation-delay: -0.1s;}
@-webkit-keyframes bouncedelay {0%, 80%, 100% {-webkit-transform: scale(0.0)} 40% {-webkit-transform: scale(1.0)}}
@keyframes bouncedelay {0%, 80%, 100% {transform: scale(0.0); -webkit-transform: scale(0.0);} 40% {transform: scale(1.0); -webkit-transform: scale(1.0);}}
</style>
<div id='paneloading' style='display:'>
<div class='spinner'>
<div class='spinner-container container1'>
<div class='circle1'></div>
<div class='circle2'></div>
<div class='circle3'></div>
<div class='circle4'></div>
</div>
<div class='spinner-container container2'>
<div class='circle1'></div>
<div class='circle2'></div>
<div class='circle3'></div>
<div class='circle4'></div>
</div>
<div class='spinner-container container3'>
<div class='circle1'></div>
<div class='circle2'></div>
<div class='circle3'></div>
<div class='circle4'></div>
</div>
</div>
</div>';
// 判断是否可以在QQ和微信内访问
if (strpos($_SERVER['HTTP_USER_AGENT'], 'QQ/') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
$can_access = false;
foreach ($domains as $domain) {
$headers = get_headers('http://$domain');
if (strpos($headers[0], '200') !== false) {
$can_access = true;
break;
}
}
if ($can_access) {
// 可以访问,跳转
header('Refresh: 2; URL=' . $new_url);
echo '<title>跳转中,请稍等 </title>
// 省略loading动画代码
';
} else {
// 无可用域名
echo '无可用域名';
}
} else {
// 不在QQ和微信内,直接跳转
header('Refresh: 2; URL=' . $new_url);
echo '<title>跳转中,请稍等 </title>
// 省略loading动画代码
';
}
}
原文地址: https://www.cveoy.top/t/topic/nPVT 著作权归作者所有。请勿转载和采集!