} else {
                if ($op == "get_latest") {
                    $tm = $_GET['tm'] + 0;
                    // timestamp
                    if (!$tm) {
                        $tm = time() - 60 * 60 * 24 * 7;
                    }
                    // 1 week back
                    $query = "SELECT * from {$waypointsTable} WHERE modifyDate>=FROM_UNIXTIME({$tm}) AND type=1000 ";
                    $res = $db->sql_query($query);
                    header('Content-Type: text/xml');
                    echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>";
                    echo "<search>";
                    if ($res <= 0) {
                        echo "</search>";
                        return;
                    }
                    $i = 0;
                    while ($row = mysql_fetch_assoc($res)) {
                        $resWaypoint = new waypoint($row["ID"]);
                        $resWaypoint->getFromDB();
                        echo $resWaypoint->exportXML('XML');
                        $i++;
                    }
                    mysql_freeResult($res);
                    echo "</search>";
                }
            }
        }
    }
}
Exemple #2
0
 $minTakeoffDistance = 10000000;
 $i = 0;
 foreach ($waypoints as $waypoint) {
     $takeoff_distance = $firstPoint->calcDistance($waypoint);
     if ($takeoff_distance < $minTakeoffDistance) {
         $minTakeoffDistance = $takeoff_distance;
         $takeoffIDTmp = $waypoint->waypointID;
     }
     $i++;
 }
 $nearestWaypoint = new waypoint($takeoffIDTmp);
 $nearestWaypoint->getFromDB();
 $XML_str = "<result>\n";
 $XML_str .= "\n\t\t\t<title>Leonardo at " . $_SERVER['SERVER_NAME'] . " :: Flight list</title>\n\t\t\t<link>http://" . $_SERVER['SERVER_NAME'] . getLeonardoLink(array('op' => 'list_flights')) . "</link>\t\t\n\t\t\t<date>" . gmdate('D, d M Y H:i:s', time()) . " GMT</date>\n\t\t";
 $XML_str .= "<waypoints>\n";
 $XML_str .= $nearestWaypoint->exportXML('XML');
 $XML_str .= "\n<distance>" . sprintf("%.0f", $minTakeoffDistance) . "</distance>\n";
 $XML_str .= "</waypoints>\n\n";
 $where_clause = "AND takeoffID={$nearestWaypoint->waypointID} AND filename<>'' ";
 $query = "SELECT * FROM {$flightsTable} WHERE private=0 {$where_clause} ORDER BY FLIGHT_POINTS  DESC {$lim} ";
 //echo $query;
 //exit;
 $res = $db->sql_query($query);
 if ($res <= 0) {
     echo "<H3> Error in query! {$query} </H3>\n";
     exit;
 }
 $XML_str .= "\n\t\t<flights>";
 while ($row = mysql_fetch_assoc($res)) {
     //			 $nearestWaypoint=new waypoint($takeoffIDTmp);
     //			 $nearestWaypoint->getFromDB();