Completed
Push — master ( b40ad5...583e49 )
by Yannick
29:34
created
require/class.Common.php 3 patches
Indentation   +161 added lines, -161 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 = '', $sizelimit = false, $async = false) {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
@@ -166,10 +166,10 @@  discard block
 block discarded – undo
166 166
 	}
167 167
 
168 168
 	/**
169
-	* Convert a HTML table to an array
170
-	* @param String $data HTML page
171
-	* @return Array array of the tables in HTML page
172
-	*/
169
+	 * Convert a HTML table to an array
170
+	 * @param String $data HTML page
171
+	 * @return Array array of the tables in HTML page
172
+	 */
173 173
 	public function table2array($data) {
174 174
 		if (!is_string($data)) return array();
175 175
 		if ($data == '') return array();
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
 	}
204 204
 	
205 205
 	/**
206
-	* Convert <p> part of a HTML page to an array
207
-	* @param String $data HTML page
208
-	* @return Array array of the <p> in HTML page
209
-	*/
206
+	 * Convert <p> part of a HTML page to an array
207
+	 * @param String $data HTML page
208
+	 * @return Array array of the <p> in HTML page
209
+	 */
210 210
 	public function text2array($data) {
211 211
 		$html = str_get_html($data);
212 212
 		if ($html === false) return array();
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
 	}
222 222
 
223 223
 	/**
224
-	* Give distance between 2 coordonnates
225
-	* @param Float $lat latitude of first point
226
-	* @param Float $lon longitude of first point
227
-	* @param Float $latc latitude of second point
228
-	* @param Float $lonc longitude of second point
229
-	* @param String $unit km else no unit used
230
-	* @return Float Distance in $unit
231
-	*/
224
+	 * Give distance between 2 coordonnates
225
+	 * @param Float $lat latitude of first point
226
+	 * @param Float $lon longitude of first point
227
+	 * @param Float $latc latitude of second point
228
+	 * @param Float $lonc longitude of second point
229
+	 * @param String $unit km else no unit used
230
+	 * @return Float Distance in $unit
231
+	 */
232 232
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
233 233
 		if ($lat == $latc && $lon == $lonc) return 0;
234 234
 		$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;
@@ -246,25 +246,25 @@  discard block
 block discarded – undo
246 246
 	}
247 247
 
248 248
 	/**
249
-	* Give plunge between 2 altitudes and distance
250
-	* @param Float $initial_altitude altitude of first point in m
251
-	* @param Float $final_altitude altitude of second point in m
252
-	* @param String $distance distance between two points in m
253
-	* @return Float plunge
254
-	*/
249
+	 * Give plunge between 2 altitudes and distance
250
+	 * @param Float $initial_altitude altitude of first point in m
251
+	 * @param Float $final_altitude altitude of second point in m
252
+	 * @param String $distance distance between two points in m
253
+	 * @return Float plunge
254
+	 */
255 255
 	public function plunge($initial_altitude,$final_altitude,$distance) {
256 256
 		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
257 257
 		return $plunge;
258 258
 	}
259 259
 
260 260
 	/**
261
-	* Give azimuth between 2 coordonnates
262
-	* @param Float $lat latitude of first point
263
-	* @param Float $lon longitude of first point
264
-	* @param Float $latc latitude of second point
265
-	* @param Float $lonc longitude of second point
266
-	* @return Float Azimuth
267
-	*/
261
+	 * Give azimuth between 2 coordonnates
262
+	 * @param Float $lat latitude of first point
263
+	 * @param Float $lon longitude of first point
264
+	 * @param Float $latc latitude of second point
265
+	 * @param Float $lonc longitude of second point
266
+	 * @return Float Azimuth
267
+	 */
268 268
 	public function azimuth($lat, $lon, $latc, $lonc) {
269 269
 		$dX = $latc - $lat;
270 270
 		$dY = $lonc - $lon;
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
 	
276 276
 	
277 277
 	/**
278
-	* Check is distance realistic
279
-	* @param int $timeDifference the time between the reception of both messages
280
-	* @param float $distance distance covered
281
-	* @return whether distance is realistic
282
-	*/
278
+	 * Check is distance realistic
279
+	 * @param int $timeDifference the time between the reception of both messages
280
+	 * @param float $distance distance covered
281
+	 * @return whether distance is realistic
282
+	 */
283 283
 	public function withinThreshold ($timeDifference, $distance) {
284 284
 		$x = abs($timeDifference);
285 285
 		$d = abs($distance);
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	}
298 298
 
299 299
 	public function isInteger($input){
300
-	    return(ctype_digit(strval($input)));
300
+		return(ctype_digit(strval($input)));
301 301
 	}
302 302
 
303 303
 
@@ -328,11 +328,11 @@  discard block
 block discarded – undo
328 328
 	}
329 329
 	
330 330
 	/**
331
-	* Copy folder contents
332
-	* @param       string   $source    Source path
333
-	* @param       string   $dest      Destination path
334
-	* @return      bool     Returns true on success, false on failure
335
-	*/
331
+	 * Copy folder contents
332
+	 * @param       string   $source    Source path
333
+	 * @param       string   $dest      Destination path
334
+	 * @return      bool     Returns true on success, false on failure
335
+	 */
336 336
 	public function xcopy($source, $dest)
337 337
 	{
338 338
 		$files = glob($source.'*.*');
@@ -344,20 +344,20 @@  discard block
 block discarded – undo
344 344
 	}
345 345
 	
346 346
 	/**
347
-	* Check if an url exist
348
-	* @param	String $url url to check
349
-	* @return	bool Return true on succes false on failure
350
-	*/
347
+	 * Check if an url exist
348
+	 * @param	String $url url to check
349
+	 * @return	bool Return true on succes false on failure
350
+	 */
351 351
 	public function urlexist($url){
352 352
 		$headers=get_headers($url);
353 353
 		return stripos($headers[0],"200 OK")?true:false;
354 354
 	}
355 355
 	
356 356
 	/**
357
-	* Convert hexa to string
358
-	* @param	String $hex data in hexa
359
-	* @return	String Return result
360
-	*/
357
+	 * Convert hexa to string
358
+	 * @param	String $hex data in hexa
359
+	 * @return	String Return result
360
+	 */
361 361
 	public function hex2str($hex) {
362 362
 		$str = '';
363 363
 		$hexln = strlen($hex);
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
 	}
367 367
 	
368 368
 	/**
369
-	* Convert hexa color to rgb
370
-	* @param	String $hex data in hexa
371
-	* @return	String Return result
372
-	*/
369
+	 * Convert hexa color to rgb
370
+	 * @param	String $hex data in hexa
371
+	 * @return	String Return result
372
+	 */
373 373
 	public function hex2rgb($hex) {
374 374
 		$hex = str_replace('#','',$hex);
375 375
 		return sscanf($hex, "%02x%02x%02x"); 
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
 	}
448 448
 	
449 449
 	/**
450
-	* Returns list of available locales
451
-	*
452
-	* @return array
450
+	 * Returns list of available locales
451
+	 *
452
+	 * @return array
453 453
 	 */
454 454
 	public function listLocaleDir()
455 455
 	{
@@ -548,100 +548,100 @@  discard block
 block discarded – undo
548 548
 	public function remove_accents($string) {
549 549
 		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
550 550
 		$chars = array(
551
-		    // Decompositions for Latin-1 Supplement
552
-		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
553
-		    chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
554
-		    chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
555
-		    chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
556
-		    chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
557
-		    chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
558
-		    chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
559
-		    chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
560
-		    chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
561
-		    chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
562
-		    chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
563
-		    chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
564
-		    chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
565
-		    chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
566
-		    chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
567
-		    chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
568
-		    chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
569
-		    chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
570
-		    chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
571
-		    chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
572
-		    chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
573
-		    chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
574
-		    chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
575
-		    chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
576
-		    chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
577
-		    chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
578
-		    chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
579
-		    chr(195).chr(191) => 'y',
580
-		    // Decompositions for Latin Extended-A
581
-		    chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
582
-		    chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
583
-		    chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
584
-		    chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
585
-		    chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
586
-		    chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
587
-		    chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
588
-		    chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
589
-		    chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
590
-		    chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
591
-		    chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
592
-		    chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
593
-		    chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
594
-		    chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
595
-		    chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
596
-		    chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
597
-		    chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
598
-		    chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
599
-		    chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
600
-		    chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
601
-		    chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
602
-		    chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
603
-		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
604
-		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
605
-		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
606
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
607
-		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
608
-		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
609
-		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
610
-		    chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
611
-		    chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
612
-		    chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
613
-		    chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
614
-		    chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
615
-		    chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
616
-		    chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
617
-		    chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
618
-		    chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
619
-		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
620
-		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
621
-		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
622
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
623
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
624
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
625
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
626
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
627
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
628
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
629
-		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
630
-		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
631
-		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
632
-		    chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
633
-		    chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
634
-		    chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
635
-		    chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
636
-		    chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
637
-		    chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
638
-		    chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
639
-		    chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
640
-		    chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
641
-		    chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
642
-		    chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
643
-		    chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
644
-		    chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
551
+			// Decompositions for Latin-1 Supplement
552
+			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
553
+			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
554
+			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
555
+			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
556
+			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
557
+			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
558
+			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
559
+			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
560
+			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
561
+			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
562
+			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
563
+			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
564
+			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
565
+			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
566
+			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
567
+			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
568
+			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
569
+			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
570
+			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
571
+			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
572
+			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
573
+			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
574
+			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
575
+			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
576
+			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
577
+			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
578
+			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
579
+			chr(195).chr(191) => 'y',
580
+			// Decompositions for Latin Extended-A
581
+			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
582
+			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
583
+			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
584
+			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
585
+			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
586
+			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
587
+			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
588
+			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
589
+			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
590
+			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
591
+			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
592
+			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
593
+			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
594
+			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
595
+			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
596
+			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
597
+			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
598
+			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
599
+			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
600
+			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
601
+			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
602
+			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
603
+			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
604
+			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
605
+			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
606
+			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
607
+			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
608
+			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
609
+			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
610
+			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
611
+			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
612
+			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
613
+			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
614
+			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
615
+			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
616
+			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
617
+			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
618
+			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
619
+			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
620
+			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
621
+			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
622
+			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
623
+			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
624
+			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
625
+			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
626
+			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
627
+			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
628
+			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
629
+			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
630
+			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
631
+			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
632
+			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
633
+			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
634
+			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
635
+			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
636
+			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
637
+			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
638
+			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
639
+			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
640
+			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
641
+			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
642
+			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
643
+			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
644
+			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
645 645
 		);
646 646
 		$string = strtr($string, $chars);
647 647
 		return $string;
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 			$dfX = $first_pass[$j][0];
782 782
 			$dfDiffLong = abs($dfX - $dfPrevX);
783 783
 			if ($dfDiffLong > $dfDiffSpace &&
784
-			    (($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) 
784
+				(($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) 
785 785
 			{
786 786
 				$bHasBigDiff = true;
787 787
 			} else if ($dfDiffLong > $dfMaxSmallDiffLong) {
@@ -800,8 +800,8 @@  discard block
 block discarded – undo
800 800
 					$dfX2 = floatval($first_pass[$k][0]);
801 801
 					$dfY2 = floatval($first_pass[$k][1]);
802 802
 					if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 &&
803
-					    $k+1 < count($first_pass) &&
804
-					    $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
803
+						$k+1 < count($first_pass) &&
804
+						$first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
805 805
 					{
806 806
 						$poNewLS[] = array(-180, $first_pass[$k][1]);
807 807
 						$k++;
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
 						$poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]);
810 810
 						continue;
811 811
 					} else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 &&
812
-					    $k+1 < count($first_pass) &&
813
-					    $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
812
+						$k+1 < count($first_pass) &&
813
+						$first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
814 814
 					{
815 815
 						$poNewLS[] = array(180, $first_pass[$k][1]);
816 816
 						$k++;
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 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 = '', $sizelimit = false, $async = false) {
17
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '', $sizelimit = false, $async = false) {
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
 			}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		if ($sizelimit === true) {
69 69
 			curl_setopt($ch, CURLOPT_BUFFERSIZE, 128);
70 70
 			curl_setopt($ch, CURLOPT_NOPROGRESS, false);
71
-			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr,$downloadsize, $downloaded, $uploadsize, $uploaded){
71
+			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr, $downloadsize, $downloaded, $uploadsize, $uploaded) {
72 72
 				return ($downloaded > (3*1024)) ? 1 : 0;
73 73
 			});
74 74
 		}
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
 		$result = curl_exec($ch);
80 80
 		$info = curl_getinfo($ch);
81 81
 		curl_close($ch);
82
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
82
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
83 83
 			echo "Cloudflare Detected\n";
84 84
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
85 85
 			$useragent = UAgent::random();
86 86
 			cloudflare::useUserAgent($useragent);
87 87
 			if ($clearanceCookie = cloudflare::bypass($url)) {
88
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
88
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
89 89
 			}
90 90
 		} else {
91 91
 			return $result;
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
110 110
 		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
111 111
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
112
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
112
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
113 113
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
114 114
 			}
115 115
 		}
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
 		fclose($fp);
