随机获取变量$j46里的域名前判断是否可以在微信和QQ内访问如果可以访问则获取不可以则提示无可用域名$j46 = $confj46;$j47 = $confj47;if $j47 == 1 $domains = explode $j46;$chosen_domain = $domainsarray_rand$domains; 随机获取$j46里的一个值if !isset$_COOKIEredir
// 判断域名是否可用 function checkDomain($domain) { // 检查微信是否可访问 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://mp.weixin.qq.com/"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); $output = curl_exec($ch); curl_close($ch); if (strpos($output, "302 Found") !== false) { return false; }
// 检查QQ是否可访问 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://mqq.qq.com/"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); $output = curl_exec($ch); curl_close($ch); if (strpos($output, "302 Found") !== false) { return false; }
return true; }
$j46 = $conf['j46']; $j47 = $conf['j47']; if ($j47 == 1) { $domains = explode(",", "$j46"); $available_domains = array();
// 遍历域名,获取可用域名 foreach ($domains as $domain) { if (checkDomain($domain)) { array_push($available_domains, $domain); } }
// 随机获取可用域名 if (count($available_domains) > 0) { $chosen_domain = $available_domains[array_rand($available_domains)];
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>嘿嘿";
exit();
} else {
// 已经跳转过,不再跳转
}
} else { // 没有可用域名 echo "无可用域名"; }
原文地址: https://www.cveoy.top/t/topic/egOc 著作权归作者所有。请勿转载和采集!