}
    eval($line);
}
$START_TIME = $flight->START_TIME;
$END_TIME = $flight->END_TIME;
$DURATION = $END_TIME - $START_TIME;
//	$START_TIME=$min_time;
//	$END_TIME=$max_time;
//	$DURATION=$END_TIME-$START_TIME;
$lang_enc = 'utf-8';
# martin jursa 22.06.2008: enable configuration of map type
$GMapType = 'G_SATELLITE_MAP';
if (in_array($CONF['google_maps']['default_maptype'], array('G_NORMAL_MAP', 'G_HYBRID_MAP', 'G_PHYSICAL_MAP', 'G_SATELLITE_MAP', 'G_SATELLITE_3D_MAP'))) {
    $GMapType = $CONF['google_maps']['default_maptype'];
}
if ($CONF_airspaceChecks && (L_auth::isAdmin($userID) || $flight->belongsToUser($userID)) || $CONF['thermals']['enable']) {
    // find min/max lat/lon
    $filename = $flight->getIGCFilename();
    $lines = file($filename);
    if (!$lines) {
        echo "Cant read file";
        return;
    }
    $i = 0;
    // find bounding box of flight
    $min_lat = 1000;
    $max_lat = -1000;
    $min_lon = 1000;
    $max_lon = -1000;
    foreach ($lines as $line) {
        $line = trim($line);
require_once $LeoCodeBase . "/CL_image.php";
require_once $LeoCodeBase . "/CL_template.php";
$Ltemplate = new LTemplate($LeoCodeBase . '/templates/' . $PREFS->themeName);
global $flightsTable, $deletedFlightsTable;
if ($_GET['deleted'] && L_auth::isAdmin($userID)) {
    $flightsTable = $deletedFlightsTable;
    $deletedFlights = 1;
}
$flightID += 0;
$flight = new flight();
if (!$flight->getFlightFromDB($flightID)) {
    echo "<br><div align='center'>No such flight exists</div><br><BR>";
    return;
}
//echo $flight->private." & ".$flight->flightIsViewableByUser($userID)." $$";
if ($flight->private && $flight->private != 4 && !$flight->belongsToUser($userID) && !L_auth::isAdmin($userID)) {
    echo "<br><div align=center><h3>" . _FLIGHT_IS_PRIVATE . "</h3></div><br><BR>";
    return;
}
//debug
//$mapUrl=$flight->createStaticMap(1);
$flight->incViews();
//show limited info to non friends
if ($flight->private == 4 && !$flight->flightIsViewableByUser($userID)) {
    require dirname(__FILE__) . '/GUI_flight_show_ext.php';
    return;
}
if ($flight->externalFlightType & SYNC_INSERT_FLIGHT_LINK) {
    require dirname(__FILE__) . '/GUI_flight_show_ext.php';
    return;
}
<?php

//************************************************************************
// Leonardo XC Server, http://www.leonardoxc.net
//
// Copyright (c) 2004-2010 by Andreadakis Manolis
//
// This program is free software. You can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License.
//
// $Id: GUI_flight_delete.php,v 1.12 2010/03/14 20:56:11 manolis Exp $
//
//************************************************************************
$flightID = makeSane($_REQUEST["flightID"], 1);
$confirmed = makeSane($_REQUEST["confirmed"]);
$flight = new flight();
$flight->getFlightFromDB($flightID);
if ($confirmed && ($flight->belongsToUser($userID) || L_auth::isAdmin($userID))) {
    $flight->deleteFlight();
    echo "<br><span class='ok'>" . _THE_FLIGHT_HAS_BEEN_DELETED . "</span><br><br>";
    echo "<a href='" . getLeonardoLink(array('op' => 'list_flights')) . "'>" . _RETURN . "</a><br></div>";
} else {
    $location = formatLocation(getWaypointName($flight->takeoffID), $flight->takeoffVinicity, $takeoffRadious);
    openMain(_CAUTION_THE_FLIGHT_WILL_BE_DELETED, 0, "delete_icon.png");
    echo "<div align=center><br><b>" . _PILOT . ": " . $flight->userName . " &nbsp;&nbsp; " . _THE_DATE . ": " . formatDate($flight->DATE) . "  &nbsp;&nbsp; " . _TAKEOFF_LOCATION . ": " . $location . "</b> ";
    echo "<br><br><a href='" . getLeonardoLink(array('op' => 'delete_flight', 'flightID' => $flightID, 'confirmed' => '1')) . "'>" . _YES . "</a> | <a href='javascript:history.go(-1)'>" . _NO . "</a>";
    echo "<br></div>";
    closeMain();
}
//************************************************************************

	require_once $LeoCodeBase."/CL_image.php";
	require_once $LeoCodeBase."/CL_template.php";

	$Ltemplate = new LTemplate($LeoCodeBase.'/templates/'.$PREFS->themeName);


  $flightID+=0;
  $flight=new flight();
  if ( ! $flight->getFlightFromDB($flightID) ) {
  	echo "<br><div align='center'>No such flight exists</div><br><BR>";
	return;  
  }
  
  if ( $flight->private && ! $flight->belongsToUser($userID) && ! L_auth::isAdmin($userID) ) {
		echo "<TD align=center>"._FLIGHT_IS_PRIVATE."</td>";
		return;
  }

    //debug
    $mapUrl=$flight->createStaticMap(1);

  $flight->incViews();

  if ( $flight->externalFlightType & SYNC_INSERT_FLIGHT_LINK ){
	require dirname(__FILE__).'/GUI_flight_show_ext.php';
	return;
  }

sort($flightsList);
if ($flightsNum == 0) {
    exit;
}
if ($flightsNum == 1) {
    $flight = new flight();
    $flight->getFlightFromDB($flightsList[0], 0);
    $flightID = $flightsList[0];
    if ($flight->is3D()) {
        $title1 = _Altitude . ' (' . ($PREFS->metricSystem == 1 ? _M : _FT) . ')';
    } else {
        $title1 = _Distance_from_takeoff . ' (' . ($PREFS->metricSystem == 1 ? _KM_PER_HR : _MPH) . ')';
    }
    // print_r($flight);exit;
    $takeoffID = $flight->takeoffID;
    $isAdmin = L_auth::isAdmin($userID) || $flight->belongsToUser($userID);
    $trackPossibleColors = array("AB7224", "3388BE", "FF0000", "00FF00", "0000FF", "FFFF00", "FF00FF", "00FFFF", "EF8435", "34A7F0", "33F1A3", "9EF133", "808080");
} else {
    $title1 = _Altitude . ' (' . ($PREFS->metricSystem == 1 ? _M : _FT) . ')';
    $flightID = 0;
    $takeoffID = 0;
    $trackPossibleColors = array("FF0000", "00FF00", "0000FF", "FFFF00", "FF00FF", "00FFFF", "EF8435", "34A7F0", "33F1A3", "9EF133", "808080");
    $isAdmin = L_auth::isAdmin($userID);
}
$colotStr = '';
foreach ($trackPossibleColors as $color) {
    if ($colotStr) {
        $colotStr .= ',';
    }
    $colotStr .= " '#{$color}'";
}
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";
$filename = makeSane($_REQUEST['file'], 2);
$flightID = makeSane($_REQUEST['flightID'], 1);
if ($flightID <= 0 && !$filename) {
    exit;
}
$clientIP = getClientIpAddr();
if ($flightID) {
    $flight = new flight();
    $flight->getFlightFromDB($flightID);
    $authOK = 0;
    if ($flight->belongsToUser($userID) || L_auth::isModerator($userID) || L_auth::canDownloadIGC($clientIP)) {
        $authOK = 1;
    }
} else {
    if ($filename) {
        $authOK = 0;
        $base_name = basename($filename);
        // echo $base_name."#";
        if (L_auth::isModerator($userID) || L_auth::canDownloadIGC($clientIP) || $_SESSION['di' . $base_name]) {
            $authOK = 1;
        }
    }
}
if ($authOK) {
    $type = 'igc';
    require_once dirname(__FILE__) . '/download_igc.php';
// Copyright (c) 2004-2010 by Andreadakis Manolis
//
// This program is free software. You can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License.
//
// $Id: GUI_flight_edit.php,v 1.52 2010/11/21 14:26:01 manolis Exp $                                                                 
//
//************************************************************************
  require_once dirname(__FILE__).'/CL_image.php';
  require_once dirname(__FILE__)."/CL_NACclub.php";
  require_once dirname(__FILE__)."/CL_user.php";
  $flight=new flight();
  $flight->getFlightFromDB($flightID);

  if ( 	$flight->belongsToUser($userID) ||	L_auth::isModerator($userID)  ) {

	require_once dirname(__FILE__)."/CL_flightScore.php";
	$flightScore=new flightScore($flight->flightID);
	$flightScore->getFromDB();


	if ($_REQUEST["changeFlight"]) {  // make changes
		$newUserIDStr=$_POST["newUserID"];
		if ($newUserIDStr) { // move this flight to a new userID
			 $newUserIDStrPart=split('_',$newUserIDStr);
			 $newUserServerID=0;
			 if (count($newUserIDStrPart)>1) {
				$newUserServerID=$newUserIDStrPart[0];
			 	$newUserID=$newUserIDStrPart[1];				
	  	     } else if (is_numeric($newUserIDStr) ){
require_once dirname(__FILE__) . "/FN_UTM.php";
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";
$flightID = makeSane($_GET['flightID'], 1);
if ($flightID <= 0) {
    exit;
}
$flight = new flight();
$flight->getFlightFromDB($flightID);
if (!$flight->belongsToUser($userID) && !L_auth::isModerator($userID)) {
    echo "go away";
    return;
}
if ($_POST['setTimes'] == 1) {
    // set new bounds !!!
    $startTime = makeSane($_REQUEST['timeTextSecs1'], 1);
    // in secs
    $endTime = makeSane($_REQUEST['timeTextSecs2'], 1);
    $flight->forceBounds = 1;
    // must be in these time bounds
    $flight->START_TIME = $startTime;
    $flight->END_TIME = $endTime;
    $waypointsWebPath = moduleRelPath(0) . "/" . $waypointsRelPath;
    $flight->getFlightFromIGC($flight->getIGCFilename(), 0);
    $flight->deleteSecondaryFiles();