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

aircraft-statistics-airline.php (3 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
6
if (!isset($_GET['aircraft_type'])) {
7
        header('Location: '.$globalURL.'/aircraft');
8
        die();
9
}
10
$aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING);
11
$Spotter = new Spotter();
12
$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type,"0,1","");
13
14
15
if (!empty($spotter_array))
16
{
17
	$title = sprintf(_("Most Common Airlines from %s (%s)"),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']);
18
	require_once('header.php');
19
	print '<div class="select-item">';
20
	print '<form action="'.$globalURL.'/aircraft" method="post">';
21
	print '<select name="aircraft_type" class="selectpicker" data-live-search="true">';
22
	print '<option></option>';
23
	$aircraft_types = $Spotter->getAllAircraftTypes();
24 View Code Duplication
	foreach($aircraft_types as $aircrafttype)
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...
25
	{
26
		if($aircraft_type == $aircrafttype['aircraft_icao'])
27
		{
28
			print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
29
		} else {
30
			print '<option value="'.$aircrafttype['aircraft_icao'].'">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
31
		}
32
	}
33
	print '</select>';
34
	print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
35
	print '</form>';
36
	print '</div>';
37
38 View Code Duplication
	if ($aircraft_type != "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...
39
	{
40
		print '<div class="info column">';
41
		print '<h1>'.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')</h1>';
42
		print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['aircraft_name'].'</div>';
43
		print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['aircraft_type'].'</div>'; 
44
		print '<div><span class="label">'._("Manufacturer").'</span><a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $spotter_array[0]['aircraft_manufacturer'])).'">'.$spotter_array[0]['aircraft_manufacturer'].'</a></div>';
45
		print '</div>';
46
	} else {
47
		print '<div class="alert alert-warning">'._("This special aircraft profile shows all flights in where the aircraft type is unknown.").'</div>';
48
	}
49
	include('aircraft-sub-menu.php');
50
	print '<div class="column">';
51
	print '<h2>'._("Most Common Airlines").'</h2>';
52
	print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights from <strong>%s (%s)</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>';
53
54
	$airline_array = $Spotter->countAllAirlinesByAircraft($aircraft_type);
55
56
	if (!empty($airline_array))
57
	{
58
		print '<div class="table-responsive">';
59
		print '<table class="common-airline">';
60
		print '<thead>';
61
		print '<th></th>';
62
		print '<th></th>';
63
		print '<th>'._("Airline").'</th>';
64
		print '<th>'._("Country").'</th>';
65
		print '<th>'._("# of times").'</th>';
66
		print '<th></th>';
67
		print '</thead>';
68
		print '<tbody>';
69
		$i = 1;
70
		foreach($airline_array as $airline_item)
71
		{
72
			print '<tr>';
73
			print '<td><strong>'.$i.'</strong></td>';
74
			print '<td class="logo">';
75
			print '<a href="'.$globalURL.'/airline/'.$airline_item['airline_icao'].'"><img src="';
76
			if (@getimagesize($globalURL.'/images/airlines/'.$airline_item['airline_icao'].'.png'))
77
			{
78
				print $globalURL.'/images/airlines/'.$airline_item['airline_icao'].'.png';
79
			} else {
80
				print $globalURL.'/images/airlines/placeholder.png';
81
			}
82
			print '" /></a>';
83
			print '</td>';
84
			print '<td>';
85
			print '<a href="'.$globalURL.'/airline/'.$airline_item['airline_icao'].'">'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')</a>';
86
			print '</td>';
87
			print '<td>';
88
			print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airline_item['airline_country'])).'">'.$airline_item['airline_country'].'</a>';
89
			print '</td>';
90
			print '<td>';
91
			print $airline_item['airline_count'];
92
			print '</td>';
93
			print '<td><a href="'.$globalURL.'/search?airline='.$airline_item['airline_icao'].'&aircraft='.$aircraft_type.'">Search flights</a></td>';
94
			print '</tr>';
95
			$i++;
96
		}
97
		print '<tbody>';
98
		print '</table>';
99
		print '</div>';
100
	}
101
	print '</div>';
102
} else {
103
	$title = "Aircraft Type";
104
	require_once('header.php');
105
	print '<h1>'._("Error").'</h1>';
106
	print '<p>'._("Sorry, the aircraft type does not exist in this database. :(").'</p>';  
107
}
108
109
require_once('footer.php');
110
?>
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...