php判断来源地址是否来自于本站
<?php if(PHP_VERSION<'4.1.0'){$_SERVER = $HTTP_SERVER_VARS;} if(isset($_SERVER["HTTP_REFERER"])){ //针对部分浏览器可能无HTTP_REFERER,所以做这么一个判断 $servername=$_SERVER['SERVER_NAME']; $sub_from=$_SERVER["HTTP_REFERER"]; $sub_len=strlen($servername); $checkfrom=substr($sub_from,7,$sub_len); if($checkfrom!=$servername) { echo "<script language='javascript'>window.alert('数据来源有误,本站不接收站外提交的数据!');window.opener=self;window.close();</script>"; exit; } } ?>