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

airline.php (8 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
require_once('require/class.Stats.php');
6
7
if (isset($_POST['airline']))
8
{
9
	header('Location: '.$globalURL.'/airline/'.$_POST['airline']);
10
} else {
11
	$title = "Airlines";
12
	require_once('header.php');
13
	$Spotter = new Spotter();
14
	print '<div class="column">';
15
	print '<h1>'._("Airlines").'</h1>';
16
	if (isset($_POST['airline_type'])) {
17
		$airline_type = filter_input(INPUT_POST,'airline_type',FILTER_SANITIZE_STRING);
18
		//$airline_names = $Spotter->getAllAirlineNames($airline_type);
1 ignored issue
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
19
	} else {
20
		//$airline_names = $Spotter->getAllAirlineNames();
1 ignored issue
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
21
		$airline_type = 'all';
22
	}
23
24
	print '<div class="select-item"><form action="'.$globalURL.'/airline" method="post"><select name="airline_type" class="selectpicker" data-live-search="true">';
25
	print '<option value="all"';
26
	if ($airline_type == 'all') print 'selected="selected" ';
27
	print '>'._("All").'</option><option value="passenger"';
28
	if ($airline_type == 'passenger') print 'selected="selected" ';
29
	print '>'._("Passenger").'</option><option value="cargo"';
30
	if ($airline_type == 'cargo') print 'selected="selected" ';
31
	print '>'._("Cargo").'</option><option value="military"';
32
	if ($airline_type == 'military') print 'selected="selected" ';
33
	print '>'._("Military").'</option></select>';
34
	print '<button type="submit"><i class="fa fa-angle-double-right"></i></button></form></div>';
35
36 View Code Duplication
	if (isset($_POST['airline_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...
37
	{
38
		$airline_type = filter_input(INPUT_POST,'airline_type',FILTER_SANITIZE_STRING);
39
		$airline_names = $Spotter->getAllAirlineNames($airline_type);
40
	} else {
41
		$Stats = new Stats();
42
		//$airline_names = $Spotter->getAllAirlineNames();
1 ignored issue
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
43
		$airline_names = $Stats->getAllAirlineNames();
44
		if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames();
45
	}
46
	$previous = null;
47
	print '<div class="alphabet-legend">';
48 View Code Duplication
	foreach($airline_names as $value) 
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...
49
	{
50
		//echo $value['airline_name']."\n";
1 ignored issue
show
Unused Code Comprehensibility introduced by
78% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
51
		//echo mb_substr($value['airline_name'],0,1).' - '.$value['airline_name']."\n";
1 ignored issue
show
Unused Code Comprehensibility introduced by
79% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
52
		$firstLetter = mb_strtoupper(mb_substr($value['airline_name'], 0, 1),'UTF-8');
53
		if($previous !== $firstLetter)
54
		{
55
			if ($previous !== null) print ' | ';
56
			print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>';
57
		}
58
		$previous = $firstLetter;
59
	}
60
	print '</div>';
61
	$previous = null;
62
	foreach($airline_names as $value) {
63
		$firstLetter = strtoupper(substr($value['airline_name'], 0, 1));
64
		if ($firstLetter != "")
65
		{
66
			if($previous !== $firstLetter)
67
			{
68
				if ($previous !== null) print '</div>';
69
				print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">';
70
			}
71
			$previous = $firstLetter;
72
			print '<div class="alphabet-airline alphabet-item">';
73
			print '<a href="'.$globalURL.'/airline/'.$value['airline_icao'].'">';
74
			if (isset($globalIVAO) && $globalIVAO && (@getimagesize('images/airlines/'.$value['airline_icao'].'.gif') || @getimagesize($globalURL.'/images/airlines/'.$value['airline_icao'].'.gif')))
75
			{
76
				print '<img src="'.$globalURL.'/images/airlines/'.$value['airline_icao'].'.gif" alt="'._("Click to see airline activity").'" title="'._("Click to see airline activity").'" /> ';
77
			} elseif (@getimagesize('images/airlines/'.$value['airline_icao'].'.png') || @getimagesize($globalURL.'/images/airlines/'.$value['airline_icao'].'.png'))
78
			{
79
				print '<img src="'.$globalURL.'/images/airlines/'.$value['airline_icao'].'.png" alt="'._("Click to see airline activity").'" title="'._("Click to see airline activity").'" /> ';
80
			} else {
81
				print $value['airline_name'];
82
			}
83
			print '</a>';
84
			print '</div>';
85
		}
86
	}
87
	print '</div>';
88
	require_once('footer.php');
89
}
90
?>
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...