Example #1
0
 protected function _findAllowDeny(array $items)
 {
     $utils = new \HTRouter\Utils();
     // Iterate all "ALLOW" or "DENY" items. We just return if at least one of them matches
     foreach ($items as $entry) {
         switch ($entry->type) {
             case "env":
                 $env = $this->getRouter()->getEnvironment();
                 if (isset($env[$entry->env])) {
                     return true;
                 }
                 break;
             case "nenv":
                 $env = $this->getRouter()->getEnvironment();
                 if (!isset($env[$entry->env])) {
                     return true;
                 }
                 break;
             case "all":
                 return true;
                 break;
             case "ip":
                 if ($utils->checkMatchingIP($entry->ip, $this->getRequest()->getIp())) {
                     return true;
                 }
                 break;
             case "host":
                 if ($utils->checkMatchingHost($entry->host, $this->getRequest()->getIp())) {
                     return true;
                 }
                 break;
             default:
                 throw new \LogicException("Unknown entry type: " . $entry->type);
                 break;
         }
     }
     return false;
 }