Completed
Push — master ( 73f088...7f17b6 )
by Yannick
07:13
created

flightid-overview.php (19 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
if ($_GET['id'] == "")
3
{
4
	header('Location: /');
5
}
6
7
require_once('require/class.Connection.php');
8
require_once('require/class.Spotter.php');
9
require_once('require/class.Language.php');
10
require_once('require/class.SpotterArchive.php');
11
$Spotter = new Spotter();
12
$SpotterArchive = new SpotterArchive();
13
$spotter_array = $Spotter->getSpotterDataByID($_GET['id']);
14
15
16
if (!empty($spotter_array))
17
{
18
	if(isset($spotter_array[0]['flightaware_id'])) {
19
		$flightaware_id = $spotter_array[0]['flightaware_id'];
20
	}
21 View Code Duplication
	if(isset($spotter_array[0]['last_latitude']) && $spotter_array[0]['last_latitude'] != '') {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
		$latitude = $spotter_array[0]['last_latitude'];
23
	} elseif(isset($spotter_array[0]['latitude'])) {
24
		$latitude = $spotter_array[0]['latitude'];
25
	}
26 View Code Duplication
	if(isset($spotter_array[0]['last_longitude']) && $spotter_array[0]['last_longitude'] != '') {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
		$longitude = $spotter_array[0]['last_longitude'];
28
	} elseif(isset($spotter_array[0]['longitude'])) {
29
		$longitude = $spotter_array[0]['longitude'];
30
	}
31
	$title = '';
32
	if(isset($spotter_array[0]['ident'])) {
33
		$title .= $spotter_array[0]['ident'];
34
	}
35
	if(isset($spotter_array[0]['airline_name'])) {
36
		$title .= ' - '.$spotter_array[0]['airline_name'];
37
	}
38 View Code Duplication
	if(isset($spotter_array[0]['aircraft_name']) && $spotter_array[0]['aircraft_name'] != 'Not Available') {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
		$title .= ' - '.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')';
40
	}
41
	if(isset($spotter_array[0]['registration']) && $spotter_array[0]['registration'] != 'NA' && $spotter_array[0]['registration'] != 'N/A') {
42
		$title .= ' - '.$spotter_array[0]['registration'];
43
	}
44
	//$facebook_meta_image = $spotter_array[0]['image'];
1 ignored issue
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
45
	require_once('header.php');
46
47
	if (isset($globalArchive) && $globalArchive) {
48
		// Requirement for altitude graph
49
		print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>';
50
		$all_data = $SpotterArchive->getAltitudeSpeedArchiveSpotterDataById($spotter_array[0]['flightaware_id']);
51
		
52
		if (isset($globalTimezone)) {
53
			date_default_timezone_set($globalTimezone);
54
		} else date_default_timezone_set('UTC');
55
		
56
		//date_default_timezone_set('UTC');
57
		if (is_array($all_data) && count($all_data) > 0) {
58
			print '<div id="chart6" class="chart" width="100%"></div>
59
                    <script> 
60
                        google.load("visualization", "1.1", {packages:["line","corechart"]});
61
                      google.setOnLoadCallback(drawChart6);
62
                      function drawChart6() {
63
                        var data = google.visualization.arrayToDataTable([
64
                            ["Hour","Altitude","Speed"], ';
65
                            $altitude_data = '';
66 View Code Duplication
			foreach($all_data as $data)
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
67
			{
68
				$altitude_data .= '[ "'.date("G:i",strtotime($data['date']." UTC")).'",'.$data['altitude'].','.$data['ground_speed'].'],';
69
			}
70
			$altitude_data = substr($altitude_data, 0, -1);
71
			print $altitude_data.']);
72
73
                        var options = {
74
                            legend: {position: "none"},
75
                            series: {
76
                        	0: {axis: "Altitude"},
77
                        	1: {axis: "Speed"}
78
                    	    },
79
                    	    axes: {
80
                    		y: {
81
                    		    Altitude: {label: "Altitude (FL)"},
82
                    		    Speed: {label: "Speed (knots)"},
83
                    		}
84
                    	    },
85
                            height:210
86
                        };
87
88
                        var chart = new google.charts.Line(document.getElementById("chart6"));
89
                        chart.draw(data, options);
90
                      }
91
                      $(window).resize(function(){
92
                              drawChart6();
93
                            });
94
                  </script>';
95
		}
96
	}
97
98
99
	print '<div class="info column">';
100
	print '<h1>';
101
	if ($globalIVAO && @getimagesize($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.gif')) {
102
		print '<a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'"><img src="'.$globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.gif" class="airline-logo" /></a> ';
103
	} elseif (@getimagesize($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png')) {
104
		print '<a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'"><img src="'.$globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png" class="airline-logo" /></a> ';
105
	} else {
106
		if ($spotter_array[0]['airline_name'] != "") {
107
			print '<a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a> ';
108
		}
109
	}
110
	if(isset($spotter_array[0]['ident'])) {
111
		print $spotter_array[0]['ident'];
112
	}
113
	if(isset($spotter_array[0]['airline_name'])) {
114
		print ' - '.$spotter_array[0]['airline_name'];
115
	}
116 View Code Duplication
	if(isset($spotter_array[0]['aircraft_name']) && $spotter_array[0]['aircraft_name'] != 'Not Available') {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
117
		print ' - '.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')';
118
	}
119
	if(isset($spotter_array[0]['registration']) && $spotter_array[0]['registration'] != 'NA') {
120
		print ' - '.$spotter_array[0]['registration'];
121
	}
122
	print '</h1>';
123
	print '</div>';
124
125
	if ($spotter_array[0]['registration'] != "") {
126
		//$highlight = $Spotter->getHighlightByRegistration($spotter_array[0]['registration']);
1 ignored issue
show
Unused Code Comprehensibility introduced by
77% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
127
		$highlight = $spotter_array[0]['highlight'];
128
		if ($highlight != "") {
129
			print '<div class="alert alert-warning">'.$highlight.'</div>';
130
		}
131
	}
132
133
	include('flightid-sub-menu.php');
134
	print '<div class="clear column">';
135
	print '<div class="image">';
136
	if ($spotter_array[0]['image'] != "")
137
	{
138
		if ($spotter_array[0]['image_source'] == 'planespotters') {
139
			$planespotter_url_array = explode("_", $spotter_array[0]['image']);
140
			$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
141
			print '<a href="http://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id.'" target="_blank"><img src="'.$spotter_array[0]['image_thumbnail'].'" alt="Click image to view on Planespotters.net" title="Click image to view on Planespotters.net" width="100%" /></a>';
142
			print '<div class="note">Disclaimer: The images are courtesy of Planespotters.net and their respective uploaders. This system may not always 100% accuratly show the actual aircraft.</div>';
143
			print '<div class="note">Planespotters.net didn\'t allow us to show full size pics here. This pic is copyright '.$spotter_array[0]['image_copyright'].'</div>';
144
		} else {
145
			if (isset($spotter_array[0]['image_source_website']) && $spotter_array[0]['image_source_website'] != '') {
146
				print '<a href="'.$spotter_array[0]['image_source_website'].'"><img src="'.$spotter_array[0]['image'].'" width="100%" /></a>';
147
			} else {
148
				print '<img src="'.$spotter_array[0]['image'].'" width="100%" />';
149
			}
150
			print '<div class="note">Disclaimer: The source of the above image is '.$spotter_array[0]['image_source'].' and is copyright '.$spotter_array[0]['image_copyright'].'. This system may not show the actual aircraft with 100% accuracy.</div>';
151
		}
152
	} else {
0 ignored issues
show
This else statement is empty and can be removed.

This check looks for the else branches of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These else branches can be removed.

if (rand(1, 6) > 3) {
print "Check failed";
} else {
    //print "Check succeeded";
}

could be turned into

if (rand(1, 6) > 3) {
    print "Check failed";
}

This is much more concise to read.

Loading history...
153
		//print '<img src="'.$globalURL.'/images/placeholder.png" alt="No image found!" title="No image found!" />';
1 ignored issue
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
154
	}
155
	print '</div>';
156
		
157
/*			print '<div class="col-sm-4 details">';
1 ignored issue
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
158
		 
159
		 	foreach($spotter_array as $spotter_item)
160
		  {
161
		  	print '<div class="detail">';
162
		  	if (@getimagesize($globalURL.'/images/airlines/'.$spotter_item['airline_icao'].'.png'))
163
	  		{
164
	    			print '<a href="'.$globalURL.'/airline/'.$spotter_item['airline_icao'].'"><img src="'.$globalURL.'/images/airlines/'.$spotter_item['airline_icao'].'.png" /></a>';
165
	  		} else {
166
	  				if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != "")
167
	  				{
168
	  					print '<a href="'.$globalURL.'/airline/'.$spotter_item['airline_icao'].'">'.$spotter_item['airline_name'].'</a>';
169
	  				} else {
170
	    				print 'N/A';
171
	  				}
172
	  		}
173
	  		print '</div>';
174
	  			
175
	  		print '<div class="detail">';
176
	  			print '<div class="title">Ident/Callsign</div>';
177
	  			print '<div>';
178
	  			if ($spotter_item['ident'] != "")
179
	  			{
180
	  				print '<a href="'.$globalURL.'/ident/'.$spotter_item['ident'].'">'.$spotter_item['ident'].'</a>';
181
	  			} else {
182
	    			print 'N/A';
183
	  			}
184
	  			print '</div>';
185
	  		print '</div>';
186
	  		
187
	  		print '<div class="detail">';
188
	  			print '<div class="title">Aircraft</div>';
189
	  			print '<div>';
190
	  				if (isset($spotter_item['aircraft_name']))
191
		  			{
192
		    			print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
193
		  			} else {
194
		  				if ($spotter_item['aircraft_type'] != "")
195
		  				{
196
		    				print $spotter_item['aircraft_type'];
197
		  				} else {
198
		    				print 'N/A';
199
		  				}
200
		  			}
201
	  			print '</div>';
202
	  		print '</div>';
203
	  		
204
	  		print '<div class="detail">';
205
	  			print '<div class="title">Registration</div>';
206
	  			print '<div>';
207
	  				if ($spotter_item['registration'] != "")
208
		  			{
209
		    			print '<a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'">'.$spotter_item['registration'].'</a>';
210
		  			} else {
211
		    				print 'N/A';
212
		  			}
213
	  			print '</div>';
214
	  		print '</div>';
215
	  		
216
	  		print '<div class="detail">';
217
	  			print '<div class="title">Coming from</div>';
218
	  			print '<div>';
219
	  				if ($spotter_item['departure_airport_name'] != "")
220
	    			{
221
		    			print '<a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'">'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_name'].', '.$spotter_item['departure_airport_country'].' ('.$spotter_item['departure_airport'].')</a>';
222
	    			} else {
223
	    				print $spotter_item['departure_airport'];
224
	    			}
225
	  			print '</div>';
226
	  		print '</div>';
227
	  		
228
	  		print '<div class="detail">';
229
	  			print '<div class="title">Flying to</div>';
230
	  			print '<div>';
231
	  				if ($spotter_item['arrival_airport_name'] != "")
232
	    			{
233
		    			print '<a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_name'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a>';
234
						} else {
235
							print $spotter_item['arrival_airport'];
236
						}
237
	  			print '</div>';
238
	  		print '</div>';	
239
	  		
240
	  		print '<div class="detail">';
241
	  			print '<div class="title">Date</div>';
242
	  			print '<div>';
243
                    
244
	  				print '<a href="'.$globalURL.'/date/'.date("Y-m-d", strtotime($spotter_item['date_iso_8601'])).'">'.date("M j, Y, g:i a", strtotime($spotter_item['date_iso_8601'])).'</a>';
245
	  			print '</div>';
246
	  		print '</div>';		
247
		  }
248
		 
249
		 print '</div>';
250
		
251
		
252
			print '<div class="col-sm-7 col-sm-offset-1 image">';
253
			
254
			print '<div class="image">';
255
		    	
256
	
257
				if ($spotter_array[0]['image'] != "")
258
				{	 	
259
                    $planespotter_url_array = explode("_", $spotter_array[0]['image']);
260
                    $planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
261
                    print '<a href="http://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id.'" target="_blank"><img src="'.$spotter_array[0]['image'].'" alt="Click image to view on Planespotters.net" title="Click image to view on Planespotters.net" /></a>';
262
					
263
				} else {
264
					print '<img src="'.$globalURL.'/images/placeholder.png" alt="No image found!" title="No image found!" />';
265
				}
266
			 
267
			 print '</div>';
268
			 print '<div class="note">Disclaimer: The images are courtesy of Planespotters.net and may not always be 100% accurate of the actual aircraft that has flown over.</div>';
269
		 print '</div>';
270
	 print '</div>';
271
*/
272
273
	foreach($spotter_array as $spotter_item)
274
	{
275
		print '<div class="details">';
276
		print '<h3>Flight Information</h3>';
277
		print '<div class="detail callsign">';
278
		print '<div class="title">Ident/Callsign</div>';
279
		print '<div>';
280
		if ($spotter_item['ident'] != "")
281
		{
282
			print '<a href="'.$globalURL.'/ident/'.$spotter_item['ident'].'">'.$spotter_item['ident'].'</a>';
283
		} else {
284
			print 'N/A';
285
		}
286
		print '</div>';
287
		print '</div>';
288
289
		if (isset($spotter_item['aircraft_owner']) && $spotter_item['aircraft_owner'] != '') 
290
		{
291
			print '<div class="detail fa-user">';
292
			print '<div class="title">Owner</div>';
293
			print '<div>';
294
			print $spotter_item['aircraft_owner'];
295
			print '</div>';
296
			print '</div>';
297
		} elseif ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
298
			print '<div class="detail fa-user">';
299
			print '<div class="title">Pilot Name</div>';
300
			print '<div>';
301
			if (isset($spotter_item['pilot_id']) && $spotter_item['pilot_id'] != "")
302
			{
303
				if ($spotter_item['format_source'] == 'whazzup') print '<a href="https://www.ivao.aero/Member.aspx?ID='.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>';
304
				elseif ($spotter_item['format_source'] == 'vatsimtxt') print '<a href="http://www.vataware.com/pilot/'.$spotter_item['pilot_id'].'">'.$spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')</a>';
305
				else print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
306
			} else {
307
				if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != "")
308
				{
309
					print $spotter_item['pilot_name'];
310
				} else {
311
					print 'N/A';
312
				}
313
			}
314
			print '</div>';
315
			print '</div>';
316
		}
317
318
		print '<div class="detail airline">';
319
		print '<div class="title">Airline</div>';
320
		print '<div>';
321
		if ($spotter_item['airline_name'] != "")
322
		{
323
			print '<a href="'.$globalURL.'/airline/'.$spotter_item['airline_icao'].'">'.$spotter_item['airline_name'].'</a>';
324
		} else {
325
			print 'N/A';
326
		}
327
		print '</div>';
328
		print '</div>';
329
330
		print '<div class="detail aircraft">';
331
		print '<div class="title">Aircraft</div>';
332
		print '<div>';
333
		if ($spotter_item['aircraft_name'] != "")
334
		{
335
			print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
336
		} else {
337
			if ($spotter_item['aircraft_type'] != "")
338
			{
339
				print $spotter_item['aircraft_type'];
340
			} else {
341
				print 'N/A';
342
			}
343
		}
344
		print '</div>';
345
		print '</div>';
346
347
		print '<div class="detail registration">';
348
		print '<div class="title">Registration</div>';
349
		print '<div>';
350
		if ($spotter_item['registration'] != "")
351
		{
352
			print '<a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'">'.$spotter_item['registration'].'</a>';
353
		} else {
354
			print 'N/A';
355
		}
356
		print '</div>';
357
		print '</div>';
358
359
		print '<div class="detail departure">';
360
		print '<div class="title">Departure Airport</div>';
361
		print '<div>';
362
		if ($spotter_item['departure_airport_name'] != "")
363
		{
364
			print '<a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'">'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_name'].', '.$spotter_item['departure_airport_country'].' ('.$spotter_item['departure_airport'].')</a>';
365
		} else {
366
			print $spotter_item['departure_airport'];
367
		}
368
		print '</div>';
369
		if (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != '') {
370
			if ($spotter_item['departure_airport_time'] > 2460) {
371
				print '<div class="time">';
372
				print 'at '.date('H:m',$spotter_item['departure_airport_time']);
373
				print '</div>';
374
			} else {
375
				print '<div class="time">';
376
				print 'at '.$spotter_item['departure_airport_time'];
377
				print '</div>';
378
			}
379
		}
380
		print '</div>';
381
382
		print '<div class="detail arrival">';
383
		print '<div class="title">Arrival Airport</div>';
384
		print '<div>';
385
		if ($spotter_item['arrival_airport_name'] != "")
386
		{
387
			print '<a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_name'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a>';
388
		} else {
389
			print $spotter_item['arrival_airport'];
390
		}
391
		print '</div>';
392
		if (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != '') {
393
			print '<div class="time">';
394
			print 'at '.$spotter_item['arrival_airport_time'];
395
			print '</div>';
396
		} elseif (isset($spotter_item['real_arrival_airport_time']) && $spotter_item['real_arrival_airport_time'] != '') {
397
			print '<div class="time">';
398
			print 'at '.$spotter_item['real_arrival_airport_time'];
399
			print '</div>';
400
		}
401
		print '</div>';
402
403
		if ($spotter_item['waypoints'] != "" || $spotter_item['route_stop'] != "")
404
		{
405
			print '<div class="detail coordinates">';
406
			print '<div class="title">Route</div>';
407
			print '<div>';
408
			if ($spotter_item['waypoints'] != "")
409
			{
410
				print $spotter_item['waypoints'];
411
			} elseif ($spotter_item['route_stop'] != "")
412
			{
413
				print $spotter_item['route_stop'];
414
			}
415
			print '</div>';
416
			print '</div>';
417
		}
418
		print '</div>';
419
420
		print '<div class="details">';
421
		print '<h3>Additional information as it flew nearby</h3>';
422
		print '<div class="detail speed">';
423
		print '<div class="title">Ground Speed</div>';
424
		print '<div>';
425
		if (isset($spotter_item['last_ground_speed']) && $spotter_item['last_ground_speed'] != '') {
426 View Code Duplication
			if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
427
				print round($spotter_item['last_ground_speed']*1.15078).' mph';
428
			} elseif ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
429
				print $spotter_item['last_ground_speed'].' knots';
430
			} else {
431
				print round($spotter_item['last_ground_speed']*1.852).' km/h';
432
			}
433 View Code Duplication
		} else {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
434
			if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
435
				print round($spotter_item['ground_speed']*1.15078).' mph';
436
			} elseif ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
437
				print $spotter_item['ground_speed'].' knots';
438
			} else {
439
				print round($spotter_item['ground_speed']*1.852).' km/h';
440
			}
441
		}
442
		print '</div>';
443
		print '</div>';	
444
445
		print '<div class="detail heading">';
446
		print '<div class="title">Heading (degrees)</div>';
447
		print '<div>';
448
		print $spotter_item['heading'].' ('.$spotter_item['heading_name'].')';
449
		print '</div>';
450
		print '</div>';
451
452
		print '<div class="detail altitude">';
453
		print '<div class="title">Altitude</div>';
454
		print '<div>';
455
		if (isset($spotter_item['last_altitude']) && $spotter_item['last_altitude'] != '') {
456 View Code Duplication
			if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
457
				print number_format($spotter_item['last_altitude'].'00').' feet';
458
			} else {
459
				print round($spotter_item['last_altitude']*30.48).' m';
460
			}
461 View Code Duplication
		} else {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
462
			if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
463
				print number_format($spotter_item['altitude'].'00').' feet';
464
			} else {
465
				print round($spotter_item['altitude']*30.48).' m';
466
			}
