Completed
Push — master ( 0ba033...062c39 )
by Yannick
10:34
created

NOTAM::deleteAllNOTAMLocation()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 3
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
require_once(dirname(__FILE__).'/settings.php');
3
require_once(dirname(__FILE__).'/class.Connection.php');
4
require_once(dirname(__FILE__).'/class.Common.php');
5
require_once(dirname(__FILE__).'/class.Spotter.php');
6
7
class NOTAM {
8
	public $db;
9
	private $abbr = array(
10
	                    'A/A' => 'Air-to-air',
11
	                    'A/G' => 'Air-to-ground',
12
	                    'AAL' => 'Above Aerodrome Level',
13
	                    'ABM' => 'Abeam',
14
	                    'ABN' => 'Aerodrome Beacon',
15
	                    'ABT' => 'About',
16
	                    'ABV' => 'Above',
17
	                    'ACC' => 'Area Control',
18
	                    'ACFT' => 'Aircraft',
19
	                    'ACK' => 'Acknowledge',
20
	                    'ACL' => 'Altimeter Check Location',
21
	                    'ACN' => 'Aircraft Classification Number',
22
	                    'ACPT' => 'Accepted',
23
	                    'ACT' => 'Active',
24
	                    'AD' => 'Aerodrome',
25
	                    'ADA' => 'Advisory Area',
26
	                    'ADC' => 'Aerodrome Chart',
27
	                    'ADDN' => 'Additional',
28
	                    'ADJ' => 'Adjacent',
29
	                    'ADR' => 'Advisory Route',
30
	                    'ADS' => 'Automatic Dependent Surveillance',
31
	                    'ADVS' => 'Advisory Service',
32
	                    'ADZ' => 'Advised',
33
	                    'AFIL' => 'Flight Plan Filed In The Air',
34
	                    'AFM' => 'Affirm',
35
	                    'AFT' => 'After',
36
	                    'AGA' => 'Aerodromes, Air Routes and Ground Aids',
37
	                    'AGN' => 'Again',
38
	                    'ALERFA' => 'Alert Phase',
39
	                    'ALRS' => 'Alerting Service',
40
	                    'ALS' => 'Approach Lighting System',
41
	                    'ALT' => 'Altitude',
42
	                    'ALTN' => 'Alternate',
43
	                    'AMA' => 'Area Minimum Altitude',
44
	                    'ANC' => 'Aeronautical Chart',
45
	                    'ANCS' => 'Aeronautical Navigation Chart',
46
	                    'ANS' => 'Answer',
47
	                    'AOC' => 'Aerodrome Obstacle Chart',
48
	                    'AP' => 'Airport',
49
	                    'APCH' => 'Approach',
50
	                    'APDC' => 'Aircraft Parking/docking Chart',
51
	                    'APN' => 'Apron',
52
	                    'APNS' => 'Aprons',
53
	                    'APP' => 'Approach Control',
54
	                    'APR' => 'April',
55
	                    'APRX' => 'Approximately',
56
	                    'APSG' => 'After Passing',
57
	                    'APV' => 'Approved',
58
	                    'ARC' => 'Area Chart',
59
	                    'ARNG' => 'Arrange',
60
	                    'ARO' => 'Air Traffic Services Reporting Office',
61
	                    'ARP' => 'Aerodrome Reference Point',
62
	                    'ARR' => 'Arriving',
63
	                    'ARST' => 'Arresting',
64
	                    'ASC' => 'Ascend To',
65
	                    'ASDA' => 'Accelerate-Stop Distance Available',
66
	                    'ASPEEDG' => 'Airspeed Gain',
67
	                    'ASPEEDL' => 'Airspeed Loss',
68
	                    'ASPH' => 'Asphalt',
69
	                    'ATA' => 'Actual Time of Arrival',
70
	                    'ATD' => 'Actual Time of Departure',
71
	                    'ATFM' => 'Air Traffic Flow Management',
72
	                    'ATM' => 'Air Traffic Management',
73
	                    'ATP' => 'At',
74
	                    'ATTN' => 'Attention',
75
	                    'ATZ' => 'Aerodrome Traffic Zone',
76
	                    'AUG' => 'August',
77
	                    'AUTH' => 'Authorization',
78
	                    'AUW' => 'All Up Weight',
79
	                    'AUX' => 'Auxiliary',
80
	                    'AVBL' => 'Available',
81
	                    'AVG' => 'Average',
82
	                    'AVGAS' => 'Aviation Gasoline',
83
	                    'AWTA' => 'Advise At What Time Able',
84
	                    'AWY' => 'Airway',
85
	                    'AWYS' => 'Airways',
86
	                    'AZM' => 'Azimuth',
87
	                    'BA' => 'Braking Action',
88
	                    'BCN' => 'Beacon',
89
	                    'BCST' => 'Broadcast',
90
	                    'BDRY' => 'Boundary',
91
	                    'BFR' => 'Before',
92
	                    'BLDG' => 'Building',
93
	                    'BLO' => 'Below Clouds',
94
	                    'BLW' => 'Below',
95
	                    'BRF' => 'Short',
96
	                    'BRG' => 'Bearing',
97
	                    'BRKG' => 'Breaking',
98
	                    'BTL' => 'Between Layers',
99
	                    'BTN' => 'Between',
100
	                    'CD' => 'Candela',
101
	                    'CDN' => 'Coordination',
102
	                    'CF' => 'Change Frequency To',
103
	                    'CFM' => 'Confirm',
104
	                    'CGL' => 'Circling Guidance Light(s)',
105
	                    'CH' => 'Channel',
106
	                    'CHG' => 'Changed',
107
	                    'CIT' => 'Near or Over Large Towns',
108
	                    'CIV' => 'Civil',
109
	                    'CK' => 'Check',
110
	                    'CL' => 'Centre Line',
111
	                    'CLBR' => 'Calibration',
112
	                    'CLD' => 'Cloud',
113
	                    'CLG' => 'Calling',
114
	                    'CLIMB-OUT' => 'Climb-out Area',
115
	                    'CLR' => 'Clearance',
116
	                    'CLRD' => 'Cleared',
117
	                    'CLSD' => 'Closed',
118
	                    'CMB' => 'Climb',
119
	                    'CMPL' => 'Complete',
120
	                    'CNL' => 'Cancel',
121
	                    'CNS' => 'Communications, Navigation And Surveillance',
122
	                    'COM' => 'Communications',
123
	                    'CONC' => 'Concrete',
124
	                    'COND' => 'Condition',
125
	                    'CONS' => 'Continuous',
126
	                    'CONST' => 'Construction',
127
	                    'CONT' => 'Continued',
128
	                    'COOR' => 'Coordination',
129
	                    'COORD' => 'Coordinates',
130
	                    'COP' => 'Change-over Point',
131
	                    'COR' => 'Correction',
132
	                    'COT' => 'At The Coast',
133
	                    'COV' => 'Covered',
134
	                    'CPDLC' => 'Controller-pilot Data Link Communications',
135
	                    'CPL' => 'Current Flight Plan',
136
	                    'CRC' => 'Cyclic Redundancy Check',
137
	                    'CRZ' => 'Cruise',
138
	                    'CTAM' => 'Climb To And Maintain',
139
	                    'CTC' => 'Contact',
140
	                    'CTL' => 'Control',
141
	                    'CTN' => 'Caution',
142
	                    'CTR' => 'Control Zone',
143
	                    'CVR' => 'Cockpit Voice Recorder',
144
	                    'CW' => 'Continuous Wave',
145
	                    'CWY' => 'Clearway',
146
	                    'DA' => 'Decision Altitude',
147
	                    'DCKG' => 'Docking',
148
	                    'DCP' => 'Datum Crossing Point',
149
	                    'DCPC' => 'Direct Controller-pilot Communications',
150
	                    'DCT' => 'Direct',
151
	                    'DEC' => 'December',
152
	                    'DEG' => 'Degrees',
153
	                    'DEP' => 'Departing',
154
	                    'DES' => 'Descend',
155
	                    'DEST' => 'Destination',
156
	                    'DETRESFA' => 'Distress Phase',
157
	                    'DEV' => 'Deviating',
158
	                    'DFDR' => 'Digital Flight Data Recorder',
159
	                    'DFTI' => 'Distance From Touchdown Indicator',
160
	                    'DH' => 'Decision Height',
161
	                    'DIP' => 'Diffuse',
162
	                    'DIST' => 'Distance',
163
	                    'DIV' => 'Divert',
164
	                    'DLA' => 'Delay',
165
	                    'DLY' => 'Daily',
166
	                    'DNG' => 'Dangerous',
167
	                    'DOM' => 'Domestic',
168
	                    'DPT' => 'Depth',
169
	                    'DR' => 'Dead Reckoning',
170
	                    'DRG' => 'During',
171
	                    'DTAM' => 'Descend To And Maintain',
172
	                    'DTG' => 'Date-time Group',
173
	                    'DTHR' => 'Displaced Runway Threshold',
174
	                    'DTRT' => 'Deteriorating',
175
	                    'DTW' => 'Dual Tandem Wheels',
176
	                    'DUPE' => 'This Is A Duplicate Message',
177
	                    'DUR' => 'Duration',
178
	                    'DVOR' => 'Doppler VOR',
179
	                    'DW' => 'Dual Wheels',
180
	                    'EAT' => 'Expected Approach Time',
181
	                    'EB' => 'Eastbound',
182
	                    'EDA' => 'Elevation Differential Area',
183
	                    'EET' => 'Estimated Elapsed Time',
184
	                    'EFC' => 'Expect Further Clearance',
185
	                    'ELBA' => 'Emergency Location Beacon',
186
	                    'ELEV' => 'Elevation',
187
	                    'ELR' => 'Extra Long Range',
188
	                    'EM' => 'Emission',
189
	                    'EMERG' => 'Emergency',
190
	                    'END' => 'Stop-end',
191
	                    'ENE' => 'East-north-east',
192
	                    'ENG' => 'Engine',
193
	                    'ENR' => 'En-route',
194
	                    'ENRC' => 'En-route Chart',
195
	                    'EOBT' => 'Estimated Off-block Time',
196
	                    'EQPT' => 'Equipment',
197
	                    'ER' => 'Here',
198
	                    'ESE' => 'East-south-east',
199
	                    'EST' => 'Estimate',
200
	                    'ETA' => 'Estimated Time Of Arrival',
201
	                    'ETD' => 'Estimated Time Of Departure',
202
	                    'ETO' => 'Estimated Time Over Significant Point',
203
	                    'EV' => 'Every',
204
	                    'EXC' => 'Except',
205
	                    'EXER' => 'Exercise',
206
	                    'EXP' => 'Expect',
207
	                    'EXTD' => 'Extend',
208
	                    'FAC' => 'Facilities',
209
	                    'FAF' => 'Final Approach Fix',
210
	                    'FAL' => 'Facilitation of International Airtransport',
211
	                    'FAP' => 'Final Approach Point',
212
	                    'FATO' => 'Final Approach And Take-off Area',
213
	                    'FAX' => 'Fax',
214
	                    'FBL' => 'Light',
215
	                    'FCST' => 'Forecast',
216
	                    'FCT' => 'Friction Coefficient',
217
	                    'FDPS' => 'Flight Data Processing System',
218
	                    'FEB' => 'February',
219
	                    'FLD' => 'Field',
220
	                    'FLG' => 'Flashing',
221
	                    'FLR' => 'Flares',
222
	                    'FLT' => 'Flight',
223
	                    'FLTS' => 'Flights',
224
	                    'FLTCK' => 'Flight Check',
225
	                    'FLUC' => 'Fluctuating',
226
	                    'FLW' => 'Follow(s)',
227
	                    'FLY' => 'Fly',
228
	                    'FM' => 'From',
229
	                    'FMS' => 'Flight Management System',
230
	                    'FMU' => 'Flow Management Unit',
231
	                    'FNA' => 'Final Approach',
232
	                    'FPAP' => 'Flight Path Alignment Point',
233
	                    'FPL' => 'Flight Plan',
234
	                    'FPLS' => 'Flight Plans',
235
	                    'FPM' => 'Feet Per Minute',
236
	                    'FPR' => 'Flight Plan Route',
237
	                    'FR' => 'Fuel Remaining',
238
	                    'FREQ' => 'Frequency',
239
	                    'FRI' => 'Friday',
240
	                    'FRNG' => 'Firing',
241
	                    'FRONT' => 'Front',
242
	                    'FRQ' => 'Frequent',
243
	                    'FSL' => 'Full Stop Landing',
244
	                    'FSS' => 'Flight Service Station',
245
	                    'FST' => 'First',
246
	                    'FTP' => 'Fictitious Threshold Point',
247
	                    'G/A' => 'Ground-to-air',
248
	                    'G/A/G' => 'Ground-to-air and Air-to-ground',
249
	                    'GARP' => 'GBAS Azimuth Reference Point',
250
	                    'GBAS' => 'Ground-based Augmentation System',
251
	                    'GCAJ' => 'Ground Controlled Approach',
252
	                    'GEN' => 'General',
253
	                    'GEO' => 'Geographic or True',
254
	                    'GES' => 'Ground Earth Station',
255
	                    'GLD' => 'Glider',
256
	                    'GMC' => 'Ground Movement Chart',
257
	                    'GND' => 'Ground',
258
	                    'GNDCK' => 'Ground Check',
259
	                    'GP' => 'Glide Path',
260
	                    'GRASS' => 'Grass landing area',
261
	                    'GRVL' => 'Gravel',
262
	                    'GUND' => 'Geoid Undulation',
263
	                    'H24' => '24 Hours',
264
	                    'HAPI' => 'Helicopter Approach Path Indicator',
265
	                    'HBN' => 'Hazard Beacon',
266
	                    'HDG' => 'Heading',
267
	                    'HEL' => 'Helicopter',
268
	                    'HGT' => 'Height',
269
	                    'HJ' => 'Sunrise to Sunset',
270
	                    'HLDG' => 'Holding',
271
	                    'HN' => 'Sunset to Sunrise',
272
	                    'HO' => 'Service Available To Meet Operational Requirements',
273
	                    'HOL' => 'Holiday',
274
	                    'HOSP' => 'Hospital Aircraft',
275
	                    'HOT' => 'Height',
276
	                    'HPA' => 'Hectopascal',
277
	                    'HR' => 'Hours',
278
	                    'HRS' => 'Hours',
279
	                    'HS' => 'Service Available During Hours Of Scheduled Operations',
280
	                    'HURCN' => 'Hurricane',
281
	                    'HVY' => 'Heavy',
282
	                    'HX' => 'No Specific Working Hours',
283
	                    'HYR' => 'Higher',
284
	                    'IAC' => 'Instrument Approach Chart',
285
	                    'IAF' => 'Initial Approach Fix',
286
	                    'IAO' => 'In And Out Of Clouds',
287
	                    'IAP' => 'Instrument Approach Procedure',
288
	                    'IAR' => 'Intersection Of Air Routes',
289
	                    'IBN' => 'Identification Beacon',
290
	                    'ID' => 'Identifier',
291
	                    'IDENT' => 'Identification',
292
	                    'IFF' => 'Identification Friend/Foe',
293
	                    'IGA' => 'International General Aviation',
294
	                    'IM' => 'Inner Marker',
295
	                    'IMPR' => 'Improving',
296
	                    'IMT' => 'Immediately',
297
	                    'INA' => 'Initial Approach',
298
	                    'INBD' => 'Inbound',
299
	                    'INCERFA' => 'Uncertainty Phase',
300
	                    'INFO' => 'Information',
301
	                    'INOP' => 'Inoperative',
302
	                    'INP' => 'If Not Possible',
303
	                    'INPR' => 'In Progress',
304
	                    'INSTL' => 'Installation',
305
	                    'INSTR' => 'Instrument',
306
	                    'INT' => 'Intersection',
307
	                    'INTS' => 'Intersections',
308
	                    'INTL' => 'International',
309
	                    'INTRG' => 'Interrogator',
310
	                    'INTRP' => 'Interruption',
311
	                    'INTSF' => 'Intensifying',
312
	                    'INTST' => 'Intensity',
313
	                    'ISA' => 'International Standard Atmosphere',
314
	                    'JAN' => 'January',
315
	                    'JTST' => 'Jet stream',
316
	                    'JUL' => 'July',
317
	                    'JUN' => 'June',
318
	                    'KMH' => 'Kilometres Per Hour',
319
	                    'KPA' => 'Kilopascal',
320
	                    'KT' => 'Knots',
321
	                    'KW' => 'Kilowatts',
322
	                    'LAN' => 'Inland',
323
	                    'LAT' => 'Latitude',
324
	                    'LDA' => 'Landing Distance Available',
325
	                    'LDAH' => 'Landing Distance Available, Helicopter',
326
	                    'LDG' => 'Landing',
327
	                    'LDI' => 'Landing Direction Indicator',
328
	                    'LEN' => 'Length',
329
	                    'LGT' => 'Lighting',
330
	                    'LGTD' => 'Lighted',
331
	                    'LIH' => 'Light Intensity High',
332
	                    'LIL' => 'Light Intensity Low',
333
	                    'LIM' => 'Light Intensity Medium',
334
	                    'LLZ' => 'Localizer',
335
	                    'LM' => 'Locator, Middle',
336
	                    'LMT' => 'Local Mean Time',
337
	                    'LNG' => 'Long',
338
	                    'LO' => 'Locator, Outer',
339
	                    'LOG' => 'Located',
340
	                    'LONG' => 'Longitude',
341
	                    'LRG' => 'Long Range',
342
	                    'LTD' => 'Limited',
343
	                    'LTP' => 'Landing Threshold Point',
344
	                    'LVE' => 'Leaving',
345
	                    'LVL' => 'Level',
346
	                    'LYR' => 'Layer',
347
	                    'MAA' => 'Maximum Authorized Altitude',
348
	                    'MAG' => 'Magnetic',
349
	                    'MAINT' => 'Maintenance',
350
	                    'MAP' => 'Aeronautical Maps and Charts',
351
	                    'MAPT' => 'Missed Approach Point',
352
	                    'MAR' => 'March',
353
	                    'MAX' => 'Maximum',
354
	                    'MAY' => 'May',
355
	                    'MBST' => 'Microburst',
356
	                    'MCA' => 'Minimum Crossing Altitude',
357
	                    'MCW' => 'Modulated Continuous Wave',
358
	                    'MDA' => 'Minimum Descent Altitude',
359
	                    'MDH' => 'Minimum Descent Height',
360
	                    'MEA' => 'Minimum En-route Altitude',
361
	                    'MEHT' => 'Minimum Eye Height Over Threshold',
362
	                    'MET' => 'Meteorological',
363
	                    'MID' => 'Mid-point',
364
	                    'MIL' => 'Military',
365
	                    'MIN' => 'Minutes',
366
	                    'MKR' => 'Marker Radio Beacon',
367
	                    'MLS' => 'Microwave Landing System',
368
	                    'MM' => 'Middle Marker',
369
	                    'MNM' => 'Minimum',
370
	                    'MNPS' => 'Minimum Navigation Performance Specifications',
371
	                    'MNT' => 'Monitor',
372
	                    'MNTN' => 'Maintain',
373
	                    'MOA' => 'Military Operating Area',
374
	                    'MOC' => 'Minimum Obstacle Clearance',
375
	                    'MOD' => 'Moderate',
376
	                    'MON' => 'Monday',
377
	                    'MOPS' => 'Minimum Operational Performance Standards',
378
	                    'MOV' => 'Movement',
379
	                    'MRA' => 'Minimum Reception Altitude',
380
	                    'MRG' => 'Medium Range',
381
	                    'MRP' => 'ATS/MET Reporting Point',
382
	                    'MS' => 'Minus',
383
	                    'MSA' => 'Minimum Sector Altitude',
384
	                    'MSAW' => 'Minimum Safe Altitude Warning',
385
	                    'MSG' => 'Message',
386
	                    'MSSR' => 'Monopulse Secondary Surveillance Radar',
387
	                    'MT' => 'Mountain',
388
	                    'MTU' => 'Metric Units',
389
	                    'MTW' => 'Mountain Waves',
390
	                    'NASC' => 'National AIS System Centre',
391
	                    'NAT' => 'North Atlantic',
392
	                    'NAV' => 'Navigation',
393
	                    'NB' => 'Northbound',
394
	                    'NBFR' => 'Not Before',
395
	                    'NE' => 'North-east',
396
	                    'NEB' => 'North-eastbound',
397
	                    'NEG' => 'Negative',
398
	                    'NGT' => 'Night',
399
	                    'NIL' => 'None',
400
	                    'NML' => 'Normal',
401
	                    'NNE' => 'North-north-east',
402
	                    'NNW' => 'North-north-west',
403
	                    'NOF' => 'International NOTAM Office',
404
	                    'NOV' => 'November',
405
	                    'NOZ' => 'Normal Operating Zone',
406
	                    'NR' => 'Number',
407
	                    'NRH' => 'No Reply Heard',
408
	                    'NTL' => 'National',
409
	                    'NTZ' => 'No Transgression Zone',
410
	                    'NW' => 'North-west',
411
	                    'NWB' => 'North-westbound',
412
	                    'NXT' => 'Next',
413
	                    'O/R' => 'On Request',
414
	                    'OAC' => 'Oceanic Area Control Centre',
415
	                    'OAS' => 'Obstacle Assessment Surface',
416
	                    'OBS' => 'Observe',
417
	                    'OBST' => 'Obstacle',
418
	                    'OBSTS' => 'Obstacles',
419
	                    'OCA' => 'Oceanic Control Area',
420
	                    'OCH' => 'Obstacle Clearance Height',
421
	                    'OCS' => 'Obstacle Clearance Surface',
422
	                    'OCT' => 'October',
423
	                    'OFZ' => 'Obstacle Free Zone',
424
	                    'OGN' => 'Originate',
425
	                    'OHD' => 'Overhead',
426
	                    'OM' => 'Outer Marker',
427
	                    'OPC' => 'Control Indicated Is Operational Control',
428
	                    'OPMET' => 'Operational Meteorological',
429
	                    'OPN' => 'Open',
430
	                    'OPR' => 'Operate',
431
	                    'OPS' => 'Operations',
432
	                    'ORD' => 'Order',
433
	                    'OSV' => 'Ocean Station Vessel',
434
	                    'OTLK' => 'Outlook',
435
	                    'OTP' => 'On Top',
436
	                    'OTS' => 'Organized Track System',
437
	                    'OUBD' => 'Outbound',
438
	                    'PA' => 'Precision Approach',
439
	                    'PALS' => 'Precision Approach Lighting System',
440
	                    'PANS' => 'Procedures for Air Navigation Services',
441
	                    'PAR' => 'Precision Approach Radar',
442
	                    'PARL' => 'Parallel',
443
	                    'PATC' => 'Precision Approach Terrain Chart',
444
	                    'PAX' => 'Passenger(s)',
445
	                    'PCD' => 'Proceed',
446
	                    'PCL' => 'Pilot-controlled Lighting',
447
	                    'PCN' => 'Pavement Classification Number',
448
	                    'PDC' => 'Pre-departure Clearance',
449
	                    'PDG' => 'Procedure Design Gradient',
450
	                    'PER' => 'Performance',
451
	                    'PERM' => 'Permanent',
452
	                    'PIB' => 'Pre-flight Information Bulletin',
453
	                    'PJE' => 'Parachute Jumping Exercise',
454
	                    'PLA' => 'Practice Low Approach',
455
	                    'PLN' => 'Flight Plan',
456
	                    'PLVL' => 'Present Level',
457
	                    'PN' => 'Prior Notice Required',
458
	                    'PNR' => 'Point Of No Return',
459
	                    'POB' => 'Persons On Board',
460
	                    'POSS' => 'Possible',
461
	                    'PPI' => 'Plan Position Indicator',
462
	                    'PPR' => 'Prior Permission Required',
463
	                    'PPSN' => 'Present Position',
464
	                    'PRI' => 'Primary',
465
	                    'PRKG' => 'Parking',
466
	                    'PROB' => 'Probability',
467
	                    'PROC' => 'Procedure',
468
	                    'PROV' => 'Provisional',
469
	                    'PS' => 'Plus',
470
	                    'PSG' => 'Passing',
471
	                    'PSN' => 'Position',
472
	                    'PSNS' => 'Positions',
473
	                    'PSR' => 'Primary Surveillance Radar',
474
	                    'PSYS' => 'Pressure System(s)',
475
	                    'PTN' => 'Procedure Turn',
476
	                    'PTS' => 'Polar Track Structure',
477
	                    'PWR' => 'Power',
478
	                    'QUAD' => 'Quadrant',
479
	                    'RAC' => 'Rules of The Air and Air Traffic Services',
480
	                    'RAG' => 'Runway Arresting Gear',
481
	                    'RAI' => 'Runway Alignment Indicator',
482
	                    'RASC' => 'Regional AIS System Centre',
483
	                    'RASS' => 'Remote Altimeter Setting Source',
484
	                    'RB' => 'Rescue Boat',
485
	                    'RCA' => 'Reach Cruising Altitude',
486
	                    'RCC' => 'Rescue Coordination Centre',
487
	                    'RCF' => 'Radiocommunication Failure',
488
	                    'RCH' => 'Reaching',
489
	                    'RCL' => 'Runway Centre Line',
490
	                    'RCLL' => 'Runway Centre Line Light(s)',
491
	                    'RCLR' => 'Recleared',
492
	                    'RDH' => 'Reference Datum Height',
493
	                    'RDL' => 'Radial',
494
	                    'RDO' => 'Radio',
495
	                    'RE' => 'Recent',
496
	                    'REC' => 'Receiver',
497
	                    'REDL' => 'Runway Edge Light(s)',
498
	                    'REF' => 'Refer To',
499
	                    'REG' => 'Registration',
500
	                    'RENL' => 'Runway End Light(s)',
501
	                    'REP' => 'Report',
502
	                    'REQ' => 'Requested',
503
	                    'RERTE' => 'Re-route',
504
	                    'RESA' => 'Runway End Safety Area',
505
	                    'RG' => 'Range (lights)',
506
	                    'RHC' => 'Right-hand Circuit',
507
	                    'RIF' => 'Reclearance In Flight',
508
	                    'RITE' => 'Right',
509
	                    'RL' => 'Report Leaving',
510
	                    'RLA' => 'Relay To',
511
	                    'RLCE' => 'Request Level Change En Route',
512
	                    'RLLS' => 'Runway Lead-in Lighting System',
513
	                    'RLNA' => 'Request Level Not Available',
514
	                    'RMAC' => 'Radar Minimum Altitude Chart',
515
	                    'RMK' => 'Remark',
516
	                    'RNG' => 'Radio Range',
517
	                    'RNP' => 'Required Navigation Performance',
518
	                    'ROC' => 'Rate Of Climb',
519
	                    'ROD' => 'Rate Of Descent',
520
	                    'ROFOR' => 'Route Forecast',
521
	                    'RON' => 'Receiving Only',
522
	                    'RPI' => 'Radar Position Indicator',
523
	                    'RPL' => 'Repetitive Flight Plan',
524
	                    'RPLC' => 'Replaced',
525
	                    'RPS' => 'Radar Position Symbol',
526
	                    'RQMNTS' => 'Requirements',
527
	                    'RQP' => 'Request Flight Plan',
528
	                    'RQS' => 'Request Supplementary Flight Plan',
529
	                    'RR' => 'Report Reaching',
530
	                    'RSC' => 'Rescue Sub-centre',
531
	                    'RSCD' => 'Runway Surface Condition',
532
	                    'RSP' => 'Responder Beacon',
533
	                    'RSR' => 'En-route Surveillance Radar',
534
	                    'RTE' => 'Route',
535
	                    'RTES' => 'Routes',
536
	                    'RTF' => 'Radiotelephone',
537
	                    'RTG' => 'Radiotelegraph',
538
	                    'RTHL' => 'Runway Threshold Light(s)',
539
	                    'RTN' => 'Return',
540
	                    'RTODAH' => 'Rejected Take-off Distance Available, Helicopter',
541
	                    'RTS' => 'Return To Service',
542
	                    'RTT' => 'Radioteletypewriter',
543
	                    'RTZL' => 'Runway Touchdown Zone Light(s)',
544
	                    'RUT' => 'Standard Regional Route Transmitting Frequencies',
545
	                    'RV' => 'Rescue Vessel',
546
	                    'RVSM' => 'Reduced Vertical Separation Minimum',
547
	                    'RWY' => 'Runway',
548
	                    'RWYS' => 'Runways',
549
	                    'SALS' => 'Simple Approach Lighting System',
550
	                    'SAN' => 'Sanitary',
551
	                    'SAP' => 'As Soon As Possible',
552
	                    'SAR' => 'Search and Rescue',
553
	                    'SARPS' => 'Standards and Recommended Practices',
554
	                    'SAT' => 'Saturday',
555
	                    'SATCOM' => 'Satellite Communication',
556
	                    'SB' => 'Southbound',
557
	                    'SBAS' => 'Satellite-based Augmentation System',
558
	                    'SDBY' => 'Stand by',
559
	                    'SE' => 'South-east',
560
	                    'SEA' => 'Sea',
561
	                    'SEB' => 'South-eastbound',
562
	                    'SEC' => 'Seconds',
563
	                    'SECN' => 'Section',
564
	                    'SECT' => 'Sector',
565
	                    'SEP' => 'September',
566
	                    'SER' => 'Service',
567
	                    'SEV' => 'Severe',
568
	                    'SFC' => 'Surface',
569
	                    'SGL' => 'Signal',
570
	                    'SID' => 'Standard Instrument Departure',
571
	                    'SIF' => 'Selective Identification Feature',
572
	                    'SIG' => 'Significant',
573
	                    'SIMUL' => 'Simultaneous',
574
	                    'SKED' => 'Schedule',
575
	                    'SLP' => 'Speed Limiting Point',
576
	                    'SLW' => 'Slow',
577
	                    'SMC' => 'Surface Movement Control',
578
	                    'SMR' => 'Surface Movement Radar',
579
	                    'SPL' => 'Supplementary Flight Plan',
580
	                    'SPOC' => 'SAR Point Of Contact',
581
	                    'SPOT' => 'Spot Wind',
582
	                    'SR' => 'Sunrise',
583
	                    'SRA' => 'Surveillance Radar Approach',
584
	                    'SRE' => 'Surveillance Radar Element Of Precision Approach Radar System',
585
	                    'SRG' => 'Short Range',
586
	                    'SRR' => 'Search and Rescue Region',
587
	                    'SRY' => 'Secondary',
588
	                    'SS' => 'Sunset',
589
	                    'SSE' => 'South-south-east',
590
	                    'SSR' => 'Secondary Surveillance Radar',
591
	                    'SST' => 'Supersonic Transport',
592
	                    'SSW' => 'South-south-west',
593
	                    'STA' => 'Straight-in Approach',
594
	                    'STAR' => 'Standard Instrument Arrival',
595
	                    'STD' => 'Standard',
596
	                    'STN' => 'Station',
597
	                    'STNR' => 'Stationary',
598
	                    'STOL' => 'Short Take-off and Landing',
599
	                    'STS' => 'Status',
600
	                    'STWL' => 'Stopway Light(s)',
601
	                    'SUBJ' => 'Subject To',
602
	                    'SUN' => 'Sunday',
603
	                    'SUP' => 'Supplement',
604
	                    'SUPPS' => 'Regional Supplementary Procedures Service Message',
605
	                    'SVCBL' => 'Serviceable',
606
	                    'SW' => 'South-west',
607
	                    'SWB' => 'South-westbound',
608
	                    'SWY' => 'Stopway',
609
	                    'TA' => 'Transition Altitude',
610
	                    'TAA' => 'Terminal Arrival Altitude',
611
	                    'TAF' => 'Aerodrome Forecast',
612
	                    'TAIL' => 'Tail Wind',
613
	                    'TAR' => 'Terminal Area Surveillance Radar',
614
	                    'TAX' => 'Taxi',
615
	                    'TCAC' => 'Tropical Cyclone Advisory Centre',
616
	                    'TDO' => 'Tornado',
617
	                    'TDZ' => 'Touchdown Zone',
618
	                    'TECR' => 'Technical Reason',
619
	                    'TEMPO' => 'Temporarily',
620
	                    'TFC' => 'Traffic',
621
	                    'TGL' => 'Touch-and-go',
622
	                    'TGS' => 'Taxiing Guidance System',
623
	                    'THR' => 'Threshold',
624
	                    'THRU' => 'Through',
625
	                    'THU' => 'Thursday',
626
	                    'TIBA' => 'Traffic Information Broadcast By Aircraft',
627
	                    'TIL' => 'Until',
628
	                    'TIP' => 'Until Past',
629
	                    'TKOF' => 'Take-off',
630
	                    'TL' => 'Till',
631
	                    'TLOF' => 'Touchdown And Lift-off Area',
632
	                    'TMA' => 'Terminal Control Area',
633
	                    'TNA' => 'Turn Altitude',
634
	                    'TNH' => 'Turn Height',
635
	                    'TOC' => 'Top of Climb',
636
	                    'TODA' => 'Take-off Distance Available',
637
	                    'TODAH' => 'Take-off Distance Available, Helicopter',
638
	                    'TORA' => 'Take-off Run Available',
639
	                    'TP' => 'Turning Point',
640
	                    'TR' => 'Track',
641
	                    'TRA' => 'Temporary Reserved Airspace',
642
	                    'TRANS' => 'Transmitter',
643
	                    'TRL' => 'Transition Level',
644
	                    'TUE' => 'Tuesday',
645
	                    'TURB' => 'Turbulence',
646
	                    'TVOR' => 'Terminal VOR',
647
	                    'TWR' => 'Tower',
648
	                    'TWY' => 'Taxiway',
649
	                    'TWYL' => 'Taxiway-link',
650
	                    'TXT' => 'Text',
651
	                    'TYP' => 'Type of Aircraft',
652
	                    'U/S' => 'Unserviceable',
653
	                    'UAB' => 'Until Advised By',
654
	                    'UAC' => 'Upper Area Control Centre',
655
	                    'UAR' => 'Upper Air Route',
656
	                    'UFN' => 'Until Further Notice',
657
	                    'UHDT' => 'Unable Higher Due Traffic',
658
	                    'UIC' => 'Upper Information Centre',
659
	                    'UIR' => 'Upper Flight Information Region',
660
	                    'ULR' => 'Ultra Long Range',
661
	                    'UNA' => 'Unable',
662
	                    'UNAP' => 'Unable To Approve',
663
	                    'UNL' => 'Unlimited',
664
	                    'UNREL' => 'Unreliable',
665
	                    'UTA' => 'Upper Control Area',
666
	                    'VAAC' => 'Volcanic Ash Advisory Centre',
667
	                    'VAC' => 'Visual Approach Chart',
668
	                    'VAL' => 'In Valleys',
669
	                    'VAN' => 'Runway Control Van',
670
	                    'VAR' => 'Visual-aural Radio Range',
671
	                    'VC' => 'Vicinity',
672
	                    'VCY' => 'Vicinity',
673
	                    'VER' => 'Vertical',
674
	                    'VIS' => 'Visibility',
675
	                    'VLR' => 'Very Long Range',
676
	                    'VPA' => 'Vertical Path Angle',
677
	                    'VRB' => 'Variable',
678
	                    'VSA' => 'By Visual Reference To The Ground',
679
	                    'VSP' => 'Vertical Speed',
680
	                    'VTOL' => 'Vertical Take-off And Landing',
681
	                    'WAC' => 'World Aeronautical Chart',
682
	                    'WAFC' => 'World Area Forecast Centre',
683
	                    'WB' => 'Westbound',
684
	                    'WBAR' => 'Wing Bar Lights',
685
	                    'WDI' => 'Wind Direction Indicator',
686
	                    'WDSPR' => 'Widespread',
687
	                    'WED' => 'Wednesday',
688
	                    'WEF' => 'Effective From',
689
	                    'WI' => 'Within',
690
	                    'WID' => 'Width',
691
	                    'WIE' => 'Effective Immediately',
692
	                    'WILCO' => 'Will Comply',
693
	                    'WIND' => 'Wind',
694
	                    'WINTEM' => 'Forecast Upper Wind And Temperature For Aviation',
695
	                    'WIP' => 'Work In Progress',
696
	                    'WKN' => 'Weaken',
697
	                    'WNW' => 'West-north-west',
698
	                    'WO' => 'Without',
699
	                    'WPT' => 'Way-point',
700
	                    'WRNG' => 'Warning',
701
	                    'WSW' => 'West-south-west',
702
	                    'WT' => 'Weight',
703
	                    'WWW' => 'Worldwide Web',
704
	                    'WX' => 'Weather',
705
	                    'XBAR' => 'Crossbar',
706
	                    'XNG' => 'Crossing',
707
	                    'XS' => 'Atmospherics',
708
	                    'YCZ' => 'Yellow Caution Zone',
709
	                    'YR' => 'Your');
710
711
712
	public function __construct($dbc = null) {
713
		$Connection = new Connection($dbc);
714
		$this->db = $Connection->db;
715
	}
716
	public function getAllNOTAM() {
717
		global $globalDBdriver;
718
		//$query = "SELECT * FROM notam WHERE radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP()";
719
		if ($globalDBdriver == 'mysql') {
720
			$query  = 'SELECT * FROM notam WHERE radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP()';
721
		} else {
722
			$query  = "SELECT * FROM notam WHERE radius > 0 AND date_end > CURRENT_TIMESTAMP AT TIME ZONE 'UTC' AND date_begin < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
723
		}
724
		$query_values = array();
725
		try {
726
			$sth = $this->db->prepare($query);
727
			$sth->execute($query_values);
728
		} catch(PDOException $e) {
729
			echo "error : ".$e->getMessage();
730
		}
731
		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
732
		return $all;
733
	}
734
	public function getAllNOTAMbyCoord($coord) {
735
		global $globalDBdriver;
736
		if (is_array($coord)) {
737
			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
738
			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
739
			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
740
			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
741
		} else return array();
742
		if ($globalDBdriver == 'mysql') {
743
			$query  = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP()';
744
		} else {
745
			$query  = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong." AND radius > 0 AND date_end > CURRENT_TIMESTAMP AT TIME ZONE 'UTC' AND date_begin < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
746
		}
747
		//$query = "SELECT * FROM notam WHERE radius > 0";
748
		$query_values = array();
749
		try {
750
			$sth = $this->db->prepare($query);
751
			$sth->execute($query_values);
752
		} catch(PDOException $e) {
753
			echo "error : ".$e->getMessage();
754
		}
755
		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
756
		return $all;
757
	}
758
	public function getNOTAMbyRef($ref) {
759
		$query = "SELECT * FROM notam WHERE ref = :ref";
760
		$query_values = array('ref' => $ref);
761
		try {
762
			$sth = $this->db->prepare($query);
763
			$sth->execute($query_values);
764
		} catch(PDOException $e) {
765
			return "error : ".$e->getMessage();
766
		}
767
		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
768
		if (isset($all[0])) return $all[0];
769
		else return array();
770
	}
771
772
	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) {
773
		$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)";
