$boundBox['minLat'] = 43.1589;
    $boundBox['maxLat'] = 48.1717;
    $boundBox['minLon'] = 6.11194;
    $boundBox['maxLon'] = 13.5261;
    while ($row = $db->sql_fetchrow($res)) {
        if (!$row['filename'] || $row['MAX_LINEAR_DISTANCE'] < 10000 || $row['DURATION'] < 3600 || $row['MAX_ALT'] - $row['TAKEOFF_ALT'] < 100) {
            continue;
        }
        //if ($row['firstLat'] < $boundBox['minLat'] || $row['firstLat'] > $boundBox['maxLat'] ) continue;
        //if ($row['firstLon'] < $boundBox['minLon'] || $row['firstLon'] > $boundBox['maxLon'] ) continue;
        // if ($row['DATE'] < '2008-06-01' || $row['DATE']  > '2008-08-31' ) continue;
        //$igcPath=''; // $flightsAbsPath;
        //if ($row['userServerID'])
        //	$igcPath.=$row['userServerID'].'_';
        //$igcPath.=$row['userID']."/flights/".substr($row['DATE'],0,4)."/".$row['filename']."\n";
        $igcPath = str_replace("%PILOTID%", getPilotID($row['userServerID'], $row['userID']), str_replace("%YEAR%", substr($row['DATE'], 0, 4), $CONF['paths']['igc'])) . '/' . $row['filename'];
        echo $igcPath;
        $igcNum++;
    }
    echo "</pre>";
    echo "#flight found : {$igcNum}<BR>";
    exit;
}
if ($RUN['view'] == 'print') {
    require_once dirname(__FILE__) . "/CL_pdf.php";
    require_once dirname(__FILE__) . "/MENU_second_menu.php";
    // now the real query
    $res = $db->sql_query($query);
    if ($res <= 0) {
        echo "<H3> Error in query! </H3>\n";
        exit;
Example #2
0
     }
 }
 $query = "SELECT * FROM {$flightsTable} {$extra_tbl} WHERE \n\t\t\t\t firstLat>={$south} &&  firstLat<={$north} &&  \n\t\t\t\t firstLon>={$west} && firstLon<={$east} {$filter_clause}\n\t\t\t\t ORDER BY  FLIGHT_POINTS DESC LIMIT 100 ";
 //echo $query;
 $res = $db->sql_query($query);
 if ($res <= 0) {
     echo "<H3> Error in query! {$query} </H3>\n";
     exit;
 }
 $i = 0;
 $str = '';
 while ($row = mysql_fetch_assoc($res)) {
     $name = getPilotRealName($row["userID"], $row["userServerID"], 0, 0, 0);
     $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']);
     }
     $flight = new flight();
     $flight->getFlightFromDB($row['ID'], 0, $row);
     $extendedInfo = 0;
     $lineColor = "ff0000";
     $exaggeration = 1;
     $lineWidth = 2;
     $getFlightKML = $flight->getFlightKML() . "&c={$lineColor}&w={$lineWidth}&an={$extendedInfo}";
     $desc = $flight->kmlGetDescription($extendedInfo, $getFlightKML, 1);
     $snippet = "<![CDATA[" . formatDistance($flight->FLIGHT_KM, 1) . ", " . _DURATION . ": " . sec2Time($flight->DURATION, 1) . "]]>";
