public function Parse($filename) { $parser = new PlainConfParser(); $root = new CNode(CNode::K_ROOT, $filename, CNode::T_ROOT); $rawfiles = new RawFiles(); $parser->parse_raw($rawfiles, $root); return $root; }
private function init($isnew) { if ($isnew) { if (!file_exists($this->_path) && !PathTool::createFile($this->_path, $err)) { $this->_conferr = 'Failed to create config file at ' . $this->_path; return FALSE; } else { $this->_root = new CNode(CNode::K_ROOT, $this->_path, CNode::T_ROOT); return TRUE; } } if (!file_exists($this->_path) || filesize($this->_path) < 10) { if ($this->_type == DInfo::CT_SERV) { if (file_exists($this->_xmlpath) && !$this->migrate_allxml2conf()) { return FALSE; } else { $this->_conferr = 'Failed to find config file at ' . $this->_path; return FALSE; } } else { if (file_exists($this->_xmlpath)) { if (!$this->migrate_xml2conf()) { return FALSE; } } else { // treat as new vh or tp $this->_root = new CNode(CNode::K_ROOT, $this->_path, CNode::T_ROOT); return TRUE; } } } $parser = new PlainConfParser(); $this->_root = $parser->Parse($this->_path); if ($this->_root->HasFatalErr()) { $this->_conferr = $this->_root->GetErr(); error_log("fatel err " . $this->_root->GetErr()); return FALSE; } $this->after_read(); return TRUE; }