Exemple #1
0
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);
}
            } 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>";
                }
            }
        }
    }
}
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] . ") &nbsp;";
//$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>";
?>

<style type="text/css">
    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;
    }
Exemple #5
0
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);
}
Exemple #6
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;
    }
}
Exemple #7
0
 }
 // $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);
     $END_TIME = sec2Time24h($row['END_TIME'], 1);
}
?>
<head>
  <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>";