774
		$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);
775
		try {
776
			$sth = $this->db->prepare($query);
777
			$sth->execute($query_values);
778
		} catch(PDOException $e) {
779
			return "error : ".$e->getMessage();
780
		}
781
	}
782
783
	public function deleteNOTAM($id) {
784
		$query = "DELETE FROM notam WHERE id = :id";
785
		$query_values = array(':id' => $id);
786
		try {
787
			$sth = $this->db->prepare($query);
788
			$sth->execute($query_values);
789
		} catch(PDOException $e) {
790
			return "error : ".$e->getMessage();
791
		}
792
	}
793
	public function deleteOldNOTAM() {
794
		global $globalDBdriver;
795
		if ($globalDBdriver == 'mysql') {
796
			$query = "DELETE FROM notam WHERE date_end < UTC_TIMESTAMP()";
797
		} else {
798
			$query = "DELETE FROM notam WHERE date_end < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
799
		}
800
		$query_values = array();
801
		try {
802
			$sth = $this->db->prepare($query);
803
			$sth->execute($query_values);
804
		} catch(PDOException $e) {
805
			return "error : ".$e->getMessage();
806
		}
807
	}
808
	public function deleteNOTAMbyRef($ref) {
809
		$query = "DELETE FROM notam WHERE ref = :ref";
810
		$query_values = array(':ref' => $ref);
811
		try {
812
			$sth = $this->db->prepare($query);
813
			$sth->execute($query_values);
814
		} catch(PDOException $e) {
815
			return "error : ".$e->getMessage();
816
		}
817
	}
