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['aircraft_manufacturer'])) { |
||
6 | header('Location: '.$globalURL.'/manufacturer'); |
||
7 | die(); |
||
8 | } |
||
9 | $Spotter = new Spotter(); |
||
10 | $manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING))); |
||
11 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
||
12 | |||
13 | $spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort); |
||
14 | |||
15 | if (!empty($spotter_array)) |
||
16 | { |
||
17 | $title = sprintf(_("Most Common Routes from %s"),$manufacturer); |
||
18 | |||
19 | require_once('header.php'); |
||
20 | print '<div class="select-item">'; |
||
21 | print '<form action="'.$globalURL.'/manufacturer" method="post">'; |
||
22 | print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">'; |
||
23 | print '<option></option>'; |
||
24 | $all_manufacturers = $Spotter->getAllManufacturers(); |
||
25 | foreach($all_manufacturers as $all_manufacturer) |
||
26 | { |
||
27 | if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer']))) |
||
28 | { |
||
29 | print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>'; |
||
30 | } else { |
||
31 | print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'">'.$all_manufacturer['aircraft_manufacturer'].'</option>'; |
||
32 | } |
||
33 | } |
||
34 | print '</select>'; |
||
35 | print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>'; |
||
36 | print '</form>'; |
||
37 | print '</div>'; |
||
38 | |||
39 | print '<div class="info column">'; |
||
40 | print '<h1>'.$manufacturer.'</h1>'; |
||
41 | print '</div>'; |
||
42 | |||
43 | include('manufacturer-sub-menu.php'); |
||
44 | print '<div class="column">'; |
||
45 | print '<h2>'._("Most Common Routes").'</h2>'; |
||
46 | print '<p>'.sprintf(_("The statistic below shows the most common routes from <strong>%s</strong>."),$manufacturer).'</p>'; |
||
47 | |||
48 | $route_array = $Spotter->countAllRoutesByManufacturer($manufacturer); |
||
49 | View Code Duplication | if (!empty($route_array)) |
|
1 ignored issue
–
show
|
|||
50 | { |
||
51 | print '<div class="table-responsive">'; |
||
52 | print '<table class="common-routes table-striped">'; |
||
53 | print '<thead>'; |
||
54 | print '<th></th>'; |
||
55 | print '<th>'._("Departure Airport").'</th>'; |
||
56 | print '<th>'._("Arrival Airport").'</th>'; |
||
57 | print '<th>'._("# of times").'</th>'; |
||
58 | print '<th></th>'; |
||
59 | print '<th></th>'; |
||
60 | print '</thead>'; |
||
61 | print '<tbody>'; |
||
62 | $i = 1; |
||
63 | foreach($route_array as $route_item) |
||
64 | { |
||
65 | print '<tr>'; |
||
66 | print '<td><strong>'.$i.'</strong></td>'; |
||
67 | print '<td>'; |
||
68 | print '<a href="'.$globalURL.'/airport/'.$route_item['airport_departure_icao'].'">'.$route_item['airport_departure_city'].', '.$route_item['airport_departure_country'].' ('.$route_item['airport_departure_icao'].')</a>'; |
||
69 | print '</td>'; |
||
70 | print '<td>'; |
||
71 | print '<a href="'.$globalURL.'/airport/'.$route_item['airport_arrival_icao'].'">'.$route_item['airport_arrival_city'].', '.$route_item['airport_arrival_country'].' ('.$route_item['airport_arrival_icao'].')</a>'; |
||
72 | print '</td>'; |
||
73 | print '<td>'; |
||
74 | print $route_item['route_count']; |
||
75 | print '</td>'; |
||
76 | print '<td>'; |
||
77 | print '<a href="'.$globalURL.'/search?manufacturer='.$_GET['aircraft_manufacturer'].'&departure_airport_route='.$route_item['airport_departure_icao'].'&arrival_airport_route='.$route_item['airport_arrival_icao'].'">'._("Search Flights").'</a>'; |
||
78 | print '</td>'; |
||
79 | print '<td>'; |
||
80 | print '<a href="'.$globalURL.'/route/'.$route_item['airport_departure_icao'].'/'.$route_item['airport_arrival_icao'].'">'._("Route History").'</a>'; |
||
81 | print '</td>'; |
||
82 | print '</tr>'; |
||
83 | $i++; |
||
84 | } |
||
85 | print '<tbody>'; |
||
86 | print '</table>'; |
||
87 | print '</div>'; |
||
88 | } |
||
89 | print '</div>'; |
||
90 | } else { |
||
91 | $title = _("Manufacturer"); |
||
92 | require_once('header.php'); |
||
93 | print '<h1>'._("Error").'</h1>'; |
||
94 | print '<p>'._("Sorry, the aircraft manufacturer does not exist in this database. :(").'</p>'; |
||
95 | } |
||
96 | |||
97 | require_once('footer.php'); |
||
98 | ?> |
||
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.