Completed
Push — master ( ae4662...65be4b )
by Yannick
11:45 queued 04:47
created

aircraft-data.php (13 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
require_once('require/class.Connection.php');
3
require_once('require/class.Spotter.php');
4
require_once('require/class.Language.php');
5
require_once('require/class.SpotterLive.php');
6
require_once('require/class.SpotterArchive.php');
7
$SpotterLive = new SpotterLive();
8
$SpotterArchive = new SpotterArchive();
9
10
$from_archive = false;
11 View Code Duplication
if (isset($_GET['ident'])) {
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...
12
	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
13
	$spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident);
14
	if (empty($spotter_array)) {
15
		$from_archive = true;
16
		$spotter_array = $SpotterArchive->getLastArchiveSpotterDataByIdent($ident);
17
	}
18
}
19 View Code Duplication
if (isset($_GET['flightaware_id'])) {
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...
20
	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
21
	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
22
	if (empty($spotter_array)) {
23
		$from_archive = true;
24
		$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
25
	}
26
}
27
 ?>
28
<div class="alldetails">
29
<button type="button" class="close">&times;</button>
30
<?php
31
$spotter_item = $spotter_array[0];
32
date_default_timezone_set('UTC');
33
if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
34
{
35 View Code Duplication
	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
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...
36
		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
37
	} else $image = $spotter_item['image_thumbnail'];
38
39
}
40
/* else {
1 ignored issue
show
Unused Code Comprehensibility introduced by
47% 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...
41
	$image = "images/placeholder_thumb.png";
42
} */
43
44
print '<div class="top">';
45
if (isset($image)) {
46
	print '<div class="left"><img src="'.$image.'" alt="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].'" title="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].' Image &copy; '.$spotter_item['image_copyright'].'"/><br />Image &copy; '.$spotter_item['image_copyright'].'</div>';
47
}
48
print '<div class="right"><div class="callsign-details"><div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
49
if (isset($spotter_item['airline_name'])) print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
50
print '</div>';
51
print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
52 View Code Duplication
if (isset($spotter_item['departure_airport_time'])) {
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...
53
	if ($spotter_item['departure_airport_time'] > 2460) {
54
		print '<br /><span class="time">'.date('H:m',$spotter_item['departure_airport_time']).'</span>';
55
	} else {
56
		print '<br /><span class="time">'.$spotter_item['departure_airport_time'].'</span>';
57
	}
58
}
59
print '</div><i class="fa fa-long-arrow-right"></i><div class="airport">';
60
print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country'];
61 View Code Duplication
if (isset($spotter_item['arrival_airport_time'])) {
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...
62
	if ($spotter_item['arrival_airport_time'] > 2460) {
63
		print '<br /><span class="time">'.date('H:m',$spotter_item['arrival_airport_time']).'</span>';
64
	} else {
65
		print '<br /><span class="time">'.$spotter_item['arrival_airport_time'].'</span>';
66
	}
67
}
68
print '</div></div>';
69
//if (isset($spotter_item['route_stop'])) print 'Route stop : '.$spotter_item['route_stop'];
1 ignored issue
show
Unused Code Comprehensibility introduced by
81% 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...
70
print '</div></div>';
71
print '<div class="details"><div class="mobile airports"><div class="airport">';
72
print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
73
print '</div><i class="fa fa-long-arrow-right"></i><div class="airport">';
74
print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country'];
75
print '</div></div><div>';
76
print '<span>'._("Aircraft").'</span>';
77
if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
78
if (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a>';
79
else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
80
print '</div>';
81
print '<div><span>'._("Altitude").'</span>';
82
if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
83
	print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')';
84
} else {
85
	print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')';
86
}
87
print '</div>';
88
if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
89
print '<div><span>'._("Speed").'</span>';
90 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...
91
	print round($spotter_item['ground_speed']*1.15078).' mph';
92
} elseif ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
93
	print $spotter_item['ground_speed'].' knots';
94
} else {
95
	print round($spotter_item['ground_speed']*1.852).' km/h';
96
}
97
print '</div>';
98
print '<div><span>'._("Coordinates").'</span>'.$spotter_item['latitude'].', '.$spotter_item['longitude'].'</div>';
99
print '<div><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>';
100
if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') {
101
	print '<div><span>'._("Pilot").'</span>';
102
	if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
103
	else print $spotter_item['pilot_name'];
104
	print '</div>';
105
}
106
107 View Code Duplication
if (isset($spotter_item['aircraft_owner']) && $spotter_item['aircraft_owner'] != '') {
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...
108
	print '<div><span>'._("Owner").'</span>';
109
	print $spotter_item['aircraft_owner'];
110
	print '</div>';
111
}
112 View Code Duplication
if (isset($spotter_item['over_country']) && $spotter_item['over_country'] != '') {
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...
113
	print '<div><span>'._("Over country").'</span>';
114
	print $spotter_item['over_country'];
115
	print '</div>';
116
}
117 View Code Duplication
if (isset($spotter_item['source_name']) && $spotter_item['source_name'] != '') {
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...
118
	print '<div><span>'._("Source").'</span>';
119
	print $spotter_item['source_name'];
120
	print '</div>';
121
}
122
print '</div>';
123
124
if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
125 View Code Duplication
if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
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...
126
if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
127 View Code Duplication
if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
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...
128
print '</div>';
129
?>
130
</div>
131