818
	public function deleteAllNOTAM() {
819
		$query = "DELETE FROM notam";
820
		try {
821
			$sth = $this->db->prepare($query);
822
			$sth->execute();
823
		} catch(PDOException $e) {
824
			return "error : ".$e->getMessage();
825
		}
826
	}
827
	public function deleteAllNOTAMLocation() {
828
		$query = "DELETE FROM notam";
829
		try {
830
			$sth = $this->db->prepare($query);
831
			$sth->execute();
832
		} catch(PDOException $e) {
833
			return "error : ".$e->getMessage();
834
		}
835
	}
836
837
	public function updateNOTAM() {
838
		global $globalNOTAMAirports;
839
		if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) {
840
			foreach (array_chunk($globalNOTAMAirports,10) as $airport) {
841
				$airport_icao = implode(',',$airport);
842
				$alldata = $this->downloadNOTAM($airport_icao);
843
				if (count($alldata) > 0) {
844
					foreach ($alldata as $initial_data) {
845
						$data = $this->parse($initial_data);
846
						$notamref = $this->getNOTAMbyRef($data['ref']);
847
						if (count($notamref) == 0) $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']);
848
					}
849
				}
850
			}
851
		}
852
	}
853
854
	public function updateNOTAMallAirports() {
855
		$Spotter = new Spotter();
856
		$allairports = $Spotter->getAllAirportInfo();
857
		foreach (array_chunk($allairports,20) as $airport) {
858
			$airports_icao = array();
859
			foreach($airport as $icao) {
860
				if (isset($icao['icao'])) $airports_icao[] = $icao['icao'];
861
			}
862
			$airport_icao = implode(',',$airports_icao);
863
			$alldata = $this->downloadNOTAM($airport_icao);
864
			if ($globalTransaction) $this->db->beginTransaction();
1 ignored issue
show
Bug introduced by
The variable $globalTransaction does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The method beginTransaction cannot be called on $this->db (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
865
			if (count($alldata) > 0) {
866
				foreach ($alldata as $initial_data) {
867
					//print_r($initial_data);
868
					$data = $this->parse($initial_data);
869
					//print_r($data);
870
					if (isset($data['ref'])) {
871
						$notamref = $this->getNOTAMbyRef($data['ref']);
872
						if (count($notamref) == 0) {
873
							if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']);
874
							if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']);
875
							elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$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']);
876
						}
877
					}
878
				}
879
			} else echo 'Error on download. Nothing matches for '.$airport_icao."\n";
880
			if ($globalTransaction) $this->db->commit();
1 ignored issue
show
Bug introduced by
The method commit cannot be called on $this->db (of type null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
881
			sleep(5);
882
		}
883
	}
884
885
	public function downloadNOTAM($icao) {
886
		date_default_timezone_set("UTC");
887
		$Common = new Common();
888
		//$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
889
		$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
890
		$data = $Common->getData($url);
891
		preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches);
892
		//print_r($matches);
893
		if (isset($matches[1])) return $matches[1];
894
		else return array();
895
	}
896
897
	public function parse($data) {
898
		$Common = new Common();
899
		$result = array();
900
		$result['full_notam'] = $data;
901
		$data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data);
902
		$data = preg_split('#(?=([A-Z]\)\s))#',$data);
903
		//print_r($data);
904
		foreach ($data as $line) {
905
			$line = trim($line);
906
			if (preg_match('#Q\) (.*)#',$line,$matches)) {
907
				$line = str_replace(' ','',$line);
908
				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)) {
909
				//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)) {
910
					//print_r($matches);
911
					$result['fir'] = $matches[1];
912
					$result['code'] = $matches[2];
913
					$rules = str_split($matches[3]);
914
					foreach ($rules as $rule) {
915
						if ($rule == 'I') {
916
							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/IFR';
917
							else $result['rules'] = 'IFR';
918
						} elseif ($rule == 'V') {
919
							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/VFR';
920
							else $result['rules'] = 'VFR';
921
						} elseif ($rule == 'K') {
922
							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/Checklist';
923
							else $result['rules'] = 'Checklist';
924
						}
925
					}
926
					$attentions = str_split($matches[4]);
927
					foreach ($attentions as $attention) {
928
						if ($attention == 'N') {
929
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Immediate attention';
930
							else $result['rules'] = 'Immediate attention';
931
						} elseif ($attention == 'B') {
932
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Operational significance';
933
							else $result['rules'] = 'Operational significance';
934
						} elseif ($attention == 'O') {
935
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Flight operations';
936
							else $result['rules'] = 'Flight operations';
937
						} elseif ($attention == 'M') {
938
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Misc';
939
							else $result['rules'] = 'Misc';
940
						} elseif ($attention == 'K') {
941
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Checklist';
942
							else $result['rules'] = 'Checklist';
943
						}
944
					}
945
					if ($matches[5] == 'A') $result['scope'] = 'Airport warning';
946
					elseif ($matches[5] == 'E') $result['scope'] = 'Enroute warning';
947
					elseif ($matches[5] == 'W') $result['scope'] = 'Navigation warning';
948
					elseif ($matches[5] == 'K') $result['scope'] = 'Checklist';
949
					elseif ($matches[5] == 'AE') $result['scope'] = 'Airport/Enroute warning';
950
					elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning';
951
					$result['lower_limit'] = $matches[6];
952
					$result['upper_limit'] = $matches[7];
953
					$latitude = $Common->convertDec($matches[8],'latitude');
954
					if ($matches[9] == 'S') $latitude = -$latitude;
955
					$longitude = $Common->convertDec($matches[10],'longitude');
956
					if ($matches[11] == 'W') $longitude = -$longitude;
957
					$result['latitude'] = $latitude;
958
					$result['longitude'] = $longitude;
959
					$result['radius'] = intval($matches[12]);
960
				} else echo 'ERROR : '.$line."\n";
961
			}
