PHP与JS屏蔽电脑端代码
JS屏蔽电脑端代码,屏蔽win电脑端与苹果笔记本Mac(屏蔽后会跳转指定网址),感觉这个比PHP屏蔽好用一点(因为一般别人在F12控制台伪造了UA 也会被屏蔽)
<script type="text/javascript"> var system ={ win : false, mac : false, xll : false }; var p = navigator.platform; system.win = p.indexOf("Win") == 0; system.mac = p.indexOf("Mac") == 0; system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); if(system.win||system.mac||system.xll){ window.location.href="https://baidu.com"; //跳转地址 }</script>
话不多说了,上PHP屏蔽代码
<?php function strexists2($string, $find) { return !(strpos($string, $find) === false); } function deep_in_array2($value, $array) { foreach($array as $item) { if(!is_array($item)) { if (strpos($value, $item) !== false) { return true; } else { continue; } } if(in_array($value, $item)) { return true; } else if(deep_in_array($value, $item)) { return true; } } return false; } function mobile() { $useragent = strtolower($_SERVER['HTTP_USER_AGENT']); $ualist = array('android', 'midp', 'nokia', 'mobile', 'iphone', 'ipod', 'blackberry', 'windows phone'); if((deep_in_array2($useragent, $ualist) || strexists2($_SERVER['HTTP_ACCEPT'], "VND.WAP") || strexists2($_SERVER['HTTP_VIA'],"wap"))) if(strpos($useragent,'iphone')!==false||strpos($useragent,'ipod')!==false) return '苹果'; else return '安卓'; else return '电脑'; } if(mobile()=='电脑'){ exit(header("location:https://baidu.com")); } //跳转地址
全能资源库丨本站资源除特殊声明外,均来自于网络收集整理仅供学习研究,如需商业使用请获得作者商业授权,如果侵犯了您的合法权益,请联系我们的投诉邮箱:qinglikf@163.com,我们将在24小时内删除!如有其它疑问请联系在线客服(微信公众号:轻狸团队 丨菜单栏人工客服)特别注意:访问本站即同意本站《免责声明&版权声明》,本站原创内容未经授权禁止转载!
全能资源库 » PHP与JS屏蔽电脑端代码
全能资源库 » PHP与JS屏蔽电脑端代码