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.Translation.php'); |
||
6 | require_once('require/class.SpotterLive.php'); |
||
7 | require_once('require/class.SpotterArchive.php'); |
||
8 | |||
9 | if (!isset($_GET['ident'])){ |
||
10 | header('Location: '.$globalURL.''); |
||
11 | } else { |
||
12 | $Spotter = new Spotter(); |
||
13 | $SpotterArchive = new SpotterArchive(); |
||
14 | $Translation = new Translation(); |
||
15 | //calculuation for the pagination |
||
16 | View Code Duplication | if(!isset($_GET['limit'])) |
|
1 ignored issue
–
show
|
|||
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 | if (!ctype_digit(strval($limit_start)) || !ctype_digit(strval($limit_end))) { |
||
26 | $limit_start = 0; |
||
27 | $limit_end = 25; |
||
28 | } |
||
29 | } |
||
30 | $absolute_difference = abs($limit_start - $limit_end); |
||
31 | $limit_next = $limit_end + $absolute_difference; |
||
32 | $limit_previous_1 = $limit_start - $absolute_difference; |
||
33 | $limit_previous_2 = $limit_end - $absolute_difference; |
||
34 | |||
35 | $page_url = $globalURL.'/ident/'.$_GET['ident']; |
||
36 | |||
37 | $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
||
38 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
||
39 | 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. ![]() |
|||
40 | { |
||
41 | $spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
||
42 | if (empty($spotter_array)) { |
||
43 | $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
||
44 | } |
||
45 | } else { |
||
46 | $spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference); |
||
47 | if (empty($spotter_array)) { |
||
48 | $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference); |
||
49 | } |
||
50 | } |
||
51 | if (!empty($spotter_array)) { |
||
52 | $new_ident = $Translation->checkTranslation($ident); |
||
53 | if ($new_ident != $ident) { |
||
54 | $ident = $new_ident; |
||
55 | 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. ![]() |
|||
56 | { |
||
57 | $spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
||
58 | if (empty($spotter_array)) { |
||
59 | $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference, $sort); |
||
60 | } |
||
61 | } else { |
||
62 | $spotter_array = $Spotter->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference); |
||
63 | if (empty($spotter_array)) { |
||
64 | $spotter_array = $SpotterArchive->getSpotterDataByIdent($ident,$limit_start.",".$absolute_difference); |
||
65 | } |
||
66 | } |
||
67 | } |
||
68 | } |
||
69 | |||
70 | if (!empty($spotter_array)) |
||
71 | { |
||
72 | $title = sprintf(_("Detailed View for %s"),$spotter_array[0]['ident']); |
||
73 | $ident = $spotter_array[0]['ident']; |
||
74 | if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude']; |
||
75 | if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude']; |
||
76 | require_once('header.php'); |
||
77 | if (isset($globalArchive) && $globalArchive) { |
||
78 | // Requirement for altitude graph |
||
79 | print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>'; |
||
80 | $all_data = $SpotterArchive->getAltitudeSpeedArchiveSpotterDataById($spotter_array[0]['flightaware_id']); |
||
81 | if (isset($globalTimezone)) { |
||
82 | date_default_timezone_set($globalTimezone); |
||
83 | } else date_default_timezone_set('UTC'); |
||
84 | if (count($all_data) > 0) { |
||
85 | print '<div id="chart6" class="chart" width="100%"></div> |
||
86 | <script> |
||
87 | google.load("visualization", "1.1", {packages:["line","corechart"]}); |
||
88 | google.setOnLoadCallback(drawChart6); |
||
89 | function drawChart6() { |
||
90 | var data = google.visualization.arrayToDataTable([ |
||
91 | ["Hour","'._("Altitude").'","'._("Speed").'"], '; |
||
92 | $altitude_data = ''; |
||
93 | View Code Duplication | foreach($all_data as $data) |
|
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. ![]() |
|||
94 | { |
||
95 | $altitude_data .= '[ "'.date("G:i",strtotime($data['date']." UTC")).'",'.$data['altitude'].','.$data['ground_speed'].'],'; |
||
96 | } |
||
97 | $altitude_data = substr($altitude_data, 0, -1); |
||
98 | print $altitude_data.']); |
||
99 | |||
100 | var options = { |
||
101 | legend: {position: "none"}, |
||
102 | series: { |
||
103 | 0: {axis: "Altitude"}, |
||
104 | 1: {axis: "Speed"} |
||
105 | }, |
||
106 | axes: { |
||
107 | y: { |
||
108 | Altitude: {label: "'._("Altitude (FL)").'"}, |
||
109 | Speed: {label: "'._("Speed (knots)").'"}, |
||
110 | } |
||
111 | }, |
||
112 | height:210 |
||
113 | }; |
||
114 | |||
115 | var chart = new google.charts.Line(document.getElementById("chart6")); |
||
116 | chart.draw(data, options); |
||
117 | } |
||
118 | $(window).resize(function(){ |
||
119 | drawChart6(); |
||
120 | }); |
||
121 | </script>'; |
||
122 | } |
||
123 | } |
||
124 | print '<div class="info column">'; |
||
125 | print '<h1>'.$spotter_array[0]['ident'].'</h1>'; |
||
126 | print '<div><span class="label">'._("Ident").'</span>'.$spotter_array[0]['ident'].'</div>'; |
||
127 | if (isset($spotter_array[0]['airline_icao'])) { |
||
128 | print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>'; |
||
129 | } |
||
130 | print '<div><span class="label">'._("Flight History").'</span><a href="http://flightaware.com/live/flight/'.$spotter_array[0]['ident'].'" target="_blank">'._("View the Flight History of this callsign").'</a></div>'; |
||
131 | print '</div>'; |
||
132 | |||
133 | include('ident-sub-menu.php'); |
||
134 | print '<div class="table column">'; |
||
135 | print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the ident/callsign of <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>'; |
||
136 | |||
137 | include('table-output.php'); |
||
138 | print '<div class="pagination">'; |
||
139 | if ($limit_previous_1 >= 0) |
||
140 | { |
||
141 | print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'/'.$_GET['sort'].'">«'._("Previous Page").'</a>'; |
||
142 | } |
||
143 | if ($spotter_array[0]['query_number_rows'] == $absolute_difference) |
||
144 | { |
||
145 | print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'/'.$_GET['sort'].'">'._("Next Page").'»</a>'; |
||
146 | } |
||
147 | print '</div>'; |
||
148 | print '</div>'; |
||
149 | } else { |
||
150 | $title = _("Ident"); |
||
151 | require_once('header.php'); |
||
152 | print '<h1>'._("Error").'</h1>'; |
||
153 | print '<p>'._("Sorry, this ident/callsign is not in the database. :(").'</p>'; |
||
154 | } |
||
155 | } |
||
156 | require_once('footer.php'); |
||
157 | ?> |
||
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.