function getFlightInfo(&$track, &$geoServerStatus) { $id = $track['flightId']; $query = "SELECT * FROM flightInfo WHERE id='{$id}'"; $result = mysql_query($query) or die('Query error: ' . mysql_error()); if (mysql_num_rows($result) == 1) { $flightInfo = mysql_fetch_object($result); } else { $query = "INSERT INTO flightInfo (id) VALUES ('{$id}')"; $result = mysql_query($query) or die('Query error: ' . mysql_error()); $query = "SELECT * FROM flightInfo WHERE id='{$id}'"; $result = mysql_query($query) or die('Query error: ' . mysql_error()); $flightInfo = mysql_fetch_object($result); } // Retrieve take-off information if ($flightInfo->startLocation == NULL) { $track['start']['location'] = getNearbyPlace($track['start']['lat'], $track['start']['lon'], $geoServerStatus); if ($track['start']['location']['place'] != '-') { $query = "UPDATE flightInfo " . "SET startLocation = '" . format_mysql($track['start']['location']['place']) . "', " . "startCountry = '" . format_mysql($track['start']['location']['country']) . "' " . "WHERE id='{$id}'"; $result = mysql_query($query) or die('Query error: ' . mysql_error()); } } else { $track['start']['location']['place'] = $flightInfo->startLocation; $track['start']['location']['country'] = $flightInfo->startCountry; } // Retrieve position / landing information if ($flightInfo->endLocation == NULL || $track['live']) { $track['end']['location'] = getNearbyPlace($track['end']['lat'], $track['end']['lon'], $geoServerStatus); if ($track['end']['location']['place'] != '-' && !$track['live']) { $query = "UPDATE flightInfo " . "SET endLocation = '" . format_mysql($track['end']['location']['place']) . "', " . "endCountry = '" . format_mysql($track['end']['location']['country']) . "' " . "WHERE id='{$id}'"; $result = mysql_query($query) or die('Query error: ' . mysql_error()); } } else { $track['end']['location']['place'] = $flightInfo->endLocation; $track['end']['location']['country'] = $flightInfo->endCountry; } // Retrieve timezone information if ($flightInfo->timezone == NULL) { $flightInfo->timezone = getTimeZone($track['start']['lat'], $track['start']['lon'], $geoServerStatus); if ($flightInfo->timezone != NULL) { $query = "UPDATE flightInfo " . "SET timezone = '{$flightInfo->timezone}' " . "WHERE id='{$id}'"; $result = mysql_query($query) or die('Query error: ' . mysql_error()); } } return $flightInfo; }
$utc = isset($_POST['utc']) ? 1 : 0; $test = isset($_POST['test']) ? true : false; $ua = $_SERVER['HTTP_USER_AGENT']; // Log connection file_put_contents('id.txt', $_POST['id'] . " - " . date(DATE_RFC822) . "\n", FILE_APPEND | LOCK_EX); $link = mysql_connect(dbHost, dbUser, dbPassword) or die('Could not connect: ' . mysql_error()); mysql_select_db(dbName) or die('Database does not exist'); // Is it only a connection test ? if ($test) { $id = isset($_POST['id']) ? intval($_POST['id']) : 0; $insert = "INSERT INTO test (id, time) VALUES ({$id}, NOW())"; mysql_query($insert) or die('Query error: ' . mysql_error()); exit; } // Get the pilot id when it exists otherwise exit $query = sprintf("SELECT id FROM pilot WHERE pseudo = '%s'", format_mysql($_POST['id'])); $result = mysql_query($query) or die('Query error: ' . mysql_error()); if (mysql_num_rows($result) == 1) { $pilot = mysql_fetch_object($result); $pilotId = $pilot->id; } else { exit; } // Create a new flight on start if (isset($_POST['start'])) { $query = "INSERT INTO flight (pilotId, start, end, utc, ua) VALUES ({$pilotId}, NULL, NULL, {$utc}, '{$ua}')"; mysql_query($query) or die('Query error: ' . mysql_error()); } // Get the current flight id $query = "SELECT start, end, id FROM flight WHERE pilotId = '{$pilotId}' ORDER BY id DESC LIMIT 0, 1"; $result = mysql_query($query) or die('Query error: ' . mysql_error());
*/ require 'mvg_db.inc.php'; require 'vg_cfg.inc.php'; echo "<?xml version='1.0' encoding='UTF-8'?>\n" . "<!DOCTYPE html PUBLIC '-//WAPFORUM//DTD XHTML Mobile 1.0//EN' 'http://www.wapforum.org/DTD/xhtml-mobile10.dtd'>\n" . "<html xmlns='http://www.w3.org/1999/xhtml'>\n" . "<head>\n" . " <meta http-equiv='content-type' content='text/html; charset=UTF-8'/>\n" . " <title>Map</title>\n" . "</head>\n" . "<body>\n"; // Keep going only if an id has been provided if (isset($_GET['id'])) { if (!isset($_GET['zoom'])) { $zoom = 11; } else { $zoom = $_GET['zoom']; } $link = mysql_connect(dbHost, dbUser, dbPassword) or die('Could not connect: ' . mysql_error()); mysql_select_db(dbName) or die('Database does not exist'); // Map size $w = $h = 180; $query = sprintf("SELECT latitude, longitude, elevation, time FROM pilot, flight, point " . "WHERE pseudo = '%s' AND " . "pilotId = pilot.id AND " . "flightId = flight.id " . "ORDER BY point.time DESC " . "LIMIT 0,1", format_mysql($_GET['id'])); $result = mysql_query($query) or die('Query error: ' . mysql_error()); if (mysql_num_rows($result) == 1) { $position = mysql_fetch_object($result); // Center psotion $lat = isset($_GET['lat']) ? floatval($_GET['lat']) : $position->latitude; $lon = isset($_GET['lon']) ? floatval($_GET['lon']) : $position->longitude; $img = sprintf("Date: {$position->time}<br/>\n" . "Lieu: " . getNearbyPlace($position->latitude, $position->longitude) . " [" . $position->latitude . " - " . $position->longitude . "]<br/>\n" . "h: " . $position->elevation . "m (" . max(0, $position->elevation - GetElevGnd($position->latitude, $position->longitude)) . "m/sol)<br/>\n" . "<img src='http://maps.google.com/staticmap?zoom=%d&size={$w}x{$h}&" . "center={$lat},{$lon}&" . "maptype=mobile&markers={$position->latitude},{$position->longitude},smallgreen&" . "key=ABQIAAAAJPvmQMZVrrV3inIwT2t4RBQf-JSUIEMNUNF63gcoYgskNGvaZRQmUvzGcFUdj4nlylxP8SK4sRKYsg'></img>\n", $zoom); $zoomIn = $zoomOut = $up = $down = $left = $right = "<a href='http://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . "?id=" . $_GET['id']; $zoomIn .= "&zoom=" . ($zoom + 1) . "&lat={$lat}&lon={$lon}'>+</a>\n"; $zoomOut .= "&zoom=" . ($zoom - 1) . "&lat={$lat}&lon={$lon}'>-</a>\n"; $projection = new Mercator($zoom, 256); $latUp = $latDown = $projection->Y($lat); $lonLeft = $lonRight = $projection->X($lon); $latUp = $projection->Lat($latUp - $h / 2); $latDown = $projection->Lat($latDown + $h / 2);