onestopweb 阅读(36) 评论(0)
<?php
header('Content-Type: text/html; charset=utf-8');
define("WEBSITE", "http://onestopweb.iteye.com");

if($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['fdata'])){
    sourceJudgment();
    echo $_POST["website"];
    exit;
}
//来源判断
function sourceJudgment(){
    if (strpos($_SERVER['HTTP_REFERER'], WEBSITE)===false) {
        header('Location:'.WEBSITE.'/index.php?f='.$_SERVER['HTTP_REFERER']);
        exit;
    }
}
?>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>PHP 判断请求来源</title>
</head>
<body>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
	<input type="text" name="website" value="" placeholder="请输入网址">
	<input type="submit" name="fdata" value="提交">
</form>
</body>

  

效果图:

 

 

 

 

 

 

 

 

 

 

  • 大小: 11.7 KB