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.