Completed
Push — master ( 8b0949...4e1c61 )
by Yannick
55:45 queued 25:25
created
live-santa-czml.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,9 @@  discard block
 block discarded – undo
28 28
 
29 29
 //	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
30 30
 $output .= ',"clock": {"currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"';
31
-if (!isset($_GET['now'])) $output .= ',"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z"';
31
+if (!isset($_GET['now'])) {
32
+	$output .= ',"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z"';
33
+}
32 34
 $output .= '}';
33 35
 //$output .= ',"clock": {"currentTime" : "'.date("c",time()).'","multiplier" : 300,"range" : "UNBOUNDED","step": "TICK_DEPENDENT"}';
34 36
 //$output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
@@ -37,7 +39,9 @@  discard block
 block discarded – undo
37 39
 $output .= '},';
38 40
 $output .= '{';
39 41
 $output .= '"id": "santaclaus",';
40
-if (!isset($_GET['now'])) $output .= '"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z",';
42
+if (!isset($_GET['now'])) {
43
+	$output .= '"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z",';
44
+}
41 45
 $output .= '"properties": {';
42 46
 // Not yet supported in CZML with Cesium
43 47
 $output .= '},';
Please login to merge, or discard this patch.
Spacing   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 //	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "LOOP_STOP","step": "SYSTEM_CLOCK_MULTIPLIER"}';
28 28
 
29 29
 //	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
