PHP带权重的随机跳转源码直接运行无错版2秒跳转
更新时间:2019-02-25 10:36 已阅读: 次 | 作者:骏马网络 来源:潍坊做网站
PHP带权重的随机跳转源码直接运行无错版2秒跳转
<?php
header("Content-Type: text/html;charset=utf-8");
function getConsultant()
{
$data = array(
array('name'=>'http://www.baidu.com','weights'=>1),
array('name'=>'http://www.qq.com','weights'=>2),
array('name'=>'http://www.163.com','weights'=>3),
array('name'=>'http://www.sina.com.cn','weights'=>4)
);
$weight = 0;
$users = array();
foreach ($data as $one) {
$oneWeight = (int)$one['weights'] ? $one['weights'] : 1;
$weight += $oneWeight;
for ($i = 0; $i < $oneWeight; $i ++) {
$users[] = $one;
}
}
return $users[rand(0, $weight-1)];
}
$tzurlarr = getConsultant();
$tz_url = $tzurlarr['name'];
echo $tz_url ;
?>
<HTML>
<HEAD>
</HEAD>
<BODY>
<script type="text/javascript">
onload=function()
{ //在进入网页的时候加载该方法
setTimeout(go, 2000); /*在js中是ms的单位 2000 */
};
function go(){
location.href='<?php echo $tz_url ; ?>';
}
</script>
<h2>正在为你跳转最新可用的福利网站访问域名,请稍候(<span id="seconds">2秒</span>).....</h2>
<p><small>防止使用域名屏蔽,请访问网站后保存本站跳转域名。以免找不到回家的路!</small></p>
</BODY>
</HTML>
<?php
header("Content-Type: text/html;charset=utf-8");
function getConsultant()
{
$data = array(
array('name'=>'http://www.baidu.com','weights'=>1),
array('name'=>'http://www.qq.com','weights'=>2),
array('name'=>'http://www.163.com','weights'=>3),
array('name'=>'http://www.sina.com.cn','weights'=>4)
);
$weight = 0;
$users = array();
foreach ($data as $one) {
$oneWeight = (int)$one['weights'] ? $one['weights'] : 1;
$weight += $oneWeight;
for ($i = 0; $i < $oneWeight; $i ++) {
$users[] = $one;
}
}
return $users[rand(0, $weight-1)];
}
$tzurlarr = getConsultant();
$tz_url = $tzurlarr['name'];
echo $tz_url ;
?>
<HTML>
<HEAD>
</HEAD>
<BODY>
<script type="text/javascript">
onload=function()
{ //在进入网页的时候加载该方法
setTimeout(go, 2000); /*在js中是ms的单位 2000 */
};
function go(){
location.href='<?php echo $tz_url ; ?>';
}
</script>
<h2>正在为你跳转最新可用的福利网站访问域名,请稍候(<span id="seconds">2秒</span>).....</h2>
<p><small>防止使用域名屏蔽,请访问网站后保存本站跳转域名。以免找不到回家的路!</small></p>
</BODY>
</HTML>
文章引用:https://www.wfwz.net/news/210.html如需转载,请注明出处。