/** * @param Address|AddressGroup $Obj * @return bool */ public function addObject($Obj) { $this->fasthashcomp = null; $ret = parent::add($Obj); if ($ret && $this->xmlroot !== null) { if (count($this->o) > 1) { DH::createElement($this->xmlroot, 'member', $Obj->name()); } else { $this->rewriteXML(); } } return $ret; }
public function rewriteXML() { if (count($this->o) > 0) { if ($this->xmlroot === null) { $this->xmlroot = DH::createElement($this->owner->xmlroot, 'tag'); } DH::Hosts_to_xmlDom($this->xmlroot, $this->o, 'member', false); } else { if ($this->xmlroot !== null) { $this->owner->xmlroot->removeChild($this->xmlroot); $this->xmlroot = null; } } }
public function rewriteXML() { if ($this->isTmpAddr()) { return; } DH::clearDomNodeChilds($this->xmlroot); $tmp = DH::createElement($this->xmlroot, self::$AddressTypes[$this->type], $this->value); if ($this->_description !== null && strlen($this->_description) > 0) { DH::createElement($this->xmlroot, 'description', $this->_description); } }
/** * @param string $tagName * @param DOMNode $node * @param null|string $withText * @return bool|DOMElement|DOMNode */ static function findFirstElementOrCreate($tagName, DOMNode $node, $withText = null) { $ret = DH::findFirstElement($tagName, $node); if ($ret === FALSE) { return DH::createElement($node, $tagName, $withText); } return $ret; }
/** * @param string $newProtocol */ public function setProtocol($newProtocol) { if ($newProtocol != 'tcp' || $newProtocol != 'udp') { derr("unsupported protocol '{$newProtocol}'"); } if ($newProtocol == $this->_protocol) { return; } $this->_protocol = $newProtocol; DH::clearDomNodeChilds($this->protocolRoot); $this->tcpOrUdpRoot = DH::createElement($this->protocolRoot, $this->_protocol); DH::createElement($this->tcpOrUdpRoot, 'port', $this->_dport); if (strlen($this->_sport) > 0) { DH::createElement($this->tcpOrUdpRoot, 'source-port', $this->_dport); } }
/** * @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; }
public function createVirtualSystem($vsysID, $displayName = '') { if (!is_numeric($vsysID)) { derr("new vsys id must be an integer but '{$vsysID}' was provided"); } $newVsysName = 'vsys' . $vsysID; if ($this->findVirtualSystem($newVsysName) !== null) { derr("cannot create '{$newVsysName}' because it already exists"); } $xmlNode = DH::importXmlStringOrDie($this->xmldoc, VirtualSystem::$templateXml); $xmlNode->setAttribute('name', $newVsysName); if (strlen($displayName) > 0) { DH::createElement($xmlNode, 'display-name', $displayName); } $this->vsyssroot->appendChild($xmlNode); $newVsys = new VirtualSystem($this); $newVsys->load_from_domxml($xmlNode); $this->virtualSystems[] = $newVsys; return $newVsys; }
/** * @param string $local * @param string $remote * @param null|string $name * @return bool */ public function addProxyId($local, $remote, $name = null) { if ($name === null) { $name = $this->findAvailableProxyIdName('proxy-'); } foreach ($this->proxys as &$proxy) { if ($proxy['local'] == $local && $proxy['remote'] == $remote) { return false; } } $newRoot = DH::createElement($this->proxyIdRoot, 'entry'); $newRoot->setAttribute('name', $name); DH::createElement($newRoot, 'local', $local); DH::createElement($newRoot, 'remote', $remote); $newArray = array('name' => $name, 'local' => $local, 'remote' => $remote, 'xmlroot' => $newRoot); $this->proxys[] =& $newArray; return true; }