PHP Simple Implementation mask The specified IP segment user's access _php instance

Source: Internet
Author: User

This time in the statistical tool always see some unknown browsers, unknown operating system users frequent requests and IP are in a paragraph, so I have some doubt, these users are effective users. Web Access no browser no operating system records, I after a few days of analysis to confirm that these visits are not people in the access but some machines or others in the collection of my station, the initiation of a kind of shielding the idea of this IP.

The statistics inside the browser has not recorded the user data export to see the next screen IP has not been realistic IP many more than 100, but carefully watch it is not difficult to see that these IP are concentrated in some IP break. Think of a way to screen the entire IP segment users, may cause some manslaughter but to ensure that the site traffic is clean.

Okay, I'm not talking about it. Here is a description of my implementation and the implementation of the Code

I wanted to. Shielding the front ends of the IP segment 111.11.11.11 This IP I'm going to shield with 111.11 of the beginning of this IP segment of the access

My idea is to put the IP set to be screened in an array and then use the obtained user's IP to go to the array match, in the array of shielding is not in the array to release.

Serve it. One of the very rough functions I've written. Don't spray.

/** 
 * Shielded IP segment 
 * 
/function Killip ($IP) { 
  $return = false; 
  $ip 1 = Array (' n ', ' 112 ', ' 102 ', ' 114 '); 
  $ip 2 = Array (' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 '); 
  $temp = Explode ('. ', $ip); 
  if (In_array ($temp [0], $ip 1) && In_array ($temp [1], $ip 2)) { 
    $return = true; 
  } 
  return $return; 

The above mentioned is the entire content of this article, I hope you can enjoy.

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.