function findTakeoff($args) { $sitePass = $args[0]; $lat = $args[1]; $lon = $args[2]; if (!securityCheck($sitePass)) { return new IXR_Error(4000, 'Access Denied'); } $firstPoint = new gpsPoint(); $firstPoint->lat = $lat; $firstPoint->lon = $lon; // calc TAKEOFF - LANDING PLACES if (count($waypoints) == 0) { $waypoints = getWaypoints(); } $takeoffIDTmp = 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(); // echo "&^".$nearestWaypoint->name."&"; return array($nearestWaypoint, $minTakeoffDistance); }
function checkLocation($serverID, $locationArray, $bounds) { // print_r($locationArray); // find nearest waypoint in local db list($nearestTakeoffID, $nearestDistance) = findNearestWaypoint($bounds['firstLat'], $bounds['firstLon']); // echo "nearest takeoff : $nearestTakeoffID,$nearestDistance <BR>"; if ($nearestDistance < $locationArray['takeoffVinicity'] + 500) { // we will use our waypoint if our local waypoint is nearest ( + 500m margin ) return array($nearestTakeoffID, $nearestDistance); } else { // we will import this takeoff and use that instead $newWaypoint = new waypoint(); $newWaypoint->setLat($locationArray['takeoffLat']); $newWaypoint->setLon($locationArray['takeoffLon']); $newWaypoint->name = $locationArray['takeoffName']; $newWaypoint->type = 1000; // takeoff $newWaypoint->intName = $locationArray['takeoffNameInt']; $newWaypoint->location = $locationArray['takeoffLocation']; $newWaypoint->intLocation = $locationArray['takeoffLocationInt']; $newWaypoint->countryCode = $locationArray['takeoffCountry']; $newWaypoint->link = ''; $newWaypoint->description = ''; $newWaypoint->putToDB(0); // also add it up to $waypoints because we use this array for subsequent queries global $waypoints; array_push($waypoints, $newWaypoint); return array($newWaypoint->waypointID, $locationArray['takeoffVinicity']); } }
} 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>"; } } } } }
function GetTripDetail($tripId) { //----------------------------------------- // selected trip $trip = new trip(); $trip->retrieve($tripId); // get all waypoints for this trip $waypoint = new waypoint(); $waypoints = $waypoint->getAllObjectsArray('tripid = ' . DB::qstr($tripId), null, 'objid'); /* $wpdistance = ''; $totaldistance = 0; $wptypical = ''; $totaltypical = 0; $wpconsumption = ''; $totalconsumption = 0; $wpaverage = ''; $wpdrivetime = ''; $totaldrivetime = 0; $wpchargetime = ''; $totalchargetime = 0; $startdrivetime = $trip->att('theoreticalstarttime'); $wpchargeneeded = 0; $wpchargestarted = 0; $wparrivaltime = ''; $wpdeparturetime = ''; $wpchargestart = 0; */ // declare and initialize all variables $wpnbr = -1; $statusid = WaypointStatus::STATUS_LEFT; // build the waypoints array $dwp = null; //foreach ($waypoints as &$wp) { for ($i = 0; $i < count($waypoints); $i++) { // get the needed waypoints $wp = $waypoints[array_keys($waypoints)[$i]]; if ($i > 0) { $prevwp = $waypoints[array_keys($waypoints)[$i - 1]]; } if ($i < count($waypoints) - 1) { $nextwp = $waypoints[array_keys($waypoints)[$i + 1]]; } // get the active waypoint (etappe) and status if ($statusid == WaypointStatus::STATUS_LEFT) { $wpnbr++; $statusid = $wp['statusid']; } // calculate all values // first position : O overview (effective), T theoretical, F formatting // second position : A distance, T Typical, V consumption G Average // third position : 1 waypoint-value, 2 sum CalculateDistance($i, $wp, $prevwp, $oa1, $ta1, $oa2, $ta2, $ot1, $tt1, $ot2, $tt2, $ov1, $tv1, $ov2, $tv2, $og1, $tg1, $og2, $tg2, $fa1, $fa2, $ft1, $ft2, $fv1, $fv2, $fg1, $fg2); $oa1 = format($oa1, 1); $foa2 = format($oa2, 1); $ta1 = format($ta1, 1); $fta2 = format($ta2, 1); $ot1 = format($ot1, 0); $fot2 = format($ot2, 0); $tt1 = format($tt1, 0); $ftt2 = format($tt2, 0); $ov1 = format($ov1, 1); $fov2 = format($ov2, 1); $tv1 = format($tv1, 1); $ftv2 = format($tv2, 1); $og1 = format($og1, 0); $fog2 = format($og2, 0); $tg1 = format($tg1, 0); $ftg2 = format($tg2, 0); CalculateTimes($trip, $i, $wp, $prevwp, $nextwp, $or1, $tr1, $or2, $tr2, $ol1, $tl1, $ol2, $tl2, $ocn, $tcn, $oat, $tat, $ovt, $tvt, $fr1, $fr2, $fl1, $fl2, $fcn, $fat, $fvt); // build the waypoint output result $dwp[] = array('id' => $wp['objid'], 'location' => '', 'name' => $wp['destination'], 'statusid' => $wp['statusid'], 'overview' => array('distance' => $oa1, 'totaldistance' => $foa2, 'typical' => $ot1, 'totaltypical' => $fot2, 'consumption' => $ov1, 'totalconsumption' => $fov2, 'average' => $og1, 'totalaverage' => $fog2, 'drivetime' => $or1, 'totaldrivetime' => $or2, 'chargetime' => $ol1, 'totalchargetime' => $ol2, 'chargeneeded' => $ocn, 'arrivaltime' => $oat, 'departuretime' => $ovt), 'theoretical' => array('distance' => $ta1, 'totaldistance' => $fta2, 'typical' => $tt1, 'totaltypical' => $ftt2, 'consumption' => $tv1, 'totalconsumption' => $ftv2, 'average' => $tg1, 'totalaverage' => $ftg2, 'drivetime' => $tr1, 'totaldrivetime' => $tr2, 'chargetime' => $tl1, 'totalchargetime' => $tl2, 'chargeneeded' => $tcn, 'arrivaltime' => $tat, 'departuretime' => $tvt), 'formating' => array('distance' => $fa1, 'totaldistance' => $fa2, 'typical' => $ft1, 'totaltypical' => $ft2, 'consumption' => $fv1, 'totalconsumption' => $fv2, 'average' => $fg1, 'totalaverage' => $fg2, 'drivetime' => $tr1, 'totaldrivetime' => $tr2, 'chargetime' => $tl1, 'totalchargetime' => $tl2, 'chargeneeded' => $tcn, 'arrivaltime' => $tat, 'departuretime' => $tvt)); //$wpchargestarted = $wpchargeneeded; } // final result $d = array('id' => $tripId, 'desc' => $trip->att('name'), 'statusid' => $statusid, 'etape' => $wpnbr, 'waypoints' => $dwp); return array("key" => "trip", "data" => $d); //return $d; }
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $CONF_ENCODING; ?> "> <style type="text/css"> body, p, table,tr,td {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;} body {margin:0px} </style> <script language="javascript" src="<?php echo $moduleRelPath; ?> /js/DHTML_functions.js"></script> </head> <?php $waypointIDview = makeSane($_GET['wID'], 1); $wpInfo = new waypoint($waypointIDview); $wpInfo->getFromDB(); // $wpName= getWaypointName($waypointIDview); $wpName = selectWaypointName($wpInfo->name, $wpInfo->intName, $wpInfo->countryCode); $wpLocation = selectWaypointLocation($wpInfo->location, $wpInfo->intLocation, $wpInfo->countryCode); if (L_auth::isAdmin($userID)) { $opString = "<a href='" . getLeonardoLink(array('op' => 'edit_waypoint', 'waypointIDedit' => $waypointIDview)) . "'><img src='" . $moduleRelPath . "/img/change_icon.png' border=0 align=bottom></a>"; } $titleString = _Waypoint_Name . " : " . $wpName . " (" . $countries[$wpInfo->countryCode] . ") "; //$opString="<a href='#' onclick=\"toggleVisible('takeoffID','takeoffPos',14,-20,0,0);return false;\"> //<img src='".$moduleRelPath."/templates/".$PREFS->themeName."/img/exit.png' border=0></a>"; open_inner_table("<table class=main_text width=100% cellpadding=0 cellspacing=0><tr><td>" . $titleString . "</td><td align=right width=50><div align=right>" . $opString . "</div></td></tr></table>", 705, "icon_pin.png"); open_tr(); echo "<td>"; ?>
function GetTripDetail($tripId) { //----------------------------------------- // selected trip $trip = new trip(); $trip->retrieve($tripId); $waypoint = new waypoint(); $waypoints = $waypoint->getAllObjectsArray('tripid = ' . DB::qstr($tripId), null, 'objid'); // make the result array $wpnbr = -1; $statusid = 4; $wpdistance = ''; $totaldistance = 0; $wptypical = ''; $totaltypical = 0; $wpconsumption = ''; $totalconsumption = 0; $wpaverage = ''; $wpdrivetime = ''; $totaldrivetime = 0; $wpchargetime = ''; $totalchargetime = 0; $startdrivetime = $trip->att('theoreticalstarttime'); $wpchargeneeded = 0; $wpchargestarted = 0; $wparrivaltime = ''; $wpdeparturetime = ''; $wpchargestart = 0; // build the waypoints array $dwp = null; //foreach ($waypoints as &$wp) { for ($i = 0; $i < count($waypoints); $i++) { $wp = $waypoints[array_keys($waypoints)[$i]]; //var_dump($wp); exit(); if ($statusid == 4) { $wpnbr++; $statusid = $wp['statusid']; } if ($i == 0) { // first waypoint initialize counters if ($wp['statusid'] < 4) { $startdrivetime = $trip->att('date'); $wpchargeneeded = $wp['theoreticalchargeneeded']; } else { $startdrivetime = $wp['departuretime']; $wpchargeneeded = $wp['departuretypical']; } $wpdeparturetime = date('H:i', $startdrivetime); $wpchargestarted = $wpchargeneeded; } else { // make running totals if ($wp['statusid'] == 0) { $wpdistance = $wp['theoreticaldistance']; $wptypical = $wp['theoreticaltypical']; $wpconsumption = $wp['theoreticalconsumption']; $wparrivaltime = $startdrivetime + $wp['theoreticaldrivetime'] * 60; $wpchargestart = $wpchargestarted - $wp['theoreticaltypical']; } else { $wpdistance = $wp['arrivaldistance']; $wptypical = $wpchargestarted - $wp['arrivaltypical']; $wpconsumption = $wp['arrivalconsumption']; $wparrivaltime = $wp['arrivaltime']; $wpchargestart = intval($wp['arrivaltypical']); } $totaldistance += $wpdistance; $totaltypical += $wptypical; $totalconsumption += $wpconsumption; $startdrivetime = $wparrivaltime; if ($wpdistance != 0) { $wpaverage = round($wpconsumption * 1000 / $wpdistance, 0); } else { $wpaverage = ''; } if ($wp['statusid'] < 3) { //$startdrivetime = $wparrivaltime + ($wp['theoreticalchargetime'] * 60); $startdrivetime = $wparrivaltime + CalculateChargeTime(0, $wp['theoreticalchargeneeded']) * 60; $wpchargeneeded = $wp['theoreticalchargeneeded']; } if ($wp['statusid'] == 3) { $startdrivetime = $wp['chargeendtime']; $wpchargeneeded = $wp['chargeendtypical']; } if ($wp['statusid'] == 4) { $wpchargeneeded = $wp['departuretypical']; $startdrivetime = $wp['departuretime']; } // to calculate $wpdrivetime = $wp['theoreticaldrivetime']; $totaldrivetime += $wpdrivetime; //$wpchargetime = $wp['theoreticalchargetime']; $wpchargetime = CalculateChargeTime(0, $wp['theoreticalchargeneeded']); $totalchargetime += $wpchargetime; //format the output $wpdistance = number_format($wpdistance, 1, ',', '.'); $wptypical = number_format($wptypical, 0); $wpconsumption = number_format($wpconsumption, 1, ',', '.'); $wpdrivetime = date('H:i', mktime(0, $wpdrivetime, 0, 1, 1, 2000)); if ($wpchargetime > 0) { $wpchargetime = date('H:i', mktime(0, $wpchargetime, 0, 1, 1, 2000)); } else { $wpchargetime = ''; } $wparrivaltime = date('H:i', $wparrivaltime); $wpdeparturetime = date('H:i', $startdrivetime); } // build the waypoint $dwp[] = array('id' => $wp['objid'], 'location' => '', 'name' => $wp['destination'], 'statusid' => $wp['statusid'], 'overview' => array('distance' => $wpdistance, 'totaldistance' => number_format($totaldistance, 1, ',', '.'), 'typical' => $wptypical, 'totaltypical' => $totaltypical, 'consumption' => $wpconsumption, 'totalconsumption' => number_format($totalconsumption, 1, ',', '.'), 'averageconsumption' => $wpaverage, 'drivetime' => $wpdrivetime, 'totaldrivetime' => date('H:i', mktime(0, $totaldrivetime, 0, 1, 1, 2000)), 'chargetime' => $wpchargetime, 'totalchargetime' => date('H:i', mktime(0, $totalchargetime, 0, 1, 1, 2000)), 'chargeneeded' => $wpchargeneeded, 'arrivaltime' => $wparrivaltime, 'departuretime' => $wpdeparturetime), 'theoretical' => array('arrival' => array('distance' => $wpdistance + 0.0, 'typical' => $wpchargestarted - $wp['theoreticaltypical'], 'consumption' => $wp['theoreticalconsumption'] + 0.0, 'time' => $wp['theoreticaldrivetime']), 'chargestart' => array('typical' => $wpchargestart, 'time' => ''), 'chargeend' => array('typical' => $wp['theoreticalchargeneeded'] + 0, 'time' => ''), 'departure' => array('distance' => 0.0, 'typical' => $wpchargeneeded + 0, 'consumption' => 0.0, 'time' => '')), 'effective' => array('arrival' => array('distance' => $wp['arrivaldistance'], 'typical' => $wp['arrivaltypical'], 'consumption' => $wp['arrivalconsumption'], 'time' => $wp['arrivaltime']), 'chargestart' => array('typical' => $wp['chargestarttypical'], 'time' => $wp['chargestarttime']), 'chargeend' => array('typical' => $wp['chargeendtypical'], 'time' => $wp['chargeendtime']), 'departure' => array('distance' => $wp['departuredistance'], 'typical' => $wp['departuretypical'], 'consumption' => $wp['departureconsumption'], 'time' => $wp['departuretime']))); $wpchargestarted = $wpchargeneeded; } // final result $d = array('id' => $tripId, 'desc' => $trip->att('name'), 'statusid' => $statusid, 'etape' => $wpnbr, 'waypoints' => $dwp); return array("key" => "trip", "data" => $d); //return $d; }
require_once dirname(__FILE__) . "/FN_waypoint.php"; require_once dirname(__FILE__) . "/FN_output.php"; require_once dirname(__FILE__) . "/FN_pilot.php"; require_once dirname(__FILE__) . "/FN_flight.php"; require_once dirname(__FILE__) . "/templates/" . $PREFS->themeName . "/theme.php"; setDEBUGfromGET(); require_once dirname(__FILE__) . "/language/" . CONF_LANG_ENCODING_TYPE . "/lang-" . $currentlang . ".php"; require_once dirname(__FILE__) . "/language/" . CONF_LANG_ENCODING_TYPE . "/countries-" . $currentlang . ".php"; if (!L_auth::isAdmin($userID)) { // return; } $waypointLat = $_REQUEST['lat'] + 0; $waypointLon = $_REQUEST['lon'] + 0; if ($_POST['addWaypoint'] == 1) { // ADD waypoint $waypt = new waypoint(0); $waypt->name = makeSane($_POST['wname'], 2); $waypt->intName = makeSane($_POST['intName'], 2); $waypt->type = makeSane($_POST['type'], 1); $waypt->lat = makeSane($_POST['lat'], 1); $waypt->lon = makeSane($_POST['lon'], 1); $waypt->location = makeSane($_POST['location'], 2); $waypt->intLocation = makeSane($_POST['intLocation'], 2); $waypt->countryCode = makeSane($_POST['countryCode'], 2); $waypt->link = makeSane($_POST['link'], 2); $waypt->description = makeSane($_POST['description'], 2); if (!$waypt->name && !$waypt->intName) { echo "<H3> Please give takeoff name! </H3>\n"; return; } // fill in values that the user left out.
function toXML($forceProtocol = '') { /* maybe also include these "forceBounds" "autoScore" */ global $CONF_server_id, $CONF_photosPerFlight, $CONF; if ($CONF['sync']['protocol']['format'] == 'JSON' && $forceProtocol != 'XML' || $forceProtocol == 'JSON') { $useJSON = 1; require_once dirname(__FILE__) . '/lib/json/CL_json.php'; } else { $useJSON = 0; } if ($this->flightScore) { $flightScore =& $this->flightScore; if (!$flightScore->gotValues) { $flightScore->getFromDB(); } } else { $flightScore = new flightScore($this->flightID); $flightScore->getFromDB(); } $defaultMethodID = $CONF['scoring']['default_set']; $scoreDetails = $flightScore->scores[$defaultMethodID][$flightScore->bestScoreType]; $tpNum = 0; $tpStr = ''; for ($i = 1; $i <= 7; $i++) { if ($scoreDetails['tp'][$i]) { $newPoint = new gpsPoint($scoreDetails['tp'][$i]); if ($tpNum > 0) { $tpStr .= " ,\n\t\t"; } $tpStr .= ' {"id": ' . $i . ' , "lat": ' . $newPoint->lat() . ', "lon": ' . $newPoint->lon() . ', "UTCsecs": ' . ($newPoint->gpsTime + 0) . ' } '; $tpNum++; } } $takeoff = new waypoint($this->takeoffID); $takeoff->getFromDB(); // $firstPoint=new gpsPoint($this->FIRST_POINT,$this->timezone); // $lastPoint=new gpsPoint($this->LAST_POINT,$this->timezone); $firstPoint = new gpsPoint('', $this->timezone); $firstPoint->setLat($this->firstLat); $firstPoint->setLon($this->firstLon); $firstPoint->gpsTime = $this->firstPointTM; $lastPoint = new gpsPoint('', $this->timezone); $lastPoint->setLat($this->lastLat); $lastPoint->setLon($this->lastLon); $lastPoint->gpsTime = $this->lastPointTM; list($lastName, $firstName, $lastNameEn, $firstNameEn, $pilotCountry, $Sex, $Birthdate, $CIVL_ID) = getPilotInfoEn($this->userID, $this->userServerID); $userServerID = $this->userServerID; if ($userServerID == 0) { $userServerID = $CONF_server_id; } // will be changed when dateAdded will be UTC $dateAdded = $this->dateAdded; // We changed this, dateAdded is in UTC from now on !!!! // So the conversion is not needed //$dateAdded=tm2fulldate(fulldate2tm($dateAdded)-date('Z')); // convert to UTC if ($this->serverID == 0 || $this->serverID == $CONF_server_id) { $isLocal = 1; } else { $isLocal = 0; } if (!$useJSON) { $resStr = "<flight>\n<serverID>{$CONF_server_id}</serverID>\n<id>{$this->flightID}</id>\n<dateAdded>{$dateAdded}</dateAdded>\n<filename>{$this->filename}</filename>\n<linkIGC>" . $this->getIGC_URL() . "</linkIGC>\n<linkIGCzip>" . $this->getZippedIGC_URL() . "</linkIGCzip>\n<linkDisplay>" . htmlspecialchars($this->getFlightLinkURL()) . "</linkDisplay>\n<linkGE>" . htmlspecialchars($this->getFlightKML(0)) . "</linkGE>\n\n<info>\n\t<glider>{$this->glider}</glider>\n\t<gliderBrandID>{$this->gliderBrandID}</gliderBrandID>\n\t<gliderCat>{$this->cat}</gliderCat>\n\t<cat>{$this->category}</cat>\n\t<linkURL>{$this->linkURL}</linkURL>\n\t<private>{$this->private}</private>\n\t<comments>{$this->comments}</comments>\n</info>\n\n<time>\n\t<date>{$this->DATE}</date>\n\t<Timezone>{$this->timezone}</Timezone>\n\t<StartTime>{$this->START_TIME}</StartTime>\n\t<Duration>{$this->DURATION}</Duration>\n</time>\n\n<pilot>\n\t<userID>{$this->userID}</userID>\n\t<serverID>{$userServerID}</serverID>\n\t<civlID>{$CIVL_ID}</civlID>\n\t<userName>{$this->userName}</userName>\n\t<pilotFirstName>{$firstName}</pilotFirstName>\n\t<pilotLastName>{$lastName}</pilotLastName>\n\t<pilotFirstNameEn>{$firstNameEn}</pilotFirstNameEn>\n\t<pilotLastNameEn>{$lastNameEn}</pilotLastNameEn>\n\t<pilotCountry>{$pilotCountry}</pilotCountry>\n\t<pilotBirthdate>{$Birthdate}</pilotBirthdate>\n\t<pilotSex>{$Sex}</pilotSex>\n</pilot>\n\n<location>\n\t<firstLat>{$firstPoint->lat}</firstLat>\n\t<firstLon>" . $firstPoint->lon() . "</firstLon>\n\t<takeoffID>{$this->takeoffID}</takeoffID>\n\t<serverID>{$CONF_server_id}</serverID>\n\t<takeoffVinicity>{$this->takeoffVinicity}</takeoffVinicity>\n\t<takeoffName>{$takeoff->name}</takeoffName>\n\t<takeoffNameInt>{$takeoff->intName}</takeoffNameInt>\n\t<takeoffCountry>{$takeoff->countryCode}</takeoffCountry>\n\t<takeoffLocation>{$takeoff->location}</takeoffLocation>\n\t<takeoffLocationInt>{$takeoff->intlocation}</takeoffLocationInt>\n\t<takeoffLat>{$takeoff->lat}</takeoffLat>\n\t<takeoffLon>" . $takeoff->lon() . "</takeoffLon>\n</location>\n\n<stats>\n\t<FlightType>{$this->BEST_FLIGHT_TYPE}</FlightType>\n\t<StraightDistance>{$this->MAX_LINEAR_DISTANCE}</StraightDistance>\n\t<XCdistance>{$this->FLIGHT_KM}</XCdistance>\n\t<XCscore>{$this->FLIGHT_POINTS}</XCscore>\n\t<MaxSpeed>{$this->MAX_SPEED}</MaxSpeed>\n\t<MaxVario>{$this->MAX_VARIO}</MaxVario>\n\t<MinVario>{$this->MIN_VARIO}</MinVario>\n\t<MaxAltASL>{$this->MAX_ALT}</MaxAltASL>\n\t<MinAltASL>{$this->MIN_ALT}</MinAltASL>\n\t<TakeoffAlt>{$this->TAKEOFF_ALT}</TakeoffAlt>\n</stats>\n\n<validation>\n\t<validated>{$this->validated}</validated>\n\t<grecord>{$this->grecord}</grecord>\n\t<hash>{$this->hash}</hash>\n\t<validationMessage>{$this->validationMessage}</validationMessage>\n\t<airspaceCheck>{$this->airspaceCheck}</airspaceCheck>\n\t<airspaceCheckFinal>{$this->airspaceCheckFinal}</airspaceCheckFinal>\n\t<airspaceCheckMsg>{$this->airspaceCheckMsg}</airspaceCheckMsg>\n</validation>\n\n\n</flight>\n"; } else { $resStr = '{ "flight": { "serverID": ' . ($this->serverID ? $this->serverID : $CONF_server_id) . ', "id": ' . ($isLocal ? $this->flightID : $this->original_ID) . ', "dateAdded": "' . $dateAdded . '", "filename": "' . json::prepStr($this->filename) . '", "linkIGC": "' . json::prepStr($this->getIGC_URL()) . '", "linkIGCzip": "' . json::prepStr($this->getZippedIGC_URL()) . '", "linkDisplay": "' . ($isLocal ? json::prepStr($this->getFlightLinkURL()) : json::prepStr($this->getOriginalURL())) . '", "linkGE": "' . ($isLocal ? json::prepStr($this->getFlightKML(0)) : json::prepStr($this->getOriginalKML())) . '", "isLive": ' . $this->isLive . ', "info": { "glider": "' . json::prepStr($this->glider) . '", "gliderBrandID": ' . $this->gliderBrandID . ', "gliderBrand": "' . json::prepStr($CONF['brands']['list'][$this->gliderBrandID]) . '", "gliderCat": ' . $this->cat . ', "cat": ' . $this->category . ', "linkURL": "' . json::prepStr($this->linkURL) . '", "private": ' . $this->private . ', "comments": "' . json::prepStr($this->comments) . '" }, "time": { "date": "' . json::prepStr($this->DATE) . '", "Timezone": "' . $this->timezone . '", "StartTime": "' . $this->START_TIME . '", "Duration": "' . $this->DURATION . '" }, "bounds": { "forceBounds": ' . $this->forceBounds . ', "firstLat": ' . $firstPoint->lat() . ', "firstLon": ' . $firstPoint->lon() . ', "firstTM": ' . ($firstPoint->gpsTime + 0) . ', "lastLat": ' . $lastPoint->lat() . ', "lastLon": ' . $lastPoint->lon() . ', "lastTM": ' . ($lastPoint->gpsTime + 0) . ' }, "pilot": { "userID": "' . $this->userID . '", "serverID": "' . $userServerID . '", "civlID": "' . $CIVL_ID . '", "userName": "******", "pilotFirstName": "' . json::prepStr($firstName) . '", "pilotLastName": "' . json::prepStr($lastName) . '", "pilotFirstNameEn": "' . json::prepStr($firstNameEn) . '", "pilotLastNameEn": "' . json::prepStr($lastNameEn) . '", "pilotCountry": "' . $pilotCountry . '", "pilotBirthdate": "' . json::prepStr($Birthdate) . '", "pilotSex": "' . $Sex . '" }, "location": { "takeoffID": "' . ($this->takeoffID + 0) . '", "serverID": "' . $CONF_server_id . '", "takeoffVinicity": "' . $this->takeoffVinicity . '", "takeoffName": "' . json::prepStr($takeoff->name) . '", "takeoffNameInt": "' . json::prepStr($takeoff->intName) . '", "takeoffCountry": "' . $takeoff->countryCode . '", "takeoffLocation": "' . json::prepStr($takeoff->location) . '", "takeoffLocationInt": "' . json::prepStr($takeoff->intlocation) . '", "takeoffLat": "' . $takeoff->lat() . '", "takeoffLon": "' . $takeoff->lon() . '" }, "stats": { "FlightType": "' . $this->BEST_FLIGHT_TYPE . '", "MaxStraightDistance": ' . ($this->MAX_LINEAR_DISTANCE + 0) . ', "StraightDistance": ' . $this->LINEAR_DISTANCE . ', "XCdistance": "' . ($this->FLIGHT_KM + 0) . '", "XCscore": "' . ($this->FLIGHT_POINTS + 0) . '", "MaxSpeed": "' . $this->MAX_SPEED . '", "MeanGliderSpeed": "' . $this->MEAN_SPEED . '", "MaxVario": "' . $this->MAX_VARIO . '", "MinVario": "' . $this->MIN_VARIO . '", "MaxAltASL": "' . $this->MAX_ALT . '", "MinAltASL": "' . $this->MIN_ALT . '", "TakeoffAlt": "' . $this->TAKEOFF_ALT . '" }, ' . $flightScore->toSyncJSON() . ' , "turnpoints": [ ' . $tpStr . ' ] , "validation": { "validated": "' . $this->validated . '", "grecord": "' . $this->grecord . '", "hash": "' . $this->hash . '", "validationMessage": "' . json::prepStr($this->validationMessage) . '", "airspaceCheck": "' . json::prepStr($this->airspaceCheck) . '", "airspaceCheckFinal": "' . json::prepStr($this->airspaceCheckFinal) . '", "airspaceCheckMsg": "' . json::prepStr($this->airspaceCheckMsg) . '" } } }'; } return $resStr; }
function flights_find($arg) { global $db, $flightsTable; global $takeoffRadious, $CONF; require_once "FN_pilot.php"; $sitePass = $arg[0]; $lat = $arg[1]; $lon = -$arg[2]; $limit = $arg[3]; if (!securityCheck($sitePass)) { return new IXR_Error(4000, 'Access Denied'); } $firstPoint = new gpsPoint(); $firstPoint->lat = $lat; $firstPoint->lon = $lon; // calc TAKEOFF - LANDING PLACES if (count($waypoints) == 0) { $waypoints = getWaypoints(0, 1); } $takeoffIDTmp = 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(); //$nearestWaypoint; //$minTakeoffDistance; if ($limit > 0) { $lim = "LIMIT {$limit}"; } else { $lim = ""; } $where_clause = "AND takeoffID={$nearestWaypoint->waypointID}"; $query = "SELECT * FROM {$flightsTable} WHERE private=0 {$where_clause} ORDER BY FLIGHT_POINTS DESC {$lim} "; //echo $query; $res = $db->sql_query($query); if ($res <= 0) { return new IXR_Error(4000, 'Error in query! ' . $query); } $flights = array(); $i = 0; while ($row = mysql_fetch_assoc($res)) { $name = getPilotRealName($row["userID"], $row["serverID"]); $link = htmlspecialchars("http://" . $_SERVER['SERVER_NAME'] . getLeonardoLink(array('op' => 'show_flight', 'flightID' => $row['ID']))); $this_year = substr($row['DATE'], 0, 4); $linkIGC = htmlspecialchars("http://" . $_SERVER['SERVER_NAME'] . getRelMainDir() . str_replace("%PILOTID%", getPilotID($row["userServerID"], $row["userID"]), str_replace("%YEAR%", $this_year, $CONF['paths']['igc'])) . '/' . $row['filename']); //$flightsRelPath."/".$row[userID]."/flights/".$this_year."/".$row[filename] ); if ($row['takeoffVinicity'] > $takeoffRadious) { $location = getWaypointName($row['takeoffID']) . " [~" . sprintf("%.1f", $row['takeoffVinicity'] / 1000) . " km]"; } else { $location = getWaypointName($row['takeoffID']); } $flights[$i]['pilot'] = htmlspecialchars($name); $flights[$i]['takeoff'] = htmlspecialchars($location); $flights[$i]['date'] = $row['DATE']; $flights[$i]['duration'] = $row['DURATION']; $flights[$i]['openDistance'] = $row['MAX_LINEAR_DISTANCE']; $flights[$i]['OLCkm'] = $row['FLIGHT_KM']; $flights[$i]['OLCScore'] = $row['FLIGHT_POINTS']; $flights[$i]['OLCtype'] = $row['BEST_FLIGHT_TYPE']; $flights[$i]['displayLink'] = $link; $i++; } return array($i, $flights); //return array($i,0); }
function makeWaypointPlacemark($waypointID, $returnCountryCode = 0, $includeStyle = 1, $includeLookat = 1, $styleUrl = '') { global $db, $waypointsTable; global $flightsTable, $countries, $CONF_mainfile, $moduleRelPath; $wpInfo = new waypoint($waypointID); $wpInfo->getFromDB(); $wpName = selectWaypointName($wpInfo->name, $wpInfo->intName, $wpInfo->countryCode); $wpLocation = selectWaypointLocation($wpInfo->location, $wpInfo->intLocation, $wpInfo->countryCode); $query = "SELECT MAX(MAX_LINEAR_DISTANCE) as record_km, ID FROM {$flightsTable} WHERE takeoffID =" . $waypointID . " GROUP BY ID ORDER BY record_km DESC "; $flightNum = 0; $res = $db->sql_query($query); if ($res > 0) { $flightNum = mysql_num_rows($res); $row = $db->sql_fetchrow($res); $siteRecordLink = "<a href='http://" . $_SERVER['SERVER_NAME'] . getLeonardoLink(array('op' => 'show_flight', 'flightID' => $row['ID'])) . "'>" . formatDistance($row['record_km'], 1) . "</a>"; } else { $siteRecordLink = ""; } $pointFlightsLink = "<a href='http://" . $_SERVER['SERVER_NAME'] . getLeonardoLink(array('op' => 'list_flights', 'takeoffID' => $waypointID, 'year' => '0', 'season' => '0')) . "'>" . _See_flights_near_this_point . " [ " . $flightNum . " ]</a>"; $countryFlightsLink = "<a href='http://" . $_SERVER['SERVER_NAME'] . getLeonardoLink(array('op' => 'list_flights', 'takeoffID' => '0', 'year' => '0', 'season' => '0', 'country' => $wpInfo->countryCode)) . "'>" . $countries[$wpInfo->countryCode] . "</a>"; if ($wpInfo->link) { $siteLink = '<a href="' . formatURL($wpInfo->link) . '" target="_blank">' . formatURL($wpInfo->link) . '</a>'; } else { $siteLink = "-"; } // "<?xml version='1.0' encoding='".$langEncodings[$currentlang]."'? > // <?xml version="1.0" encoding="UTF-8"? > $xml_text = '<Placemark> <name><![CDATA[' . $wpName . ' ]]></name> <description><![CDATA[<table cellpadding=0 cellspacing=0 width=300>' . '<tr bgcolor="#D7E1EE"><td>' . _SITE_REGION . ': ' . $wpLocation . ' - ' . $countryFlightsLink . '</td></tr>' . '<tr bgcolor="#CCCCCC"><td>' . $pointFlightsLink . '</td></tr>' . '<tr ><td>' . _SITE_RECORD . ' : ' . $siteRecordLink . '</td></tr>' . '<tr bgcolor="#CCCCCC"><td>' . _SITE_LINK . ' : ' . $siteLink . '</td></tr>' . '<tr ><td>' . $wpInfo->description . '</td></tr>' . '<tr ><td></td></tr>' . '</table> ]]> </description>'; if ($includeLookat) { $xml_text .= ' <LookAt> <longitude>' . -$wpInfo->lon . '</longitude> <latitude>' . $wpInfo->lat . '</latitude> <range>10000</range> <tilt>0</tilt> <heading>0</heading> </LookAt> '; } if ($includeStyle) { $xml_text .= ' <styleUrl>root://styleMaps#default+nicon=0x307+hicon=0x317</styleUrl> <Style> <IconStyle> <scale>0.8</scale> <Icon> <href>root://icons/palette-4.png</href> <x>160</x> <y>128</y> <w>32</w> <h>32</h> </Icon> </IconStyle> <LabelStyle> <scale>0.8</scale> </LabelStyle> </Style> '; } if ($styleUrl) { $xml_text .= "<styleUrl>{$styleUrl}</styleUrl>\n"; } $xml_text .= ' <Point> <coordinates>' . -$wpInfo->lon . ',' . $wpInfo->lat . ',0</coordinates> </Point> </Placemark>'; if ($returnCountryCode) { return array($xml_text, $wpInfo->countryCode); } else { return $xml_text; } }
if ($res <= 0) { echo "Problem in removing takeoff from area QUERY"; } else { if ($db->sql_affectedrows()) { echo "Takeoff removed from area<br>"; } else { echo "Problem in removing takeoff from area"; } } } else { if ($op == 'deleteTakeoffs') { $toDeleteStr = $_GET['takeoffs']; $toDeleteList = split('_', $toDeleteStr); //echo "list is :"; //print_r($toDeleteList); $flightsNum = waypoint::deleteBulk($toDeleteList); echo "{$flightsNum} flights relocated<BR>"; foreach ($toDeleteList as $waypointIDdelete) { echo "Takeoff #{$waypointIDdelete} deleted<BR>"; } } } } if ($op == 'getTakeoffInfo') { $wpID = $_GET['wpID'] + 0; echo "<b>{$wpID}</b><BR>"; $query = "SELECT intName , countryCode from {$waypointsTable} WHERE ID={$wpID} "; $res = $db->sql_query($query); if ($res > 0) { if ($row = mysql_fetch_assoc($res)) { $description = $row['intName'];
} } // $orderBy=" FLIGHT_POINTS DESC "; $orderBy = " `DATE` DESC "; $query = "SELECT * {$select_clause} FROM {$flightsTable} WHERE {$where_clause} ORDER BY {$orderBy} {$lim} "; // , distance ASC , dateAdded DESC // echo $query."<BR><BR>"; $res = $db->sql_query($query); if ($res <= 0) { echo "<H3> Error in query! {$query} </H3>\n"; exit; } $JSON_str = ""; $i = 0; while ($row = mysql_fetch_assoc($res)) { $nearestWaypoint = new waypoint($takeoffIDTmp); $nearestWaypoint->getFromDB(); $name = getPilotRealName($row["userID"], $row["userServerID"], 1); $link = htmlspecialchars("http://" . $_SERVER['SERVER_NAME'] . getLeonardoLink(array('op' => 'show_flight', 'flightID' => $row['ID']))); $this_year = substr($row[DATE], 0, 4); $linkIGC = htmlspecialchars("http://" . $_SERVER['SERVER_NAME'] . getRelMainDir() . str_replace("%PILOTID%", getPilotID($row["userServerID"], $row["userID"]), str_replace("%YEAR%", $this_year, $CONF['paths']['igc'])) . '/' . $row['filename']); //$flightsRelPath."/".$row[userID]."/flights/".$this_year."/".$row[filename] ); if ($row['takeoffVinicity'] > $takeoffRadious) { $location = getWaypointName($row['takeoffID']) . " [~" . sprintf("%.1f", $row['takeoffVinicity'] / 1000) . " km]"; } else { $location = getWaypointName($row['takeoffID']); } if ($i > 0) { $JSON_str .= ", "; } $START_TIME = sec2Time24h($row['START_TIME'], 1);
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $CONF_ENCODING; ?> "> <style type="text/css"> body, p, table,tr,td {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;} body {margin:0px} </style> </head> <?php $waypointIDdelete = makeSane($_REQUEST['waypointIDdelete'], 1); $waypt = new waypoint($waypointIDdelete); $waypt->getFromDB(); if ($_POST['deleteWaypoint'] == 1) { // DELETE waypoint $waypt = new waypoint($waypointIDdelete); if ($waypt->delete()) { ?> <script language="javascript"> function refreshParent() { topWinRef=top.location.href; top.window.location.href=topWinRef; } </script> <?php echo "<center>" . _THE_TAKEOFF_HAS_BEEN_DELETED . "<br><br>"; echo "<a href='javascript:refreshParent();'>RETURN </a>"; echo "<br></center>"; } else { echo "<H3> Error in deleting waypoint from DB! </H3>\n"; }
$waypt->lon = $_POST['lon']; $waypt->location = $_POST['location']; $waypt->intLocation = $_POST['intLocation']; $waypt->countryCode = $_POST['countryCode']; $waypt->link = $_POST['link']; $waypt->description = $_POST['description']; if ($waypt->putToDB(1)) { echo "<center>" . _THE_CHANGES_HAVE_BEEN_APPLIED . "<br>"; echo "<a href='" . getLeonardoLink(array('op' => 'show_waypoint', 'waypointIDedit' => $waypointIDedit)) . "'>RETURN to view mode</a> or "; echo "<a href='" . getLeonardoLink(array('op' => 'list_flights')) . "'>RETURN to flights</a>"; echo "<br></center>"; } else { echo "<H3> Error in puting waypoint info into DB! </H3>\n"; } } $waypt = new waypoint($waypointIDedit); $waypt->getFromDB(); require_once dirname(__FILE__) . '/FN_editor.php'; openMain("Edit waypoint", 760, "icon_pin.png"); ?> <form name="form1" method="post" action=""> <table width="725" border="0" align="center" cellpadding="2" class=main_text> <tr> <td width="104" bgcolor="#CFE2CF"><div align="right"><font color="#003366">Name</font></div></td> <td width="212" bgcolor="#E3E7F2"><font color="#003366"> <input name="wname" type="text" id="wname" size="30" value="<?php echo $waypt->name; ?>
require_once dirname(__FILE__) . "/../CL_gpsPoint.php"; $opServerUrl = "http://pgforum.thenet.gr/modules/leonardo/op2.php"; $client = new IXR_Client($opServerUrl); if (!$client->query('flights.find', "mypass", 40.5667, -22.4, 0)) { die('An error occurred - ' . $client->getErrorCode() . ":" . $client->getErrorMessage()); } else { list($flights_num, $flights) = $client->getResponse(); if ($flights_num > 0) { foreach ($flights as $flight) { echo $flight['pilot'] . " " . $flight['takeoff'] . "<BR>"; } } } exit; if (!$client->query('test.findTakeoff', "mypass", 40.5667, -22.4)) { die('An error occurred - ' . $client->getErrorCode() . ":" . $client->getErrorMessage()); } else { list($ar, $distance) = $client->getResponse(); $nearestWaypoint = new waypoint(); $nearestWaypoint->fillFromArray($ar); echo $nearestWaypoint->name; echo "#{$distance}<BR>"; } /* if ( ! $client->query('takeoffs.getAll', "mypass") ) { die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage()); } else { list($num,$ar)= $client->getResponse(); echo "GOT $num waypoints"; } */