467
		}
468
		print '</div>';
469
		print '</div>';
470
471
		print '<div class="detail coordinates">';
472
		print '<div class="title">Coordinates</div>';
473
		print '<div>';
474
		//print '<a href="https://www.google.com/maps/place/'.$spotter_item['latitude'].','.$spotter_item['longitude'].'/@'.$spotter_item['latitude'].','.$spotter_item['longitude'].',10z" target="_blank">Lat: '.$spotter_item['latitude'].' Lng: '.$spotter_item['longitude'].'</a>';
1 ignored issue
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
475
		if (isset($spotter_item['last_latitude']) && $spotter_item['last_latitude'] != '') {
476
			print 'Lat: '.$spotter_item['last_latitude'].' Lng: '.$spotter_item['last_longitude'];
477
		} else {
478
			print 'Lat: '.$spotter_item['latitude'].' Lng: '.$spotter_item['longitude'];
479
		}
480
		print '</div>';
481
		print '</div>';
482
483
		print '<div class="detail date">';
484
		print '<div class="title">Date ('.$globalTimezone.')</div>';
485
		print '<div>';
486
		date_default_timezone_set($globalTimezone);
487
		print '<a href="'.$globalURL.'/date/'.date("Y-m-d", strtotime($spotter_item['date_iso_8601'])).'">'.date("M j, Y g:i a", strtotime($spotter_item['date_iso_8601'])).'</a>';