30
-$output .= ',"clock": {"currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"';
30
+$output .= ',"clock": {"currentTime" : "'.date("c", time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"';
31 31
 if (!isset($_GET['now'])) $output .= ',"interval": "'.date("Y").'-12-24T02:00:00Z/'.date("Y").'-12-25T02:00:00Z"';
32 32
 $output .= '}';
33 33
 //$output .= ',"clock": {"currentTime" : "'.date("c",time()).'","multiplier" : 300,"range" : "UNBOUNDED","step": "TICK_DEPENDENT"}';
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 if (!isset($_GET['now'])) {
60 60
 	$output .= '"epoch" : "'.date("Y").'-12-24T02:00:00Z",';
61 61
 } else {
62
-	$output .= '"epoch" : "'.date("c",time() - $globalLiveInterval).'",';
62
+	$output .= '"epoch" : "'.date("c", time() - $globalLiveInterval).'",';
63 63
 }
64 64
 //$output .= '"type": "Point",';
65 65
 //$output .= '"interpolationAlgorithm" : "LAGRANGE",';
@@ -69,581 +69,581 @@  discard block
 block discarded – undo
69 69
 $output .= '"cartographicDegrees": [';
70 70
 $i = 0;
71 71
 $output .= $i.',-114.4,82.7,150000,';
72
-$i = $i+300;
72
+$i = $i + 300;
73 73
 $output .= $i.',-173.300003,64.379997,150000,';
74
-$i = $i+300;
74
+$i = $i + 300;
75 75
 $output .= $i.',177.479995,64.75,150000,';
76
-$i = $i+300;
76
+$i = $i + 300;
77 77
 $output .= $i.',158.65,53.016667,150000,';
78
-$i = $i+300;
78
+$i = $i + 300;
79 79
 $output .= $i.',165.545318,11.626074,150000,';
80
-$i = $i+300;
80
+$i = $i + 300;
81 81
 $output .= $i.',171.1300517813333,7.07999665990053,150000,';
82
-$i = $i+300;
82
+$i = $i + 300;
83 83
 $output .= $i.',179.380004,-16.469999,150000,';
84
-$i = $i+300;
84
+$i = $i + 300;
85 85
 $output .= $i.',178.429992,-18.129999,150000,';
86
-$i = $i+300;
86
+$i = $i + 300;
87 87
 $output .= $i.',174.759994,-36.849998,150000,';
88
-$i = $i+300;
88
+$i = $i + 300;
89 89
 $output .= $i.',176.839996,-39.639999,150000,';
90
-$i = $i+300;
90
+$i = $i + 300;
91 91
 $output .= $i.',174.779998,-41.279998,150000,';
92
-$i = $i+300;
92
+$i = $i + 300;
93 93
 $output .= $i.',172.639999,-43.529998,150000,';
94
-$i = $i+300;
94
+$i = $i + 300;
95 95
 $output .= $i.',167.838199,-46.986747,150000,';
96
-$i = $i+300;
96
+$i = $i + 300;
97 97
 $output .= $i.',168.320999,-17.740391,150000,';
98
-$i = $i+300;
98
+$i = $i + 300;
99 99
 $output .= $i.',167.149993,-15.51,150000,';
100
-$i = $i+300;
100
+$i = $i + 300;
101 101
 $output .= $i.',159.910003,-9.43,150000,';
102
-$i = $i+300;
102
+$i = $i + 300;
103 103
 $output .= $i.',156.850006,-8.1,150000,';
104
-$i = $i+300;
104
+$i = $i + 300;
105 105
 $output .= $i.',158.160003,6.92,150000,';
106
-$i = $i+300;
106
+$i = $i + 300;
107 107
 $output .= $i.',150.017702,45.873311,150000,';
108
-$i = $i+300;
108
+$i = $i + 300;
109 109
 $output .= $i.',154.796487,49.429802,150000,';
110
-$i = $i+300;
110
+$i = $i + 300;
111 111
 $output .= $i.',142.7262,46.948978,150000,';
112
-$i = $i+300;
112
+$i = $i + 300;
113 113
 $output .= $i.',150.800003,59.569999,150000,';
114
-$i = $i+300;
114
+$i = $i + 300;
115 115
 $output .= $i.',135.119995,48.419998,150000,';
116
-$i = $i+300;
116
+$i = $i + 300;
117 117
 $output .= $i.',131.899993,43.130001,150000,';
118
-$i = $i+300;
118
+$i = $i + 300;
119 119
 $output .= $i.',142.212096,27.070652,150000,';
120
-$i = $i+300;
120
+$i = $i + 300;
121 121
 $output .= $i.',141.312779,24.78389,150000,';
122
-$i = $i+300;
122
+$i = $i + 300;
123 123
 $output .= $i.',144.79373,13.444305,150000,';
124
-$i = $i+300;
124
+$i = $i + 300;
125 125
 $output .= $i.',151.783334,8.45,150000,';
126
-$i = $i+300;
126
+$i = $i + 300;
127 127
 $output .= $i.',151.749999,7.416667,150000,';
128
-$i = $i+300;
128
+$i = $i + 300;
129 129
 $output .= $i.',152.160003,-4.199999,150000,';
130
-$i = $i+300;
130
+$i = $i + 300;
131 131
 $output .= $i.',146.990005,-6.719999,150000,';
132
-$i = $i+300;
132
+$i = $i + 300;
133 133
 $output .= $i.',143.211639,-9.085352,150000,';
134
-$i = $i+300;
134
+$i = $i + 300;
135 135
 $output .= $i.',146.779998,-19.26,150000,';
136
-$i = $i+300;
136
+$i = $i + 300;
137 137
 $output .= $i.',149.179992,-21.139999,150000,';
138
-$i = $i+300;
138
+$i = $i + 300;
139 139
 $output .= $i.',153.020004,-27.459999,150000,';
140
-$i = $i+300;
140
+$i = $i + 300;
141 141
 $output .= $i.',151.210006,-33.869998,150000,';
142
-$i = $i+300;
142
+$i = $i + 300;
143 143
 $output .= $i.',147.291199,-42.85088,150000,';
144
-$i = $i+300;
144
+$i = $i + 300;
145 145
 $output .= $i.',138.600006,-34.93,150000,';
146
-$i = $i+300;
146
+$i = $i + 300;
147 147
 $output .= $i.',133.869995,-23.7,150000,';
148
-$i = $i+300;
148
+$i = $i + 300;
149 149
 $output .= $i.',130.850006,-12.43,150000,';
150
-$i = $i+300;
150
+$i = $i + 300;
151 151
 $output .= $i.',143.62,-3.56,150000,';
152
-$i = $i+300;
152
+$i = $i + 300;
153 153
 $output .= $i.',134.5552,7.3608,150000,';
154
-$i = $i+300;
154
+$i = $i + 300;
155 155
 $output .= $i.',135.169998,34.68,150000,';
156
-$i = $i+300;
156
+$i = $i + 300;
157 157
 $output .= $i.',138.690002,35.169998,150000,';
158
-$i = $i+300;
158
+$i = $i + 300;
159 159
 $output .= $i.',139.770004,35.669998,150000,';
160
-$i = $i+300;
160
+$i = $i + 300;
161 161
 $output .= $i.',140.740005,40.830001,150000,';
162
-$i = $i+300;
162
+$i = $i + 300;
163 163
 $output .= $i.',128.600006,35.869998,150000,';
164
-$i = $i+300;
164
+$i = $i + 300;
165 165
 $output .= $i.',125.925925,38.950981,150000,';
166
-$i = $i+300;
166
+$i = $i + 300;
167 167
 $output .= $i.',129.771118,62.093056,150000,';
168
-$i = $i+300;
168
+$i = $i + 300;
169 169
 $output .= $i.',104.239997,52.330001,150000,';
170
-$i = $i+300;
170
+$i = $i + 300;
171 171
 $output .= $i.',114.5056,48.060478,150000,';
172
-$i = $i+300;
172
+$i = $i + 300;
173 173
 $output .= $i.',106.580001,29.569999,150000,';
174
-$i = $i+300;
174
+$i = $i + 300;
175 175
 $output .= $i.',121.470001,31.229999,150000,';
176
-$i = $i+300;
176
+$i = $i + 300;
177 177
 $output .= $i.',113.25,23.12,150000,';
178
-$i = $i+300;
178
+$i = $i + 300;
179 179
 $output .= $i.',114.177465,22.307184,150000,';
180
-$i = $i+300;
180
+$i = $i + 300;
181 181
 $output .= $i.',121.639999,18.36,150000,';
182
-$i = $i+300;
182
+$i = $i + 300;
183 183
 $output .= $i.',122.080001,6.92,150000,';
184
-$i = $i+300;
184
+$i = $i + 300;
185 185
 $output .= $i.',114.639999,4.809999,150000,';
186
-$i = $i+300;
186
+$i = $i + 300;
187 187
 $output .= $i.',119.412399,-5.152193,150000,';
188
-$i = $i+300;
188
+$i = $i + 300;
189 189
 $output .= $i.',122.230003,-17.959999,150000,';
190
-$i = $i+300;
190
+$i = $i + 300;
191 191
 $output .= $i.',115.839996,-31.959999,150000,';
192
-$i = $i+300;
192
+$i = $i + 300;
193 193
 $output .= $i.',105.680687,-10.428593,150000,';
194
-$i = $i+300;
194
+$i = $i + 300;
195 195
 $output .= $i.',104.75,-2.99,150000,';
196
-$i = $i+300;
196
+$i = $i + 300;
197 197
 $output .= $i.',113.029998,3.17,150000,';
198
-$i = $i+300;
198
+$i = $i + 300;
199 199
 $output .= $i.',100.720001,4.86,150000,';
200
-$i = $i+300;
200
+$i = $i + 300;
201 201
 $output .= $i.',104.18,10.609999,150000,';
202
-$i = $i+300;
202
+$i = $i + 300;
203 203
 $output .= $i.',103.864403,13.36866,150000,';
204
-$i = $i+300;
204
+$i = $i + 300;
205 205
 $output .= $i.',99.330001,9.14,150000,';
206
-$i = $i+300;
206
+$i = $i + 300;
207 207
 $output .= $i.',105.073303,18.30217,150000,';
208
-$i = $i+300;
208
+$i = $i + 300;
209 209
 $output .= $i.',91.132088,29.6507,150000,';
210
-$i = $i+300;
210
+$i = $i + 300;
211 211
 $output .= $i.',116.477651,40.332809,150000,';
212
-$i = $i+300;
212
+$i = $i + 300;
213 213
 $output .= $i.',93.059997,56.02,150000,';
214
-$i = $i+300;
214
+$i = $i + 300;
215 215
 $output .= $i.',86.18,69.410003,150000,';
216
-$i = $i+300;
216
+$i = $i + 300;
217 217
 $output .= $i.',88.202881,69.315422,150000,';
218
-$i = $i+300;
218
+$i = $i + 300;
219 219
 $output .= $i.',73.400001,55,150000,';
220
-$i = $i+300;
220
+$i = $i + 300;
221 221
 $output .= $i.',76.949996,52.299999,150000,';
222
-$i = $i+300;
222
+$i = $i + 300;
223 223
 $output .= $i.',78.379997,42.490001,150000,';
224
-$i = $i+300;
224
+$i = $i + 300;
225 225
 $output .= $i.',69.779998,37.919998,150000,';
226
-$i = $i+300;
226
+$i = $i + 300;
227 227
 $output .= $i.',86.933333,27.983333,150000,';
228
-$i = $i+300;
228
+$i = $i + 300;
229 229
 $output .= $i.',84.870002,27.02,150000,';
230
-$i = $i+300;
230
+$i = $i + 300;
231 231
 $output .= $i.',88.36,22.569999,150000,';
232
-$i = $i+300;
232
+$i = $i + 300;
233 233
 $output .= $i.',90.389999,23.7,150000,';
234
-$i = $i+300;
234
+$i = $i + 300;
235 235
 $output .= $i.',97.04,20.78,150000,';
236
-$i = $i+300;
236
+$i = $i + 300;
237 237
 $output .= $i.',92.762917,11.66857,150000,';
238
-$i = $i+300;
238
+$i = $i + 300;
239 239
 $output .= $i.',50.23720550537109,-46.10261535644531,150000,';
240
-$i = $i+300;
240
+$i = $i + 300;
241 241
 $output .= $i.',72.422489,-7.336367,150000,';
242
-$i = $i+300;
242
+$i = $i + 300;
243 243
 $output .= $i.',73.510915,4.174199,150000,';
244
-$i = $i+300;
244
+$i = $i + 300;
245 245
 $output .= $i.',81.050003,6.989999,150000,';
246
-$i = $i+300;
246
+$i = $i + 300;
247 247
 $output .= $i.',72.819999,18.959999,150000,';
248
-$i = $i+300;
248
+$i = $i + 300;
249 249
 $output .= $i.',78.042222,27.174167,150000,';
250
-$i = $i+300;
250
+$i = $i + 300;
251 251
 $output .= $i.',71.449996,30.2,150000,';
252
-$i = $i+300;
252
+$i = $i + 300;
253 253
 $output .= $i.',67.109993,36.703819,150000,';
254
-$i = $i+300;
254
+$i = $i + 300;
255 255
 $output .= $i.',54.36,39.509998,150000,';
256
-$i = $i+300;
256
+$i = $i + 300;
257 257
 $output .= $i.',63.726529,40.214486,150000,';
258
-$i = $i+300;
258
+$i = $i + 300;
259 259
 $output .= $i.',58.853439,48.251126,150000,';
260
-$i = $i+300;
260
+$i = $i + 300;
261 261
 $output .= $i.',56.23246,58.00024,150000,';
262
-$i = $i+300;
262
+$i = $i + 300;
263 263
 $output .= $i.',49.659999,58.599998,150000,';
264
-$i = $i+300;
264
+$i = $i + 300;
265 265
 $output .= $i.',50.150001,53.2,150000,';
266
-$i = $i+300;
266
+$i = $i + 300;
267 267
 $output .= $i.',44.11,41.979999,150000,';
268
-$i = $i+300;
268
+$i = $i + 300;
269 269
 $output .= $i.',49.893226,40.38344,150000,';
270
-$i = $i+300;
270
+$i = $i + 300;
271 271
 $output .= $i.',44.75,40.5,150000,';
272
-$i = $i+300;
272
+$i = $i + 300;
273 273
 $output .= $i.',50.95,34.650001,150000,';
274
-$i = $i+300;
274
+$i = $i + 300;
275 275
 $output .= $i.',56.27433,27.18717,150000,';
276
-$i = $i+300;
276
+$i = $i + 300;
277 277
 $output .= $i.',54.989491,25.005817,150000,';
278
-$i = $i+300;
278
+$i = $i + 300;
279 279
 $output .= $i.',59.549999,22.569999,150000,';
280
-$i = $i+300;
280
+$i = $i + 300;
281 281
 $output .= $i.',47.58318996007591,-9.722414273737707,150000,';
282
-$i = $i+300;
282
+$i = $i + 300;
283 283
 $output .= $i.',57.471008,-20.26026,150000,';
284
-$i = $i+300;
284
+$i = $i + 300;
285 285
 $output .= $i.',37.946460723877,-46.6428451538086,150000,';
286
-$i = $i+300;
286
+$i = $i + 300;
287 287
 $output .= $i.',53,-67.5,150000,';
288
-$i = $i+300;
288
+$i = $i + 300;
289 289
 $output .= $i.',46.99004,-25.03233,150000,';
290
-$i = $i+300;
290
+$i = $i + 300;
291 291
 $output .= $i.',46.310001,-15.72,150000,';
292
-$i = $i+300;
292
+$i = $i + 300;
293 293
 $output .= $i.',44.41203117370608,-12.22338294982911,150000,';
294
-$i = $i+300;
294
+$i = $i + 300;
295 295
 $output .= $i.',39.3822,-6.097406,150000,';
296
-$i = $i+300;
296
+$i = $i + 300;
297 297
 $output .= $i.',39.659999,-4.039999,150000,';
298
-$i = $i+300;
298
+$i = $i + 300;
299 299
 $output .= $i.',40.033333,7.916667,150000,';
300
-$i = $i+300;
300
+$i = $i + 300;
301 301
 $output .= $i.',42.549999,16.899999,150000,';
302
-$i = $i+300;
302
+$i = $i + 300;
303 303
 $output .= $i.',43.970001,26.37,150000,';
304
-$i = $i+300;
304
+$i = $i + 300;
305 305
 $output .= $i.',41.12,30.455,150000,';
306
-$i = $i+300;
306
+$i = $i + 300;
307 307
 $output .= $i.',38.278671,34.547951,150000,';
308
-$i = $i+300;
308
+$i = $i + 300;
309 309
 $output .= $i.',37.619998,55.75,150000,';
310
-$i = $i+300;
310
+$i = $i + 300;
311 311
 $output .= $i.',30.453329,59.951889,150000,';
312
-$i = $i+300;
312
+$i = $i + 300;
313 313
 $output .= $i.',23.12,63.84,150000,';
314
-$i = $i+300;
314
+$i = $i + 300;
315 315
 $output .= $i.',26.709999,58.380001,150000,';
316
-$i = $i+300;
316
+$i = $i + 300;
317 317
 $output .= $i.',25.42,57.549999,150000,';
318
-$i = $i+300;
318
+$i = $i + 300;
319 319
 $output .= $i.',23.319999,55.93,150000,';
320
-$i = $i+300;
320
+$i = $i + 300;
321 321
 $output .= $i.',26.1,52.119998,150000,';
322
-$i = $i+300;
322
+$i = $i + 300;
323 323
 $output .= $i.',32.259998,48.5,150000,';
324
-$i = $i+300;
324
+$i = $i + 300;
325 325
 $output .= $i.',28.829999,47.029998,150000,';
326
-$i = $i+300;
326
+$i = $i + 300;
327 327
 $output .= $i.',25.61,45.659999,150000,';
328
-$i = $i+300;
328
+$i = $i + 300;
329 329
 $output .= $i.',27.469999,42.509998,150000,';
330
-$i = $i+300;
330
+$i = $i + 300;
331 331
 $output .= $i.',23.729999,37.979999,150000,';
332
-$i = $i+300;
332
+$i = $i + 300;
333 333
 $output .= $i.',27.149999,38.43,150000,';
334
-$i = $i+300;
334
+$i = $i + 300;
335 335
 $output .= $i.',31.132659,29.977088,150000,';
336
-$i = $i+300;
336
+$i = $i + 300;
337 337
 $output .= $i.',32.659999,13.17,150000,';
338
-$i = $i+300;
338
+$i = $i + 300;
339 339
 $output .= $i.',33.599998,1.71,150000,';
340
-$i = $i+300;
340
+$i = $i + 300;
341 341
 $output .= $i.',25.92,-2.95,150000,';
342
-$i = $i+300;
342
+$i = $i + 300;
343 343
 $output .= $i.',28.45,-14.439999,150000,';
344
-$i = $i+300;
344
+$i = $i + 300;
345 345
 $output .= $i.',30.819999,-20.059999,150000,';
346
-$i = $i+300;
346
+$i = $i + 300;
347 347
 $output .= $i.',21.639999,-21.7,150000,';
348
-$i = $i+300;
348
+$i = $i + 300;
349 349
 $output .= $i.',25.59,-33.959999,150000,';
350
-$i = $i+300;
350
+$i = $i + 300;
351 351
 $output .= $i.',18.129999,-26.579999,150000,';
352
-$i = $i+300;
352
+$i = $i + 300;
353 353
 $output .= $i.',13.767777,-10.722417,150000,';
354
-$i = $i+300;
354
+$i = $i + 300;
355 355
 $output .= $i.',10.13,-0.15,150000,';
356
-$i = $i+300;
356
+$i = $i + 300;
357 357
 $output .= $i.',20.67,5.76,150000,';
358
-$i = $i+300;
358
+$i = $i + 300;
359 359
 $output .= $i.',9.71,4.059999,150000,';
360
-$i = $i+300;
360
+$i = $i + 300;
361 361
 $output .= $i.',7.44,10.52,150000,';
362
-$i = $i+300;
362
+$i = $i + 300;
363 363
 $output .= $i.',18.69,12.189999,150000,';
364
-$i = $i+300;
364
+$i = $i + 300;
365 365
 $output .= $i.',7.98,17,150000,';
366
-$i = $i+300;
366
+$i = $i + 300;
367 367
 $output .= $i.',14.42,27.069999,150000,';
368
-$i = $i+300;
368
+$i = $i + 300;
369 369
 $output .= $i.',3.678539,32.489059,150000,';
370
-$i = $i+300;
370
+$i = $i + 300;
371 371
 $output .= $i.',-7.619999,33.599998,150000,';
372
-$i = $i+300;
372
+$i = $i + 300;
373 373
 $output .= $i.',13.611066,38.129963,150000,';
374
-$i = $i+300;
374
+$i = $i + 300;
375 375
 $output .= $i.',12.482323,41.895466,150000,';
376
-$i = $i+300;
376
+$i = $i + 300;
377 377
 $output .= $i.',17.189752,44.763891,150000,';
378
-$i = $i+300;
378
+$i = $i + 300;
379 379
 $output .= $i.',16.45,43.509998,150000,';
380
-$i = $i+300;
380
+$i = $i + 300;
381 381
 $output .= $i.',14.51,46.060001,150000,';
382
-$i = $i+300;
382
+$i = $i + 300;
383 383
 $output .= $i.',21.629999,47.54,150000,';
384
-$i = $i+300;
384
+$i = $i + 300;
385 385
 $output .= $i.',16.37,48.220001,150000,';
386
-$i = $i+300;
386
+$i = $i + 300;
387 387
 $output .= $i.',10.736111,47.554444,150000,';
388
-$i = $i+300;
388
+$i = $i + 300;
389 389
 $output .= $i.',14.43,50.080001,150000,';
390
-$i = $i+300;
390
+$i = $i + 300;
391 391
 $output .= $i.',17.129999,48.159999,150000,';
392
-$i = $i+300;
392
+$i = $i + 300;
393 393
 $output .= $i.',22.569999,51.240001,150000,';
394
-$i = $i+300;
394
+$i = $i + 300;
395 395
 $output .= $i.',13.411895,52.523781,150000,';
396
-$i = $i+300;
396
+$i = $i + 300;
397 397
 $output .= $i.',10.039999,56.470001,150000,';
398
-$i = $i+300;
398
+$i = $i + 300;
399 399
 $output .= $i.',13.02,55.61,150000,';
400
-$i = $i+300;
400
+$i = $i + 300;
401 401
 $output .= $i.',17.329999,62.400001,150000,';
402
-$i = $i+300;
402
+$i = $i + 300;
403 403
 $output .= $i.',14.229999,78.059997,150000,';
404
-$i = $i+300;
404
+$i = $i + 300;
405 405
 $output .= $i.',10.399999,63.439998,150000,';
406
-$i = $i+300;
406
+$i = $i + 300;
407 407
 $output .= $i.',2.350966,48.856558,150000,';
408
-$i = $i+300;
408
+$i = $i + 300;
409 409
 $output .= $i.',7.42,43.75,150000,';
410
-$i = $i+300;
410
+$i = $i + 300;
411 411
 $output .= $i.',1.57,42.54,150000,';
412
-$i = $i+300;
412
+$i = $i + 300;
413 413
 $output .= $i.',-0.991293,37.605651,150000,';
414
-$i = $i+300;
414
+$i = $i + 300;
415 415
 $output .= $i.',-7.429999,39.29,150000,';
416
-$i = $i+300;
416
+$i = $i + 300;
417 417
 $output .= $i.',-11.4053,16.5889,150000,';
418
-$i = $i+300;
418
+$i = $i + 300;
419 419
 $output .= $i.',-3.009999,16.78,150000,';
420
-$i = $i+300;
420
+$i = $i + 300;
421 421
 $output .= $i.',-5.36008,5.83885,150000,';
422
-$i = $i+300;
422
+$i = $i + 300;
423 423
 $output .= $i.',-12.3,11.319999,150000,';
424
-$i = $i+300;
424
+$i = $i + 300;
425 425
 $output .= $i.',-16.239999,12.829999,150000,';
426
-$i = $i+300;
426
+$i = $i + 300;
427 427
 $output .= $i.',-16.2507,28.457661,150000,';
428
-$i = $i+300;
428
+$i = $i + 300;
429 429
 $output .= $i.',-0.126197,51.500197,150000,';
430
-$i = $i+300;
430
+$i = $i + 300;
431 431
 $output .= $i.',-2.968111,56.461428,150000,';
432
-$i = $i+300;
432
+$i = $i + 300;
433 433
 $output .= $i.',-7.308429,54.998539,150000,';
434
-$i = $i+300;
434
+$i = $i + 300;
435 435
 $output .= $i.',-8.92,52.7,150000,';
436
-$i = $i+300;
436
+$i = $i + 300;
437 437
 $output .= $i.',-19.000959,63.427502,150000,';
438
-$i = $i+300;
438
+$i = $i + 300;
439 439
 $output .= $i.',-28.364049911499,38.47212219238281,150000,';
440
-$i = $i+300;
440
+$i = $i + 300;
441 441
 $output .= $i.',-23.76,15.279999,150000,';
442
-$i = $i+300;
442
+$i = $i + 300;
443 443
 $output .= $i.',-36.511219,-54.274151,150000,';
444
-$i = $i+300;
444
+$i = $i + 300;
445 445
 $output .= $i.',-58.979999,-51.830001,150000,';
446
-$i = $i+300;
446
+$i = $i + 300;
447 447
 $output .= $i.',-64.190002,-31.399999,150000,';
448
-$i = $i+300;
448
+$i = $i + 300;
449 449
 $output .= $i.',-54.18,-32.36,150000,';
450
-$i = $i+300;
450
+$i = $i + 300;
451 451
 $output .= $i.',-43.2,-22.909999,150000,';
452
-$i = $i+300;
452
+$i = $i + 300;
453 453
 $output .= $i.',-37.333333,65.666667,150000,';
454
-$i = $i+300;
454
+$i = $i + 300;
455 455
 $output .= $i.',-69.345131,77.48262,150000,';
456
-$i = $i+300;
456
+$i = $i + 300;
457 457
 $output .= $i.',-55.65049,48.929001,150000,';
458
-$i = $i+300;
458
+$i = $i + 300;
459 459
 $output .= $i.',-63.530471,44.681263,150000,';
460
-$i = $i+300;
460
+$i = $i + 300;
461 461
 $output .= $i.',-66.647818,45.957319,150000,';
462
-$i = $i+300;
462
+$i = $i + 300;
463 463
 $output .= $i.',-59.630001,13.18,150000,';
464
-$i = $i+300;
464
+$i = $i + 300;
465 465
 $output .= $i.',-61.744888,12.06526,150000,';
466
-$i = $i+300;
466
+$i = $i + 300;
467 467
 $output .= $i.',-61.171322,10.30501,150000,';
468
-$i = $i+300;
468
+$i = $i + 300;
469 469
 $output .= $i.',-67.470001,7.9,150000,';
470
-$i = $i+300;
470
+$i = $i + 300;
471 471
 $output .= $i.',-58.159999,6.789999,150000,';
472
-$i = $i+300;
472
+$i = $i + 300;
473 473
 $output .= $i.',-60.02,-3.119999,150000,';
474
-$i = $i+300;
474
+$i = $i + 300;
475 475
 $output .= $i.',-56.45,-14.409999,150000,';
476
-$i = $i+300;
476
+$i = $i + 300;
477 477
 $output .= $i.',-65.260002,-19.059999,150000,';
478
-$i = $i+300;
478
+$i = $i + 300;
479 479
 $output .= $i.',-56.636503,-24.158676,150000,';
480
-$i = $i+300;
480
+$i = $i + 300;
481 481
 $output .= $i.',-56.509998,-33.409999,150000,';
482
-$i = $i+300;
482
+$i = $i + 300;
483 483
 $output .= $i.',-68.523514,-50.021889,150000,';
484
-$i = $i+300;
484
+$i = $i + 300;
485 485
 $output .= $i.',-72.505127,-51.732529,150000,';
486
-$i = $i+300;
486
+$i = $i + 300;
487 487
 $output .= $i.',-71.639999,-33.04,150000,';
488
-$i = $i+300;
488
+$i = $i + 300;
489 489
 $output .= $i.',-72.515821,-13.162849,150000,';
490
-$i = $i+300;
490
+$i = $i + 300;
491 491
 $output .= $i.',-76.970001,-6.03,150000,';
492
-$i = $i+300;
492
+$i = $i + 300;
493 493
 $output .= $i.',-78.620002,-1.24,150000,';
494
-$i = $i+300;
494
+$i = $i + 300;
495 495
 $output .= $i.',-76.739997,8.1,150000,';
496
-$i = $i+300;
496
+$i = $i + 300;
497 497
 $output .= $i.',-79.879913,9.368985,150000,';
498
-$i = $i+300;
498
+$i = $i + 300;
499 499
 $output .= $i.',-76.949996,18,150000,';
500
-$i = $i+300;
500
+$i = $i + 300;
501 501
 $output .= $i.',-72.699996,19.11,150000,';
502
-$i = $i+300;
502
+$i = $i + 300;
503 503
 $output .= $i.',-75.220001,20.149999,150000,';
504
-$i = $i+300;
504
+$i = $i + 300;
505 505
 $output .= $i.',-73.682953,20.95027,150000,';
506
-$i = $i+300;
506
+$i = $i + 300;
507 507
 $output .= $i.',-80.605,28.405556,150000,';
508
-$i = $i+300;
508
+$i = $i + 300;
509 509
 $output .= $i.',-84.388056,33.748889,150000,';
510
-$i = $i+300;
510
+$i = $i + 300;
511 511
 $output .= $i.',-79.931111,32.776389,150000,';
512
-$i = $i+300;
512
+$i = $i + 300;
513 513
 $output .= $i.',-83.920833,35.960556,150000,';
514
-$i = $i+300;
514
+$i = $i + 300;
515 515
 $output .= $i.',-84.500278,38.049167,150000,';
516
-$i = $i+300;
516
+$i = $i + 300;
517 517
 $output .= $i.',-77.460833,38.303056,150000,';
518
-$i = $i+300;
518
+$i = $i + 300;
519 519
 $output .= $i.',-82.515556,40.758333,150000,';
520
-$i = $i+300;
520
+$i = $i + 300;
521 521
 $output .= $i.',-83.045833,42.331389,150000,';
522
-$i = $i+300;
522
+$i = $i + 300;
523 523
 $output .= $i.',-74.006389,40.714167,150000,';
524
-$i = $i+300;
524
+$i = $i + 300;
525 525
 $output .= $i.',-71.802778,42.2625,150000,';
526
-$i = $i+300;
526
+$i = $i + 300;
527 527
 $output .= $i.',-72.973056,43.610556,150000,';
528
-$i = $i+300;
528
+$i = $i + 300;
529 529
 $output .= $i.',-68.0125,46.860556,150000,';
530
-$i = $i+300;
530
+$i = $i + 300;
531 531
 $output .= $i.',-72.581779,46.357398,150000,';
532
-$i = $i+300;
532
+$i = $i + 300;
533 533
 $output .= $i.',-78.53632621543271,52.72737572958358,150000,';
534
-$i = $i+300;
534
+$i = $i + 300;
535 535
 $output .= $i.',-66.921779,52.940118,150000,';
536
-$i = $i+300;
536
+$i = $i + 300;
537 537
 $output .= $i.',-75.652573,62.201069,150000,';
538
-$i = $i+300;
538
+$i = $i + 300;
539 539
 $output .= $i.',-64.865257,67.935417,150000,';
540
-$i = $i+300;
540
+$i = $i + 300;
541 541
 $output .= $i.',-94.969443,74.716943,150000,';
542
-$i = $i+300;
542
+$i = $i + 300;
543 543
 $output .= $i.',-82.793909,76.395731,150000,';
544
-$i = $i+300;
544
+$i = $i + 300;
545 545
 $output .= $i.',-97.49276733398439,69.18675994873048,150000,';
546
-$i = $i+300;
546
+$i = $i + 300;
547 547
 $output .= $i.',-90.5537452697754,63.36753463745121,150000,';
548
-$i = $i+300;
548
+$i = $i + 300;
549 549
 $output .= $i.',-89.270113,48.412197,150000,';
550
-$i = $i+300;
550
+$i = $i + 300;
551 551
 $output .= $i.',-79.604159,43.68731,150000,';
552
-$i = $i+300;
552
+$i = $i + 300;
553 553
 $output .= $i.',-89.401111,43.073056,150000,';
554
-$i = $i+300;
554
+$i = $i + 300;
555 555
 $output .= $i.',-94.633611,42.395278,150000,';
556
-$i = $i+300;
556
+$i = $i + 300;
557 557
 $output .= $i.',-89.588889,40.693611,150000,';
558
-$i = $i+300;
558
+$i = $i + 300;
559 559
 $output .= $i.',-90.197778,38.627222,150000,';
560
-$i = $i+300;
560
+$i = $i + 300;
561 561
 $output .= $i.',-90.704167,35.842222,150000,';
562
-$i = $i+300;
562
+$i = $i + 300;
563 563
 $output .= $i.',-91.061667,33.41,150000,';
564
-$i = $i+300;
564
+$i = $i + 300;
565 565
 $output .= $i.',-92.445,31.311111,150000,';
566
-$i = $i+300;
566
+$i = $i + 300;
567 567
 $output .= $i.',-98.493333,29.423889,150000,';
568
-$i = $i+300;
568
+$i = $i + 300;
569 569
 $output .= $i.',-103.349998,20.67,150000,';
570
-$i = $i+300;
570
+$i = $i + 300;
571 571
 $output .= $i.',-86.830001,21.17,150000,';
572
-$i = $i+300;
572
+$i = $i + 300;
573 573
 $output .= $i.',-89.529998,14.979999,150000,';
574
-$i = $i+300;
574
+$i = $i + 300;
575 575
 $output .= $i.',-87.449996,13.42,150000,';
576
-$i = $i+300;
576
+$i = $i + 300;
577 577
 $output .= $i.',-83.709999,9.369999,150000,';
578
-$i = $i+300;
578
+$i = $i + 300;
579 579
 $output .= $i.',-91.5149765,-0.3781085,150000,';
580
-$i = $i+300;
580
+$i = $i + 300;
581 581
 $output .= $i.',-109.425598,-27.1546,150000,';
582
-$i = $i+300;
582
+$i = $i + 300;
583 583
 $output .= $i.',-109.9142,22.88093,150000,';
584
-$i = $i+300;
584
+$i = $i + 300;
585 585
 $output .= $i.',-110.910003,27.92,150000,';
586
-$i = $i+300;
586
+$i = $i + 300;
587 587
 $output .= $i.',-110.925833,32.221667,150000,';
588
-$i = $i+300;
588
+$i = $i + 300;
589 589
 $output .= $i.',-104.526667,33.395,150000,';
590
-$i = $i+300;
590
+$i = $i + 300;
591 591
 $output .= $i.',-113.061111,37.6775,150000,';
592
-$i = $i+300;
592
+$i = $i + 300;
593 593
 $output .= $i.',-104.820833,38.833889,150000,';
594
-$i = $i+300;
594
+$i = $i + 300;
595 595
 $output .= $i.',-108.73,42.833056,150000,';
596
-$i = $i+300;
596
+$i = $i + 300;
597 597
 $output .= $i.',-113.895,45.175833,150000,';
598
-$i = $i+300;
598
+$i = $i + 300;
599 599
 $output .= $i.',-113.993056,46.872222,150000,';
600
-$i = $i+300;
600
+$i = $i + 300;
601 601
 $output .= $i.',-114.080796,51.039877,150000,';
602
-$i = $i+300;
602
+$i = $i + 300;
603 603
 $output .= $i.',-102.3889594419702,57.15883691318781,150000,';
604
-$i = $i+300;
604
+$i = $i + 300;
605 605
 $output .= $i.',-118.0333,66.0833,150000,';
606
-$i = $i+300;
606
+$i = $i + 300;
607 607
 $output .= $i.',-140.55,64.45,150000,';
608
-$i = $i+300;
608
+$i = $i + 300;
609 609
 $output .= $i.',-122.690386,58.80667,150000,';
610
-$i = $i+300;
610
+$i = $i + 300;
611 611
 $output .= $i.',-121.92985,50.686341,150000,';
612
-$i = $i+300;
612
+$i = $i + 300;
613 613
 $output .= $i.',-122.330833,47.606389,150000,';
614
-$i = $i+300;
614
+$i = $i + 300;
615 615
 $output .= $i.',-122.274167,47.564167,150000,';
616
-$i = $i+300;
616
+$i = $i + 300;
617 617
 $output .= $i.',-122.968503,45.309901,150000,';
618
-$i = $i+300;
618
+$i = $i + 300;
619 619
 $output .= $i.',-122.874444,42.326667,150000,';
620
-$i = $i+300;
620
+$i = $i + 300;
621 621
 $output .= $i.',-122.390556,40.586667,150000,';
622
-$i = $i+300;
622
+$i = $i + 300;
623 623
 $output .= $i.',-117.068611,39.493333,150000,';
624
-$i = $i+300;
624
+$i = $i + 300;
625 625
 $output .= $i.',-122.418333,37.775,150000,';
626
-$i = $i+300;
626
+$i = $i + 300;
627 627
 $output .= $i.',-117.108333,34.207778,150000,';
628
-$i = $i+300;
628
+$i = $i + 300;
629 629
 $output .= $i.',-116.544444,33.830278,150000,';
630
-$i = $i+300;
630
+$i = $i + 300;
631 631
 $output .= $i.',-117.156389,32.715278,150000,';
632
-$i = $i+300;
632
+$i = $i + 300;
633 633
 $output .= $i.',-149.891667,61.218333,150000,';
634
-$i = $i+300;
634
+$i = $i + 300;
635 635
 $output .= $i.',-155.566389,62.948889,150000,';
636
-$i = $i+300;
636
+$i = $i + 300;
637 637
 $output .= $i.',-165.406389,64.501111,150000,';
638
-$i = $i+300;
638
+$i = $i + 300;
639 639
 $output .= $i.',-155.09,19.729722,150000,';
640
-$i = $i+300;
640
+$i = $i + 300;
641 641
 $output .= $i.',-156.337974,20.804858,150000,';
642
-$i = $i+300;
642
+$i = $i + 300;
643 643
 $output .= $i.',-157.043209,21.141189,150000,';
644
-$i = $i+300;
644
+$i = $i + 300;
645 645
 $output .= $i.',-158.009167,21.386667,150000,';
646
-$i = $i+300;
646
+$i = $i + 300;
647 647
 $output .= $i.',-159.371111,21.981111,150000';
648 648
 
649 649
 $output .= ']}}';
Please login to merge, or discard this patch.
route-detailed.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -3,17 +3,17 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 
6
-if (!isset($_GET['departure_airport']) || !isset($_GET['arrival_airport'])){
6
+if (!isset($_GET['departure_airport']) || !isset($_GET['arrival_airport'])) {
7 7
 	header('Location: '.$globalURL.'');
8 8
 } else {
9 9
 	$Spotter = new Spotter();
10 10
 	//calculuation for the pagination
11
-	if(!isset($_GET['limit']))
11
+	if (!isset($_GET['limit']))
12 12
 	{
13 13
 		$limit_start = 0;
14 14
 		$limit_end = 25;
15 15
 		$absolute_difference = 25;
16
-	}  else {
16
+	} else {
17 17
 		$limit_explode = explode(",", $_GET['limit']);
18 18
 		$limit_start = $limit_explode[0];
19 19
 		$limit_end = $limit_explode[1];
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
 	$limit_previous_1 = $limit_start - $absolute_difference;
28 28
 	$limit_previous_2 = $limit_end - $absolute_difference;
29 29
 	
30
-	$departure_airport = filter_input(INPUT_GET,'departure_airport',FILTER_SANITIZE_STRING);
31
-	$arrival_airport = filter_input(INPUT_GET,'arrival_airport',FILTER_SANITIZE_STRING);
30
+	$departure_airport = filter_input(INPUT_GET, 'departure_airport', FILTER_SANITIZE_STRING);
31
+	$arrival_airport = filter_input(INPUT_GET, 'arrival_airport', FILTER_SANITIZE_STRING);
32 32
 	$page_url = $globalURL.'/route/'.$departure_airport.'/'.$arrival_airport;
33
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
33
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
34 34
 	if ($sort != '') {
35 35
 		$spotter_array = $Spotter->getSpotterDataByRoute($departure_airport, $arrival_airport, $limit_start.",".$absolute_difference, $sort);
36 36
 	} else {
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  
40 40
 	if (!empty($spotter_array))
41 41
 	{
42
-		$title = sprintf(_("Detailed View for flights between %s (%s), %s - %s (%s), %s"),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']);
42
+		$title = sprintf(_("Detailed View for flights between %s (%s), %s - %s (%s), %s"), $spotter_array[0]['departure_airport_name'], $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['departure_airport_country'], $spotter_array[0]['arrival_airport_name'], $spotter_array[0]['arrival_airport_icao'], $spotter_array[0]['arrival_airport_country']);
43 43
 		require_once('header.php');
44 44
 		print '<div class="info column">';
45 45
 		print '<h1>'._("Flights between").' '.$spotter_array[0]['departure_airport_name'].' ('.$spotter_array[0]['departure_airport_icao'].'), '.$spotter_array[0]['departure_airport_country'].' - '.$spotter_array[0]['arrival_airport_name'].' ('.$spotter_array[0]['arrival_airport_icao'].'), '.$spotter_array[0]['arrival_airport_country'].'</h1>';
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 		include('route-sub-menu.php');
51 51
 		print '<div class="table column">';
52
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights that used the route <strong>%s - %s</strong>."),$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['arrival_airport_icao']).'</p>';
52
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights that used the route <strong>%s - %s</strong>."), $spotter_array[0]['departure_airport_icao'], $spotter_array[0]['arrival_airport_icao']).'</p>';
53 53
     
54 54
 		include('table-output.php'); 
55 55
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 		$limit_start = 0;
15 15
 		$limit_end = 25;
16 16
 		$absolute_difference = 25;
17
-	}  else {
17
+	} else {
18 18
 		$limit_explode = explode(",", $_GET['limit']);
19 19
 		$limit_start = $limit_explode[0];
20 20
 		$limit_end = $limit_explode[1];
Please login to merge, or discard this patch.
upcoming.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 require_once('header.php');
8 8
 
9 9
 //calculuation for the pagination
10
-if(!isset($_GET['limit']))
10
+if (!isset($_GET['limit']))
11 11
 {
12 12
 	$limit_start = 0;
13 13
 	$limit_end = 25;
14 14
 	$absolute_difference = 25;
15
-}  else {
15
+} else {
16 16
 	$limit_explode = explode(",", $_GET['limit']);
17 17
 	$limit_start = $limit_explode[0];
18 18
 	$limit_end = $limit_explode[1];
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 print '<div class="table column">';	
36 36
 print '<p>'._("This page shows all upcoming flights within the next 3 hours calculated using historical data, based on the number of same flights on the current day of the week &amp; current time. This does not take into account real-time delays and other factors.").'</p>';
37 37
 
38
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
38
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
39 39
 if ($sort != '') {
40 40
 	$spotter_array = $Spotter->getUpcomingFlights($limit_start.",".$absolute_difference, $sort);
41 41
 } else {
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 	$limit_start = 0;
13 13
 	$limit_end = 25;
14 14
 	$absolute_difference = 25;
15
-}  else {
15
+} else {
16 16
 	$limit_explode = explode(",", $_GET['limit']);
17 17
 	$limit_start = $limit_explode[0];
18 18
 	$limit_end = $limit_explode[1];
Please login to merge, or discard this patch.
date-statistics-airline.php 2 patches
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,8 +6,11 @@
 block discarded – undo
6 6
 $Spotter = new Spotter();
7 7
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
8 8
 $date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
9
-if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
10
-else $spotter_array = '';
9
+if (isset($_GET['date'])) {
10
+	$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
11
+} else {
12
+	$spotter_array = '';
13
+}
11 14
 
12 15
 if (!empty($spotter_array))
13 16
 {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -4,14 +4,14 @@  discard block
 block discarded – undo
4 4
 require_once('require/class.Language.php');
5 5
 
6 6
 $Spotter = new Spotter();
7
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
8
-$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
9
-if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
7
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
8
+$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING);
9
+if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort);
10 10
 else $spotter_array = '';
11 11
 
12 12
 if (!empty($spotter_array))
13 13
 {
14
-	$title = sprintf(_("Most Common Airlines on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
14
+	$title = sprintf(_("Most Common Airlines on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
15 15
 
16 16
 	require_once('header.php');
17 17
 	print '<div class="select-item">';
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 	print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
30 30
 	print '<br />';
31 31
 	print '<div class="info column">';
32
-	print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
32
+	print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
33 33
 	print '</div>';
34 34
 
35 35
 	include('date-sub-menu.php');
36 36
 	print '<div class="column">';
37 37
 	print '<h2>'._("Most Common Airlines").'</h2>';
38
-	print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
38
+	print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
39 39
 
40 40
 	$airline_array = $Spotter->countAllAirlinesByDate($date);
41 41
 	if (!empty($airline_array))
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		print '</thead>';
53 53
 		print '<tbody>';
54 54
 		$i = 1;
55
-		foreach($airline_array as $airline_item)
55
+		foreach ($airline_array as $airline_item)
56 56
 		{
57 57
 			print '<tr>';
58 58
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
date-statistics-airline-country.php 2 patches
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,11 @@
 block discarded – undo
8 8
 $date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
9 9
 
10 10
 $Spotter = new Spotter();
11
-if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
12
-else $spotter_array = array();
11
+if (isset($_GET['date'])) {
12
+	$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
13
+} else {
14
+	$spotter_array = array();
15
+}
13 16
 
14 17
 if (!empty($spotter_array))
15 18
 {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -3,16 +3,16 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 
6
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
7
-$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
6
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
7
+$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING);
8 8
 
9 9
 $Spotter = new Spotter();
10
-if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
10
+if (isset($_GET['date'])) $spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort);
11 11
 else $spotter_array = array();
12 12
 
13 13
 if (!empty($spotter_array))
14 14
 {
15
-	$title = sprintf(_("Most Common Airlines by Country on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
15
+	$title = sprintf(_("Most Common Airlines by Country on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
16 16
 	require_once('header.php');
17 17
 	print '<div class="select-item">';
18 18
 	print '<form action="'.$globalURL.'/date" method="post" class="form-inline">';
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 	print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
30 30
 	print '<br />';
31 31
 	print '<div class="info column">';
32
-	print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
32
+	print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
33 33
 	print '</div>';
34 34
 
35 35
 	include('date-sub-menu.php');
36 36
 	print '<div class="column">';
37 37
 	print '<h2>'._("Most Common Airlines by Country").'</h2>';
38
-	print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
38
+	print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
39 39
 
40 40
 	$airline_array = $Spotter->countAllAirlineCountriesByDate($date);
41 41
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
45 45
 	print 'var series = [';
46 46
 	$country_data = '';
47
-	foreach($airline_array as $airline_item)
47
+	foreach ($airline_array as $airline_item)
48 48
 	{
49 49
 		$country_data .= '[ "'.$airline_item['airline_country_iso3'].'",'.$airport_item['airline_country_count'].'],';
50 50
 	}
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		print '</thead>';
92 92
 		print '<tbody>';
93 93
 		$i = 1;
94
-		foreach($airline_array as $airline_item)
94
+		foreach ($airline_array as $airline_item)
95 95
 		{
96 96
 			print '<tr>';
97 97
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
incident-latest.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,8 +38,12 @@
 block discarded – undo
38 38
 if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) {
39 39
 	include('table-output.php');
40 40
 	print '<div class="pagination">';
41
-	if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
42
-	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
41
+	if ($limit_previous_1 >= 0) {
42
+		print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
43
+	}
44
+	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) {
45
+		print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
46
+	}
43 47
 	print '</div>';
44 48
 }
45 49
 print '</div>';
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 $page_url = $globalURL.'/accident-latest';
10 10
 
11
-if(!isset($_GET['limit']))
11
+if (!isset($_GET['limit']))
12 12
 {
13 13
 	$limit_start = 0;
14 14
 	$limit_end = 25;
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 print '<div class="table column">';
36 36
 print '<p>'._("The table below shows the latest Incidents.").'</p>';
37
-$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference,'incident');
37
+$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference, 'incident');
38 38
 //print_r($spotter_array);
39 39
 if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) {
40 40
 	include('table-output.php');
Please login to merge, or discard this patch.
incident-detailed.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 {
11 11
 	$date = date('Y-m-d');
12 12
 } else {
13
-	$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
13
+	$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING);
14 14
 }
15 15
 
16
-if(!isset($_GET['limit']))
16
+if (!isset($_GET['limit']))
17 17
 {
18 18
 	$limit_start = 0;
19 19
 	$limit_end = 25;
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
 print '<br />';
49 49
 
50 50
 print '<div class="info column">';
51
-print '<h1>'.sprintf(_("Incidents from %s"),date("l F j, Y",strtotime($date))).'</h1>';
51
+print '<h1>'.sprintf(_("Incidents from %s"), date("l F j, Y", strtotime($date))).'</h1>';
52 52
 print '</div>';
53 53
 
54 54
 print '<div class="table column">';
55
-print '<p>'.sprintf(_("The table below shows the Incidents on <strong>%s</strong>."),date("l M j, Y",strtotime($date))).'</p>';
56
-$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference,'incident',$date);
55
+print '<p>'.sprintf(_("The table below shows the Incidents on <strong>%s</strong>."), date("l M j, Y", strtotime($date))).'</p>';
56
+$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference, 'incident', $date);
57 57
 //print_r($spotter_array);
58 58
 if (!empty($spotter_array) && isset($spotter_array[0]['query_number_rows']) && $spotter_array[0]['query_number_rows'] != 0) {
59 59
 	include('table-output.php');
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,8 +58,12 @@
 block discarded – undo
58 58
 if (!empty($spotter_array) && isset($spotter_array[0]['query_number_rows']) && $spotter_array[0]['query_number_rows'] != 0) {
59 59
 	include('table-output.php');
60 60
 	print '<div class="pagination">';
61
-	if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
62
-	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
61
+	if ($limit_previous_1 >= 0) {
62
+		print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
63
+	}
64
+	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) {
65
+		print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
66
+	}
63 67
 	print '</div>';
64 68
 }
65 69
 print '</div>';
Please login to merge, or discard this patch.
js/map.js.php 3 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once('../require/settings.php');
3 3
 require_once('../require/class.Language.php'); 
4 4
 
5
-setcookie("MapFormat",'2d');
5
+setcookie("MapFormat", '2d');
6 6
 
7 7
 // Compressed GeoJson is used if true
8 8
 if (!isset($globalJsonCompress)) $compress = true;
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 	$lastupd = $_GET['archivespeed']*$archiveupdatetime;
19 19
 	if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
20 20
 	else $enddate = time();
21
-	setcookie("archive_begin",$begindate);
22
-	setcookie("archive_end",$enddate);
23
-	setcookie("archive_update",$lastupd);
24
-	setcookie("archive_speed",$archivespeed);
21
+	setcookie("archive_begin", $begindate);
22
+	setcookie("archive_end", $enddate);
23
+	setcookie("archive_update", $lastupd);
24
+	setcookie("archive_speed", $archivespeed);
25 25
 ?>
26 26
 document.cookie =  'archive_begin=<?php print $begindate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
27 27
 document.cookie =  'archive_end=<?php print $enddate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
@@ -92,16 +92,16 @@  discard block
 block discarded – undo
92 92
 <?php
93 93
 	}
94 94
 	if (isset($_GET['ident'])) {
95
-		$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
95
+		$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
96 96
 	}
97 97
 	if (isset($_GET['flightaware_id'])) {
98
-		$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
98
+		$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
99 99
 	}
100 100
 	if (isset($_GET['latitude'])) {
101
-		$latitude = filter_input(INPUT_GET,'latitude',FILTER_SANITIZE_STRING);
101
+		$latitude = filter_input(INPUT_GET, 'latitude', FILTER_SANITIZE_STRING);
102 102
 	}
103 103
 	if (isset($_GET['longitude'])) {
104
-		$longitude = filter_input(INPUT_GET,'longitude',FILTER_SANITIZE_STRING);
104
+		$longitude = filter_input(INPUT_GET, 'longitude', FILTER_SANITIZE_STRING);
105 105
 	}
106 106
 ?>
107 107
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	     || navigator.userAgent.match(/BlackBerry/i)
137 137
 	     || navigator.userAgent.match(/Windows Phone/i))
138 138
 	{
139
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>;
139
+		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom - 1; else print '8'; ?>;
140 140
 	} else {
141 141
 		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>;
142 142
 	}
@@ -230,19 +230,19 @@  discard block
 block discarded – undo
230 230
 	map.addLayer(yandexLayer);
231 231
 <?php
232 232
 	} elseif ($MapType == 'Bing-Aerial') {
233
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
233
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
234 234
 ?>
235 235
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
236 236
 	map.addLayer(bingLayer);
237 237
 <?php
238 238
 	} elseif ($MapType == 'Bing-Hybrid') {
239
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
239
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
240 240
 ?>
241 241
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
242 242
 	map.addLayer(bingLayer);
243 243
 <?php
244 244
 	} elseif ($MapType == 'Bing-Road') {
245
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
245
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
246 246
 ?>
247 247
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
248 248
 	map.addLayer(bingLayer);
@@ -534,10 +534,10 @@  discard block
 block discarded – undo
534 534
 	};
535 535
 	archive.update = function (props) {
536 536
 		if (typeof props != 'undefined') {
537
-			//this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
538
-			this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>';
537
+			//this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><i class="fa fa-fast-backward" aria-hidden="true"></i> <i class="fa fa-backward" aria-hidden="true"></i>  <a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>  <i class="fa fa-forward" aria-hidden="true"></i> <i class="fa fa-fast-forward" aria-hidden="true"></i>';
538
+			this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b>' + props.archive_date + ' UTC </b>' + '<br/><a href="#" onClick="archivePause();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="archivePlay();"><i class="fa fa-play" aria-hidden="true"></i></a>';
539 539
 		} else {
540
-			this._div.innerHTML = '<h4><?php echo str_replace("'","\'",_("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
540
+			this._div.innerHTML = '<h4><?php echo str_replace("'", "\'", _("Archive Date & Time")); ?></h4>' +  '<b><i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-bottom"></i></b>';
541 541
 		}
542 542
 
543 543
 	};
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 <?php
738 738
 		} else {
739 739
 ?>
740
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
740
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
741 741
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
742 742
 <?php
743 743
 		}
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 			    /*
754 754
 			    shadowUrl: iconURLShadowpath,
755 755
 			    shadowSize: [<?php print $globalAircraftSize; ?>, <?php print $globalAircraftSize; ?>],
756
-			    shadowAnchor: [<?php print ($globalAircraftSize/2)+1; ?>, <?php print $globalAircraftSize; ?>]
756
+			    shadowAnchor: [<?php print ($globalAircraftSize/2) + 1; ?>, <?php print $globalAircraftSize; ?>]
757 757
 			    */
758 758
 			})
759 759
 		    })
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 <?php
787 787
 		} else {
788 788
 ?>
789
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
789
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
790 790
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
791 791
 <?php
792 792
 		}
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 <?php
835 835
 		} else {
836 836
 ?>
837
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
837
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
838 838
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
839 839
 <?php
840 840
 		}
@@ -1460,23 +1460,23 @@  discard block
 block discarded – undo
1460 1460
 	    airs.push(air.value);
1461 1461
 	}
1462 1462
     }
1463
-    document.cookie =  'filter_Airlines='+airs.join()+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"))); ?>; path=/'
1463
+    document.cookie =  'filter_Airlines='+airs.join()+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"))); ?>; path=/'
1464 1464
 }
1465 1465
 function airlinestype(selectObj) {
1466 1466
     var idx = selectObj.selectedIndex;
1467 1467
     var airtype = selectObj.options[idx].value;
1468
-    document.cookie =  'filter_airlinestype='+airtype+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"))); ?>; path=/'
1468
+    document.cookie =  'filter_airlinestype='+airtype+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"))); ?>; path=/'
1469 1469
 }
1470 1470
 function alliance(selectObj) {
1471 1471
     var idx = selectObj.selectedIndex;
1472 1472
     var alliance = selectObj.options[idx].value;
1473
-    document.cookie =  'filter_alliance='+alliance+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"))); ?>; path=/'
1473
+    document.cookie =  'filter_alliance='+alliance+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"))); ?>; path=/'
1474 1474
 }
1475 1475
 
1476 1476
 function identfilter() {
1477 1477
     var ident = $('#identfilter').val();
1478 1478
     console.log('Filter with '+ident);
1479
-    document.cookie =  'filter_ident='+ident+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
1479
+    document.cookie =  'filter_ident='+ident+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 2, date("Y"))); ?>; path=/'
1480 1480
 }
