Completed
Branch master (3f174d)
by Yannick
13:43
created
require/class.NOTAM.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -725,6 +725,10 @@
 block discarded – undo
725 725
 		return $all;
726 726
 	}
727 727
 
728
+	/**
729
+	 * @param string $type
730
+	 * @param string $rules
731
+	 */
728 732
 	public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) {
729 733
 		$query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)";
730 734
 		$query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam);
Please login to merge, or discard this patch.
Indentation   +700 added lines, -700 removed lines patch added patch discarded remove patch
@@ -6,706 +6,706 @@
 block discarded – undo
6 6
 class NOTAM {
7 7
 	public $db;
8 8
 	private $abbr = array(
9
-	                    'A/A' => 'Air-to-air',
10
-	                    'A/G' => 'Air-to-ground',
11
-	                    'AAL' => 'Above Aerodrome Level',
12
-	                    'ABM' => 'Abeam',
13
-	                    'ABN' => 'Aerodrome Beacon',
14
-	                    'ABT' => 'About',
15
-	                    'ABV' => 'Above',
16
-	                    'ACC' => 'Area Control',
17
-	                    'ACFT' => 'Aircraft',
18
-	                    'ACK' => 'Acknowledge',
19
-	                    'ACL' => 'Altimeter Check Location',
20
-	                    'ACN' => 'Aircraft Classification Number',
21
-	                    'ACPT' => 'Accepted',
22
-	                    'ACT' => 'Active',
23
-	                    'AD' => 'Aerodrome',
24
-	                    'ADA' => 'Advisory Area',
25
-	                    'ADC' => 'Aerodrome Chart',
26
-	                    'ADDN' => 'Additional',
27
-	                    'ADJ' => 'Adjacent',
28
-	                    'ADR' => 'Advisory Route',
29
-	                    'ADS' => 'Automatic Dependent Surveillance',
30
-	                    'ADVS' => 'Advisory Service',
31
-	                    'ADZ' => 'Advised',
32
-	                    'AFIL' => 'Flight Plan Filed In The Air',
33
-	                    'AFM' => 'Affirm',
34
-	                    'AFT' => 'After',
35
-	                    'AGA' => 'Aerodromes, Air Routes and Ground Aids',
36
-	                    'AGN' => 'Again',
37
-	                    'ALERFA' => 'Alert Phase',
38
-	                    'ALRS' => 'Alerting Service',
39
-	                    'ALS' => 'Approach Lighting System',
40
-	                    'ALT' => 'Altitude',
41
-	                    'ALTN' => 'Alternate',
42
-	                    'AMA' => 'Area Minimum Altitude',
43
-	                    'ANC' => 'Aeronautical Chart',
44
-	                    'ANCS' => 'Aeronautical Navigation Chart',
45
-	                    'ANS' => 'Answer',
46
-	                    'AOC' => 'Aerodrome Obstacle Chart',
47
-	                    'AP' => 'Airport',
48
-	                    'APCH' => 'Approach',
49
-	                    'APDC' => 'Aircraft Parking/docking Chart',
50
-	                    'APN' => 'Apron',
51
-	                    'APNS' => 'Aprons',
52
-	                    'APP' => 'Approach Control',
53
-	                    'APR' => 'April',
54
-	                    'APRX' => 'Approximately',
55
-	                    'APSG' => 'After Passing',
56
-	                    'APV' => 'Approved',
57
-	                    'ARC' => 'Area Chart',
58
-	                    'ARNG' => 'Arrange',
59
-	                    'ARO' => 'Air Traffic Services Reporting Office',
60
-	                    'ARP' => 'Aerodrome Reference Point',
61
-	                    'ARR' => 'Arriving',
62
-	                    'ARST' => 'Arresting',
63
-	                    'ASC' => 'Ascend To',
64
-	                    'ASDA' => 'Accelerate-Stop Distance Available',
65
-	                    'ASPEEDG' => 'Airspeed Gain',
66
-	                    'ASPEEDL' => 'Airspeed Loss',
67
-	                    'ASPH' => 'Asphalt',
68
-	                    'ATA' => 'Actual Time of Arrival',
69
-	                    'ATD' => 'Actual Time of Departure',
70
-	                    'ATFM' => 'Air Traffic Flow Management',
71
-	                    'ATM' => 'Air Traffic Management',
72
-	                    'ATP' => 'At',
73
-	                    'ATTN' => 'Attention',
74
-	                    'ATZ' => 'Aerodrome Traffic Zone',
75
-	                    'AUG' => 'August',
76
-	                    'AUTH' => 'Authorization',
77
-	                    'AUW' => 'All Up Weight',
78
-	                    'AUX' => 'Auxiliary',
79
-	                    'AVBL' => 'Available',
80
-	                    'AVG' => 'Average',
81
-	                    'AVGAS' => 'Aviation Gasoline',
82
-	                    'AWTA' => 'Advise At What Time Able',
83
-	                    'AWY' => 'Airway',
84
-	                    'AWYS' => 'Airways',
85
-	                    'AZM' => 'Azimuth',
86
-	                    'BA' => 'Braking Action',
87
-	                    'BCN' => 'Beacon',
88
-	                    'BCST' => 'Broadcast',
89
-	                    'BDRY' => 'Boundary',
90
-	                    'BFR' => 'Before',
91
-	                    'BLDG' => 'Building',
92
-	                    'BLO' => 'Below Clouds',
93
-	                    'BLW' => 'Below',
94
-	                    'BRF' => 'Short',
95
-	                    'BRG' => 'Bearing',
96
-	                    'BRKG' => 'Breaking',
97
-	                    'BTL' => 'Between Layers',
98
-	                    'BTN' => 'Between',
99
-	                    'CD' => 'Candela',
100
-	                    'CDN' => 'Coordination',
101
-	                    'CF' => 'Change Frequency To',
102
-	                    'CFM' => 'Confirm',
103
-	                    'CGL' => 'Circling Guidance Light(s)',
104
-	                    'CH' => 'Channel',
105
-	                    'CHG' => 'Changed',
106
-	                    'CIT' => 'Near or Over Large Towns',
107
-	                    'CIV' => 'Civil',
108
-	                    'CK' => 'Check',
109
-	                    'CL' => 'Centre Line',
110
-	                    'CLBR' => 'Calibration',
111
-	                    'CLD' => 'Cloud',
112
-	                    'CLG' => 'Calling',
113
-	                    'CLIMB-OUT' => 'Climb-out Area',
114
-	                    'CLR' => 'Clearance',
115
-	                    'CLRD' => 'Cleared',
116
-	                    'CLSD' => 'Closed',
117
-	                    'CMB' => 'Climb',
118
-	                    'CMPL' => 'Complete',
119
-	                    'CNL' => 'Cancel',
120
-	                    'CNS' => 'Communications, Navigation And Surveillance',
121
-	                    'COM' => 'Communications',
122
-	                    'CONC' => 'Concrete',
123
-	                    'COND' => 'Condition',
124
-	                    'CONS' => 'Continuous',
125
-	                    'CONST' => 'Construction',
126
-	                    'CONT' => 'Continued',
127
-	                    'COOR' => 'Coordination',
128
-	                    'COORD' => 'Coordinates',
129
-	                    'COP' => 'Change-over Point',
130
-	                    'COR' => 'Correction',
131
-	                    'COT' => 'At The Coast',
132
-	                    'COV' => 'Covered',
133
-	                    'CPDLC' => 'Controller-pilot Data Link Communications',
134
-	                    'CPL' => 'Current Flight Plan',
135
-	                    'CRC' => 'Cyclic Redundancy Check',
136
-	                    'CRZ' => 'Cruise',
137
-	                    'CTAM' => 'Climb To And Maintain',
138
-	                    'CTC' => 'Contact',
139
-	                    'CTL' => 'Control',
140
-	                    'CTN' => 'Caution',
141
-	                    'CTR' => 'Control Zone',
142
-	                    'CVR' => 'Cockpit Voice Recorder',
143
-	                    'CW' => 'Continuous Wave',
144
-	                    'CWY' => 'Clearway',
145
-	                    'DA' => 'Decision Altitude',
146
-	                    'DCKG' => 'Docking',
147
-	                    'DCP' => 'Datum Crossing Point',
148
-	                    'DCPC' => 'Direct Controller-pilot Communications',
149
-	                    'DCT' => 'Direct',
150
-	                    'DEC' => 'December',
151
-	                    'DEG' => 'Degrees',
152
-	                    'DEP' => 'Departing',
153
-	                    'DES' => 'Descend',
154
-	                    'DEST' => 'Destination',
155
-	                    'DETRESFA' => 'Distress Phase',
156
-	                    'DEV' => 'Deviating',
157
-	                    'DFDR' => 'Digital Flight Data Recorder',
158
-	                    'DFTI' => 'Distance From Touchdown Indicator',
159
-	                    'DH' => 'Decision Height',
160
-	                    'DIP' => 'Diffuse',
161
-	                    'DIST' => 'Distance',
162
-	                    'DIV' => 'Divert',
163
-	                    'DLA' => 'Delay',
164
-	                    'DLY' => 'Daily',
165
-	                    'DNG' => 'Dangerous',
166
-	                    'DOM' => 'Domestic',
167
-	                    'DPT' => 'Depth',
168
-	                    'DR' => 'Dead Reckoning',
169
-	                    'DRG' => 'During',
170
-	                    'DTAM' => 'Descend To And Maintain',
171
-	                    'DTG' => 'Date-time Group',
172
-	                    'DTHR' => 'Displaced Runway Threshold',
173
-	                    'DTRT' => 'Deteriorating',
174
-	                    'DTW' => 'Dual Tandem Wheels',
175
-	                    'DUPE' => 'This Is A Duplicate Message',
176
-	                    'DUR' => 'Duration',
177
-	                    'DVOR' => 'Doppler VOR',
178
-	                    'DW' => 'Dual Wheels',
179
-	                    'EAT' => 'Expected Approach Time',
180
-	                    'EB' => 'Eastbound',
181
-	                    'EDA' => 'Elevation Differential Area',
182
-	                    'EET' => 'Estimated Elapsed Time',
183
-	                    'EFC' => 'Expect Further Clearance',
184
-	                    'ELBA' => 'Emergency Location Beacon',
185
-	                    'ELEV' => 'Elevation',
186
-	                    'ELR' => 'Extra Long Range',
187
-	                    'EM' => 'Emission',
188
-	                    'EMERG' => 'Emergency',
189
-	                    'END' => 'Stop-end',
190
-	                    'ENE' => 'East-north-east',
191
-	                    'ENG' => 'Engine',
192
-	                    'ENR' => 'En-route',
193
-	                    'ENRC' => 'En-route Chart',
194
-	                    'EOBT' => 'Estimated Off-block Time',
195
-	                    'EQPT' => 'Equipment',
196
-	                    'ER' => 'Here',
197
-	                    'ESE' => 'East-south-east',
198
-	                    'EST' => 'Estimate',
199
-	                    'ETA' => 'Estimated Time Of Arrival',
200
-	                    'ETD' => 'Estimated Time Of Departure',
201
-	                    'ETO' => 'Estimated Time Over Significant Point',
202
-	                    'EV' => 'Every',
203
-	                    'EXC' => 'Except',
204
-	                    'EXER' => 'Exercise',
205
-	                    'EXP' => 'Expect',
206
-	                    'EXTD' => 'Extend',
207
-	                    'FAC' => 'Facilities',
208
-	                    'FAF' => 'Final Approach Fix',
209
-	                    'FAL' => 'Facilitation of International Airtransport',
210
-	                    'FAP' => 'Final Approach Point',
211
-	                    'FATO' => 'Final Approach And Take-off Area',
212
-	                    'FAX' => 'Fax',
213
-	                    'FBL' => 'Light',
214
-	                    'FCST' => 'Forecast',
215
-	                    'FCT' => 'Friction Coefficient',
216
-	                    'FDPS' => 'Flight Data Processing System',
217
-	                    'FEB' => 'February',
218
-	                    'FLD' => 'Field',
219
-	                    'FLG' => 'Flashing',
220
-	                    'FLR' => 'Flares',
221
-	                    'FLT' => 'Flight',
222
-	                    'FLTS' => 'Flights',
223
-	                    'FLTCK' => 'Flight Check',
224
-	                    'FLUC' => 'Fluctuating',
225
-	                    'FLW' => 'Follow(s)',
226
-	                    'FLY' => 'Fly',
227
-	                    'FM' => 'From',
228
-	                    'FMS' => 'Flight Management System',
229
-	                    'FMU' => 'Flow Management Unit',
230
-	                    'FNA' => 'Final Approach',
231
-	                    'FPAP' => 'Flight Path Alignment Point',
232
-	                    'FPL' => 'Flight Plan',
233
-	                    'FPLS' => 'Flight Plans',
234
-	                    'FPM' => 'Feet Per Minute',
235
-	                    'FPR' => 'Flight Plan Route',
236
-	                    'FR' => 'Fuel Remaining',
237
-	                    'FREQ' => 'Frequency',
238
-	                    'FRI' => 'Friday',
239
-	                    'FRNG' => 'Firing',
240
-	                    'FRONT' => 'Front',
241
-	                    'FRQ' => 'Frequent',
242
-	                    'FSL' => 'Full Stop Landing',
243
-	                    'FSS' => 'Flight Service Station',
244
-	                    'FST' => 'First',
245
-	                    'FTP' => 'Fictitious Threshold Point',
246
-	                    'G/A' => 'Ground-to-air',
247
-	                    'G/A/G' => 'Ground-to-air and Air-to-ground',
248
-	                    'GARP' => 'GBAS Azimuth Reference Point',
249
-	                    'GBAS' => 'Ground-based Augmentation System',
250
-	                    'GCAJ' => 'Ground Controlled Approach',
251
-	                    'GEN' => 'General',
252
-	                    'GEO' => 'Geographic or True',
253
-	                    'GES' => 'Ground Earth Station',
254
-	                    'GLD' => 'Glider',
255
-	                    'GMC' => 'Ground Movement Chart',
256
-	                    'GND' => 'Ground',
257
-	                    'GNDCK' => 'Ground Check',
258
-	                    'GP' => 'Glide Path',
259
-	                    'GRASS' => 'Grass landing area',
260
-	                    'GRVL' => 'Gravel',
261
-	                    'GUND' => 'Geoid Undulation',
262
-	                    'H24' => '24 Hours',
263
-	                    'HAPI' => 'Helicopter Approach Path Indicator',
264
-	                    'HBN' => 'Hazard Beacon',
265
-	                    'HDG' => 'Heading',
266
-	                    'HEL' => 'Helicopter',
267
-	                    'HGT' => 'Height',
268
-	                    'HJ' => 'Sunrise to Sunset',
269
-	                    'HLDG' => 'Holding',
270
-	                    'HN' => 'Sunset to Sunrise',
271
-	                    'HO' => 'Service Available To Meet Operational Requirements',
272
-	                    'HOL' => 'Holiday',
273
-	                    'HOSP' => 'Hospital Aircraft',
274
-	                    'HOT' => 'Height',
275
-	                    'HPA' => 'Hectopascal',
276
-	                    'HR' => 'Hours',
277
-	                    'HRS' => 'Hours',
278
-	                    'HS' => 'Service Available During Hours Of Scheduled Operations',
279
-	                    'HURCN' => 'Hurricane',
280
-	                    'HVY' => 'Heavy',
281
-	                    'HX' => 'No Specific Working Hours',
282
-	                    'HYR' => 'Higher',
283
-	                    'IAC' => 'Instrument Approach Chart',
284
-	                    'IAF' => 'Initial Approach Fix',
285
-	                    'IAO' => 'In And Out Of Clouds',
286
-	                    'IAP' => 'Instrument Approach Procedure',
287
-	                    'IAR' => 'Intersection Of Air Routes',
288
-	                    'IBN' => 'Identification Beacon',
289
-	                    'ID' => 'Identifier',
290
-	                    'IDENT' => 'Identification',
291
-	                    'IFF' => 'Identification Friend/Foe',
292
-	                    'IGA' => 'International General Aviation',
293
-	                    'IM' => 'Inner Marker',
294
-	                    'IMPR' => 'Improving',
295
-	                    'IMT' => 'Immediately',
296
-	                    'INA' => 'Initial Approach',
297
-	                    'INBD' => 'Inbound',
298
-	                    'INCERFA' => 'Uncertainty Phase',
299
-	                    'INFO' => 'Information',
300
-	                    'INOP' => 'Inoperative',
301
-	                    'INP' => 'If Not Possible',
302
-	                    'INPR' => 'In Progress',
303
-	                    'INSTL' => 'Installation',
304
-	                    'INSTR' => 'Instrument',
305
-	                    'INT' => 'Intersection',
306
-	                    'INTS' => 'Intersections',
307
-	                    'INTL' => 'International',
308
-	                    'INTRG' => 'Interrogator',
309
-	                    'INTRP' => 'Interruption',
310
-	                    'INTSF' => 'Intensifying',
311
-	                    'INTST' => 'Intensity',
312
-	                    'ISA' => 'International Standard Atmosphere',
313
-	                    'JAN' => 'January',
314
-	                    'JTST' => 'Jet stream',
315
-	                    'JUL' => 'July',
316
-	                    'JUN' => 'June',
317
-	                    'KMH' => 'Kilometres Per Hour',
318
-	                    'KPA' => 'Kilopascal',
319
-	                    'KT' => 'Knots',
320
-	                    'KW' => 'Kilowatts',
321
-	                    'LAN' => 'Inland',
322
-	                    'LAT' => 'Latitude',
323
-	                    'LDA' => 'Landing Distance Available',
324
-	                    'LDAH' => 'Landing Distance Available, Helicopter',
325
-	                    'LDG' => 'Landing',
326
-	                    'LDI' => 'Landing Direction Indicator',
327
-	                    'LEN' => 'Length',
328
-	                    'LGT' => 'Lighting',
329
-	                    'LGTD' => 'Lighted',
330
-	                    'LIH' => 'Light Intensity High',
331
-	                    'LIL' => 'Light Intensity Low',
332
-	                    'LIM' => 'Light Intensity Medium',
333
-	                    'LLZ' => 'Localizer',
334
-	                    'LM' => 'Locator, Middle',
335
-	                    'LMT' => 'Local Mean Time',
336
-	                    'LNG' => 'Long',
337
-	                    'LO' => 'Locator, Outer',
338
-	                    'LOG' => 'Located',
339
-	                    'LONG' => 'Longitude',
340
-	                    'LRG' => 'Long Range',
341
-	                    'LTD' => 'Limited',
342
-	                    'LTP' => 'Landing Threshold Point',
343
-	                    'LVE' => 'Leaving',
344
-	                    'LVL' => 'Level',
345
-	                    'LYR' => 'Layer',
346
-	                    'MAA' => 'Maximum Authorized Altitude',
347
-	                    'MAG' => 'Magnetic',
348
-	                    'MAINT' => 'Maintenance',
349
-	                    'MAP' => 'Aeronautical Maps and Charts',
350
-	                    'MAPT' => 'Missed Approach Point',
351
-	                    'MAR' => 'March',
352
-	                    'MAX' => 'Maximum',
353
-	                    'MAY' => 'May',
354
-	                    'MBST' => 'Microburst',
355
-	                    'MCA' => 'Minimum Crossing Altitude',
356
-	                    'MCW' => 'Modulated Continuous Wave',
357
-	                    'MDA' => 'Minimum Descent Altitude',
358
-	                    'MDH' => 'Minimum Descent Height',
359
-	                    'MEA' => 'Minimum En-route Altitude',
360
-	                    'MEHT' => 'Minimum Eye Height Over Threshold',
361
-	                    'MET' => 'Meteorological',
362
-	                    'MID' => 'Mid-point',
363
-	                    'MIL' => 'Military',
364
-	                    'MIN' => 'Minutes',
365
-	                    'MKR' => 'Marker Radio Beacon',
366
-	                    'MLS' => 'Microwave Landing System',
367
-	                    'MM' => 'Middle Marker',
368
-	                    'MNM' => 'Minimum',
369
-	                    'MNPS' => 'Minimum Navigation Performance Specifications',
370
-	                    'MNT' => 'Monitor',
371
-	                    'MNTN' => 'Maintain',
372
-	                    'MOA' => 'Military Operating Area',
373
-	                    'MOC' => 'Minimum Obstacle Clearance',
374
-	                    'MOD' => 'Moderate',
375
-	                    'MON' => 'Monday',
376
-	                    'MOPS' => 'Minimum Operational Performance Standards',
377
-	                    'MOV' => 'Movement',
378
-	                    'MRA' => 'Minimum Reception Altitude',
379
-	                    'MRG' => 'Medium Range',
380
-	                    'MRP' => 'ATS/MET Reporting Point',
381
-	                    'MS' => 'Minus',
382
-	                    'MSA' => 'Minimum Sector Altitude',
383
-	                    'MSAW' => 'Minimum Safe Altitude Warning',
384
-	                    'MSG' => 'Message',
385
-	                    'MSSR' => 'Monopulse Secondary Surveillance Radar',
386
-	                    'MT' => 'Mountain',
387
-	                    'MTU' => 'Metric Units',
388
-	                    'MTW' => 'Mountain Waves',
389
-	                    'NASC' => 'National AIS System Centre',
390
-	                    'NAT' => 'North Atlantic',
391
-	                    'NAV' => 'Navigation',
392
-	                    'NB' => 'Northbound',
393
-	                    'NBFR' => 'Not Before',
394
-	                    'NE' => 'North-east',
395
-	                    'NEB' => 'North-eastbound',
396
-	                    'NEG' => 'Negative',
397
-	                    'NGT' => 'Night',
398
-	                    'NIL' => 'None',
399
-	                    'NML' => 'Normal',
400
-	                    'NNE' => 'North-north-east',
401
-	                    'NNW' => 'North-north-west',
402
-	                    'NOF' => 'International NOTAM Office',
403
-	                    'NOV' => 'November',
404
-	                    'NOZ' => 'Normal Operating Zone',
405
-	                    'NR' => 'Number',
406
-	                    'NRH' => 'No Reply Heard',
407
-	                    'NTL' => 'National',
408
-	                    'NTZ' => 'No Transgression Zone',
409
-	                    'NW' => 'North-west',
410
-	                    'NWB' => 'North-westbound',
411
-	                    'NXT' => 'Next',
412
-	                    'O/R' => 'On Request',
413
-	                    'OAC' => 'Oceanic Area Control Centre',
414
-	                    'OAS' => 'Obstacle Assessment Surface',
415
-	                    'OBS' => 'Observe',
416
-	                    'OBST' => 'Obstacle',
417
-	                    'OBSTS' => 'Obstacles',
418
-	                    'OCA' => 'Oceanic Control Area',
419
-	                    'OCH' => 'Obstacle Clearance Height',
420
-	                    'OCS' => 'Obstacle Clearance Surface',
421
-	                    'OCT' => 'October',
422
-	                    'OFZ' => 'Obstacle Free Zone',
423
-	                    'OGN' => 'Originate',
424
-	                    'OHD' => 'Overhead',
425
-	                    'OM' => 'Outer Marker',
426
-	                    'OPC' => 'Control Indicated Is Operational Control',
427
-	                    'OPMET' => 'Operational Meteorological',
428
-	                    'OPN' => 'Open',
429
-	                    'OPR' => 'Operate',
430
-	                    'OPS' => 'Operations',
431
-	                    'ORD' => 'Order',
432
-	                    'OSV' => 'Ocean Station Vessel',
433
-	                    'OTLK' => 'Outlook',
434
-	                    'OTP' => 'On Top',
435
-	                    'OTS' => 'Organized Track System',
436
-	                    'OUBD' => 'Outbound',
437
-	                    'PA' => 'Precision Approach',
438
-	                    'PALS' => 'Precision Approach Lighting System',
439
-	                    'PANS' => 'Procedures for Air Navigation Services',
440
-	                    'PAR' => 'Precision Approach Radar',
441
-	                    'PARL' => 'Parallel',
442
-	                    'PATC' => 'Precision Approach Terrain Chart',
443
-	                    'PAX' => 'Passenger(s)',
444
-	                    'PCD' => 'Proceed',
445
-	                    'PCL' => 'Pilot-controlled Lighting',
446
-	                    'PCN' => 'Pavement Classification Number',
447
-	                    'PDC' => 'Pre-departure Clearance',
448
-	                    'PDG' => 'Procedure Design Gradient',
449
-	                    'PER' => 'Performance',
450
-	                    'PERM' => 'Permanent',
451
-	                    'PIB' => 'Pre-flight Information Bulletin',
452
-	                    'PJE' => 'Parachute Jumping Exercise',
453
-	                    'PLA' => 'Practice Low Approach',
454
-	                    'PLN' => 'Flight Plan',
455
-	                    'PLVL' => 'Present Level',
456
-	                    'PN' => 'Prior Notice Required',
457
-	                    'PNR' => 'Point Of No Return',
458
-	                    'POB' => 'Persons On Board',
459
-	                    'POSS' => 'Possible',
460
-	                    'PPI' => 'Plan Position Indicator',
461
-	                    'PPR' => 'Prior Permission Required',
462
-	                    'PPSN' => 'Present Position',
463
-	                    'PRI' => 'Primary',
464
-	                    'PRKG' => 'Parking',
465
-	                    'PROB' => 'Probability',
466
-	                    'PROC' => 'Procedure',
467
-	                    'PROV' => 'Provisional',
468
-	                    'PS' => 'Plus',
469
-	                    'PSG' => 'Passing',
470
-	                    'PSN' => 'Position',
471
-	                    'PSNS' => 'Positions',
472
-	                    'PSR' => 'Primary Surveillance Radar',
473
-	                    'PSYS' => 'Pressure System(s)',
474
-	                    'PTN' => 'Procedure Turn',
475
-	                    'PTS' => 'Polar Track Structure',
476
-	                    'PWR' => 'Power',
477
-	                    'QUAD' => 'Quadrant',
478
-	                    'RAC' => 'Rules of The Air and Air Traffic Services',
479
-	                    'RAG' => 'Runway Arresting Gear',
480
-	                    'RAI' => 'Runway Alignment Indicator',
481
-	                    'RASC' => 'Regional AIS System Centre',
482
-	                    'RASS' => 'Remote Altimeter Setting Source',
483
-	                    'RB' => 'Rescue Boat',
484
-	                    'RCA' => 'Reach Cruising Altitude',
485
-	                    'RCC' => 'Rescue Coordination Centre',
486
-	                    'RCF' => 'Radiocommunication Failure',
487
-	                    'RCH' => 'Reaching',
488
-	                    'RCL' => 'Runway Centre Line',
489
-	                    'RCLL' => 'Runway Centre Line Light(s)',
490
-	                    'RCLR' => 'Recleared',
491
-	                    'RDH' => 'Reference Datum Height',
492
-	                    'RDL' => 'Radial',
493
-	                    'RDO' => 'Radio',
494
-	                    'RE' => 'Recent',
495
-	                    'REC' => 'Receiver',
496
-	                    'REDL' => 'Runway Edge Light(s)',
497
-	                    'REF' => 'Refer To',
498
-	                    'REG' => 'Registration',
499
-	                    'RENL' => 'Runway End Light(s)',
500
-	                    'REP' => 'Report',
501
-	                    'REQ' => 'Requested',
502
-	                    'RERTE' => 'Re-route',
503
-	                    'RESA' => 'Runway End Safety Area',
504
-	                    'RG' => 'Range (lights)',
505
-	                    'RHC' => 'Right-hand Circuit',
506
-	                    'RIF' => 'Reclearance In Flight',
507
-	                    'RITE' => 'Right',
508
-	                    'RL' => 'Report Leaving',
509
-	                    'RLA' => 'Relay To',
510
-	                    'RLCE' => 'Request Level Change En Route',
511
-	                    'RLLS' => 'Runway Lead-in Lighting System',
512
-	                    'RLNA' => 'Request Level Not Available',
513
-	                    'RMAC' => 'Radar Minimum Altitude Chart',
514
-	                    'RMK' => 'Remark',
515
-	                    'RNG' => 'Radio Range',
516
-	                    'RNP' => 'Required Navigation Performance',
517
-	                    'ROC' => 'Rate Of Climb',
518
-	                    'ROD' => 'Rate Of Descent',
519
-	                    'ROFOR' => 'Route Forecast',
520
-	                    'RON' => 'Receiving Only',
521
-	                    'RPI' => 'Radar Position Indicator',
522
-	                    'RPL' => 'Repetitive Flight Plan',
523
-	                    'RPLC' => 'Replaced',
524
-	                    'RPS' => 'Radar Position Symbol',
525
-	                    'RQMNTS' => 'Requirements',
526
-	                    'RQP' => 'Request Flight Plan',
527
-	                    'RQS' => 'Request Supplementary Flight Plan',
528
-	                    'RR' => 'Report Reaching',
529
-	                    'RSC' => 'Rescue Sub-centre',
530
-	                    'RSCD' => 'Runway Surface Condition',
531
-	                    'RSP' => 'Responder Beacon',
532
-	                    'RSR' => 'En-route Surveillance Radar',
533
-	                    'RTE' => 'Route',
534
-	                    'RTES' => 'Routes',
535
-	                    'RTF' => 'Radiotelephone',
536
-	                    'RTG' => 'Radiotelegraph',
537
-	                    'RTHL' => 'Runway Threshold Light(s)',
538
-	                    'RTN' => 'Return',
539
-	                    'RTODAH' => 'Rejected Take-off Distance Available, Helicopter',
540
-	                    'RTS' => 'Return To Service',
541
-	                    'RTT' => 'Radioteletypewriter',
542
-	                    'RTZL' => 'Runway Touchdown Zone Light(s)',
543
-	                    'RUT' => 'Standard Regional Route Transmitting Frequencies',
544
-	                    'RV' => 'Rescue Vessel',
545
-	                    'RVSM' => 'Reduced Vertical Separation Minimum',
546
-	                    'RWY' => 'Runway',
547
-	                    'RWYS' => 'Runways',
548
-	                    'SALS' => 'Simple Approach Lighting System',
549
-	                    'SAN' => 'Sanitary',
550
-	                    'SAP' => 'As Soon As Possible',
551
-	                    'SAR' => 'Search and Rescue',
552
-	                    'SARPS' => 'Standards and Recommended Practices',
553
-	                    'SAT' => 'Saturday',
554
-	                    'SATCOM' => 'Satellite Communication',
555
-	                    'SB' => 'Southbound',
556
-	                    'SBAS' => 'Satellite-based Augmentation System',
557
-	                    'SDBY' => 'Stand by',
558
-	                    'SE' => 'South-east',
559
-	                    'SEA' => 'Sea',
560
-	                    'SEB' => 'South-eastbound',
561
-	                    'SEC' => 'Seconds',
562
-	                    'SECN' => 'Section',
563
-	                    'SECT' => 'Sector',
564
-	                    'SEP' => 'September',
565
-	                    'SER' => 'Service',
566
-	                    'SEV' => 'Severe',
567
-	                    'SFC' => 'Surface',
568
-	                    'SGL' => 'Signal',
569
-	                    'SID' => 'Standard Instrument Departure',
570
-	                    'SIF' => 'Selective Identification Feature',
571
-	                    'SIG' => 'Significant',
572
-	                    'SIMUL' => 'Simultaneous',
573
-	                    'SKED' => 'Schedule',
574
-	                    'SLP' => 'Speed Limiting Point',
575
-	                    'SLW' => 'Slow',
576
-	                    'SMC' => 'Surface Movement Control',
577
-	                    'SMR' => 'Surface Movement Radar',
578
-	                    'SPL' => 'Supplementary Flight Plan',
579
-	                    'SPOC' => 'SAR Point Of Contact',
580
-	                    'SPOT' => 'Spot Wind',
581
-	                    'SR' => 'Sunrise',
582
-	                    'SRA' => 'Surveillance Radar Approach',
583
-	                    'SRE' => 'Surveillance Radar Element Of Precision Approach Radar System',
584
-	                    'SRG' => 'Short Range',
585
-	                    'SRR' => 'Search and Rescue Region',
586
-	                    'SRY' => 'Secondary',
587
-	                    'SS' => 'Sunset',
588
-	                    'SSE' => 'South-south-east',
589
-	                    'SSR' => 'Secondary Surveillance Radar',
590
-	                    'SST' => 'Supersonic Transport',
591
-	                    'SSW' => 'South-south-west',
592
-	                    'STA' => 'Straight-in Approach',
593
-	                    'STAR' => 'Standard Instrument Arrival',
594
-	                    'STD' => 'Standard',
595
-	                    'STN' => 'Station',
596
-	                    'STNR' => 'Stationary',
597
-	                    'STOL' => 'Short Take-off and Landing',
598
-	                    'STS' => 'Status',
599
-	                    'STWL' => 'Stopway Light(s)',
600
-	                    'SUBJ' => 'Subject To',
601
-	                    'SUN' => 'Sunday',
602
-	                    'SUP' => 'Supplement',
603
-	                    'SUPPS' => 'Regional Supplementary Procedures Service Message',
604
-	                    'SVCBL' => 'Serviceable',
605
-	                    'SW' => 'South-west',
606
-	                    'SWB' => 'South-westbound',
607
-	                    'SWY' => 'Stopway',
608
-	                    'TA' => 'Transition Altitude',
609
-	                    'TAA' => 'Terminal Arrival Altitude',
610
-	                    'TAF' => 'Aerodrome Forecast',
611
-	                    'TAIL' => 'Tail Wind',
612
-	                    'TAR' => 'Terminal Area Surveillance Radar',
613
-	                    'TAX' => 'Taxi',
614
-	                    'TCAC' => 'Tropical Cyclone Advisory Centre',
615
-	                    'TDO' => 'Tornado',
616
-	                    'TDZ' => 'Touchdown Zone',
617
-	                    'TECR' => 'Technical Reason',
618
-	                    'TEMPO' => 'Temporarily',
619
-	                    'TFC' => 'Traffic',
620
-	                    'TGL' => 'Touch-and-go',
621
-	                    'TGS' => 'Taxiing Guidance System',
622
-	                    'THR' => 'Threshold',
623
-	                    'THRU' => 'Through',
624
-	                    'THU' => 'Thursday',
625
-	                    'TIBA' => 'Traffic Information Broadcast By Aircraft',
626
-	                    'TIL' => 'Until',
627
-	                    'TIP' => 'Until Past',
628
-	                    'TKOF' => 'Take-off',
629
-	                    'TL' => 'Till',
630
-	                    'TLOF' => 'Touchdown And Lift-off Area',
631
-	                    'TMA' => 'Terminal Control Area',
632
-	                    'TNA' => 'Turn Altitude',
633
-	                    'TNH' => 'Turn Height',
634
-	                    'TOC' => 'Top of Climb',
635
-	                    'TODA' => 'Take-off Distance Available',
636
-	                    'TODAH' => 'Take-off Distance Available, Helicopter',
637
-	                    'TORA' => 'Take-off Run Available',
638
-	                    'TP' => 'Turning Point',
639
-	                    'TR' => 'Track',
640
-	                    'TRA' => 'Temporary Reserved Airspace',
641
-	                    'TRANS' => 'Transmitter',
642
-	                    'TRL' => 'Transition Level',
643
-	                    'TUE' => 'Tuesday',
644
-	                    'TURB' => 'Turbulence',
645
-	                    'TVOR' => 'Terminal VOR',
646
-	                    'TWR' => 'Tower',
647
-	                    'TWY' => 'Taxiway',
648
-	                    'TWYL' => 'Taxiway-link',
649
-	                    'TXT' => 'Text',
650
-	                    'TYP' => 'Type of Aircraft',
651
-	                    'U/S' => 'Unserviceable',
652
-	                    'UAB' => 'Until Advised By',
653
-	                    'UAC' => 'Upper Area Control Centre',
654
-	                    'UAR' => 'Upper Air Route',
655
-	                    'UFN' => 'Until Further Notice',
656
-	                    'UHDT' => 'Unable Higher Due Traffic',
657
-	                    'UIC' => 'Upper Information Centre',
658
-	                    'UIR' => 'Upper Flight Information Region',
659
-	                    'ULR' => 'Ultra Long Range',
660
-	                    'UNA' => 'Unable',
661
-	                    'UNAP' => 'Unable To Approve',
662
-	                    'UNL' => 'Unlimited',
663
-	                    'UNREL' => 'Unreliable',
664
-	                    'UTA' => 'Upper Control Area',
665
-	                    'VAAC' => 'Volcanic Ash Advisory Centre',
666
-	                    'VAC' => 'Visual Approach Chart',
667
-	                    'VAL' => 'In Valleys',
668
-	                    'VAN' => 'Runway Control Van',
669
-	                    'VAR' => 'Visual-aural Radio Range',
670
-	                    'VC' => 'Vicinity',
671
-	                    'VCY' => 'Vicinity',
672
-	                    'VER' => 'Vertical',
673
-	                    'VIS' => 'Visibility',
674
-	                    'VLR' => 'Very Long Range',
675
-	                    'VPA' => 'Vertical Path Angle',
676
-	                    'VRB' => 'Variable',
677
-	                    'VSA' => 'By Visual Reference To The Ground',
678
-	                    'VSP' => 'Vertical Speed',
679
-	                    'VTOL' => 'Vertical Take-off And Landing',
680
-	                    'WAC' => 'World Aeronautical Chart',
681
-	                    'WAFC' => 'World Area Forecast Centre',
682
-	                    'WB' => 'Westbound',
683
-	                    'WBAR' => 'Wing Bar Lights',
684
-	                    'WDI' => 'Wind Direction Indicator',
685
-	                    'WDSPR' => 'Widespread',
686
-	                    'WED' => 'Wednesday',
687
-	                    'WEF' => 'Effective From',
688
-	                    'WI' => 'Within',
689
-	                    'WID' => 'Width',
690
-	                    'WIE' => 'Effective Immediately',
691
-	                    'WILCO' => 'Will Comply',
692
-	                    'WIND' => 'Wind',
693
-	                    'WINTEM' => 'Forecast Upper Wind And Temperature For Aviation',
694
-	                    'WIP' => 'Work In Progress',
695
-	                    'WKN' => 'Weaken',
696
-	                    'WNW' => 'West-north-west',
697
-	                    'WO' => 'Without',
698
-	                    'WPT' => 'Way-point',
699
-	                    'WRNG' => 'Warning',
700
-	                    'WSW' => 'West-south-west',
701
-	                    'WT' => 'Weight',
702
-	                    'WWW' => 'Worldwide Web',
703
-	                    'WX' => 'Weather',
704
-	                    'XBAR' => 'Crossbar',
705
-	                    'XNG' => 'Crossing',
706
-	                    'XS' => 'Atmospherics',
707
-	                    'YCZ' => 'Yellow Caution Zone',
708
-	                    'YR' => 'Your');
9
+						'A/A' => 'Air-to-air',
10
+						'A/G' => 'Air-to-ground',
11
+						'AAL' => 'Above Aerodrome Level',
12
+						'ABM' => 'Abeam',
13
+						'ABN' => 'Aerodrome Beacon',
14
+						'ABT' => 'About',
15
+						'ABV' => 'Above',
16
+						'ACC' => 'Area Control',
17
+						'ACFT' => 'Aircraft',
18
+						'ACK' => 'Acknowledge',
19
+						'ACL' => 'Altimeter Check Location',
20
+						'ACN' => 'Aircraft Classification Number',
21
+						'ACPT' => 'Accepted',
22
+						'ACT' => 'Active',
23
+						'AD' => 'Aerodrome',
24
+						'ADA' => 'Advisory Area',
25
+						'ADC' => 'Aerodrome Chart',
26
+						'ADDN' => 'Additional',
27
+						'ADJ' => 'Adjacent',
28
+						'ADR' => 'Advisory Route',
29
+						'ADS' => 'Automatic Dependent Surveillance',
30
+						'ADVS' => 'Advisory Service',
31
+						'ADZ' => 'Advised',
32
+						'AFIL' => 'Flight Plan Filed In The Air',
33
+						'AFM' => 'Affirm',
34
+						'AFT' => 'After',
35
+						'AGA' => 'Aerodromes, Air Routes and Ground Aids',
36
+						'AGN' => 'Again',
37
+						'ALERFA' => 'Alert Phase',
38
+						'ALRS' => 'Alerting Service',
39
+						'ALS' => 'Approach Lighting System',
40
+						'ALT' => 'Altitude',
41
+						'ALTN' => 'Alternate',
42
+						'AMA' => 'Area Minimum Altitude',
43
+						'ANC' => 'Aeronautical Chart',
44
+						'ANCS' => 'Aeronautical Navigation Chart',
45
+						'ANS' => 'Answer',
46
+						'AOC' => 'Aerodrome Obstacle Chart',
47
+						'AP' => 'Airport',
48
+						'APCH' => 'Approach',
49
+						'APDC' => 'Aircraft Parking/docking Chart',
50
+						'APN' => 'Apron',
51
+						'APNS' => 'Aprons',
52
+						'APP' => 'Approach Control',
53
+						'APR' => 'April',
54
+						'APRX' => 'Approximately',
55
+						'APSG' => 'After Passing',
56
+						'APV' => 'Approved',
57
+						'ARC' => 'Area Chart',
58
+						'ARNG' => 'Arrange',
59
+						'ARO' => 'Air Traffic Services Reporting Office',
60
+						'ARP' => 'Aerodrome Reference Point',
61
+						'ARR' => 'Arriving',
62
+						'ARST' => 'Arresting',
63
+						'ASC' => 'Ascend To',
64
+						'ASDA' => 'Accelerate-Stop Distance Available',
65
+						'ASPEEDG' => 'Airspeed Gain',
66
+						'ASPEEDL' => 'Airspeed Loss',
67
+						'ASPH' => 'Asphalt',
68
+						'ATA' => 'Actual Time of Arrival',
69
+						'ATD' => 'Actual Time of Departure',
70
+						'ATFM' => 'Air Traffic Flow Management',
71
+						'ATM' => 'Air Traffic Management',
72
+						'ATP' => 'At',
73
+						'ATTN' => 'Attention',
74
+						'ATZ' => 'Aerodrome Traffic Zone',
75
+						'AUG' => 'August',
76
+						'AUTH' => 'Authorization',
77
+						'AUW' => 'All Up Weight',
78
+						'AUX' => 'Auxiliary',
79
+						'AVBL' => 'Available',
80
+						'AVG' => 'Average',
81
+						'AVGAS' => 'Aviation Gasoline',
82
+						'AWTA' => 'Advise At What Time Able',
83
+						'AWY' => 'Airway',
84
+						'AWYS' => 'Airways',
85
+						'AZM' => 'Azimuth',
86
+						'BA' => 'Braking Action',
87
+						'BCN' => 'Beacon',
88
+						'BCST' => 'Broadcast',
89
+						'BDRY' => 'Boundary',
90
+						'BFR' => 'Before',
91
+						'BLDG' => 'Building',
92
+						'BLO' => 'Below Clouds',
93
+						'BLW' => 'Below',
94
+						'BRF' => 'Short',
95
+						'BRG' => 'Bearing',
96
+						'BRKG' => 'Breaking',
97
+						'BTL' => 'Between Layers',
98
+						'BTN' => 'Between',
99
+						'CD' => 'Candela',
100
+						'CDN' => 'Coordination',
101
+						'CF' => 'Change Frequency To',
102
+						'CFM' => 'Confirm',
103
+						'CGL' => 'Circling Guidance Light(s)',
104
+						'CH' => 'Channel',
105
+						'CHG' => 'Changed',
106
+						'CIT' => 'Near or Over Large Towns',
107
+						'CIV' => 'Civil',
108
+						'CK' => 'Check',
109
+						'CL' => 'Centre Line',
110
+						'CLBR' => 'Calibration',
111
+						'CLD' => 'Cloud',
112
+						'CLG' => 'Calling',
113
+						'CLIMB-OUT' => 'Climb-out Area',
114
+						'CLR' => 'Clearance',
115
+						'CLRD' => 'Cleared',
116
+						'CLSD' => 'Closed',
117
+						'CMB' => 'Climb',
118
+						'CMPL' => 'Complete',
119
+						'CNL' => 'Cancel',
120
+						'CNS' => 'Communications, Navigation And Surveillance',
121
+						'COM' => 'Communications',
122
+						'CONC' => 'Concrete',
123
+						'COND' => 'Condition',
124
+						'CONS' => 'Continuous',
125
+						'CONST' => 'Construction',
126
+						'CONT' => 'Continued',
127
+						'COOR' => 'Coordination',
128
+						'COORD' => 'Coordinates',
129
+						'COP' => 'Change-over Point',
130
+						'COR' => 'Correction',
131
+						'COT' => 'At The Coast',
132
+						'COV' => 'Covered',
133
+						'CPDLC' => 'Controller-pilot Data Link Communications',
134
+						'CPL' => 'Current Flight Plan',
135
+						'CRC' => 'Cyclic Redundancy Check',
136
+						'CRZ' => 'Cruise',
137
+						'CTAM' => 'Climb To And Maintain',
138
+						'CTC' => 'Contact',
139
+						'CTL' => 'Control',
140
+						'CTN' => 'Caution',
141
+						'CTR' => 'Control Zone',
142
+						'CVR' => 'Cockpit Voice Recorder',
143
+						'CW' => 'Continuous Wave',
144
+						'CWY' => 'Clearway',
145
+						'DA' => 'Decision Altitude',
146
+						'DCKG' => 'Docking',
147
+						'DCP' => 'Datum Crossing Point',
148
+						'DCPC' => 'Direct Controller-pilot Communications',
149
+						'DCT' => 'Direct',
150
+						'DEC' => 'December',
151
+						'DEG' => 'Degrees',
152
+						'DEP' => 'Departing',
153
+						'DES' => 'Descend',
154
+						'DEST' => 'Destination',
155
+						'DETRESFA' => 'Distress Phase',
156
+						'DEV' => 'Deviating',
157
+						'DFDR' => 'Digital Flight Data Recorder',
158
+						'DFTI' => 'Distance From Touchdown Indicator',
159
+						'DH' => 'Decision Height',
160
+						'DIP' => 'Diffuse',
161
+						'DIST' => 'Distance',
162
+						'DIV' => 'Divert',
163
+						'DLA' => 'Delay',
164
+						'DLY' => 'Daily',
165
+						'DNG' => 'Dangerous',
166
+						'DOM' => 'Domestic',
167
+						'DPT' => 'Depth',
168
+						'DR' => 'Dead Reckoning',
169
+						'DRG' => 'During',
170
+						'DTAM' => 'Descend To And Maintain',
171
+						'DTG' => 'Date-time Group',
172
+						'DTHR' => 'Displaced Runway Threshold',
173
+						'DTRT' => 'Deteriorating',
174
+						'DTW' => 'Dual Tandem Wheels',
175
+						'DUPE' => 'This Is A Duplicate Message',
176
+						'DUR' => 'Duration',
177
+						'DVOR' => 'Doppler VOR',
178
+						'DW' => 'Dual Wheels',
179
+						'EAT' => 'Expected Approach Time',
180
+						'EB' => 'Eastbound',
181
+						'EDA' => 'Elevation Differential Area',
182
+						'EET' => 'Estimated Elapsed Time',
183
+						'EFC' => 'Expect Further Clearance',
184
+						'ELBA' => 'Emergency Location Beacon',
185
+						'ELEV' => 'Elevation',
186
+						'ELR' => 'Extra Long Range',
187
+						'EM' => 'Emission',
188
+						'EMERG' => 'Emergency',
189
+						'END' => 'Stop-end',
190
+						'ENE' => 'East-north-east',
191
+						'ENG' => 'Engine',
192
+						'ENR' => 'En-route',
193
+						'ENRC' => 'En-route Chart',
194
+						'EOBT' => 'Estimated Off-block Time',
195
+						'EQPT' => 'Equipment',
196
+						'ER' => 'Here',
197
+						'ESE' => 'East-south-east',
198
+						'EST' => 'Estimate',
199
+						'ETA' => 'Estimated Time Of Arrival',
200
+						'ETD' => 'Estimated Time Of Departure',
201
+						'ETO' => 'Estimated Time Over Significant Point',
202
+						'EV' => 'Every',
203
+						'EXC' => 'Except',
204
+						'EXER' => 'Exercise',
205
+						'EXP' => 'Expect',
206
+						'EXTD' => 'Extend',
207
+						'FAC' => 'Facilities',
208
+						'FAF' => 'Final Approach Fix',
209
+						'FAL' => 'Facilitation of International Airtransport',
210
+						'FAP' => 'Final Approach Point',
211
+						'FATO' => 'Final Approach And Take-off Area',
212
+						'FAX' => 'Fax',
213
+						'FBL' => 'Light',
214
+						'FCST' => 'Forecast',
215
+						'FCT' => 'Friction Coefficient',
216
+						'FDPS' => 'Flight Data Processing System',
217
+						'FEB' => 'February',
218
+						'FLD' => 'Field',
219
+						'FLG' => 'Flashing',
220
+						'FLR' => 'Flares',
221
+						'FLT' => 'Flight',
222
+						'FLTS' => 'Flights',
223
+						'FLTCK' => 'Flight Check',
224
+						'FLUC' => 'Fluctuating',
225
+						'FLW' => 'Follow(s)',
226
+						'FLY' => 'Fly',
227
+						'FM' => 'From',
228
+						'FMS' => 'Flight Management System',
229
+						'FMU' => 'Flow Management Unit',
230
+						'FNA' => 'Final Approach',
231
+						'FPAP' => 'Flight Path Alignment Point',
232
+						'FPL' => 'Flight Plan',
233
+						'FPLS' => 'Flight Plans',
234
+						'FPM' => 'Feet Per Minute',
235
+						'FPR' => 'Flight Plan Route',
236
+						'FR' => 'Fuel Remaining',
237
+						'FREQ' => 'Frequency',
238
+						'FRI' => 'Friday',
239
+						'FRNG' => 'Firing',
240
+						'FRONT' => 'Front',
241
+						'FRQ' => 'Frequent',
242
+						'FSL' => 'Full Stop Landing',
243
+						'FSS' => 'Flight Service Station',
244
+						'FST' => 'First',
245
+						'FTP' => 'Fictitious Threshold Point',
246
+						'G/A' => 'Ground-to-air',
247
+						'G/A/G' => 'Ground-to-air and Air-to-ground',
248
+						'GARP' => 'GBAS Azimuth Reference Point',
249
+						'GBAS' => 'Ground-based Augmentation System',
250
+						'GCAJ' => 'Ground Controlled Approach',
251
+						'GEN' => 'General',
252
+						'GEO' => 'Geographic or True',
253
+						'GES' => 'Ground Earth Station',
254
+						'GLD' => 'Glider',
255
+						'GMC' => 'Ground Movement Chart',
256
+						'GND' => 'Ground',
257
+						'GNDCK' => 'Ground Check',
258
+						'GP' => 'Glide Path',
259
+						'GRASS' => 'Grass landing area',
260
+						'GRVL' => 'Gravel',
261
+						'GUND' => 'Geoid Undulation',
262
+						'H24' => '24 Hours',
263
+						'HAPI' => 'Helicopter Approach Path Indicator',
264
+						'HBN' => 'Hazard Beacon',
265
+						'HDG' => 'Heading',
266
+						'HEL' => 'Helicopter',
267
+						'HGT' => 'Height',
268
+						'HJ' => 'Sunrise to Sunset',
269
+						'HLDG' => 'Holding',
270
+						'HN' => 'Sunset to Sunrise',
271
+						'HO' => 'Service Available To Meet Operational Requirements',
272
+						'HOL' => 'Holiday',
273
+						'HOSP' => 'Hospital Aircraft',
274
+						'HOT' => 'Height',
275
+						'HPA' => 'Hectopascal',
276
+						'HR' => 'Hours',
277
+						'HRS' => 'Hours',
278
+						'HS' => 'Service Available During Hours Of Scheduled Operations',
279
+						'HURCN' => 'Hurricane',
280
+						'HVY' => 'Heavy',
281
+						'HX' => 'No Specific Working Hours',
282
+						'HYR' => 'Higher',
283
+						'IAC' => 'Instrument Approach Chart',
284
+						'IAF' => 'Initial Approach Fix',
285
+						'IAO' => 'In And Out Of Clouds',
286
+						'IAP' => 'Instrument Approach Procedure',
287
+						'IAR' => 'Intersection Of Air Routes',
288
+						'IBN' => 'Identification Beacon',
289
+						'ID' => 'Identifier',
290
+						'IDENT' => 'Identification',
291
+						'IFF' => 'Identification Friend/Foe',
292
+						'IGA' => 'International General Aviation',
293
+						'IM' => 'Inner Marker',
294
+						'IMPR' => 'Improving',
295
+						'IMT' => 'Immediately',
296
+						'INA' => 'Initial Approach',
297
+						'INBD' => 'Inbound',
298
+						'INCERFA' => 'Uncertainty Phase',
299
+						'INFO' => 'Information',
300
+						'INOP' => 'Inoperative',
301
+						'INP' => 'If Not Possible',
302
+						'INPR' => 'In Progress',
303
+						'INSTL' => 'Installation',
304
+						'INSTR' => 'Instrument',
305
+						'INT' => 'Intersection',
306
+						'INTS' => 'Intersections',
307
+						'INTL' => 'International',
308
+						'INTRG' => 'Interrogator',
309
+						'INTRP' => 'Interruption',
310
+						'INTSF' => 'Intensifying',
311
+						'INTST' => 'Intensity',
312
+						'ISA' => 'International Standard Atmosphere',
313
+						'JAN' => 'January',
314
+						'JTST' => 'Jet stream',
315
+						'JUL' => 'July',
316
+						'JUN' => 'June',
317
+						'KMH' => 'Kilometres Per Hour',
318
+						'KPA' => 'Kilopascal',
319
+						'KT' => 'Knots',
320
+						'KW' => 'Kilowatts',
321
+						'LAN' => 'Inland',
322
+						'LAT' => 'Latitude',
323
+						'LDA' => 'Landing Distance Available',
324
+						'LDAH' => 'Landing Distance Available, Helicopter',
325
+						'LDG' => 'Landing',
326
+						'LDI' => 'Landing Direction Indicator',
327
+						'LEN' => 'Length',
328
+						'LGT' => 'Lighting',
329
+						'LGTD' => 'Lighted',
330
+						'LIH' => 'Light Intensity High',
331
+						'LIL' => 'Light Intensity Low',
332
+						'LIM' => 'Light Intensity Medium',
333
+						'LLZ' => 'Localizer',
334
+						'LM' => 'Locator, Middle',
335
+						'LMT' => 'Local Mean Time',
336
+						'LNG' => 'Long',
337
+						'LO' => 'Locator, Outer',
338
+						'LOG' => 'Located',
339
+						'LONG' => 'Longitude',
340
+						'LRG' => 'Long Range',
341
+						'LTD' => 'Limited',
342
+						'LTP' => 'Landing Threshold Point',
343
+						'LVE' => 'Leaving',
344
+						'LVL' => 'Level',
345
+						'LYR' => 'Layer',
346
+						'MAA' => 'Maximum Authorized Altitude',
347
+						'MAG' => 'Magnetic',
348
+						'MAINT' => 'Maintenance',
349
+						'MAP' => 'Aeronautical Maps and Charts',
350
+						'MAPT' => 'Missed Approach Point',
351
+						'MAR' => 'March',
352
+						'MAX' => 'Maximum',
353
+						'MAY' => 'May',
354
+						'MBST' => 'Microburst',
355
+						'MCA' => 'Minimum Crossing Altitude',
356
+						'MCW' => 'Modulated Continuous Wave',
357
+						'MDA' => 'Minimum Descent Altitude',
358
+						'MDH' => 'Minimum Descent Height',
359
+						'MEA' => 'Minimum En-route Altitude',
360
+						'MEHT' => 'Minimum Eye Height Over Threshold',
361
+						'MET' => 'Meteorological',
362
+						'MID' => 'Mid-point',
363
+						'MIL' => 'Military',
364
+						'MIN' => 'Minutes',
365
+						'MKR' => 'Marker Radio Beacon',
366
+						'MLS' => 'Microwave Landing System',
367
+						'MM' => 'Middle Marker',
368
+						'MNM' => 'Minimum',
369
+						'MNPS' => 'Minimum Navigation Performance Specifications',
370
+						'MNT' => 'Monitor',
371
+						'MNTN' => 'Maintain',
372
+						'MOA' => 'Military Operating Area',
373
+						'MOC' => 'Minimum Obstacle Clearance',
374
+						'MOD' => 'Moderate',
375
+						'MON' => 'Monday',
376
+						'MOPS' => 'Minimum Operational Performance Standards',
377
+						'MOV' => 'Movement',
378
+						'MRA' => 'Minimum Reception Altitude',
379
+						'MRG' => 'Medium Range',
380
+						'MRP' => 'ATS/MET Reporting Point',
381
+						'MS' => 'Minus',
382
+						'MSA' => 'Minimum Sector Altitude',
383
+						'MSAW' => 'Minimum Safe Altitude Warning',
384
+						'MSG' => 'Message',
385
+						'MSSR' => 'Monopulse Secondary Surveillance Radar',
386
+						'MT' => 'Mountain',
387
+						'MTU' => 'Metric Units',
388
+						'MTW' => 'Mountain Waves',
389
+						'NASC' => 'National AIS System Centre',
390
+						'NAT' => 'North Atlantic',
391
+						'NAV' => 'Navigation',
392
+						'NB' => 'Northbound',
393
+						'NBFR' => 'Not Before',
394
+						'NE' => 'North-east',
395
+						'NEB' => 'North-eastbound',
396
+						'NEG' => 'Negative',
397
+						'NGT' => 'Night',
398
+						'NIL' => 'None',
399
+						'NML' => 'Normal',
400
+						'NNE' => 'North-north-east',
401
+						'NNW' => 'North-north-west',
402
+						'NOF' => 'International NOTAM Office',
403
+						'NOV' => 'November',
404
+						'NOZ' => 'Normal Operating Zone',
405
+						'NR' => 'Number',
406
+						'NRH' => 'No Reply Heard',
407
+						'NTL' => 'National',
408
+						'NTZ' => 'No Transgression Zone',
409
+						'NW' => 'North-west',
410
+						'NWB' => 'North-westbound',
411
+						'NXT' => 'Next',
412
+						'O/R' => 'On Request',
413
+						'OAC' => 'Oceanic Area Control Centre',
414
+						'OAS' => 'Obstacle Assessment Surface',
415
+						'OBS' => 'Observe',
416
+						'OBST' => 'Obstacle',
417
+						'OBSTS' => 'Obstacles',
418
+						'OCA' => 'Oceanic Control Area',
419
+						'OCH' => 'Obstacle Clearance Height',
420
+						'OCS' => 'Obstacle Clearance Surface',
421
+						'OCT' => 'October',
422
+						'OFZ' => 'Obstacle Free Zone',
423
+						'OGN' => 'Originate',
424
+						'OHD' => 'Overhead',
425
+						'OM' => 'Outer Marker',
426
+						'OPC' => 'Control Indicated Is Operational Control',
427
+						'OPMET' => 'Operational Meteorological',
428
+						'OPN' => 'Open',
429
+						'OPR' => 'Operate',
430
+						'OPS' => 'Operations',
431
+						'ORD' => 'Order',
432
+						'OSV' => 'Ocean Station Vessel',
433
+						'OTLK' => 'Outlook',
434
+						'OTP' => 'On Top',
435
+						'OTS' => 'Organized Track System',
436
+						'OUBD' => 'Outbound',
437
+						'PA' => 'Precision Approach',
438
+						'PALS' => 'Precision Approach Lighting System',
439
+						'PANS' => 'Procedures for Air Navigation Services',
440
+						'PAR' => 'Precision Approach Radar',
441
+						'PARL' => 'Parallel',
442
+						'PATC' => 'Precision Approach Terrain Chart',
443
+						'PAX' => 'Passenger(s)',
444
+						'PCD' => 'Proceed',
445
+						'PCL' => 'Pilot-controlled Lighting',
446
+						'PCN' => 'Pavement Classification Number',
447
+						'PDC' => 'Pre-departure Clearance',
448
+						'PDG' => 'Procedure Design Gradient',
449
+						'PER' => 'Performance',
450
+						'PERM' => 'Permanent',
451
+						'PIB' => 'Pre-flight Information Bulletin',
452
+						'PJE' => 'Parachute Jumping Exercise',
453
+						'PLA' => 'Practice Low Approach',
454
+						'PLN' => 'Flight Plan',
455
+						'PLVL' => 'Present Level',
456
+						'PN' => 'Prior Notice Required',
457
+						'PNR' => 'Point Of No Return',
458
+						'POB' => 'Persons On Board',
459
+						'POSS' => 'Possible',
460
+						'PPI' => 'Plan Position Indicator',
461
+						'PPR' => 'Prior Permission Required',
462
+						'PPSN' => 'Present Position',
463
+						'PRI' => 'Primary',
464
+						'PRKG' => 'Parking',
465
+						'PROB' => 'Probability',
466
+						'PROC' => 'Procedure',
467
+						'PROV' => 'Provisional',
468
+						'PS' => 'Plus',
469
+						'PSG' => 'Passing',
470
+						'PSN' => 'Position',
471
+						'PSNS' => 'Positions',
472
+						'PSR' => 'Primary Surveillance Radar',
473
+						'PSYS' => 'Pressure System(s)',
474
+						'PTN' => 'Procedure Turn',
475
+						'PTS' => 'Polar Track Structure',
476
+						'PWR' => 'Power',
477
+						'QUAD' => 'Quadrant',
478
+						'RAC' => 'Rules of The Air and Air Traffic Services',
479
+						'RAG' => 'Runway Arresting Gear',
480
+						'RAI' => 'Runway Alignment Indicator',
481
+						'RASC' => 'Regional AIS System Centre',
482
+						'RASS' => 'Remote Altimeter Setting Source',
483
+						'RB' => 'Rescue Boat',
484
+						'RCA' => 'Reach Cruising Altitude',
485
+						'RCC' => 'Rescue Coordination Centre',
486
+						'RCF' => 'Radiocommunication Failure',
487
+						'RCH' => 'Reaching',
488
+						'RCL' => 'Runway Centre Line',
489
+						'RCLL' => 'Runway Centre Line Light(s)',
490
+						'RCLR' => 'Recleared',
491
+						'RDH' => 'Reference Datum Height',
492
+						'RDL' => 'Radial',
493
+						'RDO' => 'Radio',
494
+						'RE' => 'Recent',
495
+						'REC' => 'Receiver',
496
+						'REDL' => 'Runway Edge Light(s)',
497
+						'REF' => 'Refer To',
498
+						'REG' => 'Registration',
499
+						'RENL' => 'Runway End Light(s)',
500
+						'REP' => 'Report',
501
+						'REQ' => 'Requested',
502
+						'RERTE' => 'Re-route',
503
+						'RESA' => 'Runway End Safety Area',
504
+						'RG' => 'Range (lights)',
505
+						'RHC' => 'Right-hand Circuit',
506
+						'RIF' => 'Reclearance In Flight',
507
+						'RITE' => 'Right',
508
+						'RL' => 'Report Leaving',
509
+						'RLA' => 'Relay To',
510
+						'RLCE' => 'Request Level Change En Route',
511
+						'RLLS' => 'Runway Lead-in Lighting System',
512
+						'RLNA' => 'Request Level Not Available',
513
+						'RMAC' => 'Radar Minimum Altitude Chart',
514
+						'RMK' => 'Remark',
515
+						'RNG' => 'Radio Range',
516
+						'RNP' => 'Required Navigation Performance',
517
+						'ROC' => 'Rate Of Climb',
518
+						'ROD' => 'Rate Of Descent',
519
+						'ROFOR' => 'Route Forecast',
520
+						'RON' => 'Receiving Only',
521
+						'RPI' => 'Radar Position Indicator',
522
+						'RPL' => 'Repetitive Flight Plan',
523
+						'RPLC' => 'Replaced',
524
+						'RPS' => 'Radar Position Symbol',
525
+						'RQMNTS' => 'Requirements',
526
+						'RQP' => 'Request Flight Plan',
527
+						'RQS' => 'Request Supplementary Flight Plan',
528
+						'RR' => 'Report Reaching',
529
+						'RSC' => 'Rescue Sub-centre',
530
+						'RSCD' => 'Runway Surface Condition',
531
+						'RSP' => 'Responder Beacon',
532
+						'RSR' => 'En-route Surveillance Radar',
533
+						'RTE' => 'Route',
534
+						'RTES' => 'Routes',
535
+						'RTF' => 'Radiotelephone',
536
+						'RTG' => 'Radiotelegraph',
537
+						'RTHL' => 'Runway Threshold Light(s)',
538
+						'RTN' => 'Return',
539
+						'RTODAH' => 'Rejected Take-off Distance Available, Helicopter',
540
+						'RTS' => 'Return To Service',
541
+						'RTT' => 'Radioteletypewriter',
542
+						'RTZL' => 'Runway Touchdown Zone Light(s)',
543
+						'RUT' => 'Standard Regional Route Transmitting Frequencies',
544
+						'RV' => 'Rescue Vessel',
545
+						'RVSM' => 'Reduced Vertical Separation Minimum',
546
+						'RWY' => 'Runway',
547
+						'RWYS' => 'Runways',
548
+						'SALS' => 'Simple Approach Lighting System',
549
+						'SAN' => 'Sanitary',
550
+						'SAP' => 'As Soon As Possible',
551
+						'SAR' => 'Search and Rescue',
552
+						'SARPS' => 'Standards and Recommended Practices',
553
+						'SAT' => 'Saturday',
554
+						'SATCOM' => 'Satellite Communication',
555
+						'SB' => 'Southbound',
556
+						'SBAS' => 'Satellite-based Augmentation System',
557
+						'SDBY' => 'Stand by',
558
+						'SE' => 'South-east',
559
+						'SEA' => 'Sea',
560
+						'SEB' => 'South-eastbound',
561
+						'SEC' => 'Seconds',
562
+						'SECN' => 'Section',
563
+						'SECT' => 'Sector',
564
+						'SEP' => 'September',
565
+						'SER' => 'Service',
566
+						'SEV' => 'Severe',
567
+						'SFC' => 'Surface',
568
+						'SGL' => 'Signal',
569
+						'SID' => 'Standard Instrument Departure',
570
+						'SIF' => 'Selective Identification Feature',
571
+						'SIG' => 'Significant',
572
+						'SIMUL' => 'Simultaneous',
573
+						'SKED' => 'Schedule',
574
+						'SLP' => 'Speed Limiting Point',
575
+						'SLW' => 'Slow',
576
+						'SMC' => 'Surface Movement Control',
577
+						'SMR' => 'Surface Movement Radar',
578
+						'SPL' => 'Supplementary Flight Plan',
579
+						'SPOC' => 'SAR Point Of Contact',
580
+						'SPOT' => 'Spot Wind',
581
+						'SR' => 'Sunrise',
582
+						'SRA' => 'Surveillance Radar Approach',
583
+						'SRE' => 'Surveillance Radar Element Of Precision Approach Radar System',
584
+						'SRG' => 'Short Range',
585
+						'SRR' => 'Search and Rescue Region',
586
+						'SRY' => 'Secondary',
587
+						'SS' => 'Sunset',
588
+						'SSE' => 'South-south-east',
589
+						'SSR' => 'Secondary Surveillance Radar',
590
+						'SST' => 'Supersonic Transport',
591
+						'SSW' => 'South-south-west',
592
+						'STA' => 'Straight-in Approach',
593
+						'STAR' => 'Standard Instrument Arrival',
594
+						'STD' => 'Standard',
595
+						'STN' => 'Station',
596
+						'STNR' => 'Stationary',
597
+						'STOL' => 'Short Take-off and Landing',
598
+						'STS' => 'Status',
599
+						'STWL' => 'Stopway Light(s)',
600
+						'SUBJ' => 'Subject To',
601
+						'SUN' => 'Sunday',
602
+						'SUP' => 'Supplement',
603
+						'SUPPS' => 'Regional Supplementary Procedures Service Message',
604
+						'SVCBL' => 'Serviceable',
605
+						'SW' => 'South-west',
606
+						'SWB' => 'South-westbound',
607
+						'SWY' => 'Stopway',
608
+						'TA' => 'Transition Altitude',
609
+						'TAA' => 'Terminal Arrival Altitude',
610
+						'TAF' => 'Aerodrome Forecast',
611
+						'TAIL' => 'Tail Wind',
612
+						'TAR' => 'Terminal Area Surveillance Radar',
613
+						'TAX' => 'Taxi',
614
+						'TCAC' => 'Tropical Cyclone Advisory Centre',
615
+						'TDO' => 'Tornado',
616
+						'TDZ' => 'Touchdown Zone',
617
+						'TECR' => 'Technical Reason',
618
+						'TEMPO' => 'Temporarily',
619
+						'TFC' => 'Traffic',
620
+						'TGL' => 'Touch-and-go',
621
+						'TGS' => 'Taxiing Guidance System',
622
+						'THR' => 'Threshold',
623
+						'THRU' => 'Through',
624
+						'THU' => 'Thursday',
625
+						'TIBA' => 'Traffic Information Broadcast By Aircraft',
626
+						'TIL' => 'Until',
627
+						'TIP' => 'Until Past',
628
+						'TKOF' => 'Take-off',
629
+						'TL' => 'Till',
630
+						'TLOF' => 'Touchdown And Lift-off Area',
631
+						'TMA' => 'Terminal Control Area',
632
+						'TNA' => 'Turn Altitude',
633
+						'TNH' => 'Turn Height',
634
+						'TOC' => 'Top of Climb',
635
+						'TODA' => 'Take-off Distance Available',
636
+						'TODAH' => 'Take-off Distance Available, Helicopter',
637
+						'TORA' => 'Take-off Run Available',
638
+						'TP' => 'Turning Point',
639
+						'TR' => 'Track',
640
+						'TRA' => 'Temporary Reserved Airspace',
641
+						'TRANS' => 'Transmitter',
642
+						'TRL' => 'Transition Level',
643
+						'TUE' => 'Tuesday',
644
+						'TURB' => 'Turbulence',
645
+						'TVOR' => 'Terminal VOR',
646
+						'TWR' => 'Tower',
647
+						'TWY' => 'Taxiway',
648
+						'TWYL' => 'Taxiway-link',
649
+						'TXT' => 'Text',
650
+						'TYP' => 'Type of Aircraft',
651
+						'U/S' => 'Unserviceable',
652
+						'UAB' => 'Until Advised By',
653
+						'UAC' => 'Upper Area Control Centre',
654
+						'UAR' => 'Upper Air Route',
655
+						'UFN' => 'Until Further Notice',
656
+						'UHDT' => 'Unable Higher Due Traffic',
657
+						'UIC' => 'Upper Information Centre',
658
+						'UIR' => 'Upper Flight Information Region',
659
+						'ULR' => 'Ultra Long Range',
660
+						'UNA' => 'Unable',
661
+						'UNAP' => 'Unable To Approve',
662
+						'UNL' => 'Unlimited',
663
+						'UNREL' => 'Unreliable',
664
+						'UTA' => 'Upper Control Area',
665
+						'VAAC' => 'Volcanic Ash Advisory Centre',
666
+						'VAC' => 'Visual Approach Chart',
667
+						'VAL' => 'In Valleys',
668
+						'VAN' => 'Runway Control Van',
669
+						'VAR' => 'Visual-aural Radio Range',
670
+						'VC' => 'Vicinity',
671
+						'VCY' => 'Vicinity',
672
+						'VER' => 'Vertical',
673
+						'VIS' => 'Visibility',
674
+						'VLR' => 'Very Long Range',
675
+						'VPA' => 'Vertical Path Angle',
676
+						'VRB' => 'Variable',
677
+						'VSA' => 'By Visual Reference To The Ground',
678
+						'VSP' => 'Vertical Speed',
679
+						'VTOL' => 'Vertical Take-off And Landing',
680
+						'WAC' => 'World Aeronautical Chart',
681
+						'WAFC' => 'World Area Forecast Centre',
682
+						'WB' => 'Westbound',
683
+						'WBAR' => 'Wing Bar Lights',
684
+						'WDI' => 'Wind Direction Indicator',
685
+						'WDSPR' => 'Widespread',
686
+						'WED' => 'Wednesday',
687
+						'WEF' => 'Effective From',
688
+						'WI' => 'Within',
689
+						'WID' => 'Width',
690
+						'WIE' => 'Effective Immediately',
691
+						'WILCO' => 'Will Comply',
692
+						'WIND' => 'Wind',
693
+						'WINTEM' => 'Forecast Upper Wind And Temperature For Aviation',
694
+						'WIP' => 'Work In Progress',
695
+						'WKN' => 'Weaken',
696
+						'WNW' => 'West-north-west',
697
+						'WO' => 'Without',
698
+						'WPT' => 'Way-point',
699
+						'WRNG' => 'Warning',
700
+						'WSW' => 'West-south-west',
701
+						'WT' => 'Weight',
702
+						'WWW' => 'Worldwide Web',
703
+						'WX' => 'Weather',
704
+						'XBAR' => 'Crossbar',
705
+						'XNG' => 'Crossing',
706
+						'XS' => 'Atmospherics',
707
+						'YCZ' => 'Yellow Caution Zone',
708
+						'YR' => 'Your');
709 709
 
710 710
 
711 711
 	function __construct($dbc = null) {
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -718,20 +718,20 @@  discard block
 block discarded – undo
718 718
 		try {
719 719
 			$sth = $this->db->prepare($query);
720 720
 			$sth->execute($query_values);
721
-		} catch(PDOException $e) {
721
+		} catch (PDOException $e) {
722 722
 			return "error : ".$e->getMessage();
723 723
 		}
724 724
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
725 725
 		return $all;
726 726
 	}
727 727
 
728
-	public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) {
728
+	public function addNOTAM($ref, $title, $type, $fir, $code, $rules, $scope, $lower_limit, $upper_limit, $center_latitude, $center_longitude, $radius, $date_begin, $date_end, $permanent, $text, $full_notam) {
729 729
 		$query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)";
730
-		$query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam);
730
+		$query_values = array(':ref' => $ref, ':title' => $title, ':type' => $type, ':fir' => $fir, ':code' => $code, ':rules' => $rules, ':scope' => $scope, ':lower_limit' => $lower_limit, ':upper_limit' => $upper_limit, ':center_latitude' => $center_latitude, ':center_longitude' => $center_longitude, ':radius' => $radius, ':date_begin' => $date_begin, ':date_end' => $date_end, ':permanent' => $permanent, ':text' => $text, ':full_notam' => $full_notam);
731 731
 		try {
732 732
 			$sth = $this->db->prepare($query);
733 733
 			$sth->execute($query_values);
734
-		} catch(PDOException $e) {
734
+		} catch (PDOException $e) {
735 735
 			return "error : ".$e->getMessage();
736 736
 		}
737 737
 	}
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 		try {
743 743
 			$sth = $this->db->prepare($query);
744 744
 			$sth->execute($query_values);
745
-		} catch(PDOException $e) {
745
+		} catch (PDOException $e) {
746 746
 			return "error : ".$e->getMessage();
747 747
 		}
748 748
 	}
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
 		try {
752 752
 			$sth = $this->db->prepare($query);
753 753
 			$sth->execute();
754
-		} catch(PDOException $e) {
754
+		} catch (PDOException $e) {
755 755
 			return "error : ".$e->getMessage();
756 756
 		}
757 757
 	}
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 			foreach ($globalNOTAMAirports as $airport) {
763 763
 				$data = $this->downloadNOTAM($airport);
764 764
 				if (count($data) > 0) {
765
-					$this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
765
+					$this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
766 766
 				}
767 767
 			}
768 768
 		}
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 		date_default_timezone_set("UTC");
773 773
 		$Common = new Common();
774 774
 		//$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
775
-		$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
775
+		$url = str_replace('{icao}', $icao, 'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
776 776
 		$data = $Common->getData($url);
777 777
 		preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches);
778 778
 		if (isset($matches[1])) return $matches[1];
@@ -783,14 +783,14 @@  discard block
 block discarded – undo
783 783
 		$Common = new Common();
784 784
 		$result = array();
785 785
 		$result['full_notam'] = $data;
786
-		$data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data);
787
-		$data = preg_split('#(?=([A-Z]\)\s))#',$data);
786
+		$data = str_ireplace(array("\r", "\n", '\r', '\n'), ' ', $data);
787
+		$data = preg_split('#(?=([A-Z]\)\s))#', $data);
788 788
 		//print_r($data);
789 789
 		foreach ($data as $line) {
790 790
 			$line = trim($line);
791
-			if (preg_match('#Q\) (.*)#',$line,$matches)) {
792
-				$line = str_replace(' ','',$line);
793
-				if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) {
791
+			if (preg_match('#Q\) (.*)#', $line, $matches)) {
792
+				$line = str_replace(' ', '', $line);
793
+				if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#', $line, $matches)) {
794 794
 					//print_r($matches);
795 795
 					$result['fir'] = $matches[1];
796 796
 					$result['code'] = $matches[2];
@@ -834,42 +834,42 @@  discard block
 block discarded – undo
834 834
 					elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning';
835 835
 					$result['lower_limit'] = $matches[6];
836 836
 					$result['upper_limit'] = $matches[7];
837
-					$latitude = $Common->convertDec($matches[8],'latitude');
837
+					$latitude = $Common->convertDec($matches[8], 'latitude');
838 838
 					if ($matches[9] == 'S') $latitude = -$latitude;
839
-					$longitude = $Common->convertDec($matches[10],'longitude');
839
+					$longitude = $Common->convertDec($matches[10], 'longitude');
840 840
 					if ($matches[11] == 'W') $longitude = -$longitude;
841 841
 					$result['latitude'] = $latitude;
842 842
 					$result['longitude'] = $longitude;
843 843
 					$result['radius'] = intval($matches[12]);
844 844
 				} else echo 'ERROR : '.$line."\n";
845 845
 			}
846
-			elseif (preg_match('#A\) (.*)#',$line,$matches)) {
846
+			elseif (preg_match('#A\) (.*)#', $line, $matches)) {
847 847
 				$result['icao'] = $matches[1];
848 848
 			}
849
-			elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) {
849
+			elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#', $line, $matches)) {
850 850
 				$result['date_begin'] = $matches[1].'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
851 851
 			}
852
-			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) {
852
+			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $line, $matches)) {
853 853
 				$result['date_finish'] = $matches[1].'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
854 854
 			}
855
-			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) {
855
+			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#', $line, $matches)) {
856 856
 				$result['date_finish'] = $matches[1].'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
857 857
 				if ($matches[6] == 'EST') $result['estimated'] = true;
858 858
 				else $result['estimated'] = false;
859 859
 				if ($matches[6] == 'PERM') $result['permanent'] = true;
860 860
 				else $result['permanent'] = false;
861 861
 			}
862
-			elseif (preg_match('#E\) (.*)#',$line,$matches)) {
863
-				$text = explode(' ',$matches[1]);
862
+			elseif (preg_match('#E\) (.*)#', $line, $matches)) {
863
+				$text = explode(' ', $matches[1]);
864 864
 				foreach ($text as $word) {
865 865
 					if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]);
866
-					elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3);
866
+					elseif (ctype_digit(strval(substr($word, 3))) && isset($this->abbr[substr($word, 0, 3)])) $rtext[] = strtoupper($this->abbr[substr($word, 0, 3)]).' '.substr($word, 3);
867 867
 					else $rtext[] = $word;
868 868
 				}
869
-				$result['text'] = implode(' ',$rtext);
870
-			} elseif (preg_match('#F\) (.*)#',$line,$matches)) {
871
-			} elseif (preg_match('#G\) (.*)#',$line,$matches)) {
872
-			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)$#',$line,$matches)) {
869
+				$result['text'] = implode(' ', $rtext);
870
+			} elseif (preg_match('#F\) (.*)#', $line, $matches)) {
871
+			} elseif (preg_match('#G\) (.*)#', $line, $matches)) {
872
+			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)$#', $line, $matches)) {
873 873
 				if ($matches[1] == 'NOTAMN') $result['type'] = 'new';
874 874
 				if ($matches[1] == 'NOTAMC') $result['type'] = 'cancel';
875 875
 				if ($matches[1] == 'NOTAMC') $result['type'] = 'replace';
Please login to merge, or discard this patch.
Braces   +98 added lines, -47 removed lines patch added patch discarded remove patch
@@ -775,8 +775,11 @@  discard block
 block discarded – undo
775 775
 		$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
776 776
 		$data = $Common->getData($url);
777 777
 		preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches);
778
-		if (isset($matches[1])) return $matches[1];
779
-		else return array();
778
+		if (isset($matches[1])) {
779
+			return $matches[1];
780
+		} else {
781
+			return array();
782
+		}
780 783
 	}
781 784
 
782 785
 	public function parse($data) {
@@ -797,82 +800,130 @@  discard block
 block discarded – undo
797 800
 					$rules = str_split($matches[3]);
798 801
 					foreach ($rules as $rule) {
799 802
 						if ($rule == 'I') {
800
-							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/IFR';
801
-							else $result['rules'] = 'IFR';
803
+							if (isset($result['rules'])) {
804
+								$result['rules'] = $result['rules'].'/IFR';
805
+							} else {
806
+								$result['rules'] = 'IFR';
807
+							}
802 808
 						} elseif ($rule == 'V') {
803
-							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/VFR';
804
-							else $result['rules'] = 'VFR';
809
+							if (isset($result['rules'])) {
810
+								$result['rules'] = $result['rules'].'/VFR';
811
+							} else {
812
+								$result['rules'] = 'VFR';
813
+							}
805 814
 						} elseif ($rule == 'K') {
806
-							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/Checklist';
807
-							else $result['rules'] = 'Checklist';
815
+							if (isset($result['rules'])) {
816
+								$result['rules'] = $result['rules'].'/Checklist';
817
+							} else {
818
+								$result['rules'] = 'Checklist';
819
+							}
808 820
 						}
809 821
 					}
810 822
 					$attentions = str_split($matches[4]);
811 823
 					foreach ($attentions as $attention) {
812 824
 						if ($attention == 'N') {
813
-							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Immediate attention';
814
-							else $result['rules'] = 'Immediate attention';
825
+							if (isset($result['attention'])) {
826
+								$result['attention'] = $result['attention'].' / Immediate attention';
827
+							} else {
828
+								$result['rules'] = 'Immediate attention';
829
+							}
815 830
 						} elseif ($attention == 'B') {
816
-							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Operational significance';
817
-							else $result['rules'] = 'Operational significance';
831
+							if (isset($result['attention'])) {
832
+								$result['attention'] = $result['attention'].' / Operational significance';
833
+							} else {
834
+								$result['rules'] = 'Operational significance';
835
+							}
818 836
 						} elseif ($attention == 'O') {
819
-							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Flight operations';
820
-							else $result['rules'] = 'Flight operations';
837
+							if (isset($result['attention'])) {
838
+								$result['attention'] = $result['attention'].' / Flight operations';
839
+							} else {
840
+								$result['rules'] = 'Flight operations';
841
+							}
821 842
 						} elseif ($attention == 'M') {
822
-							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Misc';
823
-							else $result['rules'] = 'Misc';
843
+							if (isset($result['attention'])) {
844
+								$result['attention'] = $result['attention'].' / Misc';
845
+							} else {
846
+								$result['rules'] = 'Misc';
847
+							}
824 848
 						} elseif ($attention == 'K') {
825
-							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Checklist';
826
-							else $result['rules'] = 'Checklist';
849
+							if (isset($result['attention'])) {
850
+								$result['attention'] = $result['attention'].' / Checklist';
851
+							} else {
852
+								$result['rules'] = 'Checklist';
853
+							}
827 854
 						}
828 855
 					}
829
-					if ($matches[5] == 'A') $result['scope'] = 'Airport warning';
830
-					elseif ($matches[5] == 'E') $result['scope'] = 'Enroute warning';
831
-					elseif ($matches[5] == 'W') $result['scope'] = 'Navigation warning';
832
-					elseif ($matches[5] == 'K') $result['scope'] = 'Checklist';
833
-					elseif ($matches[5] == 'AE') $result['scope'] = 'Airport/Enroute warning';
834
-					elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning';
856
+					if ($matches[5] == 'A') {
857
+						$result['scope'] = 'Airport warning';
858
+					} elseif ($matches[5] == 'E') {
859
+						$result['scope'] = 'Enroute warning';
860
+					} elseif ($matches[5] == 'W') {
861
+						$result['scope'] = 'Navigation warning';
862
+					} elseif ($matches[5] == 'K') {
863
+						$result['scope'] = 'Checklist';
864
+					} elseif ($matches[5] == 'AE') {
865
+						$result['scope'] = 'Airport/Enroute warning';
866
+					} elseif ($matches[5] == 'AW') {
867
+						$result['scope'] = 'Airport/Navigation warning';
868
+					}
835 869
 					$result['lower_limit'] = $matches[6];
836 870
 					$result['upper_limit'] = $matches[7];
837 871
 					$latitude = $Common->convertDec($matches[8],'latitude');
838
-					if ($matches[9] == 'S') $latitude = -$latitude;
872
+					if ($matches[9] == 'S') {
873
+						$latitude = -$latitude;
874
+					}
839 875
 					$longitude = $Common->convertDec($matches[10],'longitude');
840
-					if ($matches[11] == 'W') $longitude = -$longitude;
876
+					if ($matches[11] == 'W') {
877
+						$longitude = -$longitude;
878
+					}
841 879
 					$result['latitude'] = $latitude;
842 880
 					$result['longitude'] = $longitude;
843 881
 					$result['radius'] = intval($matches[12]);
844
-				} else echo 'ERROR : '.$line."\n";
845
-			}
846
-			elseif (preg_match('#A\) (.*)#',$line,$matches)) {
882
+				} else {
883
+					echo 'ERROR : '.$line."\n";
884
+				}
885
+			} elseif (preg_match('#A\) (.*)#',$line,$matches)) {
847 886
 				$result['icao'] = $matches[1];
848
-			}
849
-			elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) {
887
+			} elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) {
850 888
 				$result['date_begin'] = $matches[1].'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
851
-			}
852
-			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) {
889
+			} elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) {
853 890
 				$result['date_finish'] = $matches[1].'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
854
-			}
855
-			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) {
891
+			} elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) {
856 892
 				$result['date_finish'] = $matches[1].'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
857
-				if ($matches[6] == 'EST') $result['estimated'] = true;
858
-				else $result['estimated'] = false;
859
-				if ($matches[6] == 'PERM') $result['permanent'] = true;
860
-				else $result['permanent'] = false;
861
-			}
862
-			elseif (preg_match('#E\) (.*)#',$line,$matches)) {
893
+				if ($matches[6] == 'EST') {
894
+					$result['estimated'] = true;
895
+				} else {
896
+					$result['estimated'] = false;
897
+				}
898
+				if ($matches[6] == 'PERM') {
899
+					$result['permanent'] = true;
900
+				} else {
901
+					$result['permanent'] = false;
902
+				}
903
+			} elseif (preg_match('#E\) (.*)#',$line,$matches)) {
863 904
 				$text = explode(' ',$matches[1]);
864 905
 				foreach ($text as $word) {
865
-					if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]);
866
-					elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3);
867
-					else $rtext[] = $word;
906
+					if (isset($this->abbr[$word])) {
907
+						$rtext[] = strtoupper($this->abbr[$word]);
908
+					} elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) {
909
+						$rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3);
910
+					} else {
911
+						$rtext[] = $word;
912
+					}
868 913
 				}
869 914
 				$result['text'] = implode(' ',$rtext);
870 915
 			} elseif (preg_match('#F\) (.*)#',$line,$matches)) {
871 916
 			} elseif (preg_match('#G\) (.*)#',$line,$matches)) {
872 917
 			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)$#',$line,$matches)) {
873
-				if ($matches[1] == 'NOTAMN') $result['type'] = 'new';
874
-				if ($matches[1] == 'NOTAMC') $result['type'] = 'cancel';
875
-				if ($matches[1] == 'NOTAMC') $result['type'] = 'replace';
918
+				if ($matches[1] == 'NOTAMN') {
919
+					$result['type'] = 'new';
920
+				}
921
+				if ($matches[1] == 'NOTAMC') {
922
+					$result['type'] = 'cancel';
923
+				}
924
+				if ($matches[1] == 'NOTAMC') {
925
+					$result['type'] = 'replace';
926
+				}
876 927
 			}
877 928
 		}
878 929
 		return $result;
Please login to merge, or discard this patch.
require/class.SBS.php 4 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -178,6 +178,10 @@  discard block
 block discarded – undo
178 178
 	return 1;
179 179
     }
180 180
     
181
+    /**
182
+     * @param double $lat
183
+     * @param integer $isodd
184
+     */
181 185
     function cprN($lat,$isodd) {
182 186
 	$nl = $this->cprNL($lat) - $isodd;
183 187
 	if ($nl > 1) return $nl;
@@ -185,6 +189,10 @@  discard block
 block discarded – undo
185 189
     }
186 190
 
187 191
 
192
+    /**
193
+     * @param string $msg
194
+     * @param string $bin
195
+     */
188 196
     function parityCheck($msg, $bin) {
189 197
 $modes_checksum_table = array(
190 198
 0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178,
Please login to merge, or discard this patch.
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class SBS {
3
-    static $latlon = array();
3
+	static $latlon = array();
4 4
     
5
-    function parse($buffer) {
5
+	function parse($buffer) {
6 6
 	// Not yet finished, no CRC checks
7 7
 	//echo $buffer."\n";
8 8
 	$typehex = substr($buffer,0,1);
@@ -12,47 +12,47 @@  discard block
 block discarded – undo
12 12
 	$bin = gmp_strval( gmp_init($hex,16), 2);
13 13
 	//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
14 14
 	if (strlen($hex) == 28) {
15
-	    $df = intval(substr($bin,0,5),2);
16
-	    $ca = intval(substr($bin,5,3),2);
17
-	    // Only support DF17 for now
18
-	    //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) {
19
-	    if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) {
15
+		$df = intval(substr($bin,0,5),2);
16
+		$ca = intval(substr($bin,5,3),2);
17
+		// Only support DF17 for now
18
+		//if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) {
19
+		if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) {
20 20
 		$icao = substr($hex,2,6);
21 21
 		$data['hex'] = $icao;
22 22
 		$tc = intval(substr($bin,32,5),2);
23 23
 		if ($tc >= 1 && $tc <= 4) {
24
-		    //callsign
25
-		    $csbin = substr($bin,40,56);
26
-		    $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######');
27
-		    $cs = '';
28
-		    $cs .= $charset[intval(substr($csbin,0,6),2)];
29
-		    $cs .= $charset[intval(substr($csbin,6,6),2)];
30
-		    $cs .= $charset[intval(substr($csbin,12,6),2)];
31
-		    $cs .= $charset[intval(substr($csbin,18,6),2)];
32
-		    $cs .= $charset[intval(substr($csbin,24,6),2)];
33
-		    $cs .= $charset[intval(substr($csbin,30,6),2)];
34
-		    $cs .= $charset[intval(substr($csbin,36,6),2)];
35
-		    $cs .= $charset[intval(substr($csbin,42,6),2)];
36
-		    $cs = str_replace('_','',$cs);
37
-		    $cs = str_replace('#','',$cs);
38
-		    $callsign = $cs;
39
-		    $data['ident'] = $callsign;
24
+			//callsign
25
+			$csbin = substr($bin,40,56);
26
+			$charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######');
27
+			$cs = '';
28
+			$cs .= $charset[intval(substr($csbin,0,6),2)];
29
+			$cs .= $charset[intval(substr($csbin,6,6),2)];
30
+			$cs .= $charset[intval(substr($csbin,12,6),2)];
31
+			$cs .= $charset[intval(substr($csbin,18,6),2)];
32
+			$cs .= $charset[intval(substr($csbin,24,6),2)];
33
+			$cs .= $charset[intval(substr($csbin,30,6),2)];
34
+			$cs .= $charset[intval(substr($csbin,36,6),2)];
35
+			$cs .= $charset[intval(substr($csbin,42,6),2)];
36
+			$cs = str_replace('_','',$cs);
37
+			$cs = str_replace('#','',$cs);
38
+			$callsign = $cs;
39
+			$data['ident'] = $callsign;
40 40
 		} elseif ($tc >= 9 && $tc <= 18) {
41
-		    // Check Q-bit
42
-		    $q = substr($bin,47,1);
43
-		    if ($q) {
41
+			// Check Q-bit
42
+			$q = substr($bin,47,1);
43
+			if ($q) {
44 44
 			$n = intval(substr($bin,40,7).substr($bin,48,4),2);
45 45
 			$alt = $n*25-1000;
46 46
 			$data['altitude'] = $alt;
47
-		    }
48
-		    // Check odd/even flag
49
-		    $oe = substr($bin,53,1);
50
-		    //if ($oe) => odd else even
51
-		    //  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
52
-		    $cprlat = intval(substr($bin,54,17),2)/131072.0;
53
-		    $cprlon = intval(substr($bin,71,17),2)/131072.0;
54
-		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
55
-		    elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
47
+			}
48
+			// Check odd/even flag
49
+			$oe = substr($bin,53,1);
50
+			//if ($oe) => odd else even
51
+			//  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
52
+			$cprlat = intval(substr($bin,54,17),2)/131072.0;
53
+			$cprlon = intval(substr($bin,71,17),2)/131072.0;
54
+			if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
55
+			elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
56 56
 			$cprlat_odd = $cprlat;
57 57
 			$cprlon_odd = $cprlon;
58 58
 			$cprlat_even = $this::$latlon[$icao]['latitude'];
@@ -65,56 +65,56 @@  discard block
 block discarded – undo
65 65
 			if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
66 66
 			// check latitude zone
67 67
 			if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
68
-			    if ($this::$latlon[$icao]['created'] > time()) {
68
+				if ($this::$latlon[$icao]['created'] > time()) {
69 69
 				$ni = $this->cprN($lat_even,0);
70 70
 				$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
71 71
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
72 72
 				$lat = $lat_even;
73 73
 				if ($lon > 180) $lon = $lon -360;
74 74
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
75
-				    //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
76
-				    $data['latitude'] = $lat;
77
-				    $data['longitude'] = $lon;
75
+					//if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
76
+					$data['latitude'] = $lat;
77
+					$data['longitude'] = $lon;
78 78
 				}
79
-			    } else {
79
+				} else {
80 80
 				$ni = $this->cprN($lat_odd,1);
81 81
 				$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
82 82
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
83 83
 				$lat = $lat_odd;
84 84
 				if ($lon > 180) $lon = $lon -360;
85 85
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
86
-				    //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
87
-				    $data['latitude'] = $lat;
88
-				    $data['longitude'] = $lon;
86
+					//if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
87
+					$data['latitude'] = $lat;
88
+					$data['longitude'] = $lon;
89
+				}
89 90
 				}
90
-			    }
91 91
 			} else echo "Not cprNL";
92 92
 			unset($this::$latlon[$icao]);
93
-		    }
93
+			}
94 94
 		} elseif ($tc == 19) {
95
-		    // speed & heading
96
-		    $v_ew_dir = intval(substr($bin,45,1));
97
-		    $v_ew = intval(substr($bin,46,10),2);
98
-		    $v_ns_dir = intval(substr($bin,56,1));
99
-		    $v_ns = intval(substr($bin,57,10),2);
100
-		    if ($v_ew_dir) $v_ew = -1*$v_ew;
101
-		    if ($v_ns_dir) $v_ns = -1*$v_ns;
102
-		    $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
103
-		    $heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
104
-		    if ($heading <0) $heading = $heading+360;
105
-		    $data['speed'] = $speed;
106
-		    $data['heading'] = $heading;
95
+			// speed & heading
96
+			$v_ew_dir = intval(substr($bin,45,1));
97
+			$v_ew = intval(substr($bin,46,10),2);
98
+			$v_ns_dir = intval(substr($bin,56,1));
99
+			$v_ns = intval(substr($bin,57,10),2);
100
+			if ($v_ew_dir) $v_ew = -1*$v_ew;
101
+			if ($v_ns_dir) $v_ns = -1*$v_ns;
102
+			$speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
103
+			$heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
104
+			if ($heading <0) $heading = $heading+360;
105
+			$data['speed'] = $speed;
106
+			$data['heading'] = $heading;
107
+		}
107 108
 		}
108
-	    }
109
-	    if (isset($data)) {
109
+		if (isset($data)) {
110 110
 		//print_r($data);
111 111
 		return $data;
112
-	    }
113
-        }
114
-    }
112
+		}
113
+		}
114
+	}
115 115
 
116 116
 
117
-    function cprNL($lat) {
117
+	function cprNL($lat) {
118 118
 	//Lookup table to convert the latitude to index.
119 119
 	if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
120 120
 	if ($lat < 10.47047130) return 59;
@@ -176,16 +176,16 @@  discard block
 block discarded – undo
176 176
 	if ($lat < 86.53536998) return 3;
177 177
 	if ($lat < 87.00000000) return 2;
178 178
 	return 1;
179
-    }
179
+	}
180 180
     
181
-    function cprN($lat,$isodd) {
181
+	function cprN($lat,$isodd) {
182 182
 	$nl = $this->cprNL($lat) - $isodd;
183 183
 	if ($nl > 1) return $nl;
184 184
 	else return 1;
185
-    }
185
+	}
186 186
 
187 187
 
188
-    function parityCheck($msg, $bin) {
188
+	function parityCheck($msg, $bin) {
189 189
 $modes_checksum_table = array(
190 190
 0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178,
191 191
 0x2c38bc, 0x161c5e, 0x0b0e2f, 0xfa7d13, 0x82c48d, 0xbe9842, 0x5f4c21, 0xd05c14,
@@ -207,13 +207,13 @@  discard block
 block discarded – undo
207 207
 	$checksum = intval(substr($msg,22,6),16);
208 208
 
209 209
 	for ($j = 0; $j < strlen($bin); $j++) {
210
-	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
210
+		if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
211 211
 	}
212 212
 	if ($crc == $checksum) return true;
213 213
 	else {
214
-	    //echo "**** CRC ERROR ****\n";
215
-	    return false;
214
+		//echo "**** CRC ERROR ****\n";
215
+		return false;
216
+	}
216 217
 	}
217
-    }
218 218
 }
219 219
 ?>
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -5,83 +5,83 @@  discard block
 block discarded – undo
5 5
     function parse($buffer) {
6 6
 	// Not yet finished, no CRC checks
7 7
 	//echo $buffer."\n";
8
-	$typehex = substr($buffer,0,1);
9
-	if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1);
10
-	elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13);
11
-	else $hex = substr($buffer,1,-1);
12
-	$bin = gmp_strval( gmp_init($hex,16), 2);
8
+	$typehex = substr($buffer, 0, 1);
9
+	if ($typehex == '*' || $typehex == ':') $hex = substr($buffer, 1, -1);
10
+	elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer, 13, -13);
11
+	else $hex = substr($buffer, 1, -1);
12
+	$bin = gmp_strval(gmp_init($hex, 16), 2);
13 13
 	//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
14 14
 	if (strlen($hex) == 28) {
15
-	    $df = intval(substr($bin,0,5),2);
16
-	    $ca = intval(substr($bin,5,3),2);
15
+	    $df = intval(substr($bin, 0, 5), 2);
16
+	    $ca = intval(substr($bin, 5, 3), 2);
17 17
 	    // Only support DF17 for now
18 18
 	    //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) {
19
-	    if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) {
20
-		$icao = substr($hex,2,6);
19
+	    if (($df == 17 || $df == 18) && ($this->parityCheck($hex, $bin) || $typehex == '@')) {
20
+		$icao = substr($hex, 2, 6);
21 21
 		$data['hex'] = $icao;
22
-		$tc = intval(substr($bin,32,5),2);
22
+		$tc = intval(substr($bin, 32, 5), 2);
23 23
 		if ($tc >= 1 && $tc <= 4) {
24 24
 		    //callsign
25
-		    $csbin = substr($bin,40,56);
25
+		    $csbin = substr($bin, 40, 56);
26 26
 		    $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######');
27 27
 		    $cs = '';
28
-		    $cs .= $charset[intval(substr($csbin,0,6),2)];
29
-		    $cs .= $charset[intval(substr($csbin,6,6),2)];
30
-		    $cs .= $charset[intval(substr($csbin,12,6),2)];
31
-		    $cs .= $charset[intval(substr($csbin,18,6),2)];
32
-		    $cs .= $charset[intval(substr($csbin,24,6),2)];
33
-		    $cs .= $charset[intval(substr($csbin,30,6),2)];
34
-		    $cs .= $charset[intval(substr($csbin,36,6),2)];
35
-		    $cs .= $charset[intval(substr($csbin,42,6),2)];
36
-		    $cs = str_replace('_','',$cs);
37
-		    $cs = str_replace('#','',$cs);
28
+		    $cs .= $charset[intval(substr($csbin, 0, 6), 2)];
29
+		    $cs .= $charset[intval(substr($csbin, 6, 6), 2)];
30
+		    $cs .= $charset[intval(substr($csbin, 12, 6), 2)];
31
+		    $cs .= $charset[intval(substr($csbin, 18, 6), 2)];
32
+		    $cs .= $charset[intval(substr($csbin, 24, 6), 2)];
33
+		    $cs .= $charset[intval(substr($csbin, 30, 6), 2)];
34
+		    $cs .= $charset[intval(substr($csbin, 36, 6), 2)];
35
+		    $cs .= $charset[intval(substr($csbin, 42, 6), 2)];
36
+		    $cs = str_replace('_', '', $cs);
37
+		    $cs = str_replace('#', '', $cs);
38 38
 		    $callsign = $cs;
39 39
 		    $data['ident'] = $callsign;
40 40
 		} elseif ($tc >= 9 && $tc <= 18) {
41 41
 		    // Check Q-bit
42
-		    $q = substr($bin,47,1);
42
+		    $q = substr($bin, 47, 1);
43 43
 		    if ($q) {
44
-			$n = intval(substr($bin,40,7).substr($bin,48,4),2);
45
-			$alt = $n*25-1000;
44
+			$n = intval(substr($bin, 40, 7).substr($bin, 48, 4), 2);
45
+			$alt = $n*25 - 1000;
46 46
 			$data['altitude'] = $alt;
47 47
 		    }
48 48
 		    // Check odd/even flag
49
-		    $oe = substr($bin,53,1);
49
+		    $oe = substr($bin, 53, 1);
50 50
 		    //if ($oe) => odd else even
51 51
 		    //  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
52
-		    $cprlat = intval(substr($bin,54,17),2)/131072.0;
53
-		    $cprlon = intval(substr($bin,71,17),2)/131072.0;
54
-		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
52
+		    $cprlat = intval(substr($bin, 54, 17), 2)/131072.0;
53
+		    $cprlon = intval(substr($bin, 71, 17), 2)/131072.0;
54
+		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat, 'longitude' => $cprlon, 'created' => time());
55 55
 		    elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
56 56
 			$cprlat_odd = $cprlat;
57 57
 			$cprlon_odd = $cprlon;
58 58
 			$cprlat_even = $this::$latlon[$icao]['latitude'];
59 59
 			$cprlon_even = $this::$latlon[$icao]['longitude'];
60 60
 		    
61
-			$j = 59*$cprlat_even-60*$cprlat_odd+0.5;
62
-			$lat_even = (360.0/60)*($j%60+$cprlat_even);
63
-			$lat_odd = (360.0/59)*($j%59+$cprlat_odd);
61
+			$j = 59*$cprlat_even - 60*$cprlat_odd + 0.5;
62
+			$lat_even = (360.0/60)*($j%60 + $cprlat_even);
63
+			$lat_odd = (360.0/59)*($j%59 + $cprlat_odd);
64 64
 			if ($lat_even >= 270) $lat_even = $lat_even - 360;
65 65
 			if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
66 66
 			// check latitude zone
67 67
 			if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
68 68
 			    if ($this::$latlon[$icao]['created'] > time()) {
69
-				$ni = $this->cprN($lat_even,0);
70
-				$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
71
-				$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
69
+				$ni = $this->cprN($lat_even, 0);
70
+				$m = floor($cprlon_even*($this->cprNL($lat_even) - 1) - $cprlon_odd*$this->cprNL($lat_even) + 0.5);
71
+				$lon = (360.0/$ni)*($m%$ni + $cprlon_even);
72 72
 				$lat = $lat_even;
73
-				if ($lon > 180) $lon = $lon -360;
73
+				if ($lon > 180) $lon = $lon - 360;
74 74
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
75 75
 				    //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
76 76
 				    $data['latitude'] = $lat;
77 77
 				    $data['longitude'] = $lon;
78 78
 				}
79 79
 			    } else {
80
-				$ni = $this->cprN($lat_odd,1);
81
-				$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
82
-				$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
80
+				$ni = $this->cprN($lat_odd, 1);
81
+				$m = floor($cprlon_even*($this->cprNL($lat_odd) - 1) - $cprlon_odd*$this->cprNL($lat_odd) + 0.5);
82
+				$lon = (360.0/$ni)*($m%$ni + $cprlon_odd);
83 83
 				$lat = $lat_odd;
84
-				if ($lon > 180) $lon = $lon -360;
84
+				if ($lon > 180) $lon = $lon - 360;
85 85
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
86 86
 				    //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
87 87
 				    $data['latitude'] = $lat;
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 		    }
94 94
 		} elseif ($tc == 19) {
95 95
 		    // speed & heading
96
-		    $v_ew_dir = intval(substr($bin,45,1));
97
-		    $v_ew = intval(substr($bin,46,10),2);
98
-		    $v_ns_dir = intval(substr($bin,56,1));
99
-		    $v_ns = intval(substr($bin,57,10),2);
96
+		    $v_ew_dir = intval(substr($bin, 45, 1));
97
+		    $v_ew = intval(substr($bin, 46, 10), 2);
98
+		    $v_ns_dir = intval(substr($bin, 56, 1));
99
+		    $v_ns = intval(substr($bin, 57, 10), 2);
100 100
 		    if ($v_ew_dir) $v_ew = -1*$v_ew;
101 101
 		    if ($v_ns_dir) $v_ns = -1*$v_ns;
102
-		    $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
103
-		    $heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
104
-		    if ($heading <0) $heading = $heading+360;
102
+		    $speed = sqrt($v_ns*$v_ns + $v_ew*$v_ew);
103
+		    $heading = atan2($v_ew, $v_ns)*360.0/(2*pi());
104
+		    if ($heading < 0) $heading = $heading + 360;
105 105
 		    $data['speed'] = $speed;
106 106
 		    $data['heading'] = $heading;
107 107
 		}
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
     function cprNL($lat) {
118 118
 	//Lookup table to convert the latitude to index.
119
-	if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
119
+	if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator.
120 120
 	if ($lat < 10.47047130) return 59;
121 121
 	if ($lat < 14.82817437) return 58;
122 122
 	if ($lat < 18.18626357) return 57;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	return 1;
179 179
     }
180 180
     
181
-    function cprN($lat,$isodd) {
181
+    function cprN($lat, $isodd) {
182 182
 	$nl = $this->cprNL($lat) - $isodd;
183 183
 	if ($nl > 1) return $nl;
184 184
 	else return 1;
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
 );
205 205
 
206 206
 	$crc = 0;
207
-	$checksum = intval(substr($msg,22,6),16);
207
+	$checksum = intval(substr($msg, 22, 6), 16);
208 208
 
209 209
 	for ($j = 0; $j < strlen($bin); $j++) {
210
-	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
210
+	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j], 0);
211 211
 	}
212 212
 	if ($crc == $checksum) return true;
213 213
 	else {
Please login to merge, or discard this patch.
Braces   +223 added lines, -77 removed lines patch added patch discarded remove patch
@@ -6,9 +6,13 @@  discard block
 block discarded – undo
6 6
 	// Not yet finished, no CRC checks
7 7
 	//echo $buffer."\n";
8 8
 	$typehex = substr($buffer,0,1);
9
-	if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1);
10
-	elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13);
11
-	else $hex = substr($buffer,1,-1);
9
+	if ($typehex == '*' || $typehex == ':') {
10
+		$hex = substr($buffer,1,-1);
11
+	} elseif ($typehex == '@' || $typehex == '%') {
12
+		$hex = substr($buffer,13,-13);
13
+	} else {
14
+		$hex = substr($buffer,1,-1);
15
+	}
12 16
 	$bin = gmp_strval( gmp_init($hex,16), 2);
13 17
 	//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
14 18
 	if (strlen($hex) == 28) {
@@ -51,8 +55,9 @@  discard block
 block discarded – undo
51 55
 		    //  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
52 56
 		    $cprlat = intval(substr($bin,54,17),2)/131072.0;
53 57
 		    $cprlon = intval(substr($bin,71,17),2)/131072.0;
54
-		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
55
-		    elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
58
+		    if ($oe == 0) {
59
+		    	$this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
60
+		    } elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
56 61
 			$cprlat_odd = $cprlat;
57 62
 			$cprlon_odd = $cprlon;
58 63
 			$cprlat_even = $this::$latlon[$icao]['latitude'];
@@ -61,8 +66,12 @@  discard block
 block discarded – undo
61 66
 			$j = 59*$cprlat_even-60*$cprlat_odd+0.5;
62 67
 			$lat_even = (360.0/60)*($j%60+$cprlat_even);
63 68
 			$lat_odd = (360.0/59)*($j%59+$cprlat_odd);
64
-			if ($lat_even >= 270) $lat_even = $lat_even - 360;
65
-			if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
69
+			if ($lat_even >= 270) {
70
+				$lat_even = $lat_even - 360;
71
+			}
72
+			if ($lat_odd >= 270) {
73
+				$lat_odd = $lat_odd - 360;
74
+			}
66 75
 			// check latitude zone
67 76
 			if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
68 77
 			    if ($this::$latlon[$icao]['created'] > time()) {
@@ -70,7 +79,9 @@  discard block
 block discarded – undo
70 79
 				$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
71 80
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
72 81
 				$lat = $lat_even;
73
-				if ($lon > 180) $lon = $lon -360;
82
+				if ($lon > 180) {
83
+					$lon = $lon -360;
84
+				}
74 85
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
75 86
 				    //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
76 87
 				    $data['latitude'] = $lat;
@@ -81,14 +92,18 @@  discard block
 block discarded – undo
81 92
 				$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
82 93
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
83 94
 				$lat = $lat_odd;
84
-				if ($lon > 180) $lon = $lon -360;
95
+				if ($lon > 180) {
96
+					$lon = $lon -360;
97
+				}
85 98
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
86 99
 				    //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
87 100
 				    $data['latitude'] = $lat;
88 101
 				    $data['longitude'] = $lon;
89 102
 				}
90 103
 			    }
91
-			} else echo "Not cprNL";
104
+			} else {
105
+				echo "Not cprNL";
106
+			}
92 107
 			unset($this::$latlon[$icao]);
93 108
 		    }
94 109
 		} elseif ($tc == 19) {
@@ -97,11 +112,17 @@  discard block
 block discarded – undo
97 112
 		    $v_ew = intval(substr($bin,46,10),2);
98 113
 		    $v_ns_dir = intval(substr($bin,56,1));
99 114
 		    $v_ns = intval(substr($bin,57,10),2);
100
-		    if ($v_ew_dir) $v_ew = -1*$v_ew;
101
-		    if ($v_ns_dir) $v_ns = -1*$v_ns;
115
+		    if ($v_ew_dir) {
116
+		    	$v_ew = -1*$v_ew;
117
+		    }
118
+		    if ($v_ns_dir) {
119
+		    	$v_ns = -1*$v_ns;
120
+		    }
102 121
 		    $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
103 122
 		    $heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
104
-		    if ($heading <0) $heading = $heading+360;
123
+		    if ($heading <0) {
124
+		    	$heading = $heading+360;
125
+		    }
105 126
 		    $data['speed'] = $speed;
106 127
 		    $data['heading'] = $heading;
107 128
 		}
@@ -116,72 +137,194 @@  discard block
 block discarded – undo
116 137
 
117 138
     function cprNL($lat) {
118 139
 	//Lookup table to convert the latitude to index.
119
-	if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
120
-	if ($lat < 10.47047130) return 59;
121
-	if ($lat < 14.82817437) return 58;
122
-	if ($lat < 18.18626357) return 57;
123
-	if ($lat < 21.02939493) return 56;
124
-	if ($lat < 23.54504487) return 55;
125
-	if ($lat < 25.82924707) return 54;
126
-	if ($lat < 27.93898710) return 53;
127
-	if ($lat < 29.91135686) return 52;
128
-	if ($lat < 31.77209708) return 51;
129
-	if ($lat < 33.53993436) return 50;
130
-	if ($lat < 35.22899598) return 49;
131
-	if ($lat < 36.85025108) return 48;
132
-	if ($lat < 38.41241892) return 47;
133
-	if ($lat < 39.92256684) return 46;
134
-	if ($lat < 41.38651832) return 45;
135
-	if ($lat < 42.80914012) return 44;
136
-	if ($lat < 44.19454951) return 43;
137
-	if ($lat < 45.54626723) return 42;
138
-	if ($lat < 46.86733252) return 41;
139
-	if ($lat < 48.16039128) return 40;
140
-	if ($lat < 49.42776439) return 39;
141
-	if ($lat < 50.67150166) return 38;
142
-	if ($lat < 51.89342469) return 37;
143
-	if ($lat < 53.09516153) return 36;
144
-	if ($lat < 54.27817472) return 35;
145
-	if ($lat < 55.44378444) return 34;
146
-	if ($lat < 56.59318756) return 33;
147
-	if ($lat < 57.72747354) return 32;
148
-	if ($lat < 58.84763776) return 31;
149
-	if ($lat < 59.95459277) return 30;
150
-	if ($lat < 61.04917774) return 29;
151
-	if ($lat < 62.13216659) return 28;
152
-	if ($lat < 63.20427479) return 27;
153
-	if ($lat < 64.26616523) return 26;
154
-	if ($lat < 65.31845310) return 25;
155
-	if ($lat < 66.36171008) return 24;
156
-	if ($lat < 67.39646774) return 23;
157
-	if ($lat < 68.42322022) return 22;
158
-	if ($lat < 69.44242631) return 21;
159
-	if ($lat < 70.45451075) return 20;
160
-	if ($lat < 71.45986473) return 19;
161
-	if ($lat < 72.45884545) return 18;
162
-	if ($lat < 73.45177442) return 17;
163
-	if ($lat < 74.43893416) return 16;
164
-	if ($lat < 75.42056257) return 15;
165
-	if ($lat < 76.39684391) return 14;
166
-	if ($lat < 77.36789461) return 13;
167
-	if ($lat < 78.33374083) return 12;
168
-	if ($lat < 79.29428225) return 11;
169
-	if ($lat < 80.24923213) return 10;
170
-	if ($lat < 81.19801349) return 9;
171
-	if ($lat < 82.13956981) return 8;
172
-	if ($lat < 83.07199445) return 7;
173
-	if ($lat < 83.99173563) return 6;
174
-	if ($lat < 84.89166191) return 5;
175
-	if ($lat < 85.75541621) return 4;
176
-	if ($lat < 86.53536998) return 3;
177
-	if ($lat < 87.00000000) return 2;
140
+	if ($lat < 0) {
141
+		$lat = -$lat;
142
+	}
143
+	// Table is simmetric about the equator.
144
+	if ($lat < 10.47047130) {
145
+		return 59;
146
+	}
147
+	if ($lat < 14.82817437) {
148
+		return 58;
149
+	}
150
+	if ($lat < 18.18626357) {
151
+		return 57;
152
+	}
153
+	if ($lat < 21.02939493) {
154
+		return 56;
155
+	}
156
+	if ($lat < 23.54504487) {
157
+		return 55;
158
+	}
159
+	if ($lat < 25.82924707) {
160
+		return 54;
161
+	}
162
+	if ($lat < 27.93898710) {
163
+		return 53;
164
+	}
165
+	if ($lat < 29.91135686) {
166
+		return 52;
167
+	}
168
+	if ($lat < 31.77209708) {
169
+		return 51;
170
+	}
171
+	if ($lat < 33.53993436) {
172
+		return 50;
173
+	}
174
+	if ($lat < 35.22899598) {
175
+		return 49;
176
+	}
177
+	if ($lat < 36.85025108) {
178
+		return 48;
179
+	}
180
+	if ($lat < 38.41241892) {
181
+		return 47;
182
+	}
183
+	if ($lat < 39.92256684) {
184
+		return 46;
185
+	}
186
+	if ($lat < 41.38651832) {
187
+		return 45;
188
+	}
189
+	if ($lat < 42.80914012) {
190
+		return 44;
191
+	}
192
+	if ($lat < 44.19454951) {
193
+		return 43;
194
+	}
195
+	if ($lat < 45.54626723) {
196
+		return 42;
197
+	}
198
+	if ($lat < 46.86733252) {
199
+		return 41;
200
+	}
201
+	if ($lat < 48.16039128) {
202
+		return 40;
203
+	}
204
+	if ($lat < 49.42776439) {
205
+		return 39;
206
+	}
207
+	if ($lat < 50.67150166) {
208
+		return 38;
209
+	}
210
+	if ($lat < 51.89342469) {
211
+		return 37;
212
+	}
213
+	if ($lat < 53.09516153) {
214
+		return 36;
215
+	}
216
+	if ($lat < 54.27817472) {
217
+		return 35;
218
+	}
219
+	if ($lat < 55.44378444) {
220
+		return 34;
221
+	}
222
+	if ($lat < 56.59318756) {
223
+		return 33;
224
+	}
225
+	if ($lat < 57.72747354) {
226
+		return 32;
227
+	}
228
+	if ($lat < 58.84763776) {
229
+		return 31;
230
+	}
231
+	if ($lat < 59.95459277) {
232
+		return 30;
233
+	}
234
+	if ($lat < 61.04917774) {
235
+		return 29;
236
+	}
237
+	if ($lat < 62.13216659) {
238
+		return 28;
239
+	}
240
+	if ($lat < 63.20427479) {
241
+		return 27;
242
+	}
243
+	if ($lat < 64.26616523) {
244
+		return 26;
245
+	}
246
+	if ($lat < 65.31845310) {
247
+		return 25;
248
+	}
249
+	if ($lat < 66.36171008) {
250
+		return 24;
251
+	}
252
+	if ($lat < 67.39646774) {
253
+		return 23;
254
+	}
255
+	if ($lat < 68.42322022) {
256
+		return 22;
257
+	}
258
+	if ($lat < 69.44242631) {
259
+		return 21;
260
+	}
261
+	if ($lat < 70.45451075) {
262
+		return 20;
263
+	}
264
+	if ($lat < 71.45986473) {
265
+		return 19;
266
+	}
267
+	if ($lat < 72.45884545) {
268
+		return 18;
269
+	}
270
+	if ($lat < 73.45177442) {
271
+		return 17;
272
+	}
273
+	if ($lat < 74.43893416) {
274
+		return 16;
275
+	}
276
+	if ($lat < 75.42056257) {
277
+		return 15;
278
+	}
279
+	if ($lat < 76.39684391) {
280
+		return 14;
281
+	}
282
+	if ($lat < 77.36789461) {
283
+		return 13;
284
+	}
285
+	if ($lat < 78.33374083) {
286
+		return 12;
287
+	}
288
+	if ($lat < 79.29428225) {
289
+		return 11;
290
+	}
291
+	if ($lat < 80.24923213) {
292
+		return 10;
293
+	}
294
+	if ($lat < 81.19801349) {
295
+		return 9;
296
+	}
297
+	if ($lat < 82.13956981) {
298
+		return 8;
299
+	}
300
+	if ($lat < 83.07199445) {
301
+		return 7;
302
+	}
303
+	if ($lat < 83.99173563) {
304
+		return 6;
305
+	}
306
+	if ($lat < 84.89166191) {
307
+		return 5;
308
+	}
309
+	if ($lat < 85.75541621) {
310
+		return 4;
311
+	}
312
+	if ($lat < 86.53536998) {
313
+		return 3;
314
+	}
315
+	if ($lat < 87.00000000) {
316
+		return 2;
317
+	}
178 318
 	return 1;
179 319
     }
180 320
     
181 321
     function cprN($lat,$isodd) {
182 322
 	$nl = $this->cprNL($lat) - $isodd;
183
-	if ($nl > 1) return $nl;
184
-	else return 1;
323
+	if ($nl > 1) {
324
+		return $nl;
325
+	} else {
326
+		return 1;
327
+	}
185 328
     }
186 329
 
187 330
 
@@ -207,10 +350,13 @@  discard block
 block discarded – undo
207 350
 	$checksum = intval(substr($msg,22,6),16);
208 351
 
209 352
 	for ($j = 0; $j < strlen($bin); $j++) {
210
-	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
353
+	    if ($bin[$j]) {
354
+	    	$crc = $crc^intval($modes_checksum_table[$j],0);
355
+	    }
211 356
 	}
212
-	if ($crc == $checksum) return true;
213
-	else {
357
+	if ($crc == $checksum) {
358
+		return true;
359
+	} else {
214 360
 	    //echo "**** CRC ERROR ****\n";
215 361
 	    return false;
216 362
 	}
Please login to merge, or discard this patch.
require/class.Spotter.php 4 patches
Doc Comments   +6 added lines, -16 removed lines patch added patch discarded remove patch
@@ -16,8 +16,6 @@  discard block
 block discarded – undo
16 16
 	* Executes the SQL statements to get the spotter information
17 17
 	*
18 18
 	* @param String $query the SQL query
19
-	* @param String $limit the limit query
20
-	* @return Array the spotter information
21 19
 	*
22 20
 	*/
23 21
 	public function getDataFromDB($query, $params = array(), $limitQuery = '')
@@ -1524,9 +1522,6 @@  discard block
 block discarded – undo
1524 1522
     /**
1525 1523
 	* Gets a list of all aircraft with a special highlight text
1526 1524
 	*
1527
-	* @param String $aircraft_registration the aircraft registration
1528
-	* @param String $airport_departure the departure airport
1529
-	* @return Array the spotter information
1530 1525
 	*
1531 1526
 	*/
1532 1527
 	public function getSpotterDataByRoute($departure_airport_icao = '', $arrival_airport_icao = '', $limit = '', $sort = '')
@@ -1751,7 +1746,7 @@  discard block
 block discarded – undo
1751 1746
 	/**
1752 1747
 	* Gets the airport info based on the icao
1753 1748
 	*
1754
-	* @param String $airport_iata the icao code of the airport
1749
+	* @param String $airport the icao code of the airport
1755 1750
 	* @return Array airport information
1756 1751
 	*
1757 1752
 	*/
@@ -2005,7 +2000,7 @@  discard block
 block discarded – undo
2005 2000
 	/**
2006 2001
 	* Gets the aircraft info based on the aircraft ident
2007 2002
 	*
2008
-	* @param String $aircraft_ident the aircraft ident (hex)
2003
+	* @param String $aircraft_modes the aircraft ident (hex)
2009 2004
 	* @return String aircraft type
2010 2005
 	*
2011 2006
 	*/
@@ -2070,7 +2065,7 @@  discard block
 block discarded – undo
2070 2065
 	/**
2071 2066
 	* Gets the aircraft info based on the aircraft registration
2072 2067
 	*
2073
-	* @param String $aircraft_registration the aircraft registration
2068
+	* @param string $registration the aircraft registration
2074 2069
 	* @return Array aircraft information
2075 2070
 	*
2076 2071
 	*/
@@ -2102,7 +2097,7 @@  discard block
 block discarded – undo
2102 2097
 	/**
2103 2098
 	* Gets the aircraft owner & base based on the aircraft registration
2104 2099
 	*
2105
-	* @param String $aircraft_registration the aircraft registration
2100
+	* @param String $registration the aircraft registration
2106 2101
 	* @return Array aircraft information
2107 2102
 	*
2108 2103
 	*/
@@ -2875,10 +2870,6 @@  discard block
 block discarded – undo
2875 2870
 	*
2876 2871
 	* @param String $flightaware_id the ID from flightaware
2877 2872
 	* @param String $ident the flight ident
2878
-	* @param String $aircraft_icao the aircraft type
2879
-	* @param String $departure_airport_icao the departure airport
2880
-	* @param String $arrival_airport_icao the arrival airport
2881
-	* @return String success or false
2882 2873
 	*
2883 2874
 	*/	
2884 2875
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
@@ -7531,6 +7522,7 @@  discard block
 block discarded – undo
7531 7522
 	/**
7532 7523
 	* Counts all hours
7533 7524
 	*
7525
+	* @param string $orderby
7534 7526
 	* @return Array the hour list
7535 7527
 	*
7536 7528
 	*/
@@ -8343,7 +8335,7 @@  discard block
 block discarded – undo
8343 8335
 	/**
8344 8336
 	* Parses the direction degrees to working
8345 8337
 	*
8346
-	* @param Float $direction the direction in degrees
8338
+	* @param integer $direction the direction in degrees
8347 8339
 	* @return Array the direction information
8348 8340
 	*
8349 8341
 	*/
@@ -8511,8 +8503,6 @@  discard block
 block discarded – undo
8511 8503
 	/**
8512 8504
 	* Gets Countrie from latitude/longitude
8513 8505
 	*
8514
-	* @param String $aircraft_modes the flight ModeS in hex
8515
-	* @return String the aircraft registration
8516 8506
 	*
8517 8507
 	*/
8518 8508
 	
Please login to merge, or discard this patch.
Indentation   +1277 added lines, -1277 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
 	}
14 14
 	
15 15
 	/**
16
-	* Executes the SQL statements to get the spotter information
17
-	*
18
-	* @param String $query the SQL query
19
-	* @param String $limit the limit query
20
-	* @return Array the spotter information
21
-	*
22
-	*/
16
+	 * Executes the SQL statements to get the spotter information
17
+	 *
18
+	 * @param String $query the SQL query
19
+	 * @param String $limit the limit query
20
+	 * @return Array the spotter information
21
+	 *
22
+	 */
23 23
 	public function getDataFromDB($query, $params = array(), $limitQuery = '')
24 24
 	{
25 25
 		global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS;
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
179 179
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
180 180
 					} else $temp_array['aircraft_shadow'] = 'default.png';
181
-                                } else {
182
-                            		$temp_array['aircraft_shadow'] = 'default.png';
181
+								} else {
182
+									$temp_array['aircraft_shadow'] = 'default.png';
183 183
 					$temp_array['aircraft_name'] = 'N/A';
184 184
 					$temp_array['aircraft_manufacturer'] = 'N/A';
185
-                            	}
185
+								}
186 186
 			}
187 187
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
188 188
 				$airline_array = array();
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
 	
361 361
 	
362 362
 	/**
363
-	* Gets all the spotter information
364
-	*
365
-	* @return Array the spotter information
366
-	*
367
-	*/
363
+	 * Gets all the spotter information
364
+	 *
365
+	 * @return Array the spotter information
366
+	 *
367
+	 */
368 368
 	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 = '')
369 369
 	{
370 370
 		global $globalTimezone, $globalDBdriver;
@@ -711,11 +711,11 @@  discard block
 block discarded – undo
711 711
 	
712 712
 	
713 713
 	/**
714
-	* Gets all the spotter information based on the latest data entry
715
-	*
716
-	* @return Array the spotter information
717
-	*
718
-	*/
714
+	 * Gets all the spotter information based on the latest data entry
715
+	 *
716
+	 * @return Array the spotter information
717
+	 *
718
+	 */
719 719
 	public function getLatestSpotterData($limit = '', $sort = '')
720 720
 	{
721 721
 		global $global_query;
@@ -752,12 +752,12 @@  discard block
 block discarded – undo
752 752
 	}
753 753
     
754 754
     
755
-    /**
756
-	* Gets all the spotter information based on a user's latitude and longitude
757
-	*
758
-	* @return Array the spotter information
759
-	*
760
-	*/
755
+	/**
756
+	 * Gets all the spotter information based on a user's latitude and longitude
757
+	 *
758
+	 * @return Array the spotter information
759
+	 *
760
+	 */
761 761
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
762 762
 	{
763 763
 		date_default_timezone_set('UTC');
@@ -825,12 +825,12 @@  discard block
 block discarded – undo
825 825
 	}
826 826
     
827 827
     
828
-    /**
829
-	* Gets all the spotter information sorted by the newest aircraft type
830
-	*
831
-	* @return Array the spotter information
832
-	*
833
-	*/
828
+	/**
829
+	 * Gets all the spotter information sorted by the newest aircraft type
830
+	 *
831
+	 * @return Array the spotter information
832
+	 *
833
+	 */
834 834
 	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '')
835 835
 	{
836 836
 		global $global_query;
@@ -867,12 +867,12 @@  discard block
 block discarded – undo
867 867
 	}
868 868
     
869 869
     
870
-    /**
871
-	* Gets all the spotter information sorted by the newest aircraft registration
872
-	*
873
-	* @return Array the spotter information
874
-	*
875
-	*/
870
+	/**
871
+	 * Gets all the spotter information sorted by the newest aircraft registration
872
+	 *
873
+	 * @return Array the spotter information
874
+	 *
875
+	 */
876 876
 	public function getNewestSpotterDataSortedByAircraftRegistration($limit = '', $sort = '')
877 877
 	{
878 878
 		global $global_query;
@@ -909,12 +909,12 @@  discard block
 block discarded – undo
909 909
 	}
910 910
     
911 911
     
912
-    /**
913
-	* Gets all the spotter information sorted by the newest airline
914
-	*
915
-	* @return Array the spotter information
916
-	*
917
-	*/
912
+	/**
913
+	 * Gets all the spotter information sorted by the newest airline
914
+	 *
915
+	 * @return Array the spotter information
916
+	 *
917
+	 */
918 918
 	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '')
919 919
 	{
920 920
 		global $global_query;
@@ -951,12 +951,12 @@  discard block
 block discarded – undo
951 951
 	}
952 952
     
953 953
     
954
-    /**
955
-	* Gets all the spotter information sorted by the newest departure airport
956
-	*
957
-	* @return Array the spotter information
958
-	*
959
-	*/
954
+	/**
955
+	 * Gets all the spotter information sorted by the newest departure airport
956
+	 *
957
+	 * @return Array the spotter information
958
+	 *
959
+	 */
960 960
 	public function getNewestSpotterDataSortedByDepartureAirport($limit = '', $sort = '')
961 961
 	{
962 962
 		global $global_query;
@@ -993,12 +993,12 @@  discard block
 block discarded – undo
993 993
 	}
994 994
     
995 995
     
996
-    /**
997
-	* Gets all the spotter information sorted by the newest arrival airport
998
-	*
999
-	* @return Array the spotter information
1000
-	*
1001
-	*/
996
+	/**
997
+	 * Gets all the spotter information sorted by the newest arrival airport
998
+	 *
999
+	 * @return Array the spotter information
1000
+	 *
1001
+	 */
1002 1002
 	public function getNewestSpotterDataSortedByArrivalAirport($limit = '', $sort = '')
1003 1003
 	{
1004 1004
 		global $global_query;
@@ -1036,11 +1036,11 @@  discard block
 block discarded – undo
1036 1036
 	
1037 1037
 
1038 1038
 	/**
1039
-	* Gets all the spotter information based on the spotter id
1040
-	*
1041
-	* @return Array the spotter information
1042
-	*
1043
-	*/
1039
+	 * Gets all the spotter information based on the spotter id
1040
+	 *
1041
+	 * @return Array the spotter information
1042
+	 *
1043
+	 */
1044 1044
 	public function getSpotterDataByID($id = '')
1045 1045
 	{
1046 1046
 		global $global_query;
@@ -1071,11 +1071,11 @@  discard block
 block discarded – undo
1071 1071
 	
1072 1072
 	
1073 1073
 	/**
1074
-	* Gets all the spotter information based on the callsign
1075
-	*
1076
-	* @return Array the spotter information
1077
-	*
1078
-	*/
1074
+	 * Gets all the spotter information based on the callsign
1075
+	 *
1076
+	 * @return Array the spotter information
1077
+	 *
1078
+	 */
1079 1079
 	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
1080 1080
 	{
1081 1081
 		global $global_query;
@@ -1127,11 +1127,11 @@  discard block
 block discarded – undo
1127 1127
 	
1128 1128
 	
1129 1129
 	/**
1130
-	* Gets all the spotter information based on the aircraft type
1131
-	*
1132
-	* @return Array the spotter information
1133
-	*
1134
-	*/
1130
+	 * Gets all the spotter information based on the aircraft type
1131
+	 *
1132
+	 * @return Array the spotter information
1133
+	 *
1134
+	 */
1135 1135
 	public function getSpotterDataByAircraft($aircraft_type = '', $limit = '', $sort = '')
1136 1136
 	{
1137 1137
 		global $global_query;
@@ -1182,11 +1182,11 @@  discard block
 block discarded – undo
1182 1182
 	
1183 1183
 	
1184 1184
 	/**
1185
-	* Gets all the spotter information based on the aircraft registration
1186
-	*
1187
-	* @return Array the spotter information
1188
-	*
1189
-	*/
1185
+	 * Gets all the spotter information based on the aircraft registration
1186
+	 *
1187
+	 * @return Array the spotter information
1188
+	 *
1189
+	 */
1190 1190
 	public function getSpotterDataByRegistration($registration = '', $limit = '', $sort = '')
1191 1191
 	{
1192 1192
 		global $global_query;
@@ -1239,11 +1239,11 @@  discard block
 block discarded – undo
1239 1239
 	
1240 1240
 	
1241 1241
 	/**
1242
-	* Gets all the spotter information based on the airline
1243
-	*
1244
-	* @return Array the spotter information
1245
-	*
1246
-	*/
1242
+	 * Gets all the spotter information based on the airline
1243
+	 *
1244
+	 * @return Array the spotter information
1245
+	 *
1246
+	 */
1247 1247
 	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '')
1248 1248
 	{
1249 1249
 		global $global_query;
@@ -1293,11 +1293,11 @@  discard block
 block discarded – undo
1293 1293
 	
1294 1294
 	
1295 1295
 	/**
1296
-	* Gets all the spotter information based on the airport
1297
-	*
1298
-	* @return Array the spotter information
1299
-	*
1300
-	*/
1296
+	 * Gets all the spotter information based on the airport
1297
+	 *
1298
+	 * @return Array the spotter information
1299
+	 *
1300
+	 */
1301 1301
 	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '')
1302 1302
 	{
1303 1303
 		global $global_query;
@@ -1349,11 +1349,11 @@  discard block
 block discarded – undo
1349 1349
 
1350 1350
 
1351 1351
 	/**
1352
-	* Gets all the spotter information based on the date
1353
-	*
1354
-	* @return Array the spotter information
1355
-	*
1356
-	*/
1352
+	 * Gets all the spotter information based on the date
1353
+	 *
1354
+	 * @return Array the spotter information
1355
+	 *
1356
+	 */
1357 1357
 	public function getSpotterDataByDate($date = '', $limit = '', $sort = '')
1358 1358
 	{
1359 1359
 		global $global_query, $globalTimezone, $globalDBdriver;
@@ -1408,11 +1408,11 @@  discard block
 block discarded – undo
1408 1408
 
1409 1409
 
1410 1410
 	/**
1411
-	* Gets all the spotter information based on the country name
1412
-	*
1413
-	* @return Array the spotter information
1414
-	*
1415
-	*/
1411
+	 * Gets all the spotter information based on the country name
1412
+	 *
1413
+	 * @return Array the spotter information
1414
+	 *
1415
+	 */
1416 1416
 	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '')
1417 1417
 	{
1418 1418
 		global $global_query;
@@ -1464,11 +1464,11 @@  discard block
 block discarded – undo
1464 1464
 	
1465 1465
 	
1466 1466
 	/**
1467
-	* Gets all the spotter information based on the manufacturer name
1468
-	*
1469
-	* @return Array the spotter information
1470
-	*
1471
-	*/
1467
+	 * Gets all the spotter information based on the manufacturer name
1468
+	 *
1469
+	 * @return Array the spotter information
1470
+	 *
1471
+	 */
1472 1472
 	public function getSpotterDataByManufacturer($aircraft_manufacturer = '', $limit = '', $sort = '')
1473 1473
 	{
1474 1474
 		global $global_query;
@@ -1521,14 +1521,14 @@  discard block
 block discarded – undo
1521 1521
 
1522 1522
   
1523 1523
   
1524
-    /**
1525
-	* Gets a list of all aircraft with a special highlight text
1526
-	*
1527
-	* @param String $aircraft_registration the aircraft registration
1528
-	* @param String $airport_departure the departure airport
1529
-	* @return Array the spotter information
1530
-	*
1531
-	*/
1524
+	/**
1525
+	 * Gets a list of all aircraft with a special highlight text
1526
+	 *
1527
+	 * @param String $aircraft_registration the aircraft registration
1528
+	 * @param String $airport_departure the departure airport
1529
+	 * @return Array the spotter information
1530
+	 *
1531
+	 */
1532 1532
 	public function getSpotterDataByRoute($departure_airport_icao = '', $arrival_airport_icao = '', $limit = '', $sort = '')
1533 1533
 	{
1534 1534
 		global $global_query;
@@ -1593,11 +1593,11 @@  discard block
 block discarded – undo
1593 1593
 	
1594 1594
 	
1595 1595
 	/**
1596
-	* Gets all the spotter information based on the special column in the table
1597
-	*
1598
-	* @return Array the spotter information
1599
-	*
1600
-	*/
1596
+	 * Gets all the spotter information based on the special column in the table
1597
+	 *
1598
+	 * @return Array the spotter information
1599
+	 *
1600
+	 */
1601 1601
 	public function getSpotterDataByHighlight($limit = '', $sort = '')
1602 1602
 	{
1603 1603
 		global $global_query;
@@ -1635,12 +1635,12 @@  discard block
 block discarded – undo
1635 1635
     
1636 1636
     
1637 1637
     
1638
-    /**
1639
-	* Gets all the highlight based on a aircraft registration
1640
-	*
1641
-	* @return String the highlight text
1642
-	*
1643
-	*/
1638
+	/**
1639
+	 * Gets all the highlight based on a aircraft registration
1640
+	 *
1641
+	 * @return String the highlight text
1642
+	 *
1643
+	 */
1644 1644
 	public function getHighlightByRegistration($registration)
1645 1645
 	{
1646 1646
 		global $global_query;
@@ -1663,13 +1663,13 @@  discard block
 block discarded – undo
1663 1663
 
1664 1664
 	
1665 1665
 	/**
1666
-	* Gets the squawk usage from squawk code
1667
-	*
1668
-	* @param String $squawk squawk code
1669
-	* @param String $country country
1670
-	* @return String usage
1671
-	*
1672
-	*/
1666
+	 * Gets the squawk usage from squawk code
1667
+	 *
1668
+	 * @param String $squawk squawk code
1669
+	 * @param String $country country
1670
+	 * @return String usage
1671
+	 *
1672
+	 */
1673 1673
 	public function getSquawkUsage($squawk = '',$country = 'FR')
1674 1674
 	{
1675 1675
 		
@@ -1693,12 +1693,12 @@  discard block
 block discarded – undo
1693 1693
 	}
1694 1694
 
1695 1695
 	/**
1696
-	* Gets the airport icao from the iata
1697
-	*
1698
-	* @param String $airport_iata the iata code of the airport
1699
-	* @return String airport iata
1700
-	*
1701
-	*/
1696
+	 * Gets the airport icao from the iata
1697
+	 *
1698
+	 * @param String $airport_iata the iata code of the airport
1699
+	 * @return String airport iata
1700
+	 *
1701
+	 */
1702 1702
 	public function getAirportIcao($airport_iata = '')
1703 1703
 	{
1704 1704
 		
@@ -1720,14 +1720,14 @@  discard block
 block discarded – undo
1720 1720
 	}
1721 1721
 
1722 1722
 	/**
1723
-	* Gets the airport distance
1724
-	*
1725
-	* @param String $airport_icao the icao code of the airport
1726
-	* @param Float $latitude the latitude
1727
-	* @param Float $longitude the longitude
1728
-	* @return Float distance to the airport
1729
-	*
1730
-	*/
1723
+	 * Gets the airport distance
1724
+	 *
1725
+	 * @param String $airport_icao the icao code of the airport
1726
+	 * @param Float $latitude the latitude
1727
+	 * @param Float $longitude the longitude
1728
+	 * @return Float distance to the airport
1729
+	 *
1730
+	 */
1731 1731
 	public function getAirportDistance($airport_icao,$latitude,$longitude)
1732 1732
 	{
1733 1733
 		
@@ -1749,12 +1749,12 @@  discard block
 block discarded – undo
1749 1749
 	}
1750 1750
 	
1751 1751
 	/**
1752
-	* Gets the airport info based on the icao
1753
-	*
1754
-	* @param String $airport_iata the icao code of the airport
1755
-	* @return Array airport information
1756
-	*
1757
-	*/
1752
+	 * Gets the airport info based on the icao
1753
+	 *
1754
+	 * @param String $airport_iata the icao code of the airport
1755
+	 * @return Array airport information
1756
+	 *
1757
+	 */
1758 1758
 	public function getAllAirportInfo($airport = '')
1759 1759
 	{
1760 1760
 		
@@ -1800,12 +1800,12 @@  discard block
 block discarded – undo
1800 1800
 	}
1801 1801
 	
1802 1802
 	/**
1803
-	* Gets the airport info based on the country
1804
-	*
1805
-	* @param Array $countries Airports countries
1806
-	* @return Array airport information
1807
-	*
1808
-	*/
1803
+	 * Gets the airport info based on the country
1804
+	 *
1805
+	 * @param Array $countries Airports countries
1806
+	 * @return Array airport information
1807
+	 *
1808
+	 */
1809 1809
 	public function getAllAirportInfobyCountry($countries)
1810 1810
 	{
1811 1811
 		$lst_countries = '';
@@ -1843,12 +1843,12 @@  discard block
 block discarded – undo
1843 1843
 	}
1844 1844
 	
1845 1845
 	/**
1846
-	* Gets airports info based on the coord
1847
-	*
1848
-	* @param Array $coord Airports longitude min,latitude min, longitude max, latitude max
1849
-	* @return Array airport information
1850
-	*
1851
-	*/
1846
+	 * Gets airports info based on the coord
1847
+	 *
1848
+	 * @param Array $coord Airports longitude min,latitude min, longitude max, latitude max
1849
+	 * @return Array airport information
1850
+	 *
1851
+	 */
1852 1852
 	public function getAllAirportInfobyCoord($coord)
1853 1853
 	{
1854 1854
 		global $globalDBdriver;
@@ -1881,12 +1881,12 @@  discard block
 block discarded – undo
1881 1881
 	}
1882 1882
 
1883 1883
 	/**
1884
-	* Gets waypoints info based on the coord
1885
-	*
1886
-	* @param Array $coord waypoints coord
1887
-	* @return Array airport information
1888
-	*
1889
-	*/
1884
+	 * Gets waypoints info based on the coord
1885
+	 *
1886
+	 * @param Array $coord waypoints coord
1887
+	 * @return Array airport information
1888
+	 *
1889
+	 */
1890 1890
 	public function getAllWaypointsInfobyCoord($coord)
1891 1891
 	{
1892 1892
 		$lst_countries = '';
@@ -1922,12 +1922,12 @@  discard block
 block discarded – undo
1922 1922
 	
1923 1923
 	
1924 1924
 	/**
1925
-	* Gets the airline info based on the icao code or iata code
1926
-	*
1927
-	* @param String $airline_icao the iata code of the airport
1928
-	* @return Array airport information
1929
-	*
1930
-	*/
1925
+	 * Gets the airline info based on the icao code or iata code
1926
+	 *
1927
+	 * @param String $airline_icao the iata code of the airport
1928
+	 * @return Array airport information
1929
+	 *
1930
+	 */
1931 1931
 	public function getAllAirlineInfo($airline_icao)
1932 1932
 	{
1933 1933
 		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
@@ -1943,7 +1943,7 @@  discard block
 block discarded – undo
1943 1943
 			
1944 1944
 			$sth = $this->db->prepare($query);
1945 1945
 			$sth->execute(array(':airline_icao' => $airline_icao));
1946
-                        /*
1946
+						/*
1947 1947
 			$airline_array = array();
1948 1948
 			$temp_array = array();
1949 1949
 		
@@ -1966,12 +1966,12 @@  discard block
 block discarded – undo
1966 1966
 	
1967 1967
 	
1968 1968
 	/**
1969
-	* Gets the aircraft info based on the aircraft type
1970
-	*
1971
-	* @param String $aircraft_type the aircraft type
1972
-	* @return Array aircraft information
1973
-	*
1974
-	*/
1969
+	 * Gets the aircraft info based on the aircraft type
1970
+	 *
1971
+	 * @param String $aircraft_type the aircraft type
1972
+	 * @return Array aircraft information
1973
+	 *
1974
+	 */
1975 1975
 	public function getAllAircraftInfo($aircraft_type)
1976 1976
 	{
1977 1977
 		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
@@ -2003,12 +2003,12 @@  discard block
 block discarded – undo
2003 2003
 	}
2004 2004
 	
2005 2005
 	/**
2006
-	* Gets the aircraft info based on the aircraft ident
2007
-	*
2008
-	* @param String $aircraft_ident the aircraft ident (hex)
2009
-	* @return String aircraft type
2010
-	*
2011
-	*/
2006
+	 * Gets the aircraft info based on the aircraft ident
2007
+	 *
2008
+	 * @param String $aircraft_ident the aircraft ident (hex)
2009
+	 * @return String aircraft type
2010
+	 *
2011
+	 */
2012 2012
 	public function getAllAircraftType($aircraft_modes)
2013 2013
 	{
2014 2014
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -2025,12 +2025,12 @@  discard block
 block discarded – undo
2025 2025
 	}
2026 2026
 
2027 2027
 	/**
2028
-	* Gets correct aircraft operator corde
2029
-	*
2030
-	* @param String $operator the aircraft operator code (callsign)
2031
-	* @return String aircraft operator code
2032
-	*
2033
-	*/
2028
+	 * Gets correct aircraft operator corde
2029
+	 *
2030
+	 * @param String $operator the aircraft operator code (callsign)
2031
+	 * @return String aircraft operator code
2032
+	 *
2033
+	 */
2034 2034
 	public function getOperator($operator)
2035 2035
 	{
2036 2036
 		$operator = filter_var($operator,FILTER_SANITIZE_STRING);
@@ -2046,16 +2046,16 @@  discard block
 block discarded – undo
2046 2046
 	}
2047 2047
 
2048 2048
 	/**
2049
-	* Gets the aircraft route based on the aircraft callsign
2050
-	*
2051
-	* @param String $callsign the aircraft callsign
2052
-	* @return Array aircraft type
2053
-	*
2054
-	*/
2049
+	 * Gets the aircraft route based on the aircraft callsign
2050
+	 *
2051
+	 * @param String $callsign the aircraft callsign
2052
+	 * @return Array aircraft type
2053
+	 *
2054
+	 */
2055 2055
 	public function getRouteInfo($callsign)
2056 2056
 	{
2057 2057
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2058
-                if ($callsign == '') return array();
2058
+				if ($callsign == '') return array();
2059 2059
 		$query  = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2060 2060
 		
2061 2061
 		$sth = $this->db->prepare($query);
@@ -2068,12 +2068,12 @@  discard block
 block discarded – undo
2068 2068
 	}
2069 2069
 	
2070 2070
 	/**
2071
-	* Gets the aircraft info based on the aircraft registration
2072
-	*
2073
-	* @param String $aircraft_registration the aircraft registration
2074
-	* @return Array aircraft information
2075
-	*
2076
-	*/
2071
+	 * Gets the aircraft info based on the aircraft registration
2072
+	 *
2073
+	 * @param String $aircraft_registration the aircraft registration
2074
+	 * @return Array aircraft information
2075
+	 *
2076
+	 */
2077 2077
 	public function getAircraftInfoByRegistration($registration)
2078 2078
 	{
2079 2079
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2100,12 +2100,12 @@  discard block
 block discarded – undo
2100 2100
 	}
2101 2101
 	
2102 2102
 	/**
2103
-	* Gets the aircraft owner & base based on the aircraft registration
2104
-	*
2105
-	* @param String $aircraft_registration the aircraft registration
2106
-	* @return Array aircraft information
2107
-	*
2108
-	*/
2103
+	 * Gets the aircraft owner & base based on the aircraft registration
2104
+	 *
2105
+	 * @param String $aircraft_registration the aircraft registration
2106
+	 * @return Array aircraft information
2107
+	 *
2108
+	 */
2109 2109
 	public function getAircraftOwnerByRegistration($registration)
2110 2110
 	{
2111 2111
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2121,11 +2121,11 @@  discard block
 block discarded – undo
2121 2121
 	
2122 2122
   
2123 2123
   /**
2124
-	* Gets all flights (but with only little info)
2125
-	*
2126
-	* @return Array basic flight information
2127
-	*
2128
-	*/
2124
+   * Gets all flights (but with only little info)
2125
+   *
2126
+   * @return Array basic flight information
2127
+   *
2128
+   */
2129 2129
 	public function getAllFlightsforSitemap()
2130 2130
 	{
2131 2131
 		//$query  = "SELECT spotter_output.spotter_id, spotter_output.ident, spotter_output.airline_name, spotter_output.aircraft_name, spotter_output.aircraft_icao FROM spotter_output ORDER BY LIMIT ";
@@ -2133,7 +2133,7 @@  discard block
 block discarded – undo
2133 2133
 		
2134 2134
 		$sth = $this->db->prepare($query);
2135 2135
 		$sth->execute();
2136
-                  /*
2136
+				  /*
2137 2137
 		$flight_array = array();
2138 2138
 		$temp_array = array();
2139 2139
 		
@@ -2155,11 +2155,11 @@  discard block
 block discarded – undo
2155 2155
 	}
2156 2156
   
2157 2157
 	/**
2158
-	* Gets a list of all aircraft manufacturers
2159
-	*
2160
-	* @return Array list of aircraft types
2161
-	*
2162
-	*/
2158
+	 * Gets a list of all aircraft manufacturers
2159
+	 *
2160
+	 * @return Array list of aircraft types
2161
+	 *
2162
+	 */
2163 2163
 	public function getAllManufacturers()
2164 2164
 	{
2165 2165
 		/*
@@ -2188,11 +2188,11 @@  discard block
 block discarded – undo
2188 2188
   
2189 2189
   
2190 2190
   /**
2191
-	* Gets a list of all aircraft types
2192
-	*
2193
-	* @return Array list of aircraft types
2194
-	*
2195
-	*/
2191
+   * Gets a list of all aircraft types
2192
+   *
2193
+   * @return Array list of aircraft types
2194
+   *
2195
+   */
2196 2196
 	public function getAllAircraftTypes()
2197 2197
 	{
2198 2198
 		/*
@@ -2224,11 +2224,11 @@  discard block
 block discarded – undo
2224 2224
 	
2225 2225
 	
2226 2226
 	/**
2227
-	* Gets a list of all aircraft registrations
2228
-	*
2229
-	* @return Array list of aircraft registrations
2230
-	*
2231
-	*/
2227
+	 * Gets a list of all aircraft registrations
2228
+	 *
2229
+	 * @return Array list of aircraft registrations
2230
+	 *
2231
+	 */
2232 2232
 	public function getAllAircraftRegistrations()
2233 2233
 	{
2234 2234
 		$query  = "SELECT DISTINCT spotter_output.registration 
@@ -2253,12 +2253,12 @@  discard block
 block discarded – undo
2253 2253
 	}
2254 2254
 
2255 2255
 	/**
2256
-	* Gets all source name
2257
-	*
2258
-	* @param String type format of source
2259
-	* @return Array list of source name
2260
-	*
2261
-	*/
2256
+	 * Gets all source name
2257
+	 *
2258
+	 * @param String type format of source
2259
+	 * @return Array list of source name
2260
+	 *
2261
+	 */
2262 2262
 	public function getAllSourceName($type = '')
2263 2263
 	{
2264 2264
 		$query_values = array();
@@ -2289,11 +2289,11 @@  discard block
 block discarded – undo
2289 2289
 
2290 2290
 
2291 2291
 	/**
2292
-	* Gets a list of all airline names
2293
-	*
2294
-	* @return Array list of airline names
2295
-	*
2296
-	*/
2292
+	 * Gets a list of all airline names
2293
+	 *
2294
+	 * @return Array list of airline names
2295
+	 *
2296
+	 */
2297 2297
 	public function getAllAirlineNames($airline_type = '')
2298 2298
 	{
2299 2299
 		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
@@ -2336,11 +2336,11 @@  discard block
 block discarded – undo
2336 2336
 	
2337 2337
 	
2338 2338
 	/**
2339
-	* Gets a list of all airline countries
2340
-	*
2341
-	* @return Array list of airline countries
2342
-	*
2343
-	*/
2339
+	 * Gets a list of all airline countries
2340
+	 *
2341
+	 * @return Array list of airline countries
2342
+	 *
2343
+	 */
2344 2344
 	public function getAllAirlineCountries()
2345 2345
 	{
2346 2346
 		
@@ -2369,11 +2369,11 @@  discard block
 block discarded – undo
2369 2369
 	
2370 2370
 	
2371 2371
 	/**
2372
-	* Gets a list of all departure & arrival names
2373
-	*
2374
-	* @return Array list of airport names
2375
-	*
2376
-	*/
2372
+	 * Gets a list of all departure & arrival names
2373
+	 *
2374
+	 * @return Array list of airport names
2375
+	 *
2376
+	 */
2377 2377
 	public function getAllAirportNames()
2378 2378
 	{
2379 2379
 		$airport_array = array();
@@ -2424,11 +2424,11 @@  discard block
 block discarded – undo
2424 2424
 	
2425 2425
 	
2426 2426
 	/**
2427
-	* Gets a list of all departure & arrival airport countries
2428
-	*
2429
-	* @return Array list of airport countries
2430
-	*
2431
-	*/
2427
+	 * Gets a list of all departure & arrival airport countries
2428
+	 *
2429
+	 * @return Array list of airport countries
2430
+	 *
2431
+	 */
2432 2432
 	public function getAllAirportCountries()
2433 2433
 	{
2434 2434
 		$airport_array = array();
@@ -2478,11 +2478,11 @@  discard block
 block discarded – undo
2478 2478
 	
2479 2479
 	
2480 2480
 	/**
2481
-	* Gets a list of all countries (airline, departure airport & arrival airport)
2482
-	*
2483
-	* @return Array list of countries
2484
-	*
2485
-	*/
2481
+	 * Gets a list of all countries (airline, departure airport & arrival airport)
2482
+	 *
2483
+	 * @return Array list of countries
2484
+	 *
2485
+	 */
2486 2486
 	public function getAllCountries()
2487 2487
 	{
2488 2488
 		$Connection= new Connection($this->db);
@@ -2566,11 +2566,11 @@  discard block
 block discarded – undo
2566 2566
 	
2567 2567
 	
2568 2568
 	/**
2569
-	* Gets a list of all idents/callsigns
2570
-	*
2571
-	* @return Array list of ident/callsign names
2572
-	*
2573
-	*/
2569
+	 * Gets a list of all idents/callsigns
2570
+	 *
2571
+	 * @return Array list of ident/callsign names
2572
+	 *
2573
+	 */
2574 2574
 	public function getAllIdents()
2575 2575
 	{
2576 2576
 		$query  = "SELECT DISTINCT spotter_output.ident
@@ -2594,9 +2594,9 @@  discard block
 block discarded – undo
2594 2594
 	}
2595 2595
 
2596 2596
 	/**
2597
-	* Get a list of flights from airport since 7 days
2598
-	* @return Array number, icao, name and city of airports
2599
-	*/
2597
+	 * Get a list of flights from airport since 7 days
2598
+	 * @return Array number, icao, name and city of airports
2599
+	 */
2600 2600
 
2601 2601
 	public function getLast7DaysAirportsDeparture($airport_icao = '') {
2602 2602
 		global $globalTimezone, $globalDBdriver;
@@ -2626,9 +2626,9 @@  discard block
 block discarded – undo
2626 2626
 	}
2627 2627
 
2628 2628
 	/**
2629
-	* Get a list of flights from detected airport since 7 days
2630
-	* @return Array number, icao, name and city of airports
2631
-	*/
2629
+	 * Get a list of flights from detected airport since 7 days
2630
+	 * @return Array number, icao, name and city of airports
2631
+	 */
2632 2632
 
2633 2633
 	public function getLast7DaysDetectedAirportsDeparture($airport_icao = '') {
2634 2634
 		global $globalTimezone, $globalDBdriver;
@@ -2669,9 +2669,9 @@  discard block
 block discarded – undo
2669 2669
 	}
2670 2670
 
2671 2671
 	/**
2672
-	* Get a list of flights to airport since 7 days
2673
-	* @return Array number, icao, name and city of airports
2674
-	*/
2672
+	 * Get a list of flights to airport since 7 days
2673
+	 * @return Array number, icao, name and city of airports
2674
+	 */
2675 2675
 
2676 2676
 	public function getLast7DaysAirportsArrival($airport_icao = '') {
2677 2677
 		global $globalTimezone, $globalDBdriver;
@@ -2703,9 +2703,9 @@  discard block
 block discarded – undo
2703 2703
 
2704 2704
 
2705 2705
 	/**
2706
-	* Get a list of flights detected to airport since 7 days
2707
-	* @return Array number, icao, name and city of airports
2708
-	*/
2706
+	 * Get a list of flights detected to airport since 7 days
2707
+	 * @return Array number, icao, name and city of airports
2708
+	 */
2709 2709
 
2710 2710
 	public function getLast7DaysDetectedAirportsArrival($airport_icao = '') {
2711 2711
 		global $globalTimezone, $globalDBdriver;
@@ -2749,11 +2749,11 @@  discard block
 block discarded – undo
2749 2749
 
2750 2750
 
2751 2751
 	/**
2752
-	* Gets a list of all dates
2753
-	*
2754
-	* @return Array list of date names
2755
-	*
2756
-	*/
2752
+	 * Gets a list of all dates
2753
+	 *
2754
+	 * @return Array list of date names
2755
+	 *
2756
+	 */
2757 2757
 	public function getAllDates()
2758 2758
 	{
2759 2759
 		global $globalTimezone, $globalDBdriver;
@@ -2794,11 +2794,11 @@  discard block
 block discarded – undo
2794 2794
 	
2795 2795
 	
2796 2796
 	/**
2797
-	* Gets all route combinations
2798
-	*
2799
-	* @return Array the route list
2800
-	*
2801
-	*/
2797
+	 * Gets all route combinations
2798
+	 *
2799
+	 * @return Array the route list
2800
+	 *
2801
+	 */
2802 2802
 	public function getAllRoutes()
2803 2803
 	{
2804 2804
 		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route,  spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao 
@@ -2824,13 +2824,13 @@  discard block
 block discarded – undo
2824 2824
 	}
2825 2825
 
2826 2826
 	/**
2827
-	* Update ident spotter data
2828
-	*
2829
-	* @param String $flightaware_id the ID from flightaware
2830
-	* @param String $ident the flight ident
2831
-	* @return String success or false
2832
-	*
2833
-	*/	
2827
+	 * Update ident spotter data
2828
+	 *
2829
+	 * @param String $flightaware_id the ID from flightaware
2830
+	 * @param String $ident the flight ident
2831
+	 * @return String success or false
2832
+	 *
2833
+	 */	
2834 2834
 	public function updateIdentSpotterData($flightaware_id = '', $ident = '')
2835 2835
 	{
2836 2836
 		if (!is_numeric(substr($ident, 0, 3)))
@@ -2851,14 +2851,14 @@  discard block
 block discarded – undo
2851 2851
 		} else {
2852 2852
 			$airline_array = $this->getAllAirlineInfo("NA");
2853 2853
 		}
2854
-                $airline_name = $airline_array[0]['name'];
2855
-                $airline_icao = $airline_array[0]['icao'];
2856
-                $airline_country = $airline_array[0]['country'];
2857
-                $airline_type = $airline_array[0]['type'];
2854
+				$airline_name = $airline_array[0]['name'];
2855
+				$airline_icao = $airline_array[0]['icao'];
2856
+				$airline_country = $airline_array[0]['country'];
2857
+				$airline_type = $airline_array[0]['type'];
2858 2858
 
2859 2859
 
2860 2860
 		$query = 'UPDATE spotter_output SET ident = :ident, airline_name = :airline_name, airline_icao = :airline_icao, airline_country = :airline_country, airline_type = :airline_type WHERE flightaware_id = :flightaware_id';
2861
-                $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type);
2861
+				$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type);
2862 2862
 
2863 2863
 		try {
2864 2864
 			$sth = $this->db->prepare($query);
@@ -2871,21 +2871,21 @@  discard block
 block discarded – undo
2871 2871
 
2872 2872
 	}
2873 2873
 	/**
2874
-	* Update latest spotter data
2875
-	*
2876
-	* @param String $flightaware_id the ID from flightaware
2877
-	* @param String $ident the flight ident
2878
-	* @param String $aircraft_icao the aircraft type
2879
-	* @param String $departure_airport_icao the departure airport
2880
-	* @param String $arrival_airport_icao the arrival airport
2881
-	* @return String success or false
2882
-	*
2883
-	*/	
2874
+	 * Update latest spotter data
2875
+	 *
2876
+	 * @param String $flightaware_id the ID from flightaware
2877
+	 * @param String $ident the flight ident
2878
+	 * @param String $aircraft_icao the aircraft type
2879
+	 * @param String $departure_airport_icao the departure airport
2880
+	 * @param String $arrival_airport_icao the arrival airport
2881
+	 * @return String success or false
2882
+	 *
2883
+	 */	
2884 2884
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
2885 2885
 	{
2886 2886
 		if ($groundspeed == '') $groundspeed = NULL;
2887 2887
 		$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id';
2888
-                $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
2888
+				$query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
2889 2889
 
2890 2890
 		try {
2891 2891
 			$sth = $this->db->prepare($query);
@@ -2899,16 +2899,16 @@  discard block
 block discarded – undo
2899 2899
 	}
2900 2900
 
2901 2901
 	/**
2902
-	* Adds a new spotter data
2903
-	*
2904
-	* @param String $flightaware_id the ID from flightaware
2905
-	* @param String $ident the flight ident
2906
-	* @param String $aircraft_icao the aircraft type
2907
-	* @param String $departure_airport_icao the departure airport
2908
-	* @param String $arrival_airport_icao the arrival airport
2909
-	* @return String success or false
2910
-	*
2911
-	*/
2902
+	 * Adds a new spotter data
2903
+	 *
2904
+	 * @param String $flightaware_id the ID from flightaware
2905
+	 * @param String $ident the flight ident
2906
+	 * @param String $aircraft_icao the aircraft type
2907
+	 * @param String $departure_airport_icao the departure airport
2908
+	 * @param String $arrival_airport_icao the arrival airport
2909
+	 * @return String success or false
2910
+	 *
2911
+	 */
2912 2912
 	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '',$squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false,$format_source = '', $source_name = '')
2913 2913
 	{
2914 2914
 		global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed;
@@ -3113,8 +3113,8 @@  discard block
 block discarded – undo
3113 3113
     
3114 3114
 		if ($globalIVAO && $aircraft_icao != '')
3115 3115
 		{
3116
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3117
-            		else $airline_icao = '';
3116
+					if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3117
+					else $airline_icao = '';
3118 3118
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3119 3119
 			if (!isset($image_array[0]['registration']))
3120 3120
 			{
@@ -3145,49 +3145,49 @@  discard block
 block discarded – undo
3145 3145
 	
3146 3146
 		if (count($airline_array) == 0) 
3147 3147
 		{
3148
-                        $airline_array = $this->getAllAirlineInfo('NA');
3149
-                }
3150
-                if (count($aircraft_array) == 0) 
3151
-                {
3152
-                        $aircraft_array = $this->getAllAircraftInfo('NA');
3153
-                }
3154
-                if (count($departure_airport_array) == 0) 
3155
-                {
3156
-                        $departure_airport_array = $this->getAllAirportInfo('NA');
3157
-                }
3158
-                if (count($arrival_airport_array) == 0) 
3159
-                {
3160
-                        $arrival_airport_array = $this->getAllAirportInfo('NA');
3161
-                }
3162
-                if ($registration == '') $registration = 'NA';
3163
-                if ($squawk == '' || $Common->isInteger($squawk) == false) $squawk = NULL;
3164
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) == false) $verticalrate = NULL;
3165
-                if ($heading == '' || $Common->isInteger($heading) == false) $heading = 0;
3166
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) == false) $groundspeed = 0;
3167
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3168
-                $query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3148
+						$airline_array = $this->getAllAirlineInfo('NA');
3149
+				}
3150
+				if (count($aircraft_array) == 0) 
3151
+				{
3152
+						$aircraft_array = $this->getAllAircraftInfo('NA');
3153
+				}
3154
+				if (count($departure_airport_array) == 0) 
3155
+				{
3156
+						$departure_airport_array = $this->getAllAirportInfo('NA');
3157
+				}
3158
+				if (count($arrival_airport_array) == 0) 
3159
+				{
3160
+						$arrival_airport_array = $this->getAllAirportInfo('NA');
3161
+				}
3162
+				if ($registration == '') $registration = 'NA';
3163
+				if ($squawk == '' || $Common->isInteger($squawk) == false) $squawk = NULL;
3164
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) == false) $verticalrate = NULL;
3165
+				if ($heading == '' || $Common->isInteger($heading) == false) $heading = 0;
3166
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) == false) $groundspeed = 0;
3167
+				if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3168
+				$query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3169 3169
                 VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)";
3170 3170
 
3171
-                $airline_name = $airline_array[0]['name'];
3172
-                $airline_icao = $airline_array[0]['icao'];
3173
-                $airline_country = $airline_array[0]['country'];
3174
-                $airline_type = $airline_array[0]['type'];
3171
+				$airline_name = $airline_array[0]['name'];
3172
+				$airline_icao = $airline_array[0]['icao'];
3173
+				$airline_country = $airline_array[0]['country'];
3174
+				$airline_type = $airline_array[0]['type'];
3175 3175
 		if ($airline_type == '') {
3176 3176
 			$timeelapsed = microtime(true);
3177 3177
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3178 3178
 			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3179 3179
 		}
3180 3180
 		if ($airline_type == null) $airline_type = '';
3181
-                $aircraft_type = $aircraft_array[0]['type'];
3182
-                $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3183
-                $departure_airport_name = $departure_airport_array[0]['name'];
3184
-                $departure_airport_city = $departure_airport_array[0]['city'];
3185
-                $departure_airport_country = $departure_airport_array[0]['country'];
3186
-                $arrival_airport_icao = $arrival_airport_icao;
3187
-                $arrival_airport_name = $arrival_airport_array[0]['name'];
3188
-                $arrival_airport_city = $arrival_airport_array[0]['city'];
3189
-                $arrival_airport_country = $arrival_airport_array[0]['country'];
3190
-                $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date,':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name);
3181
+				$aircraft_type = $aircraft_array[0]['type'];
3182
+				$aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3183
+				$departure_airport_name = $departure_airport_array[0]['name'];
3184
+				$departure_airport_city = $departure_airport_array[0]['city'];
3185
+				$departure_airport_country = $departure_airport_array[0]['country'];
3186
+				$arrival_airport_icao = $arrival_airport_icao;
3187
+				$arrival_airport_name = $arrival_airport_array[0]['name'];
3188
+				$arrival_airport_city = $arrival_airport_array[0]['city'];
3189
+				$arrival_airport_country = $arrival_airport_array[0]['country'];
3190
+				$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date,':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name);
3191 3191
 
3192 3192
 		try {
3193 3193
 		        
@@ -3195,7 +3195,7 @@  discard block
 block discarded – undo
3195 3195
 			$sth->execute($query_values);
3196 3196
 			$this->db = null;
3197 3197
 		} catch (PDOException $e) {
3198
-		    return "error : ".$e->getMessage();
3198
+			return "error : ".$e->getMessage();
3199 3199
 		}
3200 3200
 		
3201 3201
 		return "success";
@@ -3204,11 +3204,11 @@  discard block
 block discarded – undo
3204 3204
 	
3205 3205
   
3206 3206
   /**
3207
-	* Gets the aircraft ident within the last hour
3208
-	*
3209
-	* @return String the ident
3210
-	*
3211
-	*/
3207
+   * Gets the aircraft ident within the last hour
3208
+   *
3209
+   * @return String the ident
3210
+   *
3211
+   */
3212 3212
 	public function getIdentFromLastHour($ident)
3213 3213
 	{
3214 3214
 		global $globalDBdriver, $globalTimezone;
@@ -3224,11 +3224,11 @@  discard block
 block discarded – undo
3224 3224
 								AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
3225 3225
 								AND spotter_output.date < now() AT TIME ZONE 'UTC'";
3226 3226
 			$query_data = array(':ident' => $ident);
3227
-    		}
3227
+			}
3228 3228
 		
3229 3229
 		$sth = $this->db->prepare($query);
3230 3230
 		$sth->execute($query_data);
3231
-    		$ident_result='';
3231
+			$ident_result='';
3232 3232
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3233 3233
 		{
3234 3234
 			$ident_result = $row['ident'];
@@ -3239,11 +3239,11 @@  discard block
 block discarded – undo
3239 3239
 	
3240 3240
 	
3241 3241
 	/**
3242
-	* Gets the aircraft data from the last 20 seconds
3243
-	*
3244
-	* @return Array the spotter data
3245
-	*
3246
-	*/
3242
+	 * Gets the aircraft data from the last 20 seconds
3243
+	 *
3244
+	 * @return Array the spotter data
3245
+	 *
3246
+	 */
3247 3247
 	public function getRealTimeData($q = '')
3248 3248
 	{
3249 3249
 		global $globalDBdriver;
@@ -3287,75 +3287,75 @@  discard block
 block discarded – undo
3287 3287
 	
3288 3288
 	
3289 3289
 	 /**
3290
-	* Gets all airlines that have flown over
3291
-	*
3292
-	* @return Array the airline list
3293
-	*
3294
-	*/
3290
+	  * Gets all airlines that have flown over
3291
+	  *
3292
+	  * @return Array the airline list
3293
+	  *
3294
+	  */
3295 3295
 	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
3296 3296
 	{
3297 3297
 		global $globalDBdriver;
3298 3298
 		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3299 3299
 		 			FROM spotter_output
3300 3300
 					WHERE spotter_output.airline_name <> '' AND spotter_output.airline_icao <> 'NA' ";
3301
-                if ($olderthanmonths > 0) {
3302
-            		if ($globalDBdriver == 'mysql') {
3301
+				if ($olderthanmonths > 0) {
3302
+					if ($globalDBdriver == 'mysql') {
3303 3303
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
3304 3304
 			} else {
3305 3305
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
3306 3306
 			}
3307 3307
 		}
3308
-                if ($sincedate != '') {
3309
-            		if ($globalDBdriver == 'mysql') {
3308
+				if ($sincedate != '') {
3309
+					if ($globalDBdriver == 'mysql') {
3310 3310
 				$query .= "AND date > '".$sincedate."' ";
3311 3311
 			} else {
3312 3312
 				$query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP)";
3313 3313
 			}
3314 3314
 		}
3315
-        	$query .= "GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
3315
+			$query .= "GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
3316 3316
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3317 3317
       
3318 3318
 		
3319 3319
 		$sth = $this->db->prepare($query);
3320 3320
 		$sth->execute();
3321 3321
       
3322
-        $airline_array = array();
3322
+		$airline_array = array();
3323 3323
 		$temp_array = array();
3324 3324
         
3325 3325
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3326 3326
 		{
3327 3327
 			$temp_array['airline_name'] = $row['airline_name'];
3328
-            $temp_array['airline_icao'] = $row['airline_icao'];
3329
-            $temp_array['airline_count'] = $row['airline_count'];
3330
-            $temp_array['airline_country'] = $row['airline_country'];
3328
+			$temp_array['airline_icao'] = $row['airline_icao'];
3329
+			$temp_array['airline_count'] = $row['airline_count'];
3330
+			$temp_array['airline_country'] = $row['airline_country'];
3331 3331
           
3332
-            $airline_array[] = $temp_array;
3332
+			$airline_array[] = $temp_array;
3333 3333
 		}
3334 3334
 
3335 3335
 		return $airline_array;
3336 3336
 	}
3337 3337
 
3338 3338
 	 /**
3339
-	* Gets all pilots that have flown over
3340
-	*
3341
-	* @return Array the pilots list
3342
-	*
3343
-	*/
3339
+	  * Gets all pilots that have flown over
3340
+	  *
3341
+	  * @return Array the pilots list
3342
+	  *
3343
+	  */
3344 3344
 	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '')
3345 3345
 	{
3346 3346
 		global $globalDBdriver;
3347 3347
 		$query  = "SELECT DISTINCT spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3348 3348
 		 			FROM spotter_output
3349 3349
 					WHERE spotter_output.pilot_id <> '' ";
3350
-                if ($olderthanmonths > 0) {
3351
-            		if ($globalDBdriver == 'mysql') {
3350
+				if ($olderthanmonths > 0) {
3351
+					if ($globalDBdriver == 'mysql') {
3352 3352
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
3353 3353
 			} else {
3354 3354
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
3355 3355
 			}
3356 3356
 		}
3357
-                if ($sincedate != '') {
3358
-            		if ($globalDBdriver == 'mysql') {
3357
+				if ($sincedate != '') {
3358
+					if ($globalDBdriver == 'mysql') {
3359 3359
 				$query .= "AND date > '".$sincedate."' ";
3360 3360
 			} else {
3361 3361
 				$query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -3382,11 +3382,11 @@  discard block
 block discarded – undo
3382 3382
 	}
3383 3383
 	
3384 3384
 	 /**
3385
-	* Gets all owner that have flown over
3386
-	*
3387
-	* @return Array the pilots list
3388
-	*
3389
-	*/
3385
+	  * Gets all owner that have flown over
3386
+	  *
3387
+	  * @return Array the pilots list
3388
+	  *
3389
+	  */
3390 3390
 	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '')
3391 3391
 	{
3392 3392
 		global $globalDBdriver;
@@ -3414,11 +3414,11 @@  discard block
 block discarded – undo
3414 3414
 	
3415 3415
 	
3416 3416
 	/**
3417
-	* Gets all airlines that have flown over by aircraft
3418
-	*
3419
-	* @return Array the airline list
3420
-	*
3421
-	*/
3417
+	 * Gets all airlines that have flown over by aircraft
3418
+	 *
3419
+	 * @return Array the airline list
3420
+	 *
3421
+	 */
3422 3422
 	public function countAllAirlinesByAircraft($aircraft_icao)
3423 3423
 	{
3424 3424
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -3451,11 +3451,11 @@  discard block
 block discarded – undo
3451 3451
 
3452 3452
 
3453 3453
 	/**
3454
-	* Gets all airline countries that have flown over by aircraft
3455
-	*
3456
-	* @return Array the airline country list
3457
-	*
3458
-	*/
3454
+	 * Gets all airline countries that have flown over by aircraft
3455
+	 *
3456
+	 * @return Array the airline country list
3457
+	 *
3458
+	 */
3459 3459
 	public function countAllAirlineCountriesByAircraft($aircraft_icao)
3460 3460
 	{
3461 3461
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -3488,11 +3488,11 @@  discard block
 block discarded – undo
3488 3488
 	
3489 3489
 	
3490 3490
 	/**
3491
-	* Gets all airlines that have flown over by airport
3492
-	*
3493
-	* @return Array the airline list
3494
-	*
3495
-	*/
3491
+	 * Gets all airlines that have flown over by airport
3492
+	 *
3493
+	 * @return Array the airline list
3494
+	 *
3495
+	 */
3496 3496
 	public function countAllAirlinesByAirport($airport_icao)
3497 3497
 	{
3498 3498
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -3524,11 +3524,11 @@  discard block
 block discarded – undo
3524 3524
 
3525 3525
 
3526 3526
 	/**
3527
-	* Gets all airline countries that have flown over by airport icao
3528
-	*
3529
-	* @return Array the airline country list
3530
-	*
3531
-	*/
3527
+	 * Gets all airline countries that have flown over by airport icao
3528
+	 *
3529
+	 * @return Array the airline country list
3530
+	 *
3531
+	 */
3532 3532
 	public function countAllAirlineCountriesByAirport($airport_icao)
3533 3533
 	{
3534 3534
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -3559,11 +3559,11 @@  discard block
 block discarded – undo
3559 3559
 
3560 3560
 
3561 3561
 	/**
3562
-	* Gets all airlines that have flown over by aircraft manufacturer
3563
-	*
3564
-	* @return Array the airline list
3565
-	*
3566
-	*/
3562
+	 * Gets all airlines that have flown over by aircraft manufacturer
3563
+	 *
3564
+	 * @return Array the airline list
3565
+	 *
3566
+	 */
3567 3567
 	public function countAllAirlinesByManufacturer($aircraft_manufacturer)
3568 3568
 	{
3569 3569
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -3595,11 +3595,11 @@  discard block
 block discarded – undo
3595 3595
 
3596 3596
 
3597 3597
 	/**
3598
-	* Gets all airline countries that have flown over by aircraft manufacturer
3599
-	*
3600
-	* @return Array the airline country list
3601
-	*
3602
-	*/
3598
+	 * Gets all airline countries that have flown over by aircraft manufacturer
3599
+	 *
3600
+	 * @return Array the airline country list
3601
+	 *
3602
+	 */
3603 3603
 	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer)
3604 3604
 	{
3605 3605
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -3629,11 +3629,11 @@  discard block
 block discarded – undo
3629 3629
 
3630 3630
 
3631 3631
 	/**
3632
-	* Gets all airlines that have flown over by date
3633
-	*
3634
-	* @return Array the airline list
3635
-	*
3636
-	*/
3632
+	 * Gets all airlines that have flown over by date
3633
+	 *
3634
+	 * @return Array the airline list
3635
+	 *
3636
+	 */
3637 3637
 	public function countAllAirlinesByDate($date)
3638 3638
 	{
3639 3639
 		global $globalTimezone, $globalDBdriver;
@@ -3679,11 +3679,11 @@  discard block
 block discarded – undo
3679 3679
 	
3680 3680
 	
3681 3681
 	/**
3682
-	* Gets all airline countries that have flown over by date
3683
-	*
3684
-	* @return Array the airline country list
3685
-	*
3686
-	*/
3682
+	 * Gets all airline countries that have flown over by date
3683
+	 *
3684
+	 * @return Array the airline country list
3685
+	 *
3686
+	 */
3687 3687
 	public function countAllAirlineCountriesByDate($date)
3688 3688
 	{
3689 3689
 		global $globalTimezone, $globalDBdriver;
@@ -3727,11 +3727,11 @@  discard block
 block discarded – undo
3727 3727
 
3728 3728
 
3729 3729
 	/**
3730
-	* Gets all airlines that have flown over by ident/callsign
3731
-	*
3732
-	* @return Array the airline list
3733
-	*
3734
-	*/
3730
+	 * Gets all airlines that have flown over by ident/callsign
3731
+	 *
3732
+	 * @return Array the airline list
3733
+	 *
3734
+	 */
3735 3735
 	public function countAllAirlinesByIdent($ident)
3736 3736
 	{
3737 3737
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -3762,11 +3762,11 @@  discard block
 block discarded – undo
3762 3762
 	}
3763 3763
 
3764 3764
 	/**
3765
-	* Gets all airlines that have flown over by route
3766
-	*
3767
-	* @return Array the airline list
3768
-	*
3769
-	*/
3765
+	 * Gets all airlines that have flown over by route
3766
+	 *
3767
+	 * @return Array the airline list
3768
+	 *
3769
+	 */
3770 3770
 	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao)
3771 3771
 	{
3772 3772
 		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
@@ -3798,11 +3798,11 @@  discard block
 block discarded – undo
3798 3798
 	}
3799 3799
 
3800 3800
 	/**
3801
-	* Gets all airline countries that have flown over by route
3802
-	*
3803
-	* @return Array the airline country list
3804
-	*
3805
-	*/
3801
+	 * Gets all airline countries that have flown over by route
3802
+	 *
3803
+	 * @return Array the airline country list
3804
+	 *
3805
+	 */
3806 3806
 	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao)
3807 3807
 	{
3808 3808
 		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
@@ -3834,11 +3834,11 @@  discard block
 block discarded – undo
3834 3834
 
3835 3835
 
3836 3836
 	/**
3837
-	* Gets all airlines that have flown over by country
3838
-	*
3839
-	* @return Array the airline list
3840
-	*
3841
-	*/
3837
+	 * Gets all airlines that have flown over by country
3838
+	 *
3839
+	 * @return Array the airline list
3840
+	 *
3841
+	 */
3842 3842
 	public function countAllAirlinesByCountry($country)
3843 3843
 	{
3844 3844
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -3869,11 +3869,11 @@  discard block
 block discarded – undo
3869 3869
 
3870 3870
 
3871 3871
 	/**
3872
-	* Gets all airline countries that have flown over by country
3873
-	*
3874
-	* @return Array the airline country list
3875
-	*
3876
-	*/
3872
+	 * Gets all airline countries that have flown over by country
3873
+	 *
3874
+	 * @return Array the airline country list
3875
+	 *
3876
+	 */
3877 3877
 	public function countAllAirlineCountriesByCountry($country)
3878 3878
 	{
3879 3879
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -3903,11 +3903,11 @@  discard block
 block discarded – undo
3903 3903
 
3904 3904
 
3905 3905
 	/**
3906
-	* Gets all airlines countries
3907
-	*
3908
-	* @return Array the airline country list
3909
-	*
3910
-	*/
3906
+	 * Gets all airlines countries
3907
+	 *
3908
+	 * @return Array the airline country list
3909
+	 *
3910
+	 */
3911 3911
 	public function countAllAirlineCountries($limit = true)
3912 3912
 	{
3913 3913
 		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
@@ -3933,11 +3933,11 @@  discard block
 block discarded – undo
3933 3933
 	}
3934 3934
 
3935 3935
 	/**
3936
-	* Gets all number of flight over countries
3937
-	*
3938
-	* @return Array the airline country list
3939
-	*
3940
-	*/
3936
+	 * Gets all number of flight over countries
3937
+	 *
3938
+	 * @return Array the airline country list
3939
+	 *
3940
+	 */
3941 3941
 	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
3942 3942
 	{
3943 3943
 		global $globalDBdriver;
@@ -3949,14 +3949,14 @@  discard block
 block discarded – undo
3949 3949
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
3950 3950
 					FROM countries c, spotter_live s
3951 3951
 					WHERE c.iso2 = s.over_country ";
3952
-                if ($olderthanmonths > 0) {
3952
+				if ($olderthanmonths > 0) {
3953 3953
 			if ($globalDBdriver == 'mysql') {
3954 3954
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
3955 3955
 			} else {
3956 3956
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
3957 3957
 			}
3958 3958
 		}
3959
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
3959
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
3960 3960
 		$query .= "GROUP BY c.name ORDER BY nb DESC";
3961 3961
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3962 3962
       
@@ -3980,35 +3980,35 @@  discard block
 block discarded – undo
3980 3980
 	
3981 3981
 	
3982 3982
 	/**
3983
-	* Gets all aircraft types that have flown over
3984
-	*
3985
-	* @return Array the aircraft list
3986
-	*
3987
-	*/
3983
+	 * Gets all aircraft types that have flown over
3984
+	 *
3985
+	 * @return Array the aircraft list
3986
+	 *
3987
+	 */
3988 3988
 	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '')
3989 3989
 	{
3990 3990
 		global $globalDBdriver;
3991 3991
 		$query  = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
3992 3992
                     FROM spotter_output
3993 3993
                     WHERE spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> '' ";
3994
-                if ($olderthanmonths > 0) {
3995
-            		if ($globalDBdriver == 'mysql') {
3994
+				if ($olderthanmonths > 0) {
3995
+					if ($globalDBdriver == 'mysql') {
3996 3996
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
3997 3997
 			} else {
3998 3998
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
3999 3999
 			}
4000
-                }
4001
-                if ($sincedate != '') {
4002
-            		if ($globalDBdriver == 'mysql') {
4000
+				}
4001
+				if ($sincedate != '') {
4002
+					if ($globalDBdriver == 'mysql') {
4003 4003
 				$query .= "AND date > '".$sincedate."' ";
4004 4004
 			} else {
4005 4005
 				$query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP)";
4006 4006
 			}
4007 4007
 		}
4008 4008
 
4009
-                //if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
4010
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
4011
-                $query .= "GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name ORDER BY aircraft_icao_count DESC";
4009
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
4010
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
4011
+				$query .= "GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name ORDER BY aircraft_icao_count DESC";
4012 4012
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4013 4013
       
4014 4014
 		
@@ -4031,11 +4031,11 @@  discard block
 block discarded – undo
4031 4031
 
4032 4032
 
4033 4033
 	/**
4034
-	* Gets all aircraft registration that have flown over by aircaft icao
4035
-	*
4036
-	* @return Array the aircraft list
4037
-	*
4038
-	*/
4034
+	 * Gets all aircraft registration that have flown over by aircaft icao
4035
+	 *
4036
+	 * @return Array the aircraft list
4037
+	 *
4038
+	 */
4039 4039
 	public function countAllAircraftRegistrationByAircraft($aircraft_icao)
4040 4040
 	{
4041 4041
 		$Image = new Image($this->db);
@@ -4074,11 +4074,11 @@  discard block
 block discarded – undo
4074 4074
 
4075 4075
 
4076 4076
 	/**
4077
-	* Gets all aircraft types that have flown over by airline icao
4078
-	*
4079
-	* @return Array the aircraft list
4080
-	*
4081
-	*/
4077
+	 * Gets all aircraft types that have flown over by airline icao
4078
+	 *
4079
+	 * @return Array the aircraft list
4080
+	 *
4081
+	 */
4082 4082
 	public function countAllAircraftTypesByAirline($airline_icao)
4083 4083
 	{
4084 4084
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
@@ -4108,11 +4108,11 @@  discard block
 block discarded – undo
4108 4108
 
4109 4109
 
4110 4110
 	/**
4111
-	* Gets all aircraft registration that have flown over by airline icao
4112
-	*
4113
-	* @return Array the aircraft list
4114
-	*
4115
-	*/
4111
+	 * Gets all aircraft registration that have flown over by airline icao
4112
+	 *
4113
+	 * @return Array the aircraft list
4114
+	 *
4115
+	 */
4116 4116
 	public function countAllAircraftRegistrationByAirline($airline_icao)
4117 4117
 	{
4118 4118
 		$Image = new Image($this->db);
@@ -4150,11 +4150,11 @@  discard block
 block discarded – undo
4150 4150
 
4151 4151
 
4152 4152
 	/**
4153
-	* Gets all aircraft manufacturer that have flown over by airline icao
4154
-	*
4155
-	* @return Array the aircraft list
4156
-	*
4157
-	*/
4153
+	 * Gets all aircraft manufacturer that have flown over by airline icao
4154
+	 *
4155
+	 * @return Array the aircraft list
4156
+	 *
4157
+	 */
4158 4158
 	public function countAllAircraftManufacturerByAirline($airline_icao)
4159 4159
 	{
4160 4160
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
@@ -4183,11 +4183,11 @@  discard block
 block discarded – undo
4183 4183
 
4184 4184
 
4185 4185
 	/**
4186
-	* Gets all aircraft types that have flown over by airline icao
4187
-	*
4188
-	* @return Array the aircraft list
4189
-	*
4190
-	*/
4186
+	 * Gets all aircraft types that have flown over by airline icao
4187
+	 *
4188
+	 * @return Array the aircraft list
4189
+	 *
4190
+	 */
4191 4191
 	public function countAllAircraftTypesByAirport($airport_icao)
4192 4192
 	{
4193 4193
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -4216,11 +4216,11 @@  discard block
 block discarded – undo
4216 4216
 
4217 4217
 
4218 4218
 	/**
4219
-	* Gets all aircraft registration that have flown over by airport icao
4220
-	*
4221
-	* @return Array the aircraft list
4222
-	*
4223
-	*/
4219
+	 * Gets all aircraft registration that have flown over by airport icao
4220
+	 *
4221
+	 * @return Array the aircraft list
4222
+	 *
4223
+	 */
4224 4224
 	public function countAllAircraftRegistrationByAirport($airport_icao)
4225 4225
 	{
4226 4226
 		$Image = new Image($this->db);
@@ -4236,24 +4236,24 @@  discard block
 block discarded – undo
4236 4236
 		$sth = $this->db->prepare($query);
4237 4237
 		$sth->execute(array(':airport_icao' => $airport_icao));
4238 4238
       
4239
-        $aircraft_array = array();
4239
+		$aircraft_array = array();
4240 4240
 		$temp_array = array();
4241 4241
         
4242
-        while($row = $sth->fetch(PDO::FETCH_ASSOC))
4242
+		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4243 4243
 		{
4244 4244
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4245 4245
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4246 4246
 			$temp_array['registration'] = $row['registration'];
4247
-            $temp_array['airline_name'] = $row['airline_name'];
4247
+			$temp_array['airline_name'] = $row['airline_name'];
4248 4248
 			$temp_array['image_thumbnail'] = "";
4249
-            if($row['registration'] != "")
4250
-              {
4251
-                  $image_array = $Image->getSpotterImage($row['registration']);
4252
-                  $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4253
-              }
4254
-            $temp_array['registration_count'] = $row['registration_count'];
4249
+			if($row['registration'] != "")
4250
+			  {
4251
+				  $image_array = $Image->getSpotterImage($row['registration']);
4252
+				  $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4253
+			  }
4254
+			$temp_array['registration_count'] = $row['registration_count'];
4255 4255
           
4256
-            $aircraft_array[] = $temp_array;
4256
+			$aircraft_array[] = $temp_array;
4257 4257
 		}
4258 4258
 
4259 4259
 		return $aircraft_array;
@@ -4261,11 +4261,11 @@  discard block
 block discarded – undo
4261 4261
 	
4262 4262
 	
4263 4263
 	/**
4264
-	* Gets all aircraft manufacturer that have flown over by airport icao
4265
-	*
4266
-	* @return Array the aircraft list
4267
-	*
4268
-	*/
4264
+	 * Gets all aircraft manufacturer that have flown over by airport icao
4265
+	 *
4266
+	 * @return Array the aircraft list
4267
+	 *
4268
+	 */
4269 4269
 	public function countAllAircraftManufacturerByAirport($airport_icao)
4270 4270
 	{
4271 4271
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -4280,15 +4280,15 @@  discard block
 block discarded – undo
4280 4280
 		$sth = $this->db->prepare($query);
4281 4281
 		$sth->execute(array(':airport_icao' => $airport_icao));
4282 4282
       
4283
-    $aircraft_array = array();
4283
+	$aircraft_array = array();
4284 4284
 		$temp_array = array();
4285 4285
         
4286
-    while($row = $sth->fetch(PDO::FETCH_ASSOC))
4286
+	while($row = $sth->fetch(PDO::FETCH_ASSOC))
4287 4287
 		{
4288 4288
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4289 4289
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
4290 4290
           
4291
-      $aircraft_array[] = $temp_array;
4291
+	  $aircraft_array[] = $temp_array;
4292 4292
 		}
4293 4293
 
4294 4294
 		return $aircraft_array;
@@ -4297,11 +4297,11 @@  discard block
 block discarded – undo
4297 4297
 	
4298 4298
 	
4299 4299
 	/**
4300
-	* Gets all aircraft types that have flown over by aircraft manufacturer
4301
-	*
4302
-	* @return Array the aircraft list
4303
-	*
4304
-	*/
4300
+	 * Gets all aircraft types that have flown over by aircraft manufacturer
4301
+	 *
4302
+	 * @return Array the aircraft list
4303
+	 *
4304
+	 */
4305 4305
 	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer)
4306 4306
 	{
4307 4307
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -4316,16 +4316,16 @@  discard block
 block discarded – undo
4316 4316
 		$sth = $this->db->prepare($query);
4317 4317
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
4318 4318
       
4319
-        $aircraft_array = array();
4319
+		$aircraft_array = array();
4320 4320
 		$temp_array = array();
4321 4321
         
4322
-        while($row = $sth->fetch(PDO::FETCH_ASSOC))
4322
+		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4323 4323
 		{
4324 4324
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4325 4325
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4326
-            $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count'];
4326
+			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count'];
4327 4327
           
4328
-            $aircraft_array[] = $temp_array;
4328
+			$aircraft_array[] = $temp_array;
4329 4329
 		}
4330 4330
 
4331 4331
 		return $aircraft_array;
@@ -4333,11 +4333,11 @@  discard block
 block discarded – undo
4333 4333
 	
4334 4334
 	
4335 4335
 	/**
4336
-	* Gets all aircraft registration that have flown over by aircaft manufacturer
4337
-	*
4338
-	* @return Array the aircraft list
4339
-	*
4340
-	*/
4336
+	 * Gets all aircraft registration that have flown over by aircaft manufacturer
4337
+	 *
4338
+	 * @return Array the aircraft list
4339
+	 *
4340
+	 */
4341 4341
 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer)
4342 4342
 	{
4343 4343
 		$Image = new Image($this->db);
@@ -4353,24 +4353,24 @@  discard block
 block discarded – undo
4353 4353
 		$sth = $this->db->prepare($query);
4354 4354
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
4355 4355
       
4356
-        $aircraft_array = array();
4356
+		$aircraft_array = array();
4357 4357
 		$temp_array = array();
4358 4358
         
4359
-        while($row = $sth->fetch(PDO::FETCH_ASSOC))
4359
+		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4360 4360
 		{
4361 4361
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4362 4362
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4363 4363
 			$temp_array['registration'] = $row['registration'];
4364
-            $temp_array['airline_name'] = $row['airline_name'];
4364
+			$temp_array['airline_name'] = $row['airline_name'];
4365 4365
 			$temp_array['image_thumbnail'] = "";
4366
-            if($row['registration'] != "")
4367
-              {
4368
-                  $image_array = $Image->getSpotterImage($row['registration']);
4369
-                  $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4370
-              }
4371
-            $temp_array['registration_count'] = $row['registration_count'];
4366
+			if($row['registration'] != "")
4367
+			  {
4368
+				  $image_array = $Image->getSpotterImage($row['registration']);
4369
+				  $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4370
+			  }
4371
+			$temp_array['registration_count'] = $row['registration_count'];
4372 4372
           
4373
-            $aircraft_array[] = $temp_array;
4373
+			$aircraft_array[] = $temp_array;
4374 4374
 		}
4375 4375
 
4376 4376
 		return $aircraft_array;
@@ -4379,11 +4379,11 @@  discard block
 block discarded – undo
4379 4379
 	
4380 4380
 	
4381 4381
 	/**
4382
-	* Gets all aircraft types that have flown over by date
4383
-	*
4384
-	* @return Array the aircraft list
4385
-	*
4386
-	*/
4382
+	 * Gets all aircraft types that have flown over by date
4383
+	 *
4384
+	 * @return Array the aircraft list
4385
+	 *
4386
+	 */
4387 4387
 	public function countAllAircraftTypesByDate($date)
4388 4388
 	{
4389 4389
 		global $globalTimezone, $globalDBdriver;
@@ -4426,11 +4426,11 @@  discard block
 block discarded – undo
4426 4426
 
4427 4427
 
4428 4428
 	/**
4429
-	* Gets all aircraft registration that have flown over by date
4430
-	*
4431
-	* @return Array the aircraft list
4432
-	*
4433
-	*/
4429
+	 * Gets all aircraft registration that have flown over by date
4430
+	 *
4431
+	 * @return Array the aircraft list
4432
+	 *
4433
+	 */
4434 4434
 	public function countAllAircraftRegistrationByDate($date)
4435 4435
 	{
4436 4436
 		global $globalTimezone, $globalDBdriver;
@@ -4482,11 +4482,11 @@  discard block
 block discarded – undo
4482 4482
 
4483 4483
 
4484 4484
 	/**
4485
-	* Gets all aircraft manufacturer that have flown over by date
4486
-	*
4487
-	* @return Array the aircraft manufacturer list
4488
-	*
4489
-	*/
4485
+	 * Gets all aircraft manufacturer that have flown over by date
4486
+	 *
4487
+	 * @return Array the aircraft manufacturer list
4488
+	 *
4489
+	 */
4490 4490
 	public function countAllAircraftManufacturerByDate($date)
4491 4491
 	{
4492 4492
 		global $globalTimezone, $globalDBdriver;
@@ -4529,11 +4529,11 @@  discard block
 block discarded – undo
4529 4529
 
4530 4530
 
4531 4531
 	/**
4532
-	* Gets all aircraft types that have flown over by ident/callsign
4533
-	*
4534
-	* @return Array the aircraft list
4535
-	*
4536
-	*/
4532
+	 * Gets all aircraft types that have flown over by ident/callsign
4533
+	 *
4534
+	 * @return Array the aircraft list
4535
+	 *
4536
+	 */
4537 4537
 	public function countAllAircraftTypesByIdent($ident)
4538 4538
 	{
4539 4539
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -4563,11 +4563,11 @@  discard block
 block discarded – undo
4563 4563
 
4564 4564
 
4565 4565
 	/**
4566
-	* Gets all aircraft registration that have flown over by ident/callsign
4567
-	*
4568
-	* @return Array the aircraft list
4569
-	*
4570
-	*/
4566
+	 * Gets all aircraft registration that have flown over by ident/callsign
4567
+	 *
4568
+	 * @return Array the aircraft list
4569
+	 *
4570
+	 */
4571 4571
 	public function countAllAircraftRegistrationByIdent($ident)
4572 4572
 	{
4573 4573
 		$Image = new Image($this->db);
@@ -4607,11 +4607,11 @@  discard block
 block discarded – undo
4607 4607
 
4608 4608
 
4609 4609
 	/**
4610
-	* Gets all aircraft manufacturer that have flown over by ident/callsign
4611
-	*
4612
-	* @return Array the aircraft manufacturer list
4613
-	*
4614
-	*/
4610
+	 * Gets all aircraft manufacturer that have flown over by ident/callsign
4611
+	 *
4612
+	 * @return Array the aircraft manufacturer list
4613
+	 *
4614
+	 */
4615 4615
 	public function countAllAircraftManufacturerByIdent($ident)
4616 4616
 	{
4617 4617
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -4626,15 +4626,15 @@  discard block
 block discarded – undo
4626 4626
 		$sth = $this->db->prepare($query);
4627 4627
 		$sth->execute(array(':ident' => $ident));
4628 4628
       
4629
-    $aircraft_array = array();
4629
+	$aircraft_array = array();
4630 4630
 		$temp_array = array();
4631 4631
         
4632
-    while($row = $sth->fetch(PDO::FETCH_ASSOC))
4632
+	while($row = $sth->fetch(PDO::FETCH_ASSOC))
4633 4633
 		{
4634 4634
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4635 4635
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
4636 4636
           
4637
-      $aircraft_array[] = $temp_array;
4637
+	  $aircraft_array[] = $temp_array;
4638 4638
 		}
4639 4639
 
4640 4640
 		return $aircraft_array;
@@ -4642,11 +4642,11 @@  discard block
 block discarded – undo
4642 4642
 	
4643 4643
 	
4644 4644
 	/**
4645
-	* Gets all aircraft types that have flown over by route
4646
-	*
4647
-	* @return Array the aircraft list
4648
-	*
4649
-	*/
4645
+	 * Gets all aircraft types that have flown over by route
4646
+	 *
4647
+	 * @return Array the aircraft list
4648
+	 *
4649
+	 */
4650 4650
 	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao)
4651 4651
 	{
4652 4652
 		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
@@ -4663,16 +4663,16 @@  discard block
 block discarded – undo
4663 4663
 		$sth = $this->db->prepare($query);
4664 4664
 		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4665 4665
       
4666
-        $aircraft_array = array();
4666
+		$aircraft_array = array();
4667 4667
 		$temp_array = array();
4668 4668
         
4669
-        while($row = $sth->fetch(PDO::FETCH_ASSOC))
4669
+		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4670 4670
 		{
4671 4671
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4672 4672
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4673
-            $temp_array['aircraft_icao_count'] = $row['aircraft_icao_count'];
4673
+			$temp_array['aircraft_icao_count'] = $row['aircraft_icao_count'];
4674 4674
           
4675
-            $aircraft_array[] = $temp_array;
4675
+			$aircraft_array[] = $temp_array;
4676 4676
 		}
4677 4677
 
4678 4678
 		return $aircraft_array;
@@ -4680,11 +4680,11 @@  discard block
 block discarded – undo
4680 4680
 	
4681 4681
 	
4682 4682
 	/**
4683
-	* Gets all aircraft registration that have flown over by route
4684
-	*
4685
-	* @return Array the aircraft list
4686
-	*
4687
-	*/
4683
+	 * Gets all aircraft registration that have flown over by route
4684
+	 *
4685
+	 * @return Array the aircraft list
4686
+	 *
4687
+	 */
4688 4688
 	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao)
4689 4689
 	{
4690 4690
 		$Image = new Image($this->db);
@@ -4726,11 +4726,11 @@  discard block
 block discarded – undo
4726 4726
 	
4727 4727
 	
4728 4728
 	/**
4729
-	* Gets all aircraft manufacturer that have flown over by route
4730
-	*
4731
-	* @return Array the aircraft manufacturer list
4732
-	*
4733
-	*/
4729
+	 * Gets all aircraft manufacturer that have flown over by route
4730
+	 *
4731
+	 * @return Array the aircraft manufacturer list
4732
+	 *
4733
+	 */
4734 4734
 	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao)
4735 4735
 	{
4736 4736
 		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
@@ -4764,11 +4764,11 @@  discard block
 block discarded – undo
4764 4764
 	
4765 4765
 	
4766 4766
 	/**
4767
-	* Gets all aircraft types that have flown over by country
4768
-	*
4769
-	* @return Array the aircraft list
4770
-	*
4771
-	*/
4767
+	 * Gets all aircraft types that have flown over by country
4768
+	 *
4769
+	 * @return Array the aircraft list
4770
+	 *
4771
+	 */
4772 4772
 	public function countAllAircraftTypesByCountry($country)
4773 4773
 	{
4774 4774
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -4800,11 +4800,11 @@  discard block
 block discarded – undo
4800 4800
 
4801 4801
 
4802 4802
 	/**
4803
-	* Gets all aircraft registration that have flown over by country
4804
-	*
4805
-	* @return Array the aircraft list
4806
-	*
4807
-	*/
4803
+	 * Gets all aircraft registration that have flown over by country
4804
+	 *
4805
+	 * @return Array the aircraft list
4806
+	 *
4807
+	 */
4808 4808
 	public function countAllAircraftRegistrationByCountry($country)
4809 4809
 	{
4810 4810
 		$Image = new Image($this->db);
@@ -4845,11 +4845,11 @@  discard block
 block discarded – undo
4845 4845
 	
4846 4846
 	
4847 4847
 	/**
4848
-	* Gets all aircraft manufacturer that have flown over by country
4849
-	*
4850
-	* @return Array the aircraft manufacturer list
4851
-	*
4852
-	*/
4848
+	 * Gets all aircraft manufacturer that have flown over by country
4849
+	 *
4850
+	 * @return Array the aircraft manufacturer list
4851
+	 *
4852
+	 */
4853 4853
 	public function countAllAircraftManufacturerByCountry($country)
4854 4854
 	{
4855 4855
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -4881,11 +4881,11 @@  discard block
 block discarded – undo
4881 4881
 	
4882 4882
 	
4883 4883
 	/**
4884
-	* Gets all aircraft manufacturers that have flown over
4885
-	*
4886
-	* @return Array the aircraft list
4887
-	*
4888
-	*/
4884
+	 * Gets all aircraft manufacturers that have flown over
4885
+	 *
4886
+	 * @return Array the aircraft list
4887
+	 *
4888
+	 */
4889 4889
 	public function countAllAircraftManufacturers()
4890 4890
 	{
4891 4891
 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
@@ -4916,11 +4916,11 @@  discard block
 block discarded – undo
4916 4916
 	
4917 4917
 	
4918 4918
 	/**
4919
-	* Gets all aircraft registrations that have flown over
4920
-	*
4921
-	* @return Array the aircraft list
4922
-	*
4923
-	*/
4919
+	 * Gets all aircraft registrations that have flown over
4920
+	 *
4921
+	 * @return Array the aircraft list
4922
+	 *
4923
+	 */
4924 4924
 	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '')
4925 4925
 	{
4926 4926
 		global $globalDBdriver;
@@ -4928,15 +4928,15 @@  discard block
 block discarded – undo
4928 4928
 		$query  = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
4929 4929
                     FROM spotter_output 
4930 4930
                     WHERE spotter_output.registration <> '' AND spotter_output.registration <> 'NA' ";
4931
-                if ($olderthanmonths > 0) {
4932
-            		if ($globalDBdriver == 'mysql') {
4931
+				if ($olderthanmonths > 0) {
4932
+					if ($globalDBdriver == 'mysql') {
4933 4933
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
4934 4934
 			} else {
4935 4935
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
4936 4936
 			}
4937 4937
 		}
4938
-                if ($sincedate != '') {
4939
-            		if ($globalDBdriver == 'mysql') {
4938
+				if ($sincedate != '') {
4939
+					if ($globalDBdriver == 'mysql') {
4940 4940
 				$query .= "AND date > '".$sincedate."' ";
4941 4941
 			} else {
4942 4942
 				$query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4945,7 +4945,7 @@  discard block
 block discarded – undo
4945 4945
 
4946 4946
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
4947 4947
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
4948
-                $query .= "GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
4948
+				$query .= "GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
4949 4949
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4950 4950
 		
4951 4951
 		$sth = $this->db->prepare($query);
@@ -4978,35 +4978,35 @@  discard block
 block discarded – undo
4978 4978
 	
4979 4979
 	
4980 4980
 	/**
4981
-	* Gets all departure airports of the airplanes that have flown over
4982
-	*
4983
-	* @return Array the airport list
4984
-	*
4985
-	*/
4981
+	 * Gets all departure airports of the airplanes that have flown over
4982
+	 *
4983
+	 * @return Array the airport list
4984
+	 *
4985
+	 */
4986 4986
 	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '')
4987 4987
 	{
4988 4988
 		global $globalDBdriver;
4989 4989
 		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
4990 4990
 								FROM spotter_output
4991 4991
                     WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' ";
4992
-                if ($olderthanmonths > 0) {
4993
-            		if ($globalDBdriver == 'mysql') {
4992
+				if ($olderthanmonths > 0) {
4993
+					if ($globalDBdriver == 'mysql') {
4994 4994
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
4995 4995
 			} else {
4996 4996
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
4997 4997
 			}
4998
-                }
4999
-                if ($sincedate != '') {
5000
-            		if ($globalDBdriver == 'mysql') {
4998
+				}
4999
+				if ($sincedate != '') {
5000
+					if ($globalDBdriver == 'mysql') {
5001 5001
 				$query .= "AND date > '".$sincedate."' ";
5002 5002
 			} else {
5003 5003
 				$query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP)";
5004 5004
 			}
5005 5005
 		}
5006 5006
 
5007
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5008
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5009
-                $query .= "GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5007
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5008
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5009
+				$query .= "GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5010 5010
 				ORDER BY airport_departure_icao_count DESC";
5011 5011
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5012 5012
       
@@ -5030,35 +5030,35 @@  discard block
 block discarded – undo
5030 5030
 	}
5031 5031
 	
5032 5032
 	/**
5033
-	* Gets all detected departure airports of the airplanes that have flown over
5034
-	*
5035
-	* @return Array the airport list
5036
-	*
5037
-	*/
5033
+	 * Gets all detected departure airports of the airplanes that have flown over
5034
+	 *
5035
+	 * @return Array the airport list
5036
+	 *
5037
+	 */
5038 5038
 	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '')
5039 5039
 	{
5040 5040
 		global $globalDBdriver;
5041 5041
 		$query  = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
5042 5042
 				FROM spotter_output, airport
5043 5043
                     WHERE spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao ";
5044
-                if ($olderthanmonths > 0) {
5045
-            		if ($globalDBdriver == 'mysql') {
5044
+				if ($olderthanmonths > 0) {
5045
+					if ($globalDBdriver == 'mysql') {
5046 5046
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
5047 5047
 			} else {
5048 5048
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
5049 5049
 			}
5050
-                }
5051
-                if ($sincedate != '') {
5052
-            		if ($globalDBdriver == 'mysql') {
5050
+				}
5051
+				if ($sincedate != '') {
5052
+					if ($globalDBdriver == 'mysql') {
5053 5053
 				$query .= "AND date > '".$sincedate."' ";
5054 5054
 			} else {
5055 5055
 				$query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP)";
5056 5056
 			}
5057 5057
 		}
5058 5058
 
5059
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5060
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5061
-                $query .= "GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
5059
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5060
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5061
+				$query .= "GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
5062 5062
 				ORDER BY airport_departure_icao_count DESC";
5063 5063
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5064 5064
       
@@ -5084,11 +5084,11 @@  discard block
 block discarded – undo
5084 5084
 	
5085 5085
 	
5086 5086
 	/**
5087
-	* Gets all departure airports of the airplanes that have flown over based on an airline icao
5088
-	*
5089
-	* @return Array the airport list
5090
-	*
5091
-	*/
5087
+	 * Gets all departure airports of the airplanes that have flown over based on an airline icao
5088
+	 *
5089
+	 * @return Array the airport list
5090
+	 *
5091
+	 */
5092 5092
 	public function countAllDepartureAirportsByAirline($airline_icao)
5093 5093
 	{
5094 5094
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
@@ -5123,11 +5123,11 @@  discard block
 block discarded – undo
5123 5123
 	
5124 5124
 	
5125 5125
 	/**
5126
-	* Gets all departure airports by country of the airplanes that have flown over based on an airline icao
5127
-	*
5128
-	* @return Array the airport list
5129
-	*
5130
-	*/
5126
+	 * Gets all departure airports by country of the airplanes that have flown over based on an airline icao
5127
+	 *
5128
+	 * @return Array the airport list
5129
+	 *
5130
+	 */
5131 5131
 	public function countAllDepartureAirportCountriesByAirline($airline_icao)
5132 5132
 	{
5133 5133
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
@@ -5159,11 +5159,11 @@  discard block
 block discarded – undo
5159 5159
 	
5160 5160
 	
5161 5161
 	/**
5162
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft icao
5163
-	*
5164
-	* @return Array the airport list
5165
-	*
5166
-	*/
5162
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft icao
5163
+	 *
5164
+	 * @return Array the airport list
5165
+	 *
5166
+	 */
5167 5167
 	public function countAllDepartureAirportsByAircraft($aircraft_icao)
5168 5168
 	{
5169 5169
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -5197,11 +5197,11 @@  discard block
 block discarded – undo
5197 5197
 	
5198 5198
 	
5199 5199
 	/**
5200
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
5201
-	*
5202
-	* @return Array the airport list
5203
-	*
5204
-	*/
5200
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
5201
+	 *
5202
+	 * @return Array the airport list
5203
+	 *
5204
+	 */
5205 5205
 	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao)
5206 5206
 	{
5207 5207
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -5232,11 +5232,11 @@  discard block
 block discarded – undo
5232 5232
 	
5233 5233
 	
5234 5234
 	/**
5235
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft registration
5236
-	*
5237
-	* @return Array the airport list
5238
-	*
5239
-	*/
5235
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft registration
5236
+	 *
5237
+	 * @return Array the airport list
5238
+	 *
5239
+	 */
5240 5240
 	public function countAllDepartureAirportsByRegistration($registration)
5241 5241
 	{
5242 5242
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -5270,11 +5270,11 @@  discard block
 block discarded – undo
5270 5270
 	
5271 5271
 	
5272 5272
 	/**
5273
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration
5274
-	*
5275
-	* @return Array the airport list
5276
-	*
5277
-	*/
5273
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration
5274
+	 *
5275
+	 * @return Array the airport list
5276
+	 *
5277
+	 */
5278 5278
 	public function countAllDepartureAirportCountriesByRegistration($registration)
5279 5279
 	{
5280 5280
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -5305,11 +5305,11 @@  discard block
 block discarded – undo
5305 5305
 	
5306 5306
 	
5307 5307
 	/**
5308
-	* Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao
5309
-	*
5310
-	* @return Array the airport list
5311
-	*
5312
-	*/
5308
+	 * Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao
5309
+	 *
5310
+	 * @return Array the airport list
5311
+	 *
5312
+	 */
5313 5313
 	public function countAllDepartureAirportsByAirport($airport_icao)
5314 5314
 	{
5315 5315
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -5343,11 +5343,11 @@  discard block
 block discarded – undo
5343 5343
 	
5344 5344
 	
5345 5345
 	/**
5346
-	* Gets all departure airports by country of the airplanes that have flown over based on an airport icao
5347
-	*
5348
-	* @return Array the airport list
5349
-	*
5350
-	*/
5346
+	 * Gets all departure airports by country of the airplanes that have flown over based on an airport icao
5347
+	 *
5348
+	 * @return Array the airport list
5349
+	 *
5350
+	 */
5351 5351
 	public function countAllDepartureAirportCountriesByAirport($airport_icao)
5352 5352
 	{
5353 5353
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -5379,11 +5379,11 @@  discard block
 block discarded – undo
5379 5379
 	
5380 5380
 	
5381 5381
 	/**
5382
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer
5383
-	*
5384
-	* @return Array the airport list
5385
-	*
5386
-	*/
5382
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer
5383
+	 *
5384
+	 * @return Array the airport list
5385
+	 *
5386
+	 */
5387 5387
 	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer)
5388 5388
 	{
5389 5389
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -5417,11 +5417,11 @@  discard block
 block discarded – undo
5417 5417
 	
5418 5418
 	
5419 5419
 	/**
5420
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer
5421
-	*
5422
-	* @return Array the airport list
5423
-	*
5424
-	*/
5420
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer
5421
+	 *
5422
+	 * @return Array the airport list
5423
+	 *
5424
+	 */
5425 5425
 	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer)
5426 5426
 	{
5427 5427
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -5452,11 +5452,11 @@  discard block
 block discarded – undo
5452 5452
 	
5453 5453
 	
5454 5454
 	/**
5455
-	* Gets all departure airports of the airplanes that have flown over based on a date
5456
-	*
5457
-	* @return Array the airport list
5458
-	*
5459
-	*/
5455
+	 * Gets all departure airports of the airplanes that have flown over based on a date
5456
+	 *
5457
+	 * @return Array the airport list
5458
+	 *
5459
+	 */
5460 5460
 	public function countAllDepartureAirportsByDate($date)
5461 5461
 	{
5462 5462
 		global $globalTimezone, $globalDBdriver;
@@ -5504,11 +5504,11 @@  discard block
 block discarded – undo
5504 5504
 	
5505 5505
 	
5506 5506
 	/**
5507
-	* Gets all departure airports by country of the airplanes that have flown over based on a date
5508
-	*
5509
-	* @return Array the airport list
5510
-	*
5511
-	*/
5507
+	 * Gets all departure airports by country of the airplanes that have flown over based on a date
5508
+	 *
5509
+	 * @return Array the airport list
5510
+	 *
5511
+	 */
5512 5512
 	public function countAllDepartureAirportCountriesByDate($date)
5513 5513
 	{
5514 5514
 		global $globalTimezone, $globalDBdriver;
@@ -5552,11 +5552,11 @@  discard block
 block discarded – undo
5552 5552
 	
5553 5553
 	
5554 5554
 	/**
5555
-	* Gets all departure airports of the airplanes that have flown over based on a ident/callsign
5556
-	*
5557
-	* @return Array the airport list
5558
-	*
5559
-	*/
5555
+	 * Gets all departure airports of the airplanes that have flown over based on a ident/callsign
5556
+	 *
5557
+	 * @return Array the airport list
5558
+	 *
5559
+	 */
5560 5560
 	public function countAllDepartureAirportsByIdent($ident)
5561 5561
 	{
5562 5562
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -5591,11 +5591,11 @@  discard block
 block discarded – undo
5591 5591
 	
5592 5592
 	
5593 5593
 	/**
5594
-	* Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident
5595
-	*
5596
-	* @return Array the airport list
5597
-	*
5598
-	*/
5594
+	 * Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident
5595
+	 *
5596
+	 * @return Array the airport list
5597
+	 *
5598
+	 */
5599 5599
 	public function countAllDepartureAirportCountriesByIdent($ident)
5600 5600
 	{
5601 5601
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -5627,11 +5627,11 @@  discard block
 block discarded – undo
5627 5627
 	
5628 5628
 	
5629 5629
 	/**
5630
-	* Gets all departure airports of the airplanes that have flown over based on a country
5631
-	*
5632
-	* @return Array the airport list
5633
-	*
5634
-	*/
5630
+	 * Gets all departure airports of the airplanes that have flown over based on a country
5631
+	 *
5632
+	 * @return Array the airport list
5633
+	 *
5634
+	 */
5635 5635
 	public function countAllDepartureAirportsByCountry($country)
5636 5636
 	{
5637 5637
 		$date = filter_var($date,FILTER_SANITIZE_STRING);
@@ -5665,11 +5665,11 @@  discard block
 block discarded – undo
5665 5665
 
5666 5666
 
5667 5667
 	/**
5668
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
5669
-	*
5670
-	* @return Array the airport list
5671
-	*
5672
-	*/
5668
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
5669
+	 *
5670
+	 * @return Array the airport list
5671
+	 *
5672
+	 */
5673 5673
 	public function countAllDepartureAirportCountriesByCountry($country)
5674 5674
 	{
5675 5675
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -5700,40 +5700,40 @@  discard block
 block discarded – undo
5700 5700
 	
5701 5701
 
5702 5702
 	/**
5703
-	* Gets all arrival airports of the airplanes that have flown over
5704
-	*
5705
-	* @return Array the airport list
5706
-	*
5707
-	*/
5703
+	 * Gets all arrival airports of the airplanes that have flown over
5704
+	 *
5705
+	 * @return Array the airport list
5706
+	 *
5707
+	 */
5708 5708
 	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false)
5709 5709
 	{
5710 5710
 		global $globalDBdriver;
5711 5711
 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
5712 5712
 								FROM spotter_output 
5713 5713
                     WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' ";
5714
-                if ($olderthanmonths > 0) {
5715
-            		if ($globalDBdriver == 'mysql') {
5714
+				if ($olderthanmonths > 0) {
5715
+					if ($globalDBdriver == 'mysql') {
5716 5716
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
5717 5717
 			} else {
5718 5718
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
5719 5719
 			}
5720
-                if ($sincedate != '') {
5721
-            		if ($globalDBdriver == 'mysql') {
5720
+				if ($sincedate != '') {
5721
+					if ($globalDBdriver == 'mysql') {
5722 5722
 				$query .= "AND date > '".$sincedate."' ";
5723 5723
 			} else {
5724 5724
 				$query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP)";
5725 5725
 			}
5726 5726
 		}
5727
-            		if ($globalDBdriver == 'mysql') {
5727
+					if ($globalDBdriver == 'mysql') {
5728 5728
 				$query .= "AND date > '".$sincedate."' ";
5729 5729
 			} else {
5730 5730
 				$query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP)";
5731 5731
 			}
5732 5732
 		}
5733 5733
 
5734
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5735
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5736
-                $query .= "GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
5734
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5735
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5736
+				$query .= "GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
5737 5737
 					ORDER BY airport_arrival_icao_count DESC";
5738 5738
 		if ($limit) $query .= " LIMIT 10";
5739 5739
       
@@ -5762,40 +5762,40 @@  discard block
 block discarded – undo
5762 5762
 	}
5763 5763
 	
5764 5764
 	/**
5765
-	* Gets all detected arrival airports of the airplanes that have flown over
5766
-	*
5767
-	* @return Array the airport list
5768
-	*
5769
-	*/
5765
+	 * Gets all detected arrival airports of the airplanes that have flown over
5766
+	 *
5767
+	 * @return Array the airport list
5768
+	 *
5769
+	 */
5770 5770
 	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false)
5771 5771
 	{
5772 5772
 		global $globalDBdriver;
5773 5773
 		$query  = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
5774 5774
 			FROM spotter_output, airport 
5775 5775
                     WHERE spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao ";
5776
-                if ($olderthanmonths > 0) {
5777
-            		if ($globalDBdriver == 'mysql') {
5776
+				if ($olderthanmonths > 0) {
5777
+					if ($globalDBdriver == 'mysql') {
5778 5778
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
5779 5779
 			} else {
5780 5780
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
5781 5781
 			}
5782
-                if ($sincedate != '') {
5783
-            		if ($globalDBdriver == 'mysql') {
5782
+				if ($sincedate != '') {
5783
+					if ($globalDBdriver == 'mysql') {
5784 5784
 				$query .= "AND date > '".$sincedate."' ";
5785 5785
 			} else {
5786 5786
 				$query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP)";
5787 5787
 			}
5788 5788
 		}
5789
-            		if ($globalDBdriver == 'mysql') {
5789
+					if ($globalDBdriver == 'mysql') {
5790 5790
 				$query .= "AND date > '".$sincedate."' ";
5791 5791
 			} else {
5792 5792
 				$query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP)";
5793 5793
 			}
5794 5794
 		}
5795 5795
 
5796
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5797
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5798
-                $query .= "GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
5796
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5797
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5798
+				$query .= "GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
5799 5799
 					ORDER BY airport_arrival_icao_count DESC";
5800 5800
 		if ($limit) $query .= " LIMIT 10";
5801 5801
       
@@ -5826,11 +5826,11 @@  discard block
 block discarded – undo
5826 5826
 	
5827 5827
 	
5828 5828
 	/**
5829
-	* Gets all arrival airports of the airplanes that have flown over based on an airline icao
5830
-	*
5831
-	* @return Array the airport list
5832
-	*
5833
-	*/
5829
+	 * Gets all arrival airports of the airplanes that have flown over based on an airline icao
5830
+	 *
5831
+	 * @return Array the airport list
5832
+	 *
5833
+	 */
5834 5834
 	public function countAllArrivalAirportsByAirline($airline_icao)
5835 5835
 	{
5836 5836
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
@@ -5864,11 +5864,11 @@  discard block
 block discarded – undo
5864 5864
 	
5865 5865
 	
5866 5866
 	/**
5867
-	* Gets all arrival airports by country of the airplanes that have flown over based on an airline icao
5868
-	*
5869
-	* @return Array the airport list
5870
-	*
5871
-	*/
5867
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an airline icao
5868
+	 *
5869
+	 * @return Array the airport list
5870
+	 *
5871
+	 */
5872 5872
 	public function countAllArrivalAirportCountriesByAirline($airline_icao)
5873 5873
 	{
5874 5874
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
@@ -5899,11 +5899,11 @@  discard block
 block discarded – undo
5899 5899
 	
5900 5900
 	
5901 5901
 	/**
5902
-	* Gets all arrival airports of the airplanes that have flown over based on an aircraft icao
5903
-	*
5904
-	* @return Array the airport list
5905
-	*
5906
-	*/
5902
+	 * Gets all arrival airports of the airplanes that have flown over based on an aircraft icao
5903
+	 *
5904
+	 * @return Array the airport list
5905
+	 *
5906
+	 */
5907 5907
 	public function countAllArrivalAirportsByAircraft($aircraft_icao)
5908 5908
 	{
5909 5909
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -5938,11 +5938,11 @@  discard block
 block discarded – undo
5938 5938
 	
5939 5939
 	
5940 5940
 	/**
5941
-	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao
5942
-	*
5943
-	* @return Array the airport list
5944
-	*
5945
-	*/
5941
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao
5942
+	 *
5943
+	 * @return Array the airport list
5944
+	 *
5945
+	 */
5946 5946
 	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao)
5947 5947
 	{
5948 5948
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -5973,11 +5973,11 @@  discard block
 block discarded – undo
5973 5973
 	
5974 5974
 	
5975 5975
 	/**
5976
-	* Gets all arrival airports of the airplanes that have flown over based on an aircraft registration
5977
-	*
5978
-	* @return Array the airport list
5979
-	*
5980
-	*/
5976
+	 * Gets all arrival airports of the airplanes that have flown over based on an aircraft registration
5977
+	 *
5978
+	 * @return Array the airport list
5979
+	 *
5980
+	 */
5981 5981
 	public function countAllArrivalAirportsByRegistration($registration)
5982 5982
 	{
5983 5983
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -6011,11 +6011,11 @@  discard block
 block discarded – undo
6011 6011
 	
6012 6012
 	
6013 6013
 	/**
6014
-	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration
6015
-	*
6016
-	* @return Array the airport list
6017
-	*
6018
-	*/
6014
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration
6015
+	 *
6016
+	 * @return Array the airport list
6017
+	 *
6018
+	 */
6019 6019
 	public function countAllArrivalAirportCountriesByRegistration($registration)
6020 6020
 	{
6021 6021
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -6047,11 +6047,11 @@  discard block
 block discarded – undo
6047 6047
 	
6048 6048
 	
6049 6049
 	/**
6050
-	* Gets all arrival airports of the airplanes that have flown over based on an departure airport
6051
-	*
6052
-	* @return Array the airport list
6053
-	*
6054
-	*/
6050
+	 * Gets all arrival airports of the airplanes that have flown over based on an departure airport
6051
+	 *
6052
+	 * @return Array the airport list
6053
+	 *
6054
+	 */
6055 6055
 	public function countAllArrivalAirportsByAirport($airport_icao)
6056 6056
 	{
6057 6057
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -6085,11 +6085,11 @@  discard block
 block discarded – undo
6085 6085
 	
6086 6086
 	
6087 6087
 	/**
6088
-	* Gets all arrival airports by country of the airplanes that have flown over based on an airport icao
6089
-	*
6090
-	* @return Array the airport list
6091
-	*
6092
-	*/
6088
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an airport icao
6089
+	 *
6090
+	 * @return Array the airport list
6091
+	 *
6092
+	 */
6093 6093
 	public function countAllArrivalAirportCountriesByAirport($airport_icao)
6094 6094
 	{
6095 6095
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -6120,11 +6120,11 @@  discard block
 block discarded – undo
6120 6120
 	
6121 6121
 	
6122 6122
 	/**
6123
-	* Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer
6124
-	*
6125
-	* @return Array the airport list
6126
-	*
6127
-	*/
6123
+	 * Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer
6124
+	 *
6125
+	 * @return Array the airport list
6126
+	 *
6127
+	 */
6128 6128
 	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer)
6129 6129
 	{
6130 6130
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -6159,11 +6159,11 @@  discard block
 block discarded – undo
6159 6159
 	
6160 6160
 	
6161 6161
 	/**
6162
-	* Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer
6163
-	*
6164
-	* @return Array the airport list
6165
-	*
6166
-	*/
6162
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer
6163
+	 *
6164
+	 * @return Array the airport list
6165
+	 *
6166
+	 */
6167 6167
 	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer)
6168 6168
 	{
6169 6169
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -6195,11 +6195,11 @@  discard block
 block discarded – undo
6195 6195
 	
6196 6196
 	
6197 6197
 	/**
6198
-	* Gets all arrival airports of the airplanes that have flown over based on a date
6199
-	*
6200
-	* @return Array the airport list
6201
-	*
6202
-	*/
6198
+	 * Gets all arrival airports of the airplanes that have flown over based on a date
6199
+	 *
6200
+	 * @return Array the airport list
6201
+	 *
6202
+	 */
6203 6203
 	public function countAllArrivalAirportsByDate($date)
6204 6204
 	{
6205 6205
 		global $globalTimezone, $globalDBdriver;
@@ -6246,11 +6246,11 @@  discard block
 block discarded – undo
6246 6246
 	
6247 6247
 	
6248 6248
 	/**
6249
-	* Gets all arrival airports by country of the airplanes that have flown over based on a date
6250
-	*
6251
-	* @return Array the airport list
6252
-	*
6253
-	*/
6249
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a date
6250
+	 *
6251
+	 * @return Array the airport list
6252
+	 *
6253
+	 */
6254 6254
 	public function countAllArrivalAirportCountriesByDate($date)
6255 6255
 	{
6256 6256
 		global $globalTimezone, $globalDBdriver;
@@ -6294,11 +6294,11 @@  discard block
 block discarded – undo
6294 6294
 	
6295 6295
 	
6296 6296
 	/**
6297
-	* Gets all arrival airports of the airplanes that have flown over based on a ident/callsign
6298
-	*
6299
-	* @return Array the airport list
6300
-	*
6301
-	*/
6297
+	 * Gets all arrival airports of the airplanes that have flown over based on a ident/callsign
6298
+	 *
6299
+	 * @return Array the airport list
6300
+	 *
6301
+	 */
6302 6302
 	public function countAllArrivalAirportsByIdent($ident)
6303 6303
 	{
6304 6304
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -6332,11 +6332,11 @@  discard block
 block discarded – undo
6332 6332
 	
6333 6333
 	
6334 6334
 	/**
6335
-	* Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident
6336
-	*
6337
-	* @return Array the airport list
6338
-	*
6339
-	*/
6335
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident
6336
+	 *
6337
+	 * @return Array the airport list
6338
+	 *
6339
+	 */
6340 6340
 	public function countAllArrivalAirportCountriesByIdent($ident)
6341 6341
 	{
6342 6342
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -6368,11 +6368,11 @@  discard block
 block discarded – undo
6368 6368
 	
6369 6369
 	
6370 6370
 	/**
6371
-	* Gets all arrival airports of the airplanes that have flown over based on a country
6372
-	*
6373
-	* @return Array the airport list
6374
-	*
6375
-	*/
6371
+	 * Gets all arrival airports of the airplanes that have flown over based on a country
6372
+	 *
6373
+	 * @return Array the airport list
6374
+	 *
6375
+	 */
6376 6376
 	public function countAllArrivalAirportsByCountry($country)
6377 6377
 	{
6378 6378
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -6406,11 +6406,11 @@  discard block
 block discarded – undo
6406 6406
 	
6407 6407
 	
6408 6408
 	/**
6409
-	* Gets all arrival airports by country of the airplanes that have flown over based on a country
6410
-	*
6411
-	* @return Array the airport list
6412
-	*
6413
-	*/
6409
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a country
6410
+	 *
6411
+	 * @return Array the airport list
6412
+	 *
6413
+	 */
6414 6414
 	public function countAllArrivalAirportCountriesByCountry($country)
6415 6415
 	{
6416 6416
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -6442,11 +6442,11 @@  discard block
 block discarded – undo
6442 6442
 
6443 6443
 
6444 6444
 	/**
6445
-	* Counts all airport departure countries
6446
-	*
6447
-	* @return Array the airport departure list
6448
-	*
6449
-	*/
6445
+	 * Counts all airport departure countries
6446
+	 *
6447
+	 * @return Array the airport departure list
6448
+	 *
6449
+	 */
6450 6450
 	public function countAllDepartureCountries()
6451 6451
 	{
6452 6452
 		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
@@ -6476,11 +6476,11 @@  discard block
 block discarded – undo
6476 6476
 	
6477 6477
 	
6478 6478
 	/**
6479
-	* Counts all airport arrival countries
6480
-	*
6481
-	* @return Array the airport arrival list
6482
-	*
6483
-	*/
6479
+	 * Counts all airport arrival countries
6480
+	 *
6481
+	 * @return Array the airport arrival list
6482
+	 *
6483
+	 */
6484 6484
 	public function countAllArrivalCountries($limit = true)
6485 6485
 	{
6486 6486
 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
@@ -6513,11 +6513,11 @@  discard block
 block discarded – undo
6513 6513
 
6514 6514
 
6515 6515
 	/**
6516
-	* Gets all route combinations
6517
-	*
6518
-	* @return Array the route list
6519
-	*
6520
-	*/
6516
+	 * Gets all route combinations
6517
+	 *
6518
+	 * @return Array the route list
6519
+	 *
6520
+	 */
6521 6521
 	public function countAllRoutes()
6522 6522
 	{
6523 6523
 		
@@ -6557,11 +6557,11 @@  discard block
 block discarded – undo
6557 6557
 	
6558 6558
 	
6559 6559
 	/**
6560
-	* Gets all route combinations based on an aircraft
6561
-	*
6562
-	* @return Array the route list
6563
-	*
6564
-	*/
6560
+	 * Gets all route combinations based on an aircraft
6561
+	 *
6562
+	 * @return Array the route list
6563
+	 *
6564
+	 */
6565 6565
 	public function countAllRoutesByAircraft($aircraft_icao)
6566 6566
 	{
6567 6567
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -6599,11 +6599,11 @@  discard block
 block discarded – undo
6599 6599
 	
6600 6600
 	
6601 6601
 	/**
6602
-	* Gets all route combinations based on an aircraft registration
6603
-	*
6604
-	* @return Array the route list
6605
-	*
6606
-	*/
6602
+	 * Gets all route combinations based on an aircraft registration
6603
+	 *
6604
+	 * @return Array the route list
6605
+	 *
6606
+	 */
6607 6607
 	public function countAllRoutesByRegistration($registration)
6608 6608
 	{
6609 6609
 		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
@@ -6642,11 +6642,11 @@  discard block
 block discarded – undo
6642 6642
 	
6643 6643
 	
6644 6644
 	/**
6645
-	* Gets all route combinations based on an airline
6646
-	*
6647
-	* @return Array the route list
6648
-	*
6649
-	*/
6645
+	 * Gets all route combinations based on an airline
6646
+	 *
6647
+	 * @return Array the route list
6648
+	 *
6649
+	 */
6650 6650
 	public function countAllRoutesByAirline($airline_icao)
6651 6651
 	{
6652 6652
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
@@ -6685,11 +6685,11 @@  discard block
 block discarded – undo
6685 6685
 	
6686 6686
 	
6687 6687
 	/**
6688
-	* Gets all route combinations based on an airport
6689
-	*
6690
-	* @return Array the route list
6691
-	*
6692
-	*/
6688
+	 * Gets all route combinations based on an airport
6689
+	 *
6690
+	 * @return Array the route list
6691
+	 *
6692
+	 */
6693 6693
 	public function countAllRoutesByAirport($airport_icao)
6694 6694
 	{
6695 6695
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -6728,11 +6728,11 @@  discard block
 block discarded – undo
6728 6728
 	
6729 6729
 	
6730 6730
 	/**
6731
-	* Gets all route combinations based on an country
6732
-	*
6733
-	* @return Array the route list
6734
-	*
6735
-	*/
6731
+	 * Gets all route combinations based on an country
6732
+	 *
6733
+	 * @return Array the route list
6734
+	 *
6735
+	 */
6736 6736
 	public function countAllRoutesByCountry($country)
6737 6737
 	{
6738 6738
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -6770,11 +6770,11 @@  discard block
 block discarded – undo
6770 6770
 
6771 6771
 
6772 6772
 	/**
6773
-	* Gets all route combinations based on an date
6774
-	*
6775
-	* @return Array the route list
6776
-	*
6777
-	*/
6773
+	 * Gets all route combinations based on an date
6774
+	 *
6775
+	 * @return Array the route list
6776
+	 *
6777
+	 */
6778 6778
 	public function countAllRoutesByDate($date)
6779 6779
 	{
6780 6780
 		global $globalTimezone, $globalDBdriver;
@@ -6825,11 +6825,11 @@  discard block
 block discarded – undo
6825 6825
 	
6826 6826
 	
6827 6827
 	/**
6828
-	* Gets all route combinations based on an ident/callsign
6829
-	*
6830
-	* @return Array the route list
6831
-	*
6832
-	*/
6828
+	 * Gets all route combinations based on an ident/callsign
6829
+	 *
6830
+	 * @return Array the route list
6831
+	 *
6832
+	 */
6833 6833
 	public function countAllRoutesByIdent($ident)
6834 6834
 	{
6835 6835
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -6867,11 +6867,11 @@  discard block
 block discarded – undo
6867 6867
 	
6868 6868
 	
6869 6869
 	/**
6870
-	* Gets all route combinations based on an manufacturer
6871
-	*
6872
-	* @return Array the route list
6873
-	*
6874
-	*/
6870
+	 * Gets all route combinations based on an manufacturer
6871
+	 *
6872
+	 * @return Array the route list
6873
+	 *
6874
+	 */
6875 6875
 	public function countAllRoutesByManufacturer($aircraft_manufacturer)
6876 6876
 	{
6877 6877
 		$aircraft_manufacturer = filter_var($aircraft_manufactuer,FILTER_SANITIZE_STRING);
@@ -6910,11 +6910,11 @@  discard block
 block discarded – undo
6910 6910
 	
6911 6911
 	
6912 6912
 	/**
6913
-	* Gets all route combinations with waypoints
6914
-	*
6915
-	* @return Array the route list
6916
-	*
6917
-	*/
6913
+	 * Gets all route combinations with waypoints
6914
+	 *
6915
+	 * @return Array the route list
6916
+	 *
6917
+	 */
6918 6918
 	public function countAllRoutesWithWaypoints()
6919 6919
 	{
6920 6920
 		$query  = "SELECT DISTINCT spotter_output.waypoints AS route, count(spotter_output.waypoints) AS route_count, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
@@ -6954,11 +6954,11 @@  discard block
 block discarded – undo
6954 6954
 	
6955 6955
 	
6956 6956
 	/**
6957
-	* Gets all callsigns that have flown over
6958
-	*
6959
-	* @return Array the callsign list
6960
-	*
6961
-	*/
6957
+	 * Gets all callsigns that have flown over
6958
+	 *
6959
+	 * @return Array the callsign list
6960
+	 *
6961
+	 */
6962 6962
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '')
6963 6963
 	{
6964 6964
 		global $globalDBdriver;
@@ -6999,11 +6999,11 @@  discard block
 block discarded – undo
6999 6999
 
7000 7000
 
7001 7001
 	/**
7002
-	* Counts all dates
7003
-	*
7004
-	* @return Array the date list
7005
-	*
7006
-	*/
7002
+	 * Counts all dates
7003
+	 *
7004
+	 * @return Array the date list
7005
+	 *
7006
+	 */
7007 7007
 	public function countAllDates()
7008 7008
 	{
7009 7009
 		global $globalTimezone, $globalDBdriver;
@@ -7048,11 +7048,11 @@  discard block
 block discarded – undo
7048 7048
 	
7049 7049
 	
7050 7050
 	/**
7051
-	* Counts all dates during the last 7 days
7052
-	*
7053
-	* @return Array the date list
7054
-	*
7055
-	*/
7051
+	 * Counts all dates during the last 7 days
7052
+	 *
7053
+	 * @return Array the date list
7054
+	 *
7055
+	 */
7056 7056
 	public function countAllDatesLast7Days()
7057 7057
 	{
7058 7058
 		global $globalTimezone, $globalDBdriver;
@@ -7076,7 +7076,7 @@  discard block
 block discarded – undo
7076 7076
 								GROUP BY date_name 
7077 7077
 								ORDER BY date_name ASC";
7078 7078
 			$query_data = array(':offset' => $offset);
7079
-    		}
7079
+			}
7080 7080
 		
7081 7081
 		$sth = $this->db->prepare($query);
7082 7082
 		$sth->execute($query_data);
@@ -7096,11 +7096,11 @@  discard block
 block discarded – undo
7096 7096
 	}
7097 7097
 
7098 7098
 	/**
7099
-	* Counts all dates during the last month
7100
-	*
7101
-	* @return Array the date list
7102
-	*
7103
-	*/
7099
+	 * Counts all dates during the last month
7100
+	 *
7101
+	 * @return Array the date list
7102
+	 *
7103
+	 */
7104 7104
 	public function countAllDatesLastMonth()
7105 7105
 	{
7106 7106
 		global $globalTimezone, $globalDBdriver;
@@ -7124,7 +7124,7 @@  discard block
 block discarded – undo
7124 7124
 								GROUP BY date_name 
7125 7125
 								ORDER BY date_name ASC";
7126 7126
 			$query_data = array(':offset' => $offset);
7127
-    		}
7127
+			}
7128 7128
 		
7129 7129
 		$sth = $this->db->prepare($query);
7130 7130
 		$sth->execute($query_data);
@@ -7144,11 +7144,11 @@  discard block
 block discarded – undo
7144 7144
 	}
7145 7145
 	
7146 7146
 	/**
7147
-	* Counts all month
7148
-	*
7149
-	* @return Array the month list
7150
-	*
7151
-	*/
7147
+	 * Counts all month
7148
+	 *
7149
+	 * @return Array the month list
7150
+	 *
7151
+	 */
7152 7152
 	public function countAllMonths()
7153 7153
 	{
7154 7154
 		global $globalTimezone, $globalDBdriver;
@@ -7190,11 +7190,11 @@  discard block
 block discarded – undo
7190 7190
 	}
7191 7191
 
7192 7192
 	/**
7193
-	* Counts all military month
7194
-	*
7195
-	* @return Array the month list
7196
-	*
7197
-	*/
7193
+	 * Counts all military month
7194
+	 *
7195
+	 * @return Array the month list
7196
+	 *
7197
+	 */
7198 7198
 	public function countAllMilitaryMonths()
7199 7199
 	{
7200 7200
 		global $globalTimezone, $globalDBdriver;
@@ -7237,11 +7237,11 @@  discard block
 block discarded – undo
7237 7237
 	}
7238 7238
 	
7239 7239
 	/**
7240
-	* Counts all month owners
7241
-	*
7242
-	* @return Array the month list
7243
-	*
7244
-	*/
7240
+	 * Counts all month owners
7241
+	 *
7242
+	 * @return Array the month list
7243
+	 *
7244
+	 */
7245 7245
 	public function countAllMonthsOwners()
7246 7246
 	{
7247 7247
 		global $globalTimezone, $globalDBdriver;
@@ -7284,11 +7284,11 @@  discard block
 block discarded – undo
7284 7284
 	}
7285 7285
 
7286 7286
 	/**
7287
-	* Counts all month pilot
7288
-	*
7289
-	* @return Array the month list
7290
-	*
7291
-	*/
7287
+	 * Counts all month pilot
7288
+	 *
7289
+	 * @return Array the month list
7290
+	 *
7291
+	 */
7292 7292
 	public function countAllMonthsPilots()
7293 7293
 	{
7294 7294
 		global $globalTimezone, $globalDBdriver;
@@ -7332,11 +7332,11 @@  discard block
 block discarded – undo
7332 7332
 	
7333 7333
 
7334 7334
 	/**
7335
-	* Counts all month airline
7336
-	*
7337
-	* @return Array the month list
7338
-	*
7339
-	*/
7335
+	 * Counts all month airline
7336
+	 *
7337
+	 * @return Array the month list
7338
+	 *
7339
+	 */
7340 7340
 	public function countAllMonthsAirlines()
7341 7341
 	{
7342 7342
 		global $globalTimezone, $globalDBdriver;
@@ -7379,11 +7379,11 @@  discard block
 block discarded – undo
7379 7379
 	}
7380 7380
 	
7381 7381
 	/**
7382
-	* Counts all month aircraft
7383
-	*
7384
-	* @return Array the month list
7385
-	*
7386
-	*/
7382
+	 * Counts all month aircraft
7383
+	 *
7384
+	 * @return Array the month list
7385
+	 *
7386
+	 */
7387 7387
 	public function countAllMonthsAircrafts()
7388 7388
 	{
7389 7389
 		global $globalTimezone, $globalDBdriver;
@@ -7427,11 +7427,11 @@  discard block
 block discarded – undo
7427 7427
 	
7428 7428
 
7429 7429
 	/**
7430
-	* Counts all month real arrival
7431
-	*
7432
-	* @return Array the month list
7433
-	*
7434
-	*/
7430
+	 * Counts all month real arrival
7431
+	 *
7432
+	 * @return Array the month list
7433
+	 *
7434
+	 */
7435 7435
 	public function countAllMonthsRealArrivals()
7436 7436
 	{
7437 7437
 		global $globalTimezone, $globalDBdriver;
@@ -7476,11 +7476,11 @@  discard block
 block discarded – undo
7476 7476
 
7477 7477
 
7478 7478
 	/**
7479
-	* Counts all dates during the last year
7480
-	*
7481
-	* @return Array the date list
7482
-	*
7483
-	*/
7479
+	 * Counts all dates during the last year
7480
+	 *
7481
+	 * @return Array the date list
7482
+	 *
7483
+	 */
7484 7484
 	public function countAllMonthsLastYear()
7485 7485
 	{
7486 7486
 		global $globalTimezone, $globalDBdriver;
@@ -7506,7 +7506,7 @@  discard block
 block discarded – undo
7506 7506
 								GROUP BY year_name, month_name
7507 7507
 								ORDER BY year_name, month_name ASC";
7508 7508
 			$query_data = array(':offset' => $offset);
7509
-    		}
7509
+			}
7510 7510
 		
7511 7511
 		$sth = $this->db->prepare($query);
7512 7512
 		$sth->execute($query_data);
@@ -7529,11 +7529,11 @@  discard block
 block discarded – undo
7529 7529
 	
7530 7530
 	
7531 7531
 	/**
7532
-	* Counts all hours
7533
-	*
7534
-	* @return Array the hour list
7535
-	*
7536
-	*/
7532
+	 * Counts all hours
7533
+	 *
7534
+	 * @return Array the hour list
7535
+	 *
7536
+	 */
7537 7537
 	public function countAllHours($orderby)
7538 7538
 	{
7539 7539
 		global $globalTimezone, $globalDBdriver;
@@ -7592,11 +7592,11 @@  discard block
 block discarded – undo
7592 7592
 	
7593 7593
 	
7594 7594
 	/**
7595
-	* Counts all hours by airline
7596
-	*
7597
-	* @return Array the hour list
7598
-	*
7599
-	*/
7595
+	 * Counts all hours by airline
7596
+	 *
7597
+	 * @return Array the hour list
7598
+	 *
7599
+	 */
7600 7600
 	public function countAllHoursByAirline($airline_icao)
7601 7601
 	{
7602 7602
 		global $globalTimezone, $globalDBdriver;
@@ -7643,11 +7643,11 @@  discard block
 block discarded – undo
7643 7643
 	
7644 7644
 	
7645 7645
 	/**
7646
-	* Counts all hours by aircraft
7647
-	*
7648
-	* @return Array the hour list
7649
-	*
7650
-	*/
7646
+	 * Counts all hours by aircraft
7647
+	 *
7648
+	 * @return Array the hour list
7649
+	 *
7650
+	 */
7651 7651
 	public function countAllHoursByAircraft($aircraft_icao)
7652 7652
 	{
7653 7653
 		global $globalTimezone, $globalDBdriver;
@@ -7691,11 +7691,11 @@  discard block
 block discarded – undo
7691 7691
 	
7692 7692
 	
7693 7693
 	/**
7694
-	* Counts all hours by aircraft registration
7695
-	*
7696
-	* @return Array the hour list
7697
-	*
7698
-	*/
7694
+	 * Counts all hours by aircraft registration
7695
+	 *
7696
+	 * @return Array the hour list
7697
+	 *
7698
+	 */
7699 7699
 	public function countAllHoursByRegistration($registration)
7700 7700
 	{
7701 7701
 		global $globalTimezone, $globalDBdriver;
@@ -7739,11 +7739,11 @@  discard block
 block discarded – undo
7739 7739
 	
7740 7740
 	
7741 7741
 	/**
7742
-	* Counts all hours by airport
7743
-	*
7744
-	* @return Array the hour list
7745
-	*
7746
-	*/
7742
+	 * Counts all hours by airport
7743
+	 *
7744
+	 * @return Array the hour list
7745
+	 *
7746
+	 */
7747 7747
 	public function countAllHoursByAirport($airport_icao)
7748 7748
 	{
7749 7749
 		global $globalTimezone, $globalDBdriver;
@@ -7788,11 +7788,11 @@  discard block
 block discarded – undo
7788 7788
 	
7789 7789
 	
7790 7790
 	/**
7791
-	* Counts all hours by manufacturer
7792
-	*
7793
-	* @return Array the hour list
7794
-	*
7795
-	*/
7791
+	 * Counts all hours by manufacturer
7792
+	 *
7793
+	 * @return Array the hour list
7794
+	 *
7795
+	 */
7796 7796
 	public function countAllHoursByManufacturer($aircraft_manufacturer)
7797 7797
 	{
7798 7798
 		global $globalTimezone, $globalDBdriver;
@@ -7837,11 +7837,11 @@  discard block
 block discarded – undo
7837 7837
 	
7838 7838
 	
7839 7839
 	/**
7840
-	* Counts all hours by date
7841
-	*
7842
-	* @return Array the hour list
7843
-	*
7844
-	*/
7840
+	 * Counts all hours by date
7841
+	 *
7842
+	 * @return Array the hour list
7843
+	 *
7844
+	 */
7845 7845
 	public function countAllHoursByDate($date)
7846 7846
 	{
7847 7847
 		global $globalTimezone, $globalDBdriver;
@@ -7886,11 +7886,11 @@  discard block
 block discarded – undo
7886 7886
 	
7887 7887
 	
7888 7888
 	/**
7889
-	* Counts all hours by a ident/callsign
7890
-	*
7891
-	* @return Array the hour list
7892
-	*
7893
-	*/
7889
+	 * Counts all hours by a ident/callsign
7890
+	 *
7891
+	 * @return Array the hour list
7892
+	 *
7893
+	 */
7894 7894
 	public function countAllHoursByIdent($ident)
7895 7895
 	{
7896 7896
 		global $globalTimezone, $globalDBdriver;
@@ -7936,11 +7936,11 @@  discard block
 block discarded – undo
7936 7936
 	
7937 7937
 	
7938 7938
 	/**
7939
-	* Counts all hours by route
7940
-	*
7941
-	* @return Array the hour list
7942
-	*
7943
-	*/
7939
+	 * Counts all hours by route
7940
+	 *
7941
+	 * @return Array the hour list
7942
+	 *
7943
+	 */
7944 7944
 	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao)
7945 7945
 	{
7946 7946
 		global $globalTimezone, $globalDBdriver;
@@ -7985,11 +7985,11 @@  discard block
 block discarded – undo
7985 7985
 	
7986 7986
 	
7987 7987
 	/**
7988
-	* Counts all hours by country
7989
-	*
7990
-	* @return Array the hour list
7991
-	*
7992
-	*/
7988
+	 * Counts all hours by country
7989
+	 *
7990
+	 * @return Array the hour list
7991
+	 *
7992
+	 */
7993 7993
 	public function countAllHoursByCountry($country)
7994 7994
 	{
7995 7995
 		global $globalTimezone, $globalDBdriver;
@@ -8035,11 +8035,11 @@  discard block
 block discarded – undo
8035 8035
 
8036 8036
 
8037 8037
 	/**
8038
-	* Counts all aircraft that have flown over
8039
-	*
8040
-	* @return Integer the number of aircrafts
8041
-	*
8042
-	*/
8038
+	 * Counts all aircraft that have flown over
8039
+	 *
8040
+	 * @return Integer the number of aircrafts
8041
+	 *
8042
+	 */
8043 8043
 	public function countOverallAircrafts()
8044 8044
 	{
8045 8045
 		$query  = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
@@ -8053,11 +8053,11 @@  discard block
 block discarded – undo
8053 8053
 	}
8054 8054
 
8055 8055
 	/**
8056
-	* Counts all flight that really arrival
8057
-	*
8058
-	* @return Integer the number of aircrafts
8059
-	*
8060
-	*/
8056
+	 * Counts all flight that really arrival
8057
+	 *
8058
+	 * @return Integer the number of aircrafts
8059
+	 *
8060
+	 */
8061 8061
 	public function countOverallArrival()
8062 8062
 	{
8063 8063
 		$query  = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
@@ -8071,11 +8071,11 @@  discard block
 block discarded – undo
8071 8071
 	}
8072 8072
 
8073 8073
 	/**
8074
-	* Counts all pilots that have flown over
8075
-	*
8076
-	* @return Integer the number of pilots
8077
-	*
8078
-	*/
8074
+	 * Counts all pilots that have flown over
8075
+	 *
8076
+	 * @return Integer the number of pilots
8077
+	 *
8078
+	 */
8079 8079
 	public function countOverallPilots()
8080 8080
 	{
8081 8081
 		$query  = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
@@ -8089,11 +8089,11 @@  discard block
 block discarded – undo
8089 8089
 	}
8090 8090
 
8091 8091
 	/**
8092
-	* Counts all owners that have flown over
8093
-	*
8094
-	* @return Integer the number of owners
8095
-	*
8096
-	*/
8092
+	 * Counts all owners that have flown over
8093
+	 *
8094
+	 * @return Integer the number of owners
8095
+	 *
8096
+	 */
8097 8097
 	public function countOverallOwners()
8098 8098
 	{
8099 8099
 		$query  = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
@@ -8108,11 +8108,11 @@  discard block
 block discarded – undo
8108 8108
 	
8109 8109
 	
8110 8110
 	/**
8111
-	* Counts all flights that have flown over
8112
-	*
8113
-	* @return Integer the number of flights
8114
-	*
8115
-	*/
8111
+	 * Counts all flights that have flown over
8112
+	 *
8113
+	 * @return Integer the number of flights
8114
+	 *
8115
+	 */
8116 8116
 	public function countOverallFlights()
8117 8117
 	{
8118 8118
 		$query  = "SELECT COUNT(spotter_output.spotter_id) AS flight_count  
@@ -8125,11 +8125,11 @@  discard block
 block discarded – undo
8125 8125
 	}
8126 8126
 	
8127 8127
 	/**
8128
-	* Counts all military flights that have flown over
8129
-	*
8130
-	* @return Integer the number of flights
8131
-	*
8132
-	*/
8128
+	 * Counts all military flights that have flown over
8129
+	 *
8130
+	 * @return Integer the number of flights
8131
+	 *
8132
+	 */
8133 8133
 	public function countOverallMilitaryFlights()
8134 8134
 	{
8135 8135
 		$query  = "SELECT COUNT(s.spotter_id) AS flight_count  
@@ -8144,11 +8144,11 @@  discard block
 block discarded – undo
8144 8144
 	
8145 8145
 	
8146 8146
 	/**
8147
-	* Counts all airlines that have flown over
8148
-	*
8149
-	* @return Integer the number of airlines
8150
-	*
8151
-	*/
8147
+	 * Counts all airlines that have flown over
8148
+	 *
8149
+	 * @return Integer the number of airlines
8150
+	 *
8151
+	 */
8152 8152
 	public function countOverallAirlines()
8153 8153
 	{
8154 8154
 		$query  = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count 
@@ -8162,11 +8162,11 @@  discard block
 block discarded – undo
8162 8162
 
8163 8163
   
8164 8164
 	/**
8165
-	* Counts all hours of today
8166
-	*
8167
-	* @return Array the hour list
8168
-	*
8169
-	*/
8165
+	 * Counts all hours of today
8166
+	 *
8167
+	 * @return Array the hour list
8168
+	 *
8169
+	 */
8170 8170
 	public function countAllHoursFromToday()
8171 8171
 	{
8172 8172
 		global $globalTimezone, $globalDBdriver;
@@ -8207,11 +8207,11 @@  discard block
 block discarded – undo
8207 8207
 	}
8208 8208
     
8209 8209
 	/**
8210
-	* Gets all the spotter information based on calculated upcoming flights
8211
-	*
8212
-	* @return Array the spotter information
8213
-	*
8214
-	*/
8210
+	 * Gets all the spotter information based on calculated upcoming flights
8211
+	 *
8212
+	 * @return Array the spotter information
8213
+	 *
8214
+	 */
8215 8215
 	public function getUpcomingFlights($limit = '', $sort = '')
8216 8216
 	{
8217 8217
 		global $global_query, $globalDBdriver, $globalTimezone;
@@ -8273,12 +8273,12 @@  discard block
 block discarded – undo
8273 8273
 	}
8274 8274
     
8275 8275
     
8276
-     /**
8277
-	* Gets the Barrie Spotter ID based on the FlightAware ID
8278
-	*
8279
-	* @return Integer the Barrie Spotter ID
8280
-	*
8281
-	*/
8276
+	 /**
8277
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
8278
+	  *
8279
+	  * @return Integer the Barrie Spotter ID
8280
+	  *
8281
+	  */
8282 8282
 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id)
8283 8283
 	{
8284 8284
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -8299,13 +8299,13 @@  discard block
 block discarded – undo
8299 8299
   
8300 8300
  
8301 8301
 	/**
8302
-	* Parses a date string
8303
-	*
8304
-	* @param String $dateString the date string
8305
-	* @param String $timezone the timezone of a user
8306
-	* @return Array the time information
8307
-	*
8308
-	*/
8302
+	 * Parses a date string
8303
+	 *
8304
+	 * @param String $dateString the date string
8305
+	 * @param String $timezone the timezone of a user
8306
+	 * @return Array the time information
8307
+	 *
8308
+	 */
8309 8309
 	public function parseDateString($dateString, $timezone = '')
8310 8310
 	{
8311 8311
 		$time_array = array();
@@ -8341,12 +8341,12 @@  discard block
 block discarded – undo
8341 8341
 	
8342 8342
 	
8343 8343
 	/**
8344
-	* Parses the direction degrees to working
8345
-	*
8346
-	* @param Float $direction the direction in degrees
8347
-	* @return Array the direction information
8348
-	*
8349
-	*/
8344
+	 * Parses the direction degrees to working
8345
+	 *
8346
+	 * @param Float $direction the direction in degrees
8347
+	 * @return Array the direction information
8348
+	 *
8349
+	 */
8350 8350
 	public function parseDirection($direction = 0)
8351 8351
 	{
8352 8352
 		if ($direction == '') $direction = 0;
@@ -8425,18 +8425,18 @@  discard block
 block discarded – undo
8425 8425
 	
8426 8426
 	
8427 8427
 	/**
8428
-	* Gets the aircraft registration
8429
-	*
8430
-	* @param String $flightaware_id the flight aware id
8431
-	* @return String the aircraft registration
8432
-	*
8433
-	*/
8428
+	 * Gets the aircraft registration
8429
+	 *
8430
+	 * @param String $flightaware_id the flight aware id
8431
+	 * @return String the aircraft registration
8432
+	 *
8433
+	 */
8434 8434
 	
8435 8435
 	public function getAircraftRegistration($flightaware_id)
8436 8436
 	{
8437 8437
 		global $globalFlightAwareUsername, $globalFlightAwarePassword;
8438 8438
         
8439
-        $options = array(
8439
+		$options = array(
8440 8440
 			'trace' => true,
8441 8441
 			'exceptions' => 0,
8442 8442
 			'login' => $globalFlightAwareUsername,
@@ -8459,12 +8459,12 @@  discard block
 block discarded – undo
8459 8459
 
8460 8460
 
8461 8461
 	/**
8462
-	* Gets the aircraft registration from ModeS
8463
-	*
8464
-	* @param String $aircraft_modes the flight ModeS in hex
8465
-	* @return String the aircraft registration
8466
-	*
8467
-	*/
8462
+	 * Gets the aircraft registration from ModeS
8463
+	 *
8464
+	 * @param String $aircraft_modes the flight ModeS in hex
8465
+	 * @return String the aircraft registration
8466
+	 *
8467
+	 */
8468 8468
 	
8469 8469
 	public function getAircraftRegistrationBymodeS($aircraft_modes)
8470 8470
 	{
@@ -8477,19 +8477,19 @@  discard block
 block discarded – undo
8477 8477
     
8478 8478
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
8479 8479
 		if (count($row) > 0) {
8480
-		    //return $row['Registration'];
8481
-		    return $row['registration'];
8480
+			//return $row['Registration'];
8481
+			return $row['registration'];
8482 8482
 		} else return '';
8483 8483
 	
8484 8484
 	}
8485 8485
 
8486 8486
 	/**
8487
-	* Gets the aircraft type from ModeS
8488
-	*
8489
-	* @param String $aircraft_modes the flight ModeS in hex
8490
-	* @return String the aircraft type
8491
-	*
8492
-	*/
8487
+	 * Gets the aircraft type from ModeS
8488
+	 *
8489
+	 * @param String $aircraft_modes the flight ModeS in hex
8490
+	 * @return String the aircraft type
8491
+	 *
8492
+	 */
8493 8493
 	
8494 8494
 	public function getAircraftTypeBymodeS($aircraft_modes)
8495 8495
 	{
@@ -8502,19 +8502,19 @@  discard block
 block discarded – undo
8502 8502
     
8503 8503
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
8504 8504
 		if (count($row) > 0) {
8505
-		    if ($row['type_flight'] == null) return '';
8506
-		    else return $row['type_flight'];
8505
+			if ($row['type_flight'] == null) return '';
8506
+			else return $row['type_flight'];
8507 8507
 		} else return '';
8508 8508
 	
8509 8509
 	}
8510 8510
 
8511 8511
 	/**
8512
-	* Gets Countrie from latitude/longitude
8513
-	*
8514
-	* @param String $aircraft_modes the flight ModeS in hex
8515
-	* @return String the aircraft registration
8516
-	*
8517
-	*/
8512
+	 * Gets Countrie from latitude/longitude
8513
+	 *
8514
+	 * @param String $aircraft_modes the flight ModeS in hex
8515
+	 * @return String the aircraft registration
8516
+	 *
8517
+	 */
8518 8518
 	
8519 8519
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
8520 8520
 	{
@@ -8548,12 +8548,12 @@  discard block
 block discarded – undo
8548 8548
 	}
8549 8549
 
8550 8550
 	/**
8551
-	* converts the registration code using the country prefix
8552
-	*
8553
-	* @param String $registration the aircraft registration
8554
-	* @return String the aircraft registration
8555
-	*
8556
-	*/
8551
+	 * converts the registration code using the country prefix
8552
+	 *
8553
+	 * @param String $registration the aircraft registration
8554
+	 * @return String the aircraft registration
8555
+	 *
8556
+	 */
8557 8557
 	public function convertAircraftRegistration($registration)
8558 8558
 	{
8559 8559
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -8591,28 +8591,28 @@  discard block
 block discarded – undo
8591 8591
 		if (strlen($registration_prefix) == 1)
8592 8592
 		{
8593 8593
 			if (0 === strpos($registration, 'N')) {
8594
-                $registration = preg_replace("/^(.{1})/", "$1", $registration);
8595
-            } else {
8596
-                $registration = preg_replace("/^(.{1})/", "$1-", $registration);
8597
-            }
8594
+				$registration = preg_replace("/^(.{1})/", "$1", $registration);
8595
+			} else {
8596
+				$registration = preg_replace("/^(.{1})/", "$1-", $registration);
8597
+			}
8598 8598
 		} else if(strlen($registration_prefix) == 2){
8599
-            if (0 === strpos($registration, 'N')) {
8600
-                $registration = preg_replace("/^(.{2})/", "$1", $registration);
8601
-            } else {
8602
-                $registration = preg_replace("/^(.{2})/", "$1-", $registration);
8603
-            }
8599
+			if (0 === strpos($registration, 'N')) {
8600
+				$registration = preg_replace("/^(.{2})/", "$1", $registration);
8601
+			} else {
8602
+				$registration = preg_replace("/^(.{2})/", "$1-", $registration);
8603
+			}
8604 8604
 		}
8605 8605
 
8606 8606
 		return $registration;	
8607 8607
 	}
8608 8608
 
8609 8609
 	/**
8610
-	* Country from the registration code
8611
-	*
8612
-	* @param String $registration the aircraft registration
8613
-	* @return String the country
8614
-	*
8615
-	*/
8610
+	 * Country from the registration code
8611
+	 *
8612
+	 * @param String $registration the aircraft registration
8613
+	 * @return String the country
8614
+	 *
8615
+	 */
8616 8616
 	public function countryFromAircraftRegistration($registration)
8617 8617
 	{
8618 8618
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -8633,8 +8633,8 @@  discard block
 block discarded – undo
8633 8633
 				$country = $row['country'];
8634 8634
 			}
8635 8635
 		} else {
8636
-    			$registration_1 = substr($registration, 0, 1);
8637
-		        $registration_2 = substr($registration, 0, 2);
8636
+				$registration_1 = substr($registration, 0, 1);
8637
+				$registration_2 = substr($registration, 0, 2);
8638 8638
 
8639 8639
 			$country = '';
8640 8640
 			//first get the prefix based on two characters
@@ -8670,11 +8670,11 @@  discard block
 block discarded – undo
8670 8670
 	}
8671 8671
 	
8672 8672
 	/**
8673
-	* Set a new highlight value for a flight
8674
-	*
8675
-	* @param String $flightaware_id flightaware_id from spotter_output table
8676
-	* @param String $highlight New highlight value
8677
-	*/
8673
+	 * Set a new highlight value for a flight
8674
+	 *
8675
+	 * @param String $flightaware_id flightaware_id from spotter_output table
8676
+	 * @param String $highlight New highlight value
8677
+	 */
8678 8678
 	public function setHighlightFlight($flightaware_id,$highlight) {
8679 8679
 		
8680 8680
 		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
@@ -8683,12 +8683,12 @@  discard block
 block discarded – undo
8683 8683
 	}
8684 8684
 	
8685 8685
 	/**
8686
-	* Gets the short url from bit.ly
8687
-	*
8688
-	* @param String $url the full url
8689
-	* @return String the bit.ly url
8690
-	*
8691
-	*/
8686
+	 * Gets the short url from bit.ly
8687
+	 *
8688
+	 * @param String $url the full url
8689
+	 * @return String the bit.ly url
8690
+	 *
8691
+	 */
8692 8692
 	public function getBitlyURL($url)
8693 8693
 	{
8694 8694
 		global $globalBitlyAccessToken;
@@ -8723,130 +8723,130 @@  discard block
 block discarded – undo
8723 8723
 	}
8724 8724
     
8725 8725
     
8726
-    public function importFromFlightAware()
8727
-    {
8728
-       global $globalFlightAwareUsername, $globalFlightAwarePassword, $globalLatitudeMax, $globalLatitudeMin, $globalLongitudeMax, $globalLongitudeMin, $globalAirportIgnore;
8726
+	public function importFromFlightAware()
8727
+	{
8728
+	   global $globalFlightAwareUsername, $globalFlightAwarePassword, $globalLatitudeMax, $globalLatitudeMin, $globalLongitudeMax, $globalLongitudeMin, $globalAirportIgnore;
8729 8729
 	$Spotter = new Spotter($this->db);
8730 8730
 	$SPotterLive = new SpotterLive($this->db);
8731
-        $options = array(
8732
-            'trace' => true,
8733
-            'exceptions' => 0,
8734
-            'login' => $globalFlightAwareUsername,
8735
-            'password' => $globalFlightAwarePassword,
8736
-        );
8737
-        $client = new SoapClient('http://flightxml.flightaware.com/soap/FlightXML2/wsdl', $options);
8738
-
8739
-        $params = array('query' => '{range lat '.$globalLatitudeMin.' '.$globalLatitudeMax.'} {range lon '.$globalLongitudeMax.' '.$globalLongitudeMin.'} {true inAir}', 'howMany' => '15', 'offset' => '0');
8731
+		$options = array(
8732
+			'trace' => true,
8733
+			'exceptions' => 0,
8734
+			'login' => $globalFlightAwareUsername,
8735
+			'password' => $globalFlightAwarePassword,
8736
+		);
8737
+		$client = new SoapClient('http://flightxml.flightaware.com/soap/FlightXML2/wsdl', $options);
8738
+
8739
+		$params = array('query' => '{range lat '.$globalLatitudeMin.' '.$globalLatitudeMax.'} {range lon '.$globalLongitudeMax.' '.$globalLongitudeMin.'} {true inAir}', 'howMany' => '15', 'offset' => '0');
8740 8740
         
8741
-        $result = $client->SearchBirdseyeInFlight($params);
8741
+		$result = $client->SearchBirdseyeInFlight($params);
8742 8742
 
8743
-        $dataFound = false;
8744
-        $ignoreImport = false;
8743
+		$dataFound = false;
8744
+		$ignoreImport = false;
8745 8745
         
8746
-        if (isset($result->SearchBirdseyeInFlightResult))
8747
-        {
8748
-            if (is_array($result->SearchBirdseyeInFlightResult->aircraft))
8749
-            {
8750
-                    foreach($result->SearchBirdseyeInFlightResult->aircraft as $aircraft)
8751
-                    {
8752
-                        if (!strstr($aircraft->origin, 'L ') && !strstr($aircraft->destination, 'L '))
8753
-                        {
8754
-                            foreach($globalAirportIgnore as $airportIgnore)
8755
-                            {
8756
-                                if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore)
8757
-                                {
8758
-                                   $ignoreImport = true; 
8759
-                                }
8760
-                            }
8761
-                            if ($ignoreImport == false)
8762
-                            {
8763
-                            $flightaware_id = $aircraft->faFlightID;
8764
-                            $ident = $aircraft->ident;
8765
-                            $aircraft_type = $aircraft->type;
8766
-                            $departure_airport = $aircraft->origin;
8767
-                            $arrival_airport = $aircraft->destination;
8768
-                            $latitude = $aircraft->latitude;
8769
-                            $longitude = $aircraft->longitude;
8770
-                            $waypoints = $aircraft->waypoints;
8771
-                            $altitude = $aircraft->altitude;
8772
-                            $heading = $aircraft->heading;
8773
-                            $groundspeed = $aircraft->groundspeed;
8774
-
8775
-                            $dataFound = true;
8776
-
8777
-                            //gets the callsign from the last hour
8778
-                            $last_hour_ident = $this->getIdentFromLastHour($ident);
8779
-
8780
-                            //change the departure/arrival airport to NA if its not available
8781
-                                if ($departure_airport == "" || $departure_airport == "---" || $departure_airport == "ZZZ" || $departure_airport == "ZZZZ") { $departure_airport = "NA"; }
8782
-                                if ($arrival_airport == "" || $arrival_airport == "---" || $arrival_airport == "ZZZ" || $arrival_airport == "ZZZZ") { $arrival_airport = "NA"; }
8783
-
8784
-
8785
-                            //if there was no aircraft with the same callsign within the last hour and go post it into the archive
8786
-                            if($last_hour_ident == "")
8787
-                            {
8788
-                                //adds the spotter data for the archive
8789
-                                $Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
8790
-                            }
8791
-
8792
-                            //adds the spotter LIVE data
8793
-                            $SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
8794
-                        }
8795
-                        }
8796
-                        $ignoreImport = false;
8797
-                    }
8798
-                } else {
8799
-                    if (!strstr($result->SearchBirdseyeInFlightResult->aircraft->origin, 'L ') && !strstr($result->SearchBirdseyeInFlightResult->aircraft->destination, 'L '))
8800
-                    {
8801
-                        foreach($globalAirportIgnore as $airportIgnore)
8802
-                        {
8803
-                            foreach($globalAirportIgnore as $airportIgnore)
8804
-                            {
8805
-                                if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore)
8806
-                                {
8807
-                                   $ignoreImport = true; 
8808
-                                }
8809
-                            }
8810
-                            if ($ignoreImport == false)
8811
-                            {
8812
-                        $flightaware_id = $result->SearchBirdseyeInFlightResult->aircraft->faFlightID;
8813
-                        $ident = $result->SearchBirdseyeInFlightResult->aircraft->ident;
8814
-                        $aircraft_type = $result->SearchBirdseyeInFlightResult->aircraft->type;
8815
-                        $departure_airport = $result->SearchBirdseyeInFlightResult->aircraft->origin;
8816
-                        $arrival_airport = $result->SearchBirdseyeInFlightResult->aircraft->destination;
8817
-                        $latitude = $result->SearchBirdseyeInFlightResult->aircraft->latitude;
8818
-                        $longitude = $result->SearchBirdseyeInFlightResult->aircraft->longitude;
8819
-                        $waypoints = $result->SearchBirdseyeInFlightResult->aircraft->waypoints;
8820
-                        $altitude = $result->SearchBirdseyeInFlightResult->aircraft->altitude;
8821
-                        $heading = $result->SearchBirdseyeInFlightResult->aircraft->heading;
8822
-                        $groundspeed = $result->SearchBirdseyeInFlightResult->aircraft->groundspeed;
8823
-
8824
-                        $dataFound = true;
8825
-
8826
-                        //gets the callsign from the last hour
8827
-                        $last_hour_ident = $this->getIdentFromLastHour($ident);
8828
-
8829
-                        //change the departure/arrival airport to NA if its not available
8830
-                                if ($departure_airport == "" || $departure_airport == "---" || $departure_airport == "ZZZ" || $departure_airport == "ZZZZ") { $departure_airport = "NA"; }
8831
-                                if ($arrival_airport == "" || $arrival_airport == "---" || $arrival_airport == "ZZZ" || $arrival_airport == "ZZZZ") { $arrival_airport = "NA"; }
8832
-
8833
-                        //if there was no aircraft with the same callsign within the last hour and go post it into the archive
8834
-                        if($last_hour_ident == "")
8835
-                        {
8836
-                            //adds the spotter data for the archive
8837
-                            $Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
8838
-                        }
8839
-
8840
-                        //adds the spotter LIVE data
8841
-                        $SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
8842
-                    }
8843
-                            $ignoreImport = false;
8844
-                        }
8845
-                    }
8846
-
8847
-                }
8848
-        } 
8849
-    }
8746
+		if (isset($result->SearchBirdseyeInFlightResult))
8747
+		{
8748
+			if (is_array($result->SearchBirdseyeInFlightResult->aircraft))
8749
+			{
8750
+					foreach($result->SearchBirdseyeInFlightResult->aircraft as $aircraft)
8751
+					{
8752
+						if (!strstr($aircraft->origin, 'L ') && !strstr($aircraft->destination, 'L '))
8753
+						{
8754
+							foreach($globalAirportIgnore as $airportIgnore)
8755
+							{
8756
+								if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore)
8757
+								{
8758
+								   $ignoreImport = true; 
8759
+								}
8760
+							}
8761
+							if ($ignoreImport == false)
8762
+							{
8763
+							$flightaware_id = $aircraft->faFlightID;
8764
+							$ident = $aircraft->ident;
8765
+							$aircraft_type = $aircraft->type;
8766
+							$departure_airport = $aircraft->origin;
8767
+							$arrival_airport = $aircraft->destination;
8768
+							$latitude = $aircraft->latitude;
8769
+							$longitude = $aircraft->longitude;
8770
+							$waypoints = $aircraft->waypoints;
8771
+							$altitude = $aircraft->altitude;
8772
+							$heading = $aircraft->heading;
8773
+							$groundspeed = $aircraft->groundspeed;
8774
+
8775
+							$dataFound = true;
8776
+
8777
+							//gets the callsign from the last hour
8778
+							$last_hour_ident = $this->getIdentFromLastHour($ident);
8779
+
8780
+							//change the departure/arrival airport to NA if its not available
8781
+								if ($departure_airport == "" || $departure_airport == "---" || $departure_airport == "ZZZ" || $departure_airport == "ZZZZ") { $departure_airport = "NA"; }
8782
+								if ($arrival_airport == "" || $arrival_airport == "---" || $arrival_airport == "ZZZ" || $arrival_airport == "ZZZZ") { $arrival_airport = "NA"; }
8783
+
8784
+
8785
+							//if there was no aircraft with the same callsign within the last hour and go post it into the archive
8786
+							if($last_hour_ident == "")
8787
+							{
8788
+								//adds the spotter data for the archive
8789
+								$Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
8790
+							}
8791
+
8792
+							//adds the spotter LIVE data
8793
+							$SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
8794
+						}
8795
+						}
8796
+						$ignoreImport = false;
8797
+					}
8798
+				} else {
8799
+					if (!strstr($result->SearchBirdseyeInFlightResult->aircraft->origin, 'L ') && !strstr($result->SearchBirdseyeInFlightResult->aircraft->destination, 'L '))
8800
+					{
8801
+						foreach($globalAirportIgnore as $airportIgnore)
8802
+						{
8803
+							foreach($globalAirportIgnore as $airportIgnore)
8804
+							{
8805
+								if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore)
8806
+								{
8807
+								   $ignoreImport = true; 
8808
+								}
8809
+							}
8810
+							if ($ignoreImport == false)
8811
+							{
8812
+						$flightaware_id = $result->SearchBirdseyeInFlightResult->aircraft->faFlightID;
8813
+						$ident = $result->SearchBirdseyeInFlightResult->aircraft->ident;
8814
+						$aircraft_type = $result->SearchBirdseyeInFlightResult->aircraft->type;
8815
+						$departure_airport = $result->SearchBirdseyeInFlightResult->aircraft->origin;
8816
+						$arrival_airport = $result->SearchBirdseyeInFlightResult->aircraft->destination;
8817
+						$latitude = $result->SearchBirdseyeInFlightResult->aircraft->latitude;
8818
+						$longitude = $result->SearchBirdseyeInFlightResult->aircraft->longitude;
8819
+						$waypoints = $result->SearchBirdseyeInFlightResult->aircraft->waypoints;
8820
+						$altitude = $result->SearchBirdseyeInFlightResult->aircraft->altitude;
8821
+						$heading = $result->SearchBirdseyeInFlightResult->aircraft->heading;
8822
+						$groundspeed = $result->SearchBirdseyeInFlightResult->aircraft->groundspeed;
8823
+
8824
+						$dataFound = true;
8825
+
8826
+						//gets the callsign from the last hour
8827
+						$last_hour_ident = $this->getIdentFromLastHour($ident);
8828
+
8829
+						//change the departure/arrival airport to NA if its not available
8830
+								if ($departure_airport == "" || $departure_airport == "---" || $departure_airport == "ZZZ" || $departure_airport == "ZZZZ") { $departure_airport = "NA"; }
8831
+								if ($arrival_airport == "" || $arrival_airport == "---" || $arrival_airport == "ZZZ" || $arrival_airport == "ZZZZ") { $arrival_airport = "NA"; }
8832
+
8833
+						//if there was no aircraft with the same callsign within the last hour and go post it into the archive
8834
+						if($last_hour_ident == "")
8835
+						{
8836
+							//adds the spotter data for the archive
8837
+							$Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
8838
+						}
8839
+
8840
+						//adds the spotter LIVE data
8841
+						$SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
8842
+					}
8843
+							$ignoreImport = false;
8844
+						}
8845
+					}
8846
+
8847
+				}
8848
+		} 
8849
+	}
8850 8850
 
8851 8851
 
8852 8852
 	// Update flights data when new data in DB
@@ -8987,11 +8987,11 @@  discard block
 block discarded – undo
8987 8987
 			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
8988 8988
 	                      FROM airport WHERE longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
8989 8989
 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;";
8990
-                } else {
8990
+				} else {
8991 8991
 			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2))) as distance 
8992 8992
 	                      FROM airport WHERE CAST(longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
8993 8993
 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;";
8994
-    		}
8994
+			}
8995 8995
 		$sth = $this->db->prepare($query);
8996 8996
 		$sth->execute();
8997 8997
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Spacing   +699 added lines, -699 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 require_once(dirname(__FILE__).'/class.Image.php');
5 5
 $global_query = "SELECT spotter_output.* FROM spotter_output";
6 6
 
7
-class Spotter{
7
+class Spotter {
8 8
 	public $db;
9 9
 	
10 10
 	function __construct($dbc = null) {
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 			$sth = $this->db->prepare($query.$limitQuery);
50 50
 			$sth->execute($params);
51 51
 		} catch (PDOException $e) {
52
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
52
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
53 53
 			exit();
54 54
 		}
55 55
 		
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 		$temp_array = array();
61 61
 		
62 62
 
63
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
63
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
64 64
 		{
65 65
 			$num_rows++;
66 66
 			$temp_array = array();
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 			if (isset($row['route_stop'])) {
106 106
 				$temp_array['route_stop'] = $row['route_stop'];
107 107
 				if ($row['route_stop'] != '') {
108
-					$allroute = explode(' ',$row['route_stop']);
108
+					$allroute = explode(' ', $row['route_stop']);
109 109
 			
110 110
 					foreach ($allroute as $route) {
111 111
 						$route_airport_array = $this->getAllAirportInfo($route);
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
 			{
157 157
 				$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
158 158
 			} else {
159
-				$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
159
+				$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
160 160
 			}
161 161
 			$temp_array['date_minutes_past'] = $dateArray['minutes'];
162
-			$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
163
-			$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
162
+			$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
163
+			$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
164 164
 			$temp_array['date_unix'] = strtotime($row['date']." UTC");
165 165
 			
166 166
 			if (isset($row['aircraft_name']) && $row['aircraft_name'] != '' && isset($row['aircraft_shadow']) && $row['aircraft_shadow'] != '') {
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 				$temp_array['airline_type'] = $row['airline_type'];
217 217
 			}
218 218
 			if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') {
219
-				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'],3));
219
+				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'], 3));
220 220
 				//$acars_array = ACARS->getLiveAcarsData('BA40YL');
221 221
 				if (count($acars_array) > 0) {
222 222
 					$temp_array['acars'] = $acars_array;
@@ -233,11 +233,11 @@  discard block
 block discarded – undo
233 233
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
234 234
 			}
235 235
 
236
-			if($temp_array['registration'] != "" || ($globalIVAO && $temp_array['aircraft_type'] != ''))
236
+			if ($temp_array['registration'] != "" || ($globalIVAO && $temp_array['aircraft_type'] != ''))
237 237
 			{
238 238
 				if ($globalIVAO) {
239
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
240
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
239
+					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('', $temp_array['aircraft_type'], $temp_array['airline_icao']);
240
+					else $image_array = $Image->getSpotterImage('', $temp_array['aircraft_type']);
241 241
 				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
242 242
 				if (count($image_array) > 0) {
243 243
 					$temp_array['image'] = $image_array[0]['image'];
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 			if (isset($row['arrival_airport_time']) && $row['arrival_airport_time'] != '') {
261 261
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
262 262
 			}
263
-			if ((!isset($globalIVAO) || ! $globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
263
+			if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
264 264
 				$schedule_array = $Schedule->getSchedule($temp_array['ident']);
265 265
 				//print_r($schedule_array);
266 266
 				if (count($schedule_array) > 0) {
@@ -341,12 +341,12 @@  discard block
 block discarded – undo
341 341
 			if (isset($row['squawk'])) {
342 342
 				$temp_array['squawk'] = $row['squawk'];
343 343
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
344
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
345
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
344
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['country_iso2']);
345
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
346 346
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
347
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
348
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
349
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
347
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['over_country']);
348
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
349
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
350 350
 			}
351 351
     			
352 352
 			$temp_array['query_number_rows'] = $num_rows;
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	* @return Array the spotter information
366 366
 	*
367 367
 	*/
368
-	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 = '')
368
+	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 = '')
369 369
 	{
370 370
 		global $globalTimezone, $globalDBdriver;
371 371
 		require_once(dirname(__FILE__).'/class.Translation.php');
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 				return false;
383 383
 			} else {
384 384
 				$q_array = explode(" ", $q);
385
-				foreach ($q_array as $q_item){
386
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
385
+				foreach ($q_array as $q_item) {
386
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
387 387
 					$additional_query .= " AND (";
388 388
 					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
389 389
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -415,37 +415,37 @@  discard block
 block discarded – undo
415 415
 
416 416
 		if ($registration != "")
417 417
 		{
418
-			$registration = filter_var($registration,FILTER_SANITIZE_STRING);
418
+			$registration = filter_var($registration, FILTER_SANITIZE_STRING);
419 419
 			if (!is_string($registration))
420 420
 			{
421 421
 				return false;
422 422
 			} else {
423 423
 				$additional_query .= " AND spotter_output.registration = :registration";
424
-				$query_values = array_merge($query_values,array(':registration' => $registration));
424
+				$query_values = array_merge($query_values, array(':registration' => $registration));
425 425
 			}
426 426
 		}
427 427
 
428 428
 		if ($aircraft_icao != "")
429 429
 		{
430
-			$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
430
+			$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
431 431
 			if (!is_string($aircraft_icao))
432 432
 			{
433 433
 				return false;
434 434
 			} else {
435 435
 				$additional_query .= " AND spotter_output.aircraft_icao = :aircraft_icao";
436
-				$query_values = array_merge($query_values,array(':aircraft_icao' => $aircraft_icao));
436
+				$query_values = array_merge($query_values, array(':aircraft_icao' => $aircraft_icao));
437 437
 			}
438 438
 		}
439 439
 
440 440
 		if ($aircraft_manufacturer != "")
441 441
 		{
442
-			$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
442
+			$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
443 443
 			if (!is_string($aircraft_manufacturer))
444 444
 			{
445 445
 				return false;
446 446
 			} else {
447 447
 				$additional_query .= " AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer";
448
-				$query_values = array_merge($query_values,array(':aircraft_manufacturer' => $aircraft_manufacturer));
448
+				$query_values = array_merge($query_values, array(':aircraft_manufacturer' => $aircraft_manufacturer));
449 449
 			}
450 450
 		}
451 451
 
@@ -461,25 +461,25 @@  discard block
 block discarded – undo
461 461
 
462 462
 		if ($airline_icao != "")
463 463
 		{
464
-			$registration = filter_var($airline_icao,FILTER_SANITIZE_STRING);
464
+			$registration = filter_var($airline_icao, FILTER_SANITIZE_STRING);
465 465
 			if (!is_string($airline_icao))
466 466
 			{
467 467
 				return false;
468 468
 			} else {
469 469
 				$additional_query .= " AND spotter_output.airline_icao = :airline_icao";
470
-				$query_values = array_merge($query_values,array(':airline_icao' => $airline_icao));
470
+				$query_values = array_merge($query_values, array(':airline_icao' => $airline_icao));
471 471
 			}
472 472
 		}
473 473
 
474 474
 		if ($airline_country != "")
475 475
 		{
476
-			$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
476
+			$airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
477 477
 			if (!is_string($airline_country))
478 478
 			{
479 479
 				return false;
480 480
 			} else {
481 481
 				$additional_query .= " AND spotter_output.airline_country = :airline_country";
482
-				$query_values = array_merge($query_values,array(':airline_country' => $airline_country));
482
+				$query_values = array_merge($query_values, array(':airline_country' => $airline_country));
483 483
 			}
484 484
 		}
485 485
 
@@ -506,31 +506,31 @@  discard block
 block discarded – undo
506 506
 
507 507
 		if ($airport != "")
508 508
 		{
509
-			$airport = filter_var($airport,FILTER_SANITIZE_STRING);
509
+			$airport = filter_var($airport, FILTER_SANITIZE_STRING);
510 510
 			if (!is_string($airport))
511 511
 			{
512 512
 				return false;
513 513
 			} else {
514 514
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :airport OR spotter_output.arrival_airport_icao = :airport)";
515
-				$query_values = array_merge($query_values,array(':airport' => $airport));
515
+				$query_values = array_merge($query_values, array(':airport' => $airport));
516 516
 			}
517 517
 		}
518 518
 
519 519
 		if ($airport_country != "")
520 520
 		{
521
-			$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
521
+			$airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
522 522
 			if (!is_string($airport_country))
523 523
 			{
524 524
 				return false;
525 525
 			} else {
526 526
 				$additional_query .= " AND (spotter_output.departure_airport_country = :airport_country OR spotter_output.arrival_airport_country = :airport_country)";
527
-				$query_values = array_merge($query_values,array(':airport_country' => $airport_country));
527
+				$query_values = array_merge($query_values, array(':airport_country' => $airport_country));
528 528
 			}
529 529
 		}
530 530
     
531 531
 		if ($callsign != "")
532 532
 		{
533
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
533
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
534 534
 			if (!is_string($callsign))
535 535
 			{
536 536
 				return false;
@@ -538,79 +538,79 @@  discard block
 block discarded – undo
538 538
 				$translate = $Translation->ident2icao($callsign);
539 539
 				if ($translate != $callsign) {
540 540
 					$additional_query .= " AND (spotter_output.ident = :callsign OR spotter_output.ident = :translate)";
541
-					$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
541
+					$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
542 542
 				} else {
543 543
 					$additional_query .= " AND spotter_output.ident = :callsign";
544
-					$query_values = array_merge($query_values,array(':callsign' => $callsign));
544
+					$query_values = array_merge($query_values, array(':callsign' => $callsign));
545 545
 				}
546 546
 			}
547 547
 		}
548 548
 
549 549
 		if ($owner != "")
550 550
 		{
551
-			$owner = filter_var($owner,FILTER_SANITIZE_STRING);
551
+			$owner = filter_var($owner, FILTER_SANITIZE_STRING);
552 552
 			if (!is_string($owner))
553 553
 			{
554 554
 				return false;
555 555
 			} else {
556 556
 				$additional_query .= " AND spotter_output.owner_name = :owner";
557
-				$query_values = array_merge($query_values,array(':owner' => $owner));
557
+				$query_values = array_merge($query_values, array(':owner' => $owner));
558 558
 			}
559 559
 		}
560 560
 
561 561
 		if ($pilot_name != "")
562 562
 		{
563
-			$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
563
+			$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
564 564
 			if (!is_string($pilot_name))
565 565
 			{
566 566
 				return false;
567 567
 			} else {
568 568
 				$additional_query .= " AND spotter_output.pilot_name = :pilot_name";
569
-				$query_values = array_merge($query_values,array(':pilot_name' => $pilot_name));
569
+				$query_values = array_merge($query_values, array(':pilot_name' => $pilot_name));
570 570
 			}
571 571
 		}
572 572
 
573 573
 		if ($pilot_id != "")
574 574
 		{
575
-			$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
575
+			$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
576 576
 			if (!is_string($pilot_id))
577 577
 			{
578 578
 				return false;
579 579
 			} else {
580 580
 				$additional_query .= " AND spotter_output.pilot_id = :pilot_id";
581
-				$query_values = array_merge($query_values,array(':pilot_id' => $pilot_id));
581
+				$query_values = array_merge($query_values, array(':pilot_id' => $pilot_id));
582 582
 			}
583 583
 		}
584 584
 
585 585
 		if ($departure_airport_route != "")
586 586
 		{
587
-			$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
587
+			$departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
588 588
 			if (!is_string($departure_airport_route))
589 589
 			{
590 590
 				return false;
591 591
 			} else {
592 592
 				$additional_query .= " AND spotter_output.departure_airport_icao = :departure_airport_route";
593
-				$query_values = array_merge($query_values,array(':departure_airport_route' => $departure_airport_route));
593
+				$query_values = array_merge($query_values, array(':departure_airport_route' => $departure_airport_route));
594 594
 			}
595 595
 		}
596 596
 
597 597
 		if ($arrival_airport_route != "")
598 598
 		{
599
-			$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
599
+			$arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
600 600
 			if (!is_string($arrival_airport_route))
601 601
 			{
602 602
 				return false;
603 603
 			} else {
604 604
 				$additional_query .= " AND spotter_output.arrival_airport_icao = :arrival_airport_route";
605
-				$query_values = array_merge($query_values,array(':arrival_airport_route' => $arrival_airport_route));
605
+				$query_values = array_merge($query_values, array(':arrival_airport_route' => $arrival_airport_route));
606 606
 			}
607 607
 		}
608 608
 
609 609
 		if ($altitude != "")
610 610
 		{
611 611
 			$altitude_array = explode(",", $altitude);
612
-			$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
613
-			$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
612
+			$altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
613
+			$altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
614 614
 
615 615
 			if ($altitude_array[1] != "")
616 616
 			{                
@@ -626,8 +626,8 @@  discard block
 block discarded – undo
626 626
 		if ($date_posted != "")
627 627
 		{
628 628
 			$date_array = explode(",", $date_posted);
629
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
630
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
629
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
630
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
631 631
 
632 632
 			if ($globalTimezone != '') {
633 633
 				date_default_timezone_set($globalTimezone);
@@ -658,8 +658,8 @@  discard block
 block discarded – undo
658 658
 		{
659 659
 			$limit_array = explode(",", $limit);
660 660
 			
661
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
662
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
661
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
662
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
663 663
 			
664 664
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
665 665
 			{
@@ -688,24 +688,24 @@  discard block
 block discarded – undo
688 688
 
689 689
 
690 690
 		if ($origLat != "" && $origLon != "" && $dist != "") {
691
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
691
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
692 692
 
693 693
 			if ($globalDBdriver == 'mysql') {
694
-				$query="SELECT spotter_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2))) as distance 
694
+				$query = "SELECT spotter_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2))) as distance 
695 695
 						FROM spotter_output, spotter_archive WHERE spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND spotter_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and spotter_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
696 696
 						AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query;
697 697
 			} else {
698
-				$query="SELECT spotter_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
698
+				$query = "SELECT spotter_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
699 699
 						FROM spotter_output, spotter_archive WHERE spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
700 700
 						AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$orderby_query;
701 701
 			}
702 702
 		} else {		
703
-			$query  = "SELECT spotter_output.* FROM spotter_output 
703
+			$query = "SELECT spotter_output.* FROM spotter_output 
704 704
 					WHERE spotter_output.ident <> '' 
705 705
 					".$additional_query."
706 706
 					".$orderby_query;
707 707
 		}
708
-		$spotter_array = $this->getDataFromDB($query, $query_values,$limit_query);
708
+		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query);
709 709
 		return $spotter_array;
710 710
 	}
711 711
 	
@@ -726,8 +726,8 @@  discard block
 block discarded – undo
726 726
 		{
727 727
 			$limit_array = explode(",", $limit);
728 728
 			
729
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
730
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
729
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
730
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
731 731
 			
732 732
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
733 733
 			{
@@ -744,9 +744,9 @@  discard block
 block discarded – undo
744 744
 			$orderby_query = " ORDER BY spotter_output.date DESC";
745 745
 		}
746 746
 
747
-		$query  = $global_query." ".$orderby_query;
747
+		$query = $global_query." ".$orderby_query;
748 748
 
749
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query);
749
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
750 750
 
751 751
 		return $spotter_array;
752 752
 	}
@@ -792,34 +792,34 @@  discard block
 block discarded – undo
792 792
 			{
793 793
 				return false;
794 794
 			} else {
795
-				if ($interval == "30m"){
795
+				if ($interval == "30m") {
796 796
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) <= $this_output.date ';
797
-				} else if ($interval == "1h"){
797
+				} else if ($interval == "1h") {
798 798
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) <= $this_output.date ';
799
-				} else if ($interval == "3h"){
799
+				} else if ($interval == "3h") {
800 800
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 3 HOUR) <= $this_output.date ';
801
-				} else if ($interval == "6h"){
801
+				} else if ($interval == "6h") {
802 802
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 6 HOUR) <= $this_output.date ';
803
-				} else if ($interval == "12h"){
803
+				} else if ($interval == "12h") {
804 804
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) <= $this_output.date ';
805
-				} else if ($interval == "24h"){
805
+				} else if ($interval == "24h") {
806 806
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 24 HOUR) <= $this_output.date ';
807
-				} else if ($interval == "7d"){
807
+				} else if ($interval == "7d") {
808 808
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) <= $this_output.date ';
809
-				} else if ($interval == "30d"){
809
+				} else if ($interval == "30d") {
810 810
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 DAY) <= $this_output.date ';
811 811
 				} 
812 812
 			}
813 813
 		}
814 814
 
815
-		$query  = "SELECT spotter_output.*, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_output 
815
+		$query = "SELECT spotter_output.*, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_output 
816 816
                    WHERE spotter_output.latitude <> '' 
817 817
 				   AND spotter_output.longitude <> '' 
818 818
                    ".$additional_query."
819 819
                    HAVING distance < :radius  
820 820
 				   ORDER BY distance";
821 821
 
822
-		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius),$limit_query);
822
+		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius), $limit_query);
823 823
 
824 824
 		return $spotter_array;
825 825
 	}
@@ -841,8 +841,8 @@  discard block
 block discarded – undo
841 841
 		{
842 842
 			$limit_array = explode(",", $limit);
843 843
 			
844
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
845
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
844
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
845
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
846 846
 			
847 847
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
848 848
 			{
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
860 860
 		}
861 861
 
862
-		$query  = $global_query." WHERE spotter_output.aircraft_name <> '' GROUP BY spotter_output.aircraft_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
862
+		$query = $global_query." WHERE spotter_output.aircraft_name <> '' GROUP BY spotter_output.aircraft_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
863 863
 
864 864
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
865 865
 
@@ -883,8 +883,8 @@  discard block
 block discarded – undo
883 883
 		{
884 884
 			$limit_array = explode(",", $limit);
885 885
 			
886
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
887
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
886
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
887
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
888 888
 			
889 889
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
890 890
 			{
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
902 902
 		}
903 903
 
904
-		$query  = $global_query." WHERE spotter_output.registration <> '' GROUP BY spotter_output.registration,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
904
+		$query = $global_query." WHERE spotter_output.registration <> '' GROUP BY spotter_output.registration,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
905 905
 
906 906
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
907 907
 
@@ -925,8 +925,8 @@  discard block
 block discarded – undo
925 925
 		{
926 926
 			$limit_array = explode(",", $limit);
927 927
 			
928
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
929
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
928
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
929
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
930 930
 			
931 931
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
932 932
 			{
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
944 944
 		}
945 945
 
946
-		$query  = $global_query." WHERE spotter_output.airline_name <> '' GROUP BY spotter_output.airline_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
946
+		$query = $global_query." WHERE spotter_output.airline_name <> '' GROUP BY spotter_output.airline_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
947 947
 
948 948
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
949 949
 
@@ -967,8 +967,8 @@  discard block
 block discarded – undo
967 967
 		{
968 968
 			$limit_array = explode(",", $limit);
969 969
 			
970
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
971
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
970
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
971
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
972 972
 			
973 973
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
974 974
 			{
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
986 986
 		}
987 987
 
988
-		$query  = $global_query." WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' GROUP BY spotter_output.departure_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
988
+		$query = $global_query." WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' GROUP BY spotter_output.departure_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
989 989
 
990 990
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
991 991
 
@@ -1009,8 +1009,8 @@  discard block
 block discarded – undo
1009 1009
 		{
1010 1010
 			$limit_array = explode(",", $limit);
1011 1011
 			
1012
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1013
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1012
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1013
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1014 1014
 			
1015 1015
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1016 1016
 			{
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1028 1028
 		}
1029 1029
 
1030
-		$query  = $global_query." WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1030
+		$query = $global_query." WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1031 1031
 
1032 1032
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1033 1033
 
@@ -1060,9 +1060,9 @@  discard block
 block discarded – undo
1060 1060
 			}
1061 1061
 		}
1062 1062
 
1063
-		$query  = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ";
1063
+		$query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ";
1064 1064
 
1065
-		$spotter_array = $this->getDataFromDB($query,$query_values);
1065
+		$spotter_array = $this->getDataFromDB($query, $query_values);
1066 1066
 
1067 1067
 		return $spotter_array;
1068 1068
 	}
@@ -1099,8 +1099,8 @@  discard block
 block discarded – undo
1099 1099
 		{
1100 1100
 			$limit_array = explode(",", $limit);
1101 1101
 			
1102
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1103
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1102
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1103
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1104 1104
 			
1105 1105
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1106 1106
 			{
@@ -1155,8 +1155,8 @@  discard block
 block discarded – undo
1155 1155
 		{
1156 1156
 			$limit_array = explode(",", $limit);
1157 1157
 			
1158
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1159
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1158
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1159
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1160 1160
 			
1161 1161
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1162 1162
 			{
@@ -1210,8 +1210,8 @@  discard block
 block discarded – undo
1210 1210
 		{
1211 1211
 			$limit_array = explode(",", $limit);
1212 1212
 			
1213
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1214
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1213
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1214
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1215 1215
 			
1216 1216
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1217 1217
 			{
@@ -1267,8 +1267,8 @@  discard block
 block discarded – undo
1267 1267
 		{
1268 1268
 			$limit_array = explode(",", $limit);
1269 1269
 			
1270
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1271
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1270
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1271
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1272 1272
 			
1273 1273
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1274 1274
 			{
@@ -1321,8 +1321,8 @@  discard block
 block discarded – undo
1321 1321
 		{
1322 1322
 			$limit_array = explode(",", $limit);
1323 1323
 			
1324
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1325
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1324
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1325
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1326 1326
 			
1327 1327
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1328 1328
 			{
@@ -1380,8 +1380,8 @@  discard block
 block discarded – undo
1380 1380
 		{
1381 1381
 			$limit_array = explode(",", $limit);
1382 1382
 			
1383
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1384
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1383
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1384
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1385 1385
 			
1386 1386
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1387 1387
 			{
@@ -1437,8 +1437,8 @@  discard block
 block discarded – undo
1437 1437
 		{
1438 1438
 			$limit_array = explode(",", $limit);
1439 1439
 			
1440
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1441
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1440
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1441
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1442 1442
 			
1443 1443
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1444 1444
 			{
@@ -1493,8 +1493,8 @@  discard block
 block discarded – undo
1493 1493
 		{
1494 1494
 			$limit_array = explode(",", $limit);
1495 1495
 			
1496
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1497
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1496
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1497
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1498 1498
 			
1499 1499
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1500 1500
 			{
@@ -1541,7 +1541,7 @@  discard block
 block discarded – undo
1541 1541
 			{
1542 1542
 				return false;
1543 1543
 			} else {
1544
-				$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1544
+				$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1545 1545
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao)";
1546 1546
 				$query_values = array(':departure_airport_icao' => $departure_airport_icao);
1547 1547
 			}
@@ -1553,9 +1553,9 @@  discard block
 block discarded – undo
1553 1553
 			{
1554 1554
 				return false;
1555 1555
 			} else {
1556
-				$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1556
+				$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1557 1557
 				$additional_query .= " AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)";
1558
-				$query_values = array_merge($query_values,array(':arrival_airport_icao' => $arrival_airport_icao));
1558
+				$query_values = array_merge($query_values, array(':arrival_airport_icao' => $arrival_airport_icao));
1559 1559
 			}
1560 1560
 		}
1561 1561
 		
@@ -1563,8 +1563,8 @@  discard block
 block discarded – undo
1563 1563
 		{
1564 1564
 			$limit_array = explode(",", $limit);
1565 1565
 			
1566
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1567
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1566
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1567
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1568 1568
 			
1569 1569
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1570 1570
 			{
@@ -1608,8 +1608,8 @@  discard block
 block discarded – undo
1608 1608
 		{
1609 1609
 			$limit_array = explode(",", $limit);
1610 1610
 			
1611
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1612
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1611
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1612
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1613 1613
 			
1614 1614
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1615 1615
 			{
@@ -1626,7 +1626,7 @@  discard block
 block discarded – undo
1626 1626
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1627 1627
 		}
1628 1628
 
1629
-		$query  = $global_query." WHERE spotter_output.highlight <> '' ".$orderby_query;
1629
+		$query = $global_query." WHERE spotter_output.highlight <> '' ".$orderby_query;
1630 1630
 
1631 1631
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1632 1632
 
@@ -1647,14 +1647,14 @@  discard block
 block discarded – undo
1647 1647
 		
1648 1648
 		date_default_timezone_set('UTC');
1649 1649
 		
1650
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
1650
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
1651 1651
 
1652 1652
 		
1653
-		$query  = $global_query." WHERE spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1653
+		$query = $global_query." WHERE spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1654 1654
 		$sth = $this->db->prepare($query);
1655 1655
 		$sth->execute(array(':registration' => $registration));
1656 1656
 
1657
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1657
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1658 1658
 		{
1659 1659
 			$highlight = $row['highlight'];
1660 1660
 		}
@@ -1670,16 +1670,16 @@  discard block
 block discarded – undo
1670 1670
 	* @return String usage
1671 1671
 	*
1672 1672
 	*/
1673
-	public function getSquawkUsage($squawk = '',$country = 'FR')
1673
+	public function getSquawkUsage($squawk = '', $country = 'FR')
1674 1674
 	{
1675 1675
 		
1676
-		$squawk = filter_var($squawk,FILTER_SANITIZE_STRING);
1677
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
1676
+		$squawk = filter_var($squawk, FILTER_SANITIZE_STRING);
1677
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
1678 1678
 
1679 1679
 		$query_values = array();
1680 1680
 
1681
-		$query  = "SELECT squawk.* FROM squawk WHERE squawk.code = :squawk AND squawk.country = :country LIMIT 1";
1682
-		$query_values = array(':squawk' => ltrim($squawk,'0'), ':country' => $country);
1681
+		$query = "SELECT squawk.* FROM squawk WHERE squawk.code = :squawk AND squawk.country = :country LIMIT 1";
1682
+		$query_values = array(':squawk' => ltrim($squawk, '0'), ':country' => $country);
1683 1683
 		
1684 1684
 		$sth = $this->db->prepare($query);
1685 1685
 		$sth->execute($query_values);
@@ -1702,11 +1702,11 @@  discard block
 block discarded – undo
1702 1702
 	public function getAirportIcao($airport_iata = '')
1703 1703
 	{
1704 1704
 		
1705
-		$airport_iata = filter_var($airport_iata,FILTER_SANITIZE_STRING);
1705
+		$airport_iata = filter_var($airport_iata, FILTER_SANITIZE_STRING);
1706 1706
 
1707 1707
 		$query_values = array();
1708 1708
 
1709
-		$query  = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
1709
+		$query = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
1710 1710
 		$query_values = array(':airport' => $airport_iata);
1711 1711
 		
1712 1712
 		
@@ -1728,14 +1728,14 @@  discard block
 block discarded – undo
1728 1728
 	* @return Float distance to the airport
1729 1729
 	*
1730 1730
 	*/
1731
-	public function getAirportDistance($airport_icao,$latitude,$longitude)
1731
+	public function getAirportDistance($airport_icao, $latitude, $longitude)
1732 1732
 	{
1733 1733
 		
1734
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
1734
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
1735 1735
 
1736 1736
 		$query_values = array();
1737 1737
 
1738
-		$query  = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
1738
+		$query = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
1739 1739
 		$query_values = array(':airport' => $airport_icao);
1740 1740
 		$sth = $this->db->prepare($query);
1741 1741
 		$sth->execute($query_values);
@@ -1744,7 +1744,7 @@  discard block
 block discarded – undo
1744 1744
 			$airport_latitude = $row['latitude'];
1745 1745
 			$airport_longitude = $row['longitude'];
1746 1746
 			$Common = new Common();
1747
-			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
1747
+			return $Common->distance($latitude, $longitude, $airport_latitude, $airport_longitude);
1748 1748
 		} else return '';
1749 1749
 	}
1750 1750
 	
@@ -1758,11 +1758,11 @@  discard block
 block discarded – undo
1758 1758
 	public function getAllAirportInfo($airport = '')
1759 1759
 	{
1760 1760
 		
1761
-		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
1761
+		$airport = filter_var($airport, FILTER_SANITIZE_STRING);
1762 1762
 
1763 1763
 		$query_values = array();
1764 1764
 		if ($airport == 'NA') {
1765
-			return array(array('name' => 'Not available','city' => 'N/A', 'country' => 'N/A','iata' => 'NA','icao' => 'NA','altitude' => NULL,'latitude' => 0,'longitude' => 0,'type' => 'NA','home_link' => '','wikipedia_link' => '','image_thumb' => '', 'image' => ''));
1765
+			return array(array('name' => 'Not available', 'city' => 'N/A', 'country' => 'N/A', 'iata' => 'NA', 'icao' => 'NA', 'altitude' => NULL, 'latitude' => 0, 'longitude' => 0, 'type' => 'NA', 'home_link' => '', 'wikipedia_link' => '', 'image_thumb' => '', 'image' => ''));
1766 1766
 		} elseif ($airport == '') {
1767 1767
 			$query  = "SELECT airport.name, airport.city, airport.country, airport.iata, airport.icao, airport.latitude, airport.longitude, airport.altitude, airport.type, airport.home_link, airport.wikipedia_link, airport.image_thumb, airport.image FROM airport";
1768 1768
 		} else {
@@ -1810,14 +1810,14 @@  discard block
 block discarded – undo
1810 1810
 	{
1811 1811
 		$lst_countries = '';
1812 1812
 		foreach ($countries as $country) {
1813
-			$country = filter_var($country,FILTER_SANITIZE_STRING);
1813
+			$country = filter_var($country, FILTER_SANITIZE_STRING);
1814 1814
 			if ($lst_countries == '') {
1815 1815
 				$lst_countries = "'".$country."'";
1816 1816
 			} else {
1817 1817
 				$lst_countries .= ",'".$country."'";
1818 1818
 			}
1819 1819
 		}
1820
-		$query  = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
1820
+		$query = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
1821 1821
 		
1822 1822
 		$sth = $this->db->prepare($query);
1823 1823
 		$sth->execute();
@@ -1825,7 +1825,7 @@  discard block
 block discarded – undo
1825 1825
 		$airport_array = array();
1826 1826
 		$temp_array = array();
1827 1827
 		
1828
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1828
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1829 1829
 		{
1830 1830
 			$temp_array['name'] = $row['name'];
1831 1831
 			$temp_array['city'] = $row['city'];
@@ -1854,10 +1854,10 @@  discard block
 block discarded – undo
1854 1854
 		global $globalDBdriver;
1855 1855
 		$lst_countries = '';
1856 1856
 		if (is_array($coord)) {
1857
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1858
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1859
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1860
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1857
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1858
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1859
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1860
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1861 1861
 		}
1862 1862
 		if ($globalDBdriver == 'mysql') {
1863 1863
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
@@ -1870,7 +1870,7 @@  discard block
 block discarded – undo
1870 1870
 		$airport_array = array();
1871 1871
 		$temp_array = array();
1872 1872
 		
1873
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1873
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1874 1874
 		{
1875 1875
 			$temp_array = $row;
1876 1876
 
@@ -1891,13 +1891,13 @@  discard block
 block discarded – undo
1891 1891
 	{
1892 1892
 		$lst_countries = '';
1893 1893
 		if (is_array($coord)) {
1894
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1895
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1896
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1897
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1894
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1895
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1896
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1897
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1898 1898
 		}
1899 1899
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
1900
-		$query  = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
1900
+		$query = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
1901 1901
 		//$query  = "SELECT waypoints.* FROM waypoints";
1902 1902
 		//$query  = "SELECT waypoints.* FROM waypoints INNER JOIN (SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") w ON w.name_end = waypoints.name_begin OR w.name_begin = waypoints.name_begin OR w.name_begin = waypoints.name_end OR w.name_end = waypoints.name_end";
1903 1903
 		//$query = "SELECT * FROM waypoints LEFT JOIN waypoints w ON waypoints.name_end = w.name_begin WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
@@ -1910,7 +1910,7 @@  discard block
 block discarded – undo
1910 1910
 		$waypoints_array = array();
1911 1911
 		$temp_array = array();
1912 1912
 		
1913
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1913
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1914 1914
 		{
1915 1915
 			$temp_array = $row;
1916 1916
 
@@ -1930,9 +1930,9 @@  discard block
 block discarded – undo
1930 1930
 	*/
1931 1931
 	public function getAllAirlineInfo($airline_icao)
1932 1932
 	{
1933
-		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
1933
+		$airline_icao = strtoupper(filter_var($airline_icao, FILTER_SANITIZE_STRING));
1934 1934
 		if ($airline_icao == 'NA') {
1935
-			$airline_array[] = array('name' => 'Not Available','iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
1935
+			$airline_array[] = array('name' => 'Not Available', 'iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
1936 1936
 			return $airline_array;
1937 1937
 		} else {
1938 1938
 			if (strlen($airline_icao) == 2) {
@@ -1974,12 +1974,12 @@  discard block
 block discarded – undo
1974 1974
 	*/
1975 1975
 	public function getAllAircraftInfo($aircraft_type)
1976 1976
 	{
1977
-		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
1977
+		$aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING);
1978 1978
 
1979 1979
 		if ($aircraft_type == 'NA') {
1980
-			return array(array('icao' => 'NA','type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
1980
+			return array(array('icao' => 'NA', 'type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
1981 1981
 		}
1982
-		$query  = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow FROM aircraft WHERE aircraft.icao = :aircraft_type";
1982
+		$query = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow FROM aircraft WHERE aircraft.icao = :aircraft_type";
1983 1983
 		
1984 1984
 		$sth = $this->db->prepare($query);
1985 1985
 		$sth->execute(array(':aircraft_type' => $aircraft_type));
@@ -2011,9 +2011,9 @@  discard block
 block discarded – undo
2011 2011
 	*/
2012 2012
 	public function getAllAircraftType($aircraft_modes)
2013 2013
 	{
2014
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
2014
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
2015 2015
 
2016
-		$query  = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
2016
+		$query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
2017 2017
 		
2018 2018
 		$sth = $this->db->prepare($query);
2019 2019
 		$sth->execute(array(':aircraft_modes' => $aircraft_modes));
@@ -2033,8 +2033,8 @@  discard block
 block discarded – undo
2033 2033
 	*/
2034 2034
 	public function getOperator($operator)
2035 2035
 	{
2036
-		$operator = filter_var($operator,FILTER_SANITIZE_STRING);
2037
-		$query  = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2036
+		$operator = filter_var($operator, FILTER_SANITIZE_STRING);
2037
+		$query = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2038 2038
 		
2039 2039
 		$sth = $this->db->prepare($query);
2040 2040
 		$sth->execute(array(':operator' => $operator));
@@ -2054,9 +2054,9 @@  discard block
 block discarded – undo
2054 2054
 	*/
2055 2055
 	public function getRouteInfo($callsign)
2056 2056
 	{
2057
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2057
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
2058 2058
                 if ($callsign == '') return array();
2059
-		$query  = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2059
+		$query = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2060 2060
 		
2061 2061
 		$sth = $this->db->prepare($query);
2062 2062
 		$sth->execute(array(':callsign' => $callsign));
@@ -2076,9 +2076,9 @@  discard block
 block discarded – undo
2076 2076
 	*/
2077 2077
 	public function getAircraftInfoByRegistration($registration)
2078 2078
 	{
2079
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2079
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2080 2080
 
2081
-		$query  = "SELECT spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_icao FROM spotter_output WHERE spotter_output.registration = :registration";
2081
+		$query = "SELECT spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_icao FROM spotter_output WHERE spotter_output.registration = :registration";
2082 2082
 		
2083 2083
 		$sth = $this->db->prepare($query);
2084 2084
 		$sth->execute(array(':registration' => $registration));
@@ -2086,7 +2086,7 @@  discard block
 block discarded – undo
2086 2086
 		$aircraft_array = array();
2087 2087
 		$temp_array = array();
2088 2088
 		
2089
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2089
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2090 2090
 		{
2091 2091
 			$temp_array['airline_icao'] = $row['airline_icao'];
2092 2092
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -2108,10 +2108,10 @@  discard block
 block discarded – undo
2108 2108
 	*/
2109 2109
 	public function getAircraftOwnerByRegistration($registration)
2110 2110
 	{
2111
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2111
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2112 2112
 		$Connection = new Connection($this->db);
2113 2113
 		if ($Connection->tableExists('aircraft_owner')) {
2114
-			$query  = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1";
2114
+			$query = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1";
2115 2115
 			$sth = $this->db->prepare($query);
2116 2116
 			$sth->execute(array(':registration' => $registration));
2117 2117
 
@@ -2129,7 +2129,7 @@  discard block
 block discarded – undo
2129 2129
 	public function getAllFlightsforSitemap()
2130 2130
 	{
2131 2131
 		//$query  = "SELECT spotter_output.spotter_id, spotter_output.ident, spotter_output.airline_name, spotter_output.aircraft_name, spotter_output.aircraft_icao FROM spotter_output ORDER BY LIMIT ";
2132
-		$query  = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2132
+		$query = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2133 2133
 		
2134 2134
 		$sth = $this->db->prepare($query);
2135 2135
 		$sth->execute();
@@ -2176,7 +2176,7 @@  discard block
 block discarded – undo
2176 2176
 		$manufacturer_array = array();
2177 2177
 		$temp_array = array();
2178 2178
 		
2179
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2179
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2180 2180
 		{
2181 2181
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
2182 2182
 
@@ -2210,7 +2210,7 @@  discard block
 block discarded – undo
2210 2210
 		$aircraft_array = array();
2211 2211
 		$temp_array = array();
2212 2212
 		
2213
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2213
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2214 2214
 		{
2215 2215
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
2216 2216
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
@@ -2231,7 +2231,7 @@  discard block
 block discarded – undo
2231 2231
 	*/
2232 2232
 	public function getAllAircraftRegistrations()
2233 2233
 	{
2234
-		$query  = "SELECT DISTINCT spotter_output.registration 
2234
+		$query = "SELECT DISTINCT spotter_output.registration 
2235 2235
 				FROM spotter_output  
2236 2236
 				WHERE spotter_output.registration <> '' 
2237 2237
 				ORDER BY spotter_output.registration ASC";
@@ -2242,7 +2242,7 @@  discard block
 block discarded – undo
2242 2242
 		$aircraft_array = array();
2243 2243
 		$temp_array = array();
2244 2244
 		
2245
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2245
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2246 2246
 		{
2247 2247
 			$temp_array['registration'] = $row['registration'];
2248 2248
 
@@ -2262,7 +2262,7 @@  discard block
 block discarded – undo
2262 2262
 	public function getAllSourceName($type = '')
2263 2263
 	{
2264 2264
 		$query_values = array();
2265
-		$query  = "SELECT DISTINCT spotter_output.source_name 
2265
+		$query = "SELECT DISTINCT spotter_output.source_name 
2266 2266
 				FROM spotter_output  
2267 2267
 				WHERE spotter_output.source_name <> ''";
2268 2268
 		if ($type != '') {
@@ -2278,7 +2278,7 @@  discard block
 block discarded – undo
2278 2278
 		$source_array = array();
2279 2279
 		$temp_array = array();
2280 2280
 		
2281
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2281
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2282 2282
 		{
2283 2283
 			$temp_array['source_name'] = $row['source_name'];
2284 2284
 			$source_array[] = $temp_array;
@@ -2296,7 +2296,7 @@  discard block
 block discarded – undo
2296 2296
 	*/
2297 2297
 	public function getAllAirlineNames($airline_type = '')
2298 2298
 	{
2299
-		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
2299
+		$airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
2300 2300
 		if ($airline_type == '' || $airline_type == 'all') {
2301 2301
 			/*
2302 2302
 			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
@@ -2306,7 +2306,7 @@  discard block
 block discarded – undo
2306 2306
 			*/
2307 2307
 			$query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines ORDER BY name ASC";
2308 2308
 		} else {
2309
-			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2309
+			$query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2310 2310
 					FROM spotter_output
2311 2311
 					WHERE spotter_output.airline_icao <> '' 
2312 2312
 					AND spotter_output.airline_type = :airline_type 
@@ -2323,7 +2323,7 @@  discard block
 block discarded – undo
2323 2323
 		$airline_array = array();
2324 2324
 		$temp_array = array();
2325 2325
 		
2326
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2326
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2327 2327
 		{
2328 2328
 			$temp_array['airline_icao'] = $row['airline_icao'];
2329 2329
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -2344,7 +2344,7 @@  discard block
 block discarded – undo
2344 2344
 	public function getAllAirlineCountries()
2345 2345
 	{
2346 2346
 		
2347
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2347
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2348 2348
 				FROM spotter_output  
2349 2349
 				WHERE spotter_output.airline_country <> '' 
2350 2350
 				ORDER BY spotter_output.airline_country ASC";
@@ -2356,7 +2356,7 @@  discard block
 block discarded – undo
2356 2356
 		$airline_array = array();
2357 2357
 		$temp_array = array();
2358 2358
 		
2359
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2359
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2360 2360
 		{
2361 2361
 			$temp_array['airline_country'] = $row['airline_country'];
2362 2362
 
@@ -2378,7 +2378,7 @@  discard block
 block discarded – undo
2378 2378
 	{
2379 2379
 		$airport_array = array();
2380 2380
 
2381
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao AS airport_icao, spotter_output.departure_airport_name AS airport_name, spotter_output.departure_airport_city AS airport_city, spotter_output.departure_airport_country AS airport_country
2381
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao AS airport_icao, spotter_output.departure_airport_name AS airport_name, spotter_output.departure_airport_city AS airport_city, spotter_output.departure_airport_country AS airport_country
2382 2382
 				FROM spotter_output 
2383 2383
 				WHERE spotter_output.departure_airport_icao <> '' AND spotter_output.departure_airport_icao <> 'NA' 
2384 2384
 				ORDER BY spotter_output.departure_airport_city ASC";
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
 		$sth->execute();
2389 2389
 
2390 2390
 		$temp_array = array();
2391
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2391
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2392 2392
 		{
2393 2393
 			$temp_array['airport_icao'] = $row['airport_icao'];
2394 2394
 			$temp_array['airport_name'] = $row['airport_name'];
@@ -2398,7 +2398,7 @@  discard block
 block discarded – undo
2398 2398
 			$airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array;
2399 2399
 		}
2400 2400
 
2401
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao AS airport_icao, spotter_output.arrival_airport_name AS airport_name, spotter_output.arrival_airport_city AS airport_city, spotter_output.arrival_airport_country AS airport_country
2401
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao AS airport_icao, spotter_output.arrival_airport_name AS airport_name, spotter_output.arrival_airport_city AS airport_city, spotter_output.arrival_airport_country AS airport_country
2402 2402
 								FROM spotter_output 
2403 2403
 								WHERE spotter_output.arrival_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' 
2404 2404
 								ORDER BY spotter_output.arrival_airport_city ASC";
@@ -2406,7 +2406,7 @@  discard block
 block discarded – undo
2406 2406
 		$sth = $this->db->prepare($query);
2407 2407
 		$sth->execute();
2408 2408
 
2409
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2409
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2410 2410
 			{
2411 2411
 		//	if ($airport_array[$row['airport_city'].",".$row['airport_name']]['airport_icao'] != $row['airport_icao'])
2412 2412
 		//	{
@@ -2446,14 +2446,14 @@  discard block
 block discarded – undo
2446 2446
    
2447 2447
 		$temp_array = array();
2448 2448
 		
2449
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2449
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2450 2450
 		{
2451 2451
 			$temp_array['airport_country'] = $row['airport_country'];
2452 2452
 
2453 2453
 			$airport_array[$row['airport_country']] = $temp_array;
2454 2454
 		}
2455 2455
 								
2456
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2456
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2457 2457
 								FROM spotter_output
2458 2458
 								WHERE spotter_output.arrival_airport_country <> '' 
2459 2459
 								ORDER BY spotter_output.arrival_airport_country ASC";
@@ -2461,7 +2461,7 @@  discard block
 block discarded – undo
2461 2461
 		$sth = $this->db->prepare($query);
2462 2462
 		$sth->execute();
2463 2463
 		
2464
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2464
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2465 2465
 		{
2466 2466
 			if (isset($airport_array[$row['airport_country']]['airport_country']) && $airport_array[$row['airport_country']]['airport_country'] != $row['airport_country'])
2467 2467
 			{
@@ -2485,12 +2485,12 @@  discard block
 block discarded – undo
2485 2485
 	*/
2486 2486
 	public function getAllCountries()
2487 2487
 	{
2488
-		$Connection= new Connection($this->db);
2488
+		$Connection = new Connection($this->db);
2489 2489
 		if ($Connection->tableExists('countries')) {
2490 2490
 		
2491 2491
 		$country_array = array();
2492 2492
 					
2493
-		$query  = "SELECT countries.name AS airport_country
2493
+		$query = "SELECT countries.name AS airport_country
2494 2494
 				FROM countries
2495 2495
 				ORDER BY countries.name ASC";
2496 2496
 		$sth = $this->db->prepare($query);
@@ -2498,7 +2498,7 @@  discard block
 block discarded – undo
2498 2498
    
2499 2499
 		$temp_array = array();
2500 2500
 		
2501
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2501
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2502 2502
 		{
2503 2503
 			$temp_array['country'] = $row['airport_country'];
2504 2504
 
@@ -2506,7 +2506,7 @@  discard block
 block discarded – undo
2506 2506
 		}
2507 2507
 		} else {
2508 2508
 
2509
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
2509
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
2510 2510
 								FROM spotter_output
2511 2511
 								WHERE spotter_output.departure_airport_country <> '' 
2512 2512
 								ORDER BY spotter_output.departure_airport_country ASC";
@@ -2516,14 +2516,14 @@  discard block
 block discarded – undo
2516 2516
    
2517 2517
 		$temp_array = array();
2518 2518
 		
2519
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2519
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2520 2520
 		{
2521 2521
 			$temp_array['country'] = $row['airport_country'];
2522 2522
 
2523 2523
 			$country_array[$row['airport_country']] = $temp_array;
2524 2524
 		}
2525 2525
 								
2526
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2526
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2527 2527
 								FROM spotter_output
2528 2528
 								WHERE spotter_output.arrival_airport_country <> '' 
2529 2529
 								ORDER BY spotter_output.arrival_airport_country ASC";
@@ -2531,7 +2531,7 @@  discard block
 block discarded – undo
2531 2531
 		$sth = $this->db->prepare($query);
2532 2532
 		$sth->execute();
2533 2533
 		
2534
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2534
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2535 2535
 		{
2536 2536
 			if ($country_array[$row['airport_country']]['country'] != $row['airport_country'])
2537 2537
 			{
@@ -2541,7 +2541,7 @@  discard block
 block discarded – undo
2541 2541
 			}
2542 2542
 		}
2543 2543
 		
2544
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2544
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2545 2545
 								FROM spotter_output  
2546 2546
 								WHERE spotter_output.airline_country <> '' 
2547 2547
 								ORDER BY spotter_output.airline_country ASC";
@@ -2549,7 +2549,7 @@  discard block
 block discarded – undo
2549 2549
 		$sth = $this->db->prepare($query);
2550 2550
 		$sth->execute();
2551 2551
 		
2552
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2552
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2553 2553
 		{
2554 2554
 			if (isset($country_array[$row['airline_country']]['country']) && $country_array[$row['airline_country']]['country'] != $row['airline_country'])
2555 2555
 			{
@@ -2573,7 +2573,7 @@  discard block
 block discarded – undo
2573 2573
 	*/
2574 2574
 	public function getAllIdents()
2575 2575
 	{
2576
-		$query  = "SELECT DISTINCT spotter_output.ident
2576
+		$query = "SELECT DISTINCT spotter_output.ident
2577 2577
 								FROM spotter_output
2578 2578
 								WHERE spotter_output.ident <> '' 
2579 2579
 								ORDER BY spotter_output.date ASC LIMIT 700 OFFSET 0";
@@ -2584,7 +2584,7 @@  discard block
 block discarded – undo
2584 2584
 		$ident_array = array();
2585 2585
 		$temp_array = array();
2586 2586
 		
2587
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2587
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2588 2588
 		{
2589 2589
 			$temp_array['ident'] = $row['ident'];
2590 2590
 			$ident_array[] = $temp_array;
@@ -2764,12 +2764,12 @@  discard block
 block discarded – undo
2764 2764
 		} else $offset = '+00:00';
2765 2765
 
2766 2766
 		if ($globalDBdriver == 'mysql') {
2767
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
2767
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
2768 2768
 								FROM spotter_output
2769 2769
 								WHERE spotter_output.date <> '' 
2770 2770
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
2771 2771
 		} else {
2772
-			$query  = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
2772
+			$query = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
2773 2773
 								FROM spotter_output
2774 2774
 								WHERE spotter_output.date <> '' 
2775 2775
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
@@ -2781,7 +2781,7 @@  discard block
 block discarded – undo
2781 2781
 		$date_array = array();
2782 2782
 		$temp_array = array();
2783 2783
 		
2784
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2784
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2785 2785
 		{
2786 2786
 			$temp_array['date'] = $row['date'];
2787 2787
 
@@ -2801,7 +2801,7 @@  discard block
 block discarded – undo
2801 2801
 	*/
2802 2802
 	public function getAllRoutes()
2803 2803
 	{
2804
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route,  spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao 
2804
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route,  spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao 
2805 2805
 				FROM spotter_output
2806 2806
 				WHERE spotter_output.ident <> '' 
2807 2807
 				GROUP BY route
@@ -2812,7 +2812,7 @@  discard block
 block discarded – undo
2812 2812
 
2813 2813
 		$routes_array = array();
2814 2814
 		$temp_array = array();
2815
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2815
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2816 2816
 		{
2817 2817
 			$temp_array['route'] = $row['route'];
2818 2818
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -2845,7 +2845,7 @@  discard block
 block discarded – undo
2845 2845
 			if (count($airline_array) == 0) {
2846 2846
 				$airline_array = $this->getAllAirlineInfo("NA");
2847 2847
 			}
2848
-			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
2848
+			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
2849 2849
 				$airline_array = $this->getAllAirlineInfo("NA");
2850 2850
 			}
2851 2851
 		} else {
@@ -2858,7 +2858,7 @@  discard block
 block discarded – undo
2858 2858
 
2859 2859
 
2860 2860
 		$query = 'UPDATE spotter_output SET ident = :ident, airline_name = :airline_name, airline_icao = :airline_icao, airline_country = :airline_country, airline_type = :airline_type WHERE flightaware_id = :flightaware_id';
2861
-                $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type);
2861
+                $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type);
2862 2862
 
2863 2863
 		try {
2864 2864
 			$sth = $this->db->prepare($query);
@@ -2881,11 +2881,11 @@  discard block
 block discarded – undo
2881 2881
 	* @return String success or false
2882 2882
 	*
2883 2883
 	*/	
2884
-	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
2884
+	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '', $arrival_airport_time = '')
2885 2885
 	{
2886 2886
 		if ($groundspeed == '') $groundspeed = NULL;
2887 2887
 		$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id';
2888
-                $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
2888
+                $query_values = array(':flightaware_id' => $flightaware_id, ':real_arrival_airport_icao' => $arrival_airport_icao, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
2889 2889
 
2890 2890
 		try {
2891 2891
 			$sth = $this->db->prepare($query);
@@ -2909,7 +2909,7 @@  discard block
 block discarded – undo
2909 2909
 	* @return String success or false
2910 2910
 	*
2911 2911
 	*/
2912
-	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '',$squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false,$format_source = '', $source_name = '')
2912
+	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false, $format_source = '', $source_name = '')
2913 2913
 	{
2914 2914
 		global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed;
2915 2915
 		
@@ -2932,13 +2932,13 @@  discard block
 block discarded – undo
2932 2932
 				if ($ModeS != '') {
2933 2933
 					$timeelapsed = microtime(true);
2934 2934
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS);
2935
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
2935
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
2936 2936
 				} else {
2937
-					$myhex = explode('-',$flightaware_id);
2937
+					$myhex = explode('-', $flightaware_id);
2938 2938
 					if (count($myhex) > 0) {
2939 2939
 						$timeelapsed = microtime(true);
2940 2940
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0]);
2941
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
2941
+						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
2942 2942
 					}
2943 2943
 				}
2944 2944
 			}
@@ -2964,15 +2964,15 @@  discard block
 block discarded – undo
2964 2964
 					if (count($airline_array) == 0) {
2965 2965
 						$airline_array = $this->getAllAirlineInfo("NA");
2966 2966
 					}
2967
-					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
2967
+					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
2968 2968
 						$airline_array = $this->getAllAirlineInfo("NA");
2969 2969
 					}
2970
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
2970
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
2971 2971
 
2972 2972
 				} else {
2973 2973
 					$timeelapsed = microtime(true);
2974 2974
 					$airline_array = $this->getAllAirlineInfo("NA");
2975
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
2975
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
2976 2976
 				}
2977 2977
 			}
2978 2978
 		} else $airline_array = array();
@@ -2988,27 +2988,27 @@  discard block
 block discarded – undo
2988 2988
 				{
2989 2989
 					$timeelapsed = microtime(true);
2990 2990
 					$aircraft_array = $this->getAllAircraftInfo("NA");
2991
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
2991
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
2992 2992
 				} else {
2993 2993
 					$timeelapsed = microtime(true);
2994 2994
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
2995
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
2995
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
2996 2996
 				}
2997 2997
 			}
2998 2998
 		} else {
2999 2999
 			if ($ModeS != '') {
3000 3000
 				$timeelapsed = microtime(true);
3001 3001
 				$aircraft_icao = $this->getAllAircraftType($ModeS);
3002
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3002
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3003 3003
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3004 3004
 				{
3005 3005
 					$timeelapsed = microtime(true);
3006 3006
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3007
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3007
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3008 3008
 				} else {
3009 3009
 					$timeelapsed = microtime(true);
3010 3010
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3011
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3011
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3012 3012
 				}
3013 3013
 			}
3014 3014
 		}
@@ -3022,7 +3022,7 @@  discard block
 block discarded – undo
3022 3022
 			} else {
3023 3023
 				$timeelapsed = microtime(true);
3024 3024
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3025
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3025
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3026 3026
 			}
3027 3027
 		}
3028 3028
 		
@@ -3035,7 +3035,7 @@  discard block
 block discarded – undo
3035 3035
 			} else {
3036 3036
 				$timeelapsed = microtime(true);
3037 3037
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3038
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3038
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3039 3039
 			}
3040 3040
 		}
3041 3041
 
@@ -3099,7 +3099,7 @@  discard block
 block discarded – undo
3099 3099
 		{
3100 3100
 			$timeelapsed = microtime(true);
3101 3101
 			$image_array = $Image->getSpotterImage($registration);
3102
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3102
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3103 3103
 			if (!isset($image_array[0]['registration']))
3104 3104
 			{
3105 3105
 				//echo "Add image !!!! \n";
@@ -3107,7 +3107,7 @@  discard block
 block discarded – undo
3107 3107
 			}
3108 3108
 			$timeelapsed = microtime(true);
3109 3109
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3110
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3110
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3111 3111
 			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
3112 3112
 		}
3113 3113
     
@@ -3115,33 +3115,33 @@  discard block
 block discarded – undo
3115 3115
 		{
3116 3116
             		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3117 3117
             		else $airline_icao = '';
3118
-			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3118
+			$image_array = $Image->getSpotterImage('', $aircraft_icao, $airline_icao);
3119 3119
 			if (!isset($image_array[0]['registration']))
3120 3120
 			{
3121 3121
 				//echo "Add image !!!! \n";
3122
-				$Image->addSpotterImage('',$aircraft_icao,$airline_icao);
3122
+				$Image->addSpotterImage('', $aircraft_icao, $airline_icao);
3123 3123
 			}
3124 3124
 		}
3125 3125
     
3126
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
3127
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
3128
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
3129
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3130
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
3131
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
3132
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3133
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3134
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
3135
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3136
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
3137
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3138
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
3139
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
3140
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
3141
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
3142
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
3143
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
3144
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
3126
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
3127
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
3128
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
3129
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3130
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
3131
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
3132
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3133
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3134
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
3135
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3136
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
3137
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3138
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
3139
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
3140
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
3141
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
3142
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
3143
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
3144
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
3145 3145
 	
3146 3146
 		if (count($airline_array) == 0) 
3147 3147
 		{
@@ -3165,7 +3165,7 @@  discard block
 block discarded – undo
3165 3165
                 if ($heading == '' || $Common->isInteger($heading) == false) $heading = 0;
3166 3166
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) == false) $groundspeed = 0;
3167 3167
                 if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3168
-                $query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3168
+                $query = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3169 3169
                 VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)";
3170 3170
 
3171 3171
                 $airline_name = $airline_array[0]['name'];
@@ -3175,7 +3175,7 @@  discard block
 block discarded – undo
3175 3175
 		if ($airline_type == '') {
3176 3176
 			$timeelapsed = microtime(true);
3177 3177
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3178
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3178
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3179 3179
 		}
3180 3180
 		if ($airline_type == null) $airline_type = '';
3181 3181
                 $aircraft_type = $aircraft_array[0]['type'];
@@ -3187,7 +3187,7 @@  discard block
 block discarded – undo
3187 3187
                 $arrival_airport_name = $arrival_airport_array[0]['name'];
3188 3188
                 $arrival_airport_city = $arrival_airport_array[0]['city'];
3189 3189
                 $arrival_airport_country = $arrival_airport_array[0]['country'];
3190
-                $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date,':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name);
3190
+                $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name);
3191 3191
 
3192 3192
 		try {
3193 3193
 		        
@@ -3213,13 +3213,13 @@  discard block
 block discarded – undo
3213 3213
 	{
3214 3214
 		global $globalDBdriver, $globalTimezone;
3215 3215
 		if ($globalDBdriver == 'mysql') {
3216
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3216
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3217 3217
 								WHERE spotter_output.ident = :ident 
3218 3218
 								AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
3219 3219
 								AND spotter_output.date < UTC_TIMESTAMP()";
3220 3220
 			$query_data = array(':ident' => $ident);
3221 3221
 		} elseif ($globalDBdriver == 'pgsql') {
3222
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3222
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3223 3223
 								WHERE spotter_output.ident = :ident 
3224 3224
 								AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
3225 3225
 								AND spotter_output.date < now() AT TIME ZONE 'UTC'";
@@ -3228,8 +3228,8 @@  discard block
 block discarded – undo
3228 3228
 		
3229 3229
 		$sth = $this->db->prepare($query);
3230 3230
 		$sth->execute($query_data);
3231
-    		$ident_result='';
3232
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3231
+    		$ident_result = '';
3232
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3233 3233
 		{
3234 3234
 			$ident_result = $row['ident'];
3235 3235
 		}
@@ -3255,8 +3255,8 @@  discard block
 block discarded – undo
3255 3255
 				return false;
3256 3256
 			} else {
3257 3257
 				$q_array = explode(" ", $q);
3258
-				foreach ($q_array as $q_item){
3259
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
3258
+				foreach ($q_array as $q_item) {
3259
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
3260 3260
 					$additional_query .= " AND (";
3261 3261
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
3262 3262
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
@@ -3271,11 +3271,11 @@  discard block
 block discarded – undo
3271 3271
 			}
3272 3272
 		}
3273 3273
 		if ($globalDBdriver == 'mysql') {
3274
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3274
+			$query = "SELECT spotter_output.* FROM spotter_output 
3275 3275
 				WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
3276 3276
 				AND spotter_output.date < UTC_TIMESTAMP()";
3277 3277
 		} else {
3278
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3278
+			$query = "SELECT spotter_output.* FROM spotter_output 
3279 3279
 				WHERE spotter_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
3280 3280
 				AND spotter_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
3281 3281
 		}
@@ -3295,7 +3295,7 @@  discard block
 block discarded – undo
3295 3295
 	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
3296 3296
 	{
3297 3297
 		global $globalDBdriver;
3298
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3298
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3299 3299
 		 			FROM spotter_output
3300 3300
 					WHERE spotter_output.airline_name <> '' AND spotter_output.airline_icao <> 'NA' ";
3301 3301
                 if ($olderthanmonths > 0) {
@@ -3322,7 +3322,7 @@  discard block
 block discarded – undo
3322 3322
         $airline_array = array();
3323 3323
 		$temp_array = array();
3324 3324
         
3325
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3325
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3326 3326
 		{
3327 3327
 			$temp_array['airline_name'] = $row['airline_name'];
3328 3328
             $temp_array['airline_icao'] = $row['airline_icao'];
@@ -3344,7 +3344,7 @@  discard block
 block discarded – undo
3344 3344
 	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '')
3345 3345
 	{
3346 3346
 		global $globalDBdriver;
3347
-		$query  = "SELECT DISTINCT spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3347
+		$query = "SELECT DISTINCT spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3348 3348
 		 			FROM spotter_output
3349 3349
 					WHERE spotter_output.pilot_id <> '' ";
3350 3350
                 if ($olderthanmonths > 0) {
@@ -3371,7 +3371,7 @@  discard block
 block discarded – undo
3371 3371
 		$airline_array = array();
3372 3372
 		$temp_array = array();
3373 3373
         
3374
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3374
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3375 3375
 		{
3376 3376
 			$temp_array['pilot_name'] = $row['pilot_name'];
3377 3377
 			$temp_array['pilot_id'] = $row['pilot_id'];
@@ -3403,7 +3403,7 @@  discard block
 block discarded – undo
3403 3403
 		$airline_array = array();
3404 3404
 		$temp_array = array();
3405 3405
         
3406
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3406
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3407 3407
 		{
3408 3408
 			$temp_array['owner_name'] = $row['owner_name'];
3409 3409
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -3421,9 +3421,9 @@  discard block
 block discarded – undo
3421 3421
 	*/
3422 3422
 	public function countAllAirlinesByAircraft($aircraft_icao)
3423 3423
 	{
3424
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3424
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3425 3425
 
3426
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3426
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3427 3427
 		 			FROM spotter_output
3428 3428
 					WHERE spotter_output.airline_name <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
3429 3429
                     GROUP BY spotter_output.airline_name
@@ -3436,7 +3436,7 @@  discard block
 block discarded – undo
3436 3436
 		$airline_array = array();
3437 3437
 		$temp_array = array();
3438 3438
         
3439
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3439
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3440 3440
 		{
3441 3441
 			$temp_array['airline_name'] = $row['airline_name'];
3442 3442
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3458,9 +3458,9 @@  discard block
 block discarded – undo
3458 3458
 	*/
3459 3459
 	public function countAllAirlineCountriesByAircraft($aircraft_icao)
3460 3460
 	{
3461
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3461
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3462 3462
       
3463
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3463
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3464 3464
 		 			FROM spotter_output
3465 3465
 					WHERE spotter_output.airline_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
3466 3466
                     GROUP BY spotter_output.airline_country
@@ -3474,7 +3474,7 @@  discard block
 block discarded – undo
3474 3474
 		$airline_country_array = array();
3475 3475
 		$temp_array = array();
3476 3476
         
3477
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3477
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3478 3478
 		{
3479 3479
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
3480 3480
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -3495,9 +3495,9 @@  discard block
 block discarded – undo
3495 3495
 	*/
3496 3496
 	public function countAllAirlinesByAirport($airport_icao)
3497 3497
 	{
3498
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
3498
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
3499 3499
 
3500
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3500
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3501 3501
 		 			FROM spotter_output
3502 3502
 					WHERE spotter_output.airline_name <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao ) 
3503 3503
                     GROUP BY spotter_output.airline_name
@@ -3510,7 +3510,7 @@  discard block
 block discarded – undo
3510 3510
 		$airline_array = array();
3511 3511
 		$temp_array = array();
3512 3512
         
3513
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3513
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3514 3514
 		{
3515 3515
 			$temp_array['airline_name'] = $row['airline_name'];
3516 3516
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3531,9 +3531,9 @@  discard block
 block discarded – undo
3531 3531
 	*/
3532 3532
 	public function countAllAirlineCountriesByAirport($airport_icao)
3533 3533
 	{
3534
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
3534
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
3535 3535
       
3536
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3536
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3537 3537
 		 			FROM spotter_output
3538 3538
 					WHERE spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao )
3539 3539
 					GROUP BY spotter_output.airline_country
@@ -3547,7 +3547,7 @@  discard block
 block discarded – undo
3547 3547
 		$airline_country_array = array();
3548 3548
 		$temp_array = array();
3549 3549
         
3550
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3550
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3551 3551
 		{
3552 3552
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
3553 3553
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -3566,9 +3566,9 @@  discard block
 block discarded – undo
3566 3566
 	*/
3567 3567
 	public function countAllAirlinesByManufacturer($aircraft_manufacturer)
3568 3568
 	{
3569
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
3569
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
3570 3570
 
3571
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3571
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3572 3572
 		 			FROM spotter_output
3573 3573
 					WHERE spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
3574 3574
 					GROUP BY spotter_output.airline_name
@@ -3580,7 +3580,7 @@  discard block
 block discarded – undo
3580 3580
 		$airline_array = array();
3581 3581
 		$temp_array = array();
3582 3582
         
3583
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3583
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3584 3584
 		{
3585 3585
 			$temp_array['airline_name'] = $row['airline_name'];
3586 3586
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3602,9 +3602,9 @@  discard block
 block discarded – undo
3602 3602
 	*/
3603 3603
 	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer)
3604 3604
 	{
3605
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
3605
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
3606 3606
       
3607
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3607
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3608 3608
 		 			FROM spotter_output
3609 3609
 					WHERE spotter_output.airline_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
3610 3610
 					GROUP BY spotter_output.airline_country
@@ -3618,7 +3618,7 @@  discard block
 block discarded – undo
3618 3618
 		$airline_country_array = array();
3619 3619
 		$temp_array = array();
3620 3620
         
3621
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3621
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3622 3622
 		{
3623 3623
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
3624 3624
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -3637,7 +3637,7 @@  discard block
 block discarded – undo
3637 3637
 	public function countAllAirlinesByDate($date)
3638 3638
 	{
3639 3639
 		global $globalTimezone, $globalDBdriver;
3640
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
3640
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
3641 3641
 
3642 3642
 		if ($globalTimezone != '') {
3643 3643
 			date_default_timezone_set($globalTimezone);
@@ -3646,13 +3646,13 @@  discard block
 block discarded – undo
3646 3646
 		} else $offset = '+00:00';
3647 3647
 
3648 3648
 		if ($globalDBdriver == 'mysql') {
3649
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3649
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3650 3650
 		 			FROM spotter_output
3651 3651
 					WHERE DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
3652 3652
 					GROUP BY spotter_output.airline_name
3653 3653
 					ORDER BY airline_count DESC";
3654 3654
 		} else {
3655
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3655
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3656 3656
 		 			FROM spotter_output
3657 3657
 					WHERE to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
3658 3658
 					GROUP BY spotter_output.airline_name
@@ -3664,7 +3664,7 @@  discard block
 block discarded – undo
3664 3664
 
3665 3665
 		$airline_array = array();
3666 3666
 		$temp_array = array();
3667
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3667
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3668 3668
 		{
3669 3669
 			$temp_array['airline_name'] = $row['airline_name'];
3670 3670
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3687,7 +3687,7 @@  discard block
 block discarded – undo
3687 3687
 	public function countAllAirlineCountriesByDate($date)
3688 3688
 	{
3689 3689
 		global $globalTimezone, $globalDBdriver;
3690
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
3690
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
3691 3691
 		if ($globalTimezone != '') {
3692 3692
 			date_default_timezone_set($globalTimezone);
3693 3693
 			$datetime = new DateTime($date);
@@ -3695,14 +3695,14 @@  discard block
 block discarded – undo
3695 3695
 		} else $offset = '+00:00';
3696 3696
 		
3697 3697
 		if ($globalDBdriver == 'mysql') {
3698
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3698
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3699 3699
 		 			FROM spotter_output
3700 3700
 					WHERE spotter_output.airline_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
3701 3701
 					GROUP BY spotter_output.airline_country
3702 3702
 					ORDER BY airline_country_count DESC
3703 3703
 					LIMIT 10 OFFSET 0";
3704 3704
 		} else {
3705
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3705
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3706 3706
 		 			FROM spotter_output
3707 3707
 					WHERE spotter_output.airline_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
3708 3708
 					GROUP BY spotter_output.airline_country
@@ -3715,7 +3715,7 @@  discard block
 block discarded – undo
3715 3715
  
3716 3716
 		$airline_country_array = array();
3717 3717
 		$temp_array = array();
3718
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3718
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3719 3719
 		{
3720 3720
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
3721 3721
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -3734,9 +3734,9 @@  discard block
 block discarded – undo
3734 3734
 	*/
3735 3735
 	public function countAllAirlinesByIdent($ident)
3736 3736
 	{
3737
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
3737
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
3738 3738
 
3739
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3739
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3740 3740
 		 		FROM spotter_output
3741 3741
 				WHERE spotter_output.ident = :ident  
3742 3742
 				GROUP BY spotter_output.airline_name
@@ -3749,7 +3749,7 @@  discard block
 block discarded – undo
3749 3749
 		$airline_array = array();
3750 3750
 		$temp_array = array();
3751 3751
         
3752
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3752
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3753 3753
 		{
3754 3754
 			$temp_array['airline_name'] = $row['airline_name'];
3755 3755
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3769,10 +3769,10 @@  discard block
 block discarded – undo
3769 3769
 	*/
3770 3770
 	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao)
3771 3771
 	{
3772
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
3773
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
3772
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
3773
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
3774 3774
 
3775
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3775
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3776 3776
 		 			FROM spotter_output
3777 3777
 					WHERE (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
3778 3778
 					GROUP BY spotter_output.airline_name
@@ -3780,12 +3780,12 @@  discard block
 block discarded – undo
3780 3780
       
3781 3781
 		
3782 3782
 		$sth = $this->db->prepare($query);
3783
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
3783
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
3784 3784
       
3785 3785
 		$airline_array = array();
3786 3786
 		$temp_array = array();
3787 3787
         
3788
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3788
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3789 3789
 		{
3790 3790
 			$temp_array['airline_name'] = $row['airline_name'];
3791 3791
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3805,10 +3805,10 @@  discard block
 block discarded – undo
3805 3805
 	*/
3806 3806
 	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao)
3807 3807
 	{
3808
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
3809
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
3808
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
3809
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
3810 3810
       
3811
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3811
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3812 3812
 		 		FROM spotter_output
3813 3813
 				WHERE spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
3814 3814
 				GROUP BY spotter_output.airline_country
@@ -3817,11 +3817,11 @@  discard block
 block discarded – undo
3817 3817
       
3818 3818
 		
3819 3819
 		$sth = $this->db->prepare($query);
3820
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
3820
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
3821 3821
       
3822 3822
 		$airline_country_array = array();
3823 3823
 		$temp_array = array();
3824
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3824
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3825 3825
 		{
3826 3826
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
3827 3827
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -3841,9 +3841,9 @@  discard block
 block discarded – undo
3841 3841
 	*/
3842 3842
 	public function countAllAirlinesByCountry($country)
3843 3843
 	{
3844
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
3844
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
3845 3845
 
3846
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3846
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3847 3847
 		 		FROM spotter_output
3848 3848
 				WHERE ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
3849 3849
 				GROUP BY spotter_output.airline_name
@@ -3855,7 +3855,7 @@  discard block
 block discarded – undo
3855 3855
 
3856 3856
 		$airline_array = array();
3857 3857
 		$temp_array = array();
3858
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3858
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3859 3859
 		{
3860 3860
 			$temp_array['airline_name'] = $row['airline_name'];
3861 3861
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3876,9 +3876,9 @@  discard block
 block discarded – undo
3876 3876
 	*/
3877 3877
 	public function countAllAirlineCountriesByCountry($country)
3878 3878
 	{
3879
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
3879
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
3880 3880
       
3881
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3881
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3882 3882
 		 		FROM spotter_output
3883 3883
 				WHERE spotter_output.airline_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
3884 3884
 				GROUP BY spotter_output.airline_country
@@ -3891,7 +3891,7 @@  discard block
 block discarded – undo
3891 3891
 
3892 3892
 		$airline_country_array = array();
3893 3893
 		$temp_array = array();
3894
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3894
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3895 3895
 		{
3896 3896
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
3897 3897
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -3910,7 +3910,7 @@  discard block
 block discarded – undo
3910 3910
 	*/
3911 3911
 	public function countAllAirlineCountries($limit = true)
3912 3912
 	{
3913
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3913
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3914 3914
 		 			FROM spotter_output
3915 3915
 					WHERE spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' 
3916 3916
 					GROUP BY spotter_output.airline_country
@@ -3922,7 +3922,7 @@  discard block
 block discarded – undo
3922 3922
 
3923 3923
 		$airline_array = array();
3924 3924
 		$temp_array = array();
3925
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3925
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3926 3926
 		{
3927 3927
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
3928 3928
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -3938,7 +3938,7 @@  discard block
 block discarded – undo
3938 3938
 	* @return Array the airline country list
3939 3939
 	*
3940 3940
 	*/
3941
-	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
3941
+	public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
3942 3942
 	{
3943 3943
 		global $globalDBdriver;
3944 3944
 		/*
@@ -3967,7 +3967,7 @@  discard block
 block discarded – undo
3967 3967
 		$flight_array = array();
3968 3968
 		$temp_array = array();
3969 3969
         
3970
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3970
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3971 3971
 		{
3972 3972
 			$temp_array['flight_count'] = $row['nb'];
3973 3973
 			$temp_array['flight_country'] = $row['name'];
@@ -3985,10 +3985,10 @@  discard block
 block discarded – undo
3985 3985
 	* @return Array the aircraft list
3986 3986
 	*
3987 3987
 	*/
3988
-	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '')
3988
+	public function countAllAircraftTypes($limit = true, $olderthanmonths = 0, $sincedate = '')
3989 3989
 	{
3990 3990
 		global $globalDBdriver;
3991
-		$query  = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
3991
+		$query = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
3992 3992
                     FROM spotter_output
3993 3993
                     WHERE spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> '' ";
3994 3994
                 if ($olderthanmonths > 0) {
@@ -4018,7 +4018,7 @@  discard block
 block discarded – undo
4018 4018
 		$aircraft_array = array();
4019 4019
 		$temp_array = array();
4020 4020
         
4021
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4021
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4022 4022
 		{
4023 4023
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4024 4024
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4039,9 +4039,9 @@  discard block
 block discarded – undo
4039 4039
 	public function countAllAircraftRegistrationByAircraft($aircraft_icao)
4040 4040
 	{
4041 4041
 		$Image = new Image($this->db);
4042
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
4042
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
4043 4043
 
4044
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4044
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4045 4045
 				FROM spotter_output
4046 4046
 				WHERE spotter_output.registration <> '' AND spotter_output.aircraft_icao = :aircraft_icao  
4047 4047
 				GROUP BY spotter_output.registration 
@@ -4053,14 +4053,14 @@  discard block
 block discarded – undo
4053 4053
 		$aircraft_array = array();
4054 4054
 		$temp_array = array();
4055 4055
         
4056
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4056
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4057 4057
 		{
4058 4058
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4059 4059
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4060 4060
 			$temp_array['registration'] = $row['registration'];
4061 4061
 			$temp_array['airline_name'] = $row['airline_name'];
4062 4062
 			$temp_array['image_thumbnail'] = "";
4063
-			if($row['registration'] != "")
4063
+			if ($row['registration'] != "")
4064 4064
 			{
4065 4065
 				$image_array = $Image->getSpotterImage($row['registration']);
4066 4066
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4081,9 +4081,9 @@  discard block
 block discarded – undo
4081 4081
 	*/
4082 4082
 	public function countAllAircraftTypesByAirline($airline_icao)
4083 4083
 	{
4084
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
4084
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
4085 4085
 
4086
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4086
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4087 4087
 				FROM spotter_output
4088 4088
 				WHERE spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao = :airline_icao 
4089 4089
 				GROUP BY spotter_output.aircraft_name 
@@ -4095,7 +4095,7 @@  discard block
 block discarded – undo
4095 4095
 		$ircraft_array = array();
4096 4096
 		$temp_array = array();
4097 4097
 
4098
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4098
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4099 4099
 		{
4100 4100
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4101 4101
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4116,9 +4116,9 @@  discard block
 block discarded – undo
4116 4116
 	public function countAllAircraftRegistrationByAirline($airline_icao)
4117 4117
 	{
4118 4118
 		$Image = new Image($this->db);
4119
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
4119
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
4120 4120
 
4121
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
4121
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
4122 4122
 				FROM spotter_output
4123 4123
 				WHERE spotter_output.registration <> '' AND spotter_output.airline_icao = :airline_icao 
4124 4124
 				GROUP BY spotter_output.registration 
@@ -4129,14 +4129,14 @@  discard block
 block discarded – undo
4129 4129
 
4130 4130
 		$aircraft_array = array();
4131 4131
 		$temp_array = array();
4132
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4132
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4133 4133
 		{
4134 4134
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4135 4135
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4136 4136
 			$temp_array['registration'] = $row['registration'];
4137 4137
 			$temp_array['airline_name'] = $row['airline_name'];
4138 4138
 			$temp_array['image_thumbnail'] = "";
4139
-			if($row['registration'] != "")
4139
+			if ($row['registration'] != "")
4140 4140
 			{
4141 4141
 				$image_array = $Image->getSpotterImage($row['registration']);
4142 4142
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4157,9 +4157,9 @@  discard block
 block discarded – undo
4157 4157
 	*/
4158 4158
 	public function countAllAircraftManufacturerByAirline($airline_icao)
4159 4159
 	{
4160
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
4160
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
4161 4161
 
4162
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4162
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4163 4163
 				FROM spotter_output
4164 4164
 				WHERE spotter_output.aircraft_manufacturer <> '' AND spotter_output.airline_icao = :airline_icao 
4165 4165
 				GROUP BY spotter_output.aircraft_manufacturer 
@@ -4171,7 +4171,7 @@  discard block
 block discarded – undo
4171 4171
 		$aircraft_array = array();
4172 4172
 		$temp_array = array();
4173 4173
 
4174
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4174
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4175 4175
 		{
4176 4176
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4177 4177
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4190,9 +4190,9 @@  discard block
 block discarded – undo
4190 4190
 	*/
4191 4191
 	public function countAllAircraftTypesByAirport($airport_icao)
4192 4192
 	{
4193
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4193
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4194 4194
 
4195
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4195
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4196 4196
 				FROM spotter_output
4197 4197
 				WHERE spotter_output.aircraft_icao <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) 
4198 4198
 				GROUP BY spotter_output.aircraft_name 
@@ -4203,7 +4203,7 @@  discard block
 block discarded – undo
4203 4203
 
4204 4204
 		$aircraft_array = array();
4205 4205
 		$temp_array = array();
4206
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4206
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4207 4207
 		{
4208 4208
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4209 4209
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4224,9 +4224,9 @@  discard block
 block discarded – undo
4224 4224
 	public function countAllAircraftRegistrationByAirport($airport_icao)
4225 4225
 	{
4226 4226
 		$Image = new Image($this->db);
4227
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4227
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4228 4228
 
4229
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4229
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4230 4230
                     FROM spotter_output
4231 4231
                     WHERE spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)   
4232 4232
                     GROUP BY spotter_output.registration 
@@ -4239,14 +4239,14 @@  discard block
 block discarded – undo
4239 4239
         $aircraft_array = array();
4240 4240
 		$temp_array = array();
4241 4241
         
4242
-        while($row = $sth->fetch(PDO::FETCH_ASSOC))
4242
+        while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4243 4243
 		{
4244 4244
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4245 4245
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4246 4246
 			$temp_array['registration'] = $row['registration'];
4247 4247
             $temp_array['airline_name'] = $row['airline_name'];
4248 4248
 			$temp_array['image_thumbnail'] = "";
4249
-            if($row['registration'] != "")
4249
+            if ($row['registration'] != "")
4250 4250
               {
4251 4251
                   $image_array = $Image->getSpotterImage($row['registration']);
4252 4252
                   $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4268,9 +4268,9 @@  discard block
 block discarded – undo
4268 4268
 	*/
4269 4269
 	public function countAllAircraftManufacturerByAirport($airport_icao)
4270 4270
 	{
4271
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4271
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4272 4272
 
4273
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4273
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4274 4274
                     FROM spotter_output
4275 4275
                     WHERE spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)  
4276 4276
                     GROUP BY spotter_output.aircraft_manufacturer 
@@ -4283,7 +4283,7 @@  discard block
 block discarded – undo
4283 4283
     $aircraft_array = array();
4284 4284
 		$temp_array = array();
4285 4285
         
4286
-    while($row = $sth->fetch(PDO::FETCH_ASSOC))
4286
+    while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4287 4287
 		{
4288 4288
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4289 4289
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4304,9 +4304,9 @@  discard block
 block discarded – undo
4304 4304
 	*/
4305 4305
 	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer)
4306 4306
 	{
4307
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4307
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4308 4308
 
4309
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4309
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4310 4310
                     FROM spotter_output
4311 4311
                     WHERE spotter_output.aircraft_manufacturer = :aircraft_manufacturer
4312 4312
                     GROUP BY spotter_output.aircraft_name 
@@ -4319,7 +4319,7 @@  discard block
 block discarded – undo
4319 4319
         $aircraft_array = array();
4320 4320
 		$temp_array = array();
4321 4321
         
4322
-        while($row = $sth->fetch(PDO::FETCH_ASSOC))
4322
+        while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4323 4323
 		{
4324 4324
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4325 4325
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4341,9 +4341,9 @@  discard block
 block discarded – undo
4341 4341
 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer)
4342 4342
 	{
4343 4343
 		$Image = new Image($this->db);
4344
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4344
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4345 4345
 
4346
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
4346
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
4347 4347
                     FROM spotter_output
4348 4348
                     WHERE spotter_output.registration <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
4349 4349
                     GROUP BY spotter_output.registration 
@@ -4356,14 +4356,14 @@  discard block
 block discarded – undo
4356 4356
         $aircraft_array = array();
4357 4357
 		$temp_array = array();
4358 4358
         
4359
-        while($row = $sth->fetch(PDO::FETCH_ASSOC))
4359
+        while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4360 4360
 		{
4361 4361
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4362 4362
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4363 4363
 			$temp_array['registration'] = $row['registration'];
4364 4364
             $temp_array['airline_name'] = $row['airline_name'];
4365 4365
 			$temp_array['image_thumbnail'] = "";
4366
-            if($row['registration'] != "")
4366
+            if ($row['registration'] != "")
4367 4367
               {
4368 4368
                   $image_array = $Image->getSpotterImage($row['registration']);
4369 4369
                   $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4387,7 +4387,7 @@  discard block
 block discarded – undo
4387 4387
 	public function countAllAircraftTypesByDate($date)
4388 4388
 	{
4389 4389
 		global $globalTimezone, $globalDBdriver;
4390
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4390
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4391 4391
 		if ($globalTimezone != '') {
4392 4392
 			date_default_timezone_set($globalTimezone);
4393 4393
 			$datetime = new DateTime($date);
@@ -4395,13 +4395,13 @@  discard block
 block discarded – undo
4395 4395
 		} else $offset = '+00:00';
4396 4396
 
4397 4397
 		if ($globalDBdriver == 'mysql') {
4398
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4398
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4399 4399
 					FROM spotter_output
4400 4400
 					WHERE DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
4401 4401
 					GROUP BY spotter_output.aircraft_name 
4402 4402
 					ORDER BY aircraft_icao_count DESC";
4403 4403
 		} else {
4404
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4404
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4405 4405
 					FROM spotter_output
4406 4406
 					WHERE to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date
4407 4407
 					GROUP BY spotter_output.aircraft_name 
@@ -4413,7 +4413,7 @@  discard block
 block discarded – undo
4413 4413
 
4414 4414
 		$aircraft_array = array();
4415 4415
 		$temp_array = array();
4416
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4416
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4417 4417
 		{
4418 4418
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4419 4419
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4435,7 +4435,7 @@  discard block
 block discarded – undo
4435 4435
 	{
4436 4436
 		global $globalTimezone, $globalDBdriver;
4437 4437
 		$Image = new Image($this->db);
4438
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4438
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4439 4439
 		if ($globalTimezone != '') {
4440 4440
 			date_default_timezone_set($globalTimezone);
4441 4441
 			$datetime = new DateTime($date);
@@ -4443,13 +4443,13 @@  discard block
 block discarded – undo
4443 4443
 		} else $offset = '+00:00';
4444 4444
 
4445 4445
 		if ($globalDBdriver == 'mysql') {
4446
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
4446
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
4447 4447
 					FROM spotter_output
4448 4448
 					WHERE spotter_output.registration <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4449 4449
 					GROUP BY spotter_output.registration 
4450 4450
 					ORDER BY registration_count DESC";
4451 4451
 		} else {
4452
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
4452
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
4453 4453
 					FROM spotter_output
4454 4454
 					WHERE spotter_output.registration <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4455 4455
 					GROUP BY spotter_output.registration 
@@ -4461,14 +4461,14 @@  discard block
 block discarded – undo
4461 4461
 
4462 4462
 		$aircraft_array = array();
4463 4463
 		$temp_array = array();
4464
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4464
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4465 4465
 		{
4466 4466
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4467 4467
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4468 4468
 			$temp_array['registration'] = $row['registration'];
4469 4469
 			$temp_array['airline_name'] = $row['airline_name'];
4470 4470
 			$temp_array['image_thumbnail'] = "";
4471
-			if($row['registration'] != "")
4471
+			if ($row['registration'] != "")
4472 4472
 			{
4473 4473
 				$image_array = $Image->getSpotterImage($row['registration']);
4474 4474
 				$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4490,7 +4490,7 @@  discard block
 block discarded – undo
4490 4490
 	public function countAllAircraftManufacturerByDate($date)
4491 4491
 	{
4492 4492
 		global $globalTimezone, $globalDBdriver;
4493
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4493
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4494 4494
 		if ($globalTimezone != '') {
4495 4495
 			date_default_timezone_set($globalTimezone);
4496 4496
 			$datetime = new DateTime($date);
@@ -4498,13 +4498,13 @@  discard block
 block discarded – undo
4498 4498
 		} else $offset = '+00:00';
4499 4499
 
4500 4500
 		if ($globalDBdriver == 'mysql') {
4501
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4501
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4502 4502
 				FROM spotter_output
4503 4503
 				WHERE spotter_output.aircraft_manufacturer <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4504 4504
 				GROUP BY spotter_output.aircraft_manufacturer 
4505 4505
 				ORDER BY aircraft_manufacturer_count DESC";
4506 4506
 		} else {
4507
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4507
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4508 4508
 				FROM spotter_output
4509 4509
 				WHERE spotter_output.aircraft_manufacturer <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4510 4510
 				GROUP BY spotter_output.aircraft_manufacturer 
@@ -4517,7 +4517,7 @@  discard block
 block discarded – undo
4517 4517
 		$aircraft_array = array();
4518 4518
 		$temp_array = array();
4519 4519
 
4520
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4520
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4521 4521
 		{
4522 4522
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4523 4523
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4536,9 +4536,9 @@  discard block
 block discarded – undo
4536 4536
 	*/
4537 4537
 	public function countAllAircraftTypesByIdent($ident)
4538 4538
 	{
4539
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
4539
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
4540 4540
 
4541
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4541
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4542 4542
 				FROM spotter_output
4543 4543
 				WHERE spotter_output.ident = :ident 
4544 4544
 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao
@@ -4550,7 +4550,7 @@  discard block
 block discarded – undo
4550 4550
 		$aircraft_array = array();
4551 4551
 		$temp_array = array();
4552 4552
 
4553
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4553
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4554 4554
 		{
4555 4555
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4556 4556
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4571,9 +4571,9 @@  discard block
 block discarded – undo
4571 4571
 	public function countAllAircraftRegistrationByIdent($ident)
4572 4572
 	{
4573 4573
 		$Image = new Image($this->db);
4574
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
4574
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
4575 4575
 
4576
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4576
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4577 4577
                     FROM spotter_output
4578 4578
                     WHERE spotter_output.registration <> '' AND spotter_output.ident = :ident   
4579 4579
                     GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name
@@ -4586,14 +4586,14 @@  discard block
 block discarded – undo
4586 4586
 		$aircraft_array = array();
4587 4587
 		$temp_array = array();
4588 4588
         
4589
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4589
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4590 4590
 		{
4591 4591
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4592 4592
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4593 4593
 			$temp_array['registration'] = $row['registration'];
4594 4594
 			$temp_array['airline_name'] = $row['airline_name'];
4595 4595
 			$temp_array['image_thumbnail'] = "";
4596
-			if($row['registration'] != "")
4596
+			if ($row['registration'] != "")
4597 4597
 			{
4598 4598
 				$image_array = $Image->getSpotterImage($row['registration']);
4599 4599
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4614,9 +4614,9 @@  discard block
 block discarded – undo
4614 4614
 	*/
4615 4615
 	public function countAllAircraftManufacturerByIdent($ident)
4616 4616
 	{
4617
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
4617
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
4618 4618
 
4619
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4619
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4620 4620
                     FROM spotter_output
4621 4621
                     WHERE spotter_output.aircraft_manufacturer <> '' AND spotter_output.ident = :ident  
4622 4622
                     GROUP BY spotter_output.aircraft_manufacturer 
@@ -4629,7 +4629,7 @@  discard block
 block discarded – undo
4629 4629
     $aircraft_array = array();
4630 4630
 		$temp_array = array();
4631 4631
         
4632
-    while($row = $sth->fetch(PDO::FETCH_ASSOC))
4632
+    while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4633 4633
 		{
4634 4634
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4635 4635
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4649,11 +4649,11 @@  discard block
 block discarded – undo
4649 4649
 	*/
4650 4650
 	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao)
4651 4651
 	{
4652
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4653
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4652
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4653
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4654 4654
 		
4655 4655
 
4656
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4656
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4657 4657
                     FROM spotter_output
4658 4658
                     WHERE (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
4659 4659
                     GROUP BY spotter_output.aircraft_name 
@@ -4661,12 +4661,12 @@  discard block
 block discarded – undo
4661 4661
  
4662 4662
 		
4663 4663
 		$sth = $this->db->prepare($query);
4664
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4664
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4665 4665
       
4666 4666
         $aircraft_array = array();
4667 4667
 		$temp_array = array();
4668 4668
         
4669
-        while($row = $sth->fetch(PDO::FETCH_ASSOC))
4669
+        while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4670 4670
 		{
4671 4671
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4672 4672
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4688,10 +4688,10 @@  discard block
 block discarded – undo
4688 4688
 	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao)
4689 4689
 	{
4690 4690
 		$Image = new Image($this->db);
4691
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4692
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4691
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4692
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4693 4693
 
4694
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
4694
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
4695 4695
                     FROM spotter_output
4696 4696
                     WHERE spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)   
4697 4697
                     GROUP BY spotter_output.registration 
@@ -4699,19 +4699,19 @@  discard block
 block discarded – undo
4699 4699
 
4700 4700
 		
4701 4701
 		$sth = $this->db->prepare($query);
4702
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4702
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4703 4703
       
4704 4704
 		$aircraft_array = array();
4705 4705
 		$temp_array = array();
4706 4706
         
4707
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4707
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4708 4708
 		{
4709 4709
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4710 4710
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4711 4711
 			$temp_array['registration'] = $row['registration'];
4712 4712
 			$temp_array['airline_name'] = $row['airline_name'];
4713 4713
 			$temp_array['image_thumbnail'] = "";
4714
-			if($row['registration'] != "")
4714
+			if ($row['registration'] != "")
4715 4715
 			{
4716 4716
 				$image_array = $Image->getSpotterImage($row['registration']);
4717 4717
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4733,10 +4733,10 @@  discard block
 block discarded – undo
4733 4733
 	*/
4734 4734
 	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao)
4735 4735
 	{
4736
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4737
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4736
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4737
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4738 4738
 
4739
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4739
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4740 4740
                     FROM spotter_output
4741 4741
                     WHERE spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
4742 4742
                     GROUP BY spotter_output.aircraft_manufacturer 
@@ -4744,12 +4744,12 @@  discard block
 block discarded – undo
4744 4744
 
4745 4745
 		
4746 4746
 		$sth = $this->db->prepare($query);
4747
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4747
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4748 4748
       
4749 4749
 		$aircraft_array = array();
4750 4750
 		$temp_array = array();
4751 4751
         
4752
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4752
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4753 4753
 		{
4754 4754
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4755 4755
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4771,9 +4771,9 @@  discard block
 block discarded – undo
4771 4771
 	*/
4772 4772
 	public function countAllAircraftTypesByCountry($country)
4773 4773
 	{
4774
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4774
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4775 4775
 
4776
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4776
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4777 4777
                     FROM spotter_output
4778 4778
                     WHERE ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
4779 4779
                     GROUP BY spotter_output.aircraft_name 
@@ -4786,7 +4786,7 @@  discard block
 block discarded – undo
4786 4786
 		$aircraft_array = array();
4787 4787
 		$temp_array = array();
4788 4788
         
4789
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4789
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4790 4790
 		{
4791 4791
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4792 4792
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4808,9 +4808,9 @@  discard block
 block discarded – undo
4808 4808
 	public function countAllAircraftRegistrationByCountry($country)
4809 4809
 	{
4810 4810
 		$Image = new Image($this->db);
4811
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4811
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4812 4812
 
4813
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
4813
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
4814 4814
                     FROM spotter_output
4815 4815
                     WHERE spotter_output.registration <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country)    
4816 4816
                     GROUP BY spotter_output.registration 
@@ -4823,14 +4823,14 @@  discard block
 block discarded – undo
4823 4823
 		$aircraft_array = array();
4824 4824
 		$temp_array = array();
4825 4825
         
4826
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4826
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4827 4827
 		{
4828 4828
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4829 4829
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4830 4830
 			$temp_array['registration'] = $row['registration'];
4831 4831
 			$temp_array['airline_name'] = $row['airline_name'];
4832 4832
 			$temp_array['image_thumbnail'] = "";
4833
-			if($row['registration'] != "")
4833
+			if ($row['registration'] != "")
4834 4834
 			{
4835 4835
 				$image_array = $Image->getSpotterImage($row['registration']);
4836 4836
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4852,9 +4852,9 @@  discard block
 block discarded – undo
4852 4852
 	*/
4853 4853
 	public function countAllAircraftManufacturerByCountry($country)
4854 4854
 	{
4855
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4855
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4856 4856
 
4857
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4857
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4858 4858
                     FROM spotter_output
4859 4859
                     WHERE spotter_output.aircraft_manufacturer <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country) 
4860 4860
                     GROUP BY spotter_output.aircraft_manufacturer 
@@ -4867,7 +4867,7 @@  discard block
 block discarded – undo
4867 4867
 		$aircraft_array = array();
4868 4868
 		$temp_array = array();
4869 4869
         
4870
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4870
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4871 4871
 		{
4872 4872
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4873 4873
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4888,7 +4888,7 @@  discard block
 block discarded – undo
4888 4888
 	*/
4889 4889
 	public function countAllAircraftManufacturers()
4890 4890
 	{
4891
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4891
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4892 4892
                     FROM spotter_output 
4893 4893
                     WHERE spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available' 
4894 4894
                     GROUP BY spotter_output.aircraft_manufacturer
@@ -4902,7 +4902,7 @@  discard block
 block discarded – undo
4902 4902
 		$manufacturer_array = array();
4903 4903
 		$temp_array = array();
4904 4904
         
4905
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4905
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4906 4906
 		{
4907 4907
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4908 4908
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4921,11 +4921,11 @@  discard block
 block discarded – undo
4921 4921
 	* @return Array the aircraft list
4922 4922
 	*
4923 4923
 	*/
4924
-	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '')
4924
+	public function countAllAircraftRegistrations($limit = true, $olderthanmonths = 0, $sincedate = '')
4925 4925
 	{
4926 4926
 		global $globalDBdriver;
4927 4927
 		$Image = new Image($this->db);
4928
-		$query  = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
4928
+		$query = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
4929 4929
                     FROM spotter_output 
4930 4930
                     WHERE spotter_output.registration <> '' AND spotter_output.registration <> 'NA' ";
4931 4931
                 if ($olderthanmonths > 0) {
@@ -4954,7 +4954,7 @@  discard block
 block discarded – undo
4954 4954
 		$aircraft_array = array();
4955 4955
 		$temp_array = array();
4956 4956
         
4957
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4957
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4958 4958
 		{
4959 4959
 			$temp_array['registration'] = $row['registration'];
4960 4960
 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count'];
@@ -4962,7 +4962,7 @@  discard block
 block discarded – undo
4962 4962
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4963 4963
 			$temp_array['airline_name'] = $row['airline_name'];
4964 4964
 			$temp_array['image_thumbnail'] = "";
4965
-			if($row['registration'] != "")
4965
+			if ($row['registration'] != "")
4966 4966
 			{
4967 4967
 				$image_array = $Image->getSpotterImage($row['registration']);
4968 4968
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4986,7 +4986,7 @@  discard block
 block discarded – undo
4986 4986
 	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '')
4987 4987
 	{
4988 4988
 		global $globalDBdriver;
4989
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
4989
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
4990 4990
 								FROM spotter_output
4991 4991
                     WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' ";
4992 4992
                 if ($olderthanmonths > 0) {
@@ -5016,7 +5016,7 @@  discard block
 block discarded – undo
5016 5016
 		$airport_array = array();
5017 5017
 		$temp_array = array();
5018 5018
         
5019
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5019
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5020 5020
 		{
5021 5021
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5022 5022
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5038,7 +5038,7 @@  discard block
 block discarded – undo
5038 5038
 	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '')
5039 5039
 	{
5040 5040
 		global $globalDBdriver;
5041
-		$query  = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
5041
+		$query = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
5042 5042
 				FROM spotter_output, airport
5043 5043
                     WHERE spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao ";
5044 5044
                 if ($olderthanmonths > 0) {
@@ -5068,7 +5068,7 @@  discard block
 block discarded – undo
5068 5068
 		$airport_array = array();
5069 5069
 		$temp_array = array();
5070 5070
         
5071
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5071
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5072 5072
 		{
5073 5073
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5074 5074
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5091,9 +5091,9 @@  discard block
 block discarded – undo
5091 5091
 	*/
5092 5092
 	public function countAllDepartureAirportsByAirline($airline_icao)
5093 5093
 	{
5094
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5094
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5095 5095
 
5096
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5096
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5097 5097
 								FROM spotter_output
5098 5098
                     WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao 
5099 5099
                     GROUP BY spotter_output.departure_airport_icao
@@ -5106,7 +5106,7 @@  discard block
 block discarded – undo
5106 5106
 		$airport_array = array();
5107 5107
 		$temp_array = array();
5108 5108
         
5109
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5109
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5110 5110
 		{
5111 5111
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5112 5112
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5130,9 +5130,9 @@  discard block
 block discarded – undo
5130 5130
 	*/
5131 5131
 	public function countAllDepartureAirportCountriesByAirline($airline_icao)
5132 5132
 	{
5133
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5133
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5134 5134
 					
5135
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5135
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5136 5136
 								FROM spotter_output 
5137 5137
                     WHERE spotter_output.departure_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
5138 5138
                     GROUP BY spotter_output.departure_airport_country
@@ -5145,7 +5145,7 @@  discard block
 block discarded – undo
5145 5145
 		$airport_array = array();
5146 5146
 		$temp_array = array();
5147 5147
         
5148
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5148
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5149 5149
 		{
5150 5150
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5151 5151
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5166,9 +5166,9 @@  discard block
 block discarded – undo
5166 5166
 	*/
5167 5167
 	public function countAllDepartureAirportsByAircraft($aircraft_icao)
5168 5168
 	{
5169
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
5169
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
5170 5170
 
5171
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5171
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5172 5172
 								FROM spotter_output
5173 5173
                     WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao 
5174 5174
                     GROUP BY spotter_output.departure_airport_icao
@@ -5181,7 +5181,7 @@  discard block
 block discarded – undo
5181 5181
 		$airport_array = array();
5182 5182
 		$temp_array = array();
5183 5183
         
5184
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5184
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5185 5185
 		{
5186 5186
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5187 5187
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5204,9 +5204,9 @@  discard block
 block discarded – undo
5204 5204
 	*/
5205 5205
 	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao)
5206 5206
 	{
5207
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
5207
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
5208 5208
 					
5209
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5209
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5210 5210
 								FROM spotter_output 
5211 5211
                     WHERE spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
5212 5212
                     GROUP BY spotter_output.departure_airport_country
@@ -5219,7 +5219,7 @@  discard block
 block discarded – undo
5219 5219
 		$airport_array = array();
5220 5220
 		$temp_array = array();
5221 5221
         
5222
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5222
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5223 5223
 		{
5224 5224
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5225 5225
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5239,9 +5239,9 @@  discard block
 block discarded – undo
5239 5239
 	*/
5240 5240
 	public function countAllDepartureAirportsByRegistration($registration)
5241 5241
 	{
5242
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
5242
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
5243 5243
 
5244
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5244
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5245 5245
 								FROM spotter_output
5246 5246
                     WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.registration = :registration 
5247 5247
                     GROUP BY spotter_output.departure_airport_icao
@@ -5254,7 +5254,7 @@  discard block
 block discarded – undo
5254 5254
 		$airport_array = array();
5255 5255
 		$temp_array = array();
5256 5256
         
5257
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5257
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5258 5258
 		{
5259 5259
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5260 5260
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5277,9 +5277,9 @@  discard block
 block discarded – undo
5277 5277
 	*/
5278 5278
 	public function countAllDepartureAirportCountriesByRegistration($registration)
5279 5279
 	{
5280
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
5280
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
5281 5281
 					
5282
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5282
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5283 5283
 								FROM spotter_output 
5284 5284
                     WHERE spotter_output.departure_airport_country <> '' AND spotter_output.registration = :registration 
5285 5285
                     GROUP BY spotter_output.departure_airport_country
@@ -5292,7 +5292,7 @@  discard block
 block discarded – undo
5292 5292
 		$airport_array = array();
5293 5293
 		$temp_array = array();
5294 5294
         
5295
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5295
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5296 5296
 		{
5297 5297
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5298 5298
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5312,9 +5312,9 @@  discard block
 block discarded – undo
5312 5312
 	*/
5313 5313
 	public function countAllDepartureAirportsByAirport($airport_icao)
5314 5314
 	{
5315
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5315
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5316 5316
 
5317
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5317
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5318 5318
 								FROM spotter_output
5319 5319
                     WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao = :airport_icao 
5320 5320
                     GROUP BY spotter_output.departure_airport_icao
@@ -5327,7 +5327,7 @@  discard block
 block discarded – undo
5327 5327
 		$airport_array = array();
5328 5328
 		$temp_array = array();
5329 5329
         
5330
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5330
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5331 5331
 		{
5332 5332
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5333 5333
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5350,9 +5350,9 @@  discard block
 block discarded – undo
5350 5350
 	*/
5351 5351
 	public function countAllDepartureAirportCountriesByAirport($airport_icao)
5352 5352
 	{
5353
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5353
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5354 5354
 					
5355
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5355
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5356 5356
 								FROM spotter_output 
5357 5357
                     WHERE spotter_output.departure_airport_country <> '' AND spotter_output.arrival_airport_icao = :airport_icao 
5358 5358
                     GROUP BY spotter_output.departure_airport_country
@@ -5365,7 +5365,7 @@  discard block
 block discarded – undo
5365 5365
 		$airport_array = array();
5366 5366
 		$temp_array = array();
5367 5367
         
5368
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5368
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5369 5369
 		{
5370 5370
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5371 5371
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5386,9 +5386,9 @@  discard block
 block discarded – undo
5386 5386
 	*/
5387 5387
 	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer)
5388 5388
 	{
5389
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
5389
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
5390 5390
 
5391
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5391
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5392 5392
 								FROM spotter_output
5393 5393
                     WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
5394 5394
                     GROUP BY spotter_output.departure_airport_icao
@@ -5401,7 +5401,7 @@  discard block
 block discarded – undo
5401 5401
 		$airport_array = array();
5402 5402
 		$temp_array = array();
5403 5403
         
5404
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5404
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5405 5405
 		{
5406 5406
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5407 5407
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5424,9 +5424,9 @@  discard block
 block discarded – undo
5424 5424
 	*/
5425 5425
 	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer)
5426 5426
 	{
5427
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
5427
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
5428 5428
 					
5429
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5429
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5430 5430
 								FROM spotter_output 
5431 5431
                     WHERE spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
5432 5432
                     GROUP BY spotter_output.departure_airport_country
@@ -5439,7 +5439,7 @@  discard block
 block discarded – undo
5439 5439
 		$airport_array = array();
5440 5440
 		$temp_array = array();
5441 5441
         
5442
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5442
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5443 5443
 		{
5444 5444
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5445 5445
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5460,7 +5460,7 @@  discard block
 block discarded – undo
5460 5460
 	public function countAllDepartureAirportsByDate($date)
5461 5461
 	{
5462 5462
 		global $globalTimezone, $globalDBdriver;
5463
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
5463
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
5464 5464
 
5465 5465
 		if ($globalTimezone != '') {
5466 5466
 			date_default_timezone_set($globalTimezone);
@@ -5469,13 +5469,13 @@  discard block
 block discarded – undo
5469 5469
 		} else $offset = '+00:00';
5470 5470
 
5471 5471
 		if ($globalDBdriver == 'mysql') {
5472
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5472
+			$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5473 5473
 					FROM spotter_output
5474 5474
 					WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
5475 5475
 					GROUP BY spotter_output.departure_airport_icao
5476 5476
 					ORDER BY airport_departure_icao_count DESC";
5477 5477
 		} else {
5478
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5478
+			$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5479 5479
 					FROM spotter_output
5480 5480
 					WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date
5481 5481
 					GROUP BY spotter_output.departure_airport_icao
@@ -5488,7 +5488,7 @@  discard block
 block discarded – undo
5488 5488
 		$airport_array = array();
5489 5489
 		$temp_array = array();
5490 5490
         
5491
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5491
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5492 5492
 		{
5493 5493
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5494 5494
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5512,7 +5512,7 @@  discard block
 block discarded – undo
5512 5512
 	public function countAllDepartureAirportCountriesByDate($date)
5513 5513
 	{
5514 5514
 		global $globalTimezone, $globalDBdriver;
5515
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
5515
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
5516 5516
 		if ($globalTimezone != '') {
5517 5517
 			date_default_timezone_set($globalTimezone);
5518 5518
 			$datetime = new DateTime($date);
@@ -5520,13 +5520,13 @@  discard block
 block discarded – undo
5520 5520
 		} else $offset = '+00:00';
5521 5521
 
5522 5522
 		if ($globalDBdriver == 'mysql') {
5523
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5523
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5524 5524
 					FROM spotter_output 
5525 5525
 					WHERE spotter_output.departure_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
5526 5526
 					GROUP BY spotter_output.departure_airport_country
5527 5527
 					ORDER BY airport_departure_country_count DESC";
5528 5528
 		} else {
5529
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5529
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5530 5530
 					FROM spotter_output 
5531 5531
 					WHERE spotter_output.departure_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
5532 5532
 					GROUP BY spotter_output.departure_airport_country
@@ -5539,7 +5539,7 @@  discard block
 block discarded – undo
5539 5539
 		$airport_array = array();
5540 5540
 		$temp_array = array();
5541 5541
         
5542
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5542
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5543 5543
 		{
5544 5544
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5545 5545
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5559,9 +5559,9 @@  discard block
 block discarded – undo
5559 5559
 	*/
5560 5560
 	public function countAllDepartureAirportsByIdent($ident)
5561 5561
 	{
5562
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5562
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5563 5563
 
5564
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5564
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5565 5565
 		    FROM spotter_output
5566 5566
                     WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.ident = :ident 
5567 5567
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
@@ -5574,7 +5574,7 @@  discard block
 block discarded – undo
5574 5574
 		$airport_array = array();
5575 5575
 		$temp_array = array();
5576 5576
         
5577
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5577
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5578 5578
 		{
5579 5579
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5580 5580
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5598,9 +5598,9 @@  discard block
 block discarded – undo
5598 5598
 	*/
5599 5599
 	public function countAllDepartureAirportCountriesByIdent($ident)
5600 5600
 	{
5601
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5601
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5602 5602
 					
5603
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5603
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5604 5604
 								FROM spotter_output 
5605 5605
                     WHERE spotter_output.departure_airport_country <> '' AND spotter_output.ident = :ident 
5606 5606
                     GROUP BY spotter_output.departure_airport_country
@@ -5613,7 +5613,7 @@  discard block
 block discarded – undo
5613 5613
 		$airport_array = array();
5614 5614
 		$temp_array = array();
5615 5615
         
5616
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5616
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5617 5617
 		{
5618 5618
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5619 5619
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5634,9 +5634,9 @@  discard block
 block discarded – undo
5634 5634
 	*/
5635 5635
 	public function countAllDepartureAirportsByCountry($country)
5636 5636
 	{
5637
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
5637
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
5638 5638
 
5639
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5639
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5640 5640
 								FROM spotter_output
5641 5641
                     WHERE ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
5642 5642
                     GROUP BY spotter_output.departure_airport_icao
@@ -5649,7 +5649,7 @@  discard block
 block discarded – undo
5649 5649
 		$airport_array = array();
5650 5650
 		$temp_array = array();
5651 5651
         
5652
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5652
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5653 5653
 		{
5654 5654
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5655 5655
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5672,9 +5672,9 @@  discard block
 block discarded – undo
5672 5672
 	*/
5673 5673
 	public function countAllDepartureAirportCountriesByCountry($country)
5674 5674
 	{
5675
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
5675
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
5676 5676
 					
5677
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5677
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5678 5678
 								FROM spotter_output 
5679 5679
                     WHERE spotter_output.departure_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
5680 5680
                     GROUP BY spotter_output.departure_airport_country
@@ -5687,7 +5687,7 @@  discard block
 block discarded – undo
5687 5687
 		$airport_array = array();
5688 5688
 		$temp_array = array();
5689 5689
         
5690
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5690
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5691 5691
 		{
5692 5692
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5693 5693
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5708,7 +5708,7 @@  discard block
 block discarded – undo
5708 5708
 	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false)
5709 5709
 	{
5710 5710
 		global $globalDBdriver;
5711
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
5711
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
5712 5712
 								FROM spotter_output 
5713 5713
                     WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' ";
5714 5714
                 if ($olderthanmonths > 0) {
@@ -5744,7 +5744,7 @@  discard block
 block discarded – undo
5744 5744
 		$airport_array = array();
5745 5745
 		$temp_array = array();
5746 5746
         
5747
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5747
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5748 5748
 		{
5749 5749
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
5750 5750
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -5767,10 +5767,10 @@  discard block
 block discarded – undo
5767 5767
 	* @return Array the airport list
5768 5768
 	*
5769 5769
 	*/
5770
-	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false)
5770
+	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false)
5771 5771
 	{
5772 5772
 		global $globalDBdriver;
5773
-		$query  = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
5773
+		$query = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
5774 5774
 			FROM spotter_output, airport 
5775 5775
                     WHERE spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao ";
5776 5776
                 if ($olderthanmonths > 0) {
@@ -5806,7 +5806,7 @@  discard block
 block discarded – undo
5806 5806
 		$airport_array = array();
5807 5807
 		$temp_array = array();
5808 5808
         
5809
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5809
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5810 5810
 		{
5811 5811
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
5812 5812
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -5833,9 +5833,9 @@  discard block
 block discarded – undo
5833 5833
 	*/
5834 5834
 	public function countAllArrivalAirportsByAirline($airline_icao)
5835 5835
 	{
5836
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5836
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5837 5837
 
5838
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
5838
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
5839 5839
 								FROM spotter_output 
5840 5840
                     WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao 
5841 5841
                     GROUP BY spotter_output.arrival_airport_icao
@@ -5848,7 +5848,7 @@  discard block
 block discarded – undo
5848 5848
 		$airport_array = array();
5849 5849
 		$temp_array = array();
5850 5850
         
5851
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5851
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5852 5852
 		{
5853 5853
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
5854 5854
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -5871,9 +5871,9 @@  discard block
 block discarded – undo
5871 5871
 	*/
5872 5872
 	public function countAllArrivalAirportCountriesByAirline($airline_icao)
5873 5873
 	{
5874
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5874
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5875 5875
 					
5876
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
5876
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
5877 5877
 								FROM spotter_output 
5878 5878
                     WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
5879 5879
                     GROUP BY spotter_output.arrival_airport_country
@@ -5886,7 +5886,7 @@  discard block
 block discarded – undo
5886 5886
 		$airport_array = array();
5887 5887
 		$temp_array = array();
5888 5888
         
5889
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5889
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5890 5890
 		{
5891 5891
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
5892 5892
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -5906,9 +5906,9 @@  discard block
 block discarded – undo
5906 5906
 	*/
5907 5907
 	public function countAllArrivalAirportsByAircraft($aircraft_icao)
5908 5908
 	{
5909
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
5909
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
5910 5910
 
5911
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
5911
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
5912 5912
 								FROM spotter_output 
5913 5913
                     WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao 
5914 5914
                     GROUP BY spotter_output.arrival_airport_icao
@@ -5921,7 +5921,7 @@  discard block
 block discarded – undo
5921 5921
 		$airport_array = array();
5922 5922
 		$temp_array = array();
5923 5923
         
5924
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5924
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5925 5925
 		{
5926 5926
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
5927 5927
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -5945,9 +5945,9 @@  discard block
 block discarded – undo
5945 5945
 	*/
5946 5946
 	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao)
5947 5947
 	{
5948
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
5948
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
5949 5949
 					
5950
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
5950
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
5951 5951
 								FROM spotter_output 
5952 5952
                     WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
5953 5953
                     GROUP BY spotter_output.arrival_airport_country
@@ -5960,7 +5960,7 @@  discard block
 block discarded – undo
5960 5960
 		$airport_array = array();
5961 5961
 		$temp_array = array();
5962 5962
         
5963
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5963
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5964 5964
 		{
5965 5965
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
5966 5966
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -5980,9 +5980,9 @@  discard block
 block discarded – undo
5980 5980
 	*/
5981 5981
 	public function countAllArrivalAirportsByRegistration($registration)
5982 5982
 	{
5983
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
5983
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
5984 5984
 
5985
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
5985
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
5986 5986
 								FROM spotter_output 
5987 5987
                     WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.registration = :registration 
5988 5988
                     GROUP BY spotter_output.arrival_airport_icao
@@ -5995,7 +5995,7 @@  discard block
 block discarded – undo
5995 5995
 		$airport_array = array();
5996 5996
 		$temp_array = array();
5997 5997
         
5998
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5998
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5999 5999
 		{
6000 6000
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6001 6001
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6018,9 +6018,9 @@  discard block
 block discarded – undo
6018 6018
 	*/
6019 6019
 	public function countAllArrivalAirportCountriesByRegistration($registration)
6020 6020
 	{
6021
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
6021
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
6022 6022
 					
6023
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6023
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6024 6024
 								FROM spotter_output 
6025 6025
                     WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.registration = :registration 
6026 6026
                     GROUP BY spotter_output.arrival_airport_country
@@ -6033,7 +6033,7 @@  discard block
 block discarded – undo
6033 6033
 		$airport_array = array();
6034 6034
 		$temp_array = array();
6035 6035
         
6036
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6036
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6037 6037
 		{
6038 6038
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6039 6039
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6054,9 +6054,9 @@  discard block
 block discarded – undo
6054 6054
 	*/
6055 6055
 	public function countAllArrivalAirportsByAirport($airport_icao)
6056 6056
 	{
6057
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
6057
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
6058 6058
 
6059
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6059
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6060 6060
 								FROM spotter_output 
6061 6061
                     WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.departure_airport_icao = :airport_icao 
6062 6062
                     GROUP BY spotter_output.arrival_airport_icao
@@ -6069,7 +6069,7 @@  discard block
 block discarded – undo
6069 6069
 		$airport_array = array();
6070 6070
 		$temp_array = array();
6071 6071
         
6072
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6072
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6073 6073
 		{
6074 6074
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6075 6075
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6092,9 +6092,9 @@  discard block
 block discarded – undo
6092 6092
 	*/
6093 6093
 	public function countAllArrivalAirportCountriesByAirport($airport_icao)
6094 6094
 	{
6095
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
6095
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
6096 6096
 					
6097
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6097
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6098 6098
 								FROM spotter_output 
6099 6099
                     WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.departure_airport_icao = :airport_icao 
6100 6100
                     GROUP BY spotter_output.arrival_airport_country
@@ -6107,7 +6107,7 @@  discard block
 block discarded – undo
6107 6107
 		$airport_array = array();
6108 6108
 		$temp_array = array();
6109 6109
         
6110
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6110
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6111 6111
 		{
6112 6112
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6113 6113
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6127,9 +6127,9 @@  discard block
 block discarded – undo
6127 6127
 	*/
6128 6128
 	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer)
6129 6129
 	{
6130
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
6130
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
6131 6131
 
6132
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6132
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6133 6133
 								FROM spotter_output 
6134 6134
                     WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
6135 6135
                     GROUP BY spotter_output.arrival_airport_icao
@@ -6142,7 +6142,7 @@  discard block
 block discarded – undo
6142 6142
 		$airport_array = array();
6143 6143
 		$temp_array = array();
6144 6144
         
6145
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6145
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6146 6146
 		{
6147 6147
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6148 6148
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6166,9 +6166,9 @@  discard block
 block discarded – undo
6166 6166
 	*/
6167 6167
 	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer)
6168 6168
 	{
6169
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
6169
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
6170 6170
 					
6171
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6171
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6172 6172
 								FROM spotter_output 
6173 6173
                     WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
6174 6174
                     GROUP BY spotter_output.arrival_airport_country
@@ -6181,7 +6181,7 @@  discard block
 block discarded – undo
6181 6181
 		$airport_array = array();
6182 6182
 		$temp_array = array();
6183 6183
         
6184
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6184
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6185 6185
 		{
6186 6186
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6187 6187
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6203,7 +6203,7 @@  discard block
 block discarded – undo
6203 6203
 	public function countAllArrivalAirportsByDate($date)
6204 6204
 	{
6205 6205
 		global $globalTimezone, $globalDBdriver;
6206
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
6206
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
6207 6207
 		if ($globalTimezone != '') {
6208 6208
 			date_default_timezone_set($globalTimezone);
6209 6209
 			$datetime = new DateTime($date);
@@ -6211,13 +6211,13 @@  discard block
 block discarded – undo
6211 6211
 		} else $offset = '+00:00';
6212 6212
 
6213 6213
 		if ($globalDBdriver == 'mysql') {
6214
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6214
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6215 6215
 					FROM spotter_output 
6216 6216
 					WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  
6217 6217
 					GROUP BY spotter_output.arrival_airport_icao
6218 6218
 					ORDER BY airport_arrival_icao_count DESC";
6219 6219
 		} else {
6220
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6220
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6221 6221
 					FROM spotter_output 
6222 6222
 					WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  
6223 6223
 					GROUP BY spotter_output.arrival_airport_icao
@@ -6230,7 +6230,7 @@  discard block
 block discarded – undo
6230 6230
 		$airport_array = array();
6231 6231
 		$temp_array = array();
6232 6232
         
6233
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6233
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6234 6234
 		{
6235 6235
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6236 6236
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6254,7 +6254,7 @@  discard block
 block discarded – undo
6254 6254
 	public function countAllArrivalAirportCountriesByDate($date)
6255 6255
 	{
6256 6256
 		global $globalTimezone, $globalDBdriver;
6257
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
6257
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
6258 6258
 		if ($globalTimezone != '') {
6259 6259
 			date_default_timezone_set($globalTimezone);
6260 6260
 			$datetime = new DateTime($date);
@@ -6262,13 +6262,13 @@  discard block
 block discarded – undo
6262 6262
 		} else $offset = '+00:00';
6263 6263
 
6264 6264
 		if ($globalDBdriver == 'mysql') {
6265
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6265
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6266 6266
 					FROM spotter_output 
6267 6267
 					WHERE spotter_output.arrival_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
6268 6268
 					GROUP BY spotter_output.arrival_airport_country
6269 6269
 					ORDER BY airport_arrival_country_count DESC";
6270 6270
 		} else {
6271
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6271
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6272 6272
 					FROM spotter_output 
6273 6273
 					WHERE spotter_output.arrival_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
6274 6274
 					GROUP BY spotter_output.arrival_airport_country
@@ -6281,7 +6281,7 @@  discard block
 block discarded – undo
6281 6281
 		$airport_array = array();
6282 6282
 		$temp_array = array();
6283 6283
         
6284
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6284
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6285 6285
 		{
6286 6286
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6287 6287
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6301,9 +6301,9 @@  discard block
 block discarded – undo
6301 6301
 	*/
6302 6302
 	public function countAllArrivalAirportsByIdent($ident)
6303 6303
 	{
6304
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
6304
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
6305 6305
 
6306
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6306
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6307 6307
 		    FROM spotter_output 
6308 6308
                     WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.ident = :ident  
6309 6309
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
@@ -6316,7 +6316,7 @@  discard block
 block discarded – undo
6316 6316
 		$airport_array = array();
6317 6317
 		$temp_array = array();
6318 6318
         
6319
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6319
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6320 6320
 		{
6321 6321
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6322 6322
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6339,9 +6339,9 @@  discard block
 block discarded – undo
6339 6339
 	*/
6340 6340
 	public function countAllArrivalAirportCountriesByIdent($ident)
6341 6341
 	{
6342
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
6342
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
6343 6343
 					
6344
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6344
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6345 6345
 								FROM spotter_output 
6346 6346
                     WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.ident = :ident 
6347 6347
                     GROUP BY spotter_output.arrival_airport_country
@@ -6354,7 +6354,7 @@  discard block
 block discarded – undo
6354 6354
 		$airport_array = array();
6355 6355
 		$temp_array = array();
6356 6356
         
6357
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6357
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6358 6358
 		{
6359 6359
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6360 6360
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6375,9 +6375,9 @@  discard block
 block discarded – undo
6375 6375
 	*/
6376 6376
 	public function countAllArrivalAirportsByCountry($country)
6377 6377
 	{
6378
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6378
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6379 6379
 
6380
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6380
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6381 6381
 								FROM spotter_output 
6382 6382
                     WHERE ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
6383 6383
                     GROUP BY spotter_output.arrival_airport_icao
@@ -6390,7 +6390,7 @@  discard block
 block discarded – undo
6390 6390
 		$airport_array = array();
6391 6391
 		$temp_array = array();
6392 6392
         
6393
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6393
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6394 6394
 		{
6395 6395
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6396 6396
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6413,9 +6413,9 @@  discard block
 block discarded – undo
6413 6413
 	*/
6414 6414
 	public function countAllArrivalAirportCountriesByCountry($country)
6415 6415
 	{
6416
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6416
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6417 6417
 					
6418
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6418
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6419 6419
 								FROM spotter_output 
6420 6420
                     WHERE spotter_output.arrival_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
6421 6421
                     GROUP BY spotter_output.arrival_airport_country
@@ -6428,7 +6428,7 @@  discard block
 block discarded – undo
6428 6428
 		$airport_array = array();
6429 6429
 		$temp_array = array();
6430 6430
         
6431
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6431
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6432 6432
 		{
6433 6433
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6434 6434
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6449,7 +6449,7 @@  discard block
 block discarded – undo
6449 6449
 	*/
6450 6450
 	public function countAllDepartureCountries()
6451 6451
 	{
6452
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6452
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6453 6453
 								FROM spotter_output 
6454 6454
                     WHERE spotter_output.departure_airport_country <> '' AND spotter_output.departure_airport_icao <> 'NA' 
6455 6455
                     GROUP BY spotter_output.departure_airport_country
@@ -6463,7 +6463,7 @@  discard block
 block discarded – undo
6463 6463
 		$airport_array = array();
6464 6464
 		$temp_array = array();
6465 6465
         
6466
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6466
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6467 6467
 		{
6468 6468
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
6469 6469
 			$temp_array['airport_departure_country'] = $row['departure_airport_country'];
@@ -6483,7 +6483,7 @@  discard block
 block discarded – undo
6483 6483
 	*/
6484 6484
 	public function countAllArrivalCountries($limit = true)
6485 6485
 	{
6486
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6486
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6487 6487
 								FROM spotter_output 
6488 6488
                     WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA' 
6489 6489
                     GROUP BY spotter_output.arrival_airport_country
@@ -6497,7 +6497,7 @@  discard block
 block discarded – undo
6497 6497
 		$airport_array = array();
6498 6498
 		$temp_array = array();
6499 6499
         
6500
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6500
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6501 6501
 		{
6502 6502
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
6503 6503
 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country'];
@@ -6521,7 +6521,7 @@  discard block
 block discarded – undo
6521 6521
 	public function countAllRoutes()
6522 6522
 	{
6523 6523
 		
6524
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6524
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6525 6525
 		    FROM spotter_output
6526 6526
                     WHERE spotter_output.ident <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> 'NA'
6527 6527
                     GROUP BY route,spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
@@ -6535,7 +6535,7 @@  discard block
 block discarded – undo
6535 6535
 		$routes_array = array();
6536 6536
 		$temp_array = array();
6537 6537
         
6538
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6538
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6539 6539
 		{
6540 6540
 			$temp_array['route_count'] = $row['route_count'];
6541 6541
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6564,9 +6564,9 @@  discard block
 block discarded – undo
6564 6564
 	*/
6565 6565
 	public function countAllRoutesByAircraft($aircraft_icao)
6566 6566
 	{
6567
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
6567
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
6568 6568
 		
6569
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6569
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6570 6570
 								FROM spotter_output
6571 6571
                     WHERE spotter_output.ident <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
6572 6572
                     GROUP BY route
@@ -6579,7 +6579,7 @@  discard block
 block discarded – undo
6579 6579
 		$routes_array = array();
6580 6580
 		$temp_array = array();
6581 6581
         
6582
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6582
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6583 6583
 		{
6584 6584
 			$temp_array['route_count'] = $row['route_count'];
6585 6585
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6608,7 +6608,7 @@  discard block
 block discarded – undo
6608 6608
 	{
6609 6609
 		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
6610 6610
 		
6611
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6611
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6612 6612
 								FROM spotter_output
6613 6613
                     WHERE spotter_output.ident <> '' AND spotter_output.registration = :registration 
6614 6614
                     GROUP BY route
@@ -6621,7 +6621,7 @@  discard block
 block discarded – undo
6621 6621
 		$routes_array = array();
6622 6622
 		$temp_array = array();
6623 6623
         
6624
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6624
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6625 6625
 		{
6626 6626
 			$temp_array['route_count'] = $row['route_count'];
6627 6627
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6649,9 +6649,9 @@  discard block
 block discarded – undo
6649 6649
 	*/
6650 6650
 	public function countAllRoutesByAirline($airline_icao)
6651 6651
 	{
6652
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
6652
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
6653 6653
 		
6654
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6654
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6655 6655
 								FROM spotter_output
6656 6656
                     WHERE spotter_output.ident <> '' AND spotter_output.airline_icao = :airline_icao 
6657 6657
                     GROUP BY route
@@ -6664,7 +6664,7 @@  discard block
 block discarded – undo
6664 6664
 		$routes_array = array();
6665 6665
 		$temp_array = array();
6666 6666
         
6667
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6667
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6668 6668
 		{
6669 6669
 			$temp_array['route_count'] = $row['route_count'];
6670 6670
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6692,9 +6692,9 @@  discard block
 block discarded – undo
6692 6692
 	*/
6693 6693
 	public function countAllRoutesByAirport($airport_icao)
6694 6694
 	{
6695
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
6695
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
6696 6696
 		
6697
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6697
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6698 6698
 								FROM spotter_output
6699 6699
                     WHERE spotter_output.ident <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
6700 6700
                     GROUP BY route
@@ -6707,7 +6707,7 @@  discard block
 block discarded – undo
6707 6707
 		$routes_array = array();
6708 6708
 		$temp_array = array();
6709 6709
         
6710
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6710
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6711 6711
 		{
6712 6712
 			$temp_array['route_count'] = $row['route_count'];
6713 6713
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6735,9 +6735,9 @@  discard block
 block discarded – undo
6735 6735
 	*/
6736 6736
 	public function countAllRoutesByCountry($country)
6737 6737
 	{
6738
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6738
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6739 6739
 		
6740
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6740
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6741 6741
 								FROM spotter_output
6742 6742
                     WHERE spotter_output.ident <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
6743 6743
                     GROUP BY route
@@ -6750,7 +6750,7 @@  discard block
 block discarded – undo
6750 6750
 		$routes_array = array();
6751 6751
 		$temp_array = array();
6752 6752
         
6753
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6753
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6754 6754
 		{
6755 6755
 			$temp_array['route_count'] = $row['route_count'];
6756 6756
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6778,7 +6778,7 @@  discard block
 block discarded – undo
6778 6778
 	public function countAllRoutesByDate($date)
6779 6779
 	{
6780 6780
 		global $globalTimezone, $globalDBdriver;
6781
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
6781
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
6782 6782
 		if ($globalTimezone != '') {
6783 6783
 			date_default_timezone_set($globalTimezone);
6784 6784
 			$datetime = new DateTime($date);
@@ -6786,13 +6786,13 @@  discard block
 block discarded – undo
6786 6786
 		} else $offset = '+00:00';
6787 6787
 		
6788 6788
 		if ($globalDBdriver == 'mysql') {
6789
-			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6789
+			$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6790 6790
 					FROM spotter_output
6791 6791
 					WHERE spotter_output.ident <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  
6792 6792
 					GROUP BY route
6793 6793
 					ORDER BY route_count DESC";
6794 6794
 		} else {
6795
-			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6795
+			$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6796 6796
 					FROM spotter_output
6797 6797
 					WHERE spotter_output.ident <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  
6798 6798
 					GROUP BY route
@@ -6805,7 +6805,7 @@  discard block
 block discarded – undo
6805 6805
 		$routes_array = array();
6806 6806
 		$temp_array = array();
6807 6807
         
6808
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6808
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6809 6809
 		{
6810 6810
 			$temp_array['route_count'] = $row['route_count'];
6811 6811
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6832,9 +6832,9 @@  discard block
 block discarded – undo
6832 6832
 	*/
6833 6833
 	public function countAllRoutesByIdent($ident)
6834 6834
 	{
6835
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
6835
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
6836 6836
 		
6837
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6837
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6838 6838
 		    FROM spotter_output
6839 6839
                     WHERE spotter_output.ident <> '' AND spotter_output.ident = :ident   
6840 6840
                     GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
@@ -6847,7 +6847,7 @@  discard block
 block discarded – undo
6847 6847
 		$routes_array = array();
6848 6848
 		$temp_array = array();
6849 6849
         
6850
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6850
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6851 6851
 		{
6852 6852
 			$temp_array['route_count'] = $row['route_count'];
6853 6853
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6874,9 +6874,9 @@  discard block
 block discarded – undo
6874 6874
 	*/
6875 6875
 	public function countAllRoutesByManufacturer($aircraft_manufacturer)
6876 6876
 	{
6877
-		$aircraft_manufacturer = filter_var($aircraft_manufactuer,FILTER_SANITIZE_STRING);
6877
+		$aircraft_manufacturer = filter_var($aircraft_manufactuer, FILTER_SANITIZE_STRING);
6878 6878
 		
6879
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6879
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6880 6880
 								FROM spotter_output
6881 6881
                     WHERE spotter_output.ident <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
6882 6882
                     GROUP BY route
@@ -6889,7 +6889,7 @@  discard block
 block discarded – undo
6889 6889
 		$routes_array = array();
6890 6890
 		$temp_array = array();
6891 6891
         
6892
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6892
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6893 6893
 		{
6894 6894
 			$temp_array['route_count'] = $row['route_count'];
6895 6895
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6917,7 +6917,7 @@  discard block
 block discarded – undo
6917 6917
 	*/
6918 6918
 	public function countAllRoutesWithWaypoints()
6919 6919
 	{
6920
-		$query  = "SELECT DISTINCT spotter_output.waypoints AS route, count(spotter_output.waypoints) AS route_count, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6920
+		$query = "SELECT DISTINCT spotter_output.waypoints AS route, count(spotter_output.waypoints) AS route_count, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
6921 6921
 		    FROM spotter_output
6922 6922
                     WHERE spotter_output.ident <> '' AND spotter_output.waypoints <> '' 
6923 6923
                     GROUP BY route, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
@@ -6931,7 +6931,7 @@  discard block
 block discarded – undo
6931 6931
 		$routes_array = array();
6932 6932
 		$temp_array = array();
6933 6933
         
6934
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6934
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6935 6935
 		{
6936 6936
 			$temp_array['spotter_id'] = $row['spotter_id'];
6937 6937
 			$temp_array['route_count'] = $row['route_count'];
@@ -6962,7 +6962,7 @@  discard block
 block discarded – undo
6962 6962
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '')
6963 6963
 	{
6964 6964
 		global $globalDBdriver;
6965
-		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
6965
+		$query = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
6966 6966
                     FROM spotter_output
6967 6967
                     WHERE spotter_output.ident <> ''  ";
6968 6968
 		 if ($olderthanmonths > 0) {
@@ -6982,7 +6982,7 @@  discard block
 block discarded – undo
6982 6982
 		$callsign_array = array();
6983 6983
 		$temp_array = array();
6984 6984
         
6985
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6985
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6986 6986
 		{
6987 6987
 			$temp_array['callsign_icao'] = $row['ident'];
6988 6988
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -7014,13 +7014,13 @@  discard block
 block discarded – undo
7014 7014
 		} else $offset = '+00:00';
7015 7015
 
7016 7016
 		if ($globalDBdriver == 'mysql') {
7017
-			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7017
+			$query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7018 7018
 								FROM spotter_output 
7019 7019
 								GROUP BY date_name 
7020 7020
 								ORDER BY date_count DESC
7021 7021
 								LIMIT 10 OFFSET 0";
7022 7022
 		} else {
7023
-			$query  = "SELECT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7023
+			$query = "SELECT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7024 7024
 								FROM spotter_output 
7025 7025
 								GROUP BY date_name 
7026 7026
 								ORDER BY date_count DESC
@@ -7034,7 +7034,7 @@  discard block
 block discarded – undo
7034 7034
 		$date_array = array();
7035 7035
 		$temp_array = array();
7036 7036
         
7037
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7037
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7038 7038
 		{
7039 7039
 			$temp_array['date_name'] = $row['date_name'];
7040 7040
 			$temp_array['date_count'] = $row['date_count'];
@@ -7063,14 +7063,14 @@  discard block
 block discarded – undo
7063 7063
 		} else $offset = '+00:00';
7064 7064
 		
7065 7065
 		if ($globalDBdriver == 'mysql') {
7066
-			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7066
+			$query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7067 7067
 								FROM spotter_output 
7068 7068
 								WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)
7069 7069
 								GROUP BY date_name 
7070 7070
 								ORDER BY spotter_output.date ASC";
7071 7071
 			$query_data = array(':offset' => $offset);
7072 7072
 		} elseif ($globalDBdriver == 'pgsql') {
7073
-			$query  = "SELECT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7073
+			$query = "SELECT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7074 7074
 								FROM spotter_output 
7075 7075
 								WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '7 DAYS'
7076 7076
 								GROUP BY date_name 
@@ -7084,7 +7084,7 @@  discard block
 block discarded – undo
7084 7084
 		$date_array = array();
7085 7085
 		$temp_array = array();
7086 7086
         
7087
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7087
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7088 7088
 		{
7089 7089
 			$temp_array['date_name'] = $row['date_name'];
7090 7090
 			$temp_array['date_count'] = $row['date_count'];
@@ -7111,14 +7111,14 @@  discard block
 block discarded – undo
7111 7111
 		} else $offset = '+00:00';
7112 7112
 		
7113 7113
 		if ($globalDBdriver == 'mysql') {
7114
-			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7114
+			$query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7115 7115
 								FROM spotter_output 
7116 7116
 								WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)
7117 7117
 								GROUP BY date_name 
7118 7118
 								ORDER BY spotter_output.date ASC";
7119 7119
 			$query_data = array(':offset' => $offset);
7120 7120
 		} elseif ($globalDBdriver == 'pgsql') {
7121
-			$query  = "SELECT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7121
+			$query = "SELECT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7122 7122
 								FROM spotter_output 
7123 7123
 								WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 MONTHS'
7124 7124
 								GROUP BY date_name 
@@ -7132,7 +7132,7 @@  discard block
 block discarded – undo
7132 7132
 		$date_array = array();
7133 7133
 		$temp_array = array();
7134 7134
         
7135
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7135
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7136 7136
 		{
7137 7137
 			$temp_array['date_name'] = $row['date_name'];
7138 7138
 			$temp_array['date_count'] = $row['date_count'];
@@ -7159,12 +7159,12 @@  discard block
 block discarded – undo
7159 7159
 		} else $offset = '+00:00';
7160 7160
 
7161 7161
 		if ($globalDBdriver == 'mysql') {
7162
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
7162
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
7163 7163
 								FROM spotter_output 
7164 7164
 								GROUP BY year_name, month_name 
7165 7165
 								ORDER BY date_count DESC";
7166 7166
 		} else {
7167
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
7167
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
7168 7168
 								FROM spotter_output 
7169 7169
 								GROUP BY year_name, month_name 
7170 7170
 								ORDER BY date_count DESC";
@@ -7177,7 +7177,7 @@  discard block
 block discarded – undo
7177 7177
 		$date_array = array();
7178 7178
 		$temp_array = array();
7179 7179
         
7180
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7180
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7181 7181
 		{
7182 7182
 			$temp_array['month_name'] = $row['month_name'];
7183 7183
 			$temp_array['year_name'] = $row['year_name'];
@@ -7205,13 +7205,13 @@  discard block
 block discarded – undo
7205 7205
 		} else $offset = '+00:00';
7206 7206
 
7207 7207
 		if ($globalDBdriver == 'mysql') {
7208
-			$query  = "SELECT YEAR(CONVERT_TZ(s.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(s.date,'+00:00', :offset)) AS month_name, count(*) as date_count
7208
+			$query = "SELECT YEAR(CONVERT_TZ(s.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(s.date,'+00:00', :offset)) AS month_name, count(*) as date_count
7209 7209
 								FROM spotter_output s
7210 7210
 								WHERE s.airline_type = 'military'
7211 7211
 								GROUP BY year_name, month_name 
7212 7212
 								ORDER BY date_count DESC";
7213 7213
 		} else {
7214
-			$query  = "SELECT EXTRACT(YEAR FROM s.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM s.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
7214
+			$query = "SELECT EXTRACT(YEAR FROM s.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM s.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
7215 7215
 								FROM spotter_output s
7216 7216
 								WHERE s.airline_type = 'military'
7217 7217
 								GROUP BY year_name, month_name 
@@ -7224,7 +7224,7 @@  discard block
 block discarded – undo
7224 7224
 		$date_array = array();
7225 7225
 		$temp_array = array();
7226 7226
         
7227
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7227
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7228 7228
 		{
7229 7229
 			$temp_array['month_name'] = $row['month_name'];
7230 7230
 			$temp_array['year_name'] = $row['year_name'];
@@ -7252,13 +7252,13 @@  discard block
 block discarded – undo
7252 7252
 		} else $offset = '+00:00';
7253 7253
 
7254 7254
 		if ($globalDBdriver == 'mysql') {
7255
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
7255
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
7256 7256
 								FROM spotter_output 
7257 7257
 								WHERE owner_name <> ''
7258 7258
 								GROUP BY year_name, month_name
7259 7259
 								ORDER BY date_count DESC";
7260 7260
 		} else {
7261
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
7261
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
7262 7262
 								FROM spotter_output 
7263 7263
 								WHERE owner_name <> ''
7264 7264
 								GROUP BY year_name, month_name
@@ -7271,7 +7271,7 @@  discard block
 block discarded – undo
7271 7271
 		$date_array = array();
7272 7272
 		$temp_array = array();
7273 7273
         
7274
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7274
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7275 7275
 		{
7276 7276
 			$temp_array['month_name'] = $row['month_name'];
7277 7277
 			$temp_array['year_name'] = $row['year_name'];
@@ -7299,13 +7299,13 @@  discard block
 block discarded – undo
7299 7299
 		} else $offset = '+00:00';
7300 7300
 
7301 7301
 		if ($globalDBdriver == 'mysql') {
7302
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
7302
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
7303 7303
 								FROM spotter_output 
7304 7304
 								WHERE pilot_id <> '' AND pilot_id IS NOT NULL
7305 7305
 								GROUP BY year_name, month_name
7306 7306
 								ORDER BY date_count DESC";
7307 7307
 		} else {
7308
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
7308
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
7309 7309
 								FROM spotter_output 
7310 7310
 								WHERE pilot_id <> '' AND pilot_id IS NOT NULL
7311 7311
 								GROUP BY year_name, month_name
@@ -7318,7 +7318,7 @@  discard block
 block discarded – undo
7318 7318
 		$date_array = array();
7319 7319
 		$temp_array = array();
7320 7320
         
7321
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7321
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7322 7322
 		{
7323 7323
 			$temp_array['month_name'] = $row['month_name'];
7324 7324
 			$temp_array['year_name'] = $row['year_name'];
@@ -7347,13 +7347,13 @@  discard block
 block discarded – undo
7347 7347
 		} else $offset = '+00:00';
7348 7348
 
7349 7349
 		if ($globalDBdriver == 'mysql') {
7350
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
7350
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
7351 7351
 								FROM spotter_output 
7352 7352
 								WHERE airline_icao <> '' 
7353 7353
 								GROUP BY year_name, month_name
7354 7354
 								ORDER BY date_count DESC";
7355 7355
 		} else {
7356
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct airline_icao) as date_count
7356
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct airline_icao) as date_count
7357 7357
 								FROM spotter_output 
7358 7358
 								WHERE airline_icao <> '' 
7359 7359
 								GROUP BY year_name, month_name
@@ -7366,7 +7366,7 @@  discard block
 block discarded – undo
7366 7366
 		$date_array = array();
7367 7367
 		$temp_array = array();
7368 7368
         
7369
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7369
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7370 7370
 		{
7371 7371
 			$temp_array['month_name'] = $row['month_name'];
7372 7372
 			$temp_array['year_name'] = $row['year_name'];
@@ -7394,13 +7394,13 @@  discard block
 block discarded – undo
7394 7394
 		} else $offset = '+00:00';
7395 7395
 
7396 7396
 		if ($globalDBdriver == 'mysql') {
7397
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
7397
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
7398 7398
 								FROM spotter_output 
7399 7399
 								WHERE aircraft_icao <> '' 
7400 7400
 								GROUP BY year_name, month_name
7401 7401
 								ORDER BY date_count DESC";
7402 7402
 		} else {
7403
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
7403
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
7404 7404
 								FROM spotter_output 
7405 7405
 								WHERE aircraft_icao <> '' 
7406 7406
 								GROUP BY year_name, month_name
@@ -7413,7 +7413,7 @@  discard block
 block discarded – undo
7413 7413
 		$date_array = array();
7414 7414
 		$temp_array = array();
7415 7415
         
7416
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7416
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7417 7417
 		{
7418 7418
 			$temp_array['month_name'] = $row['month_name'];
7419 7419
 			$temp_array['year_name'] = $row['year_name'];
@@ -7442,13 +7442,13 @@  discard block
 block discarded – undo
7442 7442
 		} else $offset = '+00:00';
7443 7443
 
7444 7444
 		if ($globalDBdriver == 'mysql') {
7445
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
7445
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
7446 7446
 								FROM spotter_output 
7447 7447
 								WHERE real_arrival_airport_icao <> '' 
7448 7448
 								GROUP BY year_name, month_name
7449 7449
 								ORDER BY date_count DESC";
7450 7450
 		} else {
7451
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
7451
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
7452 7452
 								FROM spotter_output 
7453 7453
 								WHERE real_arrival_airport_icao <> '' 
7454 7454
 								GROUP BY year_name, month_name
@@ -7461,7 +7461,7 @@  discard block
 block discarded – undo
7461 7461
 		$date_array = array();
7462 7462
 		$temp_array = array();
7463 7463
         
7464
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7464
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7465 7465
 		{
7466 7466
 			$temp_array['month_name'] = $row['month_name'];
7467 7467
 			$temp_array['year_name'] = $row['year_name'];
@@ -7491,7 +7491,7 @@  discard block
 block discarded – undo
7491 7491
 		} else $offset = '+00:00';
7492 7492
 		
7493 7493
 		if ($globalDBdriver == 'mysql') {
7494
-			$query  = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
7494
+			$query = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
7495 7495
 								FROM spotter_output 
7496 7496
 								WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)
7497 7497
 								GROUP BY year_name, month_name
@@ -7500,7 +7500,7 @@  discard block
 block discarded – undo
7500 7500
 		} elseif ($globalDBdriver == 'pgsql') {
7501 7501
 			// FIXME : not working
7502 7502
 			//$query  = "SELECT spotter_output.date AT TIME ZONE INTERVAL :offset AS date_name, count(*) as date_count
7503
-			$query  = "SELECT EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count
7503
+			$query = "SELECT EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count
7504 7504
 								FROM spotter_output 
7505 7505
 								WHERE spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 YEARS'
7506 7506
 								GROUP BY year_name, month_name
@@ -7514,7 +7514,7 @@  discard block
 block discarded – undo
7514 7514
 		$date_array = array();
7515 7515
 		$temp_array = array();
7516 7516
         
7517
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7517
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7518 7518
 		{
7519 7519
 			$temp_array['year_name'] = $row['year_name'];
7520 7520
 			$temp_array['month_name'] = $row['month_name'];
@@ -7553,7 +7553,7 @@  discard block
 block discarded – undo
7553 7553
 		}
7554 7554
 		
7555 7555
 		if ($globalDBdriver == 'mysql') {
7556
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7556
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7557 7557
 								FROM spotter_output 
7558 7558
 								GROUP BY hour_name 
7559 7559
 								".$orderby_sql;
@@ -7566,7 +7566,7 @@  discard block
 block discarded – undo
7566 7566
   */    
7567 7567
 		$query_data = array(':offset' => $offset);
7568 7568
 		} elseif ($globalDBdriver == 'pgsql') {
7569
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7569
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7570 7570
 								FROM spotter_output 
7571 7571
 								GROUP BY hour_name 
7572 7572
 								".$orderby_sql;
@@ -7579,7 +7579,7 @@  discard block
 block discarded – undo
7579 7579
 		$hour_array = array();
7580 7580
 		$temp_array = array();
7581 7581
         
7582
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7582
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7583 7583
 		{
7584 7584
 			$temp_array['hour_name'] = $row['hour_name'];
7585 7585
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -7606,16 +7606,16 @@  discard block
 block discarded – undo
7606 7606
 			$offset = $datetime->format('P');
7607 7607
 		} else $offset = '+00:00';
7608 7608
 
7609
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
7609
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
7610 7610
 
7611 7611
 		if ($globalDBdriver == 'mysql') {
7612
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7612
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7613 7613
 								FROM spotter_output 
7614 7614
 								WHERE spotter_output.airline_icao = :airline_icao
7615 7615
 								GROUP BY hour_name 
7616 7616
 								ORDER BY hour_name ASC";
7617 7617
 		} else {
7618
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7618
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7619 7619
 								FROM spotter_output 
7620 7620
 								WHERE spotter_output.airline_icao = :airline_icao
7621 7621
 								GROUP BY hour_name 
@@ -7623,12 +7623,12 @@  discard block
 block discarded – undo
7623 7623
 		}
7624 7624
 		
7625 7625
 		$sth = $this->db->prepare($query);
7626
-		$sth->execute(array(':airline_icao' => $airline_icao,':offset' => $offset));
7626
+		$sth->execute(array(':airline_icao' => $airline_icao, ':offset' => $offset));
7627 7627
       
7628 7628
 		$hour_array = array();
7629 7629
 		$temp_array = array();
7630 7630
         
7631
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7631
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7632 7632
 		{
7633 7633
 			$temp_array['hour_name'] = $row['hour_name'];
7634 7634
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -7651,7 +7651,7 @@  discard block
 block discarded – undo
7651 7651
 	public function countAllHoursByAircraft($aircraft_icao)
7652 7652
 	{
7653 7653
 		global $globalTimezone, $globalDBdriver;
7654
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
7654
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
7655 7655
 		if ($globalTimezone != '') {
7656 7656
 			date_default_timezone_set($globalTimezone);
7657 7657
 			$datetime = new DateTime();
@@ -7659,13 +7659,13 @@  discard block
 block discarded – undo
7659 7659
 		} else $offset = '+00:00';
7660 7660
 
7661 7661
 		if ($globalDBdriver == 'mysql') {
7662
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7662
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7663 7663
 								FROM spotter_output 
7664 7664
 								WHERE spotter_output.aircraft_icao = :aircraft_icao
7665 7665
 								GROUP BY hour_name 
7666 7666
 								ORDER BY hour_name ASC";
7667 7667
 		} else {
7668
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7668
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7669 7669
 								FROM spotter_output 
7670 7670
 								WHERE spotter_output.aircraft_icao = :aircraft_icao
7671 7671
 								GROUP BY hour_name 
@@ -7673,12 +7673,12 @@  discard block
 block discarded – undo
7673 7673
 		}
7674 7674
 		
7675 7675
 		$sth = $this->db->prepare($query);
7676
-		$sth->execute(array(':aircraft_icao' => $aircraft_icao,':offset' => $offset));
7676
+		$sth->execute(array(':aircraft_icao' => $aircraft_icao, ':offset' => $offset));
7677 7677
       
7678 7678
 		$hour_array = array();
7679 7679
 		$temp_array = array();
7680 7680
         
7681
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7681
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7682 7682
 		{
7683 7683
 			$temp_array['hour_name'] = $row['hour_name'];
7684 7684
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -7699,7 +7699,7 @@  discard block
 block discarded – undo
7699 7699
 	public function countAllHoursByRegistration($registration)
7700 7700
 	{
7701 7701
 		global $globalTimezone, $globalDBdriver;
7702
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
7702
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
7703 7703
 		if ($globalTimezone != '') {
7704 7704
 			date_default_timezone_set($globalTimezone);
7705 7705
 			$datetime = new DateTime();
@@ -7707,13 +7707,13 @@  discard block
 block discarded – undo
7707 7707
 		} else $offset = '+00:00';
7708 7708
 
7709 7709
 		if ($globalDBdriver == 'mysql') {
7710
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7710
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7711 7711
 								FROM spotter_output 
7712 7712
 								WHERE spotter_output.registration = :registration
7713 7713
 								GROUP BY hour_name 
7714 7714
 								ORDER BY hour_name ASC";
7715 7715
 		} else {
7716
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7716
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7717 7717
 								FROM spotter_output 
7718 7718
 								WHERE spotter_output.registration = :registration
7719 7719
 								GROUP BY hour_name 
@@ -7721,12 +7721,12 @@  discard block
 block discarded – undo
7721 7721
 		}
7722 7722
 		
7723 7723
 		$sth = $this->db->prepare($query);
7724
-		$sth->execute(array(':registration' => $registration,':offset' => $offset));
7724
+		$sth->execute(array(':registration' => $registration, ':offset' => $offset));
7725 7725
       
7726 7726
 		$hour_array = array();
7727 7727
 		$temp_array = array();
7728 7728
         
7729
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7729
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7730 7730
 		{
7731 7731
 			$temp_array['hour_name'] = $row['hour_name'];
7732 7732
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -7747,7 +7747,7 @@  discard block
 block discarded – undo
7747 7747
 	public function countAllHoursByAirport($airport_icao)
7748 7748
 	{
7749 7749
 		global $globalTimezone, $globalDBdriver;
7750
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
7750
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
7751 7751
 		if ($globalTimezone != '') {
7752 7752
 			date_default_timezone_set($globalTimezone);
7753 7753
 			$datetime = new DateTime();
@@ -7755,13 +7755,13 @@  discard block
 block discarded – undo
7755 7755
 		} else $offset = '+00:00';
7756 7756
 
7757 7757
 		if ($globalDBdriver == 'mysql') {
7758
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7758
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7759 7759
 								FROM spotter_output 
7760 7760
 								WHERE (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
7761 7761
 								GROUP BY hour_name 
7762 7762
 								ORDER BY hour_name ASC";
7763 7763
 		} else {
7764
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7764
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7765 7765
 								FROM spotter_output 
7766 7766
 								WHERE (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
7767 7767
 								GROUP BY hour_name 
@@ -7769,12 +7769,12 @@  discard block
 block discarded – undo
7769 7769
 		}
7770 7770
 		
7771 7771
 		$sth = $this->db->prepare($query);
7772
-		$sth->execute(array(':airport_icao' => $airport_icao,':offset' => $offset));
7772
+		$sth->execute(array(':airport_icao' => $airport_icao, ':offset' => $offset));
7773 7773
       
7774 7774
 		$hour_array = array();
7775 7775
 		$temp_array = array();
7776 7776
         
7777
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7777
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7778 7778
 		{
7779 7779
 			$temp_array['hour_name'] = $row['hour_name'];
7780 7780
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -7796,7 +7796,7 @@  discard block
 block discarded – undo
7796 7796
 	public function countAllHoursByManufacturer($aircraft_manufacturer)
7797 7797
 	{
7798 7798
 		global $globalTimezone, $globalDBdriver;
7799
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
7799
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
7800 7800
 		if ($globalTimezone != '') {
7801 7801
 			date_default_timezone_set($globalTimezone);
7802 7802
 			$datetime = new DateTime();
@@ -7804,13 +7804,13 @@  discard block
 block discarded – undo
7804 7804
 		} else $offset = '+00:00';
7805 7805
 
7806 7806
 		if ($globalDBdriver == 'mysql') {
7807
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7807
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7808 7808
 								FROM spotter_output 
7809 7809
 								WHERE spotter_output.aircraft_manufacturer = :aircraft_manufacturer
7810 7810
 								GROUP BY hour_name 
7811 7811
 								ORDER BY hour_name ASC";
7812 7812
 		} else {
7813
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7813
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7814 7814
 								FROM spotter_output 
7815 7815
 								WHERE spotter_output.aircraft_manufacturer = :aircraft_manufacturer
7816 7816
 								GROUP BY hour_name 
@@ -7818,12 +7818,12 @@  discard block
 block discarded – undo
7818 7818
 		}
7819 7819
 		
7820 7820
 		$sth = $this->db->prepare($query);
7821
-		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer,':offset' => $offset));
7821
+		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer, ':offset' => $offset));
7822 7822
       
7823 7823
 		$hour_array = array();
7824 7824
 		$temp_array = array();
7825 7825
         
7826
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7826
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7827 7827
 		{
7828 7828
 			$temp_array['hour_name'] = $row['hour_name'];
7829 7829
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -7845,7 +7845,7 @@  discard block
 block discarded – undo
7845 7845
 	public function countAllHoursByDate($date)
7846 7846
 	{
7847 7847
 		global $globalTimezone, $globalDBdriver;
7848
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
7848
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
7849 7849
 		if ($globalTimezone != '') {
7850 7850
 			date_default_timezone_set($globalTimezone);
7851 7851
 			$datetime = new DateTime($date);
@@ -7853,13 +7853,13 @@  discard block
 block discarded – undo
7853 7853
 		} else $offset = '+00:00';
7854 7854
 
7855 7855
 		if ($globalDBdriver == 'mysql') {
7856
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7856
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7857 7857
 								FROM spotter_output 
7858 7858
 								WHERE DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
7859 7859
 								GROUP BY hour_name 
7860 7860
 								ORDER BY hour_name ASC";
7861 7861
 		} else {
7862
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7862
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7863 7863
 								FROM spotter_output 
7864 7864
 								WHERE to_char(spotter_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
7865 7865
 								GROUP BY hour_name 
@@ -7872,7 +7872,7 @@  discard block
 block discarded – undo
7872 7872
 		$hour_array = array();
7873 7873
 		$temp_array = array();
7874 7874
         
7875
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7875
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7876 7876
 		{
7877 7877
 			$temp_array['hour_name'] = $row['hour_name'];
7878 7878
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -7894,7 +7894,7 @@  discard block
 block discarded – undo
7894 7894
 	public function countAllHoursByIdent($ident)
7895 7895
 	{
7896 7896
 		global $globalTimezone, $globalDBdriver;
7897
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7897
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7898 7898
 		if ($globalTimezone != '') {
7899 7899
 			date_default_timezone_set($globalTimezone);
7900 7900
 			$datetime = new DateTime();
@@ -7902,13 +7902,13 @@  discard block
 block discarded – undo
7902 7902
 		} else $offset = '+00:00';
7903 7903
 
7904 7904
 		if ($globalDBdriver == 'mysql') {
7905
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7905
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7906 7906
 								FROM spotter_output 
7907 7907
 								WHERE spotter_output.ident = :ident 
7908 7908
 								GROUP BY hour_name 
7909 7909
 								ORDER BY hour_name ASC";
7910 7910
 		} else {
7911
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7911
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7912 7912
 								FROM spotter_output 
7913 7913
 								WHERE spotter_output.ident = :ident 
7914 7914
 								GROUP BY hour_name 
@@ -7917,12 +7917,12 @@  discard block
 block discarded – undo
7917 7917
       
7918 7918
 		
7919 7919
 		$sth = $this->db->prepare($query);
7920
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
7920
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
7921 7921
       
7922 7922
 		$hour_array = array();
7923 7923
 		$temp_array = array();
7924 7924
         
7925
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7925
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7926 7926
 		{
7927 7927
 			$temp_array['hour_name'] = $row['hour_name'];
7928 7928
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -7944,8 +7944,8 @@  discard block
 block discarded – undo
7944 7944
 	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao)
7945 7945
 	{
7946 7946
 		global $globalTimezone, $globalDBdriver;
7947
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
7948
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
7947
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
7948
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
7949 7949
 		if ($globalTimezone != '') {
7950 7950
 			date_default_timezone_set($globalTimezone);
7951 7951
 			$datetime = new DateTime();
@@ -7953,13 +7953,13 @@  discard block
 block discarded – undo
7953 7953
 		} else $offset = '+00:00';
7954 7954
 
7955 7955
 		if ($globalDBdriver == 'mysql') {
7956
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7956
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
7957 7957
 								FROM spotter_output 
7958 7958
 								WHERE (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
7959 7959
 								GROUP BY hour_name 
7960 7960
 								ORDER BY hour_name ASC";
7961 7961
 		} else {
7962
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7962
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
7963 7963
 								FROM spotter_output 
7964 7964
 								WHERE (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
7965 7965
 								GROUP BY hour_name 
@@ -7967,12 +7967,12 @@  discard block
 block discarded – undo
7967 7967
 		}
7968 7968
 		
7969 7969
 		$sth = $this->db->prepare($query);
7970
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':offset' => $offset));
7970
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':offset' => $offset));
7971 7971
       
7972 7972
 		$hour_array = array();
7973 7973
 		$temp_array = array();
7974 7974
         
7975
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7975
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7976 7976
 		{
7977 7977
 			$temp_array['hour_name'] = $row['hour_name'];
7978 7978
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -7993,7 +7993,7 @@  discard block
 block discarded – undo
7993 7993
 	public function countAllHoursByCountry($country)
7994 7994
 	{
7995 7995
 		global $globalTimezone, $globalDBdriver;
7996
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7996
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7997 7997
 		if ($globalTimezone != '') {
7998 7998
 			date_default_timezone_set($globalTimezone);
7999 7999
 			$datetime = new DateTime();
@@ -8001,13 +8001,13 @@  discard block
 block discarded – undo
8001 8001
 		} else $offset = '+00:00';
8002 8002
 
8003 8003
 		if ($globalDBdriver == 'mysql') {
8004
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8004
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8005 8005
 								FROM spotter_output 
8006 8006
 								WHERE ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
8007 8007
 								GROUP BY hour_name 
8008 8008
 								ORDER BY hour_name ASC";
8009 8009
 		} else {
8010
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8010
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8011 8011
 								FROM spotter_output 
8012 8012
 								WHERE ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
8013 8013
 								GROUP BY hour_name 
@@ -8015,12 +8015,12 @@  discard block
 block discarded – undo
8015 8015
 		}
8016 8016
 		
8017 8017
 		$sth = $this->db->prepare($query);
8018
-		$sth->execute(array(':country' => $country,':offset' => $offset));
8018
+		$sth->execute(array(':country' => $country, ':offset' => $offset));
8019 8019
       
8020 8020
 		$hour_array = array();
8021 8021
 		$temp_array = array();
8022 8022
         
8023
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8023
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8024 8024
 		{
8025 8025
 			$temp_array['hour_name'] = $row['hour_name'];
8026 8026
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8042,7 +8042,7 @@  discard block
 block discarded – undo
8042 8042
 	*/
8043 8043
 	public function countOverallAircrafts()
8044 8044
 	{
8045
-		$query  = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
8045
+		$query = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
8046 8046
                     FROM spotter_output
8047 8047
                     WHERE spotter_output.ident <> ''";
8048 8048
       
@@ -8060,7 +8060,7 @@  discard block
 block discarded – undo
8060 8060
 	*/
8061 8061
 	public function countOverallArrival()
8062 8062
 	{
8063
-		$query  = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
8063
+		$query = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
8064 8064
                     FROM spotter_output
8065 8065
                     WHERE spotter_output.arrival_airport_icao <> ''";
8066 8066
       
@@ -8078,7 +8078,7 @@  discard block
 block discarded – undo
8078 8078
 	*/
8079 8079
 	public function countOverallPilots()
8080 8080
 	{
8081
-		$query  = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
8081
+		$query = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
8082 8082
                     FROM spotter_output
8083 8083
                     WHERE spotter_output.pilot_id <> ''";
8084 8084
       
@@ -8096,7 +8096,7 @@  discard block
 block discarded – undo
8096 8096
 	*/
8097 8097
 	public function countOverallOwners()
8098 8098
 	{
8099
-		$query  = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
8099
+		$query = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
8100 8100
                     FROM spotter_output
8101 8101
                     WHERE spotter_output.owner_name <> ''";
8102 8102
       
@@ -8115,7 +8115,7 @@  discard block
 block discarded – undo
8115 8115
 	*/
8116 8116
 	public function countOverallFlights()
8117 8117
 	{
8118
-		$query  = "SELECT COUNT(spotter_output.spotter_id) AS flight_count  
8118
+		$query = "SELECT COUNT(spotter_output.spotter_id) AS flight_count  
8119 8119
                     FROM spotter_output";
8120 8120
       
8121 8121
 		
@@ -8132,7 +8132,7 @@  discard block
 block discarded – undo
8132 8132
 	*/
8133 8133
 	public function countOverallMilitaryFlights()
8134 8134
 	{
8135
-		$query  = "SELECT COUNT(s.spotter_id) AS flight_count  
8135
+		$query = "SELECT COUNT(s.spotter_id) AS flight_count  
8136 8136
                     FROM spotter_output s, airlines a WHERE s.airline_icao = a.icao AND a.type = 'military'";
8137 8137
       
8138 8138
 		
@@ -8151,7 +8151,7 @@  discard block
 block discarded – undo
8151 8151
 	*/
8152 8152
 	public function countOverallAirlines()
8153 8153
 	{
8154
-		$query  = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count 
8154
+		$query = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count 
8155 8155
 							FROM spotter_output";
8156 8156
       
8157 8157
 		
@@ -8177,13 +8177,13 @@  discard block
 block discarded – undo
8177 8177
 		} else $offset = '+00:00';
8178 8178
 
8179 8179
 		if ($globalDBdriver == 'mysql') {
8180
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8180
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8181 8181
 								FROM spotter_output 
8182 8182
 								WHERE DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = CURDATE()
8183 8183
 								GROUP BY hour_name 
8184 8184
 								ORDER BY hour_name ASC";
8185 8185
 		} else {
8186
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8186
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8187 8187
 								FROM spotter_output 
8188 8188
 								WHERE to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
8189 8189
 								GROUP BY hour_name 
@@ -8196,7 +8196,7 @@  discard block
 block discarded – undo
8196 8196
 		$hour_array = array();
8197 8197
 		$temp_array = array();
8198 8198
         
8199
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8199
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8200 8200
 		{
8201 8201
 			$temp_array['hour_name'] = $row['hour_name'];
8202 8202
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8219,8 +8219,8 @@  discard block
 block discarded – undo
8219 8219
 		if ($limit != "")
8220 8220
 		{
8221 8221
 			$limit_array = explode(",", $limit);
8222
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
8223
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
8222
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
8223
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
8224 8224
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
8225 8225
 			{
8226 8226
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -8267,7 +8267,7 @@  discard block
 block discarded – undo
8267 8267
 			    FROM spotter_output
8268 8268
 			    WHERE DATE_PART('dow', spotter_output.date) = DATE_PART('dow', date 'now' AT TIME ZONE :timezone) AND EXTRACT (HOUR FROM spotter_output.date AT TIME ZONE :timezone) >= '$currentHour' AND EXTRACT (HOUR FROM spotter_output.date AT TIME ZONE :timezone) <= '$next3Hours' AND ident <> '' 
8269 8269
 			    GROUP BY spotter_output.ident, spotter_output.spotter_id HAVING count(spotter_output.ident) > 10 $orderby_query";
8270
-		$spotter_array = $this->getDataFromDB($query.$limit_query,array(':timezone' => $globalTimezone));
8270
+		$spotter_array = $this->getDataFromDB($query.$limit_query, array(':timezone' => $globalTimezone));
8271 8271
 		}
8272 8272
 		return $spotter_array;
8273 8273
 	}
@@ -8281,9 +8281,9 @@  discard block
 block discarded – undo
8281 8281
 	*/
8282 8282
 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id)
8283 8283
 	{
8284
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
8284
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
8285 8285
 
8286
-		$query  = "SELECT spotter_output.spotter_id
8286
+		$query = "SELECT spotter_output.spotter_id
8287 8287
 								FROM spotter_output 
8288 8288
 								WHERE spotter_output.flightaware_id = '".$flightaware_id."'";
8289 8289
         
@@ -8291,7 +8291,7 @@  discard block
 block discarded – undo
8291 8291
 		$sth = $this->db->prepare($query);
8292 8292
 		$sth->execute();
8293 8293
 
8294
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8294
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8295 8295
 		{
8296 8296
 			return $row['spotter_id'];
8297 8297
 		}
@@ -8316,23 +8316,23 @@  discard block
 block discarded – undo
8316 8316
 		}
8317 8317
 		
8318 8318
 		$current_date = date("Y-m-d H:i:s");
8319
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
8319
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
8320 8320
 		
8321 8321
 		$diff = abs(strtotime($current_date) - strtotime($date));
8322 8322
 
8323
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
8323
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
8324 8324
 		$years = $time_array['years'];
8325 8325
 		
8326
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
8326
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
8327 8327
 		$months = $time_array['months'];
8328 8328
 		
8329
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
8329
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
8330 8330
 		$days = $time_array['days'];
8331
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
8331
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
8332 8332
 		$hours = $time_array['hours'];
8333
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
8333
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
8334 8334
 		$minutes = $time_array['minutes'];
8335
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
8335
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
8336 8336
 		
8337 8337
 		return $time_array;	
8338 8338
 	}	
@@ -8358,63 +8358,63 @@  discard block
 block discarded – undo
8358 8358
 			$temp_array['direction_degree'] = $direction;
8359 8359
 			$temp_array['direction_shortname'] = "N";
8360 8360
 			$temp_array['direction_fullname'] = "North";
8361
-		} elseif ($direction >= 22.5 && $direction < 45){
8361
+		} elseif ($direction >= 22.5 && $direction < 45) {
8362 8362
 			$temp_array['direction_degree'] = $direction;
8363 8363
 			$temp_array['direction_shortname'] = "NNE";
8364 8364
 			$temp_array['direction_fullname'] = "North-Northeast";
8365
-		} elseif ($direction >= 45 && $direction < 67.5){
8365
+		} elseif ($direction >= 45 && $direction < 67.5) {
8366 8366
 			$temp_array['direction_degree'] = $direction;
8367 8367
 			$temp_array['direction_shortname'] = "NE";
8368 8368
 			$temp_array['direction_fullname'] = "Northeast";
8369
-		} elseif ($direction >= 67.5 && $direction < 90){
8369
+		} elseif ($direction >= 67.5 && $direction < 90) {
8370 8370
 			$temp_array['direction_degree'] = $direction;
8371 8371
 			$temp_array['direction_shortname'] = "ENE";
8372 8372
 			$temp_array['direction_fullname'] = "East-Northeast";
8373
-		} elseif ($direction >= 90 && $direction < 112.5){
8373
+		} elseif ($direction >= 90 && $direction < 112.5) {
8374 8374
 			$temp_array['direction_degree'] = $direction;
8375 8375
 			$temp_array['direction_shortname'] = "E";
8376 8376
 			$temp_array['direction_fullname'] = "East";
8377
-		} elseif ($direction >= 112.5 && $direction < 135){
8377
+		} elseif ($direction >= 112.5 && $direction < 135) {
8378 8378
 			$temp_array['direction_degree'] = $direction;
8379 8379
 			$temp_array['direction_shortname'] = "ESE";
8380 8380
 			$temp_array['direction_fullname'] = "East-Southeast";
8381
-		} elseif ($direction >= 135 && $direction < 157.5){
8381
+		} elseif ($direction >= 135 && $direction < 157.5) {
8382 8382
 			$temp_array['direction_degree'] = $direction;
8383 8383
 			$temp_array['direction_shortname'] = "SE";
8384 8384
 			$temp_array['direction_fullname'] = "Southeast";
8385
-		} elseif ($direction >= 157.5 && $direction < 180){
8385
+		} elseif ($direction >= 157.5 && $direction < 180) {
8386 8386
 			$temp_array['direction_degree'] = $direction;
8387 8387
 			$temp_array['direction_shortname'] = "SSE";
8388 8388
 			$temp_array['direction_fullname'] = "South-Southeast";
8389
-		} elseif ($direction >= 180 && $direction < 202.5){
8389
+		} elseif ($direction >= 180 && $direction < 202.5) {
8390 8390
 			$temp_array['direction_degree'] = $direction;
8391 8391
 			$temp_array['direction_shortname'] = "S";
8392 8392
 			$temp_array['direction_fullname'] = "South";
8393
-		} elseif ($direction >= 202.5 && $direction < 225){
8393
+		} elseif ($direction >= 202.5 && $direction < 225) {
8394 8394
 			$temp_array['direction_degree'] = $direction;
8395 8395
 			$temp_array['direction_shortname'] = "SSW";
8396 8396
 			$temp_array['direction_fullname'] = "South-Southwest";
8397
-		} elseif ($direction >= 225 && $direction < 247.5){
8397
+		} elseif ($direction >= 225 && $direction < 247.5) {
8398 8398
 			$temp_array['direction_degree'] = $direction;
8399 8399
 			$temp_array['direction_shortname'] = "SW";
8400 8400
 			$temp_array['direction_fullname'] = "Southwest";
8401
-		} elseif ($direction >= 247.5 && $direction < 270){
8401
+		} elseif ($direction >= 247.5 && $direction < 270) {
8402 8402
 			$temp_array['direction_degree'] = $direction;
8403 8403
 			$temp_array['direction_shortname'] = "WSW";
8404 8404
 			$temp_array['direction_fullname'] = "West-Southwest";
8405
-		} elseif ($direction >= 270 && $direction < 292.5){
8405
+		} elseif ($direction >= 270 && $direction < 292.5) {
8406 8406
 			$temp_array['direction_degree'] = $direction;
8407 8407
 			$temp_array['direction_shortname'] = "W";
8408 8408
 			$temp_array['direction_fullname'] = "West";
8409
-		} elseif ($direction >= 292.5 && $direction < 315){
8409
+		} elseif ($direction >= 292.5 && $direction < 315) {
8410 8410
 			$temp_array['direction_degree'] = $direction;
8411 8411
 			$temp_array['direction_shortname'] = "WNW";
8412 8412
 			$temp_array['direction_fullname'] = "West-Northwest";
8413
-		} elseif ($direction >= 315 && $direction < 337.5){
8413
+		} elseif ($direction >= 315 && $direction < 337.5) {
8414 8414
 			$temp_array['direction_degree'] = $direction;
8415 8415
 			$temp_array['direction_shortname'] = "NW";
8416 8416
 			$temp_array['direction_fullname'] = "Northwest";
8417
-		} elseif ($direction >= 337.5 && $direction < 360){
8417
+		} elseif ($direction >= 337.5 && $direction < 360) {
8418 8418
 			$temp_array['direction_degree'] = $direction;
8419 8419
 			$temp_array['direction_shortname'] = "NNW";
8420 8420
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -8468,9 +8468,9 @@  discard block
 block discarded – undo
8468 8468
 	
8469 8469
 	public function getAircraftRegistrationBymodeS($aircraft_modes)
8470 8470
 	{
8471
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
8471
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
8472 8472
 	
8473
-		$query  = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
8473
+		$query = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
8474 8474
 		
8475 8475
 		$sth = $this->db->prepare($query);
8476 8476
 		$sth->execute(array(':aircraft_modes' => $aircraft_modes));
@@ -8493,9 +8493,9 @@  discard block
 block discarded – undo
8493 8493
 	
8494 8494
 	public function getAircraftTypeBymodeS($aircraft_modes)
8495 8495
 	{
8496
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
8496
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
8497 8497
 	
8498
-		$query  = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
8498
+		$query = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
8499 8499
 		
8500 8500
 		$sth = $this->db->prepare($query);
8501 8501
 		$sth->execute(array(':aircraft_modes' => $aircraft_modes));
@@ -8516,11 +8516,11 @@  discard block
 block discarded – undo
8516 8516
 	*
8517 8517
 	*/
8518 8518
 	
8519
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
8519
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
8520 8520
 	{
8521 8521
 		global $globalDBdriver;
8522
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
8523
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
8522
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
8523
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
8524 8524
 	
8525 8525
 		try {
8526 8526
 			/*
@@ -8556,19 +8556,19 @@  discard block
 block discarded – undo
8556 8556
 	*/
8557 8557
 	public function convertAircraftRegistration($registration)
8558 8558
 	{
8559
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
8559
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8560 8560
 		$registration_prefix = '';
8561 8561
 		$registration_1 = substr($registration, 0, 1);
8562 8562
 		$registration_2 = substr($registration, 0, 2);
8563 8563
 
8564 8564
 		//first get the prefix based on two characters
8565
-		$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
8565
+		$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
8566 8566
       
8567 8567
 		
8568 8568
 		$sth = $this->db->prepare($query);
8569 8569
 		$sth->execute(array(':registration_2' => $registration_2));
8570 8570
         
8571
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8571
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8572 8572
 		{
8573 8573
 			$registration_prefix = $row['registration_prefix'];
8574 8574
 		}
@@ -8576,12 +8576,12 @@  discard block
 block discarded – undo
8576 8576
 		//if we didn't find a two chracter prefix lets just search the one with one character
8577 8577
 		if ($registration_prefix == "")
8578 8578
 		{
8579
-			$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
8579
+			$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
8580 8580
 	      
8581 8581
 			$sth = $this->db->prepare($query);
8582 8582
 			$sth->execute(array(':registration_1' => $registration_1));
8583 8583
 	        
8584
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
8584
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8585 8585
 			{
8586 8586
 				$registration_prefix = $row['registration_prefix'];
8587 8587
 			}
@@ -8595,7 +8595,7 @@  discard block
 block discarded – undo
8595 8595
             } else {
8596 8596
                 $registration = preg_replace("/^(.{1})/", "$1-", $registration);
8597 8597
             }
8598
-		} else if(strlen($registration_prefix) == 2){
8598
+		} else if (strlen($registration_prefix) == 2) {
8599 8599
             if (0 === strpos($registration, 'N')) {
8600 8600
                 $registration = preg_replace("/^(.{2})/", "$1", $registration);
8601 8601
             } else {
@@ -8615,11 +8615,11 @@  discard block
 block discarded – undo
8615 8615
 	*/
8616 8616
 	public function countryFromAircraftRegistration($registration)
8617 8617
 	{
8618
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
8618
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8619 8619
 		
8620 8620
 		$registration_prefix = '';
8621 8621
 		
8622
-		$registration_test = explode('-',$registration);
8622
+		$registration_test = explode('-', $registration);
8623 8623
 		$country = '';
8624 8624
 		if ($registration_test[0] != $registration) {
8625 8625
 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
@@ -8627,7 +8627,7 @@  discard block
 block discarded – undo
8627 8627
 			$sth = $this->db->prepare($query);
8628 8628
 			$sth->execute(array(':registration_1' => $registration_test[0]));
8629 8629
 	        
8630
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
8630
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8631 8631
 			{
8632 8632
 				$registration_prefix = $row['registration_prefix'];
8633 8633
 				$country = $row['country'];
@@ -8638,13 +8638,13 @@  discard block
 block discarded – undo
8638 8638
 
8639 8639
 			$country = '';
8640 8640
 			//first get the prefix based on two characters
8641
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
8641
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
8642 8642
       
8643 8643
 			
8644 8644
 			$sth = $this->db->prepare($query);
8645 8645
 			$sth->execute(array(':registration_2' => $registration_2));
8646 8646
         
8647
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
8647
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8648 8648
 			{
8649 8649
 				$registration_prefix = $row['registration_prefix'];
8650 8650
 				$country = $row['country'];
@@ -8653,12 +8653,12 @@  discard block
 block discarded – undo
8653 8653
 			//if we didn't find a two chracter prefix lets just search the one with one character
8654 8654
 			if ($registration_prefix == "")
8655 8655
 			{
8656
-				$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
8656
+				$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
8657 8657
 	      
8658 8658
 				$sth = $this->db->prepare($query);
8659 8659
 				$sth->execute(array(':registration_1' => $registration_1));
8660 8660
 	        
8661
-				while($row = $sth->fetch(PDO::FETCH_ASSOC))
8661
+				while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8662 8662
 				{
8663 8663
 					$registration_prefix = $row['registration_prefix'];
8664 8664
 					$country = $row['country'];
@@ -8675,9 +8675,9 @@  discard block
 block discarded – undo
8675 8675
 	* @param String $flightaware_id flightaware_id from spotter_output table
8676 8676
 	* @param String $highlight New highlight value
8677 8677
 	*/
8678
-	public function setHighlightFlight($flightaware_id,$highlight) {
8678
+	public function setHighlightFlight($flightaware_id, $highlight) {
8679 8679
 		
8680
-		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
8680
+		$query = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
8681 8681
 		$sth = $this->db->prepare($query);
8682 8682
 		$sth->execute(array(':flightaware_id' => $flightaware_id, ':highlight' => $highlight));
8683 8683
 	}
@@ -8706,7 +8706,7 @@  discard block
 block discarded – undo
8706 8706
 		
8707 8707
 		$bitly_data = json_decode($bitly_data);
8708 8708
 		
8709
-		if ($bitly_data->status_txt = "OK"){
8709
+		if ($bitly_data->status_txt = "OK") {
8710 8710
 			$bitly_url = $bitly_data->data->url;
8711 8711
 		}
8712 8712
 
@@ -8716,7 +8716,7 @@  discard block
 block discarded – undo
8716 8716
 
8717 8717
 	public function getOrderBy()
8718 8718
 	{
8719
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
8719
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
8720 8720
 		
8721 8721
 		return $orderby;
8722 8722
 		
@@ -8747,11 +8747,11 @@  discard block
 block discarded – undo
8747 8747
         {
8748 8748
             if (is_array($result->SearchBirdseyeInFlightResult->aircraft))
8749 8749
             {
8750
-                    foreach($result->SearchBirdseyeInFlightResult->aircraft as $aircraft)
8750
+                    foreach ($result->SearchBirdseyeInFlightResult->aircraft as $aircraft)
8751 8751
                     {
8752 8752
                         if (!strstr($aircraft->origin, 'L ') && !strstr($aircraft->destination, 'L '))
8753 8753
                         {
8754
-                            foreach($globalAirportIgnore as $airportIgnore)
8754
+                            foreach ($globalAirportIgnore as $airportIgnore)
8755 8755
                             {
8756 8756
                                 if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore)
8757 8757
                                 {
@@ -8783,7 +8783,7 @@  discard block
 block discarded – undo
8783 8783
 
8784 8784
 
8785 8785
                             //if there was no aircraft with the same callsign within the last hour and go post it into the archive
8786
-                            if($last_hour_ident == "")
8786
+                            if ($last_hour_ident == "")
8787 8787
                             {
8788 8788
                                 //adds the spotter data for the archive
8789 8789
                                 $Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
@@ -8798,9 +8798,9 @@  discard block
 block discarded – undo
8798 8798
                 } else {
8799 8799
                     if (!strstr($result->SearchBirdseyeInFlightResult->aircraft->origin, 'L ') && !strstr($result->SearchBirdseyeInFlightResult->aircraft->destination, 'L '))
8800 8800
                     {
8801
-                        foreach($globalAirportIgnore as $airportIgnore)
8801
+                        foreach ($globalAirportIgnore as $airportIgnore)
8802 8802
                         {
8803
-                            foreach($globalAirportIgnore as $airportIgnore)
8803
+                            foreach ($globalAirportIgnore as $airportIgnore)
8804 8804
                             {
8805 8805
                                 if ($aircraft->origin == $airportIgnore || $aircraft->destination == $airportIgnore)
8806 8806
                                 {
@@ -8831,7 +8831,7 @@  discard block
 block discarded – undo
8831 8831
                                 if ($arrival_airport == "" || $arrival_airport == "---" || $arrival_airport == "ZZZ" || $arrival_airport == "ZZZZ") { $arrival_airport = "NA"; }
8832 8832
 
8833 8833
                         //if there was no aircraft with the same callsign within the last hour and go post it into the archive
8834
-                        if($last_hour_ident == "")
8834
+                        if ($last_hour_ident == "")
8835 8835
                         {
8836 8836
                             //adds the spotter data for the archive
8837 8837
                             $Spotter->addSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
@@ -8865,14 +8865,14 @@  discard block
 block discarded – undo
8865 8865
 		}
8866 8866
 		$sth = $this->db->prepare($query);
8867 8867
 		$sth->execute();
8868
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8868
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8869 8869
 		{
8870 8870
 			$departure_airport_array = $this->getAllAirportInfo($row['fromairport_icao']);
8871 8871
 			$arrival_airport_array = $this->getAllAirportInfo($row['toairport_icao']);
8872 8872
 			if (count($departure_airport_array) > 0 && count($arrival_airport_array) > 0) {
8873
-				$update_query="UPDATE spotter_output SET departure_airport_icao = :fromicao, arrival_airport_icao = :toicao, departure_airport_name = :departure_airport_name, departure_airport_city = :departure_airport_city, departure_airport_country = :departure_airport_country, arrival_airport_name = :arrival_airport_name, arrival_airport_city = :arrival_airport_city, arrival_airport_country = :arrival_airport_country WHERE spotter_id = :spotter_id";
8873
+				$update_query = "UPDATE spotter_output SET departure_airport_icao = :fromicao, arrival_airport_icao = :toicao, departure_airport_name = :departure_airport_name, departure_airport_city = :departure_airport_city, departure_airport_country = :departure_airport_country, arrival_airport_name = :arrival_airport_name, arrival_airport_city = :arrival_airport_city, arrival_airport_country = :arrival_airport_country WHERE spotter_id = :spotter_id";
8874 8874
 				$sthu = $this->db->prepare($update_query);
8875
-				$sthu->execute(array(':fromicao' => $row['fromairport_icao'],':toicao' => $row['toairport_icao'],':spotter_id' => $row['spotter_id'],':departure_airport_name' => $departure_airport_array[0]['name'],':departure_airport_city' => $departure_airport_array[0]['city'],':departure_airport_country' => $departure_airport_array[0]['country'],':arrival_airport_name' => $arrival_airport_array[0]['name'],':arrival_airport_city' => $arrival_airport_array[0]['city'],':arrival_airport_country' => $arrival_airport_array[0]['country']));
8875
+				$sthu->execute(array(':fromicao' => $row['fromairport_icao'], ':toicao' => $row['toairport_icao'], ':spotter_id' => $row['spotter_id'], ':departure_airport_name' => $departure_airport_array[0]['name'], ':departure_airport_city' => $departure_airport_array[0]['city'], ':departure_airport_country' => $departure_airport_array[0]['country'], ':arrival_airport_name' => $arrival_airport_array[0]['name'], ':arrival_airport_city' => $arrival_airport_array[0]['city'], ':arrival_airport_country' => $arrival_airport_array[0]['country']));
8876 8876
 			}
8877 8877
 		}
8878 8878
 		
@@ -8885,15 +8885,15 @@  discard block
 block discarded – undo
8885 8885
 		}
8886 8886
 		$sth = $this->db->prepare($query);
8887 8887
 		$sth->execute();
8888
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8888
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8889 8889
 		{
8890 8890
 			if (is_numeric(substr($row['ident'], -1, 1)))
8891 8891
 			{
8892 8892
 				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3));
8893 8893
 				if (isset($airline_array[0]['name'])) {
8894
-					$update_query  = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
8894
+					$update_query = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
8895 8895
 					$sthu = $this->db->prepare($update_query);
8896
-					$sthu->execute(array(':airline_name' => $airline_array[0]['name'],':airline_icao' => $airline_array[0]['icao'], ':airline_country' => $airline_array[0]['country'], ':airline_type' => $airline_array[0]['type'], ':spotter_id' => $row['spotter_id']));
8896
+					$sthu->execute(array(':airline_name' => $airline_array[0]['name'], ':airline_icao' => $airline_array[0]['icao'], ':airline_country' => $airline_array[0]['country'], ':airline_type' => $airline_array[0]['type'], ':spotter_id' => $row['spotter_id']));
8897 8897
 				}
8898 8898
 			}
8899 8899
 		}
@@ -8913,18 +8913,18 @@  discard block
 block discarded – undo
8913 8913
 		}
8914 8914
 		$sth = $this->db->prepare($query);
8915 8915
 		$sth->execute();
8916
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8916
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8917 8917
 		{
8918 8918
 			if ($row['aircraft_icao'] != '') {
8919 8919
 				$aircraft_name = $this->getAllAircraftInfo($row['aircraft_icao']);
8920
-				if ($row['registration'] != ""){
8920
+				if ($row['registration'] != "") {
8921 8921
 					$image_array = $Image->getSpotterImage($row['registration']);
8922 8922
 					if (count($image_array) == 0) {
8923 8923
 						$Image->addSpotterImage($row['registration']);
8924 8924
 					}
8925 8925
 				}
8926 8926
 				if (count($aircraft_name) > 0) {
8927
-					$update_query  = "UPDATE spotter_output SET spotter_output.aircraft_name = :aircraft_name, spotter_output.aircraft_manufacturer = :aircraft_manufacturer WHERE spotter_output.spotter_id = :spotter_id";
8927
+					$update_query = "UPDATE spotter_output SET spotter_output.aircraft_name = :aircraft_name, spotter_output.aircraft_manufacturer = :aircraft_manufacturer WHERE spotter_output.spotter_id = :spotter_id";
8928 8928
 					$sthu = $this->db->prepare($update_query);
8929 8929
 					$sthu->execute(array(':aircraft_name' => $aircraft_name[0]['type'], ':aircraft_manufacturer' => $aircraft_name[0]['manufacturer'], ':spotter_id' => $row['spotter_id']));
8930 8930
 				}
@@ -8939,10 +8939,10 @@  discard block
 block discarded – undo
8939 8939
 		$query = "SELECT spotter_output.spotter_id, spotter_output.last_latitude, spotter_output.last_longitude, spotter_output.last_altitude, spotter_output.arrival_airport_icao, spotter_output.real_arrival_airport_icao FROM spotter_output";
8940 8940
 		$sth = $this->db->prepare($query);
8941 8941
 		$sth->execute();
8942
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8942
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8943 8943
 		{
8944 8944
 			if ($row['last_latitude'] != '' && $row['last_longitude'] != '') {
8945
-				$closestAirports = $this->closestAirports($row['last_latitude'],$row['last_longitude'],$globalClosestMinDist);
8945
+				$closestAirports = $this->closestAirports($row['last_latitude'], $row['last_longitude'], $globalClosestMinDist);
8946 8946
 				$airport_icao = '';
8947 8947
 				 if (isset($closestAirports[0])) {
8948 8948
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
@@ -8956,7 +8956,7 @@  discard block
 block discarded – undo
8956 8956
 								break;
8957 8957
 							}
8958 8958
 						}
8959
-					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
8959
+					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100 + 1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude'] + 5000))) {
8960 8960
 						$airport_icao = $closestAirports[0]['icao'];
8961 8961
 						if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
8962 8962
 					} else {
@@ -8967,28 +8967,28 @@  discard block
 block discarded – undo
8967 8967
 				}
8968 8968
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
8969 8969
 					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
8970
-					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
8970
+					$update_query = "UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
8971 8971
 					$sthu = $this->db->prepare($update_query);
8972
-					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
8972
+					$sthu->execute(array(':airport_icao' => $airport_icao, ':spotter_id' => $row['spotter_id']));
8973 8973
 				}
8974 8974
 			}
8975 8975
 		}
8976 8976
 	}
8977 8977
 	
8978
-	public function closestAirports($origLat,$origLon,$dist = 10) {
8978
+	public function closestAirports($origLat, $origLon, $dist = 10) {
8979 8979
 		global $globalDBdriver;
8980
-		$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
8980
+		$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
8981 8981
 /*
8982 8982
 		$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - abs(latitude))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(abs(latitude)*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
8983 8983
                       FROM airport WHERE longitude between ($origLon-$dist/abs(cos(radians($origLat))*69)) and ($origLon+$dist/abs(cos(radians($origLat))*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
8984 8984
                       having distance < $dist ORDER BY distance limit 100;";
8985 8985
 */
8986 8986
 		if ($globalDBdriver == 'mysql') {
8987
-			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
8987
+			$query = "SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
8988 8988
 	                      FROM airport WHERE longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
8989 8989
 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;";
8990 8990
                 } else {
8991
-			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2))) as distance 
8991
+			$query = "SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2))) as distance 
8992 8992
 	                      FROM airport WHERE CAST(longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
8993 8993
 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;";
8994 8994
     		}
Please login to merge, or discard this patch.
Braces   +465 added lines, -158 removed lines patch added patch discarded remove patch
@@ -26,9 +26,15 @@  discard block
 block discarded – undo
26 26
 		$Image = new Image($this->db);
27 27
 		$Schedule = new Schedule($this->db);
28 28
 		$ACARS = new ACARS($this->db);
29
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
30
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
31
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
29
+		if (!isset($globalIVAO)) {
30
+			$globalIVAO = FALSE;
31
+		}
32
+		if (!isset($globalVATSIM)) {
33
+			$globalVATSIM = FALSE;
34
+		}
35
+		if (!isset($globalphpVMS)) {
36
+			$globalphpVMS = FALSE;
37
+		}
32 38
 		date_default_timezone_set('UTC');
33 39
 		
34 40
 		if (!is_string($query))
@@ -77,18 +83,24 @@  discard block
 block discarded – undo
77 83
 				$temp_array['spotter_id'] = '';
78 84
 			}
79 85
 			$temp_array['flightaware_id'] = $row['flightaware_id'];
80
-			if (isset($row['modes'])) $temp_array['modes'] = $row['modes'];
86
+			if (isset($row['modes'])) {
87
+				$temp_array['modes'] = $row['modes'];
88
+			}
81 89
 			$temp_array['ident'] = $row['ident'];
82 90
 			if (isset($row['registration']) && $row['registration'] != '') {
83 91
 				$temp_array['registration'] = $row['registration'];
84 92
 			} elseif (isset($temp_array['modes'])) {
85 93
 				$temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']);
86
-			} else $temp_array['registration'] = '';
94
+			} else {
95
+				$temp_array['registration'] = '';
96
+			}
87 97
 			$temp_array['aircraft_type'] = $row['aircraft_icao'];
88 98
 			
89 99
 			$temp_array['departure_airport'] = $row['departure_airport_icao'];
90 100
 			$temp_array['arrival_airport'] = $row['arrival_airport_icao'];
91
-			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
101
+			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) {
102
+				$temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
103
+			}
92 104
 			$temp_array['latitude'] = $row['latitude'];
93 105
 			$temp_array['longitude'] = $row['longitude'];
94 106
 			/*
@@ -122,7 +134,9 @@  discard block
 block discarded – undo
122 134
 			$temp_array['altitude'] = $row['altitude'];
123 135
 			$temp_array['heading'] = $row['heading'];
124 136
 			$heading_direction = $this->parseDirection($row['heading']);
125
-			if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
137
+			if (isset($heading_direction[0]['direction_fullname'])) {
138
+				$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
139
+			}
126 140
 			$temp_array['ground_speed'] = $row['ground_speed'];
127 141
 			$temp_array['image'] = "";
128 142
 			$temp_array['image_thumbnail'] = "";
@@ -131,7 +145,9 @@  discard block
 block discarded – undo
131 145
  
132 146
 			if (isset($row['highlight'])) {
133 147
 				$temp_array['highlight'] = $row['highlight'];
134
-			} else $temp_array['highlight'] = '';
148
+			} else {
149
+				$temp_array['highlight'] = '';
150
+			}
135 151
 			
136 152
 			$dateArray = $this->parseDateString($row['date']);
137 153
 			if ($dateArray['seconds'] < 10)
@@ -177,7 +193,9 @@  discard block
 block discarded – undo
177 193
 				
178 194
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
179 195
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
180
-					} else $temp_array['aircraft_shadow'] = 'default.png';
196
+					} else {
197
+						$temp_array['aircraft_shadow'] = 'default.png';
198
+					}
181 199
                                 } else {
182 200
                             		$temp_array['aircraft_shadow'] = 'default.png';
183 201
 					$temp_array['aircraft_name'] = 'N/A';
@@ -207,12 +225,18 @@  discard block
 block discarded – undo
207 225
 				}
208 226
 			} else {
209 227
 				$temp_array['airline_icao'] = $row['airline_icao'];
210
-				if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata'];
211
-				else $temp_array['airline_iata'] = '';
228
+				if (isset($row['airline_iata'])) {
229
+					$temp_array['airline_iata'] = $row['airline_iata'];
230
+				} else {
231
+					$temp_array['airline_iata'] = '';
232
+				}
212 233
 				$temp_array['airline_name'] = $row['airline_name'];
213 234
 				$temp_array['airline_country'] = $row['airline_country'];
214
-				if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign'];
215
-				else $temp_array['airline_callsign'] = 'N/A';
235
+				if (isset($row['airline_callsign'])) {
236
+					$temp_array['airline_callsign'] = $row['airline_callsign'];
237
+				} else {
238
+					$temp_array['airline_callsign'] = 'N/A';
239
+				}
216 240
 				$temp_array['airline_type'] = $row['airline_type'];
217 241
 			}
218 242
 			if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') {
@@ -228,7 +252,9 @@  discard block
 block discarded – undo
228 252
 			}
229 253
 			if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !isset($temp_array['aircraft_owner'])) {
230 254
 				$owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']);
231
-				if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
255
+				if ($owner_info['owner'] != '') {
256
+					$temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
257
+				}
232 258
 				$temp_array['aircraft_base'] = $owner_info['base'];
233 259
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
234 260
 			}
@@ -236,9 +262,14 @@  discard block
 block discarded – undo
236 262
 			if($temp_array['registration'] != "" || ($globalIVAO && $temp_array['aircraft_type'] != ''))
237 263
 			{
238 264
 				if ($globalIVAO) {
239
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
240
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
241
-				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
265
+					if (isset($temp_array['airline_icao'])) {
266
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
267
+					} else {
268
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
269
+					}
270
+				} else {
271
+					$image_array = $Image->getSpotterImage($temp_array['registration']);
272
+				}
242 273
 				if (count($image_array) > 0) {
243 274
 					$temp_array['image'] = $image_array[0]['image'];
244 275
 					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -288,7 +319,9 @@  discard block
 block discarded – undo
288 319
 			//if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') {
289 320
 			if ($row['departure_airport_icao'] != '') {
290 321
 				$departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']);
291
-				if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA');
322
+				if (!isset($departure_airport_array[0]['name'])) {
323
+					$departure_airport_array = $this->getAllAirportInfo('NA');
324
+				}
292 325
 			/*
293 326
 			} elseif ($row['departure_airport_name'] != '') {
294 327
 				$temp_array['departure_airport_name'] = $row['departure_airport_name'];
@@ -296,7 +329,9 @@  discard block
 block discarded – undo
296 329
 				$temp_array['departure_airport_country'] = $row['departure_airport_country'];
297 330
 				$temp_array['departure_airport_icao'] = $row['departure_airport_icao'];
298 331
 			*/
299
-			} else $departure_airport_array = $this->getAllAirportInfo('NA');
332
+			} else {
333
+				$departure_airport_array = $this->getAllAirportInfo('NA');
334
+			}
300 335
 			if (isset($departure_airport_array[0]['name'])) {
301 336
 				$temp_array['departure_airport_name'] = $departure_airport_array[0]['name'];
302 337
 				$temp_array['departure_airport_city'] = $departure_airport_array[0]['city'];
@@ -316,8 +351,12 @@  discard block
 block discarded – undo
316 351
 			
317 352
 			if ($row['arrival_airport_icao'] != '') {
318 353
 				$arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']);
319
-				if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA');
320
-			} else $arrival_airport_array = $this->getAllAirportInfo('NA');
354
+				if (count($arrival_airport_array) == 0) {
355
+					$arrival_airport_array = $this->getAllAirportInfo('NA');
356
+				}
357
+			} else {
358
+				$arrival_airport_array = $this->getAllAirportInfo('NA');
359
+			}
321 360
 			if (isset($arrival_airport_array[0]['name'])) {
322 361
 				$temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name'];
323 362
 				$temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city'];
@@ -333,27 +372,45 @@  discard block
 block discarded – undo
333 372
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
334 373
 			}
335 374
 			*/
336
-			if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id'];
337
-			if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name'];
338
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
339
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
340
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
375
+			if (isset($row['pilot_id']) && $row['pilot_id'] != '') {
376
+				$temp_array['pilot_id'] = $row['pilot_id'];
377
+			}
378
+			if (isset($row['pilot_name']) && $row['pilot_name'] != '') {
379
+				$temp_array['pilot_name'] = $row['pilot_name'];
380
+			}
381
+			if (isset($row['source_name']) && $row['source_name'] != '') {
382
+				$temp_array['source_name'] = $row['source_name'];
383
+			}
384
+			if (isset($row['over_country']) && $row['over_country'] != '') {
385
+				$temp_array['over_country'] = $row['over_country'];
386
+			}
387
+			if (isset($row['distance']) && $row['distance'] != '') {
388
+				$temp_array['distance'] = $row['distance'];
389
+			}
341 390
 			if (isset($row['squawk'])) {
342 391
 				$temp_array['squawk'] = $row['squawk'];
343 392
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
344 393
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
345
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
394
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
395
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
396
+					}
346 397
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
347 398
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
348
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
349
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
399
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
400
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
401
+					}
402
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) {
403
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
404
+				}
350 405
 			}
351 406
     			
352 407
 			$temp_array['query_number_rows'] = $num_rows;
353 408
 			
354 409
 			$spotter_array[] = $temp_array;
355 410
 		}
356
-		if ($num_rows == 0) return array();
411
+		if ($num_rows == 0) {
412
+			return array();
413
+		}
357 414
 		$spotter_array[0]['query_number_rows'] = $num_rows;
358 415
 		return $spotter_array;
359 416
 	}	
@@ -385,7 +442,9 @@  discard block
 block discarded – undo
385 442
 				foreach ($q_array as $q_item){
386 443
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
387 444
 					$additional_query .= " AND (";
388
-					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
445
+					if (is_int($q_item)) {
446
+						$additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
447
+					}
389 448
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
390 449
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
391 450
 					$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR ";
@@ -406,7 +465,9 @@  discard block
 block discarded – undo
406 465
 					$additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR ";
407 466
 					$additional_query .= "(spotter_output.ident like '%".$q_item."%') OR ";
408 467
 					$translate = $Translation->ident2icao($q_item);
409
-					if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
468
+					if ($translate != $q_item) {
469
+						$additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
470
+					}
410 471
 					$additional_query .= "(spotter_output.highlight like '%".$q_item."%')";
411 472
 					$additional_query .= ")";
412 473
 				}
@@ -633,7 +694,9 @@  discard block
 block discarded – undo
633 694
 				date_default_timezone_set($globalTimezone);
634 695
 				$datetime = new DateTime();
635 696
 				$offset = $datetime->format('P');
636
-			} else $offset = '+00:00';
697
+			} else {
698
+				$offset = '+00:00';
699
+			}
637 700
 
638 701
 			if ($date_array[1] != "")
639 702
 			{
@@ -666,7 +729,9 @@  discard block
 block discarded – undo
666 729
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
667 730
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
668 731
 			}
669
-		} else $limit_query = "";
732
+		} else {
733
+			$limit_query = "";
734
+		}
670 735
 
671 736
 
672 737
 		if ($sort != "")
@@ -1366,7 +1431,9 @@  discard block
 block discarded – undo
1366 1431
 				date_default_timezone_set($globalTimezone);
1367 1432
 				$datetime = new DateTime($date);
1368 1433
 				$offset = $datetime->format('P');
1369
-			} else $offset = '+00:00';
1434
+			} else {
1435
+				$offset = '+00:00';
1436
+			}
1370 1437
 			if ($globalDBdriver == 'mysql') {
1371 1438
 				$additional_query = " AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date ";
1372 1439
 				$query_values = array(':date' => $datetime->format('Y-m-d'), ':offset' => $offset);
@@ -1658,7 +1725,9 @@  discard block
 block discarded – undo
1658 1725
 		{
1659 1726
 			$highlight = $row['highlight'];
1660 1727
 		}
1661
-		if (isset($highlight)) return $highlight;
1728
+		if (isset($highlight)) {
1729
+			return $highlight;
1730
+		}
1662 1731
 	}
1663 1732
 
1664 1733
 	
@@ -1689,7 +1758,9 @@  discard block
 block discarded – undo
1689 1758
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
1690 1759
 		if (count($row) > 0) {
1691 1760
 			return $row['usage'];
1692
-		} else return '';
1761
+		} else {
1762
+			return '';
1763
+		}
1693 1764
 	}
1694 1765
 
1695 1766
 	/**
@@ -1716,7 +1787,9 @@  discard block
 block discarded – undo
1716 1787
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
1717 1788
 		if (count($row) > 0) {
1718 1789
 			return $row['icao'];
1719
-		} else return '';
1790
+		} else {
1791
+			return '';
1792
+		}
1720 1793
 	}
1721 1794
 
1722 1795
 	/**
@@ -1745,7 +1818,9 @@  discard block
 block discarded – undo
1745 1818
 			$airport_longitude = $row['longitude'];
1746 1819
 			$Common = new Common();
1747 1820
 			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
1748
-		} else return '';
1821
+		} else {
1822
+			return '';
1823
+		}
1749 1824
 	}
1750 1825
 	
1751 1826
 	/**
@@ -2021,7 +2096,9 @@  discard block
 block discarded – undo
2021 2096
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2022 2097
 		if (isset($row['icaotypecode'])) {
2023 2098
 			return $row['icaotypecode'];
2024
-		} else return '';
2099
+		} else {
2100
+			return '';
2101
+		}
2025 2102
 	}
2026 2103
 
2027 2104
 	/**
@@ -2042,7 +2119,9 @@  discard block
 block discarded – undo
2042 2119
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2043 2120
 		if (isset($row['operator_correct'])) {
2044 2121
 			return $row['operator_correct'];
2045
-		} else return $operator;
2122
+		} else {
2123
+			return $operator;
2124
+		}
2046 2125
 	}
2047 2126
 
2048 2127
 	/**
@@ -2055,7 +2134,9 @@  discard block
 block discarded – undo
2055 2134
 	public function getRouteInfo($callsign)
2056 2135
 	{
2057 2136
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2058
-                if ($callsign == '') return array();
2137
+                if ($callsign == '') {
2138
+                	return array();
2139
+                }
2059 2140
 		$query  = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2060 2141
 		
2061 2142
 		$sth = $this->db->prepare($query);
@@ -2064,7 +2145,9 @@  discard block
 block discarded – undo
2064 2145
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2065 2146
 		if (count($row) > 0) {
2066 2147
 			return $row;
2067
-		} else return array();
2148
+		} else {
2149
+			return array();
2150
+		}
2068 2151
 	}
2069 2152
 	
2070 2153
 	/**
@@ -2116,7 +2199,9 @@  discard block
 block discarded – undo
2116 2199
 			$sth->execute(array(':registration' => $registration));
2117 2200
 
2118 2201
 			return $sth->fetch(PDO::FETCH_ASSOC);
2119
-		} else return array();
2202
+		} else {
2203
+			return array();
2204
+		}
2120 2205
 	}
2121 2206
 	
2122 2207
   
@@ -2272,8 +2357,11 @@  discard block
 block discarded – undo
2272 2357
 		$query .= " ORDER BY spotter_output.source_name ASC";
2273 2358
 
2274 2359
 		$sth = $this->db->prepare($query);
2275
-		if (!empty($query_values)) $sth->execute($query_values);
2276
-		else $sth->execute();
2360
+		if (!empty($query_values)) {
2361
+			$sth->execute($query_values);
2362
+		} else {
2363
+			$sth->execute();
2364
+		}
2277 2365
 
2278 2366
 		$source_array = array();
2279 2367
 		$temp_array = array();
@@ -2604,7 +2692,9 @@  discard block
 block discarded – undo
2604 2692
 			date_default_timezone_set($globalTimezone);
2605 2693
 			$datetime = new DateTime();
2606 2694
 			$offset = $datetime->format('P');
2607
-		} else $offset = '+00:00';
2695
+		} else {
2696
+			$offset = '+00:00';
2697
+		}
2608 2698
 		if ($airport_icao == '') {
2609 2699
 			if ($globalDBdriver == 'mysql') {
2610 2700
 				$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -2636,7 +2726,9 @@  discard block
 block discarded – undo
2636 2726
 			date_default_timezone_set($globalTimezone);
2637 2727
 			$datetime = new DateTime();
2638 2728
 			$offset = $datetime->format('P');
2639
-		} else $offset = '+00:00';
2729
+		} else {
2730
+			$offset = '+00:00';
2731
+		}
2640 2732
 		if ($airport_icao == '') {
2641 2733
 			if ($globalDBdriver == 'mysql') {
2642 2734
 				$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -2679,7 +2771,9 @@  discard block
 block discarded – undo
2679 2771
 			date_default_timezone_set($globalTimezone);
2680 2772
 			$datetime = new DateTime();
2681 2773
 			$offset = $datetime->format('P');
2682
-		} else $offset = '+00:00';
2774
+		} else {
2775
+			$offset = '+00:00';
2776
+		}
2683 2777
 		if ($airport_icao == '') {
2684 2778
 			if ($globalDBdriver == 'mysql') {
2685 2779
 				$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -2713,7 +2807,9 @@  discard block
 block discarded – undo
2713 2807
 			date_default_timezone_set($globalTimezone);
2714 2808
 			$datetime = new DateTime();
2715 2809
 			$offset = $datetime->format('P');
2716
-		} else $offset = '+00:00';
2810
+		} else {
2811
+			$offset = '+00:00';
2812
+		}
2717 2813
 		if ($airport_icao == '') {
2718 2814
 			if ($globalDBdriver == 'mysql') {
2719 2815
 				$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -2761,7 +2857,9 @@  discard block
 block discarded – undo
2761 2857
 			date_default_timezone_set($globalTimezone);
2762 2858
 			$datetime = new DateTime();
2763 2859
 			$offset = $datetime->format('P');
2764
-		} else $offset = '+00:00';
2860
+		} else {
2861
+			$offset = '+00:00';
2862
+		}
2765 2863
 
2766 2864
 		if ($globalDBdriver == 'mysql') {
2767 2865
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
@@ -2883,7 +2981,9 @@  discard block
 block discarded – undo
2883 2981
 	*/	
2884 2982
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
2885 2983
 	{
2886
-		if ($groundspeed == '') $groundspeed = NULL;
2984
+		if ($groundspeed == '') {
2985
+			$groundspeed = NULL;
2986
+		}
2887 2987
 		$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id';
2888 2988
                 $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
2889 2989
 
@@ -2917,9 +3017,15 @@  discard block
 block discarded – undo
2917 3017
 		$Image = new Image($this->db);
2918 3018
 		$Common = new Common();
2919 3019
 		
2920
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
2921
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
2922
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
3020
+		if (!isset($globalIVAO)) {
3021
+			$globalIVAO = FALSE;
3022
+		}
3023
+		if (!isset($globalVATSIM)) {
3024
+			$globalVATSIM = FALSE;
3025
+		}
3026
+		if (!isset($globalphpVMS)) {
3027
+			$globalphpVMS = FALSE;
3028
+		}
2923 3029
 		date_default_timezone_set('UTC');
2924 3030
 		
2925 3031
 		//getting the registration
@@ -2932,13 +3038,17 @@  discard block
 block discarded – undo
2932 3038
 				if ($ModeS != '') {
2933 3039
 					$timeelapsed = microtime(true);
2934 3040
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS);
2935
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3041
+					if ($globalDebugTimeElapsed) {
3042
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3043
+					}
2936 3044
 				} else {
2937 3045
 					$myhex = explode('-',$flightaware_id);
2938 3046
 					if (count($myhex) > 0) {
2939 3047
 						$timeelapsed = microtime(true);
2940 3048
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0]);
2941
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3049
+						if ($globalDebugTimeElapsed) {
3050
+							echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3051
+						}
2942 3052
 					}
2943 3053
 				}
2944 3054
 			}
@@ -2967,15 +3077,21 @@  discard block
 block discarded – undo
2967 3077
 					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
2968 3078
 						$airline_array = $this->getAllAirlineInfo("NA");
2969 3079
 					}
2970
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3080
+					if ($globalDebugTimeElapsed) {
3081
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3082
+					}
2971 3083
 
2972 3084
 				} else {
2973 3085
 					$timeelapsed = microtime(true);
2974 3086
 					$airline_array = $this->getAllAirlineInfo("NA");
2975
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3087
+					if ($globalDebugTimeElapsed) {
3088
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3089
+					}
2976 3090
 				}
2977 3091
 			}
2978
-		} else $airline_array = array();
3092
+		} else {
3093
+			$airline_array = array();
3094
+		}
2979 3095
 		
2980 3096
 		//getting the aircraft information
2981 3097
 		if ($aircraft_icao != "")
@@ -2988,27 +3104,37 @@  discard block
 block discarded – undo
2988 3104
 				{
2989 3105
 					$timeelapsed = microtime(true);
2990 3106
 					$aircraft_array = $this->getAllAircraftInfo("NA");
2991
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3107
+					if ($globalDebugTimeElapsed) {
3108
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3109
+					}
2992 3110
 				} else {
2993 3111
 					$timeelapsed = microtime(true);
2994 3112
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
2995
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3113
+					if ($globalDebugTimeElapsed) {
3114
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3115
+					}
2996 3116
 				}
2997 3117
 			}
2998 3118
 		} else {
2999 3119
 			if ($ModeS != '') {
3000 3120
 				$timeelapsed = microtime(true);
3001 3121
 				$aircraft_icao = $this->getAllAircraftType($ModeS);
3002
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3122
+				if ($globalDebugTimeElapsed) {
3123
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3124
+				}
3003 3125
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3004 3126
 				{
3005 3127
 					$timeelapsed = microtime(true);
3006 3128
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3007
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3129
+					if ($globalDebugTimeElapsed) {
3130
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3131
+					}
3008 3132
 				} else {
3009 3133
 					$timeelapsed = microtime(true);
3010 3134
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3011
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3135
+					if ($globalDebugTimeElapsed) {
3136
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3137
+					}
3012 3138
 				}
3013 3139
 			}
3014 3140
 		}
@@ -3022,7 +3148,9 @@  discard block
 block discarded – undo
3022 3148
 			} else {
3023 3149
 				$timeelapsed = microtime(true);
3024 3150
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3025
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3151
+				if ($globalDebugTimeElapsed) {
3152
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3153
+				}
3026 3154
 			}
3027 3155
 		}
3028 3156
 		
@@ -3035,7 +3163,9 @@  discard block
 block discarded – undo
3035 3163
 			} else {
3036 3164
 				$timeelapsed = microtime(true);
3037 3165
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3038
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3166
+				if ($globalDebugTimeElapsed) {
3167
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3168
+				}
3039 3169
 			}
3040 3170
 		}
3041 3171
 
@@ -3070,7 +3200,9 @@  discard block
 block discarded – undo
3070 3200
 			{
3071 3201
 				return false;
3072 3202
 			}
3073
-		} else $altitude = 0;
3203
+		} else {
3204
+			$altitude = 0;
3205
+		}
3074 3206
 		
3075 3207
 		if ($heading != "")
3076 3208
 		{
@@ -3099,7 +3231,9 @@  discard block
 block discarded – undo
3099 3231
 		{
3100 3232
 			$timeelapsed = microtime(true);
3101 3233
 			$image_array = $Image->getSpotterImage($registration);
3102
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3234
+			if ($globalDebugTimeElapsed) {
3235
+				echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3236
+			}
3103 3237
 			if (!isset($image_array[0]['registration']))
3104 3238
 			{
3105 3239
 				//echo "Add image !!!! \n";
@@ -3107,14 +3241,21 @@  discard block
 block discarded – undo
3107 3241
 			}
3108 3242
 			$timeelapsed = microtime(true);
3109 3243
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3110
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3111
-			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
3244
+			if ($globalDebugTimeElapsed) {
3245
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3246
+			}
3247
+			if ($owner_info['owner'] != '') {
3248
+				$aircraft_owner = ucwords(strtolower($owner_info['owner']));
3249
+			}
3112 3250
 		}
3113 3251
     
3114 3252
 		if ($globalIVAO && $aircraft_icao != '')
3115 3253
 		{
3116
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3117
-            		else $airline_icao = '';
3254
+            		if (isset($airline_array[0]['icao'])) {
3255
+            			$airline_icao = $airline_array[0]['icao'];
3256
+            		} else {
3257
+            			$airline_icao = '';
3258
+            		}
3118 3259
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3119 3260
 			if (!isset($image_array[0]['registration']))
3120 3261
 			{
@@ -3159,12 +3300,24 @@  discard block
 block discarded – undo
3159 3300
                 {
3160 3301
                         $arrival_airport_array = $this->getAllAirportInfo('NA');
3161 3302
                 }
3162
-                if ($registration == '') $registration = 'NA';
3163
-                if ($squawk == '' || $Common->isInteger($squawk) == false) $squawk = NULL;
3164
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) == false) $verticalrate = NULL;
3165
-                if ($heading == '' || $Common->isInteger($heading) == false) $heading = 0;
3166
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) == false) $groundspeed = 0;
3167
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3303
+                if ($registration == '') {
3304
+                	$registration = 'NA';
3305
+                }
3306
+                if ($squawk == '' || $Common->isInteger($squawk) == false) {
3307
+                	$squawk = NULL;
3308
+                }
3309
+                if ($verticalrate == '' || $Common->isInteger($verticalrate) == false) {
3310
+                	$verticalrate = NULL;
3311
+                }
3312
+                if ($heading == '' || $Common->isInteger($heading) == false) {
3313
+                	$heading = 0;
3314
+                }
3315
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) == false) {
3316
+                	$groundspeed = 0;
3317
+                }
3318
+                if (!isset($aircraft_owner)) {
3319
+                	$aircraft_owner = NULL;
3320
+                }
3168 3321
                 $query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3169 3322
                 VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)";
3170 3323
 
@@ -3175,9 +3328,13 @@  discard block
 block discarded – undo
3175 3328
 		if ($airline_type == '') {
3176 3329
 			$timeelapsed = microtime(true);
3177 3330
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3178
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3331
+			if ($globalDebugTimeElapsed) {
3332
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3333
+			}
3334
+		}
3335
+		if ($airline_type == null) {
3336
+			$airline_type = '';
3179 3337
 		}
3180
-		if ($airline_type == null) $airline_type = '';
3181 3338
                 $aircraft_type = $aircraft_array[0]['type'];
3182 3339
                 $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3183 3340
                 $departure_airport_name = $departure_airport_array[0]['name'];
@@ -3313,7 +3470,9 @@  discard block
 block discarded – undo
3313 3470
 			}
3314 3471
 		}
3315 3472
         	$query .= "GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
3316
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3473
+		if ($limit) {
3474
+			$query .= " LIMIT 10 OFFSET 0";
3475
+		}
3317 3476
       
3318 3477
 		
3319 3478
 		$sth = $this->db->prepare($query);
@@ -3362,7 +3521,9 @@  discard block
 block discarded – undo
3362 3521
 			}
3363 3522
 		}
3364 3523
 		$query .= "GROUP BY spotter_output.pilot_id,spotter_output.pilot_name ORDER BY pilot_count DESC";
3365
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3524
+		if ($limit) {
3525
+			$query .= " LIMIT 10 OFFSET 0";
3526
+		}
3366 3527
       
3367 3528
 		
3368 3529
 		$sth = $this->db->prepare($query);
@@ -3394,7 +3555,9 @@  discard block
 block discarded – undo
3394 3555
 		 			FROM spotter_output
3395 3556
 					WHERE spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
3396 3557
 		$query .= "GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
3397
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3558
+		if ($limit) {
3559
+			$query .= " LIMIT 10 OFFSET 0";
3560
+		}
3398 3561
       
3399 3562
 		
3400 3563
 		$sth = $this->db->prepare($query);
@@ -3643,7 +3806,9 @@  discard block
 block discarded – undo
3643 3806
 			date_default_timezone_set($globalTimezone);
3644 3807
 			$datetime = new DateTime($date);
3645 3808
 			$offset = $datetime->format('P');
3646
-		} else $offset = '+00:00';
3809
+		} else {
3810
+			$offset = '+00:00';
3811
+		}
3647 3812
 
3648 3813
 		if ($globalDBdriver == 'mysql') {
3649 3814
 			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
@@ -3692,7 +3857,9 @@  discard block
 block discarded – undo
3692 3857
 			date_default_timezone_set($globalTimezone);
3693 3858
 			$datetime = new DateTime($date);
3694 3859
 			$offset = $datetime->format('P');
3695
-		} else $offset = '+00:00';
3860
+		} else {
3861
+			$offset = '+00:00';
3862
+		}
3696 3863
 		
3697 3864
 		if ($globalDBdriver == 'mysql') {
3698 3865
 			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
@@ -3915,7 +4082,9 @@  discard block
 block discarded – undo
3915 4082
 					WHERE spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' 
3916 4083
 					GROUP BY spotter_output.airline_country
3917 4084
 					ORDER BY airline_country_count DESC";
3918
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4085
+		if ($limit) {
4086
+			$query .= " LIMIT 10 OFFSET 0";
4087
+		}
3919 4088
       
3920 4089
 		$sth = $this->db->prepare($query);
3921 4090
 		$sth->execute();
@@ -3956,9 +4125,13 @@  discard block
 block discarded – undo
3956 4125
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
3957 4126
 			}
3958 4127
 		}
3959
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
4128
+                if ($sincedate != '') {
4129
+                	$query .= "AND date > '".$sincedate."' ";
4130
+                }
3960 4131
 		$query .= "GROUP BY c.name ORDER BY nb DESC";
3961
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4132
+		if ($limit) {
4133
+			$query .= " LIMIT 10 OFFSET 0";
4134
+		}
3962 4135
       
3963 4136
 		
3964 4137
 		$sth = $this->db->prepare($query);
@@ -4009,7 +4182,9 @@  discard block
 block discarded – undo
4009 4182
                 //if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
4010 4183
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
4011 4184
                 $query .= "GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name ORDER BY aircraft_icao_count DESC";
4012
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4185
+		if ($limit) {
4186
+			$query .= " LIMIT 10 OFFSET 0";
4187
+		}
4013 4188
       
4014 4189
 		
4015 4190
 		$sth = $this->db->prepare($query);
@@ -4063,7 +4238,9 @@  discard block
 block discarded – undo
4063 4238
 			if($row['registration'] != "")
4064 4239
 			{
4065 4240
 				$image_array = $Image->getSpotterImage($row['registration']);
4066
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4241
+				if (isset($image_array[0]['image_thumbnail'])) {
4242
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4243
+				}
4067 4244
 			}
4068 4245
 			$emp_array['registration_count'] = $row['registration_count'];
4069 4246
 
@@ -4139,7 +4316,9 @@  discard block
 block discarded – undo
4139 4316
 			if($row['registration'] != "")
4140 4317
 			{
4141 4318
 				$image_array = $Image->getSpotterImage($row['registration']);
4142
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4319
+				if (isset($image_array[0]['image_thumbnail'])) {
4320
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4321
+				}
4143 4322
 			}
4144 4323
 			$temp_array['registration_count'] = $row['registration_count'];
4145 4324
 
@@ -4392,7 +4571,9 @@  discard block
 block discarded – undo
4392 4571
 			date_default_timezone_set($globalTimezone);
4393 4572
 			$datetime = new DateTime($date);
4394 4573
 			$offset = $datetime->format('P');
4395
-		} else $offset = '+00:00';
4574
+		} else {
4575
+			$offset = '+00:00';
4576
+		}
4396 4577
 
4397 4578
 		if ($globalDBdriver == 'mysql') {
4398 4579
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
@@ -4440,7 +4621,9 @@  discard block
 block discarded – undo
4440 4621
 			date_default_timezone_set($globalTimezone);
4441 4622
 			$datetime = new DateTime($date);
4442 4623
 			$offset = $datetime->format('P');
4443
-		} else $offset = '+00:00';
4624
+		} else {
4625
+			$offset = '+00:00';
4626
+		}
4444 4627
 
4445 4628
 		if ($globalDBdriver == 'mysql') {
4446 4629
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
@@ -4495,7 +4678,9 @@  discard block
 block discarded – undo
4495 4678
 			date_default_timezone_set($globalTimezone);
4496 4679
 			$datetime = new DateTime($date);
4497 4680
 			$offset = $datetime->format('P');
4498
-		} else $offset = '+00:00';
4681
+		} else {
4682
+			$offset = '+00:00';
4683
+		}
4499 4684
 
4500 4685
 		if ($globalDBdriver == 'mysql') {
4501 4686
 			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
@@ -4596,8 +4781,11 @@  discard block
 block discarded – undo
4596 4781
 			if($row['registration'] != "")
4597 4782
 			{
4598 4783
 				$image_array = $Image->getSpotterImage($row['registration']);
4599
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4600
-				else $temp_array['image_thumbnail'] = '';
4784
+				if (isset($image_array[0]['image_thumbnail'])) {
4785
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4786
+				} else {
4787
+					$temp_array['image_thumbnail'] = '';
4788
+				}
4601 4789
 			}
4602 4790
 			$temp_array['registration_count'] = $row['registration_count'];
4603 4791
 			$aircraft_array[] = $temp_array;
@@ -4714,7 +4902,9 @@  discard block
 block discarded – undo
4714 4902
 			if($row['registration'] != "")
4715 4903
 			{
4716 4904
 				$image_array = $Image->getSpotterImage($row['registration']);
4717
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4905
+				if (isset($image_array[0]['image_thumbnail'])) {
4906
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4907
+				}
4718 4908
 			}
4719 4909
 			$temp_array['registration_count'] = $row['registration_count'];
4720 4910
           
@@ -4833,7 +5023,9 @@  discard block
 block discarded – undo
4833 5023
 			if($row['registration'] != "")
4834 5024
 			{
4835 5025
 				$image_array = $Image->getSpotterImage($row['registration']);
4836
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5026
+				if (isset($image_array[0]['image_thumbnail'])) {
5027
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5028
+				}
4837 5029
 			}
4838 5030
 			$temp_array['registration_count'] = $row['registration_count'];
4839 5031
           
@@ -4946,7 +5138,9 @@  discard block
 block discarded – undo
4946 5138
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
4947 5139
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
4948 5140
                 $query .= "GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
4949
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5141
+		if ($limit) {
5142
+			$query .= " LIMIT 10 OFFSET 0";
5143
+		}
4950 5144
 		
4951 5145
 		$sth = $this->db->prepare($query);
4952 5146
 		$sth->execute();
@@ -4965,7 +5159,9 @@  discard block
 block discarded – undo
4965 5159
 			if($row['registration'] != "")
4966 5160
 			{
4967 5161
 				$image_array = $Image->getSpotterImage($row['registration']);
4968
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5162
+				if (isset($image_array[0]['image_thumbnail'])) {
5163
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5164
+				}
4969 5165
 			}
4970 5166
           
4971 5167
 			$aircraft_array[] = $temp_array;
@@ -5008,7 +5204,9 @@  discard block
 block discarded – undo
5008 5204
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5009 5205
                 $query .= "GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5010 5206
 				ORDER BY airport_departure_icao_count DESC";
5011
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5207
+		if ($limit) {
5208
+			$query .= " LIMIT 10 OFFSET 0";
5209
+		}
5012 5210
       
5013 5211
 		$sth = $this->db->prepare($query);
5014 5212
 		$sth->execute();
@@ -5060,7 +5258,9 @@  discard block
 block discarded – undo
5060 5258
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5061 5259
                 $query .= "GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
5062 5260
 				ORDER BY airport_departure_icao_count DESC";
5063
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5261
+		if ($limit) {
5262
+			$query .= " LIMIT 10 OFFSET 0";
5263
+		}
5064 5264
       
5065 5265
 		$sth = $this->db->prepare($query);
5066 5266
 		$sth->execute();
@@ -5466,7 +5666,9 @@  discard block
 block discarded – undo
5466 5666
 			date_default_timezone_set($globalTimezone);
5467 5667
 			$datetime = new DateTime($date);
5468 5668
 			$offset = $datetime->format('P');
5469
-		} else $offset = '+00:00';
5669
+		} else {
5670
+			$offset = '+00:00';
5671
+		}
5470 5672
 
5471 5673
 		if ($globalDBdriver == 'mysql') {
5472 5674
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
@@ -5517,7 +5719,9 @@  discard block
 block discarded – undo
5517 5719
 			date_default_timezone_set($globalTimezone);
5518 5720
 			$datetime = new DateTime($date);
5519 5721
 			$offset = $datetime->format('P');
5520
-		} else $offset = '+00:00';
5722
+		} else {
5723
+			$offset = '+00:00';
5724
+		}
5521 5725
 
5522 5726
 		if ($globalDBdriver == 'mysql') {
5523 5727
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
@@ -5735,7 +5939,9 @@  discard block
 block discarded – undo
5735 5939
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5736 5940
                 $query .= "GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
5737 5941
 					ORDER BY airport_arrival_icao_count DESC";
5738
-		if ($limit) $query .= " LIMIT 10";
5942
+		if ($limit) {
5943
+			$query .= " LIMIT 10";
5944
+		}
5739 5945
       
5740 5946
 		
5741 5947
 		$sth = $this->db->prepare($query);
@@ -5755,7 +5961,9 @@  discard block
 block discarded – undo
5755 5961
 			if ($icaoaskey) {
5756 5962
 				$icao = $row['arrival_airport_icao'];
5757 5963
 				$airport_array[$icao] = $temp_array;
5758
-			} else $airport_array[] = $temp_array;
5964
+			} else {
5965
+				$airport_array[] = $temp_array;
5966
+			}
5759 5967
 		}
5760 5968
 
5761 5969
 		return $airport_array;
@@ -5797,7 +6005,9 @@  discard block
 block discarded – undo
5797 6005
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5798 6006
                 $query .= "GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
5799 6007
 					ORDER BY airport_arrival_icao_count DESC";
5800
-		if ($limit) $query .= " LIMIT 10";
6008
+		if ($limit) {
6009
+			$query .= " LIMIT 10";
6010
+		}
5801 6011
       
5802 6012
 		
5803 6013
 		$sth = $this->db->prepare($query);
@@ -5817,7 +6027,9 @@  discard block
 block discarded – undo
5817 6027
 			if ($icaoaskey) {
5818 6028
 				$icao = $row['arrival_airport_icao'];
5819 6029
 				$airport_array[$icao] = $temp_array;
5820
-			} else $airport_array[] = $temp_array;
6030
+			} else {
6031
+				$airport_array[] = $temp_array;
6032
+			}
5821 6033
 		}
5822 6034
 
5823 6035
 		return $airport_array;
@@ -6208,7 +6420,9 @@  discard block
 block discarded – undo
6208 6420
 			date_default_timezone_set($globalTimezone);
6209 6421
 			$datetime = new DateTime($date);
6210 6422
 			$offset = $datetime->format('P');
6211
-		} else $offset = '+00:00';
6423
+		} else {
6424
+			$offset = '+00:00';
6425
+		}
6212 6426
 
6213 6427
 		if ($globalDBdriver == 'mysql') {
6214 6428
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
@@ -6259,7 +6473,9 @@  discard block
 block discarded – undo
6259 6473
 			date_default_timezone_set($globalTimezone);
6260 6474
 			$datetime = new DateTime($date);
6261 6475
 			$offset = $datetime->format('P');
6262
-		} else $offset = '+00:00';
6476
+		} else {
6477
+			$offset = '+00:00';
6478
+		}
6263 6479
 
6264 6480
 		if ($globalDBdriver == 'mysql') {
6265 6481
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
@@ -6488,7 +6704,9 @@  discard block
 block discarded – undo
6488 6704
                     WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA' 
6489 6705
                     GROUP BY spotter_output.arrival_airport_country
6490 6706
 					ORDER BY airport_arrival_country_count DESC";
6491
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6707
+		if ($limit) {
6708
+			$query .= " LIMIT 10 OFFSET 0";
6709
+		}
6492 6710
       
6493 6711
 		
6494 6712
 		$sth = $this->db->prepare($query);
@@ -6783,7 +7001,9 @@  discard block
 block discarded – undo
6783 7001
 			date_default_timezone_set($globalTimezone);
6784 7002
 			$datetime = new DateTime($date);
6785 7003
 			$offset = $datetime->format('P');
6786
-		} else $offset = '+00:00';
7004
+		} else {
7005
+			$offset = '+00:00';
7006
+		}
6787 7007
 		
6788 7008
 		if ($globalDBdriver == 'mysql') {
6789 7009
 			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
@@ -6966,15 +7186,23 @@  discard block
 block discarded – undo
6966 7186
                     FROM spotter_output
6967 7187
                     WHERE spotter_output.ident <> ''  ";
6968 7188
 		 if ($olderthanmonths > 0) {
6969
-			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6970
-			else $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
7189
+			if ($globalDBdriver == 'mysql') {
7190
+				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7191
+			} else {
7192
+				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
7193
+			}
6971 7194
 		}
6972 7195
 		if ($sincedate != '') {
6973
-			if ($globalDBdriver == 'mysql') $query .= "AND date > '".$sincedate."' ";
6974
-			else $query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP) ";
7196
+			if ($globalDBdriver == 'mysql') {
7197
+				$query .= "AND date > '".$sincedate."' ";
7198
+			} else {
7199
+				$query .= "AND date > CAST('".$sincedate."' AS TIMESTAMP) ";
7200
+			}
6975 7201
 		}
6976 7202
 		$query .= "GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
6977
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7203
+		if ($limit) {
7204
+			$query .= " LIMIT 10 OFFSET 0";
7205
+		}
6978 7206
       		
6979 7207
 		$sth = $this->db->prepare($query);
6980 7208
 		$sth->execute();
@@ -7011,7 +7239,9 @@  discard block
 block discarded – undo
7011 7239
 			date_default_timezone_set($globalTimezone);
7012 7240
 			$datetime = new DateTime();
7013 7241
 			$offset = $datetime->format('P');
7014
-		} else $offset = '+00:00';
7242
+		} else {
7243
+			$offset = '+00:00';
7244
+		}
7015 7245
 
7016 7246
 		if ($globalDBdriver == 'mysql') {
7017 7247
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7060,7 +7290,9 @@  discard block
 block discarded – undo
7060 7290
 			date_default_timezone_set($globalTimezone);
7061 7291
 			$datetime = new DateTime();
7062 7292
 			$offset = $datetime->format('P');
7063
-		} else $offset = '+00:00';
7293
+		} else {
7294
+			$offset = '+00:00';
7295
+		}
7064 7296
 		
7065 7297
 		if ($globalDBdriver == 'mysql') {
7066 7298
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7108,7 +7340,9 @@  discard block
 block discarded – undo
7108 7340
 			date_default_timezone_set($globalTimezone);
7109 7341
 			$datetime = new DateTime();
7110 7342
 			$offset = $datetime->format('P');
7111
-		} else $offset = '+00:00';
7343
+		} else {
7344
+			$offset = '+00:00';
7345
+		}
7112 7346
 		
7113 7347
 		if ($globalDBdriver == 'mysql') {
7114 7348
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7156,7 +7390,9 @@  discard block
 block discarded – undo
7156 7390
 			date_default_timezone_set($globalTimezone);
7157 7391
 			$datetime = new DateTime();
7158 7392
 			$offset = $datetime->format('P');
7159
-		} else $offset = '+00:00';
7393
+		} else {
7394
+			$offset = '+00:00';
7395
+		}
7160 7396
 
7161 7397
 		if ($globalDBdriver == 'mysql') {
7162 7398
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -7202,7 +7438,9 @@  discard block
 block discarded – undo
7202 7438
 			date_default_timezone_set($globalTimezone);
7203 7439
 			$datetime = new DateTime();
7204 7440
 			$offset = $datetime->format('P');
7205
-		} else $offset = '+00:00';
7441
+		} else {
7442
+			$offset = '+00:00';
7443
+		}
7206 7444
 
7207 7445
 		if ($globalDBdriver == 'mysql') {
7208 7446
 			$query  = "SELECT YEAR(CONVERT_TZ(s.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(s.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -7249,7 +7487,9 @@  discard block
 block discarded – undo
7249 7487
 			date_default_timezone_set($globalTimezone);
7250 7488
 			$datetime = new DateTime();
7251 7489
 			$offset = $datetime->format('P');
7252
-		} else $offset = '+00:00';
7490
+		} else {
7491
+			$offset = '+00:00';
7492
+		}
7253 7493
 
7254 7494
 		if ($globalDBdriver == 'mysql') {
7255 7495
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
@@ -7296,7 +7536,9 @@  discard block
 block discarded – undo
7296 7536
 			date_default_timezone_set($globalTimezone);
7297 7537
 			$datetime = new DateTime();
7298 7538
 			$offset = $datetime->format('P');
7299
-		} else $offset = '+00:00';
7539
+		} else {
7540
+			$offset = '+00:00';
7541
+		}
7300 7542
 
7301 7543
 		if ($globalDBdriver == 'mysql') {
7302 7544
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
@@ -7344,7 +7586,9 @@  discard block
 block discarded – undo
7344 7586
 			date_default_timezone_set($globalTimezone);
7345 7587
 			$datetime = new DateTime();
7346 7588
 			$offset = $datetime->format('P');
7347
-		} else $offset = '+00:00';
7589
+		} else {
7590
+			$offset = '+00:00';
7591
+		}
7348 7592
 
7349 7593
 		if ($globalDBdriver == 'mysql') {
7350 7594
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
@@ -7391,7 +7635,9 @@  discard block
 block discarded – undo
7391 7635
 			date_default_timezone_set($globalTimezone);
7392 7636
 			$datetime = new DateTime();
7393 7637
 			$offset = $datetime->format('P');
7394
-		} else $offset = '+00:00';
7638
+		} else {
7639
+			$offset = '+00:00';
7640
+		}
7395 7641
 
7396 7642
 		if ($globalDBdriver == 'mysql') {
7397 7643
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
@@ -7439,7 +7685,9 @@  discard block
 block discarded – undo
7439 7685
 			date_default_timezone_set($globalTimezone);
7440 7686
 			$datetime = new DateTime();
7441 7687
 			$offset = $datetime->format('P');
7442
-		} else $offset = '+00:00';
7688
+		} else {
7689
+			$offset = '+00:00';
7690
+		}
7443 7691
 
7444 7692
 		if ($globalDBdriver == 'mysql') {
7445 7693
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
@@ -7488,7 +7736,9 @@  discard block
 block discarded – undo
7488 7736
 			date_default_timezone_set($globalTimezone);
7489 7737
 			$datetime = new DateTime();
7490 7738
 			$offset = $datetime->format('P');
7491
-		} else $offset = '+00:00';
7739
+		} else {
7740
+			$offset = '+00:00';
7741
+		}
7492 7742
 		
7493 7743
 		if ($globalDBdriver == 'mysql') {
7494 7744
 			$query  = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -7541,7 +7791,9 @@  discard block
 block discarded – undo
7541 7791
 			date_default_timezone_set($globalTimezone);
7542 7792
 			$datetime = new DateTime();
7543 7793
 			$offset = $datetime->format('P');
7544
-		} else $offset = '+00:00';
7794
+		} else {
7795
+			$offset = '+00:00';
7796
+		}
7545 7797
 
7546 7798
 		if ($orderby == "hour")
7547 7799
 		{
@@ -7604,7 +7856,9 @@  discard block
 block discarded – undo
7604 7856
 			date_default_timezone_set($globalTimezone);
7605 7857
 			$datetime = new DateTime();
7606 7858
 			$offset = $datetime->format('P');
7607
-		} else $offset = '+00:00';
7859
+		} else {
7860
+			$offset = '+00:00';
7861
+		}
7608 7862
 
7609 7863
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
7610 7864
 
@@ -7656,7 +7910,9 @@  discard block
 block discarded – undo
7656 7910
 			date_default_timezone_set($globalTimezone);
7657 7911
 			$datetime = new DateTime();
7658 7912
 			$offset = $datetime->format('P');
7659
-		} else $offset = '+00:00';
7913
+		} else {
7914
+			$offset = '+00:00';
7915
+		}
7660 7916
 
7661 7917
 		if ($globalDBdriver == 'mysql') {
7662 7918
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -7704,7 +7960,9 @@  discard block
 block discarded – undo
7704 7960
 			date_default_timezone_set($globalTimezone);
7705 7961
 			$datetime = new DateTime();
7706 7962
 			$offset = $datetime->format('P');
7707
-		} else $offset = '+00:00';
7963
+		} else {
7964
+			$offset = '+00:00';
7965
+		}
7708 7966
 
7709 7967
 		if ($globalDBdriver == 'mysql') {
7710 7968
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -7752,7 +8010,9 @@  discard block
 block discarded – undo
7752 8010
 			date_default_timezone_set($globalTimezone);
7753 8011
 			$datetime = new DateTime();
7754 8012
 			$offset = $datetime->format('P');
7755
-		} else $offset = '+00:00';
8013
+		} else {
8014
+			$offset = '+00:00';
8015
+		}
7756 8016
 
7757 8017
 		if ($globalDBdriver == 'mysql') {
7758 8018
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -7801,7 +8061,9 @@  discard block
 block discarded – undo
7801 8061
 			date_default_timezone_set($globalTimezone);
7802 8062
 			$datetime = new DateTime();
7803 8063
 			$offset = $datetime->format('P');
7804
-		} else $offset = '+00:00';
8064
+		} else {
8065
+			$offset = '+00:00';
8066
+		}
7805 8067
 
7806 8068
 		if ($globalDBdriver == 'mysql') {
7807 8069
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -7850,7 +8112,9 @@  discard block
 block discarded – undo
7850 8112
 			date_default_timezone_set($globalTimezone);
7851 8113
 			$datetime = new DateTime($date);
7852 8114
 			$offset = $datetime->format('P');
7853
-		} else $offset = '+00:00';
8115
+		} else {
8116
+			$offset = '+00:00';
8117
+		}
7854 8118
 
7855 8119
 		if ($globalDBdriver == 'mysql') {
7856 8120
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -7899,7 +8163,9 @@  discard block
 block discarded – undo
7899 8163
 			date_default_timezone_set($globalTimezone);
7900 8164
 			$datetime = new DateTime();
7901 8165
 			$offset = $datetime->format('P');
7902
-		} else $offset = '+00:00';
8166
+		} else {
8167
+			$offset = '+00:00';
8168
+		}
7903 8169
 
7904 8170
 		if ($globalDBdriver == 'mysql') {
7905 8171
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -7950,7 +8216,9 @@  discard block
 block discarded – undo
7950 8216
 			date_default_timezone_set($globalTimezone);
7951 8217
 			$datetime = new DateTime();
7952 8218
 			$offset = $datetime->format('P');
7953
-		} else $offset = '+00:00';
8219
+		} else {
8220
+			$offset = '+00:00';
8221
+		}
7954 8222
 
7955 8223
 		if ($globalDBdriver == 'mysql') {
7956 8224
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -7998,7 +8266,9 @@  discard block
 block discarded – undo
7998 8266
 			date_default_timezone_set($globalTimezone);
7999 8267
 			$datetime = new DateTime();
8000 8268
 			$offset = $datetime->format('P');
8001
-		} else $offset = '+00:00';
8269
+		} else {
8270
+			$offset = '+00:00';
8271
+		}
8002 8272
 
8003 8273
 		if ($globalDBdriver == 'mysql') {
8004 8274
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8174,7 +8444,9 @@  discard block
 block discarded – undo
8174 8444
 			date_default_timezone_set($globalTimezone);
8175 8445
 			$datetime = new DateTime();
8176 8446
 			$offset = $datetime->format('P');
8177
-		} else $offset = '+00:00';
8447
+		} else {
8448
+			$offset = '+00:00';
8449
+		}
8178 8450
 
8179 8451
 		if ($globalDBdriver == 'mysql') {
8180 8452
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8349,7 +8621,9 @@  discard block
 block discarded – undo
8349 8621
 	*/
8350 8622
 	public function parseDirection($direction = 0)
8351 8623
 	{
8352
-		if ($direction == '') $direction = 0;
8624
+		if ($direction == '') {
8625
+			$direction = 0;
8626
+		}
8353 8627
 		$direction_array = array();
8354 8628
 		$temp_array = array();
8355 8629
 
@@ -8479,7 +8753,9 @@  discard block
 block discarded – undo
8479 8753
 		if (count($row) > 0) {
8480 8754
 		    //return $row['Registration'];
8481 8755
 		    return $row['registration'];
8482
-		} else return '';
8756
+		} else {
8757
+			return '';
8758
+		}
8483 8759
 	
8484 8760
 	}
8485 8761
 
@@ -8502,9 +8778,14 @@  discard block
 block discarded – undo
8502 8778
     
8503 8779
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
8504 8780
 		if (count($row) > 0) {
8505
-		    if ($row['type_flight'] == null) return '';
8506
-		    else return $row['type_flight'];
8507
-		} else return '';
8781
+		    if ($row['type_flight'] == null) {
8782
+		    	return '';
8783
+		    } else {
8784
+		    	return $row['type_flight'];
8785
+		    }
8786
+		} else {
8787
+			return '';
8788
+		}
8508 8789
 	
8509 8790
 	}
8510 8791
 
@@ -8539,9 +8820,13 @@  discard block
 block discarded – undo
8539 8820
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
8540 8821
 			if (count($row) > 0) {
8541 8822
 				return $row;
8542
-			} else return '';
8823
+			} else {
8824
+				return '';
8825
+			}
8543 8826
 		} catch (PDOException $e) {
8544
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
8827
+			if (isset($globalDebug) && $globalDebug) {
8828
+				echo 'Error : '.$e->getMessage()."\n";
8829
+			}
8545 8830
 			return '';
8546 8831
 		}
8547 8832
 	
@@ -8693,7 +8978,9 @@  discard block
 block discarded – undo
8693 8978
 	{
8694 8979
 		global $globalBitlyAccessToken;
8695 8980
 		
8696
-		if ($globalBitlyAccessToken == '') return $url;
8981
+		if ($globalBitlyAccessToken == '') {
8982
+			return $url;
8983
+		}
8697 8984
         
8698 8985
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
8699 8986
 		
@@ -8857,7 +9144,9 @@  discard block
 block discarded – undo
8857 9144
 		
8858 9145
 
8859 9146
 		// routes
8860
-		if ($globalDebug) print "Routes...\n";
9147
+		if ($globalDebug) {
9148
+			print "Routes...\n";
9149
+		}
8861 9150
 		if ($globalDBdriver == 'mysql') {
8862 9151
 			$query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
8863 9152
 		} elseif ($globalDBdriver == 'pgsql') {
@@ -8876,7 +9165,9 @@  discard block
 block discarded – undo
8876 9165
 			}
8877 9166
 		}
8878 9167
 		
8879
-		if ($globalDebug) print "Airlines...\n";
9168
+		if ($globalDebug) {
9169
+			print "Airlines...\n";
9170
+		}
8880 9171
 		//airlines
8881 9172
 		if ($globalDBdriver == 'mysql') {
8882 9173
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
@@ -8898,13 +9189,17 @@  discard block
 block discarded – undo
8898 9189
 			}
8899 9190
 		}
8900 9191
 
8901
-		if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n";
9192
+		if ($globalDebug) {
9193
+			print "Remove Duplicate in aircraft_modes...\n";
9194
+		}
8902 9195
 		//duplicate modes
8903 9196
 		$query = "DELETE aircraft_modes FROM aircraft_modes LEFT OUTER JOIN (SELECT max(`AircraftID`) as `AircraftID`,`ModeS` FROM `aircraft_modes` group by ModeS) as KeepRows ON aircraft_modes.AircraftID = KeepRows.AircraftID WHERE KeepRows.AircraftID IS NULL";
8904 9197
 		$sth = $this->db->prepare($query);
8905 9198
 		$sth->execute();
8906 9199
 		
8907
-		if ($globalDebug) print "Aircraft...\n";
9200
+		if ($globalDebug) {
9201
+			print "Aircraft...\n";
9202
+		}
8908 9203
 		//aircraft
8909 9204
 		if ($globalDBdriver == 'mysql') {
8910 9205
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -8947,26 +9242,38 @@  discard block
 block discarded – undo
8947 9242
 				 if (isset($closestAirports[0])) {
8948 9243
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
8949 9244
 						$airport_icao = $closestAirports[0]['icao'];
8950
-						if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
9245
+						if ($globalDebug) {
9246
+							echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
9247
+						}
8951 9248
 					} elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') {
8952 9249
 						foreach ($closestAirports as $airport) {
8953 9250
 							if ($row['arrival_airport_icao'] == $airport['icao']) {
8954 9251
 								$airport_icao = $airport['icao'];
8955
-								if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
9252
+								if ($globalDebug) {
9253
+									echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
9254
+								}
8956 9255
 								break;
8957 9256
 							}
8958 9257
 						}
8959 9258
 					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
8960 9259
 						$airport_icao = $closestAirports[0]['icao'];
8961
-						if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
9260
+						if ($globalDebug) {
9261
+							echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
9262
+						}
8962 9263
 					} else {
8963
-						if ($globalDebug) echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
9264
+						if ($globalDebug) {
9265
+							echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
9266
+						}
8964 9267
 					}
8965 9268
 				} else {
8966
-					if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
9269
+					if ($globalDebug) {
9270
+						echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
9271
+					}
8967 9272
 				}
8968 9273
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
8969
-					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
9274
+					if ($globalDebug) {
9275
+						echo "Updating airport to ".$airport_icao."...\n";
9276
+					}
8970 9277
 					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
8971 9278
 					$sthu = $this->db->prepare($update_query);
8972 9279
 					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
Please login to merge, or discard this patch.
require/class.SpotterImport.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -40,6 +40,10 @@
 block discarded – undo
40 40
 	}
41 41
     }
42 42
 
43
+    /**
44
+     * @param string $id
45
+     * @param string $ident
46
+     */
43 47
     function get_Schedule($id,$ident) {
44 48
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 49
 	// Get schedule here, so it's done only one time
Please login to merge, or discard this patch.
Indentation   +344 added lines, -344 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 
11 11
 class SpotterImport {
12
-    private $all_flights = array();
13
-    private $last_delete_hourly = '';
14
-    private $last_delete = '';
15
-    private $stats = array();
16
-    private $tmd = 0;
17
-    private $source_locatioon = array();
18
-    public $db = null;
19
-    public $nb = 0;
20
-
21
-    function __construct($dbc = null) {
12
+	private $all_flights = array();
13
+	private $last_delete_hourly = '';
14
+	private $last_delete = '';
15
+	private $stats = array();
16
+	private $tmd = 0;
17
+	private $source_locatioon = array();
18
+	public $db = null;
19
+	public $nb = 0;
20
+
21
+	function __construct($dbc = null) {
22 22
 	global $globalBeta;
23 23
 	$Connection = new Connection($dbc);
24 24
 	$this->db = $Connection->db;
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	$currentdate = date('Y-m-d');
30 30
 	$sourcestat = $Stats->getStatsSource($currentdate);
31 31
 	if (!empty($sourcestat)) {
32
-	    foreach($sourcestat as $srcst) {
33
-	    	$type = $srcst['stats_type'];
32
+		foreach($sourcestat as $srcst) {
33
+			$type = $srcst['stats_type'];
34 34
 		if ($type == 'polar' || $type == 'hist') {
35
-		    $source = $srcst['source_name'];
36
-		    $data = $srcst['source_data'];
37
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
38
-	        }
39
-	    }
35
+			$source = $srcst['source_name'];
36
+			$data = $srcst['source_data'];
37
+			$this->stats[$currentdate][$source][$type] = json_decode($data,true);
38
+			}
39
+		}
40
+	}
40 41
 	}
41
-    }
42 42
 
43
-    function get_Schedule($id,$ident) {
43
+	function get_Schedule($id,$ident) {
44 44
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 45
 	// Get schedule here, so it's done only one time
46 46
 	
@@ -58,35 +58,35 @@  discard block
 block discarded – undo
58 58
 	$Translation = new Translation($dbc);
59 59
 	$operator = $Spotter->getOperator($ident);
60 60
 	if ($Schedule->checkSchedule($operator) == 0) {
61
-	    $operator = $Translation->checkTranslation($ident);
62
-	    if ($Schedule->checkSchedule($operator) == 0) {
61
+		$operator = $Translation->checkTranslation($ident);
62
+		if ($Schedule->checkSchedule($operator) == 0) {
63 63
 		$schedule = $Schedule->fetchSchedule($operator);
64 64
 		if (count($schedule) > 0) {
65
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
66
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
67
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
68
-		    // FIXME : Check if route schedule = route from DB
69
-		    if ($schedule['DepartureAirportIATA'] != '') {
65
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
66
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
67
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
68
+			// FIXME : Check if route schedule = route from DB
69
+			if ($schedule['DepartureAirportIATA'] != '') {
70 70
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
71
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
72
-			    if ($airport_icao != '') {
71
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
72
+				if ($airport_icao != '') {
73 73
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
74 74
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
75
-			    }
75
+				}
76
+			}
76 77
 			}
77
-		    }
78
-		    if ($schedule['ArrivalAirportIATA'] != '') {
78
+			if ($schedule['ArrivalAirportIATA'] != '') {
79 79
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
80
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
81
-			    if ($airport_icao != '') {
80
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
81
+				if ($airport_icao != '') {
82 82
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
83 83
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
84
-			    }
84
+				}
85
+			}
85 86
 			}
86
-		    }
87
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
87
+			$Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
88
+		}
88 89
 		}
89
-	    }
90 90
 	}
91 91
 	// close connection, at least one way will work ?
92 92
        
@@ -104,91 +104,91 @@  discard block
 block discarded – undo
104 104
 	}
105 105
 	  */
106 106
 	}
107
-    }
107
+	}
108 108
 
109
-    public function checkAll() {
109
+	public function checkAll() {
110 110
 	global $globalDebug;
111 111
 	if ($globalDebug) echo "Update last seen flights data...\n";
112 112
 	foreach ($this->all_flights as $key => $flight) {
113
-	    if (isset($this->all_flights[$key]['id'])) {
113
+		if (isset($this->all_flights[$key]['id'])) {
114 114
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
115
-    		$Spotter = new Spotter($this->db);
116
-        	$real_arrival = $this->arrival($key);
117
-        	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
118
-            }
115
+			$Spotter = new Spotter($this->db);
116
+			$real_arrival = $this->arrival($key);
117
+			$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
118
+			}
119
+	}
119 120
 	}
120
-    }
121 121
 
122
-    public function arrival($key) {
122
+	public function arrival($key) {
123 123
 	global $globalClosestMinDist, $globalDebug;
124 124
 	$Spotter = new Spotter($this->db);
125
-        $airport_icao = '';
126
-        $airport_time = '';
127
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
125
+		$airport_icao = '';
126
+		$airport_time = '';
127
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
128 128
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
129
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
130
-    	    if (isset($closestAirports[0])) {
131
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
132
-        	    $airport_icao = $closestAirports[0]['icao'];
133
-        	    $airport_time = $this->all_flights[$key]['datetime'];
134
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
135
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
136
-        	    foreach ($closestAirports as $airport) {
137
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
138
-        		    $airport_icao = $airport['icao'];
139
-        		    $airport_time = $this->all_flights[$key]['datetime'];
140
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
141
-        		    break;
142
-        		}
143
-        	    }
144
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
145
-        		$airport_icao = $closestAirports[0]['icao'];
146
-        		$airport_time = $this->all_flights[$key]['datetime'];
147
-        	} else {
148
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
149
-        	}
150
-    	    } else {
151
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
152
-    	    }
153
-
154
-        } else {
155
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
156
-        }
157
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
158
-    }
159
-
160
-
161
-
162
-    function del() {
129
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
130
+			if (isset($closestAirports[0])) {
131
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
132
+				$airport_icao = $closestAirports[0]['icao'];
133
+				$airport_time = $this->all_flights[$key]['datetime'];
134
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
135
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
136
+				foreach ($closestAirports as $airport) {
137
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
138
+					$airport_icao = $airport['icao'];
139
+					$airport_time = $this->all_flights[$key]['datetime'];
140
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
141
+					break;
142
+				}
143
+				}
144
+			} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
145
+				$airport_icao = $closestAirports[0]['icao'];
146
+				$airport_time = $this->all_flights[$key]['datetime'];
147
+			} else {
148
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
149
+			}
150
+			} else {
151
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
152
+			}
153
+
154
+		} else {
155
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
156
+		}
157
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
158
+	}
159
+
160
+
161
+
162
+	function del() {
163 163
 	global $globalDebug;
164 164
 	// Delete old infos
165 165
 	foreach ($this->all_flights as $key => $flight) {
166
-    	    if (isset($flight['lastupdate'])) {
167
-        	if ($flight['lastupdate'] < (time()-3000)) {
168
-            	    if (isset($this->all_flights[$key]['id'])) {
169
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
166
+			if (isset($flight['lastupdate'])) {
167
+			if ($flight['lastupdate'] < (time()-3000)) {
168
+					if (isset($this->all_flights[$key]['id'])) {
169
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
170 170
 			/*
171 171
 			$SpotterLive = new SpotterLive();
172 172
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
173 173
 			$SpotterLive->db = null;
174 174
 			*/
175
-            		// FIXME : Add check on ground if available
176
-            		$real_arrival = $this->arrival($key);
177
-            		$Spotter = new Spotter($this->db);
178
-            		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
175
+					// FIXME : Add check on ground if available
176
+					$real_arrival = $this->arrival($key);
177
+					$Spotter = new Spotter($this->db);
178
+					if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
179 179
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
180 180
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
181 181
 			}
182 182
 			// Put in archive
183 183
 //			$Spotter->db = null;
184
-            	    }
185
-            	    unset($this->all_flights[$key]);
186
-    	        }
187
-	    }
188
-        }
189
-    }
190
-
191
-    function add($line) {
184
+					}
185
+					unset($this->all_flights[$key]);
186
+				}
187
+		}
188
+		}
189
+	}
190
+
191
+	function add($line) {
192 192
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBSupdate, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta;
193 193
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
194 194
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
@@ -213,18 +213,18 @@  discard block
 block discarded – undo
213 213
 	
214 214
 	// SBS format is CSV format
215 215
 	if(is_array($line) && isset($line['hex'])) {
216
-	    //print_r($line);
217
-  	    if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
216
+		//print_r($line);
217
+  		if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
218 218
 
219 219
 		// Increment message number
220 220
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
221
-		    $current_date = date('Y-m-d');
222
-		    $source = $line['source_name'];
223
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
224
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
225
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
226
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
227
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
221
+			$current_date = date('Y-m-d');
222
+			$source = $line['source_name'];
223
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
224
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
225
+				$this->stats[$current_date][$source]['msg']['date'] = time();
226
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
227
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
228 228
 		}
229 229
 		
230 230
 		/*
@@ -240,16 +240,16 @@  discard block
 block discarded – undo
240 240
 		//$this->db = $dbc;
241 241
 
242 242
 		$hex = trim($line['hex']);
243
-	        $id = trim($line['hex']);
243
+			$id = trim($line['hex']);
244 244
 		
245 245
 		//print_r($this->all_flights);
246 246
 		if (!isset($this->all_flights[$id]['hex'])) {
247
-		    $this->all_flights[$id] = array('hex' => $hex);
248
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
249
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
247
+			$this->all_flights[$id] = array('hex' => $hex);
248
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
249
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
250 250
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
251
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
252
-		    if (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') {
251
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
252
+			if (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') {
253 253
 
254 254
 			$timeelapsed = microtime(true);
255 255
 			$Spotter = new Spotter($this->db);
@@ -258,30 +258,30 @@  discard block
 block discarded – undo
258 258
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
259 259
 
260 260
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
261
-			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
262
-			    elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
263
-			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
264
-			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
261
+				if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
262
+				elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
263
+				elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
264
+				elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
265 265
 			}
266 266
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
267
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
268
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => false));
269
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
270
-		    if (!isset($line['id'])) {
267
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
268
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => false));
269
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
270
+			if (!isset($line['id'])) {
271 271
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
272 272
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
273 273
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
274 274
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
275
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
276
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
275
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
276
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
277 277
 
278
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
278
+			if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
279 279
 		}
280 280
 		
281 281
 		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
282
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
282
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
283 283
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
284
-		    } else {
284
+			} else {
285 285
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
286 286
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
287 287
 				/*
@@ -290,32 +290,32 @@  discard block
 block discarded – undo
290 290
 				print_r($line);
291 291
 				*/
292 292
 				return '';
293
-		    }
293
+			}
294 294
 		} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
295 295
 
296 296
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
297
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
297
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
298 298
 		}
299 299
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
300
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
300
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
301 301
 		}
302 302
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
303
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
303
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
304 304
 		}
305 305
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
306
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
306
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
307 307
 		}
308 308
  
309 309
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
310
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
311
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
310
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
311
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
312 312
 			$timeelapsed = microtime(true);
313
-            		$Spotter = new Spotter($this->db);
314
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident']);
313
+					$Spotter = new Spotter($this->db);
314
+					$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident']);
315 315
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
316 316
 			$Spotter->db = null;
317 317
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
318
-		    }
318
+			}
319 319
 
320 320
 /*
321 321
 		    if (!isset($line['id'])) {
@@ -325,26 +325,26 @@  discard block
 block discarded – undo
325 325
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
326 326
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
327 327
   */
328
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
328
+			if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
329 329
 
330
-		    //$putinarchive = true;
331
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
330
+			//$putinarchive = true;
331
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
332 332
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
333
-		    }
334
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
333
+			}
334
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
335 335
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
336
-		    }
337
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
338
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
339
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
336
+			}
337
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
338
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
339
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
340 340
 				$timeelapsed = microtime(true);
341 341
 				$Spotter = new Spotter($this->db);
342 342
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
343 343
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
344
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
344
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
345 345
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
346 346
 
347
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
347
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
348 348
 			$timeelapsed = microtime(true);
349 349
 			$Spotter = new Spotter($this->db);
350 350
 			$route = $Spotter->getRouteInfo(trim($line['ident']));
@@ -358,11 +358,11 @@  discard block
 block discarded – undo
358 358
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
359 359
 
360 360
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
361
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
362
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
361
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
362
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
363 363
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
364
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
365
-		    	    }
364
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
365
+					}
366 366
 			}
367 367
 			if (!isset($globalFork)) $globalFork = TRUE;
368 368
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
@@ -380,33 +380,33 @@  discard block
 block discarded – undo
380 380
 				$this->get_Schedule($id,trim($line['ident']));
381 381
 			//    }
382 382
 			}
383
-		    }
383
+			}
384 384
 		}
385 385
 
386 386
 		if (isset($line['speed']) && $line['speed'] != '') {
387 387
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
388
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
389
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
390
-		    //$dataFound = true;
388
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
389
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
390
+			//$dataFound = true;
391 391
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
392
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
393
-		    if ($distance > 1000 && $distance < 10000) {
394
-		    // use datetime
392
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
393
+			if ($distance > 1000 && $distance < 10000) {
394
+			// use datetime
395 395
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
396 396
 			$speed = $speed*3.6;
397 397
 			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
398 398
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
399
-		    }
399
+			}
400 400
 		}
401 401
 
402 402
 
403 403
 
404
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') {
405
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
406
-	    	    else unset($timediff);
407
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
404
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') {
405
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
406
+				else unset($timediff);
407
+				if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
408 408
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
409
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
409
+				if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
410 410
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
411 411
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
412 412
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -422,21 +422,21 @@  discard block
 block discarded – undo
422 422
 				$this->tmd = 0;
423 423
 				//echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
424 424
 				//$putinarchive = true;
425
-			    } else {
426
-			    /*
425
+				} else {
426
+				/*
427 427
 				echo '//////// checkLine FALSE'."\n";
428 428
 				echo 'Check DATA : '.$this->all_flights[$id]['archive_latitude'].' '.$this->all_flights[$id]['archive_longitude'].' '.$this->all_flights[$id]['livedb_latitude'].' '.$this->all_flights[$id]['livedb_longitude'].' '.$line['latitude'].' '.$line['longitude']."\n";
429 429
 			    */
430
-			    }
430
+				}
431 431
 			}
432 432
 
433 433
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
434
-			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
434
+				//if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
435 435
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
436 436
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
437
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
438
-				    $dataFound = true;
439
-				    $this->all_flights[$id]['time_last_coord'] = time();
437
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
438
+					$dataFound = true;
439
+					$this->all_flights[$id]['time_last_coord'] = time();
440 440
 				}
441 441
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
442 442
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -447,20 +447,20 @@  discard block
 block discarded – undo
447 447
 				    //$putinarchive = true;
448 448
 				}
449 449
 				*/
450
-			    /*
450
+				/*
451 451
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
452 452
 				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
453 453
 			    }
454 454
 			    */
455 455
 			}
456 456
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
457
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
458
-			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
457
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
458
+				//if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
459 459
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
460 460
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
461
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
462
-				    $dataFound = true;
463
-				    $this->all_flights[$id]['time_last_coord'] = time();
461
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
462
+					$dataFound = true;
463
+					$this->all_flights[$id]['time_last_coord'] = time();
464 464
 				}
465 465
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
466 466
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -478,49 +478,49 @@  discard block
 block discarded – undo
478 478
 			    */
479 479
 			}
480 480
 
481
-		    } else if ($globalDebug && $timediff > 20) {
481
+			} else if ($globalDebug && $timediff > 20) {
482 482
 			$this->tmd = $this->tmd + 1;
483 483
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
484 484
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
485 485
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
486 486
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
487
-		    }
487
+			}
488 488
 		}
489 489
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
490
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
491
-		    //$dataFound = true;
490
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
491
+			//$dataFound = true;
492 492
 		}
493 493
 		if (isset($line['format_source']) && $line['format_source'] != '') {
494
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
494
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
495 495
 		}
496 496
 		if (isset($line['source_name']) && $line['source_name'] != '') {
497
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
497
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
498 498
 		}
499 499
 		if (isset($line['emergency']) && $line['emergency'] != '') {
500
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
501
-		    //$dataFound = true;
500
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
501
+			//$dataFound = true;
502 502
 		}
503 503
 		if (isset($line['ground']) && $line['ground'] != '') {
504
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
504
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
505 505
 			// Here we force archive of flight because after ground it's a new one (or should be)
506 506
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
507 507
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
508 508
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
509
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
509
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
510 510
 			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
511
-		    }
512
-		    if ($line['ground'] != 1) $line['ground'] = 0;
513
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
514
-		    //$dataFound = true;
511
+			}
512
+			if ($line['ground'] != 1) $line['ground'] = 0;
513
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
514
+			//$dataFound = true;
515 515
 		}
516 516
 		if (isset($line['squawk']) && $line['squawk'] != '') {
517
-		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
518
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
519
-			    $highlight = '';
520
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
521
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
522
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
523
-			    if ($highlight != '') {
517
+			if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
518
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
519
+				$highlight = '';
520
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
521
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
522
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
523
+				if ($highlight != '') {
524 524
 				$timeelapsed = microtime(true);
525 525
 				$Spotter = new Spotter($this->db);
526 526
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
@@ -530,38 +530,38 @@  discard block
 block discarded – undo
530 530
 				$this->all_flights[$id]['putinarchive'] = true;
531 531
 				//$putinarchive = true;
532 532
 				$highlight = '';
533
-			    }
533
+				}
534 534
 			    
535
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
536
-		    //$dataFound = true;
535
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
536
+			//$dataFound = true;
537 537
 		}
538 538
 
539 539
 		if (isset($line['altitude']) && $line['altitude'] != '') {
540
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
540
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
541 541
 			if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
542 542
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
543 543
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
544 544
 			//$dataFound = true;
545
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
545
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
546 546
   		}
547 547
 
548 548
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
549
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
549
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
550 550
 		}
551 551
 		
552 552
 		if (isset($line['heading']) && $line['heading'] != '') {
553
-		    if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
554
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
555
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
556
-		    //$dataFound = true;
553
+			if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
554
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
555
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
556
+			//$dataFound = true;
557 557
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
558
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
559
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
560
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
561
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
558
+  			$heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
559
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
560
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
561
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
562 562
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
563
-  		    // If not enough messages and ACARS set heading to 0
564
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
563
+  			// If not enough messages and ACARS set heading to 0
564
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
565 565
   		}
566 566
 		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
567 567
 		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -571,118 +571,118 @@  discard block
 block discarded – undo
571 571
 		//if (time()-$this->all_flights[$id]['lastupdate'] > 30 && $dataFound == true && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
572 572
 		//if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
573 573
 		if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
574
-		    $this->all_flights[$id]['lastupdate'] = time();
575
-		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
576
-		        if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
577
-			    //print_r($this->all_flights);
578
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
579
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
580
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
574
+			$this->all_flights[$id]['lastupdate'] = time();
575
+			if ($this->all_flights[$id]['addedSpotter'] == 0) {
576
+				if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
577
+				//print_r($this->all_flights);
578
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
579
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
580
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
581 581
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
582 582
 				$timeelapsed = microtime(true);
583 583
 				$SpotterLive = new SpotterLive($this->db);
584 584
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
585
-				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
586
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
585
+					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
586
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
587 587
 
588 588
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
589
-				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
590
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
589
+					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
590
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
591 591
 
592 592
 				} else $recent_ident = '';
593 593
 				$SpotterLive->db=null;
594 594
 
595 595
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
596 596
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
597
-			    } else {
597
+				} else {
598 598
 				$recent_ident = '';
599 599
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
600
-			    }
601
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
602
-			    if($recent_ident == "")
603
-			    {
600
+				}
601
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
602
+				if($recent_ident == "")
603
+				{
604 604
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
605 605
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
606 606
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
607 607
 				//adds the spotter data for the archive
608 608
 				$ignoreImport = false;
609 609
 				foreach($globalAirportIgnore as $airportIgnore) {
610
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
610
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
611 611
 					$ignoreImport = true;
612
-				    }
612
+					}
613 613
 				}
614 614
 				if (count($globalAirportAccept) > 0) {
615
-				    $ignoreImport = true;
616
-				    foreach($globalAirportIgnore as $airportIgnore) {
615
+					$ignoreImport = true;
616
+					foreach($globalAirportIgnore as $airportIgnore) {
617 617
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
618
-					    $ignoreImport = false;
618
+						$ignoreImport = false;
619
+					}
619 620
 					}
620
-				    }
621 621
 				}
622 622
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
623
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
623
+					foreach($globalAirlineIgnore as $airlineIgnore) {
624 624
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
625
-					    $ignoreImport = true;
625
+						$ignoreImport = true;
626
+					}
626 627
 					}
627
-				    }
628 628
 				}
629 629
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
630
-				    $ignoreImport = true;
631
-				    foreach($globalAirlineAccept as $airlineAccept) {
630
+					$ignoreImport = true;
631
+					foreach($globalAirlineAccept as $airlineAccept) {
632 632
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
633
-					    $ignoreImport = false;
633
+						$ignoreImport = false;
634
+					}
634 635
 					}
635
-				    }
636 636
 				}
637 637
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
638
-				    $ignoreImport = true;
639
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
638
+					$ignoreImport = true;
639
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
640 640
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
641
-					    $ignoreImport = false;
641
+						$ignoreImport = false;
642
+					}
642 643
 					}
643
-				    }
644 644
 				}
645 645
 				
646 646
 				if (!$ignoreImport) {
647
-				    $highlight = '';
648
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
649
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
650
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
651
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
652
-				    $timeelapsed = microtime(true);
653
-				    $Spotter = new Spotter($this->db);
654
-				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
655
-				    $Spotter->db = null;
656
-				    if ($globalDebug && isset($result)) echo $result."\n";
657
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
647
+					$highlight = '';
648
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
649
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
650
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
651
+					if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
652
+					$timeelapsed = microtime(true);
653
+					$Spotter = new Spotter($this->db);
654
+					$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
655
+					$Spotter->db = null;
656
+					if ($globalDebug && isset($result)) echo $result."\n";
657
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
658 658
 				    
659
-				    // Add source stat in DB
660
-				    $Stats = new Stats($this->db);
661
-				    if (!empty($this->stats)) {
659
+					// Add source stat in DB
660
+					$Stats = new Stats($this->db);
661
+					if (!empty($this->stats)) {
662 662
 					if ($globalDebug) echo 'Add source stats : ';
663
-				        foreach($this->stats as $date => $data) {
664
-					    foreach($data as $source => $sourced) {
665
-					        //print_r($sourced);
666
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
667
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
668
-				    		if (isset($sourced['msg'])) {
669
-				    		    if (time() - $sourced['msg']['date'] > 10) {
670
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
671
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
672
-			    			        unset($this->stats[$date][$source]['msg']);
673
-			    			    }
674
-			    			}
675
-			    		    }
676
-			    		    if ($date != date('Y-m-d')) {
677
-			    			unset($this->stats[$date]);
678
-			    		    }
679
-				    	}
680
-				    	if ($globalDebug) echo 'Done'."\n";
681
-
682
-				    }
683
-				    $Stats->db = null;
663
+						foreach($this->stats as $date => $data) {
664
+						foreach($data as $source => $sourced) {
665
+							//print_r($sourced);
666
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
667
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
668
+							if (isset($sourced['msg'])) {
669
+								if (time() - $sourced['msg']['date'] > 10) {
670
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
671
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
672
+									unset($this->stats[$date][$source]['msg']);
673
+								}
674
+							}
675
+							}
676
+							if ($date != date('Y-m-d')) {
677
+							unset($this->stats[$date]);
678
+							}
679
+						}
680
+						if ($globalDebug) echo 'Done'."\n";
681
+
682
+					}
683
+					$Stats->db = null;
684 684
 				    
685
-				    $this->del();
685
+					$this->del();
686 686
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
687 687
 				$ignoreImport = false;
688 688
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -700,18 +700,18 @@  discard block
 block discarded – undo
700 700
 			*/
701 701
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
702 702
 				if ($this->last_delete == '' || time() - $this->last_delete > 1800) {
703
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
704
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
705
-				    $SpotterLive = new SpotterLive($this->db);
706
-				    $SpotterLive->deleteLiveSpotterData();
707
-				    $SpotterLive->db=null;
708
-				    if ($globalDebug) echo " Done\n";
709
-				    $this->last_delete = time();
703
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
704
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
705
+					$SpotterLive = new SpotterLive($this->db);
706
+					$SpotterLive->deleteLiveSpotterData();
707
+					$SpotterLive->db=null;
708
+					if ($globalDebug) echo " Done\n";
709
+					$this->last_delete = time();
710 710
 				}
711
-			    } else {
711
+				} else {
712 712
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
713
-				    $this->all_flights[$id]['id'] = $recent_ident;
714
-				    $this->all_flights[$id]['addedSpotter'] = 1;
713
+					$this->all_flights[$id]['id'] = $recent_ident;
714
+					$this->all_flights[$id]['addedSpotter'] = 1;
715 715
 				}
716 716
 				if (isset($globalDaemon) && !$globalDaemon) {
717 717
 					$Spotter = new Spotter($this->db);
@@ -719,14 +719,14 @@  discard block
 block discarded – undo
719 719
 					$Spotter->db = null;
720 720
 				}
721 721
 				
722
-			    }
722
+				}
723
+			}
723 724
 			}
724
-		    }
725
-		    //adds the spotter LIVE data
726
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
727
-		    //echo "\nAdd in Live !! \n";
728
-		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
729
-		    if ($globalDebug) {
725
+			//adds the spotter LIVE data
726
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
727
+			//echo "\nAdd in Live !! \n";
728
+			//echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
729
+			if ($globalDebug) {
730 730
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
731 731
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
732 732
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
@@ -734,49 +734,49 @@  discard block
 block discarded – undo
734 734
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
735 735
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
736 736
 			}
737
-		    }
738
-		    $ignoreImport = false;
739
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
740
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
737
+			}
738
+			$ignoreImport = false;
739
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
740
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
741 741
 
742
-		    foreach($globalAirportIgnore as $airportIgnore) {
743
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
744
-			    $ignoreImport = true;
742
+			foreach($globalAirportIgnore as $airportIgnore) {
743
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
744
+				$ignoreImport = true;
745
+			}
745 746
 			}
746
-		    }
747
-		    if (count($globalAirportAccept) > 0) {
748
-		        $ignoreImport = true;
749
-		        foreach($globalAirportIgnore as $airportIgnore) {
750
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
747
+			if (count($globalAirportAccept) > 0) {
748
+				$ignoreImport = true;
749
+				foreach($globalAirportIgnore as $airportIgnore) {
750
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
751 751
 				$ignoreImport = false;
752
-			    }
752
+				}
753
+			}
753 754
 			}
754
-		    }
755
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
755
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
756 756
 			foreach($globalAirlineIgnore as $airlineIgnore) {
757
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
757
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
758 758
 				$ignoreImport = true;
759
-			    }
759
+				}
760
+			}
760 761
 			}
761
-		    }
762
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
762
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
763 763
 			$ignoreImport = true;
764 764
 			foreach($globalAirlineAccept as $airlineAccept) {
765
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
765
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
766 766
 				$ignoreImport = false;
767
-			    }
767
+				}
768 768
 			}
769
-		    }
770
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
769
+			}
770
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
771 771
 			$ignoreImport = true;
772 772
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
773
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
774
-			        $ignoreImport = false;
775
-			    }
773
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
774
+					$ignoreImport = false;
775
+				}
776
+			}
776 777
 			}
777
-		    }
778 778
 
779
-		    if (!$ignoreImport) {
779
+			if (!$ignoreImport) {
780 780
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
781 781
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
782 782
 				$timeelapsed = microtime(true);
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
 					if ($stats_heading == 16) $stats_heading = 0;
815 815
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
816 816
 						for ($i=0;$i<=15;$i++) {
817
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
817
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
818 818
 						}
819 819
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
820 820
 					} else {
@@ -827,11 +827,11 @@  discard block
 block discarded – undo
827 827
 					//var_dump($this->stats);
828 828
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
829 829
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
830
-						    end($this->stats[$current_date][$source]['hist']);
831
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
830
+							end($this->stats[$current_date][$source]['hist']);
831
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
832 832
 						} else $mini = 0;
833 833
 						for ($i=$mini;$i<=$distance;$i+=10) {
834
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
834
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
835 835
 						}
836 836
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
837 837
 					} else {
@@ -848,22 +848,22 @@  discard block
 block discarded – undo
848 848
 			
849 849
 			
850 850
 			if ($this->last_delete_hourly == '' || time() - $this->last_delete_hourly > 900) {
851
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
852
-			    $SpotterLive = new SpotterLive($this->db);
853
-			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
854
-			    $SpotterLive->db = null;
855
-			    //SpotterLive->deleteLiveSpotterData();
856
-			    if ($globalDebug) echo " Done\n";
857
-			    $this->last_delete_hourly = time();
851
+				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
852
+				$SpotterLive = new SpotterLive($this->db);
853
+				$SpotterLive->deleteLiveSpotterDataNotUpdated();
854
+				$SpotterLive->db = null;
855
+				//SpotterLive->deleteLiveSpotterData();
856
+				if ($globalDebug) echo " Done\n";
857
+				$this->last_delete_hourly = time();
858 858
 			}
859 859
 			
860
-		    }
861
-		    $ignoreImport = false;
860
+			}
861
+			$ignoreImport = false;
862 862
 		}
863 863
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
864 864
 		if ($send) return $this->all_flights[$id];
865
-	    }
865
+		}
866
+	}
866 867
 	}
867
-    }
868 868
 }
869 869
 ?>
Please login to merge, or discard this patch.
Spacing   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	$currentdate = date('Y-m-d');
30 30
 	$sourcestat = $Stats->getStatsSource($currentdate);
31 31
 	if (!empty($sourcestat)) {
32
-	    foreach($sourcestat as $srcst) {
32
+	    foreach ($sourcestat as $srcst) {
33 33
 	    	$type = $srcst['stats_type'];
34 34
 		if ($type == 'polar' || $type == 'hist') {
35 35
 		    $source = $srcst['source_name'];
36 36
 		    $data = $srcst['source_data'];
37
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
37
+		    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
38 38
 	        }
39 39
 	    }
40 40
 	}
41 41
     }
42 42
 
43
-    function get_Schedule($id,$ident) {
43
+    function get_Schedule($id, $ident) {
44 44
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 45
 	// Get schedule here, so it's done only one time
46 46
 	
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 		$schedule = $Schedule->fetchSchedule($operator);
64 64
 		if (count($schedule) > 0) {
65 65
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
66
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
67
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
66
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
67
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
68 68
 		    // FIXME : Check if route schedule = route from DB
69 69
 		    if ($schedule['DepartureAirportIATA'] != '') {
70 70
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 			    }
85 85
 			}
86 86
 		    }
87
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
87
+		    $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']);
88 88
 		}
89 89
 	    }
90 90
 	}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
115 115
     		$Spotter = new Spotter($this->db);
116 116
         	$real_arrival = $this->arrival($key);
117
-        	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
117
+        	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
118 118
             }
119 119
 	}
120 120
     }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         $airport_time = '';
127 127
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
128 128
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
129
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
129
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
130 130
     	    if (isset($closestAirports[0])) {
131 131
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
132 132
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         		    break;
142 142
         		}
143 143
         	    }
144
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
144
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
145 145
         		$airport_icao = $closestAirports[0]['icao'];
146 146
         		$airport_time = $this->all_flights[$key]['datetime'];
147 147
         	} else {
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         } else {
155 155
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
156 156
         }
157
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
157
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
158 158
     }
159 159
 
160 160
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	// Delete old infos
165 165
 	foreach ($this->all_flights as $key => $flight) {
166 166
     	    if (isset($flight['lastupdate'])) {
167
-        	if ($flight['lastupdate'] < (time()-3000)) {
167
+        	if ($flight['lastupdate'] < (time() - 3000)) {
168 168
             	    if (isset($this->all_flights[$key]['id'])) {
169 169
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
170 170
 			/*
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
             		$real_arrival = $this->arrival($key);
177 177
             		$Spotter = new Spotter($this->db);
178 178
             		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
179
-				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
179
+				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
180 180
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
181 181
 			}
182 182
 			// Put in archive
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	$send = false;
213 213
 	
214 214
 	// SBS format is CSV format
215
-	if(is_array($line) && isset($line['hex'])) {
215
+	if (is_array($line) && isset($line['hex'])) {
216 216
 	    //print_r($line);
217 217
   	    if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
218 218
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 		//print_r($this->all_flights);
246 246
 		if (!isset($this->all_flights[$id]['hex'])) {
247 247
 		    $this->all_flights[$id] = array('hex' => $hex);
248
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
248
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
249 249
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
250 250
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
251 251
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 			$Spotter = new Spotter($this->db);
256 256
 			$aircraft_icao = $Spotter->getAllAircraftType($hex);
257 257
 			$Spotter->db = null;
258
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
258
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
259 259
 
260 260
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
261 261
 			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
@@ -263,24 +263,24 @@  discard block
 block discarded – undo
263 263
 			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
264 264
 			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
265 265
 			}
266
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
267
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
268
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => false));
269
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
266
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
267
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao']));
268
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => false));
269
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
270 270
 		    if (!isset($line['id'])) {
271 271
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
272 272
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
273 273
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
274
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
274
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
275 275
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
276
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
276
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
277 277
 
278 278
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
279 279
 		}
280 280
 		
281
-		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
281
+		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/', $line['datetime'])) {
282 282
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
283
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
283
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
284 284
 		    } else {
285 285
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
286 286
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -291,30 +291,30 @@  discard block
 block discarded – undo
291 291
 				*/
292 292
 				return '';
293 293
 		    }
294
-		} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
294
+		} else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
295 295
 
296 296
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
297
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
297
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
298 298
 		}
299 299
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
300
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
300
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
301 301
 		}
302 302
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
303
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
303
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id']));
304 304
 		}
305 305
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
306
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
306
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name']));
307 307
 		}
308 308
  
309 309
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
310
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
310
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
311 311
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
312 312
 			$timeelapsed = microtime(true);
313 313
             		$Spotter = new Spotter($this->db);
314
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident']);
314
+            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident']);
315 315
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
316 316
 			$Spotter->db = null;
317
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
317
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
318 318
 		    }
319 319
 
320 320
 /*
@@ -325,24 +325,24 @@  discard block
 block discarded – undo
325 325
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
326 326
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
327 327
   */
328
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
328
+		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
329 329
 
330 330
 		    //$putinarchive = true;
331 331
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
332
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
332
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
333 333
 		    }
334 334
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
335
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
335
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
336 336
 		    }
337 337
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
338
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
338
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
339 339
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
340 340
 				$timeelapsed = microtime(true);
341 341
 				$Spotter = new Spotter($this->db);
342 342
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
343 343
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
344
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
345
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
344
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
345
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
346 346
 
347 347
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
348 348
 			$timeelapsed = microtime(true);
@@ -355,13 +355,13 @@  discard block
 block discarded – undo
355 355
 				$Translation->db = null;
356 356
 			}
357 357
 			$Spotter->db = null;
358
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
358
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
359 359
 
360 360
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
361 361
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
362 362
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
363 363
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
364
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
364
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop']));
365 365
 		    	    }
366 366
 			}
367 367
 			if (!isset($globalFork)) $globalFork = TRUE;
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 				}
378 378
 			    } else {
379 379
 			    */
380
-				$this->get_Schedule($id,trim($line['ident']));
380
+				$this->get_Schedule($id, trim($line['ident']));
381 381
 			//    }
382 382
 			}
383 383
 		    }
@@ -385,16 +385,16 @@  discard block
 block discarded – undo
385 385
 
386 386
 		if (isset($line['speed']) && $line['speed'] != '') {
387 387
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
388
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
389
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
388
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
389
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
390 390
 		    //$dataFound = true;
391 391
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
392
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
392
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
393 393
 		    if ($distance > 1000 && $distance < 10000) {
394 394
 		    // use datetime
395 395
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
396 396
 			$speed = $speed*3.6;
397
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
397
+			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
398 398
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
399 399
 		    }
400 400
 		}
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
 
403 403
 
404 404
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') {
405
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
405
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
406 406
 	    	    else unset($timediff);
407
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
407
+	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) {
408 408
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
409
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
409
+			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
410 410
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
411 411
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
412 412
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -415,10 +415,10 @@  discard block
 block discarded – undo
415 415
 				//echo "\n".' ------- Check Country.... ';
416 416
 				$timeelapsed = microtime(true);
417 417
 				$Spotter = new Spotter($this->db);
418
-				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
418
+				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
419 419
 				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
420 420
 				$Spotter->db = null;
421
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
421
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
422 422
 				$this->tmd = 0;
423 423
 				//echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
424 424
 				//$putinarchive = true;
@@ -433,13 +433,13 @@  discard block
 block discarded – undo
433 433
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
434 434
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
435 435
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
436
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
436
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
437 437
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
438 438
 				    $dataFound = true;
439 439
 				    $this->all_flights[$id]['time_last_coord'] = time();
440 440
 				}
441 441
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
442
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
442
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
443 443
 				/*
444 444
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
445 445
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -457,13 +457,13 @@  discard block
 block discarded – undo
457 457
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
458 458
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
459 459
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
460
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
460
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
461 461
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
462 462
 				    $dataFound = true;
463 463
 				    $this->all_flights[$id]['time_last_coord'] = time();
464 464
 				}
465 465
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
466
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
466
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
467 467
 				/*
468 468
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
469 469
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -481,41 +481,41 @@  discard block
 block discarded – undo
481 481
 		    } else if ($globalDebug && $timediff > 20) {
482 482
 			$this->tmd = $this->tmd + 1;
483 483
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
484
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
485
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
484
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
485
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
486 486
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
487 487
 		    }
488 488
 		}
489 489
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
490
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
490
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
491 491
 		    //$dataFound = true;
492 492
 		}
493 493
 		if (isset($line['format_source']) && $line['format_source'] != '') {
494
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
494
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
495 495
 		}
496 496
 		if (isset($line['source_name']) && $line['source_name'] != '') {
497
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
497
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
498 498
 		}
499 499
 		if (isset($line['emergency']) && $line['emergency'] != '') {
500
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
500
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
501 501
 		    //$dataFound = true;
502 502
 		}
503 503
 		if (isset($line['ground']) && $line['ground'] != '') {
504 504
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
505 505
 			// Here we force archive of flight because after ground it's a new one (or should be)
506
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
507
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
508
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
509
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
510
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
506
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
507
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
508
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
509
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
510
+			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
511 511
 		    }
512 512
 		    if ($line['ground'] != 1) $line['ground'] = 0;
513
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
513
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
514 514
 		    //$dataFound = true;
515 515
 		}
516 516
 		if (isset($line['squawk']) && $line['squawk'] != '') {
517 517
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
518
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
518
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
519 519
 			    $highlight = '';
520 520
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
521 521
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -523,48 +523,48 @@  discard block
 block discarded – undo
523 523
 			    if ($highlight != '') {
524 524
 				$timeelapsed = microtime(true);
525 525
 				$Spotter = new Spotter($this->db);
526
-				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
526
+				$Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
527 527
 				$Spotter->db = null;
528
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
528
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
529 529
 
530 530
 				$this->all_flights[$id]['putinarchive'] = true;
531 531
 				//$putinarchive = true;
532 532
 				$highlight = '';
533 533
 			    }
534 534
 			    
535
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
535
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
536 536
 		    //$dataFound = true;
537 537
 		}
538 538
 
539 539
 		if (isset($line['altitude']) && $line['altitude'] != '') {
540 540
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
541
-			if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
542
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
543
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
541
+			if (abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
542
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
543
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
544 544
 			//$dataFound = true;
545 545
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
546 546
   		}
547 547
 
548 548
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
549
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
549
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
550 550
 		}
551 551
 		
552 552
 		if (isset($line['heading']) && $line['heading'] != '') {
553
-		    if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
554
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
555
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
553
+		    if (abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
554
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
555
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
556 556
 		    //$dataFound = true;
557 557
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
558
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
559
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
560
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
558
+  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
559
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
560
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
561 561
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
562 562
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
563 563
   		    // If not enough messages and ACARS set heading to 0
564
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
564
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
565 565
   		}
566
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
567
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
566
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
567
+		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
568 568
 
569 569
 //		print_r($this->all_flights[$id]);
570 570
 		//gets the callsign from the last hour
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 		if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
574 574
 		    $this->all_flights[$id]['lastupdate'] = time();
575 575
 		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
576
-		        if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
576
+		        if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
577 577
 			    //print_r($this->all_flights);
578 578
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
579 579
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -583,60 +583,60 @@  discard block
 block discarded – undo
583 583
 				$SpotterLive = new SpotterLive($this->db);
584 584
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
585 585
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
586
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
586
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
587 587
 
588 588
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
589 589
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
590
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
590
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
591 591
 
592 592
 				} else $recent_ident = '';
593
-				$SpotterLive->db=null;
593
+				$SpotterLive->db = null;
594 594
 
595 595
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
596 596
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
597 597
 			    } else {
598 598
 				$recent_ident = '';
599
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
599
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
600 600
 			    }
601 601
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
602
-			    if($recent_ident == "")
602
+			    if ($recent_ident == "")
603 603
 			    {
604 604
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
605 605
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
606 606
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
607 607
 				//adds the spotter data for the archive
608 608
 				$ignoreImport = false;
609
-				foreach($globalAirportIgnore as $airportIgnore) {
609
+				foreach ($globalAirportIgnore as $airportIgnore) {
610 610
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
611 611
 					$ignoreImport = true;
612 612
 				    }
613 613
 				}
614 614
 				if (count($globalAirportAccept) > 0) {
615 615
 				    $ignoreImport = true;
616
-				    foreach($globalAirportIgnore as $airportIgnore) {
616
+				    foreach ($globalAirportIgnore as $airportIgnore) {
617 617
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
618 618
 					    $ignoreImport = false;
619 619
 					}
620 620
 				    }
621 621
 				}
622 622
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
623
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
624
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
623
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
624
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
625 625
 					    $ignoreImport = true;
626 626
 					}
627 627
 				    }
628 628
 				}
629 629
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
630 630
 				    $ignoreImport = true;
631
-				    foreach($globalAirlineAccept as $airlineAccept) {
632
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
631
+				    foreach ($globalAirlineAccept as $airlineAccept) {
632
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
633 633
 					    $ignoreImport = false;
634 634
 					}
635 635
 				    }
636 636
 				}
637 637
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
638 638
 				    $ignoreImport = true;
639
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
639
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
640 640
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
641 641
 					    $ignoreImport = false;
642 642
 					}
@@ -648,27 +648,27 @@  discard block
 block discarded – undo
648 648
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
649 649
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
650 650
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
651
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
651
+				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
652 652
 				    $timeelapsed = microtime(true);
653 653
 				    $Spotter = new Spotter($this->db);
654
-				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
654
+				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name']);
655 655
 				    $Spotter->db = null;
656 656
 				    if ($globalDebug && isset($result)) echo $result."\n";
657
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
657
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
658 658
 				    
659 659
 				    // Add source stat in DB
660 660
 				    $Stats = new Stats($this->db);
661 661
 				    if (!empty($this->stats)) {
662 662
 					if ($globalDebug) echo 'Add source stats : ';
663
-				        foreach($this->stats as $date => $data) {
664
-					    foreach($data as $source => $sourced) {
663
+				        foreach ($this->stats as $date => $data) {
664
+					    foreach ($data as $source => $sourced) {
665 665
 					        //print_r($sourced);
666
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
667
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
666
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
667
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
668 668
 				    		if (isset($sourced['msg'])) {
669 669
 				    		    if (time() - $sourced['msg']['date'] > 10) {
670 670
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
671
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
671
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
672 672
 			    			        unset($this->stats[$date][$source]['msg']);
673 673
 			    			    }
674 674
 			    			}
@@ -704,18 +704,18 @@  discard block
 block discarded – undo
704 704
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
705 705
 				    $SpotterLive = new SpotterLive($this->db);
706 706
 				    $SpotterLive->deleteLiveSpotterData();
707
-				    $SpotterLive->db=null;
707
+				    $SpotterLive->db = null;
708 708
 				    if ($globalDebug) echo " Done\n";
709 709
 				    $this->last_delete = time();
710 710
 				}
711 711
 			    } else {
712
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
712
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
713 713
 				    $this->all_flights[$id]['id'] = $recent_ident;
714 714
 				    $this->all_flights[$id]['addedSpotter'] = 1;
715 715
 				}
716 716
 				if (isset($globalDaemon) && !$globalDaemon) {
717 717
 					$Spotter = new Spotter($this->db);
718
-					$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
718
+					$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
719 719
 					$Spotter->db = null;
720 720
 				}
721 721
 				
@@ -739,37 +739,37 @@  discard block
 block discarded – undo
739 739
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
740 740
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
741 741
 
742
-		    foreach($globalAirportIgnore as $airportIgnore) {
742
+		    foreach ($globalAirportIgnore as $airportIgnore) {
743 743
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
744 744
 			    $ignoreImport = true;
745 745
 			}
746 746
 		    }
747 747
 		    if (count($globalAirportAccept) > 0) {
748 748
 		        $ignoreImport = true;
749
-		        foreach($globalAirportIgnore as $airportIgnore) {
749
+		        foreach ($globalAirportIgnore as $airportIgnore) {
750 750
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
751 751
 				$ignoreImport = false;
752 752
 			    }
753 753
 			}
754 754
 		    }
755 755
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
756
-			foreach($globalAirlineIgnore as $airlineIgnore) {
757
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
756
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
757
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
758 758
 				$ignoreImport = true;
759 759
 			    }
760 760
 			}
761 761
 		    }
762 762
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
763 763
 			$ignoreImport = true;
764
-			foreach($globalAirlineAccept as $airlineAccept) {
765
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
764
+			foreach ($globalAirlineAccept as $airlineAccept) {
765
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
766 766
 				$ignoreImport = false;
767 767
 			    }
768 768
 			}
769 769
 		    }
770 770
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
771 771
 			$ignoreImport = true;
772
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
772
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
773 773
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
774 774
 			        $ignoreImport = false;
775 775
 			    }
@@ -777,13 +777,13 @@  discard block
 block discarded – undo
777 777
 		    }
778 778
 
779 779
 		    if (!$ignoreImport) {
780
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
780
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
781 781
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
782 782
 				$timeelapsed = microtime(true);
783 783
 				$SpotterLive = new SpotterLive($this->db);
784
-				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
784
+				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
785 785
 				$SpotterLive->db = null;
786
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
786
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
787 787
 
788 788
 				// Put statistics in $this->stats variable
789 789
 				//if ($line['format_source'] != 'aprs') {
@@ -801,19 +801,19 @@  discard block
 block discarded – undo
801 801
 							$latitude = $globalCenterLatitude;
802 802
 							$longitude = $globalCenterLongitude;
803 803
 						}
804
-						$source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
804
+						$source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
805 805
 					} else {
806 806
 						$latitude = $source_location[$source]['latitude'];
807 807
 						$longitude = $source_location[$source]['longitude'];
808 808
 					}
809
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
809
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
810 810
 					//$stats_heading = $stats_heading%22.5;
811 811
 					$stats_heading = round($stats_heading/22.5);
812
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
812
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
813 813
 					$current_date = date('Y-m-d');
814 814
 					if ($stats_heading == 16) $stats_heading = 0;
815 815
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
816
-						for ($i=0;$i<=15;$i++) {
816
+						for ($i = 0; $i <= 15; $i++) {
817 817
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
818 818
 						}
819 819
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -828,9 +828,9 @@  discard block
 block discarded – undo
828 828
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
829 829
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
830 830
 						    end($this->stats[$current_date][$source]['hist']);
831
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
831
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
832 832
 						} else $mini = 0;
833
-						for ($i=$mini;$i<=$distance;$i+=10) {
833
+						for ($i = $mini; $i <= $distance; $i += 10) {
834 834
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
835 835
 						}
836 836
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
844 844
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
845 845
 				if ($globalDebug) echo $result."\n";
846
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
846
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
847 847
 			//$this->del();
848 848
 			
849 849
 			
Please login to merge, or discard this patch.
Braces   +270 added lines, -95 removed lines patch added patch discarded remove patch
@@ -62,7 +62,9 @@  discard block
 block discarded – undo
62 62
 	    if ($Schedule->checkSchedule($operator) == 0) {
63 63
 		$schedule = $Schedule->fetchSchedule($operator);
64 64
 		if (count($schedule) > 0) {
65
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
65
+		    if ($globalDebug) {
66
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
67
+		    }
66 68
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
67 69
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
68 70
 		    // FIXME : Check if route schedule = route from DB
@@ -71,7 +73,9 @@  discard block
 block discarded – undo
71 73
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
72 74
 			    if ($airport_icao != '') {
73 75
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
74
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
76
+				if ($globalDebug) {
77
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
78
+				}
75 79
 			    }
76 80
 			}
77 81
 		    }
@@ -80,7 +84,9 @@  discard block
 block discarded – undo
80 84
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
81 85
 			    if ($airport_icao != '') {
82 86
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
83
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
87
+				if ($globalDebug) {
88
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
89
+				}
84 90
 			    }
85 91
 			}
86 92
 		    }
@@ -108,7 +114,9 @@  discard block
 block discarded – undo
108 114
 
109 115
     public function checkAll() {
110 116
 	global $globalDebug;
111
-	if ($globalDebug) echo "Update last seen flights data...\n";
117
+	if ($globalDebug) {
118
+		echo "Update last seen flights data...\n";
119
+	}
112 120
 	foreach ($this->all_flights as $key => $flight) {
113 121
 	    if (isset($this->all_flights[$key]['id'])) {
114 122
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
@@ -124,20 +132,26 @@  discard block
 block discarded – undo
124 132
 	$Spotter = new Spotter($this->db);
125 133
         $airport_icao = '';
126 134
         $airport_time = '';
127
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
135
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
136
+        	$globalClosestMinDist = 50;
137
+        }
128 138
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
129 139
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
130 140
     	    if (isset($closestAirports[0])) {
131 141
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
132 142
         	    $airport_icao = $closestAirports[0]['icao'];
133 143
         	    $airport_time = $this->all_flights[$key]['datetime'];
134
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
144
+        	    if ($globalDebug) {
145
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
146
+        	    }
135 147
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
136 148
         	    foreach ($closestAirports as $airport) {
137 149
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
138 150
         		    $airport_icao = $airport['icao'];
139 151
         		    $airport_time = $this->all_flights[$key]['datetime'];
140
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
152
+        		    if ($globalDebug) {
153
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
154
+        		    }
141 155
         		    break;
142 156
         		}
143 157
         	    }
@@ -145,14 +159,20 @@  discard block
 block discarded – undo
145 159
         		$airport_icao = $closestAirports[0]['icao'];
146 160
         		$airport_time = $this->all_flights[$key]['datetime'];
147 161
         	} else {
148
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
162
+        		if ($globalDebug) {
163
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
164
+        		}
149 165
         	}
150 166
     	    } else {
151
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
167
+    		    if ($globalDebug) {
168
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
169
+    		    }
152 170
     	    }
153 171
 
154 172
         } else {
155
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
173
+        	if ($globalDebug) {
174
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
175
+        	}
156 176
         }
157 177
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
158 178
     }
@@ -166,7 +186,9 @@  discard block
 block discarded – undo
166 186
     	    if (isset($flight['lastupdate'])) {
167 187
         	if ($flight['lastupdate'] < (time()-3000)) {
168 188
             	    if (isset($this->all_flights[$key]['id'])) {
169
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
189
+            		if ($globalDebug) {
190
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
191
+            		}
170 192
 			/*
171 193
 			$SpotterLive = new SpotterLive();
172 194
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -177,7 +199,9 @@  discard block
 block discarded – undo
177 199
             		$Spotter = new Spotter($this->db);
178 200
             		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
179 201
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
180
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
202
+				if ($globalDebug && $result != 'success') {
203
+					echo '!!! ERROR : '.$result."\n";
204
+				}
181 205
 			}
182 206
 			// Put in archive
183 207
 //			$Spotter->db = null;
@@ -191,8 +215,10 @@  discard block
 block discarded – undo
191 215
     function add($line) {
192 216
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBSupdate, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta;
193 217
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
194
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
195
-/*
218
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
219
+		$globalCoordMinChange = '0.02';
220
+	}
221
+	/*
196 222
 	$Spotter = new Spotter();
197 223
 	$dbc = $Spotter->db;
198 224
 	$SpotterLive = new SpotterLive($dbc);
@@ -220,11 +246,15 @@  discard block
 block discarded – undo
220 246
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
221 247
 		    $current_date = date('Y-m-d');
222 248
 		    $source = $line['source_name'];
223
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
249
+		    if ($source == '' || $line['format_source'] == 'aprs') {
250
+		    	$source = $line['format_source'];
251
+		    }
224 252
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
225 253
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
226 254
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
227
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
255
+		    } else {
256
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
257
+		    }
228 258
 		}
229 259
 		
230 260
 		/*
@@ -255,35 +285,55 @@  discard block
 block discarded – undo
255 285
 			$Spotter = new Spotter($this->db);
256 286
 			$aircraft_icao = $Spotter->getAllAircraftType($hex);
257 287
 			$Spotter->db = null;
258
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
288
+			if ($globalDebugTimeElapsed) {
289
+				echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
290
+			}
259 291
 
260 292
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
261
-			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
262
-			    elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
263
-			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
264
-			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
293
+			    if ($line['aircraft_type'] == 'PARA_GLIDER') {
294
+			    	$aircraft_icao = 'GLID';
295
+			    } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
296
+			    	$aircraft_icao = 'UHEL';
297
+			    } elseif ($line['aircraft_type'] == 'TOW_PLANE') {
298
+			    	$aircraft_icao = 'TOWPLANE';
299
+			    } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
300
+			    	$aircraft_icao = 'POWAIRC';
301
+			    }
265 302
 			}
266 303
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
267
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
304
+		    } else {
305
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
306
+		    }
268 307
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => false));
269 308
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
270 309
 		    if (!isset($line['id'])) {
271
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
272
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
310
+			if (!isset($globalDaemon)) {
311
+				$globalDaemon = TRUE;
312
+			}
313
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
273 314
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
274
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
315
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
316
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
317
+			}
275 318
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
276
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
319
+		     } else {
320
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
321
+		     }
277 322
 
278
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
323
+		    if ($globalDebug) {
324
+		    	echo "*********** New aircraft hex : ".$hex." ***********\n";
325
+		    }
279 326
 		}
280 327
 		
281 328
 		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
282 329
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
283 330
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
284 331
 		    } else {
285
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
286
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
332
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
333
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
334
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
335
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
336
+				}
287 337
 				/*
288 338
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
289 339
 				print_r($this->all_flights[$id]);
@@ -291,7 +341,9 @@  discard block
 block discarded – undo
291 341
 				*/
292 342
 				return '';
293 343
 		    }
294
-		} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
344
+		} else {
345
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
346
+		}
295 347
 
296 348
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
297 349
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
@@ -312,9 +364,13 @@  discard block
 block discarded – undo
312 364
 			$timeelapsed = microtime(true);
313 365
             		$Spotter = new Spotter($this->db);
314 366
             		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident']);
315
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
367
+			if ($globalDebug && $result != 'success') {
368
+				echo '!!! ERROR : '.$result."\n";
369
+			}
316 370
 			$Spotter->db = null;
317
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
371
+			if ($globalDebugTimeElapsed) {
372
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
373
+			}
318 374
 		    }
319 375
 
320 376
 /*
@@ -325,7 +381,9 @@  discard block
 block discarded – undo
325 381
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
326 382
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
327 383
   */
328
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
384
+		    if (!isset($this->all_flights[$id]['id'])) {
385
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
386
+		    }
329 387
 
330 388
 		    //$putinarchive = true;
331 389
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -342,7 +400,9 @@  discard block
 block discarded – undo
342 400
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
343 401
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
344 402
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
345
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
403
+				if ($globalDebugTimeElapsed) {
404
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
405
+				}
346 406
 
347 407
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
348 408
 			$timeelapsed = microtime(true);
@@ -355,7 +415,9 @@  discard block
 block discarded – undo
355 415
 				$Translation->db = null;
356 416
 			}
357 417
 			$Spotter->db = null;
358
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
418
+			if ($globalDebugTimeElapsed) {
419
+				echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
420
+			}
359 421
 
360 422
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
361 423
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -364,7 +426,9 @@  discard block
 block discarded – undo
364 426
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
365 427
 		    	    }
366 428
 			}
367
-			if (!isset($globalFork)) $globalFork = TRUE;
429
+			if (!isset($globalFork)) {
430
+				$globalFork = TRUE;
431
+			}
368 432
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
369 433
 			  /*
370 434
 			    if (function_exists('pcntl_fork') && $globalFork) {
@@ -394,16 +458,23 @@  discard block
 block discarded – undo
394 458
 		    // use datetime
395 459
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
396 460
 			$speed = $speed*3.6;
397
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
398
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
461
+			if ($speed < 1000) {
462
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
463
+			}
464
+  			if ($globalDebug) {
465
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
466
+  			}
399 467
 		    }
400 468
 		}
401 469
 
402 470
 
403 471
 
404 472
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') {
405
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
406
-	    	    else unset($timediff);
473
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
474
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
475
+	    	    } else {
476
+	    	    	unset($timediff);
477
+	    	    }
407 478
 	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
408 479
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
409 480
 			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -416,9 +487,13 @@  discard block
 block discarded – undo
416 487
 				$timeelapsed = microtime(true);
417 488
 				$Spotter = new Spotter($this->db);
418 489
 				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
419
-				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
490
+				if (!empty($all_country)) {
491
+					$this->all_flights[$id]['over_country'] = $all_country['iso2'];
492
+				}
420 493
 				$Spotter->db = null;
421
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
494
+				if ($globalDebugTimeElapsed) {
495
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
496
+				}
422 497
 				$this->tmd = 0;
423 498
 				//echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
424 499
 				//$putinarchive = true;
@@ -432,7 +507,9 @@  discard block
 block discarded – undo
432 507
 
433 508
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
434 509
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
435
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
510
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
511
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
512
+				}
436 513
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
437 514
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
438 515
 				    $dataFound = true;
@@ -454,9 +531,13 @@  discard block
 block discarded – undo
454 531
 			    */
455 532
 			}
456 533
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
457
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
534
+			    if ($line['longitude'] > 180) {
535
+			    	$line['longitude'] = $line['longitude'] - 360;
536
+			    }
458 537
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
459
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
538
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
539
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
540
+				}
460 541
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
461 542
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
462 543
 				    $dataFound = true;
@@ -505,11 +586,17 @@  discard block
 block discarded – undo
505 586
 			// Here we force archive of flight because after ground it's a new one (or should be)
506 587
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
507 588
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
508
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
509
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
510
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
589
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
590
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
591
+			} elseif (isset($line['id'])) {
592
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
593
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
594
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
595
+			}
596
+		    }
597
+		    if ($line['ground'] != 1) {
598
+		    	$line['ground'] = 0;
511 599
 		    }
512
-		    if ($line['ground'] != 1) $line['ground'] = 0;
513 600
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
514 601
 		    //$dataFound = true;
515 602
 		}
@@ -517,28 +604,40 @@  discard block
 block discarded – undo
517 604
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
518 605
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
519 606
 			    $highlight = '';
520
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
521
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
522
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
607
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
608
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
609
+			    }
610
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
611
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
612
+			    }
613
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
614
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
615
+			    }
523 616
 			    if ($highlight != '') {
524 617
 				$timeelapsed = microtime(true);
525 618
 				$Spotter = new Spotter($this->db);
526 619
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
527 620
 				$Spotter->db = null;
528
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
621
+				if ($globalDebugTimeElapsed) {
622
+					echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
623
+				}
529 624
 
530 625
 				$this->all_flights[$id]['putinarchive'] = true;
531 626
 				//$putinarchive = true;
532 627
 				$highlight = '';
533 628
 			    }
534 629
 			    
535
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
630
+		    } else {
631
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
632
+		    }
536 633
 		    //$dataFound = true;
537 634
 		}
538 635
 
539 636
 		if (isset($line['altitude']) && $line['altitude'] != '') {
540 637
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
541
-			if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
638
+			if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) {
639
+				$this->all_flights[$id]['putinarchive'] = true;
640
+			}
542 641
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
543 642
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
544 643
 			//$dataFound = true;
@@ -550,21 +649,30 @@  discard block
 block discarded – undo
550 649
 		}
551 650
 		
552 651
 		if (isset($line['heading']) && $line['heading'] != '') {
553
-		    if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
652
+		    if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) {
653
+		    	$this->all_flights[$id]['putinarchive'] = true;
654
+		    }
554 655
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
555 656
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
556 657
 		    //$dataFound = true;
557 658
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
558 659
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
559 660
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
560
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
561
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
661
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) {
662
+		    	$this->all_flights[$id]['putinarchive'] = true;
663
+		    }
664
+  		    if ($globalDebug) {
665
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
666
+  		    }
562 667
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
563 668
   		    // If not enough messages and ACARS set heading to 0
564 669
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
565 670
   		}
566
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
567
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
671
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
672
+			$dataFound = false;
673
+		} elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
674
+			$dataFound = false;
675
+		}
568 676
 
569 677
 //		print_r($this->all_flights[$id]);
570 678
 		//gets the callsign from the last hour
@@ -578,22 +686,33 @@  discard block
 block discarded – undo
578 686
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
579 687
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
580 688
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
581
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
689
+				if ($globalDebug) {
690
+					echo "Check if aircraft is already in DB...";
691
+				}
582 692
 				$timeelapsed = microtime(true);
583 693
 				$SpotterLive = new SpotterLive($this->db);
584 694
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
585 695
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
586
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
696
+				    if ($globalDebugTimeElapsed) {
697
+				    	echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
698
+				    }
587 699
 
588 700
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
589 701
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
590
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
702
+				    if ($globalDebugTimeElapsed) {
703
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
704
+				    }
591 705
 
592
-				} else $recent_ident = '';
706
+				} else {
707
+					$recent_ident = '';
708
+				}
593 709
 				$SpotterLive->db=null;
594 710
 
595
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
596
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
711
+				if ($globalDebug && $recent_ident == '') {
712
+					echo " Not in DB.\n";
713
+				} elseif ($globalDebug && $recent_ident != '') {
714
+					echo " Already in DB.\n";
715
+				}
597 716
 			    } else {
598 717
 				$recent_ident = '';
599 718
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -601,7 +720,9 @@  discard block
 block discarded – undo
601 720
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
602 721
 			    if($recent_ident == "")
603 722
 			    {
604
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
723
+				if ($globalDebug) {
724
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
725
+				}
605 726
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
606 727
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
607 728
 				//adds the spotter data for the archive
@@ -645,26 +766,44 @@  discard block
 block discarded – undo
645 766
 				
646 767
 				if (!$ignoreImport) {
647 768
 				    $highlight = '';
648
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
649
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
650
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
651
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
769
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
770
+				    	$highlight = 'Squawk 7500 : Hijack';
771
+				    }
772
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
773
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
774
+				    }
775
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
776
+				    	$highlight = 'Squawk 7700 : Emergency';
777
+				    }
778
+				    if (!isset($this->all_flights[$id]['id'])) {
779
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
780
+				    }
652 781
 				    $timeelapsed = microtime(true);
653 782
 				    $Spotter = new Spotter($this->db);
654 783
 				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
655 784
 				    $Spotter->db = null;
656
-				    if ($globalDebug && isset($result)) echo $result."\n";
657
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
785
+				    if ($globalDebug && isset($result)) {
786
+				    	echo $result."\n";
787
+				    }
788
+				    if ($globalDebugTimeElapsed) {
789
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
790
+				    }
658 791
 				    
659 792
 				    // Add source stat in DB
660 793
 				    $Stats = new Stats($this->db);
661 794
 				    if (!empty($this->stats)) {
662
-					if ($globalDebug) echo 'Add source stats : ';
795
+					if ($globalDebug) {
796
+						echo 'Add source stats : ';
797
+					}
663 798
 				        foreach($this->stats as $date => $data) {
664 799
 					    foreach($data as $source => $sourced) {
665 800
 					        //print_r($sourced);
666
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
667
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
801
+				    	        if (isset($sourced['polar'])) {
802
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
803
+				    	        }
804
+				    	        if (isset($sourced['hist'])) {
805
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
806
+				    	        }
668 807
 				    		if (isset($sourced['msg'])) {
669 808
 				    		    if (time() - $sourced['msg']['date'] > 10) {
670 809
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -677,13 +816,17 @@  discard block
 block discarded – undo
677 816
 			    			unset($this->stats[$date]);
678 817
 			    		    }
679 818
 				    	}
680
-				    	if ($globalDebug) echo 'Done'."\n";
819
+				    	if ($globalDebug) {
820
+				    		echo 'Done'."\n";
821
+				    	}
681 822
 
682 823
 				    }
683 824
 				    $Stats->db = null;
684 825
 				    
685 826
 				    $this->del();
686
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
827
+				} elseif ($globalDebug) {
828
+					echo 'Ignore data'."\n";
829
+				}
687 830
 				$ignoreImport = false;
688 831
 				$this->all_flights[$id]['addedSpotter'] = 1;
689 832
 				//print_r($this->all_flights[$id]);
@@ -700,12 +843,16 @@  discard block
 block discarded – undo
700 843
 			*/
701 844
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
702 845
 				if ($this->last_delete == '' || time() - $this->last_delete > 1800) {
703
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
846
+				    if ($globalDebug) {
847
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
848
+				    }
704 849
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
705 850
 				    $SpotterLive = new SpotterLive($this->db);
706 851
 				    $SpotterLive->deleteLiveSpotterData();
707 852
 				    $SpotterLive->db=null;
708
-				    if ($globalDebug) echo " Done\n";
853
+				    if ($globalDebug) {
854
+				    	echo " Done\n";
855
+				    }
709 856
 				    $this->last_delete = time();
710 857
 				}
711 858
 			    } else {
@@ -728,11 +875,17 @@  discard block
 block discarded – undo
728 875
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
729 876
 		    if ($globalDebug) {
730 877
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
731
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
732
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
878
+				if (isset($this->all_flights[$id]['source_name'])) {
879
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
880
+				} else {
881
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
882
+				}
733 883
 			} else {
734
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
735
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
884
+				if (isset($this->all_flights[$id]['source_name'])) {
885
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
886
+				} else {
887
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
888
+				}
736 889
 			}
737 890
 		    }
738 891
 		    $ignoreImport = false;
@@ -778,19 +931,25 @@  discard block
 block discarded – undo
778 931
 
779 932
 		    if (!$ignoreImport) {
780 933
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
781
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
934
+				if ($globalDebug) {
935
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
936
+				}
782 937
 				$timeelapsed = microtime(true);
783 938
 				$SpotterLive = new SpotterLive($this->db);
784 939
 				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
785 940
 				$SpotterLive->db = null;
786
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
941
+				if ($globalDebugTimeElapsed) {
942
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
943
+				}
787 944
 
788 945
 				// Put statistics in $this->stats variable
789 946
 				//if ($line['format_source'] != 'aprs') {
790 947
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
791 948
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs') {
792 949
 					$source = $this->all_flights[$id]['source_name'];
793
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
950
+					if ($source == '') {
951
+						$source = $this->all_flights[$id]['format_source'];
952
+					}
794 953
 					if (!isset($source_location[$source])) {
795 954
 						$Location = new Source();
796 955
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -811,7 +970,9 @@  discard block
 block discarded – undo
811 970
 					$stats_heading = round($stats_heading/22.5);
812 971
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
813 972
 					$current_date = date('Y-m-d');
814
-					if ($stats_heading == 16) $stats_heading = 0;
973
+					if ($stats_heading == 16) {
974
+						$stats_heading = 0;
975
+					}
815 976
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
816 977
 						for ($i=0;$i<=15;$i++) {
817 978
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -829,7 +990,9 @@  discard block
 block discarded – undo
829 990
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
830 991
 						    end($this->stats[$current_date][$source]['hist']);
831 992
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
832
-						} else $mini = 0;
993
+						} else {
994
+							$mini = 0;
995
+						}
833 996
 						for ($i=$mini;$i<=$distance;$i+=10) {
834 997
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
835 998
 						}
@@ -840,20 +1003,30 @@  discard block
 block discarded – undo
840 1003
 				}
841 1004
 
842 1005
 				$this->all_flights[$id]['lastupdate'] = time();
843
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1006
+				if ($this->all_flights[$id]['putinarchive']) {
1007
+					$send = true;
1008
+				}
844 1009
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
845
-				if ($globalDebug) echo $result."\n";
846
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1010
+				if ($globalDebug) {
1011
+					echo $result."\n";
1012
+				}
1013
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1014
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1015
+			}
847 1016
 			//$this->del();
848 1017
 			
849 1018
 			
850 1019
 			if ($this->last_delete_hourly == '' || time() - $this->last_delete_hourly > 900) {
851
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1020
+			    if ($globalDebug) {
1021
+			    	echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1022
+			    }
852 1023
 			    $SpotterLive = new SpotterLive($this->db);
853 1024
 			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
854 1025
 			    $SpotterLive->db = null;
855 1026
 			    //SpotterLive->deleteLiveSpotterData();
856
-			    if ($globalDebug) echo " Done\n";
1027
+			    if ($globalDebug) {
1028
+			    	echo " Done\n";
1029
+			    }
857 1030
 			    $this->last_delete_hourly = time();
858 1031
 			}
859 1032
 			
@@ -861,7 +1034,9 @@  discard block
 block discarded – undo
861 1034
 		    $ignoreImport = false;
862 1035
 		}
863 1036
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
864
-		if ($send) return $this->all_flights[$id];
1037
+		if ($send) {
1038
+			return $this->all_flights[$id];
1039
+		}
865 1040
 	    }
866 1041
 	}
867 1042
     }
Please login to merge, or discard this patch.
require/class.Stats.php 4 patches
Doc Comments   +36 added lines patch added patch discarded remove patch
@@ -13,6 +13,10 @@  discard block
 block discarded – undo
13 13
 		$this->db = $Connection->db;
14 14
         }
15 15
               
16
+	/**
17
+	 * @param string $type
18
+	 * @param string $stats_date
19
+	 */
16 20
 	public function addLastStatsUpdate($type,$stats_date) {
17 21
                 $query = "DELETE FROM config WHERE name = :type;
18 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
@@ -521,6 +525,10 @@  discard block
 block discarded – undo
521 525
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
522 526
                 return $all;
523 527
 	}
528
+
529
+	/**
530
+	 * @param string $type
531
+	 */
524 532
 	public function getStats($type) {
525 533
                 $query = "SELECT * FROM stats WHERE stats_type = :type ORDER BY stats_date";
526 534
                 $query_values = array(':type' => $type);
@@ -533,6 +541,11 @@  discard block
 block discarded – undo
533 541
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
534 542
                 return $all;
535 543
         }
544
+
545
+	/**
546
+	 * @param string $type
547
+	 * @param string $year
548
+	 */
536 549
 	public function getSumStats($type,$year) {
537 550
     		global $globalArchiveMonths, $globalDBdriver;
538 551
     		if ($globalDBdriver == 'mysql') {
@@ -632,6 +645,10 @@  discard block
 block discarded – undo
632 645
                 return $all[0]['total'];
633 646
         }
634 647
 
648
+	/**
649
+	 * @param string $type
650
+	 * @param string $stats_date
651
+	 */
635 652
 	public function addStat($type,$cnt,$stats_date) {
636 653
 		global $globalDBdriver;
637 654
 		if ($globalDBdriver == 'mysql') {
@@ -663,6 +680,10 @@  discard block
 block discarded – undo
663 680
                         return "error : ".$e->getMessage();
664 681
                 }
665 682
         }
683
+
684
+	/**
685
+	 * @param string $date
686
+	 */
666 687
 	public function getStatsSource($date,$stats_type = '') {
667 688
 		if ($stats_type == '') {
668 689
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -681,6 +702,9 @@  discard block
 block discarded – undo
681 702
                 return $all;
682 703
         }
683 704
 
705
+	/**
706
+	 * @param string $stats_type
707
+	 */
684 708
 	public function addStatSource($data,$source_name,$stats_type,$date) {
685 709
 		global $globalDBdriver;
686 710
 		if ($globalDBdriver == 'mysql') {
@@ -696,6 +720,10 @@  discard block
 block discarded – undo
696 720
                         return "error : ".$e->getMessage();
697 721
                 }
698 722
         }
723
+
724
+	/**
725
+	 * @param string $type
726
+	 */
699 727
 	public function addStatFlight($type,$date_name,$cnt) {
700 728
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt) VALUES (:type,:flight_date,:cnt)";
701 729
                 $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt);
@@ -882,6 +910,10 @@  discard block
 block discarded – undo
882 910
                         return "error : ".$e->getMessage();
883 911
                 }
884 912
         }
913
+
914
+	/**
915
+	 * @param string $type
916
+	 */
885 917
 	public function deleteStatFlight($type) {
886 918
                 $query = "DELETE FROM stats_flight WHERE stats_type = :type";
887 919
                 $query_values = array(':type' => $type);
@@ -892,6 +924,10 @@  discard block
 block discarded – undo
892 924
                         return "error : ".$e->getMessage();
893 925
                 }
894 926
         }
927
+
928
+	/**
929
+	 * @param string $type
930
+	 */
895 931
 	public function deleteStatAirport($type) {
896 932
                 $query = "DELETE FROM stats_airport WHERE stats_type = :type";
897 933
                 $query_values = array(':type' => $type);
Please login to merge, or discard this patch.
Indentation   +685 added lines, -685 removed lines patch added patch discarded remove patch
@@ -8,199 +8,199 @@  discard block
 block discarded – undo
8 8
 require_once(dirname(__FILE__).'/class.Common.php');
9 9
 class Stats {
10 10
 	public $db;
11
-        function __construct($dbc = null) {
11
+		function __construct($dbc = null) {
12 12
 		$Connection = new Connection($dbc);
13 13
 		$this->db = $Connection->db;
14
-        }
14
+		}
15 15
               
16 16
 	public function addLastStatsUpdate($type,$stats_date) {
17
-                $query = "DELETE FROM config WHERE name = :type;
17
+				$query = "DELETE FROM config WHERE name = :type;
18 18
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
19
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
20
-                 try {
21
-                        $sth = $this->db->prepare($query);
22
-                        $sth->execute($query_values);
23
-                } catch(PDOException $e) {
24
-                        return "error : ".$e->getMessage();
25
-                }
26
-        }
19
+				$query_values = array('type' => $type,':stats_date' => $stats_date);
20
+				 try {
21
+						$sth = $this->db->prepare($query);
22
+						$sth->execute($query_values);
23
+				} catch(PDOException $e) {
24
+						return "error : ".$e->getMessage();
25
+				}
26
+		}
27 27
 
28 28
 	public function getLastStatsUpdate($type = 'last_update_stats') {
29
-                $query = "SELECT value FROM config WHERE name = :type";
30
-                 try {
31
-                        $sth = $this->db->prepare($query);
32
-                        $sth->execute(array(':type' => $type));
33
-                } catch(PDOException $e) {
34
-                        echo "error : ".$e->getMessage();
35
-                }
36
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
37
-                return $all;
38
-        }
29
+				$query = "SELECT value FROM config WHERE name = :type";
30
+				 try {
31
+						$sth = $this->db->prepare($query);
32
+						$sth->execute(array(':type' => $type));
33
+				} catch(PDOException $e) {
34
+						echo "error : ".$e->getMessage();
35
+				}
36
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
37
+				return $all;
38
+		}
39 39
 	public function getAllAirlineNames($airline_type = '') {
40
-                $query = "SELECT * FROM stats_airline ORDER BY airline_name ASC";
41
-                 try {
42
-                        $sth = $this->db->prepare($query);
43
-                        $sth->execute();
44
-                } catch(PDOException $e) {
45
-                        echo "error : ".$e->getMessage();
46
-                }
47
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
48
-                return $all;
49
-        }
40
+				$query = "SELECT * FROM stats_airline ORDER BY airline_name ASC";
41
+				 try {
42
+						$sth = $this->db->prepare($query);
43
+						$sth->execute();
44
+				} catch(PDOException $e) {
45
+						echo "error : ".$e->getMessage();
46
+				}
47
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
48
+				return $all;
49
+		}
50 50
 	public function getAllAircraftTypes() {
51
-                $query = "SELECT * FROM stats_aircraft ORDER BY aircraft_name ASC";
52
-                 try {
53
-                        $sth = $this->db->prepare($query);
54
-                        $sth->execute();
55
-                } catch(PDOException $e) {
56
-                        echo "error : ".$e->getMessage();
57
-                }
58
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
59
-                return $all;
60
-        }
51
+				$query = "SELECT * FROM stats_aircraft ORDER BY aircraft_name ASC";
52
+				 try {
53
+						$sth = $this->db->prepare($query);
54
+						$sth->execute();
55
+				} catch(PDOException $e) {
56
+						echo "error : ".$e->getMessage();
57
+				}
58
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
59
+				return $all;
60
+		}
61 61
 	public function getAllAirportNames() {
62
-                $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
63
-                 try {
64
-                        $sth = $this->db->prepare($query);
65
-                        $sth->execute();
66
-                } catch(PDOException $e) {
67
-                        echo "error : ".$e->getMessage();
68
-                }
69
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
70
-                return $all;
71
-        }
62
+				$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
63
+				 try {
64
+						$sth = $this->db->prepare($query);
65
+						$sth->execute();
66
+				} catch(PDOException $e) {
67
+						echo "error : ".$e->getMessage();
68
+				}
69
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
70
+				return $all;
71
+		}
72 72
 
73 73
 
74 74
 	public function countAllAircraftTypes($limit = true) {
75 75
 		if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
76 76
 		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' ORDER BY aircraft_icao_count DESC";
77
-                 try {
78
-                        $sth = $this->db->prepare($query);
79
-                        $sth->execute();
80
-                } catch(PDOException $e) {
81
-                        echo "error : ".$e->getMessage();
82
-                }
83
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
84
-                if (empty($all)) {
85
-            	    $Spotter = new Spotter($this->db);
86
-            	    $all = $Spotter->countAllAircraftTypes($limit);
87
-                }
88
-                return $all;
77
+				 try {
78
+						$sth = $this->db->prepare($query);
79
+						$sth->execute();
80
+				} catch(PDOException $e) {
81
+						echo "error : ".$e->getMessage();
82
+				}
83
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
84
+				if (empty($all)) {
85
+					$Spotter = new Spotter($this->db);
86
+					$all = $Spotter->countAllAircraftTypes($limit);
87
+				}
88
+				return $all;
89 89
 	}
90 90
 	public function countAllAirlineCountries($limit = true) {
91 91
 		if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
92 92
 		else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao GROUP BY airline_country ORDER BY airline_country_count DESC";
93
-                 try {
94
-                        $sth = $this->db->prepare($query);
95
-                        $sth->execute();
96
-                } catch(PDOException $e) {
97
-                        echo "error : ".$e->getMessage();
98
-                }
99
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
100
-                if (empty($all)) {
101
-            		$Spotter = new Spotter($this->db);
102
-            		$all = $Spotter->countAllAirlineCountries($limit);
93
+				 try {
94
+						$sth = $this->db->prepare($query);
95
+						$sth->execute();
96
+				} catch(PDOException $e) {
97
+						echo "error : ".$e->getMessage();
98
+				}
99
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
100
+				if (empty($all)) {
101
+					$Spotter = new Spotter($this->db);
102
+					$all = $Spotter->countAllAirlineCountries($limit);
103 103
                 
104
-                }
105
-                return $all;
104
+				}
105
+				return $all;
106 106
 	}
107 107
 	public function countAllAircraftManufacturers($limit = true) {
108 108
 		if ($limit) $query = "SELECT aircraft.manufacturer AS aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft,aircraft WHERE stats_aircraft.aircraft_icao=aircraft.icao GROUP BY aircraft.manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
109 109
 		else $query = "SELECT aircraft.manufacturer AS aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft,aircraft WHERE stats_aircraft.aircraft_icao=aircraft.icao GROUP BY aircraft.manufacturer ORDER BY aircraft_manufacturer_count DESC";
110
-                 try {
111
-                        $sth = $this->db->prepare($query);
112
-                        $sth->execute();
113
-                } catch(PDOException $e) {
114
-                        echo "error : ".$e->getMessage();
115
-                }
116
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
117
-                if (empty($all)) {
118
-            		$Spotter = new Spotter($this->db);
110
+				 try {
111
+						$sth = $this->db->prepare($query);
112
+						$sth->execute();
113
+				} catch(PDOException $e) {
114
+						echo "error : ".$e->getMessage();
115
+				}
116
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
117
+				if (empty($all)) {
118
+					$Spotter = new Spotter($this->db);
119 119
 			$all = $Spotter->countAllAircraftManufacturers($limit);
120
-                }
121
-                return $all;
120
+				}
121
+				return $all;
122 122
 	}
123 123
 
124 124
 	public function countAllArrivalCountries($limit = true) {
125 125
 		if ($limit) $query = "SELECT airport_country AS arrival_airport_country, arrival as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0";
126 126
 		else $query = "SELECT airport_country AS arrival_airport_country, arrival as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly'";
127
-                 try {
128
-                        $sth = $this->db->prepare($query);
129
-                        $sth->execute();
130
-                } catch(PDOException $e) {
131
-                        echo "error : ".$e->getMessage();
132
-                }
133
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
134
-                if (empty($all)) {
135
-	                $Spotter = new Spotter($this->db);
136
-            		$all = $Spotter->countAllArrivalCountries($limit);
137
-                }
138
-                return $all;
127
+				 try {
128
+						$sth = $this->db->prepare($query);
129
+						$sth->execute();
130
+				} catch(PDOException $e) {
131
+						echo "error : ".$e->getMessage();
132
+				}
133
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
134
+				if (empty($all)) {
135
+					$Spotter = new Spotter($this->db);
136
+					$all = $Spotter->countAllArrivalCountries($limit);
137
+				}
138
+				return $all;
139 139
 	}
140 140
 	public function countAllDepartureCountries($limit = true) {
141 141
 		if ($limit) $query = "SELECT airport_country AS departure_airport_country, departure as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0";
142 142
 		else $query = "SELECT airport_country AS departure_airport_country, departure as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly'";
143
-                 try {
144
-                        $sth = $this->db->prepare($query);
145
-                        $sth->execute();
146
-                } catch(PDOException $e) {
147
-                        echo "error : ".$e->getMessage();
148
-                }
149
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
150
-                if (empty($all)) {
151
-		        $Spotter = new Spotter($this->db);
152
-    	    	        $all = $Spotter->countAllDepartureCountries($limit);
153
-                }
154
-                return $all;
143
+				 try {
144
+						$sth = $this->db->prepare($query);
145
+						$sth->execute();
146
+				} catch(PDOException $e) {
147
+						echo "error : ".$e->getMessage();
148
+				}
149
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
150
+				if (empty($all)) {
151
+				$Spotter = new Spotter($this->db);
152
+						$all = $Spotter->countAllDepartureCountries($limit);
153
+				}
154
+				return $all;
155 155
 	}
156 156
 
157 157
 	public function countAllAirlines($limit = true) {
158 158
 		if ($limit) $query = "SELECT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = airline_icao ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
159 159
 		else $query = "SELECT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = airline_icao ORDER BY airline_count DESC";
160
-                 try {
161
-                        $sth = $this->db->prepare($query);
162
-                        $sth->execute();
163
-                } catch(PDOException $e) {
164
-                        echo "error : ".$e->getMessage();
165
-                }
166
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
167
-                if (empty($all)) {
168
-	                $Spotter = new Spotter($this->db);
169
-    		        $all = $Spotter->countAllAirlines($limit);
170
-                }
171
-                return $all;
160
+				 try {
161
+						$sth = $this->db->prepare($query);
162
+						$sth->execute();
163
+				} catch(PDOException $e) {
164
+						echo "error : ".$e->getMessage();
165
+				}
166
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
167
+				if (empty($all)) {
168
+					$Spotter = new Spotter($this->db);
169
+					$all = $Spotter->countAllAirlines($limit);
170
+				}
171
+				return $all;
172 172
 	}
173 173
 	public function countAllAircraftRegistrations($limit = true) {
174 174
 		if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
175 175
 		else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao ORDER BY aircraft_registration_count DESC";
176
-                 try {
177
-                        $sth = $this->db->prepare($query);
178
-                        $sth->execute();
179
-                } catch(PDOException $e) {
180
-                        echo "error : ".$e->getMessage();
181
-                }
182
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
183
-                if (empty($all)) {
184
-	                $Spotter = new Spotter($this->db);
185
-    		        $all = $Spotter->countAllAircraftRegistrations($limit);
186
-                }
187
-                return $all;
176
+				 try {
177
+						$sth = $this->db->prepare($query);
178
+						$sth->execute();
179
+				} catch(PDOException $e) {
180
+						echo "error : ".$e->getMessage();
181
+				}
182
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
183
+				if (empty($all)) {
184
+					$Spotter = new Spotter($this->db);
185
+					$all = $Spotter->countAllAircraftRegistrations($limit);
186
+				}
187
+				return $all;
188 188
 	}
189 189
 	public function countAllCallsigns($limit = true) {
190 190
 		if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
191 191
 		else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao ORDER BY callsign_icao_count DESC";
192
-                 try {
193
-                        $sth = $this->db->prepare($query);
194
-                        $sth->execute();
195
-                } catch(PDOException $e) {
196
-                        echo "error : ".$e->getMessage();
197
-                }
198
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
199
-                if (empty($all)) {
200
-	                $Spotter = new Spotter($this->db);
201
-    		        $all = $Spotter->countAllCallsigns($limit);
202
-                }
203
-                return $all;
192
+				 try {
193
+						$sth = $this->db->prepare($query);
194
+						$sth->execute();
195
+				} catch(PDOException $e) {
196
+						echo "error : ".$e->getMessage();
197
+				}
198
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
199
+				if (empty($all)) {
200
+					$Spotter = new Spotter($this->db);
201
+					$all = $Spotter->countAllCallsigns($limit);
202
+				}
203
+				return $all;
204 204
 	}
205 205
 	public function countAllFlightOverCountries($limit = true) {
206 206
 		$Connection = new Connection();
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 				echo "error : ".$e->getMessage();
215 215
 			}
216 216
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
217
-                /*
217
+				/*
218 218
                 if (empty($all)) {
219 219
 	                $Spotter = new Spotter($this->db);
220 220
     		        $all = $Spotter->countAllFlightOverCountries($limit);
@@ -228,102 +228,102 @@  discard block
 block discarded – undo
228 228
 	public function countAllPilots($limit = true) {
229 229
 		if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
230 230
 		else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot ORDER BY pilot_count DESC";
231
-                 try {
232
-                        $sth = $this->db->prepare($query);
233
-                        $sth->execute();
234
-                } catch(PDOException $e) {
235
-                        echo "error : ".$e->getMessage();
236
-                }
237
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
238
-                if (empty($all)) {
239
-            		$Spotter = new Spotter($this->db);
240
-            		$all = $Spotter->countAllPilots($limit);
241
-                }
242
-                return $all;
231
+				 try {
232
+						$sth = $this->db->prepare($query);
233
+						$sth->execute();
234
+				} catch(PDOException $e) {
235
+						echo "error : ".$e->getMessage();
236
+				}
237
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
238
+				if (empty($all)) {
239
+					$Spotter = new Spotter($this->db);
240
+					$all = $Spotter->countAllPilots($limit);
241
+				}
242
+				return $all;
243 243
 	}
244 244
 	public function countAllOwners($limit = true) {
245 245
 		if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
246 246
 		else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner ORDER BY owner_count DESC";
247
-                 try {
248
-                        $sth = $this->db->prepare($query);
249
-                        $sth->execute();
250
-                } catch(PDOException $e) {
251
-                        echo "error : ".$e->getMessage();
252
-                }
253
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
254
-                if (empty($all)) {
255
-            		$Spotter = new Spotter($this->db);
256
-            		$all = $Spotter->countAllOwners($limit);
257
-                }
258
-                return $all;
247
+				 try {
248
+						$sth = $this->db->prepare($query);
249
+						$sth->execute();
250
+				} catch(PDOException $e) {
251
+						echo "error : ".$e->getMessage();
252
+				}
253
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
254
+				if (empty($all)) {
255
+					$Spotter = new Spotter($this->db);
256
+					$all = $Spotter->countAllOwners($limit);
257
+				}
258
+				return $all;
259 259
 	}
260 260
 	public function countAllDepartureAirports($limit = true) {
261 261
 		if ($limit) $query = "SELECT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0";
262 262
 		else $query = "SELECT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE stats_type = 'yearly'";
263
-                 try {
264
-                        $sth = $this->db->prepare($query);
265
-                        $sth->execute();
266
-                } catch(PDOException $e) {
267
-                        echo "error : ".$e->getMessage();
268
-                }
269
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
270
-                if (empty($all)) {
271
-            		$Spotter = new Spotter($this->db);
272
-            		$pall = $Spotter->countAllDepartureAirports($limit);
273
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit);
274
-        		$all = array();
275
-        		foreach ($pall as $value) {
276
-        			$icao = $value['airport_departure_icao'];
277
-        			$all[$icao] = $value;
278
-        		}
263
+				 try {
264
+						$sth = $this->db->prepare($query);
265
+						$sth->execute();
266
+				} catch(PDOException $e) {
267
+						echo "error : ".$e->getMessage();
268
+				}
269
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
270
+				if (empty($all)) {
271
+					$Spotter = new Spotter($this->db);
272
+					$pall = $Spotter->countAllDepartureAirports($limit);
273
+				$dall = $Spotter->countAllDetectedDepartureAirports($limit);
274
+				$all = array();
275
+				foreach ($pall as $value) {
276
+					$icao = $value['airport_departure_icao'];
277
+					$all[$icao] = $value;
278
+				}
279 279
         		
280
-        		foreach ($dall as $value) {
281
-        			$icao = $value['airport_departure_icao'];
282
-        			if (isset($all[$icao])) {                                                           
283
-        				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
284
-        			} else $all[$icao] = $value;
285
-        		}
286
-        		$count = array();
287
-        		foreach ($all as $key => $row) {
288
-        			$count[$key] = $row['airport_departure_icao_count'];
289
-        		}
290
-        		array_multisort($count,SORT_DESC,$all);
291
-                }
292
-                return $all;
280
+				foreach ($dall as $value) {
281
+					$icao = $value['airport_departure_icao'];
282
+					if (isset($all[$icao])) {                                                           
283
+						$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
284
+					} else $all[$icao] = $value;
285
+				}
286
+				$count = array();
287
+				foreach ($all as $key => $row) {
288
+					$count[$key] = $row['airport_departure_icao_count'];
289
+				}
290
+				array_multisort($count,SORT_DESC,$all);
291
+				}
292
+				return $all;
293 293
 	}
294 294
 	public function countAllArrivalAirports($limit = true) {
295 295
 		if ($limit) $query = "SELECT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0";
296 296
 		else $query = "SELECT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE stats_type = 'yearly'";
297
-                 try {
298
-                        $sth = $this->db->prepare($query);
299
-                        $sth->execute();
300
-                } catch(PDOException $e) {
301
-                        echo "error : ".$e->getMessage();
302
-                }
303
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
304
-                if (empty($all)) {
305
-            		$Spotter = new Spotter($this->db);
306
-        		$pall = $Spotter->countAllArrivalAirports($limit);
307
-        		$dall = $Spotter->countAllDetectedArrivalAirports($limit);
308
-        		$all = array();
309
-        		foreach ($pall as $value) {
310
-        			$icao = $value['airport_arrival_icao'];
311
-        			$all[$icao] = $value;
312
-        		}
297
+				 try {
298
+						$sth = $this->db->prepare($query);
299
+						$sth->execute();
300
+				} catch(PDOException $e) {
301
+						echo "error : ".$e->getMessage();
302
+				}
303
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
304
+				if (empty($all)) {
305
+					$Spotter = new Spotter($this->db);
306
+				$pall = $Spotter->countAllArrivalAirports($limit);
307
+				$dall = $Spotter->countAllDetectedArrivalAirports($limit);
308
+				$all = array();
309
+				foreach ($pall as $value) {
310
+					$icao = $value['airport_arrival_icao'];
311
+					$all[$icao] = $value;
312
+				}
313 313
         		
314
-        		foreach ($dall as $value) {
315
-        			$icao = $value['airport_arrival_icao'];
316
-        			if (isset($all[$icao])) {
317
-        				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
318
-        			} else $all[$icao] = $value;
319
-        		}
320
-        		$count = array();
321
-        		foreach ($all as $key => $row) {
322
-        			$count[$key] = $row['airport_arrival_icao_count'];
323
-        		}
324
-        		array_multisort($count,SORT_DESC,$all);
325
-                }
326
-                return $all;
314
+				foreach ($dall as $value) {
315
+					$icao = $value['airport_arrival_icao'];
316
+					if (isset($all[$icao])) {
317
+						$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
318
+					} else $all[$icao] = $value;
319
+				}
320
+				$count = array();
321
+				foreach ($all as $key => $row) {
322
+					$count[$key] = $row['airport_arrival_icao_count'];
323
+				}
324
+				array_multisort($count,SORT_DESC,$all);
325
+				}
326
+				return $all;
327 327
 	}
328 328
 	public function countAllMonthsLastYear($limit = true) {
329 329
 		global $globalDBdriver;
@@ -335,35 +335,35 @@  discard block
 block discarded – undo
335 335
 			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth'";
336 336
 		}
337 337
 		$query_data = array();
338
-                 try {
339
-                        $sth = $this->db->prepare($query);
340
-                        $sth->execute($query_data);
341
-                } catch(PDOException $e) {
342
-                        echo "error : ".$e->getMessage();
343
-                }
344
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
345
-                if (empty($all)) {
346
-            		$Spotter = new Spotter($this->db);
347
-            		$all = $Spotter->countAllMonthsLastYear($limit);
348
-                }
349
-                return $all;
338
+				 try {
339
+						$sth = $this->db->prepare($query);
340
+						$sth->execute($query_data);
341
+				} catch(PDOException $e) {
342
+						echo "error : ".$e->getMessage();
343
+				}
344
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
345
+				if (empty($all)) {
346
+					$Spotter = new Spotter($this->db);
347
+					$all = $Spotter->countAllMonthsLastYear($limit);
348
+				}
349
+				return $all;
350 350
 	}
351 351
 	
352 352
 	public function countAllDatesLastMonth() {
353 353
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month'";
354 354
 		$query_data = array();
355
-                 try {
356
-                        $sth = $this->db->prepare($query);
357
-                        $sth->execute($query_data);
358
-                } catch(PDOException $e) {
359
-                        echo "error : ".$e->getMessage();
360
-                }
361
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
362
-                if (empty($all)) {
363
-            		$Spotter = new Spotter($this->db);
364
-            		$all = $Spotter->countAllDatesLastMonth();
365
-                }
366
-                return $all;
355
+				 try {
356
+						$sth = $this->db->prepare($query);
357
+						$sth->execute($query_data);
358
+				} catch(PDOException $e) {
359
+						echo "error : ".$e->getMessage();
360
+				}
361
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
362
+				if (empty($all)) {
363
+					$Spotter = new Spotter($this->db);
364
+					$all = $Spotter->countAllDatesLastMonth();
365
+				}
366
+				return $all;
367 367
 	}
368 368
 	public function countAllDatesLast7Days() {
369 369
 		global $globalDBdriver;
@@ -373,64 +373,64 @@  discard block
 block discarded – undo
373 373
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS'";
374 374
 		}
375 375
 		$query_data = array();
376
-                 try {
377
-                        $sth = $this->db->prepare($query);
378
-                        $sth->execute($query_data);
379
-                } catch(PDOException $e) {
380
-                        echo "error : ".$e->getMessage();
381
-                }
382
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
383
-                if (empty($all)) {
384
-            		$Spotter = new Spotter($this->db);
385
-            		$all = $Spotter->countAllDatesLast7Days();
386
-                }
387
-                return $all;
376
+				 try {
377
+						$sth = $this->db->prepare($query);
378
+						$sth->execute($query_data);
379
+				} catch(PDOException $e) {
380
+						echo "error : ".$e->getMessage();
381
+				}
382
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
383
+				if (empty($all)) {
384
+					$Spotter = new Spotter($this->db);
385
+					$all = $Spotter->countAllDatesLast7Days();
386
+				}
387
+				return $all;
388 388
 	}
389 389
 	public function countAllDates() {
390 390
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date'";
391 391
 		$query_data = array();
392
-                 try {
393
-                        $sth = $this->db->prepare($query);
394
-                        $sth->execute($query_data);
395
-                } catch(PDOException $e) {
396
-                        echo "error : ".$e->getMessage();
397
-                }
398
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
399
-                if (empty($all)) {
400
-            		$Spotter = new Spotter($this->db);
401
-            		$all = $Spotter->countAllDates();
402
-                }
403
-                return $all;
392
+				 try {
393
+						$sth = $this->db->prepare($query);
394
+						$sth->execute($query_data);
395
+				} catch(PDOException $e) {
396
+						echo "error : ".$e->getMessage();
397
+				}
398
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
399
+				if (empty($all)) {
400
+					$Spotter = new Spotter($this->db);
401
+					$all = $Spotter->countAllDates();
402
+				}
403
+				return $all;
404 404
 	}
405 405
 	public function countAllMonths() {
406
-	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth'";
407
-                 try {
408
-                        $sth = $this->db->prepare($query);
409
-                        $sth->execute();
410
-                } catch(PDOException $e) {
411
-                        echo "error : ".$e->getMessage();
412
-                }
413
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
414
-                if (empty($all)) {
415
-            		$Spotter = new Spotter($this->db);
416
-            		$all = $Spotter->countAllMonths();
417
-                }
418
-                return $all;
406
+			$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth'";
407
+				 try {
408
+						$sth = $this->db->prepare($query);
409
+						$sth->execute();
410
+				} catch(PDOException $e) {
411
+						echo "error : ".$e->getMessage();
412
+				}
413
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
414
+				if (empty($all)) {
415
+					$Spotter = new Spotter($this->db);
416
+					$all = $Spotter->countAllMonths();
417
+				}
418
+				return $all;
419 419
 	}
420 420
 	public function countAllMilitaryMonths() {
421
-	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth'";
422
-                 try {
423
-                        $sth = $this->db->prepare($query);
424
-                        $sth->execute();
425
-                } catch(PDOException $e) {
426
-                        echo "error : ".$e->getMessage();
427
-                }
428
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
429
-                if (empty($all)) {
430
-            		$Spotter = new Spotter($this->db);
431
-            		$all = $Spotter->countAllMilitaryMonths();
432
-                }
433
-                return $all;
421
+			$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth'";
422
+				 try {
423
+						$sth = $this->db->prepare($query);
424
+						$sth->execute();
425
+				} catch(PDOException $e) {
426
+						echo "error : ".$e->getMessage();
427
+				}
428
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
429
+				if (empty($all)) {
430
+					$Spotter = new Spotter($this->db);
431
+					$all = $Spotter->countAllMilitaryMonths();
432
+				}
433
+				return $all;
434 434
 	}
435 435
 	public function countAllHours($orderby = 'hour',$limit = true) {
436 436
 		global $globalTimezone;
@@ -438,18 +438,18 @@  discard block
 block discarded – undo
438 438
 		else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour'";
439 439
 		if ($orderby == 'hour') $query .= " ORDER BY CAST(flight_date AS integer) ASC";
440 440
 		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
441
-                 try {
442
-                        $sth = $this->db->prepare($query);
443
-                        $sth->execute();
444
-                } catch(PDOException $e) {
445
-                        echo "error : ".$e->getMessage();
446
-                }
447
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
448
-                if (empty($all)) {
449
-            		$Spotter = new Spotter($this->db);
450
-            		$all = $Spotter->countAllHours($orderby,$limit);
451
-                }
452
-                return $all;
441
+				 try {
442
+						$sth = $this->db->prepare($query);
443
+						$sth->execute();
444
+				} catch(PDOException $e) {
445
+						echo "error : ".$e->getMessage();
446
+				}
447
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
448
+				if (empty($all)) {
449
+					$Spotter = new Spotter($this->db);
450
+					$all = $Spotter->countAllHours($orderby,$limit);
451
+				}
452
+				return $all;
453 453
 	}
454 454
 	
455 455
 	public function countOverallFlights() {
@@ -512,157 +512,157 @@  discard block
 block discarded – undo
512 512
 	public function getLast7DaysAirports($airport_icao = '') {
513 513
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao ORDER BY date";
514 514
 		$query_values = array(':airport_icao' => $airport_icao);
515
-                 try {
516
-                        $sth = $this->db->prepare($query);
517
-                        $sth->execute($query_values);
518
-                } catch(PDOException $e) {
519
-                        echo "error : ".$e->getMessage();
520
-                }
521
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
522
-                return $all;
515
+				 try {
516
+						$sth = $this->db->prepare($query);
517
+						$sth->execute($query_values);
518
+				} catch(PDOException $e) {
519
+						echo "error : ".$e->getMessage();
520
+				}
521
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
522
+				return $all;
523 523
 	}
524 524
 	public function getStats($type) {
525
-                $query = "SELECT * FROM stats WHERE stats_type = :type ORDER BY stats_date";
526
-                $query_values = array(':type' => $type);
527
-                 try {
528
-                        $sth = $this->db->prepare($query);
529
-                        $sth->execute($query_values);
530
-                } catch(PDOException $e) {
531
-                        echo "error : ".$e->getMessage();
532
-                }
533
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
534
-                return $all;
535
-        }
525
+				$query = "SELECT * FROM stats WHERE stats_type = :type ORDER BY stats_date";
526
+				$query_values = array(':type' => $type);
527
+				 try {
528
+						$sth = $this->db->prepare($query);
529
+						$sth->execute($query_values);
530
+				} catch(PDOException $e) {
531
+						echo "error : ".$e->getMessage();
532
+				}
533
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
534
+				return $all;
535
+		}
536 536
 	public function getSumStats($type,$year) {
537
-    		global $globalArchiveMonths, $globalDBdriver;
538
-    		if ($globalDBdriver == 'mysql') {
539
-	                $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year";
540
-	        } else {
541
-            		$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year";
542
-                }
543
-                $query_values = array(':type' => $type, ':year' => $year);
544
-                 try {
545
-                        $sth = $this->db->prepare($query);
546
-                        $sth->execute($query_values);
547
-                } catch(PDOException $e) {
548
-                        echo "error : ".$e->getMessage();
549
-                }
550
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
551
-                return $all[0]['total'];
552
-        }
537
+			global $globalArchiveMonths, $globalDBdriver;
538
+			if ($globalDBdriver == 'mysql') {
539
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year";
540
+			} else {
541
+					$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year";
542
+				}
543
+				$query_values = array(':type' => $type, ':year' => $year);
544
+				 try {
545
+						$sth = $this->db->prepare($query);
546
+						$sth->execute($query_values);
547
+				} catch(PDOException $e) {
548
+						echo "error : ".$e->getMessage();
549
+				}
550
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
551
+				return $all[0]['total'];
552
+		}
553 553
 	public function getStatsTotal($type) {
554
-    		global $globalArchiveMonths, $globalDBdriver;
555
-    		if ($globalDBdriver == 'mysql') {
554
+			global $globalArchiveMonths, $globalDBdriver;
555
+			if ($globalDBdriver == 'mysql') {
556 556
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH)";
557 557
 		} else {
558 558
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS'";
559
-                }
560
-                $query_values = array(':type' => $type);
561
-                 try {
562
-                        $sth = $this->db->prepare($query);
563
-                        $sth->execute($query_values);
564
-                } catch(PDOException $e) {
565
-                        echo "error : ".$e->getMessage();
566
-                }
567
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
568
-                return $all[0]['total'];
569
-        }
559
+				}
560
+				$query_values = array(':type' => $type);
561
+				 try {
562
+						$sth = $this->db->prepare($query);
563
+						$sth->execute($query_values);
564
+				} catch(PDOException $e) {
565
+						echo "error : ".$e->getMessage();
566
+				}
567
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
568
+				return $all[0]['total'];
569
+		}
570 570
 	public function getStatsAircraftTotal() {
571
-    		global $globalArchiveMonths, $globalDBdriver;
572
-    		if ($globalDBdriver == 'mysql') {
571
+			global $globalArchiveMonths, $globalDBdriver;
572
+			if ($globalDBdriver == 'mysql') {
573 573
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft";
574
-                } else {
574
+				} else {
575 575
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft";
576
-                }
577
-                 try {
578
-                        $sth = $this->db->prepare($query);
579
-                        $sth->execute();
580
-                } catch(PDOException $e) {
581
-                        echo "error : ".$e->getMessage();
582
-                }
583
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
584
-                return $all[0]['total'];
585
-        }
576
+				}
577
+				 try {
578
+						$sth = $this->db->prepare($query);
579
+						$sth->execute();
580
+				} catch(PDOException $e) {
581
+						echo "error : ".$e->getMessage();
582
+				}
583
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
584
+				return $all[0]['total'];
585
+		}
586 586
 	public function getStatsAirlineTotal() {
587
-    		global $globalArchiveMonths, $globalDBdriver;
588
-    		if ($globalDBdriver == 'mysql') {
587
+			global $globalArchiveMonths, $globalDBdriver;
588
+			if ($globalDBdriver == 'mysql') {
589 589
 			$query = "SELECT SUM(cnt) as total FROM stats_airline";
590
-                } else {
590
+				} else {
591 591
 			$query = "SELECT SUM(cnt) as total FROM stats_airline";
592
-                }
593
-                 try {
594
-                        $sth = $this->db->prepare($query);
595
-                        $sth->execute();
596
-                } catch(PDOException $e) {
597
-                        echo "error : ".$e->getMessage();
598
-                }
599
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
600
-                return $all[0]['total'];
601
-        }
592
+				}
593
+				 try {
594
+						$sth = $this->db->prepare($query);
595
+						$sth->execute();
596
+				} catch(PDOException $e) {
597
+						echo "error : ".$e->getMessage();
598
+				}
599
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
600
+				return $all[0]['total'];
601
+		}
602 602
 	public function getStatsOwnerTotal() {
603
-    		global $globalArchiveMonths, $globalDBdriver;
604
-    		if ($globalDBdriver == 'mysql') {
603
+			global $globalArchiveMonths, $globalDBdriver;
604
+			if ($globalDBdriver == 'mysql') {
605 605
 			$query = "SELECT SUM(cnt) as total FROM stats_owner";
606 606
 		} else {
607 607
 			$query = "SELECT SUM(cnt) as total FROM stats_owner";
608
-                }
609
-                 try {
610
-                        $sth = $this->db->prepare($query);
611
-                        $sth->execute();
612
-                } catch(PDOException $e) {
613
-                        echo "error : ".$e->getMessage();
614
-                }
615
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
616
-                return $all[0]['total'];
617
-        }
608
+				}
609
+				 try {
610
+						$sth = $this->db->prepare($query);
611
+						$sth->execute();
612
+				} catch(PDOException $e) {
613
+						echo "error : ".$e->getMessage();
614
+				}
615
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
616
+				return $all[0]['total'];
617
+		}
618 618
 	public function getStatsPilotTotal() {
619
-    		global $globalArchiveMonths, $globalDBdriver;
620
-    		if ($globalDBdriver == 'mysql') {
621
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot";
622
-            	} else {
623
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot";
624
-            	}
625
-                 try {
626
-                        $sth = $this->db->prepare($query);
627
-                        $sth->execute();
628
-                } catch(PDOException $e) {
629
-                        echo "error : ".$e->getMessage();
630
-                }
631
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
632
-                return $all[0]['total'];
633
-        }
619
+			global $globalArchiveMonths, $globalDBdriver;
620
+			if ($globalDBdriver == 'mysql') {
621
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot";
622
+				} else {
623
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot";
624
+				}
625
+				 try {
626
+						$sth = $this->db->prepare($query);
627
+						$sth->execute();
628
+				} catch(PDOException $e) {
629
+						echo "error : ".$e->getMessage();
630
+				}
631
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
632
+				return $all[0]['total'];
633
+		}
634 634
 
635 635
 	public function addStat($type,$cnt,$stats_date) {
636 636
 		global $globalDBdriver;
637 637
 		if ($globalDBdriver == 'mysql') {
638 638
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = :cnt";
639
-                } else {
639
+				} else {
640 640
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date; INSERT INTO stats (stats_type,cnt,stats_date) SELECT :type,:cnt,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date);"; 
641 641
 		}
642
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date);
643
-                 try {
644
-                        $sth = $this->db->prepare($query);
645
-                        $sth->execute($query_values);
646
-                } catch(PDOException $e) {
647
-                        return "error : ".$e->getMessage();
648
-                }
649
-        }
642
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date);
643
+				 try {
644
+						$sth = $this->db->prepare($query);
645
+						$sth->execute($query_values);
646
+				} catch(PDOException $e) {
647
+						return "error : ".$e->getMessage();
648
+				}
649
+		}
650 650
 	public function updateStat($type,$cnt,$stats_date) {
651 651
 		global $globalDBdriver;
652 652
 		if ($globalDBdriver == 'mysql') {
653 653
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
654 654
 		} else {
655
-            		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
655
+					//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
656 656
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date; INSERT INTO stats (stats_type,cnt,stats_date) SELECT :type,:cnt,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date);"; 
657
-                }
658
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date);
659
-                 try {
660
-                        $sth = $this->db->prepare($query);
661
-                        $sth->execute($query_values);
662
-                } catch(PDOException $e) {
663
-                        return "error : ".$e->getMessage();
664
-                }
665
-        }
657
+				}
658
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date);
659
+				 try {
660
+						$sth = $this->db->prepare($query);
661
+						$sth->execute($query_values);
662
+				} catch(PDOException $e) {
663
+						return "error : ".$e->getMessage();
664
+				}
665
+		}
666 666
 	public function getStatsSource($date,$stats_type = '') {
667 667
 		if ($stats_type == '') {
668 668
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -671,15 +671,15 @@  discard block
 block discarded – undo
671 671
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";
672 672
 			$query_values = array(':date' => $date,':stats_type' => $stats_type);
673 673
 		}
674
-                 try {
675
-                        $sth = $this->db->prepare($query);
676
-                        $sth->execute($query_values);
677
-                } catch(PDOException $e) {
678
-                        echo "error : ".$e->getMessage();
679
-                }
680
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
681
-                return $all;
682
-        }
674
+				 try {
675
+						$sth = $this->db->prepare($query);
676
+						$sth->execute($query_values);
677
+				} catch(PDOException $e) {
678
+						echo "error : ".$e->getMessage();
679
+				}
680
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
681
+				return $all;
682
+		}
683 683
 
684 684
 	public function addStatSource($data,$source_name,$stats_type,$date) {
685 685
 		global $globalDBdriver;
@@ -687,25 +687,25 @@  discard block
 block discarded – undo
687 687
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
688 688
 		} else {
689 689
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
690
-                }
691
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
692
-                 try {
693
-                        $sth = $this->db->prepare($query);
694
-                        $sth->execute($query_values);
695
-                } catch(PDOException $e) {
696
-                        return "error : ".$e->getMessage();
697
-                }
698
-        }
690
+				}
691
+				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
692
+				 try {
693
+						$sth = $this->db->prepare($query);
694
+						$sth->execute($query_values);
695
+				} catch(PDOException $e) {
696
+						return "error : ".$e->getMessage();
697
+				}
698
+		}
699 699
 	public function addStatFlight($type,$date_name,$cnt) {
700
-                $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt) VALUES (:type,:flight_date,:cnt)";
701
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt);
702
-                 try {
703
-                        $sth = $this->db->prepare($query);
704
-                        $sth->execute($query_values);
705
-                } catch(PDOException $e) {
706
-                        return "error : ".$e->getMessage();
707
-                }
708
-        }
700
+				$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt) VALUES (:type,:flight_date,:cnt)";
701
+				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt);
702
+				 try {
703
+						$sth = $this->db->prepare($query);
704
+						$sth->execute($query_values);
705
+				} catch(PDOException $e) {
706
+						return "error : ".$e->getMessage();
707
+				}
708
+		}
709 709
 	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '') {
710 710
 		global $globalDBdriver;
711 711
 		if ($globalDBdriver == 'mysql') {
@@ -713,14 +713,14 @@  discard block
 block discarded – undo
713 713
 		} else {
714 714
 			$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration; INSERT INTO stats_registration (aircraft_icao,registration,cnt) SELECT :aircraft_icao,:registration,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration);"; 
715 715
 		}
716
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt);
717
-                 try {
718
-                        $sth = $this->db->prepare($query);
719
-                        $sth->execute($query_values);
720
-                } catch(PDOException $e) {
721
-                        return "error : ".$e->getMessage();
722
-                }
723
-        }
716
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt);
717
+				 try {
718
+						$sth = $this->db->prepare($query);
719
+						$sth->execute($query_values);
720
+				} catch(PDOException $e) {
721
+						return "error : ".$e->getMessage();
722
+				}
723
+		}
724 724
 	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '') {
725 725
 		global $globalDBdriver;
726 726
 		if ($globalDBdriver == 'mysql') {
@@ -728,14 +728,14 @@  discard block
 block discarded – undo
728 728
 		} else {
729 729
 			$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt) SELECT :callsign_icao,:airline_icao,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao);"; 
730 730
 		}
731
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt);
732
-                 try {
733
-                        $sth = $this->db->prepare($query);
734
-                        $sth->execute($query_values);
735
-                } catch(PDOException $e) {
736
-                        return "error : ".$e->getMessage();
737
-                }
738
-        }
731
+				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt);
732
+				 try {
733
+						$sth = $this->db->prepare($query);
734
+						$sth->execute($query_values);
735
+				} catch(PDOException $e) {
736
+						return "error : ".$e->getMessage();
737
+				}
738
+		}
739 739
 	public function addStatCountry($iso2,$iso3,$name,$cnt) {
740 740
 		global $globalDBdriver;
741 741
 		if ($globalDBdriver == 'mysql') {
@@ -743,14 +743,14 @@  discard block
 block discarded – undo
743 743
 		} else {
744 744
 			$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2; INSERT INTO stats_country (iso2,iso3,name,cnt) SELECT :iso2,:iso3,:name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2);"; 
745 745
 		}
746
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt);
747
-                 try {
748
-                        $sth = $this->db->prepare($query);
749
-                        $sth->execute($query_values);
750
-                } catch(PDOException $e) {
751
-                        return "error : ".$e->getMessage();
752
-                }
753
-        }
746
+				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt);
747
+				 try {
748
+						$sth = $this->db->prepare($query);
749
+						$sth->execute($query_values);
750
+				} catch(PDOException $e) {
751
+						return "error : ".$e->getMessage();
752
+				}
753
+		}
754 754
 	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '') {
755 755
 		global $globalDBdriver;
756 756
 		if ($globalDBdriver == 'mysql') {
@@ -758,14 +758,14 @@  discard block
 block discarded – undo
758 758
 		} else {
759 759
 			$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt WHERE aircraft_icao = :aircraft_icao; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,cnt) SELECT :aircraft_icao,:aircraft_name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao);"; 
760 760
 		}
761
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt);
762
-                 try {
763
-                        $sth = $this->db->prepare($query);
764
-                        $sth->execute($query_values);
765
-                } catch(PDOException $e) {
766
-                        return "error : ".$e->getMessage();
767
-                }
768
-        }
761
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt);
762
+				 try {
763
+						$sth = $this->db->prepare($query);
764
+						$sth->execute($query_values);
765
+				} catch(PDOException $e) {
766
+						return "error : ".$e->getMessage();
767
+				}
768
+		}
769 769
 	public function addStatAirline($airline_icao,$cnt,$airline_name = '') {
770 770
 		global $globalDBdriver;
771 771
 		if ($globalDBdriver == 'mysql') {
@@ -773,14 +773,14 @@  discard block
 block discarded – undo
773 773
 		} else {
774 774
 			$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao; INSERT INTO stats_airline (airline_icao,airline_name,cnt) SELECT :airline_icao,:airline_name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao);"; 
775 775
 		}
776
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt);
777
-                 try {
778
-                        $sth = $this->db->prepare($query);
779
-                        $sth->execute($query_values);
780
-                } catch(PDOException $e) {
781
-                        return "error : ".$e->getMessage();
782
-                }
783
-        }
776
+				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt);
777
+				 try {
778
+						$sth = $this->db->prepare($query);
779
+						$sth->execute($query_values);
780
+				} catch(PDOException $e) {
781
+						return "error : ".$e->getMessage();
782
+				}
783
+		}
784 784
 	public function addStatOwner($owner_name,$cnt) {
785 785
 		global $globalDBdriver;
786 786
 		if ($globalDBdriver == 'mysql') {
@@ -788,14 +788,14 @@  discard block
 block discarded – undo
788 788
 		} else {
789 789
 			$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name; INSERT INTO stats_owner (owner_name,cnt) SELECT :owner_name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name);"; 
790 790
 		}
791
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt);
792
-                 try {
793
-                        $sth = $this->db->prepare($query);
794
-                        $sth->execute($query_values);
795
-                } catch(PDOException $e) {
796
-                        return "error : ".$e->getMessage();
797
-                }
798
-        }
791
+				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt);
792
+				 try {
793
+						$sth = $this->db->prepare($query);
794
+						$sth->execute($query_values);
795
+				} catch(PDOException $e) {
796
+						return "error : ".$e->getMessage();
797
+				}
798
+		}
799 799
 	public function addStatPilot($pilot_id,$cnt) {
800 800
 		global $globalDBdriver;
801 801
 		if ($globalDBdriver == 'mysql') {
@@ -803,14 +803,14 @@  discard block
 block discarded – undo
803 803
 		} else {
804 804
 			$query = "UPDATE stats_pilot SET cnt = cnt+:cnt WHERE pilot_id = :pilot_id; INSERT INTO stats_pilot (pilot_id,cnt) SELECT :pilot_id,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id);"; 
805 805
 		}
806
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt);
807
-                 try {
808
-                        $sth = $this->db->prepare($query);
809
-                        $sth->execute($query_values);
810
-                } catch(PDOException $e) {
811
-                        return "error : ".$e->getMessage();
812
-                }
813
-        }
806
+				$query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt);
807
+				 try {
808
+						$sth = $this->db->prepare($query);
809
+						$sth->execute($query_values);
810
+				} catch(PDOException $e) {
811
+						return "error : ".$e->getMessage();
812
+				}
813
+		}
814 814
 	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure) {
815 815
 		global $globalDBdriver;
816 816
 		if ($globalDBdriver == 'mysql') {
@@ -818,14 +818,14 @@  discard block
 block discarded – undo
818 818
 		} else {
819 819
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'yearly');"; 
820 820
 		}
821
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00');
822
-                 try {
823
-                        $sth = $this->db->prepare($query);
824
-                        $sth->execute($query_values);
825
-                } catch(PDOException $e) {
826
-                        return "error : ".$e->getMessage();
827
-                }
828
-        }
821
+				$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00');
822
+				 try {
823
+						$sth = $this->db->prepare($query);
824
+						$sth->execute($query_values);
825
+				} catch(PDOException $e) {
826
+						return "error : ".$e->getMessage();
827
+				}
828
+		}
829 829
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure) {
830 830
 		global $globalDBdriver;
831 831
 		if ($globalDBdriver == 'mysql') {
@@ -833,14 +833,14 @@  discard block
 block discarded – undo
833 833
 		} else {
834 834
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'daily'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'daily');"; 
835 835
 		}
836
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date);
837
-                 try {
838
-                        $sth = $this->db->prepare($query);
839
-                        $sth->execute($query_values);
840
-                } catch(PDOException $e) {
841
-                        return "error : ".$e->getMessage();
842
-                }
843
-        }
836
+				$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date);
837
+				 try {
838
+						$sth = $this->db->prepare($query);
839
+						$sth->execute($query_values);
840
+				} catch(PDOException $e) {
841
+						return "error : ".$e->getMessage();
842
+				}
843
+		}
844 844
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival) {
845 845
 		global $globalDBdriver;
846 846
 		if ($globalDBdriver == 'mysql') {
@@ -848,14 +848,14 @@  discard block
 block discarded – undo
848 848
 		} else {
849 849
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'yearly');"; 
850 850
 		}
851
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00');
852
-                 try {
853
-                        $sth = $this->db->prepare($query);
854
-                        $sth->execute($query_values);
855
-                } catch(PDOException $e) {
856
-                        return "error : ".$e->getMessage();
857
-                }
858
-        }
851
+				$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00');
852
+				 try {
853
+						$sth = $this->db->prepare($query);
854
+						$sth->execute($query_values);
855
+				} catch(PDOException $e) {
856
+						return "error : ".$e->getMessage();
857
+				}
858
+		}
859 859
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival) {
860 860
 		global $globalDBdriver;
861 861
 		if ($globalDBdriver == 'mysql') {
@@ -863,55 +863,55 @@  discard block
 block discarded – undo
863 863
 		} else {
864 864
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'daily');"; 
865 865
 		}
866
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date);
867
-                 try {
868
-                        $sth = $this->db->prepare($query);
869
-                        $sth->execute($query_values);
870
-                } catch(PDOException $e) {
871
-                        return "error : ".$e->getMessage();
872
-                }
873
-        }
866
+				$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date);
867
+				 try {
868
+						$sth = $this->db->prepare($query);
869
+						$sth->execute($query_values);
870
+				} catch(PDOException $e) {
871
+						return "error : ".$e->getMessage();
872
+				}
873
+		}
874 874
 
875 875
 	public function deleteStat($id) {
876
-                $query = "DELETE FROM stats WHERE stats_id = :id";
877
-                $query_values = array(':id' => $id);
878
-                 try {
879
-                        $sth = $this->db->prepare($query);
880
-                        $sth->execute($query_values);
881
-                } catch(PDOException $e) {
882
-                        return "error : ".$e->getMessage();
883
-                }
884
-        }
876
+				$query = "DELETE FROM stats WHERE stats_id = :id";
877
+				$query_values = array(':id' => $id);
878
+				 try {
879
+						$sth = $this->db->prepare($query);
880
+						$sth->execute($query_values);
881
+				} catch(PDOException $e) {
882
+						return "error : ".$e->getMessage();
883
+				}
884
+		}
885 885
 	public function deleteStatFlight($type) {
886
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
887
-                $query_values = array(':type' => $type);
888
-                 try {
889
-                        $sth = $this->db->prepare($query);
890
-                        $sth->execute($query_values);
891
-                } catch(PDOException $e) {
892
-                        return "error : ".$e->getMessage();
893
-                }
894
-        }
886
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
887
+				$query_values = array(':type' => $type);
888
+				 try {
889
+						$sth = $this->db->prepare($query);
890
+						$sth->execute($query_values);
891
+				} catch(PDOException $e) {
892
+						return "error : ".$e->getMessage();
893
+				}
894
+		}
895 895
 	public function deleteStatAirport($type) {
896
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
897
-                $query_values = array(':type' => $type);
898
-                 try {
899
-                        $sth = $this->db->prepare($query);
900
-                        $sth->execute($query_values);
901
-                } catch(PDOException $e) {
902
-                        return "error : ".$e->getMessage();
903
-                }
904
-        }
896
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
897
+				$query_values = array(':type' => $type);
898
+				 try {
899
+						$sth = $this->db->prepare($query);
900
+						$sth->execute($query_values);
901
+				} catch(PDOException $e) {
902
+						return "error : ".$e->getMessage();
903
+				}
904
+		}
905 905
         
906
-        public function addOldStats() {
907
-    		global $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver;
908
-    		$Common = new Common();
909
-    		$Connection = new Connection();
910
-    		date_default_timezone_set('UTC');
911
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
906
+		public function addOldStats() {
907
+			global $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver;
908
+			$Common = new Common();
909
+			$Connection = new Connection();
910
+			date_default_timezone_set('UTC');
911
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
912 912
 		//print_r($last_update);
913 913
 		$flightsbymonth = $this->getStats('flights_by_month');
914
-    		if (empty($last_update) && empty($flightsbymonth)) {
914
+			if (empty($last_update) && empty($flightsbymonth)) {
915 915
 			// Initial update
916 916
 			$Spotter = new Spotter($this->db);
917 917
 			$alldata = $Spotter->countAllMonths();
@@ -1052,46 +1052,46 @@  discard block
 block discarded – undo
1052 1052
 					$this->addStatPilot($number['pilot_id'],$number['pilot_count']);
1053 1053
 				}
1054 1054
 				$pall = $Spotter->countAllDepartureAirports(false,$globalArchiveMonths);
1055
-        			$dall = $Spotter->countAllDetectedDepartureAirports(false,$globalArchiveMonths);
1056
-	        		$alldata = array();
1057
-    				foreach ($pall as $value) {
1058
-	        			$icao = $value['airport_departure_icao'];
1059
-    					$alldata[$icao] = $value;
1060
-	        		}
1061
-	        		foreach ($dall as $value) {
1062
-    					$icao = $value['airport_departure_icao'];
1063
-        				if (isset($alldata[$icao])) {                                                           
1064
-        					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1065
-	        			} else $alldata[$icao] = $value;
1066
-    				}
1067
-        			$count = array();
1068
-        			foreach ($alldata as $key => $row) {
1069
-        				$count[$key] = $row['airport_departure_icao_count'];
1070
-	        		}
1071
-    				array_multisort($count,SORT_DESC,$alldata);
1055
+					$dall = $Spotter->countAllDetectedDepartureAirports(false,$globalArchiveMonths);
1056
+					$alldata = array();
1057
+					foreach ($pall as $value) {
1058
+						$icao = $value['airport_departure_icao'];
1059
+						$alldata[$icao] = $value;
1060
+					}
1061
+					foreach ($dall as $value) {
1062
+						$icao = $value['airport_departure_icao'];
1063
+						if (isset($alldata[$icao])) {                                                           
1064
+							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1065
+						} else $alldata[$icao] = $value;
1066
+					}
1067
+					$count = array();
1068
+					foreach ($alldata as $key => $row) {
1069
+						$count[$key] = $row['airport_departure_icao_count'];
1070
+					}
1071
+					array_multisort($count,SORT_DESC,$alldata);
1072 1072
 
1073 1073
 				//print_r($alldate);
1074 1074
 				foreach ($alldata as $number) {
1075 1075
 					$this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1076 1076
 				}
1077 1077
 				$pdata = $Spotter->countAllArrivalAirports(false,$globalArchiveMonths);
1078
-        			$dall = $Spotter->countAllDetectedArrivalAirports(false,$globalArchiveMonths);
1079
-	        		$alldata = array();
1080
-    				foreach ($pdata as $value) {
1081
-	        			$icao = $value['airport_arrival_icao'];
1082
-    					$alldata[$icao] = $value;
1083
-	        		}
1084
-	        		foreach ($dall as $value) {
1085
-    					$icao = $value['airport_arrival_icao'];
1086
-        				if (isset($alldata[$icao])) {                                                           
1087
-        					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1088
-	        			} else $alldata[$icao] = $value;
1089
-    				}
1090
-        			$count = array();
1091
-        			foreach ($alldata as $key => $row) {
1092
-        				$count[$key] = $row['airport_arrival_icao_count'];
1093
-	        		}
1094
-    				array_multisort($count,SORT_DESC,$alldata);
1078
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,$globalArchiveMonths);
1079
+					$alldata = array();
1080
+					foreach ($pdata as $value) {
1081
+						$icao = $value['airport_arrival_icao'];
1082
+						$alldata[$icao] = $value;
1083
+					}
1084
+					foreach ($dall as $value) {
1085
+						$icao = $value['airport_arrival_icao'];
1086
+						if (isset($alldata[$icao])) {                                                           
1087
+							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1088
+						} else $alldata[$icao] = $value;
1089
+					}
1090
+					$count = array();
1091
+					foreach ($alldata as $key => $row) {
1092
+						$count[$key] = $row['airport_arrival_icao_count'];
1093
+					}
1094
+					array_multisort($count,SORT_DESC,$alldata);
1095 1095
 				foreach ($alldata as $number) {
1096 1096
 					$this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1097 1097
 				}
@@ -1159,46 +1159,46 @@  discard block
 block discarded – undo
1159 1159
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count']);
1160 1160
 			}
1161 1161
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1162
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1163
-	        	$alldata = array();
1164
-    			foreach ($pall as $value) {
1165
-	        		$icao = $value['airport_departure_icao'];
1166
-    				$alldata[$icao] = $value;
1167
-	        	}
1168
-	        	foreach ($dall as $value) {
1169
-    				$icao = $value['airport_departure_icao'];
1170
-        			if (isset($alldata[$icao])) {                                                           
1171
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1172
-        			} else $alldata[$icao] = $value;
1162
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1163
+				$alldata = array();
1164
+				foreach ($pall as $value) {
1165
+					$icao = $value['airport_departure_icao'];
1166
+					$alldata[$icao] = $value;
1167
+				}
1168
+				foreach ($dall as $value) {
1169
+					$icao = $value['airport_departure_icao'];
1170
+					if (isset($alldata[$icao])) {                                                           
1171
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1172
+					} else $alldata[$icao] = $value;
1173 1173
 			}
1174
-    			$count = array();
1175
-    			foreach ($alldata as $key => $row) {
1176
-    				$count[$key] = $row['airport_departure_icao_count'];
1177
-        		}
1174
+				$count = array();
1175
+				foreach ($alldata as $key => $row) {
1176
+					$count[$key] = $row['airport_departure_icao_count'];
1177
+				}
1178 1178
 			array_multisort($count,SORT_DESC,$alldata);
1179 1179
 
1180 1180
 			foreach ($alldata as $number) {
1181 1181
 				$this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1182 1182
 			}
1183 1183
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1184
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1185
-	        	$alldata = array();
1186
-    			foreach ($pall as $value) {
1187
-	        		$icao = $value['airport_arrival_icao'];
1188
-    				$alldata[$icao] = $value;
1189
-	        	}
1190
-	        	foreach ($dall as $value) {
1191
-    				$icao = $value['airport_arrival_icao'];
1192
-        			if (isset($alldata[$icao])) {                                                           
1193
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1194
-	        		} else $alldata[$icao] = $value;
1195
-    			}
1196
-        		$count = array();
1197
-        		foreach ($alldata as $key => $row) {
1198
-        			$count[$key] = $row['airport_arrival_icao_count'];
1199
-	        	}
1200
-    			array_multisort($count,SORT_DESC,$alldata);
1201
-                        foreach ($alldata as $number) {
1184
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1185
+				$alldata = array();
1186
+				foreach ($pall as $value) {
1187
+					$icao = $value['airport_arrival_icao'];
1188
+					$alldata[$icao] = $value;
1189
+				}
1190
+				foreach ($dall as $value) {
1191
+					$icao = $value['airport_arrival_icao'];
1192
+					if (isset($alldata[$icao])) {                                                           
1193
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1194
+					} else $alldata[$icao] = $value;
1195
+				}
1196
+				$count = array();
1197
+				foreach ($alldata as $key => $row) {
1198
+					$count[$key] = $row['airport_arrival_icao_count'];
1199
+				}
1200
+				array_multisort($count,SORT_DESC,$alldata);
1201
+						foreach ($alldata as $number) {
1202 1202
 				$this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1203 1203
 			}
1204 1204
 			if ($Connection->tableExists('countries')) {
@@ -1248,45 +1248,45 @@  discard block
 block discarded – undo
1248 1248
 			echo '...Departure'."\n";
1249 1249
 			$this->deleteStatAirport('daily');
1250 1250
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1251
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1252
-	        	$alldata = array();
1253
-    			foreach ($pall as $value) {
1254
-	        		$icao = $value['departure_airport_icao'];
1255
-    				$alldata[$icao] = $value;
1256
-	        	}
1257
-	        	foreach ($dall as $value) {
1258
-    				$icao = $value['departure_airport_icao'];
1259
-        			if (isset($alldata[$icao])) {                                                           
1260
-        				$alldata[$icao]['departure_airport_count'] = $alldata[$icao]['departure_airport_count'] + $value['departure_airport_count'];
1261
-	        		} else $alldata[$icao] = $value;
1262
-    			}
1263
-        		$count = array();
1264
-        		foreach ($alldata as $key => $row) {
1265
-        			$count[$key] = $row['departure_airport_count'];
1266
-	        	}
1267
-    			array_multisort($count,SORT_DESC,$alldata);
1251
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1252
+				$alldata = array();
1253
+				foreach ($pall as $value) {
1254
+					$icao = $value['departure_airport_icao'];
1255
+					$alldata[$icao] = $value;
1256
+				}
1257
+				foreach ($dall as $value) {
1258
+					$icao = $value['departure_airport_icao'];
1259
+					if (isset($alldata[$icao])) {                                                           
1260
+						$alldata[$icao]['departure_airport_count'] = $alldata[$icao]['departure_airport_count'] + $value['departure_airport_count'];
1261
+					} else $alldata[$icao] = $value;
1262
+				}
1263
+				$count = array();
1264
+				foreach ($alldata as $key => $row) {
1265
+					$count[$key] = $row['departure_airport_count'];
1266
+				}
1267
+				array_multisort($count,SORT_DESC,$alldata);
1268 1268
 			foreach ($alldata as $number) {
1269 1269
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1270 1270
 			}
1271 1271
 			echo '...Arrival'."\n";
1272 1272
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1273
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1274
-	        	$alldata = array();
1275
-    			foreach ($pall as $value) {
1276
-	        		$icao = $value['arrival_airport_icao'];
1277
-    				$alldata[$icao] = $value;
1278
-	        	}
1279
-	        	foreach ($dall as $value) {
1280
-    				$icao = $value['arrival_airport_icao'];
1281
-        			if (isset($alldata[$icao])) {                                                           
1282
-        				$alldata[$icao]['arrival_airport_icao_count'] = $alldata[$icao]['arrival_airport_count'] + $value['arrival_airport_count'];
1283
-	        		} else $alldata[$icao] = $value;
1284
-    			}
1285
-        		$count = array();
1286
-        		foreach ($alldata as $key => $row) {
1287
-        			$count[$key] = $row['arrival_airport_count'];
1288
-	        	}
1289
-    			array_multisort($count,SORT_DESC,$alldata);
1273
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1274
+				$alldata = array();
1275
+				foreach ($pall as $value) {
1276
+					$icao = $value['arrival_airport_icao'];
1277
+					$alldata[$icao] = $value;
1278
+				}
1279
+				foreach ($dall as $value) {
1280
+					$icao = $value['arrival_airport_icao'];
1281
+					if (isset($alldata[$icao])) {                                                           
1282
+						$alldata[$icao]['arrival_airport_icao_count'] = $alldata[$icao]['arrival_airport_count'] + $value['arrival_airport_count'];
1283
+					} else $alldata[$icao] = $value;
1284
+				}
1285
+				$count = array();
1286
+				foreach ($alldata as $key => $row) {
1287
+					$count[$key] = $row['arrival_airport_count'];
1288
+				}
1289
+				array_multisort($count,SORT_DESC,$alldata);
1290 1290
 
1291 1291
 			foreach ($alldata as $number) {
1292 1292
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
Please login to merge, or discard this patch.
Spacing   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 		$this->db = $Connection->db;
14 14
         }
15 15
               
16
-	public function addLastStatsUpdate($type,$stats_date) {
16
+	public function addLastStatsUpdate($type, $stats_date) {
17 17
                 $query = "DELETE FROM config WHERE name = :type;
18 18
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
19
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
19
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
20 20
                  try {
21 21
                         $sth = $this->db->prepare($query);
22 22
                         $sth->execute($query_values);
23
-                } catch(PDOException $e) {
23
+                } catch (PDOException $e) {
24 24
                         return "error : ".$e->getMessage();
25 25
                 }
26 26
         }
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
                  try {
31 31
                         $sth = $this->db->prepare($query);
32 32
                         $sth->execute(array(':type' => $type));
33
-                } catch(PDOException $e) {
33
+                } catch (PDOException $e) {
34 34
                         echo "error : ".$e->getMessage();
35 35
                 }
36 36
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
                  try {
42 42
                         $sth = $this->db->prepare($query);
43 43
                         $sth->execute();
44
-                } catch(PDOException $e) {
44
+                } catch (PDOException $e) {
45 45
                         echo "error : ".$e->getMessage();
46 46
                 }
47 47
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
                  try {
53 53
                         $sth = $this->db->prepare($query);
54 54
                         $sth->execute();
55
-                } catch(PDOException $e) {
55
+                } catch (PDOException $e) {
56 56
                         echo "error : ".$e->getMessage();
57 57
                 }
58 58
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
                  try {
64 64
                         $sth = $this->db->prepare($query);
65 65
                         $sth->execute();
66
-                } catch(PDOException $e) {
66
+                } catch (PDOException $e) {
67 67
                         echo "error : ".$e->getMessage();
68 68
                 }
69 69
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                  try {
78 78
                         $sth = $this->db->prepare($query);
79 79
                         $sth->execute();
80
-                } catch(PDOException $e) {
80
+                } catch (PDOException $e) {
81 81
                         echo "error : ".$e->getMessage();
82 82
                 }
83 83
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
                  try {
94 94
                         $sth = $this->db->prepare($query);
95 95
                         $sth->execute();
96
-                } catch(PDOException $e) {
96
+                } catch (PDOException $e) {
97 97
                         echo "error : ".$e->getMessage();
98 98
                 }
99 99
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
                  try {
111 111
                         $sth = $this->db->prepare($query);
112 112
                         $sth->execute();
113
-                } catch(PDOException $e) {
113
+                } catch (PDOException $e) {
114 114
                         echo "error : ".$e->getMessage();
115 115
                 }
116 116
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                  try {
128 128
                         $sth = $this->db->prepare($query);
129 129
                         $sth->execute();
130
-                } catch(PDOException $e) {
130
+                } catch (PDOException $e) {
131 131
                         echo "error : ".$e->getMessage();
132 132
                 }
133 133
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                  try {
144 144
                         $sth = $this->db->prepare($query);
145 145
                         $sth->execute();
146
-                } catch(PDOException $e) {
146
+                } catch (PDOException $e) {
147 147
                         echo "error : ".$e->getMessage();
148 148
                 }
149 149
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                  try {
161 161
                         $sth = $this->db->prepare($query);
162 162
                         $sth->execute();
163
-                } catch(PDOException $e) {
163
+                } catch (PDOException $e) {
164 164
                         echo "error : ".$e->getMessage();
165 165
                 }
166 166
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
                  try {
177 177
                         $sth = $this->db->prepare($query);
178 178
                         $sth->execute();
179
-                } catch(PDOException $e) {
179
+                } catch (PDOException $e) {
180 180
                         echo "error : ".$e->getMessage();
181 181
                 }
182 182
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
                  try {
193 193
                         $sth = $this->db->prepare($query);
194 194
                         $sth->execute();
195
-                } catch(PDOException $e) {
195
+                } catch (PDOException $e) {
196 196
                         echo "error : ".$e->getMessage();
197 197
                 }
198 198
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			 try {
211 211
 				$sth = $this->db->prepare($query);
212 212
 				$sth->execute();
213
-			} catch(PDOException $e) {
213
+			} catch (PDOException $e) {
214 214
 				echo "error : ".$e->getMessage();
215 215
 			}
216 216
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
                  try {
232 232
                         $sth = $this->db->prepare($query);
233 233
                         $sth->execute();
234
-                } catch(PDOException $e) {
234
+                } catch (PDOException $e) {
235 235
                         echo "error : ".$e->getMessage();
236 236
                 }
237 237
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
                  try {
248 248
                         $sth = $this->db->prepare($query);
249 249
                         $sth->execute();
250
-                } catch(PDOException $e) {
250
+                } catch (PDOException $e) {
251 251
                         echo "error : ".$e->getMessage();
252 252
                 }
253 253
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
                  try {
264 264
                         $sth = $this->db->prepare($query);
265 265
                         $sth->execute();
266
-                } catch(PDOException $e) {
266
+                } catch (PDOException $e) {
267 267
                         echo "error : ".$e->getMessage();
268 268
                 }
269 269
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
         		foreach ($all as $key => $row) {
288 288
         			$count[$key] = $row['airport_departure_icao_count'];
289 289
         		}
290
-        		array_multisort($count,SORT_DESC,$all);
290
+        		array_multisort($count, SORT_DESC, $all);
291 291
                 }
292 292
                 return $all;
293 293
 	}
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
                  try {
298 298
                         $sth = $this->db->prepare($query);
299 299
                         $sth->execute();
300
-                } catch(PDOException $e) {
300
+                } catch (PDOException $e) {
301 301
                         echo "error : ".$e->getMessage();
302 302
                 }
303 303
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
         		foreach ($all as $key => $row) {
322 322
         			$count[$key] = $row['airport_arrival_icao_count'];
323 323
         		}
324
-        		array_multisort($count,SORT_DESC,$all);
324
+        		array_multisort($count, SORT_DESC, $all);
325 325
                 }
326 326
                 return $all;
327 327
 	}
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
                  try {
339 339
                         $sth = $this->db->prepare($query);
340 340
                         $sth->execute($query_data);
341
-                } catch(PDOException $e) {
341
+                } catch (PDOException $e) {
342 342
                         echo "error : ".$e->getMessage();
343 343
                 }
344 344
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
                  try {
356 356
                         $sth = $this->db->prepare($query);
357 357
                         $sth->execute($query_data);
358
-                } catch(PDOException $e) {
358
+                } catch (PDOException $e) {
359 359
                         echo "error : ".$e->getMessage();
360 360
                 }
361 361
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
                  try {
377 377
                         $sth = $this->db->prepare($query);
378 378
                         $sth->execute($query_data);
379
-                } catch(PDOException $e) {
379
+                } catch (PDOException $e) {
380 380
                         echo "error : ".$e->getMessage();
381 381
                 }
382 382
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
                  try {
393 393
                         $sth = $this->db->prepare($query);
394 394
                         $sth->execute($query_data);
395
-                } catch(PDOException $e) {
395
+                } catch (PDOException $e) {
396 396
                         echo "error : ".$e->getMessage();
397 397
                 }
398 398
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
                  try {
408 408
                         $sth = $this->db->prepare($query);
409 409
                         $sth->execute();
410
-                } catch(PDOException $e) {
410
+                } catch (PDOException $e) {
411 411
                         echo "error : ".$e->getMessage();
412 412
                 }
413 413
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
                  try {
423 423
                         $sth = $this->db->prepare($query);
424 424
                         $sth->execute();
425
-                } catch(PDOException $e) {
425
+                } catch (PDOException $e) {
426 426
                         echo "error : ".$e->getMessage();
427 427
                 }
428 428
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
                 }
433 433
                 return $all;
434 434
 	}
435
-	public function countAllHours($orderby = 'hour',$limit = true) {
435
+	public function countAllHours($orderby = 'hour', $limit = true) {
436 436
 		global $globalTimezone;
437 437
 		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour'";
438 438
 		else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour'";
@@ -441,19 +441,19 @@  discard block
 block discarded – undo
441 441
                  try {
442 442
                         $sth = $this->db->prepare($query);
443 443
                         $sth->execute();
444
-                } catch(PDOException $e) {
444
+                } catch (PDOException $e) {
445 445
                         echo "error : ".$e->getMessage();
446 446
                 }
447 447
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
448 448
                 if (empty($all)) {
449 449
             		$Spotter = new Spotter($this->db);
450
-            		$all = $Spotter->countAllHours($orderby,$limit);
450
+            		$all = $Spotter->countAllHours($orderby, $limit);
451 451
                 }
452 452
                 return $all;
453 453
 	}
454 454
 	
455 455
 	public function countOverallFlights() {
456
-		$all = $this->getSumStats('flights_bymonth',date('Y'));
456
+		$all = $this->getSumStats('flights_bymonth', date('Y'));
457 457
 		if (empty($all)) {
458 458
 			$Spotter = new Spotter($this->db);
459 459
 			$all = $Spotter->countOverallFlights();
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 		return $all;
462 462
 	}
463 463
 	public function countOverallMilitaryFlights() {
464
-		$all = $this->getSumStats('military_flights_bymonth',date('Y'));
464
+		$all = $this->getSumStats('military_flights_bymonth', date('Y'));
465 465
 		if (empty($all)) {
466 466
 			$Spotter = new Spotter($this->db);
467 467
 			$all = $Spotter->countOverallMilitaryFlights();
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 		return $all;
470 470
 	}
471 471
 	public function countOverallArrival() {
472
-		$all = $this->getSumStats('realarrivals_bymonth',date('Y'));
472
+		$all = $this->getSumStats('realarrivals_bymonth', date('Y'));
473 473
 		if (empty($all)) {
474 474
 			$Spotter = new Spotter($this->db);
475 475
 			$all = $Spotter->countOverallArrival();
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 		return $all;
478 478
 	}
479 479
 	public function countOverallAircrafts() {
480
-		$all = $this->getSumStats('aircrafts_bymonth',date('Y'));
480
+		$all = $this->getSumStats('aircrafts_bymonth', date('Y'));
481 481
 		if (empty($all)) {
482 482
 			$Spotter = new Spotter($this->db);
483 483
 			$all = $Spotter->countOverallAircrafts();
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 		return $all;
486 486
 	}
487 487
 	public function countOverallAirlines() {
488
-		$all = $this->getSumStats('airlines_bymonth',date('Y'));
488
+		$all = $this->getSumStats('airlines_bymonth', date('Y'));
489 489
 		if (empty($all)) {
490 490
 			$Spotter = new Spotter($this->db);
491 491
 			$all = $Spotter->countOverallAirlines();
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 		return $all;
494 494
 	}
495 495
 	public function countOverallOwners() {
496
-		$all = $this->getSumStats('owners_bymonth',date('Y'));
496
+		$all = $this->getSumStats('owners_bymonth', date('Y'));
497 497
 		if (empty($all)) {
498 498
 			$Spotter = new Spotter($this->db);
499 499
 			$all = $Spotter->countOverallOwners();
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 		return $all;
502 502
 	}
503 503
 	public function countOverallPilots() {
504
-		$all = $this->getSumStats('pilots_bymonth',date('Y'));
504
+		$all = $this->getSumStats('pilots_bymonth', date('Y'));
505 505
 		if (empty($all)) {
506 506
 			$Spotter = new Spotter($this->db);
507 507
 			$all = $Spotter->countOverallPilots();
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
                  try {
516 516
                         $sth = $this->db->prepare($query);
517 517
                         $sth->execute($query_values);
518
-                } catch(PDOException $e) {
518
+                } catch (PDOException $e) {
519 519
                         echo "error : ".$e->getMessage();
520 520
                 }
521 521
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -527,13 +527,13 @@  discard block
 block discarded – undo
527 527
                  try {
528 528
                         $sth = $this->db->prepare($query);
529 529
                         $sth->execute($query_values);
530
-                } catch(PDOException $e) {
530
+                } catch (PDOException $e) {
531 531
                         echo "error : ".$e->getMessage();
532 532
                 }
533 533
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
534 534
                 return $all;
535 535
         }
536
-	public function getSumStats($type,$year) {
536
+	public function getSumStats($type, $year) {
537 537
     		global $globalArchiveMonths, $globalDBdriver;
538 538
     		if ($globalDBdriver == 'mysql') {
539 539
 	                $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year";
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
                  try {
545 545
                         $sth = $this->db->prepare($query);
546 546
                         $sth->execute($query_values);
547
-                } catch(PDOException $e) {
547
+                } catch (PDOException $e) {
548 548
                         echo "error : ".$e->getMessage();
549 549
                 }
550 550
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
                  try {
562 562
                         $sth = $this->db->prepare($query);
563 563
                         $sth->execute($query_values);
564
-                } catch(PDOException $e) {
564
+                } catch (PDOException $e) {
565 565
                         echo "error : ".$e->getMessage();
566 566
                 }
567 567
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
                  try {
578 578
                         $sth = $this->db->prepare($query);
579 579
                         $sth->execute();
580
-                } catch(PDOException $e) {
580
+                } catch (PDOException $e) {
581 581
                         echo "error : ".$e->getMessage();
582 582
                 }
583 583
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
                  try {
594 594
                         $sth = $this->db->prepare($query);
595 595
                         $sth->execute();
596
-                } catch(PDOException $e) {
596
+                } catch (PDOException $e) {
597 597
                         echo "error : ".$e->getMessage();
598 598
                 }
599 599
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
                  try {
610 610
                         $sth = $this->db->prepare($query);
611 611
                         $sth->execute();
612
-                } catch(PDOException $e) {
612
+                } catch (PDOException $e) {
613 613
                         echo "error : ".$e->getMessage();
614 614
                 }
615 615
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -625,29 +625,29 @@  discard block
 block discarded – undo
625 625
                  try {
626 626
                         $sth = $this->db->prepare($query);
627 627
                         $sth->execute();
628
-                } catch(PDOException $e) {
628
+                } catch (PDOException $e) {
629 629
                         echo "error : ".$e->getMessage();
630 630
                 }
631 631
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
632 632
                 return $all[0]['total'];
633 633
         }
634 634
 
635
-	public function addStat($type,$cnt,$stats_date) {
635
+	public function addStat($type, $cnt, $stats_date) {
636 636
 		global $globalDBdriver;
637 637
 		if ($globalDBdriver == 'mysql') {
638 638
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = :cnt";
639 639
                 } else {
640 640
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date; INSERT INTO stats (stats_type,cnt,stats_date) SELECT :type,:cnt,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date);"; 
641 641
 		}
642
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date);
642
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date);
643 643
                  try {
644 644
                         $sth = $this->db->prepare($query);
645 645
                         $sth->execute($query_values);
646
-                } catch(PDOException $e) {
646
+                } catch (PDOException $e) {
647 647
                         return "error : ".$e->getMessage();
648 648
                 }
649 649
         }
650
-	public function updateStat($type,$cnt,$stats_date) {
650
+	public function updateStat($type, $cnt, $stats_date) {
651 651
 		global $globalDBdriver;
652 652
 		if ($globalDBdriver == 'mysql') {
653 653
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
@@ -655,219 +655,219 @@  discard block
 block discarded – undo
655 655
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
656 656
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date; INSERT INTO stats (stats_type,cnt,stats_date) SELECT :type,:cnt,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date);"; 
657 657
                 }
658
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date);
658
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date);
659 659
                  try {
660 660
                         $sth = $this->db->prepare($query);
661 661
                         $sth->execute($query_values);
662
-                } catch(PDOException $e) {
662
+                } catch (PDOException $e) {
663 663
                         return "error : ".$e->getMessage();
664 664
                 }
665 665
         }
666
-	public function getStatsSource($date,$stats_type = '') {
666
+	public function getStatsSource($date, $stats_type = '') {
667 667
 		if ($stats_type == '') {
668 668
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
669 669
 			$query_values = array(':date' => $date);
670 670
 		} else {
671 671
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name";
672
-			$query_values = array(':date' => $date,':stats_type' => $stats_type);
672
+			$query_values = array(':date' => $date, ':stats_type' => $stats_type);
673 673
 		}
674 674
                  try {
675 675
                         $sth = $this->db->prepare($query);
676 676
                         $sth->execute($query_values);
677
-                } catch(PDOException $e) {
677
+                } catch (PDOException $e) {
678 678
                         echo "error : ".$e->getMessage();
679 679
                 }
680 680
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
681 681
                 return $all;
682 682
         }
683 683
 
684
-	public function addStatSource($data,$source_name,$stats_type,$date) {
684
+	public function addStatSource($data, $source_name, $stats_type, $date) {
685 685
 		global $globalDBdriver;
686 686
 		if ($globalDBdriver == 'mysql') {
687 687
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
688 688
 		} else {
689 689
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
690 690
                 }
691
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
691
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
692 692
                  try {
693 693
                         $sth = $this->db->prepare($query);
694 694
                         $sth->execute($query_values);
695
-                } catch(PDOException $e) {
695
+                } catch (PDOException $e) {
696 696
                         return "error : ".$e->getMessage();
697 697
                 }
698 698
         }
699
-	public function addStatFlight($type,$date_name,$cnt) {
699
+	public function addStatFlight($type, $date_name, $cnt) {
700 700
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt) VALUES (:type,:flight_date,:cnt)";
701
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt);
701
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt);
702 702
                  try {
703 703
                         $sth = $this->db->prepare($query);
704 704
                         $sth->execute($query_values);
705
-                } catch(PDOException $e) {
705
+                } catch (PDOException $e) {
706 706
                         return "error : ".$e->getMessage();
707 707
                 }
708 708
         }
709
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '') {
709
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '') {
710 710
 		global $globalDBdriver;
711 711
 		if ($globalDBdriver == 'mysql') {
712 712
 			$query = "INSERT INTO stats_registration (aircraft_icao,registration,cnt) VALUES (:aircraft_icao,:registration,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
713 713
 		} else {
714 714
 			$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration; INSERT INTO stats_registration (aircraft_icao,registration,cnt) SELECT :aircraft_icao,:registration,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration);"; 
715 715
 		}
716
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt);
716
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt);
717 717
                  try {
718 718
                         $sth = $this->db->prepare($query);
719 719
                         $sth->execute($query_values);
720
-                } catch(PDOException $e) {
720
+                } catch (PDOException $e) {
721 721
                         return "error : ".$e->getMessage();
722 722
                 }
723 723
         }
724
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '') {
724
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '') {
725 725
 		global $globalDBdriver;
726 726
 		if ($globalDBdriver == 'mysql') {
727 727
 			$query = "INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt) VALUES (:callsign_icao,:airline_icao,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
728 728
 		} else {
729 729
 			$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt) SELECT :callsign_icao,:airline_icao,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao);"; 
730 730
 		}
731
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt);
731
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt);
732 732
                  try {
733 733
                         $sth = $this->db->prepare($query);
734 734
                         $sth->execute($query_values);
735
-                } catch(PDOException $e) {
735
+                } catch (PDOException $e) {
736 736
                         return "error : ".$e->getMessage();
737 737
                 }
738 738
         }
739
-	public function addStatCountry($iso2,$iso3,$name,$cnt) {
739
+	public function addStatCountry($iso2, $iso3, $name, $cnt) {
740 740
 		global $globalDBdriver;
741 741
 		if ($globalDBdriver == 'mysql') {
742 742
 			$query = "INSERT INTO stats_country (iso2,iso3,name,cnt) VALUES (:iso2,:iso3,:name,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
743 743
 		} else {
744 744
 			$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2; INSERT INTO stats_country (iso2,iso3,name,cnt) SELECT :iso2,:iso3,:name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2);"; 
745 745
 		}
746
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt);
746
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt);
747 747
                  try {
748 748
                         $sth = $this->db->prepare($query);
749 749
                         $sth->execute($query_values);
750
-                } catch(PDOException $e) {
750
+                } catch (PDOException $e) {
751 751
                         return "error : ".$e->getMessage();
752 752
                 }
753 753
         }
754
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '') {
754
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '') {
755 755
 		global $globalDBdriver;
756 756
 		if ($globalDBdriver == 'mysql') {
757 757
 			$query = "INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,cnt) VALUES (:aircraft_icao,:aircraft_name,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
758 758
 		} else {
759 759
 			$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt WHERE aircraft_icao = :aircraft_icao; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,cnt) SELECT :aircraft_icao,:aircraft_name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao);"; 
760 760
 		}
761
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt);
761
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt);
762 762
                  try {
763 763
                         $sth = $this->db->prepare($query);
764 764
                         $sth->execute($query_values);
765
-                } catch(PDOException $e) {
765
+                } catch (PDOException $e) {
766 766
                         return "error : ".$e->getMessage();
767 767
                 }
768 768
         }
769
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '') {
769
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '') {
770 770
 		global $globalDBdriver;
771 771
 		if ($globalDBdriver == 'mysql') {
772 772
 			$query = "INSERT INTO stats_airline (airline_icao,airline_name,cnt) VALUES (:airline_icao,:airline_name,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt,airline_name = :airline_name";
773 773
 		} else {
774 774
 			$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao; INSERT INTO stats_airline (airline_icao,airline_name,cnt) SELECT :airline_icao,:airline_name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao);"; 
775 775
 		}
776
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt);
776
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt);
777 777
                  try {
778 778
                         $sth = $this->db->prepare($query);
779 779
                         $sth->execute($query_values);
780
-                } catch(PDOException $e) {
780
+                } catch (PDOException $e) {
781 781
                         return "error : ".$e->getMessage();
782 782
                 }
783 783
         }
784
-	public function addStatOwner($owner_name,$cnt) {
784
+	public function addStatOwner($owner_name, $cnt) {
785 785
 		global $globalDBdriver;
786 786
 		if ($globalDBdriver == 'mysql') {
787 787
 			$query = "INSERT INTO stats_owner (owner_name,cnt) VALUES (:owner_name,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
788 788
 		} else {
789 789
 			$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name; INSERT INTO stats_owner (owner_name,cnt) SELECT :owner_name,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name);"; 
790 790
 		}
791
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt);
791
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt);
792 792
                  try {
793 793
                         $sth = $this->db->prepare($query);
794 794
                         $sth->execute($query_values);
795
-                } catch(PDOException $e) {
795
+                } catch (PDOException $e) {
796 796
                         return "error : ".$e->getMessage();
797 797
                 }
798 798
         }
799
-	public function addStatPilot($pilot_id,$cnt) {
799
+	public function addStatPilot($pilot_id, $cnt) {
800 800
 		global $globalDBdriver;
801 801
 		if ($globalDBdriver == 'mysql') {
802 802
 			$query = "INSERT INTO stats_pilot (pilot_id,cnt) VALUES (:pilot_id,:cnt) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt";
803 803
 		} else {
804 804
 			$query = "UPDATE stats_pilot SET cnt = cnt+:cnt WHERE pilot_id = :pilot_id; INSERT INTO stats_pilot (pilot_id,cnt) SELECT :pilot_id,:cnt WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id);"; 
805 805
 		}
806
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt);
806
+                $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt);
807 807
                  try {
808 808
                         $sth = $this->db->prepare($query);
809 809
                         $sth->execute($query_values);
810
-                } catch(PDOException $e) {
810
+                } catch (PDOException $e) {
811 811
                         return "error : ".$e->getMessage();
812 812
                 }
813 813
         }
814
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure) {
814
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure) {
815 815
 		global $globalDBdriver;
816 816
 		if ($globalDBdriver == 'mysql') {
817 817
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date) ON DUPLICATE KEY UPDATE departure = departure+:departure";
818 818
 		} else {
819 819
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'yearly');"; 
820 820
 		}
821
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00');
821
+                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00');
822 822
                  try {
823 823
                         $sth = $this->db->prepare($query);
824 824
                         $sth->execute($query_values);
825
-                } catch(PDOException $e) {
825
+                } catch (PDOException $e) {
826 826
                         return "error : ".$e->getMessage();
827 827
                 }
828 828
         }
829
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure) {
829
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure) {
830 830
 		global $globalDBdriver;
831 831
 		if ($globalDBdriver == 'mysql') {
832 832
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date) ON DUPLICATE KEY UPDATE departure = :departure";
833 833
 		} else {
834 834
 			$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'daily'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'daily');"; 
835 835
 		}
836
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date);
836
+                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date);
837 837
                  try {
838 838
                         $sth = $this->db->prepare($query);
839 839
                         $sth->execute($query_values);
840
-                } catch(PDOException $e) {
840
+                } catch (PDOException $e) {
841 841
                         return "error : ".$e->getMessage();
842 842
                 }
843 843
         }
844
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival) {
844
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival) {
845 845
 		global $globalDBdriver;
846 846
 		if ($globalDBdriver == 'mysql') {
847 847
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date) ON DUPLICATE KEY UPDATE arrival = arrival+:arrival";
848 848
 		} else {
849 849
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'yearly');"; 
850 850
 		}
851
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00');
851
+                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00');
852 852
                  try {
853 853
                         $sth = $this->db->prepare($query);
854 854
                         $sth->execute($query_values);
855
-                } catch(PDOException $e) {
855
+                } catch (PDOException $e) {
856 856
                         return "error : ".$e->getMessage();
857 857
                 }
858 858
         }
859
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival) {
859
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival) {
860 860
 		global $globalDBdriver;
861 861
 		if ($globalDBdriver == 'mysql') {
862 862
 			$query = "INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) VALUES (:airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date) ON DUPLICATE KEY UPDATE arrival = :arrival";
863 863
 		} else {
864 864
 			$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily'; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airport_icao = :airport_icao AND stats_type = 'daily');"; 
865 865
 		}
866
-                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date);
866
+                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date);
867 867
                  try {
868 868
                         $sth = $this->db->prepare($query);
869 869
                         $sth->execute($query_values);
870
-                } catch(PDOException $e) {
870
+                } catch (PDOException $e) {
871 871
                         return "error : ".$e->getMessage();
872 872
                 }
873 873
         }
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
                  try {
879 879
                         $sth = $this->db->prepare($query);
880 880
                         $sth->execute($query_values);
881
-                } catch(PDOException $e) {
881
+                } catch (PDOException $e) {
882 882
                         return "error : ".$e->getMessage();
883 883
                 }
884 884
         }
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
                  try {
889 889
                         $sth = $this->db->prepare($query);
890 890
                         $sth->execute($query_values);
891
-                } catch(PDOException $e) {
891
+                } catch (PDOException $e) {
892 892
                         return "error : ".$e->getMessage();
893 893
                 }
894 894
         }
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
                  try {
899 899
                         $sth = $this->db->prepare($query);
900 900
                         $sth->execute($query_values);
901
-                } catch(PDOException $e) {
901
+                } catch (PDOException $e) {
902 902
                         return "error : ".$e->getMessage();
903 903
                 }
904 904
         }
@@ -918,86 +918,86 @@  discard block
 block discarded – undo
918 918
 			$lastyear = false;
919 919
 			foreach ($alldata as $number) {
920 920
 				if ($number['year_name'] != date('Y')) $lastyear = true;
921
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
921
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
922 922
 			}
923 923
 			$alldata = $Spotter->countAllMilitaryMonths();
924 924
 			$lastyear = false;
925 925
 			foreach ($alldata as $number) {
926 926
 				if ($number['year_name'] != date('Y')) $lastyear = true;
927
-				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
927
+				$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
928 928
 			}
929 929
 			$alldata = $Spotter->countAllMonthsOwners();
930 930
 			foreach ($alldata as $number) {
931
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
931
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
932 932
 			}
933 933
 			$alldata = $Spotter->countAllMonthsPilots();
934 934
 			foreach ($alldata as $number) {
935
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
935
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
936 936
 			}
937 937
 			$alldata = $Spotter->countAllMonthsAirlines();
938 938
 			foreach ($alldata as $number) {
939
-				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
939
+				$this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
940 940
 			}
941 941
 			$alldata = $Spotter->countAllMonthsAircrafts();
942 942
 			foreach ($alldata as $number) {
943
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
943
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
944 944
 			}
945 945
 			$alldata = $Spotter->countAllMonthsRealArrivals();
946 946
 			foreach ($alldata as $number) {
947
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
947
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
948 948
 			}
949 949
 			$this->deleteStatFlight('month');
950 950
 			$alldata = $Spotter->countAllDatesLastMonth();
951 951
 			foreach ($alldata as $number) {
952
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
952
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
953 953
 			}
954 954
 			$previousdata = $this->countAllDates();
955 955
 			$this->deleteStatFlight('date');
956
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
956
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
957 957
 			$values = array();
958 958
 			foreach ($alldata as $cnt) {
959 959
 				$values[] = $cnt['date_count'];
960 960
 			}
961
-			array_multisort($values,SORT_DESC,$alldata);
962
-			array_splice($alldata,11);
961
+			array_multisort($values, SORT_DESC, $alldata);
962
+			array_splice($alldata, 11);
963 963
 			foreach ($alldata as $number) {
964
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
964
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
965 965
 			}
966 966
 			$this->deleteStatFlight('hour');
967 967
 			$alldata = $Spotter->countAllHours('hour');
968 968
 			foreach ($alldata as $number) {
969
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
969
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
970 970
 			}
971 971
 			if ($lastyear) {
972 972
 				$monthsSinceLastYear = date('n');
973
-				$alldata = $Spotter->countAllAircraftTypes(false,$monthsSinceLastYear);
973
+				$alldata = $Spotter->countAllAircraftTypes(false, $monthsSinceLastYear);
974 974
 				foreach ($alldata as $number) {
975
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name']);
975
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name']);
976 976
 				}
977
-				$alldata = $Spotter->countAllAirlines(false,$monthsSinceLastYear);
977
+				$alldata = $Spotter->countAllAirlines(false, $monthsSinceLastYear);
978 978
 				foreach ($alldata as $number) {
979
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
979
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']);
980 980
 				}
981 981
 				if ($Connection->tableExists('countries')) {
982
-					$alldata = $Spotter->countAllFlightOverCountries(false,$monthsSinceLastYear);
982
+					$alldata = $Spotter->countAllFlightOverCountries(false, $monthsSinceLastYear);
983 983
 					foreach ($alldata as $number) {
984
-						$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']);
984
+						$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']);
985 985
 					}
986 986
 				}
987
-				$alldata = $Spotter->countAllOwners(false,$monthsSinceLastYear);
987
+				$alldata = $Spotter->countAllOwners(false, $monthsSinceLastYear);
988 988
 				foreach ($alldata as $number) {
989
-					$this->addStatOwner($number['owner_name'],$number['owner_count']);
989
+					$this->addStatOwner($number['owner_name'], $number['owner_count']);
990 990
 				}
991
-				$alldata = $Spotter->countAllPilots(false,$monthsSinceLastYear);
991
+				$alldata = $Spotter->countAllPilots(false, $monthsSinceLastYear);
992 992
 				foreach ($alldata as $number) {
993
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count']);
993
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count']);
994 994
 				}
995 995
 				$previous_year = date('Y');
996 996
 				$previous_year--;
997
-				$this->addStat('aircrafts_byyear',$this->getStatsAircraftTotal(),$previous_year.'-01-01 00:00:00');
998
-				$this->addStat('airlines_byyear',$this->getStatsAirlineTotal(),$previous_year.'-01-01 00:00:00');
999
-				$this->addStat('owner_byyear',$this->getStatsOwnerTotal(),$previous_year.'-01-01 00:00:00');
1000
-				$this->addStat('pilot_byyear',$this->getStatsPilotTotal(),$previous_year.'-01-01 00:00:00');
997
+				$this->addStat('aircrafts_byyear', $this->getStatsAircraftTotal(), $previous_year.'-01-01 00:00:00');
998
+				$this->addStat('airlines_byyear', $this->getStatsAirlineTotal(), $previous_year.'-01-01 00:00:00');
999
+				$this->addStat('owner_byyear', $this->getStatsOwnerTotal(), $previous_year.'-01-01 00:00:00');
1000
+				$this->addStat('pilot_byyear', $this->getStatsPilotTotal(), $previous_year.'-01-01 00:00:00');
1001 1001
 				
1002 1002
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
1003 1003
 					if ($globalArchive) {
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 						try {
1007 1007
 							$sth = $this->db->prepare($query);
1008 1008
 							$sth->execute();
1009
-						} catch(PDOException $e) {
1009
+						} catch (PDOException $e) {
1010 1010
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
1011 1011
 						}
1012 1012
 					}
@@ -1014,45 +1014,45 @@  discard block
 block discarded – undo
1014 1014
 					try {
1015 1015
 						$sth = $this->db->prepare($query);
1016 1016
 						$sth->execute();
1017
-					} catch(PDOException $e) {
1017
+					} catch (PDOException $e) {
1018 1018
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
1019 1019
 					}
1020 1020
 				}
1021 1021
 			}
1022 1022
 			if (!isset($globalArchiveMonths) || $globalArchiveMonths == '') $globalArchiveMonths = 2;
1023 1023
 			if ($globalArchiveMonths > 0) {
1024
-				$alldata = $Spotter->countAllAircraftTypes(false,$globalArchiveMonths);
1024
+				$alldata = $Spotter->countAllAircraftTypes(false, $globalArchiveMonths);
1025 1025
 				foreach ($alldata as $number) {
1026
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name']);
1026
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name']);
1027 1027
 				}
1028
-				$alldata = $Spotter->countAllAirlines(false,$globalArchiveMonths);
1028
+				$alldata = $Spotter->countAllAirlines(false, $globalArchiveMonths);
1029 1029
 				foreach ($alldata as $number) {
1030
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1030
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']);
1031 1031
 				}
1032
-				$alldata = $Spotter->countAllAircraftRegistrations(false,$globalArchiveMonths);
1032
+				$alldata = $Spotter->countAllAircraftRegistrations(false, $globalArchiveMonths);
1033 1033
 				foreach ($alldata as $number) {
1034
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);
1034
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']);
1035 1035
 				}
1036
-				$alldata = $Spotter->countAllCallsigns(false,$globalArchiveMonths);
1036
+				$alldata = $Spotter->countAllCallsigns(false, $globalArchiveMonths);
1037 1037
 				foreach ($alldata as $number) {
1038
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1038
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);
1039 1039
 				}
1040
-				$alldata = $Spotter->countAllOwners(false,$globalArchiveMonths);
1040
+				$alldata = $Spotter->countAllOwners(false, $globalArchiveMonths);
1041 1041
 				foreach ($alldata as $number) {
1042
-					$this->addStatOwner($number['owner_name'],$number['owner_count']);
1042
+					$this->addStatOwner($number['owner_name'], $number['owner_count']);
1043 1043
 				}
1044 1044
 				if ($Connection->tableExists('countries')) {
1045
-					$alldata = $Spotter->countAllFlightOverCountries(false,$globalArchiveMonths);
1045
+					$alldata = $Spotter->countAllFlightOverCountries(false, $globalArchiveMonths);
1046 1046
 					foreach ($alldata as $number) {
1047
-						$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']);
1047
+						$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']);
1048 1048
 					}
1049 1049
 				}
1050
-				$alldata = $Spotter->countAllPilots(false,$globalArchiveMonths);
1050
+				$alldata = $Spotter->countAllPilots(false, $globalArchiveMonths);
1051 1051
 				foreach ($alldata as $number) {
1052
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count']);
1052
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count']);
1053 1053
 				}
1054
-				$pall = $Spotter->countAllDepartureAirports(false,$globalArchiveMonths);
1055
-        			$dall = $Spotter->countAllDetectedDepartureAirports(false,$globalArchiveMonths);
1054
+				$pall = $Spotter->countAllDepartureAirports(false, $globalArchiveMonths);
1055
+        			$dall = $Spotter->countAllDetectedDepartureAirports(false, $globalArchiveMonths);
1056 1056
 	        		$alldata = array();
1057 1057
     				foreach ($pall as $value) {
1058 1058
 	        			$icao = $value['airport_departure_icao'];
@@ -1068,14 +1068,14 @@  discard block
 block discarded – undo
1068 1068
         			foreach ($alldata as $key => $row) {
1069 1069
         				$count[$key] = $row['airport_departure_icao_count'];
1070 1070
 	        		}
1071
-    				array_multisort($count,SORT_DESC,$alldata);
1071
+    				array_multisort($count, SORT_DESC, $alldata);
1072 1072
 
1073 1073
 				//print_r($alldate);
1074 1074
 				foreach ($alldata as $number) {
1075
-					$this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1075
+					$this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count']);
1076 1076
 				}
1077
-				$pdata = $Spotter->countAllArrivalAirports(false,$globalArchiveMonths);
1078
-        			$dall = $Spotter->countAllDetectedArrivalAirports(false,$globalArchiveMonths);
1077
+				$pdata = $Spotter->countAllArrivalAirports(false, $globalArchiveMonths);
1078
+        			$dall = $Spotter->countAllDetectedArrivalAirports(false, $globalArchiveMonths);
1079 1079
 	        		$alldata = array();
1080 1080
     				foreach ($pdata as $value) {
1081 1081
 	        			$icao = $value['airport_arrival_icao'];
@@ -1091,14 +1091,14 @@  discard block
 block discarded – undo
1091 1091
         			foreach ($alldata as $key => $row) {
1092 1092
         				$count[$key] = $row['airport_arrival_icao_count'];
1093 1093
 	        		}
1094
-    				array_multisort($count,SORT_DESC,$alldata);
1094
+    				array_multisort($count, SORT_DESC, $alldata);
1095 1095
 				foreach ($alldata as $number) {
1096
-					$this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1096
+					$this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count']);
1097 1097
 				}
1098
-				$this->addStat('aircrafts_byyear',$this->getStatsAircraftTotal(),date('Y').'-01-01 00:00:00');
1099
-				$this->addStat('airlines_byyear',$this->getStatsAirlineTotal(),date('Y').'-01-01 00:00:00');
1100
-				$this->addStat('owner_byyear',$this->getStatsOwnerTotal(),date('Y').'-01-01 00:00:00');
1101
-				$this->addStat('pilot_byyear',$this->getStatsPilotTotal(),date('Y').'-01-01 00:00:00');
1098
+				$this->addStat('aircrafts_byyear', $this->getStatsAircraftTotal(), date('Y').'-01-01 00:00:00');
1099
+				$this->addStat('airlines_byyear', $this->getStatsAirlineTotal(), date('Y').'-01-01 00:00:00');
1100
+				$this->addStat('owner_byyear', $this->getStatsOwnerTotal(), date('Y').'-01-01 00:00:00');
1101
+				$this->addStat('pilot_byyear', $this->getStatsPilotTotal(), date('Y').'-01-01 00:00:00');
1102 1102
 			
1103 1103
 				if ($globalArchive) {
1104 1104
 					if ($globalDBdriver == 'mysql') {
@@ -1109,7 +1109,7 @@  discard block
 block discarded – undo
1109 1109
 					try {
1110 1110
 						$sth = $this->db->prepare($query);
1111 1111
 						$sth->execute();
1112
-					} catch(PDOException $e) {
1112
+					} catch (PDOException $e) {
1113 1113
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
1114 1114
 					}
1115 1115
 				}
@@ -1123,43 +1123,43 @@  discard block
 block discarded – undo
1123 1123
 				try {
1124 1124
 					$sth = $this->db->prepare($query);
1125 1125
 					$sth->execute();
1126
-				} catch(PDOException $e) {
1126
+				} catch (PDOException $e) {
1127 1127
 					return "error : ".$e->getMessage().' - query : '.$query."\n";
1128 1128
 				}
1129 1129
 			}
1130
-			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
1130
+			$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
1131 1131
 		} else {
1132 1132
 			echo 'Update stats !'."\n";
1133 1133
 			if (isset($last_update[0]['value'])) {
1134 1134
 				$last_update_day = $last_update[0]['value'];
1135 1135
 			} else $last_update_day = '2012-12-12 12:12:12';
1136 1136
 			$Spotter = new Spotter($this->db);
1137
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1137
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1138 1138
 			foreach ($alldata as $number) {
1139
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name']);
1139
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name']);
1140 1140
 			}
1141
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1141
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1142 1142
 			foreach ($alldata as $number) {
1143
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name']);
1143
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name']);
1144 1144
 			}
1145
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1145
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1146 1146
 			foreach ($alldata as $number) {
1147
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao']);
1147
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao']);
1148 1148
 			}
1149
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1149
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1150 1150
 			foreach ($alldata as $number) {
1151
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao']);
1151
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao']);
1152 1152
 			}
1153
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1153
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1154 1154
 			foreach ($alldata as $number) {
1155
-				$this->addStatOwner($number['owner_name'],$number['owner_count']);
1155
+				$this->addStatOwner($number['owner_name'], $number['owner_count']);
1156 1156
 			}
1157
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1157
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1158 1158
 			foreach ($alldata as $number) {
1159
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count']);
1159
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count']);
1160 1160
 			}
1161
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1162
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1161
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1162
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1163 1163
 	        	$alldata = array();
1164 1164
     			foreach ($pall as $value) {
1165 1165
 	        		$icao = $value['airport_departure_icao'];
@@ -1175,13 +1175,13 @@  discard block
 block discarded – undo
1175 1175
     			foreach ($alldata as $key => $row) {
1176 1176
     				$count[$key] = $row['airport_departure_icao_count'];
1177 1177
         		}
1178
-			array_multisort($count,SORT_DESC,$alldata);
1178
+			array_multisort($count, SORT_DESC, $alldata);
1179 1179
 
1180 1180
 			foreach ($alldata as $number) {
1181
-				$this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']);
1181
+				$this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count']);
1182 1182
 			}
1183
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1184
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1183
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1184
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1185 1185
 	        	$alldata = array();
1186 1186
     			foreach ($pall as $value) {
1187 1187
 	        		$icao = $value['airport_arrival_icao'];
@@ -1197,15 +1197,15 @@  discard block
 block discarded – undo
1197 1197
         		foreach ($alldata as $key => $row) {
1198 1198
         			$count[$key] = $row['airport_arrival_icao_count'];
1199 1199
 	        	}
1200
-    			array_multisort($count,SORT_DESC,$alldata);
1200
+    			array_multisort($count, SORT_DESC, $alldata);
1201 1201
                         foreach ($alldata as $number) {
1202
-				$this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']);
1202
+				$this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count']);
1203 1203
 			}
1204 1204
 			if ($Connection->tableExists('countries')) {
1205 1205
 				$SpotterArchive = new SpotterArchive();
1206
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1206
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1207 1207
 				foreach ($alldata as $number) {
1208
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count']);
1208
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count']);
1209 1209
 				}
1210 1210
 			}
1211 1211
 			
@@ -1218,31 +1218,31 @@  discard block
 block discarded – undo
1218 1218
 			$lastyear = false;
1219 1219
 			foreach ($alldata as $number) {
1220 1220
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1221
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1221
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1222 1222
 			}
1223 1223
 			$alldata = $Spotter->countAllMilitaryMonths();
1224 1224
 			foreach ($alldata as $number) {
1225
-				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1225
+				$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1226 1226
 			}
1227 1227
 			$alldata = $Spotter->countAllMonthsOwners();
1228 1228
 			foreach ($alldata as $number) {
1229
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1229
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1230 1230
 			}
1231 1231
 			$alldata = $Spotter->countAllMonthsPilots();
1232 1232
 			foreach ($alldata as $number) {
1233
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1233
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1234 1234
 			}
1235 1235
 			$alldata = $Spotter->countAllMonthsAirlines();
1236 1236
 			foreach ($alldata as $number) {
1237
-				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1237
+				$this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1238 1238
 			}
1239 1239
 			$alldata = $Spotter->countAllMonthsAircrafts();
1240 1240
 			foreach ($alldata as $number) {
1241
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1241
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1242 1242
 			}
1243 1243
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1244 1244
 			foreach ($alldata as $number) {
1245
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1245
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1246 1246
 			}
1247 1247
 			echo 'Airports data...'."\n";
1248 1248
 			echo '...Departure'."\n";
@@ -1264,9 +1264,9 @@  discard block
 block discarded – undo
1264 1264
         		foreach ($alldata as $key => $row) {
1265 1265
         			$count[$key] = $row['departure_airport_count'];
1266 1266
 	        	}
1267
-    			array_multisort($count,SORT_DESC,$alldata);
1267
+    			array_multisort($count, SORT_DESC, $alldata);
1268 1268
 			foreach ($alldata as $number) {
1269
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1269
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1270 1270
 			}
1271 1271
 			echo '...Arrival'."\n";
1272 1272
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1286,10 +1286,10 @@  discard block
 block discarded – undo
1286 1286
         		foreach ($alldata as $key => $row) {
1287 1287
         			$count[$key] = $row['arrival_airport_count'];
1288 1288
 	        	}
1289
-    			array_multisort($count,SORT_DESC,$alldata);
1289
+    			array_multisort($count, SORT_DESC, $alldata);
1290 1290
 
1291 1291
 			foreach ($alldata as $number) {
1292
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1292
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1293 1293
 			}
1294 1294
 
1295 1295
 			echo 'Flights data...'."\n";
@@ -1297,37 +1297,37 @@  discard block
 block discarded – undo
1297 1297
 			echo '-> countAllDatesLastMonth...'."\n";
1298 1298
 			$alldata = $Spotter->countAllDatesLastMonth();
1299 1299
 			foreach ($alldata as $number) {
1300
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1300
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1301 1301
 			}
1302 1302
 			echo '-> countAllDates...'."\n";
1303 1303
 			$previousdata = $this->countAllDates();
1304 1304
 			$this->deleteStatFlight('date');
1305
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1305
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1306 1306
 			$values = array();
1307 1307
 			foreach ($alldata as $cnt) {
1308 1308
 				$values[] = $cnt['date_count'];
1309 1309
 			}
1310
-			array_multisort($values,SORT_DESC,$alldata);
1311
-			array_splice($alldata,11);
1310
+			array_multisort($values, SORT_DESC, $alldata);
1311
+			array_splice($alldata, 11);
1312 1312
 			foreach ($alldata as $number) {
1313
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1313
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1314 1314
 			}
1315 1315
 			
1316 1316
 			$this->deleteStatFlight('hour');
1317 1317
 			echo '-> countAllHours...'."\n";
1318 1318
 			$alldata = $Spotter->countAllHours('hour');
1319 1319
 			foreach ($alldata as $number) {
1320
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1320
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1321 1321
 			}
1322 1322
 			if ($lastyear) {
1323 1323
 				echo 'Data from last year...'."\n";
1324 1324
 				// SUM all previous month to put as year
1325 1325
 				$previous_year = date('Y');
1326 1326
 				$previous_year--;
1327
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1328
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1329
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1330
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
1327
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1328
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1329
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1330
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
1331 1331
 				
1332 1332
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
1333 1333
 					if ($globalArchive) {
@@ -1335,7 +1335,7 @@  discard block
 block discarded – undo
1335 1335
 						try {
1336 1336
 							$sth = $this->db->prepare($query);
1337 1337
 							$sth->execute();
1338
-						} catch(PDOException $e) {
1338
+						} catch (PDOException $e) {
1339 1339
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
1340 1340
 						}
1341 1341
 					}
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
 					try {
1345 1345
 						$sth = $this->db->prepare($query);
1346 1346
 						$sth->execute();
1347
-					} catch(PDOException $e) {
1347
+					} catch (PDOException $e) {
1348 1348
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
1349 1349
 					}
1350 1350
 				}
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
 					try {
1367 1367
 						$sth = $this->db->prepare($query);
1368 1368
 						$sth->execute();
1369
-					} catch(PDOException $e) {
1369
+					} catch (PDOException $e) {
1370 1370
 						return "error : ".$e->getMessage();
1371 1371
 					}
1372 1372
 				}
@@ -1380,13 +1380,13 @@  discard block
 block discarded – undo
1380 1380
 				try {
1381 1381
 					$sth = $this->db->prepare($query);
1382 1382
 					$sth->execute();
1383
-				} catch(PDOException $e) {
1383
+				} catch (PDOException $e) {
1384 1384
 					return "error : ".$e->getMessage();
1385 1385
 				}
1386 1386
 			}
1387 1387
 			echo 'Insert last stats update date...'."\n";
1388 1388
 			date_default_timezone_set('UTC');
1389
-			$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
1389
+			$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
1390 1390
 		}
1391 1391
 	}
1392 1392
 }
Please login to merge, or discard this patch.
Braces   +125 added lines, -47 removed lines patch added patch discarded remove patch
@@ -72,8 +72,11 @@  discard block
 block discarded – undo
72 72
 
73 73
 
74 74
 	public function countAllAircraftTypes($limit = true) {
75
-		if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
76
-		else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' ORDER BY aircraft_icao_count DESC";
75
+		if ($limit) {
76
+			$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
77
+		} else {
78
+			$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' ORDER BY aircraft_icao_count DESC";
79
+		}
77 80
                  try {
78 81
                         $sth = $this->db->prepare($query);
79 82
                         $sth->execute();
@@ -88,8 +91,11 @@  discard block
 block discarded – undo
88 91
                 return $all;
89 92
 	}
90 93
 	public function countAllAirlineCountries($limit = true) {
91
-		if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
92
-		else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao GROUP BY airline_country ORDER BY airline_country_count DESC";
94
+		if ($limit) {
95
+			$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
96
+		} else {
97
+			$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao GROUP BY airline_country ORDER BY airline_country_count DESC";
98
+		}
93 99
                  try {
94 100
                         $sth = $this->db->prepare($query);
95 101
                         $sth->execute();
@@ -105,8 +111,11 @@  discard block
 block discarded – undo
105 111
                 return $all;
106 112
 	}
107 113
 	public function countAllAircraftManufacturers($limit = true) {
108
-		if ($limit) $query = "SELECT aircraft.manufacturer AS aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft,aircraft WHERE stats_aircraft.aircraft_icao=aircraft.icao GROUP BY aircraft.manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
109
-		else $query = "SELECT aircraft.manufacturer AS aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft,aircraft WHERE stats_aircraft.aircraft_icao=aircraft.icao GROUP BY aircraft.manufacturer ORDER BY aircraft_manufacturer_count DESC";
114
+		if ($limit) {
115
+			$query = "SELECT aircraft.manufacturer AS aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft,aircraft WHERE stats_aircraft.aircraft_icao=aircraft.icao GROUP BY aircraft.manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
116
+		} else {
117
+			$query = "SELECT aircraft.manufacturer AS aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft,aircraft WHERE stats_aircraft.aircraft_icao=aircraft.icao GROUP BY aircraft.manufacturer ORDER BY aircraft_manufacturer_count DESC";
118
+		}
110 119
                  try {
111 120
                         $sth = $this->db->prepare($query);
112 121
                         $sth->execute();
@@ -122,8 +131,11 @@  discard block
 block discarded – undo
122 131
 	}
123 132
 
124 133
 	public function countAllArrivalCountries($limit = true) {
125
-		if ($limit) $query = "SELECT airport_country AS arrival_airport_country, arrival as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0";
126
-		else $query = "SELECT airport_country AS arrival_airport_country, arrival as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly'";
134
+		if ($limit) {
135
+			$query = "SELECT airport_country AS arrival_airport_country, arrival as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0";
136
+		} else {
137
+			$query = "SELECT airport_country AS arrival_airport_country, arrival as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly'";
138
+		}
127 139
                  try {
128 140
                         $sth = $this->db->prepare($query);
129 141
                         $sth->execute();
@@ -138,8 +150,11 @@  discard block
 block discarded – undo
138 150
                 return $all;
139 151
 	}
140 152
 	public function countAllDepartureCountries($limit = true) {
141
-		if ($limit) $query = "SELECT airport_country AS departure_airport_country, departure as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0";
142
-		else $query = "SELECT airport_country AS departure_airport_country, departure as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly'";
153
+		if ($limit) {
154
+			$query = "SELECT airport_country AS departure_airport_country, departure as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0";
155
+		} else {
156
+			$query = "SELECT airport_country AS departure_airport_country, departure as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly'";
157
+		}
143 158
                  try {
144 159
                         $sth = $this->db->prepare($query);
145 160
                         $sth->execute();
@@ -155,8 +170,11 @@  discard block
 block discarded – undo
155 170
 	}
156 171
 
157 172
 	public function countAllAirlines($limit = true) {
158
-		if ($limit) $query = "SELECT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = airline_icao ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
159
-		else $query = "SELECT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = airline_icao ORDER BY airline_count DESC";
173
+		if ($limit) {
174
+			$query = "SELECT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = airline_icao ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
175
+		} else {
176
+			$query = "SELECT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = airline_icao ORDER BY airline_count DESC";
177
+		}
160 178
                  try {
161 179
                         $sth = $this->db->prepare($query);
162 180
                         $sth->execute();
@@ -171,8 +189,11 @@  discard block
 block discarded – undo
171 189
                 return $all;
172 190
 	}
173 191
 	public function countAllAircraftRegistrations($limit = true) {
174
-		if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
175
-		else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao ORDER BY aircraft_registration_count DESC";
192
+		if ($limit) {
193
+			$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
194
+		} else {
195
+			$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao ORDER BY aircraft_registration_count DESC";
196
+		}
176 197
                  try {
177 198
                         $sth = $this->db->prepare($query);
178 199
                         $sth->execute();
@@ -187,8 +208,11 @@  discard block
 block discarded – undo
187 208
                 return $all;
188 209
 	}
189 210
 	public function countAllCallsigns($limit = true) {
190
-		if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
191
-		else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao ORDER BY callsign_icao_count DESC";
211
+		if ($limit) {
212
+			$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
213
+		} else {
214
+			$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao ORDER BY callsign_icao_count DESC";
215
+		}
192 216
                  try {
193 217
                         $sth = $this->db->prepare($query);
194 218
                         $sth->execute();
@@ -205,8 +229,11 @@  discard block
 block discarded – undo
205 229
 	public function countAllFlightOverCountries($limit = true) {
206 230
 		$Connection = new Connection();
207 231
 		if ($Connection->tableExists('countries')) {
208
-			if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
209
-			else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 ORDER BY flight_count DESC";
232
+			if ($limit) {
233
+				$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
234
+			} else {
235
+				$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 ORDER BY flight_count DESC";
236
+			}
210 237
 			 try {
211 238
 				$sth = $this->db->prepare($query);
212 239
 				$sth->execute();
@@ -226,8 +253,11 @@  discard block
 block discarded – undo
226 253
 		}
227 254
 	}
228 255
 	public function countAllPilots($limit = true) {
229
-		if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
230
-		else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot ORDER BY pilot_count DESC";
256
+		if ($limit) {
257
+			$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
258
+		} else {
259
+			$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot ORDER BY pilot_count DESC";
260
+		}
231 261
                  try {
232 262
                         $sth = $this->db->prepare($query);
233 263
                         $sth->execute();
@@ -242,8 +272,11 @@  discard block
 block discarded – undo
242 272
                 return $all;
243 273
 	}
244 274
 	public function countAllOwners($limit = true) {
245
-		if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
246
-		else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner ORDER BY owner_count DESC";
275
+		if ($limit) {
276
+			$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
277
+		} else {
278
+			$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner ORDER BY owner_count DESC";
279
+		}
247 280
                  try {
248 281
                         $sth = $this->db->prepare($query);
249 282
                         $sth->execute();
@@ -258,8 +291,11 @@  discard block
 block discarded – undo
258 291
                 return $all;
259 292
 	}
260 293
 	public function countAllDepartureAirports($limit = true) {
261
-		if ($limit) $query = "SELECT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0";
262
-		else $query = "SELECT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE stats_type = 'yearly'";
294
+		if ($limit) {
295
+			$query = "SELECT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0";
296
+		} else {
297
+			$query = "SELECT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE stats_type = 'yearly'";
298
+		}
263 299
                  try {
264 300
                         $sth = $this->db->prepare($query);
265 301
                         $sth->execute();
@@ -281,7 +317,9 @@  discard block
 block discarded – undo
281 317
         			$icao = $value['airport_departure_icao'];
282 318
         			if (isset($all[$icao])) {                                                           
283 319
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
284
-        			} else $all[$icao] = $value;
320
+        			} else {
321
+        				$all[$icao] = $value;
322
+        			}
285 323
         		}
286 324
         		$count = array();
287 325
         		foreach ($all as $key => $row) {
@@ -292,8 +330,11 @@  discard block
 block discarded – undo
292 330
                 return $all;
293 331
 	}
294 332
 	public function countAllArrivalAirports($limit = true) {
295
-		if ($limit) $query = "SELECT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0";
296
-		else $query = "SELECT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE stats_type = 'yearly'";
333
+		if ($limit) {
334
+			$query = "SELECT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0";
335
+		} else {
336
+			$query = "SELECT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE stats_type = 'yearly'";
337
+		}
297 338
                  try {
298 339
                         $sth = $this->db->prepare($query);
299 340
                         $sth->execute();
@@ -315,7 +356,9 @@  discard block
 block discarded – undo
315 356
         			$icao = $value['airport_arrival_icao'];
316 357
         			if (isset($all[$icao])) {
317 358
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
318
-        			} else $all[$icao] = $value;
359
+        			} else {
360
+        				$all[$icao] = $value;
361
+        			}
319 362
         		}
320 363
         		$count = array();
321 364
         		foreach ($all as $key => $row) {
@@ -328,11 +371,17 @@  discard block
 block discarded – undo
328 371
 	public function countAllMonthsLastYear($limit = true) {
329 372
 		global $globalDBdriver;
330 373
 		if ($globalDBdriver == 'mysql') {
331
-			if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH)";
332
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth'";
374
+			if ($limit) {
375
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH)";
376
+			} else {
377
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth'";
378
+			}
333 379
 		} else {
334
-			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS'";
335
-			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth'";
380
+			if ($limit) {
381
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS'";
382
+			} else {
383
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth'";
384
+			}
336 385
 		}
337 386
 		$query_data = array();
338 387
                  try {
@@ -434,10 +483,17 @@  discard block
 block discarded – undo
434 483
 	}
435 484
 	public function countAllHours($orderby = 'hour',$limit = true) {
436 485
 		global $globalTimezone;
437
-		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour'";
438
-		else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour'";
439
-		if ($orderby == 'hour') $query .= " ORDER BY CAST(flight_date AS integer) ASC";
440
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
486
+		if ($limit) {
487
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour'";
488
+		} else {
489
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour'";
490
+		}
491
+		if ($orderby == 'hour') {
492
+			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
493
+		}
494
+		if ($orderby == 'count') {
495
+			$query .= " ORDER BY hour_count DESC";
496
+		}
441 497
                  try {
442 498
                         $sth = $this->db->prepare($query);
443 499
                         $sth->execute();
@@ -917,13 +973,17 @@  discard block
 block discarded – undo
917 973
 			$alldata = $Spotter->countAllMonths();
918 974
 			$lastyear = false;
919 975
 			foreach ($alldata as $number) {
920
-				if ($number['year_name'] != date('Y')) $lastyear = true;
976
+				if ($number['year_name'] != date('Y')) {
977
+					$lastyear = true;
978
+				}
921 979
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
922 980
 			}
923 981
 			$alldata = $Spotter->countAllMilitaryMonths();
924 982
 			$lastyear = false;
925 983
 			foreach ($alldata as $number) {
926
-				if ($number['year_name'] != date('Y')) $lastyear = true;
984
+				if ($number['year_name'] != date('Y')) {
985
+					$lastyear = true;
986
+				}
927 987
 				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
928 988
 			}
929 989
 			$alldata = $Spotter->countAllMonthsOwners();
@@ -1019,7 +1079,9 @@  discard block
 block discarded – undo
1019 1079
 					}
1020 1080
 				}
1021 1081
 			}
1022
-			if (!isset($globalArchiveMonths) || $globalArchiveMonths == '') $globalArchiveMonths = 2;
1082
+			if (!isset($globalArchiveMonths) || $globalArchiveMonths == '') {
1083
+				$globalArchiveMonths = 2;
1084
+			}
1023 1085
 			if ($globalArchiveMonths > 0) {
1024 1086
 				$alldata = $Spotter->countAllAircraftTypes(false,$globalArchiveMonths);
1025 1087
 				foreach ($alldata as $number) {
@@ -1062,7 +1124,9 @@  discard block
 block discarded – undo
1062 1124
     					$icao = $value['airport_departure_icao'];
1063 1125
         				if (isset($alldata[$icao])) {                                                           
1064 1126
         					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1065
-	        			} else $alldata[$icao] = $value;
1127
+	        			} else {
1128
+	        				$alldata[$icao] = $value;
1129
+	        			}
1066 1130
     				}
1067 1131
         			$count = array();
1068 1132
         			foreach ($alldata as $key => $row) {
@@ -1085,7 +1149,9 @@  discard block
 block discarded – undo
1085 1149
     					$icao = $value['airport_arrival_icao'];
1086 1150
         				if (isset($alldata[$icao])) {                                                           
1087 1151
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1088
-	        			} else $alldata[$icao] = $value;
1152
+	        			} else {
1153
+	        				$alldata[$icao] = $value;
1154
+	        			}
1089 1155
     				}
1090 1156
         			$count = array();
1091 1157
         			foreach ($alldata as $key => $row) {
@@ -1132,7 +1198,9 @@  discard block
 block discarded – undo
1132 1198
 			echo 'Update stats !'."\n";
1133 1199
 			if (isset($last_update[0]['value'])) {
1134 1200
 				$last_update_day = $last_update[0]['value'];
1135
-			} else $last_update_day = '2012-12-12 12:12:12';
1201
+			} else {
1202
+				$last_update_day = '2012-12-12 12:12:12';
1203
+			}
1136 1204
 			$Spotter = new Spotter($this->db);
1137 1205
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1138 1206
 			foreach ($alldata as $number) {
@@ -1169,7 +1237,9 @@  discard block
 block discarded – undo
1169 1237
     				$icao = $value['airport_departure_icao'];
1170 1238
         			if (isset($alldata[$icao])) {                                                           
1171 1239
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1172
-        			} else $alldata[$icao] = $value;
1240
+        			} else {
1241
+        				$alldata[$icao] = $value;
1242
+        			}
1173 1243
 			}
1174 1244
     			$count = array();
1175 1245
     			foreach ($alldata as $key => $row) {
@@ -1191,7 +1261,9 @@  discard block
 block discarded – undo
1191 1261
     				$icao = $value['airport_arrival_icao'];
1192 1262
         			if (isset($alldata[$icao])) {                                                           
1193 1263
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1194
-	        		} else $alldata[$icao] = $value;
1264
+	        		} else {
1265
+	        			$alldata[$icao] = $value;
1266
+	        		}
1195 1267
     			}
1196 1268
         		$count = array();
1197 1269
         		foreach ($alldata as $key => $row) {
@@ -1217,7 +1289,9 @@  discard block
 block discarded – undo
1217 1289
 			$alldata = $Spotter->countAllMonths();
1218 1290
 			$lastyear = false;
1219 1291
 			foreach ($alldata as $number) {
1220
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1292
+				if ($number['year_name'] != date('Y')) {
1293
+					$lastyear = true;
1294
+				}
1221 1295
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1222 1296
 			}
1223 1297
 			$alldata = $Spotter->countAllMilitaryMonths();
@@ -1258,7 +1332,9 @@  discard block
 block discarded – undo
1258 1332
     				$icao = $value['departure_airport_icao'];
1259 1333
         			if (isset($alldata[$icao])) {                                                           
1260 1334
         				$alldata[$icao]['departure_airport_count'] = $alldata[$icao]['departure_airport_count'] + $value['departure_airport_count'];
1261
-	        		} else $alldata[$icao] = $value;
1335
+	        		} else {
1336
+	        			$alldata[$icao] = $value;
1337
+	        		}
1262 1338
     			}
1263 1339
         		$count = array();
1264 1340
         		foreach ($alldata as $key => $row) {
@@ -1280,7 +1356,9 @@  discard block
 block discarded – undo
1280 1356
     				$icao = $value['arrival_airport_icao'];
1281 1357
         			if (isset($alldata[$icao])) {                                                           
1282 1358
         				$alldata[$icao]['arrival_airport_icao_count'] = $alldata[$icao]['arrival_airport_count'] + $value['arrival_airport_count'];
1283
-	        		} else $alldata[$icao] = $value;
1359
+	        		} else {
1360
+	        			$alldata[$icao] = $value;
1361
+	        		}
1284 1362
     			}
1285 1363
         		$count = array();
1286 1364
         		foreach ($alldata as $key => $row) {
Please login to merge, or discard this patch.
require/class.Translation.php 4 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -58,6 +58,10 @@  discard block
 block discarded – undo
58 58
                 } else return $ident;
59 59
         }
60 60
 
61
+       /**
62
+        * @param string $correct_ident
63
+        * @param string $source
64
+        */
61 65
        public function addOperator($ident,$correct_ident,$source) {
62 66
                 $query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)";
63 67
                 $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
@@ -69,6 +73,10 @@  discard block
 block discarded – undo
69 73
                 }
70 74
         }
71 75
 
76
+       /**
77
+        * @param string $correct_ident
78
+        * @param string $source
79
+        */
72 80
        public function updateOperator($ident,$correct_ident,$source) {
73 81
                 $query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident";
74 82
                 $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
Please login to merge, or discard this patch.
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -7,90 +7,90 @@  discard block
 block discarded – undo
7 7
 
8 8
 
9 9
 class Translation {
10
-    public $db;
11
-    function __construct($dbc = null) {
12
-	    $Connection = new Connection($dbc);
13
-	    $this->db = $Connection->db;
14
-    }
10
+	public $db;
11
+	function __construct($dbc = null) {
12
+		$Connection = new Connection($dbc);
13
+		$this->db = $Connection->db;
14
+	}
15 15
 
16
-    /**
17
-    * Change IATA to ICAO value for ident
18
-    * 
19
-    * @param String $ident ident
20
-    * @return String the icao
21
-    */
22
-    public function ident2icao($ident) {
16
+	/**
17
+	 * Change IATA to ICAO value for ident
18
+	 * 
19
+	 * @param String $ident ident
20
+	 * @return String the icao
21
+	 */
22
+	public function ident2icao($ident) {
23 23
 	$Spotter = new Spotter();
24 24
 	if (!is_numeric(substr($ident, 0, 3)))
25
-        {
26
-	    if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
27
-        	$airline_icao = substr($ident, 0, 2);
28
-            } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
29
-        	//$airline_icao = substr($ident, 0, 3);
30
-        	return $ident;
31
-            } else return $ident;
32
-        } else return $ident;
33
-        if ($airline_icao == 'AF') {
34
-            if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
35
-            else $icao = 'AFR'.ltrim(substr($ident,2),'0');
36
-        } else {
37
-            $identicao = $Spotter->getAllAirlineInfo($airline_icao);
38
-            if (isset($identicao[0])) {
39
-                $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
40
-            } else $icao = $ident;
41
-        }
42
-        return $icao;
43
-    }
25
+		{
26
+		if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
27
+			$airline_icao = substr($ident, 0, 2);
28
+			} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
29
+			//$airline_icao = substr($ident, 0, 3);
30
+			return $ident;
31
+			} else return $ident;
32
+		} else return $ident;
33
+		if ($airline_icao == 'AF') {
34
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
35
+			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
36
+		} else {
37
+			$identicao = $Spotter->getAllAirlineInfo($airline_icao);
38
+			if (isset($identicao[0])) {
39
+				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
40
+			} else $icao = $ident;
41
+		}
42
+		return $icao;
43
+	}
44 44
 
45 45
 
46
-       public function getOperator($ident) {
47
-                $query = "SELECT * FROM translation WHERE Operator = :ident LIMIT 1";
48
-                $query_values = array(':ident' => $ident);
49
-                 try {
50
-                        $sth = $this->db->prepare($query);
51
-                        $sth->execute($query_values);
52
-                } catch(PDOException $e) {
53
-                        return "error : ".$e->getMessage();
54
-                }
55
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
56
-                if (count($row) > 0) {
57
-                        return $row['operator_correct'];
58
-                } else return $ident;
59
-        }
46
+	   public function getOperator($ident) {
47
+				$query = "SELECT * FROM translation WHERE Operator = :ident LIMIT 1";
48
+				$query_values = array(':ident' => $ident);
49
+				 try {
50
+						$sth = $this->db->prepare($query);
51
+						$sth->execute($query_values);
52
+				} catch(PDOException $e) {
53
+						return "error : ".$e->getMessage();
54
+				}
55
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
56
+				if (count($row) > 0) {
57
+						return $row['operator_correct'];
58
+				} else return $ident;
59
+		}
60 60
 
61
-       public function addOperator($ident,$correct_ident,$source) {
62
-                $query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)";
63
-                $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
64
-                 try {
65
-                        $sth = $this->db->prepare($query);
66
-                        $sth->execute($query_values);
67
-                } catch(PDOException $e) {
68
-                        return "error : ".$e->getMessage();
69
-                }
70
-        }
61
+	   public function addOperator($ident,$correct_ident,$source) {
62
+				$query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)";
63
+				$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
64
+				 try {
65
+						$sth = $this->db->prepare($query);
66
+						$sth->execute($query_values);
67
+				} catch(PDOException $e) {
68
+						return "error : ".$e->getMessage();
69
+				}
70
+		}
71 71
 
72
-       public function updateOperator($ident,$correct_ident,$source) {
73
-                $query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident";
74
-                $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
75
-                 try {
76
-                        $sth = $this->db->prepare($query);
77
-                        $sth->execute($query_values);
78
-                } catch(PDOException $e) {
79
-                        return "error : ".$e->getMessage();
80
-                }
81
-        }
72
+	   public function updateOperator($ident,$correct_ident,$source) {
73
+				$query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident";
74
+				$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
75
+				 try {
76
+						$sth = $this->db->prepare($query);
77
+						$sth->execute($query_values);
78
+				} catch(PDOException $e) {
79
+						return "error : ".$e->getMessage();
80
+				}
81
+		}
82 82
         
83
-        public function checkTranslation($ident,$web = false) {
84
-    	    global $globalTranslationSources, $globalTranslationFetch;
85
-    	    //if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder');
86
-    	    $globalTranslationSources = array();
87
-    	    if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE;
88
-    	    //echo "Check Translation for ".$ident."...";
89
-    	    $correct = $this->getOperator($ident);
90
-    	    if ($correct != '' && $correct != $ident) {
91
-    		//echo "Found in DB !\n";
92
-    		 return $correct;
93
-    	    } /*
83
+		public function checkTranslation($ident,$web = false) {
84
+			global $globalTranslationSources, $globalTranslationFetch;
85
+			//if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder');
86
+			$globalTranslationSources = array();
87
+			if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE;
88
+			//echo "Check Translation for ".$ident."...";
89
+			$correct = $this->getOperator($ident);
90
+			if ($correct != '' && $correct != $ident) {
91
+			//echo "Found in DB !\n";
92
+			 return $correct;
93
+			} /*
94 94
     	    elseif ($web && $globalTranslationFetch) {
95 95
     		if (! is_numeric(substr($ident,-4))) {
96 96
     		    if (count($globalTranslationSources) > 0) {
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
     		}
108 108
     	    }
109 109
     	    */
110
-    	    return $this->ident2icao($ident);
111
-        }
110
+			return $this->ident2icao($ident);
111
+		}
112 112
 
113 113
 /*  
114 114
     function fromPlanefinder($icao) {
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
             } else return $ident;
32 32
         } else return $ident;
33 33
         if ($airline_icao == 'AF') {
34
-            if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
35
-            else $icao = 'AFR'.ltrim(substr($ident,2),'0');
34
+            if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
35
+            else $icao = 'AFR'.ltrim(substr($ident, 2), '0');
36 36
         } else {
37 37
             $identicao = $Spotter->getAllAirlineInfo($airline_icao);
38 38
             if (isset($identicao[0])) {
39
-                $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
39
+                $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0');
40 40
             } else $icao = $ident;
41 41
         }
42 42
         return $icao;
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
                  try {
50 50
                         $sth = $this->db->prepare($query);
51 51
                         $sth->execute($query_values);
52
-                } catch(PDOException $e) {
52
+                } catch (PDOException $e) {
53 53
                         return "error : ".$e->getMessage();
54 54
                 }
55 55
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -58,29 +58,29 @@  discard block
 block discarded – undo
58 58
                 } else return $ident;
59 59
         }
60 60
 
61
-       public function addOperator($ident,$correct_ident,$source) {
61
+       public function addOperator($ident, $correct_ident, $source) {
62 62
                 $query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)";
63
-                $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
63
+                $query_values = array(':ident' => $ident, ':correct_ident' => $correct_ident, ':source' => $source);
64 64
                  try {
65 65
                         $sth = $this->db->prepare($query);
66 66
                         $sth->execute($query_values);
67
-                } catch(PDOException $e) {
67
+                } catch (PDOException $e) {
68 68
                         return "error : ".$e->getMessage();
69 69
                 }
70 70
         }
71 71
 
72
-       public function updateOperator($ident,$correct_ident,$source) {
72
+       public function updateOperator($ident, $correct_ident, $source) {
73 73
                 $query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident";
74
-                $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
74
+                $query_values = array(':ident' => $ident, ':correct_ident' => $correct_ident, ':source' => $source);
75 75
                  try {
76 76
                         $sth = $this->db->prepare($query);
77 77
                         $sth->execute($query_values);
78
-                } catch(PDOException $e) {
78
+                } catch (PDOException $e) {
79 79
                         return "error : ".$e->getMessage();
80 80
                 }
81 81
         }
82 82
         
83
-        public function checkTranslation($ident,$web = false) {
83
+        public function checkTranslation($ident, $web = false) {
84 84
     	    global $globalTranslationSources, $globalTranslationFetch;
85 85
     	    //if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder');
86 86
     	    $globalTranslationSources = array();
Please login to merge, or discard this patch.
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,16 +28,25 @@  discard block
 block discarded – undo
28 28
             } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
29 29
         	//$airline_icao = substr($ident, 0, 3);
30 30
         	return $ident;
31
-            } else return $ident;
32
-        } else return $ident;
31
+            } else {
32
+            	return $ident;
33
+            }
34
+        } else {
35
+        	return $ident;
36
+        }
33 37
         if ($airline_icao == 'AF') {
34
-            if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
35
-            else $icao = 'AFR'.ltrim(substr($ident,2),'0');
38
+            if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
39
+            	$icao = $ident;
40
+            } else {
41
+            	$icao = 'AFR'.ltrim(substr($ident,2),'0');
42
+            }
36 43
         } else {
37 44
             $identicao = $Spotter->getAllAirlineInfo($airline_icao);
38 45
             if (isset($identicao[0])) {
39 46
                 $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
40
-            } else $icao = $ident;
47
+            } else {
48
+            	$icao = $ident;
49
+            }
41 50
         }
42 51
         return $icao;
43 52
     }
@@ -55,7 +64,9 @@  discard block
 block discarded – undo
55 64
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
56 65
                 if (count($row) > 0) {
57 66
                         return $row['operator_correct'];
58
-                } else return $ident;
67
+                } else {
68
+                	return $ident;
69
+                }
59 70
         }
60 71
 
61 72
        public function addOperator($ident,$correct_ident,$source) {
@@ -84,7 +95,9 @@  discard block
 block discarded – undo
84 95
     	    global $globalTranslationSources, $globalTranslationFetch;
85 96
     	    //if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder');
86 97
     	    $globalTranslationSources = array();
87
-    	    if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE;
98
+    	    if (!isset($globalTranslationFetch)) {
99
+    	    	$globalTranslationFetch = TRUE;
100
+    	    }
88 101
     	    //echo "Check Translation for ".$ident."...";
89 102
     	    $correct = $this->getOperator($ident);
90 103
     	    if ($correct != '' && $correct != $ident) {
Please login to merge, or discard this patch.
require/libs/geoPHP/geoPHP.inc 4 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -118,6 +118,9 @@  discard block
 block discarded – undo
118 118
     );
119 119
   }
120 120
 
121
+  /**
122
+   * @param boolean $force
123
+   */
121 124
   static function geosInstalled($force = NULL) {
122 125
     static $geos_installed = NULL;
123 126
     if ($force !== NULL) $geos_installed = $force;
@@ -222,6 +225,10 @@  discard block
 block discarded – undo
222 225
 
223 226
   // Detect a format given a value. This function is meant to be SPEEDY.
224 227
   // It could make a mistake in XML detection if you are mixing or using namespaces in weird ways (ie, KML inside an RSS feed)
228
+
229
+  /**
230
+   * @return string
231
+   */
225 232
   static function detectFormat(&$input) {
226 233
     $mem = fopen('php://memory', 'r+');
227 234
     fwrite($mem, $input, 11); // Write 11 bytes - we can detect the vast majority of formats in the first 11 bytes
Please login to merge, or discard this patch.
Indentation   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -35,110 +35,110 @@  discard block
 block discarded – undo
35 35
 {
36 36
 
37 37
   static function version() {
38
-    return '1.1';
38
+	return '1.1';
39 39
   }
40 40
 
41 41
   // geoPHP::load($data, $type, $other_args);
42 42
   // if $data is an array, all passed in values will be combined into a single geometry
43 43
   static function load() {
44
-    $args = func_get_args();
44
+	$args = func_get_args();
45 45
 
46
-    $data = array_shift($args);
47
-    $type = array_shift($args);
46
+	$data = array_shift($args);
47
+	$type = array_shift($args);
48 48
 
49
-    $type_map = geoPHP::getAdapterMap();
49
+	$type_map = geoPHP::getAdapterMap();
50 50
 
51
-    // Auto-detect type if needed
52
-    if (!$type) {
53
-      // If the user is trying to load a Geometry from a Geometry... Just pass it back
54
-      if (is_object($data)) {
55
-        if ($data instanceOf Geometry) return $data;
56
-      }
51
+	// Auto-detect type if needed
52
+	if (!$type) {
53
+	  // If the user is trying to load a Geometry from a Geometry... Just pass it back
54
+	  if (is_object($data)) {
55
+		if ($data instanceOf Geometry) return $data;
56
+	  }
57 57
       
58
-      $detected = geoPHP::detectFormat($data);
59
-      if (!$detected) {
60
-        return FALSE;
61
-      }
58
+	  $detected = geoPHP::detectFormat($data);
59
+	  if (!$detected) {
60
+		return FALSE;
61
+	  }
62 62
       
63
-      $format = explode(':', $detected);
64
-      $type = array_shift($format);
65
-      $args = $format;
66
-    }
67
-
68
-    $processor_type = $type_map[$type];
69
-
70
-    if (!$processor_type) {
71
-      throw new exception('geoPHP could not find an adapter of type '.htmlentities($type));
72
-      exit;
73
-    }
74
-
75
-    $processor = new $processor_type();
76
-
77
-    // Data is not an array, just pass it normally
78
-    if (!is_array($data)) {
79
-      $result = call_user_func_array(array($processor, "read"), array_merge(array($data), $args));
80
-    }
81
-    // Data is an array, combine all passed in items into a single geomtetry
82
-    else {
83
-      $geoms = array();
84
-      foreach ($data as $item) {
85
-        $geoms[] = call_user_func_array(array($processor, "read"), array_merge(array($item), $args));
86
-      }
87
-      $result = geoPHP::geometryReduce($geoms);
88
-    }
89
-
90
-    return $result;
63
+	  $format = explode(':', $detected);
64
+	  $type = array_shift($format);
65
+	  $args = $format;
66
+	}
67
+
68
+	$processor_type = $type_map[$type];
69
+
70
+	if (!$processor_type) {
71
+	  throw new exception('geoPHP could not find an adapter of type '.htmlentities($type));
72
+	  exit;
73
+	}
74
+
75
+	$processor = new $processor_type();
76
+
77
+	// Data is not an array, just pass it normally
78
+	if (!is_array($data)) {
79
+	  $result = call_user_func_array(array($processor, "read"), array_merge(array($data), $args));
80
+	}
81
+	// Data is an array, combine all passed in items into a single geomtetry
82
+	else {
83
+	  $geoms = array();
84
+	  foreach ($data as $item) {
85
+		$geoms[] = call_user_func_array(array($processor, "read"), array_merge(array($item), $args));
86
+	  }
87
+	  $result = geoPHP::geometryReduce($geoms);
88
+	}
89
+
90
+	return $result;
91 91
   }
92 92
 
93 93
   static function getAdapterMap() {
94
-    return array (
95
-      'wkt' =>  'WKT',
96
-      'ewkt' => 'EWKT',
97
-      'wkb' =>  'WKB',
98
-      'ewkb' => 'EWKB',
99
-      'json' => 'GeoJSON',
100
-      'geojson' => 'GeoJSON',
101
-      'kml' =>  'KML',
102
-      'gpx' =>  'GPX',
103
-      'georss' => 'GeoRSS',
104
-      'google_geocode' => 'GoogleGeocode',
105
-      'geohash' => 'GeoHash',
106
-    );
94
+	return array (
95
+	  'wkt' =>  'WKT',
96
+	  'ewkt' => 'EWKT',
97
+	  'wkb' =>  'WKB',
98
+	  'ewkb' => 'EWKB',
99
+	  'json' => 'GeoJSON',
100
+	  'geojson' => 'GeoJSON',
101
+	  'kml' =>  'KML',
102
+	  'gpx' =>  'GPX',
103
+	  'georss' => 'GeoRSS',
104
+	  'google_geocode' => 'GoogleGeocode',
105
+	  'geohash' => 'GeoHash',
106
+	);
107 107
   }
108 108
 
109 109
   static function geometryList() {
110
-    return array(
111
-      'point' => 'Point',
112
-      'linestring' => 'LineString',
113
-      'polygon' => 'Polygon',
114
-      'multipoint' => 'MultiPoint',
115
-      'multilinestring' => 'MultiLineString',
116
-      'multipolygon' => 'MultiPolygon',
117
-      'geometrycollection' => 'GeometryCollection',
118
-    );
110
+	return array(
111
+	  'point' => 'Point',
112
+	  'linestring' => 'LineString',
113
+	  'polygon' => 'Polygon',
114
+	  'multipoint' => 'MultiPoint',
115
+	  'multilinestring' => 'MultiLineString',
116
+	  'multipolygon' => 'MultiPolygon',
117
+	  'geometrycollection' => 'GeometryCollection',
118
+	);
119 119
   }
120 120
 
121 121
   static function geosInstalled($force = NULL) {
122
-    static $geos_installed = NULL;
123
-    if ($force !== NULL) $geos_installed = $force;
124
-    if ($geos_installed !== NULL) {
125
-      return $geos_installed;
126
-    }
127
-    $geos_installed = class_exists('GEOSGeometry');
128
-    return $geos_installed;
122
+	static $geos_installed = NULL;
123
+	if ($force !== NULL) $geos_installed = $force;
124
+	if ($geos_installed !== NULL) {
125
+	  return $geos_installed;
126
+	}
127
+	$geos_installed = class_exists('GEOSGeometry');
128
+	return $geos_installed;
129 129
   }
130 130
 
131 131
   static function geosToGeometry($geos) {
132
-    if (!geoPHP::geosInstalled()) {
133
-      return NULL;
134
-    }
135
-    $wkb_writer = new GEOSWKBWriter();
136
-    $wkb = $wkb_writer->writeHEX($geos);
137
-    $geometry = geoPHP::load($wkb, 'wkb', TRUE);
138
-    if ($geometry) {
139
-      $geometry->setGeos($geos);
140
-      return $geometry;
141
-    }
132
+	if (!geoPHP::geosInstalled()) {
133
+	  return NULL;
134
+	}
135
+	$wkb_writer = new GEOSWKBWriter();
136
+	$wkb = $wkb_writer->writeHEX($geos);
137
+	$geometry = geoPHP::load($wkb, 'wkb', TRUE);
138
+	if ($geometry) {
139
+	  $geometry->setGeos($geos);
140
+	  return $geometry;
141
+	}
142 142
   }
143 143
 
144 144
   // Reduce a geometry, or an array of geometries, into their 'lowest' available common geometry.
@@ -146,155 +146,155 @@  discard block
 block discarded – undo
146 146
   // A multi-point containing a single point will return a point.
147 147
   // An array of geometries can be passed and they will be compiled into a single geometry
148 148
   static function geometryReduce($geometry) {
149
-    // If it's an array of one, then just parse the one
150
-    if (is_array($geometry)) {
151
-      if (empty($geometry)) return FALSE;
152
-      if (count($geometry) == 1) return geoPHP::geometryReduce(array_shift($geometry));
153
-    }
154
-
155
-    // If the geometry cannot even theoretically be reduced more, then pass it back
156
-    if (gettype($geometry) == 'object') {
157
-      $passbacks = array('Point','LineString','Polygon');
158
-      if (in_array($geometry->geometryType(),$passbacks)) {
159
-        return $geometry;
160
-      }
161
-    }
162
-
163
-    // If it is a mutlti-geometry, check to see if it just has one member
164
-    // If it does, then pass the member, if not, then just pass back the geometry
165
-    if (gettype($geometry) == 'object') {
166
-      $simple_collections = array('MultiPoint','MultiLineString','MultiPolygon');
167
-      if (in_array(get_class($geometry),$passbacks)) {
168
-        $components = $geometry->getComponents();
169
-        if (count($components) == 1) {
170
-          return $components[0];
171
-        }
172
-        else {
173
-          return $geometry;
174
-        }
175
-      }
176
-    }
177
-
178
-    // So now we either have an array of geometries, a GeometryCollection, or an array of GeometryCollections
179
-    if (!is_array($geometry)) {
180
-      $geometry = array($geometry);
181
-    }
182
-
183
-    $geometries = array();
184
-    $geom_types = array();
185
-
186
-    $collections = array('MultiPoint','MultiLineString','MultiPolygon','GeometryCollection');
187
-
188
-    foreach ($geometry as $item) {
189
-      if ($item) {
190
-        if (in_array(get_class($item), $collections)) {
191
-          foreach ($item->getComponents() as $component) {
192
-            $geometries[] = $component;
193
-            $geom_types[] = $component->geometryType();
194
-          }
195
-        }
196
-        else {
197
-          $geometries[] = $item;
198
-          $geom_types[] = $item->geometryType();
199
-        }
200
-      }
201
-    }
202
-
203
-    $geom_types = array_unique($geom_types);
149
+	// If it's an array of one, then just parse the one
150
+	if (is_array($geometry)) {
151
+	  if (empty($geometry)) return FALSE;
152
+	  if (count($geometry) == 1) return geoPHP::geometryReduce(array_shift($geometry));
153
+	}
154
+
155
+	// If the geometry cannot even theoretically be reduced more, then pass it back
156
+	if (gettype($geometry) == 'object') {
157
+	  $passbacks = array('Point','LineString','Polygon');
158
+	  if (in_array($geometry->geometryType(),$passbacks)) {
159
+		return $geometry;
160
+	  }
161
+	}
162
+
163
+	// If it is a mutlti-geometry, check to see if it just has one member
164
+	// If it does, then pass the member, if not, then just pass back the geometry
165
+	if (gettype($geometry) == 'object') {
166
+	  $simple_collections = array('MultiPoint','MultiLineString','MultiPolygon');
167
+	  if (in_array(get_class($geometry),$passbacks)) {
168
+		$components = $geometry->getComponents();
169
+		if (count($components) == 1) {
170
+		  return $components[0];
171
+		}
172
+		else {
173
+		  return $geometry;
174
+		}
175
+	  }
176
+	}
177
+
178
+	// So now we either have an array of geometries, a GeometryCollection, or an array of GeometryCollections
179
+	if (!is_array($geometry)) {
180
+	  $geometry = array($geometry);
181
+	}
182
+
183
+	$geometries = array();
184
+	$geom_types = array();
185
+
186
+	$collections = array('MultiPoint','MultiLineString','MultiPolygon','GeometryCollection');
187
+
188
+	foreach ($geometry as $item) {
189
+	  if ($item) {
190
+		if (in_array(get_class($item), $collections)) {
191
+		  foreach ($item->getComponents() as $component) {
192
+			$geometries[] = $component;
193
+			$geom_types[] = $component->geometryType();
194
+		  }
195
+		}
196
+		else {
197
+		  $geometries[] = $item;
198
+		  $geom_types[] = $item->geometryType();
199
+		}
200
+	  }
201
+	}
202
+
203
+	$geom_types = array_unique($geom_types);
204 204
     
205
-    if (empty($geom_types)) {
206
-      return FALSE;
207
-    }
208
-
209
-    if (count($geom_types) == 1) {
210
-      if (count($geometries) == 1) {
211
-        return $geometries[0];
212
-      }
213
-      else {
214
-        $class = 'Multi'.$geom_types[0];
215
-        return new $class($geometries);
216
-      }
217
-    }
218
-    else {
219
-      return new GeometryCollection($geometries);
220
-    }
205
+	if (empty($geom_types)) {
206
+	  return FALSE;
207
+	}
208
+
209
+	if (count($geom_types) == 1) {
210
+	  if (count($geometries) == 1) {
211
+		return $geometries[0];
212
+	  }
213
+	  else {
214
+		$class = 'Multi'.$geom_types[0];
215
+		return new $class($geometries);
216
+	  }
217
+	}
218
+	else {
219
+	  return new GeometryCollection($geometries);
220
+	}
221 221
   }
222 222
 
223 223
   // Detect a format given a value. This function is meant to be SPEEDY.
224 224
   // It could make a mistake in XML detection if you are mixing or using namespaces in weird ways (ie, KML inside an RSS feed)
225 225
   static function detectFormat(&$input) {
226
-    $mem = fopen('php://memory', 'r+');
227
-    fwrite($mem, $input, 11); // Write 11 bytes - we can detect the vast majority of formats in the first 11 bytes
228
-    fseek($mem, 0);
229
-
230
-    $bytes = unpack("c*", fread($mem, 11));
231
-
232
-    // If bytes is empty, then we were passed empty input
233
-    if (empty($bytes)) return FALSE;
234
-
235
-    // First char is a tab, space or carriage-return. trim it and try again
236
-    if ($bytes[1] == 9 || $bytes[1] == 10 || $bytes[1] == 32) {
237
-      return geoPHP::detectFormat(ltrim($input));
238
-    }
239
-
240
-    // Detect WKB or EWKB -- first byte is 1 (little endian indicator)
241
-    if ($bytes[1] == 1) {
242
-      // If SRID byte is TRUE (1), it's EWKB
243
-      if ($bytes[5]) return 'ewkb';
244
-      else return 'wkb';
245
-    }
246
-
247
-    // Detect HEX encoded WKB or EWKB (PostGIS format) -- first byte is 48, second byte is 49 (hex '01' => first-byte = 1)
248
-    if ($bytes[1] == 48 && $bytes[2] == 49) {
249
-      // The shortest possible WKB string (LINESTRING EMPTY) is 18 hex-chars (9 encoded bytes) long
250
-      // This differentiates it from a geohash, which is always shorter than 18 characters.
251
-      if (strlen($input) >= 18) {
252
-        //@@TODO: Differentiate between EWKB and WKB -- check hex-char 10 or 11 (SRID bool indicator at encoded byte 5)
253
-        return 'ewkb:1';
254
-      }
255
-    }
256
-
257
-    // Detect GeoJSON - first char starts with {
258
-    if ($bytes[1] == 123) {
259
-      return 'json';
260
-    }
261
-
262
-    // Detect EWKT - first char is S
263
-    if ($bytes[1] == 83) {
264
-      return 'ewkt';
265
-    }
266
-
267
-    // Detect WKT - first char starts with P (80), L (76), M (77), or G (71)
268
-    $wkt_chars = array(80, 76, 77, 71);
269
-    if (in_array($bytes[1], $wkt_chars)) {
270
-      return 'wkt';
271
-    }
272
-
273
-    // Detect XML -- first char is <
274
-    if ($bytes[1] == 60) {
275
-      // grab the first 256 characters
276
-      $string = substr($input, 0, 256);
277
-      if (strpos($string, '<kml') !== FALSE)        return 'kml';
278
-      if (strpos($string, '<coordinate') !== FALSE) return 'kml';
279
-      if (strpos($string, '<gpx') !== FALSE)        return 'gpx';
280
-      if (strpos($string, '<georss') !== FALSE)     return 'georss';
281
-      if (strpos($string, '<rss') !== FALSE)        return 'georss';
282
-      if (strpos($string, '<feed') !== FALSE)       return 'georss';
283
-    }
284
-
285
-    // We need an 8 byte string for geohash and unpacked WKB / WKT
286
-    fseek($mem, 0);
287
-    $string = trim(fread($mem, 8));
288
-
289
-    // Detect geohash - geohash ONLY contains lowercase chars and numerics
290
-    preg_match('/[a-z0-9]+/', $string, $matches);
291
-    if ($matches[0] == $string) {
292
-      return 'geohash';
293
-    }
294
-
295
-    // What do you get when you cross an elephant with a rhino?
296
-    // http://youtu.be/RCBn5J83Poc
297
-    return FALSE;
226
+	$mem = fopen('php://memory', 'r+');
227
+	fwrite($mem, $input, 11); // Write 11 bytes - we can detect the vast majority of formats in the first 11 bytes
228
+	fseek($mem, 0);
229
+
230
+	$bytes = unpack("c*", fread($mem, 11));
231
+
232
+	// If bytes is empty, then we were passed empty input
233
+	if (empty($bytes)) return FALSE;
234
+
235
+	// First char is a tab, space or carriage-return. trim it and try again
236
+	if ($bytes[1] == 9 || $bytes[1] == 10 || $bytes[1] == 32) {
237
+	  return geoPHP::detectFormat(ltrim($input));
238
+	}
239
+
240
+	// Detect WKB or EWKB -- first byte is 1 (little endian indicator)
241
+	if ($bytes[1] == 1) {
242
+	  // If SRID byte is TRUE (1), it's EWKB
243
+	  if ($bytes[5]) return 'ewkb';
244
+	  else return 'wkb';
245
+	}
246
+
247
+	// Detect HEX encoded WKB or EWKB (PostGIS format) -- first byte is 48, second byte is 49 (hex '01' => first-byte = 1)
248
+	if ($bytes[1] == 48 && $bytes[2] == 49) {
249
+	  // The shortest possible WKB string (LINESTRING EMPTY) is 18 hex-chars (9 encoded bytes) long
250
+	  // This differentiates it from a geohash, which is always shorter than 18 characters.
251
+	  if (strlen($input) >= 18) {
252
+		//@@TODO: Differentiate between EWKB and WKB -- check hex-char 10 or 11 (SRID bool indicator at encoded byte 5)
253
+		return 'ewkb:1';
254
+	  }
255
+	}
256
+
257
+	// Detect GeoJSON - first char starts with {
258
+	if ($bytes[1] == 123) {
259
+	  return 'json';
260
+	}
261
+
262
+	// Detect EWKT - first char is S
263
+	if ($bytes[1] == 83) {
264
+	  return 'ewkt';
265
+	}
266
+
267
+	// Detect WKT - first char starts with P (80), L (76), M (77), or G (71)
268
+	$wkt_chars = array(80, 76, 77, 71);
269
+	if (in_array($bytes[1], $wkt_chars)) {
270
+	  return 'wkt';
271
+	}
272
+
273
+	// Detect XML -- first char is <
274
+	if ($bytes[1] == 60) {
275
+	  // grab the first 256 characters
276
+	  $string = substr($input, 0, 256);
277
+	  if (strpos($string, '<kml') !== FALSE)        return 'kml';
278
+	  if (strpos($string, '<coordinate') !== FALSE) return 'kml';
279
+	  if (strpos($string, '<gpx') !== FALSE)        return 'gpx';
280
+	  if (strpos($string, '<georss') !== FALSE)     return 'georss';
281
+	  if (strpos($string, '<rss') !== FALSE)        return 'georss';
282
+	  if (strpos($string, '<feed') !== FALSE)       return 'georss';
283
+	}
284
+
285
+	// We need an 8 byte string for geohash and unpacked WKB / WKT
286
+	fseek($mem, 0);
287
+	$string = trim(fread($mem, 8));
288
+
289
+	// Detect geohash - geohash ONLY contains lowercase chars and numerics
290
+	preg_match('/[a-z0-9]+/', $string, $matches);
291
+	if ($matches[0] == $string) {
292
+	  return 'geohash';
293
+	}
294
+
295
+	// What do you get when you cross an elephant with a rhino?
296
+	// http://youtu.be/RCBn5J83Poc
297
+	return FALSE;
298 298
   }
299 299
 
300 300
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
   }
92 92
 
93 93
   static function getAdapterMap() {
94
-    return array (
94
+    return array(
95 95
       'wkt' =>  'WKT',
96 96
       'ewkt' => 'EWKT',
97 97
       'wkb' =>  'WKB',
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 
155 155
     // If the geometry cannot even theoretically be reduced more, then pass it back
156 156
     if (gettype($geometry) == 'object') {
157
-      $passbacks = array('Point','LineString','Polygon');
158
-      if (in_array($geometry->geometryType(),$passbacks)) {
157
+      $passbacks = array('Point', 'LineString', 'Polygon');
158
+      if (in_array($geometry->geometryType(), $passbacks)) {
159 159
         return $geometry;
160 160
       }
161 161
     }
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
     // If it is a mutlti-geometry, check to see if it just has one member
164 164
     // If it does, then pass the member, if not, then just pass back the geometry
165 165
     if (gettype($geometry) == 'object') {
166
-      $simple_collections = array('MultiPoint','MultiLineString','MultiPolygon');
167
-      if (in_array(get_class($geometry),$passbacks)) {
166
+      $simple_collections = array('MultiPoint', 'MultiLineString', 'MultiPolygon');
167
+      if (in_array(get_class($geometry), $passbacks)) {
168 168
         $components = $geometry->getComponents();
169 169
         if (count($components) == 1) {
170 170
           return $components[0];
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     $geometries = array();
184 184
     $geom_types = array();
185 185
 
186
-    $collections = array('MultiPoint','MultiLineString','MultiPolygon','GeometryCollection');
186
+    $collections = array('MultiPoint', 'MultiLineString', 'MultiPolygon', 'GeometryCollection');
187 187
 
188 188
     foreach ($geometry as $item) {
189 189
       if ($item) {
Please login to merge, or discard this patch.
Braces   +42 added lines, -21 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
     if (!$type) {
53 53
       // If the user is trying to load a Geometry from a Geometry... Just pass it back
54 54
       if (is_object($data)) {
55
-        if ($data instanceOf Geometry) return $data;
55
+        if ($data instanceOf Geometry) {
56
+        	return $data;
57
+        }
56 58
       }
57 59
       
58 60
       $detected = geoPHP::detectFormat($data);
@@ -120,7 +122,9 @@  discard block
 block discarded – undo
120 122
 
121 123
   static function geosInstalled($force = NULL) {
122 124
     static $geos_installed = NULL;
123
-    if ($force !== NULL) $geos_installed = $force;
125
+    if ($force !== NULL) {
126
+    	$geos_installed = $force;
127
+    }
124 128
     if ($geos_installed !== NULL) {
125 129
       return $geos_installed;
126 130
     }
@@ -148,8 +152,12 @@  discard block
 block discarded – undo
148 152
   static function geometryReduce($geometry) {
149 153
     // If it's an array of one, then just parse the one
150 154
     if (is_array($geometry)) {
151
-      if (empty($geometry)) return FALSE;
152
-      if (count($geometry) == 1) return geoPHP::geometryReduce(array_shift($geometry));
155
+      if (empty($geometry)) {
156
+      	return FALSE;
157
+      }
158
+      if (count($geometry) == 1) {
159
+      	return geoPHP::geometryReduce(array_shift($geometry));
160
+      }
153 161
     }
154 162
 
155 163
     // If the geometry cannot even theoretically be reduced more, then pass it back
@@ -168,8 +176,7 @@  discard block
 block discarded – undo
168 176
         $components = $geometry->getComponents();
169 177
         if (count($components) == 1) {
170 178
           return $components[0];
171
-        }
172
-        else {
179
+        } else {
173 180
           return $geometry;
174 181
         }
175 182
       }
@@ -192,8 +199,7 @@  discard block
 block discarded – undo
192 199
             $geometries[] = $component;
193 200
             $geom_types[] = $component->geometryType();
194 201
           }
195
-        }
196
-        else {
202
+        } else {
197 203
           $geometries[] = $item;
198 204
           $geom_types[] = $item->geometryType();
199 205
         }
@@ -209,13 +215,11 @@  discard block
 block discarded – undo
209 215
     if (count($geom_types) == 1) {
210 216
       if (count($geometries) == 1) {
211 217
         return $geometries[0];
212
-      }
213
-      else {
218
+      } else {
214 219
         $class = 'Multi'.$geom_types[0];
215 220
         return new $class($geometries);
216 221
       }
217
-    }
218
-    else {
222
+    } else {
219 223
       return new GeometryCollection($geometries);
220 224
     }
221 225
   }
@@ -230,7 +234,9 @@  discard block
 block discarded – undo
230 234
     $bytes = unpack("c*", fread($mem, 11));
231 235
 
232 236
     // If bytes is empty, then we were passed empty input
233
-    if (empty($bytes)) return FALSE;
237
+    if (empty($bytes)) {
238
+    	return FALSE;
239
+    }
234 240
 
235 241
     // First char is a tab, space or carriage-return. trim it and try again
236 242
     if ($bytes[1] == 9 || $bytes[1] == 10 || $bytes[1] == 32) {
@@ -240,8 +246,11 @@  discard block
 block discarded – undo
240 246
     // Detect WKB or EWKB -- first byte is 1 (little endian indicator)
241 247
     if ($bytes[1] == 1) {
242 248
       // If SRID byte is TRUE (1), it's EWKB
243
-      if ($bytes[5]) return 'ewkb';
244
-      else return 'wkb';
249
+      if ($bytes[5]) {
250
+      	return 'ewkb';
251
+      } else {
252
+      	return 'wkb';
253
+      }
245 254
     }
246 255
 
247 256
     // Detect HEX encoded WKB or EWKB (PostGIS format) -- first byte is 48, second byte is 49 (hex '01' => first-byte = 1)
@@ -274,12 +283,24 @@  discard block
 block discarded – undo
274 283
     if ($bytes[1] == 60) {
275 284
       // grab the first 256 characters
276 285
       $string = substr($input, 0, 256);
277
-      if (strpos($string, '<kml') !== FALSE)        return 'kml';
278
-      if (strpos($string, '<coordinate') !== FALSE) return 'kml';
279
-      if (strpos($string, '<gpx') !== FALSE)        return 'gpx';
280
-      if (strpos($string, '<georss') !== FALSE)     return 'georss';
281
-      if (strpos($string, '<rss') !== FALSE)        return 'georss';
282
-      if (strpos($string, '<feed') !== FALSE)       return 'georss';
286
+      if (strpos($string, '<kml') !== FALSE) {
287
+      	return 'kml';
288
+      }
289
+      if (strpos($string, '<coordinate') !== FALSE) {
290
+      	return 'kml';
291
+      }
292
+      if (strpos($string, '<gpx') !== FALSE) {
293
+      	return 'gpx';
294
+      }
295
+      if (strpos($string, '<georss') !== FALSE) {
296
+      	return 'georss';
297
+      }
298
+      if (strpos($string, '<rss') !== FALSE) {
299
+      	return 'georss';
300
+      }
301
+      if (strpos($string, '<feed') !== FALSE) {
302
+      	return 'georss';
303
+      }
283 304
     }
284 305
 
285 306
     // We need an 8 byte string for geohash and unpacked WKB / WKT
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/adapters/GeoJSON.class.php 4 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -113,7 +113,6 @@  discard block
 block discarded – undo
113 113
    * Serializes an object into a geojson string
114 114
    *
115 115
    *
116
-   * @param Geometry $obj The object to serialize
117 116
    *
118 117
    * @return string The GeoJSON string
119 118
    */
@@ -126,6 +125,9 @@  discard block
 block discarded – undo
126 125
     }
127 126
   }
128 127
 
128
+  /**
129
+   * @param Geometry $geometry
130
+   */
129 131
   public function getArray($geometry) {
130 132
     if ($geometry->getGeomType() == 'GeometryCollection') {
131 133
       $component_array = array();
Please login to merge, or discard this patch.
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -16,97 +16,97 @@  discard block
 block discarded – undo
16 16
    * @return object Geometry
17 17
    */
18 18
   public function read($input) {
19
-    if (is_string($input)) {
20
-      $input = json_decode($input);
21
-    }
22
-    if (!is_object($input)) {
23
-      throw new Exception('Invalid JSON');
24
-    }
25
-    if (!is_string($input->type)) {
26
-      throw new Exception('Invalid JSON');
27
-    }
28
-
29
-    // Check to see if it's a FeatureCollection
30
-    if ($input->type == 'FeatureCollection') {
31
-      $geoms = array();
32
-      foreach ($input->features as $feature) {
33
-        $geoms[] = $this->read($feature);
34
-      }
35
-      return geoPHP::geometryReduce($geoms);
36
-    }
37
-
38
-    // Check to see if it's a Feature
39
-    if ($input->type == 'Feature') {
40
-      return $this->read($input->geometry);
41
-    }
42
-
43
-    // It's a geometry - process it
44
-    return $this->objToGeom($input);
19
+	if (is_string($input)) {
20
+	  $input = json_decode($input);
21
+	}
22
+	if (!is_object($input)) {
23
+	  throw new Exception('Invalid JSON');
24
+	}
25
+	if (!is_string($input->type)) {
26
+	  throw new Exception('Invalid JSON');
27
+	}
28
+
29
+	// Check to see if it's a FeatureCollection
30
+	if ($input->type == 'FeatureCollection') {
31
+	  $geoms = array();
32
+	  foreach ($input->features as $feature) {
33
+		$geoms[] = $this->read($feature);
34
+	  }
35
+	  return geoPHP::geometryReduce($geoms);
36
+	}
37
+
38
+	// Check to see if it's a Feature
39
+	if ($input->type == 'Feature') {
40
+	  return $this->read($input->geometry);
41
+	}
42
+
43
+	// It's a geometry - process it
44
+	return $this->objToGeom($input);
45 45
   }
46 46
 
47 47
   private function objToGeom($obj) {
48
-    $type = $obj->type;
48
+	$type = $obj->type;
49 49
 
50
-    if ($type == 'GeometryCollection') {
51
-      return $this->objToGeometryCollection($obj);
52
-    }
53
-    $method = 'arrayTo' . $type;
54
-    return $this->$method($obj->coordinates);
50
+	if ($type == 'GeometryCollection') {
51
+	  return $this->objToGeometryCollection($obj);
52
+	}
53
+	$method = 'arrayTo' . $type;
54
+	return $this->$method($obj->coordinates);
55 55
   }
56 56
 
57 57
   private function arrayToPoint($array) {
58
-    return new Point($array[0], $array[1]);
58
+	return new Point($array[0], $array[1]);
59 59
   }
60 60
 
61 61
   private function arrayToLineString($array) {
62
-    $points = array();
63
-    foreach ($array as $comp_array) {
64
-      $points[] = $this->arrayToPoint($comp_array);
65
-    }
66
-    return new LineString($points);
62
+	$points = array();
63
+	foreach ($array as $comp_array) {
64
+	  $points[] = $this->arrayToPoint($comp_array);
65
+	}
66
+	return new LineString($points);
67 67
   }
68 68
 
69 69
   private function arrayToPolygon($array) {
70
-    $lines = array();
71
-    foreach ($array as $comp_array) {
72
-      $lines[] = $this->arrayToLineString($comp_array);
73
-    }
74
-    return new Polygon($lines);
70
+	$lines = array();
71
+	foreach ($array as $comp_array) {
72
+	  $lines[] = $this->arrayToLineString($comp_array);
73
+	}
74
+	return new Polygon($lines);
75 75
   }
76 76
 
77 77
   private function arrayToMultiPoint($array) {
78
-    $points = array();
79
-    foreach ($array as $comp_array) {
80
-      $points[] = $this->arrayToPoint($comp_array);
81
-    }
82
-    return new MultiPoint($points);
78
+	$points = array();
79
+	foreach ($array as $comp_array) {
80
+	  $points[] = $this->arrayToPoint($comp_array);
81
+	}
82
+	return new MultiPoint($points);
83 83
   }
84 84
 
85 85
   private function arrayToMultiLineString($array) {
86
-    $lines = array();
87
-    foreach ($array as $comp_array) {
88
-      $lines[] = $this->arrayToLineString($comp_array);
89
-    }
90
-    return new MultiLineString($lines);
86
+	$lines = array();
87
+	foreach ($array as $comp_array) {
88
+	  $lines[] = $this->arrayToLineString($comp_array);
89
+	}
90
+	return new MultiLineString($lines);
91 91
   }
92 92
 
93 93
   private function arrayToMultiPolygon($array) {
94
-    $polys = array();
95
-    foreach ($array as $comp_array) {
96
-      $polys[] = $this->arrayToPolygon($comp_array);
97
-    }
98
-    return new MultiPolygon($polys);
94
+	$polys = array();
95
+	foreach ($array as $comp_array) {
96
+	  $polys[] = $this->arrayToPolygon($comp_array);
97
+	}
98
+	return new MultiPolygon($polys);
99 99
   }
100 100
 
101 101
   private function objToGeometryCollection($obj) {
102
-    $geoms = array();
103
-    if (empty($obj->geometries)) {
104
-      throw new Exception('Invalid GeoJSON: GeometryCollection with no component geometries');
105
-    }
106
-    foreach ($obj->geometries as $comp_object) {
107
-      $geoms[] = $this->objToGeom($comp_object);
108
-    }
109
-    return new GeometryCollection($geoms);
102
+	$geoms = array();
103
+	if (empty($obj->geometries)) {
104
+	  throw new Exception('Invalid GeoJSON: GeometryCollection with no component geometries');
105
+	}
106
+	foreach ($obj->geometries as $comp_object) {
107
+	  $geoms[] = $this->objToGeom($comp_object);
108
+	}
109
+	return new GeometryCollection($geoms);
110 110
   }
111 111
 
112 112
   /**
@@ -118,32 +118,32 @@  discard block
 block discarded – undo
118 118
    * @return string The GeoJSON string
119 119
    */
120 120
   public function write(Geometry $geometry, $return_array = FALSE) {
121
-    if ($return_array) {
122
-      return $this->getArray($geometry);
123
-    }
124
-    else {
125
-      return json_encode($this->getArray($geometry));
126
-    }
121
+	if ($return_array) {
122
+	  return $this->getArray($geometry);
123
+	}
124
+	else {
125
+	  return json_encode($this->getArray($geometry));
126
+	}
127 127
   }
128 128
 
129 129
   public function getArray($geometry) {
130
-    if ($geometry->getGeomType() == 'GeometryCollection') {
131
-      $component_array = array();
132
-      foreach ($geometry->components as $component) {
133
-        $component_array[] = array(
134
-          'type' => $component->geometryType(),
135
-          'coordinates' => $component->asArray(),
136
-        );
137
-      }
138
-      return array(
139
-        'type'=> 'GeometryCollection',
140
-        'geometries'=> $component_array,
141
-      );
142
-    }
143
-    else return array(
144
-      'type'=> $geometry->getGeomType(),
145
-      'coordinates'=> $geometry->asArray(),
146
-    );
130
+	if ($geometry->getGeomType() == 'GeometryCollection') {
131
+	  $component_array = array();
132
+	  foreach ($geometry->components as $component) {
133
+		$component_array[] = array(
134
+		  'type' => $component->geometryType(),
135
+		  'coordinates' => $component->asArray(),
136
+		);
137
+	  }
138
+	  return array(
139
+		'type'=> 'GeometryCollection',
140
+		'geometries'=> $component_array,
141
+	  );
142
+	}
143
+	else return array(
144
+	  'type'=> $geometry->getGeomType(),
145
+	  'coordinates'=> $geometry->asArray(),
146
+	);
147 147
   }
148 148
 }
149 149
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
     if ($type == 'GeometryCollection') {
51 51
       return $this->objToGeometryCollection($obj);
52 52
     }
53
-    $method = 'arrayTo' . $type;
53
+    $method = 'arrayTo'.$type;
54 54
     return $this->$method($obj->coordinates);
55 55
   }
56 56
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -120,8 +120,7 @@  discard block
 block discarded – undo
120 120
   public function write(Geometry $geometry, $return_array = FALSE) {
121 121
     if ($return_array) {
122 122
       return $this->getArray($geometry);
123
-    }
124
-    else {
123
+    } else {
125 124
       return json_encode($this->getArray($geometry));
126 125
     }
127 126
   }
@@ -139,11 +138,12 @@  discard block
 block discarded – undo
139 138
         'type'=> 'GeometryCollection',
140 139
         'geometries'=> $component_array,
141 140
       );
142
-    }
143
-    else return array(
141
+    } else {
142
+    	return array(
144 143
       'type'=> $geometry->getGeomType(),
145 144
       'coordinates'=> $geometry->asArray(),
146 145
     );
146
+    }
147 147
   }
148 148
 }
149 149
 
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/adapters/GeoRSS.class.php 4 patches
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,6 @@  discard block
 block discarded – undo
18 18
   /**
19 19
    * Read GeoRSS string into geometry objects
20 20
    *
21
-   * @param string $georss - an XML feed containing geoRSS
22
-   *
23 21
    * @return Geometry|GeometryCollection
24 22
    */
25 23
   public function read($gpx) {
@@ -80,6 +78,9 @@  discard block
 block discarded – undo
80 78
     return geoPHP::geometryReduce($geometries); 
81 79
   }
82 80
   
81
+  /**
82
+   * @param string $string
83
+   */
83 84
   protected function getPointsFromCoords($string) {
84 85
     $coords = array();
85 86
     $latlon = explode(' ',$string);
Please login to merge, or discard this patch.
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
    * @return Geometry|GeometryCollection
24 24
    */
25 25
   public function read($gpx) {
26
-    return $this->geomFromText($gpx);
26
+	return $this->geomFromText($gpx);
27 27
   }
28 28
 
29 29
   /**
@@ -34,195 +34,195 @@  discard block
 block discarded – undo
34 34
    * @return string The georss string representation of the input geometries
35 35
    */
36 36
   public function write(Geometry $geometry, $namespace = FALSE) {
37
-    if ($namespace) {
38
-      $this->namespace = $namespace;
39
-      $this->nss = $namespace.':';    
40
-    }
41
-    return $this->geometryToGeoRSS($geometry);
37
+	if ($namespace) {
38
+	  $this->namespace = $namespace;
39
+	  $this->nss = $namespace.':';    
40
+	}
41
+	return $this->geometryToGeoRSS($geometry);
42 42
   }
43 43
   
44 44
   public function geomFromText($text) {
45
-    // Change to lower-case, strip all CDATA, and de-namespace
46
-    $text = strtolower($text);
47
-    $text = preg_replace('/<!\[cdata\[(.*?)\]\]>/s','',$text);
45
+	// Change to lower-case, strip all CDATA, and de-namespace
46
+	$text = strtolower($text);
47
+	$text = preg_replace('/<!\[cdata\[(.*?)\]\]>/s','',$text);
48 48
         
49
-    // Load into DOMDOcument
50
-    $xmlobj = new DOMDocument();
51
-    @$xmlobj->loadXML($text);
52
-    if ($xmlobj === false) {
53
-      throw new Exception("Invalid GeoRSS: ". $text);
54
-    }
49
+	// Load into DOMDOcument
50
+	$xmlobj = new DOMDocument();
51
+	@$xmlobj->loadXML($text);
52
+	if ($xmlobj === false) {
53
+	  throw new Exception("Invalid GeoRSS: ". $text);
54
+	}
55 55
     
56
-    $this->xmlobj = $xmlobj;
57
-    try {
58
-      $geom = $this->geomFromXML();
59
-    } catch(InvalidText $e) {
60
-        throw new Exception("Cannot Read Geometry From GeoRSS: ". $text);
61
-    } catch(Exception $e) {
62
-        throw $e;
63
-    }
56
+	$this->xmlobj = $xmlobj;
57
+	try {
58
+	  $geom = $this->geomFromXML();
59
+	} catch(InvalidText $e) {
60
+		throw new Exception("Cannot Read Geometry From GeoRSS: ". $text);
61
+	} catch(Exception $e) {
62
+		throw $e;
63
+	}
64 64
 
65
-    return $geom;
65
+	return $geom;
66 66
   }
67 67
   
68 68
   protected function geomFromXML() {
69
-    $geometries = array();
70
-    $geometries = array_merge($geometries, $this->parsePoints());
71
-    $geometries = array_merge($geometries, $this->parseLines());
72
-    $geometries = array_merge($geometries, $this->parsePolygons());
73
-    $geometries = array_merge($geometries, $this->parseBoxes());
74
-    $geometries = array_merge($geometries, $this->parseCircles());
69
+	$geometries = array();
70
+	$geometries = array_merge($geometries, $this->parsePoints());
71
+	$geometries = array_merge($geometries, $this->parseLines());
72
+	$geometries = array_merge($geometries, $this->parsePolygons());
73
+	$geometries = array_merge($geometries, $this->parseBoxes());
74
+	$geometries = array_merge($geometries, $this->parseCircles());
75 75
     
76
-    if (empty($geometries)) {
77
-      throw new Exception("Invalid / Empty GeoRSS");
78
-    }
76
+	if (empty($geometries)) {
77
+	  throw new Exception("Invalid / Empty GeoRSS");
78
+	}
79 79
     
80
-    return geoPHP::geometryReduce($geometries); 
80
+	return geoPHP::geometryReduce($geometries); 
81 81
   }
82 82
   
83 83
   protected function getPointsFromCoords($string) {
84
-    $coords = array();
85
-    $latlon = explode(' ',$string);
86
-    foreach ($latlon as $key => $item) {
87
-      if (!($key % 2)) {
88
-        // It's a latitude
89
-        $lat = $item;
90
-      }
91
-      else {
92
-        // It's a longitude
93
-        $lon = $item;
94
-        $coords[] = new Point($lon, $lat);
95
-      }
96
-    }
97
-    return $coords;
84
+	$coords = array();
85
+	$latlon = explode(' ',$string);
86
+	foreach ($latlon as $key => $item) {
87
+	  if (!($key % 2)) {
88
+		// It's a latitude
89
+		$lat = $item;
90
+	  }
91
+	  else {
92
+		// It's a longitude
93
+		$lon = $item;
94
+		$coords[] = new Point($lon, $lat);
95
+	  }
96
+	}
97
+	return $coords;
98 98
   }
99 99
   
100 100
   protected function parsePoints() {
101
-    $points = array();
102
-    $pt_elements = $this->xmlobj->getElementsByTagName('point');
103
-    foreach ($pt_elements as $pt) {
104
-      $point_array = $this->getPointsFromCoords(trim($pt->firstChild->nodeValue));
105
-      $points[] = $point_array[0];
106
-    }
107
-    return $points;
101
+	$points = array();
102
+	$pt_elements = $this->xmlobj->getElementsByTagName('point');
103
+	foreach ($pt_elements as $pt) {
104
+	  $point_array = $this->getPointsFromCoords(trim($pt->firstChild->nodeValue));
105
+	  $points[] = $point_array[0];
106
+	}
107
+	return $points;
108 108
   }
109 109
   
110 110
   protected function parseLines() {
111
-    $lines = array();
112
-    $line_elements = $this->xmlobj->getElementsByTagName('line');
113
-    foreach ($line_elements as $line) {
114
-      $components = $this->getPointsFromCoords(trim($line->firstChild->nodeValue));
115
-      $lines[] = new LineString($components);
116
-    }
117
-    return $lines;
111
+	$lines = array();
112
+	$line_elements = $this->xmlobj->getElementsByTagName('line');
113
+	foreach ($line_elements as $line) {
114
+	  $components = $this->getPointsFromCoords(trim($line->firstChild->nodeValue));
115
+	  $lines[] = new LineString($components);
116
+	}
117
+	return $lines;
118 118
   }
119 119
   
120 120
   protected function parsePolygons() {
121
-    $polygons = array();
122
-    $poly_elements = $this->xmlobj->getElementsByTagName('polygon');
123
-    foreach ($poly_elements as $poly) {
124
-      if ($poly->hasChildNodes()) {
125
-        $points = $this->getPointsFromCoords(trim($poly->firstChild->nodeValue));
126
-        $exterior_ring = new LineString($points);
127
-        $polygons[] = new Polygon(array($exterior_ring));
128
-      }
129
-      else {
130
-        // It's an EMPTY polygon
131
-        $polygons[] = new Polygon(); 
132
-      }
133
-    }
134
-    return $polygons;
121
+	$polygons = array();
122
+	$poly_elements = $this->xmlobj->getElementsByTagName('polygon');
123
+	foreach ($poly_elements as $poly) {
124
+	  if ($poly->hasChildNodes()) {
125
+		$points = $this->getPointsFromCoords(trim($poly->firstChild->nodeValue));
126
+		$exterior_ring = new LineString($points);
127
+		$polygons[] = new Polygon(array($exterior_ring));
128
+	  }
129
+	  else {
130
+		// It's an EMPTY polygon
131
+		$polygons[] = new Polygon(); 
132
+	  }
133
+	}
134
+	return $polygons;
135 135
   }
136 136
   
137 137
   // Boxes are rendered into polygons
138 138
   protected function parseBoxes() {
139
-    $polygons = array();
140
-    $box_elements = $this->xmlobj->getElementsByTagName('box');
141
-    foreach ($box_elements as $box) {
142
-      $parts = explode(' ',trim($box->firstChild->nodeValue));
143
-      $components = array(
144
-        new Point($parts[3], $parts[2]),
145
-        new Point($parts[3], $parts[0]),
146
-        new Point($parts[1], $parts[0]),
147
-        new Point($parts[1], $parts[2]),
148
-        new Point($parts[3], $parts[2]),
149
-      );
150
-      $exterior_ring = new LineString($components);
151
-      $polygons[] = new Polygon(array($exterior_ring));
152
-    }
153
-    return $polygons;
139
+	$polygons = array();
140
+	$box_elements = $this->xmlobj->getElementsByTagName('box');
141
+	foreach ($box_elements as $box) {
142
+	  $parts = explode(' ',trim($box->firstChild->nodeValue));
143
+	  $components = array(
144
+		new Point($parts[3], $parts[2]),
145
+		new Point($parts[3], $parts[0]),
146
+		new Point($parts[1], $parts[0]),
147
+		new Point($parts[1], $parts[2]),
148
+		new Point($parts[3], $parts[2]),
149
+	  );
150
+	  $exterior_ring = new LineString($components);
151
+	  $polygons[] = new Polygon(array($exterior_ring));
152
+	}
153
+	return $polygons;
154 154
   }
155 155
 
156 156
   // Circles are rendered into points
157 157
   // @@TODO: Add good support once we have circular-string geometry support
158 158
   protected function parseCircles() {
159
-    $points = array();
160
-    $circle_elements = $this->xmlobj->getElementsByTagName('circle');
161
-    foreach ($circle_elements as $circle) {
162
-      $parts = explode(' ',trim($circle->firstChild->nodeValue));
163
-      $points[] = new Point($parts[1], $parts[0]);
164
-    }
165
-    return $points;
159
+	$points = array();
160
+	$circle_elements = $this->xmlobj->getElementsByTagName('circle');
161
+	foreach ($circle_elements as $circle) {
162
+	  $parts = explode(' ',trim($circle->firstChild->nodeValue));
163
+	  $points[] = new Point($parts[1], $parts[0]);
164
+	}
165
+	return $points;
166 166
   }
167 167
   
168 168
   protected function geometryToGeoRSS($geom) {
169
-    $type = strtolower($geom->getGeomType());
170
-    switch ($type) {
171
-      case 'point':
172
-        return $this->pointToGeoRSS($geom);
173
-        break;
174
-      case 'linestring':
175
-        return $this->linestringToGeoRSS($geom);
176
-        break;
177
-      case 'polygon':
178
-        return $this->PolygonToGeoRSS($geom);
179
-        break;
180
-      case 'multipoint':
181
-      case 'multilinestring':
182
-      case 'multipolygon':
183
-      case 'geometrycollection':
184
-        return $this->collectionToGeoRSS($geom);
185
-        break;
186
-    }
187
-    return $output;
169
+	$type = strtolower($geom->getGeomType());
170
+	switch ($type) {
171
+	  case 'point':
172
+		return $this->pointToGeoRSS($geom);
173
+		break;
174
+	  case 'linestring':
175
+		return $this->linestringToGeoRSS($geom);
176
+		break;
177
+	  case 'polygon':
178
+		return $this->PolygonToGeoRSS($geom);
179
+		break;
180
+	  case 'multipoint':
181
+	  case 'multilinestring':
182
+	  case 'multipolygon':
183
+	  case 'geometrycollection':
184
+		return $this->collectionToGeoRSS($geom);
185
+		break;
186
+	}
187
+	return $output;
188 188
   }
189 189
   
190 190
   private function pointToGeoRSS($geom) {
191
-    return '<'.$this->nss.'point>'.$geom->getY().' '.$geom->getX().'</'.$this->nss.'point>';
191
+	return '<'.$this->nss.'point>'.$geom->getY().' '.$geom->getX().'</'.$this->nss.'point>';
192 192
   }
193 193
   
194 194
 
195 195
   private function linestringToGeoRSS($geom) {
196
-    $output = '<'.$this->nss.'line>';
197
-    foreach ($geom->getComponents() as $k => $point) {
198
-      $output .= $point->getY().' '.$point->getX();
199
-      if ($k < ($geom->numGeometries() -1)) $output .= ' ';
200
-    }
201
-    $output .= '</'.$this->nss.'line>';
202
-    return $output;
196
+	$output = '<'.$this->nss.'line>';
197
+	foreach ($geom->getComponents() as $k => $point) {
198
+	  $output .= $point->getY().' '.$point->getX();
199
+	  if ($k < ($geom->numGeometries() -1)) $output .= ' ';
200
+	}
201
+	$output .= '</'.$this->nss.'line>';
202
+	return $output;
203 203
   }
204 204
 
205 205
   private function polygonToGeoRSS($geom) {
206
-    $output = '<'.$this->nss.'polygon>';
207
-    $exterior_ring = $geom->exteriorRing();
208
-    foreach ($exterior_ring->getComponents() as $k => $point) {
209
-      $output .= $point->getY().' '.$point->getX();
210
-      if ($k < ($exterior_ring->numGeometries() -1)) $output .= ' ';
211
-    }
212
-    $output .= '</'.$this->nss.'polygon>';
213
-    return $output;
206
+	$output = '<'.$this->nss.'polygon>';
207
+	$exterior_ring = $geom->exteriorRing();
208
+	foreach ($exterior_ring->getComponents() as $k => $point) {
209
+	  $output .= $point->getY().' '.$point->getX();
210
+	  if ($k < ($exterior_ring->numGeometries() -1)) $output .= ' ';
211
+	}
212
+	$output .= '</'.$this->nss.'polygon>';
213
+	return $output;
214 214
   }
215 215
   
216 216
   public function collectionToGeoRSS($geom) {
217
-    $georss = '<'.$this->nss.'where>';
218
-    $components = $geom->getComponents();
219
-    foreach ($geom->getComponents() as $comp) {
220
-      $georss .= $this->geometryToGeoRSS($comp);
221
-    }
217
+	$georss = '<'.$this->nss.'where>';
218
+	$components = $geom->getComponents();
219
+	foreach ($geom->getComponents() as $comp) {
220
+	  $georss .= $this->geometryToGeoRSS($comp);
221
+	}
222 222
     
223
-    $georss .= '</'.$this->nss.'where>';
223
+	$georss .= '</'.$this->nss.'where>';
224 224
     
225
-    return $georss;
225
+	return $georss;
226 226
   }
227 227
 
228 228
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -44,21 +44,21 @@  discard block
 block discarded – undo
44 44
   public function geomFromText($text) {
45 45
     // Change to lower-case, strip all CDATA, and de-namespace
46 46
     $text = strtolower($text);
47
-    $text = preg_replace('/<!\[cdata\[(.*?)\]\]>/s','',$text);
47
+    $text = preg_replace('/<!\[cdata\[(.*?)\]\]>/s', '', $text);
48 48
         
49 49
     // Load into DOMDOcument
50 50
     $xmlobj = new DOMDocument();
51 51
     @$xmlobj->loadXML($text);
52 52
     if ($xmlobj === false) {
53
-      throw new Exception("Invalid GeoRSS: ". $text);
53
+      throw new Exception("Invalid GeoRSS: ".$text);
54 54
     }
55 55
     
56 56
     $this->xmlobj = $xmlobj;
57 57
     try {
58 58
       $geom = $this->geomFromXML();
59
-    } catch(InvalidText $e) {
60
-        throw new Exception("Cannot Read Geometry From GeoRSS: ". $text);
61
-    } catch(Exception $e) {
59
+    } catch (InvalidText $e) {
60
+        throw new Exception("Cannot Read Geometry From GeoRSS: ".$text);
61
+    } catch (Exception $e) {
62 62
         throw $e;
63 63
     }
64 64
 
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
   
83 83
   protected function getPointsFromCoords($string) {
84 84
     $coords = array();
85
-    $latlon = explode(' ',$string);
85
+    $latlon = explode(' ', $string);
86 86
     foreach ($latlon as $key => $item) {
87
-      if (!($key % 2)) {
87
+      if (!($key%2)) {
88 88
         // It's a latitude
89 89
         $lat = $item;
90 90
       }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     $polygons = array();
140 140
     $box_elements = $this->xmlobj->getElementsByTagName('box');
141 141
     foreach ($box_elements as $box) {
142
-      $parts = explode(' ',trim($box->firstChild->nodeValue));
142
+      $parts = explode(' ', trim($box->firstChild->nodeValue));
143 143
       $components = array(
144 144
         new Point($parts[3], $parts[2]),
145 145
         new Point($parts[3], $parts[0]),
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     $points = array();
160 160
     $circle_elements = $this->xmlobj->getElementsByTagName('circle');
161 161
     foreach ($circle_elements as $circle) {
162
-      $parts = explode(' ',trim($circle->firstChild->nodeValue));
162
+      $parts = explode(' ', trim($circle->firstChild->nodeValue));
163 163
       $points[] = new Point($parts[1], $parts[0]);
164 164
     }
165 165
     return $points;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     $output = '<'.$this->nss.'line>';
197 197
     foreach ($geom->getComponents() as $k => $point) {
198 198
       $output .= $point->getY().' '.$point->getX();
199
-      if ($k < ($geom->numGeometries() -1)) $output .= ' ';
199
+      if ($k < ($geom->numGeometries() - 1)) $output .= ' ';
200 200
     }
201 201
     $output .= '</'.$this->nss.'line>';
202 202
     return $output;
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
     $exterior_ring = $geom->exteriorRing();
208 208
     foreach ($exterior_ring->getComponents() as $k => $point) {
209 209
       $output .= $point->getY().' '.$point->getX();
210
-      if ($k < ($exterior_ring->numGeometries() -1)) $output .= ' ';
210
+      if ($k < ($exterior_ring->numGeometries() - 1)) $output .= ' ';
211 211
     }
212 212
     $output .= '</'.$this->nss.'polygon>';
213 213
     return $output;
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -87,8 +87,7 @@  discard block
 block discarded – undo
87 87
       if (!($key % 2)) {
88 88
         // It's a latitude
89 89
         $lat = $item;
90
-      }
91
-      else {
90
+      } else {
92 91
         // It's a longitude
93 92
         $lon = $item;
94 93
         $coords[] = new Point($lon, $lat);
@@ -125,8 +124,7 @@  discard block
 block discarded – undo
125 124
         $points = $this->getPointsFromCoords(trim($poly->firstChild->nodeValue));
126 125
         $exterior_ring = new LineString($points);
127 126
         $polygons[] = new Polygon(array($exterior_ring));
128
-      }
129
-      else {
127
+      } else {
130 128
         // It's an EMPTY polygon
131 129
         $polygons[] = new Polygon(); 
132 130
       }
@@ -196,7 +194,9 @@  discard block
 block discarded – undo
196 194
     $output = '<'.$this->nss.'line>';
197 195
     foreach ($geom->getComponents() as $k => $point) {
198 196
       $output .= $point->getY().' '.$point->getX();
199
-      if ($k < ($geom->numGeometries() -1)) $output .= ' ';
197
+      if ($k < ($geom->numGeometries() -1)) {
198
+      	$output .= ' ';
199
+      }
200 200
     }
201 201
     $output .= '</'.$this->nss.'line>';
202 202
     return $output;
@@ -207,7 +207,9 @@  discard block
 block discarded – undo
207 207
     $exterior_ring = $geom->exteriorRing();
208 208
     foreach ($exterior_ring->getComponents() as $k => $point) {
209 209
       $output .= $point->getY().' '.$point->getX();
210
-      if ($k < ($exterior_ring->numGeometries() -1)) $output .= ' ';
210
+      if ($k < ($exterior_ring->numGeometries() -1)) {
211
+      	$output .= ' ';
212
+      }
211 213
     }
212 214
     $output .= '</'.$this->nss.'polygon>';
213 215
     return $output;
Please login to merge, or discard this patch.