Example #3
0
     $isLocal = 0;
 }
 if ($isLocal) {
     $row['FlightUrl'] = "http://" . $_SERVER['SERVER_NAME'] . getLeonardoLink(array('op' => 'show_flight', 'flightID' => $row['NacFlightId']));
 } else {
     if ($row['serverID'] != 0 && !$row['originalURL']) {
         if ($CONF['servers']['list'][$row['serverID']]['isLeo'] == 1) {
             if (!$row['originalURL']) {
                 $row['originalURL'] = 'http://' . $CONF['servers']['list'][$row['serverID']]['url'] . '&op=show_flight&flightID=' . $row['original_ID'];
             }
         }
     }
     $row['FlightUrl'] = $row['originalURL'];
 }
 $row['FlightUrl'] = htmlspecialchars($row['FlightUrl']);
 $trackPath = getRelMainDir() . str_replace("%PILOTID%", getPilotID($row["userServerID"], $row["userID"]), str_replace("%YEAR%", substr($row['DATE'], 0, 4), $CONF['paths']['igc'])) . '/' . rawurlencode($row['filename']);
 $row['IgcUrl'] = "http://" . $_SERVER['SERVER_NAME'] . $trackPath;
 // the pilot id is serverid_pilotid to be able to distinguish ids across servers
 //0_12345
 //5_12345
 //27_12345
 $row['NacPilotId'] = $row["userServerID"] . '_' . $row["userID"];
 $WxcFields = array('CivlId', 'PilotFirstName', 'PilotLastName', 'PilotNation', 'PilotGender', 'CivlIdApprovedBy', 'IgcUrl', 'IgcMd5', 'LastTimestamp', 'FirstTimestamp', 'NacStatus', 'NacPilotId', 'NacFlightId', 'GliderCat', 'Glider', 'TakeoffTime', 'LandingTime', 'TakeoffName', 'TakeoffCountry', 'CommentInternal', 'FlightUrl');
 foreach ($row as $key => $value) {
     if (in_array($key, $WxcFields)) {
         $valueSafe = $value;
         if (in_array($key, array('PilotFirstName', 'PilotLastName', 'Glider', 'TakeoffName', 'CommentInternal'))) {
             $valueSafe = "<![CDATA[{$value}]]>";
         }
         $FlighsXML[$item_ok] .= "      <{$key}>{$valueSafe}</{$key}>\n";
     }
Example #4
0
     for ($i = 0; $i < count($flightsToServe); $i++) {
         if ($i > 0) {
             $sql .= ' , ';
         }
         $sql .= $flightsToServe[$i];
     }
     $sql .= " ) ";
     $res = $db->sql_query($sql);
     # Error checking
     if ($res <= 0) {
         echo "<H3> Error in sync - get igc filenames query! {$sql}</H3>\n";
         exit;
     }
     while ($row = $db->sql_fetchrow($res)) {
         // $filename=dirname(__FILE__).'/flights/'.$row['userID'].'/flights/'.substr($row['DATE'],0,4).'/'.$row['filename'];
         $filename = LEONARDO_ABS_PATH . '/' . str_replace("%PILOTID%", getPilotID($row["userServerID"], $row["userID"]), str_replace("%YEAR%", substr($row['DATE'], 0, 4), $CONF['paths']['igc'])) . '/' . $row['filename'];
         if (is_file($filename)) {
             array_push($filesToServe, array(PCLZIP_ATT_FILE_NAME => $row['ID'] . ".igc", PCLZIP_ATT_FILE_CONTENT => implode("", file($filename))));
         }
         if (is_file($filename . 'saned.igc')) {
             array_push($filesToServe, array(PCLZIP_ATT_FILE_NAME => $row['ID'] . ".saned.igc", PCLZIP_ATT_FILE_CONTENT => implode("", file($filename . 'saned.igc'))));
         }
     }
 }
 array_push($filesToServe, array(PCLZIP_ATT_FILE_NAME => "sync.txt", PCLZIP_ATT_FILE_CONTENT => $RSS_str));
 $tmpZipFile = "sync_" . $clientID . "_" . time() . ".zip";
 $archive = new PclZip($CONF_tmp_path . '/' . $tmpZipFile);
 $v_list = $archive->create($filesToServe, PCLZIP_OPT_REMOVE_ALL_PATH);
 $outputStr = implode("", file($CONF_tmp_path . '/' . $tmpZipFile));
 @unlink($CONF_tmp_path . '/' . $tmpZipFile);
 $outputFilename = $tmpZipFile;
