@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | class update_schema { |
9 | 9 | |
10 | 10 | public static function update_schedule() { |
11 | - $Connection = new Connection(); |
|
12 | - $Schedule = new Schedule(); |
|
13 | - $query = "SELECT * FROM schedule"; |
|
14 | - try { |
|
15 | - $sth = $Connection->db->prepare($query); |
|
11 | + $Connection = new Connection(); |
|
12 | + $Schedule = new Schedule(); |
|
13 | + $query = "SELECT * FROM schedule"; |
|
14 | + try { |
|
15 | + $sth = $Connection->db->prepare($query); |
|
16 | 16 | $sth->execute(); |
17 | - } catch(PDOException $e) { |
|
17 | + } catch(PDOException $e) { |
|
18 | 18 | return "error : ".$e->getMessage()."\n"; |
19 | - } |
|
20 | - while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
22 | - } |
|
19 | + } |
|
20 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
21 | + $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | } |
25 | 25 | /* |
@@ -43,198 +43,198 @@ discard block |
||
43 | 43 | } |
44 | 44 | */ |
45 | 45 | private static function update_from_1() { |
46 | - $Connection = new Connection(); |
|
47 | - // Add new column to routes table |
|
48 | - //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
46 | + $Connection = new Connection(); |
|
47 | + // Add new column to routes table |
|
48 | + //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; |
|
49 | 49 | $query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL"; |
50 | - try { |
|
51 | - $sth = $Connection->db->prepare($query); |
|
52 | - $sth->execute(); |
|
53 | - } catch(PDOException $e) { |
|
54 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
55 | - } |
|
56 | - // Copy schedules data to routes table |
|
57 | - self::update_schedule(); |
|
58 | - // Delete schedule table |
|
50 | + try { |
|
51 | + $sth = $Connection->db->prepare($query); |
|
52 | + $sth->execute(); |
|
53 | + } catch(PDOException $e) { |
|
54 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
55 | + } |
|
56 | + // Copy schedules data to routes table |
|
57 | + self::update_schedule(); |
|
58 | + // Delete schedule table |
|
59 | 59 | $query = "DROP TABLE `schedule`"; |
60 | - try { |
|
61 | - $sth = $Connection->db->prepare($query); |
|
62 | - $sth->execute(); |
|
63 | - } catch(PDOException $e) { |
|
64 | - return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
65 | - } |
|
66 | - // Add source column |
|
67 | - $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
68 | - try { |
|
69 | - $sth = $Connection->db->prepare($query); |
|
70 | - $sth->execute(); |
|
71 | - } catch(PDOException $e) { |
|
72 | - return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
73 | - } |
|
60 | + try { |
|
61 | + $sth = $Connection->db->prepare($query); |
|
62 | + $sth->execute(); |
|
63 | + } catch(PDOException $e) { |
|
64 | + return "error (delete schedule table) : ".$e->getMessage()."\n"; |
|
65 | + } |
|
66 | + // Add source column |
|
67 | + $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; |
|
68 | + try { |
|
69 | + $sth = $Connection->db->prepare($query); |
|
70 | + $sth->execute(); |
|
71 | + } catch(PDOException $e) { |
|
72 | + return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; |
|
73 | + } |
|
74 | 74 | // Delete unused column |
75 | 75 | $query = "ALTER TABLE `aircraft_modes` DROP `SerialNo`, DROP `OperatorFlagCode`, DROP `Manufacturer`, DROP `Type`, DROP `FirstRegDate`, DROP `CurrentRegDate`, DROP `Country`, DROP `PreviousID`, DROP `DeRegDate`, DROP `Status`, DROP `PopularName`, DROP `GenericName`, DROP `AircraftClass`, DROP `Engines`, DROP `OwnershipStatus`, DROP `RegisteredOwners`, DROP `MTOW`, DROP `TotalHours`, DROP `YearBuilt`, DROP `CofACategory`, DROP `CofAExpiry`, DROP `UserNotes`, DROP `Interested`, DROP `UserTag`, DROP `InfoUrl`, DROP `PictureUrl1`, DROP `PictureUrl2`, DROP `PictureUrl3`, DROP `UserBool1`, DROP `UserBool2`, DROP `UserBool3`, DROP `UserBool4`, DROP `UserBool5`, DROP `UserString1`, DROP `UserString2`, DROP `UserString3`, DROP `UserString4`, DROP `UserString5`, DROP `UserInt1`, DROP `UserInt2`, DROP `UserInt3`, DROP `UserInt4`, DROP `UserInt5`"; |
76 | - try { |
|
77 | - $sth = $Connection->db->prepare($query); |
|
78 | - $sth->execute(); |
|
79 | - } catch(PDOException $e) { |
|
80 | - return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
81 | - } |
|
76 | + try { |
|
77 | + $sth = $Connection->db->prepare($query); |
|
78 | + $sth->execute(); |
|
79 | + } catch(PDOException $e) { |
|
80 | + return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; |
|
81 | + } |
|
82 | 82 | // Add ModeS column |
83 | 83 | $query = "ALTER TABLE `spotter_output` ADD `ModeS` VARCHAR(255) NULL"; |
84 | - try { |
|
85 | - $sth = $Connection->db->prepare($query); |
|
86 | - $sth->execute(); |
|
87 | - } catch(PDOException $e) { |
|
88 | - return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
89 | - } |
|
84 | + try { |
|
85 | + $sth = $Connection->db->prepare($query); |
|
86 | + $sth->execute(); |
|
87 | + } catch(PDOException $e) { |
|
88 | + return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; |
|
89 | + } |
|
90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; |
91 | - try { |
|
92 | - $sth = $Connection->db->prepare($query); |
|
93 | - $sth->execute(); |
|
94 | - } catch(PDOException $e) { |
|
95 | - return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
96 | - } |
|
97 | - // Add auto_increment for aircraft_modes |
|
98 | - $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
99 | - try { |
|
100 | - $sth = $Connection->db->prepare($query); |
|
101 | - $sth->execute(); |
|
102 | - } catch(PDOException $e) { |
|
103 | - return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
104 | - } |
|
105 | - $error = ''; |
|
91 | + try { |
|
92 | + $sth = $Connection->db->prepare($query); |
|
93 | + $sth->execute(); |
|
94 | + } catch(PDOException $e) { |
|
95 | + return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; |
|
96 | + } |
|
97 | + // Add auto_increment for aircraft_modes |
|
98 | + $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; |
|
99 | + try { |
|
100 | + $sth = $Connection->db->prepare($query); |
|
101 | + $sth->execute(); |
|
102 | + } catch(PDOException $e) { |
|
103 | + return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; |
|
104 | + } |
|
105 | + $error = ''; |
|
106 | 106 | $error .= create_db::import_file('../db/acars_live.sql'); |
107 | 107 | $error .= create_db::import_file('../db/config.sql'); |
108 | 108 | // Update schema_version to 2 |
109 | 109 | $query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'"; |
110 | - try { |
|
111 | - $sth = $Connection->db->prepare($query); |
|
112 | - $sth->execute(); |
|
113 | - } catch(PDOException $e) { |
|
114 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
115 | - } |
|
110 | + try { |
|
111 | + $sth = $Connection->db->prepare($query); |
|
112 | + $sth->execute(); |
|
113 | + } catch(PDOException $e) { |
|
114 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
115 | + } |
|
116 | 116 | return $error; |
117 | - } |
|
117 | + } |
|
118 | 118 | |
119 | 119 | private static function update_from_2() { |
120 | - $Connection = new Connection(); |
|
121 | - // Add new column decode to acars_live table |
|
120 | + $Connection = new Connection(); |
|
121 | + // Add new column decode to acars_live table |
|
122 | 122 | $query = "ALTER TABLE `acars_live` ADD `decode` TEXT"; |
123 | - try { |
|
124 | - $sth = $Connection->db->prepare($query); |
|
125 | - $sth->execute(); |
|
126 | - } catch(PDOException $e) { |
|
127 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
128 | - } |
|
129 | - $error = ''; |
|
130 | - // Create table acars_archive |
|
123 | + try { |
|
124 | + $sth = $Connection->db->prepare($query); |
|
125 | + $sth->execute(); |
|
126 | + } catch(PDOException $e) { |
|
127 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; |
|
128 | + } |
|
129 | + $error = ''; |
|
130 | + // Create table acars_archive |
|
131 | 131 | $error .= create_db::import_file('../db/acars_archive.sql'); |
132 | 132 | // Update schema_version to 3 |
133 | 133 | $query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'"; |
134 | - try { |
|
135 | - $sth = $Connection->db->prepare($query); |
|
136 | - $sth->execute(); |
|
137 | - } catch(PDOException $e) { |
|
138 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
139 | - } |
|
134 | + try { |
|
135 | + $sth = $Connection->db->prepare($query); |
|
136 | + $sth->execute(); |
|
137 | + } catch(PDOException $e) { |
|
138 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
139 | + } |
|
140 | 140 | return $error; |
141 | 141 | } |
142 | 142 | |
143 | 143 | private static function update_from_3() { |
144 | - $Connection = new Connection(); |
|
145 | - // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
144 | + $Connection = new Connection(); |
|
145 | + // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated |
|
146 | 146 | $query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP"; |
147 | - try { |
|
148 | - $sth = $Connection->db->prepare($query); |
|
149 | - $sth->execute(); |
|
150 | - } catch(PDOException $e) { |
|
151 | - return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
152 | - } |
|
153 | - // Add image_source_website column to spotter_image |
|
147 | + try { |
|
148 | + $sth = $Connection->db->prepare($query); |
|
149 | + $sth->execute(); |
|
150 | + } catch(PDOException $e) { |
|
151 | + return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; |
|
152 | + } |
|
153 | + // Add image_source_website column to spotter_image |
|
154 | 154 | $query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL"; |
155 | - try { |
|
156 | - $sth = $Connection->db->prepare($query); |
|
157 | - $sth->execute(); |
|
158 | - } catch(PDOException $e) { |
|
159 | - return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
160 | - } |
|
161 | - $error = ''; |
|
155 | + try { |
|
156 | + $sth = $Connection->db->prepare($query); |
|
157 | + $sth->execute(); |
|
158 | + } catch(PDOException $e) { |
|
159 | + return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; |
|
160 | + } |
|
161 | + $error = ''; |
|
162 | 162 | // Update schema_version to 4 |
163 | 163 | $query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'"; |
164 | - try { |
|
165 | - $sth = $Connection->db->prepare($query); |
|
166 | - $sth->execute(); |
|
167 | - } catch(PDOException $e) { |
|
168 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
169 | - } |
|
164 | + try { |
|
165 | + $sth = $Connection->db->prepare($query); |
|
166 | + $sth->execute(); |
|
167 | + } catch(PDOException $e) { |
|
168 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
169 | + } |
|
170 | 170 | return $error; |
171 | 171 | } |
172 | 172 | |
173 | 173 | private static function update_from_4() { |
174 | - $Connection = new Connection(); |
|
174 | + $Connection = new Connection(); |
|
175 | 175 | |
176 | - $error = ''; |
|
177 | - // Create table acars_label |
|
176 | + $error = ''; |
|
177 | + // Create table acars_label |
|
178 | 178 | $error .= create_db::import_file('../db/acars_label.sql'); |
179 | 179 | if ($error == '') { |
180 | - // Update schema_version to 5 |
|
181 | - $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
182 | - try { |
|
183 | - $sth = $Connection->db->prepare($query); |
|
180 | + // Update schema_version to 5 |
|
181 | + $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; |
|
182 | + try { |
|
183 | + $sth = $Connection->db->prepare($query); |
|
184 | 184 | $sth->execute(); |
185 | - } catch(PDOException $e) { |
|
185 | + } catch(PDOException $e) { |
|
186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; |
187 | - } |
|
188 | - } |
|
187 | + } |
|
188 | + } |
|
189 | 189 | return $error; |
190 | 190 | } |
191 | 191 | |
192 | 192 | private static function update_from_5() { |
193 | - $Connection = new Connection(); |
|
194 | - // Add columns to translation |
|
193 | + $Connection = new Connection(); |
|
194 | + // Add columns to translation |
|
195 | 195 | $query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;"; |
196 | - try { |
|
197 | - $sth = $Connection->db->prepare($query); |
|
198 | - $sth->execute(); |
|
199 | - } catch(PDOException $e) { |
|
200 | - return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
201 | - } |
|
202 | - // Add aircraft_shadow column to aircraft |
|
203 | - $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
204 | - try { |
|
205 | - $sth = $Connection->db->prepare($query); |
|
206 | - $sth->execute(); |
|
207 | - } catch(PDOException $e) { |
|
208 | - return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
209 | - } |
|
210 | - // Add aircraft_shadow column to spotter_live |
|
211 | - $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
212 | - try { |
|
213 | - $sth = $Connection->db->prepare($query); |
|
214 | - $sth->execute(); |
|
215 | - } catch(PDOException $e) { |
|
216 | - return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
217 | - } |
|
218 | - $error = ''; |
|
219 | - // Update table aircraft |
|
196 | + try { |
|
197 | + $sth = $Connection->db->prepare($query); |
|
198 | + $sth->execute(); |
|
199 | + } catch(PDOException $e) { |
|
200 | + return "error (add new columns to translation) : ".$e->getMessage()."\n"; |
|
201 | + } |
|
202 | + // Add aircraft_shadow column to aircraft |
|
203 | + $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
204 | + try { |
|
205 | + $sth = $Connection->db->prepare($query); |
|
206 | + $sth->execute(); |
|
207 | + } catch(PDOException $e) { |
|
208 | + return "error (add new column to aircraft) : ".$e->getMessage()."\n"; |
|
209 | + } |
|
210 | + // Add aircraft_shadow column to spotter_live |
|
211 | + $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; |
|
212 | + try { |
|
213 | + $sth = $Connection->db->prepare($query); |
|
214 | + $sth->execute(); |
|
215 | + } catch(PDOException $e) { |
|
216 | + return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; |
|
217 | + } |
|
218 | + $error = ''; |
|
219 | + // Update table aircraft |
|
220 | 220 | $error .= create_db::import_file('../db/aircraft.sql'); |
221 | 221 | $error .= create_db::import_file('../db/spotter_archive.sql'); |
222 | 222 | |
223 | 223 | // Update schema_version to 6 |
224 | 224 | $query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'"; |
225 | - try { |
|
226 | - $sth = $Connection->db->prepare($query); |
|
227 | - $sth->execute(); |
|
228 | - } catch(PDOException $e) { |
|
229 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
230 | - } |
|
225 | + try { |
|
226 | + $sth = $Connection->db->prepare($query); |
|
227 | + $sth->execute(); |
|
228 | + } catch(PDOException $e) { |
|
229 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
230 | + } |
|
231 | 231 | return $error; |
232 | 232 | } |
233 | 233 | |
234 | 234 | private static function update_from_6() { |
235 | - $Connection = new Connection(); |
|
236 | - if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
237 | - $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
235 | + $Connection = new Connection(); |
|
236 | + if (!$Connection->indexExists('spotter_output','flightaware_id')) { |
|
237 | + $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); |
|
238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); |
239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); |
240 | 240 | ALTER TABLE spotter_live ADD INDEX(flightaware_id); |
@@ -247,147 +247,147 @@ discard block |
||
247 | 247 | ALTER TABLE aircraft ADD INDEX(icao); |
248 | 248 | ALTER TABLE airport ADD INDEX(icao); |
249 | 249 | ALTER TABLE translation ADD INDEX(Operator);"; |
250 | - try { |
|
251 | - $sth = $Connection->db->prepare($query); |
|
250 | + try { |
|
251 | + $sth = $Connection->db->prepare($query); |
|
252 | 252 | $sth->execute(); |
253 | - } catch(PDOException $e) { |
|
253 | + } catch(PDOException $e) { |
|
254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; |
255 | - } |
|
256 | - } |
|
257 | - $error = ''; |
|
258 | - // Update table countries |
|
259 | - if ($Connection->tableExists('airspace')) { |
|
260 | - $error .= update_db::update_countries(); |
|
261 | - if ($error != '') return $error; |
|
255 | + } |
|
256 | + } |
|
257 | + $error = ''; |
|
258 | + // Update table countries |
|
259 | + if ($Connection->tableExists('airspace')) { |
|
260 | + $error .= update_db::update_countries(); |
|
261 | + if ($error != '') return $error; |
|
262 | 262 | } |
263 | 263 | // Update schema_version to 7 |
264 | 264 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; |
265 | - try { |
|
266 | - $sth = $Connection->db->prepare($query); |
|
267 | - $sth->execute(); |
|
268 | - } catch(PDOException $e) { |
|
269 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
270 | - } |
|
265 | + try { |
|
266 | + $sth = $Connection->db->prepare($query); |
|
267 | + $sth->execute(); |
|
268 | + } catch(PDOException $e) { |
|
269 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
270 | + } |
|
271 | 271 | return $error; |
272 | - } |
|
272 | + } |
|
273 | 273 | |
274 | 274 | private static function update_from_7() { |
275 | 275 | global $globalDBname, $globalDBdriver; |
276 | - $Connection = new Connection(); |
|
277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
276 | + $Connection = new Connection(); |
|
277 | + $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
|
278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; |
279 | - try { |
|
280 | - $sth = $Connection->db->prepare($query); |
|
281 | - $sth->execute(); |
|
282 | - } catch(PDOException $e) { |
|
283 | - return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
284 | - } |
|
285 | - if ($globalDBdriver == 'mysql') { |
|
286 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
287 | - try { |
|
288 | - $sth = $Connection->db->prepare($query); |
|
289 | - $sth->execute(); |
|
290 | - } catch(PDOException $e) { |
|
279 | + try { |
|
280 | + $sth = $Connection->db->prepare($query); |
|
281 | + $sth->execute(); |
|
282 | + } catch(PDOException $e) { |
|
283 | + return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
284 | + } |
|
285 | + if ($globalDBdriver == 'mysql') { |
|
286 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
287 | + try { |
|
288 | + $sth = $Connection->db->prepare($query); |
|
289 | + $sth->execute(); |
|
290 | + } catch(PDOException $e) { |
|
291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
292 | - } |
|
293 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
294 | - if ($row['engine'] == 'ARCHIVE') { |
|
292 | + } |
|
293 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
294 | + if ($row['engine'] == 'ARCHIVE') { |
|
295 | 295 | $query = "CREATE TABLE copy LIKE spotter_archive; |
296 | 296 | ALTER TABLE copy ENGINE=ARCHIVE; |
297 | 297 | ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; |
298 | 298 | INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`; |
299 | 299 | DROP TABLE spotter_archive; |
300 | 300 | RENAME TABLE copy TO spotter_archive;"; |
301 | - } else { |
|
302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | - } |
|
304 | - } else { |
|
305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | - } |
|
307 | - try { |
|
308 | - $sth = $Connection->db->prepare($query); |
|
309 | - $sth->execute(); |
|
310 | - } catch(PDOException $e) { |
|
311 | - return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
312 | - } |
|
301 | + } else { |
|
302 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
303 | + } |
|
304 | + } else { |
|
305 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; |
|
306 | + } |
|
307 | + try { |
|
308 | + $sth = $Connection->db->prepare($query); |
|
309 | + $sth->execute(); |
|
310 | + } catch(PDOException $e) { |
|
311 | + return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; |
|
312 | + } |
|
313 | 313 | |
314 | - $error = ''; |
|
315 | - // Update table aircraft |
|
314 | + $error = ''; |
|
315 | + // Update table aircraft |
|
316 | 316 | $error .= create_db::import_file('../db/source_location.sql'); |
317 | 317 | if ($error != '') return $error; |
318 | 318 | // Update schema_version to 6 |
319 | 319 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; |
320 | - try { |
|
321 | - $sth = $Connection->db->prepare($query); |
|
322 | - $sth->execute(); |
|
323 | - } catch(PDOException $e) { |
|
324 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
325 | - } |
|
320 | + try { |
|
321 | + $sth = $Connection->db->prepare($query); |
|
322 | + $sth->execute(); |
|
323 | + } catch(PDOException $e) { |
|
324 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
325 | + } |
|
326 | 326 | return $error; |
327 | 327 | } |
328 | 328 | |
329 | 329 | private static function update_from_8() { |
330 | - $Connection = new Connection(); |
|
331 | - $error = ''; |
|
332 | - // Update table aircraft |
|
330 | + $Connection = new Connection(); |
|
331 | + $error = ''; |
|
332 | + // Update table aircraft |
|
333 | 333 | $error .= create_db::import_file('../db/notam.sql'); |
334 | 334 | if ($error != '') return $error; |
335 | 335 | $query = "DELETE FROM config WHERE name = 'last_update_db'; |
336 | 336 | INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); |
337 | 337 | DELETE FROM config WHERE name = 'last_update_notam_db'; |
338 | 338 | INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());"; |
339 | - try { |
|
340 | - $sth = $Connection->db->prepare($query); |
|
341 | - $sth->execute(); |
|
342 | - } catch(PDOException $e) { |
|
343 | - return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
344 | - } |
|
339 | + try { |
|
340 | + $sth = $Connection->db->prepare($query); |
|
341 | + $sth->execute(); |
|
342 | + } catch(PDOException $e) { |
|
343 | + return "error (insert last_update values) : ".$e->getMessage()."\n"; |
|
344 | + } |
|
345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; |
346 | - try { |
|
347 | - $sth = $Connection->db->prepare($query); |
|
348 | - $sth->execute(); |
|
349 | - } catch(PDOException $e) { |
|
350 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
351 | - } |
|
346 | + try { |
|
347 | + $sth = $Connection->db->prepare($query); |
|
348 | + $sth->execute(); |
|
349 | + } catch(PDOException $e) { |
|
350 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
351 | + } |
|
352 | 352 | return $error; |
353 | 353 | } |
354 | 354 | |
355 | 355 | private static function update_from_9() { |
356 | - $Connection = new Connection(); |
|
357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
356 | + $Connection = new Connection(); |
|
357 | + $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; |
|
358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; |
359 | - try { |
|
360 | - $sth = $Connection->db->prepare($query); |
|
361 | - $sth->execute(); |
|
362 | - } catch(PDOException $e) { |
|
363 | - return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
364 | - } |
|
359 | + try { |
|
360 | + $sth = $Connection->db->prepare($query); |
|
361 | + $sth->execute(); |
|
362 | + } catch(PDOException $e) { |
|
363 | + return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; |
|
364 | + } |
|
365 | 365 | $error = ''; |
366 | - // Update table atc |
|
366 | + // Update table atc |
|
367 | 367 | $error .= create_db::import_file('../db/atc.sql'); |
368 | 368 | if ($error != '') return $error; |
369 | 369 | |
370 | 370 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; |
371 | - try { |
|
372 | - $sth = $Connection->db->prepare($query); |
|
373 | - $sth->execute(); |
|
374 | - } catch(PDOException $e) { |
|
375 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
376 | - } |
|
371 | + try { |
|
372 | + $sth = $Connection->db->prepare($query); |
|
373 | + $sth->execute(); |
|
374 | + } catch(PDOException $e) { |
|
375 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
376 | + } |
|
377 | 377 | return $error; |
378 | 378 | } |
379 | 379 | |
380 | 380 | private static function update_from_10() { |
381 | - $Connection = new Connection(); |
|
382 | - $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | - try { |
|
384 | - $sth = $Connection->db->prepare($query); |
|
385 | - $sth->execute(); |
|
386 | - } catch(PDOException $e) { |
|
387 | - return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
388 | - } |
|
381 | + $Connection = new Connection(); |
|
382 | + $query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; |
|
383 | + try { |
|
384 | + $sth = $Connection->db->prepare($query); |
|
385 | + $sth->execute(); |
|
386 | + } catch(PDOException $e) { |
|
387 | + return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; |
|
388 | + } |
|
389 | 389 | $error = ''; |
390 | - // Add tables |
|
390 | + // Add tables |
|
391 | 391 | $error .= create_db::import_file('../db/aircraft_owner.sql'); |
392 | 392 | if ($error != '') return $error; |
393 | 393 | $error .= create_db::import_file('../db/metar.sql'); |
@@ -398,76 +398,76 @@ discard block |
||
398 | 398 | if ($error != '') return $error; |
399 | 399 | |
400 | 400 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; |
401 | - try { |
|
402 | - $sth = $Connection->db->prepare($query); |
|
403 | - $sth->execute(); |
|
404 | - } catch(PDOException $e) { |
|
405 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
406 | - } |
|
401 | + try { |
|
402 | + $sth = $Connection->db->prepare($query); |
|
403 | + $sth->execute(); |
|
404 | + } catch(PDOException $e) { |
|
405 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
406 | + } |
|
407 | 407 | return $error; |
408 | 408 | } |
409 | 409 | |
410 | 410 | private static function update_from_11() { |
411 | 411 | global $globalDBdriver, $globalDBname; |
412 | - $Connection = new Connection(); |
|
413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | - try { |
|
415 | - $sth = $Connection->db->prepare($query); |
|
416 | - $sth->execute(); |
|
417 | - } catch(PDOException $e) { |
|
418 | - return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
419 | - } |
|
420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | - try { |
|
422 | - $sth = $Connection->db->prepare($query); |
|
423 | - $sth->execute(); |
|
424 | - } catch(PDOException $e) { |
|
425 | - return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
426 | - } |
|
427 | - if ($globalDBdriver == 'mysql') { |
|
428 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
429 | - try { |
|
430 | - $sth = $Connection->db->prepare($query); |
|
431 | - $sth->execute(); |
|
432 | - } catch(PDOException $e) { |
|
412 | + $Connection = new Connection(); |
|
413 | + $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; |
|
414 | + try { |
|
415 | + $sth = $Connection->db->prepare($query); |
|
416 | + $sth->execute(); |
|
417 | + } catch(PDOException $e) { |
|
418 | + return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; |
|
419 | + } |
|
420 | + $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
421 | + try { |
|
422 | + $sth = $Connection->db->prepare($query); |
|
423 | + $sth->execute(); |
|
424 | + } catch(PDOException $e) { |
|
425 | + return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; |
|
426 | + } |
|
427 | + if ($globalDBdriver == 'mysql') { |
|
428 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; |
|
429 | + try { |
|
430 | + $sth = $Connection->db->prepare($query); |
|
431 | + $sth->execute(); |
|
432 | + } catch(PDOException $e) { |
|
433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; |
434 | - } |
|
435 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
436 | - if ($row['engine'] == 'ARCHIVE') { |
|
434 | + } |
|
435 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
436 | + if ($row['engine'] == 'ARCHIVE') { |
|
437 | 437 | $query = "CREATE TABLE copy LIKE spotter_archive; |
438 | 438 | ALTER TABLE copy ENGINE=ARCHIVE; |
439 | 439 | ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE; |
440 | 440 | INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`; |
441 | 441 | DROP TABLE spotter_archive; |
442 | 442 | RENAME TABLE copy TO spotter_archive;"; |
443 | - } else { |
|
444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | - } |
|
446 | - } else { |
|
447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | - } |
|
449 | - try { |
|
450 | - $sth = $Connection->db->prepare($query); |
|
451 | - $sth->execute(); |
|
452 | - } catch(PDOException $e) { |
|
453 | - return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
454 | - } |
|
443 | + } else { |
|
444 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
445 | + } |
|
446 | + } else { |
|
447 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; |
|
448 | + } |
|
449 | + try { |
|
450 | + $sth = $Connection->db->prepare($query); |
|
451 | + $sth->execute(); |
|
452 | + } catch(PDOException $e) { |
|
453 | + return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; |
|
454 | + } |
|
455 | 455 | |
456 | 456 | $error = ''; |
457 | 457 | |
458 | 458 | $query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'"; |
459 | - try { |
|
460 | - $sth = $Connection->db->prepare($query); |
|
461 | - $sth->execute(); |
|
462 | - } catch(PDOException $e) { |
|
463 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
464 | - } |
|
459 | + try { |
|
460 | + $sth = $Connection->db->prepare($query); |
|
461 | + $sth->execute(); |
|
462 | + } catch(PDOException $e) { |
|
463 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
464 | + } |
|
465 | 465 | return $error; |
466 | 466 | } |
467 | 467 | private static function update_from_12() { |
468 | - $Connection = new Connection(); |
|
468 | + $Connection = new Connection(); |
|
469 | 469 | $error = ''; |
470 | - // Add tables |
|
470 | + // Add tables |
|
471 | 471 | $error .= create_db::import_file('../db/stats.sql'); |
472 | 472 | if ($error != '') return $error; |
473 | 473 | $error .= create_db::import_file('../db/stats_aircraft.sql'); |
@@ -484,166 +484,166 @@ discard block |
||
484 | 484 | if ($error != '') return $error; |
485 | 485 | |
486 | 486 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; |
487 | - try { |
|
488 | - $sth = $Connection->db->prepare($query); |
|
489 | - $sth->execute(); |
|
490 | - } catch(PDOException $e) { |
|
491 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
492 | - } |
|
487 | + try { |
|
488 | + $sth = $Connection->db->prepare($query); |
|
489 | + $sth->execute(); |
|
490 | + } catch(PDOException $e) { |
|
491 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
492 | + } |
|
493 | 493 | return $error; |
494 | 494 | } |
495 | 495 | |
496 | 496 | private static function update_from_13() { |
497 | - $Connection = new Connection(); |
|
498 | - if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
497 | + $Connection = new Connection(); |
|
498 | + if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { |
|
499 | + $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; |
|
500 | 500 | try { |
501 | 501 | $sth = $Connection->db->prepare($query); |
502 | 502 | $sth->execute(); |
503 | - } catch(PDOException $e) { |
|
503 | + } catch(PDOException $e) { |
|
504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; |
505 | - } |
|
505 | + } |
|
506 | 506 | } |
507 | - $error = ''; |
|
507 | + $error = ''; |
|
508 | 508 | $query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'"; |
509 | - try { |
|
510 | - $sth = $Connection->db->prepare($query); |
|
511 | - $sth->execute(); |
|
512 | - } catch(PDOException $e) { |
|
513 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
514 | - } |
|
509 | + try { |
|
510 | + $sth = $Connection->db->prepare($query); |
|
511 | + $sth->execute(); |
|
512 | + } catch(PDOException $e) { |
|
513 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
514 | + } |
|
515 | 515 | return $error; |
516 | 516 | } |
517 | 517 | |
518 | 518 | private static function update_from_14() { |
519 | - $Connection = new Connection(); |
|
519 | + $Connection = new Connection(); |
|
520 | 520 | $error = ''; |
521 | - // Add tables |
|
522 | - if (!$Connection->tableExists('stats_flight')) { |
|
521 | + // Add tables |
|
522 | + if (!$Connection->tableExists('stats_flight')) { |
|
523 | 523 | $error .= create_db::import_file('../db/stats_flight.sql'); |
524 | 524 | if ($error != '') return $error; |
525 | 525 | } |
526 | 526 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; |
527 | - try { |
|
528 | - $sth = $Connection->db->prepare($query); |
|
529 | - $sth->execute(); |
|
530 | - } catch(PDOException $e) { |
|
531 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
532 | - } |
|
527 | + try { |
|
528 | + $sth = $Connection->db->prepare($query); |
|
529 | + $sth->execute(); |
|
530 | + } catch(PDOException $e) { |
|
531 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
532 | + } |
|
533 | 533 | return $error; |
534 | 534 | } |
535 | 535 | |
536 | 536 | |
537 | 537 | private static function update_from_15() { |
538 | - $Connection = new Connection(); |
|
538 | + $Connection = new Connection(); |
|
539 | 539 | $error = ''; |
540 | - // Add tables |
|
541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | - try { |
|
543 | - $sth = $Connection->db->prepare($query); |
|
544 | - $sth->execute(); |
|
545 | - } catch(PDOException $e) { |
|
546 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
547 | - } |
|
540 | + // Add tables |
|
541 | + $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; |
|
542 | + try { |
|
543 | + $sth = $Connection->db->prepare($query); |
|
544 | + $sth->execute(); |
|
545 | + } catch(PDOException $e) { |
|
546 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
547 | + } |
|
548 | 548 | if ($error != '') return $error; |
549 | 549 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; |
550 | - try { |
|
551 | - $sth = $Connection->db->prepare($query); |
|
552 | - $sth->execute(); |
|
553 | - } catch(PDOException $e) { |
|
554 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
555 | - } |
|
550 | + try { |
|
551 | + $sth = $Connection->db->prepare($query); |
|
552 | + $sth->execute(); |
|
553 | + } catch(PDOException $e) { |
|
554 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
555 | + } |
|
556 | 556 | return $error; |
557 | 557 | } |
558 | 558 | |
559 | 559 | private static function update_from_16() { |
560 | - $Connection = new Connection(); |
|
560 | + $Connection = new Connection(); |
|
561 | 561 | $error = ''; |
562 | - // Add tables |
|
563 | - if (!$Connection->tableExists('stats_registration')) { |
|
562 | + // Add tables |
|
563 | + if (!$Connection->tableExists('stats_registration')) { |
|
564 | 564 | $error .= create_db::import_file('../db/stats_registration.sql'); |
565 | 565 | } |
566 | - if (!$Connection->tableExists('stats_callsign')) { |
|
566 | + if (!$Connection->tableExists('stats_callsign')) { |
|
567 | 567 | $error .= create_db::import_file('../db/stats_callsign.sql'); |
568 | 568 | } |
569 | 569 | if ($error != '') return $error; |
570 | 570 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; |
571 | - try { |
|
572 | - $sth = $Connection->db->prepare($query); |
|
573 | - $sth->execute(); |
|
574 | - } catch(PDOException $e) { |
|
575 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
576 | - } |
|
571 | + try { |
|
572 | + $sth = $Connection->db->prepare($query); |
|
573 | + $sth->execute(); |
|
574 | + } catch(PDOException $e) { |
|
575 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
576 | + } |
|
577 | 577 | return $error; |
578 | 578 | } |
579 | 579 | |
580 | 580 | private static function update_from_17() { |
581 | - $Connection = new Connection(); |
|
581 | + $Connection = new Connection(); |
|
582 | 582 | $error = ''; |
583 | - // Add tables |
|
584 | - if (!$Connection->tableExists('stats_country')) { |
|
583 | + // Add tables |
|
584 | + if (!$Connection->tableExists('stats_country')) { |
|
585 | 585 | $error .= create_db::import_file('../db/stats_country.sql'); |
586 | 586 | } |
587 | 587 | if ($error != '') return $error; |
588 | 588 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; |
589 | - try { |
|
590 | - $sth = $Connection->db->prepare($query); |
|
591 | - $sth->execute(); |
|
592 | - } catch(PDOException $e) { |
|
593 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
594 | - } |
|
589 | + try { |
|
590 | + $sth = $Connection->db->prepare($query); |
|
591 | + $sth->execute(); |
|
592 | + } catch(PDOException $e) { |
|
593 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
594 | + } |
|
595 | 595 | return $error; |
596 | 596 | } |
597 | 597 | private static function update_from_18() { |
598 | - $Connection = new Connection(); |
|
598 | + $Connection = new Connection(); |
|
599 | 599 | $error = ''; |
600 | - // Modify stats_airport table |
|
601 | - if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
602 | - $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
603 | - try { |
|
604 | - $sth = $Connection->db->prepare($query); |
|
605 | - $sth->execute(); |
|
606 | - } catch(PDOException $e) { |
|
607 | - return "error (update stats) : ".$e->getMessage()."\n"; |
|
608 | - } |
|
609 | - } |
|
600 | + // Modify stats_airport table |
|
601 | + if (!$Connection->checkColumnName('stats_airport','airport_name')) { |
|
602 | + $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; |
|
603 | + try { |
|
604 | + $sth = $Connection->db->prepare($query); |
|
605 | + $sth->execute(); |
|
606 | + } catch(PDOException $e) { |
|
607 | + return "error (update stats) : ".$e->getMessage()."\n"; |
|
608 | + } |
|
609 | + } |
|
610 | 610 | if ($error != '') return $error; |
611 | 611 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; |
612 | - try { |
|
613 | - $sth = $Connection->db->prepare($query); |
|
614 | - $sth->execute(); |
|
615 | - } catch(PDOException $e) { |
|
616 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
617 | - } |
|
612 | + try { |
|
613 | + $sth = $Connection->db->prepare($query); |
|
614 | + $sth->execute(); |
|
615 | + } catch(PDOException $e) { |
|
616 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
617 | + } |
|
618 | 618 | return $error; |
619 | 619 | } |
620 | 620 | |
621 | 621 | private static function update_from_19() { |
622 | - $Connection = new Connection(); |
|
622 | + $Connection = new Connection(); |
|
623 | 623 | $error = ''; |
624 | - // Update airport table |
|
624 | + // Update airport table |
|
625 | 625 | $error .= create_db::import_file('../db/airport.sql'); |
626 | 626 | if ($error != '') return 'Import airport.sql : '.$error; |
627 | 627 | // Remove primary key on Spotter_Archive |
628 | 628 | $query = "alter table spotter_archive drop spotter_archive_id"; |
629 | - try { |
|
630 | - $sth = $Connection->db->prepare($query); |
|
631 | - $sth->execute(); |
|
632 | - } catch(PDOException $e) { |
|
633 | - return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
634 | - } |
|
629 | + try { |
|
630 | + $sth = $Connection->db->prepare($query); |
|
631 | + $sth->execute(); |
|
632 | + } catch(PDOException $e) { |
|
633 | + return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; |
|
634 | + } |
|
635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; |
636 | - try { |
|
637 | - $sth = $Connection->db->prepare($query); |
|
638 | - $sth->execute(); |
|
639 | - } catch(PDOException $e) { |
|
640 | - return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
641 | - } |
|
636 | + try { |
|
637 | + $sth = $Connection->db->prepare($query); |
|
638 | + $sth->execute(); |
|
639 | + } catch(PDOException $e) { |
|
640 | + return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; |
|
641 | + } |
|
642 | 642 | if (!$Connection->checkColumnName('spotter_archive','over_country')) { |
643 | 643 | // Add column over_country |
644 | - $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
644 | + $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
645 | 645 | try { |
646 | - $sth = $Connection->db->prepare($query); |
|
646 | + $sth = $Connection->db->prepare($query); |
|
647 | 647 | $sth->execute(); |
648 | 648 | } catch(PDOException $e) { |
649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -651,9 +651,9 @@ discard block |
||
651 | 651 | } |
652 | 652 | if (!$Connection->checkColumnName('spotter_live','over_country')) { |
653 | 653 | // Add column over_country |
654 | - $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
654 | + $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; |
|
655 | 655 | try { |
656 | - $sth = $Connection->db->prepare($query); |
|
656 | + $sth = $Connection->db->prepare($query); |
|
657 | 657 | $sth->execute(); |
658 | 658 | } catch(PDOException $e) { |
659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; |
@@ -661,74 +661,74 @@ discard block |
||
661 | 661 | } |
662 | 662 | if (!$Connection->checkColumnName('spotter_output','source_name')) { |
663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
664 | - $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
664 | + $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
665 | 665 | try { |
666 | 666 | $sth = $Connection->db->prepare($query); |
667 | 667 | $sth->execute(); |
668 | 668 | } catch(PDOException $e) { |
669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
670 | - } |
|
671 | - } |
|
670 | + } |
|
671 | + } |
|
672 | 672 | if (!$Connection->checkColumnName('spotter_live','source_name')) { |
673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
674 | - $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
674 | + $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
675 | 675 | try { |
676 | 676 | $sth = $Connection->db->prepare($query); |
677 | 677 | $sth->execute(); |
678 | 678 | } catch(PDOException $e) { |
679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
680 | - } |
|
681 | - } |
|
680 | + } |
|
681 | + } |
|
682 | 682 | if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { |
683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
684 | - $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
684 | + $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; |
|
685 | 685 | try { |
686 | 686 | $sth = $Connection->db->prepare($query); |
687 | 687 | $sth->execute(); |
688 | 688 | } catch(PDOException $e) { |
689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
690 | - } |
|
691 | - } |
|
690 | + } |
|
691 | + } |
|
692 | 692 | if (!$Connection->checkColumnName('spotter_archive','source_name')) { |
693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output |
694 | - $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
694 | + $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; |
|
695 | 695 | try { |
696 | 696 | $sth = $Connection->db->prepare($query); |
697 | 697 | $sth->execute(); |
698 | 698 | } catch(PDOException $e) { |
699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; |
700 | - } |
|
701 | - } |
|
700 | + } |
|
701 | + } |
|
702 | 702 | if ($error != '') return $error; |
703 | 703 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; |
704 | - try { |
|
705 | - $sth = $Connection->db->prepare($query); |
|
706 | - $sth->execute(); |
|
707 | - } catch(PDOException $e) { |
|
708 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
709 | - } |
|
704 | + try { |
|
705 | + $sth = $Connection->db->prepare($query); |
|
706 | + $sth->execute(); |
|
707 | + } catch(PDOException $e) { |
|
708 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
709 | + } |
|
710 | 710 | return $error; |
711 | 711 | } |
712 | 712 | |
713 | 713 | private static function update_from_20() { |
714 | 714 | global $globalIVAO, $globalVATSIM, $globalphpVMS; |
715 | - $Connection = new Connection(); |
|
715 | + $Connection = new Connection(); |
|
716 | 716 | $error = ''; |
717 | - // Update airline table |
|
718 | - if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
717 | + // Update airline table |
|
718 | + if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
|
719 | 719 | $error .= create_db::import_file('../db/airlines.sql'); |
720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; |
721 | 721 | } |
722 | 722 | if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { |
723 | 723 | // Add column over_country |
724 | - $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
725 | - try { |
|
724 | + $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; |
|
725 | + try { |
|
726 | 726 | $sth = $Connection->db->prepare($query); |
727 | 727 | $sth->execute(); |
728 | 728 | } catch(PDOException $e) { |
729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; |
730 | - } |
|
731 | - } |
|
730 | + } |
|
731 | + } |
|
732 | 732 | if ($error != '') return $error; |
733 | 733 | /* |
734 | 734 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { |
@@ -738,12 +738,12 @@ discard block |
||
738 | 738 | } |
739 | 739 | */ |
740 | 740 | $query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'"; |
741 | - try { |
|
742 | - $sth = $Connection->db->prepare($query); |
|
743 | - $sth->execute(); |
|
744 | - } catch(PDOException $e) { |
|
745 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
746 | - } |
|
741 | + try { |
|
742 | + $sth = $Connection->db->prepare($query); |
|
743 | + $sth->execute(); |
|
744 | + } catch(PDOException $e) { |
|
745 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
746 | + } |
|
747 | 747 | return $error; |
748 | 748 | } |
749 | 749 | |
@@ -762,35 +762,35 @@ discard block |
||
762 | 762 | if ($error != '') return $error; |
763 | 763 | } |
764 | 764 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; |
765 | - try { |
|
766 | - $sth = $Connection->db->prepare($query); |
|
767 | - $sth->execute(); |
|
768 | - } catch(PDOException $e) { |
|
769 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
770 | - } |
|
765 | + try { |
|
766 | + $sth = $Connection->db->prepare($query); |
|
767 | + $sth->execute(); |
|
768 | + } catch(PDOException $e) { |
|
769 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
770 | + } |
|
771 | 771 | return $error; |
772 | 772 | } |
773 | 773 | |
774 | 774 | private static function update_from_22() { |
775 | 775 | global $globalDBdriver; |
776 | - $Connection = new Connection(); |
|
776 | + $Connection = new Connection(); |
|
777 | 777 | $error = ''; |
778 | 778 | // Add table stats polar |
779 | - if (!$Connection->tableExists('stats_source')) { |
|
779 | + if (!$Connection->tableExists('stats_source')) { |
|
780 | 780 | if ($globalDBdriver == 'mysql') { |
781 | - $error .= create_db::import_file('../db/stats_source.sql'); |
|
781 | + $error .= create_db::import_file('../db/stats_source.sql'); |
|
782 | 782 | } else { |
783 | 783 | $error .= create_db::import_file('../db/pgsql/stats_source.sql'); |
784 | 784 | } |
785 | 785 | if ($error != '') return $error; |
786 | 786 | } |
787 | 787 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; |
788 | - try { |
|
789 | - $sth = $Connection->db->prepare($query); |
|
790 | - $sth->execute(); |
|
791 | - } catch(PDOException $e) { |
|
792 | - return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
793 | - } |
|
788 | + try { |
|
789 | + $sth = $Connection->db->prepare($query); |
|
790 | + $sth->execute(); |
|
791 | + } catch(PDOException $e) { |
|
792 | + return "error (update schema_version) : ".$e->getMessage()."\n"; |
|
793 | + } |
|
794 | 794 | return $error; |
795 | 795 | } |
796 | 796 | |
@@ -821,14 +821,14 @@ discard block |
||
821 | 821 | } |
822 | 822 | if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { |
823 | 823 | // Add aircraft_manufacturer to stats_aircraft |
824 | - $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
824 | + $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; |
|
825 | 825 | try { |
826 | 826 | $sth = $Connection->db->prepare($query); |
827 | 827 | $sth->execute(); |
828 | 828 | } catch(PDOException $e) { |
829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; |
830 | - } |
|
831 | - } |
|
830 | + } |
|
831 | + } |
|
832 | 832 | |
833 | 833 | $query = "UPDATE config SET value = '24' WHERE name = 'schema_version'"; |
834 | 834 | try { |
@@ -1176,7 +1176,7 @@ discard block |
||
1176 | 1176 | } catch(PDOException $e) { |
1177 | 1177 | return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n"; |
1178 | 1178 | } |
1179 | - } |
|
1179 | + } |
|
1180 | 1180 | if (!$Connection->checkColumnName('aircraft','mfr')) { |
1181 | 1181 | // Add mfr to aircraft |
1182 | 1182 | $query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL"; |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | } catch(PDOException $e) { |
1251 | 1251 | return "error (add index ref on notam) : ".$e->getMessage()."\n"; |
1252 | 1252 | } |
1253 | - } |
|
1253 | + } |
|
1254 | 1254 | if (!$Connection->indexExists('accidents','registration_idx')) { |
1255 | 1255 | // Add index key |
1256 | 1256 | $query = "create index registration_idx on accidents (registration)"; |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | } catch(PDOException $e) { |
1261 | 1261 | return "error (add index registration on accidents) : ".$e->getMessage()."\n"; |
1262 | 1262 | } |
1263 | - } |
|
1263 | + } |
|
1264 | 1264 | if (!$Connection->indexExists('accidents','rdts')) { |
1265 | 1265 | // Add index key |
1266 | 1266 | $query = "create index rdts on accidents (registration,date,type,source)"; |
@@ -1270,7 +1270,7 @@ discard block |
||
1270 | 1270 | } catch(PDOException $e) { |
1271 | 1271 | return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n"; |
1272 | 1272 | } |
1273 | - } |
|
1273 | + } |
|
1274 | 1274 | |
1275 | 1275 | $query = "UPDATE config SET value = '31' WHERE name = 'schema_version'"; |
1276 | 1276 | try { |
@@ -1562,7 +1562,7 @@ discard block |
||
1562 | 1562 | } catch(PDOException $e) { |
1563 | 1563 | return "error (add index type on accidents) : ".$e->getMessage()."\n"; |
1564 | 1564 | } |
1565 | - } |
|
1565 | + } |
|
1566 | 1566 | $query = "UPDATE config SET value = '36' WHERE name = 'schema_version'"; |
1567 | 1567 | try { |
1568 | 1568 | $sth = $Connection->db->prepare($query); |
@@ -1700,7 +1700,7 @@ discard block |
||
1700 | 1700 | } catch(PDOException $e) { |
1701 | 1701 | return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n"; |
1702 | 1702 | } |
1703 | - } |
|
1703 | + } |
|
1704 | 1704 | $query = "UPDATE config SET value = '38' WHERE name = 'schema_version'"; |
1705 | 1705 | try { |
1706 | 1706 | $sth = $Connection->db->prepare($query); |
@@ -1712,177 +1712,177 @@ discard block |
||
1712 | 1712 | } |
1713 | 1713 | |
1714 | 1714 | |
1715 | - public static function check_version($update = false) { |
|
1716 | - global $globalDBname; |
|
1717 | - $version = 0; |
|
1718 | - $Connection = new Connection(); |
|
1719 | - if ($Connection->tableExists('aircraft')) { |
|
1720 | - if (!$Connection->tableExists('config')) { |
|
1721 | - $version = '1'; |
|
1722 | - if ($update) return self::update_from_1(); |
|
1723 | - else return $version; |
|
1715 | + public static function check_version($update = false) { |
|
1716 | + global $globalDBname; |
|
1717 | + $version = 0; |
|
1718 | + $Connection = new Connection(); |
|
1719 | + if ($Connection->tableExists('aircraft')) { |
|
1720 | + if (!$Connection->tableExists('config')) { |
|
1721 | + $version = '1'; |
|
1722 | + if ($update) return self::update_from_1(); |
|
1723 | + else return $version; |
|
1724 | 1724 | } else { |
1725 | - $Connection = new Connection(); |
|
1726 | - $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
1727 | - try { |
|
1728 | - $sth = $Connection->db->prepare($query); |
|
1729 | - $sth->execute(); |
|
1730 | - } catch(PDOException $e) { |
|
1725 | + $Connection = new Connection(); |
|
1726 | + $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
|
1727 | + try { |
|
1728 | + $sth = $Connection->db->prepare($query); |
|
1729 | + $sth->execute(); |
|
1730 | + } catch(PDOException $e) { |
|
1731 | 1731 | return "error : ".$e->getMessage()."\n"; |
1732 | - } |
|
1733 | - $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
1734 | - if ($update) { |
|
1735 | - if ($result['value'] == '2') { |
|
1736 | - $error = self::update_from_2(); |
|
1737 | - if ($error != '') return $error; |
|
1738 | - else return self::check_version(true); |
|
1739 | - } elseif ($result['value'] == '3') { |
|
1740 | - $error = self::update_from_3(); |
|
1741 | - if ($error != '') return $error; |
|
1742 | - else return self::check_version(true); |
|
1743 | - } elseif ($result['value'] == '4') { |
|
1744 | - $error = self::update_from_4(); |
|
1745 | - if ($error != '') return $error; |
|
1746 | - else return self::check_version(true); |
|
1747 | - } elseif ($result['value'] == '5') { |
|
1748 | - $error = self::update_from_5(); |
|
1749 | - if ($error != '') return $error; |
|
1750 | - else return self::check_version(true); |
|
1751 | - } elseif ($result['value'] == '6') { |
|
1752 | - $error = self::update_from_6(); |
|
1753 | - if ($error != '') return $error; |
|
1754 | - else return self::check_version(true); |
|
1755 | - } elseif ($result['value'] == '7') { |
|
1756 | - $error = self::update_from_7(); |
|
1757 | - if ($error != '') return $error; |
|
1758 | - else return self::check_version(true); |
|
1759 | - } elseif ($result['value'] == '8') { |
|
1760 | - $error = self::update_from_8(); |
|
1761 | - if ($error != '') return $error; |
|
1762 | - else return self::check_version(true); |
|
1763 | - } elseif ($result['value'] == '9') { |
|
1764 | - $error = self::update_from_9(); |
|
1765 | - if ($error != '') return $error; |
|
1766 | - else return self::check_version(true); |
|
1767 | - } elseif ($result['value'] == '10') { |
|
1768 | - $error = self::update_from_10(); |
|
1769 | - if ($error != '') return $error; |
|
1770 | - else return self::check_version(true); |
|
1771 | - } elseif ($result['value'] == '11') { |
|
1772 | - $error = self::update_from_11(); |
|
1773 | - if ($error != '') return $error; |
|
1774 | - else return self::check_version(true); |
|
1775 | - } elseif ($result['value'] == '12') { |
|
1776 | - $error = self::update_from_12(); |
|
1777 | - if ($error != '') return $error; |
|
1778 | - else return self::check_version(true); |
|
1779 | - } elseif ($result['value'] == '13') { |
|
1780 | - $error = self::update_from_13(); |
|
1781 | - if ($error != '') return $error; |
|
1782 | - else return self::check_version(true); |
|
1783 | - } elseif ($result['value'] == '14') { |
|
1784 | - $error = self::update_from_14(); |
|
1785 | - if ($error != '') return $error; |
|
1786 | - else return self::check_version(true); |
|
1787 | - } elseif ($result['value'] == '15') { |
|
1788 | - $error = self::update_from_15(); |
|
1789 | - if ($error != '') return $error; |
|
1790 | - else return self::check_version(true); |
|
1791 | - } elseif ($result['value'] == '16') { |
|
1792 | - $error = self::update_from_16(); |
|
1793 | - if ($error != '') return $error; |
|
1794 | - else return self::check_version(true); |
|
1795 | - } elseif ($result['value'] == '17') { |
|
1796 | - $error = self::update_from_17(); |
|
1797 | - if ($error != '') return $error; |
|
1798 | - else return self::check_version(true); |
|
1799 | - } elseif ($result['value'] == '18') { |
|
1800 | - $error = self::update_from_18(); |
|
1801 | - if ($error != '') return $error; |
|
1802 | - else return self::check_version(true); |
|
1803 | - } elseif ($result['value'] == '19') { |
|
1804 | - $error = self::update_from_19(); |
|
1805 | - if ($error != '') return $error; |
|
1806 | - else return self::check_version(true); |
|
1807 | - } elseif ($result['value'] == '20') { |
|
1808 | - $error = self::update_from_20(); |
|
1809 | - if ($error != '') return $error; |
|
1810 | - else return self::check_version(true); |
|
1811 | - } elseif ($result['value'] == '21') { |
|
1812 | - $error = self::update_from_21(); |
|
1813 | - if ($error != '') return $error; |
|
1814 | - else return self::check_version(true); |
|
1815 | - } elseif ($result['value'] == '22') { |
|
1816 | - $error = self::update_from_22(); |
|
1817 | - if ($error != '') return $error; |
|
1818 | - else return self::check_version(true); |
|
1819 | - } elseif ($result['value'] == '23') { |
|
1820 | - $error = self::update_from_23(); |
|
1821 | - if ($error != '') return $error; |
|
1822 | - else return self::check_version(true); |
|
1823 | - } elseif ($result['value'] == '24') { |
|
1824 | - $error = self::update_from_24(); |
|
1825 | - if ($error != '') return $error; |
|
1826 | - else return self::check_version(true); |
|
1827 | - } elseif ($result['value'] == '25') { |
|
1828 | - $error = self::update_from_25(); |
|
1829 | - if ($error != '') return $error; |
|
1830 | - else return self::check_version(true); |
|
1831 | - } elseif ($result['value'] == '26') { |
|
1832 | - $error = self::update_from_26(); |
|
1833 | - if ($error != '') return $error; |
|
1834 | - else return self::check_version(true); |
|
1835 | - } elseif ($result['value'] == '27') { |
|
1836 | - $error = self::update_from_27(); |
|
1837 | - if ($error != '') return $error; |
|
1838 | - else return self::check_version(true); |
|
1839 | - } elseif ($result['value'] == '28') { |
|
1840 | - $error = self::update_from_28(); |
|
1841 | - if ($error != '') return $error; |
|
1842 | - else return self::check_version(true); |
|
1843 | - } elseif ($result['value'] == '29') { |
|
1844 | - $error = self::update_from_29(); |
|
1845 | - if ($error != '') return $error; |
|
1846 | - else return self::check_version(true); |
|
1847 | - } elseif ($result['value'] == '30') { |
|
1848 | - $error = self::update_from_30(); |
|
1849 | - if ($error != '') return $error; |
|
1850 | - else return self::check_version(true); |
|
1851 | - } elseif ($result['value'] == '31') { |
|
1852 | - $error = self::update_from_31(); |
|
1853 | - if ($error != '') return $error; |
|
1854 | - else return self::check_version(true); |
|
1855 | - } elseif ($result['value'] == '32') { |
|
1856 | - $error = self::update_from_32(); |
|
1857 | - if ($error != '') return $error; |
|
1858 | - else return self::check_version(true); |
|
1859 | - } elseif ($result['value'] == '33') { |
|
1860 | - $error = self::update_from_33(); |
|
1861 | - if ($error != '') return $error; |
|
1862 | - else return self::check_version(true); |
|
1863 | - } elseif ($result['value'] == '34') { |
|
1864 | - $error = self::update_from_34(); |
|
1865 | - if ($error != '') return $error; |
|
1866 | - else return self::check_version(true); |
|
1867 | - } elseif ($result['value'] == '35') { |
|
1868 | - $error = self::update_from_35(); |
|
1869 | - if ($error != '') return $error; |
|
1870 | - else return self::check_version(true); |
|
1871 | - } elseif ($result['value'] == '36') { |
|
1872 | - $error = self::update_from_36(); |
|
1873 | - if ($error != '') return $error; |
|
1874 | - else return self::check_version(true); |
|
1875 | - } elseif ($result['value'] == '37') { |
|
1876 | - $error = self::update_from_37(); |
|
1877 | - if ($error != '') return $error; |
|
1878 | - else return self::check_version(true); |
|
1879 | - } else return ''; |
|
1880 | - } |
|
1881 | - else return $result['value']; |
|
1732 | + } |
|
1733 | + $result = $sth->fetch(PDO::FETCH_ASSOC); |
|
1734 | + if ($update) { |
|
1735 | + if ($result['value'] == '2') { |
|
1736 | + $error = self::update_from_2(); |
|
1737 | + if ($error != '') return $error; |
|
1738 | + else return self::check_version(true); |
|
1739 | + } elseif ($result['value'] == '3') { |
|
1740 | + $error = self::update_from_3(); |
|
1741 | + if ($error != '') return $error; |
|
1742 | + else return self::check_version(true); |
|
1743 | + } elseif ($result['value'] == '4') { |
|
1744 | + $error = self::update_from_4(); |
|
1745 | + if ($error != '') return $error; |
|
1746 | + else return self::check_version(true); |
|
1747 | + } elseif ($result['value'] == '5') { |
|
1748 | + $error = self::update_from_5(); |
|
1749 | + if ($error != '') return $error; |
|
1750 | + else return self::check_version(true); |
|
1751 | + } elseif ($result['value'] == '6') { |
|
1752 | + $error = self::update_from_6(); |
|
1753 | + if ($error != '') return $error; |
|
1754 | + else return self::check_version(true); |
|
1755 | + } elseif ($result['value'] == '7') { |
|
1756 | + $error = self::update_from_7(); |
|
1757 | + if ($error != '') return $error; |
|
1758 | + else return self::check_version(true); |
|
1759 | + } elseif ($result['value'] == '8') { |
|
1760 | + $error = self::update_from_8(); |
|
1761 | + if ($error != '') return $error; |
|
1762 | + else return self::check_version(true); |
|
1763 | + } elseif ($result['value'] == '9') { |
|
1764 | + $error = self::update_from_9(); |
|
1765 | + if ($error != '') return $error; |
|
1766 | + else return self::check_version(true); |
|
1767 | + } elseif ($result['value'] == '10') { |
|
1768 | + $error = self::update_from_10(); |
|
1769 | + if ($error != '') return $error; |
|
1770 | + else return self::check_version(true); |
|
1771 | + } elseif ($result['value'] == '11') { |
|
1772 | + $error = self::update_from_11(); |
|
1773 | + if ($error != '') return $error; |
|
1774 | + else return self::check_version(true); |
|
1775 | + } elseif ($result['value'] == '12') { |
|
1776 | + $error = self::update_from_12(); |
|
1777 | + if ($error != '') return $error; |
|
1778 | + else return self::check_version(true); |
|
1779 | + } elseif ($result['value'] == '13') { |
|
1780 | + $error = self::update_from_13(); |
|
1781 | + if ($error != '') return $error; |
|
1782 | + else return self::check_version(true); |
|
1783 | + } elseif ($result['value'] == '14') { |
|
1784 | + $error = self::update_from_14(); |
|
1785 | + if ($error != '') return $error; |
|
1786 | + else return self::check_version(true); |
|
1787 | + } elseif ($result['value'] == '15') { |
|
1788 | + $error = self::update_from_15(); |
|
1789 | + if ($error != '') return $error; |
|
1790 | + else return self::check_version(true); |
|
1791 | + } elseif ($result['value'] == '16') { |
|
1792 | + $error = self::update_from_16(); |
|
1793 | + if ($error != '') return $error; |
|
1794 | + else return self::check_version(true); |
|
1795 | + } elseif ($result['value'] == '17') { |
|
1796 | + $error = self::update_from_17(); |
|
1797 | + if ($error != '') return $error; |
|
1798 | + else return self::check_version(true); |
|
1799 | + } elseif ($result['value'] == '18') { |
|
1800 | + $error = self::update_from_18(); |
|
1801 | + if ($error != '') return $error; |
|
1802 | + else return self::check_version(true); |
|
1803 | + } elseif ($result['value'] == '19') { |
|
1804 | + $error = self::update_from_19(); |
|
1805 | + if ($error != '') return $error; |
|
1806 | + else return self::check_version(true); |
|
1807 | + } elseif ($result['value'] == '20') { |
|
1808 | + $error = self::update_from_20(); |
|
1809 | + if ($error != '') return $error; |
|
1810 | + else return self::check_version(true); |
|
1811 | + } elseif ($result['value'] == '21') { |
|
1812 | + $error = self::update_from_21(); |
|
1813 | + if ($error != '') return $error; |
|
1814 | + else return self::check_version(true); |
|
1815 | + } elseif ($result['value'] == '22') { |
|
1816 | + $error = self::update_from_22(); |
|
1817 | + if ($error != '') return $error; |
|
1818 | + else return self::check_version(true); |
|
1819 | + } elseif ($result['value'] == '23') { |
|
1820 | + $error = self::update_from_23(); |
|
1821 | + if ($error != '') return $error; |
|
1822 | + else return self::check_version(true); |
|
1823 | + } elseif ($result['value'] == '24') { |
|
1824 | + $error = self::update_from_24(); |
|
1825 | + if ($error != '') return $error; |
|
1826 | + else return self::check_version(true); |
|
1827 | + } elseif ($result['value'] == '25') { |
|
1828 | + $error = self::update_from_25(); |
|
1829 | + if ($error != '') return $error; |
|
1830 | + else return self::check_version(true); |
|
1831 | + } elseif ($result['value'] == '26') { |
|
1832 | + $error = self::update_from_26(); |
|
1833 | + if ($error != '') return $error; |
|
1834 | + else return self::check_version(true); |
|
1835 | + } elseif ($result['value'] == '27') { |
|
1836 | + $error = self::update_from_27(); |
|
1837 | + if ($error != '') return $error; |
|
1838 | + else return self::check_version(true); |
|
1839 | + } elseif ($result['value'] == '28') { |
|
1840 | + $error = self::update_from_28(); |
|
1841 | + if ($error != '') return $error; |
|
1842 | + else return self::check_version(true); |
|
1843 | + } elseif ($result['value'] == '29') { |
|
1844 | + $error = self::update_from_29(); |
|
1845 | + if ($error != '') return $error; |
|
1846 | + else return self::check_version(true); |
|
1847 | + } elseif ($result['value'] == '30') { |
|
1848 | + $error = self::update_from_30(); |
|
1849 | + if ($error != '') return $error; |
|
1850 | + else return self::check_version(true); |
|
1851 | + } elseif ($result['value'] == '31') { |
|
1852 | + $error = self::update_from_31(); |
|
1853 | + if ($error != '') return $error; |
|
1854 | + else return self::check_version(true); |
|
1855 | + } elseif ($result['value'] == '32') { |
|
1856 | + $error = self::update_from_32(); |
|
1857 | + if ($error != '') return $error; |
|
1858 | + else return self::check_version(true); |
|
1859 | + } elseif ($result['value'] == '33') { |
|
1860 | + $error = self::update_from_33(); |
|
1861 | + if ($error != '') return $error; |
|
1862 | + else return self::check_version(true); |
|
1863 | + } elseif ($result['value'] == '34') { |
|
1864 | + $error = self::update_from_34(); |
|
1865 | + if ($error != '') return $error; |
|
1866 | + else return self::check_version(true); |
|
1867 | + } elseif ($result['value'] == '35') { |
|
1868 | + $error = self::update_from_35(); |
|
1869 | + if ($error != '') return $error; |
|
1870 | + else return self::check_version(true); |
|
1871 | + } elseif ($result['value'] == '36') { |
|
1872 | + $error = self::update_from_36(); |
|
1873 | + if ($error != '') return $error; |
|
1874 | + else return self::check_version(true); |
|
1875 | + } elseif ($result['value'] == '37') { |
|
1876 | + $error = self::update_from_37(); |
|
1877 | + if ($error != '') return $error; |
|
1878 | + else return self::check_version(true); |
|
1879 | + } else return ''; |
|
1880 | + } |
|
1881 | + else return $result['value']; |
|
1882 | 1882 | } |
1883 | 1883 | |
1884 | - } else return $version; |
|
1885 | - } |
|
1884 | + } else return $version; |
|
1885 | + } |
|
1886 | 1886 | |
1887 | 1887 | } |
1888 | 1888 | //echo update_schema::check_version(); |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | $this->db = $Connection->db; |
9 | 9 | } |
10 | 10 | |
11 | - /** |
|
12 | - * Get SQL query part for filter used |
|
13 | - * @param Array $filter the filter |
|
14 | - * @return Array the SQL part |
|
15 | - */ |
|
16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
11 | + /** |
|
12 | + * Get SQL query part for filter used |
|
13 | + * @param Array $filter the filter |
|
14 | + * @return Array the SQL part |
|
15 | + */ |
|
16 | + public function getFilter($filter = array(),$where = false,$and = false) { |
|
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
18 | 18 | $filters = array(); |
19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
@@ -30,88 +30,88 @@ discard block |
||
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | 32 | foreach($filters as $flt) { |
33 | - if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
33 | + if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
34 | 34 | if ($flt['airlines'][0] != '') { |
35 | - if (isset($flt['source'])) { |
|
35 | + if (isset($flt['source'])) { |
|
36 | 36 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
37 | - } else { |
|
37 | + } else { |
|
38 | 38 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
39 | - } |
|
39 | + } |
|
40 | + } |
|
40 | 41 | } |
41 | - } |
|
42 | - if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
42 | + if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
43 | 43 | if (isset($flt['source'])) { |
44 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
44 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
45 | 45 | } else { |
46 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
46 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
47 | 47 | } |
48 | - } |
|
49 | - if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
48 | + } |
|
49 | + if (isset($flt['idents']) && !empty($flt['idents'])) { |
|
50 | 50 | if (isset($flt['source'])) { |
51 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
51 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
52 | 52 | } else { |
53 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
53 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
54 | + } |
|
54 | 55 | } |
55 | - } |
|
56 | - if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
56 | + if (isset($flt['registrations']) && !empty($flt['registrations'])) { |
|
57 | 57 | if (isset($flt['source'])) { |
58 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
58 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
59 | 59 | } else { |
60 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
60 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id"; |
|
61 | + } |
|
61 | 62 | } |
62 | - } |
|
63 | - if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
63 | + if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) { |
|
64 | 64 | if (isset($flt['source'])) { |
65 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
65 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
66 | + } |
|
66 | 67 | } |
67 | - } |
|
68 | 68 | } |
69 | 69 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
70 | - if ($filter['airlines'][0] != '') { |
|
70 | + if ($filter['airlines'][0] != '') { |
|
71 | 71 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
72 | - } |
|
72 | + } |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
76 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
76 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
77 | 77 | } |
78 | 78 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
79 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
79 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
80 | 80 | } |
81 | 81 | if (isset($filter['source']) && !empty($filter['source'])) { |
82 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
82 | + $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
83 | 83 | } |
84 | 84 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
85 | - $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
85 | + $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
86 | 86 | } |
87 | 87 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
88 | 88 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
89 | 89 | } |
90 | 90 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
91 | - $filter_query_date = ''; |
|
91 | + $filter_query_date = ''; |
|
92 | 92 | |
93 | - if (isset($filter['year']) && $filter['year'] != '') { |
|
93 | + if (isset($filter['year']) && $filter['year'] != '') { |
|
94 | 94 | if ($globalDBdriver == 'mysql') { |
95 | - $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
95 | + $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
96 | 96 | } else { |
97 | - $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
97 | + $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
98 | + } |
|
98 | 99 | } |
99 | - } |
|
100 | - if (isset($filter['month']) && $filter['month'] != '') { |
|
100 | + if (isset($filter['month']) && $filter['month'] != '') { |
|
101 | 101 | if ($globalDBdriver == 'mysql') { |
102 | - $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
102 | + $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
103 | 103 | } else { |
104 | - $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
104 | + $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
105 | 105 | } |
106 | - } |
|
107 | - if (isset($filter['day']) && $filter['day'] != '') { |
|
106 | + } |
|
107 | + if (isset($filter['day']) && $filter['day'] != '') { |
|
108 | 108 | if ($globalDBdriver == 'mysql') { |
109 | - $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
109 | + $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
110 | 110 | } else { |
111 | - $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
111 | + $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
112 | + } |
|
112 | 113 | } |
113 | - } |
|
114 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
114 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id"; |
|
115 | 115 | } |
116 | 116 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
117 | 117 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | $filter_query = $filter_query_join.$filter_query_where; |
122 | 122 | return $filter_query; |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | 125 | // Spotter_archive |
126 | 126 | public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
@@ -152,44 +152,44 @@ discard block |
||
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | - /** |
|
156 | - * Gets all the spotter information based on a particular callsign |
|
157 | - * |
|
158 | - * @return Array the spotter information |
|
159 | - * |
|
160 | - */ |
|
161 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
162 | - { |
|
155 | + /** |
|
156 | + * Gets all the spotter information based on a particular callsign |
|
157 | + * |
|
158 | + * @return Array the spotter information |
|
159 | + * |
|
160 | + */ |
|
161 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
162 | + { |
|
163 | 163 | $Spotter = new Spotter($this->db); |
164 | - date_default_timezone_set('UTC'); |
|
164 | + date_default_timezone_set('UTC'); |
|
165 | 165 | |
166 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
167 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
168 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
166 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
167 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
168 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
169 | 169 | |
170 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
170 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
171 | 171 | |
172 | - return $spotter_array; |
|
173 | - } |
|
172 | + return $spotter_array; |
|
173 | + } |
|
174 | 174 | |
175 | 175 | |
176 | - /** |
|
177 | - * Gets last the spotter information based on a particular id |
|
178 | - * |
|
179 | - * @return Array the spotter information |
|
180 | - * |
|
181 | - */ |
|
182 | - public function getLastArchiveSpotterDataById($id) |
|
183 | - { |
|
184 | - $Spotter = new Spotter($this->db); |
|
185 | - date_default_timezone_set('UTC'); |
|
186 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
187 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
188 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
189 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
176 | + /** |
|
177 | + * Gets last the spotter information based on a particular id |
|
178 | + * |
|
179 | + * @return Array the spotter information |
|
180 | + * |
|
181 | + */ |
|
182 | + public function getLastArchiveSpotterDataById($id) |
|
183 | + { |
|
184 | + $Spotter = new Spotter($this->db); |
|
185 | + date_default_timezone_set('UTC'); |
|
186 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
187 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
188 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
189 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
190 | 190 | |
191 | 191 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
192 | - /* |
|
192 | + /* |
|
193 | 193 | try { |
194 | 194 | $Connection = new Connection(); |
195 | 195 | $sth = Connection->$db->prepare($query); |
@@ -199,232 +199,232 @@ discard block |
||
199 | 199 | } |
200 | 200 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
201 | 201 | */ |
202 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
203 | - |
|
204 | - return $spotter_array; |
|
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * Gets all the spotter information based on a particular id |
|
209 | - * |
|
210 | - * @return Array the spotter information |
|
211 | - * |
|
212 | - */ |
|
213 | - public function getAllArchiveSpotterDataById($id) |
|
202 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
203 | + |
|
204 | + return $spotter_array; |
|
205 | + } |
|
206 | + |
|
207 | + /** |
|
208 | + * Gets all the spotter information based on a particular id |
|
209 | + * |
|
210 | + * @return Array the spotter information |
|
211 | + * |
|
212 | + */ |
|
213 | + public function getAllArchiveSpotterDataById($id) |
|
214 | 214 | { |
215 | - date_default_timezone_set('UTC'); |
|
216 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
217 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
215 | + date_default_timezone_set('UTC'); |
|
216 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
217 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
218 | 218 | |
219 | 219 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
220 | 220 | |
221 | - try { |
|
222 | - $sth = $this->db->prepare($query); |
|
223 | - $sth->execute(array(':id' => $id)); |
|
224 | - } catch(PDOException $e) { |
|
225 | - echo $e->getMessage(); |
|
226 | - die; |
|
227 | - } |
|
228 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
229 | - |
|
230 | - return $spotter_array; |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * Gets coordinate & time spotter information based on a particular id |
|
235 | - * |
|
236 | - * @return Array the spotter information |
|
237 | - * |
|
238 | - */ |
|
239 | - public function getCoordArchiveSpotterDataById($id) |
|
240 | - { |
|
241 | - date_default_timezone_set('UTC'); |
|
242 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
243 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
221 | + try { |
|
222 | + $sth = $this->db->prepare($query); |
|
223 | + $sth->execute(array(':id' => $id)); |
|
224 | + } catch(PDOException $e) { |
|
225 | + echo $e->getMessage(); |
|
226 | + die; |
|
227 | + } |
|
228 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
229 | + |
|
230 | + return $spotter_array; |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * Gets coordinate & time spotter information based on a particular id |
|
235 | + * |
|
236 | + * @return Array the spotter information |
|
237 | + * |
|
238 | + */ |
|
239 | + public function getCoordArchiveSpotterDataById($id) |
|
240 | + { |
|
241 | + date_default_timezone_set('UTC'); |
|
242 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
243 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
244 | 244 | |
245 | 245 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
246 | 246 | |
247 | - try { |
|
248 | - $sth = $this->db->prepare($query); |
|
249 | - $sth->execute(array(':id' => $id)); |
|
250 | - } catch(PDOException $e) { |
|
251 | - echo $e->getMessage(); |
|
252 | - die; |
|
253 | - } |
|
254 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
247 | + try { |
|
248 | + $sth = $this->db->prepare($query); |
|
249 | + $sth->execute(array(':id' => $id)); |
|
250 | + } catch(PDOException $e) { |
|
251 | + echo $e->getMessage(); |
|
252 | + die; |
|
253 | + } |
|
254 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
255 | 255 | |
256 | - return $spotter_array; |
|
257 | - } |
|
256 | + return $spotter_array; |
|
257 | + } |
|
258 | 258 | |
259 | 259 | |
260 | - /** |
|
261 | - * Gets altitude information based on a particular callsign |
|
262 | - * |
|
263 | - * @return Array the spotter information |
|
264 | - * |
|
265 | - */ |
|
266 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
267 | - { |
|
260 | + /** |
|
261 | + * Gets altitude information based on a particular callsign |
|
262 | + * |
|
263 | + * @return Array the spotter information |
|
264 | + * |
|
265 | + */ |
|
266 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
267 | + { |
|
268 | 268 | |
269 | - date_default_timezone_set('UTC'); |
|
269 | + date_default_timezone_set('UTC'); |
|
270 | 270 | |
271 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
272 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
271 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
272 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
273 | 273 | |
274 | - try { |
|
275 | - $sth = $this->db->prepare($query); |
|
276 | - $sth->execute(array(':ident' => $ident)); |
|
277 | - } catch(PDOException $e) { |
|
278 | - echo $e->getMessage(); |
|
279 | - die; |
|
280 | - } |
|
281 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
274 | + try { |
|
275 | + $sth = $this->db->prepare($query); |
|
276 | + $sth->execute(array(':ident' => $ident)); |
|
277 | + } catch(PDOException $e) { |
|
278 | + echo $e->getMessage(); |
|
279 | + die; |
|
280 | + } |
|
281 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
282 | 282 | |
283 | - return $spotter_array; |
|
284 | - } |
|
283 | + return $spotter_array; |
|
284 | + } |
|
285 | 285 | |
286 | - /** |
|
287 | - * Gets altitude information based on a particular id |
|
288 | - * |
|
289 | - * @return Array the spotter information |
|
290 | - * |
|
291 | - */ |
|
292 | - public function getAltitudeArchiveSpotterDataById($id) |
|
293 | - { |
|
286 | + /** |
|
287 | + * Gets altitude information based on a particular id |
|
288 | + * |
|
289 | + * @return Array the spotter information |
|
290 | + * |
|
291 | + */ |
|
292 | + public function getAltitudeArchiveSpotterDataById($id) |
|
293 | + { |
|
294 | 294 | |
295 | - date_default_timezone_set('UTC'); |
|
295 | + date_default_timezone_set('UTC'); |
|
296 | 296 | |
297 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
298 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
297 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
298 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
299 | 299 | |
300 | - try { |
|
301 | - $sth = $this->db->prepare($query); |
|
302 | - $sth->execute(array(':id' => $id)); |
|
303 | - } catch(PDOException $e) { |
|
304 | - echo $e->getMessage(); |
|
305 | - die; |
|
306 | - } |
|
307 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
300 | + try { |
|
301 | + $sth = $this->db->prepare($query); |
|
302 | + $sth->execute(array(':id' => $id)); |
|
303 | + } catch(PDOException $e) { |
|
304 | + echo $e->getMessage(); |
|
305 | + die; |
|
306 | + } |
|
307 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
308 | 308 | |
309 | - return $spotter_array; |
|
310 | - } |
|
309 | + return $spotter_array; |
|
310 | + } |
|
311 | 311 | |
312 | - /** |
|
313 | - * Gets altitude & speed information based on a particular id |
|
314 | - * |
|
315 | - * @return Array the spotter information |
|
316 | - * |
|
317 | - */ |
|
318 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
319 | - { |
|
312 | + /** |
|
313 | + * Gets altitude & speed information based on a particular id |
|
314 | + * |
|
315 | + * @return Array the spotter information |
|
316 | + * |
|
317 | + */ |
|
318 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
319 | + { |
|
320 | 320 | |
321 | - date_default_timezone_set('UTC'); |
|
321 | + date_default_timezone_set('UTC'); |
|
322 | 322 | |
323 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
324 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
323 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
324 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
325 | 325 | |
326 | - try { |
|
327 | - $sth = $this->db->prepare($query); |
|
328 | - $sth->execute(array(':id' => $id)); |
|
329 | - } catch(PDOException $e) { |
|
330 | - echo $e->getMessage(); |
|
331 | - die; |
|
332 | - } |
|
333 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
326 | + try { |
|
327 | + $sth = $this->db->prepare($query); |
|
328 | + $sth->execute(array(':id' => $id)); |
|
329 | + } catch(PDOException $e) { |
|
330 | + echo $e->getMessage(); |
|
331 | + die; |
|
332 | + } |
|
333 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
334 | 334 | |
335 | - return $spotter_array; |
|
336 | - } |
|
335 | + return $spotter_array; |
|
336 | + } |
|
337 | 337 | |
338 | 338 | |
339 | - /** |
|
340 | - * Gets altitude information based on a particular callsign |
|
341 | - * |
|
342 | - * @return Array the spotter information |
|
343 | - * |
|
344 | - */ |
|
345 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
346 | - { |
|
339 | + /** |
|
340 | + * Gets altitude information based on a particular callsign |
|
341 | + * |
|
342 | + * @return Array the spotter information |
|
343 | + * |
|
344 | + */ |
|
345 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
346 | + { |
|
347 | 347 | |
348 | - date_default_timezone_set('UTC'); |
|
348 | + date_default_timezone_set('UTC'); |
|
349 | 349 | |
350 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
351 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
350 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
351 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
352 | 352 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
353 | 353 | |
354 | - try { |
|
355 | - $sth = $this->db->prepare($query); |
|
356 | - $sth->execute(array(':ident' => $ident)); |
|
357 | - } catch(PDOException $e) { |
|
358 | - echo $e->getMessage(); |
|
359 | - die; |
|
360 | - } |
|
361 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
354 | + try { |
|
355 | + $sth = $this->db->prepare($query); |
|
356 | + $sth->execute(array(':ident' => $ident)); |
|
357 | + } catch(PDOException $e) { |
|
358 | + echo $e->getMessage(); |
|
359 | + die; |
|
360 | + } |
|
361 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
362 | 362 | |
363 | - return $spotter_array; |
|
364 | - } |
|
363 | + return $spotter_array; |
|
364 | + } |
|
365 | 365 | |
366 | 366 | |
367 | 367 | |
368 | - /** |
|
369 | - * Gets all the archive spotter information |
|
370 | - * |
|
371 | - * @return Array the spotter information |
|
372 | - * |
|
373 | - */ |
|
374 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
375 | - { |
|
376 | - $Spotter = new Spotter($this->db); |
|
377 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
378 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
368 | + /** |
|
369 | + * Gets all the archive spotter information |
|
370 | + * |
|
371 | + * @return Array the spotter information |
|
372 | + * |
|
373 | + */ |
|
374 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
375 | + { |
|
376 | + $Spotter = new Spotter($this->db); |
|
377 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
378 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
|
379 | 379 | |
380 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
380 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
381 | 381 | |
382 | - return $spotter_array; |
|
383 | - } |
|
382 | + return $spotter_array; |
|
383 | + } |
|
384 | 384 | |
385 | - public function deleteSpotterArchiveTrackData() |
|
386 | - { |
|
385 | + public function deleteSpotterArchiveTrackData() |
|
386 | + { |
|
387 | 387 | global $globalArchiveKeepTrackMonths; |
388 | - date_default_timezone_set('UTC'); |
|
388 | + date_default_timezone_set('UTC'); |
|
389 | 389 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
390 | - try { |
|
391 | - $sth = $this->db->prepare($query); |
|
392 | - $sth->execute(); |
|
393 | - } catch(PDOException $e) { |
|
394 | - echo $e->getMessage(); |
|
395 | - die; |
|
396 | - } |
|
390 | + try { |
|
391 | + $sth = $this->db->prepare($query); |
|
392 | + $sth->execute(); |
|
393 | + } catch(PDOException $e) { |
|
394 | + echo $e->getMessage(); |
|
395 | + die; |
|
396 | + } |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
400 | - * Gets Minimal Live Spotter data |
|
401 | - * |
|
402 | - * @return Array the spotter information |
|
403 | - * |
|
404 | - */ |
|
405 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
406 | - { |
|
407 | - global $globalDBdriver, $globalLiveInterval; |
|
408 | - date_default_timezone_set('UTC'); |
|
409 | - |
|
410 | - $filter_query = ''; |
|
411 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
412 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
413 | - } |
|
414 | - // Use spotter_output also ? |
|
415 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
416 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
417 | - } |
|
418 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
419 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
420 | - } |
|
421 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
422 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
423 | - } |
|
424 | - |
|
425 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
426 | - if ($globalDBdriver == 'mysql') { |
|
427 | - /* |
|
400 | + * Gets Minimal Live Spotter data |
|
401 | + * |
|
402 | + * @return Array the spotter information |
|
403 | + * |
|
404 | + */ |
|
405 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
406 | + { |
|
407 | + global $globalDBdriver, $globalLiveInterval; |
|
408 | + date_default_timezone_set('UTC'); |
|
409 | + |
|
410 | + $filter_query = ''; |
|
411 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
412 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
413 | + } |
|
414 | + // Use spotter_output also ? |
|
415 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
416 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
417 | + } |
|
418 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
419 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
420 | + } |
|
421 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
422 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
423 | + } |
|
424 | + |
|
425 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
426 | + if ($globalDBdriver == 'mysql') { |
|
427 | + /* |
|
428 | 428 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
429 | 429 | FROM spotter_archive |
430 | 430 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -443,56 +443,56 @@ discard block |
||
443 | 443 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
444 | 444 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
445 | 445 | '.$filter_query.' ORDER BY flightaware_id'; |
446 | - } else { |
|
447 | - //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
448 | - $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
446 | + } else { |
|
447 | + //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
448 | + $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
449 | 449 | FROM spotter_archive |
450 | 450 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
451 | 451 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
452 | 452 | '.$filter_query.' ORDER BY flightaware_id'; |
453 | - } |
|
454 | - //echo $query; |
|
455 | - try { |
|
456 | - $sth = $this->db->prepare($query); |
|
457 | - $sth->execute(); |
|
458 | - } catch(PDOException $e) { |
|
459 | - echo $e->getMessage(); |
|
460 | - die; |
|
461 | - } |
|
462 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
463 | - |
|
464 | - return $spotter_array; |
|
465 | - } |
|
453 | + } |
|
454 | + //echo $query; |
|
455 | + try { |
|
456 | + $sth = $this->db->prepare($query); |
|
457 | + $sth->execute(); |
|
458 | + } catch(PDOException $e) { |
|
459 | + echo $e->getMessage(); |
|
460 | + die; |
|
461 | + } |
|
462 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
463 | + |
|
464 | + return $spotter_array; |
|
465 | + } |
|
466 | 466 | |
467 | 467 | /** |
468 | - * Gets Minimal Live Spotter data |
|
469 | - * |
|
470 | - * @return Array the spotter information |
|
471 | - * |
|
472 | - */ |
|
473 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
474 | - { |
|
475 | - global $globalDBdriver, $globalLiveInterval; |
|
476 | - date_default_timezone_set('UTC'); |
|
477 | - |
|
478 | - $filter_query = ''; |
|
479 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
480 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
481 | - } |
|
482 | - // Should use spotter_output also ? |
|
483 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
484 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
485 | - } |
|
486 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
487 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
488 | - } |
|
489 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
490 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
491 | - } |
|
492 | - |
|
493 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
494 | - if ($globalDBdriver == 'mysql') { |
|
495 | - /* |
|
468 | + * Gets Minimal Live Spotter data |
|
469 | + * |
|
470 | + * @return Array the spotter information |
|
471 | + * |
|
472 | + */ |
|
473 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
474 | + { |
|
475 | + global $globalDBdriver, $globalLiveInterval; |
|
476 | + date_default_timezone_set('UTC'); |
|
477 | + |
|
478 | + $filter_query = ''; |
|
479 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
480 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
481 | + } |
|
482 | + // Should use spotter_output also ? |
|
483 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
484 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
485 | + } |
|
486 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
487 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
488 | + } |
|
489 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
490 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
491 | + } |
|
492 | + |
|
493 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
494 | + if ($globalDBdriver == 'mysql') { |
|
495 | + /* |
|
496 | 496 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
497 | 497 | FROM spotter_archive |
498 | 498 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -503,95 +503,95 @@ discard block |
||
503 | 503 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
504 | 504 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
505 | 505 | |
506 | - } else { |
|
507 | - //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
508 | - /* |
|
506 | + } else { |
|
507 | + //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
508 | + /* |
|
509 | 509 | $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
510 | 510 | FROM spotter_archive_output |
511 | 511 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
512 | 512 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
513 | 513 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
514 | 514 | */ |
515 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
515 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
516 | 516 | FROM spotter_archive_output |
517 | 517 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
518 | 518 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
519 | 519 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
520 | 520 | // .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
521 | 521 | |
522 | - } |
|
523 | - //echo $query; |
|
524 | - try { |
|
525 | - $sth = $this->db->prepare($query); |
|
526 | - $sth->execute(); |
|
527 | - } catch(PDOException $e) { |
|
528 | - echo $e->getMessage(); |
|
529 | - die; |
|
530 | - } |
|
531 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
532 | - |
|
533 | - return $spotter_array; |
|
534 | - } |
|
522 | + } |
|
523 | + //echo $query; |
|
524 | + try { |
|
525 | + $sth = $this->db->prepare($query); |
|
526 | + $sth->execute(); |
|
527 | + } catch(PDOException $e) { |
|
528 | + echo $e->getMessage(); |
|
529 | + die; |
|
530 | + } |
|
531 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
532 | + |
|
533 | + return $spotter_array; |
|
534 | + } |
|
535 | 535 | |
536 | 536 | /** |
537 | - * Gets count Live Spotter data |
|
538 | - * |
|
539 | - * @return Array the spotter information |
|
540 | - * |
|
541 | - */ |
|
542 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
543 | - { |
|
544 | - global $globalDBdriver, $globalLiveInterval; |
|
545 | - date_default_timezone_set('UTC'); |
|
546 | - |
|
547 | - $filter_query = ''; |
|
548 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
549 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
550 | - } |
|
551 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
552 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
553 | - } |
|
554 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
555 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
556 | - } |
|
557 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
558 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
559 | - } |
|
560 | - |
|
561 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
562 | - if ($globalDBdriver == 'mysql') { |
|
537 | + * Gets count Live Spotter data |
|
538 | + * |
|
539 | + * @return Array the spotter information |
|
540 | + * |
|
541 | + */ |
|
542 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
543 | + { |
|
544 | + global $globalDBdriver, $globalLiveInterval; |
|
545 | + date_default_timezone_set('UTC'); |
|
546 | + |
|
547 | + $filter_query = ''; |
|
548 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
549 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
550 | + } |
|
551 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
552 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
553 | + } |
|
554 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
555 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
556 | + } |
|
557 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
558 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
559 | + } |
|
560 | + |
|
561 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
562 | + if ($globalDBdriver == 'mysql') { |
|
563 | 563 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
564 | 564 | FROM spotter_archive l |
565 | 565 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
566 | - } else { |
|
566 | + } else { |
|
567 | 567 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
568 | - } |
|
569 | - //echo $query; |
|
570 | - try { |
|
571 | - $sth = $this->db->prepare($query); |
|
572 | - $sth->execute(); |
|
573 | - } catch(PDOException $e) { |
|
574 | - echo $e->getMessage(); |
|
575 | - die; |
|
576 | - } |
|
568 | + } |
|
569 | + //echo $query; |
|
570 | + try { |
|
571 | + $sth = $this->db->prepare($query); |
|
572 | + $sth->execute(); |
|
573 | + } catch(PDOException $e) { |
|
574 | + echo $e->getMessage(); |
|
575 | + die; |
|
576 | + } |
|
577 | 577 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
578 | 578 | $sth->closeCursor(); |
579 | - return $result['nb']; |
|
579 | + return $result['nb']; |
|
580 | 580 | |
581 | - } |
|
581 | + } |
|
582 | 582 | |
583 | 583 | |
584 | 584 | |
585 | 585 | // Spotter_Archive_output |
586 | 586 | |
587 | - /** |
|
588 | - * Gets all the spotter information |
|
589 | - * |
|
590 | - * @return Array the spotter information |
|
591 | - * |
|
592 | - */ |
|
593 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
594 | - { |
|
587 | + /** |
|
588 | + * Gets all the spotter information |
|
589 | + * |
|
590 | + * @return Array the spotter information |
|
591 | + * |
|
592 | + */ |
|
593 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
594 | + { |
|
595 | 595 | global $globalTimezone, $globalDBdriver; |
596 | 596 | require_once(dirname(__FILE__).'/class.Translation.php'); |
597 | 597 | $Translation = new Translation(); |
@@ -605,159 +605,159 @@ discard block |
||
605 | 605 | $filter_query = $this->getFilter($filters); |
606 | 606 | if ($q != "") |
607 | 607 | { |
608 | - if (!is_string($q)) |
|
609 | - { |
|
608 | + if (!is_string($q)) |
|
609 | + { |
|
610 | 610 | return false; |
611 | - } else { |
|
611 | + } else { |
|
612 | 612 | |
613 | 613 | $q_array = explode(" ", $q); |
614 | 614 | |
615 | 615 | foreach ($q_array as $q_item){ |
616 | - $additional_query .= " AND ("; |
|
617 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
618 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
619 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
620 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
621 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
622 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
623 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
624 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
625 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
626 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
627 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
628 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
629 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
630 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
631 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
632 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
633 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
634 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
635 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
636 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
637 | - $translate = $Translation->ident2icao($q_item); |
|
638 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
639 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
640 | - $additional_query .= ")"; |
|
641 | - } |
|
642 | - } |
|
616 | + $additional_query .= " AND ("; |
|
617 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
618 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
619 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
620 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
621 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
622 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
623 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
624 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
625 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
626 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
627 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
628 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
629 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
630 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
631 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
632 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
633 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
634 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
635 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
636 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
637 | + $translate = $Translation->ident2icao($q_item); |
|
638 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
639 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
640 | + $additional_query .= ")"; |
|
641 | + } |
|
642 | + } |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | if ($registration != "") |
646 | 646 | { |
647 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
648 | - if (!is_string($registration)) |
|
649 | - { |
|
647 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
648 | + if (!is_string($registration)) |
|
649 | + { |
|
650 | 650 | return false; |
651 | - } else { |
|
651 | + } else { |
|
652 | 652 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
653 | - } |
|
653 | + } |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | if ($aircraft_icao != "") |
657 | 657 | { |
658 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
659 | - if (!is_string($aircraft_icao)) |
|
660 | - { |
|
658 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
659 | + if (!is_string($aircraft_icao)) |
|
660 | + { |
|
661 | 661 | return false; |
662 | - } else { |
|
662 | + } else { |
|
663 | 663 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
664 | - } |
|
664 | + } |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | if ($aircraft_manufacturer != "") |
668 | 668 | { |
669 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
670 | - if (!is_string($aircraft_manufacturer)) |
|
671 | - { |
|
669 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
670 | + if (!is_string($aircraft_manufacturer)) |
|
671 | + { |
|
672 | 672 | return false; |
673 | - } else { |
|
673 | + } else { |
|
674 | 674 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
675 | - } |
|
675 | + } |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | if ($highlights == "true") |
679 | 679 | { |
680 | - if (!is_string($highlights)) |
|
681 | - { |
|
680 | + if (!is_string($highlights)) |
|
681 | + { |
|
682 | 682 | return false; |
683 | - } else { |
|
683 | + } else { |
|
684 | 684 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
685 | - } |
|
685 | + } |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | if ($airline_icao != "") |
689 | 689 | { |
690 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
691 | - if (!is_string($airline_icao)) |
|
692 | - { |
|
690 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
691 | + if (!is_string($airline_icao)) |
|
692 | + { |
|
693 | 693 | return false; |
694 | - } else { |
|
694 | + } else { |
|
695 | 695 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
696 | - } |
|
696 | + } |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | if ($airline_country != "") |
700 | 700 | { |
701 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
702 | - if (!is_string($airline_country)) |
|
703 | - { |
|
701 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
702 | + if (!is_string($airline_country)) |
|
703 | + { |
|
704 | 704 | return false; |
705 | - } else { |
|
705 | + } else { |
|
706 | 706 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
707 | - } |
|
707 | + } |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | if ($airline_type != "") |
711 | 711 | { |
712 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
713 | - if (!is_string($airline_type)) |
|
714 | - { |
|
712 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
713 | + if (!is_string($airline_type)) |
|
714 | + { |
|
715 | 715 | return false; |
716 | - } else { |
|
716 | + } else { |
|
717 | 717 | if ($airline_type == "passenger") |
718 | 718 | { |
719 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
719 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
720 | 720 | } |
721 | 721 | if ($airline_type == "cargo") |
722 | 722 | { |
723 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
723 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
724 | 724 | } |
725 | 725 | if ($airline_type == "military") |
726 | 726 | { |
727 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
727 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
728 | + } |
|
728 | 729 | } |
729 | - } |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | if ($airport != "") |
733 | 733 | { |
734 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
735 | - if (!is_string($airport)) |
|
736 | - { |
|
734 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
735 | + if (!is_string($airport)) |
|
736 | + { |
|
737 | 737 | return false; |
738 | - } else { |
|
738 | + } else { |
|
739 | 739 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
740 | - } |
|
740 | + } |
|
741 | 741 | } |
742 | 742 | |
743 | 743 | if ($airport_country != "") |
744 | 744 | { |
745 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
746 | - if (!is_string($airport_country)) |
|
747 | - { |
|
745 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
746 | + if (!is_string($airport_country)) |
|
747 | + { |
|
748 | 748 | return false; |
749 | - } else { |
|
749 | + } else { |
|
750 | 750 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
751 | - } |
|
751 | + } |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | if ($callsign != "") |
755 | 755 | { |
756 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
757 | - if (!is_string($callsign)) |
|
758 | - { |
|
756 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
757 | + if (!is_string($callsign)) |
|
758 | + { |
|
759 | 759 | return false; |
760 | - } else { |
|
760 | + } else { |
|
761 | 761 | $translate = $Translation->ident2icao($callsign); |
762 | 762 | if ($translate != $callsign) { |
763 | 763 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -765,99 +765,99 @@ discard block |
||
765 | 765 | } else { |
766 | 766 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
767 | 767 | } |
768 | - } |
|
768 | + } |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | if ($owner != "") |
772 | 772 | { |
773 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
774 | - if (!is_string($owner)) |
|
775 | - { |
|
773 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
774 | + if (!is_string($owner)) |
|
775 | + { |
|
776 | 776 | return false; |
777 | - } else { |
|
777 | + } else { |
|
778 | 778 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
779 | - } |
|
779 | + } |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | if ($pilot_name != "") |
783 | 783 | { |
784 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
785 | - if (!is_string($pilot_name)) |
|
786 | - { |
|
784 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
785 | + if (!is_string($pilot_name)) |
|
786 | + { |
|
787 | 787 | return false; |
788 | - } else { |
|
788 | + } else { |
|
789 | 789 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
790 | - } |
|
790 | + } |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | if ($pilot_id != "") |
794 | 794 | { |
795 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
796 | - if (!is_string($pilot_id)) |
|
797 | - { |
|
795 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
796 | + if (!is_string($pilot_id)) |
|
797 | + { |
|
798 | 798 | return false; |
799 | - } else { |
|
799 | + } else { |
|
800 | 800 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
801 | - } |
|
801 | + } |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | if ($departure_airport_route != "") |
805 | 805 | { |
806 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
807 | - if (!is_string($departure_airport_route)) |
|
808 | - { |
|
806 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
807 | + if (!is_string($departure_airport_route)) |
|
808 | + { |
|
809 | 809 | return false; |
810 | - } else { |
|
810 | + } else { |
|
811 | 811 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
812 | - } |
|
812 | + } |
|
813 | 813 | } |
814 | 814 | |
815 | 815 | if ($arrival_airport_route != "") |
816 | 816 | { |
817 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
818 | - if (!is_string($arrival_airport_route)) |
|
819 | - { |
|
817 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
818 | + if (!is_string($arrival_airport_route)) |
|
819 | + { |
|
820 | 820 | return false; |
821 | - } else { |
|
821 | + } else { |
|
822 | 822 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
823 | - } |
|
823 | + } |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | if ($altitude != "") |
827 | 827 | { |
828 | - $altitude_array = explode(",", $altitude); |
|
828 | + $altitude_array = explode(",", $altitude); |
|
829 | 829 | |
830 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
831 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
830 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
831 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
832 | 832 | |
833 | 833 | |
834 | - if ($altitude_array[1] != "") |
|
835 | - { |
|
834 | + if ($altitude_array[1] != "") |
|
835 | + { |
|
836 | 836 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
837 | 837 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
838 | 838 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
839 | - } else { |
|
839 | + } else { |
|
840 | 840 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
841 | 841 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
842 | - } |
|
842 | + } |
|
843 | 843 | } |
844 | 844 | |
845 | 845 | if ($date_posted != "") |
846 | 846 | { |
847 | - $date_array = explode(",", $date_posted); |
|
847 | + $date_array = explode(",", $date_posted); |
|
848 | 848 | |
849 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
850 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
849 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
850 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
851 | 851 | |
852 | - if ($globalTimezone != '') { |
|
852 | + if ($globalTimezone != '') { |
|
853 | 853 | date_default_timezone_set($globalTimezone); |
854 | 854 | $datetime = new DateTime(); |
855 | 855 | $offset = $datetime->format('P'); |
856 | - } else $offset = '+00:00'; |
|
856 | + } else $offset = '+00:00'; |
|
857 | 857 | |
858 | 858 | |
859 | - if ($date_array[1] != "") |
|
860 | - { |
|
859 | + if ($date_array[1] != "") |
|
860 | + { |
|
861 | 861 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
862 | 862 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
863 | 863 | if ($globalDBdriver == 'mysql') { |
@@ -865,28 +865,28 @@ discard block |
||
865 | 865 | } else { |
866 | 866 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
867 | 867 | } |
868 | - } else { |
|
868 | + } else { |
|
869 | 869 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
870 | - if ($globalDBdriver == 'mysql') { |
|
870 | + if ($globalDBdriver == 'mysql') { |
|
871 | 871 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
872 | 872 | } else { |
873 | 873 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
874 | 874 | } |
875 | - } |
|
875 | + } |
|
876 | 876 | } |
877 | 877 | |
878 | 878 | if ($limit != "") |
879 | 879 | { |
880 | - $limit_array = explode(",", $limit); |
|
880 | + $limit_array = explode(",", $limit); |
|
881 | 881 | |
882 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
883 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
882 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
883 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
884 | 884 | |
885 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
886 | - { |
|
885 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
886 | + { |
|
887 | 887 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
888 | 888 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
889 | - } |
|
889 | + } |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | |
@@ -917,33 +917,33 @@ discard block |
||
917 | 917 | $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
918 | 918 | |
919 | 919 | return $spotter_array; |
920 | - } |
|
920 | + } |
|
921 | 921 | |
922 | - public function deleteSpotterArchiveData() |
|
923 | - { |
|
922 | + public function deleteSpotterArchiveData() |
|
923 | + { |
|
924 | 924 | global $globalArchiveKeepMonths, $globalDBdriver; |
925 | - date_default_timezone_set('UTC'); |
|
926 | - if ($globalDBdriver == 'mysql') { |
|
925 | + date_default_timezone_set('UTC'); |
|
926 | + if ($globalDBdriver == 'mysql') { |
|
927 | 927 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
928 | 928 | } else { |
929 | 929 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
930 | 930 | } |
931 | - try { |
|
932 | - $sth = $this->db->prepare($query); |
|
933 | - $sth->execute(); |
|
934 | - } catch(PDOException $e) { |
|
935 | - return "error"; |
|
936 | - } |
|
931 | + try { |
|
932 | + $sth = $this->db->prepare($query); |
|
933 | + $sth->execute(); |
|
934 | + } catch(PDOException $e) { |
|
935 | + return "error"; |
|
936 | + } |
|
937 | 937 | } |
938 | 938 | |
939 | - /** |
|
940 | - * Gets all the spotter information based on the callsign |
|
941 | - * |
|
942 | - * @return Array the spotter information |
|
943 | - * |
|
944 | - */ |
|
945 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
946 | - { |
|
939 | + /** |
|
940 | + * Gets all the spotter information based on the callsign |
|
941 | + * |
|
942 | + * @return Array the spotter information |
|
943 | + * |
|
944 | + */ |
|
945 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
946 | + { |
|
947 | 947 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
948 | 948 | |
949 | 949 | date_default_timezone_set('UTC'); |
@@ -955,35 +955,35 @@ discard block |
||
955 | 955 | |
956 | 956 | if ($ident != "") |
957 | 957 | { |
958 | - if (!is_string($ident)) |
|
959 | - { |
|
958 | + if (!is_string($ident)) |
|
959 | + { |
|
960 | 960 | return false; |
961 | - } else { |
|
961 | + } else { |
|
962 | 962 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
963 | 963 | $query_values = array(':ident' => $ident); |
964 | - } |
|
964 | + } |
|
965 | 965 | } |
966 | 966 | |
967 | 967 | if ($limit != "") |
968 | 968 | { |
969 | - $limit_array = explode(",", $limit); |
|
969 | + $limit_array = explode(",", $limit); |
|
970 | 970 | |
971 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
972 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
971 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
972 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
973 | 973 | |
974 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
975 | - { |
|
974 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
975 | + { |
|
976 | 976 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
977 | 977 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
978 | - } |
|
978 | + } |
|
979 | 979 | } |
980 | 980 | |
981 | 981 | if ($sort != "") |
982 | 982 | { |
983 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
984 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
983 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
984 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
985 | 985 | } else { |
986 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
986 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -991,17 +991,17 @@ discard block |
||
991 | 991 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
992 | 992 | |
993 | 993 | return $spotter_array; |
994 | - } |
|
994 | + } |
|
995 | 995 | |
996 | 996 | |
997 | - /** |
|
998 | - * Gets all the spotter information based on the owner |
|
999 | - * |
|
1000 | - * @return Array the spotter information |
|
1001 | - * |
|
1002 | - */ |
|
1003 | - public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
1004 | - { |
|
997 | + /** |
|
998 | + * Gets all the spotter information based on the owner |
|
999 | + * |
|
1000 | + * @return Array the spotter information |
|
1001 | + * |
|
1002 | + */ |
|
1003 | + public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
1004 | + { |
|
1005 | 1005 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
1006 | 1006 | |
1007 | 1007 | date_default_timezone_set('UTC'); |
@@ -1014,35 +1014,35 @@ discard block |
||
1014 | 1014 | |
1015 | 1015 | if ($owner != "") |
1016 | 1016 | { |
1017 | - if (!is_string($owner)) |
|
1018 | - { |
|
1017 | + if (!is_string($owner)) |
|
1018 | + { |
|
1019 | 1019 | return false; |
1020 | - } else { |
|
1020 | + } else { |
|
1021 | 1021 | $additional_query = " AND (spotter_archive_output.owner_name = :owner)"; |
1022 | 1022 | $query_values = array(':owner' => $owner); |
1023 | - } |
|
1023 | + } |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | if ($limit != "") |
1027 | 1027 | { |
1028 | - $limit_array = explode(",", $limit); |
|
1028 | + $limit_array = explode(",", $limit); |
|
1029 | 1029 | |
1030 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1031 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1030 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1031 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1032 | 1032 | |
1033 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1034 | - { |
|
1033 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1034 | + { |
|
1035 | 1035 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1036 | 1036 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1037 | - } |
|
1037 | + } |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | if ($sort != "") |
1041 | 1041 | { |
1042 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1043 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1042 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1043 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1044 | 1044 | } else { |
1045 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1045 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | $query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1050,16 +1050,16 @@ discard block |
||
1050 | 1050 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1051 | 1051 | |
1052 | 1052 | return $spotter_array; |
1053 | - } |
|
1054 | - |
|
1055 | - /** |
|
1056 | - * Gets all the spotter information based on the pilot |
|
1057 | - * |
|
1058 | - * @return Array the spotter information |
|
1059 | - * |
|
1060 | - */ |
|
1061 | - public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1062 | - { |
|
1053 | + } |
|
1054 | + |
|
1055 | + /** |
|
1056 | + * Gets all the spotter information based on the pilot |
|
1057 | + * |
|
1058 | + * @return Array the spotter information |
|
1059 | + * |
|
1060 | + */ |
|
1061 | + public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1062 | + { |
|
1063 | 1063 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
1064 | 1064 | |
1065 | 1065 | date_default_timezone_set('UTC'); |
@@ -1078,24 +1078,24 @@ discard block |
||
1078 | 1078 | |
1079 | 1079 | if ($limit != "") |
1080 | 1080 | { |
1081 | - $limit_array = explode(",", $limit); |
|
1081 | + $limit_array = explode(",", $limit); |
|
1082 | 1082 | |
1083 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1084 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1083 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1084 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1085 | 1085 | |
1086 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1087 | - { |
|
1086 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1087 | + { |
|
1088 | 1088 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1089 | 1089 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1090 | - } |
|
1090 | + } |
|
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | if ($sort != "") |
1094 | 1094 | { |
1095 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1096 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1095 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1096 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1097 | 1097 | } else { |
1098 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1098 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | $query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1103,16 +1103,16 @@ discard block |
||
1103 | 1103 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1104 | 1104 | |
1105 | 1105 | return $spotter_array; |
1106 | - } |
|
1107 | - |
|
1108 | - /** |
|
1109 | - * Gets all number of flight over countries |
|
1110 | - * |
|
1111 | - * @return Array the airline country list |
|
1112 | - * |
|
1113 | - */ |
|
1114 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1115 | - { |
|
1106 | + } |
|
1107 | + |
|
1108 | + /** |
|
1109 | + * Gets all number of flight over countries |
|
1110 | + * |
|
1111 | + * @return Array the airline country list |
|
1112 | + * |
|
1113 | + */ |
|
1114 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1115 | + { |
|
1116 | 1116 | global $globalDBdriver; |
1117 | 1117 | /* |
1118 | 1118 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1122,14 +1122,14 @@ discard block |
||
1122 | 1122 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1123 | 1123 | FROM countries c, spotter_archive s |
1124 | 1124 | WHERE c.iso2 = s.over_country "; |
1125 | - if ($olderthanmonths > 0) { |
|
1126 | - if ($globalDBdriver == 'mysql') { |
|
1125 | + if ($olderthanmonths > 0) { |
|
1126 | + if ($globalDBdriver == 'mysql') { |
|
1127 | 1127 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1128 | 1128 | } else { |
1129 | 1129 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1130 | 1130 | } |
1131 | 1131 | } |
1132 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1132 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1133 | 1133 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1134 | 1134 | if ($limit) $query .= " LIMIT 0,10"; |
1135 | 1135 | |
@@ -1142,23 +1142,23 @@ discard block |
||
1142 | 1142 | |
1143 | 1143 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1144 | 1144 | { |
1145 | - $temp_array['flight_count'] = $row['nb']; |
|
1146 | - $temp_array['flight_country'] = $row['name']; |
|
1147 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1148 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1149 | - $flight_array[] = $temp_array; |
|
1145 | + $temp_array['flight_count'] = $row['nb']; |
|
1146 | + $temp_array['flight_country'] = $row['name']; |
|
1147 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1148 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1149 | + $flight_array[] = $temp_array; |
|
1150 | 1150 | } |
1151 | 1151 | return $flight_array; |
1152 | - } |
|
1153 | - |
|
1154 | - /** |
|
1155 | - * Gets all number of flight over countries |
|
1156 | - * |
|
1157 | - * @return Array the airline country list |
|
1158 | - * |
|
1159 | - */ |
|
1160 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1161 | - { |
|
1152 | + } |
|
1153 | + |
|
1154 | + /** |
|
1155 | + * Gets all number of flight over countries |
|
1156 | + * |
|
1157 | + * @return Array the airline country list |
|
1158 | + * |
|
1159 | + */ |
|
1160 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1161 | + { |
|
1162 | 1162 | global $globalDBdriver; |
1163 | 1163 | /* |
1164 | 1164 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1168,14 +1168,14 @@ discard block |
||
1168 | 1168 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1169 | 1169 | FROM countries c, spotter_archive s, spotter_output o |
1170 | 1170 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id "; |
1171 | - if ($olderthanmonths > 0) { |
|
1172 | - if ($globalDBdriver == 'mysql') { |
|
1171 | + if ($olderthanmonths > 0) { |
|
1172 | + if ($globalDBdriver == 'mysql') { |
|
1173 | 1173 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1174 | 1174 | } else { |
1175 | 1175 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1176 | 1176 | } |
1177 | 1177 | } |
1178 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1178 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1179 | 1179 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1180 | 1180 | if ($limit) $query .= " LIMIT 0,10"; |
1181 | 1181 | |
@@ -1188,24 +1188,24 @@ discard block |
||
1188 | 1188 | |
1189 | 1189 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1190 | 1190 | { |
1191 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1192 | - $temp_array['flight_count'] = $row['nb']; |
|
1193 | - $temp_array['flight_country'] = $row['name']; |
|
1194 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1195 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1196 | - $flight_array[] = $temp_array; |
|
1191 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1192 | + $temp_array['flight_count'] = $row['nb']; |
|
1193 | + $temp_array['flight_country'] = $row['name']; |
|
1194 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1195 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1196 | + $flight_array[] = $temp_array; |
|
1197 | 1197 | } |
1198 | 1198 | return $flight_array; |
1199 | - } |
|
1200 | - |
|
1201 | - /** |
|
1202 | - * Gets last spotter information based on a particular callsign |
|
1203 | - * |
|
1204 | - * @return Array the spotter information |
|
1205 | - * |
|
1206 | - */ |
|
1207 | - public function getDateArchiveSpotterDataById($id,$date) |
|
1208 | - { |
|
1199 | + } |
|
1200 | + |
|
1201 | + /** |
|
1202 | + * Gets last spotter information based on a particular callsign |
|
1203 | + * |
|
1204 | + * @return Array the spotter information |
|
1205 | + * |
|
1206 | + */ |
|
1207 | + public function getDateArchiveSpotterDataById($id,$date) |
|
1208 | + { |
|
1209 | 1209 | $Spotter = new Spotter($this->db); |
1210 | 1210 | date_default_timezone_set('UTC'); |
1211 | 1211 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1213,16 +1213,16 @@ discard block |
||
1213 | 1213 | $date = date('c',$date); |
1214 | 1214 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1215 | 1215 | return $spotter_array; |
1216 | - } |
|
1217 | - |
|
1218 | - /** |
|
1219 | - * Gets all the spotter information based on a particular callsign |
|
1220 | - * |
|
1221 | - * @return Array the spotter information |
|
1222 | - * |
|
1223 | - */ |
|
1224 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1225 | - { |
|
1216 | + } |
|
1217 | + |
|
1218 | + /** |
|
1219 | + * Gets all the spotter information based on a particular callsign |
|
1220 | + * |
|
1221 | + * @return Array the spotter information |
|
1222 | + * |
|
1223 | + */ |
|
1224 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1225 | + { |
|
1226 | 1226 | $Spotter = new Spotter($this->db); |
1227 | 1227 | date_default_timezone_set('UTC'); |
1228 | 1228 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1230,16 +1230,16 @@ discard block |
||
1230 | 1230 | $date = date('c',$date); |
1231 | 1231 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1232 | 1232 | return $spotter_array; |
1233 | - } |
|
1234 | - |
|
1235 | - /** |
|
1236 | - * Gets all the spotter information based on the airport |
|
1237 | - * |
|
1238 | - * @return Array the spotter information |
|
1239 | - * |
|
1240 | - */ |
|
1241 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1242 | - { |
|
1233 | + } |
|
1234 | + |
|
1235 | + /** |
|
1236 | + * Gets all the spotter information based on the airport |
|
1237 | + * |
|
1238 | + * @return Array the spotter information |
|
1239 | + * |
|
1240 | + */ |
|
1241 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1242 | + { |
|
1243 | 1243 | global $global_query; |
1244 | 1244 | $Spotter = new Spotter(); |
1245 | 1245 | date_default_timezone_set('UTC'); |
@@ -1250,35 +1250,35 @@ discard block |
||
1250 | 1250 | |
1251 | 1251 | if ($airport != "") |
1252 | 1252 | { |
1253 | - if (!is_string($airport)) |
|
1254 | - { |
|
1253 | + if (!is_string($airport)) |
|
1254 | + { |
|
1255 | 1255 | return false; |
1256 | - } else { |
|
1256 | + } else { |
|
1257 | 1257 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
1258 | 1258 | $query_values = array(':airport' => $airport); |
1259 | - } |
|
1259 | + } |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | if ($limit != "") |
1263 | 1263 | { |
1264 | - $limit_array = explode(",", $limit); |
|
1264 | + $limit_array = explode(",", $limit); |
|
1265 | 1265 | |
1266 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1267 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1266 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1267 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1268 | 1268 | |
1269 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1270 | - { |
|
1269 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1270 | + { |
|
1271 | 1271 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1272 | 1272 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1273 | - } |
|
1273 | + } |
|
1274 | 1274 | } |
1275 | 1275 | |
1276 | 1276 | if ($sort != "") |
1277 | 1277 | { |
1278 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1279 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1278 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1279 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1280 | 1280 | } else { |
1281 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1281 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | 1284 | $query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1286,6 +1286,6 @@ discard block |
||
1286 | 1286 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1287 | 1287 | |
1288 | 1288 | return $spotter_array; |
1289 | - } |
|
1289 | + } |
|
1290 | 1290 | } |
1291 | 1291 | ?> |
1292 | 1292 | \ No newline at end of file |
@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Stats.php'); |
10 | 10 | require_once(dirname(__FILE__).'/class.Source.php'); |
11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | class MarineImport { |
16 | - private $all_tracked = array(); |
|
17 | - private $last_delete_hourly = 0; |
|
18 | - private $last_delete = 0; |
|
19 | - private $stats = array(); |
|
20 | - private $tmd = 0; |
|
21 | - private $source_location = array(); |
|
22 | - public $db = null; |
|
23 | - public $nb = 0; |
|
16 | + private $all_tracked = array(); |
|
17 | + private $last_delete_hourly = 0; |
|
18 | + private $last_delete = 0; |
|
19 | + private $stats = array(); |
|
20 | + private $tmd = 0; |
|
21 | + private $source_location = array(); |
|
22 | + public $db = null; |
|
23 | + public $nb = 0; |
|
24 | 24 | |
25 | - public function __construct($dbc = null) { |
|
25 | + public function __construct($dbc = null) { |
|
26 | 26 | global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB; |
27 | 27 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
28 | - $Connection = new Connection($dbc); |
|
29 | - $this->db = $Connection->db(); |
|
30 | - date_default_timezone_set('UTC'); |
|
28 | + $Connection = new Connection($dbc); |
|
29 | + $this->db = $Connection->db(); |
|
30 | + date_default_timezone_set('UTC'); |
|
31 | 31 | } |
32 | 32 | // Get previous source stats |
33 | 33 | /* |
@@ -46,55 +46,55 @@ discard block |
||
46 | 46 | } |
47 | 47 | */ |
48 | 48 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
49 | - $APRSMarine = new APRSMarine(); |
|
50 | - //$APRSSpotter->connect(); |
|
49 | + $APRSMarine = new APRSMarine(); |
|
50 | + //$APRSSpotter->connect(); |
|
51 | + } |
|
51 | 52 | } |
52 | - } |
|
53 | 53 | |
54 | - public function checkAll() { |
|
54 | + public function checkAll() { |
|
55 | 55 | global $globalDebug; |
56 | 56 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
57 | 57 | foreach ($this->all_tracked as $key => $flight) { |
58 | - if (isset($this->all_tracked[$key]['id'])) { |
|
58 | + if (isset($this->all_tracked[$key]['id'])) { |
|
59 | 59 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
60 | - $Marine = new Marine($this->db); |
|
61 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
62 | - } |
|
60 | + $Marine = new Marine($this->db); |
|
61 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
62 | + } |
|
63 | + } |
|
63 | 64 | } |
64 | - } |
|
65 | 65 | |
66 | - public function del() { |
|
66 | + public function del() { |
|
67 | 67 | global $globalDebug, $globalNoDB, $globalNoImport; |
68 | 68 | // Delete old infos |
69 | 69 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
70 | 70 | foreach ($this->all_tracked as $key => $flight) { |
71 | - if (isset($flight['lastupdate'])) { |
|
72 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
73 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
74 | - if (isset($this->all_tracked[$key]['id'])) { |
|
75 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
76 | - /* |
|
71 | + if (isset($flight['lastupdate'])) { |
|
72 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
73 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
74 | + if (isset($this->all_tracked[$key]['id'])) { |
|
75 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
76 | + /* |
|
77 | 77 | $MarineLive = new MarineLive(); |
78 | 78 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
79 | 79 | $MarineLive->db = null; |
80 | 80 | */ |
81 | - //$real_arrival = $this->arrival($key); |
|
82 | - $Marine = new Marine($this->db); |
|
83 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
81 | + //$real_arrival = $this->arrival($key); |
|
82 | + $Marine = new Marine($this->db); |
|
83 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
84 | 84 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
85 | 85 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
86 | - } |
|
87 | - // Put in archive |
|
86 | + } |
|
87 | + // Put in archive |
|
88 | 88 | // $Marine->db = null; |
89 | 89 | } |
90 | - } |
|
91 | - unset($this->all_tracked[$key]); |
|
92 | - } |
|
93 | - } |
|
94 | - } |
|
95 | - } |
|
90 | + } |
|
91 | + unset($this->all_tracked[$key]); |
|
92 | + } |
|
93 | + } |
|
94 | + } |
|
95 | + } |
|
96 | 96 | |
97 | - public function add($line) { |
|
97 | + public function add($line) { |
|
98 | 98 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
99 | 99 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
100 | 100 | date_default_timezone_set('UTC'); |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | |
104 | 104 | // SBS format is CSV format |
105 | 105 | if(is_array($line) && isset($line['mmsi'])) { |
106 | - //print_r($line); |
|
107 | - if (isset($line['mmsi'])) { |
|
106 | + //print_r($line); |
|
107 | + if (isset($line['mmsi'])) { |
|
108 | 108 | |
109 | 109 | /* |
110 | 110 | // Increment message number |
@@ -121,64 +121,64 @@ discard block |
||
121 | 121 | |
122 | 122 | $Common = new Common(); |
123 | 123 | $AIS = new AIS(); |
124 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
125 | - else $id = trim($line['id']); |
|
124 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
125 | + else $id = trim($line['id']); |
|
126 | 126 | |
127 | 127 | if (!isset($this->all_tracked[$id])) { |
128 | - $this->all_tracked[$id] = array(); |
|
129 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
130 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
131 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
132 | - if (!isset($line['id'])) { |
|
128 | + $this->all_tracked[$id] = array(); |
|
129 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
130 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
131 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
132 | + if (!isset($line['id'])) { |
|
133 | 133 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
134 | 134 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
135 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
136 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
135 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
136 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
140 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
141 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
140 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
141 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
142 | 142 | $Marine = new Marine($this->db); |
143 | 143 | $identity = $Marine->getIdentity($line['mmsi']); |
144 | 144 | if (!empty($identity)) { |
145 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
146 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
145 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
146 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
147 | 147 | } |
148 | 148 | //print_r($identity); |
149 | 149 | unset($Marine); |
150 | 150 | //$dataFound = true; |
151 | - } |
|
151 | + } |
|
152 | 152 | } |
153 | 153 | if (isset($line['type_id']) && $line['type_id'] != '') { |
154 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
154 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
155 | 155 | } |
156 | 156 | if (isset($line['type']) && $line['type'] != '') { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
158 | 158 | } |
159 | 159 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
160 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
160 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
161 | 161 | } |
162 | 162 | if (isset($line['imo']) && $line['imo'] != '') { |
163 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
163 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
164 | 164 | } |
165 | 165 | if (isset($line['callsign']) && $line['callsign'] != '') { |
166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
167 | 167 | } |
168 | 168 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
169 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
169 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
170 | 170 | } |
171 | 171 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
172 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
172 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | |
176 | 176 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
177 | 177 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
178 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
179 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
178 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
179 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
180 | 180 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
181 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
181 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
182 | 182 | $timeelapsed = microtime(true); |
183 | 183 | $Marine = new Marine($this->db); |
184 | 184 | $fromsource = NULL; |
@@ -186,20 +186,20 @@ discard block |
||
186 | 186 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
187 | 187 | $Marine->db = null; |
188 | 188 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
189 | - } |
|
189 | + } |
|
190 | 190 | } |
191 | - } |
|
192 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
191 | + } |
|
192 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
196 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
196 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
197 | 197 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
198 | - } else { |
|
198 | + } else { |
|
199 | 199 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
200 | 200 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
201 | 201 | return ''; |
202 | - } |
|
202 | + } |
|
203 | 203 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
204 | 204 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
205 | 205 | return ''; |
@@ -216,24 +216,24 @@ discard block |
||
216 | 216 | |
217 | 217 | |
218 | 218 | if (isset($line['speed']) && $line['speed'] != '') { |
219 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
220 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
219 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
220 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
221 | 221 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
222 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
223 | - if ($distance > 1000 && $distance < 10000) { |
|
222 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
223 | + if ($distance > 1000 && $distance < 10000) { |
|
224 | 224 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
225 | 225 | $speed = $speed*3.6; |
226 | 226 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
227 | 227 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
228 | - } |
|
228 | + } |
|
229 | 229 | } |
230 | 230 | |
231 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
232 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
233 | - else unset($timediff); |
|
234 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
231 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
232 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
233 | + else unset($timediff); |
|
234 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
235 | 235 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
236 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
236 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
237 | 237 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
238 | 238 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
239 | 239 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -241,123 +241,123 @@ discard block |
||
241 | 241 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
242 | 242 | $timeelapsed = microtime(true); |
243 | 243 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
244 | - $Marine = new Marine($this->db); |
|
245 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
246 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
247 | - $Marine->db = null; |
|
248 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
244 | + $Marine = new Marine($this->db); |
|
245 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
246 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
247 | + $Marine->db = null; |
|
248 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
249 | 249 | } |
250 | 250 | $this->tmd = 0; |
251 | 251 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
252 | - } |
|
252 | + } |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
256 | 256 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
257 | 257 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
258 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
259 | - $dataFound = true; |
|
260 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
258 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
259 | + $dataFound = true; |
|
260 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
261 | 261 | } |
262 | 262 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
263 | 263 | } |
264 | 264 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
265 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
265 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
266 | 266 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
267 | 267 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
268 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
269 | - $dataFound = true; |
|
270 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
268 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
269 | + $dataFound = true; |
|
270 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
271 | 271 | } |
272 | 272 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
273 | 273 | } |
274 | 274 | |
275 | - } else if ($globalDebug && $timediff > 20) { |
|
275 | + } else if ($globalDebug && $timediff > 20) { |
|
276 | 276 | $this->tmd = $this->tmd + 1; |
277 | 277 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
278 | 278 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
279 | 279 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
280 | 280 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
281 | - } |
|
281 | + } |
|
282 | 282 | } |
283 | 283 | if (isset($line['last_update']) && $line['last_update'] != '') { |
284 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
285 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
284 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
285 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
286 | 286 | } |
287 | 287 | if (isset($line['format_source']) && $line['format_source'] != '') { |
288 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
288 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
289 | 289 | } |
290 | 290 | if (isset($line['source_name']) && $line['source_name'] != '') { |
291 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
291 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
292 | 292 | } |
293 | 293 | if (isset($line['status']) && $line['status'] != '') { |
294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
298 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
298 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | if (isset($line['heading']) && $line['heading'] != '') { |
302 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
303 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
304 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
305 | - //$dataFound = true; |
|
302 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
303 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
304 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
305 | + //$dataFound = true; |
|
306 | 306 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
307 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
308 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
309 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
310 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
307 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
308 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
309 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
310 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
311 | 311 | } |
312 | 312 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
313 | 313 | |
314 | 314 | |
315 | 315 | |
316 | 316 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
317 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
318 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
319 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
320 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
317 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
318 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
319 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
320 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
321 | 321 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
322 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
323 | - $timeelapsed = microtime(true); |
|
324 | - $MarineLive = new MarineLive($this->db); |
|
325 | - if (isset($line['id'])) { |
|
322 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
323 | + $timeelapsed = microtime(true); |
|
324 | + $MarineLive = new MarineLive($this->db); |
|
325 | + if (isset($line['id'])) { |
|
326 | 326 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
327 | 327 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
328 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
328 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
329 | 329 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
330 | 330 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
331 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
331 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
332 | 332 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
333 | 333 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
334 | - } else $recent_ident = ''; |
|
335 | - $MarineLive->db=null; |
|
336 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
337 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
334 | + } else $recent_ident = ''; |
|
335 | + $MarineLive->db=null; |
|
336 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
337 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
338 | 338 | } else $recent_ident = ''; |
339 | - } else { |
|
339 | + } else { |
|
340 | 340 | $recent_ident = ''; |
341 | 341 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
342 | - } |
|
343 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
344 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
345 | - { |
|
342 | + } |
|
343 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
344 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
345 | + { |
|
346 | 346 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
347 | 347 | //adds the spotter data for the archive |
348 | - $highlight = ''; |
|
349 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
350 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
348 | + $highlight = ''; |
|
349 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
350 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
351 | 351 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
352 | - $timeelapsed = microtime(true); |
|
353 | - $Marine = new Marine($this->db); |
|
354 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
355 | - $Marine->db = null; |
|
356 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
357 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
352 | + $timeelapsed = microtime(true); |
|
353 | + $Marine = new Marine($this->db); |
|
354 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
355 | + $Marine->db = null; |
|
356 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
357 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
358 | 358 | } |
359 | - } |
|
360 | - /* |
|
359 | + } |
|
360 | + /* |
|
361 | 361 | // Add source stat in DB |
362 | 362 | $Stats = new Stats($this->db); |
363 | 363 | if (!empty($this->stats)) { |
@@ -384,56 +384,56 @@ discard block |
||
384 | 384 | } |
385 | 385 | $Stats->db = null; |
386 | 386 | */ |
387 | - $this->del(); |
|
387 | + $this->del(); |
|
388 | 388 | //$ignoreImport = false; |
389 | 389 | $this->all_tracked[$id]['addedMarine'] = 1; |
390 | 390 | //print_r($this->all_tracked[$id]); |
391 | 391 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
392 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
393 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
394 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
392 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
393 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
394 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
395 | 395 | $MarineLive = new MarineLive($this->db); |
396 | 396 | $MarineLive->deleteLiveMarineData(); |
397 | 397 | $MarineLive->db=null; |
398 | 398 | if ($globalDebug) echo " Done\n"; |
399 | - } |
|
400 | - $this->last_delete = time(); |
|
399 | + } |
|
400 | + $this->last_delete = time(); |
|
401 | 401 | } |
402 | - } elseif ($recent_ident != '') { |
|
402 | + } elseif ($recent_ident != '') { |
|
403 | 403 | $this->all_tracked[$id]['id'] = $recent_ident; |
404 | 404 | $this->all_tracked[$id]['addedMarine'] = 1; |
405 | 405 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
406 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
406 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
407 | 407 | $Marine = new Marine($this->db); |
408 | 408 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
409 | 409 | $Marine->db = null; |
410 | - } |
|
410 | + } |
|
411 | 411 | } |
412 | 412 | |
413 | - } |
|
413 | + } |
|
414 | 414 | } |
415 | - } |
|
416 | - //adds the spotter LIVE data |
|
417 | - if ($globalDebug) { |
|
415 | + } |
|
416 | + //adds the spotter LIVE data |
|
417 | + if ($globalDebug) { |
|
418 | 418 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
419 | - } |
|
420 | - $ignoreImport = false; |
|
419 | + } |
|
420 | + $ignoreImport = false; |
|
421 | 421 | |
422 | - if (!$ignoreImport) { |
|
422 | + if (!$ignoreImport) { |
|
423 | 423 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
424 | 424 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
425 | 425 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
426 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
426 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
427 | 427 | $timeelapsed = microtime(true); |
428 | 428 | $MarineLive = new MarineLive($this->db); |
429 | 429 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
430 | 430 | $MarineLive->db = null; |
431 | 431 | if ($globalDebug) echo $result."\n"; |
432 | 432 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
433 | - } |
|
433 | + } |
|
434 | 434 | } |
435 | 435 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
436 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
436 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
437 | 437 | } |
438 | 438 | $this->all_tracked[$id]['putinarchive'] = false; |
439 | 439 | |
@@ -498,24 +498,24 @@ discard block |
||
498 | 498 | |
499 | 499 | |
500 | 500 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
501 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
501 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
502 | 502 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
503 | 503 | $MarineLive = new MarineLive($this->db); |
504 | 504 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
505 | 505 | $MarineLive->db = null; |
506 | 506 | //MarineLive->deleteLiveMarineData(); |
507 | 507 | if ($globalDebug) echo " Done\n"; |
508 | - } |
|
509 | - $this->last_delete_hourly = time(); |
|
508 | + } |
|
509 | + $this->last_delete_hourly = time(); |
|
510 | 510 | } |
511 | 511 | |
512 | - } |
|
513 | - //$ignoreImport = false; |
|
512 | + } |
|
513 | + //$ignoreImport = false; |
|
514 | 514 | } |
515 | 515 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
516 | 516 | if ($send) return $this->all_tracked[$id]; |
517 | - } |
|
517 | + } |
|
518 | + } |
|
518 | 519 | } |
519 | - } |
|
520 | 520 | } |
521 | 521 | ?> |
@@ -9,16 +9,16 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
10 | 10 | |
11 | 11 | class TrackerImport { |
12 | - private $all_tracked = array(); |
|
13 | - private $last_delete_hourly = 0; |
|
14 | - private $last_delete = 0; |
|
15 | - private $stats = array(); |
|
16 | - private $tmd = 0; |
|
17 | - private $source_location = array(); |
|
18 | - public $db = null; |
|
19 | - public $nb = 0; |
|
12 | + private $all_tracked = array(); |
|
13 | + private $last_delete_hourly = 0; |
|
14 | + private $last_delete = 0; |
|
15 | + private $stats = array(); |
|
16 | + private $tmd = 0; |
|
17 | + private $source_location = array(); |
|
18 | + public $db = null; |
|
19 | + public $nb = 0; |
|
20 | 20 | |
21 | - public function __construct($dbc = null) { |
|
21 | + public function __construct($dbc = null) { |
|
22 | 22 | global $globalBeta; |
23 | 23 | $Connection = new Connection($dbc); |
24 | 24 | $this->db = $Connection->db(); |
@@ -40,50 +40,50 @@ discard block |
||
40 | 40 | } |
41 | 41 | } |
42 | 42 | */ |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | - public function checkAll() { |
|
45 | + public function checkAll() { |
|
46 | 46 | global $globalDebug; |
47 | 47 | if ($globalDebug) echo "Update last seen tracked data...\n"; |
48 | 48 | foreach ($this->all_tracked as $key => $flight) { |
49 | - if (isset($this->all_tracked[$key]['id'])) { |
|
49 | + if (isset($this->all_tracked[$key]['id'])) { |
|
50 | 50 | //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
51 | - $Tracker = new Tracker($this->db); |
|
52 | - $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
53 | - } |
|
51 | + $Tracker = new Tracker($this->db); |
|
52 | + $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
53 | + } |
|
54 | + } |
|
54 | 55 | } |
55 | - } |
|
56 | 56 | |
57 | - public function del() { |
|
57 | + public function del() { |
|
58 | 58 | global $globalDebug; |
59 | 59 | // Delete old infos |
60 | 60 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
61 | 61 | foreach ($this->all_tracked as $key => $flight) { |
62 | - if (isset($flight['lastupdate'])) { |
|
63 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
64 | - if (isset($this->all_tracked[$key]['id'])) { |
|
65 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
62 | + if (isset($flight['lastupdate'])) { |
|
63 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
64 | + if (isset($this->all_tracked[$key]['id'])) { |
|
65 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
66 | 66 | /* |
67 | 67 | $TrackerLive = new TrackerLive(); |
68 | 68 | $TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']); |
69 | 69 | $TrackerLive->db = null; |
70 | 70 | */ |
71 | - //$real_arrival = $this->arrival($key); |
|
72 | - $Tracker = new Tracker($this->db); |
|
73 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
71 | + //$real_arrival = $this->arrival($key); |
|
72 | + $Tracker = new Tracker($this->db); |
|
73 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
74 | 74 | $result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']); |
75 | 75 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
76 | 76 | } |
77 | 77 | // Put in archive |
78 | 78 | // $Tracker->db = null; |
79 | - } |
|
80 | - unset($this->all_tracked[$key]); |
|
81 | - } |
|
82 | - } |
|
83 | - } |
|
84 | - } |
|
79 | + } |
|
80 | + unset($this->all_tracked[$key]); |
|
81 | + } |
|
82 | + } |
|
83 | + } |
|
84 | + } |
|
85 | 85 | |
86 | - public function add($line) { |
|
86 | + public function add($line) { |
|
87 | 87 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked; |
88 | 88 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
89 | 89 | date_default_timezone_set('UTC'); |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | |
93 | 93 | // SBS format is CSV format |
94 | 94 | if(is_array($line) && isset($line['ident'])) { |
95 | - //print_r($line); |
|
96 | - if (isset($line['ident'])) { |
|
95 | + //print_r($line); |
|
96 | + if (isset($line['ident'])) { |
|
97 | 97 | |
98 | 98 | /* |
99 | 99 | // Increment message number |
@@ -109,29 +109,29 @@ discard block |
||
109 | 109 | */ |
110 | 110 | |
111 | 111 | $Common = new Common(); |
112 | - if (!isset($line['id'])) $id = trim($line['ident']); |
|
113 | - else $id = trim($line['id']); |
|
112 | + if (!isset($line['id'])) $id = trim($line['ident']); |
|
113 | + else $id = trim($line['id']); |
|
114 | 114 | |
115 | 115 | if (!isset($this->all_tracked[$id])) { |
116 | - $this->all_tracked[$id] = array(); |
|
117 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
118 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
119 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
120 | - if (!isset($line['id'])) { |
|
116 | + $this->all_tracked[$id] = array(); |
|
117 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0)); |
|
118 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '')); |
|
119 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
120 | + if (!isset($line['id'])) { |
|
121 | 121 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
122 | 122 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
123 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
124 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
123 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
124 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
128 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
128 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) { |
|
129 | 129 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
130 | - } else { |
|
130 | + } else { |
|
131 | 131 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
132 | 132 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
133 | 133 | return ''; |
134 | - } |
|
134 | + } |
|
135 | 135 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
136 | 136 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."!!!"; |
137 | 137 | return ''; |
@@ -148,38 +148,38 @@ discard block |
||
148 | 148 | |
149 | 149 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
150 | 150 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
151 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
152 | - if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
151 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
152 | + if ($this->all_tracked[$id]['addedTracker'] == 1) { |
|
153 | 153 | $timeelapsed = microtime(true); |
154 | - $Tracker = new Tracker($this->db); |
|
155 | - $fromsource = NULL; |
|
156 | - $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
154 | + $Tracker = new Tracker($this->db); |
|
155 | + $fromsource = NULL; |
|
156 | + $result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource); |
|
157 | 157 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
158 | 158 | $Tracker->db = null; |
159 | 159 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
160 | - } |
|
161 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
160 | + } |
|
161 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | if (isset($line['speed']) && $line['speed'] != '') { |
165 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
166 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
165 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
166 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
167 | 167 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
168 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
169 | - if ($distance > 1000 && $distance < 10000) { |
|
168 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
169 | + if ($distance > 1000 && $distance < 10000) { |
|
170 | 170 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
171 | 171 | $speed = $speed*3.6; |
172 | 172 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
173 | 173 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
174 | - } |
|
174 | + } |
|
175 | 175 | } |
176 | 176 | |
177 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
178 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
179 | - else unset($timediff); |
|
180 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
177 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
178 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
179 | + else unset($timediff); |
|
180 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
181 | 181 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
182 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
182 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
183 | 183 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
184 | 184 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
185 | 185 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -193,120 +193,120 @@ discard block |
||
193 | 193 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
194 | 194 | $this->tmd = 0; |
195 | 195 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
196 | - } |
|
196 | + } |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
200 | 200 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
201 | 201 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
202 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
203 | - $dataFound = true; |
|
204 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
202 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
203 | + $dataFound = true; |
|
204 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
205 | 205 | } |
206 | 206 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
207 | 207 | } |
208 | 208 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
209 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
209 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
210 | 210 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
211 | 211 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
212 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
213 | - $dataFound = true; |
|
214 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
212 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
213 | + $dataFound = true; |
|
214 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
215 | 215 | } |
216 | 216 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
217 | 217 | } |
218 | 218 | |
219 | - } else if ($globalDebug && $timediff > 20) { |
|
219 | + } else if ($globalDebug && $timediff > 20) { |
|
220 | 220 | $this->tmd = $this->tmd + 1; |
221 | 221 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
222 | 222 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
223 | 223 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
224 | 224 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
225 | - } |
|
225 | + } |
|
226 | 226 | } |
227 | 227 | if (isset($line['last_update']) && $line['last_update'] != '') { |
228 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
229 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
228 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
229 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
230 | 230 | } |
231 | 231 | if (isset($line['format_source']) && $line['format_source'] != '') { |
232 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
232 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
233 | 233 | } |
234 | 234 | if (isset($line['source_name']) && $line['source_name'] != '') { |
235 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
235 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
236 | 236 | } |
237 | 237 | if (isset($line['comment']) && $line['comment'] != '') { |
238 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
239 | - //$dataFound = true; |
|
238 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment'])); |
|
239 | + //$dataFound = true; |
|
240 | 240 | } |
241 | 241 | if (isset($line['type']) && $line['type'] != '') { |
242 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
243 | - //$dataFound = true; |
|
242 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
243 | + //$dataFound = true; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | if (isset($line['altitude']) && $line['altitude'] != '') { |
247 | - //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
247 | + //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
248 | 248 | if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true; |
249 | 249 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100))); |
250 | 250 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude'])); |
251 | 251 | //$dataFound = true; |
252 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
252 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
256 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
256 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | if (isset($line['heading']) && $line['heading'] != '') { |
260 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
261 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
262 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
263 | - //$dataFound = true; |
|
260 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
261 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
262 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
263 | + //$dataFound = true; |
|
264 | 264 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
265 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
266 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
267 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
268 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
265 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
266 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
267 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
268 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
269 | 269 | } |
270 | 270 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
271 | 271 | |
272 | 272 | if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) { |
273 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
274 | - if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
275 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
276 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
273 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
274 | + if ($this->all_tracked[$id]['addedTracker'] == 0) { |
|
275 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
276 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
277 | 277 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
278 | 278 | $timeelapsed = microtime(true); |
279 | 279 | $TrackerLive = new TrackerLive($this->db); |
280 | 280 | if (isset($line['id'])) { |
281 | - $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
282 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
281 | + $recent_ident = $TrackerLive->checkIdRecent($line['id']); |
|
282 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
283 | 283 | } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
284 | - $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
285 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
284 | + $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
|
285 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
286 | 286 | } else $recent_ident = ''; |
287 | 287 | $TrackerLive->db=null; |
288 | 288 | |
289 | 289 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
290 | 290 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
291 | - } else { |
|
291 | + } else { |
|
292 | 292 | $recent_ident = ''; |
293 | 293 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
294 | - } |
|
295 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
296 | - if($recent_ident == "") |
|
297 | - { |
|
294 | + } |
|
295 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
296 | + if($recent_ident == "") |
|
297 | + { |
|
298 | 298 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : "; |
299 | 299 | //adds the spotter data for the archive |
300 | - $highlight = ''; |
|
301 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
302 | - $timeelapsed = microtime(true); |
|
303 | - $Tracker = new Tracker($this->db); |
|
304 | - $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
305 | - $Tracker->db = null; |
|
306 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
307 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
300 | + $highlight = ''; |
|
301 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi'))); |
|
302 | + $timeelapsed = microtime(true); |
|
303 | + $Tracker = new Tracker($this->db); |
|
304 | + $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
305 | + $Tracker->db = null; |
|
306 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
307 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
308 | 308 | |
309 | - /* |
|
309 | + /* |
|
310 | 310 | // Add source stat in DB |
311 | 311 | $Stats = new Stats($this->db); |
312 | 312 | if (!empty($this->stats)) { |
@@ -333,20 +333,20 @@ discard block |
||
333 | 333 | } |
334 | 334 | $Stats->db = null; |
335 | 335 | */ |
336 | - $this->del(); |
|
336 | + $this->del(); |
|
337 | 337 | //$ignoreImport = false; |
338 | 338 | $this->all_tracked[$id]['addedTracker'] = 1; |
339 | 339 | //print_r($this->all_tracked[$id]); |
340 | 340 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
341 | - if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
342 | - //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
343 | - $TrackerLive = new TrackerLive($this->db); |
|
344 | - $TrackerLive->deleteLiveTrackerData(); |
|
345 | - $TrackerLive->db=null; |
|
346 | - if ($globalDebug) echo " Done\n"; |
|
347 | - $this->last_delete = time(); |
|
341 | + if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours..."; |
|
342 | + //TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
343 | + $TrackerLive = new TrackerLive($this->db); |
|
344 | + $TrackerLive->deleteLiveTrackerData(); |
|
345 | + $TrackerLive->db=null; |
|
346 | + if ($globalDebug) echo " Done\n"; |
|
347 | + $this->last_delete = time(); |
|
348 | 348 | } |
349 | - } else { |
|
349 | + } else { |
|
350 | 350 | $this->all_tracked[$id]['id'] = $recent_ident; |
351 | 351 | $this->all_tracked[$id]['addedTracker'] = 1; |
352 | 352 | if (isset($globalDaemon) && !$globalDaemon) { |
@@ -355,16 +355,16 @@ discard block |
||
355 | 355 | $Tracker->db = null; |
356 | 356 | } |
357 | 357 | |
358 | - } |
|
358 | + } |
|
359 | + } |
|
359 | 360 | } |
360 | - } |
|
361 | - //adds the spotter LIVE data |
|
362 | - if ($globalDebug) { |
|
361 | + //adds the spotter LIVE data |
|
362 | + if ($globalDebug) { |
|
363 | 363 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
364 | - } |
|
365 | - $ignoreImport = false; |
|
364 | + } |
|
365 | + $ignoreImport = false; |
|
366 | 366 | |
367 | - if (!$ignoreImport) { |
|
367 | + if (!$ignoreImport) { |
|
368 | 368 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
369 | 369 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
370 | 370 | $timeelapsed = microtime(true); |
@@ -436,22 +436,22 @@ discard block |
||
436 | 436 | |
437 | 437 | |
438 | 438 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
439 | - if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
440 | - $TrackerLive = new TrackerLive($this->db); |
|
441 | - $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
442 | - $TrackerLive->db = null; |
|
443 | - //TrackerLive->deleteLiveTrackerData(); |
|
444 | - if ($globalDebug) echo " Done\n"; |
|
445 | - $this->last_delete_hourly = time(); |
|
439 | + if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour..."; |
|
440 | + $TrackerLive = new TrackerLive($this->db); |
|
441 | + $TrackerLive->deleteLiveTrackerDataNotUpdated(); |
|
442 | + $TrackerLive->db = null; |
|
443 | + //TrackerLive->deleteLiveTrackerData(); |
|
444 | + if ($globalDebug) echo " Done\n"; |
|
445 | + $this->last_delete_hourly = time(); |
|
446 | 446 | } |
447 | 447 | |
448 | - } |
|
449 | - //$ignoreImport = false; |
|
448 | + } |
|
449 | + //$ignoreImport = false; |
|
450 | 450 | } |
451 | 451 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
452 | 452 | if ($send) return $this->all_tracked[$id]; |
453 | - } |
|
453 | + } |
|
454 | + } |
|
454 | 455 | } |
455 | - } |
|
456 | 456 | } |
457 | 457 | ?> |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
131 | - * Gets all the spotter information based on the latest data entry |
|
132 | - * |
|
133 | - * @return Array the spotter information |
|
134 | - * |
|
135 | - */ |
|
131 | + * Gets all the spotter information based on the latest data entry |
|
132 | + * |
|
133 | + * @return Array the spotter information |
|
134 | + * |
|
135 | + */ |
|
136 | 136 | public function getLiveSpotterData($limit = '', $sort = '', $filter = array()) |
137 | 137 | { |
138 | 138 | global $globalDBdriver, $globalLiveInterval; |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
177 | - * Gets Minimal Live Spotter data |
|
178 | - * |
|
179 | - * @return Array the spotter information |
|
180 | - * |
|
181 | - */ |
|
177 | + * Gets Minimal Live Spotter data |
|
178 | + * |
|
179 | + * @return Array the spotter information |
|
180 | + * |
|
181 | + */ |
|
182 | 182 | public function getMinLiveSpotterData($filter = array()) |
183 | 183 | { |
184 | 184 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
218 | - * Gets Minimal Live Spotter data since xx seconds |
|
219 | - * |
|
220 | - * @return Array the spotter information |
|
221 | - * |
|
222 | - */ |
|
218 | + * Gets Minimal Live Spotter data since xx seconds |
|
219 | + * |
|
220 | + * @return Array the spotter information |
|
221 | + * |
|
222 | + */ |
|
223 | 223 | public function getMinLastLiveSpotterData($filter = array()) |
224 | 224 | { |
225 | 225 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
239 | 239 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
240 | 240 | } |
241 | - } else { |
|
241 | + } else { |
|
242 | 242 | if (isset($globalArchive) && $globalArchive === TRUE) { |
243 | 243 | $query = "SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source |
244 | 244 | FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | - try { |
|
253 | + try { |
|
254 | 254 | $sth = $this->db->prepare($query); |
255 | 255 | $sth->execute(); |
256 | 256 | } catch(PDOException $e) { |
@@ -262,11 +262,11 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
265 | - * Gets number of latest data entry |
|
266 | - * |
|
267 | - * @return String number of entry |
|
268 | - * |
|
269 | - */ |
|
265 | + * Gets number of latest data entry |
|
266 | + * |
|
267 | + * @return String number of entry |
|
268 | + * |
|
269 | + */ |
|
270 | 270 | public function getLiveSpotterCount($filter = array()) |
271 | 271 | { |
272 | 272 | global $globalDBdriver, $globalLiveInterval; |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
296 | - * Gets all the spotter information based on the latest data entry and coord |
|
297 | - * |
|
298 | - * @return Array the spotter information |
|
299 | - * |
|
300 | - */ |
|
296 | + * Gets all the spotter information based on the latest data entry and coord |
|
297 | + * |
|
298 | + * @return Array the spotter information |
|
299 | + * |
|
300 | + */ |
|
301 | 301 | public function getLiveSpotterDatabyCoord($coord, $filter = array()) |
302 | 302 | { |
303 | 303 | global $globalDBdriver, $globalLiveInterval; |
@@ -322,11 +322,11 @@ discard block |
||
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
325 | - * Gets all the spotter information based on the latest data entry and coord |
|
326 | - * |
|
327 | - * @return Array the spotter information |
|
328 | - * |
|
329 | - */ |
|
325 | + * Gets all the spotter information based on the latest data entry and coord |
|
326 | + * |
|
327 | + * @return Array the spotter information |
|
328 | + * |
|
329 | + */ |
|
330 | 330 | public function getMinLiveSpotterDatabyCoord($coord, $filter = array()) |
331 | 331 | { |
332 | 332 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
394 | - * Gets all the spotter information based on a user's latitude and longitude |
|
395 | - * |
|
396 | - * @return Array the spotter information |
|
397 | - * |
|
398 | - */ |
|
394 | + * Gets all the spotter information based on a user's latitude and longitude |
|
395 | + * |
|
396 | + * @return Array the spotter information |
|
397 | + * |
|
398 | + */ |
|
399 | 399 | public function getLatestSpotterForLayar($lat, $lng, $radius, $interval) |
400 | 400 | { |
401 | 401 | $Spotter = new Spotter($this->db); |
@@ -405,145 +405,145 @@ discard block |
||
405 | 405 | return false; |
406 | 406 | } |
407 | 407 | } |
408 | - if ($lng != '') |
|
409 | - { |
|
410 | - if (!is_numeric($lng)) |
|
411 | - { |
|
412 | - return false; |
|
413 | - } |
|
414 | - } |
|
415 | - |
|
416 | - if ($radius != '') |
|
417 | - { |
|
418 | - if (!is_numeric($radius)) |
|
419 | - { |
|
420 | - return false; |
|
421 | - } |
|
422 | - } |
|
408 | + if ($lng != '') |
|
409 | + { |
|
410 | + if (!is_numeric($lng)) |
|
411 | + { |
|
412 | + return false; |
|
413 | + } |
|
414 | + } |
|
415 | + |
|
416 | + if ($radius != '') |
|
417 | + { |
|
418 | + if (!is_numeric($radius)) |
|
419 | + { |
|
420 | + return false; |
|
421 | + } |
|
422 | + } |
|
423 | 423 | $additional_query = ''; |
424 | - if ($interval != '') |
|
425 | - { |
|
426 | - if (!is_string($interval)) |
|
427 | - { |
|
428 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
429 | - return false; |
|
430 | - } else { |
|
431 | - if ($interval == '1m') |
|
432 | - { |
|
433 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
434 | - } else if ($interval == '15m'){ |
|
435 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
436 | - } |
|
437 | - } |
|
438 | - } else { |
|
439 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
440 | - } |
|
441 | - |
|
442 | - $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
424 | + if ($interval != '') |
|
425 | + { |
|
426 | + if (!is_string($interval)) |
|
427 | + { |
|
428 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
429 | + return false; |
|
430 | + } else { |
|
431 | + if ($interval == '1m') |
|
432 | + { |
|
433 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
434 | + } else if ($interval == '15m'){ |
|
435 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
|
436 | + } |
|
437 | + } |
|
438 | + } else { |
|
439 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
|
440 | + } |
|
441 | + |
|
442 | + $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live |
|
443 | 443 | WHERE spotter_live.latitude <> '' |
444 | 444 | AND spotter_live.longitude <> '' |
445 | 445 | ".$additional_query." |
446 | 446 | HAVING distance < :radius |
447 | 447 | ORDER BY distance"; |
448 | 448 | |
449 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
449 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
450 | 450 | |
451 | - return $spotter_array; |
|
452 | - } |
|
451 | + return $spotter_array; |
|
452 | + } |
|
453 | 453 | |
454 | 454 | |
455 | - /** |
|
456 | - * Gets all the spotter information based on a particular callsign |
|
457 | - * |
|
458 | - * @return Array the spotter information |
|
459 | - * |
|
460 | - */ |
|
455 | + /** |
|
456 | + * Gets all the spotter information based on a particular callsign |
|
457 | + * |
|
458 | + * @return Array the spotter information |
|
459 | + * |
|
460 | + */ |
|
461 | 461 | public function getLastLiveSpotterDataByIdent($ident) |
462 | 462 | { |
463 | 463 | $Spotter = new Spotter($this->db); |
464 | 464 | date_default_timezone_set('UTC'); |
465 | 465 | |
466 | 466 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
467 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
467 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
468 | 468 | |
469 | 469 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
470 | 470 | |
471 | 471 | return $spotter_array; |
472 | 472 | } |
473 | 473 | |
474 | - /** |
|
475 | - * Gets all the spotter information based on a particular callsign |
|
476 | - * |
|
477 | - * @return Array the spotter information |
|
478 | - * |
|
479 | - */ |
|
474 | + /** |
|
475 | + * Gets all the spotter information based on a particular callsign |
|
476 | + * |
|
477 | + * @return Array the spotter information |
|
478 | + * |
|
479 | + */ |
|
480 | 480 | public function getDateLiveSpotterDataByIdent($ident,$date) |
481 | 481 | { |
482 | 482 | $Spotter = new Spotter($this->db); |
483 | 483 | date_default_timezone_set('UTC'); |
484 | 484 | |
485 | 485 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
486 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
486 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
487 | 487 | |
488 | - $date = date('c',$date); |
|
488 | + $date = date('c',$date); |
|
489 | 489 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
490 | 490 | |
491 | 491 | return $spotter_array; |
492 | 492 | } |
493 | 493 | |
494 | - /** |
|
495 | - * Gets last spotter information based on a particular callsign |
|
496 | - * |
|
497 | - * @return Array the spotter information |
|
498 | - * |
|
499 | - */ |
|
494 | + /** |
|
495 | + * Gets last spotter information based on a particular callsign |
|
496 | + * |
|
497 | + * @return Array the spotter information |
|
498 | + * |
|
499 | + */ |
|
500 | 500 | public function getLastLiveSpotterDataById($id) |
501 | 501 | { |
502 | 502 | $Spotter = new Spotter($this->db); |
503 | 503 | date_default_timezone_set('UTC'); |
504 | 504 | |
505 | 505 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
506 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
506 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
507 | 507 | |
508 | 508 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
509 | 509 | |
510 | 510 | return $spotter_array; |
511 | 511 | } |
512 | 512 | |
513 | - /** |
|
514 | - * Gets last spotter information based on a particular callsign |
|
515 | - * |
|
516 | - * @return Array the spotter information |
|
517 | - * |
|
518 | - */ |
|
513 | + /** |
|
514 | + * Gets last spotter information based on a particular callsign |
|
515 | + * |
|
516 | + * @return Array the spotter information |
|
517 | + * |
|
518 | + */ |
|
519 | 519 | public function getDateLiveSpotterDataById($id,$date) |
520 | 520 | { |
521 | 521 | $Spotter = new Spotter($this->db); |
522 | 522 | date_default_timezone_set('UTC'); |
523 | 523 | |
524 | 524 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
525 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
526 | - $date = date('c',$date); |
|
525 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC'; |
|
526 | + $date = date('c',$date); |
|
527 | 527 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
528 | 528 | |
529 | 529 | return $spotter_array; |
530 | 530 | } |
531 | 531 | |
532 | - /** |
|
533 | - * Gets altitude information based on a particular callsign |
|
534 | - * |
|
535 | - * @return Array the spotter information |
|
536 | - * |
|
537 | - */ |
|
532 | + /** |
|
533 | + * Gets altitude information based on a particular callsign |
|
534 | + * |
|
535 | + * @return Array the spotter information |
|
536 | + * |
|
537 | + */ |
|
538 | 538 | public function getAltitudeLiveSpotterDataByIdent($ident) |
539 | 539 | { |
540 | 540 | |
541 | 541 | date_default_timezone_set('UTC'); |
542 | 542 | |
543 | 543 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
544 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
544 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
545 | 545 | |
546 | - try { |
|
546 | + try { |
|
547 | 547 | |
548 | 548 | $sth = $this->db->prepare($query); |
549 | 549 | $sth->execute(array(':ident' => $ident)); |
@@ -556,12 +556,12 @@ discard block |
||
556 | 556 | return $spotter_array; |
557 | 557 | } |
558 | 558 | |
559 | - /** |
|
560 | - * Gets all the spotter information based on a particular id |
|
561 | - * |
|
562 | - * @return Array the spotter information |
|
563 | - * |
|
564 | - */ |
|
559 | + /** |
|
560 | + * Gets all the spotter information based on a particular id |
|
561 | + * |
|
562 | + * @return Array the spotter information |
|
563 | + * |
|
564 | + */ |
|
565 | 565 | public function getAllLiveSpotterDataById($id,$liveinterval = false) |
566 | 566 | { |
567 | 567 | global $globalDBdriver, $globalLiveInterval; |
@@ -589,18 +589,18 @@ discard block |
||
589 | 589 | return $spotter_array; |
590 | 590 | } |
591 | 591 | |
592 | - /** |
|
593 | - * Gets all the spotter information based on a particular ident |
|
594 | - * |
|
595 | - * @return Array the spotter information |
|
596 | - * |
|
597 | - */ |
|
592 | + /** |
|
593 | + * Gets all the spotter information based on a particular ident |
|
594 | + * |
|
595 | + * @return Array the spotter information |
|
596 | + * |
|
597 | + */ |
|
598 | 598 | public function getAllLiveSpotterDataByIdent($ident) |
599 | 599 | { |
600 | 600 | date_default_timezone_set('UTC'); |
601 | 601 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
602 | 602 | $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
603 | - try { |
|
603 | + try { |
|
604 | 604 | |
605 | 605 | $sth = $this->db->prepare($query); |
606 | 606 | $sth->execute(array(':ident' => $ident)); |
@@ -614,23 +614,23 @@ discard block |
||
614 | 614 | |
615 | 615 | |
616 | 616 | /** |
617 | - * Deletes all info in the table |
|
618 | - * |
|
619 | - * @return String success or false |
|
620 | - * |
|
621 | - */ |
|
617 | + * Deletes all info in the table |
|
618 | + * |
|
619 | + * @return String success or false |
|
620 | + * |
|
621 | + */ |
|
622 | 622 | public function deleteLiveSpotterData() |
623 | 623 | { |
624 | 624 | global $globalDBdriver; |
625 | 625 | if ($globalDBdriver == 'mysql') { |
626 | 626 | //$query = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date"; |
627 | 627 | $query = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date'; |
628 | - //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
628 | + //$query = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)"; |
|
629 | 629 | } else { |
630 | 630 | $query = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date"; |
631 | 631 | } |
632 | 632 | |
633 | - try { |
|
633 | + try { |
|
634 | 634 | |
635 | 635 | $sth = $this->db->prepare($query); |
636 | 636 | $sth->execute(); |
@@ -642,18 +642,18 @@ discard block |
||
642 | 642 | } |
643 | 643 | |
644 | 644 | /** |
645 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
646 | - * |
|
647 | - * @return String success or false |
|
648 | - * |
|
649 | - */ |
|
645 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
646 | + * |
|
647 | + * @return String success or false |
|
648 | + * |
|
649 | + */ |
|
650 | 650 | public function deleteLiveSpotterDataNotUpdated() |
651 | 651 | { |
652 | 652 | global $globalDBdriver, $globalDebug; |
653 | 653 | if ($globalDBdriver == 'mysql') { |
654 | 654 | //$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0'; |
655 | - $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
656 | - try { |
|
655 | + $query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0"; |
|
656 | + try { |
|
657 | 657 | |
658 | 658 | $sth = $this->db->prepare($query); |
659 | 659 | $sth->execute(); |
@@ -661,8 +661,8 @@ discard block |
||
661 | 661 | return "error"; |
662 | 662 | } |
663 | 663 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
664 | - $i = 0; |
|
665 | - $j =0; |
|
664 | + $i = 0; |
|
665 | + $j =0; |
|
666 | 666 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
667 | 667 | foreach($all as $row) |
668 | 668 | { |
@@ -670,20 +670,20 @@ discard block |
||
670 | 670 | $j++; |
671 | 671 | if ($j == 30) { |
672 | 672 | if ($globalDebug) echo "."; |
673 | - try { |
|
673 | + try { |
|
674 | 674 | |
675 | 675 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
676 | 676 | $sth->execute(); |
677 | 677 | } catch(PDOException $e) { |
678 | 678 | return "error"; |
679 | 679 | } |
680 | - $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
681 | - $j = 0; |
|
680 | + $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
|
681 | + $j = 0; |
|
682 | 682 | } |
683 | 683 | $query_delete .= "'".$row['flightaware_id']."',"; |
684 | 684 | } |
685 | 685 | if ($i > 0) { |
686 | - try { |
|
686 | + try { |
|
687 | 687 | |
688 | 688 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
689 | 689 | $sth->execute(); |
@@ -694,9 +694,9 @@ discard block |
||
694 | 694 | return "success"; |
695 | 695 | } elseif ($globalDBdriver == 'pgsql') { |
696 | 696 | //$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0"; |
697 | - //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
698 | - $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
699 | - try { |
|
697 | + //$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
698 | + $query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)"; |
|
699 | + try { |
|
700 | 700 | |
701 | 701 | $sth = $this->db->prepare($query); |
702 | 702 | $sth->execute(); |
@@ -740,17 +740,17 @@ discard block |
||
740 | 740 | } |
741 | 741 | |
742 | 742 | /** |
743 | - * Deletes all info in the table for an ident |
|
744 | - * |
|
745 | - * @return String success or false |
|
746 | - * |
|
747 | - */ |
|
743 | + * Deletes all info in the table for an ident |
|
744 | + * |
|
745 | + * @return String success or false |
|
746 | + * |
|
747 | + */ |
|
748 | 748 | public function deleteLiveSpotterDataByIdent($ident) |
749 | 749 | { |
750 | 750 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
751 | 751 | $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
752 | 752 | |
753 | - try { |
|
753 | + try { |
|
754 | 754 | |
755 | 755 | $sth = $this->db->prepare($query); |
756 | 756 | $sth->execute(array(':ident' => $ident)); |
@@ -762,17 +762,17 @@ discard block |
||
762 | 762 | } |
763 | 763 | |
764 | 764 | /** |
765 | - * Deletes all info in the table for an id |
|
766 | - * |
|
767 | - * @return String success or false |
|
768 | - * |
|
769 | - */ |
|
765 | + * Deletes all info in the table for an id |
|
766 | + * |
|
767 | + * @return String success or false |
|
768 | + * |
|
769 | + */ |
|
770 | 770 | public function deleteLiveSpotterDataById($id) |
771 | 771 | { |
772 | 772 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
773 | 773 | $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
774 | 774 | |
775 | - try { |
|
775 | + try { |
|
776 | 776 | |
777 | 777 | $sth = $this->db->prepare($query); |
778 | 778 | $sth->execute(array(':id' => $id)); |
@@ -785,11 +785,11 @@ discard block |
||
785 | 785 | |
786 | 786 | |
787 | 787 | /** |
788 | - * Gets the aircraft ident within the last hour |
|
789 | - * |
|
790 | - * @return String the ident |
|
791 | - * |
|
792 | - */ |
|
788 | + * Gets the aircraft ident within the last hour |
|
789 | + * |
|
790 | + * @return String the ident |
|
791 | + * |
|
792 | + */ |
|
793 | 793 | public function getIdentFromLastHour($ident) |
794 | 794 | { |
795 | 795 | global $globalDBdriver, $globalTimezone; |
@@ -815,14 +815,14 @@ discard block |
||
815 | 815 | $ident_result = $row['ident']; |
816 | 816 | } |
817 | 817 | return $ident_result; |
818 | - } |
|
818 | + } |
|
819 | 819 | |
820 | 820 | /** |
821 | - * Check recent aircraft |
|
822 | - * |
|
823 | - * @return String the ident |
|
824 | - * |
|
825 | - */ |
|
821 | + * Check recent aircraft |
|
822 | + * |
|
823 | + * @return String the ident |
|
824 | + * |
|
825 | + */ |
|
826 | 826 | public function checkIdentRecent($ident) |
827 | 827 | { |
828 | 828 | global $globalDBdriver, $globalTimezone; |
@@ -848,14 +848,14 @@ discard block |
||
848 | 848 | $ident_result = $row['flightaware_id']; |
849 | 849 | } |
850 | 850 | return $ident_result; |
851 | - } |
|
851 | + } |
|
852 | 852 | |
853 | 853 | /** |
854 | - * Check recent aircraft by id |
|
855 | - * |
|
856 | - * @return String the ident |
|
857 | - * |
|
858 | - */ |
|
854 | + * Check recent aircraft by id |
|
855 | + * |
|
856 | + * @return String the ident |
|
857 | + * |
|
858 | + */ |
|
859 | 859 | public function checkIdRecent($id) |
860 | 860 | { |
861 | 861 | global $globalDBdriver, $globalTimezone; |
@@ -881,14 +881,14 @@ discard block |
||
881 | 881 | $ident_result = $row['flightaware_id']; |
882 | 882 | } |
883 | 883 | return $ident_result; |
884 | - } |
|
884 | + } |
|
885 | 885 | |
886 | 886 | /** |
887 | - * Check recent aircraft by ModeS |
|
888 | - * |
|
889 | - * @return String the ModeS |
|
890 | - * |
|
891 | - */ |
|
887 | + * Check recent aircraft by ModeS |
|
888 | + * |
|
889 | + * @return String the ModeS |
|
890 | + * |
|
891 | + */ |
|
892 | 892 | public function checkModeSRecent($modes) |
893 | 893 | { |
894 | 894 | global $globalDBdriver, $globalTimezone; |
@@ -915,19 +915,19 @@ discard block |
||
915 | 915 | $ident_result = $row['flightaware_id']; |
916 | 916 | } |
917 | 917 | return $ident_result; |
918 | - } |
|
918 | + } |
|
919 | 919 | |
920 | 920 | /** |
921 | - * Adds a new spotter data |
|
922 | - * |
|
923 | - * @param String $flightaware_id the ID from flightaware |
|
924 | - * @param String $ident the flight ident |
|
925 | - * @param String $aircraft_icao the aircraft type |
|
926 | - * @param String $departure_airport_icao the departure airport |
|
927 | - * @param String $arrival_airport_icao the arrival airport |
|
928 | - * @return String success or false |
|
929 | - * |
|
930 | - */ |
|
921 | + * Adds a new spotter data |
|
922 | + * |
|
923 | + * @param String $flightaware_id the ID from flightaware |
|
924 | + * @param String $ident the flight ident |
|
925 | + * @param String $aircraft_icao the aircraft type |
|
926 | + * @param String $departure_airport_icao the departure airport |
|
927 | + * @param String $arrival_airport_icao the arrival airport |
|
928 | + * @return String success or false |
|
929 | + * |
|
930 | + */ |
|
931 | 931 | public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
932 | 932 | { |
933 | 933 | global $globalURL, $globalArchive, $globalDebug; |
@@ -1062,10 +1062,10 @@ discard block |
||
1062 | 1062 | $arrival_airport_country = ''; |
1063 | 1063 | |
1064 | 1064 | |
1065 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1066 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1067 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1068 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1065 | + if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
1066 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
1067 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
1068 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
1069 | 1069 | |
1070 | 1070 | $query = ''; |
1071 | 1071 | if ($globalArchive) { |
@@ -1086,10 +1086,10 @@ discard block |
||
1086 | 1086 | return "error : ".$e->getMessage(); |
1087 | 1087 | } |
1088 | 1088 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
1089 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
1090 | - $SpotterArchive = new SpotterArchive($this->db); |
|
1091 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1092 | - if ($globalDebug) echo $result.')'; |
|
1089 | + if ($globalDebug) echo '(Add to SBS archive : '; |
|
1090 | + $SpotterArchive = new SpotterArchive($this->db); |
|
1091 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
1092 | + if ($globalDebug) echo $result.')'; |
|
1093 | 1093 | } |
1094 | 1094 | return "success"; |
1095 | 1095 |
@@ -5,23 +5,23 @@ discard block |
||
5 | 5 | $marine = false; |
6 | 6 | $usecoord = false; |
7 | 7 | if (isset($_GET['tracker'])) { |
8 | - $tracker = true; |
|
8 | + $tracker = true; |
|
9 | 9 | } |
10 | 10 | if (isset($_GET['marine'])) { |
11 | - $marine = true; |
|
11 | + $marine = true; |
|
12 | 12 | } |
13 | 13 | if ($tracker) { |
14 | - require_once('require/class.Tracker.php'); |
|
15 | - require_once('require/class.TrackerLive.php'); |
|
16 | - //require_once('require/class.TrackerArchive.php'); |
|
14 | + require_once('require/class.Tracker.php'); |
|
15 | + require_once('require/class.TrackerLive.php'); |
|
16 | + //require_once('require/class.TrackerArchive.php'); |
|
17 | 17 | } elseif ($marine) { |
18 | - require_once('require/class.Marine.php'); |
|
19 | - require_once('require/class.MarineLive.php'); |
|
20 | - //require_once('require/class.MarineArchive.php'); |
|
18 | + require_once('require/class.Marine.php'); |
|
19 | + require_once('require/class.MarineLive.php'); |
|
20 | + //require_once('require/class.MarineArchive.php'); |
|
21 | 21 | } else { |
22 | - require_once('require/class.Spotter.php'); |
|
23 | - require_once('require/class.SpotterLive.php'); |
|
24 | - require_once('require/class.SpotterArchive.php'); |
|
22 | + require_once('require/class.Spotter.php'); |
|
23 | + require_once('require/class.SpotterLive.php'); |
|
24 | + require_once('require/class.SpotterArchive.php'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | $begintime = microtime(true); |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | $Common = new Common(); |
42 | 42 | |
43 | 43 | if (isset($_GET['download'])) { |
44 | - if ($_GET['download'] == "true") |
|
45 | - { |
|
44 | + if ($_GET['download'] == "true") |
|
45 | + { |
|
46 | 46 | header('Content-disposition: attachment; filename="flightairmap.json"'); |
47 | - } |
|
47 | + } |
|
48 | 48 | } |
49 | 49 | header('Content-Type: text/javascript'); |
50 | 50 | |
@@ -497,17 +497,17 @@ discard block |
||
497 | 497 | if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
498 | 498 | |
499 | 499 | if ( |
500 | - (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
501 | - || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
500 | + (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') |
|
501 | + || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory) |
|
502 | 502 | // || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id'])) |
503 | 503 | // || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident']) |
504 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
505 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
506 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
507 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
508 | - || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
509 | - || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
510 | - ) { |
|
504 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id'])) |
|
505 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']) |
|
506 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id'])) |
|
507 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id']) |
|
508 | + || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid'])) |
|
509 | + || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid']) |
|
510 | + ) { |
|
511 | 511 | if ($tracker) { |
512 | 512 | $spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']); |
513 | 513 | } elseif ($marine) { |
@@ -592,26 +592,26 @@ discard block |
||
592 | 592 | } |
593 | 593 | |
594 | 594 | if (isset($history) && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) { |
595 | - $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
596 | - if (isset($spotter_item['departure_airport_latitude'])) { |
|
595 | + $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": ['; |
|
596 | + if (isset($spotter_item['departure_airport_latitude'])) { |
|
597 | 597 | $output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],'; |
598 | - } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
598 | + } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') { |
|
599 | 599 | $dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']); |
600 | 600 | if (isset($dairport[0]['latitude'])) { |
601 | - $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
601 | + $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],'; |
|
602 | 602 | } |
603 | - } |
|
604 | - if (isset($spotter_item['arrival_airport_latitude'])) { |
|
603 | + } |
|
604 | + if (isset($spotter_item['arrival_airport_latitude'])) { |
|
605 | 605 | $output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']'; |
606 | - } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
606 | + } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') { |
|
607 | 607 | $aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']); |
608 | 608 | if (isset($aairport[0]['latitude'])) { |
609 | - $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
609 | + $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']'; |
|
610 | 610 | } |
611 | - } |
|
612 | - $output_air .= ']}},'; |
|
613 | - $output .= $output_air; |
|
614 | - unset($output_air); |
|
611 | + } |
|
612 | + $output_air .= ']}},'; |
|
613 | + $output .= $output_air; |
|
614 | + unset($output_air); |
|
615 | 615 | } |
616 | 616 | } |
617 | 617 | $output = substr($output, 0, -1); |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | |
13 | 13 | |
14 | 14 | /** |
15 | - * Get SQL query part for filter used |
|
16 | - * @param Array $filter the filter |
|
17 | - * @return Array the SQL part |
|
18 | - */ |
|
15 | + * Get SQL query part for filter used |
|
16 | + * @param Array $filter the filter |
|
17 | + * @return Array the SQL part |
|
18 | + */ |
|
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
21 | 21 | $filters = array(); |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | - * Gets all the spotter information based on the latest data entry |
|
90 | - * |
|
91 | - * @return Array the spotter information |
|
92 | - * |
|
93 | - */ |
|
89 | + * Gets all the spotter information based on the latest data entry |
|
90 | + * |
|
91 | + * @return Array the spotter information |
|
92 | + * |
|
93 | + */ |
|
94 | 94 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
95 | 95 | { |
96 | 96 | global $globalDBdriver, $globalLiveInterval; |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | - * Gets Minimal Live Spotter data |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
135 | + * Gets Minimal Live Spotter data |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | 140 | public function getMinLiveMarineData($filter = array()) |
141 | 141 | { |
142 | 142 | global $globalDBdriver, $globalLiveInterval; |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | - * Gets Minimal Live Spotter data since xx seconds |
|
170 | - * |
|
171 | - * @return Array the spotter information |
|
172 | - * |
|
173 | - */ |
|
169 | + * Gets Minimal Live Spotter data since xx seconds |
|
170 | + * |
|
171 | + * @return Array the spotter information |
|
172 | + * |
|
173 | + */ |
|
174 | 174 | public function getMinLastLiveMarineData($filter = array()) |
175 | 175 | { |
176 | 176 | global $globalDBdriver, $globalLiveInterval; |
@@ -183,13 +183,13 @@ discard block |
||
183 | 183 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
184 | 184 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
185 | 185 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
186 | - } else { |
|
186 | + } else { |
|
187 | 187 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
188 | 188 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
189 | 189 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
190 | 190 | } |
191 | 191 | |
192 | - try { |
|
192 | + try { |
|
193 | 193 | $sth = $this->db->prepare($query); |
194 | 194 | $sth->execute(); |
195 | 195 | } catch(PDOException $e) { |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
204 | - * Gets number of latest data entry |
|
205 | - * |
|
206 | - * @return String number of entry |
|
207 | - * |
|
208 | - */ |
|
204 | + * Gets number of latest data entry |
|
205 | + * |
|
206 | + * @return String number of entry |
|
207 | + * |
|
208 | + */ |
|
209 | 209 | public function getLiveMarineCount($filter = array()) |
210 | 210 | { |
211 | 211 | global $globalDBdriver, $globalLiveInterval; |
@@ -230,11 +230,11 @@ discard block |
||
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
233 | - * Gets all the spotter information based on the latest data entry and coord |
|
234 | - * |
|
235 | - * @return Array the spotter information |
|
236 | - * |
|
237 | - */ |
|
233 | + * Gets all the spotter information based on the latest data entry and coord |
|
234 | + * |
|
235 | + * @return Array the spotter information |
|
236 | + * |
|
237 | + */ |
|
238 | 238 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
239 | 239 | { |
240 | 240 | global $globalDBdriver, $globalLiveInterval; |
@@ -258,11 +258,11 @@ discard block |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
261 | - * Gets all the spotter information based on the latest data entry and coord |
|
262 | - * |
|
263 | - * @return Array the spotter information |
|
264 | - * |
|
265 | - */ |
|
261 | + * Gets all the spotter information based on the latest data entry and coord |
|
262 | + * |
|
263 | + * @return Array the spotter information |
|
264 | + * |
|
265 | + */ |
|
266 | 266 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
267 | 267 | { |
268 | 268 | global $globalDBdriver, $globalLiveInterval; |
@@ -290,11 +290,11 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
293 | - * Gets all the spotter information based on a user's latitude and longitude |
|
294 | - * |
|
295 | - * @return Array the spotter information |
|
296 | - * |
|
297 | - */ |
|
293 | + * Gets all the spotter information based on a user's latitude and longitude |
|
294 | + * |
|
295 | + * @return Array the spotter information |
|
296 | + * |
|
297 | + */ |
|
298 | 298 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
299 | 299 | { |
300 | 300 | $Marine = new Marine($this->db); |
@@ -307,134 +307,134 @@ discard block |
||
307 | 307 | if ($lng != '') |
308 | 308 | { |
309 | 309 | if (!is_numeric($lng)) |
310 | - { |
|
311 | - return false; |
|
312 | - } |
|
313 | - } |
|
314 | - |
|
315 | - if ($radius != '') |
|
316 | - { |
|
317 | - if (!is_numeric($radius)) |
|
318 | - { |
|
319 | - return false; |
|
320 | - } |
|
321 | - } |
|
310 | + { |
|
311 | + return false; |
|
312 | + } |
|
313 | + } |
|
314 | + |
|
315 | + if ($radius != '') |
|
316 | + { |
|
317 | + if (!is_numeric($radius)) |
|
318 | + { |
|
319 | + return false; |
|
320 | + } |
|
321 | + } |
|
322 | 322 | $additional_query = ''; |
323 | 323 | if ($interval != '') |
324 | - { |
|
325 | - if (!is_string($interval)) |
|
326 | - { |
|
327 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
328 | - return false; |
|
329 | - } else { |
|
330 | - if ($interval == '1m') |
|
331 | - { |
|
332 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
333 | - } else if ($interval == '15m'){ |
|
334 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
335 | - } |
|
336 | - } |
|
337 | - } else { |
|
338 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
339 | - } |
|
340 | - |
|
341 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
324 | + { |
|
325 | + if (!is_string($interval)) |
|
326 | + { |
|
327 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
328 | + return false; |
|
329 | + } else { |
|
330 | + if ($interval == '1m') |
|
331 | + { |
|
332 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
333 | + } else if ($interval == '15m'){ |
|
334 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
335 | + } |
|
336 | + } |
|
337 | + } else { |
|
338 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
339 | + } |
|
340 | + |
|
341 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
342 | 342 | WHERE marine_live.latitude <> '' |
343 | 343 | AND marine_live.longitude <> '' |
344 | 344 | ".$additional_query." |
345 | 345 | HAVING distance < :radius |
346 | 346 | ORDER BY distance"; |
347 | 347 | |
348 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
348 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
349 | 349 | |
350 | - return $spotter_array; |
|
351 | - } |
|
350 | + return $spotter_array; |
|
351 | + } |
|
352 | 352 | |
353 | 353 | |
354 | - /** |
|
355 | - * Gets all the spotter information based on a particular callsign |
|
356 | - * |
|
357 | - * @return Array the spotter information |
|
358 | - * |
|
359 | - */ |
|
354 | + /** |
|
355 | + * Gets all the spotter information based on a particular callsign |
|
356 | + * |
|
357 | + * @return Array the spotter information |
|
358 | + * |
|
359 | + */ |
|
360 | 360 | public function getLastLiveMarineDataByIdent($ident) |
361 | 361 | { |
362 | 362 | $Marine = new Marine($this->db); |
363 | 363 | date_default_timezone_set('UTC'); |
364 | 364 | |
365 | 365 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
366 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
366 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
367 | 367 | |
368 | 368 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
369 | 369 | |
370 | 370 | return $spotter_array; |
371 | 371 | } |
372 | 372 | |
373 | - /** |
|
374 | - * Gets all the spotter information based on a particular callsign |
|
375 | - * |
|
376 | - * @return Array the spotter information |
|
377 | - * |
|
378 | - */ |
|
373 | + /** |
|
374 | + * Gets all the spotter information based on a particular callsign |
|
375 | + * |
|
376 | + * @return Array the spotter information |
|
377 | + * |
|
378 | + */ |
|
379 | 379 | public function getDateLiveMarineDataByIdent($ident,$date) |
380 | 380 | { |
381 | 381 | $Marine = new Marine($this->db); |
382 | 382 | date_default_timezone_set('UTC'); |
383 | 383 | |
384 | 384 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
385 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
385 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
386 | 386 | |
387 | - $date = date('c',$date); |
|
387 | + $date = date('c',$date); |
|
388 | 388 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
389 | 389 | |
390 | 390 | return $spotter_array; |
391 | 391 | } |
392 | 392 | |
393 | - /** |
|
394 | - * Gets last spotter information based on a particular callsign |
|
395 | - * |
|
396 | - * @return Array the spotter information |
|
397 | - * |
|
398 | - */ |
|
393 | + /** |
|
394 | + * Gets last spotter information based on a particular callsign |
|
395 | + * |
|
396 | + * @return Array the spotter information |
|
397 | + * |
|
398 | + */ |
|
399 | 399 | public function getLastLiveMarineDataById($id) |
400 | 400 | { |
401 | 401 | $Marine = new Marine($this->db); |
402 | 402 | date_default_timezone_set('UTC'); |
403 | 403 | |
404 | 404 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
405 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
405 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
406 | 406 | |
407 | 407 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
408 | 408 | |
409 | 409 | return $spotter_array; |
410 | 410 | } |
411 | 411 | |
412 | - /** |
|
413 | - * Gets last spotter information based on a particular callsign |
|
414 | - * |
|
415 | - * @return Array the spotter information |
|
416 | - * |
|
417 | - */ |
|
412 | + /** |
|
413 | + * Gets last spotter information based on a particular callsign |
|
414 | + * |
|
415 | + * @return Array the spotter information |
|
416 | + * |
|
417 | + */ |
|
418 | 418 | public function getDateLiveMarineDataById($id,$date) |
419 | 419 | { |
420 | 420 | $Marine = new Marine($this->db); |
421 | 421 | date_default_timezone_set('UTC'); |
422 | 422 | |
423 | 423 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
424 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
425 | - $date = date('c',$date); |
|
424 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
425 | + $date = date('c',$date); |
|
426 | 426 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
427 | 427 | |
428 | 428 | return $spotter_array; |
429 | 429 | } |
430 | 430 | |
431 | 431 | |
432 | - /** |
|
433 | - * Gets all the spotter information based on a particular id |
|
434 | - * |
|
435 | - * @return Array the spotter information |
|
436 | - * |
|
437 | - */ |
|
432 | + /** |
|
433 | + * Gets all the spotter information based on a particular id |
|
434 | + * |
|
435 | + * @return Array the spotter information |
|
436 | + * |
|
437 | + */ |
|
438 | 438 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
439 | 439 | { |
440 | 440 | global $globalDBdriver, $globalLiveInterval; |
@@ -462,18 +462,18 @@ discard block |
||
462 | 462 | return $spotter_array; |
463 | 463 | } |
464 | 464 | |
465 | - /** |
|
466 | - * Gets all the spotter information based on a particular ident |
|
467 | - * |
|
468 | - * @return Array the spotter information |
|
469 | - * |
|
470 | - */ |
|
465 | + /** |
|
466 | + * Gets all the spotter information based on a particular ident |
|
467 | + * |
|
468 | + * @return Array the spotter information |
|
469 | + * |
|
470 | + */ |
|
471 | 471 | public function getAllLiveMarineDataByIdent($ident) |
472 | 472 | { |
473 | 473 | date_default_timezone_set('UTC'); |
474 | 474 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
475 | 475 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
476 | - try { |
|
476 | + try { |
|
477 | 477 | |
478 | 478 | $sth = $this->db->prepare($query); |
479 | 479 | $sth->execute(array(':ident' => $ident)); |
@@ -487,23 +487,23 @@ discard block |
||
487 | 487 | |
488 | 488 | |
489 | 489 | /** |
490 | - * Deletes all info in the table |
|
491 | - * |
|
492 | - * @return String success or false |
|
493 | - * |
|
494 | - */ |
|
490 | + * Deletes all info in the table |
|
491 | + * |
|
492 | + * @return String success or false |
|
493 | + * |
|
494 | + */ |
|
495 | 495 | public function deleteLiveMarineData() |
496 | 496 | { |
497 | 497 | global $globalDBdriver; |
498 | 498 | if ($globalDBdriver == 'mysql') { |
499 | 499 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
500 | 500 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
501 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
501 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
502 | 502 | } else { |
503 | 503 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
504 | 504 | } |
505 | 505 | |
506 | - try { |
|
506 | + try { |
|
507 | 507 | |
508 | 508 | $sth = $this->db->prepare($query); |
509 | 509 | $sth->execute(); |
@@ -515,18 +515,18 @@ discard block |
||
515 | 515 | } |
516 | 516 | |
517 | 517 | /** |
518 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
519 | - * |
|
520 | - * @return String success or false |
|
521 | - * |
|
522 | - */ |
|
518 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
519 | + * |
|
520 | + * @return String success or false |
|
521 | + * |
|
522 | + */ |
|
523 | 523 | public function deleteLiveMarineDataNotUpdated() |
524 | 524 | { |
525 | 525 | global $globalDBdriver, $globalDebug; |
526 | 526 | if ($globalDBdriver == 'mysql') { |
527 | 527 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
528 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
529 | - try { |
|
528 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
529 | + try { |
|
530 | 530 | |
531 | 531 | $sth = $this->db->prepare($query); |
532 | 532 | $sth->execute(); |
@@ -534,8 +534,8 @@ discard block |
||
534 | 534 | return "error"; |
535 | 535 | } |
536 | 536 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
537 | - $i = 0; |
|
538 | - $j =0; |
|
537 | + $i = 0; |
|
538 | + $j =0; |
|
539 | 539 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
540 | 540 | foreach($all as $row) |
541 | 541 | { |
@@ -543,20 +543,20 @@ discard block |
||
543 | 543 | $j++; |
544 | 544 | if ($j == 30) { |
545 | 545 | if ($globalDebug) echo "."; |
546 | - try { |
|
546 | + try { |
|
547 | 547 | |
548 | 548 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
549 | 549 | $sth->execute(); |
550 | 550 | } catch(PDOException $e) { |
551 | 551 | return "error"; |
552 | 552 | } |
553 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
554 | - $j = 0; |
|
553 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
554 | + $j = 0; |
|
555 | 555 | } |
556 | 556 | $query_delete .= "'".$row['fammarine_id']."',"; |
557 | 557 | } |
558 | 558 | if ($i > 0) { |
559 | - try { |
|
559 | + try { |
|
560 | 560 | |
561 | 561 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
562 | 562 | $sth->execute(); |
@@ -567,9 +567,9 @@ discard block |
||
567 | 567 | return "success"; |
568 | 568 | } elseif ($globalDBdriver == 'pgsql') { |
569 | 569 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
570 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
571 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
572 | - try { |
|
570 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
571 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
572 | + try { |
|
573 | 573 | |
574 | 574 | $sth = $this->db->prepare($query); |
575 | 575 | $sth->execute(); |
@@ -613,17 +613,17 @@ discard block |
||
613 | 613 | } |
614 | 614 | |
615 | 615 | /** |
616 | - * Deletes all info in the table for an ident |
|
617 | - * |
|
618 | - * @return String success or false |
|
619 | - * |
|
620 | - */ |
|
616 | + * Deletes all info in the table for an ident |
|
617 | + * |
|
618 | + * @return String success or false |
|
619 | + * |
|
620 | + */ |
|
621 | 621 | public function deleteLiveMarineDataByIdent($ident) |
622 | 622 | { |
623 | 623 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
624 | 624 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
625 | 625 | |
626 | - try { |
|
626 | + try { |
|
627 | 627 | |
628 | 628 | $sth = $this->db->prepare($query); |
629 | 629 | $sth->execute(array(':ident' => $ident)); |
@@ -635,17 +635,17 @@ discard block |
||
635 | 635 | } |
636 | 636 | |
637 | 637 | /** |
638 | - * Deletes all info in the table for an id |
|
639 | - * |
|
640 | - * @return String success or false |
|
641 | - * |
|
642 | - */ |
|
638 | + * Deletes all info in the table for an id |
|
639 | + * |
|
640 | + * @return String success or false |
|
641 | + * |
|
642 | + */ |
|
643 | 643 | public function deleteLiveMarineDataById($id) |
644 | 644 | { |
645 | 645 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
646 | 646 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
647 | 647 | |
648 | - try { |
|
648 | + try { |
|
649 | 649 | |
650 | 650 | $sth = $this->db->prepare($query); |
651 | 651 | $sth->execute(array(':id' => $id)); |
@@ -658,11 +658,11 @@ discard block |
||
658 | 658 | |
659 | 659 | |
660 | 660 | /** |
661 | - * Gets the aircraft ident within the last hour |
|
662 | - * |
|
663 | - * @return String the ident |
|
664 | - * |
|
665 | - */ |
|
661 | + * Gets the aircraft ident within the last hour |
|
662 | + * |
|
663 | + * @return String the ident |
|
664 | + * |
|
665 | + */ |
|
666 | 666 | public function getIdentFromLastHour($ident) |
667 | 667 | { |
668 | 668 | global $globalDBdriver, $globalTimezone; |
@@ -688,14 +688,14 @@ discard block |
||
688 | 688 | $ident_result = $row['ident']; |
689 | 689 | } |
690 | 690 | return $ident_result; |
691 | - } |
|
691 | + } |
|
692 | 692 | |
693 | 693 | /** |
694 | - * Check recent aircraft |
|
695 | - * |
|
696 | - * @return String the ident |
|
697 | - * |
|
698 | - */ |
|
694 | + * Check recent aircraft |
|
695 | + * |
|
696 | + * @return String the ident |
|
697 | + * |
|
698 | + */ |
|
699 | 699 | public function checkIdentRecent($ident) |
700 | 700 | { |
701 | 701 | global $globalDBdriver, $globalTimezone; |
@@ -721,14 +721,14 @@ discard block |
||
721 | 721 | $ident_result = $row['fammarine_id']; |
722 | 722 | } |
723 | 723 | return $ident_result; |
724 | - } |
|
724 | + } |
|
725 | 725 | |
726 | 726 | /** |
727 | - * Check recent aircraft by id |
|
728 | - * |
|
729 | - * @return String the ident |
|
730 | - * |
|
731 | - */ |
|
727 | + * Check recent aircraft by id |
|
728 | + * |
|
729 | + * @return String the ident |
|
730 | + * |
|
731 | + */ |
|
732 | 732 | public function checkIdRecent($id) |
733 | 733 | { |
734 | 734 | global $globalDBdriver, $globalTimezone; |
@@ -754,14 +754,14 @@ discard block |
||
754 | 754 | $ident_result = $row['fammarine_id']; |
755 | 755 | } |
756 | 756 | return $ident_result; |
757 | - } |
|
757 | + } |
|
758 | 758 | |
759 | 759 | /** |
760 | - * Check recent aircraft by mmsi |
|
761 | - * |
|
762 | - * @return String the ident |
|
763 | - * |
|
764 | - */ |
|
760 | + * Check recent aircraft by mmsi |
|
761 | + * |
|
762 | + * @return String the ident |
|
763 | + * |
|
764 | + */ |
|
765 | 765 | public function checkMMSIRecent($mmsi) |
766 | 766 | { |
767 | 767 | global $globalDBdriver, $globalTimezone; |
@@ -787,19 +787,19 @@ discard block |
||
787 | 787 | $ident_result = $row['fammarine_id']; |
788 | 788 | } |
789 | 789 | return $ident_result; |
790 | - } |
|
790 | + } |
|
791 | 791 | |
792 | 792 | /** |
793 | - * Adds a new spotter data |
|
794 | - * |
|
795 | - * @param String $fammarine_id the ID from flightaware |
|
796 | - * @param String $ident the flight ident |
|
797 | - * @param String $aircraft_icao the aircraft type |
|
798 | - * @param String $departure_airport_icao the departure airport |
|
799 | - * @param String $arrival_airport_icao the arrival airport |
|
800 | - * @return String success or false |
|
801 | - * |
|
802 | - */ |
|
793 | + * Adds a new spotter data |
|
794 | + * |
|
795 | + * @param String $fammarine_id the ID from flightaware |
|
796 | + * @param String $ident the flight ident |
|
797 | + * @param String $aircraft_icao the aircraft type |
|
798 | + * @param String $departure_airport_icao the departure airport |
|
799 | + * @param String $arrival_airport_icao the arrival airport |
|
800 | + * @return String success or false |
|
801 | + * |
|
802 | + */ |
|
803 | 803 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
804 | 804 | { |
805 | 805 | global $globalURL, $globalArchive, $globalDebug; |
@@ -870,10 +870,10 @@ discard block |
||
870 | 870 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
871 | 871 | |
872 | 872 | |
873 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
874 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
875 | - if ($arrival_date == '') $arrival_date = NULL; |
|
876 | - $query = ''; |
|
873 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
874 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
875 | + if ($arrival_date == '') $arrival_date = NULL; |
|
876 | + $query = ''; |
|
877 | 877 | if ($globalArchive) { |
878 | 878 | if ($globalDebug) echo '-- Delete previous data -- '; |
879 | 879 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
@@ -9,10 +9,10 @@ discard block |
||
9 | 9 | } |
10 | 10 | |
11 | 11 | /** |
12 | - * Get SQL query part for filter used |
|
13 | - * @param Array $filter the filter |
|
14 | - * @return Array the SQL part |
|
15 | - */ |
|
12 | + * Get SQL query part for filter used |
|
13 | + * @param Array $filter the filter |
|
14 | + * @return Array the SQL part |
|
15 | + */ |
|
16 | 16 | public function getFilter($filter = array(),$where = false,$and = false) { |
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
18 | 18 | $filters = array(); |
@@ -110,44 +110,44 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | |
113 | - /** |
|
114 | - * Gets all the spotter information based on a particular callsign |
|
115 | - * |
|
116 | - * @return Array the spotter information |
|
117 | - * |
|
118 | - */ |
|
119 | - public function getLastArchiveMarineDataByIdent($ident) |
|
120 | - { |
|
113 | + /** |
|
114 | + * Gets all the spotter information based on a particular callsign |
|
115 | + * |
|
116 | + * @return Array the spotter information |
|
117 | + * |
|
118 | + */ |
|
119 | + public function getLastArchiveMarineDataByIdent($ident) |
|
120 | + { |
|
121 | 121 | $Marine = new Marine($this->db); |
122 | - date_default_timezone_set('UTC'); |
|
122 | + date_default_timezone_set('UTC'); |
|
123 | 123 | |
124 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
125 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
126 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
124 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
125 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
126 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
127 | 127 | |
128 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
128 | + $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
129 | 129 | |
130 | - return $spotter_array; |
|
131 | - } |
|
130 | + return $spotter_array; |
|
131 | + } |
|
132 | 132 | |
133 | 133 | |
134 | - /** |
|
135 | - * Gets last the spotter information based on a particular id |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
140 | - public function getLastArchiveMarineDataById($id) |
|
141 | - { |
|
142 | - $Marine = new Marine($this->db); |
|
143 | - date_default_timezone_set('UTC'); |
|
144 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
145 | - //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
146 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
147 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
134 | + /** |
|
135 | + * Gets last the spotter information based on a particular id |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | + public function getLastArchiveMarineDataById($id) |
|
141 | + { |
|
142 | + $Marine = new Marine($this->db); |
|
143 | + date_default_timezone_set('UTC'); |
|
144 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
145 | + //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
146 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
147 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
148 | 148 | |
149 | 149 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
150 | - /* |
|
150 | + /* |
|
151 | 151 | try { |
152 | 152 | $Connection = new Connection(); |
153 | 153 | $sth = Connection->$db->prepare($query); |
@@ -157,232 +157,232 @@ discard block |
||
157 | 157 | } |
158 | 158 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
159 | 159 | */ |
160 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
161 | - |
|
162 | - return $spotter_array; |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Gets all the spotter information based on a particular id |
|
167 | - * |
|
168 | - * @return Array the spotter information |
|
169 | - * |
|
170 | - */ |
|
171 | - public function getAllArchiveMarineDataById($id) |
|
160 | + $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
161 | + |
|
162 | + return $spotter_array; |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Gets all the spotter information based on a particular id |
|
167 | + * |
|
168 | + * @return Array the spotter information |
|
169 | + * |
|
170 | + */ |
|
171 | + public function getAllArchiveMarineDataById($id) |
|
172 | 172 | { |
173 | - date_default_timezone_set('UTC'); |
|
174 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
175 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
173 | + date_default_timezone_set('UTC'); |
|
174 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
175 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
176 | 176 | |
177 | 177 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
178 | 178 | |
179 | - try { |
|
180 | - $sth = $this->db->prepare($query); |
|
181 | - $sth->execute(array(':id' => $id)); |
|
182 | - } catch(PDOException $e) { |
|
183 | - echo $e->getMessage(); |
|
184 | - die; |
|
185 | - } |
|
186 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
187 | - |
|
188 | - return $spotter_array; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Gets coordinate & time spotter information based on a particular id |
|
193 | - * |
|
194 | - * @return Array the spotter information |
|
195 | - * |
|
196 | - */ |
|
197 | - public function getCoordArchiveMarineDataById($id) |
|
198 | - { |
|
199 | - date_default_timezone_set('UTC'); |
|
200 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
201 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
179 | + try { |
|
180 | + $sth = $this->db->prepare($query); |
|
181 | + $sth->execute(array(':id' => $id)); |
|
182 | + } catch(PDOException $e) { |
|
183 | + echo $e->getMessage(); |
|
184 | + die; |
|
185 | + } |
|
186 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
187 | + |
|
188 | + return $spotter_array; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Gets coordinate & time spotter information based on a particular id |
|
193 | + * |
|
194 | + * @return Array the spotter information |
|
195 | + * |
|
196 | + */ |
|
197 | + public function getCoordArchiveMarineDataById($id) |
|
198 | + { |
|
199 | + date_default_timezone_set('UTC'); |
|
200 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
201 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
202 | 202 | |
203 | 203 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
204 | 204 | |
205 | - try { |
|
206 | - $sth = $this->db->prepare($query); |
|
207 | - $sth->execute(array(':id' => $id)); |
|
208 | - } catch(PDOException $e) { |
|
209 | - echo $e->getMessage(); |
|
210 | - die; |
|
211 | - } |
|
212 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
205 | + try { |
|
206 | + $sth = $this->db->prepare($query); |
|
207 | + $sth->execute(array(':id' => $id)); |
|
208 | + } catch(PDOException $e) { |
|
209 | + echo $e->getMessage(); |
|
210 | + die; |
|
211 | + } |
|
212 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
213 | 213 | |
214 | - return $spotter_array; |
|
215 | - } |
|
214 | + return $spotter_array; |
|
215 | + } |
|
216 | 216 | |
217 | 217 | |
218 | - /** |
|
219 | - * Gets altitude information based on a particular callsign |
|
220 | - * |
|
221 | - * @return Array the spotter information |
|
222 | - * |
|
223 | - */ |
|
224 | - public function getAltitudeArchiveMarineDataByIdent($ident) |
|
225 | - { |
|
218 | + /** |
|
219 | + * Gets altitude information based on a particular callsign |
|
220 | + * |
|
221 | + * @return Array the spotter information |
|
222 | + * |
|
223 | + */ |
|
224 | + public function getAltitudeArchiveMarineDataByIdent($ident) |
|
225 | + { |
|
226 | 226 | |
227 | - date_default_timezone_set('UTC'); |
|
227 | + date_default_timezone_set('UTC'); |
|
228 | 228 | |
229 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
230 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
229 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
230 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
231 | 231 | |
232 | - try { |
|
233 | - $sth = $this->db->prepare($query); |
|
234 | - $sth->execute(array(':ident' => $ident)); |
|
235 | - } catch(PDOException $e) { |
|
236 | - echo $e->getMessage(); |
|
237 | - die; |
|
238 | - } |
|
239 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
232 | + try { |
|
233 | + $sth = $this->db->prepare($query); |
|
234 | + $sth->execute(array(':ident' => $ident)); |
|
235 | + } catch(PDOException $e) { |
|
236 | + echo $e->getMessage(); |
|
237 | + die; |
|
238 | + } |
|
239 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
240 | 240 | |
241 | - return $spotter_array; |
|
242 | - } |
|
241 | + return $spotter_array; |
|
242 | + } |
|
243 | 243 | |
244 | - /** |
|
245 | - * Gets altitude information based on a particular id |
|
246 | - * |
|
247 | - * @return Array the spotter information |
|
248 | - * |
|
249 | - */ |
|
250 | - public function getAltitudeArchiveMarineDataById($id) |
|
251 | - { |
|
244 | + /** |
|
245 | + * Gets altitude information based on a particular id |
|
246 | + * |
|
247 | + * @return Array the spotter information |
|
248 | + * |
|
249 | + */ |
|
250 | + public function getAltitudeArchiveMarineDataById($id) |
|
251 | + { |
|
252 | 252 | |
253 | - date_default_timezone_set('UTC'); |
|
253 | + date_default_timezone_set('UTC'); |
|
254 | 254 | |
255 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
256 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
255 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
256 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
257 | 257 | |
258 | - try { |
|
259 | - $sth = $this->db->prepare($query); |
|
260 | - $sth->execute(array(':id' => $id)); |
|
261 | - } catch(PDOException $e) { |
|
262 | - echo $e->getMessage(); |
|
263 | - die; |
|
264 | - } |
|
265 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
258 | + try { |
|
259 | + $sth = $this->db->prepare($query); |
|
260 | + $sth->execute(array(':id' => $id)); |
|
261 | + } catch(PDOException $e) { |
|
262 | + echo $e->getMessage(); |
|
263 | + die; |
|
264 | + } |
|
265 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
266 | 266 | |
267 | - return $spotter_array; |
|
268 | - } |
|
267 | + return $spotter_array; |
|
268 | + } |
|
269 | 269 | |
270 | - /** |
|
271 | - * Gets altitude & speed information based on a particular id |
|
272 | - * |
|
273 | - * @return Array the spotter information |
|
274 | - * |
|
275 | - */ |
|
276 | - public function getAltitudeSpeedArchiveMarineDataById($id) |
|
277 | - { |
|
270 | + /** |
|
271 | + * Gets altitude & speed information based on a particular id |
|
272 | + * |
|
273 | + * @return Array the spotter information |
|
274 | + * |
|
275 | + */ |
|
276 | + public function getAltitudeSpeedArchiveMarineDataById($id) |
|
277 | + { |
|
278 | 278 | |
279 | - date_default_timezone_set('UTC'); |
|
279 | + date_default_timezone_set('UTC'); |
|
280 | 280 | |
281 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
282 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
281 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
282 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
283 | 283 | |
284 | - try { |
|
285 | - $sth = $this->db->prepare($query); |
|
286 | - $sth->execute(array(':id' => $id)); |
|
287 | - } catch(PDOException $e) { |
|
288 | - echo $e->getMessage(); |
|
289 | - die; |
|
290 | - } |
|
291 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
284 | + try { |
|
285 | + $sth = $this->db->prepare($query); |
|
286 | + $sth->execute(array(':id' => $id)); |
|
287 | + } catch(PDOException $e) { |
|
288 | + echo $e->getMessage(); |
|
289 | + die; |
|
290 | + } |
|
291 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
292 | 292 | |
293 | - return $spotter_array; |
|
294 | - } |
|
293 | + return $spotter_array; |
|
294 | + } |
|
295 | 295 | |
296 | 296 | |
297 | - /** |
|
298 | - * Gets altitude information based on a particular callsign |
|
299 | - * |
|
300 | - * @return Array the spotter information |
|
301 | - * |
|
302 | - */ |
|
303 | - public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
304 | - { |
|
297 | + /** |
|
298 | + * Gets altitude information based on a particular callsign |
|
299 | + * |
|
300 | + * @return Array the spotter information |
|
301 | + * |
|
302 | + */ |
|
303 | + public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
304 | + { |
|
305 | 305 | |
306 | - date_default_timezone_set('UTC'); |
|
306 | + date_default_timezone_set('UTC'); |
|
307 | 307 | |
308 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
309 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
308 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
309 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
310 | 310 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
311 | 311 | |
312 | - try { |
|
313 | - $sth = $this->db->prepare($query); |
|
314 | - $sth->execute(array(':ident' => $ident)); |
|
315 | - } catch(PDOException $e) { |
|
316 | - echo $e->getMessage(); |
|
317 | - die; |
|
318 | - } |
|
319 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
312 | + try { |
|
313 | + $sth = $this->db->prepare($query); |
|
314 | + $sth->execute(array(':ident' => $ident)); |
|
315 | + } catch(PDOException $e) { |
|
316 | + echo $e->getMessage(); |
|
317 | + die; |
|
318 | + } |
|
319 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
320 | 320 | |
321 | - return $spotter_array; |
|
322 | - } |
|
321 | + return $spotter_array; |
|
322 | + } |
|
323 | 323 | |
324 | 324 | |
325 | 325 | |
326 | - /** |
|
327 | - * Gets all the archive spotter information |
|
328 | - * |
|
329 | - * @return Array the spotter information |
|
330 | - * |
|
331 | - */ |
|
332 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
333 | - { |
|
334 | - $Marine = new Marine($this->db); |
|
335 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
336 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
326 | + /** |
|
327 | + * Gets all the archive spotter information |
|
328 | + * |
|
329 | + * @return Array the spotter information |
|
330 | + * |
|
331 | + */ |
|
332 | + public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
333 | + { |
|
334 | + $Marine = new Marine($this->db); |
|
335 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
336 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
|
337 | 337 | |
338 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
338 | + $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
339 | 339 | |
340 | - return $spotter_array; |
|
341 | - } |
|
340 | + return $spotter_array; |
|
341 | + } |
|
342 | 342 | |
343 | - public function deleteMarineArchiveTrackData() |
|
344 | - { |
|
343 | + public function deleteMarineArchiveTrackData() |
|
344 | + { |
|
345 | 345 | global $globalArchiveKeepTrackMonths; |
346 | - date_default_timezone_set('UTC'); |
|
346 | + date_default_timezone_set('UTC'); |
|
347 | 347 | $query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
348 | - try { |
|
349 | - $sth = $this->db->prepare($query); |
|
350 | - $sth->execute(); |
|
351 | - } catch(PDOException $e) { |
|
352 | - echo $e->getMessage(); |
|
353 | - die; |
|
354 | - } |
|
348 | + try { |
|
349 | + $sth = $this->db->prepare($query); |
|
350 | + $sth->execute(); |
|
351 | + } catch(PDOException $e) { |
|
352 | + echo $e->getMessage(); |
|
353 | + die; |
|
354 | + } |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
358 | - * Gets Minimal Live Marine data |
|
359 | - * |
|
360 | - * @return Array the spotter information |
|
361 | - * |
|
362 | - */ |
|
363 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
364 | - { |
|
365 | - global $globalDBdriver, $globalLiveInterval; |
|
366 | - date_default_timezone_set('UTC'); |
|
367 | - |
|
368 | - $filter_query = ''; |
|
369 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
370 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
371 | - } |
|
372 | - // Use spotter_output also ? |
|
373 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
374 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
375 | - } |
|
376 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
377 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
378 | - } |
|
379 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
380 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
381 | - } |
|
358 | + * Gets Minimal Live Marine data |
|
359 | + * |
|
360 | + * @return Array the spotter information |
|
361 | + * |
|
362 | + */ |
|
363 | + public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
364 | + { |
|
365 | + global $globalDBdriver, $globalLiveInterval; |
|
366 | + date_default_timezone_set('UTC'); |
|
367 | + |
|
368 | + $filter_query = ''; |
|
369 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
370 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
371 | + } |
|
372 | + // Use spotter_output also ? |
|
373 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
374 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
375 | + } |
|
376 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
377 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
378 | + } |
|
379 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
380 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
381 | + } |
|
382 | 382 | |
383 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
384 | - if ($globalDBdriver == 'mysql') { |
|
385 | - /* |
|
383 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
384 | + if ($globalDBdriver == 'mysql') { |
|
385 | + /* |
|
386 | 386 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
387 | 387 | FROM marine_archive |
388 | 388 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
@@ -401,56 +401,56 @@ discard block |
||
401 | 401 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
402 | 402 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
403 | 403 | '.$filter_query.' ORDER BY fammarine_id'; |
404 | - } else { |
|
405 | - //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
406 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
404 | + } else { |
|
405 | + //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
406 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
407 | 407 | FROM marine_archive |
408 | 408 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
409 | 409 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
410 | 410 | '.$filter_query.' ORDER BY fammarine_id'; |
411 | - } |
|
412 | - //echo $query; |
|
413 | - try { |
|
414 | - $sth = $this->db->prepare($query); |
|
415 | - $sth->execute(); |
|
416 | - } catch(PDOException $e) { |
|
417 | - echo $e->getMessage(); |
|
418 | - die; |
|
419 | - } |
|
420 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
411 | + } |
|
412 | + //echo $query; |
|
413 | + try { |
|
414 | + $sth = $this->db->prepare($query); |
|
415 | + $sth->execute(); |
|
416 | + } catch(PDOException $e) { |
|
417 | + echo $e->getMessage(); |
|
418 | + die; |
|
419 | + } |
|
420 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
421 | 421 | |
422 | - return $spotter_array; |
|
423 | - } |
|
422 | + return $spotter_array; |
|
423 | + } |
|
424 | 424 | |
425 | 425 | /** |
426 | - * Gets Minimal Live Marine data |
|
427 | - * |
|
428 | - * @return Array the spotter information |
|
429 | - * |
|
430 | - */ |
|
431 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
432 | - { |
|
433 | - global $globalDBdriver, $globalLiveInterval; |
|
434 | - date_default_timezone_set('UTC'); |
|
435 | - |
|
436 | - $filter_query = ''; |
|
437 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
438 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
439 | - } |
|
440 | - // Should use spotter_output also ? |
|
441 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
442 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
443 | - } |
|
444 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
445 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
446 | - } |
|
447 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
448 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
449 | - } |
|
426 | + * Gets Minimal Live Marine data |
|
427 | + * |
|
428 | + * @return Array the spotter information |
|
429 | + * |
|
430 | + */ |
|
431 | + public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
432 | + { |
|
433 | + global $globalDBdriver, $globalLiveInterval; |
|
434 | + date_default_timezone_set('UTC'); |
|
435 | + |
|
436 | + $filter_query = ''; |
|
437 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
438 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
439 | + } |
|
440 | + // Should use spotter_output also ? |
|
441 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
442 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
443 | + } |
|
444 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
445 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
446 | + } |
|
447 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
448 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
449 | + } |
|
450 | 450 | |
451 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
452 | - if ($globalDBdriver == 'mysql') { |
|
453 | - /* |
|
451 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
452 | + if ($globalDBdriver == 'mysql') { |
|
453 | + /* |
|
454 | 454 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
455 | 455 | FROM marine_archive |
456 | 456 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
@@ -461,95 +461,95 @@ discard block |
||
461 | 461 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
462 | 462 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
463 | 463 | |
464 | - } else { |
|
465 | - //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
466 | - /* |
|
464 | + } else { |
|
465 | + //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
466 | + /* |
|
467 | 467 | $query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
468 | 468 | FROM marine_archive_output |
469 | 469 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
470 | 470 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
471 | 471 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
472 | 472 | */ |
473 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
473 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
474 | 474 | FROM marine_archive_output |
475 | 475 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
476 | 476 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
477 | 477 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
478 | 478 | // .' GROUP BY spotter_output.fammarine_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
479 | 479 | |
480 | - } |
|
481 | - //echo $query; |
|
482 | - try { |
|
483 | - $sth = $this->db->prepare($query); |
|
484 | - $sth->execute(); |
|
485 | - } catch(PDOException $e) { |
|
486 | - echo $e->getMessage(); |
|
487 | - die; |
|
488 | - } |
|
489 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
480 | + } |
|
481 | + //echo $query; |
|
482 | + try { |
|
483 | + $sth = $this->db->prepare($query); |
|
484 | + $sth->execute(); |
|
485 | + } catch(PDOException $e) { |
|
486 | + echo $e->getMessage(); |
|
487 | + die; |
|
488 | + } |
|
489 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
490 | 490 | |
491 | - return $spotter_array; |
|
492 | - } |
|
491 | + return $spotter_array; |
|
492 | + } |
|
493 | 493 | |
494 | 494 | /** |
495 | - * Gets count Live Marine data |
|
496 | - * |
|
497 | - * @return Array the spotter information |
|
498 | - * |
|
499 | - */ |
|
500 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
501 | - { |
|
502 | - global $globalDBdriver, $globalLiveInterval; |
|
503 | - date_default_timezone_set('UTC'); |
|
504 | - |
|
505 | - $filter_query = ''; |
|
506 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
507 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
508 | - } |
|
509 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
510 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
511 | - } |
|
512 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
513 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
514 | - } |
|
515 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
516 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
517 | - } |
|
495 | + * Gets count Live Marine data |
|
496 | + * |
|
497 | + * @return Array the spotter information |
|
498 | + * |
|
499 | + */ |
|
500 | + public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
501 | + { |
|
502 | + global $globalDBdriver, $globalLiveInterval; |
|
503 | + date_default_timezone_set('UTC'); |
|
518 | 504 | |
519 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
520 | - if ($globalDBdriver == 'mysql') { |
|
505 | + $filter_query = ''; |
|
506 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
507 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
508 | + } |
|
509 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
510 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
511 | + } |
|
512 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
513 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
514 | + } |
|
515 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
516 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
517 | + } |
|
518 | + |
|
519 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
520 | + if ($globalDBdriver == 'mysql') { |
|
521 | 521 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb |
522 | 522 | FROM marine_archive l |
523 | 523 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
524 | - } else { |
|
524 | + } else { |
|
525 | 525 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
526 | - } |
|
527 | - //echo $query; |
|
528 | - try { |
|
529 | - $sth = $this->db->prepare($query); |
|
530 | - $sth->execute(); |
|
531 | - } catch(PDOException $e) { |
|
532 | - echo $e->getMessage(); |
|
533 | - die; |
|
534 | - } |
|
526 | + } |
|
527 | + //echo $query; |
|
528 | + try { |
|
529 | + $sth = $this->db->prepare($query); |
|
530 | + $sth->execute(); |
|
531 | + } catch(PDOException $e) { |
|
532 | + echo $e->getMessage(); |
|
533 | + die; |
|
534 | + } |
|
535 | 535 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
536 | 536 | $sth->closeCursor(); |
537 | - return $result['nb']; |
|
537 | + return $result['nb']; |
|
538 | 538 | |
539 | - } |
|
539 | + } |
|
540 | 540 | |
541 | 541 | |
542 | 542 | |
543 | 543 | // marine_archive_output |
544 | 544 | |
545 | - /** |
|
546 | - * Gets all the spotter information |
|
547 | - * |
|
548 | - * @return Array the spotter information |
|
549 | - * |
|
550 | - */ |
|
551 | - public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
552 | - { |
|
545 | + /** |
|
546 | + * Gets all the spotter information |
|
547 | + * |
|
548 | + * @return Array the spotter information |
|
549 | + * |
|
550 | + */ |
|
551 | + public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
552 | + { |
|
553 | 553 | global $globalTimezone, $globalDBdriver; |
554 | 554 | require_once(dirname(__FILE__).'/class.Translation.php'); |
555 | 555 | $Translation = new Translation(); |
@@ -563,159 +563,159 @@ discard block |
||
563 | 563 | $filter_query = $this->getFilter($filters); |
564 | 564 | if ($q != "") |
565 | 565 | { |
566 | - if (!is_string($q)) |
|
567 | - { |
|
566 | + if (!is_string($q)) |
|
567 | + { |
|
568 | 568 | return false; |
569 | - } else { |
|
569 | + } else { |
|
570 | 570 | |
571 | 571 | $q_array = explode(" ", $q); |
572 | 572 | |
573 | 573 | foreach ($q_array as $q_item){ |
574 | - $additional_query .= " AND ("; |
|
575 | - $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
576 | - $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
577 | - $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
578 | - $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
579 | - $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
580 | - $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
581 | - $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
582 | - $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
583 | - $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
584 | - $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
585 | - $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
586 | - $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
587 | - $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
588 | - $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
589 | - $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
590 | - $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
591 | - $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
592 | - $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
593 | - $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
594 | - $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
595 | - $translate = $Translation->ident2icao($q_item); |
|
596 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
597 | - $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
598 | - $additional_query .= ")"; |
|
574 | + $additional_query .= " AND ("; |
|
575 | + $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
576 | + $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
577 | + $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
578 | + $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
579 | + $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
580 | + $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
581 | + $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
582 | + $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
583 | + $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
584 | + $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
585 | + $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
586 | + $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
587 | + $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
588 | + $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
589 | + $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
590 | + $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
591 | + $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
592 | + $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
593 | + $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
594 | + $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
595 | + $translate = $Translation->ident2icao($q_item); |
|
596 | + if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
597 | + $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
598 | + $additional_query .= ")"; |
|
599 | + } |
|
599 | 600 | } |
600 | - } |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | if ($registration != "") |
604 | 604 | { |
605 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
606 | - if (!is_string($registration)) |
|
607 | - { |
|
605 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
606 | + if (!is_string($registration)) |
|
607 | + { |
|
608 | 608 | return false; |
609 | - } else { |
|
609 | + } else { |
|
610 | 610 | $additional_query .= " AND (marine_archive_output.registration = '".$registration."')"; |
611 | - } |
|
611 | + } |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | if ($aircraft_icao != "") |
615 | 615 | { |
616 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
617 | - if (!is_string($aircraft_icao)) |
|
618 | - { |
|
616 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
617 | + if (!is_string($aircraft_icao)) |
|
618 | + { |
|
619 | 619 | return false; |
620 | - } else { |
|
620 | + } else { |
|
621 | 621 | $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
622 | - } |
|
622 | + } |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | if ($aircraft_manufacturer != "") |
626 | 626 | { |
627 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
628 | - if (!is_string($aircraft_manufacturer)) |
|
629 | - { |
|
627 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
628 | + if (!is_string($aircraft_manufacturer)) |
|
629 | + { |
|
630 | 630 | return false; |
631 | - } else { |
|
631 | + } else { |
|
632 | 632 | $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
633 | - } |
|
633 | + } |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | if ($highlights == "true") |
637 | 637 | { |
638 | - if (!is_string($highlights)) |
|
639 | - { |
|
638 | + if (!is_string($highlights)) |
|
639 | + { |
|
640 | 640 | return false; |
641 | - } else { |
|
641 | + } else { |
|
642 | 642 | $additional_query .= " AND (marine_archive_output.highlight <> '')"; |
643 | - } |
|
643 | + } |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | if ($airline_icao != "") |
647 | 647 | { |
648 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
649 | - if (!is_string($airline_icao)) |
|
650 | - { |
|
648 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
649 | + if (!is_string($airline_icao)) |
|
650 | + { |
|
651 | 651 | return false; |
652 | - } else { |
|
652 | + } else { |
|
653 | 653 | $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')"; |
654 | - } |
|
654 | + } |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | if ($airline_country != "") |
658 | 658 | { |
659 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
660 | - if (!is_string($airline_country)) |
|
661 | - { |
|
659 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
660 | + if (!is_string($airline_country)) |
|
661 | + { |
|
662 | 662 | return false; |
663 | - } else { |
|
663 | + } else { |
|
664 | 664 | $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')"; |
665 | - } |
|
665 | + } |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | if ($airline_type != "") |
669 | 669 | { |
670 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
671 | - if (!is_string($airline_type)) |
|
672 | - { |
|
670 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
671 | + if (!is_string($airline_type)) |
|
672 | + { |
|
673 | 673 | return false; |
674 | - } else { |
|
674 | + } else { |
|
675 | 675 | if ($airline_type == "passenger") |
676 | 676 | { |
677 | - $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
677 | + $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
678 | 678 | } |
679 | 679 | if ($airline_type == "cargo") |
680 | 680 | { |
681 | - $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
681 | + $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
682 | 682 | } |
683 | 683 | if ($airline_type == "military") |
684 | 684 | { |
685 | - $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
685 | + $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
686 | + } |
|
686 | 687 | } |
687 | - } |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | if ($airport != "") |
691 | 691 | { |
692 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
693 | - if (!is_string($airport)) |
|
694 | - { |
|
692 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
693 | + if (!is_string($airport)) |
|
694 | + { |
|
695 | 695 | return false; |
696 | - } else { |
|
696 | + } else { |
|
697 | 697 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))"; |
698 | - } |
|
698 | + } |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | if ($airport_country != "") |
702 | 702 | { |
703 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
704 | - if (!is_string($airport_country)) |
|
705 | - { |
|
703 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
704 | + if (!is_string($airport_country)) |
|
705 | + { |
|
706 | 706 | return false; |
707 | - } else { |
|
707 | + } else { |
|
708 | 708 | $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))"; |
709 | - } |
|
709 | + } |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | if ($callsign != "") |
713 | 713 | { |
714 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
715 | - if (!is_string($callsign)) |
|
716 | - { |
|
714 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
715 | + if (!is_string($callsign)) |
|
716 | + { |
|
717 | 717 | return false; |
718 | - } else { |
|
718 | + } else { |
|
719 | 719 | $translate = $Translation->ident2icao($callsign); |
720 | 720 | if ($translate != $callsign) { |
721 | 721 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
@@ -723,99 +723,99 @@ discard block |
||
723 | 723 | } else { |
724 | 724 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
725 | 725 | } |
726 | - } |
|
726 | + } |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | if ($owner != "") |
730 | 730 | { |
731 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
732 | - if (!is_string($owner)) |
|
733 | - { |
|
731 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
732 | + if (!is_string($owner)) |
|
733 | + { |
|
734 | 734 | return false; |
735 | - } else { |
|
735 | + } else { |
|
736 | 736 | $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')"; |
737 | - } |
|
737 | + } |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | if ($pilot_name != "") |
741 | 741 | { |
742 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
743 | - if (!is_string($pilot_name)) |
|
744 | - { |
|
742 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
743 | + if (!is_string($pilot_name)) |
|
744 | + { |
|
745 | 745 | return false; |
746 | - } else { |
|
746 | + } else { |
|
747 | 747 | $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')"; |
748 | - } |
|
748 | + } |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | if ($pilot_id != "") |
752 | 752 | { |
753 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
754 | - if (!is_string($pilot_id)) |
|
755 | - { |
|
753 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
754 | + if (!is_string($pilot_id)) |
|
755 | + { |
|
756 | 756 | return false; |
757 | - } else { |
|
757 | + } else { |
|
758 | 758 | $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')"; |
759 | - } |
|
759 | + } |
|
760 | 760 | } |
761 | 761 | |
762 | 762 | if ($departure_airport_route != "") |
763 | 763 | { |
764 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
765 | - if (!is_string($departure_airport_route)) |
|
766 | - { |
|
764 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
765 | + if (!is_string($departure_airport_route)) |
|
766 | + { |
|
767 | 767 | return false; |
768 | - } else { |
|
768 | + } else { |
|
769 | 769 | $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
770 | - } |
|
770 | + } |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | if ($arrival_airport_route != "") |
774 | 774 | { |
775 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
776 | - if (!is_string($arrival_airport_route)) |
|
777 | - { |
|
775 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
776 | + if (!is_string($arrival_airport_route)) |
|
777 | + { |
|
778 | 778 | return false; |
779 | - } else { |
|
779 | + } else { |
|
780 | 780 | $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
781 | - } |
|
781 | + } |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | if ($altitude != "") |
785 | 785 | { |
786 | - $altitude_array = explode(",", $altitude); |
|
786 | + $altitude_array = explode(",", $altitude); |
|
787 | 787 | |
788 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
789 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
789 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
790 | 790 | |
791 | 791 | |
792 | - if ($altitude_array[1] != "") |
|
793 | - { |
|
792 | + if ($altitude_array[1] != "") |
|
793 | + { |
|
794 | 794 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
795 | 795 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
796 | 796 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
797 | - } else { |
|
797 | + } else { |
|
798 | 798 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
799 | 799 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
800 | - } |
|
800 | + } |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | if ($date_posted != "") |
804 | 804 | { |
805 | - $date_array = explode(",", $date_posted); |
|
805 | + $date_array = explode(",", $date_posted); |
|
806 | 806 | |
807 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
808 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
807 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
808 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
809 | 809 | |
810 | - if ($globalTimezone != '') { |
|
810 | + if ($globalTimezone != '') { |
|
811 | 811 | date_default_timezone_set($globalTimezone); |
812 | 812 | $datetime = new DateTime(); |
813 | 813 | $offset = $datetime->format('P'); |
814 | - } else $offset = '+00:00'; |
|
814 | + } else $offset = '+00:00'; |
|
815 | 815 | |
816 | 816 | |
817 | - if ($date_array[1] != "") |
|
818 | - { |
|
817 | + if ($date_array[1] != "") |
|
818 | + { |
|
819 | 819 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
820 | 820 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
821 | 821 | if ($globalDBdriver == 'mysql') { |
@@ -823,28 +823,28 @@ discard block |
||
823 | 823 | } else { |
824 | 824 | $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
825 | 825 | } |
826 | - } else { |
|
826 | + } else { |
|
827 | 827 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
828 | - if ($globalDBdriver == 'mysql') { |
|
828 | + if ($globalDBdriver == 'mysql') { |
|
829 | 829 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
830 | 830 | } else { |
831 | 831 | $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
832 | 832 | } |
833 | - } |
|
833 | + } |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | if ($limit != "") |
837 | 837 | { |
838 | - $limit_array = explode(",", $limit); |
|
838 | + $limit_array = explode(",", $limit); |
|
839 | 839 | |
840 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
841 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
840 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
841 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
842 | 842 | |
843 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
844 | - { |
|
843 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
844 | + { |
|
845 | 845 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
846 | 846 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
847 | - } |
|
847 | + } |
|
848 | 848 | } |
849 | 849 | |
850 | 850 | |
@@ -875,33 +875,33 @@ discard block |
||
875 | 875 | $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
876 | 876 | |
877 | 877 | return $spotter_array; |
878 | - } |
|
878 | + } |
|
879 | 879 | |
880 | - public function deleteMarineArchiveData() |
|
881 | - { |
|
880 | + public function deleteMarineArchiveData() |
|
881 | + { |
|
882 | 882 | global $globalArchiveKeepMonths, $globalDBdriver; |
883 | - date_default_timezone_set('UTC'); |
|
884 | - if ($globalDBdriver == 'mysql') { |
|
883 | + date_default_timezone_set('UTC'); |
|
884 | + if ($globalDBdriver == 'mysql') { |
|
885 | 885 | $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
886 | 886 | } else { |
887 | 887 | $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
888 | 888 | } |
889 | - try { |
|
890 | - $sth = $this->db->prepare($query); |
|
891 | - $sth->execute(); |
|
892 | - } catch(PDOException $e) { |
|
893 | - return "error"; |
|
894 | - } |
|
889 | + try { |
|
890 | + $sth = $this->db->prepare($query); |
|
891 | + $sth->execute(); |
|
892 | + } catch(PDOException $e) { |
|
893 | + return "error"; |
|
894 | + } |
|
895 | 895 | } |
896 | 896 | |
897 | - /** |
|
898 | - * Gets all the spotter information based on the callsign |
|
899 | - * |
|
900 | - * @return Array the spotter information |
|
901 | - * |
|
902 | - */ |
|
903 | - public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
904 | - { |
|
897 | + /** |
|
898 | + * Gets all the spotter information based on the callsign |
|
899 | + * |
|
900 | + * @return Array the spotter information |
|
901 | + * |
|
902 | + */ |
|
903 | + public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
904 | + { |
|
905 | 905 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
906 | 906 | |
907 | 907 | date_default_timezone_set('UTC'); |
@@ -913,35 +913,35 @@ discard block |
||
913 | 913 | |
914 | 914 | if ($ident != "") |
915 | 915 | { |
916 | - if (!is_string($ident)) |
|
917 | - { |
|
916 | + if (!is_string($ident)) |
|
917 | + { |
|
918 | 918 | return false; |
919 | - } else { |
|
919 | + } else { |
|
920 | 920 | $additional_query = " AND (marine_archive_output.ident = :ident)"; |
921 | 921 | $query_values = array(':ident' => $ident); |
922 | - } |
|
922 | + } |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | if ($limit != "") |
926 | 926 | { |
927 | - $limit_array = explode(",", $limit); |
|
927 | + $limit_array = explode(",", $limit); |
|
928 | 928 | |
929 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
930 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
929 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
930 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
931 | 931 | |
932 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
933 | - { |
|
932 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
933 | + { |
|
934 | 934 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
935 | 935 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
936 | - } |
|
936 | + } |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | if ($sort != "") |
940 | 940 | { |
941 | - $search_orderby_array = $Marine->getOrderBy(); |
|
942 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
941 | + $search_orderby_array = $Marine->getOrderBy(); |
|
942 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
943 | 943 | } else { |
944 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
944 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
945 | 945 | } |
946 | 946 | |
947 | 947 | $query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -949,17 +949,17 @@ discard block |
||
949 | 949 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
950 | 950 | |
951 | 951 | return $spotter_array; |
952 | - } |
|
952 | + } |
|
953 | 953 | |
954 | 954 | |
955 | - /** |
|
956 | - * Gets all the spotter information based on the owner |
|
957 | - * |
|
958 | - * @return Array the spotter information |
|
959 | - * |
|
960 | - */ |
|
961 | - public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
962 | - { |
|
955 | + /** |
|
956 | + * Gets all the spotter information based on the owner |
|
957 | + * |
|
958 | + * @return Array the spotter information |
|
959 | + * |
|
960 | + */ |
|
961 | + public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
962 | + { |
|
963 | 963 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
964 | 964 | |
965 | 965 | date_default_timezone_set('UTC'); |
@@ -972,35 +972,35 @@ discard block |
||
972 | 972 | |
973 | 973 | if ($owner != "") |
974 | 974 | { |
975 | - if (!is_string($owner)) |
|
976 | - { |
|
975 | + if (!is_string($owner)) |
|
976 | + { |
|
977 | 977 | return false; |
978 | - } else { |
|
978 | + } else { |
|
979 | 979 | $additional_query = " AND (marine_archive_output.owner_name = :owner)"; |
980 | 980 | $query_values = array(':owner' => $owner); |
981 | - } |
|
981 | + } |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | if ($limit != "") |
985 | 985 | { |
986 | - $limit_array = explode(",", $limit); |
|
986 | + $limit_array = explode(",", $limit); |
|
987 | 987 | |
988 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
989 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
988 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
989 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
990 | 990 | |
991 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
992 | - { |
|
991 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
992 | + { |
|
993 | 993 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
994 | 994 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
995 | - } |
|
995 | + } |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | if ($sort != "") |
999 | 999 | { |
1000 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1001 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1000 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1001 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1002 | 1002 | } else { |
1003 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1003 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | $query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1008,16 +1008,16 @@ discard block |
||
1008 | 1008 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1009 | 1009 | |
1010 | 1010 | return $spotter_array; |
1011 | - } |
|
1012 | - |
|
1013 | - /** |
|
1014 | - * Gets all the spotter information based on the pilot |
|
1015 | - * |
|
1016 | - * @return Array the spotter information |
|
1017 | - * |
|
1018 | - */ |
|
1019 | - public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1020 | - { |
|
1011 | + } |
|
1012 | + |
|
1013 | + /** |
|
1014 | + * Gets all the spotter information based on the pilot |
|
1015 | + * |
|
1016 | + * @return Array the spotter information |
|
1017 | + * |
|
1018 | + */ |
|
1019 | + public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1020 | + { |
|
1021 | 1021 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
1022 | 1022 | |
1023 | 1023 | date_default_timezone_set('UTC'); |
@@ -1036,24 +1036,24 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | if ($limit != "") |
1038 | 1038 | { |
1039 | - $limit_array = explode(",", $limit); |
|
1039 | + $limit_array = explode(",", $limit); |
|
1040 | 1040 | |
1041 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1042 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1042 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1043 | 1043 | |
1044 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1045 | - { |
|
1044 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1045 | + { |
|
1046 | 1046 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1047 | 1047 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1048 | - } |
|
1048 | + } |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | if ($sort != "") |
1052 | 1052 | { |
1053 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1054 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1053 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1054 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1055 | 1055 | } else { |
1056 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1056 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | $query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1061,16 +1061,16 @@ discard block |
||
1061 | 1061 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1062 | 1062 | |
1063 | 1063 | return $spotter_array; |
1064 | - } |
|
1065 | - |
|
1066 | - /** |
|
1067 | - * Gets all number of flight over countries |
|
1068 | - * |
|
1069 | - * @return Array the airline country list |
|
1070 | - * |
|
1071 | - */ |
|
1072 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1073 | - { |
|
1064 | + } |
|
1065 | + |
|
1066 | + /** |
|
1067 | + * Gets all number of flight over countries |
|
1068 | + * |
|
1069 | + * @return Array the airline country list |
|
1070 | + * |
|
1071 | + */ |
|
1072 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1073 | + { |
|
1074 | 1074 | global $globalDBdriver; |
1075 | 1075 | /* |
1076 | 1076 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1080,14 +1080,14 @@ discard block |
||
1080 | 1080 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1081 | 1081 | FROM countries c, marine_archive s |
1082 | 1082 | WHERE c.iso2 = s.over_country "; |
1083 | - if ($olderthanmonths > 0) { |
|
1084 | - if ($globalDBdriver == 'mysql') { |
|
1083 | + if ($olderthanmonths > 0) { |
|
1084 | + if ($globalDBdriver == 'mysql') { |
|
1085 | 1085 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1086 | 1086 | } else { |
1087 | 1087 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1088 | 1088 | } |
1089 | 1089 | } |
1090 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1090 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1091 | 1091 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1092 | 1092 | if ($limit) $query .= " LIMIT 0,10"; |
1093 | 1093 | |
@@ -1100,23 +1100,23 @@ discard block |
||
1100 | 1100 | |
1101 | 1101 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1102 | 1102 | { |
1103 | - $temp_array['flight_count'] = $row['nb']; |
|
1104 | - $temp_array['flight_country'] = $row['name']; |
|
1105 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1106 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1107 | - $flight_array[] = $temp_array; |
|
1103 | + $temp_array['flight_count'] = $row['nb']; |
|
1104 | + $temp_array['flight_country'] = $row['name']; |
|
1105 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1106 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1107 | + $flight_array[] = $temp_array; |
|
1108 | 1108 | } |
1109 | 1109 | return $flight_array; |
1110 | - } |
|
1111 | - |
|
1112 | - /** |
|
1113 | - * Gets all number of flight over countries |
|
1114 | - * |
|
1115 | - * @return Array the airline country list |
|
1116 | - * |
|
1117 | - */ |
|
1118 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1119 | - { |
|
1110 | + } |
|
1111 | + |
|
1112 | + /** |
|
1113 | + * Gets all number of flight over countries |
|
1114 | + * |
|
1115 | + * @return Array the airline country list |
|
1116 | + * |
|
1117 | + */ |
|
1118 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1119 | + { |
|
1120 | 1120 | global $globalDBdriver; |
1121 | 1121 | /* |
1122 | 1122 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1126,14 +1126,14 @@ discard block |
||
1126 | 1126 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1127 | 1127 | FROM countries c, marine_archive s, spotter_output o |
1128 | 1128 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id "; |
1129 | - if ($olderthanmonths > 0) { |
|
1130 | - if ($globalDBdriver == 'mysql') { |
|
1129 | + if ($olderthanmonths > 0) { |
|
1130 | + if ($globalDBdriver == 'mysql') { |
|
1131 | 1131 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1132 | 1132 | } else { |
1133 | 1133 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1134 | 1134 | } |
1135 | 1135 | } |
1136 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1136 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1137 | 1137 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1138 | 1138 | if ($limit) $query .= " LIMIT 0,10"; |
1139 | 1139 | |
@@ -1146,24 +1146,24 @@ discard block |
||
1146 | 1146 | |
1147 | 1147 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1148 | 1148 | { |
1149 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1150 | - $temp_array['flight_count'] = $row['nb']; |
|
1151 | - $temp_array['flight_country'] = $row['name']; |
|
1152 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1153 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1154 | - $flight_array[] = $temp_array; |
|
1149 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1150 | + $temp_array['flight_count'] = $row['nb']; |
|
1151 | + $temp_array['flight_country'] = $row['name']; |
|
1152 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1153 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1154 | + $flight_array[] = $temp_array; |
|
1155 | 1155 | } |
1156 | 1156 | return $flight_array; |
1157 | - } |
|
1158 | - |
|
1159 | - /** |
|
1160 | - * Gets last spotter information based on a particular callsign |
|
1161 | - * |
|
1162 | - * @return Array the spotter information |
|
1163 | - * |
|
1164 | - */ |
|
1165 | - public function getDateArchiveMarineDataById($id,$date) |
|
1166 | - { |
|
1157 | + } |
|
1158 | + |
|
1159 | + /** |
|
1160 | + * Gets last spotter information based on a particular callsign |
|
1161 | + * |
|
1162 | + * @return Array the spotter information |
|
1163 | + * |
|
1164 | + */ |
|
1165 | + public function getDateArchiveMarineDataById($id,$date) |
|
1166 | + { |
|
1167 | 1167 | $Marine = new Marine($this->db); |
1168 | 1168 | date_default_timezone_set('UTC'); |
1169 | 1169 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1171,16 +1171,16 @@ discard block |
||
1171 | 1171 | $date = date('c',$date); |
1172 | 1172 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1173 | 1173 | return $spotter_array; |
1174 | - } |
|
1175 | - |
|
1176 | - /** |
|
1177 | - * Gets all the spotter information based on a particular callsign |
|
1178 | - * |
|
1179 | - * @return Array the spotter information |
|
1180 | - * |
|
1181 | - */ |
|
1182 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1183 | - { |
|
1174 | + } |
|
1175 | + |
|
1176 | + /** |
|
1177 | + * Gets all the spotter information based on a particular callsign |
|
1178 | + * |
|
1179 | + * @return Array the spotter information |
|
1180 | + * |
|
1181 | + */ |
|
1182 | + public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1183 | + { |
|
1184 | 1184 | $Marine = new Marine($this->db); |
1185 | 1185 | date_default_timezone_set('UTC'); |
1186 | 1186 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1188,16 +1188,16 @@ discard block |
||
1188 | 1188 | $date = date('c',$date); |
1189 | 1189 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1190 | 1190 | return $spotter_array; |
1191 | - } |
|
1192 | - |
|
1193 | - /** |
|
1194 | - * Gets all the spotter information based on the airport |
|
1195 | - * |
|
1196 | - * @return Array the spotter information |
|
1197 | - * |
|
1198 | - */ |
|
1199 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1200 | - { |
|
1191 | + } |
|
1192 | + |
|
1193 | + /** |
|
1194 | + * Gets all the spotter information based on the airport |
|
1195 | + * |
|
1196 | + * @return Array the spotter information |
|
1197 | + * |
|
1198 | + */ |
|
1199 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1200 | + { |
|
1201 | 1201 | global $global_query; |
1202 | 1202 | $Marine = new Marine(); |
1203 | 1203 | date_default_timezone_set('UTC'); |
@@ -1208,35 +1208,35 @@ discard block |
||
1208 | 1208 | |
1209 | 1209 | if ($airport != "") |
1210 | 1210 | { |
1211 | - if (!is_string($airport)) |
|
1212 | - { |
|
1211 | + if (!is_string($airport)) |
|
1212 | + { |
|
1213 | 1213 | return false; |
1214 | - } else { |
|
1214 | + } else { |
|
1215 | 1215 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))"; |
1216 | 1216 | $query_values = array(':airport' => $airport); |
1217 | - } |
|
1217 | + } |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | if ($limit != "") |
1221 | 1221 | { |
1222 | - $limit_array = explode(",", $limit); |
|
1222 | + $limit_array = explode(",", $limit); |
|
1223 | 1223 | |
1224 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1225 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1224 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1225 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1226 | 1226 | |
1227 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1228 | - { |
|
1227 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1228 | + { |
|
1229 | 1229 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1230 | 1230 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1231 | - } |
|
1231 | + } |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | if ($sort != "") |
1235 | 1235 | { |
1236 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1237 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1236 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1237 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1238 | 1238 | } else { |
1239 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1239 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1240 | 1240 | } |
1241 | 1241 | |
1242 | 1242 | $query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1244,6 +1244,6 @@ discard block |
||
1244 | 1244 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1245 | 1245 | |
1246 | 1246 | return $spotter_array; |
1247 | - } |
|
1247 | + } |
|
1248 | 1248 | } |
1249 | 1249 | ?> |
1250 | 1250 | \ No newline at end of file |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
16 | 16 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
17 | 17 | if (isset($globalMarine) && $globalMarine) { |
18 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
18 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -24,42 +24,42 @@ discard block |
||
24 | 24 | // Check if schema is at latest version |
25 | 25 | $Connection = new Connection(); |
26 | 26 | if ($Connection->latest() === false) { |
27 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | - exit(); |
|
27 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
28 | + exit(); |
|
29 | 29 | } |
30 | 30 | if (PHP_SAPI != 'cli') { |
31 | - echo "This script MUST be called from console, not a web browser."; |
|
31 | + echo "This script MUST be called from console, not a web browser."; |
|
32 | 32 | // exit(); |
33 | 33 | } |
34 | 34 | |
35 | 35 | // This is to be compatible with old version of settings.php |
36 | 36 | if (!isset($globalSources)) { |
37 | - if (isset($globalSBS1Hosts)) { |
|
38 | - //$hosts = $globalSBS1Hosts; |
|
39 | - foreach ($globalSBS1Hosts as $host) { |
|
40 | - $globalSources[] = array('host' => $host); |
|
41 | - } |
|
42 | - } else { |
|
43 | - if (!isset($globalSBS1Host)) { |
|
44 | - echo '$globalSources MUST be defined !'; |
|
45 | - die; |
|
37 | + if (isset($globalSBS1Hosts)) { |
|
38 | + //$hosts = $globalSBS1Hosts; |
|
39 | + foreach ($globalSBS1Hosts as $host) { |
|
40 | + $globalSources[] = array('host' => $host); |
|
41 | + } |
|
42 | + } else { |
|
43 | + if (!isset($globalSBS1Host)) { |
|
44 | + echo '$globalSources MUST be defined !'; |
|
45 | + die; |
|
46 | 46 | } |
47 | 47 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
48 | 48 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
49 | - } |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); |
53 | 53 | //if (isset($options['s'])) $hosts = array($options['s']); |
54 | 54 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
55 | 55 | if (isset($options['s'])) { |
56 | - $globalSources = array(); |
|
57 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | - else $globalSources[] = array('host' => $options['s']); |
|
56 | + $globalSources = array(); |
|
57 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
58 | + else $globalSources[] = array('host' => $options['s']); |
|
59 | 59 | } elseif (isset($options['source'])) { |
60 | - $globalSources = array(); |
|
61 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | - else $globalSources[] = array('host' => $options['source']); |
|
60 | + $globalSources = array(); |
|
61 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
62 | + else $globalSources[] = array('host' => $options['source']); |
|
63 | 63 | } |
64 | 64 | if (isset($options['aprsserverhost'])) { |
65 | 65 | $globalServerAPRS = TRUE; |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
75 | 75 | else $id_source = 1; |
76 | 76 | if (isset($globalServer) && $globalServer) { |
77 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
78 | - $SI=new SpotterServer(); |
|
77 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
78 | + $SI=new SpotterServer(); |
|
79 | 79 | /* |
80 | 80 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
81 | 81 | $SI = new adsb2aprs(); |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | } else $SI=new SpotterImport($Connection->db); |
85 | 85 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
86 | 86 | if (isset($globalMarine) && $globalMarine) { |
87 | - $AIS = new AIS(); |
|
88 | - $MI = new MarineImport($Connection->db); |
|
87 | + $AIS = new AIS(); |
|
88 | + $MI = new MarineImport($Connection->db); |
|
89 | 89 | } |
90 | 90 | //$APRS=new APRS($Connection->db); |
91 | 91 | $SBS=new SBS(); |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | //$servertz = system('date +%Z'); |
96 | 96 | // signal handler - playing nice with sockets and dump1090 |
97 | 97 | if (function_exists('pcntl_fork')) { |
98 | - pcntl_signal(SIGINT, function() { |
|
99 | - global $sockets; |
|
100 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
101 | - die("Bye!\n"); |
|
102 | - }); |
|
103 | - pcntl_signal_dispatch(); |
|
98 | + pcntl_signal(SIGINT, function() { |
|
99 | + global $sockets; |
|
100 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
101 | + die("Bye!\n"); |
|
102 | + }); |
|
103 | + pcntl_signal_dispatch(); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // let's try and connect |
@@ -110,153 +110,153 @@ discard block |
||
110 | 110 | $reset = 0; |
111 | 111 | |
112 | 112 | function connect_all($hosts) { |
113 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
114 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
115 | - $reset++; |
|
116 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
117 | - foreach ($hosts as $id => $value) { |
|
113 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
114 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
115 | + $reset++; |
|
116 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
117 | + foreach ($hosts as $id => $value) { |
|
118 | 118 | $host = $value['host']; |
119 | 119 | $globalSources[$id]['last_exec'] = 0; |
120 | 120 | // Here we check type of source(s) |
121 | 121 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
122 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
123 | - //$formats[$id] = 'deltadbtxt'; |
|
124 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
125 | - //$last_exec['deltadbtxt'] = 0; |
|
126 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
127 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
128 | - //$formats[$id] = 'vatsimtxt'; |
|
129 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
130 | - //$last_exec['vatsimtxt'] = 0; |
|
131 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
132 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
133 | - //$formats[$id] = 'aircraftlistjson'; |
|
134 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
135 | - //$last_exec['aircraftlistjson'] = 0; |
|
136 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
137 | - } else if (preg_match('/opensky/i',$host)) { |
|
138 | - //$formats[$id] = 'aircraftlistjson'; |
|
139 | - $globalSources[$id]['format'] = 'opensky'; |
|
140 | - //$last_exec['aircraftlistjson'] = 0; |
|
141 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
142 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
143 | - //$formats[$id] = 'radarvirtueljson'; |
|
144 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
145 | - //$last_exec['radarvirtueljson'] = 0; |
|
146 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
147 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
148 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
149 | - exit(0); |
|
150 | - } |
|
151 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
152 | - //$formats[$id] = 'planeupdatefaa'; |
|
153 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
154 | - //$last_exec['planeupdatefaa'] = 0; |
|
155 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
156 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
157 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
158 | - exit(0); |
|
159 | - } |
|
160 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
161 | - //$formats[$id] = 'phpvmacars'; |
|
162 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
163 | - //$last_exec['phpvmacars'] = 0; |
|
164 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
165 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
166 | - //$formats[$id] = 'phpvmacars'; |
|
167 | - $globalSources[$id]['format'] = 'vam'; |
|
168 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
169 | - } else if (preg_match('/whazzup/i',$host)) { |
|
170 | - //$formats[$id] = 'whazzup'; |
|
171 | - $globalSources[$id]['format'] = 'whazzup'; |
|
172 | - //$last_exec['whazzup'] = 0; |
|
173 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
174 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
175 | - //$formats[$id] = 'pirepsjson'; |
|
176 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
177 | - //$last_exec['pirepsjson'] = 0; |
|
178 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
179 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
180 | - //$formats[$id] = 'fr24json'; |
|
181 | - $globalSources[$id]['format'] = 'fr24json'; |
|
182 | - //$last_exec['fr24json'] = 0; |
|
183 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
184 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
185 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
186 | - exit(0); |
|
187 | - } |
|
188 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
189 | - //$formats[$id] = 'fr24json'; |
|
190 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
191 | - //$last_exec['fr24json'] = 0; |
|
192 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
193 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
194 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
195 | - exit(0); |
|
196 | - } |
|
197 | - //} else if (preg_match('/10001/',$host)) { |
|
198 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
199 | - //$formats[$id] = 'tsv'; |
|
200 | - $globalSources[$id]['format'] = 'tsv'; |
|
201 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
202 | - } |
|
203 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
204 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
205 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
206 | - if ($idf !== false) { |
|
207 | - $httpfeeds[$id] = $idf; |
|
208 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
209 | - } |
|
210 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
211 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
212 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
213 | - $hostport = explode(':',$host); |
|
214 | - if (isset($hostport[1])) { |
|
122 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
123 | + //$formats[$id] = 'deltadbtxt'; |
|
124 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
125 | + //$last_exec['deltadbtxt'] = 0; |
|
126 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
127 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
128 | + //$formats[$id] = 'vatsimtxt'; |
|
129 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
130 | + //$last_exec['vatsimtxt'] = 0; |
|
131 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
132 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
133 | + //$formats[$id] = 'aircraftlistjson'; |
|
134 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
135 | + //$last_exec['aircraftlistjson'] = 0; |
|
136 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
137 | + } else if (preg_match('/opensky/i',$host)) { |
|
138 | + //$formats[$id] = 'aircraftlistjson'; |
|
139 | + $globalSources[$id]['format'] = 'opensky'; |
|
140 | + //$last_exec['aircraftlistjson'] = 0; |
|
141 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
142 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
143 | + //$formats[$id] = 'radarvirtueljson'; |
|
144 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
145 | + //$last_exec['radarvirtueljson'] = 0; |
|
146 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
147 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
148 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
149 | + exit(0); |
|
150 | + } |
|
151 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
152 | + //$formats[$id] = 'planeupdatefaa'; |
|
153 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
154 | + //$last_exec['planeupdatefaa'] = 0; |
|
155 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
156 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
157 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
158 | + exit(0); |
|
159 | + } |
|
160 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
161 | + //$formats[$id] = 'phpvmacars'; |
|
162 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
163 | + //$last_exec['phpvmacars'] = 0; |
|
164 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
165 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
166 | + //$formats[$id] = 'phpvmacars'; |
|
167 | + $globalSources[$id]['format'] = 'vam'; |
|
168 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
169 | + } else if (preg_match('/whazzup/i',$host)) { |
|
170 | + //$formats[$id] = 'whazzup'; |
|
171 | + $globalSources[$id]['format'] = 'whazzup'; |
|
172 | + //$last_exec['whazzup'] = 0; |
|
173 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
174 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
175 | + //$formats[$id] = 'pirepsjson'; |
|
176 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
177 | + //$last_exec['pirepsjson'] = 0; |
|
178 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
179 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
180 | + //$formats[$id] = 'fr24json'; |
|
181 | + $globalSources[$id]['format'] = 'fr24json'; |
|
182 | + //$last_exec['fr24json'] = 0; |
|
183 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
184 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
185 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
186 | + exit(0); |
|
187 | + } |
|
188 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
189 | + //$formats[$id] = 'fr24json'; |
|
190 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
191 | + //$last_exec['fr24json'] = 0; |
|
192 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
193 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
194 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
195 | + exit(0); |
|
196 | + } |
|
197 | + //} else if (preg_match('/10001/',$host)) { |
|
198 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
199 | + //$formats[$id] = 'tsv'; |
|
200 | + $globalSources[$id]['format'] = 'tsv'; |
|
201 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
202 | + } |
|
203 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
204 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
205 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
206 | + if ($idf !== false) { |
|
207 | + $httpfeeds[$id] = $idf; |
|
208 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
209 | + } |
|
210 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
211 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
212 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
213 | + $hostport = explode(':',$host); |
|
214 | + if (isset($hostport[1])) { |
|
215 | 215 | $port = $hostport[1]; |
216 | 216 | $hostn = $hostport[0]; |
217 | - } else { |
|
217 | + } else { |
|
218 | 218 | $port = $globalSources[$id]['port']; |
219 | 219 | $hostn = $globalSources[$id]['host']; |
220 | - } |
|
221 | - $Common = new Common(); |
|
222 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
223 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
224 | - } else { |
|
225 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
226 | - } |
|
227 | - if ($s) { |
|
228 | - $sockets[$id] = $s; |
|
229 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
230 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
220 | + } |
|
221 | + $Common = new Common(); |
|
222 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
223 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
224 | + } else { |
|
225 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
226 | + } |
|
227 | + if ($s) { |
|
228 | + $sockets[$id] = $s; |
|
229 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
230 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
231 | 231 | //$formats[$id] = 'aprs'; |
232 | 232 | $globalSources[$id]['format'] = 'aprs'; |
233 | 233 | //$aprs_connect = 0; |
234 | 234 | //$use_aprs = true; |
235 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
235 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
236 | 236 | $globalSources[$id]['format'] = 'vrstcp'; |
237 | - } elseif ($port == '10001') { |
|
238 | - //$formats[$id] = 'tsv'; |
|
239 | - $globalSources[$id]['format'] = 'tsv'; |
|
240 | - } elseif ($port == '30002') { |
|
241 | - //$formats[$id] = 'raw'; |
|
242 | - $globalSources[$id]['format'] = 'raw'; |
|
243 | - } elseif ($port == '5001') { |
|
244 | - //$formats[$id] = 'raw'; |
|
245 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
246 | - } elseif ($port == '30005') { |
|
237 | + } elseif ($port == '10001') { |
|
238 | + //$formats[$id] = 'tsv'; |
|
239 | + $globalSources[$id]['format'] = 'tsv'; |
|
240 | + } elseif ($port == '30002') { |
|
241 | + //$formats[$id] = 'raw'; |
|
242 | + $globalSources[$id]['format'] = 'raw'; |
|
243 | + } elseif ($port == '5001') { |
|
244 | + //$formats[$id] = 'raw'; |
|
245 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
246 | + } elseif ($port == '30005') { |
|
247 | 247 | // Not yet supported |
248 | - //$formats[$id] = 'beast'; |
|
249 | - $globalSources[$id]['format'] = 'beast'; |
|
250 | - //} else $formats[$id] = 'sbs'; |
|
251 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
252 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
248 | + //$formats[$id] = 'beast'; |
|
249 | + $globalSources[$id]['format'] = 'beast'; |
|
250 | + //} else $formats[$id] = 'sbs'; |
|
251 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
252 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
253 | 253 | } |
254 | 254 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
255 | - } else { |
|
255 | + } else { |
|
256 | 256 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
257 | - } |
|
258 | - } |
|
259 | - } |
|
257 | + } |
|
258 | + } |
|
259 | + } |
|
260 | 260 | } |
261 | 261 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
262 | 262 | |
@@ -279,9 +279,9 @@ discard block |
||
279 | 279 | //connect_all($globalSources); |
280 | 280 | |
281 | 281 | if (isset($globalProxy) && $globalProxy) { |
282 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
282 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
283 | 283 | } else { |
284 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
284 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | // APRS Configuration |
@@ -290,18 +290,18 @@ discard block |
||
290 | 290 | die; |
291 | 291 | } |
292 | 292 | foreach ($globalSources as $key => $source) { |
293 | - if (!isset($source['format'])) { |
|
294 | - $globalSources[$key]['format'] = 'auto'; |
|
295 | - } |
|
293 | + if (!isset($source['format'])) { |
|
294 | + $globalSources[$key]['format'] = 'auto'; |
|
295 | + } |
|
296 | 296 | } |
297 | 297 | connect_all($globalSources); |
298 | 298 | foreach ($globalSources as $key => $source) { |
299 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
299 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
300 | 300 | $aprs_connect = 0; |
301 | 301 | $use_aprs = true; |
302 | 302 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
303 | 303 | break; |
304 | - } |
|
304 | + } |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | if ($use_aprs) { |
@@ -342,117 +342,117 @@ discard block |
||
342 | 342 | |
343 | 343 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
344 | 344 | while ($i > 0) { |
345 | - if (!$globalDaemon) $i = $endtime-time(); |
|
346 | - // Delete old ATC |
|
347 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
345 | + if (!$globalDaemon) $i = $endtime-time(); |
|
346 | + // Delete old ATC |
|
347 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
348 | 348 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
349 | - $ATC->deleteOldATC(); |
|
350 | - } |
|
349 | + $ATC->deleteOldATC(); |
|
350 | + } |
|
351 | 351 | |
352 | - //if (count($last_exec) > 0) { |
|
353 | - if (count($last_exec) == count($globalSources)) { |
|
352 | + //if (count($last_exec) > 0) { |
|
353 | + if (count($last_exec) == count($globalSources)) { |
|
354 | 354 | $max = $globalMinFetch; |
355 | 355 | foreach ($last_exec as $last) { |
356 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
356 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
357 | 357 | } |
358 | 358 | if ($max != $globalMinFetch) { |
359 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
360 | - sleep($globalMinFetch-$max+2); |
|
359 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
360 | + sleep($globalMinFetch-$max+2); |
|
361 | + } |
|
361 | 362 | } |
362 | - } |
|
363 | 363 | |
364 | 364 | |
365 | - //foreach ($formats as $id => $value) { |
|
366 | - foreach ($globalSources as $id => $value) { |
|
365 | + //foreach ($formats as $id => $value) { |
|
366 | + foreach ($globalSources as $id => $value) { |
|
367 | 367 | date_default_timezone_set('UTC'); |
368 | 368 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
369 | 369 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
370 | - //$buffer = $Common->getData($hosts[$id]); |
|
371 | - $buffer = $Common->getData($value['host']); |
|
372 | - if ($buffer != '') $reset = 0; |
|
373 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
374 | - $buffer = explode('\n',$buffer); |
|
375 | - foreach ($buffer as $line) { |
|
376 | - if ($line != '' && count($line) > 7) { |
|
377 | - $line = explode(',', $line); |
|
378 | - $data = array(); |
|
379 | - $data['hex'] = $line[1]; // hex |
|
380 | - $data['ident'] = $line[2]; // ident |
|
381 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
382 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
383 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
384 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
385 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
386 | - $data['verticalrate'] = ''; // vertical rate |
|
387 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
388 | - $data['emergency'] = ''; // emergency |
|
389 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
390 | - $data['format_source'] = 'deltadbtxt'; |
|
391 | - $data['id_source'] = $id_source; |
|
392 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
393 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
394 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
395 | - $SI->add($data); |
|
396 | - unset($data); |
|
397 | - } |
|
398 | - } |
|
399 | - $last_exec[$id]['last'] = time(); |
|
370 | + //$buffer = $Common->getData($hosts[$id]); |
|
371 | + $buffer = $Common->getData($value['host']); |
|
372 | + if ($buffer != '') $reset = 0; |
|
373 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
374 | + $buffer = explode('\n',$buffer); |
|
375 | + foreach ($buffer as $line) { |
|
376 | + if ($line != '' && count($line) > 7) { |
|
377 | + $line = explode(',', $line); |
|
378 | + $data = array(); |
|
379 | + $data['hex'] = $line[1]; // hex |
|
380 | + $data['ident'] = $line[2]; // ident |
|
381 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
382 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
383 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
384 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
385 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
386 | + $data['verticalrate'] = ''; // vertical rate |
|
387 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
388 | + $data['emergency'] = ''; // emergency |
|
389 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
390 | + $data['format_source'] = 'deltadbtxt'; |
|
391 | + $data['id_source'] = $id_source; |
|
392 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
393 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
394 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
395 | + $SI->add($data); |
|
396 | + unset($data); |
|
397 | + } |
|
398 | + } |
|
399 | + $last_exec[$id]['last'] = time(); |
|
400 | 400 | } elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
401 | - date_default_timezone_set('CET'); |
|
402 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
403 | - date_default_timezone_set('UTC'); |
|
404 | - if ($buffer != '') $reset = 0; |
|
405 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
406 | - $buffer = explode('\n',$buffer); |
|
407 | - foreach ($buffer as $line) { |
|
401 | + date_default_timezone_set('CET'); |
|
402 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
403 | + date_default_timezone_set('UTC'); |
|
404 | + if ($buffer != '') $reset = 0; |
|
405 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
406 | + $buffer = explode('\n',$buffer); |
|
407 | + foreach ($buffer as $line) { |
|
408 | 408 | if ($line != '') { |
409 | - echo "'".$line."'\n"; |
|
410 | - $add = false; |
|
411 | - $ais_data = $AIS->parse_line(trim($line)); |
|
412 | - $data = array(); |
|
413 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
414 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
415 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
416 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
417 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
418 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
419 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
420 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
421 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
422 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
423 | - if (isset($ais_data['timestamp'])) { |
|
409 | + echo "'".$line."'\n"; |
|
410 | + $add = false; |
|
411 | + $ais_data = $AIS->parse_line(trim($line)); |
|
412 | + $data = array(); |
|
413 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
414 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
415 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
416 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
417 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
418 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
419 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
420 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
421 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
422 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
423 | + if (isset($ais_data['timestamp'])) { |
|
424 | 424 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
425 | 425 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
426 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
427 | - $add = true; |
|
426 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
427 | + $add = true; |
|
428 | 428 | } |
429 | - } else { |
|
429 | + } else { |
|
430 | 430 | $data['datetime'] = date('Y-m-d H:i:s'); |
431 | 431 | $add = true; |
432 | - } |
|
433 | - $data['format_source'] = 'aisnmeatxt'; |
|
434 | - $data['id_source'] = $id_source; |
|
435 | - //print_r($data); |
|
436 | - echo 'Add...'."\n"; |
|
437 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
438 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
439 | - unset($data); |
|
432 | + } |
|
433 | + $data['format_source'] = 'aisnmeatxt'; |
|
434 | + $data['id_source'] = $id_source; |
|
435 | + //print_r($data); |
|
436 | + echo 'Add...'."\n"; |
|
437 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
438 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
439 | + unset($data); |
|
440 | 440 | } |
441 | - } |
|
442 | - $last_exec[$id]['last'] = time(); |
|
441 | + } |
|
442 | + $last_exec[$id]['last'] = time(); |
|
443 | 443 | } elseif ($value['format'] == 'aisnmeahttp') { |
444 | - $arr = $httpfeeds; |
|
445 | - $w = $e = null; |
|
444 | + $arr = $httpfeeds; |
|
445 | + $w = $e = null; |
|
446 | 446 | |
447 | - if (isset($arr[$id])) { |
|
447 | + if (isset($arr[$id])) { |
|
448 | 448 | $nn = stream_select($arr,$w,$e,$timeout); |
449 | 449 | if ($nn > 0) { |
450 | - foreach ($httpfeeds as $feed) { |
|
450 | + foreach ($httpfeeds as $feed) { |
|
451 | 451 | $buffer = stream_get_line($feed,2000,"\n"); |
452 | 452 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
453 | 453 | $buffer = explode('\n',$buffer); |
454 | 454 | foreach ($buffer as $line) { |
455 | - if ($line != '') { |
|
455 | + if ($line != '') { |
|
456 | 456 | $ais_data = $AIS->parse_line(trim($line)); |
457 | 457 | $data = array(); |
458 | 458 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -468,39 +468,39 @@ discard block |
||
468 | 468 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
469 | 469 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
470 | 470 | if (isset($ais_data['timestamp'])) { |
471 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
471 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
472 | 472 | } else { |
473 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
473 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
474 | 474 | } |
475 | 475 | $data['format_source'] = 'aisnmeahttp'; |
476 | 476 | $data['id_source'] = $id_source; |
477 | 477 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
478 | 478 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
479 | 479 | unset($data); |
480 | - } |
|
480 | + } |
|
481 | + } |
|
481 | 482 | } |
482 | - } |
|
483 | 483 | } else { |
484 | - $format = $value['format']; |
|
485 | - if (isset($tt[$format])) $tt[$format]++; |
|
486 | - else $tt[$format] = 0; |
|
487 | - if ($tt[$format] > 30) { |
|
484 | + $format = $value['format']; |
|
485 | + if (isset($tt[$format])) $tt[$format]++; |
|
486 | + else $tt[$format] = 0; |
|
487 | + if ($tt[$format] > 30) { |
|
488 | 488 | sleep(2); |
489 | 489 | $sourceeen[] = $value; |
490 | 490 | connect_all($sourceeen); |
491 | 491 | $sourceeen = array(); |
492 | - } |
|
492 | + } |
|
493 | + } |
|
493 | 494 | } |
494 | - } |
|
495 | 495 | } elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
496 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
497 | - if ($buffer != '') { |
|
496 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
497 | + if ($buffer != '') { |
|
498 | 498 | //echo $buffer; |
499 | 499 | $all_data = json_decode($buffer,true); |
500 | 500 | //print_r($all_data); |
501 | 501 | if (isset($all_data[0]['DATA'])) { |
502 | 502 | foreach ($all_data[0]['DATA'] as $line) { |
503 | - if ($line != '') { |
|
503 | + if ($line != '') { |
|
504 | 504 | $data = array(); |
505 | 505 | $data['ident'] = $line['NAME']; |
506 | 506 | $data['mmsi'] = $line['MMSI']; |
@@ -517,89 +517,89 @@ discard block |
||
517 | 517 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
518 | 518 | $MI->add($data); |
519 | 519 | unset($data); |
520 | - } |
|
520 | + } |
|
521 | 521 | } |
522 | 522 | } |
523 | 523 | |
524 | - } |
|
525 | - $last_exec[$id]['last'] = time(); |
|
524 | + } |
|
525 | + $last_exec[$id]['last'] = time(); |
|
526 | 526 | } elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
527 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
528 | - if ($buffer != '') { |
|
527 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
528 | + if ($buffer != '') { |
|
529 | 529 | $all_data = json_decode($buffer,true); |
530 | 530 | if (isset($all_data[0]['mmsi'])) { |
531 | - foreach ($all_data as $line) { |
|
531 | + foreach ($all_data as $line) { |
|
532 | 532 | if ($line != '') { |
533 | - $data = array(); |
|
534 | - $data['ident'] = $line['shipname']; |
|
535 | - $data['callsign'] = $line['callsign']; |
|
536 | - $data['mmsi'] = $line['mmsi']; |
|
537 | - $data['speed'] = $line['sog']; |
|
538 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
539 | - $data['latitude'] = $line['latitude']; |
|
540 | - $data['longitude'] = $line['longitude']; |
|
541 | - $data['type_id'] = $line['shiptype']; |
|
542 | - $data['arrival_code'] = $line['destination']; |
|
543 | - $data['datetime'] = $line['time']; |
|
544 | - $data['format_source'] = 'boatbeaconapp'; |
|
545 | - $data['id_source'] = $id_source; |
|
546 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
547 | - $MI->add($data); |
|
548 | - unset($data); |
|
533 | + $data = array(); |
|
534 | + $data['ident'] = $line['shipname']; |
|
535 | + $data['callsign'] = $line['callsign']; |
|
536 | + $data['mmsi'] = $line['mmsi']; |
|
537 | + $data['speed'] = $line['sog']; |
|
538 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
539 | + $data['latitude'] = $line['latitude']; |
|
540 | + $data['longitude'] = $line['longitude']; |
|
541 | + $data['type_id'] = $line['shiptype']; |
|
542 | + $data['arrival_code'] = $line['destination']; |
|
543 | + $data['datetime'] = $line['time']; |
|
544 | + $data['format_source'] = 'boatbeaconapp'; |
|
545 | + $data['id_source'] = $id_source; |
|
546 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
547 | + $MI->add($data); |
|
548 | + unset($data); |
|
549 | + } |
|
549 | 550 | } |
550 | - } |
|
551 | 551 | } |
552 | 552 | |
553 | - } |
|
554 | - $last_exec[$id]['last'] = time(); |
|
553 | + } |
|
554 | + $last_exec[$id]['last'] = time(); |
|
555 | 555 | } elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { |
556 | - echo 'download...'; |
|
557 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
558 | - echo 'done !'."\n"; |
|
559 | - if ($buffer != '') $reset = 0; |
|
560 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
561 | - $buffer = explode('\n',$buffer); |
|
562 | - foreach ($buffer as $line) { |
|
556 | + echo 'download...'; |
|
557 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
558 | + echo 'done !'."\n"; |
|
559 | + if ($buffer != '') $reset = 0; |
|
560 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
561 | + $buffer = explode('\n',$buffer); |
|
562 | + foreach ($buffer as $line) { |
|
563 | 563 | if ($line != '') { |
564 | - $data = array(); |
|
565 | - $data['mmsi'] = (int)substr($line,0,9); |
|
566 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
567 | - //$data['status'] = substr($line,21,2); |
|
568 | - //$data['type'] = substr($line,24,3); |
|
569 | - $data['latitude'] = substr($line,29,9); |
|
570 | - $data['longitude'] = substr($line,41,9); |
|
571 | - $data['speed'] = round(substr($line,51,5)); |
|
572 | - //$data['course'] = substr($line,57,5); |
|
573 | - $data['heading'] = round(substr($line,63,3)); |
|
574 | - //$data['draft'] = substr($line,67,4); |
|
575 | - //$data['length'] = substr($line,72,3); |
|
576 | - //$data['beam'] = substr($line,76,2); |
|
577 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
578 | - //$data['callsign'] = trim(substr($line,100,7); |
|
579 | - //$data['dest'] = substr($line,108,20); |
|
580 | - //$data['etaDate'] = substr($line,129,5); |
|
581 | - //$data['etaTime'] = substr($line,135,5); |
|
582 | - $data['format_source'] = 'shipplotter'; |
|
583 | - $data['id_source'] = $id_source; |
|
584 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
585 | - //print_r($data); |
|
586 | - echo 'Add...'."\n"; |
|
587 | - $MI->add($data); |
|
588 | - unset($data); |
|
564 | + $data = array(); |
|
565 | + $data['mmsi'] = (int)substr($line,0,9); |
|
566 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
567 | + //$data['status'] = substr($line,21,2); |
|
568 | + //$data['type'] = substr($line,24,3); |
|
569 | + $data['latitude'] = substr($line,29,9); |
|
570 | + $data['longitude'] = substr($line,41,9); |
|
571 | + $data['speed'] = round(substr($line,51,5)); |
|
572 | + //$data['course'] = substr($line,57,5); |
|
573 | + $data['heading'] = round(substr($line,63,3)); |
|
574 | + //$data['draft'] = substr($line,67,4); |
|
575 | + //$data['length'] = substr($line,72,3); |
|
576 | + //$data['beam'] = substr($line,76,2); |
|
577 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); |
|
578 | + //$data['callsign'] = trim(substr($line,100,7); |
|
579 | + //$data['dest'] = substr($line,108,20); |
|
580 | + //$data['etaDate'] = substr($line,129,5); |
|
581 | + //$data['etaTime'] = substr($line,135,5); |
|
582 | + $data['format_source'] = 'shipplotter'; |
|
583 | + $data['id_source'] = $id_source; |
|
584 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
585 | + //print_r($data); |
|
586 | + echo 'Add...'."\n"; |
|
587 | + $MI->add($data); |
|
588 | + unset($data); |
|
589 | 589 | } |
590 | - } |
|
591 | - $last_exec[$id]['last'] = time(); |
|
590 | + } |
|
591 | + $last_exec[$id]['last'] = time(); |
|
592 | 592 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
593 | 593 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
594 | - //$buffer = $Common->getData($hosts[$id]); |
|
595 | - $buffer = $Common->getData($value['host']); |
|
596 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
597 | - $buffer = explode('\n',$buffer); |
|
598 | - $reset = 0; |
|
599 | - foreach ($buffer as $line) { |
|
600 | - if ($line != '') { |
|
601 | - $line = explode(':', $line); |
|
602 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
594 | + //$buffer = $Common->getData($hosts[$id]); |
|
595 | + $buffer = $Common->getData($value['host']); |
|
596 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
597 | + $buffer = explode('\n',$buffer); |
|
598 | + $reset = 0; |
|
599 | + foreach ($buffer as $line) { |
|
600 | + if ($line != '') { |
|
601 | + $line = explode(':', $line); |
|
602 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
603 | 603 | $data = array(); |
604 | 604 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
605 | 605 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -612,37 +612,37 @@ discard block |
||
612 | 612 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
613 | 613 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
614 | 614 | $data['latitude'] = $line[5]; // lat |
615 | - $data['longitude'] = $line[6]; // long |
|
616 | - $data['verticalrate'] = ''; // vertical rate |
|
617 | - $data['squawk'] = ''; // squawk |
|
618 | - $data['emergency'] = ''; // emergency |
|
619 | - $data['waypoints'] = $line[30]; |
|
615 | + $data['longitude'] = $line[6]; // long |
|
616 | + $data['verticalrate'] = ''; // vertical rate |
|
617 | + $data['squawk'] = ''; // squawk |
|
618 | + $data['emergency'] = ''; // emergency |
|
619 | + $data['waypoints'] = $line[30]; |
|
620 | 620 | $data['datetime'] = date('Y-m-d H:i:s'); |
621 | 621 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
622 | 622 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
623 | - $data['departure_airport_icao'] = $line[11]; |
|
624 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
625 | - $data['arrival_airport_icao'] = $line[13]; |
|
623 | + $data['departure_airport_icao'] = $line[11]; |
|
624 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
625 | + $data['arrival_airport_icao'] = $line[13]; |
|
626 | 626 | $data['frequency'] = $line[4]; |
627 | 627 | $data['type'] = $line[18]; |
628 | 628 | $data['range'] = $line[19]; |
629 | 629 | if (isset($line[35])) $data['info'] = $line[35]; |
630 | - $data['id_source'] = $id_source; |
|
631 | - //$data['arrival_airport_time'] = ; |
|
632 | - if ($line[9] != '') { |
|
633 | - $aircraft_data = explode('/',$line[9]); |
|
634 | - if (isset($aircraft_data[1])) { |
|
635 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
636 | - } |
|
637 | - } |
|
638 | - /* |
|
630 | + $data['id_source'] = $id_source; |
|
631 | + //$data['arrival_airport_time'] = ; |
|
632 | + if ($line[9] != '') { |
|
633 | + $aircraft_data = explode('/',$line[9]); |
|
634 | + if (isset($aircraft_data[1])) { |
|
635 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
636 | + } |
|
637 | + } |
|
638 | + /* |
|
639 | 639 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
640 | 640 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
641 | 641 | */ |
642 | - $data['format_source'] = $value['format']; |
|
642 | + $data['format_source'] = $value['format']; |
|
643 | 643 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
644 | 644 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
645 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
645 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
646 | 646 | elseif ($line[3] == 'ATC') { |
647 | 647 | //print_r($data); |
648 | 648 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -660,255 +660,255 @@ discard block |
||
660 | 660 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
661 | 661 | if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
662 | 662 | } |
663 | - unset($data); |
|
664 | - } |
|
665 | - } |
|
666 | - } |
|
667 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
668 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
669 | - $last_exec[$id]['last'] = time(); |
|
670 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
671 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
672 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
673 | - if ($buffer != '') { |
|
674 | - $all_data = json_decode($buffer,true); |
|
675 | - if (isset($all_data['acList'])) { |
|
663 | + unset($data); |
|
664 | + } |
|
665 | + } |
|
666 | + } |
|
667 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
668 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
669 | + $last_exec[$id]['last'] = time(); |
|
670 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
671 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
672 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
673 | + if ($buffer != '') { |
|
674 | + $all_data = json_decode($buffer,true); |
|
675 | + if (isset($all_data['acList'])) { |
|
676 | 676 | $reset = 0; |
677 | 677 | foreach ($all_data['acList'] as $line) { |
678 | - $data = array(); |
|
679 | - $data['hex'] = $line['Icao']; // hex |
|
680 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
681 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
682 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
683 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
684 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
685 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
686 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
687 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
688 | - $data['emergency'] = ''; // emergency |
|
689 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
678 | + $data = array(); |
|
679 | + $data['hex'] = $line['Icao']; // hex |
|
680 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
681 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
682 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
683 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
684 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
685 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
686 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
687 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
688 | + $data['emergency'] = ''; // emergency |
|
689 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
690 | 690 | |
691 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
692 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
691 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
692 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
693 | 693 | |
694 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
695 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
696 | - $data['format_source'] = 'aircraftlistjson'; |
|
697 | - $data['id_source'] = $id_source; |
|
698 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
699 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
700 | - if (isset($data['latitude'])) $SI->add($data); |
|
701 | - unset($data); |
|
694 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
695 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
696 | + $data['format_source'] = 'aircraftlistjson'; |
|
697 | + $data['id_source'] = $id_source; |
|
698 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
699 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
700 | + if (isset($data['latitude'])) $SI->add($data); |
|
701 | + unset($data); |
|
702 | 702 | } |
703 | - } elseif (is_array($all_data)) { |
|
703 | + } elseif (is_array($all_data)) { |
|
704 | 704 | $reset = 0; |
705 | 705 | foreach ($all_data as $line) { |
706 | - $data = array(); |
|
707 | - $data['hex'] = $line['hex']; // hex |
|
708 | - $data['ident'] = $line['flight']; // ident |
|
709 | - $data['altitude'] = $line['altitude']; // altitude |
|
710 | - $data['speed'] = $line['speed']; // speed |
|
711 | - $data['heading'] = $line['track']; // heading |
|
712 | - $data['latitude'] = $line['lat']; // lat |
|
713 | - $data['longitude'] = $line['lon']; // long |
|
714 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
715 | - $data['squawk'] = $line['squawk']; // squawk |
|
716 | - $data['emergency'] = ''; // emergency |
|
717 | - if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
718 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
719 | - $data['format_source'] = 'aircraftlistjson'; |
|
720 | - $data['id_source'] = $id_source; |
|
721 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
722 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
723 | - $SI->add($data); |
|
724 | - unset($data); |
|
706 | + $data = array(); |
|
707 | + $data['hex'] = $line['hex']; // hex |
|
708 | + $data['ident'] = $line['flight']; // ident |
|
709 | + $data['altitude'] = $line['altitude']; // altitude |
|
710 | + $data['speed'] = $line['speed']; // speed |
|
711 | + $data['heading'] = $line['track']; // heading |
|
712 | + $data['latitude'] = $line['lat']; // lat |
|
713 | + $data['longitude'] = $line['lon']; // long |
|
714 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
715 | + $data['squawk'] = $line['squawk']; // squawk |
|
716 | + $data['emergency'] = ''; // emergency |
|
717 | + if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); |
|
718 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
719 | + $data['format_source'] = 'aircraftlistjson'; |
|
720 | + $data['id_source'] = $id_source; |
|
721 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
722 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
723 | + $SI->add($data); |
|
724 | + unset($data); |
|
725 | + } |
|
725 | 726 | } |
726 | - } |
|
727 | - } |
|
728 | - //$last_exec['aircraftlistjson'] = time(); |
|
729 | - $last_exec[$id]['last'] = time(); |
|
730 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
731 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
732 | - $buffer = $Common->getData($value['host']); |
|
733 | - $all_data = json_decode($buffer,true); |
|
734 | - if (isset($all_data['planes'])) { |
|
727 | + } |
|
728 | + //$last_exec['aircraftlistjson'] = time(); |
|
729 | + $last_exec[$id]['last'] = time(); |
|
730 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
731 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
732 | + $buffer = $Common->getData($value['host']); |
|
733 | + $all_data = json_decode($buffer,true); |
|
734 | + if (isset($all_data['planes'])) { |
|
735 | 735 | $reset = 0; |
736 | 736 | foreach ($all_data['planes'] as $key => $line) { |
737 | - $data = array(); |
|
738 | - $data['hex'] = $key; // hex |
|
739 | - $data['ident'] = $line[3]; // ident |
|
740 | - $data['altitude'] = $line[6]; // altitude |
|
741 | - $data['speed'] = $line[8]; // speed |
|
742 | - $data['heading'] = $line[7]; // heading |
|
743 | - $data['latitude'] = $line[4]; // lat |
|
744 | - $data['longitude'] = $line[5]; // long |
|
745 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
746 | - $data['squawk'] = $line[10]; // squawk |
|
747 | - $data['emergency'] = ''; // emergency |
|
748 | - $data['registration'] = $line[2]; |
|
749 | - $data['aircraft_icao'] = $line[0]; |
|
750 | - $deparr = explode('-',$line[1]); |
|
751 | - if (count($deparr) == 2) { |
|
737 | + $data = array(); |
|
738 | + $data['hex'] = $key; // hex |
|
739 | + $data['ident'] = $line[3]; // ident |
|
740 | + $data['altitude'] = $line[6]; // altitude |
|
741 | + $data['speed'] = $line[8]; // speed |
|
742 | + $data['heading'] = $line[7]; // heading |
|
743 | + $data['latitude'] = $line[4]; // lat |
|
744 | + $data['longitude'] = $line[5]; // long |
|
745 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
746 | + $data['squawk'] = $line[10]; // squawk |
|
747 | + $data['emergency'] = ''; // emergency |
|
748 | + $data['registration'] = $line[2]; |
|
749 | + $data['aircraft_icao'] = $line[0]; |
|
750 | + $deparr = explode('-',$line[1]); |
|
751 | + if (count($deparr) == 2) { |
|
752 | 752 | $data['departure_airport_icao'] = $deparr[0]; |
753 | 753 | $data['arrival_airport_icao'] = $deparr[1]; |
754 | - } |
|
755 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
756 | - $data['format_source'] = 'planeupdatefaa'; |
|
757 | - $data['id_source'] = $id_source; |
|
758 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
759 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
760 | - $SI->add($data); |
|
761 | - unset($data); |
|
754 | + } |
|
755 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
756 | + $data['format_source'] = 'planeupdatefaa'; |
|
757 | + $data['id_source'] = $id_source; |
|
758 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
759 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
760 | + $SI->add($data); |
|
761 | + unset($data); |
|
762 | + } |
|
762 | 763 | } |
763 | - } |
|
764 | - //$last_exec['planeupdatefaa'] = time(); |
|
765 | - $last_exec[$id]['last'] = time(); |
|
766 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
767 | - $buffer = $Common->getData($value['host']); |
|
768 | - $all_data = json_decode($buffer,true); |
|
769 | - if (isset($all_data['states'])) { |
|
764 | + //$last_exec['planeupdatefaa'] = time(); |
|
765 | + $last_exec[$id]['last'] = time(); |
|
766 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
767 | + $buffer = $Common->getData($value['host']); |
|
768 | + $all_data = json_decode($buffer,true); |
|
769 | + if (isset($all_data['states'])) { |
|
770 | 770 | $reset = 0; |
771 | 771 | foreach ($all_data['states'] as $key => $line) { |
772 | - $data = array(); |
|
773 | - $data['hex'] = $line[0]; // hex |
|
774 | - $data['ident'] = trim($line[1]); // ident |
|
775 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
776 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
777 | - $data['heading'] = round($line[10]); // heading |
|
778 | - $data['latitude'] = $line[5]; // lat |
|
779 | - $data['longitude'] = $line[6]; // long |
|
780 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
781 | - //$data['squawk'] = $line[10]; // squawk |
|
782 | - //$data['emergency'] = ''; // emergency |
|
783 | - //$data['registration'] = $line[2]; |
|
784 | - //$data['aircraft_icao'] = $line[0]; |
|
785 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
786 | - $data['format_source'] = 'opensky'; |
|
787 | - $data['id_source'] = $id_source; |
|
788 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
789 | - $SI->add($data); |
|
790 | - unset($data); |
|
772 | + $data = array(); |
|
773 | + $data['hex'] = $line[0]; // hex |
|
774 | + $data['ident'] = trim($line[1]); // ident |
|
775 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
776 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
777 | + $data['heading'] = round($line[10]); // heading |
|
778 | + $data['latitude'] = $line[5]; // lat |
|
779 | + $data['longitude'] = $line[6]; // long |
|
780 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
781 | + //$data['squawk'] = $line[10]; // squawk |
|
782 | + //$data['emergency'] = ''; // emergency |
|
783 | + //$data['registration'] = $line[2]; |
|
784 | + //$data['aircraft_icao'] = $line[0]; |
|
785 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
786 | + $data['format_source'] = 'opensky'; |
|
787 | + $data['id_source'] = $id_source; |
|
788 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
789 | + $SI->add($data); |
|
790 | + unset($data); |
|
791 | + } |
|
791 | 792 | } |
792 | - } |
|
793 | - //$last_exec['planeupdatefaa'] = time(); |
|
794 | - $last_exec[$id]['last'] = time(); |
|
795 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
796 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
797 | - //$buffer = $Common->getData($hosts[$id]); |
|
798 | - $buffer = $Common->getData($value['host']); |
|
799 | - $all_data = json_decode($buffer,true); |
|
800 | - if (!empty($all_data)) $reset = 0; |
|
801 | - foreach ($all_data as $key => $line) { |
|
793 | + //$last_exec['planeupdatefaa'] = time(); |
|
794 | + $last_exec[$id]['last'] = time(); |
|
795 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
796 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
797 | + //$buffer = $Common->getData($hosts[$id]); |
|
798 | + $buffer = $Common->getData($value['host']); |
|
799 | + $all_data = json_decode($buffer,true); |
|
800 | + if (!empty($all_data)) $reset = 0; |
|
801 | + foreach ($all_data as $key => $line) { |
|
802 | 802 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
803 | - $data = array(); |
|
804 | - $data['hex'] = $line[0]; |
|
805 | - $data['ident'] = $line[16]; //$line[13] |
|
806 | - $data['altitude'] = $line[4]; // altitude |
|
807 | - $data['speed'] = $line[5]; // speed |
|
808 | - $data['heading'] = $line[3]; // heading |
|
809 | - $data['latitude'] = $line[1]; // lat |
|
810 | - $data['longitude'] = $line[2]; // long |
|
811 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
812 | - $data['squawk'] = $line[6]; // squawk |
|
813 | - $data['aircraft_icao'] = $line[8]; |
|
814 | - $data['registration'] = $line[9]; |
|
815 | - $data['departure_airport_iata'] = $line[11]; |
|
816 | - $data['arrival_airport_iata'] = $line[12]; |
|
817 | - $data['emergency'] = ''; // emergency |
|
818 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
819 | - $data['format_source'] = 'fr24json'; |
|
820 | - $data['id_source'] = $id_source; |
|
821 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
822 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
823 | - $SI->add($data); |
|
824 | - unset($data); |
|
803 | + $data = array(); |
|
804 | + $data['hex'] = $line[0]; |
|
805 | + $data['ident'] = $line[16]; //$line[13] |
|
806 | + $data['altitude'] = $line[4]; // altitude |
|
807 | + $data['speed'] = $line[5]; // speed |
|
808 | + $data['heading'] = $line[3]; // heading |
|
809 | + $data['latitude'] = $line[1]; // lat |
|
810 | + $data['longitude'] = $line[2]; // long |
|
811 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
812 | + $data['squawk'] = $line[6]; // squawk |
|
813 | + $data['aircraft_icao'] = $line[8]; |
|
814 | + $data['registration'] = $line[9]; |
|
815 | + $data['departure_airport_iata'] = $line[11]; |
|
816 | + $data['arrival_airport_iata'] = $line[12]; |
|
817 | + $data['emergency'] = ''; // emergency |
|
818 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
819 | + $data['format_source'] = 'fr24json'; |
|
820 | + $data['id_source'] = $id_source; |
|
821 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
822 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
823 | + $SI->add($data); |
|
824 | + unset($data); |
|
825 | + } |
|
825 | 826 | } |
826 | - } |
|
827 | - //$last_exec['fr24json'] = time(); |
|
828 | - $last_exec[$id]['last'] = time(); |
|
829 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
830 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
831 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
832 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
833 | - //echo $buffer; |
|
834 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
835 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
836 | - $all_data = json_decode($buffer,true); |
|
837 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
827 | + //$last_exec['fr24json'] = time(); |
|
828 | + $last_exec[$id]['last'] = time(); |
|
829 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
830 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
831 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
832 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
833 | + //echo $buffer; |
|
834 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
835 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
836 | + $all_data = json_decode($buffer,true); |
|
837 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
838 | 838 | die(json_last_error_msg()); |
839 | - } |
|
840 | - if (isset($all_data['mrkrs'])) { |
|
839 | + } |
|
840 | + if (isset($all_data['mrkrs'])) { |
|
841 | 841 | $reset = 0; |
842 | 842 | foreach ($all_data['mrkrs'] as $key => $line) { |
843 | - if (isset($line['inf'])) { |
|
843 | + if (isset($line['inf'])) { |
|
844 | 844 | $data = array(); |
845 | 845 | $data['hex'] = $line['inf']['ia']; |
846 | 846 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
847 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
848 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
849 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
850 | - $data['latitude'] = $line['pt'][0]; // lat |
|
851 | - $data['longitude'] = $line['pt'][1]; // long |
|
852 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
853 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
854 | - //$data['aircraft_icao'] = $line[8]; |
|
855 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
847 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
848 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
849 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
850 | + $data['latitude'] = $line['pt'][0]; // lat |
|
851 | + $data['longitude'] = $line['pt'][1]; // long |
|
852 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
853 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
854 | + //$data['aircraft_icao'] = $line[8]; |
|
855 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
856 | 856 | //$data['departure_airport_iata'] = $line[11]; |
857 | 857 | //$data['arrival_airport_iata'] = $line[12]; |
858 | - //$data['emergency'] = ''; // emergency |
|
858 | + //$data['emergency'] = ''; // emergency |
|
859 | 859 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
860 | - $data['format_source'] = 'radarvirtueljson'; |
|
861 | - $data['id_source'] = $id_source; |
|
860 | + $data['format_source'] = 'radarvirtueljson'; |
|
861 | + $data['id_source'] = $id_source; |
|
862 | 862 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
863 | 863 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
864 | 864 | $SI->add($data); |
865 | 865 | unset($data); |
866 | - } |
|
866 | + } |
|
867 | + } |
|
867 | 868 | } |
868 | - } |
|
869 | - //$last_exec['radarvirtueljson'] = time(); |
|
870 | - $last_exec[$id]['last'] = time(); |
|
871 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
872 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
873 | - //$buffer = $Common->getData($hosts[$id]); |
|
874 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
875 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
869 | + //$last_exec['radarvirtueljson'] = time(); |
|
870 | + $last_exec[$id]['last'] = time(); |
|
871 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
872 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
873 | + //$buffer = $Common->getData($hosts[$id]); |
|
874 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
875 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
876 | 876 | |
877 | - if (isset($all_data['pireps'])) { |
|
877 | + if (isset($all_data['pireps'])) { |
|
878 | 878 | $reset = 0; |
879 | - foreach ($all_data['pireps'] as $line) { |
|
880 | - $data = array(); |
|
881 | - $data['id'] = $line['id']; |
|
882 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
883 | - $data['ident'] = $line['callsign']; // ident |
|
884 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
885 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
886 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
887 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
888 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
889 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
890 | - $data['latitude'] = $line['lat']; // lat |
|
891 | - $data['longitude'] = $line['lon']; // long |
|
892 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
893 | - //$data['squawk'] = $line['squawk']; // squawk |
|
894 | - //$data['emergency'] = ''; // emergency |
|
895 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
896 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
897 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
898 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
899 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
900 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
901 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
902 | - else $data['info'] = ''; |
|
903 | - $data['format_source'] = 'pireps'; |
|
904 | - $data['id_source'] = $id_source; |
|
905 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
906 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
907 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
908 | - if ($line['icon'] == 'plane') { |
|
879 | + foreach ($all_data['pireps'] as $line) { |
|
880 | + $data = array(); |
|
881 | + $data['id'] = $line['id']; |
|
882 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
883 | + $data['ident'] = $line['callsign']; // ident |
|
884 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
885 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
886 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
887 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
888 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
889 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
890 | + $data['latitude'] = $line['lat']; // lat |
|
891 | + $data['longitude'] = $line['lon']; // long |
|
892 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
893 | + //$data['squawk'] = $line['squawk']; // squawk |
|
894 | + //$data['emergency'] = ''; // emergency |
|
895 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
896 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
897 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
898 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
899 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
900 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
901 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
902 | + else $data['info'] = ''; |
|
903 | + $data['format_source'] = 'pireps'; |
|
904 | + $data['id_source'] = $id_source; |
|
905 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
906 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
907 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
908 | + if ($line['icon'] == 'plane') { |
|
909 | 909 | $SI->add($data); |
910 | - // print_r($data); |
|
911 | - } elseif ($line['icon'] == 'ct') { |
|
910 | + // print_r($data); |
|
911 | + } elseif ($line['icon'] == 'ct') { |
|
912 | 912 | $data['info'] = str_replace('^§','<br />',$data['info']); |
913 | 913 | $data['info'] = str_replace('&sect;','',$data['info']); |
914 | 914 | $typec = substr($data['ident'],-3); |
@@ -923,196 +923,196 @@ discard block |
||
923 | 923 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
924 | 924 | else $data['type'] = 'Observer'; |
925 | 925 | if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
926 | - } |
|
927 | - unset($data); |
|
926 | + } |
|
927 | + unset($data); |
|
928 | 928 | } |
929 | - } |
|
930 | - //$last_exec['pirepsjson'] = time(); |
|
931 | - $last_exec[$id]['last'] = time(); |
|
932 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
933 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
934 | - //$buffer = $Common->getData($hosts[$id]); |
|
935 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
936 | - $buffer = $Common->getData($value['host']); |
|
937 | - $all_data = json_decode($buffer,true); |
|
938 | - if ($buffer != '' && is_array($all_data)) { |
|
929 | + } |
|
930 | + //$last_exec['pirepsjson'] = time(); |
|
931 | + $last_exec[$id]['last'] = time(); |
|
932 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
933 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
934 | + //$buffer = $Common->getData($hosts[$id]); |
|
935 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
936 | + $buffer = $Common->getData($value['host']); |
|
937 | + $all_data = json_decode($buffer,true); |
|
938 | + if ($buffer != '' && is_array($all_data)) { |
|
939 | 939 | $reset = 0; |
940 | 940 | foreach ($all_data as $line) { |
941 | - $data = array(); |
|
942 | - //$data['id'] = $line['id']; // id not usable |
|
943 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
944 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
945 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
946 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
947 | - $data['ident'] = $line['flightnum']; // ident |
|
948 | - $data['altitude'] = $line['alt']; // altitude |
|
949 | - $data['speed'] = $line['gs']; // speed |
|
950 | - $data['heading'] = $line['heading']; // heading |
|
951 | - $data['latitude'] = $line['lat']; // lat |
|
952 | - $data['longitude'] = $line['lng']; // long |
|
953 | - $data['verticalrate'] = ''; // verticale rate |
|
954 | - $data['squawk'] = ''; // squawk |
|
955 | - $data['emergency'] = ''; // emergency |
|
956 | - //$data['datetime'] = $line['lastupdate']; |
|
957 | - $data['last_update'] = $line['lastupdate']; |
|
958 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
959 | - $data['departure_airport_icao'] = $line['depicao']; |
|
960 | - $data['departure_airport_time'] = $line['deptime']; |
|
961 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
962 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
963 | - $data['registration'] = $line['aircraft']; |
|
964 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
965 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
966 | - if (isset($line['aircraftname'])) { |
|
941 | + $data = array(); |
|
942 | + //$data['id'] = $line['id']; // id not usable |
|
943 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
944 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
945 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
946 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
947 | + $data['ident'] = $line['flightnum']; // ident |
|
948 | + $data['altitude'] = $line['alt']; // altitude |
|
949 | + $data['speed'] = $line['gs']; // speed |
|
950 | + $data['heading'] = $line['heading']; // heading |
|
951 | + $data['latitude'] = $line['lat']; // lat |
|
952 | + $data['longitude'] = $line['lng']; // long |
|
953 | + $data['verticalrate'] = ''; // verticale rate |
|
954 | + $data['squawk'] = ''; // squawk |
|
955 | + $data['emergency'] = ''; // emergency |
|
956 | + //$data['datetime'] = $line['lastupdate']; |
|
957 | + $data['last_update'] = $line['lastupdate']; |
|
958 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
959 | + $data['departure_airport_icao'] = $line['depicao']; |
|
960 | + $data['departure_airport_time'] = $line['deptime']; |
|
961 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
962 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
963 | + $data['registration'] = $line['aircraft']; |
|
964 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
965 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
966 | + if (isset($line['aircraftname'])) { |
|
967 | 967 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
968 | 968 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
969 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
970 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
971 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
972 | - else { |
|
973 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
974 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
975 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
976 | - } |
|
977 | - } |
|
978 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
979 | - $data['id_source'] = $id_source; |
|
980 | - $data['format_source'] = 'phpvmacars'; |
|
981 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
982 | - $SI->add($data); |
|
983 | - unset($data); |
|
969 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
970 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
971 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
972 | + else { |
|
973 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
974 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
975 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
976 | + } |
|
977 | + } |
|
978 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
979 | + $data['id_source'] = $id_source; |
|
980 | + $data['format_source'] = 'phpvmacars'; |
|
981 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
982 | + $SI->add($data); |
|
983 | + unset($data); |
|
984 | 984 | } |
985 | 985 | if ($globalDebug) echo 'No more data...'."\n"; |
986 | 986 | unset($buffer); |
987 | 987 | unset($all_data); |
988 | - } |
|
989 | - //$last_exec['phpvmacars'] = time(); |
|
990 | - $last_exec[$id]['last'] = time(); |
|
991 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
992 | - //$buffer = $Common->getData($hosts[$id]); |
|
993 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
994 | - $buffer = $Common->getData($value['host']); |
|
995 | - $all_data = json_decode($buffer,true); |
|
996 | - if ($buffer != '' && is_array($all_data)) { |
|
988 | + } |
|
989 | + //$last_exec['phpvmacars'] = time(); |
|
990 | + $last_exec[$id]['last'] = time(); |
|
991 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
992 | + //$buffer = $Common->getData($hosts[$id]); |
|
993 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
994 | + $buffer = $Common->getData($value['host']); |
|
995 | + $all_data = json_decode($buffer,true); |
|
996 | + if ($buffer != '' && is_array($all_data)) { |
|
997 | 997 | $reset = 0; |
998 | 998 | foreach ($all_data as $line) { |
999 | - $data = array(); |
|
1000 | - //$data['id'] = $line['id']; // id not usable |
|
1001 | - $data['id'] = trim($line['flight_id']); |
|
1002 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1003 | - $data['pilot_name'] = $line['pilot_name']; |
|
1004 | - $data['pilot_id'] = $line['pilot_id']; |
|
1005 | - $data['ident'] = trim($line['callsign']); // ident |
|
1006 | - $data['altitude'] = $line['altitude']; // altitude |
|
1007 | - $data['speed'] = $line['gs']; // speed |
|
1008 | - $data['heading'] = $line['heading']; // heading |
|
1009 | - $data['latitude'] = $line['latitude']; // lat |
|
1010 | - $data['longitude'] = $line['longitude']; // long |
|
1011 | - $data['verticalrate'] = ''; // verticale rate |
|
1012 | - $data['squawk'] = ''; // squawk |
|
1013 | - $data['emergency'] = ''; // emergency |
|
1014 | - //$data['datetime'] = $line['lastupdate']; |
|
1015 | - $data['last_update'] = $line['last_update']; |
|
1016 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1017 | - $data['departure_airport_icao'] = $line['departure']; |
|
1018 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1019 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1020 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1021 | - //$data['registration'] = $line['aircraft']; |
|
1022 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1023 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1024 | - $data['id_source'] = $id_source; |
|
1025 | - $data['format_source'] = 'vam'; |
|
1026 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1027 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1028 | - $SI->add($data); |
|
1029 | - unset($data); |
|
999 | + $data = array(); |
|
1000 | + //$data['id'] = $line['id']; // id not usable |
|
1001 | + $data['id'] = trim($line['flight_id']); |
|
1002 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1003 | + $data['pilot_name'] = $line['pilot_name']; |
|
1004 | + $data['pilot_id'] = $line['pilot_id']; |
|
1005 | + $data['ident'] = trim($line['callsign']); // ident |
|
1006 | + $data['altitude'] = $line['altitude']; // altitude |
|
1007 | + $data['speed'] = $line['gs']; // speed |
|
1008 | + $data['heading'] = $line['heading']; // heading |
|
1009 | + $data['latitude'] = $line['latitude']; // lat |
|
1010 | + $data['longitude'] = $line['longitude']; // long |
|
1011 | + $data['verticalrate'] = ''; // verticale rate |
|
1012 | + $data['squawk'] = ''; // squawk |
|
1013 | + $data['emergency'] = ''; // emergency |
|
1014 | + //$data['datetime'] = $line['lastupdate']; |
|
1015 | + $data['last_update'] = $line['last_update']; |
|
1016 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1017 | + $data['departure_airport_icao'] = $line['departure']; |
|
1018 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1019 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1020 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1021 | + //$data['registration'] = $line['aircraft']; |
|
1022 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1023 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1024 | + $data['id_source'] = $id_source; |
|
1025 | + $data['format_source'] = 'vam'; |
|
1026 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1027 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1028 | + $SI->add($data); |
|
1029 | + unset($data); |
|
1030 | 1030 | } |
1031 | 1031 | if ($globalDebug) echo 'No more data...'."\n"; |
1032 | 1032 | unset($buffer); |
1033 | 1033 | unset($all_data); |
1034 | - } |
|
1035 | - //$last_exec['phpvmacars'] = time(); |
|
1036 | - $last_exec[$id]['last'] = time(); |
|
1034 | + } |
|
1035 | + //$last_exec['phpvmacars'] = time(); |
|
1036 | + $last_exec[$id]['last'] = time(); |
|
1037 | 1037 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
1038 | 1038 | } elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') { |
1039 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1040 | - //$last_exec[$id]['last'] = time(); |
|
1039 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1040 | + //$last_exec[$id]['last'] = time(); |
|
1041 | 1041 | |
1042 | - //$read = array( $sockets[$id] ); |
|
1043 | - $read = $sockets; |
|
1044 | - $write = NULL; |
|
1045 | - $e = NULL; |
|
1046 | - $n = socket_select($read, $write, $e, $timeout); |
|
1047 | - if ($e != NULL) var_dump($e); |
|
1048 | - if ($n > 0) { |
|
1042 | + //$read = array( $sockets[$id] ); |
|
1043 | + $read = $sockets; |
|
1044 | + $write = NULL; |
|
1045 | + $e = NULL; |
|
1046 | + $n = socket_select($read, $write, $e, $timeout); |
|
1047 | + if ($e != NULL) var_dump($e); |
|
1048 | + if ($n > 0) { |
|
1049 | 1049 | $reset = 0; |
1050 | 1050 | foreach ($read as $nb => $r) { |
1051 | - //$value = $formats[$nb]; |
|
1052 | - $format = $globalSources[$nb]['format']; |
|
1053 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1051 | + //$value = $formats[$nb]; |
|
1052 | + $format = $globalSources[$nb]['format']; |
|
1053 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
1054 | 1054 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1055 | - } elseif ($format == 'vrstcp') { |
|
1055 | + } elseif ($format == 'vrstcp') { |
|
1056 | 1056 | $buffer = @socket_read($r, 6000); |
1057 | - } else { |
|
1057 | + } else { |
|
1058 | 1058 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1059 | - } |
|
1060 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1061 | - //echo $buffer."\n"; |
|
1062 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1063 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1064 | - $error = false; |
|
1065 | - //$SI::del(); |
|
1066 | - if ($format == 'vrstcp') { |
|
1059 | + } |
|
1060 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1061 | + //echo $buffer."\n"; |
|
1062 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1063 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1064 | + $error = false; |
|
1065 | + //$SI::del(); |
|
1066 | + if ($format == 'vrstcp') { |
|
1067 | 1067 | $buffer = explode('},{',$buffer); |
1068 | - } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1069 | - // SBS format is CSV format |
|
1070 | - if ($buffer !== FALSE && $buffer != '') { |
|
1068 | + } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
1069 | + // SBS format is CSV format |
|
1070 | + if ($buffer !== FALSE && $buffer != '') { |
|
1071 | 1071 | $tt[$format] = 0; |
1072 | 1072 | if ($format == 'acarssbs3') { |
1073 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1074 | - $ACARS->add(trim($buffer)); |
|
1075 | - $ACARS->deleteLiveAcarsData(); |
|
1073 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1074 | + $ACARS->add(trim($buffer)); |
|
1075 | + $ACARS->deleteLiveAcarsData(); |
|
1076 | 1076 | } elseif ($format == 'raw') { |
1077 | - // AVR format |
|
1078 | - $data = $SBS->parse($buffer); |
|
1079 | - if (is_array($data)) { |
|
1077 | + // AVR format |
|
1078 | + $data = $SBS->parse($buffer); |
|
1079 | + if (is_array($data)) { |
|
1080 | 1080 | $data['datetime'] = date('Y-m-d H:i:s'); |
1081 | 1081 | $data['format_source'] = 'raw'; |
1082 | 1082 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1083 | 1083 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1084 | 1084 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1085 | 1085 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1086 | - } |
|
1086 | + } |
|
1087 | 1087 | } elseif ($format == 'ais') { |
1088 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1089 | - $data = array(); |
|
1090 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1091 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1092 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1093 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1094 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1095 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1096 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1097 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1098 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1099 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1100 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1101 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1102 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1088 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1089 | + $data = array(); |
|
1090 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1091 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; |
|
1092 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1093 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1094 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1095 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1096 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1097 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1098 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1099 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1100 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1101 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1102 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1103 | 1103 | |
1104 | - if (isset($ais_data['timestamp'])) { |
|
1104 | + if (isset($ais_data['timestamp'])) { |
|
1105 | 1105 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1106 | - } else { |
|
1106 | + } else { |
|
1107 | 1107 | $data['datetime'] = date('Y-m-d H:i:s'); |
1108 | - } |
|
1109 | - $data['format_source'] = 'aisnmea'; |
|
1110 | - $data['id_source'] = $id_source; |
|
1111 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1112 | - unset($data); |
|
1113 | - } elseif ($format == 'flightgearsp') { |
|
1114 | - //echo $buffer."\n"; |
|
1115 | - if (strlen($buffer) > 5) { |
|
1108 | + } |
|
1109 | + $data['format_source'] = 'aisnmea'; |
|
1110 | + $data['id_source'] = $id_source; |
|
1111 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); |
|
1112 | + unset($data); |
|
1113 | + } elseif ($format == 'flightgearsp') { |
|
1114 | + //echo $buffer."\n"; |
|
1115 | + if (strlen($buffer) > 5) { |
|
1116 | 1116 | $line = explode(',',$buffer); |
1117 | 1117 | $data = array(); |
1118 | 1118 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1129,38 +1129,38 @@ discard block |
||
1129 | 1129 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1130 | 1130 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1131 | 1131 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1132 | - } |
|
1133 | - } elseif ($format == 'acars') { |
|
1134 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1135 | - $ACARS->add(trim($buffer)); |
|
1136 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1137 | - $ACARS->deleteLiveAcarsData(); |
|
1132 | + } |
|
1133 | + } elseif ($format == 'acars') { |
|
1134 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1135 | + $ACARS->add(trim($buffer)); |
|
1136 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1137 | + $ACARS->deleteLiveAcarsData(); |
|
1138 | 1138 | } elseif ($format == 'flightgearmp') { |
1139 | - if (substr($buffer,0,1) != '#') { |
|
1139 | + if (substr($buffer,0,1) != '#') { |
|
1140 | 1140 | $data = array(); |
1141 | 1141 | //echo $buffer."\n"; |
1142 | 1142 | $line = explode(' ',$buffer); |
1143 | 1143 | if (count($line) == 11) { |
1144 | - $userserver = explode('@',$line[0]); |
|
1145 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1146 | - $data['ident'] = $userserver[0]; |
|
1147 | - $data['registration'] = $userserver[0]; |
|
1148 | - $data['latitude'] = $line[4]; |
|
1149 | - $data['longitude'] = $line[5]; |
|
1150 | - $data['altitude'] = $line[6]; |
|
1151 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1152 | - $aircraft_type = $line[10]; |
|
1153 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1154 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1155 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1156 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1144 | + $userserver = explode('@',$line[0]); |
|
1145 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1146 | + $data['ident'] = $userserver[0]; |
|
1147 | + $data['registration'] = $userserver[0]; |
|
1148 | + $data['latitude'] = $line[4]; |
|
1149 | + $data['longitude'] = $line[5]; |
|
1150 | + $data['altitude'] = $line[6]; |
|
1151 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1152 | + $aircraft_type = $line[10]; |
|
1153 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1154 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1155 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1156 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1157 | + } |
|
1157 | 1158 | } |
1158 | - } |
|
1159 | 1159 | } elseif ($format == 'beast') { |
1160 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1161 | - die; |
|
1160 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1161 | + die; |
|
1162 | 1162 | } elseif ($format == 'vrstcp') { |
1163 | - foreach($buffer as $all_data) { |
|
1163 | + foreach($buffer as $all_data) { |
|
1164 | 1164 | $line = json_decode('{'.$all_data.'}',true); |
1165 | 1165 | $data = array(); |
1166 | 1166 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1180,107 +1180,107 @@ discard block |
||
1180 | 1180 | */ |
1181 | 1181 | $data['datetime'] = date('Y-m-d H:i:s'); |
1182 | 1182 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1183 | - $data['format_source'] = 'vrstcp'; |
|
1183 | + $data['format_source'] = 'vrstcp'; |
|
1184 | 1184 | $data['id_source'] = $id_source; |
1185 | 1185 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1186 | 1186 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1187 | 1187 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1188 | 1188 | unset($data); |
1189 | - } |
|
1189 | + } |
|
1190 | 1190 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
1191 | - $line = explode("\t", $buffer); |
|
1192 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1191 | + $line = explode("\t", $buffer); |
|
1192 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1193 | 1193 | $key = $line[$k]; |
1194 | - $lined[$key] = $line[$k+1]; |
|
1195 | - } |
|
1196 | - if (count($lined) > 3) { |
|
1197 | - $data['hex'] = $lined['hexid']; |
|
1198 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1199 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1200 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1201 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1202 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1203 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1204 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1205 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1206 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1207 | - $data['id_source'] = $id_source; |
|
1208 | - $data['format_source'] = 'tsv'; |
|
1209 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1210 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1194 | + $lined[$key] = $line[$k+1]; |
|
1195 | + } |
|
1196 | + if (count($lined) > 3) { |
|
1197 | + $data['hex'] = $lined['hexid']; |
|
1198 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1199 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1200 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1201 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1202 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1203 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1204 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1205 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1206 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1207 | + $data['id_source'] = $id_source; |
|
1208 | + $data['format_source'] = 'tsv'; |
|
1209 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1210 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1211 | 1211 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1212 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1213 | - unset($lined); |
|
1214 | - unset($data); |
|
1215 | - } else $error = true; |
|
1212 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1213 | + unset($lined); |
|
1214 | + unset($data); |
|
1215 | + } else $error = true; |
|
1216 | 1216 | } elseif ($format == 'aprs' && $use_aprs) { |
1217 | - if ($aprs_connect == 0) { |
|
1217 | + if ($aprs_connect == 0) { |
|
1218 | 1218 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1219 | 1219 | $aprs_connect = 1; |
1220 | - } |
|
1220 | + } |
|
1221 | 1221 | |
1222 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1222 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1223 | 1223 | $aprs_last_tx = time(); |
1224 | 1224 | $data_aprs = "# Keep alive"; |
1225 | 1225 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1226 | - } |
|
1226 | + } |
|
1227 | 1227 | |
1228 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1229 | - //echo 'APRS data : '.$buffer."\n"; |
|
1230 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1231 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1232 | - //echo $buffer."\n"; |
|
1233 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1228 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1229 | + //echo 'APRS data : '.$buffer."\n"; |
|
1230 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1231 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1232 | + //echo $buffer."\n"; |
|
1233 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1234 | 1234 | $line = $APRS->parse($buffer); |
1235 | 1235 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1236 | 1236 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1237 | - $aprs_last_tx = time(); |
|
1238 | - $data = array(); |
|
1239 | - //print_r($line); |
|
1240 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1241 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1242 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1243 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1244 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1245 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1246 | - $data['latitude'] = $line['latitude']; |
|
1247 | - $data['longitude'] = $line['longitude']; |
|
1248 | - //$data['verticalrate'] = $line[16]; |
|
1249 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1250 | - else $data['speed'] = 0; |
|
1251 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1252 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1253 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1254 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1255 | - //else $data['heading'] = 0; |
|
1256 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1257 | - if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1258 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1259 | - $data['id_source'] = $id_source; |
|
1260 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1261 | - else $data['format_source'] = 'aprs'; |
|
1262 | - $data['source_name'] = $line['source']; |
|
1263 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1264 | - else $data['source_type'] = 'flarm'; |
|
1265 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1266 | - $currentdate = date('Y-m-d H:i:s'); |
|
1267 | - $aprsdate = strtotime($data['datetime']); |
|
1268 | - // Accept data if time <= system time + 20s |
|
1269 | - //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1270 | - if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1237 | + $aprs_last_tx = time(); |
|
1238 | + $data = array(); |
|
1239 | + //print_r($line); |
|
1240 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1241 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1242 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1243 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1244 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1245 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1246 | + $data['latitude'] = $line['latitude']; |
|
1247 | + $data['longitude'] = $line['longitude']; |
|
1248 | + //$data['verticalrate'] = $line[16]; |
|
1249 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1250 | + else $data['speed'] = 0; |
|
1251 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1252 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1253 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1254 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1255 | + //else $data['heading'] = 0; |
|
1256 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1257 | + if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1258 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1259 | + $data['id_source'] = $id_source; |
|
1260 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1261 | + else $data['format_source'] = 'aprs'; |
|
1262 | + $data['source_name'] = $line['source']; |
|
1263 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1264 | + else $data['source_type'] = 'flarm'; |
|
1265 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1266 | + $currentdate = date('Y-m-d H:i:s'); |
|
1267 | + $aprsdate = strtotime($data['datetime']); |
|
1268 | + // Accept data if time <= system time + 20s |
|
1269 | + //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1270 | + if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1271 | 1271 | $send = $SI->add($data); |
1272 | - } elseif ($data['source_type'] == 'ais') { |
|
1272 | + } elseif ($data['source_type'] == 'ais') { |
|
1273 | 1273 | echo 'add...'."\n"; |
1274 | 1274 | $send = $MI->add($data); |
1275 | - } elseif (isset($line['stealth'])) { |
|
1275 | + } elseif (isset($line['stealth'])) { |
|
1276 | 1276 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1277 | 1277 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1278 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1279 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1278 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) { |
|
1279 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1280 | 1280 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1281 | 1281 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1282 | - } |
|
1283 | - unset($data); |
|
1282 | + } |
|
1283 | + unset($data); |
|
1284 | 1284 | } |
1285 | 1285 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
1286 | 1286 | echo '!! Weather Station not yet supported'."\n"; |
@@ -1290,12 +1290,12 @@ discard block |
||
1290 | 1290 | } |
1291 | 1291 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
1292 | 1292 | //elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
1293 | - } |
|
1293 | + } |
|
1294 | 1294 | } else { |
1295 | - $line = explode(',', $buffer); |
|
1296 | - if (count($line) > 20) { |
|
1297 | - $data['hex'] = $line[4]; |
|
1298 | - /* |
|
1295 | + $line = explode(',', $buffer); |
|
1296 | + if (count($line) > 20) { |
|
1297 | + $data['hex'] = $line[4]; |
|
1298 | + /* |
|
1299 | 1299 | $data['datetime'] = $line[6].' '.$line[7]; |
1300 | 1300 | date_default_timezone_set($globalTimezone); |
1301 | 1301 | $datetime = new DateTime($data['datetime']); |
@@ -1303,30 +1303,30 @@ discard block |
||
1303 | 1303 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1304 | 1304 | date_default_timezone_set('UTC'); |
1305 | 1305 | */ |
1306 | - // Force datetime to current UTC datetime |
|
1307 | - date_default_timezone_set('UTC'); |
|
1308 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1309 | - $data['ident'] = trim($line[10]); |
|
1310 | - $data['latitude'] = $line[14]; |
|
1311 | - $data['longitude'] = $line[15]; |
|
1312 | - $data['verticalrate'] = $line[16]; |
|
1313 | - $data['emergency'] = $line[20]; |
|
1314 | - $data['speed'] = $line[12]; |
|
1315 | - $data['squawk'] = $line[17]; |
|
1316 | - $data['altitude'] = $line[11]; |
|
1317 | - $data['heading'] = $line[13]; |
|
1318 | - $data['ground'] = $line[21]; |
|
1319 | - $data['emergency'] = $line[19]; |
|
1320 | - $data['format_source'] = 'sbs'; |
|
1306 | + // Force datetime to current UTC datetime |
|
1307 | + date_default_timezone_set('UTC'); |
|
1308 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1309 | + $data['ident'] = trim($line[10]); |
|
1310 | + $data['latitude'] = $line[14]; |
|
1311 | + $data['longitude'] = $line[15]; |
|
1312 | + $data['verticalrate'] = $line[16]; |
|
1313 | + $data['emergency'] = $line[20]; |
|
1314 | + $data['speed'] = $line[12]; |
|
1315 | + $data['squawk'] = $line[17]; |
|
1316 | + $data['altitude'] = $line[11]; |
|
1317 | + $data['heading'] = $line[13]; |
|
1318 | + $data['ground'] = $line[21]; |
|
1319 | + $data['emergency'] = $line[19]; |
|
1320 | + $data['format_source'] = 'sbs'; |
|
1321 | 1321 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1322 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1322 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1323 | 1323 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1324 | - $data['id_source'] = $id_source; |
|
1325 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1326 | - else $error = true; |
|
1327 | - unset($data); |
|
1328 | - } else $error = true; |
|
1329 | - if ($error) { |
|
1324 | + $data['id_source'] = $id_source; |
|
1325 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1326 | + else $error = true; |
|
1327 | + unset($data); |
|
1328 | + } else $error = true; |
|
1329 | + if ($error) { |
|
1330 | 1330 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
1331 | 1331 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1332 | 1332 | } else { |
@@ -1342,13 +1342,13 @@ discard block |
||
1342 | 1342 | connect_all($sourceer); |
1343 | 1343 | $sourceer = array(); |
1344 | 1344 | } |
1345 | - } |
|
1345 | + } |
|
1346 | 1346 | } |
1347 | 1347 | // Sleep for xxx microseconds |
1348 | 1348 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1349 | - } else { |
|
1349 | + } else { |
|
1350 | 1350 | if ($format == 'flightgearmp') { |
1351 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1351 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1352 | 1352 | //@socket_close($r); |
1353 | 1353 | sleep($globalMinFetch); |
1354 | 1354 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1357,9 +1357,9 @@ discard block |
||
1357 | 1357 | break; |
1358 | 1358 | |
1359 | 1359 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1360 | - if (isset($tt[$format])) $tt[$format]++; |
|
1361 | - else $tt[$format] = 0; |
|
1362 | - if ($tt[$format] > 30) { |
|
1360 | + if (isset($tt[$format])) $tt[$format]++; |
|
1361 | + else $tt[$format] = 0; |
|
1362 | + if ($tt[$format] > 30) { |
|
1363 | 1363 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1364 | 1364 | //@socket_close($r); |
1365 | 1365 | sleep(2); |
@@ -1370,23 +1370,23 @@ discard block |
||
1370 | 1370 | //connect_all($globalSources); |
1371 | 1371 | $tt[$format]=0; |
1372 | 1372 | break; |
1373 | - } |
|
1373 | + } |
|
1374 | + } |
|
1374 | 1375 | } |
1375 | - } |
|
1376 | 1376 | } |
1377 | - } else { |
|
1377 | + } else { |
|
1378 | 1378 | $error = socket_strerror(socket_last_error()); |
1379 | 1379 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1380 | 1380 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1381 | 1381 | if (isset($globalDebug)) echo "Restarting...\n"; |
1382 | 1382 | // Restart the script if possible |
1383 | 1383 | if (is_array($sockets)) { |
1384 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1384 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1385 | 1385 | |
1386 | - foreach ($sockets as $sock) { |
|
1386 | + foreach ($sockets as $sock) { |
|
1387 | 1387 | @socket_shutdown($sock,2); |
1388 | 1388 | @socket_close($sock); |
1389 | - } |
|
1389 | + } |
|
1390 | 1390 | |
1391 | 1391 | } |
1392 | 1392 | if ($globalDebug) echo "Waiting..."; |
@@ -1401,13 +1401,13 @@ discard block |
||
1401 | 1401 | if ($globalDebug) echo "Restart all connections..."; |
1402 | 1402 | connect_all($globalSources); |
1403 | 1403 | } |
1404 | - } |
|
1404 | + } |
|
1405 | 1405 | } |
1406 | 1406 | if ($globalDaemon === false) { |
1407 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1408 | - $SI->checkAll(); |
|
1407 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1408 | + $SI->checkAll(); |
|
1409 | + } |
|
1409 | 1410 | } |
1410 | - } |
|
1411 | 1411 | } |
1412 | 1412 | |
1413 | 1413 | ?> |