Completed
Push — master ( 486240...8fac34 )
by Yannick
08:18
created

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