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

newest.php (4 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
$Spotter = new Spotter();
6
7
if (isset($_POST['category']))
8
{
9
	header('Location: '.$globalURL.'/newest/'.$_POST['category']);
10
}
11
12
$title = _("Newest");
13
require_once('header.php');
14
15
//calculuation for the pagination
16
if(!isset($_GET['limit']))
17
{
18
  $limit_start = 0;
19
  $limit_end = 25;
20
  $absolute_difference = 25;
21
}  else {
22
	$limit_explode = explode(",", $_GET['limit']);
23
	$limit_start = $limit_explode[0];
24
	$limit_end = $limit_explode[1];
25
}
26
27
$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
28
29
$absolute_difference = abs($limit_start - $limit_end);
30
$limit_next = $limit_end + $absolute_difference;
31
$limit_previous_1 = $limit_start - $absolute_difference;
32
$limit_previous_2 = $limit_end - $absolute_difference;
33
34
if (!isset($_GET['category']))
35
{
36
	$category = "aircraft";
37
} else {
38
	$category = filter_input(INPUT_GET,'category',FILTER_SANITIZE_STRING);
39
}
40
41
$page_url = $globalURL.'/newest/'.$category;
42
43
print '<div class="select-item">';
44
print '<form action="'.$globalURL.'/newest" method="post">';
45
print '<select name="category" class="selectpicker" data-live-search="true">';
46
47
if ($category == "aircraft")
48
{
49
	print '<option value="aircraft" selected="selected">'._("Aircraft Type").'</option>';
50
} else {
51
	print '<option value="aircraft">'._("Aircraft Type").'</option>';
52
}
53
54
if ($category == "registration")
55
{
56
	print '<option value="registration" selected="selected">'._("Aircraft Registration").'</option>';
57
} else {
58
	print '<option value="registration">'._("Aircraft Registration").'</option>';
59
}
60
61
if ($category == "airline")
62
{
63
	print '<option value="airline" selected="selected">'._("Airline").'</option>';
64
} else {
65
	print '<option value="airline">'._("Airline").'</option>';
66
}
67
68
if ($category == "departure_airport")
69
{
70
	print '<option value="departure_airport" selected="selected">'._("Departure Airport").'</option>';
71
} else {
72
	print '<option value="departure_airport">'._("Departure Airport").'</option>';
73
}
74
75
if ($category == "arrival_airport")
76
{
77
	print '<option value="arrival_airport" selected="selected">'._("Arrival Airport").'</option>';
78
} else {
79
	print '<option value="arrival_airport">'._("Arrival Airport").'</option>';
80
}
81
82
print '</select>';
83
84
print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
85
print '</form>';
86
print '</div>';
87
88
print '<div class="info column">';
89 View Code Duplication
if ($category == "aircraft")
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...
90
{
91
	print '<h1>'._("Newest Aircraft Type").'</h1>';
92
} else if ($category == "registration")
93
{
94
	print '<h1>'._("Newest Aircraft Registration").'</h1>';
95
} else if ($category == "airline")
96
{
97
	print '<h1>'._("Newest Airline").'</h1>';
98
} else if ($category == "departure_airport")
99
{
100
	print '<h1>'._("Newest Departure Airport").'</h1>';
101
} else if ($category == "arrival_airport")
102
{
103
	print '<h1>'._("Newest Arrival Airport").'</h1>';
104
}
105
print '</div>';
106
107
print '<div class="table column">';	
108 View Code Duplication
if ($category == "aircraft")
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...
109
{
110
	print '<p>'._("The table below shows the detailed information sorted by the newest recorded aircraft type. Each aircraft type is grouped and is shown only once, the first time it flew nearby.").'</p>';
111
} else if ($category == "registration")
112
{
113
	print '<p>'._("The table below shows the detailed information sorted by the newest recorded aircraft by registration. Each aircraft registration is grouped and is shown only once, the first time it flew nearby.").'</p>';
114
} else if ($category == "airline")
115
{
116
	print '<p>'._("The table below shows the detailed information sorted by the newest recorded airline. Each airline is grouped and is shown only once, the first time it flew nearby.").'</p>';
117
} else if ($category == "departure_airport")
118
{
119
	print '<p>'._("The table below shows the detailed information sorted by the newest recorded departure airport. Each departure airport is grouped and is shown only once, the first time an aircraft flew nearby from the airport.").'</p>';
120
} else if ($category == "arrival_airport")
121
{
122
	print '<p>'._("The table below shows the detailed information sorted by the newest recorded arrival airport. Each arrival airport is grouped and is shown only once, the first time an aircraft flew nearby to the airport.").'</p>';
123
}
124
125
if ($category == "aircraft")
126
{
127
	$spotter_array = $Spotter->getNewestSpotterDataSortedByAircraftType($limit_start.",".$absolute_difference, $sort);
128
} else if ($category == "registration")
129
{
130
	$spotter_array = $Spotter->getNewestSpotterDataSortedByAircraftRegistration($limit_start.",".$absolute_difference, $sort);
131
} else if ($category == "airline")
132
{
133
	$spotter_array = $Spotter->getNewestSpotterDataSortedByAirline($limit_start.",".$absolute_difference, $sort);
134
} else if ($category == "departure_airport")
135
{
136
	$spotter_array = $Spotter->getNewestSpotterDataSortedByDepartureAirport($limit_start.",".$absolute_difference, $sort);
137
} else if ($category == "arrival_airport")
138
{
139
	$spotter_array = $Spotter->getNewestSpotterDataSortedByArrivalAirport($limit_start.",".$absolute_difference, $sort);
140
}
141
 
142 View Code Duplication
if (!empty($spotter_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...
143
{
144
	include('table-output.php');
145
	print '<div class="pagination">';
146
	if ($limit_previous_1 >= 0)
147
	{
148
		print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'/'.$sort.'">&laquo;'._("Previous Page").'</a>';
149
	}
150
	if ($spotter_array[0]['query_number_rows'] == $absolute_difference)
151
	{
152
		print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'/'.$sort.'">'._("Next Page").'&raquo;</a>';
153
	}
154
	print '</div>';
155
	print '</div>';
156
}
157
158
require_once('footer.php');
159
?>
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...