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

date-detailed.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
6
if (!isset($_GET['date'])){
7
	header('Location: '.$globalURL.'');
8
} else {
9
	$Spotter = new Spotter();
10
	
11
	//calculuation for the pagination
12 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...
13
	{
14
		$limit_start = 0;
15
		$limit_end = 25;
16
		$absolute_difference = 25;
17
	}  else {
18
		$limit_explode = explode(",", $_GET['limit']);
19
		$limit_start = $limit_explode[0];
20
		$limit_end = $limit_explode[1];
21
		if (!ctype_digit(strval($limit_start)) || !ctype_digit(strval($limit_end))) {
22
			$limit_start = 0;
23
			$limit_end = 25;
24
		}
25
	}
26
	$absolute_difference = abs($limit_start - $limit_end);
27
	$limit_next = $limit_end + $absolute_difference;
28
	$limit_previous_1 = $limit_start - $absolute_difference;
29
	$limit_previous_2 = $limit_end - $absolute_difference;
30
	
31
	$page_url = $globalURL.'/date/'.$_GET['date'];
32
	
33
	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
34 View Code Duplication
	if (isset($_GET['sort'])) 
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...
35
	{
36
		$spotter_array = $Spotter->getSpotterDataByDate($_GET['date'],$limit_start.",".$absolute_difference, $sort);
37
	} else {
38
		$spotter_array = $Spotter->getSpotterDataByDate($_GET['date'],$limit_start.",".$absolute_difference);
39
	}
40
	
41
	
42
	if (!empty($spotter_array))
43
	{
44
		date_default_timezone_set($globalTimezone);
45
		$title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
46
47
		require_once('header.php');
48
		print '<div class="select-item">';
49
		print '<form action="'.$globalURL.'/date" method="post">';
50
		print '<label for="date">'._("Select a Date").'</label>';
51
		print '<input type="text" id="date" name="date" value="'.$_GET['date'].'" size="8" readonly="readonly" class="custom" />';
52
		print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
53
		print '</form>';
54
		print '</div>';
55
56
		print '<div class="info column">';
57
		print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
58
		print '</div>';
59
60
		include('date-sub-menu.php');
61
		print '<div class="table column">';
62
		print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
63
 
64
		include('table-output.php');
65
		print '<div class="pagination">';
66
		if ($limit_previous_1 >= 0)
67
		{
68
			print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'/'.$_GET['sort'].'">&laquo;'._("Previous Page").'</a>';
69
		}
70
		if ($spotter_array[0]['query_number_rows'] == $absolute_difference)
71
		{
72
			print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'/'.$_GET['sort'].'">'._("Next Page").'&raquo;</a>';
73
		}
74
		print '</div>';
75
		print '</div>';
76
	} else {
77
		$title = _("Unknown Date");
78
		require_once('header.php');
79
		print '<h1>'._("Error").'</h1>';
80
		print '<p>'._("Sorry, this date does not exist in this database. :(").'</p>'; 
81
	}
82
}
83
84
require_once('footer.php');
85
?>
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...