PHP restricts web pages to only be viewed and displayed in WeChat's built-in browser_PHP Tutorial

WBOY
Release: 2016-07-13 10:32:32
Original
1008 people have browsed it

WeChat is quite popular now, and more and more applications are being developed around WeChat. Some time ago, my company needed to write a WeChat application in PHP. In order to prevent the PHP application I worked hard to write from being stolen, Therefore, restrictions were made through PHP. This application can only be opened in the browser that comes with WeChat. I had no clue at first, but after much verification, I finally figured out this function. Now I will share the specific code with you.

 1

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

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

 4echo "Sorry! Non-WeChat browsers cannot access";

 5}else{

 6echo "Can access";

 7}

 8?>

Note: If the HTTP_USER_AGEN method is forged in the above method, you can access it normally. Game masters can also access it if they install a User-Agent Switcher on Google Chrome. Later I thought of using JS to determine whether the access is from a mobile phone, but this cannot completely solve the problem, because if the client browser disables JS, this method will be ineffective, so I think it is just like blocking the right click on the web page. It can stump some people who don’t understand, alas.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/755625.htmlTechArticleWeChat is quite popular now, and there are more and more applications developed around WeChat. Some time ago, my company needed , I wrote a WeChat application in PHP. In order to prevent the PHP application that I worked so hard to write...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!