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['country'])) { |
||
6 | header('Location: '.$globalURL.'/country'); |
||
7 | die(); |
||
8 | } |
||
9 | $Spotter = new Spotter(); |
||
10 | $country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING))); |
||
11 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
||
12 | View Code Duplication | if (isset($_GET['sort'])) { |
|
1 ignored issue
–
show
|
|||
13 | $spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", $sort); |
||
14 | } else { |
||
15 | $spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", ''); |
||
16 | } |
||
17 | |||
18 | if (!empty($spotter_array)) |
||
19 | { |
||
20 | $title = sprintf(_("Most Common Aircraft by registration from %s"),$country); |
||
21 | require_once('header.php'); |
||
22 | print '<div class="select-item">'; |
||
23 | print '<form action="'.$globalURL.'/country" method="post">'; |
||
24 | print '<select name="country" class="selectpicker" data-live-search="true">'; |
||
25 | print '<option></option>'; |
||
26 | $all_countries = $Spotter->getAllCountries(); |
||
27 | foreach($all_countries as $all_country) |
||
28 | { |
||
29 | if($country == $all_country['country']) |
||
30 | { |
||
31 | print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>'; |
||
32 | } else { |
||
33 | print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'">'.$all_country['country'].'</option>'; |
||
34 | } |
||
35 | } |
||
36 | print '</select>'; |
||
37 | print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>'; |
||
38 | print '</form>'; |
||
39 | print '</div>'; |
||
40 | |||
41 | if ($_GET['country'] != "NA") |
||
42 | { |
||
43 | print '<div class="info column">'; |
||
44 | print '<h1>'.sprintf(_("Airports & Airlines from %s"),$country).'</h1>'; |
||
45 | print '</div>'; |
||
46 | } else { |
||
47 | print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>'; |
||
48 | } |
||
49 | |||
50 | include('country-sub-menu.php'); |
||
51 | print '<div class="column">'; |
||
52 | print '<h2>'._("Most Common Aircraft by Registration").'</h2>'; |
||
53 | print '<p>'.sprintf(_("The statistic below shows the most common aircraft by registration of airlines or departure/arrival airports from <strong>%s</strong>."),$country).'</p>'; |
||
54 | $aircraft_array = $Spotter->countAllAircraftRegistrationByCountry($country); |
||
55 | if (!empty($aircraft_array)) |
||
56 | { |
||
57 | print '<div class="table-responsive">'; |
||
58 | print '<table class="common-type table-striped">'; |
||
59 | print '<thead>'; |
||
60 | print '<th></th>'; |
||
61 | print '<th></th>'; |
||
62 | print '<th>'._("Registration").'</th>'; |
||
63 | print '<th>'._("Aircraft Type").'</th>'; |
||
64 | print '<th>'._("# of times").'</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 | View Code Duplication | if ($aircraft_item['image_thumbnail'] != "") |
|
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. ![]() |
|||
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 | 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>'; |
||
84 | print '</td>'; |
||
85 | } |
||
86 | print '<td>'; |
||
87 | print '<a href="'.$globalURL.'/registration/'.$aircraft_item['registration'].'">'.$aircraft_item['registration'].'</a>'; |
||
88 | print '</td>'; |
||
89 | print '<td>'; |
||
90 | print '<a href="'.$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'">'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')</a>'; |
||
91 | print '</td>'; |
||
92 | print '<td>'; |
||
93 | print $aircraft_item['registration_count']; |
||
94 | print '</td>'; |
||
95 | print '</tr>'; |
||
96 | $i++; |
||
97 | } |
||
98 | print '<tbody>'; |
||
99 | print '</table>'; |
||
100 | print '</div>'; |
||
101 | } |
||
102 | print '</div>'; |
||
103 | } else { |
||
104 | $title = _("Country"); |
||
105 | require_once('header.php'); |
||
106 | print '<h1>'._("Error").'</h1>'; |
||
107 | print '<p>'._("Sorry, the country does not exist in this database. :(").'</p>'; |
||
108 | } |
||
109 | |||
110 | require_once('footer.php'); |
||
111 | ?> |
||
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. ![]() |
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.