488
		print '</div>';
489
		print '</div>';	
490
491
		print '<div class="detail date">';
492
		print '<div class="title">Date (UTC)</div>';
493
		print '<div>';
494
		date_default_timezone_set('UTC');
495
		print date("M j, Y G:i", strtotime($spotter_item['date_iso_8601']));
496
		print '</div>';
497
		print '</div>';
498
499 View Code Duplication
		if (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != '' && $spotter_item['departure_airport'] != 'NA') {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
500
			print '<div class="detail distance-departure">';
501
			print '<div class="title">Distance from Departure Airport</div>';
502
			print '<div>';
503
			$Common = new Common();
504
			$departure_airport_info = $Spotter->getAllAirportInfo($spotter_item['departure_airport']);
505
			if (isset($spotter_item['last_latitude']) && $spotter_item['last_latitude'] != '') {
506
				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
507
					print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'nm').' nm';
508
				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
509
					print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'mi').' mi';
510
				} else {
511
					print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'km').' km';
512
				}
513
			} else {
514
				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
515
					print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'nm').' nm';
516
				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
517
					print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'mi').' mi';
518
				} else {
519
					print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$departure_airport_info[0]['latitude'],$departure_airport_info[0]['longitude'],'km').' km';
520
				}
521
			}
522
			print '</div>';
