コード例 #1
0
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>";
}
コード例 #2
0
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;
}
コード例 #3
0
ファイル: FN_functions.php プロジェクト: Peter2121/leonardoxc
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();
}
コード例 #4
0
ファイル: toarray.php プロジェクト: stepheneb/test-from-svn
<?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());
コード例 #5
0
ファイル: auth_user.php プロジェクト: rgevaert/ABCD
$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;
            }
        }
コード例 #6
0
ファイル: fromArray.php プロジェクト: stepheneb/test-from-svn
<?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();
コード例 #7
0
ファイル: EXT_flight.php プロジェクト: Peter2121/leonardoxc
     }
     $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;
         }
         $passwdProblems = 0;
         if ($row = $db->sql_fetchrow($result)) {
コード例 #8
0
ファイル: collexis.php プロジェクト: padlrosa/Regional-2
 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;
 }
コード例 #9
0
ファイル: CL_server.php プロジェクト: Peter2121/leonardoxc
 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);
     }
 }