function getWaypointInfo($leonardoServer, $lat, $lon) { global $moduleRelPath; echo "Trying server : {$leonardoServer}<br>"; $fp = @fsockopen($leonardoServer, 80, $errno, $errstr, 3); if (!$fp) { echo "SERVER {$leonardoServer} NOT ACTIVE"; return 0; } else { fclose($fp); } $fl = "http://{$leonardoServer}/modules/leonardo/EXT_takeoff.php?op=find_wpt&lat={$lat}&lon={$lon}"; echo $fl . "<br>"; $contents = implode("\n", file($fl)); require_once dirname(__FILE__) . '/lib/miniXML/minixml.inc.php'; $xmlDoc = new MiniXMLDoc(); $xmlDoc->fromString($contents); $xmlArray = $xmlDoc->toArray(); echo "Name: " . $xmlArray[search][waypoint][name] . "#<BR>"; echo "Name: " . $xmlArray[search][waypoint][intName] . "#<BR>"; echo "Name: " . $xmlArray[search][waypoint][location] . "#<BR>"; echo "Name: " . $xmlArray[search][waypoint][intLocation] . "#<BR>"; echo "Name: " . $xmlArray[search][waypoint][type] . "#<BR>"; echo "Name: " . $xmlArray[search][waypoint][countryCode] . "#<BR>"; echo "Name: " . $xmlArray[search][waypoint][lat] . "#<BR>"; echo "Name: " . $xmlArray[search][waypoint][lon] . "#<BR>"; echo "Name: " . $xmlArray[search][waypoint][link] . "#<BR>"; echo "Name: " . $xmlArray[search][waypoint][description] . "#<BR>"; echo "Name: " . $xmlArray[search][waypoint][modifyDate] . "#<BR>"; echo "Name: " . $xmlArray[search][distance] . "#<BR>"; echo "<hr>"; }
function analyseResourceCalendarXML($string, $pimfile) { verbose("Analyzing Resource Calendar XML for File '" . $pimfile . "'"); $translator_phPIMap = array("pimfile", "uid", "summary", "from", "to"); $translator_XML = array($pimfile, "uid", "summary", "start-date", "end-date"); $xmlread = new MiniXMLDoc(); $xmlread->fromString($string); $rootArray = $xmlread->toArray(); print_r($rootArray); unset($GLOBALS["tmp"]["flattenArray"]); $ar = flattenArray($rootArray); print_r($ar); for ($i = 0; $i < count($translator_XML); $i++) { $ar[$translator_phPIMap[$i]] = $rootArray[$translator_XML[$i]]; } return $ar; }
function _processXMLInitData($str_fileName) { //Include XMLMini require_once MIGUELBASE_MINIXML . '/minixml.inc.php'; //Abrimos el fichero $xml_obj = new MiniXMLDoc(); //Procesamos el contenido $xml_obj->fromFile($str_fileName); //Cargamos la variable $xml_root =& $xml_obj->getElementByPath('menuBar'); $num_elem = $xml_root->numChildren(); $root_elements =& $xml_root->getAllChildren(); for ($i = 0; $i < $num_elem; $i++) { if ($root_elements[$i]->name() == 'menu') { //Datos del menu $menu =& $root_elements[$i]; $num_menus = $menu->numChildren(); $menu_items =& $menu->getAllChildren(); for ($j = 0; $j < $num_menus; $j++) { switch ($menu_items[$j]->name()) { case 'name': $menuName = $menu_items[$j]->getValue(); $this->menus[$i]['name'] = $menuName; case 'option': //Datos del menu $option =& $menu_items[$j]; $num_options = $option->numChildren(); $option_items =& $option->getAllChildren(); for ($k = 0; $k < $num_options; $k++) { $strOptionName = $option_items[$k]->name(); $strOptionValue = $option_items[$k]->getValue(); $this->menus[$i][$j][$strOptionName] = $strOptionValue; } break; } } } } //Debug::oneVar($this->menus, __FILE__, __LINE__); //Cerramos el xml unset($xml_obj); }
function writeXMLFile($_strFileName, $_arrMenu) { $xml = new MiniXMLDoc(); $xmlRoot =& $xml->getRoot(); $menuBar =& $xmlRoot->createChild('menuBar'); for ($i = 0; $i < count($_arrMenu); $i++) { $menu =& $menuBar->createChild('menu'); $menuName =& $menu->createChild('name'); $menuName->text($_arrMenu[$i]['name']); for ($j = 0; $j < count($_arrMenu[$i]) - 2; $j++) { $option =& $menu->createChild('option'); $child =& $option->createChild('name'); $child->text($_arrMenu[$i][$j]['name']); $child =& $option->createChild('type'); $child->text('i'); $child =& $option->createChild('link'); $child->text($_arrMenu[$i][$j]['module_name']); $child =& $option->createChild('param'); $child->text($_arrMenu[$i][$j]['param']); } } $this->writeFileFromString($_strFileName, $xml->toString()); }
<?php /* This little test demonstrates the use of fromFile() ** mainly so you can play with the MINIXML_USEFROMFILECACHING ** option. For the moment, file caching is hardly usefull ** but this may change if we implement an XSLT interface. */ header('Content-type: text/plain'); require_once 'minixml.inc.php'; $xmlDoc = new MiniXMLDoc(); $xmlDoc->fromFile('./test.xml'); print $xmlDoc->toString();
function _processXMLInitData($str_fileName) { //Include XMLMini require_once MIGUELBASE_MINIXML . '/minixml.inc.php'; //Abrimos el fichero $xml_obj = new MiniXMLDoc(); //Procesamos el contenido $xml_obj->fromFile($str_fileName); //Cargamos la variable $xml_root =& $xml_obj->getElementByPath('config'); $xml_elements =& $xml_root->getAllChildren(); for ($i = 0; $i < $xml_root->numChildren(); $i++) { $_SESSION["CONTEXT"]["MIGUEL_" . strtoupper($xml_elements[$i]->name())] = $xml_elements[$i]->getValue(); } //Cerramos el fichero unset($xml_obj); }
<?php /* This little test demonstrates the use of fromFile() ** mainly so you can play with the MINIXML_USEFROMFILECACHING ** option. For the moment, file caching is hardly usefull ** but this may change if we implement an XSLT interface. */ header('Content-type: text/plain'); require_once 'minixml.inc.php'; $xmlDoc = new MiniXMLDoc(); $xmlDoc->fromFile('./test.xml'); print_r($xmlDoc->toArray());
function _processXMLInitData($str_fileName) { //Include XMLMini require_once MIGUELBASE_MINIXML . '/minixml.inc.php'; //Abrimos el fichero $xml_obj = new MiniXMLDoc(); //Procesamos el contenido $xml_obj->fromFile($str_fileName); //Cargamos la variable $xml_root =& $xml_obj->getElementByPath('registry'); $num_elem = $xml_root->numChildren(); $root_elements =& $xml_root->getAllChildren(); for ($i = 0; $i < $num_elem; $i++) { //Datos del modulo $data =& $root_elements[$i]->getElementByPath('data'); $module =& $data->getElementByPath('name'); $data_elements =& $data->getAllChildren(); for ($j = 0; $j < $data->numChildren(); $j++) { $this->modules[$module->getValue()][$data_elements[$j]->name()] = $data_elements[$j]->getValue(); } //Datos de los servicios $services =& $root_elements[$i]->getElementByPath('services'); $services_elements =& $services->getAllChildren(); for ($j = 0; $j < $services->numChildren(); $j++) { $service_element =& $services_elements[$j]->getAllChildren(); $service_name =& $services_elements[$j]->getElementByPath('name'); for ($k = 0; $k < $services_elements[$j]->numChildren(); $k++) { $this->services[$service_name->getValue()][$service_element[$k]->name()] = $service_element[$k]->getValue(); } $this->services[$service_name->getValue()]['module'] = $module->getValue(); } //Datos de los interfaces $functions =& $root_elements[$i]->getElementByPath('functions'); $functions_elements =& $functions->getAllChildren(); for ($j = 0; $j < $functions->numChildren(); $j++) { $function_element =& $functions_elements[$j]->getAllChildren(); $method =& $functions_elements[$j]->getElementByPath('method'); $inter_name = $module->getValue() . '::' . $method->getValue(); for ($k = 0; $k < $functions_elements[$j]->numChildren(); $k++) { $this->interfaces[$inter_name][$function_element[$k]->name()] = $function_element[$k]->getValue(); } $this->interfaces[$inter_name]['module'] = $module->getValue(); } } //Cerramos el xml unset($xml_obj); }
<div align="center"> <TABLE BGCOLOR="#EEEEEE" CELLPADDING="9"> <TR> <TD> <PRE> <div ALIGN="CENTER"><B>MiniXML output</B></div><CODE> <?php /* We create a new MiniXMLDoc object */ $returnedXMLDoc = new MiniXMLDoc(); /* And parse the returned string (assume it was stored in ** $xmlString */ $returnedXMLDoc->fromString($xmlString); /* Now to verify that the document has been initialised from ** the string, we use toString() to output an XML document. */ print "Call to : \$returnedXMLDoc-><font color=\"ee3333\">toString</font>() returns:\n"; print htmlentities($returnedXMLDoc->toString()); print "Call to : \$returnedXMLDoc-><font color=\"ee3333\">getValue</font>() returns:"; print "\n\n</CODE></PRE><FONT SIZE=\"-2\">" . $returnedXMLDoc->getValue() . "</FONT><PRE><CODE>"; /* We can now query the document, fetching elements by name ** (and path) or as a list of children. ** ** Let's start by fetching the partsRateReply element.
<?php /** ensure this file is being included by a parent file */ defined('_JEXEC') or die('Restricted access'); require_once './minixml.inc.php'; $t1NumRows = 3; $t1NumCols = 3; $t2NumRows = 2; $t2NumCols = 2; $htmlDoc = new MiniXMLDoc(); $htmlArray = array('html' => array('head' => array('title' => 'XML::Mini Generated HTML page', 'style' => 'body,td,a,p,.harray(font-family:arial,sans-serif;) .qarray(text-decoration:none; color:#0000cc;)'), 'body' => array('bgcolor' => '#ffffff', 'link' => '#0000cc', 'vlink' => '#551a8b', 'h3' => 'This page was generated by XML::Mini!', 'p' => array(array('-content' => 'View the source of this page to take a look at', 'a' => array('href' => 'http://minixml.psychogenic.com', '-content' => 'XML::Mini')), array('font' => array('size' => '-1', 'color' => '#3333cc', '-content' => 'The table below was generated with php - hooray.')), array('align' => 'center', 'table' => array('cellpadding' => 5)), array('align' => 'left', '-content' => '============================', 'table' => array('width' => '75%', 'align' => 'center', 'tr' => array(array('td' => array('b' => "And here is the output of \$htmlDoc->getValue()", 'br' => '', '-content' => $htmlDoc->getValue()))))))))); # end of hash $options = array('attributes' => array('body' => array('bgcolor', 'link', 'vlink'), '-all' => array('align', 'color'), 'a' => 'href', 'font' => 'size', 'table' => array('cellpadding', 'cellspacing'))); $htmlDoc->fromArray($htmlArray, $options); print $htmlDoc->toString();
mkdir($export_data_dir); if (substr($export_data_dir, -1) != "/") { $export_data_dir .= "/"; } $sourcefiles = array(); $sourcefiles[] = $export_data_dir; // copy all necessary files: copy("files/adlcp_rootv1p2.xsd", $exportdir . "adlcp_rootv1p2.xsd"); $sourcefiles[] = $exportdir . "adlcp_rootv1p2.xsd"; copy("files/ims_xml.xsd", $exportdir . "ims_xml.xsd"); $sourcefiles[] = $exportdir . "ims_xml.xsd"; copy("files/imscp_rootv1p1p2.xsd", $exportdir . "imscp_rootv1p1p2.xsd"); $sourcefiles[] = $exportdir . "imscp_rootv1p1p2.xsd"; copy("files/imsmd_rootv1p2p1.xsd", $exportdir . "imsmd_rootv1p2p1.xsd"); $sourcefiles[] = $exportdir . "imsmd_rootv1p2p1.xsd"; $parsedDoc = new MiniXMLDoc(); $xmlRoot =& $parsedDoc->getRoot(); // Root-Element MANIFEST $manifest =& $xmlRoot->createChild('manifest'); $manifest->attribute('identifier', $USER->username . 'Export'); $manifest->attribute('version', '1.1'); $manifest->attribute('xmlns', 'http://www.imsproject.org/xsd/imscp_rootv1p1p2'); $manifest->attribute('xmlns:adlcp', 'http://www.adlnet.org/xsd/adlcp_rootv1p2'); $manifest->attribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $manifest->attribute('xsi:schemaLocation', 'http://www.imsproject.org/xsd/imscp_rootv1p1p2 imscp_rootv1p1p2.xsd http://www.imsglobal.org/xsd/imsmd_rootv1p2p1 imsmd_rootv1p2p1.xsd http://www.adlnet.org/xsd/adlcp_rootv1p2 adlcp_rootv1p2.xsd'); // Our Organizations $organizations =& $manifest->createChild('organizations'); $organizations->attribute('default', 'DATA'); // Our organization for the export structure
<?php header("Content-type: text/plain\r\n\r\n"); require_once './minixml.inc.php'; $xmlDoc = new MiniXMLDoc(); $xmlStructure = array("spies" => array("spy" => array(array('id' => '007', 'type' => 'SuperSpy', 'name' => 'James Bond', 'email' => '*****@*****.**', 'address' => 'Wherever he is needed most'), array('id' => '6', 'type' => 'RetiredSpy', 'name' => 'Number 6', 'email' => array('type' => 'private', '-content' => '*****@*****.**', 'location' => 'office'), 'address' => '123 Island Prison Lane'), array('name' => 'Inspector Gadget', 'id' => '13', 'type' => 'NotReallyASpy', 'email' => '*****@*****.**', 'friends' => array('friend' => array(array('name' => array('first' => 'little', 'last' => 'girl'), 'age' => 12, 'hair' => array('color' => 'brown', 'length' => 'long')), array('name' => array('first' => 'smelly', 'last' => 'dog'), 'age' => 14, 'hair' => array('color' => 'dirtry blond', 'length' => 'short')))))))); $arrayOptions = array('attributes' => array('-all' => array('type', 'color'), 'spy' => 'id', 'email' => array('location'), 'hair' => 'length')); $xmlDoc->fromArray($xmlStructure, $arrayOptions); print "\n\n\nParsed ARRAY looks like this:\n"; var_dump($xmlDoc->toArray()); print "\n\nOUTPUT of fromArray() *with* OPTIONAL 'attributes' options set (for spy:id, email:location, hair:length, type, color)\n"; print $xmlDoc->toString();
$lang = $_POST["lang"]; $messageArray["pt"]["invalid"] = "Usuário e/ou senha inválidos. Por favor verifique."; $messageArray["pt"]["back"] = "voltar"; $messageArray["es"]["invalid"] = "Usuario y/o contraseña inválidos. Por favor verifique."; $messageArray["es"]["back"] = "volver"; $messageArray["en"]["invalid"] = "Invalid user or password. Please verify."; $messageArray["en"]["back"] = "back"; $message = $messageArray[$lang]; if (isset($_POST["auth_submit"])) { include "auth_config.php"; $filename = $database_name; if (!file_exists($filename)) { echo "Invalid user file. Please check DATABASE_PATH in \"bvs-site-config.php\" file."; } else { $logged_in = 0; $xmlDoc = new MiniXMLDoc(); $xmlDoc->fromFile($filename); $usersXml = $xmlDoc->toArray(); foreach ($usersXml['users']['user'] as $user) { if (isset($user['_attributes'])) { $username = $user['_attributes']['name']; $password = $user['_attributes']['password']; $level = $user['_attributes']['type']; } else { $username = $user['name']; $password = $user['password']; $level = $user['type']; } if ($_POST["auth_usr"] == trim($username) && md5($_POST["auth_pwd"]) == trim($password)) { $logged_in = 1; break;
/** * */ function makeXMLData() { require_once MIGUELBASE_MINIXML . '/minixml.inc.php'; $dump_buffer = ''; $xml = new MiniXMLDoc(); $xmlRoot =& $xml->getRoot(); $config =& $xmlRoot->createChild('config'); $child =& $config->createChild('ddbbSgbd'); $child->text(Session::getValue('host_sgbd')); $child =& $config->createChild('ddbbMainDb'); $child->text(Session::getValue('ddbb_name')); $child =& $config->createChild('ddbbServer'); $child->text(Session::getValue('host_name')); $child =& $config->createChild('ddbbUser'); $child->text(Session::getValue('ddbb_user')); $child =& $config->createChild('ddbbPassword'); $child->text(Session::getValue('ddbb_passwd')); $child =& $config->createChild('siteName'); $child->text(Session::getValue('campus_name')); $child =& $config->createChild('Institution'); $child->text(Session::getValue('inst_name')); $child =& $config->createChild('InstitutionUrl'); $child->text(Session::getValue('inst_url')); $child =& $config->createChild('language'); $child->text(Session::getValue('campus_lang')); $child =& $config->createChild('emailAdministrator'); $child->text(Session::getValue('director_email')); $child =& $config->createChild('administratorName'); $child->text(Session::getValue('admin_name')); $child =& $config->createChild('administratorSurname'); $child->text(Session::getValue('admin_surname')); $child =& $config->createChild('educationManager'); $child->text(Session::getValue('director_name')); $child =& $config->createChild('telephone'); $child->text(Session::getValue('inst_phone')); $child =& $config->createChild('maxFilledSpaceUser'); $child->text('100000'); $child =& $config->createChild('maxFilledSpaceAdmin'); $child->text('1000000'); $child =& $config->createChild('mainInterfaceWidth'); $child->text('100%'); $child =& $config->createChild('miguelVersion'); $child->text(MIGUEL_VERSION); $child =& $config->createChild('versionDb'); $child->text(MIGUEL_DDBB_VERSION); $child =& $config->createChild('userMailCanBeEmpty'); $child->text('true'); $child =& $config->createChild('userPasswordCrypted'); $child->text(Session::getValue('cript_passwd')); //Write data in tmp subfolder File::Write(CONFIG_FILE, $xml->toString()); }
<?php /* This little test demonstrates the use of fromFile() ** mainly so you can play with the MINIXML_USEFROMFILECACHING ** option. For the moment, file caching is hardly usefull ** but this may change if we implement an XSLT interface. */ // xdebug_start_profiling(); header('Content-type: text/plain'); require_once 'minixml.inc.php'; $xmlDoc = new MiniXMLDoc(); $xmlDoc->fromFile('./test.xml'); // xdebug_dump_function_profile(XDEBUG_PROFILER_FS_NC); // xdebug_dump_function_profile(); // xdebug_dump_function_trace(); // xdebug_dump_function_trace(); print $xmlDoc->toString(); $costEl = $xmlDoc->getElementByPath('RATEQUOTE/STANDARDGROUNDTOTAL'); print "Standard: " . $costEl->getValue(); $costEl = $xmlDoc->getElementByPath('RATEQUOTE/DEFINITEDELIVERYTOTAL'); print "\nDefinite: " . $costEl->getValue();
} $XML_str .= "</flight>"; } $XML_str .= "</result>"; send_XML($XML_str); } else { if ($op == "submit_flight") { return; // we dont really need this, is done vi XMLRPC now require_once dirname(__FILE__) . '/lib/miniXML/minixml.inc.php'; $XML_str = "<result>\n"; $XML_path = $_GET['XMLform']; $XML_str .= "<debug>Getting submit info from {$XML_path}</debug>\n"; $linesArray = file($XML_path); $lines = implode("", $linesArray); $xmlDoc = new MiniXMLDoc(); $xmlDoc->fromString($lines); $formArray = $xmlDoc->toArray(); foreach ($formArray[FORM] as $field => $value) { $FL_FORM[$field] = $value; // echo "$field : ".$FL_FORM[$field]."<BR>"; } $sql = "SELECT " . $CONF['userdb']['user_id_field'] . ", " . $CONF['userdb']['username_field'] . ", " . $CONF['userdb']['password_field'] . " FROM " . $CONF['userdb']['users_table'] . " WHERE " . $CONF['userdb']['username_field'] . " = '" . str_replace("\\'", "''", $FL_FORM["username"]) . "'"; if (!($result = $db->sql_query($sql))) { $XML_str .= "<returnCode>-20</returnCode>\n"; $XML_str .= "<returnCodeDescription>Error in obtaining userdata for " . $FL_FORM["username"] . "</returnCodeDescription>\n"; $XML_str .= "<flightID>0</flightID>\n"; $XML_str .= "</result>"; send_XML($XML_str); exit; }
<?php header('Content-type: text/plain'); require_once 'minixml.inc.php'; $xmlDoc = new MiniXMLDoc(); # Fetch the ROOT element for the document # (an instance of XML::Mini::Element) $xmlElement =& $xmlDoc->getRoot(); # Create a sub element $newChild =& $xmlElement->createChild('mychild'); $newChild->text('hello mommy'); # Create an orphan element $orphan =& $xmlDoc->createElement('annie'); $orphan->attribute('hair', '#ff0000'); $orphan->text('tomorrow, tomorrow'); # Adopt the orphan $newChild->prependChild($orphan); $toy =& $xmlDoc->createElement('toy'); $toy->attribute('color', '#0000ff'); $toy->createChild('type', 'teddybear'); $newChild->insertChild($toy, 1); print $xmlDoc->toString(); print "\nUhm, it's not working out - she won't stop singing... Calling removeChild()\n\n"; $newChild->removeChild($orphan); $newChild->text('???'); print $xmlDoc->toString();
function demo() { print "<pre>\n"; $xd = new MiniXMLDoc(); $xd->fromFile("canPos_return.xml"); print "\nStatusCode = " . fetchValue($xd, 'eparcel/ratesAndServicesResponse/statusCode'); print "\ncomment = " . fetchValue($xd, 'eparcel/ratesAndServicesResponse/comment'); print "\nstatusMessage = " . fetchValue($xd, 'eparcel/ratesAndServicesResponse/statusMessage'); print "\n\n"; $shipping_fields = array("name", "rate", "shippingDate", "deliveryDate", "deliveryDayOfWeek", "nextDayAM", "packingID"); var_dump(fetchArray($xd, 'eparcel/ratesAndServicesResponse', 'product', $shipping_fields)); print "\n</pre>"; }
function getExtrernalServerTakeoffs($serverID, $lat, $lon, $limitKm, $limitNum) { global $xmlSites; $takeoffServers = array(1 => array("callUrl" => "http://www.paraglidingearth.com/takeoff_around.php?", "latArg" => "lat", "lonArg" => "lng", "limitKmArg" => "distance", "limitNumArg" => "limit", "XML_name" => "name", "XML_distance" => "distance", "XML_area" => "area", "XML_countryCode" => "countryCode", "XML_url" => "pe_link", "XML_lat" => "lat", "XML_lon" => "lng"), 2 => array("callUrl" => "http://www.paragliding365.com/paragliding_sites_xml.html?type=mini&", "latArg" => "latitude", "lonArg" => "longitude", "limitKmArg" => "radius", "limitNumArg" => "notused", "XML_name" => "name", "XML_distance" => "distance", "XML_area" => "location", "XML_countryCode" => "iso", "XML_url" => "link", "XML_lat" => "lat", "XML_lon" => "lng")); $getXMLurl = $takeoffServers[$serverID]["callUrl"] . $takeoffServers[$serverID]["latArg"] . "={$lat}&" . $takeoffServers[$serverID]["lonArg"] . "={$lon}&" . $takeoffServers[$serverID]["limitKmArg"] . "={$limitKm}&" . $takeoffServers[$serverID]["limitNumArg"] . "={$limitNum}"; //echo $getXMLurl; $xmlSites = fetchURL($getXMLurl); if ($xmlSites) { require_once dirname(__FILE__) . '/lib/miniXML/minixml.inc.php'; $xmlDoc = new MiniXMLDoc(); $xmlDoc->fromString($xmlSites); $xmlArray = $xmlDoc->toArray(); $takeoffsNum = 0; $takoffsList = array(); // print_r($xmlArray); if ($serverID == 1) { // paraglidingearth.com if (is_array($xmlArray['search'])) { if (is_array($xmlArray['search']['takeoff'][0])) { $arrayToUse = $xmlArray['search']['takeoff']; } else { $arrayToUse = $xmlArray['search']; } } else { $arrayToUse = 0; } } else { if ($serverID == 2) { //paragliding365.com if ($xmlArray['root']['flightareas']['flightarea']) { if (is_array($xmlArray['root']['flightareas']['flightarea'][0])) { $arrayToUse = $xmlArray['root']['flightareas']['flightarea']; } else { $arrayToUse = $xmlArray['root']['flightareas']; } } else { $arrayToUse = 0; } } else { $arrayToUse = 0; } } $takeoffsList = array(); $takeoffsNum = 0; if ($arrayToUse) { //echo "#"; //print_r($arrayToUse); foreach ($arrayToUse as $flightareaNum => $flightarea) { $XML_name = $takeoffServers[$serverID]["XML_name"]; $XML_distance = $takeoffServers[$serverID]["XML_distance"]; $XML_area = $takeoffServers[$serverID]["XML_area"]; $XML_countryCode = $takeoffServers[$serverID]["XML_countryCode"]; $XML_url = $takeoffServers[$serverID]["XML_url"]; $XML_lat = $takeoffServers[$serverID]["XML_lat"]; $XML_lon = $takeoffServers[$serverID]["XML_lon"]; if ($flightareaNum !== "_num" && $flightarea[$XML_name]) { $distance = $flightarea[$XML_distance]; if ($distance > $limitKm * 1000) { continue; } $takeoffsList[$takeoffsNum]['distance'] = $flightarea[$XML_distance]; $takeoffsList[$takeoffsNum]['name'] = $flightarea[$XML_name]; $takeoffsList[$takeoffsNum]['area'] = $flightarea[$XML_area]; $takeoffsList[$takeoffsNum]['countryCode'] = $flightarea[$XML_countryCode]; $takeoffsList[$takeoffsNum]['url'] = $flightarea[$XML_url]; $takeoffsList[$takeoffsNum]['lat'] = $flightarea[$XML_lat]; $takeoffsList[$takeoffsNum]['lon'] = $flightarea[$XML_lon]; $takeoffsNum++; if ($takeoffsNum == $limitNum) { break; } } } } return $takeoffsList; } // if we have content return array(); }
$export_data_dir .= "/"; } $sourcefiles = array(); $sourcefiles[] = $export_data_dir; // copy all necessary files: copy("epxfiles/comment.xsd", $exportdir . "comment.xsd"); $sourcefiles[] = $exportdir . "comment.xsd"; copy("epxfiles/epx.xsd", $exportdir . "epx.xsd"); $sourcefiles[] = $exportdir . "epx.xsd"; copy("epxfiles/file.xsd", $exportdir . "file.xsd"); $sourcefiles[] = $exportdir . "file.xsd"; copy("epxfiles/link.xsd", $exportdir . "link.xsd"); $sourcefiles[] = $exportdir . "link.xsd"; copy("epxfiles/note.xsd", $exportdir . "note.xsd"); $sourcefiles[] = $exportdir . "note.xsd"; $parsedDoc = new MiniXMLDoc(); $xmlRoot =& $parsedDoc->getRoot(); $epxroot =& $xmlRoot->createChild('epx:epx'); $epxroot->attribute('version', '1.0'); $epxroot->attribute('xmlns:epx', 'https://opensvn.csie.org/epoman/EPX'); $epxportfolio =& $epxroot->createChild('epx:portfolio'); $epxportfolio->attribute('created', date("c")); $epxportfolio->attribute('name', 'Portfolio exported from Moodle'); // epx: personal information $epxinformation =& $epxportfolio->createChild('epx:information'); // TODO: this date is just the current date. Set it to the date of the last edit of the description!!! $epxinformation->attribute('lastedited', date("c")); $epxusername =& $epxinformation->createChild('epx:username'); $epxusername->cdata($USER->username); $epxforename =& $epxinformation->createChild('epx:forename'); $epxforename->cdata($USER->firstname);
require_once './minixml.inc.php'; function createHREF(&$parent, $name, $href) { $ac =& $parent->createChild('a'); $ac->attribute('href', $href); $afontel =& $ac->createChild('font'); $afontel->attribute('color', '#eeeeee'); $afontel->text($name); $parent->text(' '); return; } $t1NumRows = 3; $t1NumCols = 3; $t2NumRows = 2; $t2NumCols = 2; $htmlDoc = new MiniXMLDoc(); $docRoot =& $htmlDoc->getRoot(); $html =& $docRoot->createChild('html'); $head =& $html->createChild('head'); $title =& $head->createChild('title', 'MiniXML Generated HTML page'); $style =& $head->createChild('style'); $style->comment("body,td,a,p,.h{font-family:arial,sans-serif;} .q{text-decoration:none; color:#0000cc;}"); $body =& $html->createChild('body'); $body->attribute('bgcolor', '#ffffff'); $body->attribute('link', '#0000cc'); $body->attribute('vlink', '#551a8b'); $h =& $body->createChild('h3', 'This page was generated by MiniXML!'); /* Note that, when MINIXML_AUTOESCAPE_ENTITIES is set, we can stick in <> tags */ $p1 =& $body->createChild('p', "It slices, dices and never forgets the </closing tags>! heh ;) "); $br =& $p1->createChild('br'); $p1->text("View the source of this page to take a look at ");
function isPackageFile($p_file) { global $zoom; $xmlDoc = new MiniXMLDoc(); $xmlDoc->fromFile($p_file); $iszoomupdate =& $xmlDoc->getElementByPath('zoomupdate'); if ($iszoomupdate) { // Set the type $this->installType($iszoomupdate->attribute("type")); $this->installFilename($p_file); return $xmlDoc; } return null; }
foreach ($folders[1] as $folder) { preg_match("/<name>(.*)<\\/name>/isU", $folder, $folderNameRes); $folderName = $folderNameRes[1]; //echo "<br>### doing folder : $folderName <br>"; preg_match_all("/<Placemark>(.*)<\\/Placemark>/isU", $folder, $placemarks); foreach ($placemarks[1] as $placemark) { if (preg_match("/<name>(.*)<\\/name>.*<Point.*>.*<coordinates>(.*),(.*),(.*)<\\/coordinates>.*<\\/Point>/isU", $placemark, $info)) { //echo "<hr>name=".$info[1].", lat=".$info[2].", lon=".$info[3].", alt=".$info[4]."<hr>"; $foundPoints++; } } } echo "Found {$foundPoints} points<br>"; $foundPoints = 0; require_once dirname(__FILE__) . '/lib/miniXML/minixml.inc.php'; $parsedDoc = new MiniXMLDoc(); $parsedDoc->fromString($lines); $rootEl =& $parsedDoc->getRoot(); procElement($rootEl->getElementByPath("kml")); //$mainFolder=$rootEl->getElementByPath("Folder"); //$elChildren =& $mainFolder->getAllChildren(); echo "Found {$foundPoints} points<br>"; } function procElement(&$el, $folderName = "", $depth = 1) { global $foundPoints; $elChildren =& $el->getAllChildren(); // echo "element has ".$el->numChildren()." childs, we are at depth: $depth<br>"; for ($i = 0; $i < $el->numChildren(); $i++) { if ($elChildren[$i]->name() == "Placemark") { $pl_name = $elChildren[$i]->getElementByPath("name");
<?php /** ensure this file is being included by a parent file */ defined('_JEXEC') or die('Restricted access'); require "minixml/minixml.inc.php"; print "<pre>\n"; $xd = new MiniXMLDoc(); $xd->fromFile("canPos_return.xml"); print "\nStatusCode = " . fetchValue($xd, 'eparcel/ratesAndServicesResponse/statusCode'); print "\ncomment = " . fetchValue($xd, 'eparcel/ratesAndServicesResponse/comment'); print "\nstatusMessage = " . fetchValue($xd, 'eparcel/ratesAndServicesResponse/statusMessage'); print "\n\n"; $shipping_fields = array("name", "rate", "shippingDate", "deliveryDate", "deliveryDayOfWeek", "nextDayAM", "packingID"); var_dump(fetchArray($xd, 'eparcel/ratesAndServicesResponse', 'product', $shipping_fields)); print "\n</pre>"; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - function fetchArray(&$xmldoc, $path, $tag, $fields) { $response = $xmldoc->getElementByPath($path); $children = $response->getAllChildren(); $count = 0; $array = array(); for ($i = 0; $i < $response->numChildren(); $i++) { if ($tag == $children[$i]->name()) { foreach ($fields as $field) { $name = $children[$i]->getElement($field); $array[$count][$field] = $name->getValue(); } $count++; } }
function sync($chunkSize = 5, $verbose = 1) { // we pull data from this server global $CONF_server_id, $CONF_tmp_path; global $DBGlvl; $this->getFromDB(); // we need to take care for protocol version 2, // in v21 the StartID is the last TM in UTC , we need to start again from the last TM // in case 2 or more actions were preformed on the same second and we only // proccessed them partially // Problem: the last transaction gets pulled again and again !!! // we need to detect if the same transaction ID has been proccessed // at least 2 times, then we can move to the next ID without fear of loosing // transactions made in the same second. // we have enforced RULE #1 on the other server running protocol v2 // RULE #1 // we ensure that no transactions of the same second are split into 2 log batches // thats why we get 100 more entries and stop manually // so the following is not needed nay more , we always start +1 /* if ( $this->getProtocolVersion() == 2 ) $startID=$this->lastPullUpdateID; else // old version $startID=$this->lastPullUpdateID+1; */ $startID = $this->lastPullUpdateID + 1; if ($this->data['isLeo']) { $urlToPull = 'http://' . $this->data['url_base'] . '/sync.php?type=1&version=' . $this->getProtocolVersion(); $urlToPull .= "&c={$chunkSize}&startID={$startID}&format=" . $this->data['sync_format']; $urlToPull .= "&clientID={$CONF_server_id}&clientPass="******"&sync_type=" . $this->data['sync_type'] . "&use_zip=" . $this->data['use_zip']; } else { $urlToPull = 'http://' . $this->data['url_sync'] . "count={$chunkSize}&startID={$startID}"; } if ($verbose) { echo "Getting <strong>" . $this->data['sync_format'] . "</strong> sync-log from {$urlToPull} ... "; } if ($verbose) { flush2Browser(); } if ($verbose) { flush2Browser(); } $timeout = 60 + floor($chunkSize / 5); if ($this->data['sync_type'] & SYNC_INSERT_FLIGHT_LOCAL && $this->data['use_zip']) { $timeout *= 5; } $rssStr = fetchURL($urlToPull, $timeout); if (!$rssStr) { echo "<div class='error'>Cannot get data from server</div><BR>"; return array(-1, "Cannot get data from {$urlToPull}"); } if ($verbose) { echo " <div class='ok'>DONE</div><br>"; } if ($verbose) { flush2Browser(); } if ($this->data['use_zip']) { // we have a zip file in $rssStr, unzip it if ($verbose) { echo "Unziping sync-log ... "; } $tmpZIPfolder = $CONF_tmp_path . '/' . $this->ID . "_" . time(); makeDir($tmpZIPfolder); $zipFile = "{$tmpZIPfolder}/sync_log.zip"; writeFile($zipFile, $rssStr); require_once dirname(__FILE__) . "/lib/pclzip/pclzip.lib.php"; $archive = new PclZip($zipFile); $list = $archive->extract(PCLZIP_OPT_PATH, $tmpZIPfolder, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_BY_PREG, "/(\\.igc)|(\\.olc)|(\\.txt)\$/i"); if ($list) { if ($verbose) { echo " <div class='ok'>DONE</div><br>"; } echo "<br><b>List of uploaded igc/olc/txt files</b><BR>"; $f_num = 1; foreach ($list as $fileInZip) { echo "{$f_num}) " . $fileInZip['stored_filename'] . ' (' . floor($fileInZip['size'] / 1024) . 'Kb)<br>'; $f_num++; } if ($verbose) { flush2Browser(); } if (is_file($tmpZIPfolder . '/sync.txt')) { $rssStr = implode('', file($tmpZIPfolder . '/sync.txt')); } else { echo "Could not find sync.txt. <div class='error'>Aborting</div>"; delDir($tmpZIPfolder); return array(-2, "Could not find sync.txt"); } //delDir($tmpZIPfolder); //exit; } else { echo " <div class='error'>This is not a zip file (" . $archive->errorInfo() . ")</div><br>"; } } // // getIGC // zip // for debugging json // writeFile(dirname(__FILE__).'/sync.txt',$rssStr); //return; // echo "<PRE>$rssStr</pre>"; if ($this->data['sync_format'] == 'XML') { require_once dirname(__FILE__) . '/lib/miniXML/minixml.inc.php'; $xmlDoc = new MiniXMLDoc(); $xmlDoc->fromString($rssStr); $xmlArray = $xmlDoc->toArray(); //echo "<PRE>"; //print_r($xmlArray); //echo "</PRE>"; if ($xmlArray['log']['item']['_num']) { foreach ($xmlArray['log']['item'] as $i => $logItem) { if (!is_numeric($i)) { continue; } if (!$this->processSyncEntry($this->ID, $logItem)) { // if we got an error break the loop, the admin must solve the error break; } } } else { $this->processSyncEntry($this->ID, $xmlArray['log']['item']); } } else { if ($this->data['sync_format'] == 'JSON') { if ($verbose) { echo "Decoding log from JSON format ..."; } if ($verbose) { flush2Browser(); } require_once dirname(__FILE__) . '/lib/json/CL_json.php'; // is this needed ? // $rssStr=str_replace('\\\\"','\"',$rssStr); // for testing emply log // $rssStr='{ "log": [ ] }'; // for testing bad log // $rssStr='{ "log": [ }'; $arr = json::decode($rssStr); if ($verbose) { echo " <div class='ok'>DONE</div><br>"; } if ($verbose) { flush2Browser(); } if ($DBGlvl > 0) { echo "<PRE>"; print_r($arr); echo "</PRE>"; } //exit; $entriesNum = 0; $entriesNumOK = 0; if (count($arr['log'])) { if ($verbose) { echo "Log Entries: <div class='ok'>" . count($arr['log']) . "</div><br>"; } if ($verbose) { flush2Browser(); } foreach ($arr['log'] as $i => $logItem) { if (!is_numeric($i)) { continue; } echo $entriesNum + 1 . " / {$chunkSize} "; // add path of temp folder into array $logItem['item']['tmpDir'] = $tmpZIPfolder; $entryResult = $this->processSyncEntry($this->ID, $logItem['item'], $verbose); if ($entryResult <= -128) { // if we got an error break the loop, the admin must solve the error echo "<div class'error'>Got fatal Error, will exit</div>"; $errorInProccess = 1; break; } if ($entryResult > 0) { $entriesNumOK++; } $entriesNum++; } } else { if (is_array($arr['log'])) { // no log entries to proccess delDir($tmpZIPfolder); echo "No new log entries to proccess<br />"; return array(0, 0); } if ($verbose) { echo "Sync-log format error:<br />"; print_r($arr); echo "<hr><pre>{$rssStr}</pre>"; } else { echo "Sync-log format error:<br><pre>{$rssStr}</pre><br>"; } delDir($tmpZIPfolder); return array(-4, "Sync-log format error: <pre>{$rssStr}</pre>"); } } } if ($verbose || $entriesNum > 0) { echo "<div class='ok'>Sync-log replication finished</div><br>"; echo "Proccessed {$entriesNum} log entries ({$entriesNumOK} inserted OK) out of {$chunkSize}<br>"; } // clean up delDir($tmpZIPfolder); if ($errorInProccess) { return array(-3, $entriesNum); } else { return array(1, $entriesNum); } }
function mountFingerPrint($conceptList) { $fingerPrint = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"; $conceptIdList = ""; // percorre todas as variaveis do POST para criar um array com id e rank agrupados por tesauro foreach ($_POST as $key => $value) { if (ereg("^concept_", $key) == true) { $conceptParts = split("_", $key); $conceptThesaurus = $conceptParts[1]; $conceptId = $conceptParts[2]; $conceptRank = $_POST['rank_' . $conceptId]; $fingerprintList["{$conceptThesaurus}"]["{$conceptId}"] = $conceptRank; $conceptIdList .= $conceptId; } } //adiciona novo conceito selecionado if ($_REQUEST['add_concept_id'] != '') { $add_concept_id = $_REQUEST['add_concept_id']; $add_concept_thesaurus = $_REQUEST['add_concept_thesaurus']; // verifica se o conceito n�o existe na lista de conceitos da p�gina if (strpos($conceptIdList, $add_concept_id) === false) { $fingerprintList["{$add_concept_thesaurus}"]["{$add_concept_id}"] = "1.1"; } } //adiciona novo conceito manual if ($_REQUEST['add_concept_name'] != '') { $add_concept_name = $_REQUEST['add_concept_name']; $add_concept_thesaurus = $_REQUEST['add_concept_thesaurus']; //indexa termo para verificar se o mesmo consta do thesauro $wsRequestUrl = $this->webservice . "task=fingerprint&thesaurus=" . $this->wsParam["thesaurus"] . "&additional_thesaurus=freetext&output=4&expression=" . $add_concept_name; $wsResult = $this->documentPost($wsRequestUrl); $fpXML = new MiniXMLDoc($wsResult); $fpArray = $fpXML->toArray(); foreach ($fpArray['fingerprintlist']['fingerprint'] as $fingerprint) { $thesaurus = $fingerprint['_attributes']['thesaurus']; $concepts_count = $fingerprint['concepts']['_attributes']['count']; if ($concepts_count > 0) { if ($concepts_count == 1) { $concept_id = $fingerprint['concept']['_attributes']['id']; $fingerprintList["{$thesaurus}"]["{$concept_id}"] = "1.1"; } else { for ($i = 0; $i < $concepts_count; $i++) { $concept_id = $fingerprint['concept'][$i]['_attributes']['id']; $fingerprintList["{$thesaurus}"]["{$concept_id}"] = "1.1"; } } } } /* preg_match_all('/ id="([0-9]*)"/',$wsResult, $discovery_concepts); foreach ($discovery_concepts[1] as $new_concept){ $fingerprintList["$add_concept_thesaurus"]["$new_concept"] = "1.1"; } */ } // cria fingerprintlist xml $fingerPrint .= "<fingerprintlist>"; foreach ($fingerprintList as $thesaurus => $concepts) { $fingerPrint .= " <fingerprint thesaurus=\"" . $thesaurus . "\">"; foreach ($concepts as $id => $rank) { $required = "no"; if ($rank == "1.1") { //if concept is marked required (top) $rank = "1"; $required = "yes"; } $fingerPrint .= "<concept id=\"" . $id . "\" rank=\"" . $rank . "\" required=\"" . $required . "\"/>"; } $fingerPrint .= " </fingerprint>"; } $fingerPrint .= "</fingerprintlist>"; return $fingerPrint; }