Created
          August 23, 2012 06:45 
        
      - 
      
- 
        Save pierot/3433528 to your computer and use it in GitHub Desktop. 
    limit_prox_iprange
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function get_real_ipaddress() { | |
| if (!empty($_SERVER['HTTP_CLIENT_IP'])) { | |
| return $_SERVER['HTTP_CLIENT_IP']; | |
| } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { | |
| return $_SERVER['HTTP_X_FORWARDED_FOR']; | |
| } | |
| return $_SERVER['REMOTE_ADDR']; | |
| } | |
| function in_ip_range($ip, $ip_one, $ip_two = false) { | |
| if(!$ip_two) { | |
| return $ip_one === $ip; | |
| } | |
| return ip2long($ip_one) * -1 >= ip2long($ip) * -1 && ip2long($ip_two) * -1 <= ip2long($ip) * -1; | |
| } | |
| function validate_ip() { | |
| $ip = explode(':', get_real_ipaddress()); | |
| $ip = $ip[0]; | |
| if(in_ip_range($ip, '212.76.229.115', '212.76.229.120')) { | |
| return true; | |
| } else if(in_ip_range($ip, '194.78.4.66', '194.78.4.79')) { | |
| return true; | |
| } else if(in_ip_range($ip, '194.8.4.78', '194.8.4.78')) { | |
| return true; | |
| } | |
| header('Location: http://proximity.bbdo.be'); | |
| } | |
| validate_ip(); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment