Completed
Push — master ( e7716d...f2edfd )
by Yannick
06:34
created

registration-detailed.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
6
if (!isset($_GET['registration'])){
7
	header('Location: '.$globalURL.'');
8
} else {
9
	$Spotter = new Spotter();
10
	//calculuation for the pagination
11 View Code Duplication
	if(!isset($_GET['limit']))
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
	{
13
		$limit_start = 0;
14
		$limit_end = 25;
15
		$absolute_difference = 25;
16
	}  else {
17
		$limit_explode = explode(",", $_GET['limit']);
18
		$limit_start = $limit_explode[0];
19
		$limit_end = $limit_explode[1];
20
		if (!ctype_digit(strval($limit_start)) || !ctype_digit(strval($limit_end))) {
21
			$limit_start = 0;
22
			$limit_end = 25;
23
		}
24
	}
25
	$absolute_difference = abs($limit_start - $limit_end);
26
	$limit_next = $limit_end + $absolute_difference;
27
	$limit_previous_1 = $limit_start - $absolute_difference;
28
	$limit_previous_2 = $limit_end - $absolute_difference;
29
	$registration = filter_input(INPUT_GET,'registration',FILTER_SANITIZE_STRING);
30
	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
31
	
32
	$page_url = $globalURL.'/registration/'.$registration;
33
	
34
	if (isset($_GET['sort'])) {
35
		$spotter_array = $Spotter->getSpotterDataByRegistration($registration, $limit_start.",".$absolute_difference, $sort);
36
	} else {
37
		$spotter_array = $Spotter->getSpotterDataByRegistration($registration, $limit_start.",".$absolute_difference, '');
38
	}
39
	$aircraft_array = $Spotter->getAircraftInfoByRegistration($registration);
40
	
41
	if (!empty($spotter_array))
42
	{
43
		$title = sprintf(_("Detailed View of aircraft with registration %s"),$registration);
44
		require_once('header.php');
45
		print '<div class="info column">';
46
		print '<h1>'.$registration.' - '.$aircraft_array[0]['aircraft_name'].' ('.$aircraft_array[0]['aircraft_icao'].')</h1>';
47
		print '<div><span class="label">'._("Name").'</span><a href="'.$globalURL.'/aircraft/'.$aircraft_array[0]['aircraft_icao'].'">'.$aircraft_array[0]['aircraft_name'].'</a></div>';
48
		print '<div><span class="label">'._("ICAO").'</span><a href="'.$globalURL.'/aircraft/'.$aircraft_array[0]['aircraft_icao'].'">'.$aircraft_array[0]['aircraft_icao'].'</a></div>'; 
49
		print '<div><span class="label">'._("Manufacturer").'</span><a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $aircraft_array[0]['aircraft_manufacturer'])).'">'.$aircraft_array[0]['aircraft_manufacturer'].'</a></div>';
50
		print '</div>';
51
		
52
		include('registration-sub-menu.php');
53
		print '<div class="table column">';
54
		print '<p>'.sprintf(_("The table below shows the detailed information of all flights of aircraft with the registration <strong>%s</strong>."),$registration).'</p>';
55
56
		include('table-output.php');
57
		print '<div class="pagination">';
58
		if ($limit_previous_1 >= 0)
59
		{
60
			print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'/'.$_GET['sort'].'">&laquo;'._("Previous Page").'</a>';
61
		}
62
		if ($spotter_array[0]['query_number_rows'] == $absolute_difference)
63
		{
64
			print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'/'.$_GET['sort'].'">'._("Next Page").'&raquo;</a>';
65
		}
66
		print '</div>';
67
		print '</div>';
68
	} else {
69
		$title = _("Registration");
70
		require_once('header.php');
71
		print '<h1>'._("Error").'</h1>';
72
		print '<p>'._("Sorry, this registration does not exist in this database. :(").'</p>'; 
73
	}
74
}
75
76
require_once('footer.php');
77
?>
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...