Example #5
0
 function changeUser($newUserID, $newUserServerID)
 {
     global $CONF, $CONF_photosPerFlight;
     $pilotDir = $this->getPilotAbsDir();
     if ($newUserServerID) {
         $extra_prefix = $newUserServerID . '_';
     } else {
         $extra_prefix = '';
     }
     $newPilotDir = LEONARDO_ABS_PATH . '/' . str_replace("%PILOTID%", $extra_prefix . $newUserID, $CONF['paths']['pilot']);
     // delete non critical files
     $this->deleteFile($this->getIGCFilename(1));
     $this->deleteFile($this->getIGCFilename(2));
     $this->deleteSecondaryFiles();
     $this->deleteFile($this->getMapFilename());
     for ($metric_system = 1; $metric_system <= 2; $metric_system++) {
         for ($raw = 0; $raw <= 1; $raw++) {
             # martin jursa 28.05.2008: delete using the deleteFile() method to avoid log flooding
             $this->deleteFile($this->getChartFilename("alt", $metric_system, $raw));
             $this->deleteFile($this->getChartFilename("speed", $metric_system, $raw));
             $this->deleteFile($this->getChartFilename("vario", $metric_system, $raw));
             $this->deleteFile($this->getChartFilename("takeoff_distance", $metric_system, $raw));
         }
     }
     $flightYear = $this->getYear();
     $subdirs = array('flights', 'charts', 'maps');
     // create all dirs on the target user as well in case they are missing
     $this->checkDirs($extra_prefix . $newUserID, $flightYear);
     /*
     foreach ($subdirs as $subdir){
     	$sourceDir="$pilotDir/$subdir/$flightYear";
     	$targetDir="$newPilotDir/$subdir/$flightYear";
     
     	if ($handle = opendir($sourceDir)) {
     		while (false !== ($file = readdir($handle))) {
     			if (  substr( $file,0,strlen($this->filename) )==$this->filename  ) {
     				// echo "$file\n";
     				$filesToMove[$sourceDir.'/'.$file]=$targetDir.'/'.$file;
     			}
     		}
     		closedir($handle);
     	}
     }
     
     //	this is old code, does not work nay more!
     for($i=1;$i<=$CONF_photosPerFlight;$i++) {
     	$var_name="photo".$i."Filename";
     	$file=$this->$var_name;
     	if ($file) {
     		$sourceDir="$pilotDir/photos/$flightYear";
     		$targetDir="$newPilotDir/photos/$flightYear";
     		$filesToMove[$sourceDir.'/'.$file]=$targetDir.'/'.$file;
     	}
     }
     
     array_push($subdirs,'photos');
     
     foreach ($subdirs as $subdir){
     	makeDir("$newPilotDir/$subdir");
     }
     
     foreach ($filesToMove as $src=>$target){
     	makeDir($target);
     	@rename($src,$target);
     }
     */
     // Take care of photos!
     if ($this->hasPhotos) {
         $flightPhotos = new flightPhotos($this->flightID);
         $flightPhotos->getFromDB();
         // print_r($flightPhotos->photos );
         foreach ($flightPhotos->photos as $photoNum => $photoInfo) {
             $flightPhotos->changeUser($photoNum, getPilotID($newUserServerID, $newUserID));
         }
         $flightPhotos->putToDB(0);
     }
     // store the original paths of the files
     $igcOrg = $this->getIGCFilename(0);
     // store away the original userID
     $this->originalUserID = $this->userServerID + 0 . '_' . $this->userID;
     $this->userID = $newUserID;
     $this->userServerID = $newUserServerID;
     // now move the igc file (and optionally the olc if it exists
     @rename($igcOrg, $this->getIGCFilename(0));
     @rename($igcOrg . ".olc", $this->getIGCFilename(0) . ".olc");
     //  echo "will put to db $newUserServerID $newUserID<BR>";
     $this->putFlightToDB(1);
     // take care of same flights (hide /unhide)
     $this->hideSameFlights();
     // now also log this action
 }
Example #6
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);
}
Example #7
0
			
		require_once dirname(__FILE__)."/CL_server.php";

		if($res > 0){
			 echo "<br><br>";
			 // $flight=new flight();
			 $i=0;
			 require_once dirname(__FILE__)."/lib/ConvertCharset/ConvertCharset.class.php";
			 while ($row = mysql_fetch_assoc($res)) { 
				 // $flight=new flight();
				 //$flight->getFlightFromDB($row["ID"],0);		

				$year=substr($row['DATE'],0,4);
					
				$fdir=LEONARDO_ABS_PATH.'/'.str_replace("%PILOTID%",getPilotID($row['userServerID'],$row['userID']),str_replace("%YEAR%",$year,$CONF['paths']['igc']) ).'/';				
				$rdir=str_replace("%PILOTID%",getPilotID($row['userServerID'],$row['userID']),str_replace("%YEAR%",$year,$CONF['paths']['igc']) ).'/';				
				
				//$fdir=$flightsAbsPath."/".getPilotID($row['userServerID'],$row['userID'])."/flights/".$year."/";
				//$rdir=$flightsRelPath."/".getPilotID($row['userServerID'],$row['userID'])."/flights/".$year."/";
				$orgFilename=$fdir.$row['filename'];
						
				 if ( is_file( $orgFilename ) ){
				  	$status="OK"; 
					continue;
				 }	
				 
				 	$serverID=$row['serverID'];
					if ($serverID) {
						$server=new Server($serverID);
					}
					 $i++;