/**
  * Updates IP range in database.
  * @param array $postData
  * @param integer $id
  */
 protected function _updateIpRange($postData, $id = null)
 {
     $name = $postData['name'];
     $startingIp = $postData['startingip'];
     $endingIp = $postData['endingip'];
     if (empty($endingIp)) {
         // single address IP range
         $endingIp = $startingIp;
     }
     $roles = Admin_Form_ipRange::parseSelectedRoles($postData);
     if (empty($id)) {
         $ipRange = new Opus_Iprange();
     } else {
         $ipRange = new Opus_Iprange($id);
     }
     $ipRange->setName($name);
     $ipRange->setStartingip($startingIp);
     $ipRange->setEndingip($endingIp);
     $ipRange->setRole($roles);
     $ipRange->store();
 }
Esempio n. 2
0
 private function storeIps()
 {
     try {
         if (count($this->ips) > 0) {
             foreach ($this->ips as $i) {
                 $ip = explode('-', $i->ip, 2);
                 $lower = "";
                 $upper = "";
                 if (count($ip) == 1) {
                     $lower = $ip[0];
                     $upper = $ip[0];
                 } else {
                     if (count($ip) == 2) {
                         $lower = $ip[0];
                         $upper = $ip[1];
                     } else {
                         throw new Exception("ERROR Opus3RoleImport: " . $i . " is not a regular IP-Address or IP-Range\n");
                     }
                 }
                 $range = new Opus_Iprange();
                 $range->setStartingip($lower);
                 $range->setEndingip($upper);
                 $range->setName($i->name);
                 $range->store();
             }
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }