Completed
Push — master ( 873309...5e8324 )
by Yannick
06:25
created
require/class.Common.php 4 patches
Doc Comments   +12 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,6 +90,10 @@  discard block
 block discarded – undo
90 90
 		return strlen($headerLine); // Needed by curl
91 91
 	}
92 92
 
93
+	/**
94
+	 * @param string $url
95
+	 * @param string $file
96
+	 */
93 97
 	public static function download($url, $file, $referer = '') {
94 98
 		global $globalDebug;
95 99
 		$fp = fopen($file, 'w');
@@ -190,7 +194,7 @@  discard block
 block discarded – undo
190 194
 	* Check is distance realistic
191 195
 	* @param int $timeDifference the time between the reception of both messages
192 196
 	* @param float $distance distance covered
193
-	* @return whether distance is realistic
197
+	* @return boolean distance is realistic
194 198
 	*/
195 199
 	public function withinThreshold ($timeDifference, $distance) {
196 200
 		$x = abs($timeDifference);
@@ -213,6 +217,9 @@  discard block
 block discarded – undo
213 217
 	}
214 218
 
215 219
 
220
+	/**
221
+	 * @param string $latlong
222
+	 */
216 223
 	public function convertDec($dms,$latlong) {
217 224
 		if ($latlong == 'latitude') {
218 225
 			$deg = substr($dms, 0, 2);
@@ -224,6 +231,9 @@  discard block
 block discarded – undo
224 231
 		return $deg+(($min*60)/3600);
225 232
 	}
226 233
 	
234
+	/**
235
+	 * @param string $latlong
236
+	 */
227 237
 	public function convertDM($coord,$latlong) {
228 238
 		if ($latlong == 'latitude') {
229 239
 			if ($coord < 0) $NSEW = 'S';
@@ -352,7 +362,7 @@  discard block
 block discarded – undo
352 362
 	/**
353 363
 	* Returns list of available locales
354 364
 	*
355
-	* @return array
365
+	* @return string[]
356 366
 	 */
357 367
 	public function listLocaleDir()
358 368
 	{
Please login to merge, or discard this patch.
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
 	//protected $cookies = array();
8 8
 	
9 9
 	/**
10
-	* Get data from form result
11
-	* @param String $url form URL
12
-	* @param String $type type of submit form method (get or post)
13
-	* @param String|Array $data values form post method
14
-	* @param Array $headers header to submit with the form
15
-	* @return String the result
16
-	*/
10
+	 * Get data from form result
11
+	 * @param String $url form URL
12
+	 * @param String $type type of submit form method (get or post)
13
+	 * @param String|Array $data values form post method
14
+	 * @param Array $headers header to submit with the form
15
+	 * @return String the result
16
+	 */
17 17
 	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
 	}
108 108
 	
109 109
 	/**
110
-	* Convert a HTML table to an array
111
-	* @param String $data HTML page
112
-	* @return Array array of the tables in HTML page
113
-	*/
110
+	 * Convert a HTML table to an array
111
+	 * @param String $data HTML page
112
+	 * @return Array array of the tables in HTML page
113
+	 */
114 114
 	public function table2array($data) {
115 115
 		if (!is_string($data)) return array();
116 116
 		if ($data == '') return array();
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 	}
145 145
 	
146 146
 	/**
147
-	* Convert <p> part of a HTML page to an array
148
-	* @param String $data HTML page
149
-	* @return Array array of the <p> in HTML page
150
-	*/
147
+	 * Convert <p> part of a HTML page to an array
148
+	 * @param String $data HTML page
149
+	 * @return Array array of the <p> in HTML page
150
+	 */
151 151
 	public function text2array($data) {
152 152
 		$html = str_get_html($data);
153 153
 		if ($html === false) return array();
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
 	}
163 163
 
164 164
 	/**
165
-	* Give distance between 2 coordonnates
166
-	* @param Float $lat latitude of first point
167
-	* @param Float $lon longitude of first point
168
-	* @param Float $latc latitude of second point
169
-	* @param Float $lonc longitude of second point
170
-	* @param String $unit km else no unit used
171
-	* @return Float Distance in $unit
172
-	*/
165
+	 * Give distance between 2 coordonnates
166
+	 * @param Float $lat latitude of first point
167
+	 * @param Float $lon longitude of first point
168
+	 * @param Float $latc latitude of second point
169
+	 * @param Float $lonc longitude of second point
170
+	 * @param String $unit km else no unit used
171
+	 * @return Float Distance in $unit
172
+	 */
173 173
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
174 174
 		if ($lat == $latc && $lon == $lonc) return 0;
175 175
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
 	}
188 188
 
189 189
 	/**
190
-	* Check is distance realistic
191
-	* @param int $timeDifference the time between the reception of both messages
192
-	* @param float $distance distance covered
193
-	* @return whether distance is realistic
194
-	*/
190
+	 * Check is distance realistic
191
+	 * @param int $timeDifference the time between the reception of both messages
192
+	 * @param float $distance distance covered
193
+	 * @return whether distance is realistic
194
+	 */
195 195
 	public function withinThreshold ($timeDifference, $distance) {
196 196
 		$x = abs($timeDifference);
197 197
 		$d = abs($distance);
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	}
210 210
 
211 211
 	public function isInteger($input){
212
-	    return(ctype_digit(strval($input)));
212
+		return(ctype_digit(strval($input)));
213 213
 	}
214 214
 
215 215
 
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
 	}
241 241
 	
242 242
 	/**
243
-	* Copy folder contents
244
-	* @param       string   $source    Source path
245
-	* @param       string   $dest      Destination path
246
-	* @return      bool     Returns true on success, false on failure
247
-	*/
243
+	 * Copy folder contents
244
+	 * @param       string   $source    Source path
245
+	 * @param       string   $dest      Destination path
246
+	 * @return      bool     Returns true on success, false on failure
247
+	 */
248 248
 	public function xcopy($source, $dest)
249 249
 	{
250 250
 		$files = glob($source.'*.*');
@@ -256,20 +256,20 @@  discard block
 block discarded – undo
256 256
 	}
257 257
 	
258 258
 	/**
259
-	* Check if an url exist
260
-	* @param	String $url url to check
261
-	* @return	bool Return true on succes false on failure
262
-	*/
259
+	 * Check if an url exist
260
+	 * @param	String $url url to check
261
+	 * @return	bool Return true on succes false on failure
262
+	 */
263 263
 	public function urlexist($url){
264 264
 		$headers=get_headers($url);
265 265
 		return stripos($headers[0],"200 OK")?true:false;
266 266
 	}
267 267
 	
268 268
 	/**
269
-	* Convert hexa to string
270
-	* @param	String $hex data in hexa
271
-	* @return	String Return result
272
-	*/
269
+	 * Convert hexa to string
270
+	 * @param	String $hex data in hexa
271
+	 * @return	String Return result
272
+	 */
273 273
 	public function hex2str($hex) {
274 274
 		$str = '';
275 275
 		$hexln = strlen($hex);
@@ -350,9 +350,9 @@  discard block
 block discarded – undo
350 350
 	}
351 351
 	
352 352
 	/**
353
-	* Returns list of available locales
354
-	*
355
-	* @return array
353
+	 * Returns list of available locales
354
+	 *
355
+	 * @return array
356 356
 	 */
357 357
 	public function listLocaleDir()
358 358
 	{
@@ -447,100 +447,100 @@  discard block
 block discarded – undo
447 447
 	public function remove_accents($string) {
448 448
 		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
449 449
 		$chars = array(
450
-		    // Decompositions for Latin-1 Supplement
451
-		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
452
-		    chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
453
-		    chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
454
-		    chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
455
-		    chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
456
-		    chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
457
-		    chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
458
-		    chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
459
-		    chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
460
-		    chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
461
-		    chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
462
-		    chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
463
-		    chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
464
-		    chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
465
-		    chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
466
-		    chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
467
-		    chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
468
-		    chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
469
-		    chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
470
-		    chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
471
-		    chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
472
-		    chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
473
-		    chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
474
-		    chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
475
-		    chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
476
-		    chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
477
-		    chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
478
-		    chr(195).chr(191) => 'y',
479
-		    // Decompositions for Latin Extended-A
480
-		    chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
481
-		    chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
482
-		    chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
483
-		    chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
484
-		    chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
485
-		    chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
486
-		    chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
487
-		    chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
488
-		    chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
489
-		    chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
490
-		    chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
491
-		    chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
492
-		    chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
493
-		    chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
494
-		    chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
495
-		    chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
496
-		    chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
497
-		    chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
498
-		    chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
499
-		    chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
500
-		    chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
501
-		    chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
502
-		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
503
-		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
504
-		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
505
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
506
-		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
507
-		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
508
-		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
509
-		    chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
510
-		    chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
511
-		    chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
512
-		    chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
513
-		    chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
514
-		    chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
515
-		    chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
516
-		    chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
517
-		    chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
518
-		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
519
-		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
520
-		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
521
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
522
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
523
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
524
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
525
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
526
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
527
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
528
-		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
529
-		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
530
-		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
531
-		    chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
532
-		    chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
533
-		    chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
534
-		    chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
535
-		    chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
536
-		    chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
537
-		    chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
538
-		    chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
539
-		    chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
540
-		    chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
541
-		    chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
542
-		    chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
543
-		    chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
450
+			// Decompositions for Latin-1 Supplement
451
+			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
452
+			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
453
+			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
454
+			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
455
+			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
456
+			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
457
+			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
458
+			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
459
+			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
460
+			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
461
+			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
462
+			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
463
+			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
464
+			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
465
+			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
466
+			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
467
+			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
468
+			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
469
+			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
470
+			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
471
+			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
472
+			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
473
+			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
474
+			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
475
+			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
476
+			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
477
+			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
478
+			chr(195).chr(191) => 'y',
479
+			// Decompositions for Latin Extended-A
480
+			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
481
+			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
482
+			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
483
+			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
484
+			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
485
+			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
486
+			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
487
+			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
488
+			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
489
+			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
490
+			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
491
+			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
492
+			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
493
+			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
494
+			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
495
+			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
496
+			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
497
+			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
498
+			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
499
+			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
500
+			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
501
+			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
502
+			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
503
+			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
504
+			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
505
+			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
506
+			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
507
+			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
508
+			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
509
+			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
510
+			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
511
+			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
512
+			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
513
+			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
514
+			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
515
+			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
516
+			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
517
+			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
518
+			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
519
+			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
520
+			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
521
+			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
522
+			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
523
+			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
524
+			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
525
+			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
526
+			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
527
+			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
528
+			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
529
+			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
530
+			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
531
+			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
532
+			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
533
+			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
534
+			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
535
+			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
536
+			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
537
+			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
538
+			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
539
+			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
540
+			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
541
+			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
542
+			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
543
+			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
544 544
 		);
545 545
 		$string = strtr($string, $chars);
546 546
 		return $string;
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 	* @param Array $headers header to submit with the form
15 15
 	* @return String the result
16 16
 	*/
17
-	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') {
17
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '') {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
20 20
 		curl_setopt($ch, CURLOPT_URL, $url);
21 21
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
22
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
22
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
23 23
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
24 24
 			}
25 25
 		}
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
30 30
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
31 31
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
32
-		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
32
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
33 33
 		//curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
34 34
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
35 35
 		if ($useragent == '') {
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41 41
 		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
42
-		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
42
+		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback"));
43 43
 		if ($type == 'post') {
44 44
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
45 45
 			if (is_array($data)) {
46 46
 				curl_setopt($ch, CURLOPT_POST, count($data));
47 47
 				$data_string = '';
48
-				foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
48
+				foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
49 49
 				rtrim($data_string, '&');
50 50
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
51 51
 			} else {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		}
58 58
 		if ($cookie != '') {
59 59
 			if (is_array($cookie)) {
60
-				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';'));
60
+				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';'));
61 61
 			} else {
62 62
 				curl_setopt($ch, CURLOPT_COOKIE, $cookie);
63 63
 			}
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 		$info = curl_getinfo($ch);
70 70
 		//var_dump($info);
71 71
 		curl_close($ch);
72
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
72
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
73 73
 			echo "Cloudflare Detected\n";
74 74
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
75 75
 			$useragent = UAgent::random();
76 76
 			cloudflare::useUserAgent($useragent);
77 77
 			if ($clearanceCookie = cloudflare::bypass($url)) {
78
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
78
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
79 79
 			}
80 80
 		} else {
81 81
 			return $result;
@@ -116,27 +116,27 @@  discard block
 block discarded – undo
116 116
 		if ($data == '') return array();
117 117
 		$html = str_get_html($data);
118 118
 		if ($html === false) return array();
119
-		$tabledata=array();
120
-		foreach($html->find('tr') as $element)
119
+		$tabledata = array();
120
+		foreach ($html->find('tr') as $element)
121 121
 		{
122 122
 			$td = array();
123
-			foreach( $element->find('th') as $row)
123
+			foreach ($element->find('th') as $row)
124 124
 			{
125 125
 				$td [] = trim($row->plaintext);
126 126
 			}
127
-			$td=array_filter($td);
127
+			$td = array_filter($td);
128 128
 			$tabledata[] = $td;
129 129
 
130 130
 			$td = array();
131 131
 			$tdi = array();
132
-			foreach( $element->find('td') as $row)
132
+			foreach ($element->find('td') as $row)
133 133
 			{
134 134
 				$td [] = trim($row->plaintext);
135 135
 				$tdi [] = trim($row->innertext);
136 136
 			}
137
-			$td=array_filter($td);
138
-			$tdi=array_filter($tdi);
139
-			$tabledata[]=array_merge($td,$tdi);
137
+			$td = array_filter($td);
138
+			$tdi = array_filter($tdi);
139
+			$tabledata[] = array_merge($td, $tdi);
140 140
 		}
141 141
 		$html->clear();
142 142
 		unset($html);
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
 	public function text2array($data) {
152 152
 		$html = str_get_html($data);
153 153
 		if ($html === false) return array();
154
-		$tabledata=array();
155
-		foreach($html->find('p') as $element)
154
+		$tabledata = array();
155
+		foreach ($html->find('p') as $element)
156 156
 		{
157 157
 			$tabledata [] = trim($element->plaintext);
158 158
 		}
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 	*/
173 173
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
174 174
 		if ($lat == $latc && $lon == $lonc) return 0;
175
-		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
175
+		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515;
176 176
 		if ($unit == "km") {
177
-			return round($dist * 1.609344);
177
+			return round($dist*1.609344);
178 178
 		} elseif ($unit == "m") {
179
-			return round($dist * 1.609344 * 1000);
179
+			return round($dist*1.609344*1000);
180 180
 		} elseif ($unit == "mile" || $unit == "mi") {
181 181
 			return round($dist);
182 182
 		} elseif ($unit == "nm") {
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	* @param float $distance distance covered
193 193
 	* @return whether distance is realistic
194 194
 	*/
195
-	public function withinThreshold ($timeDifference, $distance) {
195
+	public function withinThreshold($timeDifference, $distance) {
196 196
 		$x = abs($timeDifference);
197 197
 		$d = abs($distance);
198 198
 		if ($x == 0 || $d == 0) return true;
@@ -208,12 +208,12 @@  discard block
 block discarded – undo
208 208
 		return ($array !== array_values($array));
209 209
 	}
210 210
 
211
-	public function isInteger($input){
211
+	public function isInteger($input) {
212 212
 	    return(ctype_digit(strval($input)));
213 213
 	}
214 214
 
215 215
 
216
-	public function convertDec($dms,$latlong) {
216
+	public function convertDec($dms, $latlong) {
217 217
 		if ($latlong == 'latitude') {
218 218
 			$deg = substr($dms, 0, 2);
219 219
 			$min = substr($dms, 2, 4);
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 			$deg = substr($dms, 0, 3);
222 222
 			$min = substr($dms, 3, 5);
223 223
 		}
224
-		return $deg+(($min*60)/3600);
224
+		return $deg + (($min*60)/3600);
225 225
 	}
226 226
 	
227
-	public function convertDM($coord,$latlong) {
227
+	public function convertDM($coord, $latlong) {
228 228
 		if ($latlong == 'latitude') {
229 229
 			if ($coord < 0) $NSEW = 'S';
230 230
 			else $NSEW = 'N';
@@ -234,9 +234,9 @@  discard block
 block discarded – undo
234 234
 		}
235 235
 		$coord = abs($coord);
236 236
 		$deg = floor($coord);
237
-		$coord = ($coord-$deg)*60;
237
+		$coord = ($coord - $deg)*60;
238 238
 		$min = $coord;
239
-		return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW);
239
+		return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW);
240 240
 	}
241 241
 	
242 242
 	/**
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	public function xcopy($source, $dest)
249 249
 	{
250 250
 		$files = glob($source.'*.*');
251
-		foreach($files as $file){
252
-			$file_to_go = str_replace($source,$dest,$file);
251
+		foreach ($files as $file) {
252
+			$file_to_go = str_replace($source, $dest, $file);
253 253
 			copy($file, $file_to_go);
254 254
 		}
255 255
 		return true;
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 	* @param	String $url url to check
261 261
 	* @return	bool Return true on succes false on failure
262 262
 	*/
263
-	public function urlexist($url){
264
-		$headers=get_headers($url);
265
-		return stripos($headers[0],"200 OK")?true:false;
263
+	public function urlexist($url) {
264
+		$headers = get_headers($url);
265
+		return stripos($headers[0], "200 OK") ? true : false;
266 266
 	}
267 267
 	
268 268
 	/**
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	public function hex2str($hex) {
274 274
 		$str = '';
275 275
 		$hexln = strlen($hex);
276
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
276
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
277 277
 		return $str;
278 278
 	}
279 279
 	
@@ -282,33 +282,33 @@  discard block
 block discarded – undo
282 282
 		//difference in longitudinal coordinates
283 283
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
284 284
 		//difference in the phi of latitudinal coordinates
285
-		$dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4));
285
+		$dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4));
286 286
 		//we need to recalculate $dLon if it is greater than pi
287
-		if(abs($dLon) > pi()) {
288
-			if($dLon > 0) {
289
-				$dLon = (2 * pi() - $dLon) * -1;
287
+		if (abs($dLon) > pi()) {
288
+			if ($dLon > 0) {
289
+				$dLon = (2*pi() - $dLon)*-1;
290 290
 			} else {
291
-				$dLon = 2 * pi() + $dLon;
291
+				$dLon = 2*pi() + $dLon;
292 292
 			}
293 293
 		}
294 294
 		//return the angle, normalized
295
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
295
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
296 296
 	}
297 297
 	
298
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.2) {
298
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.2) {
299 299
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
300
-		$a = -($lon2-$lon1);
300
+		$a = -($lon2 - $lon1);
301 301
 		$b = $lat2 - $lat1;
302
-		$c = -($a*$lat1+$b*$lon1);
303
-		$d = $a*$lat3+$b*$lon3+$c;
302
+		$c = -($a*$lat1 + $b*$lon1);
303
+		$d = $a*$lat3 + $b*$lon3 + $c;
304 304
 		if ($d > -$approx && $d < $approx) return true;
305 305
 		else return false;
306 306
 	}
307 307
 	
308 308
 	public function array_merge_noappend() {
309 309
 		$output = array();
310
-		foreach(func_get_args() as $array) {
311
-			foreach($array as $key => $value) {
310
+		foreach (func_get_args() as $array) {
311
+			foreach ($array as $key => $value) {
312 312
 				$output[$key] = isset($output[$key]) ?
313 313
 				array_merge($output[$key], $value) : $value;
314 314
 			}
@@ -372,34 +372,34 @@  discard block
 block discarded – undo
372 372
 		return $result;
373 373
 	}
374 374
 
375
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){
375
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1) {
376 376
 		global $globalMapRefresh;
377 377
 		$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
378 378
 		$r = 6378;
379 379
 		$latitude = deg2rad($latitude);
380 380
 		$longitude = deg2rad($longitude);
381 381
 		$bearing = deg2rad($heading); 
382
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
383
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
384
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
382
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
383
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
384
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
385 385
 	}
386 386
 	
387
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
387
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
388 388
 		// distance in meter
389 389
 		$R = 6378.14;
390
-		$latitude1 = $latitude * (M_PI/180);
391
-		$longitude1 = $longitude * (M_PI/180);
392
-		$brng = $bearing * (M_PI/180);
390
+		$latitude1 = $latitude*(M_PI/180);
391
+		$longitude1 = $longitude*(M_PI/180);
392
+		$brng = $bearing*(M_PI/180);
393 393
 		$d = $distance;
394 394
 
395 395
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
396
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
396
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
397 397
 
398
-		$latitude2 = $latitude2 * (180/M_PI);
399
-		$longitude2 = $longitude2 * (180/M_PI);
398
+		$latitude2 = $latitude2*(180/M_PI);
399
+		$longitude2 = $longitude2*(180/M_PI);
400 400
 
401
-		$flat = round ($latitude2,6);
402
-		$flong = round ($longitude2,6);
401
+		$flat = round($latitude2, 6);
402
+		$flong = round($longitude2, 6);
403 403
 /*
404 404
 		$dx = $distance*cos($bearing);
405 405
 		$dy = $distance*sin($bearing);
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 		$flong = $longitude + $dlong;
409 409
 		$flat = $latitude + $dlat;
410 410
 */
411
-		return array('latitude' => $flat,'longitude' => $flong);
411
+		return array('latitude' => $flat, 'longitude' => $flong);
412 412
 	}
413 413
 
414 414
 	/**
@@ -422,14 +422,14 @@  discard block
 block discarded – undo
422 422
 	 * @param integer $level GZIP compression level (default: 9)
423 423
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
424 424
 	 */
425
-	public function gzCompressFile($source, $level = 9){ 
426
-		$dest = $source . '.gz'; 
427
-		$mode = 'wb' . $level; 
425
+	public function gzCompressFile($source, $level = 9) { 
426
+		$dest = $source.'.gz'; 
427
+		$mode = 'wb'.$level; 
428 428
 		$error = false; 
429 429
 		if ($fp_out = gzopen($dest, $mode)) { 
430
-			if ($fp_in = fopen($source,'rb')) { 
430
+			if ($fp_in = fopen($source, 'rb')) { 
431 431
 				while (!feof($fp_in)) 
432
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
432
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
433 433
 				fclose($fp_in); 
434 434
 			} else {
435 435
 				$error = true; 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 	} 
446 446
 	
447 447
 	public function remove_accents($string) {
448
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
448
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
449 449
 		$chars = array(
450 450
 		    // Decompositions for Latin-1 Supplement
451 451
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
503 503
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
504 504
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
505
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
505
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
506 506
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
507 507
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
508 508
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -518,13 +518,13 @@  discard block
 block discarded – undo
518 518
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
519 519
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
520 520
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
521
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
522
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
523
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
524
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
525
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
526
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
527
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
521
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
522
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
523
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
524
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
525
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
526
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
527
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
528 528
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
529 529
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
530 530
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
559 559
 			if (is_numeric($string[$i]) && $concat_flag) {
560 560
 				$int .= $string[$i];
561
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
561
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
562 562
 				$concat_flag = false;
563 563
 			}
564 564
 		}
Please login to merge, or discard this patch.
Braces   +73 added lines, -30 removed lines patch added patch discarded remove patch
@@ -37,8 +37,11 @@  discard block
 block discarded – undo
37 37
 		} else {
38 38
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
39 39
 		}
40
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
40
+		if ($timeout == '') {
41
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
42
+		} else {
43
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
44
+		}
42 45
 		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
43 46
 		if ($type == 'post') {
44 47
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -85,8 +88,9 @@  discard block
 block discarded – undo
85 88
 	private function curlResponseHeaderCallback($ch, $headerLine) {
86 89
 		//global $cookies;
87 90
 		$cookies = array();
88
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
89
-			$cookies[] = $cookie;
91
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
92
+					$cookies[] = $cookie;
93
+		}
90 94
 		return strlen($headerLine); // Needed by curl
91 95
 	}
92 96
 
@@ -97,11 +101,15 @@  discard block
 block discarded – undo
97 101
 		curl_setopt($ch, CURLOPT_URL, $url);
98 102
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
99 103
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
100
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
104
+		if ($referer != '') {
105
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
106
+		}
101 107
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
102 108
 		curl_setopt($ch, CURLOPT_FILE, $fp);
103 109
 		curl_exec($ch);
104
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
110
+		if (curl_errno($ch) && $globalDebug) {
111
+			echo 'Download error: '.curl_error($ch);
112
+		}
105 113
 		curl_close($ch);
106 114
 		fclose($fp);
107 115
 	}
@@ -112,10 +120,16 @@  discard block
 block discarded – undo
112 120
 	* @return Array array of the tables in HTML page
113 121
 	*/
114 122
 	public function table2array($data) {
115
-		if (!is_string($data)) return array();
116
-		if ($data == '') return array();
123
+		if (!is_string($data)) {
124
+			return array();
125
+		}
126
+		if ($data == '') {
127
+			return array();
128
+		}
117 129
 		$html = str_get_html($data);
118
-		if ($html === false) return array();
130
+		if ($html === false) {
131
+			return array();
132
+		}
119 133
 		$tabledata=array();
120 134
 		foreach($html->find('tr') as $element)
121 135
 		{
@@ -150,7 +164,9 @@  discard block
 block discarded – undo
150 164
 	*/
151 165
 	public function text2array($data) {
152 166
 		$html = str_get_html($data);
153
-		if ($html === false) return array();
167
+		if ($html === false) {
168
+			return array();
169
+		}
154 170
 		$tabledata=array();
155 171
 		foreach($html->find('p') as $element)
156 172
 		{
@@ -171,7 +187,9 @@  discard block
 block discarded – undo
171 187
 	* @return Float Distance in $unit
172 188
 	*/
173 189
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
174
-		if ($lat == $latc && $lon == $lonc) return 0;
190
+		if ($lat == $latc && $lon == $lonc) {
191
+			return 0;
192
+		}
175 193
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
176 194
 		if ($unit == "km") {
177 195
 			return round($dist * 1.609344);
@@ -195,10 +213,16 @@  discard block
 block discarded – undo
195 213
 	public function withinThreshold ($timeDifference, $distance) {
196 214
 		$x = abs($timeDifference);
197 215
 		$d = abs($distance);
198
-		if ($x == 0 || $d == 0) return true;
216
+		if ($x == 0 || $d == 0) {
217
+			return true;
218
+		}
199 219
 		// may be due to Internet jitter; distance is realistic
200
-		if ($x < 0.7 && $d < 2000) return true;
201
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
220
+		if ($x < 0.7 && $d < 2000) {
221
+			return true;
222
+		} else {
223
+			return $d/$x < 1500*0.27778;
224
+		}
225
+		// 1500 km/h max
202 226
 	}
203 227
 
204 228
 
@@ -226,11 +250,17 @@  discard block
 block discarded – undo
226 250
 	
227 251
 	public function convertDM($coord,$latlong) {
228 252
 		if ($latlong == 'latitude') {
229
-			if ($coord < 0) $NSEW = 'S';
230
-			else $NSEW = 'N';
253
+			if ($coord < 0) {
254
+				$NSEW = 'S';
255
+			} else {
256
+				$NSEW = 'N';
257
+			}
231 258
 		} elseif ($latlong == 'longitude') {
232
-			if ($coord < 0) $NSEW = 'W';
233
-			else $NSEW = 'E';
259
+			if ($coord < 0) {
260
+				$NSEW = 'W';
261
+			} else {
262
+				$NSEW = 'E';
263
+			}
234 264
 		}
235 265
 		$coord = abs($coord);
236 266
 		$deg = floor($coord);
@@ -273,7 +303,9 @@  discard block
 block discarded – undo
273 303
 	public function hex2str($hex) {
274 304
 		$str = '';
275 305
 		$hexln = strlen($hex);
276
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
306
+		for($i=0;$i<$hexln;$i+=2) {
307
+			$str .= chr(hexdec(substr($hex,$i,2)));
308
+		}
277 309
 		return $str;
278 310
 	}
279 311
 	
@@ -301,8 +333,11 @@  discard block
 block discarded – undo
301 333
 		$b = $lat2 - $lat1;
302 334
 		$c = -($a*$lat1+$b*$lon1);
303 335
 		$d = $a*$lat3+$b*$lon3+$c;
304
-		if ($d > -$approx && $d < $approx) return true;
305
-		else return false;
336
+		if ($d > -$approx && $d < $approx) {
337
+			return true;
338
+		} else {
339
+			return false;
340
+		}
306 341
 	}
307 342
 	
308 343
 	public function array_merge_noappend() {
@@ -361,7 +396,9 @@  discard block
 block discarded – undo
361 396
 			return $result;
362 397
 		}
363 398
 		$handle = @opendir('./locale');
364
-		if ($handle === false) return $result;
399
+		if ($handle === false) {
400
+			return $result;
401
+		}
365 402
 		while (false !== ($file = readdir($handle))) {
366 403
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
367 404
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -428,8 +465,9 @@  discard block
 block discarded – undo
428 465
 		$error = false; 
429 466
 		if ($fp_out = gzopen($dest, $mode)) { 
430 467
 			if ($fp_in = fopen($source,'rb')) { 
431
-				while (!feof($fp_in)) 
432
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
468
+				while (!feof($fp_in)) {
469
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
470
+				}
433 471
 				fclose($fp_in); 
434 472
 			} else {
435 473
 				$error = true; 
@@ -438,14 +476,17 @@  discard block
 block discarded – undo
438 476
 		} else {
439 477
 			$error = true; 
440 478
 		}
441
-		if ($error)
442
-			return false; 
443
-		else
444
-			return $dest; 
479
+		if ($error) {
480
+					return false;
481
+		} else {
482
+					return $dest;
483
+		}
445 484
 	} 
446 485
 	
447 486
 	public function remove_accents($string) {
448
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
487
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
488
+			return $string;
489
+		}
449 490
 		$chars = array(
450 491
 		    // Decompositions for Latin-1 Supplement
451 492
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -569,7 +610,9 @@  discard block
 block discarded – undo
569 610
 		$ip = gethostbyname($host);
570 611
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
571 612
 		$r = @socket_connect($s, $ip, $port);
572
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
613
+		if (!socket_set_nonblock($s)) {
614
+			echo "Unable to set nonblock on socket\n";
615
+		}
573 616
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
574 617
 			return $s;
575 618
 		}
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
@@ -46,6 +46,10 @@
 block discarded – undo
46 46
 
47 47
     }
48 48
 
49
+    /**
50
+     * @param string $id
51
+     * @param string $ident
52
+     */
49 53
     public function get_Schedule($id,$ident) {
50 54
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
51 55
 	// Get schedule here, so it's done only one time
Please login to merge, or discard this patch.
Indentation   +402 added lines, -402 removed lines patch added patch discarded remove patch
@@ -8,20 +8,20 @@  discard block
 block discarded – undo
8 8
 require_once(dirname(__FILE__).'/class.Stats.php');
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 if (isset($globalServerAPRS) && $globalServerAPRS) {
11
-    require_once(dirname(__FILE__).'/class.APRS.php');
11
+	require_once(dirname(__FILE__).'/class.APRS.php');
12 12
 }
13 13
 
14 14
 class SpotterImport {
15
-    private $all_flights = array();
16
-    private $last_delete_hourly = 0;
17
-    private $last_delete = 0;
18
-    private $stats = array();
19
-    private $tmd = 0;
20
-    private $source_location = array();
21
-    public $db = null;
22
-    public $nb = 0;
23
-
24
-    public function __construct($dbc = null) {
15
+	private $all_flights = array();
16
+	private $last_delete_hourly = 0;
17
+	private $last_delete = 0;
18
+	private $stats = array();
19
+	private $tmd = 0;
20
+	private $source_location = array();
21
+	public $db = null;
22
+	public $nb = 0;
23
+
24
+	public function __construct($dbc = null) {
25 25
 	global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB;
26 26
 	if (!(isset($globalNoDB) && $globalNoDB)) {
27 27
 		$Connection = new Connection($dbc);
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 		$currentdate = date('Y-m-d');
34 34
 		$sourcestat = $Stats->getStatsSource($currentdate);
35 35
 		if (!empty($sourcestat)) {
36
-		    foreach($sourcestat as $srcst) {
37
-		    	$type = $srcst['stats_type'];
36
+			foreach($sourcestat as $srcst) {
37
+				$type = $srcst['stats_type'];
38 38
 			if ($type == 'polar' || $type == 'hist') {
39
-			    $source = $srcst['source_name'];
40
-			    $data = $srcst['source_data'];
41
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
42
-	    		}
43
-		    }
39
+				$source = $srcst['source_name'];
40
+				$data = $srcst['source_data'];
41
+				$this->stats[$currentdate][$source][$type] = json_decode($data,true);
42
+				}
43
+			}
44 44
 		}
45 45
 	}
46 46
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 		//$APRSSpotter->connect();
49 49
 	}
50 50
 
51
-    }
51
+	}
52 52
 
53
-    public function get_Schedule($id,$ident) {
53
+	public function get_Schedule($id,$ident) {
54 54
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
55 55
 	// Get schedule here, so it's done only one time
56 56
 	
@@ -70,42 +70,42 @@  discard block
 block discarded – undo
70 70
 	$operator = $Spotter->getOperator($ident);
71 71
 	$scheduleexist = false;
72 72
 	if ($Schedule->checkSchedule($operator) == 0) {
73
-	    $operator = $Translation->checkTranslation($ident);
74
-	    if ($Schedule->checkSchedule($operator) == 0) {
73
+		$operator = $Translation->checkTranslation($ident);
74
+		if ($Schedule->checkSchedule($operator) == 0) {
75 75
 		$schedule = $Schedule->fetchSchedule($operator);
76 76
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
78
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80
-		    // Should also check if route schedule = route from DB
81
-		    if ($schedule['DepartureAirportIATA'] != '') {
77
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
78
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80
+			// Should also check if route schedule = route from DB
81
+			if ($schedule['DepartureAirportIATA'] != '') {
82 82
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
83
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84
-			    if (trim($airport_icao) != '') {
83
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84
+				if (trim($airport_icao) != '') {
85 85
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
86 86
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
87
-			    }
87
+				}
88
+			}
88 89
 			}
89
-		    }
90
-		    if ($schedule['ArrivalAirportIATA'] != '') {
90
+			if ($schedule['ArrivalAirportIATA'] != '') {
91 91
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
92
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93
-			    if (trim($airport_icao) != '') {
92
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93
+				if (trim($airport_icao) != '') {
94 94
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
95 95
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
96
-			    }
96
+				}
97 97
 			}
98
-		    }
99
-		    $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']);
98
+			}
99
+			$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']);
100 100
 		}
101
-	    } else $scheduleexist = true;
101
+		} else $scheduleexist = true;
102 102
 	} else $scheduleexist = true;
103 103
 	// close connection, at least one way will work ?
104
-       if ($scheduleexist) {
104
+	   if ($scheduleexist) {
105 105
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
106
-    		$sch = $Schedule->getSchedule($operator);
106
+			$sch = $Schedule->getSchedule($operator);
107 107
 		$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']));
108
-       }
108
+	   }
109 109
 	$Spotter->db = null;
110 110
 	$Schedule->db = null;
111 111
 	$Translation->db = null;
@@ -120,96 +120,96 @@  discard block
 block discarded – undo
120 120
 	}
121 121
 	  */
122 122
 	}
123
-    }
123
+	}
124 124
 
125
-    public function checkAll() {
125
+	public function checkAll() {
126 126
 	global $globalDebug, $globalNoImport;
127 127
 	if ($globalDebug) echo "Update last seen flights data...\n";
128 128
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
129
-	    foreach ($this->all_flights as $key => $flight) {
129
+		foreach ($this->all_flights as $key => $flight) {
130 130
 		if (isset($this->all_flights[$key]['id'])) {
131
-		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132
-    		    $Spotter = new Spotter($this->db);
133
-        	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $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']);
135
-        	}
136
-	    }
131
+			//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132
+				$Spotter = new Spotter($this->db);
133
+				$real_arrival = $this->arrival($key);
134
+				if (isset($this->all_flights[$key]['altitude'])) $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']);
135
+			}
136
+		}
137
+	}
137 138
 	}
138
-    }
139 139
 
140
-    public function arrival($key) {
140
+	public function arrival($key) {
141 141
 	global $globalClosestMinDist, $globalDebug;
142 142
 	if ($globalDebug) echo 'Update arrival...'."\n";
143 143
 	$Spotter = new Spotter($this->db);
144
-        $airport_icao = '';
145
-        $airport_time = '';
146
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
144
+		$airport_icao = '';
145
+		$airport_time = '';
146
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
147 147
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149
-    	    if (isset($closestAirports[0])) {
150
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151
-        	    $airport_icao = $closestAirports[0]['icao'];
152
-        	    $airport_time = $this->all_flights[$key]['datetime'];
153
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
154
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155
-        	    foreach ($closestAirports as $airport) {
156
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157
-        		    $airport_icao = $airport['icao'];
158
-        		    $airport_time = $this->all_flights[$key]['datetime'];
159
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
160
-        		    break;
161
-        		}
162
-        	    }
163
-        	} 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))) {
164
-        		$airport_icao = $closestAirports[0]['icao'];
165
-        		$airport_time = $this->all_flights[$key]['datetime'];
166
-        	} else {
167
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
168
-        	}
169
-    	    } else {
170
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
171
-    	    }
172
-
173
-        } else {
174
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
175
-        }
176
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177
-    }
178
-
179
-
180
-
181
-    public function del() {
148
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149
+			if (isset($closestAirports[0])) {
150
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151
+				$airport_icao = $closestAirports[0]['icao'];
152
+				$airport_time = $this->all_flights[$key]['datetime'];
153
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
154
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155
+				foreach ($closestAirports as $airport) {
156
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157
+					$airport_icao = $airport['icao'];
158
+					$airport_time = $this->all_flights[$key]['datetime'];
159
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
160
+					break;
161
+				}
162
+				}
163
+			} 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))) {
164
+				$airport_icao = $closestAirports[0]['icao'];
165
+				$airport_time = $this->all_flights[$key]['datetime'];
166
+			} else {
167
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
168
+			}
169
+			} else {
170
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
171
+			}
172
+
173
+		} else {
174
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
175
+		}
176
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177
+	}
178
+
179
+
180
+
181
+	public function del() {
182 182
 	global $globalDebug, $globalNoImport, $globalNoDB;
183 183
 	// Delete old infos
184 184
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
185 185
 	foreach ($this->all_flights as $key => $flight) {
186
-    	    if (isset($flight['lastupdate'])) {
187
-        	if ($flight['lastupdate'] < (time()-3000)) {
188
-            	    if (isset($this->all_flights[$key]['id'])) {
189
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
186
+			if (isset($flight['lastupdate'])) {
187
+			if ($flight['lastupdate'] < (time()-3000)) {
188
+					if (isset($this->all_flights[$key]['id'])) {
189
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
190 190
 			/*
191 191
 			$SpotterLive = new SpotterLive();
192 192
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
193 193
 			$SpotterLive->db = null;
194 194
 			*/
195 195
 			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
196
-            		    $real_arrival = $this->arrival($key);
197
-            		    $Spotter = new Spotter($this->db);
198
-            	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
196
+						$real_arrival = $this->arrival($key);
197
+						$Spotter = new Spotter($this->db);
198
+							if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
199 199
 				$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']);
200 200
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
201
-			    }
201
+				}
202 202
 			// Put in archive
203 203
 //				$Spotter->db = null;
204 204
 			}
205
-            	    }
206
-            	    unset($this->all_flights[$key]);
207
-    	        }
208
-	    }
209
-        }
210
-    }
205
+					}
206
+					unset($this->all_flights[$key]);
207
+				}
208
+		}
209
+		}
210
+	}
211 211
 
212
-    public function add($line) {
212
+	public function add($line) {
213 213
 	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;
214 214
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
215 215
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
@@ -234,18 +234,18 @@  discard block
 block discarded – undo
234 234
 	
235 235
 	// SBS format is CSV format
236 236
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
237
-	    //print_r($line);
238
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
237
+		//print_r($line);
238
+  		if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
239 239
 
240 240
 		// Increment message number
241 241
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
242
-		    $current_date = date('Y-m-d');
243
-		    $source = $line['source_name'];
244
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
245
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
246
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
247
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
248
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
242
+			$current_date = date('Y-m-d');
243
+			$source = $line['source_name'];
244
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
245
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
246
+				$this->stats[$current_date][$source]['msg']['date'] = time();
247
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
248
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
249 249
 		}
250 250
 		
251 251
 		/*
@@ -261,49 +261,49 @@  discard block
 block discarded – undo
261 261
 		//$this->db = $dbc;
262 262
 
263 263
 		//$hex = trim($line['hex']);
264
-	        if (!isset($line['id'])) $id = trim($line['hex']);
265
-	        else $id = trim($line['id']);
264
+			if (!isset($line['id'])) $id = trim($line['hex']);
265
+			else $id = trim($line['id']);
266 266
 		
267 267
 		if (!isset($this->all_flights[$id])) {
268
-		    $this->all_flights[$id] = array();
269
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
271
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
272
-		    if (!isset($line['id'])) {
268
+			$this->all_flights[$id] = array();
269
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
271
+			if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
272
+			if (!isset($line['id'])) {
273 273
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
274 274
 //			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')));
275 275
 //			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')));
276 276
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
277
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
279
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
277
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
279
+			if ($globalAllFlights !== FALSE) $dataFound = true;
280 280
 		}
281 281
 		if (isset($line['source_type']) && $line['source_type'] != '') {
282
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
282
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
283 283
 		}
284 284
 		
285 285
 		//print_r($this->all_flights);
286 286
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
287
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
288
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
287
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
288
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
289 289
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
290
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
291
-		    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') {
290
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
291
+			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') {
292 292
 			$timeelapsed = microtime(true);
293 293
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
294
-			    $Spotter = new Spotter($this->db);
295
-			    if (isset($this->all_flights[$id]['source_type'])) {
294
+				$Spotter = new Spotter($this->db);
295
+				if (isset($this->all_flights[$id]['source_type'])) {
296 296
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
297
-			    } else {
297
+				} else {
298 298
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
299
-			    }
300
-			    $Spotter->db = null;
301
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
299
+				}
300
+				$Spotter->db = null;
301
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
303 303
 			}
304
-		    }
305
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
306
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
304
+			}
305
+			if ($globalAllFlights !== FALSE) $dataFound = true;
306
+			if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
307 307
 		}
308 308
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
309 309
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
@@ -329,9 +329,9 @@  discard block
 block discarded – undo
329 329
 		}
330 330
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
331 331
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) {
332
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
332
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
333 333
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
334
-		    } else {
334
+			} else {
335 335
 				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";
336 336
 				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";
337 337
 				/*
@@ -340,43 +340,43 @@  discard block
 block discarded – undo
340 340
 				print_r($line);
341 341
 				*/
342 342
 				return '';
343
-		    }
343
+			}
344 344
 		} else {
345 345
 			date_default_timezone_set('UTC');
346 346
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
347 347
 		}
348 348
 
349 349
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
350
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
350
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
351 351
 		}
352 352
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
353
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
353
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
354 354
 		}
355 355
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
356
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
356
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
357 357
 		}
358 358
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
359
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
359
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
360 360
 		}
361 361
  
362 362
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
363
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
364
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
363
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
364
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
365 365
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
366
-			    $timeelapsed = microtime(true);
367
-            		    $Spotter = new Spotter($this->db);
368
-            		    $fromsource = NULL;
369
-            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
370
-            		    elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
371
-			    elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
372
-			    elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
373
-			    elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
374
-            		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
375
-			    if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
376
-			    $Spotter->db = null;
377
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
378
-			}
379
-		    }
366
+				$timeelapsed = microtime(true);
367
+						$Spotter = new Spotter($this->db);
368
+						$fromsource = NULL;
369
+						if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
370
+						elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
371
+				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
372
+				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
373
+				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
374
+						$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
375
+				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
376
+				$Spotter->db = null;
377
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
378
+			}
379
+			}
380 380
 
381 381
 /*
382 382
 		    if (!isset($line['id'])) {
@@ -386,104 +386,104 @@  discard block
 block discarded – undo
386 386
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
387 387
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
388 388
   */
389
-		    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']));
389
+			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']));
390 390
 
391
-		    //$putinarchive = true;
392
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
391
+			//$putinarchive = true;
392
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
393 393
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
394
-		    }
395
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
394
+			}
395
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
396 396
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
397
-		    }
398
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
399
-		    		$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' => ''));
400
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
397
+			}
398
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
399
+					$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' => ''));
400
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
401 401
 			$timeelapsed = microtime(true);
402 402
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
403 403
 				$Spotter = new Spotter($this->db);
404 404
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
405 405
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
406
-		    		$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' => ''));
406
+					$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' => ''));
407 407
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
408
-                        }
409
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
408
+						}
409
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
410 410
 			$timeelapsed = microtime(true);
411 411
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
412
-			    $Spotter = new Spotter($this->db);
413
-			    $route = $Spotter->getRouteInfo(trim($line['ident']));
414
-			    if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
412
+				$Spotter = new Spotter($this->db);
413
+				$route = $Spotter->getRouteInfo(trim($line['ident']));
414
+				if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
415 415
 				$Translation = new Translation($this->db);
416 416
 				$ident = $Translation->checkTranslation(trim($line['ident']));
417 417
 				$route = $Spotter->getRouteInfo($ident);
418 418
 				$Translation->db = null;
419
-			    }
420
-			    $Spotter->db = null;
421
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
422
-                    	}
419
+				}
420
+				$Spotter->db = null;
421
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
422
+						}
423 423
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
424
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
425
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
424
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
425
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
426 426
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
427
-		    		$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']));
428
-		    	    }
427
+					$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']));
428
+					}
429 429
 			}
430 430
 			if (!isset($globalFork)) $globalFork = TRUE;
431 431
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
432 432
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
433 433
 			}
434
-		    }
434
+			}
435 435
 		}
436 436
 
437 437
 		if (isset($line['speed']) && $line['speed'] != '') {
438 438
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
439
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
440
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
441
-		    //$dataFound = true;
439
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
440
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
441
+			//$dataFound = true;
442 442
 		} 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'])) {
443
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
444
-		    if ($distance > 1000 && $distance < 10000) {
445
-		    // use datetime
443
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
444
+			if ($distance > 1000 && $distance < 10000) {
445
+			// use datetime
446 446
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
447 447
 			$speed = $speed*3.6;
448 448
 			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
449 449
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
450
-		    }
450
+			}
451 451
 		}
452 452
 
453 453
 
454 454
 
455
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
456
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
457
-	    	    else unset($timediff);
458
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
455
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
456
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
457
+				else unset($timediff);
458
+				if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
459 459
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
460
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
460
+				if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
461 461
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
462 462
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
463 463
 				$this->all_flights[$id]['putinarchive'] = true;
464 464
 				$this->tmd = 0;
465 465
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
466
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
467
-				    $timeelapsed = microtime(true);
468
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
466
+					if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
467
+					$timeelapsed = microtime(true);
468
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
469 469
 					$Spotter = new Spotter($this->db);
470 470
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
471 471
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
472 472
 					$Spotter->db = null;
473 473
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
474 474
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
475
-				    }
475
+					}
476
+				}
476 477
 				}
477
-			    }
478 478
 			}
479 479
 
480 480
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
481
-			    //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) {
481
+				//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) {
482 482
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
483 483
 				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') {
484
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
485
-				    $dataFound = true;
486
-				    $this->all_flights[$id]['time_last_coord'] = time();
484
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
485
+					$dataFound = true;
486
+					$this->all_flights[$id]['time_last_coord'] = time();
487 487
 				}
488 488
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
489 489
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -494,20 +494,20 @@  discard block
 block discarded – undo
494 494
 				    //$putinarchive = true;
495 495
 				}
496 496
 				*/
497
-			    /*
497
+				/*
498 498
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
499 499
 				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";
500 500
 			    }
501 501
 			    */
502 502
 			}
503 503
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
504
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
505
-			    //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) {
504
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
505
+				//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) {
506 506
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
507 507
 				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') {
508
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
509
-				    $dataFound = true;
510
-				    $this->all_flights[$id]['time_last_coord'] = time();
508
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
509
+					$dataFound = true;
510
+					$this->all_flights[$id]['time_last_coord'] = time();
511 511
 				}
512 512
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
513 513
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -525,95 +525,95 @@  discard block
 block discarded – undo
525 525
 			    */
526 526
 			}
527 527
 
528
-		    } else if ($globalDebug && $timediff > 30) {
528
+			} else if ($globalDebug && $timediff > 30) {
529 529
 			$this->tmd = $this->tmd + 1;
530 530
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
531 531
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
532 532
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
533 533
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
534
-		    }
534
+			}
535 535
 		}
536 536
 		if (isset($line['last_update']) && $line['last_update'] != '') {
537
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
538
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
537
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
538
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
539 539
 		}
540 540
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
541
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
542
-		    //$dataFound = true;
541
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
542
+			//$dataFound = true;
543 543
 		}
544 544
 		if (isset($line['format_source']) && $line['format_source'] != '') {
545
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
545
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
546 546
 		}
547 547
 		if (isset($line['source_name']) && $line['source_name'] != '') {
548
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
548
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
549 549
 		}
550 550
 		if (isset($line['emergency']) && $line['emergency'] != '') {
551
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
552
-		    //$dataFound = true;
551
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
552
+			//$dataFound = true;
553 553
 		}
554 554
 		if (isset($line['ground']) && $line['ground'] != '') {
555
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
555
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
556 556
 			// Here we force archive of flight because after ground it's a new one (or should be)
557 557
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
558 558
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
559 559
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
560
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
560
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
561 561
 			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']));
562
-		    }
563
-		    if ($line['ground'] != 1) $line['ground'] = 0;
564
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
565
-		    //$dataFound = true;
562
+			}
563
+			if ($line['ground'] != 1) $line['ground'] = 0;
564
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
565
+			//$dataFound = true;
566 566
 		}
567 567
 		if (isset($line['squawk']) && $line['squawk'] != '') {
568
-		    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'])) {
569
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
570
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
571
-			    $highlight = '';
572
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
573
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
574
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
575
-			    if ($highlight != '') {
568
+			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'])) {
569
+				if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
570
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
571
+				$highlight = '';
572
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
573
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
574
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
575
+				if ($highlight != '') {
576 576
 				$timeelapsed = microtime(true);
577 577
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
578
-				    $Spotter = new Spotter($this->db);
579
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
580
-				    $Spotter->db = null;
581
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
578
+					$Spotter = new Spotter($this->db);
579
+					$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
580
+					$Spotter->db = null;
581
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
582 582
 				}
583 583
 				//$putinarchive = true;
584 584
 				//$highlight = '';
585
-			    }
585
+				}
586 586
 			    
587
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
588
-		    //$dataFound = true;
587
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
588
+			//$dataFound = true;
589 589
 		}
590 590
 
591 591
 		if (isset($line['altitude']) && $line['altitude'] != '') {
592
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
592
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
593 593
 			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;
594 594
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
595 595
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
596 596
 			//$dataFound = true;
597
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
597
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
598 598
   		}
599 599
 
600 600
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
601
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
601
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
602 602
 		}
603 603
 		
604 604
 		if (isset($line['heading']) && $line['heading'] != '') {
605
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
606
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
607
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
608
-		    //$dataFound = true;
605
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
606
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
607
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
608
+			//$dataFound = true;
609 609
   		} 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']) {
610
-  		    $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']);
611
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
612
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
613
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
610
+  			$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']);
611
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
612
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
613
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
614 614
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
615
-  		    // If not enough messages and ACARS set heading to 0
616
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
615
+  			// If not enough messages and ACARS set heading to 0
616
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
617 617
   		}
618 618
 		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
619 619
 		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -624,125 +624,125 @@  discard block
 block discarded – undo
624 624
 		//if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
625 625
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
626 626
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
627
-		    $this->all_flights[$id]['lastupdate'] = time();
628
-		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
629
-		        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'])) {
630
-			    //print_r($this->all_flights);
631
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
632
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
633
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
627
+			$this->all_flights[$id]['lastupdate'] = time();
628
+			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
629
+				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'])) {
630
+				//print_r($this->all_flights);
631
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
632
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
633
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
634 634
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
635
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
636
-				    $timeelapsed = microtime(true);
637
-				    $SpotterLive = new SpotterLive($this->db);
638
-				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
635
+					if ($globalDebug) echo "Check if aircraft is already in DB...";
636
+					$timeelapsed = microtime(true);
637
+					$SpotterLive = new SpotterLive($this->db);
638
+					if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
639 639
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
640 640
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
641
-				    } elseif (isset($line['id'])) {
641
+					} elseif (isset($line['id'])) {
642 642
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
643 643
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
644
-				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
644
+					} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
645 645
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
646 646
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
647
-				    } else $recent_ident = '';
648
-				    $SpotterLive->db=null;
649
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
650
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
647
+					} else $recent_ident = '';
648
+					$SpotterLive->db=null;
649
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
650
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
651 651
 				} else $recent_ident = '';
652
-			    } else {
652
+				} else {
653 653
 				$recent_ident = '';
654 654
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
655
-			    }
656
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
657
-			    if($recent_ident == "")
658
-			    {
655
+				}
656
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
657
+				if($recent_ident == "")
658
+				{
659 659
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
660 660
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
661 661
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
662 662
 				//adds the spotter data for the archive
663 663
 				$ignoreImport = false;
664 664
 				foreach($globalAirportIgnore as $airportIgnore) {
665
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
665
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
666 666
 					$ignoreImport = true;
667
-				    }
667
+					}
668 668
 				}
669 669
 				if (count($globalAirportAccept) > 0) {
670
-				    $ignoreImport = true;
671
-				    foreach($globalAirportIgnore as $airportIgnore) {
670
+					$ignoreImport = true;
671
+					foreach($globalAirportIgnore as $airportIgnore) {
672 672
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
673
-					    $ignoreImport = false;
673
+						$ignoreImport = false;
674
+					}
674 675
 					}
675
-				    }
676 676
 				}
677 677
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
678
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
678
+					foreach($globalAirlineIgnore as $airlineIgnore) {
679 679
 					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)) {
680
-					    $ignoreImport = true;
680
+						$ignoreImport = true;
681
+					}
681 682
 					}
682
-				    }
683 683
 				}
684 684
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
685
-				    $ignoreImport = true;
686
-				    foreach($globalAirlineAccept as $airlineAccept) {
685
+					$ignoreImport = true;
686
+					foreach($globalAirlineAccept as $airlineAccept) {
687 687
 					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)) {
688
-					    $ignoreImport = false;
688
+						$ignoreImport = false;
689
+					}
689 690
 					}
690
-				    }
691 691
 				}
692 692
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
693
-				    $ignoreImport = true;
694
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
693
+					$ignoreImport = true;
694
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
695 695
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
696
-					    $ignoreImport = false;
696
+						$ignoreImport = false;
697
+					}
697 698
 					}
698
-				    }
699 699
 				}
700 700
 				
701 701
 				if (!$ignoreImport) {
702
-				    $highlight = '';
703
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
704
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
705
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
706
-				    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')));
707
-				    $timeelapsed = microtime(true);
708
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
702
+					$highlight = '';
703
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
704
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
705
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
706
+					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')));
707
+					$timeelapsed = microtime(true);
708
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
709 709
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
710
-					    $Spotter = new Spotter($this->db);
711
-					    $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']);
712
-					    $Spotter->db = null;
713
-					    if ($globalDebug && isset($result)) echo $result."\n";
710
+						$Spotter = new Spotter($this->db);
711
+						$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']);
712
+						$Spotter->db = null;
713
+						if ($globalDebug && isset($result)) echo $result."\n";
714
+					}
714 715
 					}
715
-				    }
716
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
717
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
716
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
717
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
718 718
 
719
-				    // Add source stat in DB
720
-				    $Stats = new Stats($this->db);
721
-				    if (!empty($this->stats)) {
719
+					// Add source stat in DB
720
+					$Stats = new Stats($this->db);
721
+					if (!empty($this->stats)) {
722 722
 					if ($globalDebug) echo 'Add source stats : ';
723
-				        foreach($this->stats as $date => $data) {
724
-					    foreach($data as $source => $sourced) {
725
-					        //print_r($sourced);
726
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
727
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
728
-				    		if (isset($sourced['msg'])) {
729
-				    		    if (time() - $sourced['msg']['date'] > 10) {
730
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
731
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
732
-			    			        unset($this->stats[$date][$source]['msg']);
733
-			    			    }
734
-			    			}
735
-			    		    }
736
-			    		    if ($date != date('Y-m-d')) {
737
-			    			unset($this->stats[$date]);
738
-			    		    }
739
-				    	}
740
-				    	if ($globalDebug) echo 'Done'."\n";
741
-
742
-				    }
743
-				    $Stats->db = null;
744
-				    }
745
-				    $this->del();
723
+						foreach($this->stats as $date => $data) {
724
+						foreach($data as $source => $sourced) {
725
+							//print_r($sourced);
726
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
727
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
728
+							if (isset($sourced['msg'])) {
729
+								if (time() - $sourced['msg']['date'] > 10) {
730
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
731
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
732
+									unset($this->stats[$date][$source]['msg']);
733
+								}
734
+							}
735
+							}
736
+							if ($date != date('Y-m-d')) {
737
+							unset($this->stats[$date]);
738
+							}
739
+						}
740
+						if ($globalDebug) echo 'Done'."\n";
741
+
742
+					}
743
+					$Stats->db = null;
744
+					}
745
+					$this->del();
746 746
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
747 747
 				//$ignoreImport = false;
748 748
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -760,41 +760,41 @@  discard block
 block discarded – undo
760 760
 			*/
761 761
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
762 762
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
763
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
764
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
765
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
763
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
764
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
765
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
766 766
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
767
-					    $SpotterLive = new SpotterLive($this->db);
768
-					    $SpotterLive->deleteLiveSpotterData();
769
-					    $SpotterLive->db=null;
767
+						$SpotterLive = new SpotterLive($this->db);
768
+						$SpotterLive->deleteLiveSpotterData();
769
+						$SpotterLive->db=null;
770
+					}
770 771
 					}
771
-				    }
772
-				    if ($globalDebug) echo " Done\n";
773
-				    $this->last_delete = time();
772
+					if ($globalDebug) echo " Done\n";
773
+					$this->last_delete = time();
774 774
 				}
775
-			    } else {
775
+				} else {
776 776
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
777
-				    $this->all_flights[$id]['id'] = $recent_ident;
778
-				    $this->all_flights[$id]['addedSpotter'] = 1;
777
+					$this->all_flights[$id]['id'] = $recent_ident;
778
+					$this->all_flights[$id]['addedSpotter'] = 1;
779 779
 				}
780 780
 				if (isset($globalDaemon) && !$globalDaemon) {
781
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
781
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
782 782
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
783
-					    $Spotter = new Spotter($this->db);
784
-					    $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']);
785
-					    $Spotter->db = null;
783
+						$Spotter = new Spotter($this->db);
784
+						$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']);
785
+						$Spotter->db = null;
786
+					}
786 787
 					}
787
-				    }
788 788
 				}
789 789
 				
790
-			    }
790
+				}
791
+			}
791 792
 			}
792
-		    }
793
-		    //adds the spotter LIVE data
794
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
795
-		    //echo "\nAdd in Live !! \n";
796
-		    //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";
797
-		    if ($globalDebug) {
793
+			//adds the spotter LIVE data
794
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
795
+			//echo "\nAdd in Live !! \n";
796
+			//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";
797
+			if ($globalDebug) {
798 798
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
799 799
 				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";
800 800
 				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";
@@ -802,60 +802,60 @@  discard block
 block discarded – undo
802 802
 				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";
803 803
 				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";
804 804
 			}
805
-		    }
806
-		    $ignoreImport = false;
807
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
808
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
805
+			}
806
+			$ignoreImport = false;
807
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
808
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
809 809
 
810
-		    foreach($globalAirportIgnore as $airportIgnore) {
811
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
812
-			    $ignoreImport = true;
810
+			foreach($globalAirportIgnore as $airportIgnore) {
811
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
812
+				$ignoreImport = true;
813 813
 			}
814
-		    }
815
-		    if (count($globalAirportAccept) > 0) {
816
-		        $ignoreImport = true;
817
-		        foreach($globalAirportIgnore as $airportIgnore) {
818
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
814
+			}
815
+			if (count($globalAirportAccept) > 0) {
816
+				$ignoreImport = true;
817
+				foreach($globalAirportIgnore as $airportIgnore) {
818
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
819 819
 				$ignoreImport = false;
820
-			    }
820
+				}
821
+			}
821 822
 			}
822
-		    }
823
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
823
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
824 824
 			foreach($globalAirlineIgnore as $airlineIgnore) {
825
-			    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)) {
825
+				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)) {
826 826
 				$ignoreImport = true;
827
-			    }
827
+				}
828 828
 			}
829
-		    }
830
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
829
+			}
830
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
831 831
 			$ignoreImport = true;
832 832
 			foreach($globalAirlineAccept as $airlineAccept) {
833
-			    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)) {
833
+				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)) {
834 834
 				$ignoreImport = false;
835
-			    }
835
+				}
836
+			}
836 837
 			}
837
-		    }
838
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
838
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
839 839
 			$ignoreImport = true;
840 840
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
841
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
842
-			        $ignoreImport = false;
843
-			    }
841
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
842
+					$ignoreImport = false;
843
+				}
844
+			}
844 845
 			}
845
-		    }
846 846
 
847
-		    if (!$ignoreImport) {
847
+			if (!$ignoreImport) {
848 848
 			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'])) {
849 849
 				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')));
850 850
 				$timeelapsed = microtime(true);
851 851
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
852
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
852
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
853 853
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
854 854
 					$SpotterLive = new SpotterLive($this->db);
855 855
 					$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']);
856 856
 					$SpotterLive->db = null;
857 857
 					if ($globalDebug) echo $result."\n";
858
-				    }
858
+					}
859 859
 				}
860 860
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
861 861
 					$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']);
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
 				//if ($line['format_source'] != 'aprs') {
868 868
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
869 869
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
870
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
870
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
871 871
 					$source = $this->all_flights[$id]['source_name'];
872 872
 					if ($source == '') $source = $this->all_flights[$id]['format_source'];
873 873
 					if (!isset($this->source_location[$source])) {
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 					if ($stats_heading == 16) $stats_heading = 0;
894 894
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
895 895
 						for ($i=0;$i<=15;$i++) {
896
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
896
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
897 897
 						}
898 898
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
899 899
 					} else {
@@ -906,17 +906,17 @@  discard block
 block discarded – undo
906 906
 					//var_dump($this->stats);
907 907
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
908 908
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
909
-						    end($this->stats[$current_date][$source]['hist']);
910
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
909
+							end($this->stats[$current_date][$source]['hist']);
910
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
911 911
 						} else $mini = 0;
912 912
 						for ($i=$mini;$i<=$distance;$i+=10) {
913
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
913
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
914 914
 						}
915 915
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
916 916
 					} else {
917 917
 						$this->stats[$current_date][$source]['hist'][$distance] += 1;
918 918
 					}
919
-				    }
919
+					}
920 920
 				}
921 921
 
922 922
 				$this->all_flights[$id]['lastupdate'] = time();
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 			//$this->del();
927 927
 			
928 928
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
929
-			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
929
+				if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
930 930
 				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
931 931
 				$SpotterLive = new SpotterLive($this->db);
932 932
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
@@ -934,19 +934,19 @@  discard block
 block discarded – undo
934 934
 				//SpotterLive->deleteLiveSpotterData();
935 935
 				if ($globalDebug) echo " Done\n";
936 936
 				$this->last_delete_hourly = time();
937
-			    } else {
937
+				} else {
938 938
 				$this->del();
939 939
 				$this->last_delete_hourly = time();
940
-			    }
940
+				}
941 941
 			}
942 942
 			
943
-		    }
944
-		    //$ignoreImport = false;
943
+			}
944
+			//$ignoreImport = false;
945 945
 		}
946 946
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
947 947
 		if ($send) return $this->all_flights[$id];
948
-	    }
948
+		}
949
+	}
949 950
 	}
950
-    }
951 951
 }
952 952
 ?>
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 		$currentdate = date('Y-m-d');
34 34
 		$sourcestat = $Stats->getStatsSource($currentdate);
35 35
 		if (!empty($sourcestat)) {
36
-		    foreach($sourcestat as $srcst) {
36
+		    foreach ($sourcestat as $srcst) {
37 37
 		    	$type = $srcst['stats_type'];
38 38
 			if ($type == 'polar' || $type == 'hist') {
39 39
 			    $source = $srcst['source_name'];
40 40
 			    $data = $srcst['source_data'];
41
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
41
+			    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
42 42
 	    		}
43 43
 		    }
44 44
 		}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     }
52 52
 
53
-    public function get_Schedule($id,$ident) {
53
+    public function get_Schedule($id, $ident) {
54 54
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
55 55
 	// Get schedule here, so it's done only one time
56 56
 	
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 		$schedule = $Schedule->fetchSchedule($operator);
76 76
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77 77
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
78
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
78
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
79
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
80 80
 		    // Should also check if route schedule = route from DB
81 81
 		    if ($schedule['DepartureAirportIATA'] != '') {
82 82
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			    }
97 97
 			}
98 98
 		    }
99
-		    $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']);
99
+		    $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']);
100 100
 		}
101 101
 	    } else $scheduleexist = true;
102 102
 	} else $scheduleexist = true;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
        if ($scheduleexist) {
105 105
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
106 106
     		$sch = $Schedule->getSchedule($operator);
107
-		$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']));
107
+		$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']));
108 108
        }
109 109
 	$Spotter->db = null;
110 110
 	$Schedule->db = null;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 132
     		    $Spotter = new Spotter($this->db);
133 133
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $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']);
134
+        	    if (isset($this->all_flights[$key]['altitude'])) $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']);
135 135
         	}
136 136
 	    }
137 137
 	}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         $airport_time = '';
146 146
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
147 147
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
148
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
149 149
     	    if (isset($closestAirports[0])) {
150 150
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 151
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         		    break;
161 161
         		}
162 162
         	    }
163
-        	} 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))) {
163
+        	} 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))) {
164 164
         		$airport_icao = $closestAirports[0]['icao'];
165 165
         		$airport_time = $this->all_flights[$key]['datetime'];
166 166
         	} else {
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         } else {
174 174
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
175 175
         }
176
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
176
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
177 177
     }
178 178
 
179 179
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
185 185
 	foreach ($this->all_flights as $key => $flight) {
186 186
     	    if (isset($flight['lastupdate'])) {
187
-        	if ($flight['lastupdate'] < (time()-3000)) {
187
+        	if ($flight['lastupdate'] < (time() - 3000)) {
188 188
             	    if (isset($this->all_flights[$key]['id'])) {
189 189
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
190 190
 			/*
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
             		    $real_arrival = $this->arrival($key);
197 197
             		    $Spotter = new Spotter($this->db);
198 198
             	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
199
-				$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']);
199
+				$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']);
200 200
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
201 201
 			    }
202 202
 			// Put in archive
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	$send = false;
234 234
 	
235 235
 	// SBS format is CSV format
236
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
236
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
237 237
 	    //print_r($line);
238 238
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
239 239
 
@@ -266,25 +266,25 @@  discard block
 block discarded – undo
266 266
 		
267 267
 		if (!isset($this->all_flights[$id])) {
268 268
 		    $this->all_flights[$id] = array();
269
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
271
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
269
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
270
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => ''));
271
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
272 272
 		    if (!isset($line['id'])) {
273 273
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
274 274
 //			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')));
275 275
 //			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')));
276
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
276
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
277 277
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
278
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
279 279
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
280 280
 		}
281 281
 		if (isset($line['source_type']) && $line['source_type'] != '') {
282
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
282
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
283 283
 		}
284 284
 		
285 285
 		//print_r($this->all_flights);
286 286
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
287
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
287
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
288 288
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
289 289
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
290 290
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -293,20 +293,20 @@  discard block
 block discarded – undo
293 293
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
294 294
 			    $Spotter = new Spotter($this->db);
295 295
 			    if (isset($this->all_flights[$id]['source_type'])) {
296
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
296
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
297 297
 			    } else {
298 298
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
299 299
 			    }
300 300
 			    $Spotter->db = null;
301
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
301
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
302
+			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
303 303
 			}
304 304
 		    }
305 305
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
306 306
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
307 307
 		}
308 308
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
309
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
309
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao']));
310 310
 		}
311 311
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
312 312
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 				$Spotter = new Spotter($this->db);
315 315
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
316 316
 				$Spotter->db = null;
317
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
317
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
318 318
 			}
319 319
 		}
320 320
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -322,15 +322,15 @@  discard block
 block discarded – undo
322 322
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
323 323
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
324 324
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
325
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
325
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
326 326
 		}
327 327
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
328
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
328
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
329 329
 		}
330 330
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
331
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) {
331
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60) {
332 332
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
333
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
333
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
334 334
 		    } else {
335 335
 				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";
336 336
 				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";
@@ -343,24 +343,24 @@  discard block
 block discarded – undo
343 343
 		    }
344 344
 		} else {
345 345
 			date_default_timezone_set('UTC');
346
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
346
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
347 347
 		}
348 348
 
349 349
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
350
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
350
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
351 351
 		}
352 352
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
353
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
353
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
354 354
 		}
355 355
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
356
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
356
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id']));
357 357
 		}
358 358
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
359
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
359
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name']));
360 360
 		}
361 361
  
362 362
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
363
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
363
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
364 364
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
365 365
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
366 366
 			    $timeelapsed = microtime(true);
@@ -371,10 +371,10 @@  discard block
 block discarded – undo
371 371
 			    elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
372 372
 			    elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
373 373
 			    elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
374
-            		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
374
+            		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
375 375
 			    if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
376 376
 			    $Spotter->db = null;
377
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
377
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
378 378
 			}
379 379
 		    }
380 380
 
@@ -386,25 +386,25 @@  discard block
 block discarded – undo
386 386
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
387 387
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
388 388
   */
389
-		    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']));
389
+		    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']));
390 390
 
391 391
 		    //$putinarchive = true;
392 392
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
393
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
393
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
394 394
 		    }
395 395
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
396
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
396
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
397 397
 		    }
398 398
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
399
-		    		$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' => ''));
399
+		    		$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' => ''));
400 400
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
401 401
 			$timeelapsed = microtime(true);
402 402
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
403 403
 				$Spotter = new Spotter($this->db);
404 404
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
405 405
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
406
-		    		$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' => ''));
407
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
406
+		    		$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' => ''));
407
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
408 408
                         }
409 409
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
410 410
 			$timeelapsed = microtime(true);
@@ -418,34 +418,34 @@  discard block
 block discarded – undo
418 418
 				$Translation->db = null;
419 419
 			    }
420 420
 			    $Spotter->db = null;
421
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
421
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
422 422
                     	}
423 423
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
424 424
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
425 425
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
426 426
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
427
-		    		$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']));
427
+		    		$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']));
428 428
 		    	    }
429 429
 			}
430 430
 			if (!isset($globalFork)) $globalFork = TRUE;
431 431
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
432
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
432
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
433 433
 			}
434 434
 		    }
435 435
 		}
436 436
 
437 437
 		if (isset($line['speed']) && $line['speed'] != '') {
438 438
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
439
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
440
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
439
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
440
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
441 441
 		    //$dataFound = true;
442 442
 		} 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'])) {
443
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
443
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
444 444
 		    if ($distance > 1000 && $distance < 10000) {
445 445
 		    // use datetime
446 446
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
447 447
 			$speed = $speed*3.6;
448
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
448
+			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
449 449
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
450 450
 		    }
451 451
 		}
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
 
454 454
 
455 455
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
456
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
456
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
457 457
 	    	    else unset($timediff);
458
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
458
+	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) {
459 459
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
460
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
460
+			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
461 461
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
462 462
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
463 463
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -467,10 +467,10 @@  discard block
 block discarded – undo
467 467
 				    $timeelapsed = microtime(true);
468 468
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
469 469
 					$Spotter = new Spotter($this->db);
470
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
470
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
471 471
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
472 472
 					$Spotter->db = null;
473
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
473
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
474 474
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
475 475
 				    }
476 476
 				}
@@ -480,13 +480,13 @@  discard block
 block discarded – undo
480 480
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
481 481
 			    //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) {
482 482
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
483
-				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') {
483
+				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') {
484 484
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
485 485
 				    $dataFound = true;
486 486
 				    $this->all_flights[$id]['time_last_coord'] = time();
487 487
 				}
488 488
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
489
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
489
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
490 490
 				/*
491 491
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
492 492
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -504,13 +504,13 @@  discard block
 block discarded – undo
504 504
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
505 505
 			    //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) {
506 506
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
507
-				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') {
507
+				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') {
508 508
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
509 509
 				    $dataFound = true;
510 510
 				    $this->all_flights[$id]['time_last_coord'] = time();
511 511
 				}
512 512
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
513
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
513
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
514 514
 				/*
515 515
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
516 516
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -528,46 +528,46 @@  discard block
 block discarded – undo
528 528
 		    } else if ($globalDebug && $timediff > 30) {
529 529
 			$this->tmd = $this->tmd + 1;
530 530
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
531
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
532
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
531
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
532
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
533 533
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
534 534
 		    }
535 535
 		}
536 536
 		if (isset($line['last_update']) && $line['last_update'] != '') {
537 537
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
538
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
538
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
539 539
 		}
540 540
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
541
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
541
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
542 542
 		    //$dataFound = true;
543 543
 		}
544 544
 		if (isset($line['format_source']) && $line['format_source'] != '') {
545
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
545
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
546 546
 		}
547 547
 		if (isset($line['source_name']) && $line['source_name'] != '') {
548
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
548
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
549 549
 		}
550 550
 		if (isset($line['emergency']) && $line['emergency'] != '') {
551
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
551
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
552 552
 		    //$dataFound = true;
553 553
 		}
554 554
 		if (isset($line['ground']) && $line['ground'] != '') {
555 555
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
556 556
 			// Here we force archive of flight because after ground it's a new one (or should be)
557
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
558
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
559
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
560
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
561
-			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']));
557
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
558
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
559
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
560
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
561
+			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']));
562 562
 		    }
563 563
 		    if ($line['ground'] != 1) $line['ground'] = 0;
564
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
564
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
565 565
 		    //$dataFound = true;
566 566
 		}
567 567
 		if (isset($line['squawk']) && $line['squawk'] != '') {
568 568
 		    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'])) {
569 569
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
570
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
570
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
571 571
 			    $highlight = '';
572 572
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
573 573
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -576,47 +576,47 @@  discard block
 block discarded – undo
576 576
 				$timeelapsed = microtime(true);
577 577
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
578 578
 				    $Spotter = new Spotter($this->db);
579
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
579
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
580 580
 				    $Spotter->db = null;
581
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
581
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
582 582
 				}
583 583
 				//$putinarchive = true;
584 584
 				//$highlight = '';
585 585
 			    }
586 586
 			    
587
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
587
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
588 588
 		    //$dataFound = true;
589 589
 		}
590 590
 
591 591
 		if (isset($line['altitude']) && $line['altitude'] != '') {
592 592
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
593
-			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;
594
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
595
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
593
+			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;
594
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
595
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
596 596
 			//$dataFound = true;
597 597
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
598 598
   		}
599 599
 
600 600
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
601
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
601
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
602 602
 		}
603 603
 		
604 604
 		if (isset($line['heading']) && $line['heading'] != '') {
605
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
606
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
607
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
605
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
606
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
607
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
608 608
 		    //$dataFound = true;
609 609
   		} 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']) {
610
-  		    $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']);
611
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
612
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
610
+  		    $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']);
611
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
612
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
613 613
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
614 614
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
615 615
   		    // If not enough messages and ACARS set heading to 0
616
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
616
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
617 617
   		}
618
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
619
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
618
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
619
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
620 620
 
621 621
 //		print_r($this->all_flights[$id]);
622 622
 		//gets the callsign from the last hour
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
627 627
 		    $this->all_flights[$id]['lastupdate'] = time();
628 628
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
629
-		        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'])) {
629
+		        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'])) {
630 630
 			    //print_r($this->all_flights);
631 631
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
632 632
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -637,61 +637,61 @@  discard block
 block discarded – undo
637 637
 				    $SpotterLive = new SpotterLive($this->db);
638 638
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
639 639
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
640
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
640
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
641 641
 				    } elseif (isset($line['id'])) {
642 642
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
643
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
643
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
644 644
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
645 645
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
646
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
646
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
647 647
 				    } else $recent_ident = '';
648
-				    $SpotterLive->db=null;
648
+				    $SpotterLive->db = null;
649 649
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
650 650
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
651 651
 				} else $recent_ident = '';
652 652
 			    } else {
653 653
 				$recent_ident = '';
654
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
654
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
655 655
 			    }
656 656
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
657
-			    if($recent_ident == "")
657
+			    if ($recent_ident == "")
658 658
 			    {
659 659
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
660 660
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
661 661
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
662 662
 				//adds the spotter data for the archive
663 663
 				$ignoreImport = false;
664
-				foreach($globalAirportIgnore as $airportIgnore) {
664
+				foreach ($globalAirportIgnore as $airportIgnore) {
665 665
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
666 666
 					$ignoreImport = true;
667 667
 				    }
668 668
 				}
669 669
 				if (count($globalAirportAccept) > 0) {
670 670
 				    $ignoreImport = true;
671
-				    foreach($globalAirportIgnore as $airportIgnore) {
671
+				    foreach ($globalAirportIgnore as $airportIgnore) {
672 672
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
673 673
 					    $ignoreImport = false;
674 674
 					}
675 675
 				    }
676 676
 				}
677 677
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
678
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
679
-					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)) {
678
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
679
+					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)) {
680 680
 					    $ignoreImport = true;
681 681
 					}
682 682
 				    }
683 683
 				}
684 684
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
685 685
 				    $ignoreImport = true;
686
-				    foreach($globalAirlineAccept as $airlineAccept) {
687
-					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)) {
686
+				    foreach ($globalAirlineAccept as $airlineAccept) {
687
+					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)) {
688 688
 					    $ignoreImport = false;
689 689
 					}
690 690
 				    }
691 691
 				}
692 692
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
693 693
 				    $ignoreImport = true;
694
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
694
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
695 695
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
696 696
 					    $ignoreImport = false;
697 697
 					}
@@ -703,32 +703,32 @@  discard block
 block discarded – undo
703 703
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
704 704
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
705 705
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
706
-				    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')));
706
+				    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')));
707 707
 				    $timeelapsed = microtime(true);
708 708
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
709 709
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
710 710
 					    $Spotter = new Spotter($this->db);
711
-					    $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']);
711
+					    $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']);
712 712
 					    $Spotter->db = null;
713 713
 					    if ($globalDebug && isset($result)) echo $result."\n";
714 714
 					}
715 715
 				    }
716
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
716
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
717 717
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
718 718
 
719 719
 				    // Add source stat in DB
720 720
 				    $Stats = new Stats($this->db);
721 721
 				    if (!empty($this->stats)) {
722 722
 					if ($globalDebug) echo 'Add source stats : ';
723
-				        foreach($this->stats as $date => $data) {
724
-					    foreach($data as $source => $sourced) {
723
+				        foreach ($this->stats as $date => $data) {
724
+					    foreach ($data as $source => $sourced) {
725 725
 					        //print_r($sourced);
726
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
727
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
726
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
727
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
728 728
 				    		if (isset($sourced['msg'])) {
729 729
 				    		    if (time() - $sourced['msg']['date'] > 10) {
730 730
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
731
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
731
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
732 732
 			    			        unset($this->stats[$date][$source]['msg']);
733 733
 			    			    }
734 734
 			    			}
@@ -766,14 +766,14 @@  discard block
 block discarded – undo
766 766
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
767 767
 					    $SpotterLive = new SpotterLive($this->db);
768 768
 					    $SpotterLive->deleteLiveSpotterData();
769
-					    $SpotterLive->db=null;
769
+					    $SpotterLive->db = null;
770 770
 					}
771 771
 				    }
772 772
 				    if ($globalDebug) echo " Done\n";
773 773
 				    $this->last_delete = time();
774 774
 				}
775 775
 			    } else {
776
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
776
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
777 777
 				    $this->all_flights[$id]['id'] = $recent_ident;
778 778
 				    $this->all_flights[$id]['addedSpotter'] = 1;
779 779
 				}
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
782 782
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
783 783
 					    $Spotter = new Spotter($this->db);
784
-					    $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']);
784
+					    $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']);
785 785
 					    $Spotter->db = null;
786 786
 					}
787 787
 				    }
@@ -807,37 +807,37 @@  discard block
 block discarded – undo
807 807
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
808 808
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
809 809
 
810
-		    foreach($globalAirportIgnore as $airportIgnore) {
810
+		    foreach ($globalAirportIgnore as $airportIgnore) {
811 811
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
812 812
 			    $ignoreImport = true;
813 813
 			}
814 814
 		    }
815 815
 		    if (count($globalAirportAccept) > 0) {
816 816
 		        $ignoreImport = true;
817
-		        foreach($globalAirportIgnore as $airportIgnore) {
817
+		        foreach ($globalAirportIgnore as $airportIgnore) {
818 818
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
819 819
 				$ignoreImport = false;
820 820
 			    }
821 821
 			}
822 822
 		    }
823 823
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
824
-			foreach($globalAirlineIgnore as $airlineIgnore) {
825
-			    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)) {
824
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
825
+			    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)) {
826 826
 				$ignoreImport = true;
827 827
 			    }
828 828
 			}
829 829
 		    }
830 830
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
831 831
 			$ignoreImport = true;
832
-			foreach($globalAirlineAccept as $airlineAccept) {
833
-			    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)) {
832
+			foreach ($globalAirlineAccept as $airlineAccept) {
833
+			    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)) {
834 834
 				$ignoreImport = false;
835 835
 			    }
836 836
 			}
837 837
 		    }
838 838
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
839 839
 			$ignoreImport = true;
840
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
840
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
841 841
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
842 842
 			        $ignoreImport = false;
843 843
 			    }
@@ -845,23 +845,23 @@  discard block
 block discarded – undo
845 845
 		    }
846 846
 
847 847
 		    if (!$ignoreImport) {
848
-			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'])) {
849
-				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')));
848
+			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'])) {
849
+				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')));
850 850
 				$timeelapsed = microtime(true);
851 851
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
852 852
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
853 853
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
854 854
 					$SpotterLive = new SpotterLive($this->db);
855
-					$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']);
855
+					$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']);
856 856
 					$SpotterLive->db = null;
857 857
 					if ($globalDebug) echo $result."\n";
858 858
 				    }
859 859
 				}
860 860
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
861
-					$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']);
861
+					$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']);
862 862
 				}
863 863
 				$this->all_flights[$id]['putinarchive'] = false;
864
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
864
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
865 865
 
866 866
 				// Put statistics in $this->stats variable
867 867
 				//if ($line['format_source'] != 'aprs') {
@@ -880,19 +880,19 @@  discard block
 block discarded – undo
880 880
 							$latitude = $globalCenterLatitude;
881 881
 							$longitude = $globalCenterLongitude;
882 882
 						}
883
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
883
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
884 884
 					} else {
885 885
 						$latitude = $this->source_location[$source]['latitude'];
886 886
 						$longitude = $this->source_location[$source]['longitude'];
887 887
 					}
888
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
888
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
889 889
 					//$stats_heading = $stats_heading%22.5;
890 890
 					$stats_heading = round($stats_heading/22.5);
891
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
891
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
892 892
 					$current_date = date('Y-m-d');
893 893
 					if ($stats_heading == 16) $stats_heading = 0;
894 894
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
895
-						for ($i=0;$i<=15;$i++) {
895
+						for ($i = 0; $i <= 15; $i++) {
896 896
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
897 897
 						}
898 898
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -907,9 +907,9 @@  discard block
 block discarded – undo
907 907
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
908 908
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
909 909
 						    end($this->stats[$current_date][$source]['hist']);
910
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
910
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
911 911
 						} else $mini = 0;
912
-						for ($i=$mini;$i<=$distance;$i+=10) {
912
+						for ($i = $mini; $i <= $distance; $i += 10) {
913 913
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
914 914
 						}
915 915
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
 				$this->all_flights[$id]['lastupdate'] = time();
923 923
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
924 924
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
925
-			} 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";
925
+			} 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";
926 926
 			//$this->del();
927 927
 			
928 928
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.
Braces   +343 added lines, -121 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@  discard block
 block discarded – undo
63 63
 	$dbc = $this->db;
64 64
 	$this->all_flights[$id]['schedule_check'] = true;
65 65
 	if ($globalSchedulesFetch) {
66
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
66
+	if ($globalDebug) {
67
+		echo 'Getting schedule info...'."\n";
68
+	}
67 69
 	$Spotter = new Spotter($dbc);
68 70
 	$Schedule = new Schedule($dbc);
69 71
 	$Translation = new Translation($dbc);
@@ -74,7 +76,9 @@  discard block
 block discarded – undo
74 76
 	    if ($Schedule->checkSchedule($operator) == 0) {
75 77
 		$schedule = $Schedule->fetchSchedule($operator);
76 78
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
79
+		    if ($globalDebug) {
80
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
81
+		    }
78 82
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79 83
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80 84
 		    // Should also check if route schedule = route from DB
@@ -83,7 +87,9 @@  discard block
 block discarded – undo
83 87
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84 88
 			    if (trim($airport_icao) != '') {
85 89
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
86
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
90
+				if ($globalDebug) {
91
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
92
+				}
87 93
 			    }
88 94
 			}
89 95
 		    }
@@ -92,17 +98,25 @@  discard block
 block discarded – undo
92 98
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93 99
 			    if (trim($airport_icao) != '') {
94 100
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
95
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
101
+				if ($globalDebug) {
102
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
103
+				}
96 104
 			    }
97 105
 			}
98 106
 		    }
99 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']);
100 108
 		}
101
-	    } else $scheduleexist = true;
102
-	} else $scheduleexist = true;
109
+	    } else {
110
+	    	$scheduleexist = true;
111
+	    }
112
+	} else {
113
+		$scheduleexist = true;
114
+	}
103 115
 	// close connection, at least one way will work ?
104 116
        if ($scheduleexist) {
105
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
117
+		if ($globalDebug) {
118
+			echo "-> get arrival/departure airport info for ".$ident."\n";
119
+		}
106 120
     		$sch = $Schedule->getSchedule($operator);
107 121
 		$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']));
108 122
        }
@@ -124,14 +138,18 @@  discard block
 block discarded – undo
124 138
 
125 139
     public function checkAll() {
126 140
 	global $globalDebug, $globalNoImport;
127
-	if ($globalDebug) echo "Update last seen flights data...\n";
141
+	if ($globalDebug) {
142
+		echo "Update last seen flights data...\n";
143
+	}
128 144
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
129 145
 	    foreach ($this->all_flights as $key => $flight) {
130 146
 		if (isset($this->all_flights[$key]['id'])) {
131 147
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 148
     		    $Spotter = new Spotter($this->db);
133 149
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $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']);
150
+        	    if (isset($this->all_flights[$key]['altitude'])) {
151
+        	    	$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']);
152
+        	    }
135 153
         	}
136 154
 	    }
137 155
 	}
@@ -139,24 +157,32 @@  discard block
 block discarded – undo
139 157
 
140 158
     public function arrival($key) {
141 159
 	global $globalClosestMinDist, $globalDebug;
142
-	if ($globalDebug) echo 'Update arrival...'."\n";
160
+	if ($globalDebug) {
161
+		echo 'Update arrival...'."\n";
162
+	}
143 163
 	$Spotter = new Spotter($this->db);
144 164
         $airport_icao = '';
145 165
         $airport_time = '';
146
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
166
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
167
+        	$globalClosestMinDist = 50;
168
+        }
147 169
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148 170
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149 171
     	    if (isset($closestAirports[0])) {
150 172
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 173
         	    $airport_icao = $closestAirports[0]['icao'];
152 174
         	    $airport_time = $this->all_flights[$key]['datetime'];
153
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
175
+        	    if ($globalDebug) {
176
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
177
+        	    }
154 178
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155 179
         	    foreach ($closestAirports as $airport) {
156 180
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157 181
         		    $airport_icao = $airport['icao'];
158 182
         		    $airport_time = $this->all_flights[$key]['datetime'];
159
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
183
+        		    if ($globalDebug) {
184
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
185
+        		    }
160 186
         		    break;
161 187
         		}
162 188
         	    }
@@ -164,14 +190,20 @@  discard block
 block discarded – undo
164 190
         		$airport_icao = $closestAirports[0]['icao'];
165 191
         		$airport_time = $this->all_flights[$key]['datetime'];
166 192
         	} else {
167
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
193
+        		if ($globalDebug) {
194
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
195
+        		}
168 196
         	}
169 197
     	    } else {
170
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
198
+    		    if ($globalDebug) {
199
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
200
+    		    }
171 201
     	    }
172 202
 
173 203
         } else {
174
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
204
+        	if ($globalDebug) {
205
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
206
+        	}
175 207
         }
176 208
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177 209
     }
@@ -181,12 +213,16 @@  discard block
 block discarded – undo
181 213
     public function del() {
182 214
 	global $globalDebug, $globalNoImport, $globalNoDB;
183 215
 	// Delete old infos
184
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
216
+	if ($globalDebug) {
217
+		echo 'Delete old values and update latest data...'."\n";
218
+	}
185 219
 	foreach ($this->all_flights as $key => $flight) {
186 220
     	    if (isset($flight['lastupdate'])) {
187 221
         	if ($flight['lastupdate'] < (time()-3000)) {
188 222
             	    if (isset($this->all_flights[$key]['id'])) {
189
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
223
+            		if ($globalDebug) {
224
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
225
+            		}
190 226
 			/*
191 227
 			$SpotterLive = new SpotterLive();
192 228
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -197,7 +233,9 @@  discard block
 block discarded – undo
197 233
             		    $Spotter = new Spotter($this->db);
198 234
             	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
199 235
 				$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']);
200
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
236
+				if ($globalDebug && $result != 'success') {
237
+					echo '!!! ERROR : '.$result."\n";
238
+				}
201 239
 			    }
202 240
 			// Put in archive
203 241
 //				$Spotter->db = null;
@@ -212,8 +250,10 @@  discard block
 block discarded – undo
212 250
     public function add($line) {
213 251
 	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;
214 252
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
215
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
216
-/*
253
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
254
+		$globalCoordMinChange = '0.02';
255
+	}
256
+	/*
217 257
 	$Spotter = new Spotter();
218 258
 	$dbc = $Spotter->db;
219 259
 	$SpotterLive = new SpotterLive($dbc);
@@ -241,11 +281,15 @@  discard block
 block discarded – undo
241 281
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
242 282
 		    $current_date = date('Y-m-d');
243 283
 		    $source = $line['source_name'];
244
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
284
+		    if ($source == '' || $line['format_source'] == 'aprs') {
285
+		    	$source = $line['format_source'];
286
+		    }
245 287
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
246 288
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
247 289
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
248
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
290
+		    } else {
291
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
292
+		    }
249 293
 		}
250 294
 		
251 295
 		/*
@@ -261,22 +305,35 @@  discard block
 block discarded – undo
261 305
 		//$this->db = $dbc;
262 306
 
263 307
 		//$hex = trim($line['hex']);
264
-	        if (!isset($line['id'])) $id = trim($line['hex']);
265
-	        else $id = trim($line['id']);
308
+	        if (!isset($line['id'])) {
309
+	        	$id = trim($line['hex']);
310
+	        } else {
311
+	        	$id = trim($line['id']);
312
+	        }
266 313
 		
267 314
 		if (!isset($this->all_flights[$id])) {
268 315
 		    $this->all_flights[$id] = array();
269 316
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270 317
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
271
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
318
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
319
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
320
+		    }
272 321
 		    if (!isset($line['id'])) {
273
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
274
-//			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')));
322
+			if (!isset($globalDaemon)) {
323
+				$globalDaemon = TRUE;
324
+			}
325
+			//			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')));
275 326
 //			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')));
276
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
327
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
328
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
329
+			}
277 330
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
279
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
331
+		     } else {
332
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
333
+		     }
334
+		    if ($globalAllFlights !== FALSE) {
335
+		    	$dataFound = true;
336
+		    }
280 337
 		}
281 338
 		if (isset($line['source_type']) && $line['source_type'] != '') {
282 339
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -298,12 +355,20 @@  discard block
 block discarded – undo
298 355
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
299 356
 			    }
300 357
 			    $Spotter->db = null;
301
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
358
+			    if ($globalDebugTimeElapsed) {
359
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
360
+			    }
361
+			    if ($aircraft_icao != '') {
362
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
363
+			    }
303 364
 			}
304 365
 		    }
305
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
306
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
366
+		    if ($globalAllFlights !== FALSE) {
367
+		    	$dataFound = true;
368
+		    }
369
+		    if ($globalDebug) {
370
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
371
+		    }
307 372
 		}
308 373
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
309 374
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
@@ -314,15 +379,24 @@  discard block
 block discarded – undo
314 379
 				$Spotter = new Spotter($this->db);
315 380
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
316 381
 				$Spotter->db = null;
317
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
382
+				if ($aircraft_icao != '') {
383
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
384
+				}
318 385
 			}
319 386
 		}
320 387
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
321
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
322
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
323
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
324
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
325
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
388
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
389
+				$aircraft_icao = 'GLID';
390
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
391
+				$aircraft_icao = 'UHEL';
392
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
393
+				$aircraft_icao = 'TOWPLANE';
394
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
395
+				$aircraft_icao = 'POWAIRC';
396
+			}
397
+			if (isset($aircraft_icao)) {
398
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
399
+			}
326 400
 		}
327 401
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
328 402
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -332,8 +406,11 @@  discard block
 block discarded – undo
332 406
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
333 407
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
334 408
 		    } else {
335
-				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";
336
-				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";
409
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
410
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
411
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
412
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
413
+				}
337 414
 				/*
338 415
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
339 416
 				print_r($this->all_flights[$id]);
@@ -366,15 +443,25 @@  discard block
 block discarded – undo
366 443
 			    $timeelapsed = microtime(true);
367 444
             		    $Spotter = new Spotter($this->db);
368 445
             		    $fromsource = NULL;
369
-            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
370
-            		    elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
371
-			    elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
372
-			    elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
373
-			    elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
446
+            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
447
+            		    	$fromsource = $globalAirlinesSource;
448
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
449
+            		    	$fromsource = 'vatsim';
450
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
451
+			    	$fromsource = 'ivao';
452
+			    } elseif (isset($globalVATSIM) && $globalVATSIM) {
453
+			    	$fromsource = 'vatsim';
454
+			    } elseif (isset($globalIVAO) && $globalIVAO) {
455
+			    	$fromsource = 'ivao';
456
+			    }
374 457
             		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
375
-			    if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
458
+			    if ($globalDebug && $result != 'success') {
459
+			    	echo '!!! ERROR : '.$result."\n";
460
+			    }
376 461
 			    $Spotter->db = null;
377
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
462
+			    if ($globalDebugTimeElapsed) {
463
+			    	echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
464
+			    }
378 465
 			}
379 466
 		    }
380 467
 
@@ -386,7 +473,9 @@  discard block
 block discarded – undo
386 473
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
387 474
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
388 475
   */
389
-		    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']));
476
+		    if (!isset($this->all_flights[$id]['id'])) {
477
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
478
+		    }
390 479
 
391 480
 		    //$putinarchive = true;
392 481
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -404,7 +493,9 @@  discard block
 block discarded – undo
404 493
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
405 494
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
406 495
 		    		$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' => ''));
407
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
496
+				if ($globalDebugTimeElapsed) {
497
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
498
+				}
408 499
                         }
409 500
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
410 501
 			$timeelapsed = microtime(true);
@@ -418,7 +509,9 @@  discard block
 block discarded – undo
418 509
 				$Translation->db = null;
419 510
 			    }
420 511
 			    $Spotter->db = null;
421
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
512
+			    if ($globalDebugTimeElapsed) {
513
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
514
+			    }
422 515
                     	}
423 516
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
424 517
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -427,9 +520,13 @@  discard block
 block discarded – undo
427 520
 		    		$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']));
428 521
 		    	    }
429 522
 			}
430
-			if (!isset($globalFork)) $globalFork = TRUE;
523
+			if (!isset($globalFork)) {
524
+				$globalFork = TRUE;
525
+			}
431 526
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
432
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
527
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
528
+					$this->get_Schedule($id,trim($line['ident']));
529
+				}
433 530
 			}
434 531
 		    }
435 532
 		}
@@ -445,16 +542,23 @@  discard block
 block discarded – undo
445 542
 		    // use datetime
446 543
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
447 544
 			$speed = $speed*3.6;
448
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
449
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
545
+			if ($speed < 1000) {
546
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
547
+			}
548
+  			if ($globalDebug) {
549
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
550
+  			}
450 551
 		    }
451 552
 		}
452 553
 
453 554
 
454 555
 
455 556
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
456
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
457
-	    	    else unset($timediff);
557
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
558
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
559
+	    	    } else {
560
+	    	    	unset($timediff);
561
+	    	    }
458 562
 	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
459 563
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
460 564
 			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -463,15 +567,23 @@  discard block
 block discarded – undo
463 567
 				$this->all_flights[$id]['putinarchive'] = true;
464 568
 				$this->tmd = 0;
465 569
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
466
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
570
+				    if ($globalDebug) {
571
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
572
+				    }
467 573
 				    $timeelapsed = microtime(true);
468 574
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
469 575
 					$Spotter = new Spotter($this->db);
470 576
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
471
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
577
+					if (!empty($all_country)) {
578
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
579
+					}
472 580
 					$Spotter->db = null;
473
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
474
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
581
+					if ($globalDebugTimeElapsed) {
582
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
583
+					}
584
+					if ($globalDebug) {
585
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
586
+					}
475 587
 				    }
476 588
 				}
477 589
 			    }
@@ -479,7 +591,9 @@  discard block
 block discarded – undo
479 591
 
480 592
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
481 593
 			    //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) {
482
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
594
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
595
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
596
+				}
483 597
 				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') {
484 598
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
485 599
 				    $dataFound = true;
@@ -501,9 +615,13 @@  discard block
 block discarded – undo
501 615
 			    */
502 616
 			}
503 617
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
504
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
618
+			    if ($line['longitude'] > 180) {
619
+			    	$line['longitude'] = $line['longitude'] - 360;
620
+			    }
505 621
 			    //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) {
506
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
622
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
623
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
624
+				}
507 625
 				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') {
508 626
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
509 627
 				    $dataFound = true;
@@ -534,7 +652,9 @@  discard block
 block discarded – undo
534 652
 		    }
535 653
 		}
536 654
 		if (isset($line['last_update']) && $line['last_update'] != '') {
537
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
655
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
656
+		    	$dataFound = true;
657
+		    }
538 658
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
539 659
 		}
540 660
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -556,41 +676,61 @@  discard block
 block discarded – undo
556 676
 			// Here we force archive of flight because after ground it's a new one (or should be)
557 677
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
558 678
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
559
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
560
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
561
-			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']));
679
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
680
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
681
+			} elseif (isset($line['id'])) {
682
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
683
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
684
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
685
+			}
686
+		    }
687
+		    if ($line['ground'] != 1) {
688
+		    	$line['ground'] = 0;
562 689
 		    }
563
-		    if ($line['ground'] != 1) $line['ground'] = 0;
564 690
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
565 691
 		    //$dataFound = true;
566 692
 		}
567 693
 		if (isset($line['squawk']) && $line['squawk'] != '') {
568 694
 		    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'])) {
569
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
695
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
696
+			    	$this->all_flights[$id]['putinarchive'] = true;
697
+			    }
570 698
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
571 699
 			    $highlight = '';
572
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
573
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
574
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
700
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
701
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
702
+			    }
703
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
704
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
705
+			    }
706
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
707
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
708
+			    }
575 709
 			    if ($highlight != '') {
576 710
 				$timeelapsed = microtime(true);
577 711
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
578 712
 				    $Spotter = new Spotter($this->db);
579 713
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
580 714
 				    $Spotter->db = null;
581
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
715
+				    if ($globalDebugTimeElapsed) {
716
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
717
+				    }
582 718
 				}
583 719
 				//$putinarchive = true;
584 720
 				//$highlight = '';
585 721
 			    }
586 722
 			    
587
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
723
+		    } else {
724
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
725
+		    }
588 726
 		    //$dataFound = true;
589 727
 		}
590 728
 
591 729
 		if (isset($line['altitude']) && $line['altitude'] != '') {
592 730
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
593
-			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;
731
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
732
+				$this->all_flights[$id]['putinarchive'] = true;
733
+			}
594 734
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
595 735
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
596 736
 			//$dataFound = true;
@@ -602,21 +742,30 @@  discard block
 block discarded – undo
602 742
 		}
603 743
 		
604 744
 		if (isset($line['heading']) && $line['heading'] != '') {
605
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
745
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
746
+		    	$this->all_flights[$id]['putinarchive'] = true;
747
+		    }
606 748
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
607 749
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
608 750
 		    //$dataFound = true;
609 751
   		} 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']) {
610 752
   		    $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']);
611 753
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
612
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
613
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
754
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
755
+		    	$this->all_flights[$id]['putinarchive'] = true;
756
+		    }
757
+  		    if ($globalDebug) {
758
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
759
+  		    }
614 760
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
615 761
   		    // If not enough messages and ACARS set heading to 0
616 762
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
617 763
   		}
618
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
619
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
764
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
765
+			$dataFound = false;
766
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
767
+			$dataFound = false;
768
+		}
620 769
 
621 770
 //		print_r($this->all_flights[$id]);
622 771
 		//gets the callsign from the last hour
@@ -632,23 +781,38 @@  discard block
 block discarded – undo
632 781
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
633 782
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
634 783
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
635
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
784
+				    if ($globalDebug) {
785
+				    	echo "Check if aircraft is already in DB...";
786
+				    }
636 787
 				    $timeelapsed = microtime(true);
637 788
 				    $SpotterLive = new SpotterLive($this->db);
638 789
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
639 790
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
640
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
791
+					if ($globalDebugTimeElapsed) {
792
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
793
+					}
641 794
 				    } elseif (isset($line['id'])) {
642 795
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
643
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
796
+					if ($globalDebugTimeElapsed) {
797
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
798
+					}
644 799
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
645 800
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
646
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
647
-				    } else $recent_ident = '';
801
+					if ($globalDebugTimeElapsed) {
802
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
803
+					}
804
+				    } else {
805
+				    	$recent_ident = '';
806
+				    }
648 807
 				    $SpotterLive->db=null;
649
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
650
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
651
-				} else $recent_ident = '';
808
+				    if ($globalDebug && $recent_ident == '') {
809
+				    	echo " Not in DB.\n";
810
+				    } elseif ($globalDebug && $recent_ident != '') {
811
+				    	echo " Already in DB.\n";
812
+				    }
813
+				} else {
814
+					$recent_ident = '';
815
+				}
652 816
 			    } else {
653 817
 				$recent_ident = '';
654 818
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -656,7 +820,9 @@  discard block
 block discarded – undo
656 820
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
657 821
 			    if($recent_ident == "")
658 822
 			    {
659
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
823
+				if ($globalDebug) {
824
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
825
+				}
660 826
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
661 827
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
662 828
 				//adds the spotter data for the archive
@@ -700,31 +866,49 @@  discard block
 block discarded – undo
700 866
 				
701 867
 				if (!$ignoreImport) {
702 868
 				    $highlight = '';
703
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
704
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
705
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
706
-				    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')));
869
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
870
+				    	$highlight = 'Squawk 7500 : Hijack';
871
+				    }
872
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
873
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
874
+				    }
875
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
876
+				    	$highlight = 'Squawk 7700 : Emergency';
877
+				    }
878
+				    if (!isset($this->all_flights[$id]['id'])) {
879
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
880
+				    }
707 881
 				    $timeelapsed = microtime(true);
708 882
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
709 883
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
710 884
 					    $Spotter = new Spotter($this->db);
711 885
 					    $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']);
712 886
 					    $Spotter->db = null;
713
-					    if ($globalDebug && isset($result)) echo $result."\n";
887
+					    if ($globalDebug && isset($result)) {
888
+					    	echo $result."\n";
889
+					    }
714 890
 					}
715 891
 				    }
716
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
892
+				    if ($globalDebugTimeElapsed) {
893
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
894
+				    }
717 895
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
718 896
 
719 897
 				    // Add source stat in DB
720 898
 				    $Stats = new Stats($this->db);
721 899
 				    if (!empty($this->stats)) {
722
-					if ($globalDebug) echo 'Add source stats : ';
900
+					if ($globalDebug) {
901
+						echo 'Add source stats : ';
902
+					}
723 903
 				        foreach($this->stats as $date => $data) {
724 904
 					    foreach($data as $source => $sourced) {
725 905
 					        //print_r($sourced);
726
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
727
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
906
+				    	        if (isset($sourced['polar'])) {
907
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
908
+				    	        }
909
+				    	        if (isset($sourced['hist'])) {
910
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
911
+				    	        }
728 912
 				    		if (isset($sourced['msg'])) {
729 913
 				    		    if (time() - $sourced['msg']['date'] > 10) {
730 914
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -737,13 +921,17 @@  discard block
 block discarded – undo
737 921
 			    			unset($this->stats[$date]);
738 922
 			    		    }
739 923
 				    	}
740
-				    	if ($globalDebug) echo 'Done'."\n";
924
+				    	if ($globalDebug) {
925
+				    		echo 'Done'."\n";
926
+				    	}
741 927
 
742 928
 				    }
743 929
 				    $Stats->db = null;
744 930
 				    }
745 931
 				    $this->del();
746
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
932
+				} elseif ($globalDebug) {
933
+					echo 'Ignore data'."\n";
934
+				}
747 935
 				//$ignoreImport = false;
748 936
 				$this->all_flights[$id]['addedSpotter'] = 1;
749 937
 				//print_r($this->all_flights[$id]);
@@ -760,7 +948,9 @@  discard block
 block discarded – undo
760 948
 			*/
761 949
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
762 950
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
763
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
951
+				    if ($globalDebug) {
952
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
953
+				    }
764 954
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
765 955
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
766 956
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -769,7 +959,9 @@  discard block
 block discarded – undo
769 959
 					    $SpotterLive->db=null;
770 960
 					}
771 961
 				    }
772
-				    if ($globalDebug) echo " Done\n";
962
+				    if ($globalDebug) {
963
+				    	echo " Done\n";
964
+				    }
773 965
 				    $this->last_delete = time();
774 966
 				}
775 967
 			    } else {
@@ -796,11 +988,17 @@  discard block
 block discarded – undo
796 988
 		    //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";
797 989
 		    if ($globalDebug) {
798 990
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
799
-				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";
800
-				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";
991
+				if (isset($this->all_flights[$id]['source_name'])) {
992
+					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";
993
+				} else {
994
+					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";
995
+				}
801 996
 			} else {
802
-				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";
803
-				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";
997
+				if (isset($this->all_flights[$id]['source_name'])) {
998
+					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";
999
+				} else {
1000
+					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";
1001
+				}
804 1002
 			}
805 1003
 		    }
806 1004
 		    $ignoreImport = false;
@@ -846,22 +1044,30 @@  discard block
 block discarded – undo
846 1044
 
847 1045
 		    if (!$ignoreImport) {
848 1046
 			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'])) {
849
-				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')));
1047
+				if (!isset($this->all_flights[$id]['id'])) {
1048
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1049
+				}
850 1050
 				$timeelapsed = microtime(true);
851 1051
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
852 1052
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
853
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1053
+					if ($globalDebug) {
1054
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1055
+					}
854 1056
 					$SpotterLive = new SpotterLive($this->db);
855 1057
 					$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']);
856 1058
 					$SpotterLive->db = null;
857
-					if ($globalDebug) echo $result."\n";
1059
+					if ($globalDebug) {
1060
+						echo $result."\n";
1061
+					}
858 1062
 				    }
859 1063
 				}
860 1064
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
861 1065
 					$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']);
862 1066
 				}
863 1067
 				$this->all_flights[$id]['putinarchive'] = false;
864
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1068
+				if ($globalDebugTimeElapsed) {
1069
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1070
+				}
865 1071
 
866 1072
 				// Put statistics in $this->stats variable
867 1073
 				//if ($line['format_source'] != 'aprs') {
@@ -869,7 +1075,9 @@  discard block
 block discarded – undo
869 1075
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
870 1076
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
871 1077
 					$source = $this->all_flights[$id]['source_name'];
872
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1078
+					if ($source == '') {
1079
+						$source = $this->all_flights[$id]['format_source'];
1080
+					}
873 1081
 					if (!isset($this->source_location[$source])) {
874 1082
 						$Location = new Source();
875 1083
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -890,7 +1098,9 @@  discard block
 block discarded – undo
890 1098
 					$stats_heading = round($stats_heading/22.5);
891 1099
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
892 1100
 					$current_date = date('Y-m-d');
893
-					if ($stats_heading == 16) $stats_heading = 0;
1101
+					if ($stats_heading == 16) {
1102
+						$stats_heading = 0;
1103
+					}
894 1104
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
895 1105
 						for ($i=0;$i<=15;$i++) {
896 1106
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -908,7 +1118,9 @@  discard block
 block discarded – undo
908 1118
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
909 1119
 						    end($this->stats[$current_date][$source]['hist']);
910 1120
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
911
-						} else $mini = 0;
1121
+						} else {
1122
+							$mini = 0;
1123
+						}
912 1124
 						for ($i=$mini;$i<=$distance;$i+=10) {
913 1125
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
914 1126
 						}
@@ -920,19 +1132,27 @@  discard block
 block discarded – undo
920 1132
 				}
921 1133
 
922 1134
 				$this->all_flights[$id]['lastupdate'] = time();
923
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1135
+				if ($this->all_flights[$id]['putinarchive']) {
1136
+					$send = true;
1137
+				}
924 1138
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
925
-			} 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";
1139
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1140
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1141
+			}
926 1142
 			//$this->del();
927 1143
 			
928 1144
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
929 1145
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
930
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1146
+				if ($globalDebug) {
1147
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1148
+				}
931 1149
 				$SpotterLive = new SpotterLive($this->db);
932 1150
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
933 1151
 				$SpotterLive->db = null;
934 1152
 				//SpotterLive->deleteLiveSpotterData();
935
-				if ($globalDebug) echo " Done\n";
1153
+				if ($globalDebug) {
1154
+					echo " Done\n";
1155
+				}
936 1156
 				$this->last_delete_hourly = time();
937 1157
 			    } else {
938 1158
 				$this->del();
@@ -944,7 +1164,9 @@  discard block
 block discarded – undo
944 1164
 		    //$ignoreImport = false;
945 1165
 		}
946 1166
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
947
-		if ($send) return $this->all_flights[$id];
1167
+		if ($send) {
1168
+			return $this->all_flights[$id];
1169
+		}
948 1170
 	    }
949 1171
 	}
950 1172
     }
Please login to merge, or discard this patch.
require/class.MarineImport.php 3 patches
Indentation   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -10,16 +10,16 @@  discard block
 block discarded – undo
10 10
 require_once(dirname(__FILE__).'/class.Source.php');
11 11
 
12 12
 class MarineImport {
13
-    private $all_tracked = array();
14
-    private $last_delete_hourly = 0;
15
-    private $last_delete = 0;
16
-    private $stats = array();
17
-    private $tmd = 0;
18
-    private $source_location = array();
19
-    public $db = null;
20
-    public $nb = 0;
13
+	private $all_tracked = array();
14
+	private $last_delete_hourly = 0;
15
+	private $last_delete = 0;
16
+	private $stats = array();
17
+	private $tmd = 0;
18
+	private $source_location = array();
19
+	public $db = null;
20
+	public $nb = 0;
21 21
 
22
-    public function __construct($dbc = null) {
22
+	public function __construct($dbc = null) {
23 23
 	global $globalBeta;
24 24
 	$Connection = new Connection($dbc);
25 25
 	$this->db = $Connection->db();
@@ -41,50 +41,50 @@  discard block
 block discarded – undo
41 41
 	    }
42 42
 	}
43 43
 	*/
44
-    }
44
+	}
45 45
 
46
-    public function checkAll() {
46
+	public function checkAll() {
47 47
 	global $globalDebug;
48 48
 	if ($globalDebug) echo "Update last seen tracked data...\n";
49 49
 	foreach ($this->all_tracked as $key => $flight) {
50
-	    if (isset($this->all_tracked[$key]['id'])) {
50
+		if (isset($this->all_tracked[$key]['id'])) {
51 51
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
52
-    		$Marine = new Marine($this->db);
53
-        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
54
-            }
52
+			$Marine = new Marine($this->db);
53
+			$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
54
+			}
55
+	}
55 56
 	}
56
-    }
57 57
 
58
-    public function del() {
58
+	public function del() {
59 59
 	global $globalDebug;
60 60
 	// Delete old infos
61 61
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
62 62
 	foreach ($this->all_tracked as $key => $flight) {
63
-    	    if (isset($flight['lastupdate'])) {
64
-        	if ($flight['lastupdate'] < (time()-3000)) {
65
-            	    if (isset($this->all_tracked[$key]['id'])) {
66
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
63
+			if (isset($flight['lastupdate'])) {
64
+			if ($flight['lastupdate'] < (time()-3000)) {
65
+					if (isset($this->all_tracked[$key]['id'])) {
66
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
67 67
 			/*
68 68
 			$MarineLive = new MarineLive();
69 69
             		$MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
70 70
 			$MarineLive->db = null;
71 71
 			*/
72
-            		//$real_arrival = $this->arrival($key);
73
-            		$Marine = new Marine($this->db);
74
-            		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72
+					//$real_arrival = $this->arrival($key);
73
+					$Marine = new Marine($this->db);
74
+					if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
75 75
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed']);
76 76
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
77 77
 			}
78 78
 			// Put in archive
79 79
 //			$Marine->db = null;
80
-            	    }
81
-            	    unset($this->all_tracked[$key]);
82
-    	        }
83
-	    }
84
-        }
85
-    }
80
+					}
81
+					unset($this->all_tracked[$key]);
82
+				}
83
+		}
84
+		}
85
+	}
86 86
 
87
-    public function add($line) {
87
+	public function add($line) {
88 88
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
89 89
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
90 90
 	date_default_timezone_set('UTC');
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 	
94 94
 	// SBS format is CSV format
95 95
 	if(is_array($line) && isset($line['mmsi'])) {
96
-	    //print_r($line);
97
-  	    if (isset($line['mmsi'])) {
96
+		//print_r($line);
97
+  		if (isset($line['mmsi'])) {
98 98
 
99 99
 		/*
100 100
 		// Increment message number
@@ -111,87 +111,87 @@  discard block
 block discarded – undo
111 111
 		
112 112
 		$Common = new Common();
113 113
 		$AIS = new AIS();
114
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
115
-	        else $id = trim($line['id']);
114
+			if (!isset($line['id'])) $id = trim($line['mmsi']);
115
+			else $id = trim($line['id']);
116 116
 		
117 117
 		if (!isset($this->all_tracked[$id])) {
118
-		    $this->all_tracked[$id] = array();
119
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
120
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => ''));
121
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
122
-		    if (!isset($line['id'])) {
118
+			$this->all_tracked[$id] = array();
119
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
120
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => ''));
121
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
122
+			if (!isset($line['id'])) {
123 123
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
124 124
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
125
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
126
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
125
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
126
+			if ($globalAllTracked !== FALSE) $dataFound = true;
127 127
 		}
128 128
 		
129 129
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
130
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
131
-		    $Marine = new Marine($this->db);
132
-		    $identity = $Marine->getIdentity($line['mmsi']);
133
-		    if (!empty($identity)) {
130
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
131
+			$Marine = new Marine($this->db);
132
+			$identity = $Marine->getIdentity($line['mmsi']);
133
+			if (!empty($identity)) {
134 134
 			$this->all_tracked[$id]['ident'] = $identity['ship_name'];
135 135
 			$this->all_tracked[$id]['type'] = $identity['type'];
136
-		    }
137
-		    //print_r($identity);
138
-		    unset($Marine);
139
-		    //$dataFound = true;
136
+			}
137
+			//print_r($identity);
138
+			unset($Marine);
139
+			//$dataFound = true;
140 140
 		}
141 141
 		if (isset($line['type_id']) && $line['type_id'] != '') {
142
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
142
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
143 143
 		}
144 144
 		if (isset($line['type']) && $line['type'] != '') {
145
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
145
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
146 146
 		}
147 147
 		if (isset($line['imo']) && $line['imo'] != '') {
148
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
148
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
149 149
 		}
150 150
 		if (isset($line['callsign']) && $line['callsign'] != '') {
151
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
151
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
152 152
 		}
153 153
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
154
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
154
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
155 155
 		}
156 156
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
157
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
157
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
158 158
 		}
159 159
 
160 160
 
161 161
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
162 162
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
164
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
163
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
164
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
165 165
 			$timeelapsed = microtime(true);
166
-            		$Marine = new Marine($this->db);
167
-            		$fromsource = NULL;
168
-            		$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
166
+					$Marine = new Marine($this->db);
167
+					$fromsource = NULL;
168
+					$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
169 169
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
170 170
 			$Marine->db = null;
171 171
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
172
-		    }
173
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
172
+			}
173
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
174 174
 		}
175 175
 
176 176
 		if (isset($line['speed']) && $line['speed'] != '') {
177
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
178
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
177
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
178
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
179 179
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
180
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
181
-		    if ($distance > 1000 && $distance < 10000) {
180
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
181
+			if ($distance > 1000 && $distance < 10000) {
182 182
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
183 183
 			$speed = $speed*3.6;
184 184
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
185 185
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
186
-		    }
186
+			}
187 187
 		}
188 188
 
189
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
190
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
191
-	    	    else unset($timediff);
192
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
189
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
190
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
191
+				else unset($timediff);
192
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
193 193
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
194
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
194
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
195 195
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
196 196
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
197 197
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -205,76 +205,76 @@  discard block
 block discarded – undo
205 205
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
206 206
 				$this->tmd = 0;
207 207
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
208
-			    }
208
+				}
209 209
 			}
210 210
 
211 211
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
212 212
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
213 213
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
214
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
215
-				    $dataFound = true;
216
-				    $this->all_tracked[$id]['time_last_coord'] = time();
214
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
215
+					$dataFound = true;
216
+					$this->all_tracked[$id]['time_last_coord'] = time();
217 217
 				}
218 218
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
219 219
 			}
220 220
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
221
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
221
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
222 222
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
223 223
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
224
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
225
-				    $dataFound = true;
226
-				    $this->all_tracked[$id]['time_last_coord'] = time();
224
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
225
+					$dataFound = true;
226
+					$this->all_tracked[$id]['time_last_coord'] = time();
227 227
 				}
228 228
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
229 229
 			}
230 230
 
231
-		    } else if ($globalDebug && $timediff > 20) {
231
+			} else if ($globalDebug && $timediff > 20) {
232 232
 			$this->tmd = $this->tmd + 1;
233 233
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
234 234
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
235 235
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
236 236
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
237
-		    }
237
+			}
238 238
 		}
239 239
 		if (isset($line['last_update']) && $line['last_update'] != '') {
240
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
241
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
240
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
241
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
242 242
 		}
243 243
 		if (isset($line['format_source']) && $line['format_source'] != '') {
244
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
244
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
245 245
 		}
246 246
 		if (isset($line['source_name']) && $line['source_name'] != '') {
247
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
247
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
248 248
 		}
249 249
 		if (isset($line['status']) && $line['status'] != '') {
250
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
250
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
251 251
 		}
252 252
 
253 253
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
254
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
254
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
255 255
 		}
256 256
 		
257 257
 		if (isset($line['heading']) && $line['heading'] != '') {
258
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
259
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
260
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261
-		    //$dataFound = true;
258
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
259
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
260
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261
+			//$dataFound = true;
262 262
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
263
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
264
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
265
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
263
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
264
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
265
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
267 267
   		}
268 268
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
269 269
 
270 270
 		if (isset($line['datetime'])) {
271
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
271
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
272 272
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
273
-		    } else {
273
+			} else {
274 274
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
275 275
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
276 276
 				return '';
277
-		    }
277
+			}
278 278
 		} else {
279 279
 			date_default_timezone_set('UTC');
280 280
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -282,45 +282,45 @@  discard block
 block discarded – undo
282 282
 
283 283
 
284 284
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
285
-		    $this->all_tracked[$id]['lastupdate'] = time();
286
-		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
287
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
288
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
285
+			$this->all_tracked[$id]['lastupdate'] = time();
286
+			if ($this->all_tracked[$id]['addedMarine'] == 0) {
287
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
288
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
289 289
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
290 290
 				$timeelapsed = microtime(true);
291 291
 				$MarineLive = new MarineLive($this->db);
292 292
 				if (isset($line['id'])) {
293
-				    $recent_ident = $MarineLive->checkIdRecent($line['id']);
294
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
293
+					$recent_ident = $MarineLive->checkIdRecent($line['id']);
294
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
295 295
 				} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
296
-				    $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
297
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
296
+					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
297
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
298 298
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
299
-				    $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
300
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
299
+					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
300
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
301 301
 				} else $recent_ident = '';
302 302
 				$MarineLive->db=null;
303 303
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
304 304
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
305
-			    } else {
305
+				} else {
306 306
 				$recent_ident = '';
307 307
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
308
-			    }
309
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
310
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
311
-			    {
308
+				}
309
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
310
+				if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
311
+				{
312 312
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
313 313
 				//adds the spotter data for the archive
314
-				    $highlight = '';
315
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
316
-				    $timeelapsed = microtime(true);
317
-				    $Marine = new Marine($this->db);
318
-				    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
319
-				    $Marine->db = null;
320
-				    if ($globalDebug && isset($result)) echo $result."\n";
321
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
314
+					$highlight = '';
315
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
316
+					$timeelapsed = microtime(true);
317
+					$Marine = new Marine($this->db);
318
+					$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
319
+					$Marine->db = null;
320
+					if ($globalDebug && isset($result)) echo $result."\n";
321
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
322 322
 				    
323
-				    /*
323
+					/*
324 324
 				    // Add source stat in DB
325 325
 				    $Stats = new Stats($this->db);
326 326
 				    if (!empty($this->stats)) {
@@ -347,20 +347,20 @@  discard block
 block discarded – undo
347 347
 				    }
348 348
 				    $Stats->db = null;
349 349
 				    */
350
-				    $this->del();
350
+					$this->del();
351 351
 				//$ignoreImport = false;
352 352
 				$this->all_tracked[$id]['addedMarine'] = 1;
353 353
 				//print_r($this->all_tracked[$id]);
354 354
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
355
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
356
-				    //MarineLive->deleteLiveMarineDataNotUpdated();
357
-				    $MarineLive = new MarineLive($this->db);
358
-				    $MarineLive->deleteLiveMarineData();
359
-				    $MarineLive->db=null;
360
-				    if ($globalDebug) echo " Done\n";
361
-				    $this->last_delete = time();
355
+					if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
356
+					//MarineLive->deleteLiveMarineDataNotUpdated();
357
+					$MarineLive = new MarineLive($this->db);
358
+					$MarineLive->deleteLiveMarineData();
359
+					$MarineLive->db=null;
360
+					if ($globalDebug) echo " Done\n";
361
+					$this->last_delete = time();
362 362
 				}
363
-			    } elseif ($recent_ident != '') {
363
+				} elseif ($recent_ident != '') {
364 364
 				$this->all_tracked[$id]['id'] = $recent_ident;
365 365
 				$this->all_tracked[$id]['addedMarine'] = 1;
366 366
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -369,16 +369,16 @@  discard block
 block discarded – undo
369 369
 					$Marine->db = null;
370 370
 				}
371 371
 				
372
-			    }
372
+				}
373
+			}
373 374
 			}
374
-		    }
375
-		    //adds the spotter LIVE data
376
-		    if ($globalDebug) {
375
+			//adds the spotter LIVE data
376
+			if ($globalDebug) {
377 377
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
378
-		    }
379
-		    $ignoreImport = false;
378
+			}
379
+			$ignoreImport = false;
380 380
 
381
-		    if (!$ignoreImport) {
381
+			if (!$ignoreImport) {
382 382
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
383 383
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
384 384
 				$timeelapsed = microtime(true);
@@ -450,22 +450,22 @@  discard block
 block discarded – undo
450 450
 			
451 451
 			
452 452
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
453
-			    if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
454
-			    $MarineLive = new MarineLive($this->db);
455
-			    $MarineLive->deleteLiveMarineDataNotUpdated();
456
-			    $MarineLive->db = null;
457
-			    //MarineLive->deleteLiveMarineData();
458
-			    if ($globalDebug) echo " Done\n";
459
-			    $this->last_delete_hourly = time();
453
+				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
454
+				$MarineLive = new MarineLive($this->db);
455
+				$MarineLive->deleteLiveMarineDataNotUpdated();
456
+				$MarineLive->db = null;
457
+				//MarineLive->deleteLiveMarineData();
458
+				if ($globalDebug) echo " Done\n";
459
+				$this->last_delete_hourly = time();
460 460
 			}
461 461
 			
462
-		    }
463
-		    //$ignoreImport = false;
462
+			}
463
+			//$ignoreImport = false;
464 464
 		}
465 465
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
466 466
 		if ($send) return $this->all_tracked[$id];
467
-	    }
467
+		}
468
+	}
468 469
 	}
469
-    }
470 470
 }
471 471
 ?>
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	    if (isset($this->all_tracked[$key]['id'])) {
51 51
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
52 52
     		$Marine = new Marine($this->db);
53
-        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
53
+        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
54 54
             }
55 55
 	}
56 56
     }
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
62 62
 	foreach ($this->all_tracked as $key => $flight) {
63 63
     	    if (isset($flight['lastupdate'])) {
64
-        	if ($flight['lastupdate'] < (time()-3000)) {
64
+        	if ($flight['lastupdate'] < (time() - 3000)) {
65 65
             	    if (isset($this->all_tracked[$key]['id'])) {
66 66
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
67 67
 			/*
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
             		//$real_arrival = $this->arrival($key);
73 73
             		$Marine = new Marine($this->db);
74 74
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
75
-				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed']);
75
+				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed']);
76 76
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
77 77
 			}
78 78
 			// Put in archive
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	$send = false;
93 93
 	
94 94
 	// SBS format is CSV format
95
-	if(is_array($line) && isset($line['mmsi'])) {
95
+	if (is_array($line) && isset($line['mmsi'])) {
96 96
 	    //print_r($line);
97 97
   	    if (isset($line['mmsi'])) {
98 98
 
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 		
117 117
 		if (!isset($this->all_tracked[$id])) {
118 118
 		    $this->all_tracked[$id] = array();
119
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
120
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => ''));
121
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0));
120
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => ''));
121
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
122 122
 		    if (!isset($line['id'])) {
123 123
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
124
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
125
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
124
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
125
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
126 126
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
127 127
 		}
128 128
 		
129 129
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
130
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
130
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi']));
131 131
 		    $Marine = new Marine($this->db);
132 132
 		    $identity = $Marine->getIdentity($line['mmsi']);
133 133
 		    if (!empty($identity)) {
@@ -139,59 +139,59 @@  discard block
 block discarded – undo
139 139
 		    //$dataFound = true;
140 140
 		}
141 141
 		if (isset($line['type_id']) && $line['type_id'] != '') {
142
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
142
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id'])));
143 143
 		}
144 144
 		if (isset($line['type']) && $line['type'] != '') {
145
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
145
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
146 146
 		}
147 147
 		if (isset($line['imo']) && $line['imo'] != '') {
148
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
148
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo']));
149 149
 		}
150 150
 		if (isset($line['callsign']) && $line['callsign'] != '') {
151
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
151
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign']));
152 152
 		}
153 153
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
154
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
154
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code']));
155 155
 		}
156 156
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
157
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
157
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date']));
158 158
 		}
159 159
 
160 160
 
161 161
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
162 162
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
163
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
164 164
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
165 165
 			$timeelapsed = microtime(true);
166 166
             		$Marine = new Marine($this->db);
167 167
             		$fromsource = NULL;
168
-            		$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
168
+            		$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
169 169
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
170 170
 			$Marine->db = null;
171
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
171
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
172 172
 		    }
173
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
173
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
174 174
 		}
175 175
 
176 176
 		if (isset($line['speed']) && $line['speed'] != '') {
177
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
178
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
177
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
178
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
179 179
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
180
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
180
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
181 181
 		    if ($distance > 1000 && $distance < 10000) {
182 182
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
183 183
 			$speed = $speed*3.6;
184
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
184
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
185 185
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
186 186
 		    }
187 187
 		}
188 188
 
189 189
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
190
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
190
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
191 191
 	    	    else unset($timediff);
192
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
192
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
193 193
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
194
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
194
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
195 195
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
196 196
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
197 197
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
200 200
 				$timeelapsed = microtime(true);
201 201
 				$Marine = new Marine($this->db);
202
-				$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
202
+				$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
203 203
 				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
204 204
 				$Marine->db = null;
205
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
205
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
206 206
 				$this->tmd = 0;
207 207
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
208 208
 			    }
@@ -210,66 +210,66 @@  discard block
 block discarded – undo
210 210
 
211 211
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
212 212
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
213
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
213
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
214 214
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
215 215
 				    $dataFound = true;
216 216
 				    $this->all_tracked[$id]['time_last_coord'] = time();
217 217
 				}
218
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
218
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
219 219
 			}
220 220
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
221 221
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
222 222
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
223
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
223
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
224 224
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
225 225
 				    $dataFound = true;
226 226
 				    $this->all_tracked[$id]['time_last_coord'] = time();
227 227
 				}
228
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
228
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
229 229
 			}
230 230
 
231 231
 		    } else if ($globalDebug && $timediff > 20) {
232 232
 			$this->tmd = $this->tmd + 1;
233 233
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
234
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
235
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
234
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
235
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
236 236
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
237 237
 		    }
238 238
 		}
239 239
 		if (isset($line['last_update']) && $line['last_update'] != '') {
240 240
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
241
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
241
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
242 242
 		}
243 243
 		if (isset($line['format_source']) && $line['format_source'] != '') {
244
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
244
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
245 245
 		}
246 246
 		if (isset($line['source_name']) && $line['source_name'] != '') {
247
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
247
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
248 248
 		}
249 249
 		if (isset($line['status']) && $line['status'] != '') {
250
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
250
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status']));
251 251
 		}
252 252
 
253 253
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
254
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
254
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
255 255
 		}
256 256
 		
257 257
 		if (isset($line['heading']) && $line['heading'] != '') {
258
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
259
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
260
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
258
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
259
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
260
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
261 261
 		    //$dataFound = true;
262 262
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
263
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
264
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
265
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
263
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
264
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
265
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266 266
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
267 267
   		}
268 268
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
269 269
 
270 270
 		if (isset($line['datetime'])) {
271 271
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
272
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
272
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
273 273
 		    } else {
274 274
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
275 275
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -277,48 +277,48 @@  discard block
 block discarded – undo
277 277
 		    }
278 278
 		} else {
279 279
 			date_default_timezone_set('UTC');
280
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
280
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
281 281
 		}
282 282
 
283 283
 
284 284
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
285 285
 		    $this->all_tracked[$id]['lastupdate'] = time();
286 286
 		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
287
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
287
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
288 288
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
289 289
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
290 290
 				$timeelapsed = microtime(true);
291 291
 				$MarineLive = new MarineLive($this->db);
292 292
 				if (isset($line['id'])) {
293 293
 				    $recent_ident = $MarineLive->checkIdRecent($line['id']);
294
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
294
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
295 295
 				} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
296 296
 				    $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
297
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
297
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
298 298
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
299 299
 				    $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
300
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
300
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
301 301
 				} else $recent_ident = '';
302
-				$MarineLive->db=null;
302
+				$MarineLive->db = null;
303 303
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
304 304
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
305 305
 			    } else {
306 306
 				$recent_ident = '';
307
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
307
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
308 308
 			    }
309 309
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
310
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
310
+			    if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
311 311
 			    {
312 312
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
313 313
 				//adds the spotter data for the archive
314 314
 				    $highlight = '';
315
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
315
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
316 316
 				    $timeelapsed = microtime(true);
317 317
 				    $Marine = new Marine($this->db);
318
-				    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
318
+				    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
319 319
 				    $Marine->db = null;
320 320
 				    if ($globalDebug && isset($result)) echo $result."\n";
321
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
321
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
322 322
 				    
323 323
 				    /*
324 324
 				    // Add source stat in DB
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
357 357
 				    $MarineLive = new MarineLive($this->db);
358 358
 				    $MarineLive->deleteLiveMarineData();
359
-				    $MarineLive->db=null;
359
+				    $MarineLive->db = null;
360 360
 				    if ($globalDebug) echo " Done\n";
361 361
 				    $this->last_delete = time();
362 362
 				}
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 				$this->all_tracked[$id]['addedMarine'] = 1;
366 366
 				if (isset($globalDaemon) && !$globalDaemon) {
367 367
 					$Marine = new Marine($this->db);
368
-					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
368
+					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
369 369
 					$Marine->db = null;
370 370
 				}
371 371
 				
@@ -379,14 +379,14 @@  discard block
 block discarded – undo
379 379
 		    $ignoreImport = false;
380 380
 
381 381
 		    if (!$ignoreImport) {
382
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
382
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
383 383
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
384 384
 				$timeelapsed = microtime(true);
385 385
 				$MarineLive = new MarineLive($this->db);
386
-				$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
386
+				$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
387 387
 				$MarineLive->db = null;
388 388
 				$this->all_tracked[$id]['putinarchive'] = false;
389
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
389
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
390 390
 
391 391
 				// Put statistics in $this->stats variable
392 392
 				/*
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 				$this->all_tracked[$id]['lastupdate'] = time();
446 446
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
447 447
 				if ($globalDebug) echo $result."\n";
448
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
448
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
449 449
 			//$this->del();
450 450
 			
451 451
 			
Please login to merge, or discard this patch.
Braces   +149 added lines, -51 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
 
46 46
     public function checkAll() {
47 47
 	global $globalDebug;
48
-	if ($globalDebug) echo "Update last seen tracked data...\n";
48
+	if ($globalDebug) {
49
+		echo "Update last seen tracked data...\n";
50
+	}
49 51
 	foreach ($this->all_tracked as $key => $flight) {
50 52
 	    if (isset($this->all_tracked[$key]['id'])) {
51 53
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -58,12 +60,16 @@  discard block
 block discarded – undo
58 60
     public function del() {
59 61
 	global $globalDebug;
60 62
 	// Delete old infos
61
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
63
+	if ($globalDebug) {
64
+		echo 'Delete old values and update latest data...'."\n";
65
+	}
62 66
 	foreach ($this->all_tracked as $key => $flight) {
63 67
     	    if (isset($flight['lastupdate'])) {
64 68
         	if ($flight['lastupdate'] < (time()-3000)) {
65 69
             	    if (isset($this->all_tracked[$key]['id'])) {
66
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
70
+            		if ($globalDebug) {
71
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
72
+            		}
67 73
 			/*
68 74
 			$MarineLive = new MarineLive();
69 75
             		$MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -73,7 +79,9 @@  discard block
 block discarded – undo
73 79
             		$Marine = new Marine($this->db);
74 80
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
75 81
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed']);
76
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
82
+				if ($globalDebug && $result != 'success') {
83
+					echo '!!! ERROR : '.$result."\n";
84
+				}
77 85
 			}
78 86
 			// Put in archive
79 87
 //			$Marine->db = null;
@@ -86,7 +94,9 @@  discard block
 block discarded – undo
86 94
 
87 95
     public function add($line) {
88 96
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
89
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
97
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
98
+		$globalCoordMinChange = '0.02';
99
+	}
90 100
 	date_default_timezone_set('UTC');
91 101
 	$dataFound = false;
92 102
 	$send = false;
@@ -111,8 +121,11 @@  discard block
 block discarded – undo
111 121
 		
112 122
 		$Common = new Common();
113 123
 		$AIS = new AIS();
114
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
115
-	        else $id = trim($line['id']);
124
+	        if (!isset($line['id'])) {
125
+	        	$id = trim($line['mmsi']);
126
+	        } else {
127
+	        	$id = trim($line['id']);
128
+	        }
116 129
 		
117 130
 		if (!isset($this->all_tracked[$id])) {
118 131
 		    $this->all_tracked[$id] = array();
@@ -120,10 +133,16 @@  discard block
 block discarded – undo
120 133
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => ''));
121 134
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
122 135
 		    if (!isset($line['id'])) {
123
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
136
+			if (!isset($globalDaemon)) {
137
+				$globalDaemon = TRUE;
138
+			}
124 139
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
125
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
126
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
140
+		     } else {
141
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
142
+		     }
143
+		    if ($globalAllTracked !== FALSE) {
144
+		    	$dataFound = true;
145
+		    }
127 146
 		}
128 147
 		
129 148
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -166,11 +185,17 @@  discard block
 block discarded – undo
166 185
             		$Marine = new Marine($this->db);
167 186
             		$fromsource = NULL;
168 187
             		$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
169
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
188
+			if ($globalDebug && $result != 'success') {
189
+				echo '!!! ERROR : '.$result."\n";
190
+			}
170 191
 			$Marine->db = null;
171
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
192
+			if ($globalDebugTimeElapsed) {
193
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
194
+			}
195
+		    }
196
+		    if (!isset($this->all_tracked[$id]['id'])) {
197
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
172 198
 		    }
173
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
174 199
 		}
175 200
 
176 201
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -181,14 +206,21 @@  discard block
 block discarded – undo
181 206
 		    if ($distance > 1000 && $distance < 10000) {
182 207
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
183 208
 			$speed = $speed*3.6;
184
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
185
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
209
+			if ($speed < 1000) {
210
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
211
+			}
212
+  			if ($globalDebug) {
213
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
214
+  			}
186 215
 		    }
187 216
 		}
188 217
 
189 218
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
190
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
191
-	    	    else unset($timediff);
219
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
220
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
221
+	    	    } else {
222
+	    	    	unset($timediff);
223
+	    	    }
192 224
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
193 225
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
194 226
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -196,20 +228,30 @@  discard block
 block discarded – undo
196 228
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
197 229
 				$this->all_tracked[$id]['putinarchive'] = true;
198 230
 				
199
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
231
+				if ($globalDebug) {
232
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
233
+				}
200 234
 				$timeelapsed = microtime(true);
201 235
 				$Marine = new Marine($this->db);
202 236
 				$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
203
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
237
+				if (!empty($all_country)) {
238
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
239
+				}
204 240
 				$Marine->db = null;
205
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
241
+				if ($globalDebugTimeElapsed) {
242
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
243
+				}
206 244
 				$this->tmd = 0;
207
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
245
+				if ($globalDebug) {
246
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
247
+				}
208 248
 			    }
209 249
 			}
210 250
 
211 251
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
212
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
252
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
253
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
254
+				}
213 255
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
214 256
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
215 257
 				    $dataFound = true;
@@ -218,8 +260,12 @@  discard block
 block discarded – undo
218 260
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
219 261
 			}
220 262
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
221
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
222
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
263
+			    if ($line['longitude'] > 180) {
264
+			    	$line['longitude'] = $line['longitude'] - 360;
265
+			    }
266
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
267
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
268
+				}
223 269
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
224 270
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
225 271
 				    $dataFound = true;
@@ -237,7 +283,9 @@  discard block
 block discarded – undo
237 283
 		    }
238 284
 		}
239 285
 		if (isset($line['last_update']) && $line['last_update'] != '') {
240
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
286
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
287
+		    	$dataFound = true;
288
+		    }
241 289
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
242 290
 		}
243 291
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -255,15 +303,21 @@  discard block
 block discarded – undo
255 303
 		}
256 304
 		
257 305
 		if (isset($line['heading']) && $line['heading'] != '') {
258
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
306
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
307
+		    	$this->all_tracked[$id]['putinarchive'] = true;
308
+		    }
259 309
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
260 310
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261 311
 		    //$dataFound = true;
262 312
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
263 313
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
264 314
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
265
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
315
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
316
+		    	$this->all_tracked[$id]['putinarchive'] = true;
317
+		    }
318
+  		    if ($globalDebug) {
319
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
320
+  		    }
267 321
   		}
268 322
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
269 323
 
@@ -271,8 +325,11 @@  discard block
 block discarded – undo
271 325
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
272 326
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
273 327
 		    } else {
274
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
275
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
328
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
329
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
330
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
331
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
332
+				}
276 333
 				return '';
277 334
 		    }
278 335
 		} else {
@@ -286,22 +343,35 @@  discard block
 block discarded – undo
286 343
 		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
287 344
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
288 345
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
289
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
346
+				if ($globalDebug) {
347
+					echo "Check if aircraft is already in DB...";
348
+				}
290 349
 				$timeelapsed = microtime(true);
291 350
 				$MarineLive = new MarineLive($this->db);
292 351
 				if (isset($line['id'])) {
293 352
 				    $recent_ident = $MarineLive->checkIdRecent($line['id']);
294
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
353
+				    if ($globalDebugTimeElapsed) {
354
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
355
+				    }
295 356
 				} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
296 357
 				    $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
297
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
358
+				    if ($globalDebugTimeElapsed) {
359
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
360
+				    }
298 361
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
299 362
 				    $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
300
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
301
-				} else $recent_ident = '';
363
+				    if ($globalDebugTimeElapsed) {
364
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
365
+				    }
366
+				} else {
367
+					$recent_ident = '';
368
+				}
302 369
 				$MarineLive->db=null;
303
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
304
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
370
+				if ($globalDebug && $recent_ident == '') {
371
+					echo " Not in DB.\n";
372
+				} elseif ($globalDebug && $recent_ident != '') {
373
+					echo " Already in DB.\n";
374
+				}
305 375
 			    } else {
306 376
 				$recent_ident = '';
307 377
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -309,16 +379,24 @@  discard block
 block discarded – undo
309 379
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
310 380
 			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
311 381
 			    {
312
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
382
+				if ($globalDebug) {
383
+					echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
384
+				}
313 385
 				//adds the spotter data for the archive
314 386
 				    $highlight = '';
315
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
387
+				    if (!isset($this->all_tracked[$id]['id'])) {
388
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
389
+				    }
316 390
 				    $timeelapsed = microtime(true);
317 391
 				    $Marine = new Marine($this->db);
318 392
 				    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
319 393
 				    $Marine->db = null;
320
-				    if ($globalDebug && isset($result)) echo $result."\n";
321
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
394
+				    if ($globalDebug && isset($result)) {
395
+				    	echo $result."\n";
396
+				    }
397
+				    if ($globalDebugTimeElapsed) {
398
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
399
+				    }
322 400
 				    
323 401
 				    /*
324 402
 				    // Add source stat in DB
@@ -352,12 +430,16 @@  discard block
 block discarded – undo
352 430
 				$this->all_tracked[$id]['addedMarine'] = 1;
353 431
 				//print_r($this->all_tracked[$id]);
354 432
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
355
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
433
+				    if ($globalDebug) {
434
+				    	echo "---- Deleting Live Marine data older than 9 hours...";
435
+				    }
356 436
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
357 437
 				    $MarineLive = new MarineLive($this->db);
358 438
 				    $MarineLive->deleteLiveMarineData();
359 439
 				    $MarineLive->db=null;
360
-				    if ($globalDebug) echo " Done\n";
440
+				    if ($globalDebug) {
441
+				    	echo " Done\n";
442
+				    }
361 443
 				    $this->last_delete = time();
362 444
 				}
363 445
 			    } elseif ($recent_ident != '') {
@@ -380,13 +462,17 @@  discard block
 block discarded – undo
380 462
 
381 463
 		    if (!$ignoreImport) {
382 464
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
383
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
465
+				if ($globalDebug) {
466
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
467
+				}
384 468
 				$timeelapsed = microtime(true);
385 469
 				$MarineLive = new MarineLive($this->db);
386 470
 				$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
387 471
 				$MarineLive->db = null;
388 472
 				$this->all_tracked[$id]['putinarchive'] = false;
389
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
473
+				if ($globalDebugTimeElapsed) {
474
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
475
+				}
390 476
 
391 477
 				// Put statistics in $this->stats variable
392 478
 				/*
@@ -443,19 +529,29 @@  discard block
 block discarded – undo
443 529
 				*/
444 530
 
445 531
 				$this->all_tracked[$id]['lastupdate'] = time();
446
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
447
-				if ($globalDebug) echo $result."\n";
448
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
532
+				if ($this->all_tracked[$id]['putinarchive']) {
533
+					$send = true;
534
+				}
535
+				if ($globalDebug) {
536
+					echo $result."\n";
537
+				}
538
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
539
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
540
+			}
449 541
 			//$this->del();
450 542
 			
451 543
 			
452 544
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
453
-			    if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
545
+			    if ($globalDebug) {
546
+			    	echo "---- Deleting Live Marine data Not updated since 2 hour...";
547
+			    }
454 548
 			    $MarineLive = new MarineLive($this->db);
455 549
 			    $MarineLive->deleteLiveMarineDataNotUpdated();
456 550
 			    $MarineLive->db = null;
457 551
 			    //MarineLive->deleteLiveMarineData();
458
-			    if ($globalDebug) echo " Done\n";
552
+			    if ($globalDebug) {
553
+			    	echo " Done\n";
554
+			    }
459 555
 			    $this->last_delete_hourly = time();
460 556
 			}
461 557
 			
@@ -463,7 +559,9 @@  discard block
 block discarded – undo
463 559
 		    //$ignoreImport = false;
464 560
 		}
465 561
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
466
-		if ($send) return $this->all_tracked[$id];
562
+		if ($send) {
563
+			return $this->all_tracked[$id];
564
+		}
467 565
 	    }
468 566
 	}
469 567
     }
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Indentation   +859 added lines, -859 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17 17
 if (isset($globalMarine) && $globalMarine) {
18
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
18
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 20
 }
21 21
 
22 22
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -24,40 +24,40 @@  discard block
 block discarded – undo
24 24
 // Check if schema is at latest version
25 25
 $Connection = new Connection();
26 26
 if ($Connection->latest() === false) {
27
-    echo "You MUST update to latest schema. Run install/index.php";
28
-    exit();
27
+	echo "You MUST update to latest schema. Run install/index.php";
28
+	exit();
29 29
 }
30 30
 if (PHP_SAPI != 'cli') {
31
-    echo "This script MUST be called from console, not a web browser.";
31
+	echo "This script MUST be called from console, not a web browser.";
32 32
 //    exit();
33 33
 }
34 34
 
35 35
 // This is to be compatible with old version of settings.php
36 36
 if (!isset($globalSources)) {
37
-    if (isset($globalSBS1Hosts)) {
38
-        //$hosts = $globalSBS1Hosts;
39
-        foreach ($globalSBS1Hosts as $host) {
40
-	    $globalSources[] = array('host' => $host);
41
-    	}
42
-    } else {
43
-        if (!isset($globalSBS1Host)) {
44
-	    echo '$globalSources MUST be defined !';
45
-	    die;
37
+	if (isset($globalSBS1Hosts)) {
38
+		//$hosts = $globalSBS1Hosts;
39
+		foreach ($globalSBS1Hosts as $host) {
40
+		$globalSources[] = array('host' => $host);
41
+		}
42
+	} else {
43
+		if (!isset($globalSBS1Host)) {
44
+		echo '$globalSources MUST be defined !';
45
+		die;
46 46
 	}
47 47
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
48 48
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
49
-    }
49
+	}
50 50
 }
51 51
 
52 52
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::'));
53 53
 //if (isset($options['s'])) $hosts = array($options['s']);
54 54
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 55
 if (isset($options['s'])) {
56
-    $globalSources = array();
57
-    $globalSources[] = array('host' => $options['s']);
56
+	$globalSources = array();
57
+	$globalSources[] = array('host' => $options['s']);
58 58
 } elseif (isset($options['source'])) {
59
-    $globalSources = array();
60
-    $globalSources[] = array('host' => $options['source']);
59
+	$globalSources = array();
60
+	$globalSources[] = array('host' => $options['source']);
61 61
 }
62 62
 if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
63 63
 if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 if (isset($options['idsource'])) $id_source = $options['idsource'];
67 67
 else $id_source = 1;
68 68
 if (isset($globalServer) && $globalServer) {
69
-    if ($globalDebug) echo "Using Server Mode\n";
70
-    $SI=new SpotterServer();
69
+	if ($globalDebug) echo "Using Server Mode\n";
70
+	$SI=new SpotterServer();
71 71
 /*
72 72
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
73 73
     $SI = new adsb2aprs();
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 } else $SI=new SpotterImport($Connection->db);
77 77
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
78 78
 if (isset($globalMarine) && $globalMarine) {
79
-    $AIS = new AIS();
80
-    $MI = new MarineImport($Connection->db);
79
+	$AIS = new AIS();
80
+	$MI = new MarineImport($Connection->db);
81 81
 }
82 82
 //$APRS=new APRS($Connection->db);
83 83
 $SBS=new SBS();
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 //$servertz = system('date +%Z');
88 88
 // signal handler - playing nice with sockets and dump1090
89 89
 if (function_exists('pcntl_fork')) {
90
-    pcntl_signal(SIGINT,  function() {
91
-        global $sockets;
92
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
93
-        die("Bye!\n");
94
-    });
95
-    pcntl_signal_dispatch();
90
+	pcntl_signal(SIGINT,  function() {
91
+		global $sockets;
92
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
93
+		die("Bye!\n");
94
+	});
95
+	pcntl_signal_dispatch();
96 96
 }
97 97
 
98 98
 // let's try and connect
@@ -102,153 +102,153 @@  discard block
 block discarded – undo
102 102
 $reset = 0;
103 103
 
104 104
 function connect_all($hosts) {
105
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
106
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
107
-    $reset++;
108
-    if ($globalDebug) echo 'Connect to all...'."\n";
109
-    foreach ($hosts as $id => $value) {
105
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
106
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
107
+	$reset++;
108
+	if ($globalDebug) echo 'Connect to all...'."\n";
109
+	foreach ($hosts as $id => $value) {
110 110
 	$host = $value['host'];
111 111
 	$globalSources[$id]['last_exec'] = 0;
112 112
 	// Here we check type of source(s)
113 113
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
114
-            if (preg_match('/deltadb.txt$/i',$host)) {
115
-        	//$formats[$id] = 'deltadbtxt';
116
-        	$globalSources[$id]['format'] = 'deltadbtxt';
117
-        	//$last_exec['deltadbtxt'] = 0;
118
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
119
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
120
-        	//$formats[$id] = 'vatsimtxt';
121
-        	$globalSources[$id]['format'] = 'vatsimtxt';
122
-        	//$last_exec['vatsimtxt'] = 0;
123
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
124
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
125
-        	//$formats[$id] = 'aircraftlistjson';
126
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
127
-        	//$last_exec['aircraftlistjson'] = 0;
128
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
129
-    	    } else if (preg_match('/opensky/i',$host)) {
130
-        	//$formats[$id] = 'aircraftlistjson';
131
-        	$globalSources[$id]['format'] = 'opensky';
132
-        	//$last_exec['aircraftlistjson'] = 0;
133
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
134
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
135
-        	//$formats[$id] = 'radarvirtueljson';
136
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
137
-        	//$last_exec['radarvirtueljson'] = 0;
138
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
139
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
140
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
141
-        	    exit(0);
142
-        	}
143
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
144
-        	//$formats[$id] = 'planeupdatefaa';
145
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
146
-        	//$last_exec['planeupdatefaa'] = 0;
147
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
148
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
149
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
150
-        	    exit(0);
151
-        	}
152
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
153
-        	//$formats[$id] = 'phpvmacars';
154
-        	$globalSources[$id]['format'] = 'phpvmacars';
155
-        	//$last_exec['phpvmacars'] = 0;
156
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
157
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
158
-        	//$formats[$id] = 'phpvmacars';
159
-        	$globalSources[$id]['format'] = 'vam';
160
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
161
-            } else if (preg_match('/whazzup/i',$host)) {
162
-        	//$formats[$id] = 'whazzup';
163
-        	$globalSources[$id]['format'] = 'whazzup';
164
-        	//$last_exec['whazzup'] = 0;
165
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
166
-            } else if (preg_match('/recentpireps/i',$host)) {
167
-        	//$formats[$id] = 'pirepsjson';
168
-        	$globalSources[$id]['format'] = 'pirepsjson';
169
-        	//$last_exec['pirepsjson'] = 0;
170
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
171
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
172
-        	//$formats[$id] = 'fr24json';
173
-        	$globalSources[$id]['format'] = 'fr24json';
174
-        	//$last_exec['fr24json'] = 0;
175
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
176
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
177
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
178
-        	    exit(0);
179
-        	}
180
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
181
-        	//$formats[$id] = 'fr24json';
182
-        	$globalSources[$id]['format'] = 'myshiptracking';
183
-        	//$last_exec['fr24json'] = 0;
184
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
185
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
186
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
187
-        	    exit(0);
188
-        	}
189
-            //} else if (preg_match('/10001/',$host)) {
190
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
191
-        	//$formats[$id] = 'tsv';
192
-        	$globalSources[$id]['format'] = 'tsv';
193
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
194
-            }
195
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
196
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
197
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
198
-    		    if ($idf !== false) {
199
-    			$httpfeeds[$id] = $idf;
200
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
201
-    		    }
202
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
203
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
204
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
205
-	    $hostport = explode(':',$host);
206
-	    if (isset($hostport[1])) {
114
+			if (preg_match('/deltadb.txt$/i',$host)) {
115
+			//$formats[$id] = 'deltadbtxt';
116
+			$globalSources[$id]['format'] = 'deltadbtxt';
117
+			//$last_exec['deltadbtxt'] = 0;
118
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
119
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
120
+			//$formats[$id] = 'vatsimtxt';
121
+			$globalSources[$id]['format'] = 'vatsimtxt';
122
+			//$last_exec['vatsimtxt'] = 0;
123
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
124
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
125
+			//$formats[$id] = 'aircraftlistjson';
126
+			$globalSources[$id]['format'] = 'aircraftlistjson';
127
+			//$last_exec['aircraftlistjson'] = 0;
128
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
129
+			} else if (preg_match('/opensky/i',$host)) {
130
+			//$formats[$id] = 'aircraftlistjson';
131
+			$globalSources[$id]['format'] = 'opensky';
132
+			//$last_exec['aircraftlistjson'] = 0;
133
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
134
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
135
+			//$formats[$id] = 'radarvirtueljson';
136
+			$globalSources[$id]['format'] = 'radarvirtueljson';
137
+			//$last_exec['radarvirtueljson'] = 0;
138
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
139
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
140
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
141
+				exit(0);
142
+			}
143
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
144
+			//$formats[$id] = 'planeupdatefaa';
145
+			$globalSources[$id]['format'] = 'planeupdatefaa';
146
+			//$last_exec['planeupdatefaa'] = 0;
147
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
148
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
149
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
150
+				exit(0);
151
+			}
152
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
153
+			//$formats[$id] = 'phpvmacars';
154
+			$globalSources[$id]['format'] = 'phpvmacars';
155
+			//$last_exec['phpvmacars'] = 0;
156
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
157
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
158
+			//$formats[$id] = 'phpvmacars';
159
+			$globalSources[$id]['format'] = 'vam';
160
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
161
+			} else if (preg_match('/whazzup/i',$host)) {
162
+			//$formats[$id] = 'whazzup';
163
+			$globalSources[$id]['format'] = 'whazzup';
164
+			//$last_exec['whazzup'] = 0;
165
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
166
+			} else if (preg_match('/recentpireps/i',$host)) {
167
+			//$formats[$id] = 'pirepsjson';
168
+			$globalSources[$id]['format'] = 'pirepsjson';
169
+			//$last_exec['pirepsjson'] = 0;
170
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
171
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
172
+			//$formats[$id] = 'fr24json';
173
+			$globalSources[$id]['format'] = 'fr24json';
174
+			//$last_exec['fr24json'] = 0;
175
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
176
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
177
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
178
+				exit(0);
179
+			}
180
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
181
+			//$formats[$id] = 'fr24json';
182
+			$globalSources[$id]['format'] = 'myshiptracking';
183
+			//$last_exec['fr24json'] = 0;
184
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
185
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
186
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
187
+				exit(0);
188
+			}
189
+			//} else if (preg_match('/10001/',$host)) {
190
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
191
+			//$formats[$id] = 'tsv';
192
+			$globalSources[$id]['format'] = 'tsv';
193
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
194
+			}
195
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
196
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
197
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
198
+				if ($idf !== false) {
199
+				$httpfeeds[$id] = $idf;
200
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
201
+				}
202
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
203
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
204
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
205
+		$hostport = explode(':',$host);
206
+		if (isset($hostport[1])) {
207 207
 		$port = $hostport[1];
208 208
 		$hostn = $hostport[0];
209
-	    } else {
209
+		} else {
210 210
 		$port = $globalSources[$id]['port'];
211 211
 		$hostn = $globalSources[$id]['host'];
212
-	    }
213
-	    $Common = new Common();
214
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
215
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
216
-    	    } else {
217
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
218
-	    }
219
-	    if ($s) {
220
-    	        $sockets[$id] = $s;
221
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
222
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
212
+		}
213
+		$Common = new Common();
214
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
215
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
216
+			} else {
217
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
218
+		}
219
+		if ($s) {
220
+				$sockets[$id] = $s;
221
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
222
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
223 223
 			//$formats[$id] = 'aprs';
224 224
 			$globalSources[$id]['format'] = 'aprs';
225 225
 			//$aprs_connect = 0;
226 226
 			//$use_aprs = true;
227
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
227
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
228 228
 			$globalSources[$id]['format'] = 'vrstcp';
229
-    		    } elseif ($port == '10001') {
230
-        		//$formats[$id] = 'tsv';
231
-        		$globalSources[$id]['format'] = 'tsv';
232
-		    } elseif ($port == '30002') {
233
-        		//$formats[$id] = 'raw';
234
-        		$globalSources[$id]['format'] = 'raw';
235
-		    } elseif ($port == '5001') {
236
-        		//$formats[$id] = 'raw';
237
-        		$globalSources[$id]['format'] = 'flightgearmp';
238
-		    } elseif ($port == '30005') {
229
+				} elseif ($port == '10001') {
230
+				//$formats[$id] = 'tsv';
231
+				$globalSources[$id]['format'] = 'tsv';
232
+			} elseif ($port == '30002') {
233
+				//$formats[$id] = 'raw';
234
+				$globalSources[$id]['format'] = 'raw';
235
+			} elseif ($port == '5001') {
236
+				//$formats[$id] = 'raw';
237
+				$globalSources[$id]['format'] = 'flightgearmp';
238
+			} elseif ($port == '30005') {
239 239
 			// Not yet supported
240
-        		//$formats[$id] = 'beast';
241
-        		$globalSources[$id]['format'] = 'beast';
242
-		    //} else $formats[$id] = 'sbs';
243
-		    } else $globalSources[$id]['format'] = 'sbs';
244
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
240
+				//$formats[$id] = 'beast';
241
+				$globalSources[$id]['format'] = 'beast';
242
+			//} else $formats[$id] = 'sbs';
243
+			} else $globalSources[$id]['format'] = 'sbs';
244
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
245 245
 		}
246 246
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
247
-            } else {
247
+			} else {
248 248
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
249
-    	    }
250
-        }
251
-    }
249
+			}
250
+		}
251
+	}
252 252
 }
253 253
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
254 254
 
@@ -271,9 +271,9 @@  discard block
 block discarded – undo
271 271
 //connect_all($globalSources);
272 272
 
273 273
 if (isset($globalProxy) && $globalProxy) {
274
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
274
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
275 275
 } else {
276
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
276
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
277 277
 }
278 278
 
279 279
 // APRS Configuration
@@ -282,18 +282,18 @@  discard block
 block discarded – undo
282 282
 	die;
283 283
 }
284 284
 foreach ($globalSources as $key => $source) {
285
-    if (!isset($source['format'])) {
286
-        $globalSources[$key]['format'] = 'auto';
287
-    }
285
+	if (!isset($source['format'])) {
286
+		$globalSources[$key]['format'] = 'auto';
287
+	}
288 288
 }
289 289
 connect_all($globalSources);
290 290
 foreach ($globalSources as $key => $source) {
291
-    if (isset($source['format']) && $source['format'] == 'aprs') {
291
+	if (isset($source['format']) && $source['format'] == 'aprs') {
292 292
 	$aprs_connect = 0;
293 293
 	$use_aprs = true;
294 294
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
295 295
 	break;
296
-    }
296
+	}
297 297
 }
298 298
 
299 299
 if ($use_aprs) {
@@ -335,152 +335,152 @@  discard block
 block discarded – undo
335 335
 
336 336
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
337 337
 while ($i > 0) {
338
-    if (!$globalDaemon) $i = $endtime-time();
339
-    // Delete old ATC
340
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
338
+	if (!$globalDaemon) $i = $endtime-time();
339
+	// Delete old ATC
340
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
341 341
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
342
-        $ATC->deleteOldATC();
343
-    }
342
+		$ATC->deleteOldATC();
343
+	}
344 344
     
345
-    //if (count($last_exec) > 0) {
346
-    if (count($last_exec) == count($globalSources)) {
345
+	//if (count($last_exec) > 0) {
346
+	if (count($last_exec) == count($globalSources)) {
347 347
 	$max = $globalMinFetch;
348 348
 	foreach ($last_exec as $last) {
349
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
349
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
350 350
 	}
351 351
 	if ($max != $globalMinFetch) {
352
-	    if ($globalDebug) echo 'Sleeping...'."\n";
353
-	    sleep($globalMinFetch-$max+2);
352
+		if ($globalDebug) echo 'Sleeping...'."\n";
353
+		sleep($globalMinFetch-$max+2);
354
+	}
354 355
 	}
355
-    }
356 356
 
357 357
     
358
-    //foreach ($formats as $id => $value) {
359
-    foreach ($globalSources as $id => $value) {
358
+	//foreach ($formats as $id => $value) {
359
+	foreach ($globalSources as $id => $value) {
360 360
 	date_default_timezone_set('UTC');
361 361
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
362 362
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
363
-	    //$buffer = $Common->getData($hosts[$id]);
364
-	    $buffer = $Common->getData($value['host']);
365
-	    if ($buffer != '') $reset = 0;
366
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
367
-	    $buffer = explode('\n',$buffer);
368
-	    foreach ($buffer as $line) {
369
-    		if ($line != '' && count($line) > 7) {
370
-    		    $line = explode(',', $line);
371
-	            $data = array();
372
-	            $data['hex'] = $line[1]; // hex
373
-	            $data['ident'] = $line[2]; // ident
374
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
375
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
376
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
377
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
378
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
379
-	            $data['verticalrate'] = ''; // vertical rate
380
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
381
-	            $data['emergency'] = ''; // emergency
382
-		    $data['datetime'] = date('Y-m-d H:i:s');
383
-		    $data['format_source'] = 'deltadbtxt';
384
-    		    $data['id_source'] = $id_source;
385
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
386
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
387
-    		    $SI->add($data);
388
-		    unset($data);
389
-    		}
390
-    	    }
391
-    	    $last_exec[$id]['last'] = time();
363
+		//$buffer = $Common->getData($hosts[$id]);
364
+		$buffer = $Common->getData($value['host']);
365
+		if ($buffer != '') $reset = 0;
366
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
367
+		$buffer = explode('\n',$buffer);
368
+		foreach ($buffer as $line) {
369
+			if ($line != '' && count($line) > 7) {
370
+				$line = explode(',', $line);
371
+				$data = array();
372
+				$data['hex'] = $line[1]; // hex
373
+				$data['ident'] = $line[2]; // ident
374
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
375
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
376
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
377
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
378
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
379
+				$data['verticalrate'] = ''; // vertical rate
380
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
381
+				$data['emergency'] = ''; // emergency
382
+			$data['datetime'] = date('Y-m-d H:i:s');
383
+			$data['format_source'] = 'deltadbtxt';
384
+				$data['id_source'] = $id_source;
385
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
386
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
387
+				$SI->add($data);
388
+			unset($data);
389
+			}
390
+			}
391
+			$last_exec[$id]['last'] = time();
392 392
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
393
-	    date_default_timezone_set('CET');
394
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
395
-	    date_default_timezone_set('UTC');
396
-	    if ($buffer != '') $reset = 0;
397
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
398
-	    $buffer = explode('\n',$buffer);
399
-	    foreach ($buffer as $line) {
393
+		date_default_timezone_set('CET');
394
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
395
+		date_default_timezone_set('UTC');
396
+		if ($buffer != '') $reset = 0;
397
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
398
+		$buffer = explode('\n',$buffer);
399
+		foreach ($buffer as $line) {
400 400
 		if ($line != '') {
401
-		    echo "'".$line."'\n";
402
-		    $add = false;
403
-		    $ais_data = $AIS->parse_line(trim($line));
404
-		    $data = array();
405
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
406
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
407
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
408
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
409
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
410
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
411
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
412
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
413
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
414
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
415
-		    if (isset($ais_data['timestamp'])) {
401
+			echo "'".$line."'\n";
402
+			$add = false;
403
+			$ais_data = $AIS->parse_line(trim($line));
404
+			$data = array();
405
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
406
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
407
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
408
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
409
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
410
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
411
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
412
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
413
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
414
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
415
+			if (isset($ais_data['timestamp'])) {
416 416
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
417 417
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
418
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
419
-			    $add = true;
418
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
419
+				$add = true;
420 420
 			}
421
-		    } else {
421
+			} else {
422 422
 			$data['datetime'] = date('Y-m-d H:i:s');
423 423
 			$add = true;
424
-		    }
425
-		    $data['format_source'] = 'aisnmeatxt';
426
-    		    $data['id_source'] = $id_source;
427
-		    print_r($data);
428
-		    echo 'Add...'."\n";
429
-		    if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
430
-		    unset($data);
424
+			}
425
+			$data['format_source'] = 'aisnmeatxt';
426
+				$data['id_source'] = $id_source;
427
+			print_r($data);
428
+			echo 'Add...'."\n";
429
+			if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
430
+			unset($data);
431 431
 		}
432
-    	    }
433
-    	    $last_exec[$id]['last'] = time();
432
+			}
433
+			$last_exec[$id]['last'] = time();
434 434
 	} elseif ($value['format'] == 'aisnmeahttp') {
435
-	    $arr = $httpfeeds;
436
-	    $w = $e = null;
435
+		$arr = $httpfeeds;
436
+		$w = $e = null;
437 437
 	    
438
-	    if (isset($arr[$id])) {
439
-	    $nn = stream_select($arr,$w,$e,$timeout);
440
-	    if ($nn > 0) {
438
+		if (isset($arr[$id])) {
439
+		$nn = stream_select($arr,$w,$e,$timeout);
440
+		if ($nn > 0) {
441 441
 		foreach ($httpfeeds as $feed) {
442
-		    $buffer = stream_get_line($feed,2000,"\n");
443
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
444
-		    $buffer = explode('\n',$buffer);
445
-		    foreach ($buffer as $line) {
442
+			$buffer = stream_get_line($feed,2000,"\n");
443
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
444
+			$buffer = explode('\n',$buffer);
445
+			foreach ($buffer as $line) {
446 446
 			if ($line != '') {
447
-			    $ais_data = $AIS->parse_line(trim($line));
448
-			    $data = array();
449
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
450
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
451
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
452
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
453
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
454
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
455
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
456
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
457
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
458
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
459
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
460
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
461
-			    if (isset($ais_data['timestamp'])) {
447
+				$ais_data = $AIS->parse_line(trim($line));
448
+				$data = array();
449
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
450
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
451
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
452
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
453
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
454
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
455
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
456
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
457
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
458
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
459
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
460
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
461
+				if (isset($ais_data['timestamp'])) {
462 462
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
463
-			    } else {
463
+				} else {
464 464
 				$data['datetime'] = date('Y-m-d H:i:s');
465
-			    }
466
-			    $data['format_source'] = 'aisnmeahttp';
467
-			    $data['id_source'] = $id_source;
468
-			    if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data);
469
-			    unset($data);
465
+				}
466
+				$data['format_source'] = 'aisnmeahttp';
467
+				$data['id_source'] = $id_source;
468
+				if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data);
469
+				unset($data);
470 470
 			}
471
-		    }
471
+			}
472
+		}
472 473
 		}
473 474
 		}
474
-	    }
475 475
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
476
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
477
-	    if ($buffer != '') {
476
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
477
+		if ($buffer != '') {
478 478
 		//echo $buffer;
479 479
 		$all_data = json_decode($buffer,true);
480 480
 		//print_r($all_data);
481 481
 		if (isset($all_data[0]['DATA'])) {
482 482
 		foreach ($all_data[0]['DATA'] as $line) {
483
-		    if ($line != '') {
483
+			if ($line != '') {
484 484
 			$data = array();
485 485
 			$data['ident'] = $line['NAME'];
486 486
 			$data['mmsi'] = $line['MMSI'];
@@ -496,87 +496,87 @@  discard block
 block discarded – undo
496 496
 			$data['id_source'] = $id_source;
497 497
 			$MI->add($data);
498 498
 			unset($data);
499
-		    }
499
+			}
500 500
 		}
501 501
 		}
502 502
 		
503
-	    }
504
-    	    $last_exec[$id]['last'] = time();
503
+		}
504
+			$last_exec[$id]['last'] = time();
505 505
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
506
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
507
-	    if ($buffer != '') {
506
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
507
+		if ($buffer != '') {
508 508
 		$all_data = json_decode($buffer,true);
509 509
 		if (isset($all_data[0]['mmsi'])) {
510
-		    foreach ($all_data as $line) {
510
+			foreach ($all_data as $line) {
511 511
 			if ($line != '') {
512
-			    $data = array();
513
-			    $data['ident'] = $line['shipname'];
514
-			    $data['callsign'] = $line['callsign'];
515
-			    $data['mmsi'] = $line['mmsi'];
516
-			    $data['speed'] = $line['sog'];
517
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
518
-			    $data['latitude'] = $line['latitude'];
519
-			    $data['longitude'] = $line['longitude'];
520
-			    $data['type_id'] = $line['shiptype'];
521
-			    $data['arrival_code'] = $line['destination'];
522
-			    $data['datetime'] = $line['time'];
523
-			    $data['format_source'] = 'boatbeaconapp';
524
-			    $data['id_source'] = $id_source;
525
-			    $MI->add($data);
526
-			    unset($data);
512
+				$data = array();
513
+				$data['ident'] = $line['shipname'];
514
+				$data['callsign'] = $line['callsign'];
515
+				$data['mmsi'] = $line['mmsi'];
516
+				$data['speed'] = $line['sog'];
517
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
518
+				$data['latitude'] = $line['latitude'];
519
+				$data['longitude'] = $line['longitude'];
520
+				$data['type_id'] = $line['shiptype'];
521
+				$data['arrival_code'] = $line['destination'];
522
+				$data['datetime'] = $line['time'];
523
+				$data['format_source'] = 'boatbeaconapp';
524
+				$data['id_source'] = $id_source;
525
+				$MI->add($data);
526
+				unset($data);
527
+			}
527 528
 			}
528
-		    }
529 529
 		}
530 530
 		
531
-	    }
532
-    	    $last_exec[$id]['last'] = time();
531
+		}
532
+			$last_exec[$id]['last'] = time();
533 533
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
534
-	    echo 'download...';
535
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
536
-	    echo 'done !'."\n";
537
-	    if ($buffer != '') $reset = 0;
538
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539
-	    $buffer = explode('\n',$buffer);
540
-	    foreach ($buffer as $line) {
534
+		echo 'download...';
535
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
536
+		echo 'done !'."\n";
537
+		if ($buffer != '') $reset = 0;
538
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539
+		$buffer = explode('\n',$buffer);
540
+		foreach ($buffer as $line) {
541 541
 		if ($line != '') {
542
-		    $data = array();
543
-		    $data['mmsi'] = (int)substr($line,0,9);
544
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
545
-		    //$data['status'] = substr($line,21,2);
546
-		    //$data['type'] = substr($line,24,3);
547
-		    $data['latitude'] = substr($line,29,9);
548
-		    $data['longitude'] = substr($line,41,9);
549
-		    $data['speed'] = round(substr($line,51,5));
550
-		    //$data['course'] = substr($line,57,5);
551
-		    $data['heading'] = round(substr($line,63,3));
552
-		    //$data['draft'] = substr($line,67,4);
553
-		    //$data['length'] = substr($line,72,3);
554
-		    //$data['beam'] = substr($line,76,2);
555
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
556
-		    //$data['callsign'] = trim(substr($line,100,7);
557
-		    //$data['dest'] = substr($line,108,20);
558
-		    //$data['etaDate'] = substr($line,129,5);
559
-		    //$data['etaTime'] = substr($line,135,5);
560
-		    $data['format_source'] = 'shipplotter';
561
-    		    $data['id_source'] = $id_source;
562
-		    print_r($data);
563
-		    echo 'Add...'."\n";
564
-		    $MI->add($data);
565
-		    unset($data);
542
+			$data = array();
543
+			$data['mmsi'] = (int)substr($line,0,9);
544
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
545
+			//$data['status'] = substr($line,21,2);
546
+			//$data['type'] = substr($line,24,3);
547
+			$data['latitude'] = substr($line,29,9);
548
+			$data['longitude'] = substr($line,41,9);
549
+			$data['speed'] = round(substr($line,51,5));
550
+			//$data['course'] = substr($line,57,5);
551
+			$data['heading'] = round(substr($line,63,3));
552
+			//$data['draft'] = substr($line,67,4);
553
+			//$data['length'] = substr($line,72,3);
554
+			//$data['beam'] = substr($line,76,2);
555
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
556
+			//$data['callsign'] = trim(substr($line,100,7);
557
+			//$data['dest'] = substr($line,108,20);
558
+			//$data['etaDate'] = substr($line,129,5);
559
+			//$data['etaTime'] = substr($line,135,5);
560
+			$data['format_source'] = 'shipplotter';
561
+				$data['id_source'] = $id_source;
562
+			print_r($data);
563
+			echo 'Add...'."\n";
564
+			$MI->add($data);
565
+			unset($data);
566 566
 		}
567
-    	    }
568
-    	    $last_exec[$id]['last'] = time();
567
+			}
568
+			$last_exec[$id]['last'] = time();
569 569
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
570 570
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
571
-	    //$buffer = $Common->getData($hosts[$id]);
572
-	    $buffer = $Common->getData($value['host']);
573
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
574
-	    $buffer = explode('\n',$buffer);
575
-	    $reset = 0;
576
-	    foreach ($buffer as $line) {
577
-    		if ($line != '') {
578
-    		    $line = explode(':', $line);
579
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
571
+		//$buffer = $Common->getData($hosts[$id]);
572
+		$buffer = $Common->getData($value['host']);
573
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
574
+		$buffer = explode('\n',$buffer);
575
+		$reset = 0;
576
+		foreach ($buffer as $line) {
577
+			if ($line != '') {
578
+				$line = explode(':', $line);
579
+				if (count($line) > 30 && $line[0] != 'callsign') {
580 580
 			$data = array();
581 581
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
582 582
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -589,36 +589,36 @@  discard block
 block discarded – undo
589 589
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
590 590
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
591 591
 			$data['latitude'] = $line[5]; // lat
592
-	        	$data['longitude'] = $line[6]; // long
593
-	        	$data['verticalrate'] = ''; // vertical rate
594
-	        	$data['squawk'] = ''; // squawk
595
-	        	$data['emergency'] = ''; // emergency
596
-	        	$data['waypoints'] = $line[30];
592
+				$data['longitude'] = $line[6]; // long
593
+				$data['verticalrate'] = ''; // vertical rate
594
+				$data['squawk'] = ''; // squawk
595
+				$data['emergency'] = ''; // emergency
596
+				$data['waypoints'] = $line[30];
597 597
 			$data['datetime'] = date('Y-m-d H:i:s');
598 598
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
599 599
 			//if (isset($line[37])) $data['last_update'] = $line[37];
600
-		        $data['departure_airport_icao'] = $line[11];
601
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
602
-		        $data['arrival_airport_icao'] = $line[13];
600
+				$data['departure_airport_icao'] = $line[11];
601
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
602
+				$data['arrival_airport_icao'] = $line[13];
603 603
 			$data['frequency'] = $line[4];
604 604
 			$data['type'] = $line[18];
605 605
 			$data['range'] = $line[19];
606 606
 			if (isset($line[35])) $data['info'] = $line[35];
607
-    			$data['id_source'] = $id_source;
608
-	    		//$data['arrival_airport_time'] = ;
609
-	    		if ($line[9] != '') {
610
-	    		    $aircraft_data = explode('/',$line[9]);
611
-	    		    if (isset($aircraft_data[1])) {
612
-	    			$data['aircraft_icao'] = $aircraft_data[1];
613
-	    		    }
614
-        		}
615
-	    		/*
607
+				$data['id_source'] = $id_source;
608
+				//$data['arrival_airport_time'] = ;
609
+				if ($line[9] != '') {
610
+					$aircraft_data = explode('/',$line[9]);
611
+					if (isset($aircraft_data[1])) {
612
+					$data['aircraft_icao'] = $aircraft_data[1];
613
+					}
614
+				}
615
+				/*
616 616
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
617 617
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
618 618
 	    		*/
619
-	    		$data['format_source'] = $value['format'];
619
+				$data['format_source'] = $value['format'];
620 620
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
621
-    			if ($line[3] == 'PILOT') $SI->add($data);
621
+				if ($line[3] == 'PILOT') $SI->add($data);
622 622
 			elseif ($line[3] == 'ATC') {
623 623
 				//print_r($data);
624 624
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -636,247 +636,247 @@  discard block
 block discarded – undo
636 636
 				if (!isset($data['source_name'])) $data['source_name'] = '';
637 637
 				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
638 638
 			}
639
-    			unset($data);
640
-    		    }
641
-    		}
642
-    	    }
643
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
644
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
645
-    	    $last_exec[$id]['last'] = time();
646
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
647
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
648
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
649
-	    if ($buffer != '') {
650
-	    $all_data = json_decode($buffer,true);
651
-	    if (isset($all_data['acList'])) {
639
+				unset($data);
640
+				}
641
+			}
642
+			}
643
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
644
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
645
+			$last_exec[$id]['last'] = time();
646
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
647
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
648
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
649
+		if ($buffer != '') {
650
+		$all_data = json_decode($buffer,true);
651
+		if (isset($all_data['acList'])) {
652 652
 		$reset = 0;
653 653
 		foreach ($all_data['acList'] as $line) {
654
-		    $data = array();
655
-		    $data['hex'] = $line['Icao']; // hex
656
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
657
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
658
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
659
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
660
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
661
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
662
-		    //$data['verticalrate'] = $line['']; // verticale rate
663
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
664
-		    $data['emergency'] = ''; // emergency
665
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
666
-		    /*
654
+			$data = array();
655
+			$data['hex'] = $line['Icao']; // hex
656
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
657
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
658
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
659
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
660
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
661
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
662
+			//$data['verticalrate'] = $line['']; // verticale rate
663
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
664
+			$data['emergency'] = ''; // emergency
665
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
666
+			/*
667 667
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
668 668
 		    else $data['datetime'] = date('Y-m-d H:i:s');
669 669
 		    */
670
-		    $data['datetime'] = date('Y-m-d H:i:s');
671
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
672
-	    	    $data['format_source'] = 'aircraftlistjson';
673
-		    $data['id_source'] = $id_source;
674
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
675
-		    if (isset($data['latitude'])) $SI->add($data);
676
-		    unset($data);
670
+			$data['datetime'] = date('Y-m-d H:i:s');
671
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
672
+				$data['format_source'] = 'aircraftlistjson';
673
+			$data['id_source'] = $id_source;
674
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
675
+			if (isset($data['latitude'])) $SI->add($data);
676
+			unset($data);
677 677
 		}
678
-	    } elseif (is_array($all_data)) {
678
+		} elseif (is_array($all_data)) {
679 679
 		$reset = 0;
680 680
 		foreach ($all_data as $line) {
681
-		    $data = array();
682
-		    $data['hex'] = $line['hex']; // hex
683
-		    $data['ident'] = $line['flight']; // ident
684
-		    $data['altitude'] = $line['altitude']; // altitude
685
-		    $data['speed'] = $line['speed']; // speed
686
-		    $data['heading'] = $line['track']; // heading
687
-		    $data['latitude'] = $line['lat']; // lat
688
-		    $data['longitude'] = $line['lon']; // long
689
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
690
-		    $data['squawk'] = $line['squawk']; // squawk
691
-		    $data['emergency'] = ''; // emergency
692
-		    $data['datetime'] = date('Y-m-d H:i:s');
693
-	    	    $data['format_source'] = 'aircraftlistjson';
694
-    		    $data['id_source'] = $id_source;
695
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
696
-		    $SI->add($data);
697
-		    unset($data);
681
+			$data = array();
682
+			$data['hex'] = $line['hex']; // hex
683
+			$data['ident'] = $line['flight']; // ident
684
+			$data['altitude'] = $line['altitude']; // altitude
685
+			$data['speed'] = $line['speed']; // speed
686
+			$data['heading'] = $line['track']; // heading
687
+			$data['latitude'] = $line['lat']; // lat
688
+			$data['longitude'] = $line['lon']; // long
689
+			$data['verticalrate'] = $line['vrt']; // verticale rate
690
+			$data['squawk'] = $line['squawk']; // squawk
691
+			$data['emergency'] = ''; // emergency
692
+			$data['datetime'] = date('Y-m-d H:i:s');
693
+				$data['format_source'] = 'aircraftlistjson';
694
+				$data['id_source'] = $id_source;
695
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
696
+			$SI->add($data);
697
+			unset($data);
698
+		}
698 699
 		}
699
-	    }
700
-	    }
701
-    	    //$last_exec['aircraftlistjson'] = time();
702
-    	    $last_exec[$id]['last'] = time();
703
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
704
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
705
-	    $buffer = $Common->getData($value['host']);
706
-	    $all_data = json_decode($buffer,true);
707
-	    if (isset($all_data['planes'])) {
700
+		}
701
+			//$last_exec['aircraftlistjson'] = time();
702
+			$last_exec[$id]['last'] = time();
703
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
704
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
705
+		$buffer = $Common->getData($value['host']);
706
+		$all_data = json_decode($buffer,true);
707
+		if (isset($all_data['planes'])) {
708 708
 		$reset = 0;
709 709
 		foreach ($all_data['planes'] as $key => $line) {
710
-		    $data = array();
711
-		    $data['hex'] = $key; // hex
712
-		    $data['ident'] = $line[3]; // ident
713
-		    $data['altitude'] = $line[6]; // altitude
714
-		    $data['speed'] = $line[8]; // speed
715
-		    $data['heading'] = $line[7]; // heading
716
-		    $data['latitude'] = $line[4]; // lat
717
-		    $data['longitude'] = $line[5]; // long
718
-		    //$data['verticalrate'] = $line[]; // verticale rate
719
-		    $data['squawk'] = $line[10]; // squawk
720
-		    $data['emergency'] = ''; // emergency
721
-		    $data['registration'] = $line[2];
722
-		    $data['aircraft_icao'] = $line[0];
723
-		    $deparr = explode('-',$line[1]);
724
-		    if (count($deparr) == 2) {
710
+			$data = array();
711
+			$data['hex'] = $key; // hex
712
+			$data['ident'] = $line[3]; // ident
713
+			$data['altitude'] = $line[6]; // altitude
714
+			$data['speed'] = $line[8]; // speed
715
+			$data['heading'] = $line[7]; // heading
716
+			$data['latitude'] = $line[4]; // lat
717
+			$data['longitude'] = $line[5]; // long
718
+			//$data['verticalrate'] = $line[]; // verticale rate
719
+			$data['squawk'] = $line[10]; // squawk
720
+			$data['emergency'] = ''; // emergency
721
+			$data['registration'] = $line[2];
722
+			$data['aircraft_icao'] = $line[0];
723
+			$deparr = explode('-',$line[1]);
724
+			if (count($deparr) == 2) {
725 725
 			$data['departure_airport_icao'] = $deparr[0];
726 726
 			$data['arrival_airport_icao'] = $deparr[1];
727
-		    }
728
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
729
-	    	    $data['format_source'] = 'planeupdatefaa';
730
-    		    $data['id_source'] = $id_source;
731
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
732
-		    $SI->add($data);
733
-		    unset($data);
727
+			}
728
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
729
+				$data['format_source'] = 'planeupdatefaa';
730
+				$data['id_source'] = $id_source;
731
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
732
+			$SI->add($data);
733
+			unset($data);
734
+		}
734 735
 		}
735
-	    }
736
-    	    //$last_exec['planeupdatefaa'] = time();
737
-    	    $last_exec[$id]['last'] = time();
738
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
739
-	    $buffer = $Common->getData($value['host']);
740
-	    $all_data = json_decode($buffer,true);
741
-	    if (isset($all_data['states'])) {
736
+			//$last_exec['planeupdatefaa'] = time();
737
+			$last_exec[$id]['last'] = time();
738
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
739
+		$buffer = $Common->getData($value['host']);
740
+		$all_data = json_decode($buffer,true);
741
+		if (isset($all_data['states'])) {
742 742
 		$reset = 0;
743 743
 		foreach ($all_data['states'] as $key => $line) {
744
-		    $data = array();
745
-		    $data['hex'] = $line[0]; // hex
746
-		    $data['ident'] = trim($line[1]); // ident
747
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
748
-		    $data['speed'] = round($line[9]*1.94384); // speed
749
-		    $data['heading'] = round($line[10]); // heading
750
-		    $data['latitude'] = $line[5]; // lat
751
-		    $data['longitude'] = $line[6]; // long
752
-		    $data['verticalrate'] = $line[11]; // verticale rate
753
-		    //$data['squawk'] = $line[10]; // squawk
754
-		    //$data['emergency'] = ''; // emergency
755
-		    //$data['registration'] = $line[2];
756
-		    //$data['aircraft_icao'] = $line[0];
757
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
758
-	    	    $data['format_source'] = 'opensky';
759
-    		    $data['id_source'] = $id_source;
760
-		    $SI->add($data);
761
-		    unset($data);
744
+			$data = array();
745
+			$data['hex'] = $line[0]; // hex
746
+			$data['ident'] = trim($line[1]); // ident
747
+			$data['altitude'] = round($line[7]*3.28084); // altitude
748
+			$data['speed'] = round($line[9]*1.94384); // speed
749
+			$data['heading'] = round($line[10]); // heading
750
+			$data['latitude'] = $line[5]; // lat
751
+			$data['longitude'] = $line[6]; // long
752
+			$data['verticalrate'] = $line[11]; // verticale rate
753
+			//$data['squawk'] = $line[10]; // squawk
754
+			//$data['emergency'] = ''; // emergency
755
+			//$data['registration'] = $line[2];
756
+			//$data['aircraft_icao'] = $line[0];
757
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
758
+				$data['format_source'] = 'opensky';
759
+				$data['id_source'] = $id_source;
760
+			$SI->add($data);
761
+			unset($data);
762
+		}
762 763
 		}
763
-	    }
764
-    	    //$last_exec['planeupdatefaa'] = time();
765
-    	    $last_exec[$id]['last'] = time();
766
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
767
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
768
-	    //$buffer = $Common->getData($hosts[$id]);
769
-	    $buffer = $Common->getData($value['host']);
770
-	    $all_data = json_decode($buffer,true);
771
-	    if (!empty($all_data)) $reset = 0;
772
-	    foreach ($all_data as $key => $line) {
764
+			//$last_exec['planeupdatefaa'] = time();
765
+			$last_exec[$id]['last'] = time();
766
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
767
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
768
+		//$buffer = $Common->getData($hosts[$id]);
769
+		$buffer = $Common->getData($value['host']);
770
+		$all_data = json_decode($buffer,true);
771
+		if (!empty($all_data)) $reset = 0;
772
+		foreach ($all_data as $key => $line) {
773 773
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
774
-		    $data = array();
775
-		    $data['hex'] = $line[0];
776
-		    $data['ident'] = $line[16]; //$line[13]
777
-	    	    $data['altitude'] = $line[4]; // altitude
778
-	    	    $data['speed'] = $line[5]; // speed
779
-	    	    $data['heading'] = $line[3]; // heading
780
-	    	    $data['latitude'] = $line[1]; // lat
781
-	    	    $data['longitude'] = $line[2]; // long
782
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
783
-	    	    $data['squawk'] = $line[6]; // squawk
784
-	    	    $data['aircraft_icao'] = $line[8];
785
-	    	    $data['registration'] = $line[9];
786
-		    $data['departure_airport_iata'] = $line[11];
787
-		    $data['arrival_airport_iata'] = $line[12];
788
-	    	    $data['emergency'] = ''; // emergency
789
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
790
-	    	    $data['format_source'] = 'fr24json';
791
-    		    $data['id_source'] = $id_source;
792
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
793
-		    $SI->add($data);
794
-		    unset($data);
774
+			$data = array();
775
+			$data['hex'] = $line[0];
776
+			$data['ident'] = $line[16]; //$line[13]
777
+				$data['altitude'] = $line[4]; // altitude
778
+				$data['speed'] = $line[5]; // speed
779
+				$data['heading'] = $line[3]; // heading
780
+				$data['latitude'] = $line[1]; // lat
781
+				$data['longitude'] = $line[2]; // long
782
+				$data['verticalrate'] = $line[15]; // verticale rate
783
+				$data['squawk'] = $line[6]; // squawk
784
+				$data['aircraft_icao'] = $line[8];
785
+				$data['registration'] = $line[9];
786
+			$data['departure_airport_iata'] = $line[11];
787
+			$data['arrival_airport_iata'] = $line[12];
788
+				$data['emergency'] = ''; // emergency
789
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
790
+				$data['format_source'] = 'fr24json';
791
+				$data['id_source'] = $id_source;
792
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
793
+			$SI->add($data);
794
+			unset($data);
795
+		}
795 796
 		}
796
-	    }
797
-    	    //$last_exec['fr24json'] = time();
798
-    	    $last_exec[$id]['last'] = time();
799
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
800
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
801
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
802
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
803
-	    //echo $buffer;
804
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
805
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
806
-	    $all_data = json_decode($buffer,true);
807
-	    if (json_last_error() != JSON_ERROR_NONE) {
797
+			//$last_exec['fr24json'] = time();
798
+			$last_exec[$id]['last'] = time();
799
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
800
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
801
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
802
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
803
+		//echo $buffer;
804
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
805
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
806
+		$all_data = json_decode($buffer,true);
807
+		if (json_last_error() != JSON_ERROR_NONE) {
808 808
 		die(json_last_error_msg());
809
-	    }
810
-	    if (isset($all_data['mrkrs'])) {
809
+		}
810
+		if (isset($all_data['mrkrs'])) {
811 811
 		$reset = 0;
812 812
 		foreach ($all_data['mrkrs'] as $key => $line) {
813
-		    if (isset($line['inf'])) {
813
+			if (isset($line['inf'])) {
814 814
 			$data = array();
815 815
 			$data['hex'] = $line['inf']['ia'];
816 816
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
817
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
818
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
819
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
820
-	    		$data['latitude'] = $line['pt'][0]; // lat
821
-	    		$data['longitude'] = $line['pt'][1]; // long
822
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
823
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
824
-	    		//$data['aircraft_icao'] = $line[8];
825
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
817
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
818
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
819
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
820
+				$data['latitude'] = $line['pt'][0]; // lat
821
+				$data['longitude'] = $line['pt'][1]; // long
822
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
823
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
824
+				//$data['aircraft_icao'] = $line[8];
825
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
826 826
 			//$data['departure_airport_iata'] = $line[11];
827 827
 			//$data['arrival_airport_iata'] = $line[12];
828
-	    		//$data['emergency'] = ''; // emergency
828
+				//$data['emergency'] = ''; // emergency
829 829
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
830
-	    		$data['format_source'] = 'radarvirtueljson';
831
-    			$data['id_source'] = $id_source;
830
+				$data['format_source'] = 'radarvirtueljson';
831
+				$data['id_source'] = $id_source;
832 832
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
833 833
 			$SI->add($data);
834 834
 			unset($data);
835
-		    }
835
+			}
836 836
 		}
837
-	    }
838
-    	    //$last_exec['radarvirtueljson'] = time();
839
-    	    $last_exec[$id]['last'] = time();
840
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
841
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
842
-	    //$buffer = $Common->getData($hosts[$id]);
843
-	    $buffer = $Common->getData($value['host'].'?'.time());
844
-	    $all_data = json_decode(utf8_encode($buffer),true);
837
+		}
838
+			//$last_exec['radarvirtueljson'] = time();
839
+			$last_exec[$id]['last'] = time();
840
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
841
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
842
+		//$buffer = $Common->getData($hosts[$id]);
843
+		$buffer = $Common->getData($value['host'].'?'.time());
844
+		$all_data = json_decode(utf8_encode($buffer),true);
845 845
 	    
846
-	    if (isset($all_data['pireps'])) {
846
+		if (isset($all_data['pireps'])) {
847 847
 		$reset = 0;
848
-	        foreach ($all_data['pireps'] as $line) {
849
-		    $data = array();
850
-		    $data['id'] = $line['id'];
851
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
852
-		    $data['ident'] = $line['callsign']; // ident
853
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
854
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
855
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
856
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
857
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
858
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
859
-		    $data['latitude'] = $line['lat']; // lat
860
-		    $data['longitude'] = $line['lon']; // long
861
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
862
-		    //$data['squawk'] = $line['squawk']; // squawk
863
-		    //$data['emergency'] = ''; // emergency
864
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
865
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
866
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
867
-		    //$data['arrival_airport_time'] = $line['arrtime'];
868
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
869
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
870
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
871
-		    else $data['info'] = '';
872
-		    $data['format_source'] = 'pireps';
873
-    		    $data['id_source'] = $id_source;
874
-		    $data['datetime'] = date('Y-m-d H:i:s');
875
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
876
-		    if ($line['icon'] == 'plane') {
848
+			foreach ($all_data['pireps'] as $line) {
849
+			$data = array();
850
+			$data['id'] = $line['id'];
851
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
852
+			$data['ident'] = $line['callsign']; // ident
853
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
854
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
855
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
856
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
857
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
858
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
859
+			$data['latitude'] = $line['lat']; // lat
860
+			$data['longitude'] = $line['lon']; // long
861
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
862
+			//$data['squawk'] = $line['squawk']; // squawk
863
+			//$data['emergency'] = ''; // emergency
864
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
865
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
866
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
867
+			//$data['arrival_airport_time'] = $line['arrtime'];
868
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
869
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
870
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
871
+			else $data['info'] = '';
872
+			$data['format_source'] = 'pireps';
873
+				$data['id_source'] = $id_source;
874
+			$data['datetime'] = date('Y-m-d H:i:s');
875
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
876
+			if ($line['icon'] == 'plane') {
877 877
 			$SI->add($data);
878
-		    //    print_r($data);
879
-    		    } elseif ($line['icon'] == 'ct') {
878
+			//    print_r($data);
879
+				} elseif ($line['icon'] == 'ct') {
880 880
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
881 881
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
882 882
 			$typec = substr($data['ident'],-3);
@@ -891,190 +891,190 @@  discard block
 block discarded – undo
891 891
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
892 892
 			else $data['type'] = 'Observer';
893 893
 			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
894
-		    }
895
-		    unset($data);
894
+			}
895
+			unset($data);
896 896
 		}
897
-	    }
898
-    	    //$last_exec['pirepsjson'] = time();
899
-    	    $last_exec[$id]['last'] = time();
900
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
901
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
902
-	    //$buffer = $Common->getData($hosts[$id]);
903
-	    if ($globalDebug) echo 'Get Data...'."\n";
904
-	    $buffer = $Common->getData($value['host']);
905
-	    $all_data = json_decode($buffer,true);
906
-	    if ($buffer != '' && is_array($all_data)) {
897
+		}
898
+			//$last_exec['pirepsjson'] = time();
899
+			$last_exec[$id]['last'] = time();
900
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
901
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
902
+		//$buffer = $Common->getData($hosts[$id]);
903
+		if ($globalDebug) echo 'Get Data...'."\n";
904
+		$buffer = $Common->getData($value['host']);
905
+		$all_data = json_decode($buffer,true);
906
+		if ($buffer != '' && is_array($all_data)) {
907 907
 		$reset = 0;
908 908
 		foreach ($all_data as $line) {
909
-	    	    $data = array();
910
-	    	    //$data['id'] = $line['id']; // id not usable
911
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
912
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
913
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
914
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
915
-	    	    $data['ident'] = $line['flightnum']; // ident
916
-	    	    $data['altitude'] = $line['alt']; // altitude
917
-	    	    $data['speed'] = $line['gs']; // speed
918
-	    	    $data['heading'] = $line['heading']; // heading
919
-	    	    $data['latitude'] = $line['lat']; // lat
920
-	    	    $data['longitude'] = $line['lng']; // long
921
-	    	    $data['verticalrate'] = ''; // verticale rate
922
-	    	    $data['squawk'] = ''; // squawk
923
-	    	    $data['emergency'] = ''; // emergency
924
-	    	    //$data['datetime'] = $line['lastupdate'];
925
-	    	    $data['last_update'] = $line['lastupdate'];
926
-		    $data['datetime'] = date('Y-m-d H:i:s');
927
-	    	    $data['departure_airport_icao'] = $line['depicao'];
928
-	    	    $data['departure_airport_time'] = $line['deptime'];
929
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
930
-    		    $data['arrival_airport_time'] = $line['arrtime'];
931
-    		    $data['registration'] = $line['aircraft'];
932
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
933
-		    if (isset($line['aircraftname'])) {
909
+				$data = array();
910
+				//$data['id'] = $line['id']; // id not usable
911
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
912
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
913
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
914
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
915
+				$data['ident'] = $line['flightnum']; // ident
916
+				$data['altitude'] = $line['alt']; // altitude
917
+				$data['speed'] = $line['gs']; // speed
918
+				$data['heading'] = $line['heading']; // heading
919
+				$data['latitude'] = $line['lat']; // lat
920
+				$data['longitude'] = $line['lng']; // long
921
+				$data['verticalrate'] = ''; // verticale rate
922
+				$data['squawk'] = ''; // squawk
923
+				$data['emergency'] = ''; // emergency
924
+				//$data['datetime'] = $line['lastupdate'];
925
+				$data['last_update'] = $line['lastupdate'];
926
+			$data['datetime'] = date('Y-m-d H:i:s');
927
+				$data['departure_airport_icao'] = $line['depicao'];
928
+				$data['departure_airport_time'] = $line['deptime'];
929
+				$data['arrival_airport_icao'] = $line['arricao'];
930
+				$data['arrival_airport_time'] = $line['arrtime'];
931
+				$data['registration'] = $line['aircraft'];
932
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
933
+			if (isset($line['aircraftname'])) {
934 934
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
935 935
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
936
-	    		$aircraft_data = explode('-',$line['aircraftname']);
937
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
938
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
939
-	    		else {
940
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
941
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
942
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
943
-	    		}
944
-	    	    }
945
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
946
-    		    $data['id_source'] = $id_source;
947
-	    	    $data['format_source'] = 'phpvmacars';
948
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
949
-		    $SI->add($data);
950
-		    unset($data);
936
+				$aircraft_data = explode('-',$line['aircraftname']);
937
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
938
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
939
+				else {
940
+					$aircraft_data = explode(' ',$line['aircraftname']);
941
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
942
+					else $data['aircraft_icao'] = $line['aircraftname'];
943
+				}
944
+				}
945
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
946
+				$data['id_source'] = $id_source;
947
+				$data['format_source'] = 'phpvmacars';
948
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
949
+			$SI->add($data);
950
+			unset($data);
951 951
 		}
952 952
 		if ($globalDebug) echo 'No more data...'."\n";
953 953
 		unset($buffer);
954 954
 		unset($all_data);
955
-	    }
956
-    	    //$last_exec['phpvmacars'] = time();
957
-    	    $last_exec[$id]['last'] = time();
958
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
959
-	    //$buffer = $Common->getData($hosts[$id]);
960
-	    if ($globalDebug) echo 'Get Data...'."\n";
961
-	    $buffer = $Common->getData($value['host']);
962
-	    $all_data = json_decode($buffer,true);
963
-	    if ($buffer != '' && is_array($all_data)) {
955
+		}
956
+			//$last_exec['phpvmacars'] = time();
957
+			$last_exec[$id]['last'] = time();
958
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
959
+		//$buffer = $Common->getData($hosts[$id]);
960
+		if ($globalDebug) echo 'Get Data...'."\n";
961
+		$buffer = $Common->getData($value['host']);
962
+		$all_data = json_decode($buffer,true);
963
+		if ($buffer != '' && is_array($all_data)) {
964 964
 		$reset = 0;
965 965
 		foreach ($all_data as $line) {
966
-	    	    $data = array();
967
-	    	    //$data['id'] = $line['id']; // id not usable
968
-	    	    $data['id'] = trim($line['flight_id']);
969
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
970
-	    	    $data['pilot_name'] = $line['pilot_name'];
971
-	    	    $data['pilot_id'] = $line['pilot_id'];
972
-	    	    $data['ident'] = trim($line['callsign']); // ident
973
-	    	    $data['altitude'] = $line['altitude']; // altitude
974
-	    	    $data['speed'] = $line['gs']; // speed
975
-	    	    $data['heading'] = $line['heading']; // heading
976
-	    	    $data['latitude'] = $line['latitude']; // lat
977
-	    	    $data['longitude'] = $line['longitude']; // long
978
-	    	    $data['verticalrate'] = ''; // verticale rate
979
-	    	    $data['squawk'] = ''; // squawk
980
-	    	    $data['emergency'] = ''; // emergency
981
-	    	    //$data['datetime'] = $line['lastupdate'];
982
-	    	    $data['last_update'] = $line['last_update'];
983
-		    $data['datetime'] = date('Y-m-d H:i:s');
984
-	    	    $data['departure_airport_icao'] = $line['departure'];
985
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
986
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
987
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
988
-    		    //$data['registration'] = $line['aircraft'];
989
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
990
-	    	    $data['aircraft_icao'] = $line['plane_type'];
991
-    		    $data['id_source'] = $id_source;
992
-	    	    $data['format_source'] = 'vam';
993
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
994
-		    $SI->add($data);
995
-		    unset($data);
966
+				$data = array();
967
+				//$data['id'] = $line['id']; // id not usable
968
+				$data['id'] = trim($line['flight_id']);
969
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
970
+				$data['pilot_name'] = $line['pilot_name'];
971
+				$data['pilot_id'] = $line['pilot_id'];
972
+				$data['ident'] = trim($line['callsign']); // ident
973
+				$data['altitude'] = $line['altitude']; // altitude
974
+				$data['speed'] = $line['gs']; // speed
975
+				$data['heading'] = $line['heading']; // heading
976
+				$data['latitude'] = $line['latitude']; // lat
977
+				$data['longitude'] = $line['longitude']; // long
978
+				$data['verticalrate'] = ''; // verticale rate
979
+				$data['squawk'] = ''; // squawk
980
+				$data['emergency'] = ''; // emergency
981
+				//$data['datetime'] = $line['lastupdate'];
982
+				$data['last_update'] = $line['last_update'];
983
+			$data['datetime'] = date('Y-m-d H:i:s');
984
+				$data['departure_airport_icao'] = $line['departure'];
985
+				//$data['departure_airport_time'] = $line['departure_time'];
986
+				$data['arrival_airport_icao'] = $line['arrival'];
987
+				//$data['arrival_airport_time'] = $line['arrival_time'];
988
+				//$data['registration'] = $line['aircraft'];
989
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
990
+				$data['aircraft_icao'] = $line['plane_type'];
991
+				$data['id_source'] = $id_source;
992
+				$data['format_source'] = 'vam';
993
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
994
+			$SI->add($data);
995
+			unset($data);
996 996
 		}
997 997
 		if ($globalDebug) echo 'No more data...'."\n";
998 998
 		unset($buffer);
999 999
 		unset($all_data);
1000
-	    }
1001
-    	    //$last_exec['phpvmacars'] = time();
1002
-    	    $last_exec[$id]['last'] = time();
1000
+		}
1001
+			//$last_exec['phpvmacars'] = time();
1002
+			$last_exec[$id]['last'] = time();
1003 1003
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1004 1004
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1005
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1006
-    	    //$last_exec[$id]['last'] = time();
1005
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1006
+			//$last_exec[$id]['last'] = time();
1007 1007
 
1008
-	    //$read = array( $sockets[$id] );
1009
-	    $read = $sockets;
1010
-	    $write = NULL;
1011
-	    $e = NULL;
1012
-	    $n = socket_select($read, $write, $e, $timeout);
1013
-	    if ($e != NULL) var_dump($e);
1014
-	    if ($n > 0) {
1008
+		//$read = array( $sockets[$id] );
1009
+		$read = $sockets;
1010
+		$write = NULL;
1011
+		$e = NULL;
1012
+		$n = socket_select($read, $write, $e, $timeout);
1013
+		if ($e != NULL) var_dump($e);
1014
+		if ($n > 0) {
1015 1015
 		$reset = 0;
1016 1016
 		foreach ($read as $nb => $r) {
1017
-		    //$value = $formats[$nb];
1018
-		    $format = $globalSources[$nb]['format'];
1019
-        	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3' || $format == 'vrstcp') {
1020
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
1021
-        	    } else {
1022
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1023
-	    	    }
1024
-        	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1025
-        	    //echo $buffer."\n";
1026
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1027
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1028
-		    $error = false;
1029
-		    //$SI::del();
1030
-		    if ($format == 'vrstcp') {
1017
+			//$value = $formats[$nb];
1018
+			$format = $globalSources[$nb]['format'];
1019
+				if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3' || $format == 'vrstcp') {
1020
+				$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
1021
+				} else {
1022
+					$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1023
+				}
1024
+				//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1025
+				//echo $buffer."\n";
1026
+			// lets play nice and handle signals such as ctrl-c/kill properly
1027
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1028
+			$error = false;
1029
+			//$SI::del();
1030
+			if ($format == 'vrstcp') {
1031 1031
 			$buffer = explode('},{',$buffer);
1032
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1033
-		    // SBS format is CSV format
1034
-		    if ($buffer != '') {
1032
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1033
+			// SBS format is CSV format
1034
+			if ($buffer != '') {
1035 1035
 			$tt[$format] = 0;
1036 1036
 			if ($format == 'acarssbs3') {
1037
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1038
-			    $ACARS->add(trim($buffer));
1039
-			    $ACARS->deleteLiveAcarsData();
1037
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1038
+				$ACARS->add(trim($buffer));
1039
+				$ACARS->deleteLiveAcarsData();
1040 1040
 			} elseif ($format == 'raw') {
1041
-			    // AVR format
1042
-			    $data = $SBS->parse($buffer);
1043
-			    if (is_array($data)) {
1041
+				// AVR format
1042
+				$data = $SBS->parse($buffer);
1043
+				if (is_array($data)) {
1044 1044
 				$data['datetime'] = date('Y-m-d H:i:s');
1045 1045
 				$data['format_source'] = 'raw';
1046 1046
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1047
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1048
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1049
-                            }
1050
-                        } elseif ($format == 'ais') {
1051
-			    $ais_data = $AIS->parse_line(trim($buffer));
1052
-			    $data = array();
1053
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1054
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1055
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1056
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1057
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1058
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1059
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1060
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1061
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1062
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1063
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1064
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1047
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1048
+								if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1049
+							}
1050
+						} elseif ($format == 'ais') {
1051
+				$ais_data = $AIS->parse_line(trim($buffer));
1052
+				$data = array();
1053
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1054
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1055
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1056
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1057
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1058
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1059
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1060
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1061
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1062
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1063
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1064
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1065 1065
 
1066
-			    if (isset($ais_data['timestamp'])) {
1066
+				if (isset($ais_data['timestamp'])) {
1067 1067
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1068
-			    } else {
1068
+				} else {
1069 1069
 				$data['datetime'] = date('Y-m-d H:i:s');
1070
-			    }
1071
-			    $data['format_source'] = 'aisnmea';
1072
-    			    $data['id_source'] = $id_source;
1073
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1074
-			    unset($data);
1075
-                        } elseif ($format == 'flightgearsp') {
1076
-                    	    //echo $buffer."\n";
1077
-                    	    if (strlen($buffer) > 5) {
1070
+				}
1071
+				$data['format_source'] = 'aisnmea';
1072
+					$data['id_source'] = $id_source;
1073
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1074
+				unset($data);
1075
+						} elseif ($format == 'flightgearsp') {
1076
+							//echo $buffer."\n";
1077
+							if (strlen($buffer) > 5) {
1078 1078
 				$line = explode(',',$buffer);
1079 1079
 				$data = array();
1080 1080
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1090,37 +1090,37 @@  discard block
 block discarded – undo
1090 1090
 				$data['format_source'] = 'flightgearsp';
1091 1091
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1092 1092
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1093
-			    }
1094
-                        } elseif ($format == 'acars') {
1095
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1096
-			    $ACARS->add(trim($buffer));
1097
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1098
-			    $ACARS->deleteLiveAcarsData();
1093
+				}
1094
+						} elseif ($format == 'acars') {
1095
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1096
+				$ACARS->add(trim($buffer));
1097
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1098
+				$ACARS->deleteLiveAcarsData();
1099 1099
 			} elseif ($format == 'flightgearmp') {
1100
-			    if (substr($buffer,0,1) != '#') {
1100
+				if (substr($buffer,0,1) != '#') {
1101 1101
 				$data = array();
1102 1102
 				//echo $buffer."\n";
1103 1103
 				$line = explode(' ',$buffer);
1104 1104
 				if (count($line) == 11) {
1105
-				    $userserver = explode('@',$line[0]);
1106
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1107
-				    $data['ident'] = $userserver[0];
1108
-				    $data['registration'] = $userserver[0];
1109
-				    $data['latitude'] = $line[4];
1110
-				    $data['longitude'] = $line[5];
1111
-				    $data['altitude'] = $line[6];
1112
-				    $data['datetime'] = date('Y-m-d H:i:s');
1113
-				    $aircraft_type = $line[10];
1114
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1115
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1116
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1105
+					$userserver = explode('@',$line[0]);
1106
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1107
+					$data['ident'] = $userserver[0];
1108
+					$data['registration'] = $userserver[0];
1109
+					$data['latitude'] = $line[4];
1110
+					$data['longitude'] = $line[5];
1111
+					$data['altitude'] = $line[6];
1112
+					$data['datetime'] = date('Y-m-d H:i:s');
1113
+					$aircraft_type = $line[10];
1114
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1115
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1116
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1117
+				}
1117 1118
 				}
1118
-			    }
1119 1119
 			} elseif ($format == 'beast') {
1120
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1121
-			    die;
1120
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1121
+				die;
1122 1122
 			} elseif ($format == 'vrstcp') {
1123
-			    foreach($buffer as $all_data) {
1123
+				foreach($buffer as $all_data) {
1124 1124
 				$line = json_decode('{'.$all_data.'}',true);
1125 1125
 				$data = array();
1126 1126
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1140,100 +1140,100 @@  discard block
 block discarded – undo
1140 1140
 				*/
1141 1141
 				$data['datetime'] = date('Y-m-d H:i:s');
1142 1142
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1143
-		    		$data['format_source'] = 'vrstcp';
1143
+					$data['format_source'] = 'vrstcp';
1144 1144
 				$data['id_source'] = $id_source;
1145 1145
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1146 1146
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1147 1147
 				unset($data);
1148
-			    }
1148
+				}
1149 1149
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1150
-			    $line = explode("\t", $buffer);
1151
-			    for($k = 0; $k < count($line); $k=$k+2) {
1150
+				$line = explode("\t", $buffer);
1151
+				for($k = 0; $k < count($line); $k=$k+2) {
1152 1152
 				$key = $line[$k];
1153
-			        $lined[$key] = $line[$k+1];
1154
-			    }
1155
-    			    if (count($lined) > 3) {
1156
-    				$data['hex'] = $lined['hexid'];
1157
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1158
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1159
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1160
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1161
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1162
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1163
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1164
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1165
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1166
-    				$data['id_source'] = $id_source;
1167
-    				$data['format_source'] = 'tsv';
1168
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1169
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1170
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1171
-    				unset($lined);
1172
-    				unset($data);
1173
-    			    } else $error = true;
1153
+					$lined[$key] = $line[$k+1];
1154
+				}
1155
+					if (count($lined) > 3) {
1156
+					$data['hex'] = $lined['hexid'];
1157
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1158
+					$data['datetime'] = date('Y-m-d H:i:s');;
1159
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1160
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1161
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1162
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1163
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1164
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1165
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1166
+					$data['id_source'] = $id_source;
1167
+					$data['format_source'] = 'tsv';
1168
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1169
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1170
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1171
+					unset($lined);
1172
+					unset($data);
1173
+					} else $error = true;
1174 1174
 			} elseif ($format == 'aprs' && $use_aprs) {
1175
-			    if ($aprs_connect == 0) {
1175
+				if ($aprs_connect == 0) {
1176 1176
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1177 1177
 				$aprs_connect = 1;
1178
-			    }
1178
+				}
1179 1179
 			    
1180
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1180
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1181 1181
 				$aprs_last_tx = time();
1182 1182
 				$data_aprs = "# Keep alive";
1183 1183
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1184
-			    }
1184
+				}
1185 1185
 			    
1186
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1187
-			    //echo 'APRS data : '.$buffer."\n";
1188
-			    $buffer = str_replace('APRS <- ','',$buffer);
1189
-			    $buffer = str_replace('APRS -> ','',$buffer);
1190
-			    //echo $buffer."\n";
1191
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1186
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1187
+				//echo 'APRS data : '.$buffer."\n";
1188
+				$buffer = str_replace('APRS <- ','',$buffer);
1189
+				$buffer = str_replace('APRS -> ','',$buffer);
1190
+				//echo $buffer."\n";
1191
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1192 1192
 				$line = $APRS->parse($buffer);
1193 1193
 				//print_r($line);
1194 1194
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1195 1195
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']))) {
1196
-				    $aprs_last_tx = time();
1197
-				    $data = array();
1198
-				    //print_r($line);
1199
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1200
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1201
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1202
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1203
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1204
-				    $data['latitude'] = $line['latitude'];
1205
-				    $data['longitude'] = $line['longitude'];
1206
-				    //$data['verticalrate'] = $line[16];
1207
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1208
-				    else $data['speed'] = 0;
1209
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1210
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1211
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1212
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1213
-				    //else $data['heading'] = 0;
1214
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1215
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1216
-    				    $data['id_source'] = $id_source;
1217
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1218
-				    else $data['format_source'] = 'aprs';
1219
-				    $data['source_name'] = $line['source'];
1220
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1221
-				    else $data['source_type'] = 'flarm';
1222
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1223
-				    $currentdate = date('Y-m-d H:i:s');
1224
-				    $aprsdate = strtotime($data['datetime']);
1225
-				    // Accept data if time <= system time + 20s
1226
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1196
+					$aprs_last_tx = time();
1197
+					$data = array();
1198
+					//print_r($line);
1199
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1200
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1201
+					else $data['datetime'] = date('Y-m-d H:i:s');
1202
+					//$data['datetime'] = date('Y-m-d H:i:s');
1203
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1204
+					$data['latitude'] = $line['latitude'];
1205
+					$data['longitude'] = $line['longitude'];
1206
+					//$data['verticalrate'] = $line[16];
1207
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1208
+					else $data['speed'] = 0;
1209
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1210
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1211
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1212
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1213
+					//else $data['heading'] = 0;
1214
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1215
+					if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1216
+						$data['id_source'] = $id_source;
1217
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1218
+					else $data['format_source'] = 'aprs';
1219
+					$data['source_name'] = $line['source'];
1220
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1221
+					else $data['source_type'] = 'flarm';
1222
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1223
+					$currentdate = date('Y-m-d H:i:s');
1224
+					$aprsdate = strtotime($data['datetime']);
1225
+					// Accept data if time <= system time + 20s
1226
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1227 1227
 					$send = $SI->add($data);
1228
-				    } elseif (isset($line['stealth'])) {
1228
+					} elseif (isset($line['stealth'])) {
1229 1229
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1230 1230
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1231
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1232
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1231
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1232
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1233 1233
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1234 1234
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1235
-				    }
1236
-				    unset($data);
1235
+					}
1236
+					unset($data);
1237 1237
 				} 
1238 1238
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1239 1239
 					echo '!! Weather Station not yet supported'."\n";
@@ -1243,12 +1243,12 @@  discard block
 block discarded – undo
1243 1243
 				}
1244 1244
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1245 1245
 				//elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1246
-			    }
1246
+				}
1247 1247
 			} else {
1248
-			    $line = explode(',', $buffer);
1249
-    			    if (count($line) > 20) {
1250
-    			    	$data['hex'] = $line[4];
1251
-    				/*
1248
+				$line = explode(',', $buffer);
1249
+					if (count($line) > 20) {
1250
+						$data['hex'] = $line[4];
1251
+					/*
1252 1252
     				$data['datetime'] = $line[6].' '.$line[7];
1253 1253
     					date_default_timezone_set($globalTimezone);
1254 1254
     					$datetime = new DateTime($data['datetime']);
@@ -1256,29 +1256,29 @@  discard block
 block discarded – undo
1256 1256
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1257 1257
     					date_default_timezone_set('UTC');
1258 1258
     				*/
1259
-    				// Force datetime to current UTC datetime
1260
-    				date_default_timezone_set('UTC');
1261
-    				$data['datetime'] = date('Y-m-d H:i:s');
1262
-    				$data['ident'] = trim($line[10]);
1263
-    				$data['latitude'] = $line[14];
1264
-    				$data['longitude'] = $line[15];
1265
-    				$data['verticalrate'] = $line[16];
1266
-    				$data['emergency'] = $line[20];
1267
-    				$data['speed'] = $line[12];
1268
-    				$data['squawk'] = $line[17];
1269
-    				$data['altitude'] = $line[11];
1270
-    				$data['heading'] = $line[13];
1271
-    				$data['ground'] = $line[21];
1272
-    				$data['emergency'] = $line[19];
1273
-    				$data['format_source'] = 'sbs';
1259
+					// Force datetime to current UTC datetime
1260
+					date_default_timezone_set('UTC');
1261
+					$data['datetime'] = date('Y-m-d H:i:s');
1262
+					$data['ident'] = trim($line[10]);
1263
+					$data['latitude'] = $line[14];
1264
+					$data['longitude'] = $line[15];
1265
+					$data['verticalrate'] = $line[16];
1266
+					$data['emergency'] = $line[20];
1267
+					$data['speed'] = $line[12];
1268
+					$data['squawk'] = $line[17];
1269
+					$data['altitude'] = $line[11];
1270
+					$data['heading'] = $line[13];
1271
+					$data['ground'] = $line[21];
1272
+					$data['emergency'] = $line[19];
1273
+					$data['format_source'] = 'sbs';
1274 1274
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1275
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1276
-    				$data['id_source'] = $id_source;
1277
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1278
-    				else $error = true;
1279
-    				unset($data);
1280
-    			    } else $error = true;
1281
-			    if ($error) {
1275
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1276
+					$data['id_source'] = $id_source;
1277
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1278
+					else $error = true;
1279
+					unset($data);
1280
+					} else $error = true;
1281
+				if ($error) {
1282 1282
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1283 1283
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1284 1284
 				} else {
@@ -1294,13 +1294,13 @@  discard block
 block discarded – undo
1294 1294
 					connect_all($sourceer);
1295 1295
 					$sourceer = array();
1296 1296
 				}
1297
-			    }
1297
+				}
1298 1298
 			}
1299 1299
 			// Sleep for xxx microseconds
1300 1300
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1301
-		    } else {
1301
+			} else {
1302 1302
 			if ($format == 'flightgearmp') {
1303
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1303
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1304 1304
 				//@socket_close($r);
1305 1305
 				sleep($globalMinFetch);
1306 1306
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1309,9 +1309,9 @@  discard block
 block discarded – undo
1309 1309
 				break;
1310 1310
 				
1311 1311
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1312
-			    if (isset($tt[$format])) $tt[$format]++;
1313
-			    else $tt[$format] = 0;
1314
-			    if ($tt[$format] > 30) {
1312
+				if (isset($tt[$format])) $tt[$format]++;
1313
+				else $tt[$format] = 0;
1314
+				if ($tt[$format] > 30) {
1315 1315
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1316 1316
 				//@socket_close($r);
1317 1317
 				sleep(2);
@@ -1322,23 +1322,23 @@  discard block
 block discarded – undo
1322 1322
 				//connect_all($globalSources);
1323 1323
 				$tt[$format]=0;
1324 1324
 				break;
1325
-			    }
1325
+				}
1326
+			}
1326 1327
 			}
1327
-		    }
1328 1328
 		}
1329
-	    } else {
1329
+		} else {
1330 1330
 		$error = socket_strerror(socket_last_error());
1331 1331
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1332 1332
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1333 1333
 			if (isset($globalDebug)) echo "Restarting...\n";
1334 1334
 			// Restart the script if possible
1335 1335
 			if (is_array($sockets)) {
1336
-			    if ($globalDebug) echo "Shutdown all sockets...";
1336
+				if ($globalDebug) echo "Shutdown all sockets...";
1337 1337
 			    
1338
-			    foreach ($sockets as $sock) {
1338
+				foreach ($sockets as $sock) {
1339 1339
 				@socket_shutdown($sock,2);
1340 1340
 				@socket_close($sock);
1341
-			    }
1341
+				}
1342 1342
 			    
1343 1343
 			}
1344 1344
 			if ($globalDebug) echo "Restart all connections...";
@@ -1349,13 +1349,13 @@  discard block
 block discarded – undo
1349 1349
 			if ($reset > 40) exit('Too many attempts...');
1350 1350
 			connect_all($globalSources);
1351 1351
 		}
1352
-	    }
1352
+		}
1353 1353
 	}
1354 1354
 	if ($globalDaemon === false) {
1355
-	    if ($globalDebug) echo 'Check all...'."\n";
1356
-	    $SI->checkAll();
1355
+		if ($globalDebug) echo 'Check all...'."\n";
1356
+		$SI->checkAll();
1357
+	}
1357 1358
 	}
1358
-    }
1359 1359
 }
1360 1360
 
1361 1361
 ?>
Please login to merge, or discard this patch.
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 	    die;
46 46
 	}
47 47
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
48
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
48
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
49 49
     }
50 50
 }
51 51
 
52
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::'));
52
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::'));
53 53
 //if (isset($options['s'])) $hosts = array($options['s']);
54 54
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 55
 if (isset($options['s'])) {
@@ -67,27 +67,27 @@  discard block
 block discarded – undo
67 67
 else $id_source = 1;
68 68
 if (isset($globalServer) && $globalServer) {
69 69
     if ($globalDebug) echo "Using Server Mode\n";
70
-    $SI=new SpotterServer();
70
+    $SI = new SpotterServer();
71 71
 /*
72 72
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
73 73
     $SI = new adsb2aprs();
74 74
     $SI->connect();
75 75
 */
76
-} else $SI=new SpotterImport($Connection->db);
76
+} else $SI = new SpotterImport($Connection->db);
77 77
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
78 78
 if (isset($globalMarine) && $globalMarine) {
79 79
     $AIS = new AIS();
80 80
     $MI = new MarineImport($Connection->db);
81 81
 }
82 82
 //$APRS=new APRS($Connection->db);
83
-$SBS=new SBS();
84
-$ACARS=new ACARS($Connection->db);
85
-$Common=new Common();
83
+$SBS = new SBS();
84
+$ACARS = new ACARS($Connection->db);
85
+$Common = new Common();
86 86
 date_default_timezone_set('UTC');
87 87
 //$servertz = system('date +%Z');
88 88
 // signal handler - playing nice with sockets and dump1090
89 89
 if (function_exists('pcntl_fork')) {
90
-    pcntl_signal(SIGINT,  function() {
90
+    pcntl_signal(SIGINT, function() {
91 91
         global $sockets;
92 92
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
93 93
         die("Bye!\n");
@@ -103,35 +103,35 @@  discard block
 block discarded – undo
103 103
 
104 104
 function connect_all($hosts) {
105 105
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
106
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
106
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
107 107
     $reset++;
108 108
     if ($globalDebug) echo 'Connect to all...'."\n";
109 109
     foreach ($hosts as $id => $value) {
110 110
 	$host = $value['host'];
111 111
 	$globalSources[$id]['last_exec'] = 0;
112 112
 	// Here we check type of source(s)
113
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
114
-            if (preg_match('/deltadb.txt$/i',$host)) {
113
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
114
+            if (preg_match('/deltadb.txt$/i', $host)) {
115 115
         	//$formats[$id] = 'deltadbtxt';
116 116
         	$globalSources[$id]['format'] = 'deltadbtxt';
117 117
         	//$last_exec['deltadbtxt'] = 0;
118 118
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
119
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
119
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
120 120
         	//$formats[$id] = 'vatsimtxt';
121 121
         	$globalSources[$id]['format'] = 'vatsimtxt';
122 122
         	//$last_exec['vatsimtxt'] = 0;
123 123
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
124
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
124
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
125 125
         	//$formats[$id] = 'aircraftlistjson';
126 126
         	$globalSources[$id]['format'] = 'aircraftlistjson';
127 127
         	//$last_exec['aircraftlistjson'] = 0;
128 128
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
129
-    	    } else if (preg_match('/opensky/i',$host)) {
129
+    	    } else if (preg_match('/opensky/i', $host)) {
130 130
         	//$formats[$id] = 'aircraftlistjson';
131 131
         	$globalSources[$id]['format'] = 'opensky';
132 132
         	//$last_exec['aircraftlistjson'] = 0;
133 133
         	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
134
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
134
+    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) {
135 135
         	//$formats[$id] = 'radarvirtueljson';
136 136
         	$globalSources[$id]['format'] = 'radarvirtueljson';
137 137
         	//$last_exec['radarvirtueljson'] = 0;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
141 141
         	    exit(0);
142 142
         	}
143
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
143
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
144 144
         	//$formats[$id] = 'planeupdatefaa';
145 145
         	$globalSources[$id]['format'] = 'planeupdatefaa';
146 146
         	//$last_exec['planeupdatefaa'] = 0;
@@ -149,26 +149,26 @@  discard block
 block discarded – undo
149 149
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
150 150
         	    exit(0);
151 151
         	}
152
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
152
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
153 153
         	//$formats[$id] = 'phpvmacars';
154 154
         	$globalSources[$id]['format'] = 'phpvmacars';
155 155
         	//$last_exec['phpvmacars'] = 0;
156 156
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
157
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
157
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
158 158
         	//$formats[$id] = 'phpvmacars';
159 159
         	$globalSources[$id]['format'] = 'vam';
160 160
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
161
-            } else if (preg_match('/whazzup/i',$host)) {
161
+            } else if (preg_match('/whazzup/i', $host)) {
162 162
         	//$formats[$id] = 'whazzup';
163 163
         	$globalSources[$id]['format'] = 'whazzup';
164 164
         	//$last_exec['whazzup'] = 0;
165 165
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
166
-            } else if (preg_match('/recentpireps/i',$host)) {
166
+            } else if (preg_match('/recentpireps/i', $host)) {
167 167
         	//$formats[$id] = 'pirepsjson';
168 168
         	$globalSources[$id]['format'] = 'pirepsjson';
169 169
         	//$last_exec['pirepsjson'] = 0;
170 170
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
171
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
171
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
172 172
         	//$formats[$id] = 'fr24json';
173 173
         	$globalSources[$id]['format'] = 'fr24json';
174 174
         	//$last_exec['fr24json'] = 0;
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
178 178
         	    exit(0);
179 179
         	}
180
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
180
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
181 181
         	//$formats[$id] = 'fr24json';
182 182
         	$globalSources[$id]['format'] = 'myshiptracking';
183 183
         	//$last_exec['fr24json'] = 0;
@@ -187,22 +187,22 @@  discard block
 block discarded – undo
187 187
         	    exit(0);
188 188
         	}
189 189
             //} else if (preg_match('/10001/',$host)) {
190
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
190
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
191 191
         	//$formats[$id] = 'tsv';
192 192
         	$globalSources[$id]['format'] = 'tsv';
193 193
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
194 194
             }
195
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
195
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
196 196
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
197
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
197
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
198 198
     		    if ($idf !== false) {
199 199
     			$httpfeeds[$id] = $idf;
200 200
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
201 201
     		    }
202 202
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
203 203
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
204
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
205
-	    $hostport = explode(':',$host);
204
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
205
+	    $hostport = explode(':', $host);
206 206
 	    if (isset($hostport[1])) {
207 207
 		$port = $hostport[1];
208 208
 		$hostn = $hostport[0];
@@ -212,19 +212,19 @@  discard block
 block discarded – undo
212 212
 	    }
213 213
 	    $Common = new Common();
214 214
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
215
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
215
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
216 216
     	    } else {
217
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
217
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
218 218
 	    }
219 219
 	    if ($s) {
220 220
     	        $sockets[$id] = $s;
221 221
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
222
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
222
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
223 223
 			//$formats[$id] = 'aprs';
224 224
 			$globalSources[$id]['format'] = 'aprs';
225 225
 			//$aprs_connect = 0;
226 226
 			//$use_aprs = true;
227
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
227
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
228 228
 			$globalSources[$id]['format'] = 'vrstcp';
229 229
     		    } elseif ($port == '10001') {
230 230
         		//$formats[$id] = 'tsv';
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
264 264
 else $timeout = 20;
265 265
 $errno = '';
266
-$errstr='';
266
+$errstr = '';
267 267
 
268 268
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
269 269
 /* Initiate connections to all the hosts simultaneously */
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 //connect_all($globalSources);
272 272
 
273 273
 if (isset($globalProxy) && $globalProxy) {
274
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
274
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
275 275
 } else {
276 276
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
277 277
 }
@@ -298,16 +298,16 @@  discard block
 block discarded – undo
298 298
 
299 299
 if ($use_aprs) {
300 300
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
301
-	$APRS=new APRS();
301
+	$APRS = new APRS();
302 302
 	$aprs_connect = 0;
303 303
 	$aprs_keep = 120;
304 304
 	$aprs_last_tx = time();
305 305
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
306
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
306
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
307 307
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
308
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
308
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
309 309
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
310
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
310
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
311 311
 	if ($aprs_full) $aprs_filter = '';
312 312
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
313 313
 	else $aprs_pass = '-1';
@@ -322,12 +322,12 @@  discard block
 block discarded – undo
322 322
 sleep(1);
323 323
 if ($globalDebug) echo "SCAN MODE \n\n";
324 324
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
325
-$endtime = time()+$globalCronEnd;
325
+$endtime = time() + $globalCronEnd;
326 326
 $i = 1;
327 327
 $tt = array();
328 328
 // Delete all ATC
329 329
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
330
-	$ATC=new ATC($Connection->db);
330
+	$ATC = new ATC($Connection->db);
331 331
 }
332 332
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
333 333
 	$ATC->deleteAll();
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 
336 336
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
337 337
 while ($i > 0) {
338
-    if (!$globalDaemon) $i = $endtime-time();
338
+    if (!$globalDaemon) $i = $endtime - time();
339 339
     // Delete old ATC
340 340
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
341 341
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	}
351 351
 	if ($max != $globalMinFetch) {
352 352
 	    if ($globalDebug) echo 'Sleeping...'."\n";
353
-	    sleep($globalMinFetch-$max+2);
353
+	    sleep($globalMinFetch - $max + 2);
354 354
 	}
355 355
     }
356 356
 
@@ -363,8 +363,8 @@  discard block
 block discarded – undo
363 363
 	    //$buffer = $Common->getData($hosts[$id]);
364 364
 	    $buffer = $Common->getData($value['host']);
365 365
 	    if ($buffer != '') $reset = 0;
366
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
367
-	    $buffer = explode('\n',$buffer);
366
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
367
+	    $buffer = explode('\n', $buffer);
368 368
 	    foreach ($buffer as $line) {
369 369
     		if ($line != '' && count($line) > 7) {
370 370
     		    $line = explode(',', $line);
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
     	    $last_exec[$id]['last'] = time();
392 392
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
393 393
 	    date_default_timezone_set('CET');
394
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
394
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
395 395
 	    date_default_timezone_set('UTC');
396 396
 	    if ($buffer != '') $reset = 0;
397
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
398
-	    $buffer = explode('\n',$buffer);
397
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
398
+	    $buffer = explode('\n', $buffer);
399 399
 	    foreach ($buffer as $line) {
400 400
 		if ($line != '') {
401 401
 		    echo "'".$line."'\n";
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
414 414
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
415 415
 		    if (isset($ais_data['timestamp'])) {
416
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
416
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
417 417
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
418 418
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
419 419
 			    $add = true;
@@ -436,12 +436,12 @@  discard block
 block discarded – undo
436 436
 	    $w = $e = null;
437 437
 	    
438 438
 	    if (isset($arr[$id])) {
439
-	    $nn = stream_select($arr,$w,$e,$timeout);
439
+	    $nn = stream_select($arr, $w, $e, $timeout);
440 440
 	    if ($nn > 0) {
441 441
 		foreach ($httpfeeds as $feed) {
442
-		    $buffer = stream_get_line($feed,2000,"\n");
443
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
444
-		    $buffer = explode('\n',$buffer);
442
+		    $buffer = stream_get_line($feed, 2000, "\n");
443
+		    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
444
+		    $buffer = explode('\n', $buffer);
445 445
 		    foreach ($buffer as $line) {
446 446
 			if ($line != '') {
447 447
 			    $ais_data = $AIS->parse_line(trim($line));
@@ -457,9 +457,9 @@  discard block
 block discarded – undo
457 457
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
458 458
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
459 459
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
460
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
460
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
461 461
 			    if (isset($ais_data['timestamp'])) {
462
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
462
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
463 463
 			    } else {
464 464
 				$data['datetime'] = date('Y-m-d H:i:s');
465 465
 			    }
@@ -473,10 +473,10 @@  discard block
 block discarded – undo
473 473
 		}
474 474
 	    }
475 475
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
476
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
476
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
477 477
 	    if ($buffer != '') {
478 478
 		//echo $buffer;
479
-		$all_data = json_decode($buffer,true);
479
+		$all_data = json_decode($buffer, true);
480 480
 		//print_r($all_data);
481 481
 		if (isset($all_data[0]['DATA'])) {
482 482
 		foreach ($all_data[0]['DATA'] as $line) {
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 			//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
492 492
 			$data['imo'] = $line['IMO'];
493 493
 			//$data['arrival_code'] = $ais_data['destination'];
494
-			$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
494
+			$data['datetime'] = date('Y-m-d H:i:s', $line['T']);
495 495
 			$data['format_source'] = 'myshiptracking';
496 496
 			$data['id_source'] = $id_source;
497 497
 			$MI->add($data);
@@ -503,9 +503,9 @@  discard block
 block discarded – undo
503 503
 	    }
504 504
     	    $last_exec[$id]['last'] = time();
505 505
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
506
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
506
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
507 507
 	    if ($buffer != '') {
508
-		$all_data = json_decode($buffer,true);
508
+		$all_data = json_decode($buffer, true);
509 509
 		if (isset($all_data[0]['mmsi'])) {
510 510
 		    foreach ($all_data as $line) {
511 511
 			if ($line != '') {
@@ -532,27 +532,27 @@  discard block
 block discarded – undo
532 532
     	    $last_exec[$id]['last'] = time();
533 533
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
534 534
 	    echo 'download...';
535
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
535
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
536 536
 	    echo 'done !'."\n";
537 537
 	    if ($buffer != '') $reset = 0;
538
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539
-	    $buffer = explode('\n',$buffer);
538
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
539
+	    $buffer = explode('\n', $buffer);
540 540
 	    foreach ($buffer as $line) {
541 541
 		if ($line != '') {
542 542
 		    $data = array();
543
-		    $data['mmsi'] = (int)substr($line,0,9);
544
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
543
+		    $data['mmsi'] = (int) substr($line, 0, 9);
544
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
545 545
 		    //$data['status'] = substr($line,21,2);
546 546
 		    //$data['type'] = substr($line,24,3);
547
-		    $data['latitude'] = substr($line,29,9);
548
-		    $data['longitude'] = substr($line,41,9);
549
-		    $data['speed'] = round(substr($line,51,5));
547
+		    $data['latitude'] = substr($line, 29, 9);
548
+		    $data['longitude'] = substr($line, 41, 9);
549
+		    $data['speed'] = round(substr($line, 51, 5));
550 550
 		    //$data['course'] = substr($line,57,5);
551
-		    $data['heading'] = round(substr($line,63,3));
551
+		    $data['heading'] = round(substr($line, 63, 3));
552 552
 		    //$data['draft'] = substr($line,67,4);
553 553
 		    //$data['length'] = substr($line,72,3);
554 554
 		    //$data['beam'] = substr($line,76,2);
555
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
555
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
556 556
 		    //$data['callsign'] = trim(substr($line,100,7);
557 557
 		    //$data['dest'] = substr($line,108,20);
558 558
 		    //$data['etaDate'] = substr($line,129,5);
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
571 571
 	    //$buffer = $Common->getData($hosts[$id]);
572 572
 	    $buffer = $Common->getData($value['host']);
573
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
574
-	    $buffer = explode('\n',$buffer);
573
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
574
+	    $buffer = explode('\n', $buffer);
575 575
 	    $reset = 0;
576 576
 	    foreach ($buffer as $line) {
577 577
     		if ($line != '') {
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
583 583
 			$data['pilot_id'] = $line[1];
584 584
 			$data['pilot_name'] = $line[2];
585
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
585
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
586 586
 			$data['ident'] = $line[0]; // ident
587 587
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
588 588
 			$data['speed'] = $line[8]; // speed
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
599 599
 			//if (isset($line[37])) $data['last_update'] = $line[37];
600 600
 		        $data['departure_airport_icao'] = $line[11];
601
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
601
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
602 602
 		        $data['arrival_airport_icao'] = $line[13];
603 603
 			$data['frequency'] = $line[4];
604 604
 			$data['type'] = $line[18];
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
     			$data['id_source'] = $id_source;
608 608
 	    		//$data['arrival_airport_time'] = ;
609 609
 	    		if ($line[9] != '') {
610
-	    		    $aircraft_data = explode('/',$line[9]);
610
+	    		    $aircraft_data = explode('/', $line[9]);
611 611
 	    		    if (isset($aircraft_data[1])) {
612 612
 	    			$data['aircraft_icao'] = $aircraft_data[1];
613 613
 	    		    }
@@ -621,9 +621,9 @@  discard block
 block discarded – undo
621 621
     			if ($line[3] == 'PILOT') $SI->add($data);
622 622
 			elseif ($line[3] == 'ATC') {
623 623
 				//print_r($data);
624
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
625
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
626
-				$typec = substr($data['ident'],-3);
624
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
625
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
626
+				$typec = substr($data['ident'], -3);
627 627
 				if ($typec == 'APP') $data['type'] = 'Approach';
628 628
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
629 629
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
635 635
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
636 636
 				if (!isset($data['source_name'])) $data['source_name'] = '';
637
-				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
637
+				if (isset($ATC)) echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
638 638
 			}
639 639
     			unset($data);
640 640
     		    }
@@ -645,9 +645,9 @@  discard block
 block discarded – undo
645 645
     	    $last_exec[$id]['last'] = time();
646 646
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
647 647
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
648
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
648
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
649 649
 	    if ($buffer != '') {
650
-	    $all_data = json_decode($buffer,true);
650
+	    $all_data = json_decode($buffer, true);
651 651
 	    if (isset($all_data['acList'])) {
652 652
 		$reset = 0;
653 653
 		foreach ($all_data['acList'] as $line) {
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
704 704
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
705 705
 	    $buffer = $Common->getData($value['host']);
706
-	    $all_data = json_decode($buffer,true);
706
+	    $all_data = json_decode($buffer, true);
707 707
 	    if (isset($all_data['planes'])) {
708 708
 		$reset = 0;
709 709
 		foreach ($all_data['planes'] as $key => $line) {
@@ -720,12 +720,12 @@  discard block
 block discarded – undo
720 720
 		    $data['emergency'] = ''; // emergency
721 721
 		    $data['registration'] = $line[2];
722 722
 		    $data['aircraft_icao'] = $line[0];
723
-		    $deparr = explode('-',$line[1]);
723
+		    $deparr = explode('-', $line[1]);
724 724
 		    if (count($deparr) == 2) {
725 725
 			$data['departure_airport_icao'] = $deparr[0];
726 726
 			$data['arrival_airport_icao'] = $deparr[1];
727 727
 		    }
728
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
728
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
729 729
 	    	    $data['format_source'] = 'planeupdatefaa';
730 730
     		    $data['id_source'] = $id_source;
731 731
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
     	    $last_exec[$id]['last'] = time();
738 738
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
739 739
 	    $buffer = $Common->getData($value['host']);
740
-	    $all_data = json_decode($buffer,true);
740
+	    $all_data = json_decode($buffer, true);
741 741
 	    if (isset($all_data['states'])) {
742 742
 		$reset = 0;
743 743
 		foreach ($all_data['states'] as $key => $line) {
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 		    //$data['emergency'] = ''; // emergency
755 755
 		    //$data['registration'] = $line[2];
756 756
 		    //$data['aircraft_icao'] = $line[0];
757
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
757
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
758 758
 	    	    $data['format_source'] = 'opensky';
759 759
     		    $data['id_source'] = $id_source;
760 760
 		    $SI->add($data);
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
768 768
 	    //$buffer = $Common->getData($hosts[$id]);
769 769
 	    $buffer = $Common->getData($value['host']);
770
-	    $all_data = json_decode($buffer,true);
770
+	    $all_data = json_decode($buffer, true);
771 771
 	    if (!empty($all_data)) $reset = 0;
772 772
 	    foreach ($all_data as $key => $line) {
773 773
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -799,11 +799,11 @@  discard block
 block discarded – undo
799 799
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
800 800
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
801 801
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
802
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
802
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
803 803
 	    //echo $buffer;
804
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
805
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
806
-	    $all_data = json_decode($buffer,true);
804
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
805
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
806
+	    $all_data = json_decode($buffer, true);
807 807
 	    if (json_last_error() != JSON_ERROR_NONE) {
808 808
 		die(json_last_error_msg());
809 809
 	    }
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 			//$data['departure_airport_iata'] = $line[11];
827 827
 			//$data['arrival_airport_iata'] = $line[12];
828 828
 	    		//$data['emergency'] = ''; // emergency
829
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
829
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
830 830
 	    		$data['format_source'] = 'radarvirtueljson';
831 831
     			$data['id_source'] = $id_source;
832 832
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -841,14 +841,14 @@  discard block
 block discarded – undo
841 841
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
842 842
 	    //$buffer = $Common->getData($hosts[$id]);
843 843
 	    $buffer = $Common->getData($value['host'].'?'.time());
844
-	    $all_data = json_decode(utf8_encode($buffer),true);
844
+	    $all_data = json_decode(utf8_encode($buffer), true);
845 845
 	    
846 846
 	    if (isset($all_data['pireps'])) {
847 847
 		$reset = 0;
848 848
 	        foreach ($all_data['pireps'] as $line) {
849 849
 		    $data = array();
850 850
 		    $data['id'] = $line['id'];
851
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
851
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
852 852
 		    $data['ident'] = $line['callsign']; // ident
853 853
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
854 854
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -877,9 +877,9 @@  discard block
 block discarded – undo
877 877
 			$SI->add($data);
878 878
 		    //    print_r($data);
879 879
     		    } elseif ($line['icon'] == 'ct') {
880
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
881
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
882
-			$typec = substr($data['ident'],-3);
880
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
881
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
882
+			$typec = substr($data['ident'], -3);
883 883
 			$data['type'] = '';
884 884
 			if ($typec == 'APP') $data['type'] = 'Approach';
885 885
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
891 891
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
892 892
 			else $data['type'] = 'Observer';
893
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
893
+			if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
894 894
 		    }
895 895
 		    unset($data);
896 896
 		}
@@ -902,14 +902,14 @@  discard block
 block discarded – undo
902 902
 	    //$buffer = $Common->getData($hosts[$id]);
903 903
 	    if ($globalDebug) echo 'Get Data...'."\n";
904 904
 	    $buffer = $Common->getData($value['host']);
905
-	    $all_data = json_decode($buffer,true);
905
+	    $all_data = json_decode($buffer, true);
906 906
 	    if ($buffer != '' && is_array($all_data)) {
907 907
 		$reset = 0;
908 908
 		foreach ($all_data as $line) {
909 909
 	    	    $data = array();
910 910
 	    	    //$data['id'] = $line['id']; // id not usable
911 911
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
912
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
912
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
913 913
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
914 914
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
915 915
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -932,12 +932,12 @@  discard block
 block discarded – undo
932 932
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
933 933
 		    if (isset($line['aircraftname'])) {
934 934
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
935
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
936
-	    		$aircraft_data = explode('-',$line['aircraftname']);
935
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
936
+	    		$aircraft_data = explode('-', $line['aircraftname']);
937 937
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
938 938
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
939 939
 	    		else {
940
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
940
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
941 941
 	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
942 942
 	    		    else $data['aircraft_icao'] = $line['aircraftname'];
943 943
 	    		}
@@ -959,14 +959,14 @@  discard block
 block discarded – undo
959 959
 	    //$buffer = $Common->getData($hosts[$id]);
960 960
 	    if ($globalDebug) echo 'Get Data...'."\n";
961 961
 	    $buffer = $Common->getData($value['host']);
962
-	    $all_data = json_decode($buffer,true);
962
+	    $all_data = json_decode($buffer, true);
963 963
 	    if ($buffer != '' && is_array($all_data)) {
964 964
 		$reset = 0;
965 965
 		foreach ($all_data as $line) {
966 966
 	    	    $data = array();
967 967
 	    	    //$data['id'] = $line['id']; // id not usable
968 968
 	    	    $data['id'] = trim($line['flight_id']);
969
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
969
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
970 970
 	    	    $data['pilot_name'] = $line['pilot_name'];
971 971
 	    	    $data['pilot_id'] = $line['pilot_id'];
972 972
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1017,9 +1017,9 @@  discard block
 block discarded – undo
1017 1017
 		    //$value = $formats[$nb];
1018 1018
 		    $format = $globalSources[$nb]['format'];
1019 1019
         	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3' || $format == 'vrstcp') {
1020
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
1020
+        		$buffer = socket_read($r, 6000, PHP_NORMAL_READ);
1021 1021
         	    } else {
1022
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1022
+	    	        $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1023 1023
 	    	    }
1024 1024
         	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1025 1025
         	    //echo $buffer."\n";
@@ -1028,8 +1028,8 @@  discard block
 block discarded – undo
1028 1028
 		    $error = false;
1029 1029
 		    //$SI::del();
1030 1030
 		    if ($format == 'vrstcp') {
1031
-			$buffer = explode('},{',$buffer);
1032
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1031
+			$buffer = explode('},{', $buffer);
1032
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1033 1033
 		    // SBS format is CSV format
1034 1034
 		    if ($buffer != '') {
1035 1035
 			$tt[$format] = 0;
@@ -1061,10 +1061,10 @@  discard block
 block discarded – undo
1061 1061
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1062 1062
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1063 1063
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1064
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1064
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1065 1065
 
1066 1066
 			    if (isset($ais_data['timestamp'])) {
1067
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1067
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1068 1068
 			    } else {
1069 1069
 				$data['datetime'] = date('Y-m-d H:i:s');
1070 1070
 			    }
@@ -1075,10 +1075,10 @@  discard block
 block discarded – undo
1075 1075
                         } elseif ($format == 'flightgearsp') {
1076 1076
                     	    //echo $buffer."\n";
1077 1077
                     	    if (strlen($buffer) > 5) {
1078
-				$line = explode(',',$buffer);
1078
+				$line = explode(',', $buffer);
1079 1079
 				$data = array();
1080 1080
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1081
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1081
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1082 1082
 				$data['ident'] = $line[6];
1083 1083
 				$data['aircraft_name'] = $line[7];
1084 1084
 				$data['longitude'] = $line[1];
@@ -1089,21 +1089,21 @@  discard block
 block discarded – undo
1089 1089
 				$data['datetime'] = date('Y-m-d H:i:s');
1090 1090
 				$data['format_source'] = 'flightgearsp';
1091 1091
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1092
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1092
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1093 1093
 			    }
1094 1094
                         } elseif ($format == 'acars') {
1095 1095
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1096 1096
 			    $ACARS->add(trim($buffer));
1097
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1097
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1098 1098
 			    $ACARS->deleteLiveAcarsData();
1099 1099
 			} elseif ($format == 'flightgearmp') {
1100
-			    if (substr($buffer,0,1) != '#') {
1100
+			    if (substr($buffer, 0, 1) != '#') {
1101 1101
 				$data = array();
1102 1102
 				//echo $buffer."\n";
1103
-				$line = explode(' ',$buffer);
1103
+				$line = explode(' ', $buffer);
1104 1104
 				if (count($line) == 11) {
1105
-				    $userserver = explode('@',$line[0]);
1106
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1105
+				    $userserver = explode('@', $line[0]);
1106
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1107 1107
 				    $data['ident'] = $userserver[0];
1108 1108
 				    $data['registration'] = $userserver[0];
1109 1109
 				    $data['latitude'] = $line[4];
@@ -1111,8 +1111,8 @@  discard block
 block discarded – undo
1111 1111
 				    $data['altitude'] = $line[6];
1112 1112
 				    $data['datetime'] = date('Y-m-d H:i:s');
1113 1113
 				    $aircraft_type = $line[10];
1114
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1115
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1114
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1115
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1116 1116
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1117 1117
 				}
1118 1118
 			    }
@@ -1120,8 +1120,8 @@  discard block
 block discarded – undo
1120 1120
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1121 1121
 			    die;
1122 1122
 			} elseif ($format == 'vrstcp') {
1123
-			    foreach($buffer as $all_data) {
1124
-				$line = json_decode('{'.$all_data.'}',true);
1123
+			    foreach ($buffer as $all_data) {
1124
+				$line = json_decode('{'.$all_data.'}', true);
1125 1125
 				$data = array();
1126 1126
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1127 1127
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1146,16 +1146,16 @@  discard block
 block discarded – undo
1146 1146
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1147 1147
 				unset($data);
1148 1148
 			    }
1149
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1149
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1150 1150
 			    $line = explode("\t", $buffer);
1151
-			    for($k = 0; $k < count($line); $k=$k+2) {
1151
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1152 1152
 				$key = $line[$k];
1153
-			        $lined[$key] = $line[$k+1];
1153
+			        $lined[$key] = $line[$k + 1];
1154 1154
 			    }
1155 1155
     			    if (count($lined) > 3) {
1156 1156
     				$data['hex'] = $lined['hexid'];
1157 1157
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1158
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1158
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1159 1159
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1160 1160
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1161 1161
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1173,22 +1173,22 @@  discard block
 block discarded – undo
1173 1173
     			    } else $error = true;
1174 1174
 			} elseif ($format == 'aprs' && $use_aprs) {
1175 1175
 			    if ($aprs_connect == 0) {
1176
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1176
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1177 1177
 				$aprs_connect = 1;
1178 1178
 			    }
1179 1179
 			    
1180
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1180
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1181 1181
 				$aprs_last_tx = time();
1182 1182
 				$data_aprs = "# Keep alive";
1183
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1183
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1184 1184
 			    }
1185 1185
 			    
1186 1186
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1187 1187
 			    //echo 'APRS data : '.$buffer."\n";
1188
-			    $buffer = str_replace('APRS <- ','',$buffer);
1189
-			    $buffer = str_replace('APRS -> ','',$buffer);
1188
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1189
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1190 1190
 			    //echo $buffer."\n";
1191
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1191
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1192 1192
 				$line = $APRS->parse($buffer);
1193 1193
 				//print_r($line);
1194 1194
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 				    $data = array();
1198 1198
 				    //print_r($line);
1199 1199
 				    if (isset($line['address'])) $data['hex'] = $line['address'];
1200
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1200
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1201 1201
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1202 1202
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1203 1203
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 				    $currentdate = date('Y-m-d H:i:s');
1224 1224
 				    $aprsdate = strtotime($data['datetime']);
1225 1225
 				    // Accept data if time <= system time + 20s
1226
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1226
+				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1227 1227
 					$send = $SI->add($data);
1228 1228
 				    } elseif (isset($line['stealth'])) {
1229 1229
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
@@ -1320,7 +1320,7 @@  discard block
 block discarded – undo
1320 1320
 				connect_all($sourceee);
1321 1321
 				$sourceee = array();
1322 1322
 				//connect_all($globalSources);
1323
-				$tt[$format]=0;
1323
+				$tt[$format] = 0;
1324 1324
 				break;
1325 1325
 			    }
1326 1326
 			}
@@ -1329,14 +1329,14 @@  discard block
 block discarded – undo
1329 1329
 	    } else {
1330 1330
 		$error = socket_strerror(socket_last_error());
1331 1331
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1332
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1332
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1333 1333
 			if (isset($globalDebug)) echo "Restarting...\n";
1334 1334
 			// Restart the script if possible
1335 1335
 			if (is_array($sockets)) {
1336 1336
 			    if ($globalDebug) echo "Shutdown all sockets...";
1337 1337
 			    
1338 1338
 			    foreach ($sockets as $sock) {
1339
-				@socket_shutdown($sock,2);
1339
+				@socket_shutdown($sock, 2);
1340 1340
 				@socket_close($sock);
1341 1341
 			    }
1342 1342
 			    
Please login to merge, or discard this patch.
Braces   +775 added lines, -264 removed lines patch added patch discarded remove patch
@@ -13,13 +13,17 @@  discard block
 block discarded – undo
13 13
 require_once(dirname(__FILE__).'/../require/class.SBS.php');
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
16
+if (isset($globalTracker) && $globalTracker) {
17
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+}
17 19
 if (isset($globalMarine) && $globalMarine) {
18 20
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
19 21
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 22
 }
21 23
 
22
-if (!isset($globalDebug)) $globalDebug = FALSE;
24
+if (!isset($globalDebug)) {
25
+	$globalDebug = FALSE;
26
+}
23 27
 
24 28
 // Check if schema is at latest version
25 29
 $Connection = new Connection();
@@ -59,22 +63,39 @@  discard block
 block discarded – undo
59 63
     $globalSources = array();
60 64
     $globalSources[] = array('host' => $options['source']);
61 65
 }
62
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
63
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
64
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
65
-if (isset($options['server'])) $globalServer = TRUE;
66
-if (isset($options['idsource'])) $id_source = $options['idsource'];
67
-else $id_source = 1;
66
+if (isset($options['aprsserverssid'])) {
67
+	$globalServerAPRSssid = $options['aprsserverssid'];
68
+}
69
+if (isset($options['aprsserverpass'])) {
70
+	$globalServerAPRSpass = $options['aprsserverpass'];
71
+}
72
+if (isset($options['nodaemon'])) {
73
+	$globalDaemon = FALSE;
74
+}
75
+if (isset($options['server'])) {
76
+	$globalServer = TRUE;
77
+}
78
+if (isset($options['idsource'])) {
79
+	$id_source = $options['idsource'];
80
+} else {
81
+	$id_source = 1;
82
+}
68 83
 if (isset($globalServer) && $globalServer) {
69
-    if ($globalDebug) echo "Using Server Mode\n";
84
+    if ($globalDebug) {
85
+    	echo "Using Server Mode\n";
86
+    }
70 87
     $SI=new SpotterServer();
71 88
 /*
72 89
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
73 90
     $SI = new adsb2aprs();
74 91
     $SI->connect();
75 92
 */
76
-} else $SI=new SpotterImport($Connection->db);
77
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
93
+} else {
94
+	$SI=new SpotterImport($Connection->db);
95
+}
96
+if (isset($globalTracker) && $globalTracker) {
97
+	$TI = new TrackerImport($Connection->db);
98
+}
78 99
 if (isset($globalMarine) && $globalMarine) {
79 100
     $AIS = new AIS();
80 101
     $MI = new MarineImport($Connection->db);
@@ -96,7 +117,9 @@  discard block
 block discarded – undo
96 117
 }
97 118
 
98 119
 // let's try and connect
99
-if ($globalDebug) echo "Connecting...\n";
120
+if ($globalDebug) {
121
+	echo "Connecting...\n";
122
+}
100 123
 $use_aprs = false;
101 124
 $aprs_full = false;
102 125
 $reset = 0;
@@ -105,7 +128,9 @@  discard block
 block discarded – undo
105 128
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
106 129
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
107 130
     $reset++;
108
-    if ($globalDebug) echo 'Connect to all...'."\n";
131
+    if ($globalDebug) {
132
+    	echo 'Connect to all...'."\n";
133
+    }
109 134
     foreach ($hosts as $id => $value) {
110 135
 	$host = $value['host'];
111 136
 	$globalSources[$id]['last_exec'] = 0;
@@ -115,27 +140,37 @@  discard block
 block discarded – undo
115 140
         	//$formats[$id] = 'deltadbtxt';
116 141
         	$globalSources[$id]['format'] = 'deltadbtxt';
117 142
         	//$last_exec['deltadbtxt'] = 0;
118
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
143
+        	if ($globalDebug) {
144
+        		echo "Connect to deltadb source (".$host.")...\n";
145
+        	}
119 146
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
120 147
         	//$formats[$id] = 'vatsimtxt';
121 148
         	$globalSources[$id]['format'] = 'vatsimtxt';
122 149
         	//$last_exec['vatsimtxt'] = 0;
123
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
150
+        	if ($globalDebug) {
151
+        		echo "Connect to vatsim source (".$host.")...\n";
152
+        	}
124 153
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
125 154
         	//$formats[$id] = 'aircraftlistjson';
126 155
         	$globalSources[$id]['format'] = 'aircraftlistjson';
127 156
         	//$last_exec['aircraftlistjson'] = 0;
128
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
157
+        	if ($globalDebug) {
158
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
159
+        	}
129 160
     	    } else if (preg_match('/opensky/i',$host)) {
130 161
         	//$formats[$id] = 'aircraftlistjson';
131 162
         	$globalSources[$id]['format'] = 'opensky';
132 163
         	//$last_exec['aircraftlistjson'] = 0;
133
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
164
+        	if ($globalDebug) {
165
+        		echo "Connect to opensky source (".$host.")...\n";
166
+        	}
134 167
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
135 168
         	//$formats[$id] = 'radarvirtueljson';
136 169
         	$globalSources[$id]['format'] = 'radarvirtueljson';
137 170
         	//$last_exec['radarvirtueljson'] = 0;
138
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
171
+        	if ($globalDebug) {
172
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
173
+        	}
139 174
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
140 175
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
141 176
         	    exit(0);
@@ -144,7 +179,9 @@  discard block
 block discarded – undo
144 179
         	//$formats[$id] = 'planeupdatefaa';
145 180
         	$globalSources[$id]['format'] = 'planeupdatefaa';
146 181
         	//$last_exec['planeupdatefaa'] = 0;
147
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
182
+        	if ($globalDebug) {
183
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
184
+        	}
148 185
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
149 186
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
150 187
         	    exit(0);
@@ -153,26 +190,36 @@  discard block
 block discarded – undo
153 190
         	//$formats[$id] = 'phpvmacars';
154 191
         	$globalSources[$id]['format'] = 'phpvmacars';
155 192
         	//$last_exec['phpvmacars'] = 0;
156
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
193
+        	if ($globalDebug) {
194
+        		echo "Connect to phpvmacars source (".$host.")...\n";
195
+        	}
157 196
             } else if (preg_match('/VAM-json.php$/i',$host)) {
158 197
         	//$formats[$id] = 'phpvmacars';
159 198
         	$globalSources[$id]['format'] = 'vam';
160
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
199
+        	if ($globalDebug) {
200
+        		echo "Connect to Vam source (".$host.")...\n";
201
+        	}
161 202
             } else if (preg_match('/whazzup/i',$host)) {
162 203
         	//$formats[$id] = 'whazzup';
163 204
         	$globalSources[$id]['format'] = 'whazzup';
164 205
         	//$last_exec['whazzup'] = 0;
165
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
206
+        	if ($globalDebug) {
207
+        		echo "Connect to whazzup source (".$host.")...\n";
208
+        	}
166 209
             } else if (preg_match('/recentpireps/i',$host)) {
167 210
         	//$formats[$id] = 'pirepsjson';
168 211
         	$globalSources[$id]['format'] = 'pirepsjson';
169 212
         	//$last_exec['pirepsjson'] = 0;
170
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
213
+        	if ($globalDebug) {
214
+        		echo "Connect to pirepsjson source (".$host.")...\n";
215
+        	}
171 216
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
172 217
         	//$formats[$id] = 'fr24json';
173 218
         	$globalSources[$id]['format'] = 'fr24json';
174 219
         	//$last_exec['fr24json'] = 0;
175
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
220
+        	if ($globalDebug) {
221
+        		echo "Connect to fr24 source (".$host.")...\n";
222
+        	}
176 223
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
177 224
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
178 225
         	    exit(0);
@@ -181,7 +228,9 @@  discard block
 block discarded – undo
181 228
         	//$formats[$id] = 'fr24json';
182 229
         	$globalSources[$id]['format'] = 'myshiptracking';
183 230
         	//$last_exec['fr24json'] = 0;
184
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
231
+        	if ($globalDebug) {
232
+        		echo "Connect to myshiptracking source (".$host.")...\n";
233
+        	}
185 234
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
186 235
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
187 236
         	    exit(0);
@@ -190,17 +239,24 @@  discard block
 block discarded – undo
190 239
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
191 240
         	//$formats[$id] = 'tsv';
192 241
         	$globalSources[$id]['format'] = 'tsv';
193
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
242
+        	if ($globalDebug) {
243
+        		echo "Connect to tsv source (".$host.")...\n";
244
+        	}
194 245
             }
195 246
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
196 247
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
197 248
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
198 249
     		    if ($idf !== false) {
199 250
     			$httpfeeds[$id] = $idf;
200
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
251
+        		if ($globalDebug) {
252
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
253
+        		}
254
+    		    } elseif ($globalDebug) {
255
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
201 256
     		    }
202
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
203
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
257
+    		} elseif ($globalDebug) {
258
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
259
+    		}
204 260
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
205 261
 	    $hostport = explode(':',$host);
206 262
 	    if (isset($hostport[1])) {
@@ -240,17 +296,25 @@  discard block
 block discarded – undo
240 296
         		//$formats[$id] = 'beast';
241 297
         		$globalSources[$id]['format'] = 'beast';
242 298
 		    //} else $formats[$id] = 'sbs';
243
-		    } else $globalSources[$id]['format'] = 'sbs';
299
+		    } else {
300
+		    	$globalSources[$id]['format'] = 'sbs';
301
+		    }
244 302
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
245 303
 		}
246
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
304
+		if ($globalDebug) {
305
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
306
+		}
247 307
             } else {
248
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
308
+		if ($globalDebug) {
309
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
310
+		}
249 311
     	    }
250 312
         }
251 313
     }
252 314
 }
253
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
315
+if (!isset($globalMinFetch)) {
316
+	$globalMinFetch = 15;
317
+}
254 318
 
255 319
 // Initialize all
256 320
 $status = array();
@@ -259,13 +323,19 @@  discard block
 block discarded – undo
259 323
 $formats = array();
260 324
 $last_exec = array();
261 325
 $time = time();
262
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
263
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
264
-else $timeout = 20;
326
+if (isset($globalSourcesTimeout)) {
327
+	$timeout = $globalSourcesTimeOut;
328
+} else if (isset($globalSBS1TimeOut)) {
329
+	$timeout = $globalSBS1TimeOut;
330
+} else {
331
+	$timeout = 20;
332
+}
265 333
 $errno = '';
266 334
 $errstr='';
267 335
 
268
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
336
+if (!isset($globalDaemon)) {
337
+	$globalDaemon = TRUE;
338
+}
269 339
 /* Initiate connections to all the hosts simultaneously */
270 340
 //connect_all($hosts);
271 341
 //connect_all($globalSources);
@@ -291,7 +361,9 @@  discard block
 block discarded – undo
291 361
     if (isset($source['format']) && $source['format'] == 'aprs') {
292 362
 	$aprs_connect = 0;
293 363
 	$use_aprs = true;
294
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
364
+	if (isset($source['port']) && $source['port'] == '10152') {
365
+		$aprs_full = true;
366
+	}
295 367
 	break;
296 368
     }
297 369
 }
@@ -302,26 +374,49 @@  discard block
 block discarded – undo
302 374
 	$aprs_connect = 0;
303 375
 	$aprs_keep = 120;
304 376
 	$aprs_last_tx = time();
305
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
306
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
307
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
308
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
309
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
310
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
311
-	if ($aprs_full) $aprs_filter = '';
312
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
313
-	else $aprs_pass = '-1';
377
+	if (isset($globalAPRSversion)) {
378
+		$aprs_version = $globalAPRSversion;
379
+	} else {
380
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
381
+	}
382
+	if (isset($globalAPRSssid)) {
383
+		$aprs_ssid = $globalAPRSssid;
384
+	} else {
385
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
386
+	}
387
+	if (isset($globalAPRSfilter)) {
388
+		$aprs_filter = $globalAPRSfilter;
389
+	} else {
390
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
391
+	}
392
+	if ($aprs_full) {
393
+		$aprs_filter = '';
394
+	}
395
+	if (isset($globalAPRSpass)) {
396
+		$aprs_pass = $globalAPRSpass;
397
+	} else {
398
+		$aprs_pass = '-1';
399
+	}
314 400
 
315
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
316
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
401
+	if ($aprs_filter != '') {
402
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
403
+	} else {
404
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
405
+	}
317 406
 	echo $aprs_login."\n";
318 407
 }
319 408
 
320 409
 // connected - lets do some work
321
-if ($globalDebug) echo "Connected!\n";
410
+if ($globalDebug) {
411
+	echo "Connected!\n";
412
+}
322 413
 sleep(1);
323
-if ($globalDebug) echo "SCAN MODE \n\n";
324
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
414
+if ($globalDebug) {
415
+	echo "SCAN MODE \n\n";
416
+}
417
+if (!isset($globalCronEnd)) {
418
+	$globalCronEnd = 60;
419
+}
325 420
 $endtime = time()+$globalCronEnd;
326 421
 $i = 1;
327 422
 $tt = array();
@@ -335,10 +430,14 @@  discard block
 block discarded – undo
335 430
 
336 431
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
337 432
 while ($i > 0) {
338
-    if (!$globalDaemon) $i = $endtime-time();
433
+    if (!$globalDaemon) {
434
+    	$i = $endtime-time();
435
+    }
339 436
     // Delete old ATC
340 437
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
341
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
438
+	if ($globalDebug) {
439
+		echo 'Delete old ATC...'."\n";
440
+	}
342 441
         $ATC->deleteOldATC();
343 442
     }
344 443
     
@@ -346,10 +445,14 @@  discard block
 block discarded – undo
346 445
     if (count($last_exec) == count($globalSources)) {
347 446
 	$max = $globalMinFetch;
348 447
 	foreach ($last_exec as $last) {
349
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
448
+	    if ((time() - $last['last']) < $max) {
449
+	    	$max = time() - $last['last'];
450
+	    }
350 451
 	}
351 452
 	if ($max != $globalMinFetch) {
352
-	    if ($globalDebug) echo 'Sleeping...'."\n";
453
+	    if ($globalDebug) {
454
+	    	echo 'Sleeping...'."\n";
455
+	    }
353 456
 	    sleep($globalMinFetch-$max+2);
354 457
 	}
355 458
     }
@@ -358,11 +461,15 @@  discard block
 block discarded – undo
358 461
     //foreach ($formats as $id => $value) {
359 462
     foreach ($globalSources as $id => $value) {
360 463
 	date_default_timezone_set('UTC');
361
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
464
+	if (!isset($last_exec[$id]['last'])) {
465
+		$last_exec[$id]['last'] = 0;
466
+	}
362 467
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
363 468
 	    //$buffer = $Common->getData($hosts[$id]);
364 469
 	    $buffer = $Common->getData($value['host']);
365
-	    if ($buffer != '') $reset = 0;
470
+	    if ($buffer != '') {
471
+	    	$reset = 0;
472
+	    }
366 473
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
367 474
 	    $buffer = explode('\n',$buffer);
368 475
 	    foreach ($buffer as $line) {
@@ -371,19 +478,38 @@  discard block
 block discarded – undo
371 478
 	            $data = array();
372 479
 	            $data['hex'] = $line[1]; // hex
373 480
 	            $data['ident'] = $line[2]; // ident
374
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
375
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
376
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
377
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
378
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
481
+	            if (isset($line[3])) {
482
+	            	$data['altitude'] = $line[3];
483
+	            }
484
+	            // altitude
485
+	            if (isset($line[4])) {
486
+	            	$data['speed'] = $line[4];
487
+	            }
488
+	            // speed
489
+	            if (isset($line[5])) {
490
+	            	$data['heading'] = $line[5];
491
+	            }
492
+	            // heading
493
+	            if (isset($line[6])) {
494
+	            	$data['latitude'] = $line[6];
495
+	            }
496
+	            // lat
497
+	            if (isset($line[7])) {
498
+	            	$data['longitude'] = $line[7];
499
+	            }
500
+	            // long
379 501
 	            $data['verticalrate'] = ''; // vertical rate
380 502
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
381 503
 	            $data['emergency'] = ''; // emergency
382 504
 		    $data['datetime'] = date('Y-m-d H:i:s');
383 505
 		    $data['format_source'] = 'deltadbtxt';
384 506
     		    $data['id_source'] = $id_source;
385
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
386
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
507
+		    if (isset($value['name']) && $value['name'] != '') {
508
+		    	$data['source_name'] = $value['name'];
509
+		    }
510
+		    if (isset($value['sourcestats'])) {
511
+		    	$data['sourcestats'] = $value['sourcestats'];
512
+		    }
387 513
     		    $SI->add($data);
388 514
 		    unset($data);
389 515
     		}
@@ -393,7 +519,9 @@  discard block
 block discarded – undo
393 519
 	    date_default_timezone_set('CET');
394 520
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
395 521
 	    date_default_timezone_set('UTC');
396
-	    if ($buffer != '') $reset = 0;
522
+	    if ($buffer != '') {
523
+	    	$reset = 0;
524
+	    }
397 525
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
398 526
 	    $buffer = explode('\n',$buffer);
399 527
 	    foreach ($buffer as $line) {
@@ -402,16 +530,36 @@  discard block
 block discarded – undo
402 530
 		    $add = false;
403 531
 		    $ais_data = $AIS->parse_line(trim($line));
404 532
 		    $data = array();
405
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
406
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
407
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
408
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
409
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
410
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
411
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
412
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
413
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
414
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
533
+		    if (isset($ais_data['ident'])) {
534
+		    	$data['ident'] = $ais_data['ident'];
535
+		    }
536
+		    if (isset($ais_data['mmsi'])) {
537
+		    	$data['mmsi'] = $ais_data['mmsi'];
538
+		    }
539
+		    if (isset($ais_data['speed'])) {
540
+		    	$data['speed'] = $ais_data['speed'];
541
+		    }
542
+		    if (isset($ais_data['heading'])) {
543
+		    	$data['heading'] = $ais_data['heading'];
544
+		    }
545
+		    if (isset($ais_data['latitude'])) {
546
+		    	$data['latitude'] = $ais_data['latitude'];
547
+		    }
548
+		    if (isset($ais_data['longitude'])) {
549
+		    	$data['longitude'] = $ais_data['longitude'];
550
+		    }
551
+		    if (isset($ais_data['status'])) {
552
+		    	$data['status'] = $ais_data['status'];
553
+		    }
554
+		    if (isset($ais_data['type'])) {
555
+		    	$data['type'] = $ais_data['type'];
556
+		    }
557
+		    if (isset($ais_data['imo'])) {
558
+		    	$data['imo'] = $ais_data['imo'];
559
+		    }
560
+		    if (isset($ais_data['callsign'])) {
561
+		    	$data['callsign'] = $ais_data['callsign'];
562
+		    }
415 563
 		    if (isset($ais_data['timestamp'])) {
416 564
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
417 565
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -426,7 +574,9 @@  discard block
 block discarded – undo
426 574
     		    $data['id_source'] = $id_source;
427 575
 		    print_r($data);
428 576
 		    echo 'Add...'."\n";
429
-		    if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
577
+		    if ($add && $ais_data['mmsi_type'] == 'Ship') {
578
+		    	$MI->add($data);
579
+		    }
430 580
 		    unset($data);
431 581
 		}
432 582
     	    }
@@ -446,18 +596,42 @@  discard block
 block discarded – undo
446 596
 			if ($line != '') {
447 597
 			    $ais_data = $AIS->parse_line(trim($line));
448 598
 			    $data = array();
449
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
450
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
451
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
452
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
453
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
454
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
455
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
456
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
457
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
458
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
459
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
460
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
599
+			    if (isset($ais_data['ident'])) {
600
+			    	$data['ident'] = $ais_data['ident'];
601
+			    }
602
+			    if (isset($ais_data['mmsi'])) {
603
+			    	$data['mmsi'] = $ais_data['mmsi'];
604
+			    }
605
+			    if (isset($ais_data['speed'])) {
606
+			    	$data['speed'] = $ais_data['speed'];
607
+			    }
608
+			    if (isset($ais_data['heading'])) {
609
+			    	$data['heading'] = $ais_data['heading'];
610
+			    }
611
+			    if (isset($ais_data['latitude'])) {
612
+			    	$data['latitude'] = $ais_data['latitude'];
613
+			    }
614
+			    if (isset($ais_data['longitude'])) {
615
+			    	$data['longitude'] = $ais_data['longitude'];
616
+			    }
617
+			    if (isset($ais_data['status'])) {
618
+			    	$data['status'] = $ais_data['status'];
619
+			    }
620
+			    if (isset($ais_data['type'])) {
621
+			    	$data['type'] = $ais_data['type'];
622
+			    }
623
+			    if (isset($ais_data['imo'])) {
624
+			    	$data['imo'] = $ais_data['imo'];
625
+			    }
626
+			    if (isset($ais_data['callsign'])) {
627
+			    	$data['callsign'] = $ais_data['callsign'];
628
+			    }
629
+			    if (isset($ais_data['destination'])) {
630
+			    	$data['arrival_code'] = $ais_data['destination'];
631
+			    }
632
+			    if (isset($ais_data['eta_ts'])) {
633
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
634
+			    }
461 635
 			    if (isset($ais_data['timestamp'])) {
462 636
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
463 637
 			    } else {
@@ -465,7 +639,9 @@  discard block
 block discarded – undo
465 639
 			    }
466 640
 			    $data['format_source'] = 'aisnmeahttp';
467 641
 			    $data['id_source'] = $id_source;
468
-			    if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data);
642
+			    if ($ais_data['mmsi_type'] == 'Ship') {
643
+			    	$MI->add($data);
644
+			    }
469 645
 			    unset($data);
470 646
 			}
471 647
 		    }
@@ -514,7 +690,9 @@  discard block
 block discarded – undo
514 690
 			    $data['callsign'] = $line['callsign'];
515 691
 			    $data['mmsi'] = $line['mmsi'];
516 692
 			    $data['speed'] = $line['sog'];
517
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
693
+			    if ($line['heading'] != '511') {
694
+			    	$data['heading'] = $line['heading'];
695
+			    }
518 696
 			    $data['latitude'] = $line['latitude'];
519 697
 			    $data['longitude'] = $line['longitude'];
520 698
 			    $data['type_id'] = $line['shiptype'];
@@ -534,7 +712,9 @@  discard block
 block discarded – undo
534 712
 	    echo 'download...';
535 713
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
536 714
 	    echo 'done !'."\n";
537
-	    if ($buffer != '') $reset = 0;
715
+	    if ($buffer != '') {
716
+	    	$reset = 0;
717
+	    }
538 718
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539 719
 	    $buffer = explode('\n',$buffer);
540 720
 	    foreach ($buffer as $line) {
@@ -578,16 +758,28 @@  discard block
 block discarded – undo
578 758
     		    $line = explode(':', $line);
579 759
     		    if (count($line) > 30 && $line[0] != 'callsign') {
580 760
 			$data = array();
581
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
582
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
761
+			if (isset($line[37]) && $line[37] != '') {
762
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
763
+			} else {
764
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
765
+			}
583 766
 			$data['pilot_id'] = $line[1];
584 767
 			$data['pilot_name'] = $line[2];
585 768
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
586 769
 			$data['ident'] = $line[0]; // ident
587
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
770
+			if ($line[7] != '' && $line[7] != 0) {
771
+				$data['altitude'] = $line[7];
772
+			}
773
+			// altitude
588 774
 			$data['speed'] = $line[8]; // speed
589
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
590
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
775
+			if (isset($line[45])) {
776
+				$data['heading'] = $line[45];
777
+			}
778
+			// heading
779
+			elseif (isset($line[38])) {
780
+				$data['heading'] = $line[38];
781
+			}
782
+			// heading
591 783
 			$data['latitude'] = $line[5]; // lat
592 784
 	        	$data['longitude'] = $line[6]; // long
593 785
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -603,7 +795,9 @@  discard block
 block discarded – undo
603 795
 			$data['frequency'] = $line[4];
604 796
 			$data['type'] = $line[18];
605 797
 			$data['range'] = $line[19];
606
-			if (isset($line[35])) $data['info'] = $line[35];
798
+			if (isset($line[35])) {
799
+				$data['info'] = $line[35];
800
+			}
607 801
     			$data['id_source'] = $id_source;
608 802
 	    		//$data['arrival_airport_time'] = ;
609 803
 	    		if ($line[9] != '') {
@@ -617,24 +811,41 @@  discard block
 block discarded – undo
617 811
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
618 812
 	    		*/
619 813
 	    		$data['format_source'] = $value['format'];
620
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
621
-    			if ($line[3] == 'PILOT') $SI->add($data);
622
-			elseif ($line[3] == 'ATC') {
814
+			if (isset($value['name']) && $value['name'] != '') {
815
+				$data['source_name'] = $value['name'];
816
+			}
817
+    			if ($line[3] == 'PILOT') {
818
+    				$SI->add($data);
819
+    			} elseif ($line[3] == 'ATC') {
623 820
 				//print_r($data);
624 821
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
625 822
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
626 823
 				$typec = substr($data['ident'],-3);
627
-				if ($typec == 'APP') $data['type'] = 'Approach';
628
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
629
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
630
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
631
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
632
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
633
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
634
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
635
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
636
-				if (!isset($data['source_name'])) $data['source_name'] = '';
637
-				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
824
+				if ($typec == 'APP') {
825
+					$data['type'] = 'Approach';
826
+				} elseif ($typec == 'TWR') {
827
+					$data['type'] = 'Tower';
828
+				} elseif ($typec == 'OBS') {
829
+					$data['type'] = 'Observer';
830
+				} elseif ($typec == 'GND') {
831
+					$data['type'] = 'Ground';
832
+				} elseif ($typec == 'DEL') {
833
+					$data['type'] = 'Delivery';
834
+				} elseif ($typec == 'DEP') {
835
+					$data['type'] = 'Departure';
836
+				} elseif ($typec == 'FSS') {
837
+					$data['type'] = 'Flight Service Station';
838
+				} elseif ($typec == 'CTR') {
839
+					$data['type'] = 'Control Radar or Centre';
840
+				} elseif ($data['type'] == '') {
841
+					$data['type'] = 'Observer';
842
+				}
843
+				if (!isset($data['source_name'])) {
844
+					$data['source_name'] = '';
845
+				}
846
+				if (isset($ATC)) {
847
+					echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
848
+				}
638 849
 			}
639 850
     			unset($data);
640 851
     		    }
@@ -653,26 +864,55 @@  discard block
 block discarded – undo
653 864
 		foreach ($all_data['acList'] as $line) {
654 865
 		    $data = array();
655 866
 		    $data['hex'] = $line['Icao']; // hex
656
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
657
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
658
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
659
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
660
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
661
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
867
+		    if (isset($line['Call'])) {
868
+		    	$data['ident'] = $line['Call'];
869
+		    }
870
+		    // ident
871
+		    if (isset($line['Alt'])) {
872
+		    	$data['altitude'] = $line['Alt'];
873
+		    }
874
+		    // altitude
875
+		    if (isset($line['Spd'])) {
876
+		    	$data['speed'] = $line['Spd'];
877
+		    }
878
+		    // speed
879
+		    if (isset($line['Trak'])) {
880
+		    	$data['heading'] = $line['Trak'];
881
+		    }
882
+		    // heading
883
+		    if (isset($line['Lat'])) {
884
+		    	$data['latitude'] = $line['Lat'];
885
+		    }
886
+		    // lat
887
+		    if (isset($line['Long'])) {
888
+		    	$data['longitude'] = $line['Long'];
889
+		    }
890
+		    // long
662 891
 		    //$data['verticalrate'] = $line['']; // verticale rate
663
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
892
+		    if (isset($line['Sqk'])) {
893
+		    	$data['squawk'] = $line['Sqk'];
894
+		    }
895
+		    // squawk
664 896
 		    $data['emergency'] = ''; // emergency
665
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
897
+		    if (isset($line['Reg'])) {
898
+		    	$data['registration'] = $line['Reg'];
899
+		    }
666 900
 		    /*
667 901
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
668 902
 		    else $data['datetime'] = date('Y-m-d H:i:s');
669 903
 		    */
670 904
 		    $data['datetime'] = date('Y-m-d H:i:s');
671
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
905
+		    if (isset($line['Type'])) {
906
+		    	$data['aircraft_icao'] = $line['Type'];
907
+		    }
672 908
 	    	    $data['format_source'] = 'aircraftlistjson';
673 909
 		    $data['id_source'] = $id_source;
674
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
675
-		    if (isset($data['latitude'])) $SI->add($data);
910
+		    if (isset($value['name']) && $value['name'] != '') {
911
+		    	$data['source_name'] = $value['name'];
912
+		    }
913
+		    if (isset($data['latitude'])) {
914
+		    	$SI->add($data);
915
+		    }
676 916
 		    unset($data);
677 917
 		}
678 918
 	    } elseif (is_array($all_data)) {
@@ -692,7 +932,9 @@  discard block
 block discarded – undo
692 932
 		    $data['datetime'] = date('Y-m-d H:i:s');
693 933
 	    	    $data['format_source'] = 'aircraftlistjson';
694 934
     		    $data['id_source'] = $id_source;
695
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
935
+		    if (isset($value['name']) && $value['name'] != '') {
936
+		    	$data['source_name'] = $value['name'];
937
+		    }
696 938
 		    $SI->add($data);
697 939
 		    unset($data);
698 940
 		}
@@ -728,7 +970,9 @@  discard block
 block discarded – undo
728 970
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
729 971
 	    	    $data['format_source'] = 'planeupdatefaa';
730 972
     		    $data['id_source'] = $id_source;
731
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
973
+		    if (isset($value['name']) && $value['name'] != '') {
974
+		    	$data['source_name'] = $value['name'];
975
+		    }
732 976
 		    $SI->add($data);
733 977
 		    unset($data);
734 978
 		}
@@ -768,7 +1012,9 @@  discard block
 block discarded – undo
768 1012
 	    //$buffer = $Common->getData($hosts[$id]);
769 1013
 	    $buffer = $Common->getData($value['host']);
770 1014
 	    $all_data = json_decode($buffer,true);
771
-	    if (!empty($all_data)) $reset = 0;
1015
+	    if (!empty($all_data)) {
1016
+	    	$reset = 0;
1017
+	    }
772 1018
 	    foreach ($all_data as $key => $line) {
773 1019
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
774 1020
 		    $data = array();
@@ -789,7 +1035,9 @@  discard block
 block discarded – undo
789 1035
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
790 1036
 	    	    $data['format_source'] = 'fr24json';
791 1037
     		    $data['id_source'] = $id_source;
792
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1038
+		    if (isset($value['name']) && $value['name'] != '') {
1039
+		    	$data['source_name'] = $value['name'];
1040
+		    }
793 1041
 		    $SI->add($data);
794 1042
 		    unset($data);
795 1043
 		}
@@ -813,23 +1061,39 @@  discard block
 block discarded – undo
813 1061
 		    if (isset($line['inf'])) {
814 1062
 			$data = array();
815 1063
 			$data['hex'] = $line['inf']['ia'];
816
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1064
+			if (isset($line['inf']['cs'])) {
1065
+				$data['ident'] = $line['inf']['cs'];
1066
+			}
1067
+			//$line[13]
817 1068
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
818
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
819
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1069
+	    		if (isset($line['inf']['gs'])) {
1070
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1071
+	    		}
1072
+	    		// speed
1073
+	    		if (isset($line['inf']['tr'])) {
1074
+	    			$data['heading'] = $line['inf']['tr'];
1075
+	    		}
1076
+	    		// heading
820 1077
 	    		$data['latitude'] = $line['pt'][0]; // lat
821 1078
 	    		$data['longitude'] = $line['pt'][1]; // long
822 1079
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
823
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1080
+	    		if (isset($line['inf']['sq'])) {
1081
+	    			$data['squawk'] = $line['inf']['sq'];
1082
+	    		}
1083
+	    		// squawk
824 1084
 	    		//$data['aircraft_icao'] = $line[8];
825
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1085
+	    		if (isset($line['inf']['rc'])) {
1086
+	    			$data['registration'] = $line['inf']['rc'];
1087
+	    		}
826 1088
 			//$data['departure_airport_iata'] = $line[11];
827 1089
 			//$data['arrival_airport_iata'] = $line[12];
828 1090
 	    		//$data['emergency'] = ''; // emergency
829 1091
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
830 1092
 	    		$data['format_source'] = 'radarvirtueljson';
831 1093
     			$data['id_source'] = $id_source;
832
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1094
+			if (isset($value['name']) && $value['name'] != '') {
1095
+				$data['source_name'] = $value['name'];
1096
+			}
833 1097
 			$SI->add($data);
834 1098
 			unset($data);
835 1099
 		    }
@@ -850,29 +1114,62 @@  discard block
 block discarded – undo
850 1114
 		    $data['id'] = $line['id'];
851 1115
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
852 1116
 		    $data['ident'] = $line['callsign']; // ident
853
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
854
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
855
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
856
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
857
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
858
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1117
+		    if (isset($line['pilotid'])) {
1118
+		    	$data['pilot_id'] = $line['pilotid'];
1119
+		    }
1120
+		    // pilot id
1121
+		    if (isset($line['name'])) {
1122
+		    	$data['pilot_name'] = $line['name'];
1123
+		    }
1124
+		    // pilot name
1125
+		    if (isset($line['alt'])) {
1126
+		    	$data['altitude'] = $line['alt'];
1127
+		    }
1128
+		    // altitude
1129
+		    if (isset($line['gs'])) {
1130
+		    	$data['speed'] = $line['gs'];
1131
+		    }
1132
+		    // speed
1133
+		    if (isset($line['heading'])) {
1134
+		    	$data['heading'] = $line['heading'];
1135
+		    }
1136
+		    // heading
1137
+		    if (isset($line['route'])) {
1138
+		    	$data['waypoints'] = $line['route'];
1139
+		    }
1140
+		    // route
859 1141
 		    $data['latitude'] = $line['lat']; // lat
860 1142
 		    $data['longitude'] = $line['lon']; // long
861 1143
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
862 1144
 		    //$data['squawk'] = $line['squawk']; // squawk
863 1145
 		    //$data['emergency'] = ''; // emergency
864
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
865
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
866
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1146
+		    if (isset($line['depicao'])) {
1147
+		    	$data['departure_airport_icao'] = $line['depicao'];
1148
+		    }
1149
+		    if (isset($line['deptime'])) {
1150
+		    	$data['departure_airport_time'] = $line['deptime'];
1151
+		    }
1152
+		    if (isset($line['arricao'])) {
1153
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1154
+		    }
867 1155
 		    //$data['arrival_airport_time'] = $line['arrtime'];
868
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
869
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
870
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
871
-		    else $data['info'] = '';
1156
+		    if (isset($line['aircraft'])) {
1157
+		    	$data['aircraft_icao'] = $line['aircraft'];
1158
+		    }
1159
+		    if (isset($line['transponder'])) {
1160
+		    	$data['squawk'] = $line['transponder'];
1161
+		    }
1162
+		    if (isset($line['atis'])) {
1163
+		    	$data['info'] = $line['atis'];
1164
+		    } else {
1165
+		    	$data['info'] = '';
1166
+		    }
872 1167
 		    $data['format_source'] = 'pireps';
873 1168
     		    $data['id_source'] = $id_source;
874 1169
 		    $data['datetime'] = date('Y-m-d H:i:s');
875
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1170
+		    if (isset($value['name']) && $value['name'] != '') {
1171
+		    	$data['source_name'] = $value['name'];
1172
+		    }
876 1173
 		    if ($line['icon'] == 'plane') {
877 1174
 			$SI->add($data);
878 1175
 		    //    print_r($data);
@@ -881,16 +1178,28 @@  discard block
 block discarded – undo
881 1178
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
882 1179
 			$typec = substr($data['ident'],-3);
883 1180
 			$data['type'] = '';
884
-			if ($typec == 'APP') $data['type'] = 'Approach';
885
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
886
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
887
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
888
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
889
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
890
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
891
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
892
-			else $data['type'] = 'Observer';
893
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1181
+			if ($typec == 'APP') {
1182
+				$data['type'] = 'Approach';
1183
+			} elseif ($typec == 'TWR') {
1184
+				$data['type'] = 'Tower';
1185
+			} elseif ($typec == 'OBS') {
1186
+				$data['type'] = 'Observer';
1187
+			} elseif ($typec == 'GND') {
1188
+				$data['type'] = 'Ground';
1189
+			} elseif ($typec == 'DEL') {
1190
+				$data['type'] = 'Delivery';
1191
+			} elseif ($typec == 'DEP') {
1192
+				$data['type'] = 'Departure';
1193
+			} elseif ($typec == 'FSS') {
1194
+				$data['type'] = 'Flight Service Station';
1195
+			} elseif ($typec == 'CTR') {
1196
+				$data['type'] = 'Control Radar or Centre';
1197
+			} else {
1198
+				$data['type'] = 'Observer';
1199
+			}
1200
+			if (isset($ATC)) {
1201
+				echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1202
+			}
894 1203
 		    }
895 1204
 		    unset($data);
896 1205
 		}
@@ -900,7 +1209,9 @@  discard block
 block discarded – undo
900 1209
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
901 1210
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
902 1211
 	    //$buffer = $Common->getData($hosts[$id]);
903
-	    if ($globalDebug) echo 'Get Data...'."\n";
1212
+	    if ($globalDebug) {
1213
+	    	echo 'Get Data...'."\n";
1214
+	    }
904 1215
 	    $buffer = $Common->getData($value['host']);
905 1216
 	    $all_data = json_decode($buffer,true);
906 1217
 	    if ($buffer != '' && is_array($all_data)) {
@@ -908,10 +1219,16 @@  discard block
 block discarded – undo
908 1219
 		foreach ($all_data as $line) {
909 1220
 	    	    $data = array();
910 1221
 	    	    //$data['id'] = $line['id']; // id not usable
911
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1222
+	    	    if (isset($line['pilotid'])) {
1223
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1224
+	    	    }
912 1225
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
913
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
914
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1226
+	    	    if (isset($line['pilotname'])) {
1227
+	    	    	$data['pilot_name'] = $line['pilotname'];
1228
+	    	    }
1229
+	    	    if (isset($line['pilotid'])) {
1230
+	    	    	$data['pilot_id'] = $line['pilotid'];
1231
+	    	    }
915 1232
 	    	    $data['ident'] = $line['flightnum']; // ident
916 1233
 	    	    $data['altitude'] = $line['alt']; // altitude
917 1234
 	    	    $data['speed'] = $line['gs']; // speed
@@ -929,27 +1246,41 @@  discard block
 block discarded – undo
929 1246
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
930 1247
     		    $data['arrival_airport_time'] = $line['arrtime'];
931 1248
     		    $data['registration'] = $line['aircraft'];
932
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1249
+		    if (isset($line['route'])) {
1250
+		    	$data['waypoints'] = $line['route'];
1251
+		    }
1252
+		    // route
933 1253
 		    if (isset($line['aircraftname'])) {
934 1254
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
935 1255
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
936 1256
 	    		$aircraft_data = explode('-',$line['aircraftname']);
937
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
938
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
939
-	    		else {
1257
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) {
1258
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1259
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) {
1260
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1261
+	    		} else {
940 1262
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
941
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
942
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
1263
+	    		    if (isset($aircraft_data[1])) {
1264
+	    		    	$data['aircraft_icao'] = $aircraft_data[1];
1265
+	    		    } else {
1266
+	    		    	$data['aircraft_icao'] = $line['aircraftname'];
1267
+	    		    }
943 1268
 	    		}
944 1269
 	    	    }
945
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1270
+    		    if (isset($line['route'])) {
1271
+    		    	$data['waypoints'] = $line['route'];
1272
+    		    }
946 1273
     		    $data['id_source'] = $id_source;
947 1274
 	    	    $data['format_source'] = 'phpvmacars';
948
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1275
+		    if (isset($value['name']) && $value['name'] != '') {
1276
+		    	$data['source_name'] = $value['name'];
1277
+		    }
949 1278
 		    $SI->add($data);
950 1279
 		    unset($data);
951 1280
 		}
952
-		if ($globalDebug) echo 'No more data...'."\n";
1281
+		if ($globalDebug) {
1282
+			echo 'No more data...'."\n";
1283
+		}
953 1284
 		unset($buffer);
954 1285
 		unset($all_data);
955 1286
 	    }
@@ -957,7 +1288,9 @@  discard block
 block discarded – undo
957 1288
     	    $last_exec[$id]['last'] = time();
958 1289
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
959 1290
 	    //$buffer = $Common->getData($hosts[$id]);
960
-	    if ($globalDebug) echo 'Get Data...'."\n";
1291
+	    if ($globalDebug) {
1292
+	    	echo 'Get Data...'."\n";
1293
+	    }
961 1294
 	    $buffer = $Common->getData($value['host']);
962 1295
 	    $all_data = json_decode($buffer,true);
963 1296
 	    if ($buffer != '' && is_array($all_data)) {
@@ -986,15 +1319,22 @@  discard block
 block discarded – undo
986 1319
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
987 1320
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
988 1321
     		    //$data['registration'] = $line['aircraft'];
989
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1322
+		    if (isset($line['route'])) {
1323
+		    	$data['waypoints'] = $line['route'];
1324
+		    }
1325
+		    // route
990 1326
 	    	    $data['aircraft_icao'] = $line['plane_type'];
991 1327
     		    $data['id_source'] = $id_source;
992 1328
 	    	    $data['format_source'] = 'vam';
993
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1329
+		    if (isset($value['name']) && $value['name'] != '') {
1330
+		    	$data['source_name'] = $value['name'];
1331
+		    }
994 1332
 		    $SI->add($data);
995 1333
 		    unset($data);
996 1334
 		}
997
-		if ($globalDebug) echo 'No more data...'."\n";
1335
+		if ($globalDebug) {
1336
+			echo 'No more data...'."\n";
1337
+		}
998 1338
 		unset($buffer);
999 1339
 		unset($all_data);
1000 1340
 	    }
@@ -1002,7 +1342,9 @@  discard block
 block discarded – undo
1002 1342
     	    $last_exec[$id]['last'] = time();
1003 1343
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1004 1344
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1005
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1345
+	    if (function_exists('pcntl_fork')) {
1346
+	    	pcntl_signal_dispatch();
1347
+	    }
1006 1348
     	    //$last_exec[$id]['last'] = time();
1007 1349
 
1008 1350
 	    //$read = array( $sockets[$id] );
@@ -1010,7 +1352,9 @@  discard block
 block discarded – undo
1010 1352
 	    $write = NULL;
1011 1353
 	    $e = NULL;
1012 1354
 	    $n = socket_select($read, $write, $e, $timeout);
1013
-	    if ($e != NULL) var_dump($e);
1355
+	    if ($e != NULL) {
1356
+	    	var_dump($e);
1357
+	    }
1014 1358
 	    if ($n > 0) {
1015 1359
 		$reset = 0;
1016 1360
 		foreach ($read as $nb => $r) {
@@ -1029,12 +1373,16 @@  discard block
 block discarded – undo
1029 1373
 		    //$SI::del();
1030 1374
 		    if ($format == 'vrstcp') {
1031 1375
 			$buffer = explode('},{',$buffer);
1032
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1376
+		    } else {
1377
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1378
+		    }
1033 1379
 		    // SBS format is CSV format
1034 1380
 		    if ($buffer != '') {
1035 1381
 			$tt[$format] = 0;
1036 1382
 			if ($format == 'acarssbs3') {
1037
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1383
+                    	    if ($globalDebug) {
1384
+                    	    	echo 'ACARS : '.$buffer."\n";
1385
+                    	    }
1038 1386
 			    $ACARS->add(trim($buffer));
1039 1387
 			    $ACARS->deleteLiveAcarsData();
1040 1388
 			} elseif ($format == 'raw') {
@@ -1043,25 +1391,55 @@  discard block
 block discarded – undo
1043 1391
 			    if (is_array($data)) {
1044 1392
 				$data['datetime'] = date('Y-m-d H:i:s');
1045 1393
 				$data['format_source'] = 'raw';
1046
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1047
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1048
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1394
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1395
+					$data['source_name'] = $globalSources[$nb]['name'];
1396
+				}
1397
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1398
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1399
+    				}
1400
+                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1401
+                                	$SI->add($data);
1402
+                                }
1049 1403
                             }
1050 1404
                         } elseif ($format == 'ais') {
1051 1405
 			    $ais_data = $AIS->parse_line(trim($buffer));
1052 1406
 			    $data = array();
1053
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1054
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1055
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1056
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1057
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1058
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1059
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1060
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1061
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1062
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1063
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1064
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1407
+			    if (isset($ais_data['ident'])) {
1408
+			    	$data['ident'] = $ais_data['ident'];
1409
+			    }
1410
+			    if (isset($ais_data['mmsi'])) {
1411
+			    	$data['mmsi'] = $ais_data['mmsi'];
1412
+			    }
1413
+			    if (isset($ais_data['speed'])) {
1414
+			    	$data['speed'] = $ais_data['speed'];
1415
+			    }
1416
+			    if (isset($ais_data['heading'])) {
1417
+			    	$data['heading'] = $ais_data['heading'];
1418
+			    }
1419
+			    if (isset($ais_data['latitude'])) {
1420
+			    	$data['latitude'] = $ais_data['latitude'];
1421
+			    }
1422
+			    if (isset($ais_data['longitude'])) {
1423
+			    	$data['longitude'] = $ais_data['longitude'];
1424
+			    }
1425
+			    if (isset($ais_data['status'])) {
1426
+			    	$data['status'] = $ais_data['status'];
1427
+			    }
1428
+			    if (isset($ais_data['type'])) {
1429
+			    	$data['type'] = $ais_data['type'];
1430
+			    }
1431
+			    if (isset($ais_data['imo'])) {
1432
+			    	$data['imo'] = $ais_data['imo'];
1433
+			    }
1434
+			    if (isset($ais_data['callsign'])) {
1435
+			    	$data['callsign'] = $ais_data['callsign'];
1436
+			    }
1437
+			    if (isset($ais_data['destination'])) {
1438
+			    	$data['arrival_code'] = $ais_data['destination'];
1439
+			    }
1440
+			    if (isset($ais_data['eta_ts'])) {
1441
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1442
+			    }
1065 1443
 
1066 1444
 			    if (isset($ais_data['timestamp'])) {
1067 1445
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1070,7 +1448,9 @@  discard block
 block discarded – undo
1070 1448
 			    }
1071 1449
 			    $data['format_source'] = 'aisnmea';
1072 1450
     			    $data['id_source'] = $id_source;
1073
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1451
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1452
+			    	$MI->add($data);
1453
+			    }
1074 1454
 			    unset($data);
1075 1455
                         } elseif ($format == 'flightgearsp') {
1076 1456
                     	    //echo $buffer."\n";
@@ -1088,11 +1468,15 @@  discard block
 block discarded – undo
1088 1468
 				$data['speed'] = round($line[5]*1.94384);
1089 1469
 				$data['datetime'] = date('Y-m-d H:i:s');
1090 1470
 				$data['format_source'] = 'flightgearsp';
1091
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1471
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1472
+					$SI->add($data);
1473
+				}
1092 1474
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1093 1475
 			    }
1094 1476
                         } elseif ($format == 'acars') {
1095
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1477
+                    	    if ($globalDebug) {
1478
+                    	    	echo 'ACARS : '.$buffer."\n";
1479
+                    	    }
1096 1480
 			    $ACARS->add(trim($buffer));
1097 1481
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1098 1482
 			    $ACARS->deleteLiveAcarsData();
@@ -1113,7 +1497,9 @@  discard block
 block discarded – undo
1113 1497
 				    $aircraft_type = $line[10];
1114 1498
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1115 1499
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1116
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1500
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1501
+				    	$SI->add($data);
1502
+				    }
1117 1503
 				}
1118 1504
 			    }
1119 1505
 			} elseif ($format == 'beast') {
@@ -1123,27 +1509,59 @@  discard block
 block discarded – undo
1123 1509
 			    foreach($buffer as $all_data) {
1124 1510
 				$line = json_decode('{'.$all_data.'}',true);
1125 1511
 				$data = array();
1126
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1127
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1128
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1129
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1130
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1131
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1132
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1512
+				if (isset($line['Icao'])) {
1513
+					$data['hex'] = $line['Icao'];
1514
+				}
1515
+				// hex
1516
+				if (isset($line['Call'])) {
1517
+					$data['ident'] = $line['Call'];
1518
+				}
1519
+				// ident
1520
+				if (isset($line['Alt'])) {
1521
+					$data['altitude'] = $line['Alt'];
1522
+				}
1523
+				// altitude
1524
+				if (isset($line['Spd'])) {
1525
+					$data['speed'] = $line['Spd'];
1526
+				}
1527
+				// speed
1528
+				if (isset($line['Trak'])) {
1529
+					$data['heading'] = $line['Trak'];
1530
+				}
1531
+				// heading
1532
+				if (isset($line['Lat'])) {
1533
+					$data['latitude'] = $line['Lat'];
1534
+				}
1535
+				// lat
1536
+				if (isset($line['Long'])) {
1537
+					$data['longitude'] = $line['Long'];
1538
+				}
1539
+				// long
1133 1540
 				//$data['verticalrate'] = $line['']; // verticale rate
1134
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1541
+				if (isset($line['Sqk'])) {
1542
+					$data['squawk'] = $line['Sqk'];
1543
+				}
1544
+				// squawk
1135 1545
 				$data['emergency'] = ''; // emergency
1136
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1546
+				if (isset($line['Reg'])) {
1547
+					$data['registration'] = $line['Reg'];
1548
+				}
1137 1549
 				/*
1138 1550
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1139 1551
 				else $data['datetime'] = date('Y-m-d H:i:s');
1140 1552
 				*/
1141 1553
 				$data['datetime'] = date('Y-m-d H:i:s');
1142
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1554
+				if (isset($line['Type'])) {
1555
+					$data['aircraft_icao'] = $line['Type'];
1556
+				}
1143 1557
 		    		$data['format_source'] = 'vrstcp';
1144 1558
 				$data['id_source'] = $id_source;
1145
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1146
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1559
+				if (isset($value['name']) && $value['name'] != '') {
1560
+					$data['source_name'] = $value['name'];
1561
+				}
1562
+				if (isset($data['latitude']) && isset($data['hex'])) {
1563
+					$SI->add($data);
1564
+				}
1147 1565
 				unset($data);
1148 1566
 			    }
1149 1567
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1156,21 +1574,43 @@  discard block
 block discarded – undo
1156 1574
     				$data['hex'] = $lined['hexid'];
1157 1575
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1158 1576
     				$data['datetime'] = date('Y-m-d H:i:s');;
1159
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1160
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1161
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1162
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1163
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1164
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1165
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1577
+    				if (isset($lined['ident'])) {
1578
+    					$data['ident'] = $lined['ident'];
1579
+    				}
1580
+    				if (isset($lined['lat'])) {
1581
+    					$data['latitude'] = $lined['lat'];
1582
+    				}
1583
+    				if (isset($lined['lon'])) {
1584
+    					$data['longitude'] = $lined['lon'];
1585
+    				}
1586
+    				if (isset($lined['speed'])) {
1587
+    					$data['speed'] = $lined['speed'];
1588
+    				}
1589
+    				if (isset($lined['squawk'])) {
1590
+    					$data['squawk'] = $lined['squawk'];
1591
+    				}
1592
+    				if (isset($lined['alt'])) {
1593
+    					$data['altitude'] = $lined['alt'];
1594
+    				}
1595
+    				if (isset($lined['heading'])) {
1596
+    					$data['heading'] = $lined['heading'];
1597
+    				}
1166 1598
     				$data['id_source'] = $id_source;
1167 1599
     				$data['format_source'] = 'tsv';
1168
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1169
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1170
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1600
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1601
+    					$data['source_name'] = $globalSources[$nb]['name'];
1602
+    				}
1603
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1604
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1605
+    				}
1606
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1607
+    					$SI->add($data);
1608
+    				}
1171 1609
     				unset($lined);
1172 1610
     				unset($data);
1173
-    			    } else $error = true;
1611
+    			    } else {
1612
+    			    	$error = true;
1613
+    			    }
1174 1614
 			} elseif ($format == 'aprs' && $use_aprs) {
1175 1615
 			    if ($aprs_connect == 0) {
1176 1616
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1196,49 +1636,82 @@  discard block
 block discarded – undo
1196 1636
 				    $aprs_last_tx = time();
1197 1637
 				    $data = array();
1198 1638
 				    //print_r($line);
1199
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1200
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1201
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1639
+				    if (isset($line['address'])) {
1640
+				    	$data['hex'] = $line['address'];
1641
+				    }
1642
+				    if (isset($line['timestamp'])) {
1643
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1644
+				    } else {
1645
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1646
+				    }
1202 1647
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1203
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1648
+				    if (isset($line['ident'])) {
1649
+				    	$data['ident'] = $line['ident'];
1650
+				    }
1204 1651
 				    $data['latitude'] = $line['latitude'];
1205 1652
 				    $data['longitude'] = $line['longitude'];
1206 1653
 				    //$data['verticalrate'] = $line[16];
1207
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1208
-				    else $data['speed'] = 0;
1209
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1210
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1211
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1212
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1654
+				    if (isset($line['speed'])) {
1655
+				    	$data['speed'] = $line['speed'];
1656
+				    } else {
1657
+				    	$data['speed'] = 0;
1658
+				    }
1659
+				    if (isset($line['altitude'])) {
1660
+				    	$data['altitude'] = $line['altitude'];
1661
+				    }
1662
+				    if (isset($line['comment'])) {
1663
+				    	$data['comment'] = $line['comment'];
1664
+				    }
1665
+				    if (isset($line['symbol'])) {
1666
+				    	$data['type'] = $line['symbol'];
1667
+				    }
1668
+				    if (isset($line['heading'])) {
1669
+				    	$data['heading'] = $line['heading'];
1670
+				    }
1213 1671
 				    //else $data['heading'] = 0;
1214
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1215
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1672
+				    if (isset($line['stealth'])) {
1673
+				    	$data['aircraft_type'] = $line['stealth'];
1674
+				    }
1675
+				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) {
1676
+				    	$data['noarchive'] = true;
1677
+				    }
1216 1678
     				    $data['id_source'] = $id_source;
1217
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1218
-				    else $data['format_source'] = 'aprs';
1679
+    				    if (isset($line['format_source'])) {
1680
+    				    	$data['format_source'] = $line['format_source'];
1681
+    				    } else {
1682
+				    	$data['format_source'] = 'aprs';
1683
+				    }
1219 1684
 				    $data['source_name'] = $line['source'];
1220
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1221
-				    else $data['source_type'] = 'flarm';
1222
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1685
+				    if (isset($line['source_type'])) {
1686
+				    	$data['source_type'] = $line['source_type'];
1687
+				    } else {
1688
+				    	$data['source_type'] = 'flarm';
1689
+				    }
1690
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1691
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1692
+    				    }
1223 1693
 				    $currentdate = date('Y-m-d H:i:s');
1224 1694
 				    $aprsdate = strtotime($data['datetime']);
1225 1695
 				    // Accept data if time <= system time + 20s
1226 1696
 				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1227 1697
 					$send = $SI->add($data);
1228 1698
 				    } elseif (isset($line['stealth'])) {
1229
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1230
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1699
+					if ($line['stealth'] != 0) {
1700
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1701
+					} else {
1702
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1703
+					}
1231 1704
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1232 1705
 				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1233 1706
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1234
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1707
+					if (isset($globalTracker) && $globalTracker) {
1708
+						$send = $TI->add($data);
1709
+					}
1235 1710
 				    }
1236 1711
 				    unset($data);
1237
-				} 
1238
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1712
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1239 1713
 					echo '!! Weather Station not yet supported'."\n";
1240
-				}
1241
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
1714
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
1242 1715
 					echo '!! Car & Trucks not yet supported'."\n";
1243 1716
 				}
1244 1717
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
@@ -1271,25 +1744,42 @@  discard block
 block discarded – undo
1271 1744
     				$data['ground'] = $line[21];
1272 1745
     				$data['emergency'] = $line[19];
1273 1746
     				$data['format_source'] = 'sbs';
1274
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1275
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1747
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1748
+					$data['source_name'] = $globalSources[$nb]['name'];
1749
+				}
1750
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1751
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1752
+    				}
1276 1753
     				$data['id_source'] = $id_source;
1277
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1278
-    				else $error = true;
1754
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1755
+    					$send = $SI->add($data);
1756
+    				} else {
1757
+    					$error = true;
1758
+    				}
1279 1759
     				unset($data);
1280
-    			    } else $error = true;
1760
+    			    } else {
1761
+    			    	$error = true;
1762
+    			    }
1281 1763
 			    if ($error) {
1282 1764
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1283
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1765
+					if ($globalDebug) {
1766
+						echo "Not a message. Ignoring... \n";
1767
+					}
1284 1768
 				} else {
1285
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1769
+					if ($globalDebug) {
1770
+						echo "Wrong line format. Ignoring... \n";
1771
+					}
1286 1772
 					if ($globalDebug) {
1287 1773
 						echo $buffer;
1288 1774
 						print_r($line);
1289 1775
 					}
1290 1776
 					//socket_close($r);
1291
-					if ($globalDebug) echo "Reconnect after an error...\n";
1292
-					if ($format == 'aprs') $aprs_connect = 0;
1777
+					if ($globalDebug) {
1778
+						echo "Reconnect after an error...\n";
1779
+					}
1780
+					if ($format == 'aprs') {
1781
+						$aprs_connect = 0;
1782
+					}
1293 1783
 					$sourceer[$nb] = $globalSources[$nb];
1294 1784
 					connect_all($sourceer);
1295 1785
 					$sourceer = array();
@@ -1297,10 +1787,14 @@  discard block
 block discarded – undo
1297 1787
 			    }
1298 1788
 			}
1299 1789
 			// Sleep for xxx microseconds
1300
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1790
+			if (isset($globalSBSSleep)) {
1791
+				usleep($globalSBSSleep);
1792
+			}
1301 1793
 		    } else {
1302 1794
 			if ($format == 'flightgearmp') {
1303
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1795
+			    	if ($globalDebug) {
1796
+			    		echo "Reconnect FlightGear MP...";
1797
+			    	}
1304 1798
 				//@socket_close($r);
1305 1799
 				sleep($globalMinFetch);
1306 1800
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1309,10 +1803,15 @@  discard block
 block discarded – undo
1309 1803
 				break;
1310 1804
 				
1311 1805
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1312
-			    if (isset($tt[$format])) $tt[$format]++;
1313
-			    else $tt[$format] = 0;
1806
+			    if (isset($tt[$format])) {
1807
+			    	$tt[$format]++;
1808
+			    } else {
1809
+			    	$tt[$format] = 0;
1810
+			    }
1314 1811
 			    if ($tt[$format] > 30) {
1315
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1812
+				if ($globalDebug) {
1813
+					echo "ERROR : Reconnect ".$format."...";
1814
+				}
1316 1815
 				//@socket_close($r);
1317 1816
 				sleep(2);
1318 1817
 				$aprs_connect = 0;
@@ -1329,11 +1828,17 @@  discard block
 block discarded – undo
1329 1828
 	    } else {
1330 1829
 		$error = socket_strerror(socket_last_error());
1331 1830
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1332
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1333
-			if (isset($globalDebug)) echo "Restarting...\n";
1831
+			if ($globalDebug) {
1832
+				echo "ERROR : socket_select give this error ".$error . "\n";
1833
+			}
1834
+			if (isset($globalDebug)) {
1835
+				echo "Restarting...\n";
1836
+			}
1334 1837
 			// Restart the script if possible
1335 1838
 			if (is_array($sockets)) {
1336
-			    if ($globalDebug) echo "Shutdown all sockets...";
1839
+			    if ($globalDebug) {
1840
+			    	echo "Shutdown all sockets...";
1841
+			    }
1337 1842
 			    
1338 1843
 			    foreach ($sockets as $sock) {
1339 1844
 				@socket_shutdown($sock,2);
@@ -1341,18 +1846,24 @@  discard block
 block discarded – undo
1341 1846
 			    }
1342 1847
 			    
1343 1848
 			}
1344
-			if ($globalDebug) echo "Restart all connections...";
1849
+			if ($globalDebug) {
1850
+				echo "Restart all connections...";
1851
+			}
1345 1852
 			sleep(2);
1346 1853
 			$time = time();
1347 1854
 			//connect_all($hosts);
1348 1855
 			$aprs_connect = 0;
1349
-			if ($reset > 40) exit('Too many attempts...');
1856
+			if ($reset > 40) {
1857
+				exit('Too many attempts...');
1858
+			}
1350 1859
 			connect_all($globalSources);
1351 1860
 		}
1352 1861
 	    }
1353 1862
 	}
1354 1863
 	if ($globalDaemon === false) {
1355
-	    if ($globalDebug) echo 'Check all...'."\n";
1864
+	    if ($globalDebug) {
1865
+	    	echo 'Check all...'."\n";
1866
+	    }
1356 1867
 	    $SI->checkAll();
1357 1868
 	}
1358 1869
     }
Please login to merge, or discard this patch.
date.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3
-$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
3
+$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING);
4 4
 if ($date == '') $date = date('Y-m-d');
5 5
 header('Location: '.$globalURL.'/date/'.$date);
6 6
 ?>
7 7
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
4
-if ($date == '') $date = date('Y-m-d');
4
+if ($date == '') {
5
+	$date = date('Y-m-d');
6
+}
5 7
 header('Location: '.$globalURL.'/date/'.$date);
6 8
 ?>
7 9
\ No newline at end of file
Please login to merge, or discard this patch.
accident.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3
-$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
3
+$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING);
4 4
 if ($date == '') $date = date('Y-m-d');
5 5
 header('Location: '.$globalURL.'/accident/'.$date);
6 6
 ?>
7 7
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
4
-if ($date == '') $date = date('Y-m-d');
4
+if ($date == '') {
5
+	$date = date('Y-m-d');
6
+}
5 7
 header('Location: '.$globalURL.'/accident/'.$date);
6 8
 ?>
7 9
\ No newline at end of file
Please login to merge, or discard this patch.
statistics-fatalities-year.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
 print '<div id="chart" class="chart" width="100%"></div><script>';
20 20
 $year_data = '';
21 21
 $year_cnt = '';
22
-foreach($date_array as $year_item)
22
+foreach ($date_array as $year_item)
23 23
 {
24 24
 	$year_data .= '"'.$year_item['year'].'-01-01",';
25 25
 	$year_cnt .= $year_item['count'].',';
26 26
 }
27 27
 $year_data = "['x',".substr($year_data, 0, -1)."]";
28
-$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
28
+$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
29 29
 print 'c3.generate({
30 30
     bindto: "#chart",
31 31
     data: { x: "x",
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
 
36 36
 if (!empty($date_array))
37 37
 {
38
-	foreach($date_array as $key => $row) {
38
+	foreach ($date_array as $key => $row) {
39 39
 		$years[$key] = $row['year'];
40 40
 		$counts[$key] = $row['count'];
41 41
 	}
42 42
 	//array_multisort($years,SORT_DESC,$date_array);
43
-	array_multisort($counts,SORT_DESC,$date_array);
43
+	array_multisort($counts, SORT_DESC, $date_array);
44 44
 	print '<div class="table-responsive">';
45 45
 	print '<table class="common-date table-striped">';
46 46
 	print '<thead>';
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	print '</thead>';
51 51
 	print '<tbody>';
52 52
 	$i = 1;
53
-	foreach($date_array as $date_item)
53
+	foreach ($date_array as $date_item)
54 54
 	{
55 55
 		print '<tr>';
56 56
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
statistics-route-airport.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 $route_array = $Spotter->countAllRoutes();
19 19
 print '<div id="chart" class="chart" width="100%"></div><script>';
20 20
 $route_data = '';
21
-foreach($route_array as $route_item)
21
+foreach ($route_array as $route_item)
22 22
 {
23 23
 	$route_data .= '[ "'.$route_item['airport_departure_icao'].' - '.$route_item['airport_arrival_icao'].'",'.$route_item['route_count'].'],';
24 24
 }
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	print '</thead>';
47 47
 	print '<tbody>';
48 48
 	$i = 1;
49
-	foreach($route_array as $route_item)
49
+	foreach ($route_array as $route_item)
50 50
 	{
51 51
 		print '<tr>';
52 52
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
 $Spotter = new Spotter();
6 6
 $title = _("Statistics").' - '._("Most common Route by Airport");
7 7
 require_once('header.php');
8
-if (!isset($filter_name)) $filter_name = '';
8
+if (!isset($filter_name)) {
9
+	$filter_name = '';
10
+}
9 11
 include('statistics-sub-menu.php'); 
10 12
 
11 13
 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
Please login to merge, or discard this patch.
statistics.php 3 patches
Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
52 52
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
53 53
 	}
54
-    ?>
54
+	?>
55 55
     </div>
56 56
     <?php include('statistics-sub-menu.php'); ?>
57 57
     <p class="global-stats">
@@ -60,23 +60,23 @@  discard block
 block discarded – undo
60 60
         <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
61 61
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
62 62
 	<?php
63
-	    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
63
+		if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
64 64
 	?>
65 65
     	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
66 66
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
67 67
         <?php
68
-    	    } else {
69
-    	?>
68
+			} else {
69
+		?>
70 70
     	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
71 71
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
72 72
     	<?php
73
-    	    }
74
-    	?>
73
+			}
74
+		?>
75 75
         <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
76 76
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
77 77
         <?php
78
-    		if ($airline_icao == '') {
79
-    	?>
78
+			if ($airline_icao == '') {
79
+		?>
80 80
         <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
81 81
 	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
82 82
 	<?php
@@ -99,88 +99,88 @@  discard block
 block discarded – undo
99 99
             <div class="col-md-6">
100 100
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
101 101
                  <?php
102
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
103
-		    if (count($aircraft_array) == 0) print _("No data available");
104
-		    else {
105
-                    print '<div id="chart1" class="chart" width="100%"></div><script>';
106
-                    $aircraft_data = '';
107
-                    foreach($aircraft_array as $aircraft_item)
108
-                    {
109
-                        $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
110
-                    }
111
-                    $aircraft_data = substr($aircraft_data, 0, -1);
112
-		    print 'var series = ['.$aircraft_data.'];';
113
-		    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
114
-		    print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
115
-		    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
116
-                    print 'var aircraftype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
117
-                    print 'dataset';
118
-                    print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
119
-                    print '</script>';
120
-                  }
121
-                  ?>
102
+				  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
103
+			if (count($aircraft_array) == 0) print _("No data available");
104
+			else {
105
+					print '<div id="chart1" class="chart" width="100%"></div><script>';
106
+					$aircraft_data = '';
107
+					foreach($aircraft_array as $aircraft_item)
108
+					{
109
+						$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
110
+					}
111
+					$aircraft_data = substr($aircraft_data, 0, -1);
112
+			print 'var series = ['.$aircraft_data.'];';
113
+			print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
114
+			print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
115
+			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
116
+					print 'var aircraftype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
117
+					print 'dataset';
118
+					print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
119
+					print '</script>';
120
+				  }
121
+				  ?>
122 122
                 <div class="more">
123 123
             	    <?php
124
-            		if ($year != '' && $month != '') {
125
-            	    ?>
124
+					if ($year != '' && $month != '') {
125
+					?>
126 126
             	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
127 127
             	    <?php
128
-            		} else {
129
-            	    ?>
128
+					} else {
129
+					?>
130 130
             	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
131 131
             	    <?php
132
-            		}
133
-            	    ?>
132
+					}
133
+					?>
134 134
                 </div>
135 135
             </div>
136 136
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
137 137
 <?php
138 138
 //    echo $airline_icao;
139
-    if ($airline_icao == '' || $airline_icao == 'all') {
139
+	if ($airline_icao == '' || $airline_icao == 'all') {
140 140
 	$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
141 141
 	if (count($airline_array) > 0) {
142
-            print '<div class="col-md-6">';
143
-	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
144
-	    print '<div id="chart2" class="chart" width="100%"></div><script>';
145
-	    $airline_data = '';
146
-	    foreach($airline_array as $airline_item)
147
-	    {
142
+			print '<div class="col-md-6">';
143
+		print '<h2>'._("Top 10 Most Common Airline").'</h2>';
144
+		print '<div id="chart2" class="chart" width="100%"></div><script>';
145
+		$airline_data = '';
146
+		foreach($airline_array as $airline_item)
147
+		{
148 148
 		$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
149
-	    }
150
-	    $airline_data = substr($airline_data, 0, -1);
151
-	    print 'var series = ['.$airline_data.'];';
152
-	    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
153
-	    print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
154
-	    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
155
-            print 'var airlinescnt = new d3pie("chart2",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
156
-	    print 'dataset';
157
-            print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
158
-            print '</script>';
159
-	    if ($year != '' && $month != '') {
149
+		}
150
+		$airline_data = substr($airline_data, 0, -1);
151
+		print 'var series = ['.$airline_data.'];';
152
+		print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
153
+		print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
154
+		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
155
+			print 'var airlinescnt = new d3pie("chart2",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
156
+		print 'dataset';
157
+			print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
158
+			print '</script>';
159
+		if ($year != '' && $month != '') {
160 160
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
161 161
 		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
162 162
 		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
163
-	    } else {
163
+		} else {
164 164
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
165 165
 		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
166 166
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
167
-	    }
168
-    	    print '</div>';
167
+		}
168
+			print '</div>';
169 169
 	}
170 170
 ?>
171 171
         </div>
172 172
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
173 173
 <?php
174
-    }
174
+	}
175 175
 ?>
176 176
         <div class="row column">
177 177
 <?php
178
-    $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
179
-    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
178
+	$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
179
+	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
180 180
 	if (empty($flightover_array)) {
181
-	    print '<div class="col-md-12">';
181
+		print '<div class="col-md-12">';
182 182
 	} else {
183
-            print '<div class="col-md-6">';
183
+			print '<div class="col-md-6">';
184 184
 	}
185 185
 ?>
186 186
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
@@ -188,23 +188,23 @@  discard block
 block discarded – undo
188 188
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
189 189
 	if (count($pilot_array) == 0) print _("No data available");
190 190
 	else {
191
-	    print '<div id="chart7" class="chart" width="100%"></div><script>';
192
-	    $pilot_data = '';
193
-	    foreach($pilot_array as $pilot_item)
194
-	    {
191
+		print '<div id="chart7" class="chart" width="100%"></div><script>';
192
+		$pilot_data = '';
193
+		foreach($pilot_array as $pilot_item)
194
+		{
195 195
 		$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
196
-	    }
197
-	    $pilot_data = substr($pilot_data, 0, -1);
198
-	    print 'var series = ['.$pilot_data.'];';
199
-	    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
200
-	    print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
201
-	    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
202
-            print 'var pilotcnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
203
-	    print 'dataset';
204
-            print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
205
-            print '</script>';
206
-        }
207
-        print '<div class="more">';
196
+		}
197
+		$pilot_data = substr($pilot_data, 0, -1);
198
+		print 'var series = ['.$pilot_data.'];';
199
+		print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
200
+		print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
201
+		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
202
+			print 'var pilotcnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
203
+		print 'dataset';
204
+			print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
205
+			print '</script>';
206
+		}
207
+		print '<div class="more">';
208 208
 	print '<a href="'.$globalURL.'/statistics/pilot'; 
209 209
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
210 210
 	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         
215 215
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
216 216
 <?php
217
-    } else {
217
+	} else {
218 218
 ?>
219 219
             <div class="col-md-6">
220 220
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
@@ -222,21 +222,21 @@  discard block
 block discarded – undo
222 222
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
223 223
 	if (count($owner_array) == 0) print _("No data available");
224 224
 	else {
225
-	    print '<div id="chart7" class="chart" width="100%"></div><script>';
226
-	    $owner_data = '';
227
-	    foreach($owner_array as $owner_item)
228
-	    {
225
+		print '<div id="chart7" class="chart" width="100%"></div><script>';
226
+		$owner_data = '';
227
+		foreach($owner_array as $owner_item)
228
+		{
229 229
 		$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
230
-	    }
231
-	    $owner_data = substr($owner_data, 0, -1);
232
-	    print 'var series = ['.$owner_data.'];';
233
-	    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
234
-	    print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
235
-	    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
236
-            print 'var ownercnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
237
-	    print 'dataset';
238
-            print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
239
-	    print '</script>';
230
+		}
231
+		$owner_data = substr($owner_data, 0, -1);
232
+		print 'var series = ['.$owner_data.'];';
233
+		print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
234
+		print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
235
+		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
236
+			print 'var ownercnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
237
+		print 'dataset';
238
+			print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
239
+		print '</script>';
240 240
 	}
241 241
 ?>
242 242
                 <div class="more">
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
         
247 247
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
248 248
 <?php
249
-    }
250
-    if (!empty($flightover_array)) {
249
+	}
250
+	if (!empty($flightover_array)) {
251 251
 ?>
252 252
             <div class="col-md-6">
253 253
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
@@ -255,20 +255,20 @@  discard block
 block discarded – undo
255 255
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
256 256
 	if (count($flightover_array) == 0) print _("No data available");
257 257
 	else {
258
-	    print '<div id="chart10" class="chart" width="100%"></div><script>';
259
-	    print 'var series = [';
260
-            $flightover_data = '';
261
-	    foreach($flightover_array as $flightover_item)
262
-	    {
258
+		print '<div id="chart10" class="chart" width="100%"></div><script>';
259
+		print 'var series = [';
260
+			$flightover_data = '';
261
+		foreach($flightover_array as $flightover_item)
262
+		{
263 263
 		$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
264
-	    }
265
-	    $flightover_data = substr($flightover_data, 0, -1);
266
-	    print $flightover_data;
267
-	    print '];';
268
-	    print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
269
-	    print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
270
-	    print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
271
-	    print 'new Datamap({
264
+		}
265
+		$flightover_data = substr($flightover_data, 0, -1);
266
+		print $flightover_data;
267
+		print '];';
268
+		print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
269
+		print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
270
+		print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
271
+		print 'new Datamap({
272 272
     		element: document.getElementById("chart10"),
273 273
     		projection: "mercator", // big world map
274 274
     		fills: { defaultFill: "#F5F5F5" },
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         	    }
294 294
 		}
295 295
 	    });";
296
-	    print '</script>';
296
+		print '</script>';
297 297
 	}
298 298
 ?>
299 299
                 <div class="more">
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
                 </div>
302 302
             </div>
303 303
 <?php
304
-    }
304
+	}
305 305
 ?>
306 306
         </div>
307 307
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -311,13 +311,13 @@  discard block
 block discarded – undo
311 311
         <div class="row column">
312 312
             <div class="col-md-6">
313 313
 <?php
314
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
315
-    if (count($airport_airport_array) > 0) {
314
+	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
315
+	if (count($airport_airport_array) > 0) {
316 316
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
317 317
 	print '<div id="chart3" class="chart" width="100%"></div><script>';
318
-        print "\n";
319
-        print 'var series = [';
320
-        $airport_data = '';
318
+		print "\n";
319
+		print 'var series = [';
320
+		$airport_data = '';
321 321
 	foreach($airport_airport_array as $airport_item)
322 322
 	{
323 323
 		$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
@@ -366,20 +366,20 @@  discard block
 block discarded – undo
366 366
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
367 367
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
368 368
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
369
-    }
369
+	}
370 370
 ?>
371 371
             </div>
372 372
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
373 373
 
374 374
             <div class="col-md-6">
375 375
 <?php
376
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
377
-    if (count($airport_airport_array2) > 0) {
376
+	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
377
+	if (count($airport_airport_array2) > 0) {
378 378
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
379 379
 	print '<div id="chart4" class="chart" width="100%"></div><script>';
380
-        print "\n";
381
-        print 'var series = [';
382
-        $airport_data = '';
380
+		print "\n";
381
+		print 'var series = [';
382
+		$airport_data = '';
383 383
 	foreach($airport_airport_array2 as $airport_item)
384 384
 	{
385 385
 		$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
@@ -429,28 +429,28 @@  discard block
 block discarded – undo
429 429
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
430 430
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
431 431
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
432
-    }
432
+	}
433 433
 ?>
434 434
             </div>
435 435
         </div>
436 436
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
437 437
 <?php
438
-    if ($year == '' && $month == '') {
438
+	if ($year == '' && $month == '') {
439 439
 ?>
440 440
         <div class="row column">
441 441
             <div class="col-md-6">
442 442
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
443 443
                 <?php
444
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
445
-		    if (count($year_array) == 0) print _("No data available");
446
-		    else {
444
+				  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
445
+			if (count($year_array) == 0) print _("No data available");
446
+			else {
447 447
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
448 448
 			$year_data = '';
449 449
 			$year_cnt = '';
450 450
 			foreach($year_array as $year_item)
451 451
 			{
452
-			    $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
453
-			    $year_cnt .= $year_item['date_count'].',';
452
+				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
453
+				$year_cnt .= $year_item['date_count'].',';
454 454
 			}
455 455
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
456 456
 			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
                 	     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area-spline"}, colors: { flights: "#1a3151"}},
461 461
                 	     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Flights"}},legend: { show: false }});';
462 462
 			print '</script>';
463
-                    }
464
-                  ?>
463
+					}
464
+				  ?>
465 465
                 <div class="more">
466 466
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
467 467
                 </div>
@@ -470,16 +470,16 @@  discard block
 block discarded – undo
470 470
             <div class="col-md-6">
471 471
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
472 472
                 <?php
473
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
474
-		    if (count($month_array) == 0) print _("No data available");
475
-		    else {
476
-                	print '<div id="chart9" class="chart" width="100%"></div><script>';
477
-                        $month_data = '';
473
+				  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
474
+			if (count($month_array) == 0) print _("No data available");
475
+			else {
476
+					print '<div id="chart9" class="chart" width="100%"></div><script>';
477
+						$month_data = '';
478 478
 			$month_cnt = '';
479 479
 			foreach($month_array as $month_item)
480 480
 			{
481
-			    $month_data .= '"'.$month_item['date_name'].'",';
482
-			    $month_cnt .= $month_item['date_count'].',';
481
+				$month_data .= '"'.$month_item['date_name'].'",';
482
+				$month_cnt .= $month_item['date_count'].',';
483 483
 			}
484 484
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
485 485
 			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
@@ -489,9 +489,9 @@  discard block
 block discarded – undo
489 489
                 	     columns: ['.$month_data.','.$month_cnt.'], types: { flights: "area-spline"}, colors: { flights: "#1a3151"}},
490 490
                 	     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
491 491
 			
492
-            		print '</script>';
493
-                    }
494
-                  ?>
492
+					print '</script>';
493
+					}
494
+				  ?>
495 495
                 <div class="more">
496 496
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
497 497
                 </div>
@@ -501,16 +501,16 @@  discard block
 block discarded – undo
501 501
             <div class="col-md-6">
502 502
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
503 503
                 <?php
504
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
505
-		    if (empty($date_array)) print _("No data available");
506
-		    else {
507
-                	print '<div id="chart5" class="chart" width="100%"></div><script>';
508
-                        $date_data = '';
504
+					$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
505
+			if (empty($date_array)) print _("No data available");
506
+			else {
507
+					print '<div id="chart5" class="chart" width="100%"></div><script>';
508
+						$date_data = '';
509 509
 			$date_cnt = '';
510 510
 			foreach($date_array as $date_item)
511 511
 			{
512
-			    $date_data .= '"'.$date_item['date_name'].'",';
513
-			    $date_cnt .= $date_item['date_count'].',';
512
+				$date_data .= '"'.$date_item['date_name'].'",';
513
+				$date_cnt .= $date_item['date_count'].',';
514 514
 			}
515 515
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
516 516
 			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
@@ -520,9 +520,9 @@  discard block
 block discarded – undo
520 520
                 	     columns: ['.$date_data.','.$date_cnt.'], types: { flights: "area-spline"}, colors: { flights: "#1a3151"}},
521 521
                 	     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
522 522
 			
523
-                	print '</script>';
524
-                    }
525
-                  ?>
523
+					print '</script>';
524
+					}
525
+				  ?>
526 526
                 <div class="more">
527 527
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
528 528
                 </div>
@@ -531,16 +531,16 @@  discard block
 block discarded – undo
531 531
             <div class="col-md-6">
532 532
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
533 533
                 <?php
534
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
535
-		    if (empty($hour_array)) print _("No data available");
536
-		    else {
537
-                	print '<div id="chart6" class="chart" width="100%"></div><script>';
538
-                        $hour_data = '';
534
+				  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
535
+			if (empty($hour_array)) print _("No data available");
536
+			else {
537
+					print '<div id="chart6" class="chart" width="100%"></div><script>';
538
+						$hour_data = '';
539 539
 			$hour_cnt = '';
540 540
 			foreach($hour_array as $hour_item)
541 541
 			{
542
-			    $hour_data .= '"'.$hour_item['hour_name'].':00",';
543
-			    $hour_cnt .= $hour_item['hour_count'].',';
542
+				$hour_data .= '"'.$hour_item['hour_name'].':00",';
543
+				$hour_cnt .= $hour_item['hour_count'].',';
544 544
 			}
545 545
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
546 546
 			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
                 	     columns: ['.$hour_cnt.'], types: { flights: "area-spline"}, colors: { flights: "#1a3151"}},
551 551
                 	     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});';
552 552
 
553
-            	     print '</script>';
554
-                  }
555
-                ?>
553
+					 print '</script>';
554
+				  }
555
+				?>
556 556
                 <div class="more">
557 557
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
558 558
                 </div>
@@ -560,26 +560,26 @@  discard block
 block discarded – undo
560 560
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
561 561
         </div>
562 562
 <?php
563
-    }
563
+	}
564 564
 ?>
565 565
 
566 566
 <?php
567
-    if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
567
+	if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
568 568
 ?>
569 569
         <div class="row column">
570 570
             <div class="col-md-6">
571 571
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
572 572
                 <?php
573
-                  $year_array = $Stats->countFatalitiesByYear();
574
-		    if (count($year_array) == 0) print _("No data available");
575
-		    else {
573
+				  $year_array = $Stats->countFatalitiesByYear();
574
+			if (count($year_array) == 0) print _("No data available");
575
+			else {
576 576
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
577
-                        $year_data = '';
577
+						$year_data = '';
578 578
 			$year_cnt = '';
579 579
 			foreach($year_array as $year_item)
580 580
 			{
581
-			    $year_data .= '"'.$year_item['year'].'-01-01",';
582
-			    $year_cnt .= $year_item['count'].',';
581
+				$year_data .= '"'.$year_item['year'].'-01-01",';
582
+				$year_cnt .= $year_item['count'].',';
583 583
 			}
584 584
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
585 585
 			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
                 	     axis: { x: { type: "timeseries",tick: { format: "%Y"}}, y: { label: "# of Flights"}},legend: { show: false }});';
591 591
 
592 592
 			print '</script>';
593
-		    }
594
-                  ?>
593
+			}
594
+				  ?>
595 595
                 <div class="more">
596 596
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
597 597
                 </div>
@@ -602,16 +602,16 @@  discard block
 block discarded – undo
602 602
             <div class="col-md-6">
603 603
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
604 604
                 <?php
605
-                  $year_array = $Stats->countFatalitiesLast12Months();
606
-		    if (count($year_array) == 0) print _("No data available");
607
-		    else {
605
+				  $year_array = $Stats->countFatalitiesLast12Months();
606
+			if (count($year_array) == 0) print _("No data available");
607
+			else {
608 608
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
609
-                        $year_data = '';
609
+						$year_data = '';
610 610
 			$year_cnt = '';
611 611
 			foreach($year_array as $year_item)
612 612
 			{
613
-			    $year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
614
-			    $year_cnt .= $year_item['count'].',';
613
+				$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
614
+				$year_cnt .= $year_item['count'].',';
615 615
 			}
616 616
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
617 617
 			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
@@ -621,8 +621,8 @@  discard block
 block discarded – undo
621 621
                 	     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area-spline"}, colors: { flights: "#1a3151"}},
622 622
                 	     axis: { x: { type: "timeseries",tick: { format: "%Y-%m"}}, y: { label: "# of Flights"}},legend: { show: false }});';
623 623
 			print '</script>';
624
-		    }
625
-                  ?>
624
+			}
625
+				  ?>
626 626
                 <div class="more">
627 627
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
628 628
                 </div>
@@ -630,30 +630,30 @@  discard block
 block discarded – undo
630 630
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
631 631
 <br/>
632 632
 <?php
633
-    }
633
+	}
634 634
 ?>
635 635
 
636 636
 <?php
637
-    if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
637
+	if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
638 638
 ?>
639 639
         <div class="row column">
640 640
         	<?php
641
-        	    //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
642
-        	    if ($year == '' && $month == '') {
643
-		        $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
644
-		    } else {
645
-        		$polar = $Stats->getStatsSource('polar',$year,$month);
646
-        	    }
647
-        	    if (!empty($polar)) {
648
-            		print '<h2>'._("Coverage pattern").'</h2>';
649
-        		foreach ($polar as $eachpolar) {
650
-        		    unset($polar_data);
651
-	        	    $Spotter = new Spotter();
652
-        		    $data = json_decode($eachpolar['source_data']);
653
-        		    foreach($data as $value => $key) {
654
-        			$direction = $Spotter->parseDirection(($value*22.5));
655
-        			$distance = $key;
656
-        			$unit = 'km';
641
+				//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
642
+				if ($year == '' && $month == '') {
643
+				$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
644
+			} else {
645
+				$polar = $Stats->getStatsSource('polar',$year,$month);
646
+				}
647
+				if (!empty($polar)) {
648
+					print '<h2>'._("Coverage pattern").'</h2>';
649
+				foreach ($polar as $eachpolar) {
650
+					unset($polar_data);
651
+					$Spotter = new Spotter();
652
+					$data = json_decode($eachpolar['source_data']);
653
+					foreach($data as $value => $key) {
654
+					$direction = $Spotter->parseDirection(($value*22.5));
655
+					$distance = $key;
656
+					$unit = 'km';
657 657
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
658 658
 					$distance = round($distance*0.539957);
659 659
 					$unit = 'nm';
@@ -664,10 +664,10 @@  discard block
 block discarded – undo
664 664
 					$distance = $distance;
665 665
 					$unit = 'km';
666 666
 				}
667
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
668
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
669
-        		    }
670
-        	?>
667
+					if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
668
+						else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
669
+					}
670
+			?>
671 671
             <div class="col-md-6">
672 672
                 <h4><?php print $eachpolar['source_name']; ?></h4>
673 673
         	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
@@ -699,27 +699,27 @@  discard block
 block discarded – undo
699 699
 		</script>
700 700
             </div>
701 701
             <?php
702
-        	    }
703
-        	}
704
-            ?>
702
+				}
703
+			}
704
+			?>
705 705
         </div>
706 706
         <div class="row column">
707 707
             <div class="col-md-6">
708 708
         	<?php
709
-        	    //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
710
-        	    if ($year == '' && $month == '') {
711
-        		$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
712
-        	    } else {
713
-        		$msg = $Stats->getStatsSource('msg',$year,$month);
714
-        	    }
715
-        	    if (!empty($msg)) {
716
-            		print '<h2>'._("Messages received").'</h2>';
717
-        		foreach ($msg as $eachmsg) {
718
-        		    //$eachmsg = $msg[0];
719
-        		    $data = $eachmsg['source_data'];
720
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
721
-        		    else $max = 500;
722
-        	?>
709
+				//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
710
+				if ($year == '' && $month == '') {
711
+				$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
712
+				} else {
713
+				$msg = $Stats->getStatsSource('msg',$year,$month);
714
+				}
715
+				if (!empty($msg)) {
716
+					print '<h2>'._("Messages received").'</h2>';
717
+				foreach ($msg as $eachmsg) {
718
+					//$eachmsg = $msg[0];
719
+					$data = $eachmsg['source_data'];
720
+					if ($data > 500) $max = (round(($data+100)/100))*100;
721
+					else $max = 500;
722
+			?>
723 723
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
724 724
         	<script>
725 725
 		      var g = new JustGage({
@@ -735,9 +735,9 @@  discard block
 block discarded – undo
735 735
 			  });
736 736
 		</script>
737 737
             <?php
738
-        	   }
739
-        	}
740
-            ?>
738
+			   }
739
+			}
740
+			?>
741 741
             </div>
742 742
         </div>
743 743
         <div class="row column">
@@ -775,26 +775,26 @@  discard block
 block discarded – undo
775 775
 			//$hist_data = substr($hist_data, 0, -1);
776 776
 			$distance_data = "['x',".substr($distance_data, 0, -1)."]";
777 777
 			$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
778
-            ?>
778
+			?>
779 779
             <div class="col-md-6">
780 780
                 <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
781 781
                 <?php
782
-                    print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
783
-		    print 'c3.generate({
782
+					print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
783
+			print 'c3.generate({
784 784
 			bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
785 785
 			data: { x: "x",
786 786
 			columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area-spline"}, colors: { flights: "#1a3151"}},
787 787
 			axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
788
-		    print '</script>';
789
-        	?>
788
+			print '</script>';
789
+			?>
790 790
     	    </div>
791 791
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
792 792
         	<?php
793
-                  }
794
-                ?>
793
+				  }
794
+				?>
795 795
         </div>
796 796
 <?php
797
-    }
797
+	}
798 798
 ?>
799 799
     </div>
800 800
 </div>  
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 $Stats = new Stats();
8 8
 
9 9
 if (!isset($filter_name)) $filter_name = '';
10
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
11 11
 if ($airline_icao == '' && isset($globalFilter)) {
12 12
 	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
13 13
 }
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 	$title = _("Statistics");
23 23
 }
24 24
 
25
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
26
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
25
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
26
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
27 27
 
28 28
 require_once('header.php');
29 29
 
@@ -49,36 +49,36 @@  discard block
 block discarded – undo
49 49
 		date_default_timezone_set('UTC');
50 50
 		$lastupdate = strtotime($last_update[0]['value']);
51 51
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
52
-		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
52
+		print '<i>Last update: '.date('Y-m-d G:i:s', $lastupdate).'</i>';
53 53
 	}
54 54
     ?>
55 55
     </div>
56 56
     <?php include('statistics-sub-menu.php'); ?>
57 57
     <p class="global-stats">
58
-        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Flights"); ?></span>
59
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
60
-        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
61
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
58
+        <span><span class="badge"><?php print number_format($Stats->countOverallFlights($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Flights"); ?></span>
59
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
60
+        <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
61
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
62 62
 	<?php
63 63
 	    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
64 64
 	?>
65
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
66
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
65
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Pilots"); ?></span>
66
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
67 67
         <?php
68 68
     	    } else {
69 69
     	?>
70
-    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
71
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
70
+    	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Owners"); ?></span>
71
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
72 72
     	<?php
73 73
     	    }
74 74
     	?>
75
-        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
76
-        <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
75
+        <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao, $filter_name, $year, $month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
76
+        <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
77 77
         <?php
78 78
     		if ($airline_icao == '') {
79 79
     	?>
80
-        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
81
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
80
+        <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name, $year, $month)); ?></span> <?php echo _("Airlines"); ?></span>
81
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
82 82
 	<?php
83 83
 		}
84 84
 	?>
@@ -86,25 +86,25 @@  discard block
 block discarded – undo
86 86
 		if (!(isset($globalIVAO) && $globalIVAO) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalphpVMS) && $globalphpVMS)) {
87 87
 			if ($airline_icao == '' || $airline_icao == 'all') {
88 88
 	?>
89
-        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name,$year,$month)); ?></span> <?php echo _("Military"); ?></span>
90
-	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
89
+        <span><span class="badge"><?php print number_format($Stats->countOverallMilitaryFlights($filter_name, $year, $month)); ?></span> <?php echo _("Military"); ?></span>
90
+	<!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
91 91
 	<?php
92 92
 			}
93 93
 		}
94 94
 	?>
95 95
     </p>
96
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
96
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
97 97
     <div class="specific-stats">
98 98
         <div class="row column">
99 99
             <div class="col-md-6">
100 100
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
101 101
                  <?php
102
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
102
+                  $aircraft_array = $Stats->countAllAircraftTypes(true, $airline_icao, $filter_name, $year, $month);
103 103
 		    if (count($aircraft_array) == 0) print _("No data available");
104 104
 		    else {
105 105
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
106 106
                     $aircraft_data = '';
107
-                    foreach($aircraft_array as $aircraft_item)
107
+                    foreach ($aircraft_array as $aircraft_item)
108 108
                     {
109 109
                         $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
110 110
                     }
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
             	    ?>
134 134
                 </div>
135 135
             </div>
136
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
136
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
137 137
 <?php
138 138
 //    echo $airline_icao;
139 139
     if ($airline_icao == '' || $airline_icao == 'all') {
140
-	$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
140
+	$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month);
141 141
 	if (count($airline_array) > 0) {
142 142
             print '<div class="col-md-6">';
143 143
 	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
144 144
 	    print '<div id="chart2" class="chart" width="100%"></div><script>';
145 145
 	    $airline_data = '';
146
-	    foreach($airline_array as $airline_item)
146
+	    foreach ($airline_array as $airline_item)
147 147
 	    {
148 148
 		$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
149 149
 	    }
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
 	}
170 170
 ?>
171 171
         </div>
172
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
172
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
173 173
 <?php
174 174
     }
175 175
 ?>
176 176
         <div class="row column">
177 177
 <?php
178
-    $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
178
+    $flightover_array = $Stats->countAllFlightOverCountries(false, $airline_icao, $filter_name, $year, $month);
179 179
     if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
180 180
 	if (empty($flightover_array)) {
181 181
 	    print '<div class="col-md-12">';
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
 ?>
186 186
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
187 187
 <?php
188
-	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
188
+	$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month);
189 189
 	if (count($pilot_array) == 0) print _("No data available");
190 190
 	else {
191 191
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
192 192
 	    $pilot_data = '';
193
-	    foreach($pilot_array as $pilot_item)
193
+	    foreach ($pilot_array as $pilot_item)
194 194
 	    {
195 195
 		$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
196 196
 	    }
@@ -212,19 +212,19 @@  discard block
 block discarded – undo
212 212
 ?>
213 213
             </div>
214 214
         
215
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
215
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
216 216
 <?php
217 217
     } else {
218 218
 ?>
219 219
             <div class="col-md-6">
220 220
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
221 221
 <?php
222
-	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
222
+	$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name, $year, $month);
223 223
 	if (count($owner_array) == 0) print _("No data available");
224 224
 	else {
225 225
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
226 226
 	    $owner_data = '';
227
-	    foreach($owner_array as $owner_item)
227
+	    foreach ($owner_array as $owner_item)
228 228
 	    {
229 229
 		$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
230 230
 	    }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                 </div>
245 245
             </div>
246 246
         
247
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
247
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
248 248
 <?php
249 249
     }
250 250
     if (!empty($flightover_array)) {
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	    print '<div id="chart10" class="chart" width="100%"></div><script>';
259 259
 	    print 'var series = [';
260 260
             $flightover_data = '';
261
-	    foreach($flightover_array as $flightover_item)
261
+	    foreach ($flightover_array as $flightover_item)
262 262
 	    {
263 263
 		$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
264 264
 	    }
@@ -304,21 +304,21 @@  discard block
 block discarded – undo
304 304
     }
305 305
 ?>
306 306
         </div>
307
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
307
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
308 308
 
309 309
     	
310 310
         </div>
311 311
         <div class="row column">
312 312
             <div class="col-md-6">
313 313
 <?php
314
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
314
+    $airport_airport_array = $Stats->countAllDepartureAirports(true, $airline_icao, $filter_name, $year, $month);
315 315
     if (count($airport_airport_array) > 0) {
316 316
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
317 317
 	print '<div id="chart3" class="chart" width="100%"></div><script>';
318 318
         print "\n";
319 319
         print 'var series = [';
320 320
         $airport_data = '';
321
-	foreach($airport_airport_array as $airport_item)
321
+	foreach ($airport_airport_array as $airport_item)
322 322
 	{
323 323
 		$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
324 324
 	}
@@ -369,18 +369,18 @@  discard block
 block discarded – undo
369 369
     }
370 370
 ?>
371 371
             </div>
372
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
372
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
373 373
 
374 374
             <div class="col-md-6">
375 375
 <?php
376
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
376
+    $airport_airport_array2 = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month);
377 377
     if (count($airport_airport_array2) > 0) {
378 378
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
379 379
 	print '<div id="chart4" class="chart" width="100%"></div><script>';
380 380
         print "\n";
381 381
         print 'var series = [';
382 382
         $airport_data = '';
383
-	foreach($airport_airport_array2 as $airport_item)
383
+	foreach ($airport_airport_array2 as $airport_item)
384 384
 	{
385 385
 		$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
386 386
 	}
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 ?>
434 434
             </div>
435 435
         </div>
436
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
436
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
437 437
 <?php
438 438
     if ($year == '' && $month == '') {
439 439
 ?>
@@ -441,19 +441,19 @@  discard block
 block discarded – undo
441 441
             <div class="col-md-6">
442 442
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
443 443
                 <?php
444
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
444
+                  $year_array = $Stats->countAllMonthsLastYear(true, $airline_icao, $filter_name);
445 445
 		    if (count($year_array) == 0) print _("No data available");
446 446
 		    else {
447 447
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
448 448
 			$year_data = '';
449 449
 			$year_cnt = '';
450
-			foreach($year_array as $year_item)
450
+			foreach ($year_array as $year_item)
451 451
 			{
452 452
 			    $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
453 453
 			    $year_cnt .= $year_item['date_count'].',';
454 454
 			}
455 455
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
456
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
456
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
457 457
 			print 'c3.generate({
458 458
                 	    bindto: "#chart8",
459 459
                 	    data: { x: "x",
@@ -466,23 +466,23 @@  discard block
 block discarded – undo
466 466
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
467 467
                 </div>
468 468
             </div>
469
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
469
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
470 470
             <div class="col-md-6">
471 471
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
472 472
                 <?php
473
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
473
+                  $month_array = $Stats->countAllDatesLastMonth($airline_icao, $filter_name);
474 474
 		    if (count($month_array) == 0) print _("No data available");
475 475
 		    else {
476 476
                 	print '<div id="chart9" class="chart" width="100%"></div><script>';
477 477
                         $month_data = '';
478 478
 			$month_cnt = '';
479
-			foreach($month_array as $month_item)
479
+			foreach ($month_array as $month_item)
480 480
 			{
481 481
 			    $month_data .= '"'.$month_item['date_name'].'",';
482 482
 			    $month_cnt .= $month_item['date_count'].',';
483 483
 			}
484 484
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
485
-			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
485
+			$month_cnt = "['flights',".substr($month_cnt, 0, -1)."]";
486 486
 			print 'c3.generate({
487 487
                 	    bindto: "#chart9",
488 488
                 	    data: { x: "x",
@@ -496,24 +496,24 @@  discard block
 block discarded – undo
496 496
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
497 497
                 </div>
498 498
             </div>
499
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
499
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
500 500
 
501 501
             <div class="col-md-6">
502 502
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
503 503
                 <?php
504
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
504
+                    $date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name);
505 505
 		    if (empty($date_array)) print _("No data available");
506 506
 		    else {
507 507
                 	print '<div id="chart5" class="chart" width="100%"></div><script>';
508 508
                         $date_data = '';
509 509
 			$date_cnt = '';
510
-			foreach($date_array as $date_item)
510
+			foreach ($date_array as $date_item)
511 511
 			{
512 512
 			    $date_data .= '"'.$date_item['date_name'].'",';
513 513
 			    $date_cnt .= $date_item['date_count'].',';
514 514
 			}
515 515
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
516
-			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
516
+			$date_cnt = "['flights',".substr($date_cnt, 0, -1)."]";
517 517
 			print 'c3.generate({
518 518
                 	    bindto: "#chart5",
519 519
                 	    data: { x: "x",
@@ -527,23 +527,23 @@  discard block
 block discarded – undo
527 527
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
528 528
                 </div>
529 529
             </div>
530
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
530
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
531 531
             <div class="col-md-6">
532 532
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
533 533
                 <?php
534
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
534
+                  $hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name);
535 535
 		    if (empty($hour_array)) print _("No data available");
536 536
 		    else {
537 537
                 	print '<div id="chart6" class="chart" width="100%"></div><script>';
538 538
                         $hour_data = '';
539 539
 			$hour_cnt = '';
540
-			foreach($hour_array as $hour_item)
540
+			foreach ($hour_array as $hour_item)
541 541
 			{
542 542
 			    $hour_data .= '"'.$hour_item['hour_name'].':00",';
543 543
 			    $hour_cnt .= $hour_item['hour_count'].',';
544 544
 			}
545 545
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
546
-			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
546
+			$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
547 547
 			print 'c3.generate({
548 548
                 	    bindto: "#chart6",
549 549
                 	    data: {
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
558 558
                 </div>
559 559
             </div>
560
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
560
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
561 561
         </div>
562 562
 <?php
563 563
     }
@@ -576,13 +576,13 @@  discard block
 block discarded – undo
576 576
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
577 577
                         $year_data = '';
578 578
 			$year_cnt = '';
579
-			foreach($year_array as $year_item)
579
+			foreach ($year_array as $year_item)
580 580
 			{
581 581
 			    $year_data .= '"'.$year_item['year'].'-01-01",';
582 582
 			    $year_cnt .= $year_item['count'].',';
583 583
 			}
584 584
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
585
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
585
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
586 586
 			print 'c3.generate({
587 587
                 	    bindto: "#chart32",
588 588
                 	    data: { x: "x",
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
597 597
                 </div>
598 598
             </div>
599
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
599
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
600 600
 
601 601
         <div class="row column">
602 602
             <div class="col-md-6">
@@ -608,13 +608,13 @@  discard block
 block discarded – undo
608 608
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
609 609
                         $year_data = '';
610 610
 			$year_cnt = '';
611
-			foreach($year_array as $year_item)
611
+			foreach ($year_array as $year_item)
612 612
 			{
613 613
 			    $year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
614 614
 			    $year_cnt .= $year_item['count'].',';
615 615
 			}
616 616
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
617
-			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
617
+			$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]";
618 618
 			print 'c3.generate({
619 619
                 	    bindto: "#chart33",
620 620
                 	    data: { x: "x",
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
628 628
                 </div>
629 629
             </div>
630
-    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
630
+    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
631 631
 <br/>
632 632
 <?php
633 633
     }
@@ -640,9 +640,9 @@  discard block
 block discarded – undo
640 640
         	<?php
641 641
         	    //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
642 642
         	    if ($year == '' && $month == '') {
643
-		        $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
643
+		        $polar = $Stats->getStatsSource('polar', date('Y'), date('m'), date('d'));
644 644
 		    } else {
645
-        		$polar = $Stats->getStatsSource('polar',$year,$month);
645
+        		$polar = $Stats->getStatsSource('polar', $year, $month);
646 646
         	    }
647 647
         	    if (!empty($polar)) {
648 648
             		print '<h2>'._("Coverage pattern").'</h2>';
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
         		    unset($polar_data);
651 651
 	        	    $Spotter = new Spotter();
652 652
         		    $data = json_decode($eachpolar['source_data']);
653
-        		    foreach($data as $value => $key) {
653
+        		    foreach ($data as $value => $key) {
654 654
         			$direction = $Spotter->parseDirection(($value*22.5));
655 655
         			$distance = $key;
656 656
         			$unit = 'km';
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
         	?>
671 671
             <div class="col-md-6">
672 672
                 <h4><?php print $eachpolar['source_name']; ?></h4>
673
-        	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
673
+        	<div id="polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
674 674
         	<script>
675 675
         	    (function() {
676 676
         	    var margin = {top: 100, right: 100, bottom: 100, left: 100},
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 		      color: color,
695 695
 		      unit: '<?php echo $unit; ?>'
696 696
 		    };
697
-		    RadarChart("#polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
697
+		    RadarChart("#polar-<?php print str_replace(' ', '_', strtolower($eachpolar['source_name'])); ?>", data, radarChartOptions);
698 698
 		    })();
699 699
 		</script>
700 700
             </div>
@@ -708,22 +708,22 @@  discard block
 block discarded – undo
708 708
         	<?php
709 709
         	    //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
710 710
         	    if ($year == '' && $month == '') {
711
-        		$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
711
+        		$msg = $Stats->getStatsSource('msg', date('Y'), date('m'), date('d'));
712 712
         	    } else {
713
-        		$msg = $Stats->getStatsSource('msg',$year,$month);
713
+        		$msg = $Stats->getStatsSource('msg', $year, $month);
714 714
         	    }
715 715
         	    if (!empty($msg)) {
716 716
             		print '<h2>'._("Messages received").'</h2>';
717 717
         		foreach ($msg as $eachmsg) {
718 718
         		    //$eachmsg = $msg[0];
719 719
         		    $data = $eachmsg['source_data'];
720
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
720
+        		    if ($data > 500) $max = (round(($data + 100)/100))*100;
721 721
         		    else $max = 500;
722 722
         	?>
723
-        	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
723
+        	<div id="msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
724 724
         	<script>
725 725
 		      var g = new JustGage({
726
-			    id: "msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>",
726
+			    id: "msg-<?php print str_replace(' ', '_', strtolower($eachmsg['source_name'])); ?>",
727 727
 			    value: <?php echo $data; ?>,
728 728
 			    min: 0,
729 729
 			    max: <?php print $max; ?>,
@@ -745,9 +745,9 @@  discard block
 block discarded – undo
745 745
             <?php
746 746
 		//$hist = $Stats->getStatsSource(date('Y-m-d'),'hist');
747 747
 		if ($year == '' && $month == '') {
748
-			$hist = $Stats->getStatsSource('hist',date('Y'),date('m'),date('d'));
748
+			$hist = $Stats->getStatsSource('hist', date('Y'), date('m'), date('d'));
749 749
 		} else {
750
-			$hist = $Stats->getStatsSource('hist',$year,$month);
750
+			$hist = $Stats->getStatsSource('hist', $year, $month);
751 751
 		}
752 752
 		foreach ($hist as $hists) {
753 753
 			//$hist_data = '';
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 			$source = $hists['source_name'];
757 757
 			$hist_array = json_decode($hists['source_data']);
758 758
 			$unit = 'km';
759
-			foreach($hist_array as $distance => $nb)
759
+			foreach ($hist_array as $distance => $nb)
760 760
 			{
761 761
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
762 762
 					$distance = round($distance*0.539957);
@@ -777,18 +777,18 @@  discard block
 block discarded – undo
777 777
 			$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
778 778
             ?>
779 779
             <div class="col-md-6">
780
-                <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
780
+                <h2><?php echo sprintf(_("Flights Distance for %s"), $source); ?></h2>
781 781
                 <?php
782
-                    print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
782
+                    print '<div id="charthist-'.str_replace(' ', '_', strtolower($source)).'" class="chart" width="100%"></div><script>';
783 783
 		    print 'c3.generate({
784
-			bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
784
+			bindto: "#charthist-'.str_replace(' ', '_', strtolower($source)).'",
785 785
 			data: { x: "x",
786 786
 			columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area-spline"}, colors: { flights: "#1a3151"}},
787 787
 			axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
788 788
 		    print '</script>';
789 789
         	?>
790 790
     	    </div>
791
-	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
791
+	    <!-- <?php print 'Time elapsed : '.(microtime(true) - $beginpage).'s' ?> -->
792 792
         	<?php
793 793
                   }
794 794
                 ?>
Please login to merge, or discard this patch.
Braces   +103 added lines, -42 removed lines patch added patch discarded remove patch
@@ -6,11 +6,15 @@  discard block
 block discarded – undo
6 6
 $beginpage = microtime(true);
7 7
 $Stats = new Stats();
8 8
 
9
-if (!isset($filter_name)) $filter_name = '';
9
+if (!isset($filter_name)) {
10
+	$filter_name = '';
11
+}
10 12
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
11 13
 if ($airline_icao == '' && isset($globalFilter)) {
12
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
13
-}
14
+	if (isset($globalFilter['airline'])) {
15
+		$airline_icao = $globalFilter['airline'][0];
16
+	}
17
+	}
14 18
 if ($airline_icao != '' && $airline_icao != 'all') {
15 19
 	$Spotter = new Spotter();
16 20
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -41,14 +45,21 @@  discard block
 block discarded – undo
41 45
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
42 46
 <div class="column">
43 47
     <div class="info">
44
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
48
+            <h1><?php if (isset($airline_name)) {
49
+	echo _("Statistics for ").$airline_name;
50
+} else {
51
+	echo _("Statistics");
52
+}
53
+?></h1>
45 54
     <?php 
46 55
 	$last_update = $Stats->getLastStatsUpdate();
47 56
 	//if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->';
48 57
 	if (isset($last_update[0]['value'])) {
49 58
 		date_default_timezone_set('UTC');
50 59
 		$lastupdate = strtotime($last_update[0]['value']);
51
-		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
60
+		if (isset($globalTimezone) && $globalTimezone != '') {
61
+			date_default_timezone_set($globalTimezone);
62
+		}
52 63
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
53 64
 	}
54 65
     ?>
@@ -100,8 +111,9 @@  discard block
 block discarded – undo
100 111
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
101 112
                  <?php
102 113
                   $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
103
-		    if (count($aircraft_array) == 0) print _("No data available");
104
-		    else {
114
+		    if (count($aircraft_array) == 0) {
115
+		    	print _("No data available");
116
+		    } else {
105 117
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
106 118
                     $aircraft_data = '';
107 119
                     foreach($aircraft_array as $aircraft_item)
@@ -123,11 +135,17 @@  discard block
 block discarded – undo
123 135
             	    <?php
124 136
             		if ($year != '' && $month != '') {
125 137
             	    ?>
126
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
138
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
139
+	echo '/'.$airline_icao;
140
+}
141
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
127 142
             	    <?php
128 143
             		} else {
129 144
             	    ?>
130
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
145
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
146
+	echo '/'.$airline_icao;
147
+}
148
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
131 149
             	    <?php
132 150
             		}
133 151
             	    ?>
@@ -158,11 +176,15 @@  discard block
 block discarded – undo
158 176
             print '</script>';
159 177
 	    if ($year != '' && $month != '') {
160 178
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
161
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
179
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
180
+			echo '/'.$airline_icao;
181
+		}
162 182
 		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
163 183
 	    } else {
164 184
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
165
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
185
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
186
+			echo '/'.$airline_icao;
187
+		}
166 188
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
167 189
 	    }
168 190
     	    print '</div>';
@@ -186,8 +208,9 @@  discard block
 block discarded – undo
186 208
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
187 209
 <?php
188 210
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
189
-	if (count($pilot_array) == 0) print _("No data available");
190
-	else {
211
+	if (count($pilot_array) == 0) {
212
+		print _("No data available");
213
+	} else {
191 214
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
192 215
 	    $pilot_data = '';
193 216
 	    foreach($pilot_array as $pilot_item)
@@ -206,7 +229,9 @@  discard block
 block discarded – undo
206 229
         }
207 230
         print '<div class="more">';
208 231
 	print '<a href="'.$globalURL.'/statistics/pilot'; 
209
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
232
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
233
+		echo '/'.$airline_icao;
234
+	}
210 235
 	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
211 236
 	print '</div>';
212 237
 ?>
@@ -220,8 +245,9 @@  discard block
 block discarded – undo
220 245
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
221 246
 <?php
222 247
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
223
-	if (count($owner_array) == 0) print _("No data available");
224
-	else {
248
+	if (count($owner_array) == 0) {
249
+		print _("No data available");
250
+	} else {
225 251
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
226 252
 	    $owner_data = '';
227 253
 	    foreach($owner_array as $owner_item)
@@ -240,7 +266,10 @@  discard block
 block discarded – undo
240 266
 	}
241 267
 ?>
242 268
                 <div class="more">
243
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
269
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
270
+	echo '/'.$airline_icao;
271
+}
272
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
244 273
                 </div>
245 274
             </div>
246 275
         
@@ -253,8 +282,9 @@  discard block
 block discarded – undo
253 282
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
254 283
 <?php
255 284
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
256
-	if (count($flightover_array) == 0) print _("No data available");
257
-	else {
285
+	if (count($flightover_array) == 0) {
286
+		print _("No data available");
287
+	} else {
258 288
 	    print '<div id="chart10" class="chart" width="100%"></div><script>';
259 289
 	    print 'var series = [';
260 290
             $flightover_data = '';
@@ -297,7 +327,10 @@  discard block
 block discarded – undo
297 327
 	}
298 328
 ?>
299 329
                 <div class="more">
300
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
330
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
331
+	echo '/'.$airline_icao;
332
+}
333
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
301 334
                 </div>
302 335
             </div>
303 336
 <?php
@@ -364,7 +397,9 @@  discard block
 block discarded – undo
364 397
 	print '</script>';
365 398
 
366 399
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
367
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
400
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
401
+		echo '/'.$airline_icao;
402
+	}
368 403
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
369 404
     }
370 405
 ?>
@@ -427,7 +462,9 @@  discard block
 block discarded – undo
427 462
 
428 463
 
429 464
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
430
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
465
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
466
+		echo '/'.$airline_icao;
467
+	}
431 468
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
432 469
     }
433 470
 ?>
@@ -442,8 +479,9 @@  discard block
 block discarded – undo
442 479
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
443 480
                 <?php
444 481
                   $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
445
-		    if (count($year_array) == 0) print _("No data available");
446
-		    else {
482
+		    if (count($year_array) == 0) {
483
+		    	print _("No data available");
484
+		    } else {
447 485
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
448 486
 			$year_data = '';
449 487
 			$year_cnt = '';
@@ -463,7 +501,10 @@  discard block
 block discarded – undo
463 501
                     }
464 502
                   ?>
465 503
                 <div class="more">
466
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
504
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
505
+	echo '/'.$airline_icao;
506
+}
507
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
467 508
                 </div>
468 509
             </div>
469 510
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -471,8 +512,9 @@  discard block
 block discarded – undo
471 512
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
472 513
                 <?php
473 514
                   $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
474
-		    if (count($month_array) == 0) print _("No data available");
475
-		    else {
515
+		    if (count($month_array) == 0) {
516
+		    	print _("No data available");
517
+		    } else {
476 518
                 	print '<div id="chart9" class="chart" width="100%"></div><script>';
477 519
                         $month_data = '';
478 520
 			$month_cnt = '';
@@ -493,7 +535,10 @@  discard block
 block discarded – undo
493 535
                     }
494 536
                   ?>
495 537
                 <div class="more">
496
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
538
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
539
+	echo '/'.$airline_icao;
540
+}
541
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
497 542
                 </div>
498 543
             </div>
499 544
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -502,8 +547,9 @@  discard block
 block discarded – undo
502 547
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
503 548
                 <?php
504 549
                     $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
505
-		    if (empty($date_array)) print _("No data available");
506
-		    else {
550
+		    if (empty($date_array)) {
551
+		    	print _("No data available");
552
+		    } else {
507 553
                 	print '<div id="chart5" class="chart" width="100%"></div><script>';
508 554
                         $date_data = '';
509 555
 			$date_cnt = '';
@@ -524,7 +570,10 @@  discard block
 block discarded – undo
524 570
                     }
525 571
                   ?>
526 572
                 <div class="more">
527
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
573
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
574
+	echo '/'.$airline_icao;
575
+}
576
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
528 577
                 </div>
529 578
             </div>
530 579
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -532,8 +581,9 @@  discard block
 block discarded – undo
532 581
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
533 582
                 <?php
534 583
                   $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
535
-		    if (empty($hour_array)) print _("No data available");
536
-		    else {
584
+		    if (empty($hour_array)) {
585
+		    	print _("No data available");
586
+		    } else {
537 587
                 	print '<div id="chart6" class="chart" width="100%"></div><script>';
538 588
                         $hour_data = '';
539 589
 			$hour_cnt = '';
@@ -554,7 +604,10 @@  discard block
 block discarded – undo
554 604
                   }
555 605
                 ?>
556 606
                 <div class="more">
557
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
607
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
608
+	echo '/'.$airline_icao;
609
+}
610
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
558 611
                 </div>
559 612
             </div>
560 613
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -571,8 +624,9 @@  discard block
 block discarded – undo
571 624
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
572 625
                 <?php
573 626
                   $year_array = $Stats->countFatalitiesByYear();
574
-		    if (count($year_array) == 0) print _("No data available");
575
-		    else {
627
+		    if (count($year_array) == 0) {
628
+		    	print _("No data available");
629
+		    } else {
576 630
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
577 631
                         $year_data = '';
578 632
 			$year_cnt = '';
@@ -603,8 +657,9 @@  discard block
 block discarded – undo
603 657
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
604 658
                 <?php
605 659
                   $year_array = $Stats->countFatalitiesLast12Months();
606
-		    if (count($year_array) == 0) print _("No data available");
607
-		    else {
660
+		    if (count($year_array) == 0) {
661
+		    	print _("No data available");
662
+		    } else {
608 663
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
609 664
                         $year_data = '';
610 665
 			$year_cnt = '';
@@ -664,8 +719,11 @@  discard block
 block discarded – undo
664 719
 					$distance = $distance;
665 720
 					$unit = 'km';
666 721
 				}
667
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
668
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
722
+        			if (!isset($polar_data)) {
723
+        				$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
724
+        			} else {
725
+        	    			$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
726
+        	    		}
669 727
         		    }
670 728
         	?>
671 729
             <div class="col-md-6">
@@ -717,8 +775,11 @@  discard block
 block discarded – undo
717 775
         		foreach ($msg as $eachmsg) {
718 776
         		    //$eachmsg = $msg[0];
719 777
         		    $data = $eachmsg['source_data'];
720
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
721
-        		    else $max = 500;
778
+        		    if ($data > 500) {
779
+        		    	$max = (round(($data+100)/100))*100;
780
+        		    } else {
781
+        		    	$max = 500;
782
+        		    }
722 783
         	?>
723 784
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
724 785
         	<script>
Please login to merge, or discard this patch.