/**
  * @param null|string $newDescription
  * @return bool
  */
 function setDescription($newDescription = null)
 {
     if ($newDescription === null || strlen($newDescription) < 1) {
         if ($this->_description === null) {
             return false;
         }
         $this->_description = null;
         $tmpRoot = DH::findFirstElement('description', $this->xmlroot);
         if ($tmpRoot === false) {
             return true;
         }
         $this->xmlroot->removeChild($tmpRoot);
     } else {
         if ($this->_description == $newDescription) {
             return false;
         }
         $this->_description = $newDescription;
         $tmpRoot = DH::findFirstElementOrCreate('description', $this->xmlroot);
         DH::setDomNodeText($tmpRoot, $this->description());
     }
     return true;
 }
 public function setAlternativeName($newName)
 {
     if ($newName == $this->_alternativeName) {
         return false;
     }
     if ($newName === null || strlen($newName) == 0) {
         $node = DH::findFirstElement('display-name', $this->xmlroot);
         if ($node === false) {
             return false;
         }
         $this->xmlroot->removeChild($node);
         return true;
     }
     $node = DH::findFirstElementOrCreate('display-name', $this->xmlroot);
     DH::setDomNodeText($node, $newName);
     return true;
 }
Пример #3
0
 /**
  *
  *
  */
 public function rewriteService_XML()
 {
     DH::clearDomNodeChilds($this->serviceroot);
     if (is_null($this->service)) {
         DH::setDomNodeText($this->serviceroot, 'any');
         return;
     }
     DH::setDomNodeText($this->serviceroot, $this->service->name());
 }
Пример #4
0
 /**
  * For developper use only
  *
  */
 protected function rewriteSDisabled_XML()
 {
     if ($this->disabled) {
         DH::setDomNodeText($this->disabledroot, 'yes');
     } else {
         DH::setDomNodeText($this->disabledroot, 'no');
     }
 }
Пример #5
0
 public function setSourcePort($newPorts)
 {
     if ($newPorts === null || strlen($newPorts) == 0) {
         if (strlen($this->_sport) == 0) {
             return false;
         }
         $this->_sport = $newPorts;
         $sportroot = DH::findFirstElement('source-port', $this->tcpOrUdpRoot);
         if ($sportroot !== false) {
             $this->tcpOrUdpRoot->removeChild($sportroot);
         }
         return true;
     }
     if ($this->_sport == $newPorts) {
         return false;
     }
     if (strlen($this->_sport) == 0) {
         DH::findFirstElementOrCreate('source-port', $this->tcpOrUdpRoot, $newPorts);
         return true;
     }
     $sportroot = DH::findFirstElementOrCreate('source-port', $this->tcpOrUdpRoot);
     DH::setDomNodeText($sportroot, $newPorts);
     return true;
 }
 /**
  * @param bool $yes
  * @return bool
  */
 public function setDestinationIsNegated($yes)
 {
     if ($this->negatedDestination != $yes) {
         $tmpRoot = DH::findFirstElement('negate-destination', $this->xmlroot);
         if ($tmpRoot === false) {
             if ($yes) {
                 DH::createElement($this->xmlroot, 'negate-destination', 'yes');
             }
         } else {
             if (!$yes) {
                 $this->xmlroot->removeChild($tmpRoot);
             } else {
                 DH::setDomNodeText($tmpRoot, 'yes');
             }
         }
         $this->negatedDestination = $yes;
         return true;
     }
     return false;
 }
 /** @param App|null $app
  * @return bool */
 public function setApplication($app)
 {
     if ($app === null) {
         derr("app cannot be null");
     }
     if ($this->_app !== $app) {
         if ($this->_app !== null) {
             $this->_app->removeReference($this);
         }
         $app->addReference($this);
         $this->_app = $app;
         $root = DH::findFirstElementOrCreate('application', $this->xmlroot);
         DH::setDomNodeText($root, $app->name());
         return true;
     }
     return false;
 }