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 | $Spotter = new Spotter(); |
||
6 | View Code Duplication | if (isset($_GET['start_date'])) { |
|
1 ignored issue
–
show
|
|||
7 | //for the date manipulation into the query |
||
8 | if($_GET['start_date'] != "" && $_GET['end_date'] != ""){ |
||
9 | $start_date = $_GET['start_date'].":00"; |
||
10 | $end_date = $_GET['end_date'].":00"; |
||
11 | $sql_date = $start_date.",".$end_date; |
||
12 | } else if($_GET['start_date'] != ""){ |
||
13 | $start_date = $_GET['start_date'].":00"; |
||
14 | $sql_date = $start_date; |
||
15 | } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){ |
||
16 | $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00"; |
||
17 | $sql_date = $end_date; |
||
18 | } else $sql_date = ''; |
||
19 | } else $sql_date = ''; |
||
20 | |||
21 | View Code Duplication | if (isset($_GET['highest_altitude'])) { |
|
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. ![]() |
|||
22 | //for altitude manipulation |
||
23 | if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){ |
||
24 | $end_altitude = $_GET['highest_altitude']; |
||
25 | $start_altitude = $_GET['lowest_altitude']; |
||
26 | $sql_altitude = $start_altitude.",".$end_altitude; |
||
27 | } else if($_GET['highest_altitude'] != ""){ |
||
28 | $end_altitude = $_GET['highest_altitude']; |
||
29 | $sql_altitude = $end_altitude; |
||
30 | } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){ |
||
31 | $start_altitude = $_GET['lowest_altitude'].",60000"; |
||
32 | $sql_altitude = $start_altitude; |
||
33 | } else $sql_altitude = ''; |
||
34 | } else $sql_altitude = ''; |
||
35 | |||
36 | //calculuation for the pagination |
||
37 | 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. ![]() |
|||
38 | { |
||
39 | if (!isset($_GET['number_results'])) |
||
40 | { |
||
41 | $limit_start = 0; |
||
42 | $limit_end = 25; |
||
43 | $absolute_difference = 25; |
||
44 | } else { |
||
45 | if ($_GET['number_results'] > 1000){ |
||
46 | $_GET['number_results'] = 1000; |
||
47 | } |
||
48 | $limit_start = 0; |
||
49 | $limit_end = $_GET['number_results']; |
||
50 | $absolute_difference = $_GET['number_results']; |
||
51 | } |
||
52 | } else { |
||
53 | $limit_explode = explode(",", $_GET['limit']); |
||
54 | $limit_start = $limit_explode[0]; |
||
55 | $limit_end = $limit_explode[1]; |
||
56 | } |
||
57 | |||
58 | $absolute_difference = abs($limit_start - $limit_end); |
||
59 | $limit_next = $limit_end + $absolute_difference; |
||
60 | $limit_previous_1 = $limit_start - $absolute_difference; |
||
61 | $limit_previous_2 = $limit_end - $absolute_difference; |
||
62 | |||
63 | if ($_GET['download'] == "true") |
||
64 | { |
||
65 | header('Content-disposition: attachment; filename="flightairmap.txt"'); |
||
66 | } |
||
67 | |||
68 | header("Content-type: text/csv"); |
||
69 | |||
70 | if (isset($_GET['sort'])) $sort = $_GET['sort']; |
||
71 | else $sort = ''; |
||
72 | $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING); |
||
73 | $registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING); |
||
74 | $aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING); |
||
75 | $manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING); |
||
76 | $highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING); |
||
77 | $airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
||
78 | $airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING); |
||
79 | $airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING); |
||
80 | $airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING); |
||
81 | $airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING); |
||
82 | $callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING); |
||
83 | $owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING); |
||
84 | $pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING); |
||
85 | $pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING); |
||
86 | $departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING); |
||
87 | $arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING); |
||
88 | $spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,''); |
||
89 | |||
90 | $i = 1; |
||
91 | //$output .= "oid;Line\n"; |
||
1 ignored issue
–
show
Unused Code
Comprehensibility
introduced
by
43% 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. ![]() |
|||
92 | $output = ''; |
||
93 | if (!empty($spotter_array)) |
||
94 | { |
||
95 | foreach($spotter_array as $spotter_item) |
||
96 | { |
||
97 | if ($spotter_item['waypoints'] != '') { |
||
98 | $waypoint_pieces = explode(' ', $spotter_item['waypoints']); |
||
99 | $waypoint_pieces = array_chunk($waypoint_pieces, 2); |
||
100 | //waypoint plotting |
||
101 | $output .= 'MULTILINESTRING(('; |
||
102 | View Code Duplication | foreach ($waypoint_pieces as $waypoint_coordinate) |
|
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. ![]() |
|||
103 | { |
||
104 | $output .= $waypoint_coordinate[1].' '.$waypoint_coordinate[0].', '; |
||
105 | } |
||
106 | $output = substr($output, 0, -2); |
||
107 | $output .= ")) "; |
||
108 | } |
||
109 | //location of aircraft |
||
110 | $output .= 'MULTIPOINT(('.$spotter_item['longitude'].' '.$spotter_item['latitude'].')) '; |
||
111 | $i++; |
||
112 | } |
||
113 | } |
||
114 | print $output; |
||
115 | |||
116 | ?> |
||
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.