125 125
 	}
126 126
 
127
-	public static function gunzip($in_file,$out_file_name = '') {
127
+	public static function gunzip($in_file, $out_file_name = '') {
128 128
 		//echo $in_file.' -> '.$out_file_name."\n";
129 129
 		$buffer_size = 4096; // read 4kb at a time
130 130
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
131 131
 		if ($in_file != '' && file_exists($in_file)) {
132 132
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
133
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
134
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
133
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
134
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
135 135
 			else {
136 136
 				echo 'gzopen not available';
137 137
 				die;
138 138
 			}
139 139
 			$out_file = fopen($out_file_name, 'wb'); 
140
-			while(!gzeof($file)) {
140
+			while (!gzeof($file)) {
141 141
 				fwrite($out_file, gzread($file, $buffer_size));
142 142
 			}  
143 143
 			fclose($out_file);
@@ -145,19 +145,19 @@  discard block
 block discarded – undo
145 145
 		}
146 146
 	}
147 147
 
148
-	public static function bunzip2($in_file,$out_file_name = '') {
148
+	public static function bunzip2($in_file, $out_file_name = '') {
149 149
 		//echo $in_file.' -> '.$out_file_name."\n";
150 150
 		$buffer_size = 4096; // read 4kb at a time
151 151
 		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
152 152
 		if ($in_file != '' && file_exists($in_file)) {
153 153
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
154
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
154
+			if (function_exists('bzopen')) $file = bzopen($in_file, 'rb');
155 155
 			else {
156 156
 				echo 'bzopen not available';
157 157
 				die;
158 158
 			}
159 159
 			$out_file = fopen($out_file_name, 'wb'); 
160
-			while(!feof($file)) {
160
+			while (!feof($file)) {
161 161
 				fwrite($out_file, bzread($file, $buffer_size));
162 162
 			}  
163 163
 			fclose($out_file);
@@ -175,27 +175,27 @@  discard block
 block discarded – undo
175 175
 		if ($data == '') return array();
176 176
 		$html = str_get_html($data);
177 177
 		if ($html === false) return array();
178
-		$tabledata=array();
179
-		foreach($html->find('tr') as $element)
178
+		$tabledata = array();
179
+		foreach ($html->find('tr') as $element)
180 180
 		{
181 181
 			$td = array();
182
-			foreach( $element->find('th') as $row)
182
+			foreach ($element->find('th') as $row)
183 183
 			{
184 184
 				$td [] = trim($row->plaintext);
185 185
 			}
186
-			$td=array_filter($td);
186
+			$td = array_filter($td);
187 187
 			$tabledata[] = $td;
188 188
 
189 189
 			$td = array();
190 190
 			$tdi = array();
191
-			foreach( $element->find('td') as $row)
191
+			foreach ($element->find('td') as $row)
192 192
 			{
193 193
 				$td [] = trim($row->plaintext);
194 194
 				$tdi [] = trim($row->innertext);
195 195
 			}
196
-			$td=array_filter($td);
197
-			$tdi=array_filter($tdi);
198
-			$tabledata[]=array_merge($td,$tdi);
196
+			$td = array_filter($td);
197
+			$tdi = array_filter($tdi);
198
+			$tabledata[] = array_merge($td, $tdi);
199 199
 		}
200 200
 		$html->clear();
201 201
 		unset($html);
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 	public function text2array($data) {
211 211
 		$html = str_get_html($data);
212 212
 		if ($html === false) return array();
213
-		$tabledata=array();
214
-		foreach($html->find('p') as $element)
213
+		$tabledata = array();
214
+		foreach ($html->find('p') as $element)
215 215
 		{
216 216
 			$tabledata [] = trim($element->plaintext);
217 217
 		}
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 	*/
232 232
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
233 233
 		if ($lat == $latc && $lon == $lonc) return 0;
234
-		$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;
234
+		$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;
235 235
 		if ($unit == "km") {
236
-			return round($dist * 1.609344);
236
+			return round($dist*1.609344);
237 237
 		} elseif ($unit == "m") {
238
-			return round($dist * 1.609344 * 1000);
238
+			return round($dist*1.609344*1000);
239 239
 		} elseif ($unit == "mile" || $unit == "mi") {
240 240
 			return round($dist);
241 241
 		} elseif ($unit == "nm") {
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	* @param String $distance distance between two points in m
253 253
 	* @return Float plunge
254 254
 	*/
255
-	public function plunge($initial_altitude,$final_altitude,$distance) {
256
-		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
255
+	public function plunge($initial_altitude, $final_altitude, $distance) {
256
+		$plunge = rad2deg(asin(($final_altitude - $initial_altitude)/$distance));
257 257
 		return $plunge;
258 258
 	}
259 259
 
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 	public function azimuth($lat, $lon, $latc, $lonc) {
269 269
 		$dX = $latc - $lat;
270 270
 		$dY = $lonc - $lon;
271
-		$azimuth = rad2deg(atan2($dY,$dX));
272
-		if ($azimuth < 0) return $azimuth+360;
271
+		$azimuth = rad2deg(atan2($dY, $dX));
272
+		if ($azimuth < 0) return $azimuth + 360;
273 273
 		return $azimuth;
274 274
 	}
275 275
 	
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	* @param float $distance distance covered
281 281
 	* @return whether distance is realistic
282 282
 	*/
283
-	public function withinThreshold ($timeDifference, $distance) {
283
+	public function withinThreshold($timeDifference, $distance) {
284 284
 		$x = abs($timeDifference);
285 285
 		$d = abs($distance);
286 286
 		if ($x == 0 || $d == 0) return true;
@@ -296,12 +296,12 @@  discard block
 block discarded – undo
296 296
 		return ($array !== array_values($array));
297 297
 	}
298 298
 
299
-	public function isInteger($input){
299
+	public function isInteger($input) {
300 300
 	    return(ctype_digit(strval($input)));
301 301
 	}
302 302
 
303 303
 
304
-	public function convertDec($dms,$latlong) {
304
+	public function convertDec($dms, $latlong) {
305 305
 		if ($latlong == 'latitude') {
306 306
 			$deg = substr($dms, 0, 2);
307 307
 			$min = substr($dms, 2, 4);
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
 			$deg = substr($dms, 0, 3);
310 310
 			$min = substr($dms, 3, 5);
311 311
 		}
312
-		return $deg+(($min*60)/3600);
312
+		return $deg + (($min*60)/3600);
313 313
 	}
314 314
 	
315
-	public function convertDM($coord,$latlong) {
315
+	public function convertDM($coord, $latlong) {
316 316
 		if ($latlong == 'latitude') {
317 317
 			if ($coord < 0) $NSEW = 'S';
318 318
 			else $NSEW = 'N';
@@ -322,9 +322,9 @@  discard block
 block discarded – undo
322 322
 		}
323 323
 		$coord = abs($coord);
324 324
 		$deg = floor($coord);
325
-		$coord = ($coord-$deg)*60;
325
+		$coord = ($coord - $deg)*60;
326 326
 		$min = $coord;
327
-		return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW);
327
+		return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW);
328 328
 	}
329 329
 	
330 330
 	/**
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 	public function xcopy($source, $dest)
337 337
 	{
338 338
 		$files = glob($source.'*.*');
339
-		foreach($files as $file){
340
-			$file_to_go = str_replace($source,$dest,$file);
339
+		foreach ($files as $file) {
340
+			$file_to_go = str_replace($source, $dest, $file);
341 341
 			copy($file, $file_to_go);
342 342
 		}
343 343
 		return true;
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 	* @param	String $url url to check
349 349
 	* @return	bool Return true on succes false on failure
350 350
 	*/
351
-	public function urlexist($url){
352
-		$headers=get_headers($url);
353
-		return stripos($headers[0],"200 OK")?true:false;
351
+	public function urlexist($url) {
352
+		$headers = get_headers($url);
353
+		return stripos($headers[0], "200 OK") ?true:false;
354 354
 	}
355 355
 	
356 356
 	/**
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	public function hex2str($hex) {
362 362
 		$str = '';
363 363
 		$hexln = strlen($hex);
364
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
364
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
365 365
 		return $str;
366 366
 	}
367 367
 	
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	* @return	String Return result
372 372
 	*/
373 373
 	public function hex2rgb($hex) {
374
-		$hex = str_replace('#','',$hex);
374
+		$hex = str_replace('#', '', $hex);
375 375
 		return sscanf($hex, "%02x%02x%02x"); 
376 376
 	}
377 377
 	
@@ -379,33 +379,33 @@  discard block
 block discarded – undo
379 379
 		//difference in longitudinal coordinates
380 380
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
381 381
 		//difference in the phi of latitudinal coordinates
382
-		$dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4));
382
+		$dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4));
383 383
 		//we need to recalculate $dLon if it is greater than pi
384
-		if(abs($dLon) > pi()) {
385
-			if($dLon > 0) {
386
-				$dLon = (2 * pi() - $dLon) * -1;
384
+		if (abs($dLon) > pi()) {
385
+			if ($dLon > 0) {
386
+				$dLon = (2*pi() - $dLon)*-1;
387 387
 			} else {
388
-				$dLon = 2 * pi() + $dLon;
388
+				$dLon = 2*pi() + $dLon;
389 389
 			}
390 390
 		}
391 391
 		//return the angle, normalized
392
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
392
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
393 393
 	}
394 394
 
395
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.15) {
395
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.15) {
396 396
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
397
-		$a = -($lon2-$lon1);
397
+		$a = -($lon2 - $lon1);
398 398
 		$b = $lat2 - $lat1;
399
-		$c = -($a*$lat1+$b*$lon1);
400
-		$d = $a*$lat3+$b*$lon3+$c;
399
+		$c = -($a*$lat1 + $b*$lon1);
400
+		$d = $a*$lat3 + $b*$lon3 + $c;
401 401
 		if ($d > -$approx && $d < $approx) return true;
402 402
 		else return false;
403 403
 	}
404 404
 	
405 405
 	public function array_merge_noappend() {
406 406
 		$output = array();
407
-		foreach(func_get_args() as $array) {
408
-			foreach($array as $key => $value) {
407
+		foreach (func_get_args() as $array) {
408
+			foreach ($array as $key => $value) {
409 409
 				$output[$key] = isset($output[$key]) ?
410 410
 				array_merge($output[$key], $value) : $value;
411 411
 			}
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 		return $result;
470 470
 	}
471 471
 
472
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = ''){
472
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = '') {
473 473
 		global $globalMapRefresh;
474 474
 		if ($seconds == '') {
475 475
 			$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
@@ -480,27 +480,27 @@  discard block
 block discarded – undo
480 480
 		$latitude = deg2rad($latitude);
481 481
 		$longitude = deg2rad($longitude);
482 482
 		$bearing = deg2rad($heading); 
483
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
484
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
485
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
483
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
484
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
485
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
486 486
 	}
487 487
 	
488
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
488
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
489 489
 		// distance in meter
490 490
 		$R = 6378.14;
491
-		$latitude1 = $latitude * (M_PI/180);
492
-		$longitude1 = $longitude * (M_PI/180);
493
-		$brng = $bearing * (M_PI/180);
491
+		$latitude1 = $latitude*(M_PI/180);
492
+		$longitude1 = $longitude*(M_PI/180);
493
+		$brng = $bearing*(M_PI/180);
494 494
 		$d = $distance;
495 495
 
496 496
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
497
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
497
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
498 498
 
499
-		$latitude2 = $latitude2 * (180/M_PI);
500
-		$longitude2 = $longitude2 * (180/M_PI);
499
+		$latitude2 = $latitude2*(180/M_PI);
500
+		$longitude2 = $longitude2*(180/M_PI);
501 501
 
502
-		$flat = round ($latitude2,6);
503
-		$flong = round ($longitude2,6);
502
+		$flat = round($latitude2, 6);
503
+		$flong = round($longitude2, 6);
504 504
 /*
505 505
 		$dx = $distance*cos($bearing);
506 506
 		$dy = $distance*sin($bearing);
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 		$flong = $longitude + $dlong;
510 510
 		$flat = $latitude + $dlat;
511 511
 */
512
-		return array('latitude' => $flat,'longitude' => $flong);
512
+		return array('latitude' => $flat, 'longitude' => $flong);
513 513
 	}
514 514
 
515 515
 	/**
@@ -523,14 +523,14 @@  discard block
 block discarded – undo
523 523
 	 * @param integer $level GZIP compression level (default: 9)
524 524
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
525 525
 	 */
526
-	public function gzCompressFile($source, $level = 9){ 
527
-		$dest = $source . '.gz'; 
528
-		$mode = 'wb' . $level; 
526
+	public function gzCompressFile($source, $level = 9) { 
527
+		$dest = $source.'.gz'; 
528
+		$mode = 'wb'.$level; 
529 529
 		$error = false; 
530 530
 		if ($fp_out = gzopen($dest, $mode)) { 
531
-			if ($fp_in = fopen($source,'rb')) { 
531
+			if ($fp_in = fopen($source, 'rb')) { 
532 532
 				while (!feof($fp_in)) 
533
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
533
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
534 534
 				fclose($fp_in); 
535 535
 			} else {
536 536
 				$error = true; 
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 	} 
547 547
 	
548 548
 	public function remove_accents($string) {
549
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
549
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
550 550
 		$chars = array(
551 551
 		    // Decompositions for Latin-1 Supplement
552 552
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
604 604
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
605 605
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
606
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
606
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
607 607
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
608 608
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
609 609
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -619,13 +619,13 @@  discard block
 block discarded – undo
619 619
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
620 620
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
621 621
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
622
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
623
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
624
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
625
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
626
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
627
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
628
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
622
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
623
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
624
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
625
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
626
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
627
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
628
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
629 629
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
630 630
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
631 631
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
660 660
 			if (is_numeric($string[$i]) && $concat_flag) {
661 661
 				$int .= $string[$i];
662
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
662
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
663 663
 				$concat_flag = false;
664 664
 			}
665 665
 		}
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 			$slice = array_slice($arr, $offset + 1, $length);
706 706
 			return implode("", $slice);
707 707
 		} else {
708
-			return mb_substr($string,$offset,$length,'UTF-8');
708
+			return mb_substr($string, $offset, $length, 'UTF-8');
709 709
 		}
710 710
 	}
711 711
 
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
 		//NOTE: use a trailing slash for folders!!!
716 716
 		//see http://bugs.php.net/bug.php?id=27609
717 717
 		//see http://bugs.php.net/bug.php?id=30931
718
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
718
+		if ($path{strlen($path) - 1} == '/') // recursively return a temporary file path
719 719
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
720 720
 		else if (is_dir($path))
721 721
 			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
722 722
 		// check tmp file for read/write capabilities
723 723
 		$rm = file_exists($path);
724 724
 		$f = @fopen($path, 'a');
725
-		if ($f===false)
725
+		if ($f === false)
726 726
 			return false;
727 727
 		fclose($f);
728 728
 		if (!$rm)
@@ -741,29 +741,29 @@  discard block
 block discarded – undo
741 741
 	 * @param Integer $offset Controls the likelyhood that lines will be split which cross the dateline
742 742
 	 * @return Array Coordinate of the route
743 743
 	*/
744
-	public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) {
745
-		if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
744
+	public function greatcircle($begin_lat, $begin_lon, $end_lat, $end_lon, $nbpts = 20, $offset = 10) {
745
+		if ($nbpts <= 2) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat));
746 746
 		$sx = deg2rad($begin_lon);
747 747
 		$sy = deg2rad($begin_lat);
748 748
 		$ex = deg2rad($end_lon);
749 749
 		$ey = deg2rad($end_lat);
750 750
 		$w = $sx - $ex;
751 751
 		$h = $sy - $ey;
752
-		$z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2);
752
+		$z = pow(sin($h/2.0), 2) + cos($sy)*cos($ey)*pow(sin($w/2.0), 2);
753 753
 		$g = 2.0*asin(sqrt($z));
754
-		if ($g == pi() || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
754
+		if ($g == pi() || is_nan($g)) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat));
755 755
 		$first_pass = array();
756
-		$delta = 1.0/($nbpts-1);
757
-		for ($i =0; $i < $nbpts; ++$i) {
756
+		$delta = 1.0/($nbpts - 1);
757
+		for ($i = 0; $i < $nbpts; ++$i) {
758 758
 			$step = $delta*$i;
759
-			$A = sin((1 - $step) * $g) / sin($g);
760
-			$B = sin($step * $g) / sin($g);
761
-			$x = $A * cos($sy) * cos($sx) + $B * cos($ey) * cos($ex);
762
-			$y = $A * cos($sy) * sin($sx) + $B * cos($ey) * sin($ex);
763
-			$z = $A * sin($sy) + $B * sin($ey);
759
+			$A = sin((1 - $step)*$g)/sin($g);
760
+			$B = sin($step*$g)/sin($g);
761
+			$x = $A*cos($sy)*cos($sx) + $B*cos($ey)*cos($ex);
762
+			$y = $A*cos($sy)*sin($sx) + $B*cos($ey)*sin($ex);
763
+			$z = $A*sin($sy) + $B*sin($ey);
764 764
 			$lat = rad2deg(atan2($z, sqrt(pow($x, 2) + pow($y, 2))));
765 765
 			$lon = rad2deg(atan2($y, $x));
766
-			$first_pass[] = array($lon,$lat);
766
+			$first_pass[] = array($lon, $lat);
767 767
 		}
768 768
 		$bHasBigDiff = false;
769 769
 		$dfMaxSmallDiffLong = 0;
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 		
778 778
 		// https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342
779 779
 		for ($j = 1; $j < count($first_pass); ++$j) {
780
-			$dfPrevX = $first_pass[$j-1][0];
780
+			$dfPrevX = $first_pass[$j - 1][0];
781 781
 			$dfX = $first_pass[$j][0];
782 782
 			$dfDiffLong = abs($dfX - $dfPrevX);
783 783
 			if ($dfDiffLong > $dfDiffSpace &&
@@ -794,14 +794,14 @@  discard block
 block discarded – undo
794 794
 			//$poMulti[] = $poNewLS;
795 795
 			for ($k = 0; $k < count($first_pass); ++$k) {
796 796
 				$dfX0 = floatval($first_pass[$k][0]);
797
-				if ($k > 0 &&  abs($dfX0 - $first_pass[$k-1][0]) > $dfDiffSpace) {
798
-					$dfX1 = floatval($first_pass[$k-1][0]);
799
-					$dfY1 = floatval($first_pass[$k-1][1]);
797
+				if ($k > 0 && abs($dfX0 - $first_pass[$k - 1][0]) > $dfDiffSpace) {
798
+					$dfX1 = floatval($first_pass[$k - 1][0]);
799
+					$dfY1 = floatval($first_pass[$k - 1][1]);
800 800
 					$dfX2 = floatval($first_pass[$k][0]);
801 801
 					$dfY2 = floatval($first_pass[$k][1]);
802 802
 					if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 &&
803
-					    $k+1 < count($first_pass) &&
804
-					    $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
803
+					    $k + 1 < count($first_pass) &&
804
+					    $first_pass[$k - 1][0] > -180 && $first_pass[$k - 1][0] < $dfRightBorderX)
805 805
 					{
806 806
 						$poNewLS[] = array(-180, $first_pass[$k][1]);
807 807
 						$k++;
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
 						$poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]);
810 810
 						continue;
811 811
 					} else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 &&
812
-					    $k+1 < count($first_pass) &&
813
-					    $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
812
+					    $k + 1 < count($first_pass) &&
813
+					    $first_pass[$k - 1][0] > $dfLeftBorderX && $first_pass[$k - 1][0] < 180)
814 814
 					{
815 815
 						$poNewLS[] = array(180, $first_pass[$k][1]);
816 816
 						$k++;
@@ -833,12 +833,12 @@  discard block
 block discarded – undo
833 833
 					}
834 834
 					if ($dfX1 <= 180 && $dfX2 >= 180 && $dfX1 < $dfX2)
835 835
 					{
836
-						$dfRatio = (180 - $dfX1) / ($dfX2 - $dfX1);
837
-						$dfY = $dfRatio * $dfY2 + (1 - $dfRatio) * $dfY1;
838
-						$poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? 180 : -180, $dfY);
836
+						$dfRatio = (180 - $dfX1)/($dfX2 - $dfX1);
837
+						$dfY = $dfRatio*$dfY2 + (1 - $dfRatio)*$dfY1;
838
+						$poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? 180 : -180, $dfY);
839 839
 						$poMulti[] = $poNewLS;
840 840
 						$poNewLS = array();
841
-						$poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? -180 : 180, $dfY);
841
+						$poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? -180 : 180, $dfY);
842 842
 						//$poMulti[] = $poNewLS;
843 843
 					} else {
844 844
 						//$poNewLS[] = array();
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 			$poNewLS0 = array();
857 857
 			//$poMulti[] = $poNewLS0;
858 858
 			for ($l = 0; $l < count($first_pass); ++$l) {
859
-				$poNewLS0[] = array($first_pass[$l][0],$first_pass[$l][1]);
859
+				$poNewLS0[] = array($first_pass[$l][0], $first_pass[$l][1]);
860 860
 			}
861 861
 			$poMulti[] = $poNewLS0;
862 862
 		}
Please login to merge, or discard this patch.
Braces   +110 added lines, -48 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");
@@ -51,7 +54,9 @@  discard block
 block discarded – undo
51 54
 			} else {
52 55
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
53 56
 			}
54
-		} elseif ($type != 'get' && $type != '') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
57
+		} elseif ($type != 'get' && $type != '') {
58
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
59
+		}
55 60
 		if ($headers != '') {
56 61
 			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
57 62
 		}
@@ -95,8 +100,9 @@  discard block
 block discarded – undo
95 100
 	private function curlResponseHeaderCallback($ch, $headerLine) {
96 101
 		//global $cookies;
97 102
 		$cookies = array();
98
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
99
-			$cookies[] = $cookie;
103
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
104
+					$cookies[] = $cookie;
105
+		}
100 106
 		return strlen($headerLine); // Needed by curl
101 107
 	}
102 108
 
@@ -107,7 +113,9 @@  discard block
 block discarded – undo
107 113
 		curl_setopt($ch, CURLOPT_URL, $url);
108 114
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
109 115
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
110
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
116
+		if ($referer != '') {
117
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
118
+		}
111 119
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
112 120
 			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
113 121
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
@@ -119,7 +127,9 @@  discard block
 block discarded – undo
119 127
 		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');
120 128
 		curl_setopt($ch, CURLOPT_FILE, $fp);
121 129
 		curl_exec($ch);
122
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
130
+		if (curl_errno($ch) && $globalDebug) {
131
+			echo 'Download error: '.curl_error($ch);
132
+		}
123 133
 		curl_close($ch);
124 134
 		fclose($fp);
125 135
 	}
@@ -127,12 +137,16 @@  discard block
 block discarded – undo
127 137
 	public static function gunzip($in_file,$out_file_name = '') {
128 138
 		//echo $in_file.' -> '.$out_file_name."\n";
129 139
 		$buffer_size = 4096; // read 4kb at a time
130
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
140
+		if ($out_file_name == '') {
141
+			$out_file_name = str_replace('.gz', '', $in_file);
142
+		}
131 143
 		if ($in_file != '' && file_exists($in_file)) {
132 144
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
133
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
134
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
135
-			else {
145
+			if (function_exists('gzopen')) {
146
+				$file = gzopen($in_file,'rb');
147
+			} elseif (function_exists('gzopen64')) {
148
+				$file = gzopen64($in_file,'rb');
149
+			} else {
136 150
 				echo 'gzopen not available';
137 151
 				die;
138 152
 			}
@@ -148,11 +162,14 @@  discard block
 block discarded – undo
148 162
 	public static function bunzip2($in_file,$out_file_name = '') {
149 163
 		//echo $in_file.' -> '.$out_file_name."\n";
150 164
 		$buffer_size = 4096; // read 4kb at a time
151
-		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
165
+		if ($out_file_name == '') {
166
+			$out_file_name = str_replace('.bz2', '', $in_file);
167
+		}
152 168
 		if ($in_file != '' && file_exists($in_file)) {
153 169
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
154
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
155
-			else {
170
+			if (function_exists('bzopen')) {
171
+				$file = bzopen($in_file,'rb');
172
+			} else {
156 173
 				echo 'bzopen not available';
157 174
 				die;
158 175
 			}
@@ -171,10 +188,16 @@  discard block
 block discarded – undo
171 188
 	* @return Array array of the tables in HTML page
172 189
 	*/
173 190
 	public function table2array($data) {
174
-		if (!is_string($data)) return array();
175
-		if ($data == '') return array();
191
+		if (!is_string($data)) {
192
+			return array();
193
+		}
194
+		if ($data == '') {
195
+			return array();
196
+		}
176 197
 		$html = str_get_html($data);
177
-		if ($html === false) return array();
198
+		if ($html === false) {
199
+			return array();
200
+		}
178 201
 		$tabledata=array();
179 202
 		foreach($html->find('tr') as $element)
180 203
 		{
@@ -209,7 +232,9 @@  discard block
 block discarded – undo
209 232
 	*/
210 233
 	public function text2array($data) {
211 234
 		$html = str_get_html($data);
212
-		if ($html === false) return array();
235
+		if ($html === false) {
236
+			return array();
237
+		}
213 238
 		$tabledata=array();
214 239
 		foreach($html->find('p') as $element)
215 240
 		{
@@ -230,7 +255,9 @@  discard block
 block discarded – undo
230 255
 	* @return Float Distance in $unit
231 256
 	*/
232 257
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
233
-		if ($lat == $latc && $lon == $lonc) return 0;
258
+		if ($lat == $latc && $lon == $lonc) {
259
+			return 0;
260
+		}
234 261
 		$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;
235 262
 		if ($unit == "km") {
236 263
 			return round($dist * 1.609344);
@@ -269,7 +296,9 @@  discard block
 block discarded – undo
269 296
 		$dX = $latc - $lat;
270 297
 		$dY = $lonc - $lon;
271 298
 		$azimuth = rad2deg(atan2($dY,$dX));
272
-		if ($azimuth < 0) return $azimuth+360;
299
+		if ($azimuth < 0) {
300
+			return $azimuth+360;
301
+		}
273 302
 		return $azimuth;
274 303
 	}
275 304
 	
@@ -283,10 +312,16 @@  discard block
 block discarded – undo
283 312
 	public function withinThreshold ($timeDifference, $distance) {
284 313
 		$x = abs($timeDifference);
285 314
 		$d = abs($distance);
286
-		if ($x == 0 || $d == 0) return true;
315
+		if ($x == 0 || $d == 0) {
316
+			return true;
317
+		}
287 318
 		// may be due to Internet jitter; distance is realistic
288
-		if ($x < 0.7 && $d < 2000) return true;
289
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
319
+		if ($x < 0.7 && $d < 2000) {
320
+			return true;
321
+		} else {
322
+			return $d/$x < 1500*0.27778;
323
+		}
324
+		// 1500 km/h max
290 325
 	}
291 326
 
292 327
 
@@ -314,11 +349,17 @@  discard block
 block discarded – undo
314 349
 	
315 350
 	public function convertDM($coord,$latlong) {
316 351
 		if ($latlong == 'latitude') {
317
-			if ($coord < 0) $NSEW = 'S';
318
-			else $NSEW = 'N';
352
+			if ($coord < 0) {
353
+				$NSEW = 'S';
354
+			} else {
355
+				$NSEW = 'N';
356
+			}
319 357
 		} else {
320
-			if ($coord < 0) $NSEW = 'W';
321
-			else $NSEW = 'E';
358
+			if ($coord < 0) {
359
+				$NSEW = 'W';
360
+			} else {
361
+				$NSEW = 'E';
362
+			}
322 363
 		}
323 364
 		$coord = abs($coord);
324 365
 		$deg = floor($coord);
@@ -361,7 +402,9 @@  discard block
 block discarded – undo
361 402
 	public function hex2str($hex) {
362 403
 		$str = '';
363 404
 		$hexln = strlen($hex);
364
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
405
+		for($i=0;$i<$hexln;$i+=2) {
406
+			$str .= chr(hexdec(substr($hex,$i,2)));
407
+		}
365 408
 		return $str;
366 409
 	}
367 410
 	
@@ -398,8 +441,11 @@  discard block
 block discarded – undo
398 441
 		$b = $lat2 - $lat1;
399 442
 		$c = -($a*$lat1+$b*$lon1);
400 443
 		$d = $a*$lat3+$b*$lon3+$c;
401
-		if ($d > -$approx && $d < $approx) return true;
402
-		else return false;
444
+		if ($d > -$approx && $d < $approx) {
445
+			return true;
446
+		} else {
447
+			return false;
448
+		}
403 449
 	}
404 450
 	
405 451
 	public function array_merge_noappend() {
@@ -458,7 +504,9 @@  discard block
 block discarded – undo
458 504
 			return $result;
459 505
 		}
460 506
 		$handle = @opendir('./locale');
461
-		if ($handle === false) return $result;
507
+		if ($handle === false) {
508
+			return $result;
509
+		}
462 510
 		while (false !== ($file = readdir($handle))) {
463 511
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
464 512
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -529,8 +577,9 @@  discard block
 block discarded – undo
529 577
 		$error = false; 
530 578
 		if ($fp_out = gzopen($dest, $mode)) { 
531 579
 			if ($fp_in = fopen($source,'rb')) { 
532
-				while (!feof($fp_in)) 
533
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
580
+				while (!feof($fp_in)) {
581
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
582
+				}
534 583
 				fclose($fp_in); 
535 584
 			} else {
536 585
 				$error = true; 
@@ -539,14 +588,17 @@  discard block
 block discarded – undo
539 588
 		} else {
540 589
 			$error = true; 
541 590
 		}
542
-		if ($error)
543
-			return false; 
544
-		else
545
-			return $dest; 
591
+		if ($error) {
592
+					return false;
593
+		} else {
594
+					return $dest;
595
+		}
546 596
 	} 
547 597
 	
548 598
 	public function remove_accents($string) {
549
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
599
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
600
+			return $string;
601
+		}
550 602
 		$chars = array(
551 603
 		    // Decompositions for Latin-1 Supplement
552 604
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -670,7 +722,9 @@  discard block
 block discarded – undo
670 722
 		$ip = gethostbyname($host);
671 723
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
672 724
 		$r = @socket_connect($s, $ip, $port);
673
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
725
+		if (!socket_set_nonblock($s)) {
726
+			echo "Unable to set nonblock on socket\n";
727
+		}
674 728
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
675 729
 			return $s;
676 730
 		}
@@ -715,18 +769,22 @@  discard block
 block discarded – undo
715 769
 		//NOTE: use a trailing slash for folders!!!
716 770
 		//see http://bugs.php.net/bug.php?id=27609
717 771
 		//see http://bugs.php.net/bug.php?id=30931
718
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
772
+		if ($path{strlen($path)-1}=='/') {
773
+			// recursively return a temporary file path
719 774
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
720
-		else if (is_dir($path))
721
-			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
775
+		} else if (is_dir($path)) {
776
+					return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
777
+		}
722 778
 		// check tmp file for read/write capabilities
723 779
 		$rm = file_exists($path);
724 780
 		$f = @fopen($path, 'a');
725
-		if ($f===false)
726
-			return false;
781
+		if ($f===false) {
782
+					return false;
783
+		}
727 784
 		fclose($f);
728
-		if (!$rm)
729
-			unlink($path);
785
+		if (!$rm) {
786
+					unlink($path);
787
+		}
730 788
 		return true;
731 789
 	}
732 790
 	
@@ -742,7 +800,9 @@  discard block
 block discarded – undo
742 800
 	 * @return Array Coordinate of the route
743 801
 	*/
744 802
 	public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) {
745
-		if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
803
+		if ($nbpts <= 2) {
804
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
805
+		}
746 806
 		$sx = deg2rad($begin_lon);
747 807
 		$sy = deg2rad($begin_lat);
748 808
 		$ex = deg2rad($end_lon);
@@ -751,7 +811,9 @@  discard block
 block discarded – undo
751 811
 		$h = $sy - $ey;
752 812
 		$z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2);
753 813
 		$g = 2.0*asin(sqrt($z));
754
-		if ($g == pi() || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
814
+		if ($g == pi() || is_nan($g)) {
815
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
816
+		}
755 817
 		$first_pass = array();
756 818
 		$delta = 1.0/($nbpts-1);
757 819
 		for ($i =0; $i < $nbpts; ++$i) {
Please login to merge, or discard this patch.
live-geojson.php 3 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -14,23 +14,23 @@  discard block
 block discarded – undo
14 14
 $usecoord = false;
15 15
 if (isset($_GET['test'])) exit();
16 16
 if (isset($_GET['tracker'])) {
17
-    $tracker = true;
17
+	$tracker = true;
18 18
 }
19 19
 if (isset($_GET['marine'])) {
20
-    $marine = true;
20
+	$marine = true;
21 21
 }
22 22
 if ($tracker) {
23
-    require_once('require/class.Tracker.php');
24
-    require_once('require/class.TrackerLive.php');
25
-    require_once('require/class.TrackerArchive.php');
23
+	require_once('require/class.Tracker.php');
24
+	require_once('require/class.TrackerLive.php');
25
+	require_once('require/class.TrackerArchive.php');
26 26
 } elseif ($marine) {
27
-    require_once('require/class.Marine.php');
28
-    require_once('require/class.MarineLive.php');
29
-    require_once('require/class.MarineArchive.php');
27
+	require_once('require/class.Marine.php');
28
+	require_once('require/class.MarineLive.php');
29
+	require_once('require/class.MarineArchive.php');
30 30
 } else {
31
-    require_once('require/class.Spotter.php');
32
-    require_once('require/class.SpotterLive.php');
33
-    require_once('require/class.SpotterArchive.php');
31
+	require_once('require/class.Spotter.php');
32
+	require_once('require/class.SpotterLive.php');
33
+	require_once('require/class.SpotterArchive.php');
34 34
 }
35 35
 
36 36
 $begintime = microtime(true);
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 $Common = new Common();
51 51
 
52 52
 if (isset($_GET['download'])) {
53
-    if ($_GET['download'] == "true")
54
-    {
53
+	if ($_GET['download'] == "true")
54
+	{
55 55
 	header('Content-disposition: attachment; filename="flightairmap.json"');
56
-    }
56
+	}
57 57
 }
58 58
 header('Content-Type: text/javascript');
59 59
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	$usecoord = true;
132 132
 	$coord = explode(',',$_GET['coord']);
133 133
 	if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
134
-	    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
134
+		&& $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
135 135
 		if ($tracker) {
136 136
 			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
137 137
 		} elseif ($marine) {
@@ -635,17 +635,17 @@  discard block
 block discarded – undo
635 635
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
636 636
 				
637 637
 				if (
638
-				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
639
-				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
638
+					(isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
639
+					|| ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
640 640
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
641 641
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
642
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
643
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
644
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
645
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
646
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
647
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
648
-				    ) {
642
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
643
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
644
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
645
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
646
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
647
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
648
+					) {
649 649
 					if ($tracker) {
650 650
 						if ($from_archive || $globalArchive) {
651 651
 							$spotter_history_array = $TrackerArchive->getAllArchiveTrackerDataById($spotter_item['famtrackid']);
@@ -653,9 +653,9 @@  discard block
 block discarded – undo
653 653
 							$spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']);
654 654
 						}
655 655
 						if (((isset($_COOKIE['mapmatching']) && $_COOKIE['mapmatching'] == 'true') ||
656
-						    (!isset($_COOKIE['mapmatching']) && $globalMapMatching === TRUE)) && 
657
-						    isset($_GET['zoom']) && $_GET['zoom'] > 12 && 
658
-						    isset($spotter_item['type']) && (
656
+							(!isset($_COOKIE['mapmatching']) && $globalMapMatching === TRUE)) && 
657
+							isset($_GET['zoom']) && $_GET['zoom'] > 12 && 
658
+							isset($spotter_item['type']) && (
659 659
 							$spotter_item['type'] == 'Firetruck' ||
660 660
 							$spotter_item['type'] == 'Ambulance' ||
661 661
 							$spotter_item['type'] == 'Truck (18 Wheeler)' ||
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 							$spotter_item['type'] == 'Jeep' ||
668 668
 							$spotter_item['type'] == 'Motorcycle' ||
669 669
 							$spotter_item['type'] == 'Car'
670
-						    )
670
+							)
671 671
 						) {
672 672
 							require(dirname(__FILE__).'/require/class.MapMatching.php');
673 673
 							$MapMatching = new MapMatching();
@@ -770,75 +770,75 @@  discard block
 block discarded – undo
770 770
 				}
771 771
 				
772 772
 				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
773
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
774
-				     && (isset($spotter_item['departure_airport']) 
775
-				        && $spotter_item['departure_airport'] != 'NA' 
776
-				        && isset($spotter_item['arrival_airport']) 
777
-				        && $spotter_item['arrival_airport'] != 'NA' 
778
-				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
779
-				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
780
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
781
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
782
-				    if (isset($spotter_item['departure_airport_latitude'])) {
773
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
774
+					 && (isset($spotter_item['departure_airport']) 
775
+						&& $spotter_item['departure_airport'] != 'NA' 
776
+						&& isset($spotter_item['arrival_airport']) 
777
+						&& $spotter_item['arrival_airport'] != 'NA' 
778
+						&& ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
779
+							|| (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
780
+					if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
781
+					else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
782
+					if (isset($spotter_item['departure_airport_latitude'])) {
783 783
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
784
-				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
784
+					} elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
785 785
 					$dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']);
786 786
 					if (isset($dairport[0]['latitude'])) {
787
-					    $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
787
+						$output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
788 788
 					}
789
-				    }
790
-				    if (isset($spotter_item['arrival_airport_latitude'])) {
789
+					}
790
+					if (isset($spotter_item['arrival_airport_latitude'])) {
791 791
 					$output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].'],';
792
-				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
792
+					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
793 793
 					$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
794 794
 					if (isset($aairport[0]['latitude'])) {
795
-					    $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],';
795
+						$output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].'],';
796 796
 					}
797
-				    }
798
-				    $output_air  = substr($output_air, 0, -1);
799
-				    $output_air .= ']}},';
800
-				    $output .= $output_air;
801
-				    unset($output_air);
797
+					}
798
+					$output_air  = substr($output_air, 0, -1);
799
+					$output_air .= ']}},';
800
+					$output .= $output_air;
801
+					unset($output_air);
802 802
 				}
803 803
 
804 804
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
805 805
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
806 806
 				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
807
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
808
-				     && (isset($spotter_item['arrival_airport']) 
809
-				        && $spotter_item['arrival_airport'] != 'NA' 
810
-				        && ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") 
811
-				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
812
-				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
813
-				    $havedata = false;
814
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
815
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
807
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
808
+					 && (isset($spotter_item['arrival_airport']) 
809
+						&& $spotter_item['arrival_airport'] != 'NA' 
810
+						&& ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == "true") 
811
+							|| (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
812
+							|| (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
813
+					$havedata = false;
814
+					if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
815
+					else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
816 816
 				    
817
-				    //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
818
-				    if (isset($spotter_item['arrival_airport_latitude'])) {
817
+					//$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
818
+					if (isset($spotter_item['arrival_airport_latitude'])) {
819 819
 					//$output_dest .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']';
820 820
 					$end_lon = $spotter_item['arrival_airport_longitude'];
821 821
 					$end_lat = $spotter_item['arrival_airport_latitude'];
822 822
 					$havedata = true;
823
-				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
823
+					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
824 824
 					$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
825 825
 					if (isset($aairport[0]['latitude'])) {
826
-					    //$output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
827
-					    $end_lon = $aairport[0]['longitude'];
828
-					    $end_lat = $aairport[0]['latitude'];
829
-					    $havedata = true;
826
+						//$output_dest .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
827
+						$end_lon = $aairport[0]['longitude'];
828
+						$end_lat = $aairport[0]['latitude'];
829
+						$havedata = true;
830 830
 					}
831
-				    }
832
-				    if ($havedata) {
831
+					}
832
+					if ($havedata) {
833 833
 					$line = $Common->greatCircle($spotter_item['latitude'],$spotter_item['longitude'],$end_lat,$end_lon);
834 834
 					foreach ($line[0] as $coord) {
835 835
 						$output_dest .= '['.$coord[0].','.$coord[1].'],';
836 836
 					}
837 837
 					$output_dest  = substr($output_dest, 0, -1);
838
-				    }
839
-				    $output_dest .= ']}},';
840
-				    if ($havedata) $output .= $output_dest;
841
-				    unset($output_dest);
838
+					}
839
+					$output_dest .= ']}},';
840
+					if ($havedata) $output .= $output_dest;
841
+					unset($output_dest);
842 842
 				}
843 843
 			}
844 844
 			$output  = substr($output, 0, -1);
Please login to merge, or discard this patch.
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -64,17 +64,17 @@  discard block
 block discarded – undo
64 64
 $min = true;
65 65
 $allhistory = false;
66 66
 $filter['source'] = array();
67
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
70
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
72
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
73
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
67
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
68
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
69
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
70
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
71
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
72
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
73
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'], FILTER_SANITIZE_STRING);
74
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
75
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
76
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
77
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
78 78
 
79 79
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
80 80
 	$min = true;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 $spotter_array = array();
84 84
 
85 85
 if (isset($_GET['ident'])) {
86
-	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
86
+	$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
87 87
 	if ($tracker) {
88 88
 		$spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident);
89 89
 	} elseif ($marine) {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	}
98 98
 	$allhistory = true;
99 99
 } elseif (isset($_GET['flightaware_id'])) {
100
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
100
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
101 101
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
102 102
 	if (empty($spotter_array)) {
103 103
 		$from_archive = true;
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 	$allhistory = true;
107 107
 } elseif (isset($_GET['famtrack_id'])) {
108
-	$famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING));
108
+	$famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING));
109 109
 	$spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id);
110 110
 	$allhistory = true;
111 111
 } elseif (isset($_GET['fammarine_id'])) {
112
-	$fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING));
112
+	$fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING));
113 113
 	$spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id);
114 114
 	$allhistory = true;
115 115
 /*
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
 */
130 130
 } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) {
131 131
 	$usecoord = true;
132
-	$coord = explode(',',$_GET['coord']);
133
-	if (filter_var($coord[0],FILTER_VALIDATE_FLOAT) && filter_var($coord[1],FILTER_VALIDATE_FLOAT) && filter_var($coord[2],FILTER_VALIDATE_FLOAT) && filter_var($coord[3],FILTER_VALIDATE_FLOAT) 
132
+	$coord = explode(',', $_GET['coord']);
133
+	if (filter_var($coord[0], FILTER_VALIDATE_FLOAT) && filter_var($coord[1], FILTER_VALIDATE_FLOAT) && filter_var($coord[2], FILTER_VALIDATE_FLOAT) && filter_var($coord[3], FILTER_VALIDATE_FLOAT) 
134 134
 	    && $coord[0] > -180.0 && $coord[0] < 180.0 && $coord[1] > -90.0 && $coord[1] < 90.0 && $coord[2] > -180.0 && $coord[2] < 180.0 && $coord[3] > -90.0 && $coord[3] < 90.0) {
135 135
 		if ($tracker) {
136
-			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
136
+			$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter);
137 137
 		} elseif ($marine) {
138
-			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter);
138
+			$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter);
139 139
 		} else {
140
-			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter);
140
+			$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter);
141 141
 		}
142 142
 	} else {
143 143
 		if ($tracker) {
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 	$from_archive = true;
153 153
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
154 154
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
155
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
156
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
157
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
158
-	$begindate = date('Y-m-d H:i:s',$begindate);
159
-	$enddate = date('Y-m-d H:i:s',$enddate);
160
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
155
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
156
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
157
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
158
+	$begindate = date('Y-m-d H:i:s', $begindate);
159
+	$enddate = date('Y-m-d H:i:s', $enddate);
160
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
161 161
 } elseif ($min) {
162 162
 	if ($tracker) {
163 163
 		$spotter_array = $TrackerLive->getMinLiveTrackerData($filter);
@@ -169,17 +169,17 @@  discard block
 block discarded – undo
169 169
 #	$min = true;
170 170
 } else {
171 171
 	if ($tracker) {
172
-		$spotter_array = $TrackerLive->getLiveTrackerData('','',$filter);
172
+		$spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter);
173 173
 	} elseif ($marine) {
174
-		$spotter_array = $marineLive->getLiveMarineData('','',$filter);
174
+		$spotter_array = $marineLive->getLiveMarineData('', '', $filter);
175 175
 	} else {
176
-		$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
176
+		$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
177 177
 	}
178 178
 }
179 179
 
180 180
 if ($usecoord) {
181 181
 	if (isset($_GET['archive'])) {
182
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
182
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
183 183
 	} else {
184 184
 		if ($tracker) {
185 185
 			$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 	if ($flightcnt == '') $flightcnt = 0;
193 193
 } else $flightcnt = 0;
194 194
 
195
-$sqltime = round(microtime(true)-$begintime,2);
195
+$sqltime = round(microtime(true) - $begintime, 2);
196 196
 
197
-$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
197
+$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
198 198
 if ($currenttime != '') $currenttime = round($currenttime/1000);
199 199
 
200 200
 if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 		if (!empty($spotter_array) && is_array($spotter_array))
214 214
 		{
215 215
 			$output .= '"features": [';
216
-			foreach($spotter_array as $spotter_item)
216
+			foreach ($spotter_array as $spotter_item)
217 217
 			{
218 218
 				$j++;
219 219
 				unset($idistance);
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 */
271 271
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
272 272
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
273
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
274
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
273
+							if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",';
274
+							else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",';
275 275
 							//"
276 276
 						} else {
277 277
 							if ($compress) $output .= '"c": "NA",';
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
281 281
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
282 282
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
283
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
283
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
284 284
 						} elseif (isset($spotter_item['aircraft_type'])) {
285 285
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
286 286
 						} elseif (!$min) {
@@ -423,15 +423,15 @@  discard block
 block discarded – undo
423 423
 						if (isset($archivespeed) || $usenextlatlon) {
424 424
 							if (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
425 425
 								if (isset($spotter_item['arrival_airport_latitude'])) {
426
-									$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
427
-									$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['arrival_airport_latitude'],$spotter_item['arrival_airport_longitude']);
426
+									$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
427
+									$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['arrival_airport_latitude'], $spotter_item['arrival_airport_longitude']);
428 428
 									$farr_lat = $spotter_item['arrival_airport_latitude'];
429 429
 									$farr_lon = $spotter_item['arrival_airport_longitude'];
430 430
 								} else {
431 431
 									$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
432 432
 									if (isset($aairport[0]['latitude'])) {
433
-										$cheading = $Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
434
-										$idistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$aairport[0]['latitude'],$aairport[0]['longitude']);
433
+										$cheading = $Common->getHeading($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
434
+										$idistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $aairport[0]['latitude'], $aairport[0]['longitude']);
435 435
 										$farr_lat = $aairport[0]['latitude'];
436 436
 										$farr_lon = $aairport[0]['longitude'];
437 437
 									}
@@ -444,59 +444,59 @@  discard block
 block discarded – undo
444 444
 						if ($currenttime != '') {
445 445
 							if (strtotime($spotter_item['date']) < $currenttime) {
446 446
 								if (isset($archivespeed)) {
447
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
448
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
447
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
448
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
449 449
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
450 450
 									else {
451
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
452
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
451
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
452
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
453 453
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
454 454
 										else {
455
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
455
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
456 456
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
457 457
 										}
458 458
 									}
459 459
 								} elseif ($usenextlatlon) {
460
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
461
-									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
460
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
461
+									$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
462 462
 									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
463 463
 									else {
464
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
465
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
464
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, 1, ($currenttime - strtotime($spotter_item['date']) + $globalMapRefresh));
465
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
466 466
 										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
467 467
 										else {
468
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
468
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
469 469
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
470 470
 										}
471 471
 									}
472 472
 								}
473 473
 							} else {
474 474
 								if (isset($archivespeed)) {
475
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
475
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
476 476
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
477 477
 								} elseif ($usenextlatlon) {
478
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
478
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
479 479
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
480 480
 								}
481 481
 							}
482 482
 						} else {
483 483
 							if (isset($archivespeed)) {
484
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
485
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
484
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed);
485
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
486 486
 								if (!isset($idistance) || $fdistance < $idistance) {
487 487
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
488 488
 								} else {
489
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed);
489
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed);
490 490
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
491 491
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
492 492
 								}
493 493
 							} elseif ($usenextlatlon) {
494
-								$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
495
-								$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
494
+								$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading);
495
+								$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
496 496
 								if (!isset($idistance) || $fdistance < $idistance) {
497 497
 										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
498 498
 								} else {
499
-									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading);
499
+									$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading);
500 500
 									//$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
501 501
 									$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
502 502
 								}
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 
506 506
 						if (!$min) $output .= '"image": "'.$image.'",';
507 507
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
508
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
508
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
509 509
 						}
510 510
 						if (isset($spotter_item['image_source_website'])) {
511 511
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
528 528
 						}
529 529
 						if (isset($spotter_item['acars'])) {
530
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
530
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
531 531
 						}
532 532
 						// type when not aircraft ?
533 533
 						if (isset($spotter_item['type'])) {
@@ -547,12 +547,12 @@  discard block
 block discarded – undo
547 547
 								if ($currenttime != '') {
548 548
 									if (strtotime($spotter_item['date']) < $currenttime) {
549 549
 										if (!isset($archivespeed)) $archivespeed = 1;
550
-										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
551
-										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
550
+										$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $heading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
551
+										$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
552 552
 										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
553 553
 										else {
554
-											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
555
-											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
554
+											$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $cheading, $archivespeed, ($currenttime - strtotime($spotter_item['date'])));
555
+											$fdistance = $Common->distance($spotter_item['latitude'], $spotter_item['longitude'], $nextcoord['latitude'], $nextcoord['longitude']);
556 556
 											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
557 557
 											else {
558 558
 												$output .= $spotter_item['longitude'].', ';
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
                 
632 632
 			}
633 633
 */
634
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
634
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
635 635
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
636 636
 				
637 637
 				if (
@@ -639,11 +639,11 @@  discard block
 block discarded – undo
639 639
 				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
640 640
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
641 641
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
642
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
642
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
643 643
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
644
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
644
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id']))
645 645
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
646
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
646
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid']))
647 647
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
648 648
 				    ) {
649 649
 					if ($tracker) {
@@ -672,9 +672,9 @@  discard block
 block discarded – undo
672 672
 							require(dirname(__FILE__).'/require/class.MapMatching.php');
673 673
 							$MapMatching = new MapMatching();
674 674
 							if (isset($spotter_item['date_iso_8601'])) {
675
-								$spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date_iso_8601'])))));
675
+								$spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date_iso_8601'])))));
676 676
 							} else {
677
-								$spotter_history_array_mm = array_merge($spotter_history_array,array(array('latitude' => $spotter_item['latitude'],'longitude' => $spotter_item['longitude'],'date' => date('c',strtotime($spotter_item['date'])))));
677
+								$spotter_history_array_mm = array_merge($spotter_history_array, array(array('latitude' => $spotter_item['latitude'], 'longitude' => $spotter_item['longitude'], 'date' => date('c', strtotime($spotter_item['date'])))));
678 678
 							}
679 679
 							$spotter_history_array = $MapMatching->match($spotter_history_array_mm);
680 680
 						}
@@ -706,9 +706,9 @@  discard block
 block discarded – undo
706 706
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
707 707
 							}
708 708
 							$output_history .= '[';
709
-							$output_history .=  $spotter_history['longitude'].', ';
710
-							$output_history .=  $spotter_history['latitude'].', ';
711
-							$output_history .=  $spotter_history['altitude']*30.48;
709
+							$output_history .= $spotter_history['longitude'].', ';
710
+							$output_history .= $spotter_history['latitude'].', ';
711
+							$output_history .= $spotter_history['altitude']*30.48;
712 712
 							$output_history .= '],';
713 713
 							/*
714 714
 							if ($from_archive === false) {
@@ -731,8 +731,8 @@  discard block
 block discarded – undo
731 731
 								$d = true;
732 732
 							}
733 733
 							$output_history .= '[';
734
-							$output_history .=  $spotter_history['longitude'].', ';
735
-							$output_history .=  $spotter_history['latitude'];
734
+							$output_history .= $spotter_history['longitude'].', ';
735
+							$output_history .= $spotter_history['latitude'];
736 736
 							$output_history .= '],';
737 737
 							/*
738 738
 							if ($from_archive === false) {
@@ -748,9 +748,9 @@  discard block
 block discarded – undo
748 748
 						//echo $output_history;
749 749
 						if ($from_archive === false && !isset($spotter_history_array[0]['mapmatching_engine'])) {
750 750
 							$output_historyd = '[';
751
-							$output_historyd .=  $spotter_item['longitude'].', ';
752
-							$output_historyd .=  $spotter_item['latitude'];
753
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
751
+							$output_historyd .= $spotter_item['longitude'].', ';
752
+							$output_historyd .= $spotter_item['latitude'];
753
+							if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48;
754 754
 							$output_historyd .= '],';
755 755
 							//$output_history = $output_historyd.$output_history;
756 756
 							$output_history = $output_history.$output_historyd;
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 							$last = array_pop($spotter_history_array);
759 759
 							$latitude = $last['latitude'];
760 760
 							$longitude = $last['longitude'];
761
-							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}','"coordinates": ['.$longitude.', '.$latitude.']}',$output);
761
+							$output = str_replace('"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']}', '"coordinates": ['.$longitude.', '.$latitude.']}', $output);
762 762
 						}
763 763
 						
764 764
 						$output_history  = substr($output_history, 0, -1);
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 					}
770 770
 				}
771 771
 				
772
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
772
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
773 773
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
774 774
 				     && (isset($spotter_item['departure_airport']) 
775 775
 				        && $spotter_item['departure_airport'] != 'NA' 
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 
804 804
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
805 805
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
806
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
806
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
807 807
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
808 808
 				     && (isset($spotter_item['arrival_airport']) 
809 809
 				        && $spotter_item['arrival_airport'] != 'NA' 
@@ -830,11 +830,11 @@  discard block
 block discarded – undo
830 830
 					}
831 831
 				    }
832 832
 				    if ($havedata) {
833
-					$line = $Common->greatCircle($spotter_item['latitude'],$spotter_item['longitude'],$end_lat,$end_lon);
833
+					$line = $Common->greatCircle($spotter_item['latitude'], $spotter_item['longitude'], $end_lat, $end_lon);
834 834
 					foreach ($line[0] as $coord) {
835 835
 						$output_dest .= '['.$coord[0].','.$coord[1].'],';
836 836
 					}
837
-					$output_dest  = substr($output_dest, 0, -1);
837
+					$output_dest = substr($output_dest, 0, -1);
838 838
 				    }
839 839
 				    $output_dest .= ']}},';
840 840
 				    if ($havedata) $output .= $output_dest;
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
 			$output  = substr($output, 0, -1);
845 845
 			$output .= ']';
846 846
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
847
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
847
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
848 848
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
849 849
 			$output .= '"fc": "'.$j.'"';
850 850
 		} else {
Please login to merge, or discard this patch.
Braces   +321 added lines, -130 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 $tracker = false;
13 13
 $marine = false;
14 14
 $usecoord = false;
15
-if (isset($_GET['test'])) exit();
15
+if (isset($_GET['test'])) {
16
+	exit();
17
+}
16 18
 if (isset($_GET['tracker'])) {
17 19
     $tracker = true;
18 20
 }
@@ -57,28 +59,55 @@  discard block
 block discarded – undo
57 59
 }
58 60
 header('Content-Type: text/javascript');
59 61
 
60
-if (!isset($globalJsonCompress)) $compress = true;
61
-else $compress = $globalJsonCompress;
62
+if (!isset($globalJsonCompress)) {
63
+	$compress = true;
64
+} else {
65
+	$compress = $globalJsonCompress;
66
+}
62 67
 
63 68
 $from_archive = false;
64 69
 $min = true;
65 70
 $allhistory = false;
66 71
 $filter['source'] = array();
67
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
70
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
72
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
73
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
72
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
73
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
74
+}
75
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
76
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
77
+}
78
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
79
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
80
+}
81
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
82
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
83
+}
84
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
85
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
86
+}
87
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
88
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
89
+}
90
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') {
91
+	$filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
92
+}
93
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
94
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
95
+}
96
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
97
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
98
+}
99
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
100
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
101
+}
102
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
103
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
104
+}
78 105
 
79 106
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
80 107
 	$min = true;
81
-} else $min = false;
108
+} else {
109
+	$min = false;
110
+}
82 111
 
83 112
 $spotter_array = array();
84 113
 
@@ -189,24 +218,38 @@  discard block
 block discarded – undo
189 218
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
190 219
 		}
191 220
 	}
192
-	if ($flightcnt == '') $flightcnt = 0;
193
-} else $flightcnt = 0;
221
+	if ($flightcnt == '') {
222
+		$flightcnt = 0;
223
+	}
224
+	} else {
225
+	$flightcnt = 0;
226
+}
194 227
 
195 228
 $sqltime = round(microtime(true)-$begintime,2);
196 229
 
197 230
 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
198
-if ($currenttime != '') $currenttime = round($currenttime/1000);
231
+if ($currenttime != '') {
232
+	$currenttime = round($currenttime/1000);
233
+}
199 234
 
200
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
201
-else $usenextlatlon = true;
202
-if ($usenextlatlon === false) $currenttime = '';
235
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
236
+	$usenextlatlon = false;
237
+} else {
238
+	$usenextlatlon = true;
239
+}
240
+if ($usenextlatlon === false) {
241
+	$currenttime = '';
242
+}
203 243
 $j = 0;
204 244
 $prev_flightaware_id = '';
205 245
 $aircrafts_shadow = array();
206 246
 $output = '{';
207 247
 	$output .= '"type": "FeatureCollection",';
208
-		if ($min) $output .= '"minimal": "true",';
209
-		else $output .= '"minimal": "false",';
248
+		if ($min) {
249
+			$output .= '"minimal": "true",';
250
+		} else {
251
+			$output .= '"minimal": "false",';
252
+		}
210 253
 		//$output .= '"fc": "'.$flightcnt.'",';
211 254
 		$output .= '"sqt": "'.$sqltime.'",';
212 255
 
@@ -251,18 +294,29 @@  discard block
 block discarded – undo
251 294
 						}
252 295
 						$output .= '"properties": {';
253 296
 						if (isset($spotter_item['flightaware_id'])) {
254
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
255
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
297
+							if ($compress) {
298
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
299
+							} else {
300
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
301
+							}
256 302
 						} elseif (isset($spotter_item['famtrackid'])) {
257
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
258
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
303
+							if ($compress) {
304
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
305
+							} else {
306
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
307
+							}
259 308
 						} elseif (isset($spotter_item['fammarine_id'])) {
260
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
261
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
309
+							if ($compress) {
310
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
311
+							} else {
312
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
313
+							}
262 314
 						}
263 315
 							$output .= '"fc": "'.$flightcnt.'",';
264 316
 							$output .= '"sqt": "'.$sqltime.'",';
265
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
317
+							if (isset($begindate)) {
318
+								$output .= '"archive_date": "'.$begindate.'",';
319
+							}
266 320
 
267 321
 /*
268 322
 							if ($min) $output .= '"minimal": "true",';
@@ -270,14 +324,22 @@  discard block
 block discarded – undo
270 324
 */
271 325
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
272 326
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
273
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
274
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
327
+							if ($compress) {
328
+								$output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
329
+							} else {
330
+								$output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
331
+							}
275 332
 							//"
276 333
 						} else {
277
-							if ($compress) $output .= '"c": "NA",';
278
-							else $output .= '"callsign": "NA",';
334
+							if ($compress) {
335
+								$output .= '"c": "NA",';
336
+							} else {
337
+								$output .= '"callsign": "NA",';
338
+							}
339
+						}
340
+						if (isset($spotter_item['registration'])) {
341
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
279 342
 						}
280
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
281 343
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
282 344
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
283 345
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -290,16 +352,23 @@  discard block
 block discarded – undo
290 352
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
291 353
 						}
292 354
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) {
293
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
294
-							else {
355
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
356
+								$spotter_item['aircraft_shadow'] = '';
357
+							} else {
295 358
 								$aircraft_icao = $spotter_item['aircraft_icao'];
296
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
297
-								else {
359
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
360
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
361
+								} else {
298 362
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
299
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
300
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
301
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
302
-									else $spotter_item['aircraft_shadow'] = '';
363
+									if (count($aircraft_info) > 0) {
364
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
365
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
366
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
367
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
368
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
369
+									} else {
370
+										$spotter_item['aircraft_shadow'] = '';
371
+									}
303 372
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
304 373
 								}
305 374
 							}
@@ -307,73 +376,139 @@  discard block
 block discarded – undo
307 376
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
308 377
 							if ($tracker) {
309 378
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
310
-									if ($compress) $output .= '"as": "ambulance.png",';
311
-									else $output .= '"aircraft_shadow": "ambulance.png",';
379
+									if ($compress) {
380
+										$output .= '"as": "ambulance.png",';
381
+									} else {
382
+										$output .= '"aircraft_shadow": "ambulance.png",';
383
+									}
312 384
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
313
-									if ($compress) $output .= '"as": "police.png",';
314
-									else $output .= '"aircraft_shadow": "police.png",';
385
+									if ($compress) {
386
+										$output .= '"as": "police.png",';
387
+									} else {
388
+										$output .= '"aircraft_shadow": "police.png",';
389
+									}
315 390
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
316
-									if ($compress) $output .= '"as": "ship.png",';
317
-									else $output .= '"aircraft_shadow": "ship.png",';
391
+									if ($compress) {
392
+										$output .= '"as": "ship.png",';
393
+									} else {
394
+										$output .= '"aircraft_shadow": "ship.png",';
395
+									}
318 396
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
319
-									if ($compress) $output .= '"as": "ship.png",';
320
-									else $output .= '"aircraft_shadow": "ship.png",';
397
+									if ($compress) {
398
+										$output .= '"as": "ship.png",';
399
+									} else {
400
+										$output .= '"aircraft_shadow": "ship.png",';
401
+									}
321 402
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
322
-									if ($compress) $output .= '"as": "ship.png",';
323
-									else $output .= '"aircraft_shadow": "ship.png",';
403
+									if ($compress) {
404
+										$output .= '"as": "ship.png",';
405
+									} else {
406
+										$output .= '"aircraft_shadow": "ship.png",';
407
+									}
324 408
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
325
-									if ($compress) $output .= '"as": "truck.png",';
326
-									else $output .= '"aircraft_shadow": "truck.png",';
409
+									if ($compress) {
410
+										$output .= '"as": "truck.png",';
411
+									} else {
412
+										$output .= '"aircraft_shadow": "truck.png",';
413
+									}
327 414
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
328
-									if ($compress) $output .= '"as": "truck.png",';
329
-									else $output .= '"aircraft_shadow": "truck.png",';
415
+									if ($compress) {
416
+										$output .= '"as": "truck.png",';
417
+									} else {
418
+										$output .= '"aircraft_shadow": "truck.png",';
419
+									}
330 420
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
331
-									if ($compress) $output .= '"as": "aircraft.png",';
332
-									else $output .= '"aircraft_shadow": "aircraft.png",';
421
+									if ($compress) {
422
+										$output .= '"as": "aircraft.png",';
423
+									} else {
424
+										$output .= '"aircraft_shadow": "aircraft.png",';
425
+									}
333 426
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
334
-									if ($compress) $output .= '"as": "aircraft.png",';
335
-									else $output .= '"aircraft_shadow": "aircraft.png",';
427
+									if ($compress) {
428
+										$output .= '"as": "aircraft.png",';
429
+									} else {
430
+										$output .= '"aircraft_shadow": "aircraft.png",';
431
+									}
336 432
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
337
-									if ($compress) $output .= '"as": "helico.png",';
338
-									else $output .= '"aircraft_shadow": "helico.png",';
433
+									if ($compress) {
434
+										$output .= '"as": "helico.png",';
435
+									} else {
436
+										$output .= '"aircraft_shadow": "helico.png",';
437
+									}
339 438
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
340
-									if ($compress) $output .= '"as": "rail.png",';
341
-									else $output .= '"aircraft_shadow": "rail.png",';
439
+									if ($compress) {
440
+										$output .= '"as": "rail.png",';
441
+									} else {
442
+										$output .= '"aircraft_shadow": "rail.png",';
443
+									}
342 444
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
343
-									if ($compress) $output .= '"as": "firetruck.png",';
344
-									else $output .= '"aircraft_shadow": "firetruck.png",';
445
+									if ($compress) {
446
+										$output .= '"as": "firetruck.png",';
447
+									} else {
448
+										$output .= '"aircraft_shadow": "firetruck.png",';
449
+									}
345 450
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
346
-									if ($compress) $output .= '"as": "bus.png",';
347
-									else $output .= '"aircraft_shadow": "bus.png",';
451
+									if ($compress) {
452
+										$output .= '"as": "bus.png",';
453
+									} else {
454
+										$output .= '"aircraft_shadow": "bus.png",';
455
+									}
348 456
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
349
-									if ($compress) $output .= '"as": "phone.png",';
350
-									else $output .= '"aircraft_shadow": "phone.png",';
457
+									if ($compress) {
458
+										$output .= '"as": "phone.png",';
459
+									} else {
460
+										$output .= '"aircraft_shadow": "phone.png",';
461
+									}
351 462
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
352
-									if ($compress) $output .= '"as": "jogger.png",';
353
-									else $output .= '"aircraft_shadow": "jogger.png",';
463
+									if ($compress) {
464
+										$output .= '"as": "jogger.png",';
465
+									} else {
466
+										$output .= '"aircraft_shadow": "jogger.png",';
467
+									}
354 468
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
355
-									if ($compress) $output .= '"as": "bike.png",';
356
-									else $output .= '"aircraft_shadow": "bike.png",';
469
+									if ($compress) {
470
+										$output .= '"as": "bike.png",';
471
+									} else {
472
+										$output .= '"aircraft_shadow": "bike.png",';
473
+									}
357 474
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
358
-									if ($compress) $output .= '"as": "motorcycle.png",';
359
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
475
+									if ($compress) {
476
+										$output .= '"as": "motorcycle.png",';
477
+									} else {
478
+										$output .= '"aircraft_shadow": "motorcycle.png",';
479
+									}
360 480
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
361
-									if ($compress) $output .= '"as": "balloon.png",';
362
-									else $output .= '"aircraft_shadow": "balloon.png",';
481
+									if ($compress) {
482
+										$output .= '"as": "balloon.png",';
483
+									} else {
484
+										$output .= '"aircraft_shadow": "balloon.png",';
485
+									}
363 486
 								} else {
364
-									if ($compress) $output .= '"as": "car.png",';
365
-									else $output .= '"aircraft_shadow": "car.png",';
487
+									if ($compress) {
488
+										$output .= '"as": "car.png",';
489
+									} else {
490
+										$output .= '"aircraft_shadow": "car.png",';
491
+									}
366 492
 								}
367 493
 							} elseif ($marine) {
368
-								if ($compress) $output .= '"as": "ship.png",';
369
-								else $output .= '"aircraft_shadow": "ship.png",';
494
+								if ($compress) {
495
+									$output .= '"as": "ship.png",';
496
+								} else {
497
+									$output .= '"aircraft_shadow": "ship.png",';
498
+								}
370 499
 							} else {
371
-								if ($compress) $output .= '"as": "default.png",';
372
-								else $output .= '"aircraft_shadow": "default.png",';
500
+								if ($compress) {
501
+									$output .= '"as": "default.png",';
502
+								} else {
503
+									$output .= '"aircraft_shadow": "default.png",';
504
+								}
373 505
 							}
374 506
 						} else {
375
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
376
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
507
+							if ($compress) {
508
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
509
+							} else {
510
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
511
+							}
377 512
 						}
