Ejemplo n.º 1
0
 protected function prepareUpdateView()
 {
     $allowList = empty($_POST['ips']['allow']) ? array() : array_flip($_POST['ips']['allow']);
     $denyList = empty($_POST['ips']['deny']) ? array() : array_flip($_POST['ips']['deny']);
     $options = array('127.0.0.1/32' => '127.0.0.1 (Loopback)', '10.0.0.0/8' => '10.0.0.0 - 10.255.255.255 (Private Network)', '172.16.0.0/12' => '172.16.0.0 - 172.31.255.255 (Private Network)', '192.168.0.0/16' => '192.168.0.0 - 192.168.255.255 (Private Network)');
     $allListItems = Doctrine::getTable('NetListItem')->findAll();
     foreach ($allListItems as $item) {
         $cidr = $item['record'];
         $range = network::cidr2range($cidr);
         if (empty($range)) {
             $description = $cidr;
         } else {
             if ($range['start'] == $range['end']) {
                 $description = $range['start'];
             } else {
                 $description = $range['start'] . ' - ' . $range['end'];
             }
         }
         if (!empty($item['description'])) {
             $description .= ' (' . $item['description'] . ')';
         }
         // all net lists go into the options list
         $options[$cidr] = $description;
         // check if it is in the selected list
         if ($this->netlist['net_list_id'] == $item['net_list_id']) {
             if (empty($item['allow'])) {
                 $denyList[$cidr] = $description;
             } else {
                 $allowList[$cidr] = $description;
             }
         }
     }
     $this->view->netListItems = array_unique($options);
     $this->view->netListAllow = array_keys($allowList);
     $this->view->netListDeny = array_keys($denyList);
     parent::prepareUpdateView();
 }