PHP restricted Web pages can only be viewed and displayed in a micro-mail built-in browser

Source: Internet
Author: User

Micro-letter is now a fire, around the application of micro-credit development is more and more, some time ago, their company needs to write a micro-letter PHP application, in order to prevent their hard written PHP application is stolen, so through PHP restrictions, only in the micro-letter from the browser to open this application, a beginning without a clue, After more verification, finally the function out, now the specific code to share to everyone.

1

2$useragent = addslashes ($_server[' http_user_agent '));

3if (Strpos ($useragent, ' micromessenger ') = = False && Strpos ($useragent, ' Windows Phone ') = = False) {

4echo "sorry! Non-micro-credit browser can not access";

5}else{

6echo "accessible";

7}

8?>

Note: If the Http_user_agen method is forged, the above method can be accessed normally. If you are a user-agent switcher in Google Browser, you can also access the player. Later thought of using JS to determine whether the mobile phone access, but this also can not completely solve the problem, because the client browser if the ban JS, the method is ineffective, so I think, this is like a screen on the right button, can only baffle some people do not understand, alas.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.