378 513
 						if (isset($spotter_item['airline_name'])) {
379 514
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -381,8 +516,11 @@  discard block
 block discarded – undo
381 516
 							$output .= '"airline_name": "NA",';
382 517
 						}
383 518
 						if (isset($spotter_item['departure_airport'])) {
384
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
385
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
519
+							if ($compress) {
520
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
521
+							} else {
522
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
523
+							}
386 524
 						}
387 525
 						if (isset($spotter_item['departure_airport_city'])) {
388 526
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -394,8 +532,11 @@  discard block
 block discarded – undo
394 532
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
395 533
 						}
396 534
 						if (isset($spotter_item['arrival_airport'])) {
397
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
398
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
535
+							if ($compress) {
536
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
537
+							} else {
538
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
539
+							}
399 540
 						}
400 541
 						if (isset($spotter_item['arrival_airport_city'])) {
401 542
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -414,8 +555,11 @@  discard block
 block discarded – undo
414 555
 						}
415 556
 						
416 557
 						if (isset($spotter_item['altitude'])) {
417
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
418
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
558
+							if ($compress) {
559
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
560
+							} else {
561
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
562
+							}
419 563
 						}
420 564
 						
421 565
 						$heading = $spotter_item['heading'];
@@ -439,19 +583,24 @@  discard block
 block discarded – undo