1481 1481
 function removefilters() {
1482 1482
     // Get an array of all cookie names (the regex matches what we don't want)
@@ -1498,7 +1498,7 @@  discard block
 block discarded – undo
1498 1498
 	}
1499 1499
     }
1500 1500
     //document.cookie =  'Sources='+sources.join()+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
1501
-    document.cookie =  'filter_Sources='+sources.join()+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"))); ?>; path=/'
1501
+    document.cookie =  'filter_Sources='+sources.join()+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"))); ?>; path=/'
1502 1502
 }
1503 1503
 
1504 1504
 function show3D() {
@@ -1521,23 +1521,23 @@  discard block
 block discarded – undo
1521 1521
 
1522 1522
 function clickVATSIM(cb) {
1523 1523
     //document.cookie =  'ShowVATSIM='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
1524
-    document.cookie =  'filter_ShowVATSIM='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
1524
+    document.cookie =  'filter_ShowVATSIM='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 2, date("Y"))); ?>; path=/'
1525 1525
 }
1526 1526
 function clickIVAO(cb) {
1527 1527
     //document.cookie =  'ShowIVAO='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
1528
-    document.cookie =  'filter_ShowIVAO='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
1528
+    document.cookie =  'filter_ShowIVAO='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 2, date("Y"))); ?>; path=/'
1529 1529
 }
1530 1530
 function clickphpVMS(cb) {
1531 1531
     //document.cookie =  'ShowVMS='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
1532
-    document.cookie =  'filter_ShowVMS='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
1532
+    document.cookie =  'filter_ShowVMS='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 2, date("Y"))); ?>; path=/'
1533 1533
 }
1534 1534
 function clickSBS1(cb) {
1535 1535
     //document.cookie =  'ShowSBS1='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
1536
-    document.cookie =  'filter_ShowSBS1='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
1536
+    document.cookie =  'filter_ShowSBS1='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 2, date("Y"))); ?>; path=/'
1537 1537
 }
1538 1538
 function clickAPRS(cb) {
1539 1539
     //document.cookie =  'ShowAPRS='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
1540
-    document.cookie =  'filter_ShowAPRS='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T",mktime(0, 0, 0, date("m")  , date("d")+2, date("Y"))); ?>; path=/'
1540
+    document.cookie =  'filter_ShowAPRS='+cb.checked+'; expires=<?php print date("D, j M Y G:i:s T", mktime(0, 0, 0, date("m"), date("d") + 2, date("Y"))); ?>; path=/'
1541 1541
 }
1542 1542
 function clickFlightPopup(cb) {
1543 1543
     document.cookie =  'flightpopup='+cb.checked+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
Please login to merge, or discard this patch.
Braces   +128 added lines, -33 removed lines patch added patch discarded remove patch
@@ -5,8 +5,11 @@  discard block
 block discarded – undo
5 5
 setcookie("MapFormat",'2d');
6 6
 
7 7
 // Compressed GeoJson is used if true
8
-if (!isset($globalJsonCompress)) $compress = true;
9
-else $compress = $globalJsonCompress;
8
+if (!isset($globalJsonCompress)) {
9
+	$compress = true;
10
+} else {
11
+	$compress = $globalJsonCompress;
12
+}
10 13
 if (isset($_GET['archive'])) {
11 14
 	//$archiveupdatetime = 50;
12 15
 	$archiveupdatetime = $globalMapRefresh;
@@ -16,8 +19,11 @@  discard block
 block discarded – undo
16 19
 	//$lastupd = round(($_GET['enddate']-$_GET['begindate'])/(($_GET['during']*60)/10));
17 20
 	//$lastupd = 20;
18 21
 	$lastupd = $_GET['archivespeed']*$archiveupdatetime;
19
-	if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
20
-	else $enddate = time();
22
+	if (isset($_GET['enddate']) && $_GET['enddate'] != '') {
23
+		$enddate = $_GET['enddate'];
24
+	} else {
25
+		$enddate = time();
26
+	}
21 27
 	setcookie("archive_begin",$begindate);
22 28
 	setcookie("archive_end",$enddate);
23 29
 	setcookie("archive_update",$lastupd);
@@ -123,7 +129,17 @@  discard block
 block discarded – undo
123 129
 	}
124 130
 
125 131
 	//create the map
126
-	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) print $latitude; else print $globalCenterLatitude; ?>,<?php if (isset($longitude)) print $longitude; else print $globalCenterLongitude; ?>], zoom);
132
+	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) {
133
+	print $latitude;
134
+} else {
135
+	print $globalCenterLatitude;
136
+}
137
+?>,<?php if (isset($longitude)) {
138
+	print $longitude;
139
+} else {
140
+	print $globalCenterLongitude;
141
+}
142
+?>], zoom);
127 143
 <?php
128 144
 	} else {
129 145
 ?>
@@ -136,9 +152,19 @@  discard block
 block discarded – undo
136 152
 	     || navigator.userAgent.match(/BlackBerry/i)
137 153
 	     || navigator.userAgent.match(/Windows Phone/i))
138 154
 	{
139
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>;
155
+		var zoom = <?php if (isset($globalLiveZoom)) {
156
+	print $globalLiveZoom-1;
157
+} else {
158
+	print '8';
159
+}
160
+?>;
140 161
 	} else {
141
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>;
162
+		var zoom = <?php if (isset($globalLiveZoom)) {
163
+	print $globalLiveZoom;
164
+} else {
165
+	print '9';
166
+}
167
+?>;
142 168
 	}
143 169
 
144 170
 	//create the map
@@ -163,16 +189,27 @@  discard block
 block discarded – undo
163 189
 	bounds = L.latLngBounds(southWest,northEast);
164 190
 	//a few title layers
165 191
 <?php
166
-	if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType'];
167
-	else $MapType = $globalMapProvider;
192
+	if (isset($_COOKIE['MapType'])) {
193
+		$MapType = $_COOKIE['MapType'];
194
+	} else {
195
+		$MapType = $globalMapProvider;
196
+	}
168 197
 
169 198
 	if ($MapType == 'Mapbox') {
170
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
171
-		else $MapBoxId = $_COOKIE['MapTypeId'];
172
-?>
199
+		if ($_COOKIE['MapTypeId'] == 'default') {
200
+			$MapBoxId = $globalMapboxId;
201
+		} else {
202
+			$MapBoxId = $_COOKIE['MapTypeId'];
203
+		}
204
+		?>
173 205
 	L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
174 206
 	    maxZoom: 18,
175
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
207
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
208
+	print 'false';
209
+} else {
210
+	print 'true';
211
+}
212
+?>,
176 213
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
177 214
 	      '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
