コード例 #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
        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");
            $parent_name = $el->getElementByPath("name");
コード例 #4
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();
}
コード例 #5
0
ファイル: example.php プロジェクト: annggeel/tienda

<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-&gt;<font color=\"ee3333\">toString</font>() returns:\n";
print htmlentities($returnedXMLDoc->toString());
print "Call to : \$returnedXMLDoc-&gt;<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.
** Normally, you'd be verifying that the element was found
** but in order to keep this light and keep everybody from 
** getting into the habit of good error checking, I'll skip
** it.
コード例 #6
0
ファイル: EXT_flight.php プロジェクト: Peter2121/leonardoxc
         $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;
         }
         $passwdProblems = 0;
コード例 #7
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);
     }
 }