Php simply blocks access from users of specified ip segments. Php simply blocks access from users of specified ip segments, during this time, phpip always shows frequent requests from users of unknown browsers and operating systems in the statistics tool, and the ip addresses are all in php to shield access from users of specified ip segments.
During this time, the statistical tool always saw frequent requests from users of unknown browsers and operating systems, and the ip addresses were all in one segment, which gave me some questions, are these users valid users. There is no browser or operating system record for website access. after several days of analysis, I confirm that these accesses are not accessed by people, but by machines or by others, there was an idea of blocking this ip address.
Export the user data that is not recorded by the browser in the statistics. it is no longer realistic to block more than one hundred ip addresses, however, it is easy to see that these ip addresses are concentrated in some ip address disconnections. Trying to block users in the entire ip segment may lead to some false positives, but it can ensure that the website traffic is clean.
Okay, I won't talk about it anymore. The following describes my implementation ideas and code.
I want to block the first and second ends of the ip address segment 111.11.11.11. I want to block access from multiple ip address segments starting with 111.11.
My implementation idea is to put the ip address set to be blocked in an array and then use the obtained user's ip address to match in the array. if the ip address is not included in the array, the ip address will be released.
For food, I wrote a very rough function.
/*** Shield IP segment */function killIp ($ ip) {$ return = false; $ ip1 = array ('20160301', '20160301', '20160301 ', '20140901'); $ ip2 = array ('1', '2', '3', '4', '5'); $ temp = explode ('. ', $ ip); if (in_array ($ temp [0], $ ip1) & in_array ($ temp [1], $ ip2) {$ return = true ;} return $ return ;}
The above is all the content of this article. I hope you will like it.
During this period of time, the statistical tool always saw frequent requests from users of unknown browsers and operating systems, and the ip addresses were all in one...