-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathsearch-yaml.php
158 lines (151 loc) · 7.12 KB
/
search-yaml.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
require_once('require/class.Connection.php');
require_once('require/class.Spotter.php');
require_once('require/class.Language.php');
$Spotter = new Spotter();
if (isset($_GET['start_date'])) {
//for the date manipulation into the query
if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
$start_date = $_GET['start_date'].":00";
$end_date = $_GET['end_date'].":00";
$sql_date = $start_date.",".$end_date;
} else if($_GET['start_date'] != ""){
$start_date = $_GET['start_date'].":00";
$sql_date = $start_date;
} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00";
$sql_date = $end_date;
} else $sql_date = '';
} else $sql_date = '';
if (isset($_GET['highest_altitude'])) {
//for altitude manipulation
if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT);
$sql_altitude = $start_altitude.",".$end_altitude;
} else if($_GET['highest_altitude'] != ""){
$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
$sql_altitude = $end_altitude;
} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
$sql_altitude = $start_altitude;
} else $sql_altitude = '';
} else $sql_altitude = '';
//calculuation for the pagination
if(!isset($_GET['limit'])) {
if (!isset($_GET['number_results'])) {
$limit_start = 0;
$limit_end = 25;
$absolute_difference = 25;
} else {
if ($_GET['number_results'] > 1000){
$_GET['number_results'] = 1000;
}
$limit_start = 0;
$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
}
} else {
$limit_explode = explode(",", $_GET['limit']);
$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
}
$absolute_difference = abs($limit_start - $limit_end);
$limit_next = $limit_end + $absolute_difference;
$limit_previous_1 = $limit_start - $absolute_difference;
$limit_previous_2 = $limit_end - $absolute_difference;
if ($_GET['download'] == "true")
{
header('Content-disposition: attachment; filename="flightairmap.yaml"');
}
header("Content-type: text/yaml");
if (isset($_GET['sort'])) $sort = $_GET['sort'];
else $sort = '';
$q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
$registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
$aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
$manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING);
$highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING);
$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
$airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING);
$airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING);
$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
$airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING);
$callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING);
$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
$pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING);
$pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING);
$departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING);
$arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING);
$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,'');
$output = "-flights:\n";
if (!empty($spotter_array)) {
foreach($spotter_array as $spotter_item) {
$output .= ' - id: '.$spotter_item['spotter_id'];
$output .= "\n";
$output .= ' - ident: '.$spotter_item['ident'];
$output .= "\n";
$output .= ' - registration: '.$spotter_item['registration'];
$output .= "\n";
$output .= ' - aircraft_icao: '.$spotter_item['aircraft_type'];
$output .= "\n";
$output .= ' - aircraft_name: '.$spotter_item['aircraft_name'];
$output .= "\n";
$output .= ' - aircraft_manufacturer: '.$spotter_item['aircraft_manufacturer'];
$output .= "\n";
$output .= ' - airline_name: '.$spotter_item['airline_name'];
$output .= "\n";
$output .= ' - airline_icao: '.$spotter_item['airline_icao'];
$output .= "\n";
$output .= ' - airline_iata: '.$spotter_item['airline_iata'];
$output .= "\n";
$output .= ' - airline_country: '.$spotter_item['airline_country'];
$output .= "\n";
$output .= ' - airline_callsign: '.$spotter_item['airline_callsign'];
$output .= "\n";
$output .= ' - airline_type: '.$spotter_item['airline_type'];
$output .= "\n";
$output .= ' - departure_airport_city: '.$spotter_item['departure_airport_city'];
$output .= "\n";
$output .= ' - departure_airport_country: '.$spotter_item['departure_airport_country'];
$output .= "\n";
$output .= ' - departure_airport_iata: '.$spotter_item['departure_airport_iata'];
$output .= "\n";
$output .= ' - departure_airport_icao: '.$spotter_item['departure_airport_icao'];
$output .= "\n";
$output .= ' - departure_airport_latitude: '.$spotter_item['departure_airport_latitude'];
$output .= "\n";
$output .= ' - departure_airport_altitude: '.$spotter_item['departure_airport_altitude'];
$output .= "\n";
$output .= ' - arrival_airport_city: '.$spotter_item['arrival_airport_city'];
$output .= "\n";
$output .= ' - arrival_airport_country: '.$spotter_item['arrival_airport_country'];
$output .= "\n";
$output .= ' - arrival_airport_iata: '.$spotter_item['arrival_airport_iata'];
$output .= "\n";
$output .= ' - arrival_airport_icao: '.$spotter_item['arrival_airport_icao'];
$output .= "\n";
$output .= ' - arrival_airport_latitude: '.$spotter_item['arrival_airport_latitude'];
$output .= "\n";
$output .= ' - arrival_airport_altitude: '.$spotter_item['arrival_airport_altitude'];
$output .= "\n";
$output .= ' - latitude: '.$spotter_item['latitude'];
$output .= "\n";
$output .= ' - longitude: '.$spotter_item['longitude'];
$output .= "\n";
$output .= ' - altitude: '.$spotter_item['altitude'];
$output .= "\n";
$output .= ' - ground_speed: '.$spotter_item['ground_speed'];
$output .= "\n";
$output .= ' - heading: '.$spotter_item['heading'];
$output .= "\n";
$output .= ' - heading_name: '.$spotter_item['heading_name'];
$output .= "\n";
$output .= ' - waypoints: '.$spotter_item['waypoints'];
$output .= "\n";
$output .= ' - date: '.date("c", strtotime($spotter_item['date_iso_8601']));
$output .= "\n\n";
}
}
print $output;
?>