439 583
 							}
440 584
 						}
441 585
 						
442
-						if ($compress)$output .= '"h": "'.$heading.'",';
443
-						else $output .= '"heading": "'.$heading.'",';
586
+						if ($compress) {
587
+							$output .= '"h": "'.$heading.'",';
588
+						} else {
589
+							$output .= '"heading": "'.$heading.'",';
590
+						}
444 591
 						if ($currenttime != '') {
445 592
 							if (strtotime($spotter_item['date']) < $currenttime) {
446 593
 								if (isset($archivespeed)) {
447 594
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
448 595
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
449
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
450
-									else {
596
+									if (!isset($idistance) || $fdistance < $idistance) {
597
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
598
+									} else {
451 599
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
452 600
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
453
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
454
-										else {
601
+										if (!isset($idistance) || $fdistance < $idistance) {
602
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
603
+										} else {
455 604
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
456 605
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
457 606
 										}
@@ -459,12 +608,14 @@  discard block
 block discarded – undo
459 608
 								} elseif ($usenextlatlon) {
460 609
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
461 610
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
462
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
463
-									else {
611
+									if (!isset($idistance) || $fdistance < $idistance) {
612
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
613
+									} else {
464 614
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
465 615
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
466
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
467
-										else {
616
+										if (!isset($idistance) || $fdistance < $idistance) {
617
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
618
+										} else {
468 619
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
469 620
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
470 621
 										}
@@ -503,7 +654,9 @@  discard block
 block discarded – undo
503 654
 							}
504 655
 						}
505 656
 
506
-						if (!$min) $output .= '"image": "'.$image.'",';
657
+						if (!$min) {
658
+							$output .= '"image": "'.$image.'",';
659
+						}
507 660
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
508 661
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
509 662
 						}
@@ -511,8 +664,11 @@  discard block
 block discarded – undo
511 664
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
512 665
 						}
513 666
 						if (isset($spotter_item['squawk'])) {
514
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
515
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
667
+							if ($compress) {
668
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
669
+							} else {
670
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
671
+							}
516 672
 						}
517 673
 						if (isset($spotter_item['squawk_usage'])) {
518 674
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -531,14 +687,23 @@  discard block
 block discarded – undo
531 687
 						}
532 688
 						// type when not aircraft ?
533 689
 						if (isset($spotter_item['type'])) {
534
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
535
-							else $output .= '"type": "'.$spotter_item['type'].'"';
690
+							if ($compress) {
691
+								$output .= '"t": "'.$spotter_item['type'].'"';
692
+							} else {
693
+								$output .= '"type": "'.$spotter_item['type'].'"';
694
+							}
536 695
 						} elseif ($marine) {
537
-							if ($compress) $output .= '"t": "ship"';
538
-							else $output .= '"type": "ship"';
696
+							if ($compress) {
697
+								$output .= '"t": "ship"';
698
+							} else {
699
+								$output .= '"type": "ship"';
700
+							}
539 701
 						} else {
540
-							if ($compress) $output .= '"t": "aircraft"';
541
-							else $output .= '"type": "aircraft"';
702
+							if ($compress) {
703
+								$output .= '"t": "aircraft"';
704
+							} else {
705
+								$output .= '"type": "aircraft"';
706
+							}
542 707
 						}
543 708
 						$output .= '},';
544 709
 						$output .= '"geometry": {';
@@ -546,15 +711,19 @@  discard block
 block discarded – undo
546 711
 								$output .= '"coordinates": [';
547 712
 								if ($currenttime != '') {
548 713
 									if (strtotime($spotter_item['date']) < $currenttime) {
549
-										if (!isset($archivespeed)) $archivespeed = 1;
714
+										if (!isset($archivespeed)) {
715
+											$archivespeed = 1;
716
+										}
550 717
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
551 718
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
552
-										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
553
-										else {
719
+										if (!isset($idistance) || $fdistance < $idistance) {
720
+											$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
721
+										} else {
554 722
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
555 723
 											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
556
-											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
557
-											else {
724
+											if (!isset($idistance) || $fdistance < $idistance) {
725
+												$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
726
+											} else {
558 727
 												$output .= $spotter_item['longitude'].', ';
559 728
 												$output .= $spotter_item['latitude'];
560 729
 											}
@@ -632,7 +801,9 @@  discard block
 block discarded – undo
632 801
 			}
633 802
 */
634 803
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
635
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
804
+				if ($history == '' && isset($_COOKIE['history'])) {
805
+					$history = $_COOKIE['history'];
806
+				}
636 807
 				
637 808
 				if (
638 809
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -702,8 +873,11 @@  discard block
 block discarded – undo
702 873
 									$output_history .= ']}},';
703 874
 									$output .= $output_history;
704 875
 								}
705
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
706
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
876
+								if ($compress) {
877
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
878
+								} else {
879
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
880
+								}
707 881
 							}
708 882
 							$output_history .= '[';
709 883
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -724,10 +898,15 @@  discard block
 block discarded – undo
724 898
 							if ($d == false) {
725 899
 								if ($compress) {
726 900
 									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",';
727
-									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
728
-									elseif (isset($spotter_history_array[0]['mapmatching_engine'])) $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
901
+									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') {
902
+										$output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
903
+									} elseif (isset($spotter_history_array[0]['mapmatching_engine'])) {
904
+										$output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
905
+									}
729 906
 									$output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": [';
730
-								} else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
907
+								} else {
908
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
909
+								}
731 910
 								$d = true;
732 911
 							}
733 912
 							$output_history .= '[';
@@ -750,7 +929,9 @@  discard block
 block discarded – undo
750 929
 							$output_historyd = '[';
751 930
 							$output_historyd .=  $spotter_item['longitude'].', ';
752 931
 							$output_historyd .=  $spotter_item['latitude'];
753
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
932
+							if (isset($spotter_history['altitude'])) {
933
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
934
+							}
754 935
 							$output_historyd .= '],';
755 936
 							//$output_history = $output_historyd.$output_history;
756 937
 							$output_history = $output_history.$output_historyd;
@@ -777,8 +958,11 @@  discard block
 block discarded – undo
777 958
 				        && $spotter_item['arrival_airport'] != 'NA' 
778 959
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
779 960
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
780
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
781
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
961
+				    if ($compress) {
962
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
963
+				    } else {
964
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
965
+				    }
782 966
 				    if (isset($spotter_item['departure_airport_latitude'])) {
783 967
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
784 968
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -811,8 +995,11 @@  discard block
 block discarded – undo
811 995
 				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
812 996
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
813 997
 				    $havedata = false;
814
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
815
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
998
+				    if ($compress) {
999
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1000
+				    } else {
1001
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1002
+				    }
816 1003
 				    
817 1004
 				    //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
818 1005
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -837,7 +1024,9 @@  discard block
 block discarded – undo
837 1024
 					$output_dest  = substr($output_dest, 0, -1);
838 1025
 				    }
839 1026
 				    $output_dest .= ']}},';
840
-				    if ($havedata) $output .= $output_dest;
1027
+				    if ($havedata) {
1028
+				    	$output .= $output_dest;
1029
+				    }
841 1030
 				    unset($output_dest);
842 1031
 				}
843 1032
 			}
@@ -845,7 +1034,9 @@  discard block
 block discarded – undo
845 1034
 			$output .= ']';
846 1035
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
847 1036
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
848
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
1037
+			if (isset($begindate)) {
1038
+				$output .= '"archive_date": "'.$begindate.'",';
1039
+			}
849 1040
 			$output .= '"fc": "'.$j.'"';
850 1041
 		} else {
851 1042
 			$output .= '"features": ';
Please login to merge, or discard this patch.