178 215
 	      'Imagery © <a href="http://mapbox.com">Mapbox</a>',
@@ -184,7 +221,12 @@  discard block
 block discarded – undo
184 221
 ?>
185 222
 	L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
186 223
 	    maxZoom: 18,
187
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
224
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
225
+	print 'false';
226
+} else {
227
+	print 'true';
228
+}
229
+?>,
188 230
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
189 231
 	      '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>'
190 232
 	}).addTo(map);
@@ -230,20 +272,26 @@  discard block
 block discarded – undo
230 272
 	map.addLayer(yandexLayer);
231 273
 <?php
232 274
 	} elseif ($MapType == 'Bing-Aerial') {
233
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
234
-?>
275
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
276
+			setcookie('MapType','OpenStreetMap');
277
+		}
278
+		?>
235 279
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
236 280
 	map.addLayer(bingLayer);
237 281
 <?php
238 282
 	} elseif ($MapType == 'Bing-Hybrid') {
239
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
240
-?>
283
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
284
+			setcookie('MapType','OpenStreetMap');
285
+		}
286
+		?>
241 287
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
242 288
 	map.addLayer(bingLayer);
243 289
 <?php
244 290
 	} elseif ($MapType == 'Bing-Road') {
245
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
246
-?>
291
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
292
+			setcookie('MapType','OpenStreetMap');
293
+		}
294
+		?>
247 295
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
248 296
 	map.addLayer(bingLayer);
249 297
 <?php
@@ -291,7 +339,12 @@  discard block
 block discarded – undo
291 339
 		}
292 340
 	} elseif ($globalBounding == 'circle') {
293 341
 ?>
294
-	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{
342
+	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) {
343
+	print $globalBoundingCircleSize;
344
+} else {
345
+	print '70000';
346
+}
347
+?>,{
295 348
 	    color: '#92C7D1',
296 349
 	    fillColor: '#92C7D1',
297 350
 	    fillOpacity: 0.3,
@@ -350,8 +403,11 @@  discard block
 block discarded – undo
350 403
 
351 404
 	function update_airportsLayer() {
352 405
 	    <?php
353
-		if (isset($_COOKIE['AirportZoom'])) $getZoom = $_COOKIE['AirportZoom'];
354
-		else $getZoom = '7';
406
+		if (isset($_COOKIE['AirportZoom'])) {
407
+			$getZoom = $_COOKIE['AirportZoom'];
408
+		} else {
409
+			$getZoom = '7';
410
+		}
355 411
 	    ?>
356 412
 	    //if (map.getZoom() <= <?php print $getZoom; ?>) {
357 413
 		if (typeof airportsLayer != 'undefined') {
@@ -687,9 +743,13 @@  discard block
 block discarded – undo
687 743
 		    if (callsign != ""){ markerLabel += callsign; }
688 744
 		    if (departure_airport_code != "" && arrival_airport_code != "" && departure_airport_code != "NA" && arrival_airport_code != "NA"){ markerLabel += ' ( '+departure_airport_code+' - '+arrival_airport_code+' )'; }
689 745
 <?php
690
-	if (isset($_COOKIE['IconColor'])) $IconColor = $_COOKIE['IconColor'];
691
-	elseif (isset($globalAircraftIconColor)) $IconColor = $globalAircraftIconColor;
692
-	else $IconColor = '1a3151';
746
+	if (isset($_COOKIE['IconColor'])) {
747
+		$IconColor = $_COOKIE['IconColor'];
748
+	} elseif (isset($globalAircraftIconColor)) {
749
+		$IconColor = $globalAircraftIconColor;
750
+	} else {
751
+		$IconColor = '1a3151';
752
+	}
693 753
 	if (!isset($ident) && !isset($flightaware_id)) {
694 754
 ?>
695 755
 		    info_update(feature.properties.fc);
@@ -737,7 +797,12 @@  discard block
 block discarded – undo
737 797
 <?php
738 798
 		} else {
739 799
 ?>
740
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
800
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
801
+	print $archiveupdatetime*1000;
802
+} else {
803
+	print $globalMapRefresh*1000+20000;
804
+}
805
+?>+feature.properties.sqt*1000);
741 806
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
742 807
 <?php
743 808
 		}
@@ -786,7 +851,12 @@  discard block
 block discarded – undo
786 851
 <?php
787 852
 		} else {
788 853
 ?>
789
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
854
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
855
+	print $archiveupdatetime*1000;
856
+} else {
857
+	print $globalMapRefresh*1000+20000;
858
+}
859
+?>+feature.properties.sqt*1000);
790 860
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
791 861
 <?php
792 862
 		}
@@ -834,7 +904,12 @@  discard block
 block discarded – undo
834 904
 <?php
835 905
 		} else {
836 906
 ?>
837
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
907
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
908
+	print $archiveupdatetime*1000;
909
+} else {
910
+	print $globalMapRefresh*1000+20000;
911
+}
912
+?>+feature.properties.sqt*1000);
838 913
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
839 914
 <?php
840 915
 		}
@@ -1177,14 +1252,24 @@  discard block
 block discarded – undo
1177 1252
 	if (isset($_GET['archive'])) {
1178 1253
 ?>
1179 1254
 //then load it again every 30 seconds
1180
-//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>);
1255
+//  var reload = setInterval(function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) {
1256
+	print ($globalMapRefresh*1000)/2;
1257
+} else {
1258
+	print '15000';
1259
+}
1260
+?>);
1181 1261
 reloadPage = setInterval(function(){if (noTimeout) getLiveData(0)},<?php print $archiveupdatetime*1000; ?>);
1182 1262
 <?php
1183 1263
 	} else {
1184 1264
 ?>
1185 1265
 //then load it again every 30 seconds
1186 1266
 reloadPage = setInterval(
1187
-    function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
1267
+    function(){if (noTimeout) getLiveData(0)},<?php if (isset($globalMapRefresh)) {
1268
+	print $globalMapRefresh*1000;
1269
+} else {
1270
+	print '30000';
1271
+}
1272
+?>);
1188 1273
 var currentdate = new Date();
1189 1274
 var currentyear = new Date().getFullYear();
1190 1275
 var begindate = new Date(Date.UTC(currentyear,11,24,2,0,0,0));
@@ -1196,7 +1281,12 @@  discard block
 block discarded – undo
1196 1281
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
1197 1282
 ?>
1198 1283
 update_polarLayer();
1199
-setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
1284
+setInterval(function(){map.removeLayer(polarLayer);update_polarLayer()},<?php if (isset($globalMapRefresh)) {
1285
+	print $globalMapRefresh*1000*2;
1286
+} else {
1287
+	print '60000';
1288
+}
1289
+?>);
1200 1290
 <?php
1201 1291
 		}
1202 1292
 ?>
@@ -1212,7 +1302,12 @@  discard block
 block discarded – undo
1212 1302
 	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
1213 1303
 ?>
1214 1304
 update_atcLayer();
1215
-setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
1305
+setInterval(function(){map.removeLayer(atcLayer);update_atcLayer()},<?php if (isset($globalMapRefresh)) {
1306
+	print $globalMapRefresh*1000*2;
1307
+} else {
1308
+	print '60000';
1309
+}
1310
+?>);
1216 1311
 <?php
1217 1312
 	}
1218 1313
 ?>
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	    <?php
353 353
 		if (isset($_COOKIE['AirportZoom'])) $getZoom = $_COOKIE['AirportZoom'];
354 354
 		else $getZoom = '7';
355
-	    ?>
355
+		?>
356 356
 	    //if (map.getZoom() <= <?php print $getZoom; ?>) {
357 357
 		if (typeof airportsLayer != 'undefined') {
358 358
 			if (map.hasLayer(airportsLayer) == true) {
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 	update_locationsLayer();
513 513
 	
514 514
 <?php
515
-	    if (!isset($ident) && !isset($flightaware_id)) {
515
+		if (!isset($ident) && !isset($flightaware_id)) {
516 516
 ?>
517 517
 	
518 518
 	function info_update (props) {
@@ -520,11 +520,11 @@  discard block
 block discarded – undo
520 520
 	}
521 521
 
522 522
 	<?php
523
-	    }
523
+		}
524 524
 	?>
525 525
 
526 526
 	<?php
527
-	    if (isset($_GET['archive'])) {
527
+		if (isset($_GET['archive'])) {
528 528
 	?>
529 529
 	var archive = L.control();
530 530
 	archive.onAdd = function (map) {
@@ -543,12 +543,12 @@  discard block
 block discarded – undo
543 543
 	};
544 544
 	archive.addTo(map);
545 545
 	<?php
546
-	    }
546
+		}
547 547
 	?>
548 548
 
549 549
 
550 550
 	<?php
551
-	    //if ((isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'false') || (isset($globalMapPopup) && !$globalMapPopup)) {
551
+		//if ((isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'false') || (isset($globalMapPopup) && !$globalMapPopup)) {
552 552
 	?>
553 553
 
554 554
 	$(".showdetails").on("click",".close",function(){
@@ -1041,15 +1041,15 @@  discard block
 block discarded – undo
1041 1041
 			if (map.getZoom() > 7) {
1042 1042
                 	    var style = {
1043 1043
 				<?php
1044
-				    if (isset($globalMapAltitudeColor) && !$globalMapAltitudeColor) {
1044
+					if (isset($globalMapAltitudeColor) && !$globalMapAltitudeColor) {
1045 1045
 				?>
1046 1046
 				"color": "#1a3151",
1047 1047
 				<?php
1048
-				    } else {
1048
+					} else {
1049 1049
 				?>
1050 1050
 				"color": getAltitudeColor(altitude),
1051 1051
 				<?php
1052
-				    }
1052
+					}
1053 1053
 				?>
1054 1054
 				"weight": 3,
1055 1055
 				"opacity": 1
@@ -1059,15 +1059,15 @@  discard block
 block discarded – undo
1059 1059
 			} else {
1060 1060
 			    var style = {
1061 1061
 				<?php
1062
-				    if (isset($globalMapAltitudeColor) && !$globalMapAltitudeColor) {
1062
+					if (isset($globalMapAltitudeColor) && !$globalMapAltitudeColor) {
1063 1063
 				?>
1064 1064
 				"color": "#1a3151",
1065 1065
 				<?php
1066
-				    } else {
1066
+					} else {
1067 1067
 				?>
1068 1068
 				"color": getAltitudeColor(altitude),
1069 1069
 				<?php
1070
-				    }
1070
+					}
1071 1071
 				?>
1072 1072
 				"weight": 2,
1073 1073
 				"opacity": 1
@@ -1079,15 +1079,15 @@  discard block
 block discarded – undo
1079 1079
 			if (map.getZoom() > 7) {
1080 1080
                 	    var style = {
1081 1081
 				<?php
1082
-				    if (isset($globalMapAltitudeColor) && !$globalMapAltitudeColor) {
1082
+					if (isset($globalMapAltitudeColor) && !$globalMapAltitudeColor) {
1083 1083
 				?>
1084 1084
                     		"color": "#1a3151",
1085 1085
 				<?php
1086
-				    } else {
1086
+					} else {
1087 1087
 				?>
1088 1088
 				"color": getAltitudeColor(altitude),
1089 1089
 				<?php
1090
-				    }
1090
+					}
1091 1091
 				?>
1092 1092
 				"weight": 3,
1093 1093
 				"opacity": 0.6
@@ -1097,15 +1097,15 @@  discard block
 block discarded – undo
1097 1097
 			} else {
1098 1098
                 	    var style = {
1099 1099
 				<?php
1100
-				    if (isset($globalMapAltitudeColor) && !$globalMapAltitudeColor) {
1100
+					if (isset($globalMapAltitudeColor) && !$globalMapAltitudeColor) {
1101 1101
 				?>
1102 1102
                     		"color": "#1a3151",
1103 1103
 				<?php
1104
-				    } else {
1104
+					} else {
1105 1105
 				?>
1106 1106
                     		"color": getAltitudeColor(altitude),
1107 1107
 				<?php
1108
-				    }
1108
+					}
1109 1109
 				?>
1110 1110
 				"weight": 2,
1111 1111
 				"opacity": 0.6
@@ -1115,21 +1115,21 @@  discard block
 block discarded – undo
1115 1115
 			}
1116 1116
                     }
1117 1117
 		    <?php
1118
-            		} else {
1119
-            	    ?>
1118
+					} else {
1119
+					?>
1120 1120
 		    if (map.getZoom() > 7) {
1121 1121
                 	var style = {
1122 1122
 			    <?php
1123 1123
 				if (isset($globalMapAltitudeColor) && !$globalMapAltitudeColor) {
1124
-			    ?>
1124
+				?>
1125 1125
                     	    "color": "#1a3151",
1126 1126
 			    <?php
1127 1127
 				} else {
1128
-			    ?>
1128
+				?>
1129 1129
                     	    "color": getAltitudeColor(altitude),
1130 1130
 			    <?php
1131 1131
 				}
1132
-			    ?>
1132
+				?>
1133 1133
                     	    "weight": 3,
1134 1134
                     	    "opacity": 0.6
1135 1135
                 	};
@@ -1139,15 +1139,15 @@  discard block
 block discarded – undo
1139 1139
                 	var style = {
1140 1140
 			    <?php
1141 1141
 				if (isset($globalMapAltitudeColor) && !$globalMapAltitudeColor) {
1142
-			    ?>
1142
+				?>
1143 1143
 			    "color": "#1a3151",
1144 1144
 			    <?php
1145 1145
 				} else {
1146
-			    ?>
1146
+				?>
1147 1147
 			    "color": getAltitudeColor(altitude),
1148 1148
 			    <?php
1149 1149
 				}
1150
-			    ?>
1150
+				?>
1151 1151
                     	    "weight": 2,
1152 1152
                     	    "opacity": 0.6
1153 1153
                 	};
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
                 	layer_data.addLayer(layer);
1156 1156
 		    }
1157 1157
 <?php
1158
-            		}
1158
+					}
1159 1159
 ?>
1160 1160
 				}
1161 1161
 			    }
@@ -1220,10 +1220,10 @@  discard block
 block discarded – undo
1220 1220
 
1221 1221
 
1222 1222
 <?php
1223
-    // Add support for custom json via $globalMapJson
1224
-    if (isset($globalMapJson) && is_array($globalMapJson)) {
1223
+	// Add support for custom json via $globalMapJson
1224
+	if (isset($globalMapJson) && is_array($globalMapJson)) {
1225 1225
 	foreach ($globalMapJson as $json) {
1226
-	    if (isset($json['url'])) {
1226
+		if (isset($json['url'])) {
1227 1227
 ?>
1228 1228
 update_genLayer('<?php print $json['url']; ?>');
1229 1229
 <?php
@@ -1232,9 +1232,9 @@  discard block
 block discarded – undo
1232 1232
 setInterval(function(){update_genLayer('<?php print $json['url']; ?>')}, <?php print $json['refresh']; ?>);
1233 1233
 <?php
1234 1234
 		}
1235
-	    }
1235
+		}
1236
+	}
1236 1237
 	}
1237
-    }
1238 1238
 
1239 1239
 ?>
1240 1240
 
Please login to merge, or discard this patch.
require/class.SpotterImport.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -40,6 +40,10 @@
 block discarded – undo
40 40
 	}
41 41
     }
42 42
 
43
+    /**
44
+     * @param string $id
45
+     * @param string $ident
46
+     */
43 47
     public function get_Schedule($id,$ident) {
44 48
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 49
 	// Get schedule here, so it's done only one time
Please login to merge, or discard this patch.
Indentation   +424 added lines, -424 removed lines patch added patch discarded remove patch
@@ -9,20 +9,20 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 require_once(dirname(__FILE__).'/class.GeoidHeight.php');
11 11
 if (isset($globalServerAPRS) && $globalServerAPRS) {
12
-    require_once(dirname(__FILE__).'/class.APRS.php');
12
+	require_once(dirname(__FILE__).'/class.APRS.php');
13 13
 }
14 14
 
15 15
 class SpotterImport {
16
-    private $all_flights = array();
17
-    private $last_delete_hourly = 0;
18
-    private $last_delete = 0;
19
-    private $stats = array();
20
-    private $tmd = 0;
21
-    private $source_location = array();
22
-    public $db = null;
23
-    public $nb = 0;
16
+	private $all_flights = array();
17
+	private $last_delete_hourly = 0;
18
+	private $last_delete = 0;
19
+	private $stats = array();
20
+	private $tmd = 0;
21
+	private $source_location = array();
22
+	public $db = null;
23
+	public $nb = 0;
24 24
 
25
-    public function __construct($dbc = null) {
25
+	public function __construct($dbc = null) {
26 26
 	global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid;
27 27
 	if (!(isset($globalNoDB) && $globalNoDB)) {
28 28
 		$Connection = new Connection($dbc);
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 		$currentdate = date('Y-m-d');
35 35
 		$sourcestat = $Stats->getStatsSource($currentdate);
36 36
 		if (!empty($sourcestat)) {
37
-		    foreach($sourcestat as $srcst) {
38
-		    	$type = $srcst['stats_type'];
37
+			foreach($sourcestat as $srcst) {
38
+				$type = $srcst['stats_type'];
39 39
 			if ($type == 'polar' || $type == 'hist') {
40
-			    $source = $srcst['source_name'];
41
-			    $data = $srcst['source_data'];
42
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
43
-	    		}
44
-		    }
40
+				$source = $srcst['source_name'];
41
+				$data = $srcst['source_data'];
42
+				$this->stats[$currentdate][$source][$type] = json_decode($data,true);
43
+				}
44
+			}
45 45
 		}
46 46
 	}
47 47
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
 			$GeoidClass = FALSE;
57 57
 		}
58 58
 	}
59
-    }
59
+	}
60 60
 
61
-    public function get_Schedule($id,$ident) {
61
+	public function get_Schedule($id,$ident) {
62 62
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
63 63
 	// Get schedule here, so it's done only one time
64 64
 	
@@ -78,43 +78,43 @@  discard block
 block discarded – undo
78 78
 	$operator = $Spotter->getOperator($ident);
79 79
 	$scheduleexist = false;
80 80
 	if ($Schedule->checkSchedule($operator) == 0) {
81
-	    $operator = $Translation->checkTranslation($ident);
82
-	    if ($Schedule->checkSchedule($operator) == 0) {
81
+		$operator = $Translation->checkTranslation($ident);
82
+		if ($Schedule->checkSchedule($operator) == 0) {
83 83
 		$schedule = $Schedule->fetchSchedule($operator);
84 84
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88
-		    // Should also check if route schedule = route from DB
89
-		    if ($schedule['DepartureAirportIATA'] != '') {
85
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88
+			// Should also check if route schedule = route from DB
89
+			if ($schedule['DepartureAirportIATA'] != '') {
90 90
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
91
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92
-			    if (trim($airport_icao) != '') {
91
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92
+				if (trim($airport_icao) != '') {
93 93
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
94 94
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
95
-			    }
95
+				}
96
+			}
96 97
 			}
97
-		    }
98
-		    if ($schedule['ArrivalAirportIATA'] != '') {
98
+			if ($schedule['ArrivalAirportIATA'] != '') {
99 99
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
100
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101
-			    if (trim($airport_icao) != '') {
100
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101
+				if (trim($airport_icao) != '') {
102 102
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
103 103
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
104
-			    }
104
+				}
105 105
 			}
106
-		    }
107
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
106
+			}
107
+			$Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
108 108
 		}
109
-	    } else $scheduleexist = true;
109
+		} else $scheduleexist = true;
110 110
 	} else $scheduleexist = true;
111 111
 	// close connection, at least one way will work ?
112
-       if ($scheduleexist) {
112
+	   if ($scheduleexist) {
113 113
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
114
-    		$sch = $Schedule->getSchedule($operator);
114
+			$sch = $Schedule->getSchedule($operator);
115 115
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
116 116
 		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
117
-       }
117
+	   }
118 118
 	$Spotter->db = null;
119 119
 	$Schedule->db = null;
120 120
 	$Translation->db = null;
@@ -129,65 +129,65 @@  discard block
 block discarded – undo
129 129
 	}
130 130
 	  */
131 131
 	}
132
-    }
132
+	}
133 133
 
134
-    public function checkAll() {
134
+	public function checkAll() {
135 135
 	global $globalDebug, $globalNoImport;
136 136
 	if ($globalDebug) echo "Update last seen flights data...\n";
137 137
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
138
-	    foreach ($this->all_flights as $key => $flight) {
138
+		foreach ($this->all_flights as $key => $flight) {
139 139
 		if (isset($this->all_flights[$key]['id'])) {
140
-		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
141
-    		    $Spotter = new Spotter($this->db);
142
-        	    $real_arrival = $this->arrival($key);
143
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
144
-        	}
145
-	    }
140
+			//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
141
+				$Spotter = new Spotter($this->db);
142
+				$real_arrival = $this->arrival($key);
143
+				if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
144
+			}
145
+		}
146
+	}
146 147
 	}
147
-    }
148 148
 