962
			elseif (preg_match('#A\) (.*)#',$line,$matches)) {
963
				$result['icao'] = $matches[1];
964
			}
965
			elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) {
966
				if ($matches[1] > 50) $year = '19'.$matches[1];
967
				else $year = '20'.$matches[1];
968
				$result['date_begin'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
969
			}
970
			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) {
971
				if ($matches[1] > 50) $year = '19'.$matches[1];
972
				else $year = '20'.$matches[1];
973
				$result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
974
				$result['permanent'] = 0;
975
			}
976
			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) {
977
				if ($matches[1] > 50) $year = '19'.$matches[1];
978
				else $year = '20'.$matches[1];
979
				$result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
980
				if ($matches[6] == 'EST') $result['estimated'] = 1;
981
				else $result['estimated'] = 0;
982
				if ($matches[6] == 'PERM') $result['permanent'] = 1;
983
				else $result['permanent'] = 0;
984
			}
985
			elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) {
986
				$result['date_end'] = '2030/12/20 12:00';
987
				if ($matches[1] == 'EST') $result['estimated'] = 1;
988
				else $result['estimated'] = 0;
989
				if ($matches[1] == 'PERM') $result['permanent'] = 1;
990
				else $result['permanent'] = 0;
991
			}
992
			elseif (preg_match('#E\) (.*)#',$line,$matches)) {
993
				$rtext = array();
994
				$text = explode(' ',$matches[1]);
995
				foreach ($text as $word) {
996
					if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]);
997
					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);
998
					else $rtext[] = $word;
999
				}
1000
				$result['text'] = implode(' ',$rtext);
1001
			//} elseif (preg_match('#F\) (.*)#',$line,$matches)) {
1002
			//} elseif (preg_match('#G\) (.*)#',$line,$matches)) {
1003
			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) {
1004
				$text = explode(' ',$line);
1005
				$result['ref'] = $text[0];
1006
				if ($matches[1] == 'NOTAMN') $result['type'] = 'new';
1007
				if ($matches[1] == 'NOTAMC') {
1008
					$result['type'] = 'cancel';
1009
					$result['ref_cancelled'] = $text[2];
1010
				}
1011
				if ($matches[1] == 'NOTAMR') {
1012
					$result['type'] = 'replace';
1013
					$result['ref_replaced'] = $text[2];
1014
				}
1015
			}
1016
		}
1017
		return $result;
1018
	}
1019
}
1020
/*
1021
$NOTAM = new NOTAM();
1022
//print_r($NOTAM->downloadNOTAM('lfll'));
1023
//print_r($NOTAM->parse(''));
1024
$NOTAM->deleteAllNOTAM();
1025
$NOTAM->updateNOTAMallAirports();
1026
*/
1027
?>