All pastes #19117 Raw Edit

Something

public php v1 · immutable
#19117 ·published 2005-08-02 18:51 UTC
rendered paste body
<?php//Find IP if it is sent by proxies.  Or just the plain IP$ip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']);//Validate IP address with wildcards ( from user-comments on http://php.net/preg_match )function valid_ipv4($ip_addr){       $num="(\*|[0-9]{1,3}|^1?\d\d$|2[0-4]\d|25[0-5])";       if(preg_match("/$num\.$num\.$num\.$num/",$ip_addr,$matches))       {          return true;       } else        {          return false;       }}// blocked ips array (you can add more)$b_ip_array = array("012.345.678.900",                     "999.999.999.*",                    "111.111.111.111",                    "222.222.222.222");//loop through arrayfor($i=0;$i<count($b_ip_array);$i++){  if(valid_ipv4($ip))  {   die("Your IP has been banned");  }}?>content goes here