149
-    public function arrival($key) {
149
+	public function arrival($key) {
150 150
 	global $globalClosestMinDist, $globalDebug;
151 151
 	if ($globalDebug) echo 'Update arrival...'."\n";
152 152
 	$Spotter = new Spotter($this->db);
153
-        $airport_icao = '';
154
-        $airport_time = '';
155
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
153
+		$airport_icao = '';
154
+		$airport_time = '';
155
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
156 156
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
157
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
158
-    	    if (isset($closestAirports[0])) {
159
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
160
-        	    $airport_icao = $closestAirports[0]['icao'];
161
-        	    $airport_time = $this->all_flights[$key]['datetime'];
162
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
163
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
164
-        	    foreach ($closestAirports as $airport) {
165
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
166
-        		    $airport_icao = $airport['icao'];
167
-        		    $airport_time = $this->all_flights[$key]['datetime'];
168
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
169
-        		    break;
170
-        		}
171
-        	    }
172
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
173
-        		$airport_icao = $closestAirports[0]['icao'];
174
-        		$airport_time = $this->all_flights[$key]['datetime'];
175
-        	} else {
176
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
177
-        	}
178
-    	    } else {
179
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
180
-    	    }
157
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
158
+			if (isset($closestAirports[0])) {
159
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
160
+				$airport_icao = $closestAirports[0]['icao'];
161
+				$airport_time = $this->all_flights[$key]['datetime'];
162
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
163
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
164
+				foreach ($closestAirports as $airport) {
165
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
166
+					$airport_icao = $airport['icao'];
167
+					$airport_time = $this->all_flights[$key]['datetime'];
168
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
169
+					break;
170
+				}
171
+				}
172
+			} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
173
+				$airport_icao = $closestAirports[0]['icao'];
174
+				$airport_time = $this->all_flights[$key]['datetime'];
175
+			} else {
176
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
177
+			}
178
+			} else {
179
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
180
+			}
181 181
 
182
-        } else {
183
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
184
-        }
185
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
186
-    }
182
+		} else {
183
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
184
+		}
185
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
186
+	}
187 187
 
188 188
 
189 189
 
190
-    public function del() {
190
+	public function del() {
191 191
 	global $globalDebug, $globalNoImport, $globalNoDB;
192 192
 	// Delete old infos
193 193
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 			}
200 200
 		}
201 201
 	}
202
-    }
202
+	}
203 203
 
204
-    public function delKey($key) {
204
+	public function delKey($key) {
205 205
 	global $globalDebug, $globalNoImport, $globalNoDB;
206 206
 	// Delete old infos
207 207
 	if (isset($this->all_flights[$key]['id'])) {
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 		if ($globalDebug) echo "\n";
224 224
 	}
225 225
 	unset($this->all_flights[$key]);
226
-    }
226
+	}
227 227
 
228
-    public function add($line) {
228
+	public function add($line) {
229 229
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive;
230 230
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
231 231
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
@@ -251,20 +251,20 @@  discard block
 block discarded – undo
251 251
 	
252 252
 	// SBS format is CSV format
253 253
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
254
-	    //print_r($line);
255
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
256
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
254
+		//print_r($line);
255
+		if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
256
+  		if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
257 257
 
258 258
 		// Increment message number
259 259
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
260
-		    $current_date = date('Y-m-d');
261
-		    if (isset($line['source_name'])) $source = $line['source_name'];
262
-		    else $source = '';
263
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
264
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
265
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
266
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
267
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
260
+			$current_date = date('Y-m-d');
261
+			if (isset($line['source_name'])) $source = $line['source_name'];
262
+			else $source = '';
263
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
264
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
265
+				$this->stats[$current_date][$source]['msg']['date'] = time();
266
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
267
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
268 268
 		}
269 269
 		
270 270
 		/*
@@ -280,54 +280,54 @@  discard block
 block discarded – undo
280 280
 		//$this->db = $dbc;
281 281
 
282 282
 		//$hex = trim($line['hex']);
283
-	        if (!isset($line['id'])) $id = trim($line['hex']);
284
-	        else $id = trim($line['id']);
283
+			if (!isset($line['id'])) $id = trim($line['hex']);
284
+			else $id = trim($line['id']);
285 285
 		
286 286
 		if (!isset($this->all_flights[$id])) {
287
-		    if ($globalDebug) echo 'New flight...'."\n";
288
-		    $this->all_flights[$id] = array();
289
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
290
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
291
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
292
-		    if (!isset($line['id'])) {
287
+			if ($globalDebug) echo 'New flight...'."\n";
288
+			$this->all_flights[$id] = array();
289
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
290
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
291
+			if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
292
+			if (!isset($line['id'])) {
293 293
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
294 294
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
295 295
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
296 296
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
297
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
298
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
299
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
297
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
298
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
299
+			if ($globalAllFlights !== FALSE) $dataFound = true;
300 300
 		}
301 301
 		if (isset($line['source_type']) && $line['source_type'] != '') {
302
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
302
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
303 303
 		}
304 304
 		
305 305
 		//print_r($this->all_flights);
306 306
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
307
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
308
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
307
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
308
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
309 309
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
310
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
311
-		    if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
310
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
311
+			if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
312 312
 			$timeelapsed = microtime(true);
313 313
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
314
-			    $Spotter = new Spotter($this->db);
315
-			    if (isset($this->all_flights[$id]['source_type'])) {
314
+				$Spotter = new Spotter($this->db);
315
+				if (isset($this->all_flights[$id]['source_type'])) {
316 316
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
317
-			    } else {
317
+				} else {
318 318
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
319
-			    }
320
-			    $Spotter->db = null;
321
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
322
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
319
+				}
320
+				$Spotter->db = null;
321
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
322
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
323 323
 			}
324
-		    }
325
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
326
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
324
+			}
325
+			if ($globalAllFlights !== FALSE) $dataFound = true;
326
+			if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
327 327
 		}
328
-	        if (isset($line['id']) && !isset($line['hex'])) {
329
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
330
-	        }
328
+			if (isset($line['id']) && !isset($line['hex'])) {
329
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
330
+			}
331 331
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
332 332
 			$icao = $line['aircraft_icao'];
333 333
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 		}
358 358
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
359 359
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
360
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
360
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
361 361
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
362
-		    } else {
362
+			} else {
363 363
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
364 364
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
365 365
 				/*
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 				print_r($line);
369 369
 				*/
370 370
 				return '';
371
-		    }
371
+			}
372 372
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
373 373
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
374 374
 			return '';
@@ -384,21 +384,21 @@  discard block
 block discarded – undo
384 384
 		}
385 385
 
386 386
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') {
387
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
387
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
388 388
 		}
389 389
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
390
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
390
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
391 391
 		}
392 392
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
393
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
393
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
394 394
 		}
395 395
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
396
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
396
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
397 397
 		}
398 398
  
399 399
 		if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
400 400
 
401
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
401
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
402 402
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
403 403
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
404 404
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -407,23 +407,23 @@  discard block
 block discarded – undo
407 407
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
408 408
 				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
409 409
 			} else {
410
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
411
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
410
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
411
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
412 412
 				$timeelapsed = microtime(true);
413
-            			$Spotter = new Spotter($this->db);
414
-            			$fromsource = NULL;
415
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
416
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
413
+						$Spotter = new Spotter($this->db);
414
+						$fromsource = NULL;
415
+						if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
416
+						elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
417 417
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
418 418
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
419 419
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
420
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
420
+						$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
421 421
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
422 422
 				$Spotter->db = null;
423 423
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
424
-			    }
424
+				}
425 425
 			}
426
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
426
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
427 427
 		    
428 428
 /*
429 429
 		    if (!isset($line['id'])) {
@@ -433,63 +433,63 @@  discard block
 block discarded – undo
433 433
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
434 434
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
435 435
   */
436
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
436
+			if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
437 437
 
438
-		    //$putinarchive = true;
439
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
438
+			//$putinarchive = true;
439
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
440 440
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
441
-		    }
442
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
441
+			}
442
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
443 443
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
444
-		    }
445
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
446
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
447
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
444
+			}
445
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
446
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
447
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
448 448
 			$timeelapsed = microtime(true);
449 449
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
450 450
 				$Spotter = new Spotter($this->db);
451 451
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
452 452
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
453
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
453
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
454 454
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
455
-                        }
456
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
455
+						}
456
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
457 457
 			$timeelapsed = microtime(true);
458 458
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
459
-			    $Spotter = new Spotter($this->db);
460
-			    $route = $Spotter->getRouteInfo(trim($line['ident']));
461
-			    if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
459
+				$Spotter = new Spotter($this->db);
460
+				$route = $Spotter->getRouteInfo(trim($line['ident']));
461
+				if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
462 462
 				$Translation = new Translation($this->db);
463 463
 				$ident = $Translation->checkTranslation(trim($line['ident']));
464 464
 				$route = $Spotter->getRouteInfo($ident);
465 465
 				$Translation->db = null;
466
-			    }
467
-			    $Spotter->db = null;
468
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
469
-                    	}
466
+				}
467
+				$Spotter->db = null;
468
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
469
+						}
470 470
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
471
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
472
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
471
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
472
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
473 473
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
474
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
475
-		    	    }
474
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
475
+					}
476 476
 			}
477 477
 			if (!isset($globalFork)) $globalFork = TRUE;
478 478
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
479 479
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
480 480
 			}
481
-		    }
481
+			}
482 482
 		}
483 483
 
484 484
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
485 485
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
486
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
487
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
488
-		    //$dataFound = true;
486
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
487
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
488
+			//$dataFound = true;
489 489
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
490
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
491
-		    if ($distance > 1000 && $distance < 10000) {
492
-		    // use datetime
490
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
491
+			if ($distance > 1000 && $distance < 10000) {
492
+			// use datetime
493 493
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
494 494
 			$speed = $speed*3.6;
495 495
 			if ($speed < 1000) {
@@ -498,49 +498,49 @@  discard block
 block discarded – undo
498 498
 	  		} else {
499 499
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
500 500
 	  		}
501
-		    }
501
+			}
502 502
 		}
503 503
 
504 504
 
505 505
 
506
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
507
-	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
508
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
509
-	    	    	return false;
510
-	    	    }
511
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
512
-	    	    else unset($timediff);
513
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
514
-	    	    else unset($timediff_archive);
515
-	    	    if ($this->tmd > 5
516
-	    	        || (isset($line['format_source']) 
517
-	    	    	    && $line['format_source'] == 'airwhere' 
518
-	    	    	    && ((!isset($this->all_flights[$id]['latitude']) 
519
-	    	    		|| !isset($this->all_flights[$id]['longitude'])) 
520
-	    	    		|| (isset($this->all_flights[$id]['latitude']) 
521
-	    	    		    && isset($this->all_flights[$id]['longitude']) 
522
-	    	    		    && $this->all_flights[$id]['latitude'] != $line['latitude'] 
523
-	    	    		    && $this->all_flights[$id]['longitude'] != $line['longitude']
524
-	    	    		)
525
-	    	    	    )
526
-	    	    	)
527
-	    		|| (isset($globalVA) && $globalVA) 
528
-	    	    	|| (isset($globalIVAO) && $globalIVAO)
529
-	    	    	|| (isset($globalVATSIM) && $globalVATSIM)
530
-	    	    	|| (isset($globalphpVMS) && $globalphpVMS)
531
-	    	    	|| (isset($globalVAM) && $globalVAM)
532
-	    	    	|| !isset($timediff)
533
-	    	    	|| $timediff > $globalLiveInterval
534
-	    	    	|| $globalArchive
535
-	    	    	|| ($timediff > 30 
536
-	    	    	    && isset($this->all_flights[$id]['latitude']) 
537
-	    	    	    && isset($this->all_flights[$id]['longitude']) 
538
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
539
-	    	    	    )
540
-	    	    	) {
506
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
507
+				if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
508
+					if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
509
+					return false;
510
+				}
511
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
512
+				else unset($timediff);
513
+				if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
514
+				else unset($timediff_archive);
515
+				if ($this->tmd > 5
516
+					|| (isset($line['format_source']) 
517
+						&& $line['format_source'] == 'airwhere' 
518
+						&& ((!isset($this->all_flights[$id]['latitude']) 
519
+						|| !isset($this->all_flights[$id]['longitude'])) 
520
+						|| (isset($this->all_flights[$id]['latitude']) 
521
+							&& isset($this->all_flights[$id]['longitude']) 
522
+							&& $this->all_flights[$id]['latitude'] != $line['latitude'] 
523
+							&& $this->all_flights[$id]['longitude'] != $line['longitude']
524
+						)
525
+						)
526
+					)
527
+				|| (isset($globalVA) && $globalVA) 
528
+					|| (isset($globalIVAO) && $globalIVAO)
529
+					|| (isset($globalVATSIM) && $globalVATSIM)
530
+					|| (isset($globalphpVMS) && $globalphpVMS)
531
+					|| (isset($globalVAM) && $globalVAM)
532
+					|| !isset($timediff)
533
+					|| $timediff > $globalLiveInterval
534
+					|| $globalArchive
535
+					|| ($timediff > 30 
536
+						&& isset($this->all_flights[$id]['latitude']) 
537
+						&& isset($this->all_flights[$id]['longitude']) 
538
+						&& $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
539
+						)
540
+					) {
541 541
 
542 542
 			if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) {
543
-			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
543
+				if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
544 544
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
545 545
 				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
546 546
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -548,9 +548,9 @@  discard block
 block discarded – undo
548 548
 				$this->all_flights[$id]['putinarchive'] = true;
549 549
 				$this->tmd = 0;
550 550
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
551
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
552
-				    $timeelapsed = microtime(true);
553
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
551
+					if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
552
+					$timeelapsed = microtime(true);
553
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
554 554
 					$Spotter = new Spotter($this->db);
555 555
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
556 556
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
@@ -558,11 +558,11 @@  discard block
 block discarded – undo
558 558
 					$Spotter->db = null;
559 559
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
560 560
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
561
-				    }
561
+					}
562 562
 				}
563 563
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
564
-			    } 
565
-			    /*
564
+				} 
565
+				/*
566 566
 			    else {
567 567
 				if (!isset($timediff)) echo 'NO TIMEDIFF';
568 568
 				else {
@@ -576,16 +576,16 @@  discard block
 block discarded – undo
576 576
 			}
577 577
 
578 578
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
579
-			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
579
+				//if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
580 580
 				if (!isset($this->all_flights[$id]['archive_latitude'])) {
581 581
 					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
582 582
 					$this->all_flights[$id]['time_last_coord'] = time();
583 583
 				}
584 584
 				//if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
585 585
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
586
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
587
-				    $dataFound = true;
588
-				    $this->all_flights[$id]['time_last_coord'] = time();
586
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
587
+					$dataFound = true;
588
+					$this->all_flights[$id]['time_last_coord'] = time();
589 589
 				}
590 590
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
591 591
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -596,24 +596,24 @@  discard block
 block discarded – undo
596 596
 				    //$putinarchive = true;
597 597
 				}
598 598
 				*/
599
-			    /*
599
+				/*
600 600
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
601 601
 				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
602 602
 			    }
603 603
 			    */
604 604
 			}
605 605
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
606
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
607
-			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
606
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
607
+				//if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
608 608
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
609 609
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
610 610
 					$this->all_flights[$id]['time_last_coord'] = time();
611 611
 				}
612 612
 				//if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
613 613
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
614
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
615
-				    $dataFound = true;
616
-				    $this->all_flights[$id]['time_last_coord'] = time();
614
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
615
+					$dataFound = true;
616
+					$this->all_flights[$id]['time_last_coord'] = time();
617 617
 				}
618 618
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
619 619
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -631,67 +631,67 @@  discard block
 block discarded – undo
631 631
 			    */
632 632
 			}
633 633
 
634
-		    } else if ($globalDebug && $timediff > 30) {
634
+			} else if ($globalDebug && $timediff > 30) {
635 635
 			$this->tmd = $this->tmd + 1;
636 636
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
637 637
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
638 638
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
639 639
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
640
-		    }
640
+			}
641 641
 		}
642 642
 		if (isset($line['last_update']) && $line['last_update'] != '') {
643
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
644
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
643
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
644
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
645 645
 		}
646 646
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
647
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
648
-		    //$dataFound = true;
647
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
648
+			//$dataFound = true;
649 649
 		}
650 650
 		if (isset($line['format_source']) && $line['format_source'] != '') {
651
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
651
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
652 652
 		}
653 653
 		if (isset($line['source_name']) && $line['source_name'] != '') {
654
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
654
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
655 655
 		}
656 656
 		if (isset($line['emergency']) && $line['emergency'] != '') {
657
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
658
-		    //$dataFound = true;
657
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
658
+			//$dataFound = true;
659 659
 		}
660 660
 		if (isset($line['ground']) && $line['ground'] != '') {
661
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
661
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
662 662
 			// Here we force archive of flight because after ground it's a new one (or should be)
663 663
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
664 664
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
665 665
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
666
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
666
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
667 667
 			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
668
-		    }
669
-		    if ($line['ground'] != 1) $line['ground'] = 0;
670
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
671
-		    //$dataFound = true;
668
+			}
669
+			if ($line['ground'] != 1) $line['ground'] = 0;
670
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
671
+			//$dataFound = true;
672 672
 		}
673 673
 		if (isset($line['squawk']) && $line['squawk'] != '') {
674
-		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
675
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
676
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
677
-			    $highlight = '';
678
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
679
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
680
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
681
-			    if ($highlight != '') {
674
+			if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
675
+				if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
676
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
677
+				$highlight = '';
678
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
679
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
680
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
681
+				if ($highlight != '') {
682 682
 				$timeelapsed = microtime(true);
683 683
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
684
-				    $Spotter = new Spotter($this->db);
685
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
686
-				    $Spotter->db = null;
687
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
684
+					$Spotter = new Spotter($this->db);
685
+					$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
686
+					$Spotter->db = null;
687
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
688 688
 				}
689 689
 				//$putinarchive = true;
690 690
 				//$highlight = '';
691
-			    }
691
+				}
692 692
 			    
693
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
694
-		    //$dataFound = true;
693
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
694
+			//$dataFound = true;
695 695
 		}
696 696
 
697 697
 		if (isset($line['altitude']) && $line['altitude'] != '') {
@@ -702,13 +702,13 @@  discard block
 block discarded – undo
702 702
 					$line['altitude'] = $line['altitude'] - $geoid;
703 703
 				}
704 704
 			}
705
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
705
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
706 706
 			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
707 707
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
708 708
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
709 709
 			//$dataFound = true;
710
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
711
-		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
710
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
711
+			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
712 712
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
713 713
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
714 714
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -717,27 +717,27 @@  discard block
 block discarded – undo
717 717
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
718 718
 				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
719 719
 			}
720
-		    }
721
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
720
+			}
721
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
722 722
 		}
723 723
 
724 724
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
725
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
725
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
726 726
 		}
727 727
 		
728 728
 		if (isset($line['heading']) && $line['heading'] != '') {
729
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
730
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
731
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
732
-		    //$dataFound = true;
729
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
730
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
731
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
732
+			//$dataFound = true;
733 733
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
734
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
735
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
736
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
737
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
734
+  			$heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
735
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
736
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
737
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
738 738
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
739
-  		    // If not enough messages and ACARS set heading to 0
740
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
739
+  			// If not enough messages and ACARS set heading to 0
740
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
741 741
   		}
742 742
 		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
743 743
 		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -750,133 +750,133 @@  discard block
 block discarded – undo
750 750
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
751 751
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
752 752
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
753
-		    $this->all_flights[$id]['lastupdate'] = time();
754
-		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
755
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
756
-			    //print_r($this->all_flights);
757
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
758
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
759
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
753
+			$this->all_flights[$id]['lastupdate'] = time();
754
+			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
755
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
756
+				//print_r($this->all_flights);
757
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
758
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
759
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
760 760
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
761
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
762
-				    $timeelapsed = microtime(true);
763
-				    $SpotterLive = new SpotterLive($this->db);
764
-				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
761
+					if ($globalDebug) echo "Check if aircraft is already in DB...";
762
+					$timeelapsed = microtime(true);
763
+					$SpotterLive = new SpotterLive($this->db);
764
+					if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
765 765
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
766 766
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
767
-				    } elseif (isset($line['id'])) {
767
+					} elseif (isset($line['id'])) {
768 768
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
769 769
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
770
-				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
770
+					} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
771 771
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
772 772
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
773
-				    } else $recent_ident = '';
774
-				    $SpotterLive->db=null;
775
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
776
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
773
+					} else $recent_ident = '';
774
+					$SpotterLive->db=null;
775
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
776
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
777 777
 				} else $recent_ident = '';
778
-			    } else {
778
+				} else {
779 779
 				$recent_ident = '';
780 780
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
781
-			    }
782
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
783
-			    if($recent_ident == "")
784
-			    {
781
+				}
782
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
783
+				if($recent_ident == "")
784
+				{
785 785
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
786 786
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
787 787
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
788 788
 				//adds the spotter data for the archive
789 789
 				$ignoreImport = false;
790 790
 				foreach($globalAirportIgnore as $airportIgnore) {
791
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
791
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
792 792
 					$ignoreImport = true;
793
-				    }
793
+					}
794 794
 				}
795 795
 				if (count($globalAirportAccept) > 0) {
796
-				    $ignoreImport = true;
797
-				    foreach($globalAirportIgnore as $airportIgnore) {
796
+					$ignoreImport = true;
797
+					foreach($globalAirportIgnore as $airportIgnore) {
798 798
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
799
-					    $ignoreImport = false;
799
+						$ignoreImport = false;
800
+					}
800 801
 					}
801
-				    }
802 802
 				}
803 803
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
804
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
804
+					foreach($globalAirlineIgnore as $airlineIgnore) {
805 805
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
806
-					    $ignoreImport = true;
806
+						$ignoreImport = true;
807
+					}
807 808
 					}
808
-				    }
809 809
 				}
810 810
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
811
-				    $ignoreImport = true;
812
-				    foreach($globalAirlineAccept as $airlineAccept) {
811
+					$ignoreImport = true;
812
+					foreach($globalAirlineAccept as $airlineAccept) {
813 813
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
814
-					    $ignoreImport = false;
814
+						$ignoreImport = false;
815
+					}
815 816
 					}
816
-				    }
817 817
 				}
818 818
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
819
-				    $ignoreImport = true;
820
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
819
+					$ignoreImport = true;
820
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
821 821
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
822
-					    $ignoreImport = false;
822
+						$ignoreImport = false;
823
+					}
823 824
 					}
824
-				    }
825 825
 				}
