日期:2014-05-16  浏览次数:20287 次

js来源IP限制
<script type="text/javascript">
function auth(doc){
var laiyuan = doc.referrer;
	var isAuth = "0";
	if(isAuth==0){// not auth
		if(laiyuan!=null && laiyuan!=''){
			var lai01 = laiyuan.substr(0,16);//http://127.0.0.1
			var lai02 = laiyuan.substr(0,19);//http://172.20.0.205
			var lai03 = laiyuan.substr(0,28);//http://www.panshao.com/myweb
			if(lai01 !='http://127.0.0.1' && lai02 !='http://172.20.0.205' 
					&& lai03 !='http://www.panshao.com/myweb') {//no right 
				return 0;
			}else{// has right
				return 1;
			}
		}else{
			return 0;
		}
	}
}

var laiyuan1 = document.referrer;
var flag = auth(document);
if(flag==0){
	window.location.href='<%=root %>'+"/fail.jsp";
}
</script>