欢迎光临 - 我的站长站,本站所有资源仅供学习与参考,禁止用于商业用途或从事违法行为!

php教程

php网页延时跳转代码

php教程 我的站长站 2021-09-09 共69人阅读

header重定向方法

用header重定向的时候,可以设置下延时跳转,代码如下:

header("Refresh:5;url=index.php");

Refresh为延迟时间,url为跳转后的地址。

带过度页面延迟跳转方法

<?php
$url=$_SERVER["HTTP_REFERER"];
$str=str_replace("http://","",$url);
$str=str_replace("https://","",$url);
$strdomain = explode("/",$str);
$domain=$strdomain[0];
if($domain==''){
empty($_SERVER['HTTP_VIA']) or exit('Access Denied');//防止快速刷新
session_start();
$seconds = '30'; //时间段[秒]
$refresh = '3'; //刷新次数
//设置监控变量
$cur_time = time();
if(isset($_SESSION['last_time'])){$_SESSION['refresh_times'] += 1;
}else{$_SESSION['refresh_times'] = 1;$_SESSION['last_time'] = $cur_time;}
//处理监控结果
if($cur_time - $_SESSION['last_time'] < $seconds){if($_SESSION['refresh_times'] >= $refresh){
//跳转至攻击者服务器地址
header(sprintf('Location:%s', 'http://127.0.0.1'));exit('Access Denied');}
}else{$_SESSION['refresh_times'] = 0;$_SESSION['last_time'] = $cur_time;}
echo 'Access Denied';exit;}
//跳转结果
$urlhttp= strtolower(substr($_REQUEST["url"],0,7));
$urlhttps=strtolower(substr($_REQUEST["url"],0,8));
if($urlhttp=='http://'||$urlhttps=='https://'){$slurl=$_REQUEST["url"];}else{$slurl='http://'.$_REQUEST["url"];}
$web=preg_replace('/(http://|https://|)*/','',$_REQUEST["url"]);
header("HTTP/1.1 301 Moved Permanently");
header("Refresh:3;url=".$slurl."");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=11,IE=10,IE=9,IE=8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
<title>网页3秒将跳转到<?php echo $web;?></title>
<style type="text/css">
<!--
body{background-color:#F7F7F7;font-family:Arial;line-height:150%;}
.main{background-color:#FFFFFF;font-size:12px;color:#666666;max-width:650px;margin:60px auto 0px;border-radius:10px;padding:30px 10px;list-style:none;border:#DFDFDF 1px solid; overflow:hidden;}
.main h6{line-height:30px;font-size:18px;margin:5px 20px;}
.main p{line-height:25px;font-size:14px;margin:5px 20px;}
-->
</style>
</head>
<body>
<div class="main">
<h6>您所访问的页面将跳转到第三方网站,可能会有安全风险,望知悉!!!</h6>
<p>3秒后将自动为你跳转到<?php echo $web;?></p>
<div style="clear:both;text-align:center;font-size:14px; margin-top:50px;">本页由舍力提供</div>
</div>
</body>
</html>

使用方法:建立一个文件夹例如go,然后在文件夹中创立一个index.php文件,把上面的代码放入到这个index.php文件中即可。

标签 php代码
相关推荐
  • php代码
  • 支付宝企业账户转账个人账户php接口代码

    前言支付宝企业账户转账个人账户php接口代码,该接口主要用于平台对用户奖励的发放,场景也很简单就是我在你平台上有余额,我提现,平台给钱。只不过项目中是用的官方的SDK调用的,仔细看了下那个SDK目录,把很多无用的接口(目前自己用不上)也包含在里面,作为强...

    php教程 159 1年前
  • php判断目录文件是否存在

    一段简单的php判断目录文件是否存在代码,收藏记录一下,以后肯定用得到的。<?php$filename = &#39;../../e/install/&#39;; if (file_exists($filename)) { echo "<h3><div align=&#39;center&#39;><font color=&#39;#FF0000&#39;>存在安全风险!请将 ...

    php教程 114 2年前
  • curl函数获取API接口数据方法

    PHP利用curl函数,获取API接口数据方法示例代码,自用收藏<?php $weather = curl_init(); curl_setopt($weather,CURLOPT_URL,"https://api.pc2801.com/cqssc/".time()); curl_setopt($weather, CURLOPT_SSL_VERIFYPEER, false); //如果...

    php教程 88 2年前
  • 158网盘直连解析代码

    API代码<?php/*** @package 158Pan* @author Andy* @version 1.2.0* @link https://lsland.cn*/// 指定允许其他域名访问 header(&#39;Access-Control-Allow-Origin:*&#39;);header(&#39;content-type:application/json;charset:utf-8&#39;);functi...

    php教程 129 2年前
  • PHP获取QQ用户昵称+头像API接口代码

    如果要获得QQ用户的头像和昵称,需要在腾讯开放平台申请API接入才可以,但是这个不需要!只需要输入用户的正确的QQ号即可返回用户的头像和昵称。API接口代码<?php // 通过QQ号即可获取用户信息 // 获取QQ头像接口// http://q1.qlogo.cn/g?b=qq&nk=QQ号&s=...

    php教程 217 2年前