826 826
 				
827 827
 				if (!$ignoreImport) {
828
-				    $highlight = '';
829
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
830
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
831
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
832
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
833
-				    $timeelapsed = microtime(true);
834
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
828
+					$highlight = '';
829
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
830
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
831
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
832
+					if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
833
+					$timeelapsed = microtime(true);
834
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
835 835
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
836
-					    $Spotter = new Spotter($this->db);
837
-					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
838
-					    $Spotter->db = null;
839
-					    if ($globalDebug) {
836
+						$Spotter = new Spotter($this->db);
837
+						$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
838
+						$Spotter->db = null;
839
+						if ($globalDebug) {
840 840
 						if (isset($result['error'])) echo 'Error: '.$result['error']."\n";
841 841
 						else echo 'Success';
842
-					    }
843
-					    if (count($result) > 1) {
844
-					    // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,
842
+						}
843
+						if (count($result) > 1) {
844
+						// ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,
845 845
 						if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao'];
846 846
 						if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration'];
847
-					    }
847
+						}
848 848
 					}
849
-				    }
850
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
851
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
849
+					}
850
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
851
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
852 852
 
853
-				    // Add source stat in DB
854
-				    $Stats = new Stats($this->db);
855
-				    if (!empty($this->stats)) {
853
+					// Add source stat in DB
854
+					$Stats = new Stats($this->db);
855
+					if (!empty($this->stats)) {
856 856
 					if ($globalDebug) echo 'Add source stats : ';
857
-				        foreach($this->stats as $date => $data) {
858
-					    foreach($data as $source => $sourced) {
859
-					        //print_r($sourced);
860
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
861
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
862
-				    		if (isset($sourced['msg'])) {
863
-				    		    if (time() - $sourced['msg']['date'] > 10) {
864
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
865
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
866
-			    			        unset($this->stats[$date][$source]['msg']);
867
-			    			    }
868
-			    			}
869
-			    		    }
870
-			    		    if ($date != date('Y-m-d')) {
871
-			    			unset($this->stats[$date]);
872
-			    		    }
873
-				    	}
874
-				    	if ($globalDebug) echo 'Done'."\n";
857
+						foreach($this->stats as $date => $data) {
858
+						foreach($data as $source => $sourced) {
859
+							//print_r($sourced);
860
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
861
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
862
+							if (isset($sourced['msg'])) {
863
+								if (time() - $sourced['msg']['date'] > 10) {
864
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
865
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
866
+									unset($this->stats[$date][$source]['msg']);
867
+								}
868
+							}
869
+							}
870
+							if ($date != date('Y-m-d')) {
871
+							unset($this->stats[$date]);
872
+							}
873
+						}
874
+						if ($globalDebug) echo 'Done'."\n";
875 875
 
876
-				    }
877
-				    $Stats->db = null;
878
-				    }
879
-				    $this->del();
876
+					}
877
+					$Stats->db = null;
878
+					}
879
+					$this->del();
880 880
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
881 881
 				//$ignoreImport = false;
882 882
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -894,41 +894,41 @@  discard block
 block discarded – undo
894 894
 			*/
895 895
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
896 896
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
897
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
898
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
899
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
897
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
898
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
899
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
900 900
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
901
-					    $SpotterLive = new SpotterLive($this->db);
902
-					    $SpotterLive->deleteLiveSpotterData();
903
-					    $SpotterLive->db=null;
901
+						$SpotterLive = new SpotterLive($this->db);
902
+						$SpotterLive->deleteLiveSpotterData();
903
+						$SpotterLive->db=null;
904 904
 					}
905
-				    }
906
-				    if ($globalDebug) echo " Done\n";
907
-				    $this->last_delete = time();
905
+					}
906
+					if ($globalDebug) echo " Done\n";
907
+					$this->last_delete = time();
908 908
 				}
909
-			    } else {
909
+				} else {
910 910
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
911
-				    $this->all_flights[$id]['id'] = $recent_ident;
912
-				    $this->all_flights[$id]['addedSpotter'] = 1;
911
+					$this->all_flights[$id]['id'] = $recent_ident;
912
+					$this->all_flights[$id]['addedSpotter'] = 1;
913 913
 				}
914 914
 				if (isset($globalDaemon) && !$globalDaemon) {
915
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
915
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
916 916
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
917
-					    $Spotter = new Spotter($this->db);
918
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
919
-					    $Spotter->db = null;
917
+						$Spotter = new Spotter($this->db);
918
+						$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
919
+						$Spotter->db = null;
920
+					}
920 921
 					}
921
-				    }
922 922
 				}
923 923
 				
924
-			    }
924
+				}
925 925
 			}
926
-		    }
927
-		    //adds the spotter LIVE data
928
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
929
-		    //echo "\nAdd in Live !! \n";
930
-		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
931
-		    if ($globalDebug) {
926
+			}
927
+			//adds the spotter LIVE data
928
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
929
+			//echo "\nAdd in Live !! \n";
930
+			//echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
931
+			if ($globalDebug) {
932 932
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
933 933
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
934 934
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
@@ -936,60 +936,60 @@  discard block
 block discarded – undo
936 936
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
937 937
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
938 938
 			}
939
-		    }
940
-		    $ignoreImport = false;
941
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
942
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
939
+			}
940
+			$ignoreImport = false;
941
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
942
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
943 943
 
944
-		    foreach($globalAirportIgnore as $airportIgnore) {
945
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
946
-			    $ignoreImport = true;
944
+			foreach($globalAirportIgnore as $airportIgnore) {
945
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
946
+				$ignoreImport = true;
947
+			}
947 948
 			}
948
-		    }
949
-		    if (count($globalAirportAccept) > 0) {
950
-		        $ignoreImport = true;
951
-		        foreach($globalAirportIgnore as $airportIgnore) {
952
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
949
+			if (count($globalAirportAccept) > 0) {
950
+				$ignoreImport = true;
951
+				foreach($globalAirportIgnore as $airportIgnore) {
952
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
953 953
 				$ignoreImport = false;
954
-			    }
954
+				}
955 955
 			}
956
-		    }
957
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
956
+			}
957
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
958 958
 			foreach($globalAirlineIgnore as $airlineIgnore) {
959
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
959
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
960 960
 				$ignoreImport = true;
961
-			    }
961
+				}
962 962
 			}
963
-		    }
964
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
963
+			}
964
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
965 965
 			$ignoreImport = true;
966 966
 			foreach($globalAirlineAccept as $airlineAccept) {
967
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
967
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
968 968
 				$ignoreImport = false;
969
-			    }
969
+				}
970
+			}
970 971
 			}
971
-		    }
972
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
972
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
973 973
 			$ignoreImport = true;
974 974
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
975
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
976
-			        $ignoreImport = false;
977
-			    }
975
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
976
+					$ignoreImport = false;
977
+				}
978
+			}
978 979
 			}
979
-		    }
980 980
 
981
-		    if (!$ignoreImport) {
981
+			if (!$ignoreImport) {
982 982
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
983 983
 				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
984 984
 				$timeelapsed = microtime(true);
985 985
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
986
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
986
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
987 987
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
988 988
 					$SpotterLive = new SpotterLive($this->db);
989 989
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
990 990
 					$SpotterLive->db = null;
991 991
 					if ($globalDebug) echo $result."\n";
992
-				    }
992
+					}
993 993
 				}
994 994
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
995 995
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
 				//if ($line['format_source'] != 'aprs') {
1002 1002
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
1003 1003
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1004
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
1004
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
1005 1005
 					$source = $this->all_flights[$id]['source_name'];
1006 1006
 					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1007 1007
 					if (!isset($this->source_location[$source])) {
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 					if ($stats_heading == 16) $stats_heading = 0;
1028 1028
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1029 1029
 						for ($i=0;$i<=15;$i++) {
1030
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1030
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
1031 1031
 						}
1032 1032
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
1033 1033
 					} else {
@@ -1040,17 +1040,17 @@  discard block
 block discarded – undo
1040 1040
 					//var_dump($this->stats);
1041 1041
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1042 1042
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1043
-						    end($this->stats[$current_date][$source]['hist']);
1044
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1043
+							end($this->stats[$current_date][$source]['hist']);
1044
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
1045 1045
 						} else $mini = 0;
1046 1046
 						for ($i=$mini;$i<=$distance;$i+=10) {
1047
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1047
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
1048 1048
 						}
1049 1049
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
1050 1050
 					} else {
1051 1051
 						$this->stats[$current_date][$source]['hist'][$distance] += 1;
1052 1052
 					}
1053
-				    }
1053
+					}
1054 1054
 				}
1055 1055
 
1056 1056
 				$this->all_flights[$id]['lastupdate'] = time();
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 			//$this->del();
1061 1061
 			
1062 1062
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1063
-			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1063
+				if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1064 1064
 				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1065 1065
 				$SpotterLive = new SpotterLive($this->db);
1066 1066
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
@@ -1068,19 +1068,19 @@  discard block
 block discarded – undo
1068 1068
 				//SpotterLive->deleteLiveSpotterData();
1069 1069
 				if ($globalDebug) echo " Done\n";
1070 1070
 				$this->last_delete_hourly = time();
1071
-			    } else {
1071
+				} else {
1072 1072
 				$this->del();
1073 1073
 				$this->last_delete_hourly = time();
1074
-			    }
1074
+				}
1075 1075
 			}
1076 1076
 			
1077
-		    }
1078
-		    //$ignoreImport = false;
1077
+			}
1078
+			//$ignoreImport = false;
1079 1079
 		}
1080 1080
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1081 1081
 		if ($send) return $this->all_flights[$id];
1082
-	    }
1082
+		}
1083
+	}
1083 1084
 	}
1084
-    }
1085 1085
 }
1086 1086
 ?>
Please login to merge, or discard this patch.
Spacing   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 		$currentdate = date('Y-m-d');
35 35
 		$sourcestat = $Stats->getStatsSource($currentdate);
36 36
 		if (!empty($sourcestat)) {
37
-		    foreach($sourcestat as $srcst) {
37
+		    foreach ($sourcestat as $srcst) {
38 38
 		    	$type = $srcst['stats_type'];
39 39
 			if ($type == 'polar' || $type == 'hist') {
40 40
 			    $source = $srcst['source_name'];
41 41
 			    $data = $srcst['source_data'];
42
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
42
+			    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
43 43
 	    		}
44 44
 		    }
45 45
 		}
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 	if (isset($globalGeoid) && $globalGeoid) {
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54
-		} catch(Exception $e) {
54
+		} catch (Exception $e) {
55 55
 			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
56 56
 			$GeoidClass = FALSE;
57 57
 		}
58 58
 	}
59 59
     }
60 60
 
61
-    public function get_Schedule($id,$ident) {
61
+    public function get_Schedule($id, $ident) {
62 62
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
63 63
 	// Get schedule here, so it's done only one time
64 64
 	
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 		$schedule = $Schedule->fetchSchedule($operator);
84 84
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85 85
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
86
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
87
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
88 88
 		    // Should also check if route schedule = route from DB
89 89
 		    if ($schedule['DepartureAirportIATA'] != '') {
90 90
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			    }
105 105
 			}
106 106
 		    }
107
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
107
+		    $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']);
108 108
 		}
109 109
 	    } else $scheduleexist = true;
110 110
 	} else $scheduleexist = true;
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
        if ($scheduleexist) {
113 113
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
114 114
     		$sch = $Schedule->getSchedule($operator);
115
-		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
116
-		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
115
+		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time']));
116
+		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'], $sch['departure_airport_icao'], $sch['departure_airport_time'], $sch['arrival_airport_icao'], $sch['arrival_airport_time']);
117 117
        }
118 118
 	$Spotter->db = null;
119 119
 	$Schedule->db = null;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
141 141
     		    $Spotter = new Spotter($this->db);
142 142
         	    $real_arrival = $this->arrival($key);
143
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
143
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
144 144
         	}
145 145
 	    }
146 146
 	}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         $airport_time = '';
155 155
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
156 156
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
157
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
157
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
158 158
     	    if (isset($closestAirports[0])) {
159 159
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
160 160
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         		    break;
170 170
         		}
171 171
         	    }
172
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
172
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
173 173
         		$airport_icao = $closestAirports[0]['icao'];
174 174
         		$airport_time = $this->all_flights[$key]['datetime'];
175 175
         	} else {
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         } else {
183 183
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
184 184
         }
185
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
185
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
186 186
     }
187 187
 
188 188
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	
195 195
 	foreach ($this->all_flights as $key => $flight) {
196 196
 		if (isset($flight['lastupdate'])) {
197
-			if ($flight['lastupdate'] < (time()-1800)) {
197
+			if ($flight['lastupdate'] < (time() - 1800)) {
198 198
 				$this->delKey($key);
199 199
 			}
200 200
 		}
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
 			$Spotter = new Spotter($this->db);
212 212
 			$SpotterLive = new SpotterLive($this->db);
213 213
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
214
-				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
214
+				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
215 215
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
216 216
 				$this->all_flights[$key]['putinarchive'] = true;
217
-				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']);
217
+				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'], $this->all_flights[$key]['route_stop'], $this->all_flights[$key]['hex'], $this->all_flights[$key]['putinarchive'], $this->all_flights[$key]['registration'], $this->all_flights[$key]['pilot_id'], $this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['format_source'], $this->all_flights[$key]['source_name'], $this->all_flights[$key]['over_country']);
218 218
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
219 219
 			}
220 220
 			$Spotter->db = null;
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 	$send = false;
251 251
 	
252 252
 	// SBS format is CSV format
253
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
253
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
254 254
 	    //print_r($line);
255 255
 	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
256
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
256
+  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'], 0, 1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
257 257
 
258 258
 		// Increment message number
259 259
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
@@ -286,25 +286,25 @@  discard block
 block discarded – undo
286 286
 		if (!isset($this->all_flights[$id])) {
287 287
 		    if ($globalDebug) echo 'New flight...'."\n";
288 288
 		    $this->all_flights[$id] = array();
289
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
290
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
291
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
289
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
290
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => ''));
291
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
292 292
 		    if (!isset($line['id'])) {
293 293
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
294 294
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
295 295
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
296
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
296
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
297 297
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
298
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
298
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
299 299
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
300 300
 		}
301 301
 		if (isset($line['source_type']) && $line['source_type'] != '') {
302
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
302
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
303 303
 		}
304 304
 		
305 305
 		//print_r($this->all_flights);
306 306
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
307
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
307
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
308 308
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
309 309
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
310 310
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -313,20 +313,20 @@  discard block
 block discarded – undo
313 313
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
314 314
 			    $Spotter = new Spotter($this->db);
315 315
 			    if (isset($this->all_flights[$id]['source_type'])) {
316
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
316
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
317 317
 			    } else {
318 318
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
319 319
 			    }
320 320
 			    $Spotter->db = null;
321
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
322
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
321
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
322
+			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
323 323
 			}
324 324
 		    }
325 325
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
326 326
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
327 327
 		}
328 328
 	        if (isset($line['id']) && !isset($line['hex'])) {
329
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
329
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => ''));
330 330
 	        }
331 331
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
332 332
 			$icao = $line['aircraft_icao'];
@@ -335,14 +335,14 @@  discard block
 block discarded – undo
335 335
 				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
336 336
 				$Spotter->db = null;
337 337
 			}
338
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
338
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao));
339 339
 		} elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
340 340
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
341 341
 				// Get aircraft ICAO from aircraft name
342 342
 				$Spotter = new Spotter($this->db);
343 343
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
344 344
 				$Spotter->db = null;
345
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
345
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
346 346
 			}
347 347
 		}
348 348
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -350,15 +350,15 @@  discard block
 block discarded – undo
350 350
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
351 351
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
352 352
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
353
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
353
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
354 354
 		}
355 355
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
356
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
356
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
357 357
 		}
358 358
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
359
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
359
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
360 360
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
361
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
361
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
362 362
 		    } else {
363 363
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
364 364
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -369,31 +369,31 @@  discard block
 block discarded – undo
369 369
 				*/
370 370
 				return '';
371 371
 		    }
372
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
372
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
373 373
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
374 374
 			return '';
375
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
375
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
376 376
 			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
377 377
 			return '';
378 378
 		} elseif (!isset($line['datetime'])) {
379 379
 			date_default_timezone_set('UTC');
380
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
380
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
381 381
 		} else {
382 382
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
383 383
 			return '';
384 384
 		}
385 385
 
386 386
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') {
387
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
387
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
388 388
 		}
389 389
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
390
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
390
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
391 391
 		}
392 392
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
393
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
393
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id'])));
394 394
 		}
395 395
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
396
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
396
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name'])));
397 397
 		}
398 398
  
399 399
 		if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
@@ -401,13 +401,13 @@  discard block
 block discarded – undo
401 401
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
402 402
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
403 403
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
404
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
405
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
406
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
407
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
408
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
404
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
405
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
406
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
407
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
408
+				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
409 409
 			} else {
410
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
410
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
411 411
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
412 412
 				$timeelapsed = microtime(true);
413 413
             			$Spotter = new Spotter($this->db);
@@ -417,13 +417,13 @@  discard block
 block discarded – undo
417 417
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
418 418
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
419 419
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
420
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
420
+            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource, $this->all_flights[$id]['source_type']);
421 421
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
422 422
 				$Spotter->db = null;
423
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
423
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
424 424
 			    }
425 425
 			}
426
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
426
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
427 427
 		    
428 428
 /*
429 429
 		    if (!isset($line['id'])) {
@@ -433,25 +433,25 @@  discard block
 block discarded – undo
433 433
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
434 434
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
435 435
   */
436
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
436
+		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
437 437
 
438 438
 		    //$putinarchive = true;
439 439
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
440
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
440
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
441 441
 		    }
442 442
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
443
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
443
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
444 444
 		    }
445 445
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
446
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
446
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
447 447
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
448 448
 			$timeelapsed = microtime(true);
449 449
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
450 450
 				$Spotter = new Spotter($this->db);
451 451
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
452 452
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
453
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
454
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
453
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
454
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
455 455
                         }
456 456
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
457 457
 			$timeelapsed = microtime(true);
@@ -465,35 +465,35 @@  discard block
 block discarded – undo
465 465
 				$Translation->db = null;
466 466
 			    }
467 467
 			    $Spotter->db = null;
468
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
468
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
469 469
                     	}
470 470
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
471 471
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
472 472
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
473 473
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
474
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
474
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop']));
475 475
 		    	    }
476 476
 			}
477 477
 			if (!isset($globalFork)) $globalFork = TRUE;
478 478
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
479
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
479
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
480 480
 			}
481 481
 		    }
482 482
 		}
483 483
 
484 484
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
485 485
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
486
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
487
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
486
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
487
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
488 488
 		    //$dataFound = true;
489 489
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
490
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
490
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
491 491
 		    if ($distance > 1000 && $distance < 10000) {
492 492
 		    // use datetime
493 493
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
494 494
 			$speed = $speed*3.6;
495 495
 			if ($speed < 1000) {
496
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
496
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
497 497
 	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
498 498
 	  		} else {
499 499
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
@@ -508,9 +508,9 @@  discard block
 block discarded – undo
508 508
 	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
509 509
 	    	    	return false;
510 510
 	    	    }
511
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
511
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
512 512
 	    	    else unset($timediff);
513
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
513
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']);
514 514
 	    	    else unset($timediff_archive);
515 515
 	    	    if ($this->tmd > 5
516 516
 	    	        || (isset($line['format_source']) 
@@ -535,14 +535,14 @@  discard block
 block discarded – undo
535 535
 	    	    	|| ($timediff > 30 
536 536
 	    	    	    && isset($this->all_flights[$id]['latitude']) 
537 537
 	    	    	    && isset($this->all_flights[$id]['longitude']) 
538
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
538
+	    	    	    && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'))
539 539
 	    	    	    )
540 540
 	    	    	) {
541 541
 
542 542
 			if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) {
543 543
 			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
544 544
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
545
-				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
545
+				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
546 546
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
547 547
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
548 548
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -552,11 +552,11 @@  discard block
 block discarded – undo
552 552
 				    $timeelapsed = microtime(true);
553 553
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
554 554
 					$Spotter = new Spotter($this->db);
555
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
555
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
556 556
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
557 557
 					else $this->all_flights[$id]['over_country'] = '';
558 558
 					$Spotter->db = null;
559
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
559
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
560 560
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
561 561
 				    }
562 562
 				}
@@ -582,13 +582,13 @@  discard block
 block discarded – undo
582 582
 					$this->all_flights[$id]['time_last_coord'] = time();
583 583
 				}
584 584
 				//if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
585
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
585
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) {
586 586
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
587 587
 				    $dataFound = true;
588 588
 				    $this->all_flights[$id]['time_last_coord'] = time();
589 589
 				}
