Esempio n. 1
0
 public function setIpAddress($ip_address)
 {
     if (preg_match('/[^\\d\\.]/', $ip_address)) {
         return FALSE;
     }
     $ip_length = strlen((string) $ip_address);
     if (strpos($ip_address, '.')) {
         $ip_list = explode('.', $ip_address);
     } elseif ($ip_length % 3) {
         return FALSE;
     } else {
         for ($i = 0; $i < $ip_length; $i += 3) {
             $sub = (int) substr($ip_address, $i, 3);
             $ip_list[] = $sub;
         }
     }
     if (!$this->allow_or_deny) {
         if ($this->inRange($ip_list, '127.0.0.1')) {
             return FALSE;
         } elseif ($this->inRange($ip_list, Current_User::getIp())) {
             return FALSE;
         }
     }
     foreach ($ip_list as $key => $subset) {
         if ($subset > 255 || $subset == NULL) {
             return FALSE;
         }
     }
     $this->ip_address = implode('.', $ip_list);
     return TRUE;
 }