search
Homephp教程php手册PHP限制网页只能在微信内置浏览器中查看并显示

PHP限制网页只能在微信内置浏览器中查看并显示

Jun 13, 2016 am 09:37 AM
phpbuilt-inapplicationdevelopWeChatshowCheckBrowserfireNowofWeb pagelimit

   微信现在算是火了,围绕微信开发的应用也越来越多了,前段时间,自己公司需要,用PHP写了一个微信应用,为了防止自己辛苦写成的PHP应用被盗用,于是通过PHP做了限制,只能在微信自带的浏览器中才能打开本应用,一开始无头绪,后经多查证,总算把这功能弄出来了,现在把具体的代码分享给大家。

  1

  2$useragent = addslashes($_SERVER['HTTP_USER_AGENT']);

  3if(strpos($useragent, 'MicroMessenger') === false && strpos($useragent, 'Windows Phone') === false ){

  4echo " Sorry!非微信浏览器不能访问";

  5}else{

  6echo "可以访问";

  7}

  8?>

  注:上述方法如果伪造了HTTP_USER_AGEN方法,就能正常访问了。玩机达人若在谷歌浏览器上装个User-Agent Switcher,同样也可访问。后来想到用JS来判断是不是手机访问,但这样同样不能彻底解决问题,因为客户端浏览器若禁止了JS,该方法又失效了,所以我想,这就像在网页上屏蔽右键一样,只能难倒一些不懂的人,唉。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)