590 590
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
591
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
591
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
592 592
 				/*
593 593
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
594 594
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -610,13 +610,13 @@  discard block
 block discarded – undo
610 610
 					$this->all_flights[$id]['time_last_coord'] = time();
611 611
 				}
612 612
 				//if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
613
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
613
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) {
614 614
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
615 615
 				    $dataFound = true;
616 616
 				    $this->all_flights[$id]['time_last_coord'] = time();
617 617
 				}
618 618
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
619
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
619
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
620 620
 				/*
621 621
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
622 622
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -634,46 +634,46 @@  discard block
 block discarded – undo
634 634
 		    } else if ($globalDebug && $timediff > 30) {
635 635
 			$this->tmd = $this->tmd + 1;
636 636
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
637
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
638
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
637
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
638
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
639 639
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
640 640
 		    }
641 641
 		}
642 642
 		if (isset($line['last_update']) && $line['last_update'] != '') {
643 643
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
644
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
644
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
645 645
 		}
646 646
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
647
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
647
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
648 648
 		    //$dataFound = true;
649 649
 		}
650 650
 		if (isset($line['format_source']) && $line['format_source'] != '') {
651
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
651
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
652 652
 		}
653 653
 		if (isset($line['source_name']) && $line['source_name'] != '') {
654
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
654
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
655 655
 		}
656 656
 		if (isset($line['emergency']) && $line['emergency'] != '') {
657
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
657
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
658 658
 		    //$dataFound = true;
659 659
 		}
660 660
 		if (isset($line['ground']) && $line['ground'] != '') {
661 661
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
662 662
 			// Here we force archive of flight because after ground it's a new one (or should be)
663
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
664
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
665
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
666
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
667
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
663
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
664
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
665
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
666
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
667
+			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
668 668
 		    }
669 669
 		    if ($line['ground'] != 1) $line['ground'] = 0;
670
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
670
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
671 671
 		    //$dataFound = true;
672 672
 		}
673 673
 		if (isset($line['squawk']) && $line['squawk'] != '') {
674 674
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
675 675
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
676
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
676
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
677 677
 			    $highlight = '';
678 678
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
679 679
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -682,66 +682,66 @@  discard block
 block discarded – undo
682 682
 				$timeelapsed = microtime(true);
683 683
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
684 684
 				    $Spotter = new Spotter($this->db);
685
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
685
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
686 686
 				    $Spotter->db = null;
687
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
687
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
688 688
 				}
689 689
 				//$putinarchive = true;
690 690
 				//$highlight = '';
691 691
 			    }
692 692
 			    
693
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
693
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
694 694
 		    //$dataFound = true;
695 695
 		}
696 696
 
697 697
 		if (isset($line['altitude']) && $line['altitude'] != '') {
698 698
 			if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) {
699 699
 				if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') {
700
-					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2);
700
+					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2);
701 701
 					//if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n";
702 702
 					$line['altitude'] = $line['altitude'] - $geoid;
703 703
 				}
704 704
 			}
705 705
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
706
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
707
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
708
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
706
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
707
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
708
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
709 709
 			//$dataFound = true;
710 710
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
711 711
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
712 712
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
713 713
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
714
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
715
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
716
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
717
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
718
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
714
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
715
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
716
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
717
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
718
+				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
719 719
 			}
720 720
 		    }
721
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
721
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude']));
722 722
 		}
723 723
 
724 724
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
725
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
725
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
726 726
 		}
727 727
 		
728 728
 		if (isset($line['heading']) && $line['heading'] != '') {
729
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
730
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
731
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
729
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
730
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
731
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
732 732
 		    //$dataFound = true;
733 733
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
734
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
735
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
736
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
734
+  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
735
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
736
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
737 737
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
738 738
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
739 739
   		    // If not enough messages and ACARS set heading to 0
740
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
740
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
741 741
   		}
742
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
743
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
744
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
742
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
743
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
744
+		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
745 745
 
746 746
 //		print_r($this->all_flights[$id]);
747 747
 		//gets the callsign from the last hour
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
753 753
 		    $this->all_flights[$id]['lastupdate'] = time();
754 754
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
755
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
755
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
756 756
 			    //print_r($this->all_flights);
757 757
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
758 758
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -763,61 +763,61 @@  discard block
 block discarded – undo
763 763
 				    $SpotterLive = new SpotterLive($this->db);
764 764
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
765 765
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
766
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
766
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
767 767
 				    } elseif (isset($line['id'])) {
768 768
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
769
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
769
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
770 770
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
771 771
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
772
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
772
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
773 773
 				    } else $recent_ident = '';
774
-				    $SpotterLive->db=null;
774
+				    $SpotterLive->db = null;
775 775
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
776 776
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
777 777
 				} else $recent_ident = '';
778 778
 			    } else {
779 779
 				$recent_ident = '';
780
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
780
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
781 781
 			    }
782 782
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
783
-			    if($recent_ident == "")
783
+			    if ($recent_ident == "")
784 784
 			    {
785 785
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
786 786
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
787 787
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
788 788
 				//adds the spotter data for the archive
789 789
 				$ignoreImport = false;
790
-				foreach($globalAirportIgnore as $airportIgnore) {
790
+				foreach ($globalAirportIgnore as $airportIgnore) {
791 791
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
792 792
 					$ignoreImport = true;
793 793
 				    }
794 794
 				}
795 795
 				if (count($globalAirportAccept) > 0) {
796 796
 				    $ignoreImport = true;
797
-				    foreach($globalAirportIgnore as $airportIgnore) {
797
+				    foreach ($globalAirportIgnore as $airportIgnore) {
798 798
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
799 799
 					    $ignoreImport = false;
800 800
 					}
801 801
 				    }
802 802
 				}
803 803
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
804
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
805
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
804
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
805
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
806 806
 					    $ignoreImport = true;
807 807
 					}
808 808
 				    }
809 809
 				}
810 810
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
811 811
 				    $ignoreImport = true;
812
-				    foreach($globalAirlineAccept as $airlineAccept) {
813
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
812
+				    foreach ($globalAirlineAccept as $airlineAccept) {
813
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
814 814
 					    $ignoreImport = false;
815 815
 					}
816 816
 				    }
817 817
 				}
818 818
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
819 819
 				    $ignoreImport = true;
820
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
820
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
821 821
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
822 822
 					    $ignoreImport = false;
823 823
 					}
@@ -829,12 +829,12 @@  discard block
 block discarded – undo
829 829
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
830 830
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
831 831
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
832
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
832
+				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
833 833
 				    $timeelapsed = microtime(true);
834 834
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
835 835
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
836 836
 					    $Spotter = new Spotter($this->db);
837
-					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
837
+					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']);
838 838
 					    $Spotter->db = null;
839 839
 					    if ($globalDebug) {
840 840
 						if (isset($result['error'])) echo 'Error: '.$result['error']."\n";
@@ -847,22 +847,22 @@  discard block
 block discarded – undo
847 847
 					    }
848 848
 					}
849 849
 				    }
850
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
850
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
851 851
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
852 852
 
853 853
 				    // Add source stat in DB
854 854
 				    $Stats = new Stats($this->db);
855 855
 				    if (!empty($this->stats)) {
856 856
 					if ($globalDebug) echo 'Add source stats : ';
857
-				        foreach($this->stats as $date => $data) {
858
-					    foreach($data as $source => $sourced) {
857
+				        foreach ($this->stats as $date => $data) {
858
+					    foreach ($data as $source => $sourced) {
859 859
 					        //print_r($sourced);
860
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
861
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
860
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
861
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
862 862
 				    		if (isset($sourced['msg'])) {
863 863
 				    		    if (time() - $sourced['msg']['date'] > 10) {
864 864
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
865
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
865
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
866 866
 			    			        unset($this->stats[$date][$source]['msg']);
867 867
 			    			    }
868 868
 			    			}
@@ -900,14 +900,14 @@  discard block
 block discarded – undo
900 900
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
901 901
 					    $SpotterLive = new SpotterLive($this->db);
902 902
 					    $SpotterLive->deleteLiveSpotterData();
903
-					    $SpotterLive->db=null;
903
+					    $SpotterLive->db = null;
904 904
 					}
905 905
 				    }
906 906
 				    if ($globalDebug) echo " Done\n";
907 907
 				    $this->last_delete = time();
908 908
 				}
909 909
 			    } else {
910
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
910
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
911 911
 				    $this->all_flights[$id]['id'] = $recent_ident;
912 912
 				    $this->all_flights[$id]['addedSpotter'] = 1;
913 913
 				}
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
916 916
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
917 917
 					    $Spotter = new Spotter($this->db);
918
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
918
+					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
919 919
 					    $Spotter->db = null;
920 920
 					}
921 921
 				    }
@@ -941,37 +941,37 @@  discard block
 block discarded – undo
941 941
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
942 942
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
943 943
 
944
-		    foreach($globalAirportIgnore as $airportIgnore) {
944
+		    foreach ($globalAirportIgnore as $airportIgnore) {
945 945
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
946 946
 			    $ignoreImport = true;
947 947
 			}
948 948
 		    }
949 949
 		    if (count($globalAirportAccept) > 0) {
950 950
 		        $ignoreImport = true;
951
-		        foreach($globalAirportIgnore as $airportIgnore) {
951
+		        foreach ($globalAirportIgnore as $airportIgnore) {
952 952
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
953 953
 				$ignoreImport = false;
954 954
 			    }
955 955
 			}
956 956
 		    }
957 957
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
958
-			foreach($globalAirlineIgnore as $airlineIgnore) {
959
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
958
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
959
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
960 960
 				$ignoreImport = true;
961 961
 			    }
962 962
 			}
963 963
 		    }
964 964
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
965 965
 			$ignoreImport = true;
966
-			foreach($globalAirlineAccept as $airlineAccept) {
967
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
966
+			foreach ($globalAirlineAccept as $airlineAccept) {
967
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
968 968
 				$ignoreImport = false;
969 969
 			    }
970 970
 			}
971 971
 		    }
972 972
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
973 973
 			$ignoreImport = true;
974
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
974
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
975 975
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
976 976
 			        $ignoreImport = false;
977 977
 			    }
@@ -979,23 +979,23 @@  discard block
 block discarded – undo
979 979
 		    }
980 980
 
981 981
 		    if (!$ignoreImport) {
982
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
983
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
982
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
983
+				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
984 984
 				$timeelapsed = microtime(true);
985 985
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
986 986
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
987 987
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
988 988
 					$SpotterLive = new SpotterLive($this->db);
989
-					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
989
+					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
990 990
 					$SpotterLive->db = null;
991 991
 					if ($globalDebug) echo $result."\n";
992 992
 				    }
993 993
 				}
994 994
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
995
-					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
995
+					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
996 996
 				}
997 997
 				$this->all_flights[$id]['putinarchive'] = false;
998
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
998
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
999 999
 
1000 1000
 				// Put statistics in $this->stats variable
1001 1001
 				//if ($line['format_source'] != 'aprs') {
@@ -1014,19 +1014,19 @@  discard block
 block discarded – undo
1014 1014
 							$latitude = $globalCenterLatitude;
1015 1015
 							$longitude = $globalCenterLongitude;
1016 1016
 						}
1017
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
1017
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
1018 1018
 					} else {
1019 1019
 						$latitude = $this->source_location[$source]['latitude'];
1020 1020
 						$longitude = $this->source_location[$source]['longitude'];
1021 1021
 					}
1022
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1022
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1023 1023
 					//$stats_heading = $stats_heading%22.5;
1024 1024
 					$stats_heading = round($stats_heading/22.5);
1025
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1025
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1026 1026
 					$current_date = date('Y-m-d');
1027 1027
 					if ($stats_heading == 16) $stats_heading = 0;
1028 1028
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1029
-						for ($i=0;$i<=15;$i++) {
1029
+						for ($i = 0; $i <= 15; $i++) {
1030 1030
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1031 1031
 						}
1032 1032
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -1041,9 +1041,9 @@  discard block
 block discarded – undo
1041 1041
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1042 1042
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1043 1043
 						    end($this->stats[$current_date][$source]['hist']);
1044
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1044
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
1045 1045
 						} else $mini = 0;
1046
-						for ($i=$mini;$i<=$distance;$i+=10) {
1046
+						for ($i = $mini; $i <= $distance; $i += 10) {
1047 1047
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1048 1048
 						}
1049 1049
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -1056,7 +1056,7 @@  discard block
 block discarded – undo
1056 1056
 				$this->all_flights[$id]['lastupdate'] = time();
1057 1057
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
1058 1058
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1059
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1059
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
1060 1060
 			//$this->del();
1061 1061
 			
1062 1062
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.
Braces   +418 added lines, -149 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54 54
 		} catch(Exception $e) {
55
-			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
55
+			if ($globalDebug) {
56
+				echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
57
+			}
56 58
 			$GeoidClass = FALSE;
57 59
 		}
58 60
 	}
@@ -71,7 +73,9 @@  discard block
 block discarded – undo
71 73
 	$dbc = $this->db;
72 74
 	$this->all_flights[$id]['schedule_check'] = true;
73 75
 	if ($globalSchedulesFetch) {
74
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
76
+	if ($globalDebug) {
77
+		echo 'Getting schedule info...'."\n";
78
+	}
75 79
 	$Spotter = new Spotter($dbc);
76 80
 	$Schedule = new Schedule($dbc);
77 81
 	$Translation = new Translation($dbc);
@@ -82,7 +86,9 @@  discard block
 block discarded – undo
82 86
 	    if ($Schedule->checkSchedule($operator) == 0) {
83 87
 		$schedule = $Schedule->fetchSchedule($operator);
84 88
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
89
+		    if ($globalDebug) {
90
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
91
+		    }
86 92
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87 93
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88 94
 		    // Should also check if route schedule = route from DB
@@ -91,7 +97,9 @@  discard block
 block discarded – undo
91 97
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92 98
 			    if (trim($airport_icao) != '') {
93 99
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
94
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
100
+				if ($globalDebug) {
101
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
102
+				}
95 103
 			    }
96 104
 			}
97 105
 		    }
@@ -100,20 +108,30 @@  discard block
 block discarded – undo
100 108
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101 109
 			    if (trim($airport_icao) != '') {
102 110
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
103
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
111
+				if ($globalDebug) {
112
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
113
+				}
104 114
 			    }
105 115
 			}
106 116
 		    }
107 117
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
108 118
 		}
109
-	    } else $scheduleexist = true;
110
-	} else $scheduleexist = true;
119
+	    } else {
120
+	    	$scheduleexist = true;
121
+	    }
122
+	} else {
123
+		$scheduleexist = true;
124
+	}
111 125
 	// close connection, at least one way will work ?
112 126
        if ($scheduleexist) {
113
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
127
+		if ($globalDebug) {
128
+			echo "-> get arrival/departure airport info for ".$ident."\n";
129
+		}
114 130
     		$sch = $Schedule->getSchedule($operator);
115 131
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
116
-		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
132
+		if ($this->all_flights[$id]['addedSpotter'] == 1) {
133
+			$Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
134
+		}
117 135
        }
118 136
 	$Spotter->db = null;
119 137
 	$Schedule->db = null;
@@ -133,14 +151,18 @@  discard block
 block discarded – undo
133 151
 
134 152
     public function checkAll() {
135 153
 	global $globalDebug, $globalNoImport;
136
-	if ($globalDebug) echo "Update last seen flights data...\n";
154
+	if ($globalDebug) {
155
+		echo "Update last seen flights data...\n";
156
+	}
137 157
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
138 158
 	    foreach ($this->all_flights as $key => $flight) {
139 159
 		if (isset($this->all_flights[$key]['id'])) {
140 160
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
141 161
     		    $Spotter = new Spotter($this->db);
142 162
         	    $real_arrival = $this->arrival($key);
143
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
163
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) {
164
+        	    	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
165
+        	    }
144 166
         	}
145 167
 	    }
146 168
 	}
@@ -148,24 +170,32 @@  discard block
 block discarded – undo
148 170
 
149 171
     public function arrival($key) {
150 172
 	global $globalClosestMinDist, $globalDebug;
151
-	if ($globalDebug) echo 'Update arrival...'."\n";
173
+	if ($globalDebug) {
174
+		echo 'Update arrival...'."\n";
175
+	}
152 176
 	$Spotter = new Spotter($this->db);
153 177
         $airport_icao = '';
154 178
         $airport_time = '';
155
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
179
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
180
+        	$globalClosestMinDist = 50;
181
+        }
156 182
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
157 183
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
158 184
     	    if (isset($closestAirports[0])) {
159 185
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
160 186
         	    $airport_icao = $closestAirports[0]['icao'];
161 187
         	    $airport_time = $this->all_flights[$key]['datetime'];
162
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
188
+        	    if ($globalDebug) {
189
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
190
+        	    }
163 191
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
164 192
         	    foreach ($closestAirports as $airport) {
165 193
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
166 194
         		    $airport_icao = $airport['icao'];
167 195
         		    $airport_time = $this->all_flights[$key]['datetime'];
168
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
196
+        		    if ($globalDebug) {
197
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
198
+        		    }
169 199
         		    break;
170 200
         		}
171 201
         	    }
@@ -173,14 +203,20 @@  discard block
 block discarded – undo
173 203
         		$airport_icao = $closestAirports[0]['icao'];
174 204
         		$airport_time = $this->all_flights[$key]['datetime'];
175 205
         	} else {
176
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
206
+        		if ($globalDebug) {
207
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
208
+        		}
177 209
         	}
178 210
     	    } else {
179
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
211
+    		    if ($globalDebug) {
212
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
213
+    		    }
180 214
     	    }
181 215
 
182 216
         } else {
183
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
217
+        	if ($globalDebug) {
218
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
219
+        	}
184 220
         }
185 221
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
186 222
     }
@@ -190,7 +226,9 @@  discard block
 block discarded – undo
190 226
     public function del() {
191 227
 	global $globalDebug, $globalNoImport, $globalNoDB;
192 228
 	// Delete old infos
193
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
229
+	if ($globalDebug) {
230
+		echo 'Delete old values and update latest data...'."\n";
231
+	}
194 232
 	
195 233
 	foreach ($this->all_flights as $key => $flight) {
196 234
 		if (isset($flight['lastupdate'])) {
@@ -205,22 +243,30 @@  discard block
 block discarded – undo
205 243
 	global $globalDebug, $globalNoImport, $globalNoDB;
206 244
 	// Delete old infos
207 245
 	if (isset($this->all_flights[$key]['id'])) {
208
-		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
246
+		if ($globalDebug) {
247
+			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
248
+		}
209 249
 		if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
210 250
 			$real_arrival = $this->arrival($key);
211 251
 			$Spotter = new Spotter($this->db);
212 252
 			$SpotterLive = new SpotterLive($this->db);
213 253
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
214 254
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
215
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
255
+				if ($globalDebug && $result != 'success') {
256
+					echo '!!! ERROR : '.$result."\n";
257
+				}
216 258
 				$this->all_flights[$key]['putinarchive'] = true;
217 259
 				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']);
218
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
260
+				if ($globalDebug && $result != 'success') {
261
+					echo '!!! ERROR : '.$result."\n";
262
+				}
219 263
 			}
220 264
 			$Spotter->db = null;
221 265
 			$SpotterLive->db = null;
222 266
 		}
223
-		if ($globalDebug) echo "\n";
267
+		if ($globalDebug) {
268
+			echo "\n";
269
+		}
224 270
 	}
225 271
 	unset($this->all_flights[$key]);
226 272
     }
@@ -228,9 +274,13 @@  discard block
 block discarded – undo
228 274
     public function add($line) {
229 275
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive;
230 276
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
231
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
232
-	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000;
233
-/*
277
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
278
+		$globalCoordMinChange = '0.01';
279
+	}
280
+	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') {
281
+		$globalAircraftMaxUpdate = 3000;
282
+	}
283
+	/*
234 284
 	$Spotter = new Spotter();
235 285
 	$dbc = $Spotter->db;
236 286
 	$SpotterLive = new SpotterLive($dbc);
@@ -252,19 +302,28 @@  discard block
 block discarded – undo
252 302
 	// SBS format is CSV format
253 303
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
254 304
 	    //print_r($line);
255
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
305
+	    if (isset($line['hex'])) {
306
+	    	$line['hex'] = strtoupper($line['hex']);
307
+	    }
256 308
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
257 309
 
258 310
 		// Increment message number
259 311
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
260 312
 		    $current_date = date('Y-m-d');
261
-		    if (isset($line['source_name'])) $source = $line['source_name'];
262
-		    else $source = '';
263
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
313
+		    if (isset($line['source_name'])) {
314
+		    	$source = $line['source_name'];
315
+		    } else {
316
+		    	$source = '';
317
+		    }
318
+		    if ($source == '' || $line['format_source'] == 'aprs') {
319
+		    	$source = $line['format_source'];
320
+		    }
264 321
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
265 322
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
266 323
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
267
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
324
+		    } else {
325
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
326
+		    }
268 327
 		}
269 328
 		
270 329
 		/*
@@ -280,23 +339,38 @@  discard block
 block discarded – undo
280 339
 		//$this->db = $dbc;
281 340
 
282 341
 		//$hex = trim($line['hex']);
283
-	        if (!isset($line['id'])) $id = trim($line['hex']);
284
-	        else $id = trim($line['id']);
342
+	        if (!isset($line['id'])) {
343
+	        	$id = trim($line['hex']);
344
+	        } else {
345
+	        	$id = trim($line['id']);
346
+	        }
285 347
 		
286 348
 		if (!isset($this->all_flights[$id])) {
287
-		    if ($globalDebug) echo 'New flight...'."\n";
349
+		    if ($globalDebug) {
350
+		    	echo 'New flight...'."\n";
351
+		    }
288 352
 		    $this->all_flights[$id] = array();
289 353
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
290 354
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
291
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
355
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
356
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
357
+		    }
292 358
 		    if (!isset($line['id'])) {
293
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
294
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
359
+			if (!isset($globalDaemon)) {
360
+				$globalDaemon = TRUE;
361
+			}
362
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
295 363
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
296
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
364
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
365
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
366
+			}
297 367
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
298
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
299
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
368
+		     } else {
369
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
370
+		     }
371
+		    if ($globalAllFlights !== FALSE) {
372
+		    	$dataFound = true;
373
+		    }
300 374
 		}
301 375
 		if (isset($line['source_type']) && $line['source_type'] != '') {
302 376
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -318,12 +392,20 @@  discard block
 block discarded – undo
318 392
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
319 393
 			    }
320 394
 			    $Spotter->db = null;
321
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
322
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
395
+			    if ($globalDebugTimeElapsed) {
396
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
397
+			    }
398
+			    if ($aircraft_icao != '') {
399
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
400
+			    }
323 401
 			}
324 402
 		    }
325
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
326
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
403
+		    if ($globalAllFlights !== FALSE) {
404
+		    	$dataFound = true;
405
+		    }
406
+		    if ($globalDebug) {
407
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
408
+		    }
327 409
 		}
328 410
 	        if (isset($line['id']) && !isset($line['hex'])) {
329 411
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
@@ -332,7 +414,9 @@  discard block
 block discarded – undo
332 414
 			$icao = $line['aircraft_icao'];
333 415
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
334 416
 				$Spotter = new Spotter($this->db);
335
-				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
417
+				if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
418
+					$icao = $Spotter->aircraft_correct_icaotype[$icao];
419
+				}
336 420
 				$Spotter->db = null;
337 421
 			}
338 422
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
@@ -342,15 +426,24 @@  discard block
 block discarded – undo
342 426
 				$Spotter = new Spotter($this->db);
343 427
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
344 428
 				$Spotter->db = null;
345
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
429
+				if ($aircraft_icao != '') {
430
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
431
+				}
346 432
 			}
347 433
 		}
348 434
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
349
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
350
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
351
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
352
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
353
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
435
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
436
+				$aircraft_icao = 'GLID';
437
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
438
+				$aircraft_icao = 'UHEL';
439
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
440
+				$aircraft_icao = 'TOWPLANE';
441
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
442
+				$aircraft_icao = 'POWAIRC';
443
+			}
444
+			if (isset($aircraft_icao)) {
445
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
446
+			}
354 447
 		}
355 448
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
356 449
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -360,8 +453,11 @@  discard block
 block discarded – undo
360 453
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
361 454
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
362 455
 		    } else {
363
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
364
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
456
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
457
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
458
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
459
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
460
+				}
365 461
 				/*
366 462
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
367 463
 				print_r($this->all_flights[$id]);
@@ -370,16 +466,22 @@  discard block
 block discarded – undo
370 466
 				return '';
371 467
 		    }
372 468
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
373
-			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
469
+			if ($globalDebug) {
470
+				echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
471
+			}
374 472
 			return '';
375 473
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
376
-			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
474
+			if ($globalDebug) {
475
+				echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
476
+			}
377 477
 			return '';
378 478
 		} elseif (!isset($line['datetime'])) {
379 479
 			date_default_timezone_set('UTC');
380 480
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
381 481
 		} else {
382
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
482
+			if ($globalDebug) {
483
+				echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
484
+			}
383 485
 			return '';
384 486
 		}
385 487
 
@@ -400,30 +502,48 @@  discard block
 block discarded – undo
400 502
 
401 503
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
402 504
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
403
-				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
505
+				if ($globalDebug) {
506
+					echo '---!!!! New ident, reset aircraft data...'."\n";
507
+				}
404 508
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
405 509
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
406
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
407
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
408
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
510
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
511
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
512
+				} elseif (isset($line['id'])) {
513
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
514
+				} elseif (isset($this->all_flights[$id]['ident'])) {
515
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
516
+				}
409 517
 			} else {
410 518
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
411 519
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
412 520
 				$timeelapsed = microtime(true);
413 521
             			$Spotter = new Spotter($this->db);
414 522
             			$fromsource = NULL;
415
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
416
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
417
-				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
418
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
419
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
523
+            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
524
+            				$fromsource = $globalAirlinesSource;
525
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
526
+            				$fromsource = 'vatsim';
527
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
528
+					$fromsource = 'ivao';
529
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
530
+					$fromsource = 'vatsim';
531
+				} elseif (isset($globalIVAO) && $globalIVAO) {
532
+					$fromsource = 'ivao';
533
+				}
420 534
             			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
421
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
535
+				if ($globalDebug && $result != 'success') {
536
+					echo '!!! ERROR : '.$result."\n";
537
+				}
422 538
 				$Spotter->db = null;
423
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
539
+				if ($globalDebugTimeElapsed) {
540
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
541
+				}
424 542
 			    }
425 543
 			}
426
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
544
+		    } else {
545
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
546
+		    }
427 547
 		    
428 548
 /*
429 549
 		    if (!isset($line['id'])) {
@@ -433,7 +553,9 @@  discard block
 block discarded – undo
433 553
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
434 554
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
435 555
   */