523
			print '</div>';
524
		}
525 View Code Duplication
		if (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != '' && $spotter_item['arrival_airport'] != 'NA') {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
526
			print '<div class="detail distance-arrival">';
527
			print '<div class="title">Distance to Arrival Airport</div>';
528
			print '<div>';
529
			$Common = new Common();
530
			$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
531
			if (isset($spotter_item['last_latitude']) && $spotter_item['last_latitude'] != '') {
532
				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
533
					print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'nm').' nm';
534
				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
535
					print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'mi').' mi';
536
				} else {
537
					print $Common->distance($spotter_item['last_latitude'],$spotter_item['last_longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'km').' km';
538
				}
539
			} else {
540
				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
541
					print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'nm').' nm';
542
				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
543
					print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'mi').' mi';
544
				} else {
545
					print $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$arrival_airport_info[0]['latitude'],$arrival_airport_info[0]['longitude'],'km').' km';
546
				}
547
			}
548
			print '</div>';
549
			print '</div>';
550
		}
551
552
553
		print '</div>';
554
	}
555
	print '</div>';
556
557
//	print '<div id="archive-map"></div>';
558
559
	if ($spotter_array[0]['registration'] != "" && $spotter_array[0]['registration'] != "NA" && $spotter_array[0]['registration'] != "N/A")
