/** * General armory fetch class * Returns XML, HTML or an array of the parsed XML page * * @param int $type * @param string $character * @param string $guild * @param string $realm * @param int $item_id * @param string $fetch_type * @return array */ function fetchArmory($type = false, $character = false, $guild = false, $realm = false, $item_id = false, $fetch_type = 'array') { global $roster; $url = $this->_makeUrl($type, false, $item_id, $character, $realm, $guild); if ($fetch_type == 'html') { $this->setUserAgent('Opera/9.22 (X11; Linux i686; U; en)'); } if ($this->_requestXml($url)) { if ($fetch_type == 'array') { // parse and return array $this->_initXmlParser(); $this->xmlParser->Parse($this->xml); $data = $this->xmlParser->getParsedData(); } elseif ($fetch_type == 'simpleClass') { // parse and return SimpleClass object $this->_initSimpleParser(); $data = $this->simpleParser->parse($this->xml); } else { // unparsed fetches return $this->xml; } return $data; } else { trigger_error('RosterArmory:: Failed to fetch ' . $url); return false; } }
private function migrate_allxml2conf() { error_log("Migrating all config from server xml config {$this->_xmlpath} \n"); $xmlparser = new XmlParser(); $xmlroot = $xmlparser->Parse($this->_xmlpath); if ($xmlroot->HasFatalErr()) { $this->_conferr = $xmlroot->Get(CNode::FLD_ERR); return FALSE; } $root = $xmlroot->DupHolder(); $filemap = DPageDef::GetInstance()->GetFileMap(DInfo::CT_SERV); // serv, vh, tp, admin $filemap->Convert(0, $xmlroot, 1, $root); // migrate all vh.xml if (($vhosts = $root->GetChildren('virtualhost')) != NULL) { if (!is_array($vhosts)) { $vhosts = array($vhosts); } foreach ($vhosts as $vh) { $vhname = $vh->Get(CNode::FLD_VAL); $vhroot = $vh->GetChildVal('vhRoot'); $vhconf = $vh->GetChildVal('configFile'); $conffile = PathTool::GetAbsFile($vhconf, 'VR', $vhname, $vhroot); $vhdata = new CData(DInfo::CT_VH, $conffile); if (($pos = strpos($vhconf, '.xml')) > 0) { $vhconf = substr($vhconf, 0, $pos) . '.conf'; $vh->SetChildVal('configFile', $vhconf); } } } // migrate all tp.xml if (($tps = $root->GetChildren('vhTemplate')) != NULL) { if (!is_array($tps)) { $tps = array($tps); } foreach ($tps as $tp) { $tpconf = $tp->GetChildVal('templateFile'); $conffile = PathTool::GetAbsFile($tpconf, 'SR'); $tpdata = new CData(DInfo::CT_TP, $conffile); if (($pos = strpos($tpconf, '.xml')) > 0) { $tpconf = substr($tpconf, 0, $pos) . '.conf'; $tp->SetChildVal('templateFile', $tpconf); } } } $buf = ''; $this->before_write_conf($root); $root->PrintBuf($buf); touch($this->_path); $this->write_file($this->_path, $buf); $this->copy_permission($this->_xmlpath, $this->_path); $migrated = $this->_xmlpath . '.migrated.' . time(); if (defined('SAVE_XML')) { copy($this->_xmlpath, $migrated); } else { rename($this->_xmlpath, $migrated); } if (defined('RECOVER_SCRIPT')) { file_put_contents(RECOVER_SCRIPT, "mv {$migrated} {$this->_xmlpath}\n", FILE_APPEND); } error_log(" converted {$this->_xmlpath} to {$this->_path}\n\n"); }