Completed
Push — master ( 5ddfd1...65bea5 )
by Yannick
11:45
created

NOTAM::addNOTAM()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 3
nop 17
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

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
		$query = "SELECT * FROM notam";
718
		$query_values = array();
719
		try {
720
			$sth = $this->db->prepare($query);
721
			$sth->execute($query_values);
722
		} catch(PDOException $e) {
723
			return "error : ".$e->getMessage();
724
		}
725
		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
726
		return $all;
727
	}
728
	public function getNOTAMbyRef($ref) {
729
		$query = "SELECT * FROM notam WHERE ref = :ref";
730
		$query_values = array('ref' => $ref);
731
		try {
732
			$sth = $this->db->prepare($query);
733
			$sth->execute($query_values);
734
		} catch(PDOException $e) {
735
			return "error : ".$e->getMessage();
736
		}
737
		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
738
		return $all;
739
	}
740
741
	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) {
742
		$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)";
743
		$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);
744
		try {
745
			$sth = $this->db->prepare($query);
746
			$sth->execute($query_values);
747
		} catch(PDOException $e) {
748
			return "error : ".$e->getMessage();
749
		}
750
	}
751
752
	public function deleteNOTAM($id) {
753
		$query = "DELETE FROM notam WHERE id = :id";
754
		$query_values = array(':id' => $id);
755
		try {
756
			$sth = $this->db->prepare($query);
757
			$sth->execute($query_values);
758
		} catch(PDOException $e) {
759
			return "error : ".$e->getMessage();
760
		}
761
	}
762
	public function deleteOldNOTAM() {
763
		global $globalDBdriver;
764
		if ($globalDBdriver == 'mysql') {
765
			$query = "DELETE FROM notam WHERE date_end < UTC_TIMESTAMP()";
766
		} else {
767
			$query = "DELETE FROM notam WHERE date_end < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
768
		}
769
		$query_values = array();
770
		try {
771
			$sth = $this->db->prepare($query);
772
			$sth->execute($query_values);
773
		} catch(PDOException $e) {
774
			return "error : ".$e->getMessage();
775
		}
776
	}
777
	public function deleteNOTAMbyRef($ref) {
778
		$query = "DELETE FROM notam WHERE ref = :ref";
779
		$query_values = array(':ref' => $ref);
780
		try {
781
			$sth = $this->db->prepare($query);
782
			$sth->execute($query_values);
783
		} catch(PDOException $e) {
784
			return "error : ".$e->getMessage();
785
		}
786
	}
787
	public function deleteAllNOTAM() {
788
		$query = "DELETE FROM notam";
789
		try {
790
			$sth = $this->db->prepare($query);
791
			$sth->execute();
792
		} catch(PDOException $e) {
793
			return "error : ".$e->getMessage();
794
		}
795
	}
796
	public function deleteAllNOTAMLocation() {
797
		$query = "DELETE FROM notam";
798
		try {
799
			$sth = $this->db->prepare($query);
800
			$sth->execute();
801
		} catch(PDOException $e) {
802
			return "error : ".$e->getMessage();
803
		}
804
	}
805
806
	public function updateNOTAM() {
807
		global $globalNOTAMAirports;
808
		if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) {
809
			foreach (array_chunk($globalNOTAMAirports,10) as $airport) {
810
				$airport_icao = implode(',',$airport);
811
				$alldata = $this->downloadNOTAM($airport_icao);
812
				if (count($alldata) > 0) {
813
					foreach ($alldata as $initial_data) {
814
						$data = $this->parse($initial_data);
815
						$notamref = $this->getNOTAMbyRef($data['ref']);
816
						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']);
817
					}
818
				}
819
			}
820
		}
821
	}
822
823
	public function updateNOTAMallAirports() {
824
		$Spotter = new Spotter();
825
		$allairports = $Spotter->getAllAirportInfo();
826
		foreach (array_chunk($allairports,10) as $airport) {
827
			$airports_icao = array();
828
			foreach($airport as $icao) {
829
				if (isset($icao['icao'])) $airports_icao[] = $icao['icao'];
830
			}
831
			$airport_icao = implode(',',$airports_icao);
832
			$alldata = $this->downloadNOTAM($airport_icao);
833
			if (count($alldata) > 0) {
834
				foreach ($alldata as $initial_data) {
835
					//print_r($initial_data);
836
					$data = $this->parse($initial_data);
837
					//print_r($data);
838
					if (isset($data['ref'])) {
839
						$notamref = $this->getNOTAMbyRef($data['ref']);
840
						if (count($notamref) == 0) {
841
							if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']);
842
							if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']);
843
							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']);
844
						}
845
					}
846
				}
847
			}
848
		}
849
	}
850
851
	public function downloadNOTAM($icao) {
852
		date_default_timezone_set("UTC");
853
		$Common = new Common();
854
		//$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
855
		$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
856
		$data = $Common->getData($url);
857
		preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches);
858
		//print_r($matches);
859
		if (isset($matches[1])) return $matches[1];
860
		else return array();
861
	}
862
863
	public function parse($data) {
864
		$Common = new Common();
865
		$result = array();
866
		$result['full_notam'] = $data;
867
		$data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data);
