2 require_once('require/class.Connection.php');
3 require_once('require/class.Marine.php');
4 require_once('require/class.Stats.php');
5 require_once('require/class.Language.php');
6 require_once('require/class.MarineArchive.php');
8 if (!isset($_GET['race'])){
9 header('Location: '.$globalURL.'/');
12 $Marine = new Marine();
13 $MarineArchive = new MarineArchive();
14 //calculuation for the pagination
15 if(!isset($_GET['limit']))
19 $absolute_difference = 25;
21 $limit_explode = explode(",", $_GET['limit']);
22 $limit_start = $limit_explode[0];
23 $limit_end = $limit_explode[1];
24 if (!ctype_digit(strval($limit_start)) ||
!ctype_digit(strval($limit_end))) {
29 $absolute_difference = abs($limit_start - $limit_end);
30 $limit_next = $limit_end +
$absolute_difference;
31 $limit_previous_1 = $limit_start - $absolute_difference;
32 $limit_previous_2 = $limit_end - $absolute_difference;
35 $race = filter_input(INPUT_GET
,'race',FILTER_SANITIZE_STRING
);
36 $page_url = $globalURL.'/marine/race/'.$race;
37 $sort = filter_input(INPUT_GET
,'sort',FILTER_SANITIZE_STRING
);
38 $year = filter_input(INPUT_GET
,'year',FILTER_SANITIZE_NUMBER_INT
);
39 $month = filter_input(INPUT_GET
,'month',FILTER_SANITIZE_NUMBER_INT
);
40 $race_data = $Marine->getRace($race);
42 if ($year != '') $filter = array_merge($filter,array('year' => $year));
43 if ($month != '') $filter = array_merge($filter,array('month' => $month));
46 $spotter_array = $Marine->getMarineDataByRace($race,$limit_start.",".$absolute_difference, $sort,$filter);
48 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
49 $spotter_array = $MarineArchive->getMarineDataByRace($race,$limit_start.",".$absolute_difference, $sort,$filter);
53 $spotter_array = $Marine->getMarineDataByRace($race,$limit_start.",".$absolute_difference,'',$filter);
55 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
56 $spotter_array = $MarineArchive->getMarineDataByRace($race,$limit_start.",".$absolute_difference,'',$filter);
61 if (!empty($spotter_array))
63 $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['race_name']);
64 $ident = $spotter_array[0]['ident'];
65 if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
66 if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
67 require_once('header.php');
69 if (isset($globalArchive) && $globalArchive) {
70 // Requirement for altitude graph
71 print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>';
72 $all_data = $MarineArchive->getAltitudeSpeedArchiveMarineDataById($spotter_array[0]['flightaware_id']);
73 if (isset($globalTimezone)) {
74 date_default_timezone_set($globalTimezone);
75 } else date_default_timezone_set('UTC');
76 if (count($all_data) > 0) {
77 print '<div id="chart6" class="chart" width="100%"></div>
79 google.load("visualization", "1.1", {packages:["line","corechart"]});
80 google.setOnLoadCallback(drawChart6);
81 function drawChart6() {
82 var data = google.visualization.arrayToDataTable([
83 ["Hour","'._("Altitude").'","'._("Speed").'"], ';
85 foreach($all_data as $data)
87 $altitude_data .= '[ "'.date("G:i",strtotime($data['date']." UTC")).'",'.$data['altitude'].','.$data['ground_speed'].'],';
89 $altitude_data = substr($altitude_data, 0, -1);
90 print $altitude_data.']);
93 legend: {position: "none"},
95 0: {axis: "Altitude"},
100 Altitude: {label: "'._("Altitude (FL)").'"},
101 Speed: {label: "'._("Speed (knots)").'"},
107 var chart = new google.charts.Line(document.getElementById("chart6"));
108 chart.draw(data, options);
110 $(window).resize(function(){
117 print '<div class="info column">';
118 print '<h1>'.$spotter_array[0]['race_name'].'</h1>';
119 if (isset($spotter_array[0]['race_id']) && $spotter_array[0]['race_id'] != '') print '<div><span class="label">'._("race ID").'</span>'.$spotter_array[0]['race_id'].'</div>';
121 if ($year == '' && $month == '') {
122 $Stats = new Stats();
123 $flights = $Stats->getStatsrace($race);
127 $flights = $Marine->countCaptainsByRace($race,$filter);
128 print '<div><span class="label">'._("Captains").'</span>'.$flights.'</div>';
129 $aircraft_type = count($Marine->countAllBoatTypesByRace($race,$filter));
130 print '<div><span class="label">'._("Boat type").'</span>'.$aircraft_type.'</div>';
131 //$aircraft_registration = count($Marine->countAllAircraftRegistrationByrace($race,$filter));
132 //print '<div><span class="label">'._("Aircraft").'</span>'.$aircraft_registration.'</div>';
133 //$aircraft_manufacturer = count($Marine->countAllAircraftManufacturerByrace($race,$filter));
134 //print '<div><span class="label">'._("Manufacturers").'</span>'.$aircraft_manufacturer.'</div>';
135 //$airlines = count($Marine->countAllAirlinesByrace($race,$filter));
136 //print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
137 //$duration = $Marine->getRaceDurationByrace($race,$filter);
138 //if ($duration != '0') print '<div><span class="label">'._("Total races spotted duration").'</span>'.$duration.'</div>';
139 if (isset($race_data['race_creator']) && $race_data['race_creator'] != '') {
140 print '<div><span class="creator">'._("Creator").'</span>'.$race_data['race_creator'].'</div>';
142 if (isset($race_data['race_startdate']) && $race_data['race_startdate'] != '') {
143 if (isset($globalTimezone)) {
144 date_default_timezone_set($globalTimezone);
145 } else date_default_timezone_set('UTC');
146 print '<div><span class="startdate">'._("Start date").'</span>'.date("r", strtotime($race_data['race_startdate'])).'</div>';
149 if (isset($race_data['race_desc']) && $race_data['race_desc'] != '') {
150 print '<div class="well">'.nl2br($race_data['race_desc']).'</div>';
153 //include('race-sub-menu.php');
154 print '<div class="table column">';
155 print '<p>'.sprintf(_("The table below shows the detailed information of all races with the race <strong>%s</strong>."),$spotter_array[0]['race_name']).'</p>';
157 include('table-output.php');
158 print '<div class="pagination">';
159 if ($limit_previous_1 >= 0)
161 print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'/'.$sort.'">«'._("Previous Page").'</a>';
163 if ($spotter_array[0]['query_number_rows'] == $absolute_difference)
165 print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'/'.$sort.'">'._("Next Page").'»</a>';
171 require_once('header.php');
172 print '<h1>'._("Error").'</h1>';
173 print '<p>'._("Sorry, this race is not in the database. :(").'</p>';
176 require_once('footer.php');