load(DDSERVICE."/BASE/INFO/Bases.xml")) exit("No Bases.xml file at DDBase/INFO ? no Remote bases at all".PHP_EOL); $bases = $basesDom->getElementsByTagName("dataCenter"); foreach ($bases as $base) { $baseId = $base->getAttribute("xml:id"); $baseDir = DATAPATH."/RemoteData/$baseId"; $baseDirRemote = DDSERVICE."/BASE/INFO/bases/$baseId"; if (!is_dir($baseDir)) mkdir($baseDir, 0775, true); chmod($baseDir,0775); if (!copy("$baseDirRemote/base.xml", "$baseDir/base.xml")) echo "Cannot copy base.xml for $baseId".PHP_EOL; } } // Merge with existing Bases.xml else { $basesDom = new DomDocument("1.0"); $basesDom->load(DATAPATH."/RemoteData/Bases.xml"); $basesDomRemote = new DomDocument("1.0"); if (!@$basesDomRemote->load(DDSERVICE."/BASE/INFO/Bases.xml")) exit("No Bases.xml file at DDBase/INFO ? IMPEX only".PHP_EOL); $basesRemote = $basesDomRemote->getElementsByTagName("dataCenter"); foreach ($basesRemote as $baseRemote) { $baseId = $baseRemote->getAttribute("xml:id"); $baseDir = DATAPATH."/RemoteData/$baseId"; $baseDirRemote = DDSERVICE."/BASE/INFO/bases/$baseId"; // add remote base if it doesn't exist if (!$basesDom->getElementById($baseId)) { if (!is_dir($baseDir)) mkdir($baseDir, 0775, true); chmod($baseDir,0775); if (!copy("$baseDirRemote/base.xml", "$baseDir/base.xml")) { echo "Cannot copy base.xml for $baseId".PHP_EOL; } else { $baseClone = $basesDom->importNode($baseRemote); $basesDom->documentElement->appendChild($baseClone); echo "Added $baseId".PHP_EOL; if ($baseId == "THEMIS") { $center = new THEMIS(); $center->makeAllParams(); } } }// just copy base xml else { if (!copy("$baseDirRemote/base.xml", "$baseDir/base.xml")) { echo "Cannot copy base.xml for $baseId".PHP_EOL; } else { echo "Copied base.xml for $baseId".PHP_EOL; } } } } $basesDom->save(DATAPATH."/RemoteData/Bases.xml"); ?>