Completed
Push — master ( d8c574...a11679 )
by Yannick
07:12
created

manufacturer-statistics-registration.php (1 issue)

Severity

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['aircraft_manufacturer'])) {
6
        header('Location: '.$globalURL.'/manufacturer');
7
        die();
8
}
9
$Spotter = new Spotter();
10
$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING)));
11
$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
12
$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort);
13
14
if (!empty($spotter_array))
15
{
16
	$title = sprintf(_("Most Common Aircraft by Registration from %s"),$manufacturer);
17
	require_once('header.php');
18
19
	print '<div class="select-item">';
20
	print '<form action="'.$globalURL.'/manufacturer" method="post">';
21
	print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
22
	print '<option></option>';
23
	$all_manufacturers = $Spotter->getAllManufacturers();
24
	foreach($all_manufacturers as $all_manufacturer)
25
	{
26
		if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
27
		{
28
			print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
29
		} else {
30
			print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'">'.$all_manufacturer['aircraft_manufacturer'].'</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
	print '<div class="info column">';
39
	print '<h1>'.$manufacturer.'</h1>';
40
	print '</div>';
41
42
	include('manufacturer-sub-menu.php');
43
	print '<div class="column">';
44
	print '<h2>'._("Most Common Aircraft by Registration").'</h2>';
45
	print '<p>'.sprintf(_("The statistic below shows the most common aircraft by registration of flights from <strong>%s</strong>."),$manufacturer).'</p>';
46
47
	$aircraft_array = $Spotter->countAllAircraftRegistrationByManufacturer($manufacturer);
48
	if (!empty($aircraft_array))
49
	{
50
		print '<div class="table-responsive">';
51
		print '<table class="common-type table-striped">';
52
		print '<thead>';
53
		print '<th></th>';
54
		print '<th></th>';
55
		print '<th>'._("Registration").'</th>';
56
		print '<th>'._("Aircraft Type").'</th>';
57
		print '<th>'._("# of times").'</th>';
58
		print '<th></th>';
59
		print '</thead>';
60
		print '<tbody>';
61
		$i = 1;
62
		foreach($aircraft_array as $aircraft_item)
63
		{
64
			print '<tr>';
65
			print '<td><strong>'.$i.'</strong></td>';
66
			if ($aircraft_item['image_thumbnail'] != "")
67
			{
68
				print '<td class="aircraft_thumbnail">';
69
				print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'"><img src="'.$aircraft_item['image_thumbnail'].'" class="img-rounded" data-toggle="popover" title="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_icao'].' - '.$aircraft_item['airline_name'].'" alt="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_type'].' - '.$aircraft_item['airline_name'].'" data-content="'._("Registration:").' '.$aircraft_item['registration'].'<br />'._("Aircraft:").' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')<br />'._("Airline:").' '.$aircraft_item['airline_name'].'" data-html="true" width="100px" /></a>';
70
				print '</td>';
71
			} else {
72
				print '<td class="aircraft_thumbnail">';
73
				print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_icao'].' - '.$aircraft_item['airline_name'].'" alt="'.$aircraft_item['registration'].' - '.$aircraft_item['aircraft_type'].' - '.$aircraft_item['airline_name'].'" data-content="'._("Registration:").' '.$aircraft_item['registration'].'<br />'._("Aircraft:").' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')<br />'._("Airline:").' '.$aircraft_item['airline_name'].'" data-html="true" width="100px" /></a>';
74
				print '</td>';
75
			}
76
			print '<td>';
77
			print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'">'.$aircraft_item['registration'].'</a>';
78
			print '</td>';
79
			print '<td>';
80
			print '<a href="'.$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'">'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')</a>';
81
			print '</td>';
82
			print '<td>';
83
			print $aircraft_item['registration_count'];
84
			print '</td>';
85
			print '<td><a href="'.$globalURL.'/search?registration='.$aircraft_item['registration'].'&manufacturer='.$_GET['aircraft_manufacturer'].'">'._("Search flights").'</a></td>';
86
			print '</tr>';
87
			$i++;
88
		}
89
		print '<tbody>';
90
		print '</table>';
91
		print '</div>';
92
	}
93
	print '</div>';
94
} else {
95
	$title = _("Manufacturer");
96
	require_once('header.php');
97
	print '<h1>'._("Error").'</h1>';
98
	print '<p>'._("Sorry, the aircraft manufacturer does not exist in this database. :(").'</p>';
99
}
100
101
require_once('footer.php');
102
?>
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...