868
		$data = preg_split('#(?=([A-Z]\)\s))#',$data);
869
		//print_r($data);
870
		foreach ($data as $line) {
871
			$line = trim($line);
872
			if (preg_match('#Q\) (.*)#',$line,$matches)) {
873
				$line = str_replace(' ','',$line);
874
				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)) {
875
				//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)) {
876
					//print_r($matches);
877
					$result['fir'] = $matches[1];
878
					$result['code'] = $matches[2];
879
					$rules = str_split($matches[3]);
880
					foreach ($rules as $rule) {
881
						if ($rule == 'I') {
882
							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/IFR';
883
							else $result['rules'] = 'IFR';
884
						} elseif ($rule == 'V') {
885
							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/VFR';
886
							else $result['rules'] = 'VFR';
887
						} elseif ($rule == 'K') {
888
							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/Checklist';
889
							else $result['rules'] = 'Checklist';
890
						}
891
					}
892
					$attentions = str_split($matches[4]);
893
					foreach ($attentions as $attention) {
894
						if ($attention == 'N') {
895
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Immediate attention';
896
							else $result['rules'] = 'Immediate attention';
897
						} elseif ($attention == 'B') {
898
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Operational significance';
899
							else $result['rules'] = 'Operational significance';
900
						} elseif ($attention == 'O') {
901
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Flight operations';
902
							else $result['rules'] = 'Flight operations';
903
						} elseif ($attention == 'M') {
904
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Misc';
905
							else $result['rules'] = 'Misc';
906
						} elseif ($attention == 'K') {
907
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Checklist';
908
							else $result['rules'] = 'Checklist';
909
						}
910
					}
911
					if ($matches[5] == 'A') $result['scope'] = 'Airport warning';
912
					elseif ($matches[5] == 'E') $result['scope'] = 'Enroute warning';
913
					elseif ($matches[5] == 'W') $result['scope'] = 'Navigation warning';
914
					elseif ($matches[5] == 'K') $result['scope'] = 'Checklist';
915
					elseif ($matches[5] == 'AE') $result['scope'] = 'Airport/Enroute warning';
916
					elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning';
917
					$result['lower_limit'] = $matches[6];
918
					$result['upper_limit'] = $matches[7];
919
					$latitude = $Common->convertDec($matches[8],'latitude');
920
					if ($matches[9] == 'S') $latitude = -$latitude;
921
					$longitude = $Common->convertDec($matches[10],'longitude');
922
					if ($matches[11] == 'W') $longitude = -$longitude;
923
					$result['latitude'] = $latitude;
924
					$result['longitude'] = $longitude;
925
					$result['radius'] = intval($matches[12]);
926
				} else echo 'ERROR : '.$line."\n";
927
			}
928
			elseif (preg_match('#A\) (.*)#',$line,$matches)) {
929
				$result['icao'] = $matches[1];
930
			}
931
			elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) {
932
				$result['date_begin'] = $matches[1].'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
933
			}
934
			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) {
935
				$result['date_end'] = $matches[1].'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
936
				$result['permanent'] = 0;
937
			}
938
			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) {
939
				$result['date_end'] = $matches[1].'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
940
				if ($matches[6] == 'EST') $result['estimated'] = 1;
941
				else $result['estimated'] = 0;
942
				if ($matches[6] == 'PERM') $result['permanent'] = 1;
943
				else $result['permanent'] = 0;
944
			}
945
			elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) {
946
				$result['date_end'] = '30/12/20 12:00';
947
				if ($matches[1] == 'EST') $result['estimated'] = 1;
948
				else $result['estimated'] = 0;
949
				if ($matches[1] == 'PERM') $result['permanent'] = 1;
950
				else $result['permanent'] = 0;
951
			}
952
			elseif (preg_match('#E\) (.*)#',$line,$matches)) {
953
				$rtext = array();
954
				$text = explode(' ',$matches[1]);
955
				foreach ($text as $word) {
956
					if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]);
957
					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);
958
					else $rtext[] = $word;
959
				}
960
				$result['text'] = implode(' ',$rtext);
961
			//} elseif (preg_match('#F\) (.*)#',$line,$matches)) {
962
			//} elseif (preg_match('#G\) (.*)#',$line,$matches)) {
963
			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) {
964
				$text = explode(' ',$line);
965
				$result['ref'] = $text[0];
966
				if ($matches[1] == 'NOTAMN') $result['type'] = 'new';
967
				if ($matches[1] == 'NOTAMC') {
968
					$result['type'] = 'cancel';
969
					$result['ref_cancelled'] = $text[2];
970
				}
971
				if ($matches[1] == 'NOTAMR') {
972
					$result['type'] = 'replace';
973
					$result['ref_replaced'] = $text[2];
974
				}
975
			}
976
		}
977
		return $result;
978
	}
979
}
980
/*
981
$NOTAM = new NOTAM();
982
//print_r($NOTAM->downloadNOTAM('lfll'));
983
//print_r($NOTAM->parse(''));
984
$NOTAM->deleteAllNOTAM();
985
$NOTAM->updateNOTAMallAirports();
986
*/
987
?>