560
	{
561
		print '<div class="last-flights">';
562
		print '<h3>Last 5 Flights of this Aircraft ('.$spotter_array[0]['registration'].')</h3>';
563
		$hide_th_links = true;
564
		$spotter_array = $Spotter->getSpotterDataByRegistration($spotter_array[0]['registration'],"0,5", "");
565
		include('table-output.php'); 
566
		print '<div class="more">';
567
		print '<a href="'.$globalURL.'/registration/'.$spotter_array[0]['registration'].'" class="btn btn-default btn" role="button">See all Flights&raquo;</a>';
568
		print '</div>';
569
		print '</div>';
570
	}
571
/*	     	?>
1 ignored issue
show
Unused Code Comprehensibility introduced by
90% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
572
	     <div class="column">
573
574
    	<div class="share">
575
	    	<span class='st_facebook' displayText='Facebook'></span>
576
			<span class='st_twitter' displayText='Tweet'></span>
577
			<span class='st_googleplus' displayText='Google +'></span>
578
			<span class='st_pinterest' displayText='Pinterest'></span>
579
			<span class='st_email' displayText='Email'></span>
580
    	</div>
581
		<script type="text/javascript">var switchTo5x=true;</script>
582
		<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
583
		<script type="text/javascript">stLight.options({publisher: "ur-5a9fbd4d-de8a-6441-d567-29163a2526c7", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script>
584
585
    	<?php
586
    print '</div>';
587
*/
588
} else {
589
	$title = "ID";
590
	require_once('header.php');
591
	print '<h1>Error</h1>';
592
	print '<p>Sorry, this flight is not in the database. :(</p>'; 
593
}
594
595
	require_once('footer.php');
596
?>
1 ignored issue
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...