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

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