436
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
556
+		    if (!isset($this->all_flights[$id]['id'])) {
557
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
558
+		    }
437 559
 
438 560
 		    //$putinarchive = true;
439 561
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -451,7 +573,9 @@  discard block
 block discarded – undo
451 573
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
452 574
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
453 575
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
454
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
576
+				if ($globalDebugTimeElapsed) {
577
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
578
+				}
455 579
                         }
456 580
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
457 581
 			$timeelapsed = microtime(true);
@@ -465,7 +589,9 @@  discard block
 block discarded – undo
465 589
 				$Translation->db = null;
466 590
 			    }
467 591
 			    $Spotter->db = null;
468
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
592
+			    if ($globalDebugTimeElapsed) {
593
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
594
+			    }
469 595
                     	}
470 596
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
471 597
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -474,9 +600,13 @@  discard block
 block discarded – undo
474 600
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
475 601
 		    	    }
476 602
 			}
477
-			if (!isset($globalFork)) $globalFork = TRUE;
603
+			if (!isset($globalFork)) {
604
+				$globalFork = TRUE;
605
+			}
478 606
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
479
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
607
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
608
+					$this->get_Schedule($id,trim($line['ident']));
609
+				}
480 610
 			}
481 611
 		    }
482 612
 		}
@@ -494,9 +624,13 @@  discard block
 block discarded – undo
494 624
 			$speed = $speed*3.6;
495 625
 			if ($speed < 1000) {
496 626
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
497
-	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
627
+	  			if ($globalDebug) {
628
+	  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
629
+	  			}
498 630
 	  		} else {
499
-	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
631
+	  			if ($globalDebug) {
632
+	  				echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
633
+	  			}
500 634
 	  		}
501 635
 		    }
502 636
 		}
@@ -505,13 +639,21 @@  discard block
 block discarded – undo
505 639
 
506 640
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
507 641
 	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
508
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
642
+	    	    	if ($globalDebug) {
643
+	    	    		echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
644
+	    	    	}
509 645
 	    	    	return false;
510 646
 	    	    }
511
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
512
-	    	    else unset($timediff);
513
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
514
-	    	    else unset($timediff_archive);
647
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
648
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
649
+	    	    } else {
650
+	    	    	unset($timediff);
651
+	    	    }
652
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) {
653
+	    	    	$timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
654
+	    	    } else {
655
+	    	    	unset($timediff_archive);
656
+	    	    }
515 657
 	    	    if ($this->tmd > 5
516 658
 	    	        || (isset($line['format_source']) 
517 659
 	    	    	    && $line['format_source'] == 'airwhere' 
@@ -548,16 +690,25 @@  discard block
 block discarded – undo
548 690
 				$this->all_flights[$id]['putinarchive'] = true;
549 691
 				$this->tmd = 0;
550 692
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
551
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
693
+				    if ($globalDebug) {
694
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
695
+				    }
552 696
 				    $timeelapsed = microtime(true);
553 697
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
554 698
 					$Spotter = new Spotter($this->db);
555 699
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
556
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
557
-					else $this->all_flights[$id]['over_country'] = '';
700
+					if (!empty($all_country)) {
701
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
702
+					} else {
703
+						$this->all_flights[$id]['over_country'] = '';
704
+					}
558 705
 					$Spotter->db = null;
559
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
560
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
706
+					if ($globalDebugTimeElapsed) {
707
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
708
+					}
709
+					if ($globalDebug) {
710
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
711
+					}
561 712
 				    }
562 713
 				}
563 714
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
@@ -603,7 +754,9 @@  discard block
 block discarded – undo
603 754
 			    */
604 755
 			}
605 756
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
606
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
757
+			    if ($line['longitude'] > 180) {
758
+			    	$line['longitude'] = $line['longitude'] - 360;
759
+			    }
607 760
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
608 761
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
609 762
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -640,7 +793,9 @@  discard block
 block discarded – undo
640 793
 		    }
641 794
 		}
642 795
 		if (isset($line['last_update']) && $line['last_update'] != '') {
643
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
796
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
797
+		    	$dataFound = true;
798
+		    }
644 799
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
645 800
 		}
646 801
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -662,35 +817,53 @@  discard block
 block discarded – undo
662 817
 			// Here we force archive of flight because after ground it's a new one (or should be)
663 818
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
664 819
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
665
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
666
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
667
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
820
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
821
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
822
+			} elseif (isset($line['id'])) {
823
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
824
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
825
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
826
+			}
827
+		    }
828
+		    if ($line['ground'] != 1) {
829
+		    	$line['ground'] = 0;
668 830
 		    }
669
-		    if ($line['ground'] != 1) $line['ground'] = 0;
670 831
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
671 832
 		    //$dataFound = true;
672 833
 		}
673 834
 		if (isset($line['squawk']) && $line['squawk'] != '') {
674 835
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
675
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
836
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
837
+			    	$this->all_flights[$id]['putinarchive'] = true;
838
+			    }
676 839
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
677 840
 			    $highlight = '';
678
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
679
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
680
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
841
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
842
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
843
+			    }
844
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
845
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
846
+			    }
847
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
848
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
849
+			    }
681 850
 			    if ($highlight != '') {
682 851
 				$timeelapsed = microtime(true);
683 852
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
684 853
 				    $Spotter = new Spotter($this->db);
685 854
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
686 855
 				    $Spotter->db = null;
687
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
856
+				    if ($globalDebugTimeElapsed) {
857
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
858
+				    }
688 859
 				}
689 860
 				//$putinarchive = true;
690 861
 				//$highlight = '';
691 862
 			    }
692 863
 			    
693
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
864
+		    } else {
865
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
866
+		    }
694 867
 		    //$dataFound = true;
695 868
 		}
696 869
 
@@ -703,19 +876,27 @@  discard block
 block discarded – undo
703 876
 				}
704 877
 			}
705 878
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
706
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
879
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
880
+				$this->all_flights[$id]['putinarchive'] = true;
881
+			}
707 882
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
708 883
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
709 884
 			//$dataFound = true;
710 885
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
711 886
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
712 887
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
713
-				if ($globalDebug) echo '--- Reset because of altitude'."\n";
888
+				if ($globalDebug) {
889
+					echo '--- Reset because of altitude'."\n";
890
+				}
714 891
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
715 892
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
716
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
717
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
718
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
893
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
894
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
895
+				} elseif (isset($line['id'])) {
896
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
897
+				} elseif (isset($this->all_flights[$id]['ident'])) {
898
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
899
+				}
719 900
 			}
720 901
 		    }
721 902
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
@@ -726,22 +907,32 @@  discard block
 block discarded – undo
726 907
 		}
727 908
 		
728 909
 		if (isset($line['heading']) && $line['heading'] != '') {
729
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
910
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
911
+		    	$this->all_flights[$id]['putinarchive'] = true;
912
+		    }
730 913
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
731 914
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
732 915
 		    //$dataFound = true;
733 916
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
734 917
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
735 918
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
736
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
737
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
919
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
920
+		    	$this->all_flights[$id]['putinarchive'] = true;
921
+		    }
922
+  		    if ($globalDebug) {
923
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
924
+  		    }
738 925
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
739 926
   		    // If not enough messages and ACARS set heading to 0
740 927
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
741 928
   		}
742
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
743
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
744
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
929
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
930
+			$dataFound = false;
931
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
932
+			$dataFound = false;
933
+		} elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) {
934
+			$dataFound = false;
935
+		}
745 936
 
746 937
 //		print_r($this->all_flights[$id]);
747 938
 		//gets the callsign from the last hour
@@ -758,23 +949,38 @@  discard block
 block discarded – undo
758 949
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
759 950
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
760 951
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
761
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
952
+				    if ($globalDebug) {
953
+				    	echo "Check if aircraft is already in DB...";
954
+				    }
762 955
 				    $timeelapsed = microtime(true);
763 956
 				    $SpotterLive = new SpotterLive($this->db);
764 957
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
765 958
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
766
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
959
+					if ($globalDebugTimeElapsed) {
960
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
961
+					}
767 962
 				    } elseif (isset($line['id'])) {
768 963
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
769
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
964
+					if ($globalDebugTimeElapsed) {
965
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
966
+					}
770 967
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
771 968
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
772
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
773
-				    } else $recent_ident = '';
969
+					if ($globalDebugTimeElapsed) {
970
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
971
+					}
972
+				    } else {
973
+				    	$recent_ident = '';
974
+				    }
774 975
 				    $SpotterLive->db=null;
775
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
776
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
777
-				} else $recent_ident = '';
976
+				    if ($globalDebug && $recent_ident == '') {
977
+				    	echo " Not in DB.\n";
978
+				    } elseif ($globalDebug && $recent_ident != '') {
979
+				    	echo " Already in DB.\n";
980
+				    }
981
+				} else {
982
+					$recent_ident = '';
983
+				}
778 984
 			    } else {
779 985
 				$recent_ident = '';
780 986
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -782,7 +988,9 @@  discard block
 block discarded – undo
782 988
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
783 989
 			    if($recent_ident == "")
784 990
 			    {
785
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
991
+				if ($globalDebug) {
992
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
993
+				}
786 994
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
787 995
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
788 996
 				//adds the spotter data for the archive
@@ -826,10 +1034,18 @@  discard block
 block discarded – undo
826 1034
 				
827 1035
 				if (!$ignoreImport) {
828 1036
 				    $highlight = '';
829
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
830
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
831
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
832
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1037
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
1038
+				    	$highlight = 'Squawk 7500 : Hijack';
1039
+				    }
1040
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
1041
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
1042
+				    }
1043
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
1044
+				    	$highlight = 'Squawk 7700 : Emergency';
1045
+				    }
1046
+				    if (!isset($this->all_flights[$id]['id'])) {
1047
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1048
+				    }
833 1049
 				    $timeelapsed = microtime(true);
834 1050
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
835 1051
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -837,28 +1053,43 @@  discard block
 block discarded – undo
837 1053
 					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
838 1054
 					    $Spotter->db = null;
839 1055
 					    if ($globalDebug) {
840
-						if (isset($result['error'])) echo 'Error: '.$result['error']."\n";
841
-						else echo 'Success';
1056
+						if (isset($result['error'])) {
1057
+							echo 'Error: '.$result['error']."\n";
1058
+						} else {
1059
+							echo 'Success';
1060
+						}
842 1061
 					    }
843 1062
 					    if (count($result) > 1) {
844 1063
 					    // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,
845
-						if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao'];
846
-						if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration'];
1064
+						if ($this->all_flights[$id]['aircraft_icao'] == '') {
1065
+							$this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao'];
1066
+						}
1067
+						if ($this->all_flights[$id]['registration'] == '') {
1068
+							$this->all_flights[$id]['registration'] = $result[':registration'];
1069
+						}
847 1070
 					    }
848 1071
 					}
849 1072
 				    }
850
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1073
+				    if ($globalDebugTimeElapsed) {
1074
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1075
+				    }
851 1076
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
852 1077
 
853 1078
 				    // Add source stat in DB
854 1079
 				    $Stats = new Stats($this->db);
855 1080
 				    if (!empty($this->stats)) {
856
-					if ($globalDebug) echo 'Add source stats : ';
1081
+					if ($globalDebug) {
1082
+						echo 'Add source stats : ';
1083
+					}
857 1084
 				        foreach($this->stats as $date => $data) {
858 1085
 					    foreach($data as $source => $sourced) {
859 1086
 					        //print_r($sourced);
860
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
861
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1087
+				    	        if (isset($sourced['polar'])) {
1088
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
1089
+				    	        }
1090
+				    	        if (isset($sourced['hist'])) {
1091
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1092
+				    	        }
862 1093
 				    		if (isset($sourced['msg'])) {
863 1094
 				    		    if (time() - $sourced['msg']['date'] > 10) {
864 1095
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -871,13 +1102,17 @@  discard block
 block discarded – undo
871 1102
 			    			unset($this->stats[$date]);
872 1103
 			    		    }
873 1104
 				    	}
874
-				    	if ($globalDebug) echo 'Done'."\n";
1105
+				    	if ($globalDebug) {
1106
+				    		echo 'Done'."\n";
1107
+				    	}
875 1108
 
876 1109
 				    }
877 1110
 				    $Stats->db = null;
878 1111
 				    }
879 1112
 				    $this->del();
880
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
1113
+				} elseif ($globalDebug) {
1114
+					echo 'Ignore data'."\n";
1115
+				}
881 1116
 				//$ignoreImport = false;
882 1117
 				$this->all_flights[$id]['addedSpotter'] = 1;
883 1118
 				//print_r($this->all_flights[$id]);
@@ -894,7 +1129,9 @@  discard block
 block discarded – undo
894 1129
 			*/
895 1130
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
896 1131
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
897
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
1132
+				    if ($globalDebug) {
1133
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
1134
+				    }
898 1135
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
899 1136
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
900 1137
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -903,7 +1140,9 @@  discard block
 block discarded – undo
903 1140
 					    $SpotterLive->db=null;
904 1141
 					}
905 1142
 				    }
906
-				    if ($globalDebug) echo " Done\n";
1143
+				    if ($globalDebug) {
1144
+				    	echo " Done\n";
1145
+				    }
907 1146
 				    $this->last_delete = time();
908 1147
 				}
909 1148
 			    } else {
@@ -930,11 +1169,17 @@  discard block
 block discarded – undo
930 1169
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
931 1170
 		    if ($globalDebug) {
932 1171
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
933
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
934
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1172
+				if (isset($this->all_flights[$id]['source_name'])) {
1173
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
1174
+				} else {
1175
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1176
+				}
935 1177
 			} else {
936
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
937
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1178
+				if (isset($this->all_flights[$id]['source_name'])) {
1179
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
1180
+				} else {
1181
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1182
+				}
938 1183
 			}
939 1184
 		    }
940 1185
 		    $ignoreImport = false;
@@ -980,22 +1225,30 @@  discard block
 block discarded – undo
980 1225
 
981 1226
 		    if (!$ignoreImport) {
982 1227
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
983
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1228
+				if (!isset($this->all_flights[$id]['id'])) {
1229
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1230
+				}
984 1231
 				$timeelapsed = microtime(true);
985 1232
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
986 1233
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
987
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1234
+					if ($globalDebug) {
1235
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1236
+					}
988 1237
 					$SpotterLive = new SpotterLive($this->db);
989 1238
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
990 1239
 					$SpotterLive->db = null;
991
-					if ($globalDebug) echo $result."\n";
1240
+					if ($globalDebug) {
1241
+						echo $result."\n";
1242
+					}
992 1243
 				    }
993 1244
 				}
994 1245
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
995 1246
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
996 1247
 				}
997 1248
 				$this->all_flights[$id]['putinarchive'] = false;
998
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1249
+				if ($globalDebugTimeElapsed) {
1250
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1251
+				}
999 1252
 
1000 1253
 				// Put statistics in $this->stats variable
1001 1254
 				//if ($line['format_source'] != 'aprs') {
@@ -1003,7 +1256,9 @@  discard block
 block discarded – undo
1003 1256
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1004 1257
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
1005 1258
 					$source = $this->all_flights[$id]['source_name'];
1006
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1259
+					if ($source == '') {
1260
+						$source = $this->all_flights[$id]['format_source'];
1261
+					}
1007 1262
 					if (!isset($this->source_location[$source])) {
1008 1263
 						$Location = new Source($this->db);
1009 1264
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -1024,7 +1279,9 @@  discard block
 block discarded – undo
1024 1279
 					$stats_heading = round($stats_heading/22.5);
1025 1280
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1026 1281
 					$current_date = date('Y-m-d');
1027
-					if ($stats_heading == 16) $stats_heading = 0;
1282
+					if ($stats_heading == 16) {
1283
+						$stats_heading = 0;
1284
+					}
1028 1285
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1029 1286
 						for ($i=0;$i<=15;$i++) {
1030 1287
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -1042,7 +1299,9 @@  discard block
 block discarded – undo
1042 1299
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1043 1300
 						    end($this->stats[$current_date][$source]['hist']);
1044 1301
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1045
-						} else $mini = 0;
1302
+						} else {
1303
+							$mini = 0;
1304
+						}
1046 1305
 						for ($i=$mini;$i<=$distance;$i+=10) {
1047 1306
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1048 1307
 						}
@@ -1054,19 +1313,27 @@  discard block
 block discarded – undo
1054 1313
 				}
1055 1314
 
1056 1315
 				$this->all_flights[$id]['lastupdate'] = time();
1057
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1316
+				if ($this->all_flights[$id]['putinarchive']) {
1317
+					$send = true;
1318
+				}
1058 1319
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1059
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1320
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1321
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1322
+			}
1060 1323
 			//$this->del();
1061 1324
 			
1062 1325
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1063 1326
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1064
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1327
+				if ($globalDebug) {
1328
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1329
+				}
1065 1330
 				$SpotterLive = new SpotterLive($this->db);
1066 1331
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
1067 1332
 				$SpotterLive->db = null;
1068 1333
 				//SpotterLive->deleteLiveSpotterData();
1069
-				if ($globalDebug) echo " Done\n";
1334
+				if ($globalDebug) {
1335
+					echo " Done\n";
1336
+				}
1070 1337
 				$this->last_delete_hourly = time();
1071 1338
 			    } else {
1072 1339
 				$this->del();
@@ -1078,7 +1345,9 @@  discard block
 block discarded – undo
1078 1345
 		    //$ignoreImport = false;
1079 1346
 		}
1080 1347
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1081
-		if ($send) return $this->all_flights[$id];
1348
+		if ($send) {
1349
+			return $this->all_flights[$id];
1350
+		}
1082 1351
 	    }
1083 1352
 	}
1084 1353
     }
Please login to merge, or discard this patch.