Completed
Push — master ( d636a6...772110 )
by Yannick
07:07
created
live-geojson.php 3 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 $Common = new Common();
12 12
 
13 13
 if (isset($_GET['download'])) {
14
-    if ($_GET['download'] == "true")
15
-    {
14
+	if ($_GET['download'] == "true")
15
+	{
16 16
 	header('Content-disposition: attachment; filename="flightairmap.json"');
17
-    }
17
+	}
18 18
 }
19 19
 header('Content-Type: text/javascript');
20 20
 
@@ -325,29 +325,29 @@  discard block
 block discarded – undo
325 325
 				if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) 
326 326
 				|| (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))) 
327 327
 				|| (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) {
328
-                                    if ($from_archive) {
329
-					    $spotter_history_array = $SpotterArchive->getAllArchiveSpotterDataById($spotter_item['flightaware_id']);
330
-                                    } else {
331
-					    $spotter_history_array = $SpotterLive->getAllLiveSpotterDataById($spotter_item['flightaware_id']);
332
-                                    }
333
-                            	$d = false;
328
+									if ($from_archive) {
329
+						$spotter_history_array = $SpotterArchive->getAllArchiveSpotterDataById($spotter_item['flightaware_id']);
330
+									} else {
331
+						$spotter_history_array = $SpotterLive->getAllLiveSpotterDataById($spotter_item['flightaware_id']);
332
+									}
333
+								$d = false;
334 334
 				foreach ($spotter_history_array as $key => $spotter_history)
335 335
 				{
336
-				    /*
336
+					/*
337 337
 				    if (abs($spotter_history['longitude']-$spotter_item['longitude']) > 200 || $d==true) {
338 338
 					if ($d == false) $d = true;
339 339
 				    } else {
340 340
 				    */
341 341
 					$alt = round($spotter_history['altitude']/10)*10;
342 342
 					if (!isset($prev_alt) || $prev_alt != $alt) {
343
-					    if (isset($prev_alt)) {
343
+						if (isset($prev_alt)) {
344 344
 						//$output_history .= '['.$spotter_history['longitude'].', '.$spotter_history['latitude'].','.$spotter_history['altitude'].']';
345 345
 						$output_history .= '['.$spotter_history['longitude'].', '.$spotter_history['latitude'].', '.$spotter_history['altitude'].']';
346 346
 						$output_history .= ']}},';
347 347
 						$output .= $output_history;
348
-					    }
349
-					    if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
350
-					    else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
348
+						}
349
+						if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
350
+						else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
351 351
 					}
352 352
 					$output_history .= '[';
353 353
 					$output_history .=  $spotter_history['longitude'].', ';
@@ -355,41 +355,41 @@  discard block
 block discarded – undo
355 355
 					$output_history .=  $spotter_history['altitude']*30.48;
356 356
 					$output_history .= '],';
357 357
 					$prev_alt = $alt;
358
-				    //}
358
+					//}
359 359
 				}
360 360
 				if (isset($output_history)) {
361
-				    $output_history  = substr($output_history, 0, -1);
362
-				    $output_history .= ']}},';
363
-				    $output .= $output_history;
364
-				    unset($prev_alt);
365
-				    unset($output_history);
361
+					$output_history  = substr($output_history, 0, -1);
362
+					$output_history .= ']}},';
363
+					$output .= $output_history;
364
+					unset($prev_alt);
365
+					unset($output_history);
366 366
 				}
367 367
 				}
368 368
 				
369 369
 				if (isset($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))))) {
370
-				    $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
371
-				    if (isset($spotter_item['departure_airport_latitude'])) {
370
+					$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
371
+					if (isset($spotter_item['departure_airport_latitude'])) {
372 372
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
373
-				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
373
+					} elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
374 374
 					$dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']);
375 375
 					//print_r($dairport);
376 376
 					//echo $spotter_item['departure_airport'];
377 377
 					if (isset($dairport[0]['latitude'])) {
378
-					    $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
378
+						$output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
379 379
 					}
380
-				    }
381
-				    if (isset($spotter_item['arrival_airport_latitude'])) {
380
+					}
381
+					if (isset($spotter_item['arrival_airport_latitude'])) {
382 382
 					$output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']';
383
-				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
383
+					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
384 384
 					//print_r($aairport);
385 385
 					$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
386 386
 					if (isset($aairport[0]['latitude'])) {
387
-					    $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
387
+						$output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
388 388
 					}
389
-				    }
390
-				    $output_air .= ']}},';
391
-				    $output .= $output_air;
392
-				    unset($output_air);
389
+					}
390
+					$output_air .= ']}},';
391
+					$output .= $output_air;
392
+					unset($output_air);
393 393
 				}
394 394
 			}
395 395
 			$output  = substr($output, 0, -1);
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -25,22 +25,22 @@  discard block
 block discarded – undo
25 25
 $min = false;
26 26
 $allhistory = false;
27 27
 $filter['source'] = array();
28
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
29
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
30
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
31
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
32
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
33
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
34
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
35
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
36
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
28
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
29
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
30
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
31
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs'));
32
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
33
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
34
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
35
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
36
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
37 37
 
38 38
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
39 39
 	$min = true;
40 40
 }
41 41
 
42 42
 if (isset($_GET['ident'])) {
43
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
43
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
44 44
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident);
45 45
 	if (empty($spotter_array)) {
46 46
 		$from_archive = true;
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	}
49 49
 	$allhistory = true;
50 50
 } elseif (isset($_GET['flightaware_id'])) {
51
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
51
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
52 52
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
53 53
 	if (empty($spotter_array)) {
54 54
 		$from_archive = true;
@@ -57,37 +57,37 @@  discard block
 block discarded – undo
57 57
 	$allhistory = true;
58 58
 } elseif (isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) {
59 59
 //if (isset($_GET['coord'])) {
60
-	$coord = explode(',',$_GET['coord']);
61
-	$spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter);
60
+	$coord = explode(',', $_GET['coord']);
61
+	$spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter);
62 62
 
63 63
 #} elseif (isset($globalMapPopup) && !$globalMapPopup) {
64 64
 } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed'])) {
65 65
 	$from_archive = true;
66 66
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
67 67
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
68
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
69
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
70
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
71
-	$begindate = date('Y-m-d H:i:s',$begindate);
72
-	$enddate = date('Y-m-d H:i:s',$enddate);
73
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
68
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
69
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
70
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
71
+	$begindate = date('Y-m-d H:i:s', $begindate);
72
+	$enddate = date('Y-m-d H:i:s', $enddate);
73
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
74 74
 } elseif ($min) {
75 75
 	$spotter_array = $SpotterLive->getMinLiveSpotterData($filter);
76 76
 #	$min = true;
77 77
 } else {
78
-	$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
78
+	$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
79 79
 }
80 80
 
81 81
 if (!empty($spotter_array)) {
82 82
 	if (isset($_GET['archive'])) {
83
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
83
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
84 84
 	} else {
85 85
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
86 86
 	}
87 87
 	if ($flightcnt == '') $flightcnt = 0;
88 88
 } else $flightcnt = 0;
89 89
 
90
-$sqltime = round(microtime(true)-$begintime,2);
90
+$sqltime = round(microtime(true) - $begintime, 2);
91 91
 
92 92
 $j = 0;
93 93
 $prev_flightaware_id = '';
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 		if (!empty($spotter_array) && is_array($spotter_array))
103 103
 		{
104 104
 			$output .= '"features": [';
105
-			foreach($spotter_array as $spotter_item)
105
+			foreach ($spotter_array as $spotter_item)
106 106
 			{
107 107
 				$j++;
108 108
 				date_default_timezone_set('UTC');
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
154 154
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
155 155
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
156
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
156
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
157 157
 						} elseif (isset($spotter_item['aircraft_type'])) {
158 158
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
159 159
 						} elseif (!$min) {
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
222 222
 						else $output .= '"heading": "'.$spotter_item['heading'].'",';
223 223
 						
224
-						if (isset($archivespeed)) $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
225
-						else $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']);
224
+						if (isset($archivespeed)) $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed);
225
+						else $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']);
226 226
 						//$output .= '"nextlatitude": "'.$nextcoord['latitude'].'",';
227 227
 						//$output .= '"nextlongitude": "'.$nextcoord['longitude'].'",';
228 228
 						$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 
231 231
 						if (!$min) $output .= '"image": "'.$image.'",';
232 232
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
233
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
233
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
234 234
 						}
235 235
 						if (isset($spotter_item['image_source_website'])) {
236 236
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
253 253
 						}
254 254
 						if (isset($spotter_item['acars'])) {
255
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
255
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
256 256
 						}
257 257
 						// type when not aircraft ?
258 258
 						if ($compress) $output .= '"t": "aircraft"';
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 */
325 325
 				//if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) || (isset($_GET['history']) && $_GET['history'] != '' && $_GET['history'] != 'NA' && ($_GET['history'] == $spotter_item['ident'] || $_GET['history'] == $spotter_item['flightaware_id'])))) {
326 326
 				//if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) || (isset($_GET['history']) && $_GET['history'] != '' && $_GET['history'] != 'NA' && ($_GET['history'] == $spotter_item['ident'] || $_GET['history'] == $spotter_item['flightaware_id']))) || (isset($_GET['history']) && $_GET['history'] == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) {
327
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
327
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
328 328
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
329 329
 				if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) 
330 330
 				|| (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))) 
@@ -354,9 +354,9 @@  discard block
 block discarded – undo
354 354
 					    else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
355 355
 					}
356 356
 					$output_history .= '[';
357
-					$output_history .=  $spotter_history['longitude'].', ';
358
-					$output_history .=  $spotter_history['latitude'].', ';
359
-					$output_history .=  $spotter_history['altitude']*30.48;
357
+					$output_history .= $spotter_history['longitude'].', ';
358
+					$output_history .= $spotter_history['latitude'].', ';
359
+					$output_history .= $spotter_history['altitude']*30.48;
360 360
 					$output_history .= '],';
361 361
 					$prev_alt = $alt;
362 362
 				    //}
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 			//$output .= ']}}';
401 401
 			$output .= ']';
402 402
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
403
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
403
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
404 404
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
405 405
 			$output .= '"fc": "'.$j.'"';
406 406
 		} else {
Please login to merge, or discard this patch.
Braces   +133 added lines, -51 removed lines patch added patch discarded remove patch
@@ -18,22 +18,43 @@  discard block
 block discarded – undo
18 18
 }
19 19
 header('Content-Type: text/javascript');
20 20
 
21
-if (!isset($globalJsonCompress)) $compress = true;
22
-else $compress = $globalJsonCompress;
21
+if (!isset($globalJsonCompress)) {
22
+	$compress = true;
23
+} else {
24
+	$compress = $globalJsonCompress;
25
+}
23 26
 
24 27
 $from_archive = false;
25 28
 $min = false;
26 29
 $allhistory = false;
27 30
 $filter['source'] = array();
28
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
29
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
30
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
31
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
32
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
33
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
34
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
35
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
36
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
31
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
32
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
33
+}
34
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
35
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
36
+}
37
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
38
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
39
+}
40
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
41
+	$filter['source'] = array_merge($filter['source'],array('sbs'));
42
+}
43
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
44
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
45
+}
46
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
47
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
48
+}
49
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
50
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
51
+}
52
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
53
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
54
+}
55
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
56
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
57
+}
37 58
 
38 59
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
39 60
 	$min = true;
@@ -84,8 +105,12 @@  discard block
 block discarded – undo
84 105
 	} else {
85 106
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
86 107
 	}
87
-	if ($flightcnt == '') $flightcnt = 0;
88
-} else $flightcnt = 0;
108
+	if ($flightcnt == '') {
109
+		$flightcnt = 0;
110
+	}
111
+	} else {
112
+	$flightcnt = 0;
113
+}
89 114
 
90 115
 $sqltime = round(microtime(true)-$begintime,2);
91 116
 
@@ -94,8 +119,11 @@  discard block
 block discarded – undo
94 119
 
95 120
 $output = '{';
96 121
 	$output .= '"type": "FeatureCollection",';
97
-		if ($min) $output .= '"minimal": "true",';
98
-		else $output .= '"minimal": "false",';
122
+		if ($min) {
123
+			$output .= '"minimal": "true",';
124
+		} else {
125
+			$output .= '"minimal": "false",';
126
+		}
99 127
 		$output .= '"fc": "'.$flightcnt.'",';
100 128
 		$output .= '"sqt": "'.$sqltime.'",';
101 129
 
@@ -132,11 +160,16 @@  discard block
 block discarded – undo
132 160
 						//$output .= '"sqt": "'.$sqltime.'",';
133 161
 						$output .= '"id": "'.$spotter_item['flightaware_id'].'",';
134 162
 						$output .= '"properties": {';
135
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
136
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
163
+							if ($compress) {
164
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
165
+							} else {
166
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
167
+							}
137 168
 							$output .= '"fc": "'.$flightcnt.'",';
138 169
 							$output .= '"sqt": "'.$sqltime.'",';
139
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
170
+							if (isset($begindate)) {
171
+								$output .= '"archive_date": "'.$begindate.'",';
172
+							}
140 173
 
141 174
 /*
142 175
 							if ($min) $output .= '"minimal": "true",';
@@ -144,13 +177,21 @@  discard block
 block discarded – undo
144 177
 */
145 178
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
146 179
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
147
-							if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",';
148
-							else $output .= '"callsign": "'.$spotter_item['ident'].'",';
180
+							if ($compress) {
181
+								$output .= '"c": "'.$spotter_item['ident'].'",';
182
+							} else {
183
+								$output .= '"callsign": "'.$spotter_item['ident'].'",';
184
+							}
149 185
 						} else {
150
-							if ($compress) $output .= '"c": "NA",';
151
-							else $output .= '"callsign": "NA",';
186
+							if ($compress) {
187
+								$output .= '"c": "NA",';
188
+							} else {
189
+								$output .= '"callsign": "NA",';
190
+							}
191
+						}
192
+						if (isset($spotter_item['registration'])) {
193
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
152 194
 						}
153
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
154 195
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
155 196
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
156 197
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -163,20 +204,31 @@  discard block
 block discarded – undo
163 204
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
164 205
 						}
165 206
 						if (!isset($spotter_item['aircraft_shadow'])) {
166
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
167
-							else {
207
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
208
+								$spotter_item['aircraft_shadow'] = '';
209
+							} else {
168 210
 								$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
169
-								if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
170
-								elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
171
-								else $spotter_item['aircraft_shadow'] = '';
211
+								if (count($aircraft_info) > 0) {
212
+									$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
213
+								} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
214
+									$spotter_item['aircraft_shadow'] = 'PA18.png';
215
+								} else {
216
+									$spotter_item['aircraft_shadow'] = '';
217
+								}
172 218
 							}
173 219
 						}
174 220
 						if ($spotter_item['aircraft_shadow'] == '') {
175
-							if ($compress) $output .= '"as": "default.png",';
176
-							else $output .= '"aircraft_shadow": "default.png",';
221
+							if ($compress) {
222
+								$output .= '"as": "default.png",';
223
+							} else {
224
+								$output .= '"aircraft_shadow": "default.png",';
225
+							}
177 226
 						} else {
178
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
179
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
227
+							if ($compress) {
228
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
229
+							} else {
230
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
231
+							}
180 232
 						}
181 233
 						if (isset($spotter_item['airline_name'])) {
182 234
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -184,8 +236,11 @@  discard block
 block discarded – undo
184 236
 							$output .= '"airline_name": "NA",';
185 237
 						}
186 238
 						if (isset($spotter_item['departure_airport'])) {
187
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
188
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
239
+							if ($compress) {
240
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
241
+							} else {
242
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
243
+							}
189 244
 						}
190 245
 						if (isset($spotter_item['departure_airport_city'])) {
191 246
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -197,8 +252,11 @@  discard block
 block discarded – undo
197 252
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
198 253
 						}
199 254
 						if (isset($spotter_item['arrival_airport'])) {
200
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
201
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
255
+							if ($compress) {
256
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
257
+							} else {
258
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
259
+							}
202 260
 						}
203 261
 						if (isset($spotter_item['arrival_airport_city'])) {
204 262
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -216,19 +274,30 @@  discard block
 block discarded – undo
216 274
 							$output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",';
217 275
 						}
218 276
 						
219
-						if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
220
-						else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
221
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
222
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
277
+						if ($compress) {
278
+							$output .= '"a": "'.$spotter_item['altitude'].'",';
279
+						} else {
280
+							$output .= '"altitude": "'.$spotter_item['altitude'].'",';
281
+						}
282
+						if ($compress) {
283
+							$output .= '"h": "'.$spotter_item['heading'].'",';
284
+						} else {
285
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
286
+						}
223 287
 						
224
-						if (isset($archivespeed)) $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
225
-						else $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']);
288
+						if (isset($archivespeed)) {
289
+							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
290
+						} else {
291
+							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']);
292
+						}
226 293
 						//$output .= '"nextlatitude": "'.$nextcoord['latitude'].'",';
227 294
 						//$output .= '"nextlongitude": "'.$nextcoord['longitude'].'",';
228 295
 						$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
229 296
 						//$output .= '"nextlatlon": ['.$nextcoord['longitude'].','.$nextcoord['latitude'].'],';
230 297
 
231
-						if (!$min) $output .= '"image": "'.$image.'",';
298
+						if (!$min) {
299
+							$output .= '"image": "'.$image.'",';
300
+						}
232 301
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
233 302
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
234 303
 						}
@@ -236,8 +305,11 @@  discard block
 block discarded – undo
236 305
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
237 306
 						}
238 307
 						if (isset($spotter_item['squawk'])) {
239
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
240
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
308
+							if ($compress) {
309
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
310
+							} else {
311
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
312
+							}
241 313
 						}
242 314
 						if (isset($spotter_item['squawk_usage'])) {
243 315
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -255,8 +327,11 @@  discard block
 block discarded – undo
255 327
 							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
256 328
 						}
257 329
 						// type when not aircraft ?
258
-						if ($compress) $output .= '"t": "aircraft"';
259
-						else $output .= '"type": "aircraft"';
330
+						if ($compress) {
331
+							$output .= '"t": "aircraft"';
332
+						} else {
333
+							$output .= '"type": "aircraft"';
334
+						}
260 335
 						$output .= '},';
261 336
 						$output .= '"geometry": {';
262 337
 							$output .= '"type": "Point",';
@@ -325,7 +400,9 @@  discard block
 block discarded – undo
325 400
 				//if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) || (isset($_GET['history']) && $_GET['history'] != '' && $_GET['history'] != 'NA' && ($_GET['history'] == $spotter_item['ident'] || $_GET['history'] == $spotter_item['flightaware_id'])))) {
326 401
 				//if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) || (isset($_GET['history']) && $_GET['history'] != '' && $_GET['history'] != 'NA' && ($_GET['history'] == $spotter_item['ident'] || $_GET['history'] == $spotter_item['flightaware_id']))) || (isset($_GET['history']) && $_GET['history'] == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) {
327 402
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
328
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
403
+				if ($history == '' && isset($_COOKIE['history'])) {
404
+					$history = $_COOKIE['history'];
405
+				}
329 406
 				if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) 
330 407
 				|| (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))) 
331 408
 				|| (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) {
@@ -350,8 +427,11 @@  discard block
 block discarded – undo
350 427
 						$output_history .= ']}},';
351 428
 						$output .= $output_history;
352 429
 					    }
353
-					    if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
354
-					    else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
430
+					    if ($compress) {
431
+					    	$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
432
+					    } else {
433
+					    	$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
434
+					    }
355 435
 					}
356 436
 					$output_history .= '[';
357 437
 					$output_history .=  $spotter_history['longitude'].', ';
@@ -401,7 +481,9 @@  discard block
 block discarded – undo
401 481
 			$output .= ']';
402 482
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
403 483
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
404
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
484
+			if (isset($begindate)) {
485
+				$output .= '"archive_date": "'.$begindate.'",';
486
+			}
405 487
 			$output .= '"fc": "'.$j.'"';
406 488
 		} else {
407 489
 			$output .= '"features": ';
Please login to merge, or discard this patch.
archive-geojson.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 $Common = new Common();
10 10
 
11 11
 if (isset($_GET['download'])) {
12
-    if ($_GET['download'] == "true")
13
-    {
12
+	if ($_GET['download'] == "true")
13
+	{
14 14
 	header('Content-disposition: attachment; filename="flightairmap.json"');
15
-    }
15
+	}
16 16
 }
17 17
 header('Content-Type: text/javascript');
18 18
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 				}
92 92
 
93 93
 				//waypoint plotting
94
-                /*
94
+				/*
95 95
 				$output .= '{';
96 96
 					$output .= '"type": "Feature",';
97 97
 						$output .= '"properties": {';
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 					$output_time .= (strtotime($spotter_history['date'])*1000).',';
271 271
 				}
272 272
 				if (isset($output_time)) {
273
-				    $output_time  = substr($output_time, 0, -1);
274
-				    $output .= '"time": ['.$output_time.'],';
273
+					$output_time  = substr($output_time, 0, -1);
274
+					$output .= '"time": ['.$output_time.'],';
275 275
 				}
276 276
 
277 277
 
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 						$output .= '"coordinates": [';
286 286
 						
287 287
 				if (isset($output_history)) {
288
-				    $output_history  = substr($output_history, 0, -1);
289
-				    $output .= $output_history;
288
+					$output_history  = substr($output_history, 0, -1);
289
+					$output .= $output_history;
290 290
 				}
291 291
 				
292 292
 						$output .= ']';
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 $min = false;
24 24
 $allhistory = false;
25 25
 $filter['source'] = array();
26
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
27
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
28
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
29
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
30
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
31
-if (isset($_COOKIE['Airlines']) && $_COOKIE['Airlines'] != '') $filter['airlines'] = explode(',',$_COOKIE['Airlines']);
32
-if (isset($_COOKIE['Sources']) && $_COOKIE['Sources'] != '') $filter['source_aprs'] = explode(',',$_COOKIE['Sources']);
26
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
27
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
28
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
29
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs'));
30
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
31
+if (isset($_COOKIE['Airlines']) && $_COOKIE['Airlines'] != '') $filter['airlines'] = explode(',', $_COOKIE['Airlines']);
32
+if (isset($_COOKIE['Sources']) && $_COOKIE['Sources'] != '') $filter['source_aprs'] = explode(',', $_COOKIE['Sources']);
33 33
 if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] != 'all') $filter['airlinestype'] = $_COOKIE['airlinestype'];
34 34
 
35 35
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 }
38 38
 
39 39
 if (isset($_GET['ident'])) {
40
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
40
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
41 41
 	$from_archive = true;
42 42
 	$spotter_array = $SpotterArchive->getLastArchiveSpotterDataByIdent($ident);
43 43
 	$allhistory = true;
44 44
 } elseif (isset($_GET['flightaware_id'])) {
45
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
45
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
46 46
 	$from_archive = true;
47 47
 	$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
48 48
 	$allhistory = true;
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
 	$from_archive = true;
51 51
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
52 52
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
53
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
54
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
55
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
56
-	$begindate = date('Y-m-d H:i:s',$begindate);
57
-	$enddate = date('Y-m-d H:i:s',$enddate);
58
-	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter);
53
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
54
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
55
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
56
+	$begindate = date('Y-m-d H:i:s', $begindate);
57
+	$enddate = date('Y-m-d H:i:s', $enddate);
58
+	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter);
59 59
 }
60 60
 
61 61
 if (!empty($spotter_array)) {
62
-	$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
62
+	$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
63 63
 	if ($flightcnt == '') $flightcnt = 0;
64 64
 } else $flightcnt = 0;
65 65
 
66
-$sqltime = round(microtime(true)-$begintime,2);
66
+$sqltime = round(microtime(true) - $begintime, 2);
67 67
 
68 68
 //var_dump($spotter_array);
69 69
 $j = 0;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		if (!empty($spotter_array) && is_array($spotter_array))
79 79
 		{
80 80
 			$output .= '"features": [';
81
-			foreach($spotter_array as $spotter_item)
81
+			foreach ($spotter_array as $spotter_item)
82 82
 			{
83 83
 				$j++;
84 84
 				date_default_timezone_set('UTC');
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
162 162
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
163 163
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
164
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
164
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
165 165
 						} elseif (isset($spotter_item['aircraft_type'])) {
166 166
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
167 167
 						} elseif (!$min) {
@@ -228,15 +228,15 @@  discard block
 block discarded – undo
228 228
 						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
229 229
 						else $output .= '"heading": "'.$spotter_item['heading'].'",';
230 230
 						
231
-						if (isset($archivespeed)) $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
232
-						else $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']);
231
+						if (isset($archivespeed)) $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed);
232
+						else $nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']);
233 233
 						//$output .= '"nextlatitude": "'.$nextcoord['latitude'].'",';
234 234
 						//$output .= '"nextlongitude": "'.$nextcoord['longitude'].'",';
235 235
 						$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
236 236
 
237 237
 						if (!$min) $output .= '"image": "'.$image.'",';
238 238
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
239
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
239
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
240 240
 						}
241 241
 						if (isset($spotter_item['image_source_website'])) {
242 242
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
259 259
 						}
260 260
 						if (isset($spotter_item['acars'])) {
261
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
261
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
262 262
 						}
263 263
 						$spotter_history_array = $SpotterArchive->getCoordArchiveSpotterDataById($spotter_item['flightaware_id']);
264 264
 						//$spotter_history_array = array();
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 					$output_time .= (strtotime($spotter_history['date'])*1000).',';
271 271
 				}
272 272
 				if (isset($output_time)) {
273
-				    $output_time  = substr($output_time, 0, -1);
273
+				    $output_time = substr($output_time, 0, -1);
274 274
 				    $output .= '"time": ['.$output_time.'],';
275 275
 				}
276 276
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 						$output .= '"coordinates": [';
286 286
 						
287 287
 				if (isset($output_history)) {
288
-				    $output_history  = substr($output_history, 0, -1);
288
+				    $output_history = substr($output_history, 0, -1);
289 289
 				    $output .= $output_history;
290 290
 				}
291 291
 				
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 			$output  = substr($output, 0, -1);
298 298
 			$output .= ']';
299 299
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
300
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
300
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
301 301
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
302 302
 			$output .= '"fc": "'.$flightcnt.'"';
303 303
 		} else {
Please login to merge, or discard this patch.
Braces   +120 added lines, -46 removed lines patch added patch discarded remove patch
@@ -16,21 +16,40 @@  discard block
 block discarded – undo
16 16
 }
17 17
 header('Content-Type: text/javascript');
18 18
 
19
-if (!isset($globalJsonCompress)) $compress = true;
20
-else $compress = $globalJsonCompress;
19
+if (!isset($globalJsonCompress)) {
20
+	$compress = true;
21
+} else {
22
+	$compress = $globalJsonCompress;
23
+}
21 24
 
22 25
 $from_archive = false;
23 26
 $min = false;
24 27
 $allhistory = false;
25 28
 $filter['source'] = array();
26
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
27
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
28
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
29
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
30
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
31
-if (isset($_COOKIE['Airlines']) && $_COOKIE['Airlines'] != '') $filter['airlines'] = explode(',',$_COOKIE['Airlines']);
32
-if (isset($_COOKIE['Sources']) && $_COOKIE['Sources'] != '') $filter['source_aprs'] = explode(',',$_COOKIE['Sources']);
33
-if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] != 'all') $filter['airlinestype'] = $_COOKIE['airlinestype'];
29
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') {
30
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
31
+}
32
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') {
33
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
34
+}
35
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') {
36
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
37
+}
38
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') {
39
+	$filter['source'] = array_merge($filter['source'],array('sbs'));
40
+}
41
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') {
42
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
43
+}
44
+if (isset($_COOKIE['Airlines']) && $_COOKIE['Airlines'] != '') {
45
+	$filter['airlines'] = explode(',',$_COOKIE['Airlines']);
46
+}
47
+if (isset($_COOKIE['Sources']) && $_COOKIE['Sources'] != '') {
48
+	$filter['source_aprs'] = explode(',',$_COOKIE['Sources']);
49
+}
50
+if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] != 'all') {
51
+	$filter['airlinestype'] = $_COOKIE['airlinestype'];
52
+}
34 53
 
35 54
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
36 55
 	$min = true;
@@ -60,8 +79,12 @@  discard block
 block discarded – undo
60 79
 
61 80
 if (!empty($spotter_array)) {
62 81
 	$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
63
-	if ($flightcnt == '') $flightcnt = 0;
64
-} else $flightcnt = 0;
82
+	if ($flightcnt == '') {
83
+		$flightcnt = 0;
84
+	}
85
+	} else {
86
+	$flightcnt = 0;
87
+}
65 88
 
66 89
 $sqltime = round(microtime(true)-$begintime,2);
67 90
 
@@ -70,8 +93,11 @@  discard block
 block discarded – undo
70 93
 
71 94
 $output = '{';
72 95
 	$output .= '"type": "FeatureCollection",';
73
-		if ($min) $output .= '"minimal": "true",';
74
-		else $output .= '"minimal": "false",';
96
+		if ($min) {
97
+			$output .= '"minimal": "true",';
98
+		} else {
99
+			$output .= '"minimal": "false",';
100
+		}
75 101
 		$output .= '"fc": "'.$flightcnt.'",';
76 102
 		$output .= '"sqt": "'.$sqltime.'",';
77 103
 
@@ -140,11 +166,16 @@  discard block
 block discarded – undo
140 166
 						//$output .= '"fc": "'.$flightcnt.'",';
141 167
 						//$output .= '"sqt": "'.$sqltime.'",';
142 168
 						$output .= '"properties": {';
143
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
144
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
169
+							if ($compress) {
170
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
171
+							} else {
172
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
173
+							}
145 174
 							$output .= '"fc": "'.$flightcnt.'",';
146 175
 							$output .= '"sqt": "'.$sqltime.'",';
147
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
176
+							if (isset($begindate)) {
177
+								$output .= '"archive_date": "'.$begindate.'",';
178
+							}
148 179
 
149 180
 /*
150 181
 							if ($min) $output .= '"minimal": "true",';
@@ -152,13 +183,21 @@  discard block
 block discarded – undo
152 183
 */
153 184
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
154 185
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
155
-							if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",';
156
-							else $output .= '"callsign": "'.$spotter_item['ident'].'",';
186
+							if ($compress) {
187
+								$output .= '"c": "'.$spotter_item['ident'].'",';
188
+							} else {
189
+								$output .= '"callsign": "'.$spotter_item['ident'].'",';
190
+							}
157 191
 						} else {
158
-							if ($compress) $output .= '"c": "NA",';
159
-							else $output .= '"callsign": "NA",';
192
+							if ($compress) {
193
+								$output .= '"c": "NA",';
194
+							} else {
195
+								$output .= '"callsign": "NA",';
196
+							}
197
+						}
198
+						if (isset($spotter_item['registration'])) {
199
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
160 200
 						}
161
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
162 201
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
163 202
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
164 203
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -171,19 +210,29 @@  discard block
 block discarded – undo
171 210
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
172 211
 						}
173 212
 						if (!isset($spotter_item['aircraft_shadow'])) {
174
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
175
-							else {
213
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
214
+								$spotter_item['aircraft_shadow'] = '';
215
+							} else {
176 216
 								$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
177
-								if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
178
-								else $spotter_item['aircraft_shadow'] = '';
217
+								if (count($aircraft_info) > 0) {
218
+									$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
219
+								} else {
220
+									$spotter_item['aircraft_shadow'] = '';
221
+								}
179 222
 							}
180 223
 						}
181 224
 						if ($spotter_item['aircraft_shadow'] == '') {
182
-							if ($compress) $output .= '"as": "default.png",';
183
-							else $output .= '"aircraft_shadow": "default.png",';
225
+							if ($compress) {
226
+								$output .= '"as": "default.png",';
227
+							} else {
228
+								$output .= '"aircraft_shadow": "default.png",';
229
+							}
184 230
 						} else {
185
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
186
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
231
+							if ($compress) {
232
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
233
+							} else {
234
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
235
+							}
187 236
 						}
188 237
 						if (isset($spotter_item['airline_name'])) {
189 238
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -191,8 +240,11 @@  discard block
 block discarded – undo
191 240
 							$output .= '"airline_name": "NA",';
192 241
 						}
193 242
 						if (isset($spotter_item['departure_airport'])) {
194
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
195
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
243
+							if ($compress) {
244
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
245
+							} else {
246
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
247
+							}
196 248
 						}
197 249
 						if (isset($spotter_item['departure_airport_city'])) {
198 250
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -204,8 +256,11 @@  discard block
 block discarded – undo
204 256
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
205 257
 						}
206 258
 						if (isset($spotter_item['arrival_airport'])) {
207
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
208
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
259
+							if ($compress) {
260
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
261
+							} else {
262
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
263
+							}
209 264
 						}
210 265
 						if (isset($spotter_item['arrival_airport_city'])) {
211 266
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -223,18 +278,29 @@  discard block
 block discarded – undo
223 278
 							$output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",';
224 279
 						}
225 280
 						
226
-						if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
227
-						else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
228
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
229
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
281
+						if ($compress) {
282
+							$output .= '"a": "'.$spotter_item['altitude'].'",';
283
+						} else {
284
+							$output .= '"altitude": "'.$spotter_item['altitude'].'",';
285
+						}
286
+						if ($compress) {
287
+							$output .= '"h": "'.$spotter_item['heading'].'",';
288
+						} else {
289
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
290
+						}
230 291
 						
231
-						if (isset($archivespeed)) $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
232
-						else $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']);
292
+						if (isset($archivespeed)) {
293
+							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
294
+						} else {
295
+							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']);
296
+						}
233 297
 						//$output .= '"nextlatitude": "'.$nextcoord['latitude'].'",';
234 298
 						//$output .= '"nextlongitude": "'.$nextcoord['longitude'].'",';
235 299
 						$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
236 300
 
237
-						if (!$min) $output .= '"image": "'.$image.'",';
301
+						if (!$min) {
302
+							$output .= '"image": "'.$image.'",';
303
+						}
238 304
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
239 305
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
240 306
 						}
@@ -242,8 +308,11 @@  discard block
 block discarded – undo
242 308
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
243 309
 						}
244 310
 						if (isset($spotter_item['squawk'])) {
245
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
246
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
311
+							if ($compress) {
312
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
313
+							} else {
314
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
315
+							}
247 316
 						}
248 317
 						if (isset($spotter_item['squawk_usage'])) {
249 318
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -277,8 +346,11 @@  discard block
 block discarded – undo
277 346
 
278 347
 
279 348
 							// FIXME : type when not aircraft ?
280
-						if ($compress) $output .= '"t": "aircraft"';
281
-						else $output .= '"type": "aircraft"';
349
+						if ($compress) {
350
+							$output .= '"t": "aircraft"';
351
+						} else {
352
+							$output .= '"type": "aircraft"';
353
+						}
282 354
 						$output .= '},';
283 355
 						$output .= '"geometry": {';
284 356
 						$output .= '"type": "MultiPoint",';
@@ -298,7 +370,9 @@  discard block
 block discarded – undo
298 370
 			$output .= ']';
299 371
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
300 372
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
301
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
373
+			if (isset($begindate)) {
374
+				$output .= '"archive_date": "'.$begindate.'",';
375
+			}
302 376
 			$output .= '"fc": "'.$flightcnt.'"';
303 377
 		} else {
304 378
 			$output .= '"features": ';
Please login to merge, or discard this patch.
aircraft-data.php 2 patches
Braces   +34 added lines, -12 removed lines patch added patch discarded remove patch
@@ -46,7 +46,9 @@  discard block
 block discarded – undo
46 46
 {
47 47
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
48 48
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
49
-	} else $image = $spotter_item['image_thumbnail'];
49
+	} else {
50
+		$image = $spotter_item['image_thumbnail'];
51
+	}
50 52
 
51 53
 }
52 54
 /* else {
@@ -58,7 +60,9 @@  discard block
 block discarded – undo
58 60
 	print '<div class="left"><img src="'.$image.'" alt="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].'" title="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].' Image &copy; '.$spotter_item['image_copyright'].'"/><br />Image &copy; '.$spotter_item['image_copyright'].'</div>';
59 61
 }
60 62
 print '<div class="right"><div class="callsign-details"><div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
61
-if (isset($spotter_item['airline_name'])) print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
63
+if (isset($spotter_item['airline_name'])) {
64
+	print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
65
+}
62 66
 print '</div>';
63 67
 print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
64 68
 if (isset($spotter_item['departure_airport_time'])) {
@@ -86,9 +90,14 @@  discard block
 block discarded – undo
86 90
 print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country'];
87 91
 print '</div></div><div>';
88 92
 print '<span>'._("Aircraft").'</span>';
89
-if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
90
-if (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
91
-else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
93
+if (isset($spotter_item['aircraft_wiki'])) {
94
+	print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
95
+}
96
+if (isset($spotter_item['aircraft_type'])) {
97
+	print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
98
+} else {
99
+	print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
100
+}
92 101
 print '</div>';
93 102
 print '<div><span>'._("Altitude").'</span>';
94 103
 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
@@ -97,7 +106,9 @@  discard block
 block discarded – undo
97 106
 	print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')';
98 107
 }
99 108
 print '</div>';
100
-if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
109
+if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') {
110
+	print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
111
+}
101 112
 print '<div><span>'._("Speed").'</span>';
102 113
 if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
103 114
 	print round($spotter_item['ground_speed']*1.15078).' mph';
@@ -111,8 +122,11 @@  discard block
 block discarded – undo
111 122
 print '<div><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>';
112 123
 if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') {
113 124
 	print '<div><span>'._("Pilot").'</span>';
114
-	if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
115
-	else print $spotter_item['pilot_name'];
125
+	if (isset($spotter_item['pilot_id'])) {
126
+		print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
127
+	} else {
128
+		print $spotter_item['pilot_name'];
129
+	}
116 130
 	print '</div>';
117 131
 }
118 132
 
@@ -133,10 +147,18 @@  discard block
 block discarded – undo
133 147
 }
134 148
 print '</div>';
135 149
 
136
-if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
137
-if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
138
-if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
139
-if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
150
+if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') {
151
+	print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
152
+}
153
+if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') {
154
+	print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
155
+}
156
+if (isset($spotter_item['acars']['message'])) {
157
+	print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
158
+}
159
+if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) {
160
+	print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
161
+}
140 162
 print '</div>';
141 163
 ?>
142 164
 </div>
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -9,14 +9,14 @@  discard block
 block discarded – undo
9 9
 
10 10
 $from_archive = false;
11 11
 if (isset($_GET['ident'])) {
12
-	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
12
+	$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
13 13
 	if (isset($_GET['currenttime'])) {
14
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
14
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
15 15
 		$currenttime = round($currenttime/1000);
16
-		$spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident,$currenttime);
16
+		$spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident, $currenttime);
17 17
 		if (empty($spotter_array)) {
18 18
 			$from_archive = true;
19
-			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident,$currenttime);
19
+			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident, $currenttime);
20 20
 		}
21 21
 	} else {
22 22
 		$spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident);
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
 	}
28 28
 }
29 29
 if (isset($_GET['flightaware_id'])) {
30
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
30
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
31 31
 	if (isset($_GET['currenttime'])) {
32
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
32
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
33 33
 		$currenttime = round($currenttime/1000);
34
-		$spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id,$currenttime);
34
+		$spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id, $currenttime);
35 35
 		if (empty($spotter_array)) {
36 36
 			$from_archive = true;
37 37
 //			$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
38
-			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id,$currenttime);
38
+			$spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id, $currenttime);
39 39
 		}
40 40
 	} else {
41 41
 		$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
55 55
 {
56 56
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
57
-		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
57
+		$image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
58 58
 	} else $image = $spotter_item['image_thumbnail'];
59 59
 
60 60
 }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
73 73
 if (isset($spotter_item['departure_airport_time'])) {
74 74
 	if ($spotter_item['departure_airport_time'] > 2460) {
75
-		print '<br /><span class="time">'.date('H:m',$spotter_item['departure_airport_time']).'</span>';
75
+		print '<br /><span class="time">'.date('H:m', $spotter_item['departure_airport_time']).'</span>';
76 76
 	} else {
77 77
 		print '<br /><span class="time">'.$spotter_item['departure_airport_time'].'</span>';
78 78
 	}
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country'];
82 82
 if (isset($spotter_item['arrival_airport_time'])) {
83 83
 	if ($spotter_item['arrival_airport_time'] > 2460) {
84
-		print '<br /><span class="time">'.date('H:m',$spotter_item['arrival_airport_time']).'</span>';
84
+		print '<br /><span class="time">'.date('H:m', $spotter_item['arrival_airport_time']).'</span>';
85 85
 	} else {
86 86
 		print '<br /><span class="time">'.$spotter_item['arrival_airport_time'].'</span>';
87 87
 	}
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
 if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
151 151
 if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
152
-if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
152
+if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br/>', $spotter_item['acars']['message'])).'</div>';
153 153
 if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
154 154
 print '</div>';
155 155
 ?>
Please login to merge, or discard this patch.
live-czml.php 3 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -13,30 +13,30 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 function quaternionrotate($heading, $attitude = 0, $bank = 0) {
16
-    // Assuming the angles are in radians.
17
-    $c1 = cos($heading/2);
18
-    $s1 = sin($heading/2);
19
-    $c2 = cos($attitude/2);
20
-    $s2 = sin($attitude/2);
21
-    $c3 = cos($bank/2);
22
-    $s3 = sin($bank/2);
23
-    $c1c2 = $c1*$c2;
24
-    $s1s2 = $s1*$s2;
25
-    $w =$c1c2*$c3 - $s1s2*$s3;
26
-    $x =$c1c2*$s3 + $s1s2*$c3;
27
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
28
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
29
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
16
+	// Assuming the angles are in radians.
17
+	$c1 = cos($heading/2);
18
+	$s1 = sin($heading/2);
19
+	$c2 = cos($attitude/2);
20
+	$s2 = sin($attitude/2);
21
+	$c3 = cos($bank/2);
22
+	$s3 = sin($bank/2);
23
+	$c1c2 = $c1*$c2;
24
+	$s1s2 = $s1*$s2;
25
+	$w =$c1c2*$c3 - $s1s2*$s3;
26
+	$x =$c1c2*$s3 + $s1s2*$c3;
27
+	$y =$s1*$c2*$c3 + $c1*$s2*$s3;
28
+	$z =$c1*$s2*$c3 - $s1*$c2*$s3;
29
+	return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
30 30
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
31 31
 
32 32
 }
33 33
 
34 34
 
35 35
 if (isset($_GET['download'])) {
36
-    if ($_GET['download'] == "true")
37
-    {
36
+	if ($_GET['download'] == "true")
37
+	{
38 38
 	header('Content-disposition: attachment; filename="flightairmap.json"');
39
-    }
39
+	}
40 40
 }
41 41
 header('Content-Type: text/javascript');
42 42
 
@@ -188,78 +188,78 @@  discard block
 block discarded – undo
188 188
 				$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20 },';
189 189
 			} elseif ($spotter_item['engine_type'] == 'Jet') {
190 190
 				if ($spotter_item['engine_count'] == '1') {
191
-				    if ($spotter_item['wake_category'] == 'M') {
191
+					if ($spotter_item['wake_category'] == 'M') {
192 192
 					$model = 'J1M';
193
-				    } elseif ($spotter_item['wake_category'] == 'L') {
193
+					} elseif ($spotter_item['wake_category'] == 'L') {
194 194
 					$model = '';
195
-				    }
195
+					}
196 196
 				} elseif ($spotter_item['engine_count'] == '2') {
197
-				    if ($spotter_item['wake_category'] == 'M') {
197
+					if ($spotter_item['wake_category'] == 'M') {
198 198
 					$model = 'J2M';
199
-				    } elseif ($spotter_item['wake_category'] == 'H') {
199
+					} elseif ($spotter_item['wake_category'] == 'H') {
200 200
 					$model = 'J2H';
201
-				    } elseif ($spotter_item['wake_category'] == 'L') {
201
+					} elseif ($spotter_item['wake_category'] == 'L') {
202 202
 					$model = 'J2L';
203
-				    }
203
+					}
204 204
 				} elseif ($spotter_item['engine_count'] == '3') {
205
-				    if ($spotter_item['wake_category'] == 'M') {
205
+					if ($spotter_item['wake_category'] == 'M') {
206 206
 					$model = 'J3M';
207
-				    } elseif ($spotter_item['wake_category'] == 'H') {
207
+					} elseif ($spotter_item['wake_category'] == 'H') {
208 208
 					$model = 'J3H';
209
-				    }
209
+					}
210 210
 				} elseif ($spotter_item['engine_count'] == '4') {
211
-				    if ($spotter_item['wake_category'] == 'M') {
211
+					if ($spotter_item['wake_category'] == 'M') {
212 212
 					$model = 'J4M';
213
-				    } elseif ($spotter_item['wake_category'] == 'H') {
213
+					} elseif ($spotter_item['wake_category'] == 'H') {
214 214
 					$model = 'J4H';
215
-				    }
215
+					}
216 216
 				}
217 217
 				if (isset($modelsdb[$model])) {
218
-				    $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$model].'","scale" : 1.0,"minimumPixelSize": 20 },';
218
+					$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$model].'","scale" : 1.0,"minimumPixelSize": 20 },';
219 219
 				} else {
220
-				    $output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
220
+					$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
221 221
 				}
222 222
 			} elseif ($spotter_item['engine_type'] == 'Turboprop') {
223 223
 				if ($spotter_item['engine_count'] == '1') {
224
-				    if ($spotter_item['wake_category'] == 'L') {
224
+					if ($spotter_item['wake_category'] == 'L') {
225 225
 					$model = 'T1L';
226
-				    }
226
+					}
227 227
 				} elseif ($spotter_item['engine_count'] == '2') {
228
-				    if ($spotter_item['wake_category'] == 'M') {
228
+					if ($spotter_item['wake_category'] == 'M') {
229 229
 					$model = 'T2M';
230
-				    } elseif ($spotter_item['wake_category'] == 'L') {
230
+					} elseif ($spotter_item['wake_category'] == 'L') {
231 231
 					$model = 'T2L';
232
-				    }
232
+					}
233 233
 				} elseif ($spotter_item['engine_count'] == '4') {
234
-				    if ($spotter_item['wake_category'] == 'M') {
235
-				    } elseif ($spotter_item['wake_category'] == 'H') {
234
+					if ($spotter_item['wake_category'] == 'M') {
235
+					} elseif ($spotter_item['wake_category'] == 'H') {
236 236
 					$model = 'T4H';
237
-				    }
237
+					}
238 238
 				}
239 239
 				if (isset($modelsdb[$model])) {
240
-				    $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$model].'","scale" : 1.0,"minimumPixelSize": 20 },';
240
+					$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$model].'","scale" : 1.0,"minimumPixelSize": 20 },';
241 241
 				} else {
242
-				    $output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
242
+					$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
243 243
 				}
244 244
 			} elseif ($spotter_item['engine_type'] == 'Piston') {
245 245
 				if ($spotter_item['engine_count'] == '1') {
246
-				    if ($spotter_item['wake_category'] == 'L') {
246
+					if ($spotter_item['wake_category'] == 'L') {
247 247
 					$model = 'P1L';
248
-				    } elseif ($spotter_item['wake_category'] == 'M') {
248
+					} elseif ($spotter_item['wake_category'] == 'M') {
249 249
 					$model = 'P1M';
250
-				    }
250
+					}
251 251
 				} elseif ($spotter_item['engine_count'] == '2') {
252
-				    if ($spotter_item['wake_category'] == 'M') {
252
+					if ($spotter_item['wake_category'] == 'M') {
253 253
 					$model = 'P2M';
254
-				    } elseif ($spotter_item['wake_category'] == 'L') {
254
+					} elseif ($spotter_item['wake_category'] == 'L') {
255 255
 					$model = 'P2L';
256
-				    }
256
+					}
257 257
 				// ju52 = P3M
258 258
 				}
259 259
 				if (isset($modelsdb[$model])) {
260
-				    $output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$model].'","scale" : 1.0,"minimumPixelSize": 20 },';
260
+					$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$model].'","scale" : 1.0,"minimumPixelSize": 20 },';
261 261
 				} else {
262
-				    $output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
262
+					$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
263 263
 				}
264 264
 			} else {
265 265
 				$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
     $s3 = sin($bank/2);
23 23
     $c1c2 = $c1*$c2;
24 24
     $s1s2 = $s1*$s2;
25
-    $w =$c1c2*$c3 - $s1s2*$s3;
26
-    $x =$c1c2*$s3 + $s1s2*$c3;
27
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
28
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
29
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
25
+    $w = $c1c2*$c3 - $s1s2*$s3;
26
+    $x = $c1c2*$s3 + $s1s2*$c3;
27
+    $y = $s1*$c2*$c3 + $c1*$s2*$s3;
28
+    $z = $c1*$s2*$c3 - $s1*$c2*$s3;
29
+    return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w);
30 30
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
31 31
 
32 32
 }
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 $min = false;
48 48
 $allhistory = false;
49 49
 $filter['source'] = array();
50
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
51
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
52
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
53
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
54
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
55
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
56
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
57
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
58
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
50
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
51
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
52
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
53
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs'));
54
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
55
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
56
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
57
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
58
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
59 59
 /*
60 60
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
61 61
 	$min = true;
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 	$from_archive = true;
103 103
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
104 104
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
105
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
106
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
107
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
108
-	$begindate = date('Y-m-d H:i:s',$begindate);
109
-	$enddate = date('Y-m-d H:i:s',$enddate);
110
-	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter);
105
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
106
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
107
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
108
+	$begindate = date('Y-m-d H:i:s', $begindate);
109
+	$enddate = date('Y-m-d H:i:s', $enddate);
110
+	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter);
111 111
 } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) {
112 112
 	$from_archive = true;
113 113
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
@@ -117,34 +117,34 @@  discard block
 block discarded – undo
117 117
 	$begindate = $_COOKIE['archive_begin'];
118 118
 	$enddate = $_COOKIE['archive_end'];
119 119
 
120
-	$archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT);
121
-	$begindate = date('Y-m-d H:i:s',$begindate);
122
-	$enddate = date('Y-m-d H:i:s',$enddate);
120
+	$archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT);
121
+	$begindate = date('Y-m-d H:i:s', $begindate);
122
+	$enddate = date('Y-m-d H:i:s', $enddate);
123 123
 //	echo 'Begin : '.$begindate.' - End : '.$enddate."\n";
124
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
124
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
125 125
 } else {
126 126
 	$spotter_array = $SpotterLive->getMinLastLiveSpotterData($filter);
127 127
 }
128 128
 
129 129
 if (!empty($spotter_array)) {
130 130
 	if (isset($_GET['archive'])) {
131
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
131
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
132 132
 	} else {
133 133
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
134 134
 	}
135 135
 	if ($flightcnt == '') $flightcnt = 0;
136 136
 } else $flightcnt = 0;
137 137
 
138
-$sqltime = round(microtime(true)-$begintime,2);
138
+$sqltime = round(microtime(true) - $begintime, 2);
139 139
 $minitime = time();
140 140
 $maxitime = 0;
141 141
 
142 142
 
143 143
 $modelsdb = array();
144 144
 if (file_exists('models/modelsdb')) {
145
-	if (($handle = fopen('models/modelsdb','r')) !== FALSE) {
146
-		while (($row = fgetcsv($handle,1000)) !== FALSE) {
147
-			if (isset($row[1]) ){
145
+	if (($handle = fopen('models/modelsdb', 'r')) !== FALSE) {
146
+		while (($row = fgetcsv($handle, 1000)) !== FALSE) {
147
+			if (isset($row[1])) {
148 148
 				$model = $row[0];
149 149
 				$modelsdb[$model] = $row[1];
150 150
 			}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 $output .= '},';
173 173
 if (!empty($spotter_array) && is_array($spotter_array))
174 174
 {
175
-	foreach($spotter_array as $spotter_item)
175
+	foreach ($spotter_array as $spotter_item)
176 176
 	{
177 177
 		$j++;
178 178
 		date_default_timezone_set('UTC');
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 			$output .= '"cartographicDegrees": [';
311 311
 			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
312 312
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
313
-			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
313
+			$output .= '"'.date("c", strtotime($spotter_item['date'])).'", ';
314 314
 			$output .= $spotter_item['longitude'].', ';
315 315
 			$output .= $spotter_item['latitude'].', ';
316 316
 			$prevlong = $spotter_item['longitude'];
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
323 323
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
324 324
 		} else {
325
-			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
325
+			$output .= ',"'.date("c", strtotime($spotter_item['date'])).'", ';
326 326
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
327 327
 			if ($spotter_item['ground_speed'] == 0) {
328 328
 				$output .= $prevlong.', ';
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	$output  = substr($output, 0, -1);
352 352
 }
353 353
 $output .= ']';
354
-$output = str_replace('%minitime%',date("c",$minitime),$output);
355
-$output = str_replace('%maxitime%',date("c",$maxitime),$output);
354
+$output = str_replace('%minitime%', date("c", $minitime), $output);
355
+$output = str_replace('%maxitime%', date("c", $maxitime), $output);
356 356
 print $output;
357 357
 ?>
Please login to merge, or discard this patch.
Braces   +56 added lines, -19 removed lines patch added patch discarded remove patch
@@ -40,22 +40,43 @@  discard block
 block discarded – undo
40 40
 }
41 41
 header('Content-Type: text/javascript');
42 42
 
43
-if (!isset($globalJsonCompress)) $compress = true;
44
-else $compress = $globalJsonCompress;
43
+if (!isset($globalJsonCompress)) {
44
+	$compress = true;
45
+} else {
46
+	$compress = $globalJsonCompress;
47
+}
45 48
 
46 49
 $from_archive = false;
47 50
 $min = false;
48 51
 $allhistory = false;
49 52
 $filter['source'] = array();
50
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
51
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
52
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
53
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
54
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
55
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
56
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
57
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
58
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
53
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
54
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
55
+}
56
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
57
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
58
+}
59
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
60
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
61
+}
62
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
63
+	$filter['source'] = array_merge($filter['source'],array('sbs'));
64
+}
65
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
66
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
67
+}
68
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
69
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
70
+}
71
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
72
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
73
+}
74
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
75
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
+}
77
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
78
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
79
+}
59 80
 /*
60 81
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
61 82
 	$min = true;
@@ -132,8 +153,12 @@  discard block
 block discarded – undo
132 153
 	} else {
133 154
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
134 155
 	}
135
-	if ($flightcnt == '') $flightcnt = 0;
136
-} else $flightcnt = 0;
156
+	if ($flightcnt == '') {
157
+		$flightcnt = 0;
158
+	}
159
+	} else {
160
+	$flightcnt = 0;
161
+}
137 162
 
138 163
 $sqltime = round(microtime(true)-$begintime,2);
139 164
 $minitime = time();
@@ -155,7 +180,9 @@  discard block
 block discarded – undo
155 180
 $j = 0;
156 181
 $prev_flightaware_id = '';
157 182
 $speed = 1;
158
-if (isset($archivespeed)) $speed = $archivespeed;
183
+if (isset($archivespeed)) {
184
+	$speed = $archivespeed;
185
+}
159 186
 $output = '[';
160 187
 $output .= '{"id" : "document", "name" : "fam","version" : "1.0"';
161 188
 //	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "LOOP_STOP","step": "SYSTEM_CLOCK_MULTIPLIER"}';
@@ -296,8 +323,12 @@  discard block
 block discarded – undo
296 323
 				}
297 324
 			} else {
298 325
 				$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },';
299
-				if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
300
-				if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
326
+				if ($spotter_item['aircraft_shadow'] != '') {
327
+					$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
328
+				}
329
+				if ($spotter_item['aircraft_icao'] != '') {
330
+					$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
331
+				}
301 332
 			}
302 333
 	//		$output .= '"heightReference": "CLAMP_TO_GROUND",';
303 334
 			$output .= '"heightReference": "RELATIVE_TO_GROUND",';
@@ -308,8 +339,12 @@  discard block
 block discarded – undo
308 339
 	//		$output .= '"interpolationDegree" : 5,';
309 340
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
310 341
 			$output .= '"cartographicDegrees": [';
311
-			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
312
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
342
+			if ($minitime > strtotime($spotter_item['date'])) {
343
+				$minitime = strtotime($spotter_item['date']);
344
+			}
345
+			if ($maxitime < strtotime($spotter_item['date'])) {
346
+				$maxitime = strtotime($spotter_item['date']);
347
+			}
313 348
 			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
314 349
 			$output .= $spotter_item['longitude'].', ';
315 350
 			$output .= $spotter_item['latitude'].', ';
@@ -323,7 +358,9 @@  discard block
 block discarded – undo
323 358
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
324 359
 		} else {
325 360
 			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
326
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
361
+			if ($maxitime < strtotime($spotter_item['date'])) {
362
+				$maxitime = strtotime($spotter_item['date']);
363
+			}
327 364
 			if ($spotter_item['ground_speed'] == 0) {
328 365
 				$output .= $prevlong.', ';
329 366
 				$output .= $prevlat.', ';
Please login to merge, or discard this patch.
install/index.php 3 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	}
93 93
 	print '</ul>You <strong>must</strong> add these modules/fix errors.</div>';
94 94
 	require('../footer.php');
95
-        exit;
95
+		exit;
96 96
 }
97 97
 
98 98
 if (!isset($_SESSION['install']) && !isset($_POST['dbtype']) && (count($error) == 0)) {
@@ -301,17 +301,17 @@  discard block
 block discarded – undo
301 301
 				</tr>
302 302
 				<!--
303 303
 		<?php
304
-		    require_once(dirname(__FILE__).'/../require/class.Connection.php');
305
-		    $Connection = new Connection();
304
+			require_once(dirname(__FILE__).'/../require/class.Connection.php');
305
+			$Connection = new Connection();
306 306
 		?>
307 307
 				-->
308 308
 		<?php
309
-		    if ($Connection->db != NULL) {
309
+			if ($Connection->db != NULL) {
310 310
 			if ($Connection->tableExists('source_location')) {
311
-			    require_once(dirname(__FILE__).'/../require/class.Source.php');
312
-			    $Source = new Source();
313
-			    $alllocations = $Source->getAllLocationInfo();
314
-			    foreach ($alllocations as $location) {
311
+				require_once(dirname(__FILE__).'/../require/class.Source.php');
312
+				$Source = new Source();
313
+				$alllocations = $Source->getAllLocationInfo();
314
+				foreach ($alllocations as $location) {
315 315
 		?>
316 316
 				<tr>
317 317
 	    				<input type="hidden" name="source_id[]" value="<?php print $location['id']; ?>" />
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
 				</tr>
326 326
 		
327 327
 		<?php
328
-			    }
328
+				}
329
+			}
329 330
 			}
330
-		    }
331 331
 		?>
332 332
 
333 333
 				<tr>
@@ -418,12 +418,12 @@  discard block
 block discarded – undo
418 418
 ?>
419 419
 							<tr>
420 420
 								<?php
421
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
421
+									if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
422 422
 								?>
423 423
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
424 424
 								<td><input type="number" name="port[]" id="port" value="<?php print $source['port']; ?>" /></td>
425 425
 								<?php
426
-								    } else {
426
+									} else {
427 427
 									$hostport = explode(':',$source['host']);
428 428
 									if (isset($hostport[1])) {
429 429
 										$host = $hostport[0];
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 								<td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td>
437 437
 								<td><input type="number" name="port[]" id="port" value="<?php print $port; ?>" /></td>
438 438
 								<?php
439
-								    }
439
+									}
440 440
 								?>
441 441
 								<td>
442 442
 									<select name="format[]" id="format">
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 			<br />
728 728
 			<p>
729 729
 			<?php 
730
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
730
+				if (extension_loaded('gd') && function_exists('gd_info')) {
731 731
 			?>
732 732
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
733 733
 				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
@@ -737,11 +737,11 @@  discard block
 block discarded – undo
737 737
 				<b>The directory cache is not writable, aircraft icon will not be cached</b>
738 738
 			<?php
739 739
 				}
740
-			    } else {
740
+				} else {
741 741
 			?>
742 742
 				<b>PHP GD is not installed, you can t change color of aircraft icon on map</b>
743 743
 			<?php
744
-			    }
744
+				}
745 745
 			?>
746 746
 			</p>
747 747
 			<br />
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 	</p>
761 761
 <?php
762 762
 	require('../footer.php');
763
-        exit;
763
+		exit;
764 764
 }
765 765
 	
766 766
 $settings = array();
@@ -850,8 +850,8 @@  discard block
 block discarded – undo
850 850
 	
851 851
 	$sources = array();
852 852
 	foreach ($source_name as $keys => $name) {
853
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
854
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
853
+		if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
854
+		else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
855 855
 	}
856 856
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
857 857
 
@@ -1116,14 +1116,14 @@  discard block
 block discarded – undo
1116 1116
 
1117 1117
 	// Set some defaults values...
1118 1118
 	if (!isset($globalAircraftImageSources)) {
1119
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1120
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1119
+		$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1120
+		$settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1121 1121
 	}
1122 1122
 
1123 1123
 	if (!isset($globalSchedulesSources)) {
1124
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1125
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1126
-    	}
1124
+		$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1125
+			$settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1126
+		}
1127 1127
 
1128 1128
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1129 1129
 
@@ -1175,21 +1175,21 @@  discard block
 block discarded – undo
1175 1175
 	$popi = false;
1176 1176
 	$popw = false;
1177 1177
 	foreach ($_SESSION['done'] as $done) {
1178
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1179
-	    if ($done == 'Create database') $pop = true;
1180
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1181
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1182
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1178
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1179
+		if ($done == 'Create database') $pop = true;
1180
+		if ($_SESSION['install'] == 'database_create') $pop = true;
1181
+		if ($_SESSION['install'] == 'database_import') $popi = true;
1182
+		if ($_SESSION['install'] == 'waypoints') $popw = true;
1183 1183
 	}
1184 1184
 	if ($pop) {
1185
-	    sleep(5);
1186
-	    print '<li>Create database....<img src="../images/loading.gif" /></li>';
1185
+		sleep(5);
1186
+		print '<li>Create database....<img src="../images/loading.gif" /></li>';
1187 1187
 	} else if ($popi) {
1188
-	    sleep(5);
1189
-	    print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1188
+		sleep(5);
1189
+		print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1190 1190
 	} else if ($popw) {
1191
-	    sleep(5);
1192
-	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1191
+		sleep(5);
1192
+		print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1193 1193
 	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1194 1194
 	print '</div></ul>';
1195 1195
 	print '<div id="error"></div>';
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
 	unset($_COOKIE['install']);
1253 1253
 	print '<div class="info column"><ul>';
1254 1254
 	foreach ($_SESSION['done'] as $done) {
1255
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1255
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1256 1256
 	}
1257 1257
 	print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>';
1258 1258
 	print '</ul></div>';
Please login to merge, or discard this patch.
Braces   +409 added lines, -106 removed lines patch added patch discarded remove patch
@@ -124,45 +124,72 @@  discard block
 block discarded – undo
124 124
 			</div>
125 125
 			<p>
126 126
 				<label for="dbhost">Database hostname</label>
127
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
127
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
128
+	print $globalDBhost;
129
+}
130
+?>" />
128 131
 			</p>
129 132
 			<p>
130 133
 				<label for="dbport">Database port</label>
131
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
134
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
135
+	print $globalDBport;
136
+}
137
+?>" />
132 138
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
133 139
 			</p>
134 140
 			<p>
135 141
 				<label for="dbname">Database name</label>
136
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
142
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
143
+	print $globalDBname;
144
+}
145
+?>" />
137 146
 			</p>
138 147
 			<p>
139 148
 				<label for="dbuser">Database user</label>
140
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
149
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
150
+	print $globalDBuser;
151
+}
152
+?>" />
141 153
 			</p>
142 154
 			<p>
143 155
 				<label for="dbuserpass">Database user password</label>
144
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
156
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
157
+	print $globalDBpass;
158
+}
159
+?>" />
145 160
 			</p>
146 161
 		</fieldset>
147 162
 		<fieldset id="site">
148 163
 			<legend>Site configuration</legend>
149 164
 			<p>
150 165
 				<label for="sitename">Site name</label>
151
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
166
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
167
+	print $globalName;
168
+}
169
+?>" />
152 170
 			</p>
153 171
 			<p>
154 172
 				<label for="siteurl">Site directory</label>
155
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
173
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
174
+	print $globalURL;
175
+}
176
+?>" />
156 177
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
157 178
 			</p>
158 179
 			<p>
159 180
 				<label for="timezone">Timezone</label>
160
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
181
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
182
+	print $globalTimezone;
183
+}
184
+?>" />
161 185
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
162 186
 			</p>
163 187
 			<p>
164 188
 				<label for="language">Language</label>
165
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
189
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
190
+	print $globalLanguage;
191
+}
192
+?>" />
166 193
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
167 194
 			</p>
168 195
 		</fieldset>
@@ -183,11 +210,17 @@  discard block
 block discarded – undo
183 210
 			<div id="mapbox_data">
184 211
 				<p>
185 212
 					<label for="mapboxid">Mapbox id</label>
186
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
213
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
214
+	print $globalMapboxId;
215
+}
216
+?>" />
187 217
 				</p>
188 218
 				<p>
189 219
 					<label for="mapboxtoken">Mapbox token</label>
190
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
220
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
221
+	print $globalMapboxToken;
222
+}
223
+?>" />
191 224
 				</p>
192 225
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
193 226
 			</div>
@@ -195,7 +228,10 @@  discard block
 block discarded – undo
195 228
 			<div id="google_data">
196 229
 				<p>
197 230
 					<label for="googlekey">Google API key</label>
198
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
231
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
232
+	print $globalGoogleAPIKey;
233
+}
234
+?>" />
199 235
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
200 236
 				</p>
201 237
 			</div>
@@ -203,7 +239,10 @@  discard block
 block discarded – undo
203 239
 			<div id="bing_data">
204 240
 				<p>
205 241
 					<label for="bingkey">Bing Map key</label>
206
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
242
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
243
+	print $globalBingMapKey;
244
+}
245
+?>" />
207 246
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
208 247
 				</p>
209 248
 			</div>
@@ -211,7 +250,10 @@  discard block
 block discarded – undo
211 250
 			<div id="mapquest_data">
212 251
 				<p>
213 252
 					<label for="mapquestkey">MapQuest key</label>
214
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
253
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
254
+	print $globalMapQuestKey;
255
+}
256
+?>" />
215 257
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
216 258
 				</p>
217 259
 			</div>
@@ -219,11 +261,17 @@  discard block
 block discarded – undo
219 261
 			<div id="here_data">
220 262
 				<p>
221 263
 					<label for="hereappid">Here App_Id</label>
222
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
264
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
265
+	print $globalHereappId;
266
+}
267
+?>" />
223 268
 				</p>
224 269
 				<p>
225 270
 					<label for="hereappcode">Here App_Code</label>
226
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
271
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
272
+	print $globalHereappCode;
273
+}
274
+?>" />
227 275
 				</p>
228 276
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
229 277
 			</div>
@@ -232,42 +280,86 @@  discard block
 block discarded – undo
232 280
 			<legend>Coverage area</legend>
233 281
 			<p>
234 282
 				<label for="latitudemax">The maximum latitude (north)</label>
235
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
283
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
284
+	print $globalLatitudeMax;
285
+}
286
+?>" />
236 287
 			</p>
237 288
 			<p>
238 289
 				<label for="latitudemin">The minimum latitude (south)</label>
239
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
290
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
291
+	print $globalLatitudeMin;
292
+}
293
+?>" />
240 294
 			</p>
241 295
 			<p>
242 296
 				<label for="longitudemax">The maximum longitude (west)</label>
243
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
297
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
298
+	print $globalLongitudeMax;
299
+}
300
+?>" />
244 301
 			</p>
245 302
 			<p>
246 303
 				<label for="longitudemin">The minimum longitude (east)</label>
247
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
304
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
305
+	print $globalLongitudeMin;
306
+}
307
+?>" />
248 308
 			</p>
249 309
 			<p>
250 310
 				<label for="latitudecenter">The latitude center</label>
251
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
311
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
312
+	print $globalCenterLatitude;
313
+}
314
+?>" />
252 315
 			</p>
253 316
 			<p>
254 317
 				<label for="longitudecenter">The longitude center</label>
255
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
318
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
319
+	print $globalCenterLongitude;
320
+}
321
+?>" />
256 322
 			</p>
257 323
 			<p>
258 324
 				<label for="livezoom">Default Zoom on live map</label>
259
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
325
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
326
+	print $globalLiveZoom;
327
+} else {
328
+	print '9';
329
+}
330
+?>" />
260 331
 			</p>
261 332
 			<p>
262 333
 				<label for="squawk_country">Country for squawk usage</label>
263 334
 				<select name="squawk_country" id="squawk_country">
264
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
265
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
266
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
267
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
268
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
269
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
270
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
335
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
336
+	print ' selected ';
337
+}
338
+?>>UK</option>
339
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
340
+	print ' selected ';
341
+}
342
+?>>NZ</option>
343
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
344
+	print ' selected ';
345
+}
346
+?>>US</option>
347
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
348
+	print ' selected ';
349
+}
350
+?>>AU</option>
351
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
352
+	print ' selected ';
353
+}
354
+?>>NL</option>
355
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
356
+	print ' selected ';
357
+}
358
+?>>FR</option>
359
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
360
+	print ' selected ';
361
+}
362
+?>>TR</option>
271 363
 				</select>
272 364
 			</p>
273 365
 		</fieldset>
@@ -276,15 +368,24 @@  discard block
 block discarded – undo
276 368
 			<p><i>Only put in DB flights that are inside a circle</i></p>
277 369
 			<p>
278 370
 				<label for="latitude">Center latitude</label>
279
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
371
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
372
+	echo $globalDistanceIgnore['latitude'];
373
+}
374
+?>" />
280 375
 			</p>
281 376
 			<p>
282 377
 				<label for="longitude">Center longitude</label>
283
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
378
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
379
+	echo $globalDistanceIgnore['longitude'];
380
+}
381
+?>" />
284 382
 			</p>
285 383
 			<p>
286 384
 				<label for="Distance">Distance (in km)</label>
287
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
385
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
386
+	echo $globalDistanceIgnore['distance'];
387
+}
388
+?>" />
288 389
 			</p>
289 390
 		</fieldset>
290 391
 		<fieldset id="sourceloc">
@@ -379,11 +480,17 @@  discard block
 block discarded – undo
379 480
 			<div id="flightaware_data">
380 481
 				<p>
381 482
 					<label for="flightawareusername">FlightAware username</label>
382
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
483
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
484
+	print $globalFlightAwareUsername;
485
+}
486
+?>" />
383 487
 				</p>
384 488
 				<p>
385 489
 					<label for="flightawarepassword">FlightAware password/API key</label>
386
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
490
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
491
+	print $globalFlightAwarePassword;
492
+}
493
+?>" />
387 494
 				</p>
388 495
 			</div>
389 496
 -->
@@ -442,25 +549,76 @@  discard block
 block discarded – undo
442 549
 								?>
443 550
 								<td>
444 551
 									<select name="format[]" id="format">
445
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
446
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
447
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
448
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
449
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
450
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
451
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
452
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server</option>
453
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
454
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
455
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
456
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
457
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
458
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
459
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS over SBS-3 TCP</option>
552
+										<option value="auto" <?php if (!isset($source['format'])) {
553
+	print 'selected';
554
+}
555
+?>>Auto</option>
556
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
557
+	print 'selected';
558
+}
559
+?>>SBS</option>
560
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
561
+	print 'selected';
562
+}
563
+?>>TSV</option>
564
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
565
+	print 'selected';
566
+}
567
+?>>Raw</option>
568
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
569
+	print 'selected';
570
+}
571
+?>>APRS</option>
572
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
573
+	print 'selected';
574
+}
575
+?>>Radarcape deltadb.txt</option>
576
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
577
+	print 'selected';
578
+}
579
+?>>Vatsim</option>
580
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
581
+	print 'selected';
582
+}
583
+?>>Virtual Radar Server</option>
584
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
585
+	print 'selected';
586
+}
587
+?>>phpVMS</option>
588
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
589
+	print 'selected';
590
+}
591
+?>>Virtual Airlines Manager</option>
592
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
593
+	print 'selected';
594
+}
595
+?>>IVAO</option>
596
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
597
+	print 'selected';
598
+}
599
+?>>FlightGear Multiplayer</option>
600
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
601
+	print 'selected';
602
+}
603
+?>>FlightGear Singleplayer</option>
604
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
605
+	print 'selected';
606
+}
607
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
608
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
609
+	print 'selected';
610
+}
611
+?>>ACARS over SBS-3 TCP</option>
460 612
 									</select>
461 613
 								</td>
462
-								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /></td>
463
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
614
+								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
615
+	print $source['name'];
616
+}
617
+?>" /></td>
618
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
619
+	print 'checked';
620
+}
621
+?> /></td>
464 622
 								<td><input type="button" id="delhost" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhost" value="Add" onclick="insRow()" /></td>
465 623
 							</tr>
466 624
 <?php
@@ -506,11 +664,17 @@  discard block
 block discarded – undo
506 664
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
507 665
 					<p>
508 666
 						<label for="acarshost">ACARS UDP host</label>
509
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
667
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
668
+	print $globalACARSHost;
669
+}
670
+?>" />
510 671
 					</p>
511 672
 					<p>
512 673
 						<label for="acarsport">ACARS UDP port</label>
513
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
674
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
675
+	print $globalACARSPort;
676
+}
677
+?>" />
514 678
 					</p>
515 679
 				</fieldset>
516 680
 			</div>
@@ -585,13 +749,19 @@  discard block
 block discarded – undo
585 749
 			<div id="schedules_options">
586 750
 				<p>
587 751
 					<label for="britishairways">British Airways API Key</label>
588
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
752
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
753
+	print $globalBritishAirwaysKey;
754
+}
755
+?>" />
589 756
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
590 757
 				</p>
591 758
 				<!--
592 759
 				<p>
593 760
 					<label for="transavia">Transavia Test API Consumer Key</label>
594
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
761
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
762
+	print $globalTransaviaKey;
763
+}
764
+?>" />
595 765
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
596 766
 				</p>
597 767
 				-->
@@ -600,10 +770,16 @@  discard block
 block discarded – undo
600 770
 						<b>Lufthansa API Key</b>
601 771
 						<p>
602 772
 							<label for="lufthansakey">Key</label>
603
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
773
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
774
+	print $globalLufthansaKey['key'];
775
+}
776
+?>" />
604 777
 						</p><p>
605 778
 							<label for="lufthansasecret">Secret</label>
606
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
779
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
780
+	print $globalLufthansaKey['secret'];
781
+}
782
+?>" />
607 783
 						</p>
608 784
 					</div>
609 785
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -623,7 +799,10 @@  discard block
 block discarded – undo
623 799
 			</p>
624 800
 			<p>
625 801
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
626
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
802
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
803
+	print $globalNOTAMSource;
804
+}
805
+?>" />
627 806
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
628 807
 			</p>
629 808
 			<br />
@@ -639,14 +818,20 @@  discard block
 block discarded – undo
639 818
 			<div id="metarsrc">
640 819
 				<p>
641 820
 					<label for="metarsource">URL of your METAR source</label>
642
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
821
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
822
+	print $globalMETARurl;
823
+}
824
+?>" />
643 825
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
644 826
 				</p>
645 827
 			</div>
646 828
 			<br />
647 829
 			<p>
648 830
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
649
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
831
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
832
+	print $globalBitlyAccessToken;
833
+}
834
+?>" />
650 835
 			</p>
651 836
 			<br />
652 837
 			<p>
@@ -660,7 +845,12 @@  discard block
 block discarded – undo
660 845
 			</p>
661 846
 			<p>
662 847
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
663
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" />
848
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
849
+	print $globalArchiveMonths;
850
+} else {
851
+	echo '0';
852
+}
853
+?>" />
664 854
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
665 855
 			</p>
666 856
 			<p>
@@ -670,12 +860,22 @@  discard block
 block discarded – undo
670 860
 			</p>
671 861
 			<p>
672 862
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
673
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" />
863
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
864
+	print $globalArchiveKeepMonths;
865
+} else {
866
+	echo '0';
867
+}
868
+?>" />
674 869
 				<p class="help-block">0 to disable</p>
675 870
 			</p>
676 871
 			<p>
677 872
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
678
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" />
873
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
874
+	print $globalArchiveKeepTrackMonths;
875
+} else {
876
+	echo '0';
877
+}
878
+?>" />
679 879
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
680 880
 			</p>
681 881
 			<br />
@@ -685,7 +885,12 @@  discard block
 block discarded – undo
685 885
 				<p class="help-block">Uncheck if the script is running as cron job</p>
686 886
 				<div id="cronends"> 
687 887
 					<label for="cronend">Run script for xx seconds</label>
688
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
888
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
889
+	print $globalCronEnd;
890
+} else {
891
+	print '0';
892
+}
893
+?>" />
689 894
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
690 895
 				</div>
691 896
 			</p>
@@ -725,26 +930,49 @@  discard block
 block discarded – undo
725 930
 			<br />
726 931
 			<p>
727 932
 				<label for="refresh">Show flights detected since xxx seconds</label>
728
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
933
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
934
+	echo $globalLiveInterval;
935
+} else {
936
+	echo '200';
937
+}
938
+?>" />
729 939
 			</p>
730 940
 			<p>
731 941
 				<label for="maprefresh">Live map refresh (in seconds)</label>
732
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
942
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
943
+	echo $globalMapRefresh;
944
+} else {
945
+	echo '30';
946
+}
947
+?>" />
733 948
 			</p>
734 949
 			<p>
735 950
 				<label for="mapidle">Map idle timeout (in minutes)</label>
736
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
951
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
952
+	echo $globalMapIdleTimeout;
953
+} else {
954
+	echo '30';
955
+}
956
+?>" />
737 957
 				<p class="help-block">0 to disable</p>
738 958
 			</p>
739 959
 			<br />
740 960
 			<p>
741 961
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
742
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
962
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
963
+	echo $globalClosestMinDist;
964
+} else {
965
+	echo '50';
966
+}
967
+?>" />
743 968
 			</p>
744 969
 			<br />
745 970
 			<p>
746 971
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
747
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
972
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
973
+	echo $globalAircraftSize;
974
+}
975
+?>" />
748 976
 			</p>
749 977
 			<br />
750 978
 			<p>
@@ -752,7 +980,12 @@  discard block
 block discarded – undo
752 980
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
753 981
 			?>
754 982
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
755
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
983
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
984
+	echo $globalAircraftIconColor;
985
+} else {
986
+	echo '1a3151';
987
+}
988
+?>" />
756 989
 			<?php
757 990
 				if (!is_writable('../cache')) {
758 991
 			?>
@@ -770,8 +1003,18 @@  discard block
 block discarded – undo
770 1003
 			<p>
771 1004
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
772 1005
 				<div class="range">
773
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
774
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1006
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1007
+	echo $globalAirportZoom;
1008
+} else {
1009
+	echo '7';
1010
+}
1011
+?>" />
1012
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1013
+	echo $globalAirportZoom;
1014
+} else {
1015
+	echo '7';
1016
+}
1017
+?></output>
775 1018
 				</div>
776 1019
 			</p>
777 1020
 		</fieldset>
@@ -799,8 +1042,12 @@  discard block
 block discarded – undo
799 1042
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
800 1043
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
801 1044
 
802
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
803
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1045
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1046
+		$error .= 'Mysql driver for PDO must be loaded';
1047
+	}
1048
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1049
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1050
+	}
804 1051
 	
805 1052
 	$_SESSION['database_root'] = $dbroot;
806 1053
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -867,15 +1114,23 @@  discard block
 block discarded – undo
867 1114
 	$source_city = $_POST['source_city'];
868 1115
 	$source_country = $_POST['source_country'];
869 1116
 	$source_ref = $_POST['source_ref'];
870
-	if (isset($source_id)) $source_id = $_POST['source_id'];
871
-	else $source_id = array();
1117
+	if (isset($source_id)) {
1118
+		$source_id = $_POST['source_id'];
1119
+	} else {
1120
+		$source_id = array();
1121
+	}
872 1122
 	
873 1123
 	$sources = array();
874 1124
 	foreach ($source_name as $keys => $name) {
875
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
876
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1125
+	    if (isset($source_id[$keys])) {
1126
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1127
+	    } else {
1128
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1129
+	    }
1130
+	}
1131
+	if (count($sources) > 0) {
1132
+		$_SESSION['sources'] = $sources;
877 1133
 	}
878
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
879 1134
 
880 1135
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
881 1136
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -913,13 +1168,21 @@  discard block
 block discarded – undo
913 1168
 	$port = $_POST['port'];
914 1169
 	$name = $_POST['name'];
915 1170
 	$format = $_POST['format'];
916
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
917
-	else $sourcestats = array();
1171
+	if (isset($_POST['sourcestats'])) {
1172
+		$sourcestats = $_POST['sourcestats'];
1173
+	} else {
1174
+		$sourcestats = array();
1175
+	}
918 1176
 	$gSources = array();
919 1177
 	foreach ($host as $key => $h) {
920
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
921
-		else $cov = 'FALSE';
922
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1178
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1179
+			$cov = 'TRUE';
1180
+		} else {
1181
+			$cov = 'FALSE';
1182
+		}
1183
+		if ($h != '') {
1184
+			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1185
+		}
923 1186
 	}
924 1187
 	$settings = array_merge($settings,array('globalSources' => $gSources));
925 1188
 
@@ -943,7 +1206,9 @@  discard block
 block discarded – undo
943 1206
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
944 1207
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
945 1208
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
946
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1209
+	} else {
1210
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1211
+	}
947 1212
 
948 1213
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
949 1214
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -982,7 +1247,9 @@  discard block
 block discarded – undo
982 1247
 
983 1248
 	// Create in settings.php keys not yet configurable if not already here
984 1249
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
985
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1250
+	if (!isset($globalDebug)) {
1251
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1252
+	}
986 1253
 
987 1254
 	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
988 1255
 	if ($archive == 'archive') {
@@ -1012,27 +1279,43 @@  discard block
 block discarded – undo
1012 1279
 	}
1013 1280
 */
1014 1281
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1015
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1016
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1017
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1018
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1282
+	if ($globalsbs == 'sbs') {
1283
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1284
+	} else {
1285
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1286
+	}
1287
+	if ($globalaprs == 'aprs') {
1288
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1289
+	} else {
1290
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1291
+	}
1019 1292
 	if ($globalivao == 'ivao') {
1020 1293
 		//$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE'));
1021 1294
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1022
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1295
+	} else {
1296
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1297
+	}
1023 1298
 	if ($globalvatsim == 'vatsim') {
1024 1299
 		//$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE'));
1025 1300
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1026
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1301
+	} else {
1302
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1303
+	}
1027 1304
 	if ($globalphpvms == 'phpvms') {
1028 1305
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1029
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1306
+	} else {
1307
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1308
+	}
1030 1309
 	if ($globalvam == 'vam') {
1031 1310
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1032
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1311
+	} else {
1312
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1313
+	}
1033 1314
 	if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') {
1034 1315
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1035
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1316
+	} else {
1317
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1318
+	}
1036 1319
 	
1037 1320
 
1038 1321
 
@@ -1156,7 +1439,9 @@  discard block
 block discarded – undo
1156 1439
 		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1157 1440
 	}
1158 1441
 
1159
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1442
+	if (!isset($globalTransaction)) {
1443
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1444
+	}
1160 1445
 
1161 1446
 	// Set some defaults values...
1162 1447
 	if (!isset($globalAircraftImageSources)) {
@@ -1171,15 +1456,23 @@  discard block
 block discarded – undo
1171 1456
 
1172 1457
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1173 1458
 
1174
-	if ($error == '') settings::modify_settings($settings);
1175
-	if ($error == '') settings::comment_settings($settings_comment);
1459
+	if ($error == '') {
1460
+		settings::modify_settings($settings);
1461
+	}
1462
+	if ($error == '') {
1463
+		settings::comment_settings($settings_comment);
1464
+	}
1176 1465
 	if ($error != '') {
1177 1466
 		print '<div class="info column">'.$error.'</div>';
1178 1467
 		require('../footer.php');
1179 1468
 		exit;
1180 1469
 	} else {
1181
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1182
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1470
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1471
+			$_SESSION['waypoints'] = 1;
1472
+		}
1473
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1474
+			$_SESSION['owner'] = 1;
1475
+		}
1183 1476
 		if (isset($_POST['createdb'])) {
1184 1477
 			$_SESSION['install'] = 'database_create';
1185 1478
 		} else {
@@ -1220,10 +1513,18 @@  discard block
 block discarded – undo
1220 1513
 	$popw = false;
1221 1514
 	foreach ($_SESSION['done'] as $done) {
1222 1515
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1223
-	    if ($done == 'Create database') $pop = true;
1224
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1225
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1226
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1516
+	    if ($done == 'Create database') {
1517
+	    	$pop = true;
1518
+	    }
1519
+	    if ($_SESSION['install'] == 'database_create') {
1520
+	    	$pop = true;
1521
+	    }
1522
+	    if ($_SESSION['install'] == 'database_import') {
1523
+	    	$popi = true;
1524
+	    }
1525
+	    if ($_SESSION['install'] == 'waypoints') {
1526
+	    	$popw = true;
1527
+	    }
1227 1528
 	}
1228 1529
 	if ($pop) {
1229 1530
 	    sleep(5);
@@ -1234,7 +1535,9 @@  discard block
 block discarded – undo
1234 1535
 	} else if ($popw) {
1235 1536
 	    sleep(5);
1236 1537
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1237
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1538
+	} else {
1539
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1540
+	}
1238 1541
 	print '</div></ul>';
1239 1542
 	print '<div id="error"></div>';
1240 1543
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
Spacing   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.create_db.php');
10 10
 require_once(dirname(__FILE__).'/class.update_schema.php');
11 11
 require_once(dirname(__FILE__).'/class.settings.php');
12
-$title="Install";
12
+$title = "Install";
13 13
 require(dirname(__FILE__).'/../require/settings.php');
14 14
 require(dirname(__FILE__).'/header.php');
15 15
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 if (!extension_loaded('curl')) {
64 64
 	$error[] = "Curl is not loaded.";
65 65
 }
66
-if(function_exists('apache_get_modules') ){
67
-	if(!in_array('mod_rewrite',apache_get_modules())) {
66
+if (function_exists('apache_get_modules')) {
67
+	if (!in_array('mod_rewrite', apache_get_modules())) {
68 68
 		$error[] = "mod_rewrite is not available.";
69 69
 	}
70 70
 /*
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 }
80 80
 if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
81 81
 	if (function_exists('get_headers')) {
82
-		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"])));
83
-		if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
82
+		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/', 'search', str_replace('index.php', $_SERVER["REQUEST_URI"])));
83
+		if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
84 84
 			print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>';
85 85
 		}
86 86
 	}
@@ -420,13 +420,13 @@  discard block
 block discarded – undo
420 420
 ?>
421 421
 							<tr>
422 422
 								<?php
423
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
423
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
424 424
 								?>
425 425
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
426 426
 								<td><input type="number" name="port[]" id="port" value="<?php print $source['port']; ?>" /></td>
427 427
 								<?php
428 428
 								    } else {
429
-									$hostport = explode(':',$source['host']);
429
+									$hostport = explode(':', $source['host']);
430 430
 									if (isset($hostport[1])) {
431 431
 										$host = $hostport[0];
432 432
 										$port = $hostport[1];
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 			<br />
745 745
 			<p>
746 746
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
747
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
747
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
748 748
 			</p>
749 749
 			<br />
750 750
 			<p>
@@ -790,14 +790,14 @@  discard block
 block discarded – undo
790 790
 $error = '';
791 791
 
792 792
 if (isset($_POST['dbtype'])) {
793
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
794
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
795
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
796
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
797
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
798
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
799
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
800
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
793
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
794
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
795
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
796
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
797
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
798
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
799
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
800
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
801 801
 
802 802
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
803 803
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -817,48 +817,48 @@  discard block
 block discarded – undo
817 817
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
818 818
 	*/
819 819
 	
820
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
820
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
821 821
 
822
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
823
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
824
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
825
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
826
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
822
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
823
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
824
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
825
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
826
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
827 827
 
828
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
829
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
830
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
831
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
832
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
833
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
834
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
835
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
836
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey));
828
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
829
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
830
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
831
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
832
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
833
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
834
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
835
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
836
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey));
837 837
 	
838
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
839
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
840
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
841
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
842
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
843
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
838
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
839
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
840
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
841
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
842
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
843
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
844 844
 
845
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
846
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
845
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
846
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
847 847
 
848
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
849
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
850
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
848
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
849
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
850
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
851 851
 
852
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
852
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
853 853
 	if ($acars == 'acars') {
854
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
854
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
855 855
 	} else {
856
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
856
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
857 857
 	}
858 858
 
859
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
860
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
861
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
859
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
860
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
861
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
862 862
 	
863 863
 	$source_name = $_POST['source_name'];
864 864
 	$source_latitude = $_POST['source_latitude'];
@@ -872,8 +872,8 @@  discard block
 block discarded – undo
872 872
 	
873 873
 	$sources = array();
874 874
 	foreach ($source_name as $keys => $name) {
875
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
876
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
875
+	    if (isset($source_id[$keys])) $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'id' => $source_id[$keys], 'source' => $source_ref[$keys]);
876
+	    else $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'source' => $source_ref[$keys]);
877 877
 	}
878 878
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
879 879
 
@@ -886,13 +886,13 @@  discard block
 block discarded – undo
886 886
 	$sbsurl = $_POST['sbsurl'];
887 887
 	*/
888 888
 
889
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
890
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
891
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
892
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
893
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
894
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
895
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
889
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
890
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
891
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
892
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
893
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
894
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
895
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
896 896
 
897 897
 /*	
898 898
 	$globalSBS1Hosts = array();
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 	}
909 909
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
910 910
 */
911
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
911
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
912 912
 	$host = $_POST['host'];
913 913
 	$port = $_POST['port'];
914 914
 	$name = $_POST['name'];
@@ -919,89 +919,89 @@  discard block
 block discarded – undo
919 919
 	foreach ($host as $key => $h) {
920 920
 		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
921 921
 		else $cov = 'FALSE';
922
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
922
+		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov);
923 923
 	}
924
-	$settings = array_merge($settings,array('globalSources' => $gSources));
924
+	$settings = array_merge($settings, array('globalSources' => $gSources));
925 925
 
926 926
 /*
927 927
 	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
928 928
 	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
929 929
 */
930
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
931
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
932
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
930
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
931
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
932
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
933 933
 
934
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
935
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
934
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
935
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
936 936
 
937
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
938
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
939
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
940
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
937
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
938
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
939
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
940
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
941 941
 
942
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
943
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
944
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
942
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
943
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
944
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
945 945
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
946
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
947
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
946
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
947
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
948 948
 
949
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
950
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
951
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
952
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
953
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
954
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
955
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
956
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
949
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
950
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
951
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
952
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
953
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
954
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
955
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
956
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
957 957
 
958
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
959
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
958
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
959
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
960 960
 
961
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
962
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
961
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
962
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
963 963
 	
964
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
964
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
965 965
 	if ($archiveyear == "archiveyear") {
966
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
966
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
967 967
 	} else {
968
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
968
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
969 969
 	}
970
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
971
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
972
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
973
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
970
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
971
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
972
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
973
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
974 974
 
975
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
976
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
977
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
978
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
975
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
976
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
977
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
978
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
979 979
 
980
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
981
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
982
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
980
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
981
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
982
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
983 983
 
984 984
 	// Create in settings.php keys not yet configurable if not already here
985 985
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
986
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
986
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
987 987
 
988
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
988
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
989 989
 	if ($archive == 'archive') {
990
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
990
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
991 991
 	} else {
992
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
992
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
993 993
 	}
994
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
994
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
995 995
 	if ($daemon == 'daemon') {
996
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
996
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
997 997
 	} else {
998
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
998
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
999 999
 	}
1000
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1000
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
1001 1001
 	if ($schedules == 'schedules') {
1002
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1002
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
1003 1003
 	} else {
1004
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1004
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
1005 1005
 	}
1006 1006
 
1007 1007
 /*
@@ -1012,165 +1012,165 @@  discard block
 block discarded – undo
1012 1012
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1013 1013
 	}
1014 1014
 */
1015
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1016
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1017
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1018
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1019
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1015
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
1016
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
1017
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1018
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1019
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1020 1020
 	if ($globalivao == 'ivao') {
1021 1021
 		//$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE'));
1022
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1023
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1022
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1023
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1024 1024
 	if ($globalvatsim == 'vatsim') {
1025 1025
 		//$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE'));
1026
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1027
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1026
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1027
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1028 1028
 	if ($globalphpvms == 'phpvms') {
1029
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1030
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1029
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1030
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1031 1031
 	if ($globalvam == 'vam') {
1032
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1033
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1032
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1033
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1034 1034
 	if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') {
1035
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1036
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1035
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1036
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1037 1037
 	
1038 1038
 
1039 1039
 
1040
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1040
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1041 1041
 	if ($notam == 'notam') {
1042
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1042
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1043 1043
 	} else {
1044
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1044
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1045 1045
 	}
1046
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1046
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1047 1047
 	if ($owner == 'owner') {
1048
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1048
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1049 1049
 	} else {
1050
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1050
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1051 1051
 	}
1052
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1052
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1053 1053
 	if ($map3d == 'map3d') {
1054
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1054
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1055 1055
 	} else {
1056
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1056
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1057 1057
 	}
1058
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1058
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1059 1059
 	if ($mapsatellites == 'mapsatellites') {
1060
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1060
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1061 1061
 	} else {
1062
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1062
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1063 1063
 	}
1064
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1064
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1065 1065
 	if ($map3ddefault == 'map3ddefault') {
1066
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1066
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1067 1067
 	} else {
1068
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1068
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1069 1069
 	}
1070
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1070
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1071 1071
 	if ($translate == 'translate') {
1072
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1072
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1073 1073
 	} else {
1074
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1074
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1075 1075
 	}
1076
-	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1076
+	$realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING);
1077 1077
 	if ($realairlines == 'realairlines') {
1078
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1078
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE'));
1079 1079
 	} else {
1080
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1080
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE'));
1081 1081
 	}
1082
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1082
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1083 1083
 	if ($estimation == 'estimation') {
1084
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1084
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1085 1085
 	} else {
1086
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1086
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1087 1087
 	}
1088
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1088
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1089 1089
 	if ($metar == 'metar') {
1090
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1090
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1091 1091
 	} else {
1092
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1092
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1093 1093
 	}
1094
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1094
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1095 1095
 	if ($metarcycle == 'metarcycle') {
1096
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1096
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1097 1097
 	} else {
1098
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1098
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1099 1099
 	}
1100
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1100
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1101 1101
 	if ($fork == 'fork') {
1102
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1102
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1103 1103
 	} else {
1104
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1104
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1105 1105
 	}
1106 1106
 
1107
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1107
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1108 1108
 	if ($colormap == 'colormap') {
1109
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1109
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1110 1110
 	} else {
1111
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1111
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1112 1112
 	}
1113 1113
 	
1114 1114
 	if (isset($_POST['aircrafticoncolor'])) {
1115
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1116
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1115
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1116
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1117 1117
 	}
1118 1118
 
1119
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1120
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1119
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1120
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1121 1121
 
1122
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1123
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1124
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1125
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1126
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1127
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1122
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1123
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1124
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1125
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1126
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1127
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1128 1128
 
1129
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1129
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1130 1130
 	if ($mappopup == 'mappopup') {
1131
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1131
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1132 1132
 	} else {
1133
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1133
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1134 1134
 	}
1135
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1135
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1136 1136
 	if ($airportpopup == 'airportpopup') {
1137
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1137
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1138 1138
 	} else {
1139
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1139
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1140 1140
 	}
1141
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1141
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1142 1142
 	if ($maphistory == 'maphistory') {
1143
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1143
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1144 1144
 	} else {
1145
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1145
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1146 1146
 	}
1147
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1147
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1148 1148
 	if ($flightroute == 'flightroute') {
1149
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1149
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1150 1150
 	} else {
1151
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1151
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1152 1152
 	}
1153
-	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1153
+	$waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING);
1154 1154
 	if ($waypoints == 'waypoints') {
1155
-		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1155
+		$settings = array_merge($settings, array('globalWaypoints' => 'TRUE'));
1156 1156
 	} else {
1157
-		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1157
+		$settings = array_merge($settings, array('globalWaypoints' => 'FALSE'));
1158 1158
 	}
1159 1159
 
1160
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1160
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1161 1161
 
1162 1162
 	// Set some defaults values...
1163 1163
 	if (!isset($globalAircraftImageSources)) {
1164
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1165
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1164
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1165
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1166 1166
 	}
1167 1167
 
1168 1168
 	if (!isset($globalSchedulesSources)) {
1169
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1170
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1169
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1170
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1171 1171
     	}
1172 1172
 
1173
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1173
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1174 1174
 
1175 1175
 	if ($error == '') settings::modify_settings($settings);
1176 1176
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this patch.
require/class.ACARS.php 3 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
 		$this->SI = new SpotterImport($this->db);
17 17
 	}
18 18
 	/**
19
-	* Change IATA to ICAO value for ident
20
-	*
21
-	* @param String $ident ident
22
-	* @return String the icao
23
-	*/
19
+	 * Change IATA to ICAO value for ident
20
+	 *
21
+	 * @param String $ident ident
22
+	 * @return String the icao
23
+	 */
24 24
 	public function ident2icao($ident) {
25 25
 		if (substr($ident,0,2) == 'AF') {
26 26
 			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 	}
37 37
 
38 38
 	/**
39
-	* Deletes all info in the live table
40
-	*
41
-	* @return String success or false
42
-	*
43
-	*/
39
+	 * Deletes all info in the live table
40
+	 *
41
+	 * @return String success or false
42
+	 *
43
+	 */
44 44
 	public function deleteLiveAcarsData()
45 45
 	{
46 46
 		global $globalDBdriver;
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 	}
61 61
 
62 62
 	/**
63
-	* Deletes all info in the archive table
64
-	*
65
-	* @return String success or false
66
-	*
67
-	*/
63
+	 * Deletes all info in the archive table
64
+	 *
65
+	 * @return String success or false
66
+	 *
67
+	 */
68 68
 	public function deleteArchiveAcarsData()
69 69
 	{
70 70
 		global $globalACARSArchiveKeepMonths, $globalDBdriver;
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 
86 86
 
87 87
 	/**
88
-	* Parse ACARS data
89
-	*
90
-	* @param String ACARS data in acarsdec data
91
-	*
92
-	*/
88
+	 * Parse ACARS data
89
+	 *
90
+	 * @param String ACARS data in acarsdec data
91
+	 *
92
+	 */
93 93
 	public function parse($data) {
94 94
 		global $globalDebug, $globalACARSArchive;
95 95
 		//$Image = new Image($this->db);
@@ -666,11 +666,11 @@  discard block
 block discarded – undo
666 666
 
667 667
 
668 668
 	/**
669
-	* Add ACARS data
670
-	*
671
-	* @param String ACARS data in acarsdec data
672
-	*
673
-	*/
669
+	 * Add ACARS data
670
+	 *
671
+	 * @param String ACARS data in acarsdec data
672
+	 *
673
+	 */
674 674
 	function add($data) {
675 675
 		global $globalDebug, $globalACARSArchive;
676 676
 		$Image = new Image($this->db);
@@ -725,15 +725,15 @@  discard block
 block discarded – undo
725 725
 	}
726 726
 
727 727
 	/**
728
-	* Add Live ACARS data in DB
729
-	*
730
-	* @param String $ident ident
731
-	* @param String $registration Registration of the aircraft
732
-	* @param String $label Label of the ACARS message
733
-	* @param String $block_id Block id of the ACARS message
734
-	* @param String $msg_no Number of the ACARS message
735
-	* @param String $message ACARS message
736
-	*/
728
+	 * Add Live ACARS data in DB
729
+	 *
730
+	 * @param String $ident ident
731
+	 * @param String $registration Registration of the aircraft
732
+	 * @param String $label Label of the ACARS message
733
+	 * @param String $block_id Block id of the ACARS message
734
+	 * @param String $msg_no Number of the ACARS message
735
+	 * @param String $message ACARS message
736
+	 */
737 737
 	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
738 738
 		global $globalDebug;
739 739
 		date_default_timezone_set('UTC');
@@ -771,15 +771,15 @@  discard block
 block discarded – undo
771 771
 	}
772 772
 
773 773
 	/**
774
-	* Add Archive ACARS data in DB
775
-	*
776
-	* @param String $ident ident
777
-	* @param String $registration Registration of the aircraft
778
-	* @param String $label Label of the ACARS message
779
-	* @param String $block_id Block id of the ACARS message
780
-	* @param String $msg_no Number of the ACARS message
781
-	* @param String $message ACARS message
782
-	*/
774
+	 * Add Archive ACARS data in DB
775
+	 *
776
+	 * @param String $ident ident
777
+	 * @param String $registration Registration of the aircraft
778
+	 * @param String $label Label of the ACARS message
779
+	 * @param String $block_id Block id of the ACARS message
780
+	 * @param String $msg_no Number of the ACARS message
781
+	 * @param String $message ACARS message
782
+	 */
783 783
 	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
784 784
 		global $globalDebug;
785 785
 		date_default_timezone_set('UTC');
@@ -813,11 +813,11 @@  discard block
 block discarded – undo
813 813
 	}
814 814
 
815 815
 	/**
816
-	* Get Message title from label from DB
817
-	*
818
-	* @param String $label
819
-	* @return String Return ACARS title
820
-	*/
816
+	 * Get Message title from label from DB
817
+	 *
818
+	 * @param String $label
819
+	 * @return String Return ACARS title
820
+	 */
821 821
 	public function getTitlefromLabel($label) {
822 822
 		$Connection = new Connection($this->db);
823 823
 		$this->db = $Connection->db;
@@ -837,10 +837,10 @@  discard block
 block discarded – undo
837 837
 	}
838 838
 
839 839
 	/**
840
-	* List all Message title & label from DB
841
-	*
842
-	* @return Array Return ACARS data in array
843
-	*/
840
+	 * List all Message title & label from DB
841
+	 *
842
+	 * @return Array Return ACARS data in array
843
+	 */
844 844
 	public function getAllTitleLabel() {
845 845
 		$query = "SELECT * FROM acars_label ORDER BY title";
846 846
 		$query_values = array();
@@ -858,11 +858,11 @@  discard block
 block discarded – undo
858 858
 	}
859 859
 
860 860
 	/**
861
-	* Get Live ACARS data from DB
862
-	*
863
-	* @param String $ident
864
-	* @return Array Return ACARS data in array
865
-	*/
861
+	 * Get Live ACARS data from DB
862
+	 *
863
+	 * @param String $ident
864
+	 * @return Array Return ACARS data in array
865
+	 */
866 866
 	public function getLiveAcarsData($ident) {
867 867
 		$query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC";
868 868
 		$query_values = array(':ident' => $ident);
@@ -880,10 +880,10 @@  discard block
 block discarded – undo
880 880
 	}
881 881
 
882 882
 	/**
883
-	* Get Latest ACARS data from DB
884
-	*
885
-	* @return Array Return ACARS data in array
886
-	*/
883
+	 * Get Latest ACARS data from DB
884
+	 *
885
+	 * @return Array Return ACARS data in array
886
+	 */
887 887
 	public function getLatestAcarsData($limit = '',$label = '') {
888 888
 		global $globalURL, $globalDBdriver;
889 889
 		$Image = new Image($this->db);
@@ -980,10 +980,10 @@  discard block
 block discarded – undo
980 980
 	}
981 981
 
982 982
 	/**
983
-	* Get Archive ACARS data from DB
984
-	*
985
-	* @return Array Return ACARS data in array
986
-	*/
983
+	 * Get Archive ACARS data from DB
984
+	 *
985
+	 * @return Array Return ACARS data in array
986
+	 */
987 987
 	public function getArchiveAcarsData($limit = '',$label = '') {
988 988
 		global $globalURL, $globalDBdriver;
989 989
 		$Image = new Image($this->db);
@@ -1085,13 +1085,13 @@  discard block
 block discarded – undo
1085 1085
 	}
1086 1086
 
1087 1087
 	/**
1088
-	* Add ModeS data to DB
1089
-	*
1090
-	* @param String $ident ident
1091
-	* @param String $registration Registration of the aircraft
1092
-	* @param String $icao
1093
-	* @param String $ICAOTypeCode
1094
-	*/
1088
+	 * Add ModeS data to DB
1089
+	 *
1090
+	 * @param String $ident ident
1091
+	 * @param String $registration Registration of the aircraft
1092
+	 * @param String $icao
1093
+	 * @param String $ICAOTypeCode
1094
+	 */
1095 1095
 	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1096 1096
 		global $globalDebug, $globalDBdriver;
1097 1097
 		$ident = trim($ident);
Please login to merge, or discard this patch.
Spacing   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 	* @return String the icao
23 23
 	*/
24 24
 	public function ident2icao($ident) {
25
-		if (substr($ident,0,2) == 'AF') {
26
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
25
+		if (substr($ident, 0, 2) == 'AF') {
26
+			if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
+			else $icao = 'AFR'.ltrim(substr($ident, 2), '0');
28 28
 		} else {
29 29
 			$Spotter = new Spotter($this->db);
30
-			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
30
+			$identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2));
31 31
 			if (isset($identicao[0])) {
32
-				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
32
+				$icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0');
33 33
 			} else $icao = $ident;
34 34
 		}
35 35
 		return $icao;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
 			$sth = $this->db->prepare($query);
55 55
 			$sth->execute();
56
-		} catch(PDOException $e) {
56
+		} catch (PDOException $e) {
57 57
 			return "error";
58 58
 		}
59 59
 		return "success";
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 			$sth = $this->db->prepare($query);
79 79
 			$sth->execute();
80
-		} catch(PDOException $e) {
80
+		} catch (PDOException $e) {
81 81
 			return "error";
82 82
 		}
83 83
 		return "success";
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
 		$ident = '';
103 103
 		$message = '';
104 104
 		$result = array();
105
-		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
106
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
107
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
108
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
105
+		$n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
106
+		if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
107
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
108
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
109 109
 		if ($n != 0) {
110
-			$registration = str_replace('.','',$registration);
111
-			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
110
+			$registration = str_replace('.', '', $registration);
111
+			$result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message);
112 112
 			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
113 113
 		} else $message = $data;
114 114
 		$decode = array();
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 				$temp = '';
129 129
 				$n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp);
130 130
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
131
-					$latitude = $la / 10000.0;
132
-					$longitude = $ln / 10000.0;
131
+					$latitude = $la/10000.0;
132
+					$longitude = $ln/10000.0;
133 133
 					if ($lac == 'S') $latitude = '-'.$latitude;
134 134
 					if ($lnc == 'W') $longitude = '-'.$longitude;
135 135
 					// Temp not always available
136 136
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
137
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
138
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
137
+					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt);
138
+					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C');
139 139
 
140 140
 					//$icao = $Translation->checkTranslation($ident);
141 141
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -147,19 +147,19 @@  discard block
 block discarded – undo
147 147
 				$dhour = '';
148 148
 				$darr = '';
149 149
 				$ahour = '';
150
-				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
150
+				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour);
151 151
 				if ($n == 4 && strlen($darr) == 4) {
152
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
153
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
154
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
152
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
153
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
154
+					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n";
155 155
 					//$icao = ACARS->ident2icao($ident);
156 156
 					//$icao = $Translation->checkTranslation($ident);
157 157
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
158 158
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
159 159
 					$found = true;
160 160
 				}
161
-				elseif ($n == 2 || $n  == 4) {
162
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
161
+				elseif ($n == 2 || $n == 4) {
162
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
163 163
 					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
164 164
 					//$icao = ACARS->ident2icao($ident);
165 165
 					//$icao = $Translation->checkTranslation($ident);
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
 				$ahour = '';
218 218
 				$aair = '';
219 219
 				$apiste = '';
220
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
220
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste);
221 221
 				if ($n > 8) {
222
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
223
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
224
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
222
+					if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
223
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
224
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
225 225
 					$icao = trim($aident);
226 226
 
227 227
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 				if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
247 247
 					$las = $las.'.'.$lass;
248 248
 					$lns = $lns.'.'.$lns;
249
-					$latitude = $las / 1000.0;
250
-					$longitude = $lns / 1000.0;
249
+					$latitude = $las/1000.0;
250
+					$longitude = $lns/1000.0;
251 251
 					if ($lac == 'S') $latitude = '-'.$latitude;
252 252
 					if ($lnc == 'W') $longitude = '-'.$longitude;
253 253
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
@@ -342,17 +342,17 @@  discard block
 block discarded – undo
342 342
 				$alt = '';
343 343
 				$fuel = '';
344 344
 				$speed = '';
345
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
345
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
346 346
 				if ($n == 9) {
347 347
 					//if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
348 348
 					$icao = trim($aident);
349 349
 					$decode['icao'] = $icao;
350
-					$latitude = $las / 100.0;
351
-					$longitude = $lns / 100.0;
350
+					$latitude = $las/100.0;
351
+					$longitude = $lns/100.0;
352 352
 					if ($lac == 'S') $latitude = '-'.$latitude;
353 353
 					if ($lnc == 'W') $longitude = '-'.$longitude;
354 354
 
355
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
355
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed);
356 356
 					$found = true;
357 357
 				}
358 358
 			}
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 					if ($lac == 'S') $latitude = '-'.$latitude;
372 372
 					if ($lnc == 'W') $longitude = '-'.$longitude;
373 373
 
374
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
374
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
375 375
 					$found = true;
376 376
 				}
377 377
 			}
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 				$dair = '';
405 405
 				$darr = '';
406 406
 				$aident = '';
407
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
407
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
408 408
 				if ($n == 8) {
409 409
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
410 410
 					$icao = trim($aident);
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 				*/
438 438
 				$dair = '';
439 439
 				$darr = '';
440
-				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
440
+				$n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr);
441 441
 				if ($n == 3) {
442 442
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
443 443
 					//$icao = $Translation->checkTranslation($ident);
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 				*/
454 454
 				$dair = '';
455 455
 				$darr = '';
456
-				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
456
+				$n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr);
457 457
 				if ($n == 3) {
458 458
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
459 459
 					//$icao = $Translation->checkTranslation($ident);
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 				}
465 465
 			}
466 466
 			if (!$found) {
467
-				$n = sscanf($message,'MET01%4c',$airport);
467
+				$n = sscanf($message, 'MET01%4c', $airport);
468 468
 				if ($n == 1) {
469 469
 					if ($globalDebug) echo 'airport name : '.$airport;
470 470
 					$decode = array('Airport/Waypoint name' => $airport);
@@ -473,241 +473,241 @@  discard block
 block discarded – undo
473 473
 			}
474 474
 
475 475
 			if ($label == 'H1') {
476
-				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
477
-					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
476
+				if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) {
477
+					$decode = array_merge(array('Message nature' => 'Equipment failure'), $decode);
478 478
 				}
479
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
480
-					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
479
+				elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) {
480
+					$decode = array_merge(array('Message nature' => 'Take off performance data'), $decode);
481 481
 				}
482
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
483
-					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
482
+				elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) {
483
+					$decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode);
484 484
 				}
485
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
486
-					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
485
+				elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) {
486
+					$decode = array_merge(array('Message nature' => 'Weather observation'), $decode);
487 487
 				}
488
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
489
-					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
488
+				elseif (preg_match(':^#DFB/PIREP:', $message)) {
489
+					$decode = array_merge(array('Message nature' => 'Pilot Report'), $decode);
490 490
 				}
491
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
492
-					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
491
+				elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) {
492
+					$decode = array_merge(array('Message nature' => 'Engine Data'), $decode);
493 493
 				}
494
-				elseif (preg_match(':^#M1AAEP:',$message)) {
495
-					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
494
+				elseif (preg_match(':^#M1AAEP:', $message)) {
495
+					$decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode);
496 496
 				}
497
-				elseif (preg_match(':^#M2APWD:',$message)) {
498
-					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
497
+				elseif (preg_match(':^#M2APWD:', $message)) {
498
+					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode);
499 499
 				}
500
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
501
-					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
500
+				elseif (preg_match(':^#M1BREQPWI:', $message)) {
501
+					$decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode);
502 502
 				}
503
-				elseif (preg_match(':^#CF:',$message)) {
504
-					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
503
+				elseif (preg_match(':^#CF:', $message)) {
504
+					$decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode);
505 505
 				}
506
-				elseif (preg_match(':^#DF:',$message)) {
507
-					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
506
+				elseif (preg_match(':^#DF:', $message)) {
507
+					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode);
508 508
 				}
509
-				elseif (preg_match(':^#EC:',$message)) {
510
-					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
509
+				elseif (preg_match(':^#EC:', $message)) {
510
+					$decode = array_merge(array('Message nature' => 'Engine Display System'), $decode);
511 511
 				}
512
-				elseif (preg_match(':^#EI:',$message)) {
513
-					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
512
+				elseif (preg_match(':^#EI:', $message)) {
513
+					$decode = array_merge(array('Message nature' => 'Engine Report'), $decode);
514 514
 				}
515
-				elseif (preg_match(':^#H1:',$message)) {
516
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
515
+				elseif (preg_match(':^#H1:', $message)) {
516
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode);
517 517
 				}
518
-				elseif (preg_match(':^#H2:',$message)) {
519
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
518
+				elseif (preg_match(':^#H2:', $message)) {
519
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode);
520 520
 				}
521
-				elseif (preg_match(':^#HD:',$message)) {
522
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
521
+				elseif (preg_match(':^#HD:', $message)) {
522
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode);
523 523
 				}
524
-				elseif (preg_match(':^#M1:',$message)) {
525
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
524
+				elseif (preg_match(':^#M1:', $message)) {
525
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode);
526 526
 				}
527
-				elseif (preg_match(':^#M2:',$message)) {
528
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
527
+				elseif (preg_match(':^#M2:', $message)) {
528
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode);
529 529
 				}
530
-				elseif (preg_match(':^#M3:',$message)) {
531
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
530
+				elseif (preg_match(':^#M3:', $message)) {
531
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode);
532 532
 				}
533
-				elseif (preg_match(':^#MD:',$message)) {
534
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
533
+				elseif (preg_match(':^#MD:', $message)) {
534
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode);
535 535
 				}
536
-				elseif (preg_match(':^#PS:',$message)) {
537
-					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
536
+				elseif (preg_match(':^#PS:', $message)) {
537
+					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode);
538 538
 				}
539
-				elseif (preg_match(':^#S1:',$message)) {
540
-					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
539
+				elseif (preg_match(':^#S1:', $message)) {
540
+					$decode = array_merge(array('Message nature' => 'SDU - Left'), $decode);
541 541
 				}
542
-				elseif (preg_match(':^#S2:',$message)) {
543
-					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
542
+				elseif (preg_match(':^#S2:', $message)) {
543
+					$decode = array_merge(array('Message nature' => 'SDU - Right'), $decode);
544 544
 				}
545
-				elseif (preg_match(':^#SD:',$message)) {
546
-					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
545
+				elseif (preg_match(':^#SD:', $message)) {
546
+					$decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode);
547 547
 				}
548
-				elseif (preg_match(':^#T[0-8]:',$message)) {
549
-					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
548
+				elseif (preg_match(':^#T[0-8]:', $message)) {
549
+					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode);
550 550
 				}
551
-				elseif (preg_match(':^#WO:',$message)) {
552
-					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
551
+				elseif (preg_match(':^#WO:', $message)) {
552
+					$decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode);
553 553
 				}
554
-				elseif (preg_match(':^#A1:',$message)) {
555
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
554
+				elseif (preg_match(':^#A1:', $message)) {
555
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode);
556 556
 				}
557
-				elseif (preg_match(':^#A3:',$message)) {
558
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
557
+				elseif (preg_match(':^#A3:', $message)) {
558
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode);
559 559
 				}
560
-				elseif (preg_match(':^#A4:',$message)) {
561
-					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
560
+				elseif (preg_match(':^#A4:', $message)) {
561
+					$decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode);
562 562
 				}
563
-				elseif (preg_match(':^#A6:',$message)) {
564
-					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
563
+				elseif (preg_match(':^#A6:', $message)) {
564
+					$decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode);
565 565
 				}
566
-				elseif (preg_match(':^#A8:',$message)) {
567
-					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
566
+				elseif (preg_match(':^#A8:', $message)) {
567
+					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode);
568 568
 				}
569
-				elseif (preg_match(':^#A9:',$message)) {
570
-					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
569
+				elseif (preg_match(':^#A9:', $message)) {
570
+					$decode = array_merge(array('Message nature' => 'ATIS report'), $decode);
571 571
 				}
572
-				elseif (preg_match(':^#A0:',$message)) {
573
-					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
572
+				elseif (preg_match(':^#A0:', $message)) {
573
+					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode);
574 574
 				}
575
-				elseif (preg_match(':^#AA:',$message)) {
576
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
575
+				elseif (preg_match(':^#AA:', $message)) {
576
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
577 577
 				}
578
-				elseif (preg_match(':^#AB:',$message)) {
579
-					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
578
+				elseif (preg_match(':^#AB:', $message)) {
579
+					$decode = array_merge(array('Message nature' => 'TWIP Report'), $decode);
580 580
 				}
581
-				elseif (preg_match(':^#AC:',$message)) {
582
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
581
+				elseif (preg_match(':^#AC:', $message)) {
582
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode);
583 583
 				}
584
-				elseif (preg_match(':^#AD:',$message)) {
585
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
584
+				elseif (preg_match(':^#AD:', $message)) {
585
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode);
586 586
 				}
587
-				elseif (preg_match(':^#AF:',$message)) {
588
-					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
587
+				elseif (preg_match(':^#AF:', $message)) {
588
+					$decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode);
589 589
 				}
590
-				elseif (preg_match(':^#B1:',$message)) {
591
-					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
590
+				elseif (preg_match(':^#B1:', $message)) {
591
+					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode);
592 592
 				}
593
-				elseif (preg_match(':^#B2:',$message)) {
594
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
593
+				elseif (preg_match(':^#B2:', $message)) {
594
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode);
595 595
 				}
596
-				elseif (preg_match(':^#B3:',$message)) {
597
-					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
596
+				elseif (preg_match(':^#B3:', $message)) {
597
+					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode);
598 598
 				}
599
-				elseif (preg_match(':^#B4:',$message)) {
600
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
599
+				elseif (preg_match(':^#B4:', $message)) {
600
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode);
601 601
 				}
602
-				elseif (preg_match(':^#B6:',$message)) {
603
-					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
602
+				elseif (preg_match(':^#B6:', $message)) {
603
+					$decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode);
604 604
 				}
605
-				elseif (preg_match(':^#B8:',$message)) {
606
-					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
605
+				elseif (preg_match(':^#B8:', $message)) {
606
+					$decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode);
607 607
 				}
608
-				elseif (preg_match(':^#B9:',$message)) {
609
-					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
608
+				elseif (preg_match(':^#B9:', $message)) {
609
+					$decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode);
610 610
 				}
611
-				elseif (preg_match(':^#B0:',$message)) {
612
-					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
611
+				elseif (preg_match(':^#B0:', $message)) {
612
+					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode);
613 613
 				}
614
-				elseif (preg_match(':^#BA:',$message)) {
615
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
614
+				elseif (preg_match(':^#BA:', $message)) {
615
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
616 616
 				}
617
-				elseif (preg_match(':^#BB:',$message)) {
618
-					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
617
+				elseif (preg_match(':^#BB:', $message)) {
618
+					$decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode);
619 619
 				}
620
-				elseif (preg_match(':^#BC:',$message)) {
621
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
620
+				elseif (preg_match(':^#BC:', $message)) {
621
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode);
622 622
 				}
623
-				elseif (preg_match(':^#BD:',$message)) {
624
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
623
+				elseif (preg_match(':^#BD:', $message)) {
624
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode);
625 625
 				}
626
-				elseif (preg_match(':^#BE:',$message)) {
627
-					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
626
+				elseif (preg_match(':^#BE:', $message)) {
627
+					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode);
628 628
 				}
629
-				elseif (preg_match(':^#BF:',$message)) {
630
-					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
629
+				elseif (preg_match(':^#BF:', $message)) {
630
+					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode);
631 631
 				}
632
-				elseif (preg_match(':^#H3:',$message)) {
633
-					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
632
+				elseif (preg_match(':^#H3:', $message)) {
633
+					$decode = array_merge(array('Message nature' => 'Icing Report'), $decode);
634 634
 				}
635 635
 			}
636 636
 			if ($label == '10') {
637
-				if (preg_match(':^DTO01:',$message)) {
638
-					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
637
+				if (preg_match(':^DTO01:', $message)) {
638
+					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode);
639 639
 				}
640
-				elseif (preg_match(':^AIS01:',$message)) {
641
-					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
640
+				elseif (preg_match(':^AIS01:', $message)) {
641
+					$decode = array_merge(array('Message nature' => 'AIS Request'), $decode);
642 642
 				}
643
-				elseif (preg_match(':^FTX01:',$message)) {
644
-					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
643
+				elseif (preg_match(':^FTX01:', $message)) {
644
+					$decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode);
645 645
 				}
646
-				elseif (preg_match(':^FPL01:',$message)) {
647
-					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
646
+				elseif (preg_match(':^FPL01:', $message)) {
647
+					$decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode);
648 648
 				}
649
-				elseif (preg_match(':^WAB01:',$message)) {
650
-					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
649
+				elseif (preg_match(':^WAB01:', $message)) {
650
+					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode);
651 651
 				}
652
-				elseif (preg_match(':^MET01:',$message)) {
653
-					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
652
+				elseif (preg_match(':^MET01:', $message)) {
653
+					$decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode);
654 654
 				}
655
-				elseif (preg_match(':^WAB02:',$message)) {
656
-					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
655
+				elseif (preg_match(':^WAB02:', $message)) {
656
+					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode);
657 657
 				}
658 658
 			}
659 659
 			if ($label == '15') {
660
-				if (preg_match(':^FST01:',$message)) {
661
-					$decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode);
660
+				if (preg_match(':^FST01:', $message)) {
661
+					$decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode);
662 662
 				}
663 663
 			}
664 664
 			if (!$found && $label == 'SA') {
665
-				$n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at);
665
+				$n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at);
666 666
 				if ($n == 4) {
667 667
 					$vsta = array('Version' => $version);
668 668
 					if ($state == 'E') {
669
-						$vsta = array_merge($vsta,array('Link state' => 'Established'));
669
+						$vsta = array_merge($vsta, array('Link state' => 'Established'));
670 670
 					}
671 671
 					elseif ($state == 'L') {
672
-						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
672
+						$vsta = array_merge($vsta, array('Link state' => 'Lost'));
673 673
 					}
674 674
 					else {
675
-						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
675
+						$vsta = array_merge($vsta, array('Link state' => 'Unknown'));
676 676
 					}
677 677
 					if ($type == 'V') {
678
-						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
678
+						$vsta = array_merge($vsta, array('Link type' => 'VHF ACARS'));
679 679
 					}
680 680
 					elseif ($type == 'S') {
681
-						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
681
+						$vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM'));
682 682
 					}
683 683
 					elseif ($type == 'H') {
684
-						$vsta = array_merge($vsta,array('Link type' => 'HF'));
684
+						$vsta = array_merge($vsta, array('Link type' => 'HF'));
685 685
 					}
686 686
 					elseif ($type == 'G') {
687
-						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
687
+						$vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM'));
688 688
 					}
689 689
 					elseif ($type == 'C') {
690
-						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
690
+						$vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM'));
691 691
 					}
692 692
 					elseif ($type == '2') {
693
-						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
693
+						$vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2'));
694 694
 					}
695 695
 					elseif ($type == 'X') {
696
-						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
696
+						$vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero'));
697 697
 					}
698 698
 					elseif ($type == 'I') {
699
-						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
699
+						$vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM'));
700 700
 					}
701 701
 					else {
702
-						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
702
+						$vsta = array_merge($vsta, array('Link type' => 'Unknown'));
703 703
 					}
704
-					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
705
-					$decode = array_merge($vsta,$decode);
704
+					$vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2))));
705
+					$decode = array_merge($vsta, $decode);
706 706
 				}
707 707
 			}
708 708
 
709 709
 			$title = $this->getTitlefromLabel($label);
710
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
710
+			if ($title != '') $decode = array_merge(array('Message title' => $title), $decode);
711 711
 
712 712
 			/*
713 713
 			// Business jets always use GS0001
@@ -740,13 +740,13 @@  discard block
 block discarded – undo
740 740
 		$message = $this->parse($data);
741 741
 		if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') {
742 742
 		
743
-			$ident = (string)$message['ident'];
743
+			$ident = (string) $message['ident'];
744 744
 			$label = $message['label'];
745 745
 			$block_id = $message['block_id'];
746 746
 			$msg_no = $message['msg_no'];
747 747
 			$msg = $message['message'];
748 748
 			$decode = $message['decode'];
749
-			$registration = (string)$message['registration'];
749
+			$registration = (string) $message['registration'];
750 750
 		
751 751
 			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
752 752
 			else $latitude = '';
@@ -763,23 +763,23 @@  discard block
 block discarded – undo
763 763
 			}
764 764
 		
765 765
 			// Business jets always use GS0001
766
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
766
+			if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude);
767 767
 			if ($globalDebug && isset($info) && $info != '') echo $info;
768 768
 
769 769
 			if (count($decode) > 0) $decode_json = json_encode($decode);
770 770
 			else $decode_json = '';
771 771
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
772
-				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
772
+				$Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS');
773 773
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
774
-				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
774
+				$Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS');
775 775
 			}
776 776
 
777
-			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
778
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
779
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
777
+			$result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
778
+			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F');
779
+			if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
780 780
 
781 781
 			if ($globalDebug && count($decode) > 0) {
782
-				echo "Human readable data : ".implode(' - ',$decode)."\n";
782
+				echo "Human readable data : ".implode(' - ', $decode)."\n";
783 783
 			}
784 784
 		}
785 785
 	}
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 	* @param String $msg_no Number of the ACARS message
795 795
 	* @param String $message ACARS message
796 796
 	*/
797
-	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
797
+	public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
798 798
 		global $globalDebug;
799 799
 		date_default_timezone_set('UTC');
800 800
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
@@ -803,22 +803,22 @@  discard block
 block discarded – undo
803 803
 
804 804
 			if ($globalDebug) echo "Test if not already in Live ACARS table...";
805 805
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
806
-			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
806
+			$query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message);
807 807
 			try {
808 808
 				$stht = $this->db->prepare($query_test);
809 809
 				$stht->execute($query_test_values);
810
-			} catch(PDOException $e) {
810
+			} catch (PDOException $e) {
811 811
 				return "error : ".$e->getMessage();
812 812
 			}
813 813
 			if ($stht->fetchColumn() == 0) {
814 814
 				if ($globalDebug) echo "Add Live ACARS data...";
815 815
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
816
-				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
816
+				$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s"));
817 817
 				try {
818 818
 
819 819
 					$sth = $this->db->prepare($query);
820 820
 					$sth->execute($query_values);
821
-				} catch(PDOException $e) {
821
+				} catch (PDOException $e) {
822 822
 					return "error : ".$e->getMessage();
823 823
 				}
824 824
 			} else {
@@ -840,10 +840,10 @@  discard block
 block discarded – undo
840 840
 	* @param String $msg_no Number of the ACARS message
841 841
 	* @param String $message ACARS message
842 842
 	*/
843
-	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
843
+	public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
844 844
 		global $globalDebug;
845 845
 		date_default_timezone_set('UTC');
846
-		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) {
846
+		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) {
847 847
 			/*
848 848
 				    if ($globalDebug) echo "Test if not already in Archive ACARS table...";
849 849
 			    	    $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message";
@@ -859,12 +859,12 @@  discard block
 block discarded – undo
859 859
 			*/
860 860
 			if ($globalDebug) echo "Add Live ACARS data...";
861 861
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
862
-			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
862
+			$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
863 863
 			try {
864 864
 
865 865
 				$sth = $this->db->prepare($query);
866 866
 				$sth->execute($query_values);
867
-			} catch(PDOException $e) {
867
+			} catch (PDOException $e) {
868 868
 				return "error : ".$e->getMessage();
869 869
 			}
870 870
 //    	    }
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 
888 888
 			$sth = $this->db->prepare($query);
889 889
 			$sth->execute($query_values);
890
-		} catch(PDOException $e) {
890
+		} catch (PDOException $e) {
891 891
 			echo "error : ".$e->getMessage();
892 892
 			die;
893 893
 		}
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 
909 909
 			$sth = $this->db->prepare($query);
910 910
 			$sth->execute($query_values);
911
-		} catch(PDOException $e) {
911
+		} catch (PDOException $e) {
912 912
 			echo "error : ".$e->getMessage();
913 913
 			die;
914 914
 		}
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 
931 931
 			$sth = $this->db->prepare($query);
932 932
 			$sth->execute($query_values);
933
-		} catch(PDOException $e) {
933
+		} catch (PDOException $e) {
934 934
 			echo "error : ".$e->getMessage();
935 935
 			die;
936 936
 		}
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 	*
945 945
 	* @return Array Return ACARS data in array
946 946
 	*/
947
-	public function getLatestAcarsData($limit = '',$label = '') {
947
+	public function getLatestAcarsData($limit = '', $label = '') {
948 948
 		global $globalURL, $globalDBdriver;
949 949
 		$Image = new Image($this->db);
950 950
 		$Spotter = new Spotter($this->db);
@@ -956,8 +956,8 @@  discard block
 block discarded – undo
956 956
 		{
957 957
 			$limit_array = explode(",", $limit);
958 958
 
959
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
960
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
959
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
960
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
961 961
 
962 962
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
963 963
 			{
@@ -979,48 +979,48 @@  discard block
 block discarded – undo
979 979
 
980 980
 			$sth = $this->db->prepare($query);
981 981
 			$sth->execute($query_values);
982
-		} catch(PDOException $e) {
982
+		} catch (PDOException $e) {
983 983
 			return "error : ".$e->getMessage();
984 984
 		}
985 985
 		$i = 0;
986 986
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
987 987
 			$data = array();
988 988
 			if ($row['registration'] != '') {
989
-				$row['registration'] = str_replace('.','',$row['registration']);
989
+				$row['registration'] = str_replace('.', '', $row['registration']);
990 990
 				$image_array = $Image->getSpotterImage($row['registration']);
991
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
992
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
993
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
991
+				if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
992
+				else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
993
+			} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
994 994
 			if ($row['registration'] == '') $row['registration'] = 'NA';
995 995
 			if ($row['ident'] == '') $row['ident'] = 'NA';
996
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
996
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
997 997
 			if (isset($identicao[0])) {
998
-				if (substr($row['ident'],0,2) == 'AF') {
999
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1000
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1001
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
998
+				if (substr($row['ident'], 0, 2) == 'AF') {
999
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1000
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1001
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1002 1002
 
1003
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1003
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1004 1004
 			} else $icao = $row['ident'];
1005
-			$icao = $Translation->checkTranslation($icao,false);
1005
+			$icao = $Translation->checkTranslation($icao, false);
1006 1006
 
1007
-			$decode = json_decode($row['decode'],true);
1007
+			$decode = json_decode($row['decode'], true);
1008 1008
 			$found = false;
1009
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1009
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1010 1010
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1011 1011
 				if (isset($airport_info[0]['icao'])) {
1012 1012
 					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1013 1013
 					$found = true;
1014 1014
 				}
1015 1015
 			}
1016
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1016
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1017 1017
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1018 1018
 				if (isset($airport_info[0]['icao'])) {
1019 1019
 					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1020 1020
 					$found = true;
1021 1021
 				}
1022 1022
 			}
1023
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1023
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1024 1024
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1025 1025
 				if (isset($airport_info[0]['icao'])) {
1026 1026
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 				}
1029 1029
 			}
1030 1030
 			if ($found) $row['decode'] = json_encode($decode);
1031
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1031
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1032 1032
 			$result[] = $data;
1033 1033
 			$i++;
1034 1034
 		}
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 	*
1045 1045
 	* @return Array Return ACARS data in array
1046 1046
 	*/
1047
-	public function getArchiveAcarsData($limit = '',$label = '') {
1047
+	public function getArchiveAcarsData($limit = '', $label = '') {
1048 1048
 		global $globalURL, $globalDBdriver;
1049 1049
 		$Image = new Image($this->db);
1050 1050
 		$Spotter = new Spotter($this->db);
@@ -1056,8 +1056,8 @@  discard block
 block discarded – undo
1056 1056
 		{
1057 1057
 			$limit_array = explode(",", $limit);
1058 1058
 
1059
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1060
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1059
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1060
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1061 1061
 
1062 1062
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1063 1063
 			{
@@ -1087,45 +1087,45 @@  discard block
 block discarded – undo
1087 1087
 
1088 1088
 			$sth = $this->db->prepare($query);
1089 1089
 			$sth->execute($query_values);
1090
-		} catch(PDOException $e) {
1090
+		} catch (PDOException $e) {
1091 1091
 			return "error : ".$e->getMessage();
1092 1092
 		}
1093
-		$i=0;
1093
+		$i = 0;
1094 1094
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1095 1095
 			$data = array();
1096 1096
 			if ($row['registration'] != '') {
1097
-				$row['registration'] = str_replace('.','',$row['registration']);
1097
+				$row['registration'] = str_replace('.', '', $row['registration']);
1098 1098
 				$image_array = $Image->getSpotterImage($row['registration']);
1099
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1100
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1101
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1099
+				if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
1100
+				else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1101
+			} else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1102 1102
 			$icao = '';
1103 1103
 			if ($row['registration'] == '') $row['registration'] = 'NA';
1104 1104
 			if ($row['ident'] == '') $row['ident'] = 'NA';
1105
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1105
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
1106 1106
 			if (isset($identicao[0])) {
1107
-				if (substr($row['ident'],0,2) == 'AF') {
1108
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1109
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1110
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1111
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1107
+				if (substr($row['ident'], 0, 2) == 'AF') {
1108
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1109
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1110
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1111
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1112 1112
 			} else $icao = $row['ident'];
1113 1113
 			$icao = $Translation->checkTranslation($icao);
1114 1114
 
1115 1115
 
1116
-			$decode = json_decode($row['decode'],true);
1116
+			$decode = json_decode($row['decode'], true);
1117 1117
 			$found = false;
1118
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1118
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1119 1119
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1120 1120
 				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1121 1121
 				$found = true;
1122 1122
 			}
1123
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1123
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1124 1124
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1125 1125
 				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1126 1126
 				$found = true;
1127 1127
 			}
1128
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1128
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1129 1129
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1130 1130
 				if (isset($airport_info[0]['icao'])) {
1131 1131
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 			}
1135 1135
 			if ($found) $row['decode'] = json_encode($decode);
1136 1136
 
1137
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1137
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1138 1138
 			$result[] = $data;
1139 1139
 			$i++;
1140 1140
 		}
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 	* @param String $icao
1153 1153
 	* @param String $ICAOTypeCode
1154 1154
 	*/
1155
-	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1155
+	public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') {
1156 1156
 		global $globalDebug, $globalDBdriver;
1157 1157
 		$ident = trim($ident);
1158 1158
 		$Translation = new Translation($this->db);
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 			return '';
1167 1167
 		}
1168 1168
 
1169
-		$registration = str_replace('.','',$registration);
1169
+		$registration = str_replace('.', '', $registration);
1170 1170
 		$ident = $Translation->ident2icao($ident);
1171 1171
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1172 1172
 		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 
1177 1177
 			$sthsi = $this->db->prepare($querysi);
1178 1178
 			$sthsi->execute($querysi_values);
1179
-		} catch(PDOException $e) {
1179
+		} catch (PDOException $e) {
1180 1180
 			if ($globalDebug) echo $e->getMessage();
1181 1181
 			return "error : ".$e->getMessage();
1182 1182
 		}
@@ -1187,8 +1187,8 @@  discard block
 block discarded – undo
1187 1187
 			$Translation = new Translation($this->db);
1188 1188
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1189 1189
 			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1190
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1191
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1190
+			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS');
1191
+			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS');
1192 1192
 		} else {
1193 1193
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1194 1194
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 				try {
1197 1197
 					$sth = $this->db->prepare($query);
1198 1198
 					$sth->execute($query_values);
1199
-				} catch(PDOException $e) {
1199
+				} catch (PDOException $e) {
1200 1200
 					if ($globalDebug) echo $e->getMessage();
1201 1201
 					return "error : ".$e->getMessage();
1202 1202
 				}
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 				$sth->closeCursor();
1205 1205
 				if (isset($result['modes'])) $hex = $result['modes'];
1206 1206
 				else $hex = '';
1207
-				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1207
+				$SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS');
1208 1208
 				$this->SI->add($SI_data);
1209 1209
 			}
1210 1210
 		}
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 
1217 1217
 			$sth = $this->db->prepare($query);
1218 1218
 			$sth->execute($query_values);
1219
-		} catch(PDOException $e) {
1219
+		} catch (PDOException $e) {
1220 1220
 			if ($globalDebug) echo $e->getMessage();
1221 1221
 			return "error : ".$e->getMessage();
1222 1222
 		}
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1228 1228
 			else $ModeS = '';
1229 1229
 			if ($ModeS == '') {
1230
-				$id = explode('-',$result['flightaware_id']);
1230
+				$id = explode('-', $result['flightaware_id']);
1231 1231
 				$ModeS = $id[0];
1232 1232
 			}
1233 1233
 			if ($ModeS != '') {
@@ -1238,21 +1238,21 @@  discard block
 block discarded – undo
1238 1238
 
1239 1239
 					$sthc = $this->db->prepare($queryc);
1240 1240
 					$sthc->execute($queryc_values);
1241
-				} catch(PDOException $e) {
1241
+				} catch (PDOException $e) {
1242 1242
 					if ($globalDebug) echo $e->getMessage();
1243 1243
 					return "error : ".$e->getMessage();
1244 1244
 				}
1245 1245
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1246 1246
 				$sthc->closeCursor();
1247
-				if (count($row) ==  0) {
1247
+				if (count($row) == 0) {
1248 1248
 					if ($globalDebug) echo " Add to ModeS table - ";
1249 1249
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1250
-					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1250
+					$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1251 1251
 					try {
1252 1252
 
1253 1253
 						$sthi = $this->db->prepare($queryi);
1254 1254
 						$sthi->execute($queryi_values);
1255
-					} catch(PDOException $e) {
1255
+					} catch (PDOException $e) {
1256 1256
 						if ($globalDebug) echo $e->getMessage();
1257 1257
 						return "error : ".$e->getMessage();
1258 1258
 					}
@@ -1260,16 +1260,16 @@  discard block
 block discarded – undo
1260 1260
 					if ($globalDebug) echo " Update ModeS table - ";
1261 1261
 					if ($ICAOTypeCode != '') {
1262 1262
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1263
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1263
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1264 1264
 					} else {
1265 1265
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1266
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration);
1266
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration);
1267 1267
 					}
1268 1268
 					try {
1269 1269
 
1270 1270
 						$sthi = $this->db->prepare($queryi);
1271 1271
 						$sthi->execute($queryi_values);
1272
-					} catch(PDOException $e) {
1272
+					} catch (PDOException $e) {
1273 1273
 						if ($globalDebug) echo $e->getMessage();
1274 1274
 						return "error : ".$e->getMessage();
1275 1275
 					}
@@ -1307,13 +1307,13 @@  discard block
 block discarded – undo
1307 1307
 					elseif ($globalDBdriver == 'pgsql') {
1308 1308
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1309 1309
 					}
1310
-					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
1310
+					$queryi_values = array(':Registration' => $registration, ':ident' => $icao);
1311 1311
 				}
1312 1312
 				try {
1313 1313
 
1314 1314
 					$sthi = $this->db->prepare($queryi);
1315 1315
 					$sthi->execute($queryi_values);
1316
-				} catch(PDOException $e) {
1316
+				} catch (PDOException $e) {
1317 1317
 					if ($globalDebug) echo $e->getMessage();
1318 1318
 					return "error : ".$e->getMessage();
1319 1319
 				}
Please login to merge, or discard this patch.
Braces   +409 added lines, -261 removed lines patch added patch discarded remove patch
@@ -23,14 +23,19 @@  discard block
 block discarded – undo
23 23
 	*/
24 24
 	public function ident2icao($ident) {
25 25
 		if (substr($ident,0,2) == 'AF') {
26
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
27
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
26
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
27
+				$icao = $ident;
28
+			} else {
29
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
30
+			}
28 31
 		} else {
29 32
 			$Spotter = new Spotter($this->db);
30 33
 			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
31 34
 			if (isset($identicao[0])) {
32 35
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
33
-			} else $icao = $ident;
36
+			} else {
37
+				$icao = $ident;
38
+			}
34 39
 		}
35 40
 		return $icao;
36 41
 	}
@@ -103,14 +108,24 @@  discard block
 block discarded – undo
103 108
 		$message = '';
104 109
 		$result = array();
105 110
 		$n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
106
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
107
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
108
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
111
+		if ($n == 0) {
112
+			$n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
113
+		}
114
+		if ($n == 0) {
115
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
116
+		}
117
+		if ($n == 0) {
118
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
119
+		}
109 120
 		if ($n != 0) {
110 121
 			$registration = str_replace('.','',$registration);
111 122
 			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
112
-			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
113
-		} else $message = $data;
123
+			if ($globalDebug) {
124
+				echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
125
+			}
126
+		} else {
127
+			$message = $data;
128
+		}
114 129
 		$decode = array();
115 130
 		$found = false;
116 131
 //		if ($registration != '' && $ident != '' && $registration != '!') {
@@ -130,12 +145,21 @@  discard block
 block discarded – undo
130 145
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
131 146
 					$latitude = $la / 10000.0;
132 147
 					$longitude = $ln / 10000.0;
133
-					if ($lac == 'S') $latitude = '-'.$latitude;
134
-					if ($lnc == 'W') $longitude = '-'.$longitude;
148
+					if ($lac == 'S') {
149
+						$latitude = '-'.$latitude;
150
+					}
151
+					if ($lnc == 'W') {
152
+						$longitude = '-'.$longitude;
153
+					}
135 154
 					// Temp not always available
136
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
137
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
138
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
155
+					if ($globalDebug) {
156
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
157
+					}
158
+					if ($temp == '') {
159
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
160
+					} else {
161
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
162
+					}
139 163
 
140 164
 					//$icao = $Translation->checkTranslation($ident);
141 165
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -149,25 +173,35 @@  discard block
 block discarded – undo
149 173
 				$ahour = '';
150 174
 				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
151 175
 				if ($n == 4 && strlen($darr) == 4) {
152
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
153
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
154
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
176
+					if ($dhour != '') {
177
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
178
+					}
179
+					if ($ahour != '') {
180
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
181
+					}
182
+					if ($globalDebug) {
183
+						echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
184
+					}
155 185
 					//$icao = ACARS->ident2icao($ident);
156 186
 					//$icao = $Translation->checkTranslation($ident);
157 187
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
158 188
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
159 189
 					$found = true;
160
-				}
161
-				elseif ($n == 2 || $n  == 4) {
162
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
163
-					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
190
+				} elseif ($n == 2 || $n  == 4) {
191
+					if ($dhour != '') {
192
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
193
+					}
194
+					if ($globalDebug) {
195
+						echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
196
+					}
164 197
 					//$icao = ACARS->ident2icao($ident);
165 198
 					//$icao = $Translation->checkTranslation($ident);
166 199
 					$decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
167 200
 					$found = true;
168
-				}
169
-				elseif ($n == 1) {
170
-					if ($globalDebug) echo 'airport arrival : '.$darr."\n";
201
+				} elseif ($n == 1) {
202
+					if ($globalDebug) {
203
+						echo 'airport arrival : '.$darr."\n";
204
+					}
171 205
 					//$icao = ACARS->ident2icao($ident);
172 206
 					//$icao = $Translation->checkTranslation($ident);
173 207
 					$decode = array('Arrival airport' => $darr);
@@ -185,7 +219,9 @@  discard block
 block discarded – undo
185 219
 				$darr = '';
186 220
 				$n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
187 221
 				if ($n == 4) {
188
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
222
+					if ($globalDebug) {
223
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
224
+					}
189 225
 					//$icao = ACARS->ident2icao($ident);
190 226
 					//$icao = $Translation->checkTranslation($ident);
191 227
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -219,14 +255,23 @@  discard block
 block discarded – undo
219 255
 				$apiste = '';
220 256
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
221 257
 				if ($n > 8) {
222
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
223
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
224
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
258
+					if ($globalDebug) {
259
+						echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
260
+					}
261
+					if ($dhour != '') {
262
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
263
+					}
264
+					if ($ahour != '') {
265
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
266
+					}
225 267
 					$icao = trim($aident);
226 268
 
227 269
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
228
-					if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
229
-					else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
270
+					if ($ahour == '') {
271
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
272
+					} else {
273
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
274
+					}
230 275
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
231 276
 					$decode['icao'] = $icao;
232 277
 					$found = true;
@@ -248,9 +293,15 @@  discard block
 block discarded – undo
248 293
 					$lns = $lns.'.'.$lns;
249 294
 					$latitude = $las / 1000.0;
250 295
 					$longitude = $lns / 1000.0;
251
-					if ($lac == 'S') $latitude = '-'.$latitude;
252
-					if ($lnc == 'W') $longitude = '-'.$longitude;
253
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
296
+					if ($lac == 'S') {
297
+						$latitude = '-'.$latitude;
298
+					}
299
+					if ($lnc == 'W') {
300
+						$longitude = '-'.$longitude;
301
+					}
302
+					if ($globalDebug) {
303
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
304
+					}
254 305
 					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
255 306
 					$found = true;
256 307
 				}
@@ -268,7 +319,9 @@  discard block
 block discarded – undo
268 319
 				$darr = '';
269 320
 				$n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
270 321
 				if ($n == 4) {
271
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
322
+					if ($globalDebug) {
323
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
324
+					}
272 325
 					//$icao = $Translation->checkTranslation($ident);
273 326
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
274 327
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -281,7 +334,9 @@  discard block
 block discarded – undo
281 334
 				$darr = '';
282 335
 				$n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
283 336
 				if ($n == 4) {
284
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
337
+					if ($globalDebug) {
338
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
339
+					}
285 340
 					//$icao = $Translation->checkTranslation($ident);
286 341
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
287 342
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -294,7 +349,9 @@  discard block
 block discarded – undo
294 349
 				$darr = '';
295 350
 				$n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
296 351
 				if ($n == 2) {
297
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
352
+					if ($globalDebug) {
353
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
354
+					}
298 355
 					//$icao = $Translation->checkTranslation($ident);
299 356
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
300 357
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -308,7 +365,9 @@  discard block
 block discarded – undo
308 365
 				$darr = '';
309 366
 				$n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
310 367
 				if ($n == 6) {
311
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
368
+					if ($globalDebug) {
369
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
370
+					}
312 371
 					//$icao = $Translation->checkTranslation($ident);
313 372
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
314 373
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -321,7 +380,9 @@  discard block
 block discarded – undo
321 380
 				$darr = '';
322 381
 				$n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
323 382
 				if ($n == 7) {
324
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
383
+					if ($globalDebug) {
384
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
385
+					}
325 386
 					//$icao = $Translation->checkTranslation($ident);
326 387
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
327 388
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -349,8 +410,12 @@  discard block
 block discarded – undo
349 410
 					$decode['icao'] = $icao;
350 411
 					$latitude = $las / 100.0;
351 412
 					$longitude = $lns / 100.0;
352
-					if ($lac == 'S') $latitude = '-'.$latitude;
353
-					if ($lnc == 'W') $longitude = '-'.$longitude;
413
+					if ($lac == 'S') {
414
+						$latitude = '-'.$latitude;
415
+					}
416
+					if ($lnc == 'W') {
417
+						$longitude = '-'.$longitude;
418
+					}
354 419
 
355 420
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
356 421
 					$found = true;
@@ -368,8 +433,12 @@  discard block
 block discarded – undo
368 433
 				if ($n == 4) {
369 434
 					$latitude = $las;
370 435
 					$longitude = $lns;
371
-					if ($lac == 'S') $latitude = '-'.$latitude;
372
-					if ($lnc == 'W') $longitude = '-'.$longitude;
436
+					if ($lac == 'S') {
437
+						$latitude = '-'.$latitude;
438
+					}
439
+					if ($lnc == 'W') {
440
+						$longitude = '-'.$longitude;
441
+					}
373 442
 
374 443
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
375 444
 					$found = true;
@@ -385,7 +454,9 @@  discard block
 block discarded – undo
385 454
 				$darr = '';
386 455
 				$n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
387 456
 				if ($n == 5) {
388
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
457
+					if ($globalDebug) {
458
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
459
+					}
389 460
 					//$icao = $Translation->checkTranslation($ident);
390 461
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
391 462
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -406,7 +477,9 @@  discard block
 block discarded – undo
406 477
 				$aident = '';
407 478
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
408 479
 				if ($n == 8) {
409
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
480
+					if ($globalDebug) {
481
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
482
+					}
410 483
 					$icao = trim($aident);
411 484
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
412 485
 					$decode['icao'] = $icao;
@@ -423,7 +496,9 @@  discard block
 block discarded – undo
423 496
 				$darr = '';
424 497
 				$n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
425 498
 				if ($n == 5) {
426
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
499
+					if ($globalDebug) {
500
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
501
+					}
427 502
 					//$icao = $Translation->checkTranslation($ident);
428 503
 
429 504
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -439,7 +514,9 @@  discard block
 block discarded – undo
439 514
 				$darr = '';
440 515
 				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
441 516
 				if ($n == 3) {
442
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
517
+					if ($globalDebug) {
518
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
519
+					}
443 520
 					//$icao = $Translation->checkTranslation($ident);
444 521
 
445 522
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -455,7 +532,9 @@  discard block
 block discarded – undo
455 532
 				$darr = '';
456 533
 				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
457 534
 				if ($n == 3) {
458
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
535
+					if ($globalDebug) {
536
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
537
+					}
459 538
 					//$icao = $Translation->checkTranslation($ident);
460 539
 
461 540
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -466,7 +545,9 @@  discard block
 block discarded – undo
466 545
 			if (!$found) {
467 546
 				$n = sscanf($message,'MET01%4c',$airport);
468 547
 				if ($n == 1) {
469
-					if ($globalDebug) echo 'airport name : '.$airport;
548
+					if ($globalDebug) {
549
+						echo 'airport name : '.$airport;
550
+					}
470 551
 					$decode = array('Airport/Waypoint name' => $airport);
471 552
 					$found = true;
472 553
 				}
@@ -475,184 +556,126 @@  discard block
 block discarded – undo
475 556
 			if ($label == 'H1') {
476 557
 				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
477 558
 					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
478
-				}
479
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
559
+				} elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
480 560
 					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
481
-				}
482
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
561
+				} elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
483 562
 					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
484
-				}
485
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
563
+				} elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
486 564
 					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
487
-				}
488
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
565
+				} elseif (preg_match(':^#DFB/PIREP:',$message)) {
489 566
 					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
490
-				}
491
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
567
+				} elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
492 568
 					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
493
-				}
494
-				elseif (preg_match(':^#M1AAEP:',$message)) {
569
+				} elseif (preg_match(':^#M1AAEP:',$message)) {
495 570
 					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
496
-				}
497
-				elseif (preg_match(':^#M2APWD:',$message)) {
571
+				} elseif (preg_match(':^#M2APWD:',$message)) {
498 572
 					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
499
-				}
500
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
573
+				} elseif (preg_match(':^#M1BREQPWI:',$message)) {
501 574
 					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
502
-				}
503
-				elseif (preg_match(':^#CF:',$message)) {
575
+				} elseif (preg_match(':^#CF:',$message)) {
504 576
 					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
505
-				}
506
-				elseif (preg_match(':^#DF:',$message)) {
577
+				} elseif (preg_match(':^#DF:',$message)) {
507 578
 					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
508
-				}
509
-				elseif (preg_match(':^#EC:',$message)) {
579
+				} elseif (preg_match(':^#EC:',$message)) {
510 580
 					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
511
-				}
512
-				elseif (preg_match(':^#EI:',$message)) {
581
+				} elseif (preg_match(':^#EI:',$message)) {
513 582
 					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
514
-				}
515
-				elseif (preg_match(':^#H1:',$message)) {
583
+				} elseif (preg_match(':^#H1:',$message)) {
516 584
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
517
-				}
518
-				elseif (preg_match(':^#H2:',$message)) {
585
+				} elseif (preg_match(':^#H2:',$message)) {
519 586
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
520
-				}
521
-				elseif (preg_match(':^#HD:',$message)) {
587
+				} elseif (preg_match(':^#HD:',$message)) {
522 588
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
523
-				}
524
-				elseif (preg_match(':^#M1:',$message)) {
589
+				} elseif (preg_match(':^#M1:',$message)) {
525 590
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
526
-				}
527
-				elseif (preg_match(':^#M2:',$message)) {
591
+				} elseif (preg_match(':^#M2:',$message)) {
528 592
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
529
-				}
530
-				elseif (preg_match(':^#M3:',$message)) {
593
+				} elseif (preg_match(':^#M3:',$message)) {
531 594
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
532
-				}
533
-				elseif (preg_match(':^#MD:',$message)) {
595
+				} elseif (preg_match(':^#MD:',$message)) {
534 596
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
535
-				}
536
-				elseif (preg_match(':^#PS:',$message)) {
597
+				} elseif (preg_match(':^#PS:',$message)) {
537 598
 					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
538
-				}
539
-				elseif (preg_match(':^#S1:',$message)) {
599
+				} elseif (preg_match(':^#S1:',$message)) {
540 600
 					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
541
-				}
542
-				elseif (preg_match(':^#S2:',$message)) {
601
+				} elseif (preg_match(':^#S2:',$message)) {
543 602
 					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
544
-				}
545
-				elseif (preg_match(':^#SD:',$message)) {
603
+				} elseif (preg_match(':^#SD:',$message)) {
546 604
 					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
547
-				}
548
-				elseif (preg_match(':^#T[0-8]:',$message)) {
605
+				} elseif (preg_match(':^#T[0-8]:',$message)) {
549 606
 					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
550
-				}
551
-				elseif (preg_match(':^#WO:',$message)) {
607
+				} elseif (preg_match(':^#WO:',$message)) {
552 608
 					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
553
-				}
554
-				elseif (preg_match(':^#A1:',$message)) {
609
+				} elseif (preg_match(':^#A1:',$message)) {
555 610
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
556
-				}
557
-				elseif (preg_match(':^#A3:',$message)) {
611
+				} elseif (preg_match(':^#A3:',$message)) {
558 612
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
559
-				}
560
-				elseif (preg_match(':^#A4:',$message)) {
613
+				} elseif (preg_match(':^#A4:',$message)) {
561 614
 					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
562
-				}
563
-				elseif (preg_match(':^#A6:',$message)) {
615
+				} elseif (preg_match(':^#A6:',$message)) {
564 616
 					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
565
-				}
566
-				elseif (preg_match(':^#A8:',$message)) {
617
+				} elseif (preg_match(':^#A8:',$message)) {
567 618
 					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
568
-				}
569
-				elseif (preg_match(':^#A9:',$message)) {
619
+				} elseif (preg_match(':^#A9:',$message)) {
570 620
 					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
571
-				}
572
-				elseif (preg_match(':^#A0:',$message)) {
621
+				} elseif (preg_match(':^#A0:',$message)) {
573 622
 					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
574
-				}
575
-				elseif (preg_match(':^#AA:',$message)) {
623
+				} elseif (preg_match(':^#AA:',$message)) {
576 624
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
577
-				}
578
-				elseif (preg_match(':^#AB:',$message)) {
625
+				} elseif (preg_match(':^#AB:',$message)) {
579 626
 					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
580
-				}
581
-				elseif (preg_match(':^#AC:',$message)) {
627
+				} elseif (preg_match(':^#AC:',$message)) {
582 628
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
583
-				}
584
-				elseif (preg_match(':^#AD:',$message)) {
629
+				} elseif (preg_match(':^#AD:',$message)) {
585 630
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
586
-				}
587
-				elseif (preg_match(':^#AF:',$message)) {
631
+				} elseif (preg_match(':^#AF:',$message)) {
588 632
 					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
589
-				}
590
-				elseif (preg_match(':^#B1:',$message)) {
633
+				} elseif (preg_match(':^#B1:',$message)) {
591 634
 					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
592
-				}
593
-				elseif (preg_match(':^#B2:',$message)) {
635
+				} elseif (preg_match(':^#B2:',$message)) {
594 636
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
595
-				}
596
-				elseif (preg_match(':^#B3:',$message)) {
637
+				} elseif (preg_match(':^#B3:',$message)) {
597 638
 					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
598
-				}
599
-				elseif (preg_match(':^#B4:',$message)) {
639
+				} elseif (preg_match(':^#B4:',$message)) {
600 640
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
601
-				}
602
-				elseif (preg_match(':^#B6:',$message)) {
641
+				} elseif (preg_match(':^#B6:',$message)) {
603 642
 					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
604
-				}
605
-				elseif (preg_match(':^#B8:',$message)) {
643
+				} elseif (preg_match(':^#B8:',$message)) {
606 644
 					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
607
-				}
608
-				elseif (preg_match(':^#B9:',$message)) {
645
+				} elseif (preg_match(':^#B9:',$message)) {
609 646
 					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
610
-				}
611
-				elseif (preg_match(':^#B0:',$message)) {
647
+				} elseif (preg_match(':^#B0:',$message)) {
612 648
 					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
613
-				}
614
-				elseif (preg_match(':^#BA:',$message)) {
649
+				} elseif (preg_match(':^#BA:',$message)) {
615 650
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
616
-				}
617
-				elseif (preg_match(':^#BB:',$message)) {
651
+				} elseif (preg_match(':^#BB:',$message)) {
618 652
 					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
619
-				}
620
-				elseif (preg_match(':^#BC:',$message)) {
653
+				} elseif (preg_match(':^#BC:',$message)) {
621 654
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
622
-				}
623
-				elseif (preg_match(':^#BD:',$message)) {
655
+				} elseif (preg_match(':^#BD:',$message)) {
624 656
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
625
-				}
626
-				elseif (preg_match(':^#BE:',$message)) {
657
+				} elseif (preg_match(':^#BE:',$message)) {
627 658
 					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
628
-				}
629
-				elseif (preg_match(':^#BF:',$message)) {
659
+				} elseif (preg_match(':^#BF:',$message)) {
630 660
 					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
631
-				}
632
-				elseif (preg_match(':^#H3:',$message)) {
661
+				} elseif (preg_match(':^#H3:',$message)) {
633 662
 					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
634 663
 				}
635 664
 			}
636 665
 			if ($label == '10') {
637 666
 				if (preg_match(':^DTO01:',$message)) {
638 667
 					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
639
-				}
640
-				elseif (preg_match(':^AIS01:',$message)) {
668
+				} elseif (preg_match(':^AIS01:',$message)) {
641 669
 					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
642
-				}
643
-				elseif (preg_match(':^FTX01:',$message)) {
670
+				} elseif (preg_match(':^FTX01:',$message)) {
644 671
 					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
645
-				}
646
-				elseif (preg_match(':^FPL01:',$message)) {
672
+				} elseif (preg_match(':^FPL01:',$message)) {
647 673
 					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
648
-				}
649
-				elseif (preg_match(':^WAB01:',$message)) {
674
+				} elseif (preg_match(':^WAB01:',$message)) {
650 675
 					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
651
-				}
652
-				elseif (preg_match(':^MET01:',$message)) {
676
+				} elseif (preg_match(':^MET01:',$message)) {
653 677
 					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
654
-				}
655
-				elseif (preg_match(':^WAB02:',$message)) {
678
+				} elseif (preg_match(':^WAB02:',$message)) {
656 679
 					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
657 680
 				}
658 681
 			}
@@ -667,38 +690,28 @@  discard block
 block discarded – undo
667 690
 					$vsta = array('Version' => $version);
668 691
 					if ($state == 'E') {
669 692
 						$vsta = array_merge($vsta,array('Link state' => 'Established'));
670
-					}
671
-					elseif ($state == 'L') {
693
+					} elseif ($state == 'L') {
672 694
 						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
673
-					}
674
-					else {
695
+					} else {
675 696
 						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
676 697
 					}
677 698
 					if ($type == 'V') {
678 699
 						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
679
-					}
680
-					elseif ($type == 'S') {
700
+					} elseif ($type == 'S') {
681 701
 						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
682
-					}
683
-					elseif ($type == 'H') {
702
+					} elseif ($type == 'H') {
684 703
 						$vsta = array_merge($vsta,array('Link type' => 'HF'));
685
-					}
686
-					elseif ($type == 'G') {
704
+					} elseif ($type == 'G') {
687 705
 						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
688
-					}
689
-					elseif ($type == 'C') {
706
+					} elseif ($type == 'C') {
690 707
 						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
691
-					}
692
-					elseif ($type == '2') {
708
+					} elseif ($type == '2') {
693 709
 						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
694
-					}
695
-					elseif ($type == 'X') {
710
+					} elseif ($type == 'X') {
696 711
 						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
697
-					}
698
-					elseif ($type == 'I') {
712
+					} elseif ($type == 'I') {
699 713
 						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
700
-					}
701
-					else {
714
+					} else {
702 715
 						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
703 716
 					}
704 717
 					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
@@ -707,7 +720,9 @@  discard block
 block discarded – undo
707 720
 			}
708 721
 
709 722
 			$title = $this->getTitlefromLabel($label);
710
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
723
+			if ($title != '') {
724
+				$decode = array_merge(array('Message title' => $title),$decode);
725
+			}
711 726
 
712 727
 			/*
713 728
 			// Business jets always use GS0001
@@ -748,14 +763,26 @@  discard block
 block discarded – undo
748 763
 			$decode = $message['decode'];
749 764
 			$registration = (string)$message['registration'];
750 765
 		
751
-			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
752
-			else $latitude = '';
753
-			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
754
-			else $longitude = '';
755
-			if (isset($decode['airicao'])) $airicao = $decode['airicao'];
756
-			else $airicao = '';
757
-			if (isset($decode['icao'])) $icao = $decode['icao'];
758
-			else $icao = $Translation->checkTranslation($ident);
766
+			if (isset($decode['latitude'])) {
767
+				$latitude = $decode['latitude'];
768
+			} else {
769
+				$latitude = '';
770
+			}
771
+			if (isset($decode['longitude'])) {
772
+				$longitude = $decode['longitude'];
773
+			} else {
774
+				$longitude = '';
775
+			}
776
+			if (isset($decode['airicao'])) {
777
+				$airicao = $decode['airicao'];
778
+			} else {
779
+				$airicao = '';
780
+			}
781
+			if (isset($decode['icao'])) {
782
+				$icao = $decode['icao'];
783
+			} else {
784
+				$icao = $Translation->checkTranslation($ident);
785
+			}
759 786
 		
760 787
 			$image_array = $Image->getSpotterImage($registration);
761 788
 			if (!isset($image_array[0]['registration'])) {
@@ -763,11 +790,18 @@  discard block
 block discarded – undo
763 790
 			}
764 791
 		
765 792
 			// Business jets always use GS0001
766
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
767
-			if ($globalDebug && isset($info) && $info != '') echo $info;
793
+			if ($ident != 'GS0001') {
794
+				$info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
795
+			}
796
+			if ($globalDebug && isset($info) && $info != '') {
797
+				echo $info;
798
+			}
768 799
 
769
-			if (count($decode) > 0) $decode_json = json_encode($decode);
770
-			else $decode_json = '';
800
+			if (count($decode) > 0) {
801
+				$decode_json = json_encode($decode);
802
+			} else {
803
+				$decode_json = '';
804
+			}
771 805
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
772 806
 				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
773 807
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
@@ -775,8 +809,12 @@  discard block
 block discarded – undo
775 809
 			}
776 810
 
777 811
 			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
778
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
779
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
812
+			if (!isset($globalACARSArchive)) {
813
+				$globalACARSArchive = array('10','80','81','82','3F');
814
+			}
815
+			if ($result && in_array($label,$globalACARSArchive)) {
816
+				$this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
817
+			}
780 818
 
781 819
 			if ($globalDebug && count($decode) > 0) {
782 820
 				echo "Human readable data : ".implode(' - ',$decode)."\n";
@@ -801,7 +839,9 @@  discard block
 block discarded – undo
801 839
 			$Connection = new Connection($this->db);
802 840
 			$this->db = $Connection->db;
803 841
 
804
-			if ($globalDebug) echo "Test if not already in Live ACARS table...";
842
+			if ($globalDebug) {
843
+				echo "Test if not already in Live ACARS table...";
844
+			}
805 845
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
806 846
 			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
807 847
 			try {
@@ -811,7 +851,9 @@  discard block
 block discarded – undo
811 851
 				return "error : ".$e->getMessage();
812 852
 			}
813 853
 			if ($stht->fetchColumn() == 0) {
814
-				if ($globalDebug) echo "Add Live ACARS data...";
854
+				if ($globalDebug) {
855
+					echo "Add Live ACARS data...";
856
+				}
815 857
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
816 858
 				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
817 859
 				try {
@@ -822,10 +864,14 @@  discard block
 block discarded – undo
822 864
 					return "error : ".$e->getMessage();
823 865
 				}
824 866
 			} else {
825
-				if ($globalDebug) echo "Data already in DB...\n";
867
+				if ($globalDebug) {
868
+					echo "Data already in DB...\n";
869
+				}
826 870
 				return false;
827 871
 			}
828
-			if ($globalDebug) echo "Done\n";
872
+			if ($globalDebug) {
873
+				echo "Done\n";
874
+			}
829 875
 			return true;
830 876
 		}
831 877
 	}
@@ -857,7 +903,9 @@  discard block
 block discarded – undo
857 903
 			    	    }
858 904
 				    if ($stht->fetchColumn() == 0) {
859 905
 			*/
860
-			if ($globalDebug) echo "Add Live ACARS data...";
906
+			if ($globalDebug) {
907
+				echo "Add Live ACARS data...";
908
+			}
861 909
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
862 910
 			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
863 911
 			try {
@@ -868,7 +916,9 @@  discard block
 block discarded – undo
868 916
 				return "error : ".$e->getMessage();
869 917
 			}
870 918
 //    	    }
871
-			if ($globalDebug) echo "Done\n";
919
+			if ($globalDebug) {
920
+				echo "Done\n";
921
+			}
872 922
 		}
873 923
 	}
874 924
 
@@ -892,8 +942,11 @@  discard block
 block discarded – undo
892 942
 			die;
893 943
 		}
894 944
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
895
-		if (count($row) > 0) return $row[0]['title'];
896
-		else return '';
945
+		if (count($row) > 0) {
946
+			return $row[0]['title'];
947
+		} else {
948
+			return '';
949
+		}
897 950
 	}
898 951
 
899 952
 	/**
@@ -913,8 +966,11 @@  discard block
 block discarded – undo
913 966
 			die;
914 967
 		}
915 968
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
916
-		if (count($row) > 0) return $row;
917
-		else return array();
969
+		if (count($row) > 0) {
970
+			return $row;
971
+		} else {
972
+			return array();
973
+		}
918 974
 	}
919 975
 
920 976
 	/**
@@ -935,8 +991,11 @@  discard block
 block discarded – undo
935 991
 			die;
936 992
 		}
937 993
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
938
-		if (count($row) > 0) return $row[0];
939
-		else return array();
994
+		if (count($row) > 0) {
995
+			return $row[0];
996
+		} else {
997
+			return array();
998
+		}
940 999
 	}
941 1000
 
942 1001
 	/**
@@ -988,20 +1047,36 @@  discard block
 block discarded – undo
988 1047
 			if ($row['registration'] != '') {
989 1048
 				$row['registration'] = str_replace('.','',$row['registration']);
990 1049
 				$image_array = $Image->getSpotterImage($row['registration']);
991
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
992
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
993
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
994
-			if ($row['registration'] == '') $row['registration'] = 'NA';
995
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1050
+				if (count($image_array) > 0) {
1051
+					$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1052
+				} else {
1053
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1054
+				}
1055
+			} else {
1056
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1057
+			}
1058
+			if ($row['registration'] == '') {
1059
+				$row['registration'] = 'NA';
1060
+			}
1061
+			if ($row['ident'] == '') {
1062
+				$row['ident'] = 'NA';
1063
+			}
996 1064
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
997 1065
 			if (isset($identicao[0])) {
998 1066
 				if (substr($row['ident'],0,2) == 'AF') {
999
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1000
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1001
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1067
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1068
+						$icao = $row['ident'];
1069
+					} else {
1070
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1071
+					}
1072
+				} else {
1073
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1074
+				}
1002 1075
 
1003 1076
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1004
-			} else $icao = $row['ident'];
1077
+			} else {
1078
+				$icao = $row['ident'];
1079
+			}
1005 1080
 			$icao = $Translation->checkTranslation($icao,false);
1006 1081
 
1007 1082
 			$decode = json_decode($row['decode'],true);
@@ -1027,7 +1102,9 @@  discard block
 block discarded – undo
1027 1102
 					$found = true;
1028 1103
 				}
1029 1104
 			}
1030
-			if ($found) $row['decode'] = json_encode($decode);
1105
+			if ($found) {
1106
+				$row['decode'] = json_encode($decode);
1107
+			}
1031 1108
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1032 1109
 			$result[] = $data;
1033 1110
 			$i++;
@@ -1035,8 +1112,9 @@  discard block
 block discarded – undo
1035 1112
 		if (isset($result)) {
1036 1113
 			$result[0]['query_number_rows'] = $i;
1037 1114
 			return $result;
1115
+		} else {
1116
+			return array();
1038 1117
 		}
1039
-		else return array();
1040 1118
 	}
1041 1119
 
1042 1120
 	/**
@@ -1096,20 +1174,36 @@  discard block
 block discarded – undo
1096 1174
 			if ($row['registration'] != '') {
1097 1175
 				$row['registration'] = str_replace('.','',$row['registration']);
1098 1176
 				$image_array = $Image->getSpotterImage($row['registration']);
1099
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1100
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1101
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1177
+				if (count($image_array) > 0) {
1178
+					$data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1179
+				} else {
1180
+					$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1181
+				}
1182
+			} else {
1183
+				$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1184
+			}
1102 1185
 			$icao = '';
1103
-			if ($row['registration'] == '') $row['registration'] = 'NA';
1104
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1186
+			if ($row['registration'] == '') {
1187
+				$row['registration'] = 'NA';
1188
+			}
1189
+			if ($row['ident'] == '') {
1190
+				$row['ident'] = 'NA';
1191
+			}
1105 1192
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1106 1193
 			if (isset($identicao[0])) {
1107 1194
 				if (substr($row['ident'],0,2) == 'AF') {
1108
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1109
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1110
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1195
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1196
+						$icao = $row['ident'];
1197
+					} else {
1198
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1199
+					}
1200
+				} else {
1201
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1202
+				}
1111 1203
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1112
-			} else $icao = $row['ident'];
1204
+			} else {
1205
+				$icao = $row['ident'];
1206
+			}
1113 1207
 			$icao = $Translation->checkTranslation($icao);
1114 1208
 
1115 1209
 
@@ -1117,12 +1211,16 @@  discard block
 block discarded – undo
1117 1211
 			$found = false;
1118 1212
 			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1119 1213
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1120
-				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1214
+				if (isset($airport_info[0]['icao'])) {
1215
+					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1216
+				}
1121 1217
 				$found = true;
1122 1218
 			}
1123 1219
 			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1124 1220
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1125
-				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1221
+				if (isset($airport_info[0]['icao'])) {
1222
+					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1223
+				}
1126 1224
 				$found = true;
1127 1225
 			}
1128 1226
 			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
@@ -1132,7 +1230,9 @@  discard block
 block discarded – undo
1132 1230
 					$found = true;
1133 1231
 				}
1134 1232
 			}
1135
-			if ($found) $row['decode'] = json_encode($decode);
1233
+			if ($found) {
1234
+				$row['decode'] = json_encode($decode);
1235
+			}
1136 1236
 
1137 1237
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1138 1238
 			$result[] = $data;
@@ -1141,7 +1241,9 @@  discard block
 block discarded – undo
1141 1241
 		if (isset($result)) {
1142 1242
 			$result[0]['query_number_rows'] = $i;
1143 1243
 			return $result;
1144
-		} else return array();
1244
+		} else {
1245
+			return array();
1246
+		}
1145 1247
 	}
1146 1248
 
1147 1249
 	/**
@@ -1157,19 +1259,29 @@  discard block
 block discarded – undo
1157 1259
 		$ident = trim($ident);
1158 1260
 		$Translation = new Translation($this->db);
1159 1261
 		$Spotter = new Spotter($this->db);
1160
-		if ($globalDebug) echo "Test if we add ModeS data...";
1262
+		if ($globalDebug) {
1263
+			echo "Test if we add ModeS data...";
1264
+		}
1161 1265
 		//if ($icao == '') $icao = ACARS->ident2icao($ident);
1162
-		if ($icao == '') $icao = $Translation->checkTranslation($ident);
1163
-		if ($globalDebug) echo '- Ident : '.$icao.' - ';
1266
+		if ($icao == '') {
1267
+			$icao = $Translation->checkTranslation($ident);
1268
+		}
1269
+		if ($globalDebug) {
1270
+			echo '- Ident : '.$icao.' - ';
1271
+		}
1164 1272
 		if ($ident == '' || $registration == '') {
1165
-			if ($globalDebug) echo "Ident or registration null, exit\n";
1273
+			if ($globalDebug) {
1274
+				echo "Ident or registration null, exit\n";
1275
+			}
1166 1276
 			return '';
1167 1277
 		}
1168 1278
 
1169 1279
 		$registration = str_replace('.','',$registration);
1170 1280
 		$ident = $Translation->ident2icao($ident);
1171 1281
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1172
-		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
1282
+		if ($globalDebug) {
1283
+			echo "Check if needed to add translation ".$ident.'... ';
1284
+		}
1173 1285
 		$querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1";
1174 1286
 		$querysi_values = array(':registration' => $registration);
1175 1287
 		try {
@@ -1177,7 +1289,9 @@  discard block
 block discarded – undo
1177 1289
 			$sthsi = $this->db->prepare($querysi);
1178 1290
 			$sthsi->execute($querysi_values);
1179 1291
 		} catch(PDOException $e) {
1180
-			if ($globalDebug) echo $e->getMessage();
1292
+			if ($globalDebug) {
1293
+				echo $e->getMessage();
1294
+			}
1181 1295
 			return "error : ".$e->getMessage();
1182 1296
 		}
1183 1297
 		$resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
@@ -1186,9 +1300,14 @@  discard block
 block discarded – undo
1186 1300
 		if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
1187 1301
 			$Translation = new Translation($this->db);
1188 1302
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1189
-			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1190
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1191
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1303
+			if ($globalDebug) {
1304
+				echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1305
+			}
1306
+			if ($ident != $trans_ident) {
1307
+				$Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1308
+			} elseif ($trans_ident == $ident) {
1309
+				$Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1310
+			}
1192 1311
 		} else {
1193 1312
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1194 1313
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1197,18 +1316,25 @@  discard block
 block discarded – undo
1197 1316
 					$sth = $this->db->prepare($query);
1198 1317
 					$sth->execute($query_values);
1199 1318
 				} catch(PDOException $e) {
1200
-					if ($globalDebug) echo $e->getMessage();
1319
+					if ($globalDebug) {
1320
+						echo $e->getMessage();
1321
+					}
1201 1322
 					return "error : ".$e->getMessage();
1202 1323
 				}
1203 1324
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1204 1325
 				$sth->closeCursor();
1205
-				if (isset($result['modes'])) $hex = $result['modes'];
1206
-				else $hex = '';
1326
+				if (isset($result['modes'])) {
1327
+					$hex = $result['modes'];
1328
+				} else {
1329
+					$hex = '';
1330
+				}
1207 1331
 				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1208 1332
 				$this->SI->add($SI_data);
1209 1333
 			}
1210 1334
 		}
1211
-		if ($globalDebug) echo 'Done'."\n";
1335
+		if ($globalDebug) {
1336
+			echo 'Done'."\n";
1337
+		}
1212 1338
 
1213 1339
 		$query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1";
1214 1340
 		$query_values = array(':ident' => $icao);
@@ -1217,15 +1343,20 @@  discard block
 block discarded – undo
1217 1343
 			$sth = $this->db->prepare($query);
1218 1344
 			$sth->execute($query_values);
1219 1345
 		} catch(PDOException $e) {
1220
-			if ($globalDebug) echo $e->getMessage();
1346
+			if ($globalDebug) {
1347
+				echo $e->getMessage();
1348
+			}
1221 1349
 			return "error : ".$e->getMessage();
1222 1350
 		}
1223 1351
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
1224 1352
 		$sth->closeCursor();
1225 1353
 		//print_r($result);
1226 1354
 		if (isset($result['flightaware_id'])) {
1227
-			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1228
-			else $ModeS = '';
1355
+			if (isset($result['ModeS'])) {
1356
+				$ModeS = $result['ModeS'];
1357
+			} else {
1358
+				$ModeS = '';
1359
+			}
1229 1360
 			if ($ModeS == '') {
1230 1361
 				$id = explode('-',$result['flightaware_id']);
1231 1362
 				$ModeS = $id[0];
@@ -1239,13 +1370,17 @@  discard block
 block discarded – undo
1239 1370
 					$sthc = $this->db->prepare($queryc);
1240 1371
 					$sthc->execute($queryc_values);
1241 1372
 				} catch(PDOException $e) {
1242
-					if ($globalDebug) echo $e->getMessage();
1373
+					if ($globalDebug) {
1374
+						echo $e->getMessage();
1375
+					}
1243 1376
 					return "error : ".$e->getMessage();
1244 1377
 				}
1245 1378
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1246 1379
 				$sthc->closeCursor();
1247 1380
 				if (count($row) ==  0) {
1248
-					if ($globalDebug) echo " Add to ModeS table - ";
1381
+					if ($globalDebug) {
1382
+						echo " Add to ModeS table - ";
1383
+					}
1249 1384
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1250 1385
 					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1251 1386
 					try {
@@ -1253,11 +1388,15 @@  discard block
 block discarded – undo
1253 1388
 						$sthi = $this->db->prepare($queryi);
1254 1389
 						$sthi->execute($queryi_values);
1255 1390
 					} catch(PDOException $e) {
1256
-						if ($globalDebug) echo $e->getMessage();
1391
+						if ($globalDebug) {
1392
+							echo $e->getMessage();
1393
+						}
1257 1394
 						return "error : ".$e->getMessage();
1258 1395
 					}
1259 1396
 				} else {
1260
-					if ($globalDebug) echo " Update ModeS table - ";
1397
+					if ($globalDebug) {
1398
+						echo " Update ModeS table - ";
1399
+					}
1261 1400
 					if ($ICAOTypeCode != '') {
1262 1401
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1263 1402
 						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
@@ -1270,7 +1409,9 @@  discard block
 block discarded – undo
1270 1409
 						$sthi = $this->db->prepare($queryi);
1271 1410
 						$sthi->execute($queryi_values);
1272 1411
 					} catch(PDOException $e) {
1273
-						if ($globalDebug) echo $e->getMessage();
1412
+						if ($globalDebug) {
1413
+							echo $e->getMessage();
1414
+						}
1274 1415
 						return "error : ".$e->getMessage();
1275 1416
 					}
1276 1417
 				}
@@ -1292,7 +1433,9 @@  discard block
 block discarded – undo
1292 1433
 					    return "error : ".$e->getMessage();
1293 1434
 				}
1294 1435
 				*/
1295
-				if ($globalDebug) echo " Update Spotter_output table - ";
1436
+				if ($globalDebug) {
1437
+					echo " Update Spotter_output table - ";
1438
+				}
1296 1439
 				if ($ICAOTypeCode != '') {
1297 1440
 					if ($globalDBdriver == 'mysql') {
1298 1441
 						$queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
@@ -1303,8 +1446,7 @@  discard block
 block discarded – undo
1303 1446
 				} else {
1304 1447
 					if ($globalDBdriver == 'mysql') {
1305 1448
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
1306
-					}
1307
-					elseif ($globalDBdriver == 'pgsql') {
1449
+					} elseif ($globalDBdriver == 'pgsql') {
1308 1450
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1309 1451
 					}
1310 1452
 					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
@@ -1314,15 +1456,21 @@  discard block
 block discarded – undo
1314 1456
 					$sthi = $this->db->prepare($queryi);
1315 1457
 					$sthi->execute($queryi_values);
1316 1458
 				} catch(PDOException $e) {
1317
-					if ($globalDebug) echo $e->getMessage();
1459
+					if ($globalDebug) {
1460
+						echo $e->getMessage();
1461
+					}
1318 1462
 					return "error : ".$e->getMessage();
1319 1463
 				}
1320 1464
 
1321 1465
 			}
1322 1466
 		} else {
1323
-			if ($globalDebug) echo " Can't find ModeS in spotter_output - ";
1467
+			if ($globalDebug) {
1468
+				echo " Can't find ModeS in spotter_output - ";
1469
+			}
1470
+		}
1471
+		if ($globalDebug) {
1472
+			echo "Done\n";
1324 1473
 		}
1325
-		if ($globalDebug) echo "Done\n";
1326 1474
 	}
1327 1475
 }
1328 1476
 ?>
Please login to merge, or discard this patch.
require/class.Image.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -319,6 +319,9 @@
 block discarded – undo
319 319
 		return false;
320 320
 	}
321 321
 
322
+	/**
323
+	 * @param string $aircraft_icao
324
+	 */
322 325
 	public function fromIvaoMtl($aircraft_icao,$airline_icao) {
323 326
 		$Common = new Common();
324 327
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
Please login to merge, or discard this patch.
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
 	}
13 13
 
14 14
 	/**
15
-	* Gets the images based on the aircraft registration
16
-	*
17
-	* @return Array the images list
18
-	*
19
-	*/
15
+	 * Gets the images based on the aircraft registration
16
+	 *
17
+	 * @return Array the images list
18
+	 *
19
+	 */
20 20
 	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
21 21
 	{
22 22
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 			WHERE spotter_image.registration = :registration";
30 30
 		$sth = $this->db->prepare($query);
31 31
 		$sth->execute(array(':registration' => $registration));
32
-          /*
32
+		  /*
33 33
         $images_array = array();
34 34
 	$temp_array = array();
35 35
 
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 	/**
55
-	* Gets the image copyright based on the Exif data
56
-	*
57
-	* @return String image copyright
58
-	*
59
-	*/
55
+	 * Gets the image copyright based on the Exif data
56
+	 *
57
+	 * @return String image copyright
58
+	 *
59
+	 */
60 60
 	public function getExifCopyright($url) {
61 61
 		$exif = exif_read_data($url);
62 62
 		$copyright = '';
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 	}
72 72
 
73 73
 	/**
74
-	* Adds the images based on the aircraft registration
75
-	*
76
-	* @return String either success or error
77
-	*
78
-	*/
74
+	 * Adds the images based on the aircraft registration
75
+	 *
76
+	 * @return String either success or error
77
+	 *
78
+	 */
79 79
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
80 80
 	{
81 81
 		global $globalDebug,$globalAircraftImageFetch;
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 	}
105 105
 
106 106
 	/**
107
-	* Gets the aircraft image
108
-	*
109
-	* @param String $aircraft_registration the registration of the aircraft
110
-	* @return Array the aircraft thumbnail, orignal url and copyright
111
-	*
112
-	*/
107
+	 * Gets the aircraft image
108
+	 *
109
+	 * @param String $aircraft_registration the registration of the aircraft
110
+	 * @return Array the aircraft thumbnail, orignal url and copyright
111
+	 *
112
+	 */
113 113
 	public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '')
114 114
 	{
115 115
 		global $globalAircraftImageSources, $globalIVAO;
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 	}
150 150
 
151 151
 	/**
152
-	* Gets the aircraft image from Planespotters
153
-	*
154
-	* @param String $aircraft_registration the registration of the aircraft
155
-	* @param String $aircraft_name type of the aircraft
156
-	* @return Array the aircraft thumbnail, orignal url and copyright
157
-	*
158
-	*/
152
+	 * Gets the aircraft image from Planespotters
153
+	 *
154
+	 * @param String $aircraft_registration the registration of the aircraft
155
+	 * @param String $aircraft_name type of the aircraft
156
+	 * @return Array the aircraft thumbnail, orignal url and copyright
157
+	 *
158
+	 */
159 159
 	public function fromPlanespotters($aircraft_registration, $aircraft_name='') {
160 160
 		$Common = new Common();
161 161
 		// If aircraft registration is only number, also check with aircraft model
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
 	}
183 183
 
184 184
 	/**
185
-	* Gets the aircraft image from Deviantart
186
-	*
187
-	* @param String $aircraft_registration the registration of the aircraft
188
-	* @param String $aircraft_name type of the aircraft
189
-	* @return Array the aircraft thumbnail, orignal url and copyright
190
-	*
191
-	*/
185
+	 * Gets the aircraft image from Deviantart
186
+	 *
187
+	 * @param String $aircraft_registration the registration of the aircraft
188
+	 * @param String $aircraft_name type of the aircraft
189
+	 * @return Array the aircraft thumbnail, orignal url and copyright
190
+	 *
191
+	 */
192 192
 	public function fromDeviantart($aircraft_registration, $aircraft_name='') {
193 193
 		$Common = new Common();
194 194
 		// If aircraft registration is only number, also check with aircraft model
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
 	}
217 217
 
218 218
 	/**
219
-	* Gets the aircraft image from JetPhotos
220
-	*
221
-	* @param String $aircraft_registration the registration of the aircraft
222
-	* @param String $aircraft_name type of the aircraft
223
-	* @return Array the aircraft thumbnail, orignal url and copyright
224
-	*
225
-	*/
219
+	 * Gets the aircraft image from JetPhotos
220
+	 *
221
+	 * @param String $aircraft_registration the registration of the aircraft
222
+	 * @param String $aircraft_name type of the aircraft
223
+	 * @return Array the aircraft thumbnail, orignal url and copyright
224
+	 *
225
+	 */
226 226
 	public function fromJetPhotos($aircraft_registration, $aircraft_name='') {
227 227
 		$Common = new Common();
228 228
 		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
 	}
259 259
 
260 260
 	/**
261
-	* Gets the aircraft image from PlanePictures
262
-	*
263
-	* @param String $aircraft_registration the registration of the aircraft
264
-	* @param String $aircraft_name type of the aircraft
265
-	* @return Array the aircraft thumbnail, orignal url and copyright
266
-	*
267
-	*/
261
+	 * Gets the aircraft image from PlanePictures
262
+	 *
263
+	 * @param String $aircraft_registration the registration of the aircraft
264
+	 * @param String $aircraft_name type of the aircraft
265
+	 * @return Array the aircraft thumbnail, orignal url and copyright
266
+	 *
267
+	 */
268 268
 	public function fromPlanePictures($aircraft_registration, $aircraft_name='') {
269 269
 		$Common = new Common();
270 270
 		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
@@ -292,13 +292,13 @@  discard block
 block discarded – undo
292 292
 	}
293 293
 
294 294
 	/**
295
-	* Gets the aircraft image from Flickr
296
-	*
297
-	* @param String $aircraft_registration the registration of the aircraft
298
-	* @param String $aircraft_name type of the aircraft
299
-	* @return Array the aircraft thumbnail, orignal url and copyright
300
-	*
301
-	*/
295
+	 * Gets the aircraft image from Flickr
296
+	 *
297
+	 * @param String $aircraft_registration the registration of the aircraft
298
+	 * @param String $aircraft_name type of the aircraft
299
+	 * @return Array the aircraft thumbnail, orignal url and copyright
300
+	 *
301
+	 */
302 302
 	public function fromFlickr($aircraft_registration,$aircraft_name='') {
303 303
 		$Common = new Common();
304 304
 		if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
 	}
337 337
 
338 338
 	/**
339
-	* Gets the aircraft image from Bing
340
-	*
341
-	* @param String $aircraft_registration the registration of the aircraft
342
-	* @param String $aircraft_name type of the aircraft
343
-	* @return Array the aircraft thumbnail, orignal url and copyright
344
-	*
345
-	*/
339
+	 * Gets the aircraft image from Bing
340
+	 *
341
+	 * @param String $aircraft_registration the registration of the aircraft
342
+	 * @param String $aircraft_name type of the aircraft
343
+	 * @return Array the aircraft thumbnail, orignal url and copyright
344
+	 *
345
+	 */
346 346
 	public function fromBing($aircraft_registration,$aircraft_name='') {
347 347
 		global $globalImageBingKey;
348 348
 		$Common = new Common();
@@ -368,13 +368,13 @@  discard block
 block discarded – undo
368 368
 	}
369 369
 
370 370
 	/**
371
-	* Gets the aircraft image from airport-data
372
-	*
373
-	* @param String $aircraft_registration the registration of the aircraft
374
-	* @param String $aircraft_name type of the aircraft
375
-	* @return Array the aircraft thumbnail, orignal url and copyright
376
-	*
377
-	*/
371
+	 * Gets the aircraft image from airport-data
372
+	 *
373
+	 * @param String $aircraft_registration the registration of the aircraft
374
+	 * @param String $aircraft_name type of the aircraft
375
+	 * @return Array the aircraft thumbnail, orignal url and copyright
376
+	 *
377
+	 */
378 378
 	public function fromAirportData($aircraft_registration,$aircraft_name='') {
379 379
 		$Common = new Common();
380 380
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
@@ -393,13 +393,13 @@  discard block
 block discarded – undo
393 393
 	}
394 394
 
395 395
 	/**
396
-	* Gets the aircraft image from WikiMedia
397
-	*
398
-	* @param String $aircraft_registration the registration of the aircraft
399
-	* @param String $aircraft_name type of the aircraft
400
-	* @return Array the aircraft thumbnail, orignal url and copyright
401
-	*
402
-	*/
396
+	 * Gets the aircraft image from WikiMedia
397
+	 *
398
+	 * @param String $aircraft_registration the registration of the aircraft
399
+	 * @param String $aircraft_name type of the aircraft
400
+	 * @return Array the aircraft thumbnail, orignal url and copyright
401
+	 *
402
+	 */
403 403
 	public function fromWikimedia($aircraft_registration,$aircraft_name='') {
404 404
 		$Common = new Common();
405 405
 		if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
@@ -449,13 +449,13 @@  discard block
 block discarded – undo
449 449
 	}
450 450
 
451 451
 	/**
452
-	* Gets the aircraft image from custom url
453
-	*
454
-	* @param String $aircraft_registration the registration of the aircraft
455
-	* @param String $aircraft_name type of the aircraft
456
-	* @return Array the aircraft thumbnail, orignal url and copyright
457
-	*
458
-	*/
452
+	 * Gets the aircraft image from custom url
453
+	 *
454
+	 * @param String $aircraft_registration the registration of the aircraft
455
+	 * @param String $aircraft_name type of the aircraft
456
+	 * @return Array the aircraft thumbnail, orignal url and copyright
457
+	 *
458
+	 */
459 459
 	public function fromCustomSource($aircraft_registration,$aircraft_name='') {
460 460
 		global $globalAircraftCustomSources;
461 461
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
Please login to merge, or discard this patch.
Braces   +126 added lines, -46 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
23 23
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24 24
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
25
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
25
+		if ($registration == '' && $aircraft_icao != '') {
26
+			$registration = $aircraft_icao.$airline_icao;
27
+		}
26 28
 		$registration = trim($registration);
27 29
 		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright
28 30
 			FROM spotter_image 
@@ -60,8 +62,11 @@  discard block
 block discarded – undo
60 62
 	public function getExifCopyright($url) {
61 63
 		$exif = exif_read_data($url);
62 64
 		$copyright = '';
63
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
64
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
65
+		if (isset($exif['COMPUTED']['copyright'])) {
66
+			$copyright = $exif['COMPUTED']['copyright'];
67
+		} elseif (isset($exif['copyright'])) {
68
+			$copyright = $exif['copyright'];
69
+		}
65 70
 		if ($copyright != '') {
66 71
 			$copyright = str_replace('Copyright ','',$copyright);
67 72
 			$copyright = str_replace('© ','',$copyright);
@@ -79,18 +84,29 @@  discard block
 block discarded – undo
79 84
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
80 85
 	{
81 86
 		global $globalDebug,$globalAircraftImageFetch;
82
-		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
87
+		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) {
88
+			return '';
89
+		}
83 90
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
84 91
 		$registration = trim($registration);
85 92
 		//getting the aircraft image
86
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
87
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
88
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
89
-		else return "success";
93
+		if ($globalDebug && $registration != '') {
94
+			echo 'Try to find an aircraft image for '.$registration.'...';
95
+		} elseif ($globalDebug && $aircraft_icao != '') {
96
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
97
+		} elseif ($globalDebug && $airline_icao != '') {
98
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
99
+		} else {
100
+			return "success";
101
+		}
90 102
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
91
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
103
+		if ($registration == '' && $aircraft_icao != '') {
104
+			$registration = $aircraft_icao.$airline_icao;
105
+		}
92 106
 		if ($image_url['original'] != '') {
93
-			if ($globalDebug) echo 'Found !'."\n";
107
+			if ($globalDebug) {
108
+				echo 'Found !'."\n";
109
+			}
94 110
 			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
95 111
 			try {
96 112
 				$sth = $this->db->prepare($query);
@@ -99,7 +115,9 @@  discard block
 block discarded – undo
99 115
 				echo $e->getMessage()."\n";
100 116
 				return "error";
101 117
 			}
102
-		} elseif ($globalDebug) echo "Not found :'(\n";
118
+		} elseif ($globalDebug) {
119
+			echo "Not found :'(\n";
120
+		}
103 121
 		return "success";
104 122
 	}
105 123
 
@@ -114,36 +132,75 @@  discard block
 block discarded – undo
114 132
 	{
115 133
 		global $globalAircraftImageSources, $globalIVAO;
116 134
 		$Spotter = new Spotter($this->db);
117
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
135
+		if (!isset($globalIVAO)) {
136
+			$globalIVAO = FALSE;
137
+		}
118 138
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
119 139
 		if ($aircraft_registration != '') {
120
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
140
+			if (strpos($aircraft_registration,'/') !== false) {
141
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
142
+			}
121 143
 			$aircraft_registration = urlencode(trim($aircraft_registration));
122 144
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
123
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
124
-			else $aircraft_name = '';
125
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
126
-			else $aircraft_icao = '';
127
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
128
-			else $airline_icao = '';
145
+			if (isset($aircraft_info[0]['aircraft_name'])) {
146
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
147
+			} else {
148
+				$aircraft_name = '';
149
+			}
150
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
151
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
152
+			} else {
153
+				$aircraft_icao = '';
154
+			}
155
+			if (isset($aircraft_info[0]['airline_icao'])) {
156
+				$airline_icao = $aircraft_info[0]['airline_icao'];
157
+			} else {
158
+				$airline_icao = '';
159
+			}
129 160
 		} elseif ($aircraft_icao != '') {
130 161
 			$aircraft_registration = $aircraft_icao;
131 162
 			$aircraft_name = '';
132
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
133
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
163
+		} else {
164
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
165
+		}
166
+		if (!isset($globalAircraftImageSources)) {
167
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
168
+		}
134 169
 		foreach ($globalAircraftImageSources as $source) {
135 170
 			$source = strtolower($source);
136
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
137
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
138
-			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
139
-			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name);
140
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
141
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
142
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
143
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
144
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
145
-			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
146
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
171
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
172
+				$images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
173
+			}
174
+			if ($source == 'planespotters' && !$globalIVAO) {
175
+				$images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
176
+			}
177
+			if ($source == 'flickr') {
178
+				$images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
179
+			}
180
+			if ($source == 'bing') {
181
+				$images_array = $this->fromBing($aircraft_registration,$aircraft_name);
182
+			}
183
+			if ($source == 'deviantart') {
184
+				$images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
185
+			}
186
+			if ($source == 'wikimedia') {
187
+				$images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
188
+			}
189
+			if ($source == 'jetphotos' && !$globalIVAO) {
190
+				$images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
191
+			}
192
+			if ($source == 'planepictures' && !$globalIVAO) {
193
+				$images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
194
+			}
195
+			if ($source == 'airportdata' && !$globalIVAO) {
196
+				$images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
197
+			}
198
+			if ($source == 'customsources') {
199
+				$images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
200
+			}
201
+			if (isset($images_array) && $images_array['original'] != '') {
202
+				return $images_array;
203
+			}
147 204
 		}
148 205
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
149 206
 	}
@@ -301,8 +358,11 @@  discard block
 block discarded – undo
301 358
 	*/
302 359
 	public function fromFlickr($aircraft_registration,$aircraft_name='') {
303 360
 		$Common = new Common();
304
-		if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
305
-		else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
361
+		if ($aircraft_name != '') {
362
+			$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
363
+		} else {
364
+			$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
365
+		}
306 366
 		$data = $Common->getData($url);
307 367
 		if ($xml = simplexml_load_string($data)) {
308 368
 			if (isset($xml->channel->item)) {
@@ -346,9 +406,14 @@  discard block
 block discarded – undo
346 406
 	public function fromBing($aircraft_registration,$aircraft_name='') {
347 407
 		global $globalImageBingKey;
348 408
 		$Common = new Common();
349
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
350
-		if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
351
-		else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
409
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
410
+			return false;
411
+		}
412
+		if ($aircraft_name != '') {
413
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
414
+		} else {
415
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
416
+		}
352 417
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
353 418
 		$data = $Common->getData($url,'get','',$headers);
354 419
 		$result = json_decode($data);
@@ -402,13 +467,18 @@  discard block
 block discarded – undo
402 467
 	*/
403 468
 	public function fromWikimedia($aircraft_registration,$aircraft_name='') {
404 469
 		$Common = new Common();
405
-		if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
406
-		else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
470
+		if ($aircraft_name != '') {
471
+			$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
472
+		} else {
473
+			$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
474
+		}
407 475
 		$data = $Common->getData($url);
408 476
 		$result = json_decode($data);
409 477
 		if (isset($result->query->search[0]->title)) {
410 478
 			$fileo = $result->query->search[0]->title;
411
-			if (substr($fileo,-3) == 'pdf') return false;
479
+			if (substr($fileo,-3) == 'pdf') {
480
+				return false;
481
+			}
412 482
 			$file = urlencode($fileo);
413 483
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
414 484
 			$data2 = $Common->getData($url2);
@@ -460,7 +530,9 @@  discard block
 block discarded – undo
460 530
 		global $globalAircraftCustomSources;
461 531
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
462 532
 		if (!empty($globalAircraftImageCustomSources)) {
463
-			if (!isset($globalAircraftImageCustomSources[0])) $globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources;
533
+			if (!isset($globalAircraftImageCustomSources[0])) {
534
+				$globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources;
535
+			}
464 536
 			foreach ($globalAircraftImageCustomSources as $source) {
465 537
 				$Common = new Common();
466 538
 				$url = str_replace('{registration}',$aircraft_registration,$source['original']);
@@ -469,17 +541,25 @@  discard block
 block discarded – undo
469 541
 					$image_url = array();
470 542
 					$image_url['thumbnail'] = $url_thumbnail;
471 543
 					$image_url['original'] = $url;
472
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
473
-					else $exifCopyright = '';
474
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
475
-					else $image_url['copyright'] = $source['copyright'];
544
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
545
+						$exifCopyright = $this->getExifCopyright($url);
546
+					} else {
547
+						$exifCopyright = '';
548
+					}
549
+					if ($exifCopyright  != '') {
550
+						$image_url['copyright'] = $exifCopyright;
551
+					} else {
552
+						$image_url['copyright'] = $source['copyright'];
553
+					}
476 554
 					$image_url['source_website'] = $source['source_website'];
477 555
 					$image_url['source'] = $source['source'];
478 556
 					return $image_url;
479 557
 				}
480 558
 			}
481 559
 			return false;
482
-		} else return false;
560
+		} else {
561
+			return false;
562
+		}
483 563
 	}
484 564
 }
485 565
 
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 	* @return Array the images list
18 18
 	*
19 19
 	*/
20
-	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
20
+	public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
21 21
 	{
22
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
23
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
22
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
23
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
24
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
25 25
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
26 26
 		$registration = trim($registration);
27
-		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
27
+		$query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
28 28
 			FROM spotter_image 
29 29
 			WHERE spotter_image.registration = :registration";
30 30
 		$sth = $this->db->prepare($query);
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
64 64
 		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
65 65
 		if ($copyright != '') {
66
-			$copyright = str_replace('Copyright ','',$copyright);
67
-			$copyright = str_replace('© ','',$copyright);
68
-			$copyright = str_replace('(c) ','',$copyright);
66
+			$copyright = str_replace('Copyright ', '', $copyright);
67
+			$copyright = str_replace('© ', '', $copyright);
68
+			$copyright = str_replace('(c) ', '', $copyright);
69 69
 		}
70 70
 		return $copyright;
71 71
 	}
@@ -76,26 +76,26 @@  discard block
 block discarded – undo
76 76
 	* @return String either success or error
77 77
 	*
78 78
 	*/
79
-	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
79
+	public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
80 80
 	{
81
-		global $globalDebug,$globalAircraftImageFetch;
81
+		global $globalDebug, $globalAircraftImageFetch;
82 82
 		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
83
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
83
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
84 84
 		$registration = trim($registration);
85 85
 		//getting the aircraft image
86 86
 		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
87 87
 		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
88 88
 		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
89 89
 		else return "success";
90
-		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
90
+		$image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao);
91 91
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
92 92
 		if ($image_url['original'] != '') {
93 93
 			if ($globalDebug) echo 'Found !'."\n";
94
-			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
94
+			$query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
95 95
 			try {
96 96
 				$sth = $this->db->prepare($query);
97
-				$sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website']));
98
-			} catch(PDOException $e) {
97
+				$sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website']));
98
+			} catch (PDOException $e) {
99 99
 				echo $e->getMessage()."\n";
100 100
 				return "error";
101 101
 			}
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 		global $globalAircraftImageSources, $globalIVAO;
116 116
 		$Spotter = new Spotter($this->db);
117 117
 		if (!isset($globalIVAO)) $globalIVAO = FALSE;
118
-		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
118
+		$aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING);
119 119
 		if ($aircraft_registration != '') {
120
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
120
+			if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
121 121
 			$aircraft_registration = urlencode(trim($aircraft_registration));
122 122
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
123 123
 			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
@@ -129,23 +129,23 @@  discard block
 block discarded – undo
129 129
 		} elseif ($aircraft_icao != '') {
130 130
 			$aircraft_registration = $aircraft_icao;
131 131
 			$aircraft_name = '';
132
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
133
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
132
+		} else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
133
+		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
134 134
 		foreach ($globalAircraftImageSources as $source) {
135 135
 			$source = strtolower($source);
136
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
137
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
138
-			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
139
-			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name);
140
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
141
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
142
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
143
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
144
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
145
-			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
136
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao, $airline_icao);
137
+			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration, $aircraft_name);
138
+			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration, $aircraft_name);
139
+			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration, $aircraft_name);
140
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration, $aircraft_name);
141
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration, $aircraft_name);
142
+			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration, $aircraft_name);
143
+			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration, $aircraft_name);
144
+			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration, $aircraft_name);
145
+			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration, $aircraft_name);
146 146
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
147 147
 		}
148
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
148
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
149 149
 	}
150 150
 
151 151
 	/**
@@ -156,24 +156,24 @@  discard block
 block discarded – undo
156 156
 	* @return Array the aircraft thumbnail, orignal url and copyright
157 157
 	*
158 158
 	*/
159
-	public function fromPlanespotters($aircraft_registration, $aircraft_name='') {
159
+	public function fromPlanespotters($aircraft_registration, $aircraft_name = '') {
160 160
 		$Common = new Common();
161 161
 		// If aircraft registration is only number, also check with aircraft model
162
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
163
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
162
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
163
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
164 164
 		} else {
165 165
 			//$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss';
166
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
166
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
167 167
 		}
168 168
 		$data = $Common->getData($url);
169 169
 		if ($xml = simplexml_load_string($data)) {
170 170
 			if (isset($xml->channel->item)) {
171 171
 				$image_url = array();
172
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
172
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
173 173
 				$image_url['thumbnail'] = $thumbnail_url;
174
-				$image_url['original'] = str_replace('thumbnail','original',$thumbnail_url);
175
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
176
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
174
+				$image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url);
175
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
176
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
177 177
 				$image_url['source'] = 'planespotters';
178 178
 				return $image_url;
179 179
 			}
@@ -189,25 +189,25 @@  discard block
 block discarded – undo
189 189
 	* @return Array the aircraft thumbnail, orignal url and copyright
190 190
 	*
191 191
 	*/
192
-	public function fromDeviantart($aircraft_registration, $aircraft_name='') {
192
+	public function fromDeviantart($aircraft_registration, $aircraft_name = '') {
193 193
 		$Common = new Common();
194 194
 		// If aircraft registration is only number, also check with aircraft model
195
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
196
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name);
195
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
196
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$aircraft_registration.'%20'.urlencode($aircraft_name);
197 197
 		} else {
198
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration;
198
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$aircraft_registration;
199 199
 		}
200 200
 
201 201
 		$data = $Common->getData($url);
202 202
 		if ($xml = simplexml_load_string($data)) {
203 203
 			if (isset($xml->channel->item->link)) {
204 204
 				$image_url = array();
205
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
205
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
206 206
 				$image_url['thumbnail'] = $thumbnail_url;
207
-				$original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
207
+				$original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
208 208
 				$image_url['original'] = $original_url;
209
-				$image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
210
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
209
+				$image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
210
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
211 211
 				$image_url['source'] = 'deviantart';
212 212
 				return $image_url;
213 213
 			}
@@ -223,32 +223,32 @@  discard block
 block discarded – undo
223 223
 	* @return Array the aircraft thumbnail, orignal url and copyright
224 224
 	*
225 225
 	*/
226
-	public function fromJetPhotos($aircraft_registration, $aircraft_name='') {
226
+	public function fromJetPhotos($aircraft_registration, $aircraft_name = '') {
227 227
 		$Common = new Common();
228
-		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
228
+		$url = 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
229 229
 		$data = $Common->getData($url);
230 230
 		$dom = new DOMDocument();
231 231
 		@$dom->loadHTML($data);
232 232
 		$all_pics = array();
233
-		foreach($dom->getElementsByTagName('img') as $image) {
233
+		foreach ($dom->getElementsByTagName('img') as $image) {
234 234
 			if ($image->getAttribute('itemprop') == "http://schema.org/image") {
235 235
 				$all_pics[] = $image->getAttribute('src');
236 236
 			}
237 237
 		}
238 238
 		$all_authors = array();
239
-		foreach($dom->getElementsByTagName('meta') as $author) {
239
+		foreach ($dom->getElementsByTagName('meta') as $author) {
240 240
 			if ($author->getAttribute('itemprop') == "http://schema.org/author") {
241 241
 				$all_authors[] = $author->getAttribute('content');
242 242
 			}
243 243
 		}
244 244
 		$all_ref = array();
245
-		foreach($dom->getElementsByTagName('a') as $link) {
245
+		foreach ($dom->getElementsByTagName('a') as $link) {
246 246
 			$all_ref[] = $link->getAttribute('href');
247 247
 		}
248 248
 		if (isset($all_pics[0])) {
249 249
 			$image_url = array();
250 250
 			$image_url['thumbnail'] = $all_pics[0];
251
-			$image_url['original'] = str_replace('_tb','',$all_pics[0]);
251
+			$image_url['original'] = str_replace('_tb', '', $all_pics[0]);
252 252
 			$image_url['copyright'] = $all_authors[0];
253 253
 			$image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8];
254 254
 			$image_url['source'] = 'JetPhotos';
@@ -265,24 +265,24 @@  discard block
 block discarded – undo
265 265
 	* @return Array the aircraft thumbnail, orignal url and copyright
266 266
 	*
267 267
 	*/
268
-	public function fromPlanePictures($aircraft_registration, $aircraft_name='') {
268
+	public function fromPlanePictures($aircraft_registration, $aircraft_name = '') {
269 269
 		$Common = new Common();
270
-		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
270
+		$url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
271 271
 		$data = $Common->getData($url);
272 272
 		$dom = new DOMDocument();
273 273
 		@$dom->loadHTML($data);
274 274
 		$all_pics = array();
275
-		foreach($dom->getElementsByTagName('img') as $image) {
275
+		foreach ($dom->getElementsByTagName('img') as $image) {
276 276
 			$all_pics[] = $image->getAttribute('src');
277 277
 		}
278 278
 		$all_links = array();
279
-		foreach($dom->getElementsByTagName('a') as $link) {
280
-			$all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href'));
279
+		foreach ($dom->getElementsByTagName('a') as $link) {
280
+			$all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href'));
281 281
 		}
282
-		if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1])) {
282
+		if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1])) {
283 283
 			$image_url = array();
284 284
 			$image_url['thumbnail'] = 'http://www.planepictures.net'.$all_pics[1];
285
-			$image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN','',$all_pics[1]);
285
+			$image_url['original'] = 'http://www.planepictures.net'.str_replace('_TN', '', $all_pics[1]);
286 286
 			$image_url['copyright'] = $all_links[6]['text'];
287 287
 			$image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href'];
288 288
 			$image_url['source'] = 'PlanePictures';
@@ -299,19 +299,19 @@  discard block
 block discarded – undo
299 299
 	* @return Array the aircraft thumbnail, orignal url and copyright
300 300
 	*
301 301
 	*/
302
-	public function fromFlickr($aircraft_registration,$aircraft_name='') {
302
+	public function fromFlickr($aircraft_registration, $aircraft_name = '') {
303 303
 		$Common = new Common();
304 304
 		if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
305 305
 		else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
306 306
 		$data = $Common->getData($url);
307 307
 		if ($xml = simplexml_load_string($data)) {
308 308
 			if (isset($xml->channel->item)) {
309
-				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
309
+				$original_url = trim((string) $xml->channel->item->enclosure->attributes()->url);
310 310
 				$image_url = array();
311 311
 				$image_url['thumbnail'] = $original_url;
312 312
 				$image_url['original'] = $original_url;
313
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
314
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
313
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
314
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
315 315
 				$image_url['source'] = 'flickr';
316 316
 				return $image_url;
317 317
 			}
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 		return false;
320 320
 	}
321 321
 
322
-	public function fromIvaoMtl($aircraft_icao,$airline_icao) {
322
+	public function fromIvaoMtl($aircraft_icao, $airline_icao) {
323 323
 		$Common = new Common();
324 324
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
325 325
 		if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) {
@@ -343,14 +343,14 @@  discard block
 block discarded – undo
343 343
 	* @return Array the aircraft thumbnail, orignal url and copyright
344 344
 	*
345 345
 	*/
346
-	public function fromBing($aircraft_registration,$aircraft_name='') {
346
+	public function fromBing($aircraft_registration, $aircraft_name = '') {
347 347
 		global $globalImageBingKey;
348 348
 		$Common = new Common();
349 349
 		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
350 350
 		if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
351 351
 		else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
352
-		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
353
-		$data = $Common->getData($url,'get','',$headers);
352
+		$headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey));
353
+		$data = $Common->getData($url, 'get', '', $headers);
354 354
 		$result = json_decode($data);
355 355
 		if (isset($result->d->results[0]->MediaUrl)) {
356 356
 			$image_url = array();
@@ -375,14 +375,14 @@  discard block
 block discarded – undo
375 375
 	* @return Array the aircraft thumbnail, orignal url and copyright
376 376
 	*
377 377
 	*/
378
-	public function fromAirportData($aircraft_registration,$aircraft_name='') {
378
+	public function fromAirportData($aircraft_registration, $aircraft_name = '') {
379 379
 		$Common = new Common();
380 380
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
381 381
 		$data = $Common->getData($url);
382 382
 		$result = json_decode($data);
383 383
 		if (isset($result->count) && $result->count > 0) {
384 384
 			$image_url = array();
385
-			$image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image);
385
+			$image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image);
386 386
 			$image_url['source_website'] = $result->data[0]->link;
387 387
 			$image_url['thumbnail'] = $result->data[0]->image;
388 388
 			$image_url['copyright'] = $result->data[0]->photographer;
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 	* @return Array the aircraft thumbnail, orignal url and copyright
401 401
 	*
402 402
 	*/
403
-	public function fromWikimedia($aircraft_registration,$aircraft_name='') {
403
+	public function fromWikimedia($aircraft_registration, $aircraft_name = '') {
404 404
 		$Common = new Common();
405 405
 		if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
406 406
 		else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 		$result = json_decode($data);
409 409
 		if (isset($result->query->search[0]->title)) {
410 410
 			$fileo = $result->query->search[0]->title;
411
-			if (substr($fileo,-3) == 'pdf') return false;
411
+			if (substr($fileo, -3) == 'pdf') return false;
412 412
 			$file = urlencode($fileo);
413 413
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
414 414
 			$data2 = $Common->getData($url2);
@@ -433,11 +433,11 @@  discard block
 block discarded – undo
433 433
 				if (isset($result2->query->pages)) {
434 434
 					foreach ($result2->query->pages as $page) {
435 435
 						if (isset($page->imageinfo[0]->extmetadata->Artist)) {
436
-							$image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
436
+							$image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
437 437
 							if (isset($page->imageinfo[0]->extmetadata->License->value)) {
438 438
 								$image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')';
439 439
 							}
440
-							$image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright']));
440
+							$image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright']));
441 441
 							return $image_url;
442 442
 						}
443 443
 					}
@@ -456,22 +456,22 @@  discard block
 block discarded – undo
456 456
 	* @return Array the aircraft thumbnail, orignal url and copyright
457 457
 	*
458 458
 	*/
459
-	public function fromCustomSource($aircraft_registration,$aircraft_name='') {
459
+	public function fromCustomSource($aircraft_registration, $aircraft_name = '') {
460 460
 		global $globalAircraftImageCustomSources;
461 461
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
462 462
 		if (!empty($globalAircraftImageCustomSources)) {
463 463
 			if (!isset($globalAircraftImageCustomSources[0])) $globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources;
464 464
 			foreach ($globalAircraftImageCustomSources as $source) {
465 465
 				$Common = new Common();
466
-				$url = str_replace('{registration}',$aircraft_registration,$source['original']);
467
-				$url_thumbnail = str_replace('{registration}',$aircraft_registration,$source['original']);
466
+				$url = str_replace('{registration}', $aircraft_registration, $source['original']);
467
+				$url_thumbnail = str_replace('{registration}', $aircraft_registration, $source['original']);
468 468
 				if ($Common->urlexist($url)) {
469 469
 					$image_url = array();
470 470
 					$image_url['thumbnail'] = $url_thumbnail;
471 471
 					$image_url['original'] = $url;
472 472
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
473 473
 					else $exifCopyright = '';
474
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
474
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
475 475
 					else $image_url['copyright'] = $source['copyright'];
476 476
 					$image_url['source_website'] = $source['source_website'];
477 477
 					$image_url['source'] = $source['source'];
Please login to merge, or discard this patch.
require/class.METAR.php 3 patches
Braces   +94 added lines, -36 removed lines patch added patch discarded remove patch
@@ -58,8 +58,11 @@  discard block
 block discarded – undo
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
61
-                if ($row['nb'] > 0) return false;
62
-                else return true;
61
+                if ($row['nb'] > 0) {
62
+                	return false;
63
+                } else {
64
+                	return true;
65
+                }
63 66
         }
64 67
 
65 68
         public static function insert_last_update() {
@@ -83,9 +86,14 @@  discard block
 block discarded – undo
83 86
     		//$pieces = explode(' ',$data);
84 87
     		$pieces = preg_split('/\s/',$data);
85 88
     		$pos = 0;
86
-    		if ($pieces[0] == 'METAR') $pos++;
87
-    		elseif ($pieces[0] == 'SPECI') $pos++;
88
-    		if (strlen($pieces[$pos]) != 4) $pos++;
89
+    		if ($pieces[0] == 'METAR') {
90
+    			$pos++;
91
+    		} elseif ($pieces[0] == 'SPECI') {
92
+    			$pos++;
93
+    		}
94
+    		if (strlen($pieces[$pos]) != 4) {
95
+    			$pos++;
96
+    		}
89 97
     		$result = array();
90 98
     		$result['location'] = $pieces[$pos];
91 99
     		$pos++;
@@ -94,16 +102,26 @@  discard block
 block discarded – undo
94 102
     		$c = count($pieces);
95 103
     		for($pos++; $pos < $c; $pos++) {
96 104
     			$piece = $pieces[$pos];
97
-    			if ($piece == 'RMK') break;
98
-    			if ($piece == 'AUTO') $result['auto'] = true;
99
-    			if ($piece == 'COR') $result['correction'] = true;
105
+    			if ($piece == 'RMK') {
106
+    				break;
107
+    			}
108
+    			if ($piece == 'AUTO') {
109
+    				$result['auto'] = true;
110
+    			}
111
+    			if ($piece == 'COR') {
112
+    				$result['correction'] = true;
113
+    			}
100 114
     			// Wind Speed
101 115
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
102 116
     				$result['wind']['direction'] = (float)$matches[1];
103 117
 				$result['wind']['unit'] = $matches[4];
104
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
105
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
106
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
118
+    				if ($result['wind']['unit'] == 'KT') {
119
+    					$result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
120
+    				} elseif ($result['wind']['unit'] == 'KPH') {
121
+    					$result['wind']['speed'] = round(((float)$matches[2])*1000,2);
122
+    				} elseif ($result['wind']['unit'] == 'MPS') {
123
+    					$result['wind']['speed'] = round(((float)$matches[2]),2);
124
+    				}
107 125
 				$result['wind']['gust'] = (float)$matches[3];
108 126
 				$result['wind']['unit'] = $matches[4];
109 127
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
@@ -185,14 +203,23 @@  discard block
 block discarded – undo
185 203
     				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
186 204
     				$type = $matches[1];
187 205
     				$cloud = array();
188
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
189
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
190
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
191
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
192
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
193
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
194
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
195
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
206
+    				if ($type == 'SKC') {
207
+    					$cloud['type'] = 'No cloud/Sky clear';
208
+    				} elseif ($type == 'CLR') {
209
+    					$cloud['type'] = 'No cloud below 12,000ft (3700m)';
210
+    				} elseif ($type == 'NSC') {
211
+    					$cloud['type'] = 'No significant cloud';
212
+    				} elseif ($type == 'FEW') {
213
+    					$cloud['type'] = 'Few';
214
+    				} elseif ($type == 'SCT') {
215
+    					$cloud['type'] = 'Scattered';
216
+    				} elseif ($type == 'BKN') {
217
+    					$cloud['type'] = 'Broken';
218
+    				} elseif ($type == 'OVC') {
219
+    					$cloud['type'] = 'Overcast/Full cloud coverage';
220
+    				} elseif ($type == 'VV') {
221
+    					$cloud['type'] = 'Vertical visibility';
222
+    				}
196 223
     				$cloud['type_code'] = $type;
197 224
     				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
198 225
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
@@ -222,8 +249,11 @@  discard block
 block discarded – undo
222 249
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
223 250
     				//echo $piece;
224 251
     				//print_r($matches);
225
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
226
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
252
+    				if (isset($matches[5])) {
253
+    					$range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
254
+    				} else {
255
+    					$range = array('exact' => (float)$matches[2], 'unit' => 'M');
256
+    				}
227 257
 				if (isset($matches[3])) {
228 258
 					$range = Array(
229 259
 					    'from' => (float)$matches[2],
@@ -256,8 +286,11 @@  discard block
 block discarded – undo
256 286
 				if (isset($matches[3])) {
257 287
 					$text[] = $this->texts[$matches[3]];
258 288
 				}
259
-				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
260
-				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
289
+				if (!isset($result['weather'])) {
290
+					$result['weather'] = implode(' ', $text);
291
+				} else {
292
+					$result['weather'] = $result['weather'].' / '.implode(' ', $text);
293
+				}
261 294
     			}
262 295
     		}
263 296
     		return $result;
@@ -269,8 +302,11 @@  discard block
 block discarded – undo
269 302
     		if (isset($globalMETARcycle) && $globalMETARcycle) {
270 303
             		$query = "SELECT * FROM metar WHERE metar_location = :icao";
271 304
                 } else {
272
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
273
-            		else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
305
+            		if ($globalDBdriver == 'mysql') {
306
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
307
+            		} else {
308
+            			$query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
309
+            		}
274 310
                 }
275 311
                 $query_values = array(':icao' => $icao);
276 312
                  try {
@@ -325,7 +361,9 @@  discard block
 block discarded – undo
325 361
         
326 362
         public function addMETARCycle() {
327 363
     		global $globalDebug, $globalIVAO;
328
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
364
+    		if (isset($globalDebug) && $globalDebug) {
365
+    			echo "Downloading METAR cycle...";
366
+    		}
329 367
     		date_default_timezone_set("UTC");
330 368
     		$Common = new Common();
331 369
     		if (isset($globalIVAO) && $globalIVAO) {
@@ -333,7 +371,9 @@  discard block
 block discarded – undo
333 371
     		} else {
334 372
 			$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT');
335 373
     		}
336
-    		if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
374
+    		if (isset($globalDebug) && $globalDebug) {
375
+    			echo "Done - Updating DB...";
376
+    		}
337 377
     		$date = '';
338 378
     		foreach(explode("\n",$cycle) as $line) {
339 379
     			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
@@ -342,22 +382,32 @@  discard block
 block discarded – undo
342 382
     			} elseif ($line != '') {
343 383
     			    //$this->parse($line);
344 384
     			    //echo $line;
345
-    			    if ($date == '') $date = date('Y/m/d H:m');
385
+    			    if ($date == '') {
386
+    			    	$date = date('Y/m/d H:m');
387
+    			    }
346 388
     			    $pos = 0;
347 389
     			    $pieces = preg_split('/\s/',$line);
348
-    			    if ($pieces[0] == 'METAR') $pos++;
349
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
390
+    			    if ($pieces[0] == 'METAR') {
391
+    			    	$pos++;
392
+    			    }
393
+    			    if (strlen($pieces[$pos]) != 4) {
394
+    			    	$pos++;
395
+    			    }
350 396
 	        	    $location = $pieces[$pos];
351 397
 	        	    echo $this->addMETAR($location,$line,$date);
352 398
     			}
353 399
     			//echo $line."\n";
354 400
     		}
355
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
401
+    		if (isset($globalDebug) && $globalDebug) {
402
+    			echo "Done\n";
403
+    		}
356 404
         
357 405
         }
358 406
         public function downloadMETAR($icao) {
359 407
     		global $globalMETARurl;
360
-    		if ($globalMETARurl == '') return array();
408
+    		if ($globalMETARurl == '') {
409
+    			return array();
410
+    		}
361 411
     		date_default_timezone_set("UTC");
362 412
     		$Common = new Common();
363 413
     		$url = str_replace('{icao}',$icao,$globalMETARurl);
@@ -370,16 +420,24 @@  discard block
 block discarded – undo
370 420
     			} elseif ($line != '') {
371 421
     			    //$this->parse($line);
372 422
     			    //echo $line;
373
-    			    if ($date == '') $date = date('Y/m/d H:m');
423
+    			    if ($date == '') {
424
+    			    	$date = date('Y/m/d H:m');
425
+    			    }
374 426
     			    $pos = 0;
375 427
     			    $pieces = preg_split('/\s/',$line);
376
-    			    if ($pieces[0] == 'METAR') $pos++;
377
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
428
+    			    if ($pieces[0] == 'METAR') {
429
+    			    	$pos++;
430
+    			    }
431
+    			    if (strlen($pieces[$pos]) != 4) {
432
+    			    	$pos++;
433
+    			    }
378 434
 	        	    $location = $pieces[$pos];
379 435
 	        	    if (strlen($location == 4)) {
380 436
 	        		$this->addMETAR($location,$line,$date);
381 437
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
382
-	        	    } else return array();
438
+	        	    } else {
439
+	        	    	return array();
440
+	        	    }
383 441
     			}
384 442
     			//echo $line."\n";
385 443
     		}
Please login to merge, or discard this patch.
Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -7,109 +7,109 @@  discard block
 block discarded – undo
7 7
 	public $db;
8 8
 	
9 9
 	protected $texts = Array(
10
-	    'MI' => 'Shallow',
11
-	    'PR' => 'Partial',
12
-	    'BC' => 'Low drifting',
13
-	    'BL' => 'Blowing',
14
-	    'SH' => 'Showers',
15
-	    'TS' => 'Thunderstorm',
16
-	    'FZ' => 'Freezing',
17
-	    'DZ' => 'Drizzle',
18
-	    'RA' => 'Rain',
19
-	    'SN' => 'Snow',
20
-	    'SG' => 'Snow Grains',
21
-	    'IC' => 'Ice crystals',
22
-	    'PL' => 'Ice pellets',
23
-	    'GR' => 'Hail',
24
-	    'GS' => 'Small hail',
25
-	    'UP' => 'Unknown',
26
-	    'BR' => 'Mist',
27
-	    'FG' => 'Fog',
28
-	    'FU' => 'Smoke',
29
-	    'VA' => 'Volcanic ash',
30
-	    'DU' => 'Widespread dust',
31
-	    'SA' => 'Sand',
32
-	    'HZ' => 'Haze',
33
-	    'PY' => 'Spray',
34
-	    'PO' => 'Well developed dust / sand whirls',
35
-	    'SQ' => 'Squalls',
36
-	    'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
-	    'SS' => 'Sandstorm',
38
-	    'DS' => 'Duststorm'
10
+		'MI' => 'Shallow',
11
+		'PR' => 'Partial',
12
+		'BC' => 'Low drifting',
13
+		'BL' => 'Blowing',
14
+		'SH' => 'Showers',
15
+		'TS' => 'Thunderstorm',
16
+		'FZ' => 'Freezing',
17
+		'DZ' => 'Drizzle',
18
+		'RA' => 'Rain',
19
+		'SN' => 'Snow',
20
+		'SG' => 'Snow Grains',
21
+		'IC' => 'Ice crystals',
22
+		'PL' => 'Ice pellets',
23
+		'GR' => 'Hail',
24
+		'GS' => 'Small hail',
25
+		'UP' => 'Unknown',
26
+		'BR' => 'Mist',
27
+		'FG' => 'Fog',
28
+		'FU' => 'Smoke',
29
+		'VA' => 'Volcanic ash',
30
+		'DU' => 'Widespread dust',
31
+		'SA' => 'Sand',
32
+		'HZ' => 'Haze',
33
+		'PY' => 'Spray',
34
+		'PO' => 'Well developed dust / sand whirls',
35
+		'SQ' => 'Squalls',
36
+		'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
+		'SS' => 'Sandstorm',
38
+		'DS' => 'Duststorm'
39 39
 	);
40 40
 	
41 41
 	public function __construct($dbc = null) {
42
-                $Connection = new Connection($dbc);
43
-                $this->db = $Connection->db;
44
-        }
42
+				$Connection = new Connection($dbc);
43
+				$this->db = $Connection->db;
44
+		}
45 45
 
46
-       public static function check_last_update() {
47
-    		global $globalDBdriver;
48
-    		if ($globalDBdriver == 'mysql') {
46
+	   public static function check_last_update() {
47
+			global $globalDBdriver;
48
+			if ($globalDBdriver == 'mysql') {
49 49
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value > DATE_SUB(NOW(), INTERVAL 20 MINUTE)";
50 50
 		} else {
51 51
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '20 MINUTES'";
52 52
 		}
53
-                try {
54
-                        $Connection = new Connection();
55
-                        $sth = $Connection->db->prepare($query);
56
-                        $sth->execute();
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
61
-                $sth->closeCursor();
62
-                if ($row['nb'] > 0) return false;
63
-                else return true;
64
-        }
53
+				try {
54
+						$Connection = new Connection();
55
+						$sth = $Connection->db->prepare($query);
56
+						$sth->execute();
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
61
+				$sth->closeCursor();
62
+				if ($row['nb'] > 0) return false;
63
+				else return true;
64
+		}
65 65
 
66
-        public static function insert_last_update() {
67
-                $query = "DELETE FROM config WHERE name = 'last_update_metar';
66
+		public static function insert_last_update() {
67
+				$query = "DELETE FROM config WHERE name = 'last_update_metar';
68 68
                         INSERT INTO config (name,value) VALUES ('last_update_metar',NOW());";
69
-                try {
70
-                        $Connection = new Connection();
71
-                        $sth = $Connection->db->prepare($query);
72
-                        $sth->execute();
73
-                } catch(PDOException $e) {
74
-                        return "error : ".$e->getMessage();
75
-                }
76
-        }
69
+				try {
70
+						$Connection = new Connection();
71
+						$sth = $Connection->db->prepare($query);
72
+						$sth->execute();
73
+				} catch(PDOException $e) {
74
+						return "error : ".$e->getMessage();
75
+				}
76
+		}
77 77
 
78 78
 
79 79
         
80
-        public function parse($data) {
81
-    		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82
-    		$codes = implode('|', array_keys($this->texts));
83
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
84
-    		//$pieces = explode(' ',$data);
85
-    		$pieces = preg_split('/\s/',$data);
86
-    		$pos = 0;
87
-    		if ($pieces[0] == 'METAR') $pos++;
88
-    		elseif ($pieces[0] == 'SPECI') $pos++;
89
-    		if (strlen($pieces[$pos]) != 4) $pos++;
90
-    		$result = array();
91
-    		$result['location'] = $pieces[$pos];
92
-    		$pos++;
93
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
-    		$result['time'] = substr($pieces[$pos],2,4);
95
-    		$c = count($pieces);
96
-    		for($pos++; $pos < $c; $pos++) {
97
-    			$piece = $pieces[$pos];
98
-    			if ($piece == 'RMK') break;
99
-    			if ($piece == 'AUTO') $result['auto'] = true;
100
-    			if ($piece == 'COR') $result['correction'] = true;
101
-    			// Wind Speed
102
-    			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
-    				$result['wind']['direction'] = (float)$matches[1];
80
+		public function parse($data) {
81
+			//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82
+			$codes = implode('|', array_keys($this->texts));
83
+			$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
84
+			//$pieces = explode(' ',$data);
85
+			$pieces = preg_split('/\s/',$data);
86
+			$pos = 0;
87
+			if ($pieces[0] == 'METAR') $pos++;
88
+			elseif ($pieces[0] == 'SPECI') $pos++;
89
+			if (strlen($pieces[$pos]) != 4) $pos++;
90
+			$result = array();
91
+			$result['location'] = $pieces[$pos];
92
+			$pos++;
93
+			$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
+			$result['time'] = substr($pieces[$pos],2,4);
95
+			$c = count($pieces);
96
+			for($pos++; $pos < $c; $pos++) {
97
+				$piece = $pieces[$pos];
98
+				if ($piece == 'RMK') break;
99
+				if ($piece == 'AUTO') $result['auto'] = true;
100
+				if ($piece == 'COR') $result['correction'] = true;
101
+				// Wind Speed
102
+				if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
+					$result['wind']['direction'] = (float)$matches[1];
104 104
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
105
+					if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
+					elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
+					elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
108 108
 				$result['wind']['gust'] = (float)$matches[3];
109 109
 				$result['wind']['unit'] = $matches[4];
110 110
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
111 111
 				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
112
-    			}
112
+				}
113 113
 
114 114
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
115 115
     				$result['wind_direction'] = (float)$matches[1];
@@ -126,35 +126,35 @@  discard block
 block discarded – undo
126 126
     				}
127 127
     			}
128 128
     			*/
129
-    			// Temperature
130
-    			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
-    				$temp = (float)$matches[1];
129
+				// Temperature
130
+				if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
+					$temp = (float)$matches[1];
132 132
 				if ($matches[1]{0} == 'M') {
133 133
 					$temp = ((float)substr($matches[1], 1)) * -1;
134 134
 				}
135
-    				$result['temperature'] = $temp;
136
-    				$dew = (float)$matches[2];
135
+					$result['temperature'] = $temp;
136
+					$dew = (float)$matches[2];
137 137
 				if ($matches[2]{0} == 'M') {
138 138
 					$dew = ((float)substr($matches[2], 1)) * -1;
139 139
 				}
140 140
 				$result['dew'] = $dew;
141
-    			}
142
-    			// QNH
143
-    			if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
144
-    			// #^(Q|A)(////|[0-9]{4})( )#
145
-    				if ($matches[1] == 'Q') {
146
-    					// hPa
147
-    					$result['QNH'] = $matches[2];
148
-    				} else {
149
-    					// inHg
150
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
151 141
 				}
152
-    				/*
142
+				// QNH
143
+				if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
144
+				// #^(Q|A)(////|[0-9]{4})( )#
145
+					if ($matches[1] == 'Q') {
146
+						// hPa
147
+						$result['QNH'] = $matches[2];
148
+					} else {
149
+						// inHg
150
+						$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
151
+				}
152
+					/*
153 153
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
154 154
     				$result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg';
155 155
     				*/
156
-    			}
157
-                     /*
156
+				}
157
+					 /*
158 158
     			// Wind Direction
159 159
     			if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) {
160 160
     				$result['wind_direction'] = $matches[1];
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
     				$result['speed_variable'] = $matches[1];
166 166
     			}
167 167
     			*/
168
-    			// Visibility
169
-    			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170
-    				if (isset($matches[3]) && strlen($matches[3]) > 0) {
168
+				// Visibility
169
+				if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170
+					if (isset($matches[3]) && strlen($matches[3]) > 0) {
171 171
 					$result['visibility'] = (float)$matches[3] * 1609.34;
172 172
 				} else {
173 173
 					if ($matches[1] == '9999') {
@@ -180,28 +180,28 @@  discard block
 block discarded – undo
180 180
 					$result['visibility'] = '> 10000';
181 181
 					$result['weather'] = "CAVOK";
182 182
 				}
183
-    			}
184
-    			// Cloud Coverage
185
-    			if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
186
-    				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187
-    				$type = $matches[1];
188
-    				$cloud = array();
189
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197
-    				$cloud['type_code'] = $type;
198
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199
-    				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200
-    				$result['cloud'][] = $cloud;
201
-    			}
202
-    			// RVR
203
-    			 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
204
-    				$rvr = array();
183
+				}
184
+				// Cloud Coverage
185
+				if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
186
+					//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187
+					$type = $matches[1];
188
+					$cloud = array();
189
+					if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
+					elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
+					elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
+					elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
+					elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
+					elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
+					elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
+					elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197
+					$cloud['type_code'] = $type;
198
+					$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199
+					$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200
+					$result['cloud'][] = $cloud;
201
+				}
202
+				// RVR
203
+				 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
204
+					$rvr = array();
205 205
 				$rvr['runway'] = $matches[1];
206 206
 				$rvr['assessment'] = $matches[2];
207 207
 				$rvr['rvr'] = $matches[3];
@@ -210,33 +210,33 @@  discard block
 block discarded – undo
210 210
 				$result['RVR'] = $rvr;
211 211
 			}
212 212
     			
213
-    			//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
214
-    			if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
215
-    				//print_r($matches);
216
-    				// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
217
-    				$result['RVR']['runway'] = $matches[1];
218
-        			$result['RVR']['deposits'] = $matches[2];
219
-        			$result['RVR']['extent'] = $matches[3];
220
-        			$result['RVR']['depth'] = $matches[4];
221
-        			$result['RVR']['friction'] = $matches[5];
222
-    			}
223
-    			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224
-    				//echo $piece;
225
-    				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
213
+				//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
214
+				if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
215
+					//print_r($matches);
216
+					// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
217
+					$result['RVR']['runway'] = $matches[1];
218
+					$result['RVR']['deposits'] = $matches[2];
219
+					$result['RVR']['extent'] = $matches[3];
220
+					$result['RVR']['depth'] = $matches[4];
221
+					$result['RVR']['friction'] = $matches[5];
222
+				}
223
+				if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224
+					//echo $piece;
225
+					//print_r($matches);
226
+					if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
+					else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
228 228
 				if (isset($matches[3])) {
229 229
 					$range = Array(
230
-					    'from' => (float)$matches[2],
231
-					    'to'   => (float)$matches[4],
232
-					    'unit' => $matches[5] ? 'FT' : 'M'
230
+						'from' => (float)$matches[2],
231
+						'to'   => (float)$matches[4],
232
+						'unit' => $matches[5] ? 'FT' : 'M'
233 233
 					);
234 234
 				}
235 235
 				$result['RVR'] = $matches[1];
236 236
 				$result['RVR_range'] = $range;
237
-    			}
238
-    			// Weather
239
-    			if (preg_match($regWeather, $piece, $matches)) {
237
+				}
238
+				// Weather
239
+				if (preg_match($regWeather, $piece, $matches)) {
240 240
 				$text = Array();
241 241
 				switch ($matches[1]) {
242 242
 					case '+':
@@ -259,35 +259,35 @@  discard block
 block discarded – undo
259 259
 				}
260 260
 				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
261 261
 				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
262
-    			}
263
-    		}
264
-    		return $result;
262
+				}
263
+			}
264
+			return $result;
265 265
         
266
-        }
266
+		}
267 267
         
268 268
 	public function getMETAR($icao) {
269
-    		global $globalMETARcycle, $globalDBdriver;
270
-    		if (isset($globalMETARcycle) && $globalMETARcycle) {
271
-            		$query = "SELECT * FROM metar WHERE metar_location = :icao";
272
-                } else {
273
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
-            		else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
275
-                }
276
-                $query_values = array(':icao' => $icao);
277
-                 try {
278
-                        $sth = $this->db->prepare($query);
279
-                        $sth->execute($query_values);
280
-                } catch(PDOException $e) {
281
-                        return "error : ".$e->getMessage();
282
-                }
283
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
284
-                if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) {
285
-            		$all = $this->downloadMETAR($icao);
286
-                }
287
-                return $all;
288
-        }
269
+			global $globalMETARcycle, $globalDBdriver;
270
+			if (isset($globalMETARcycle) && $globalMETARcycle) {
271
+					$query = "SELECT * FROM metar WHERE metar_location = :icao";
272
+				} else {
273
+					if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
+					else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
275
+				}
276
+				$query_values = array(':icao' => $icao);
277
+				 try {
278
+						$sth = $this->db->prepare($query);
279
+						$sth->execute($query_values);
280
+				} catch(PDOException $e) {
281
+						return "error : ".$e->getMessage();
282
+				}
283
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
284
+				if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) {
285
+					$all = $this->downloadMETAR($icao);
286
+				}
287
+				return $all;
288
+		}
289 289
 
290
-       public function addMETAR($location,$metar,$date) {
290
+	   public function addMETAR($location,$metar,$date) {
291 291
 		global $globalDBdriver;
292 292
 		$date = date('Y-m-d H:i:s',strtotime($date));
293 293
 		if ($globalDBdriver == 'mysql') {
@@ -295,100 +295,100 @@  discard block
 block discarded – undo
295 295
 		} else {
296 296
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
297 297
 		}
298
-                $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
299
-                 try {
300
-                        $sth = $this->db->prepare($query);
301
-                        $sth->execute($query_values);
302
-                } catch(PDOException $e) {
303
-                        return "error : ".$e->getMessage();
304
-                }
305
-        }
298
+				$query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
299
+				 try {
300
+						$sth = $this->db->prepare($query);
301
+						$sth->execute($query_values);
302
+				} catch(PDOException $e) {
303
+						return "error : ".$e->getMessage();
304
+				}
305
+		}
306 306
 
307
-       public function deleteMETAR($id) {
308
-                $query = "DELETE FROM metar WHERE id = :id";
309
-                $query_values = array(':id' => $id);
310
-                 try {
311
-                        $sth = $this->db->prepare($query);
312
-                        $sth->execute($query_values);
313
-                } catch(PDOException $e) {
314
-                        return "error : ".$e->getMessage();
315
-                }
316
-        }
317
-       public function deleteAllMETARLocation() {
318
-                $query = "DELETE FROM metar";
319
-                 try {
320
-                        $sth = $this->db->prepare($query);
321
-                        $sth->execute();
322
-                } catch(PDOException $e) {
323
-                        return "error : ".$e->getMessage();
324
-                }
325
-        }
307
+	   public function deleteMETAR($id) {
308
+				$query = "DELETE FROM metar WHERE id = :id";
309
+				$query_values = array(':id' => $id);
310
+				 try {
311
+						$sth = $this->db->prepare($query);
312
+						$sth->execute($query_values);
313
+				} catch(PDOException $e) {
314
+						return "error : ".$e->getMessage();
315
+				}
316
+		}
317
+	   public function deleteAllMETARLocation() {
318
+				$query = "DELETE FROM metar";
319
+				 try {
320
+						$sth = $this->db->prepare($query);
321
+						$sth->execute();
322
+				} catch(PDOException $e) {
323
+						return "error : ".$e->getMessage();
324
+				}
325
+		}
326 326
         
327
-        public function addMETARCycle() {
328
-    		global $globalDebug, $globalIVAO;
329
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
330
-    		date_default_timezone_set("UTC");
331
-    		$Common = new Common();
332
-    		if (isset($globalIVAO) && $globalIVAO) {
333
-        		$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
334
-    		} else {
327
+		public function addMETARCycle() {
328
+			global $globalDebug, $globalIVAO;
329
+			if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
330
+			date_default_timezone_set("UTC");
331
+			$Common = new Common();
332
+			if (isset($globalIVAO) && $globalIVAO) {
333
+				$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
334
+			} else {
335 335
 			$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT');
336
-    		}
337
-    		if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
338
-    		$date = '';
339
-    		foreach(explode("\n",$cycle) as $line) {
340
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
341
-    				//echo "date : ".$line."\n";
342
-    				$date = $line;
343
-    			} 
344
-    			if ($line != '') {
345
-    			    //$this->parse($line);
346
-    			    //echo $line;
347
-    			    if ($date == '') $date = date('Y/m/d H:m');
348
-    			    $pos = 0;
349
-    			    $pieces = preg_split('/\s/',$line);
350
-    			    if ($pieces[0] == 'METAR') $pos++;
351
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
352
-	        	    $location = $pieces[$pos];
353
-	        	    echo $this->addMETAR($location,$line,$date);
354
-    			}
355
-    			//echo $line."\n";
356
-    		}
357
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
336
+			}
337
+			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
338
+			$date = '';
339
+			foreach(explode("\n",$cycle) as $line) {
340
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
341
+					//echo "date : ".$line."\n";
342
+					$date = $line;
343
+				} 
344
+				if ($line != '') {
345
+					//$this->parse($line);
346
+					//echo $line;
347
+					if ($date == '') $date = date('Y/m/d H:m');
348
+					$pos = 0;
349
+					$pieces = preg_split('/\s/',$line);
350
+					if ($pieces[0] == 'METAR') $pos++;
351
+					if (strlen($pieces[$pos]) != 4) $pos++;
352
+					$location = $pieces[$pos];
353
+					echo $this->addMETAR($location,$line,$date);
354
+				}
355
+				//echo $line."\n";
356
+			}
357
+			if (isset($globalDebug) && $globalDebug) echo "Done\n";
358 358
         
359
-        }
360
-        public function downloadMETAR($icao) {
361
-    		global $globalMETARurl;
362
-    		if ($globalMETARurl == '') return array();
363
-    		date_default_timezone_set("UTC");
364
-    		$Common = new Common();
365
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
366
-    		$cycle = $Common->getData($url);
367
-    		$date = '';
368
-    		foreach(explode("\n",$cycle) as $line) {
369
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
370
-    				//echo "date : ".$line."\n";
371
-    				$date = $line;
372
-    			} 
373
-    			if ($line != '') {
374
-    			    //$this->parse($line);
375
-    			    //echo $line;
376
-    			    if ($date == '') $date = date('Y/m/d H:m');
377
-    			    $pos = 0;
378
-    			    $pieces = preg_split('/\s/',$line);
379
-    			    if ($pieces[0] == 'METAR') $pos++;
380
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
381
-	        	    $location = $pieces[$pos];
382
-	        	    if (strlen($location == 4)) {
383
-	        		$this->addMETAR($location,$line,$date);
384
-	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
385
-	        	    } else return array();
386
-    			}
387
-    			//echo $line."\n";
388
-    		}
389
-    		return array();
359
+		}
360
+		public function downloadMETAR($icao) {
361
+			global $globalMETARurl;
362
+			if ($globalMETARurl == '') return array();
363
+			date_default_timezone_set("UTC");
364
+			$Common = new Common();
365
+			$url = str_replace('{icao}',$icao,$globalMETARurl);
366
+			$cycle = $Common->getData($url);
367
+			$date = '';
368
+			foreach(explode("\n",$cycle) as $line) {
369
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
370
+					//echo "date : ".$line."\n";
371
+					$date = $line;
372
+				} 
373
+				if ($line != '') {
374
+					//$this->parse($line);
375
+					//echo $line;
376
+					if ($date == '') $date = date('Y/m/d H:m');
377
+					$pos = 0;
378
+					$pieces = preg_split('/\s/',$line);
379
+					if ($pieces[0] == 'METAR') $pos++;
380
+					if (strlen($pieces[$pos]) != 4) $pos++;
381
+					$location = $pieces[$pos];
382
+					if (strlen($location == 4)) {
383
+					$this->addMETAR($location,$line,$date);
384
+					return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
385
+					} else return array();
386
+				}
387
+				//echo $line."\n";
388
+			}
389
+			return array();
390 390
         
391
-        }
391
+		}
392 392
 }
393 393
 /*
394 394
 $METAR = new METAR();
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                         $Connection = new Connection();
55 55
                         $sth = $Connection->db->prepare($query);
56 56
                         $sth->execute();
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                         $Connection = new Connection();
71 71
                         $sth = $Connection->db->prepare($query);
72 72
                         $sth->execute();
73
-                } catch(PDOException $e) {
73
+                } catch (PDOException $e) {
74 74
                         return "error : ".$e->getMessage();
75 75
                 }
76 76
         }
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
         public function parse($data) {
81 81
     		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82 82
     		$codes = implode('|', array_keys($this->texts));
83
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
83
+    		$regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#';
84 84
     		//$pieces = explode(' ',$data);
85
-    		$pieces = preg_split('/\s/',$data);
85
+    		$pieces = preg_split('/\s/', $data);
86 86
     		$pos = 0;
87 87
     		if ($pieces[0] == 'METAR') $pos++;
88 88
     		elseif ($pieces[0] == 'SPECI') $pos++;
@@ -90,25 +90,25 @@  discard block
 block discarded – undo
90 90
     		$result = array();
91 91
     		$result['location'] = $pieces[$pos];
92 92
     		$pos++;
93
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
-    		$result['time'] = substr($pieces[$pos],2,4);
93
+    		$result['dayofmonth'] = substr($pieces[$pos], 0, 2);
94
+    		$result['time'] = substr($pieces[$pos], 2, 4);
95 95
     		$c = count($pieces);
96
-    		for($pos++; $pos < $c; $pos++) {
96
+    		for ($pos++; $pos < $c; $pos++) {
97 97
     			$piece = $pieces[$pos];
98 98
     			if ($piece == 'RMK') break;
99 99
     			if ($piece == 'AUTO') $result['auto'] = true;
100 100
     			if ($piece == 'COR') $result['correction'] = true;
101 101
     			// Wind Speed
102 102
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
-    				$result['wind']['direction'] = (float)$matches[1];
103
+    				$result['wind']['direction'] = (float) $matches[1];
104 104
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
108
-				$result['wind']['gust'] = (float)$matches[3];
105
+    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2);
106
+    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2);
107
+    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2);
108
+				$result['wind']['gust'] = (float) $matches[3];
109 109
 				$result['wind']['unit'] = $matches[4];
110
-				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
111
-				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
110
+				$result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0;
111
+				$result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0;
112 112
     			}
113 113
 
114 114
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
     			*/
129 129
     			// Temperature
130 130
     			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
-    				$temp = (float)$matches[1];
131
+    				$temp = (float) $matches[1];
132 132
 				if ($matches[1]{0} == 'M') {
133
-					$temp = ((float)substr($matches[1], 1)) * -1;
133
+					$temp = ((float) substr($matches[1], 1))*-1;
134 134
 				}
135 135
     				$result['temperature'] = $temp;
136
-    				$dew = (float)$matches[2];
136
+    				$dew = (float) $matches[2];
137 137
 				if ($matches[2]{0} == 'M') {
138
-					$dew = ((float)substr($matches[2], 1)) * -1;
138
+					$dew = ((float) substr($matches[2], 1))*-1;
139 139
 				}
140 140
 				$result['dew'] = $dew;
141 141
     			}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     					$result['QNH'] = $matches[2];
148 148
     				} else {
149 149
     					// inHg
150
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
150
+    					$result['QNH'] = round(($matches[2]/100)*33.86389, 2);
151 151
 				}
152 152
     				/*
153 153
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
     			// Visibility
169 169
     			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170 170
     				if (isset($matches[3]) && strlen($matches[3]) > 0) {
171
-					$result['visibility'] = (float)$matches[3] * 1609.34;
171
+					$result['visibility'] = (float) $matches[3]*1609.34;
172 172
 				} else {
173 173
 					if ($matches[1] == '9999') {
174 174
 						$result['visibility'] = '> 10000';
175 175
 					} else {
176
-						$result['visibility'] = (float)$matches[1];
176
+						$result['visibility'] = (float) $matches[1];
177 177
 					}
178 178
 				}
179 179
 				if (preg_match('#^CAVOK$#', $piece, $matches)) {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196 196
     				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197 197
     				$cloud['type_code'] = $type;
198
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
198
+    				$cloud['level'] = round(((float) $matches[2])*100*0.3048);
199 199
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200 200
     				$result['cloud'][] = $cloud;
201 201
     			}
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 				$rvr['runway'] = $matches[1];
206 206
 				$rvr['assessment'] = $matches[2];
207 207
 				$rvr['rvr'] = $matches[3];
208
-				$rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0;
209
-				$rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : '';
208
+				$rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0;
209
+				$rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : '';
210 210
 				$result['RVR'] = $rvr;
211 211
 			}
212 212
     			
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224 224
     				//echo $piece;
225 225
     				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
226
+    				if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
+    				else $range = array('exact' => (float) $matches[2], 'unit' => 'M');
228 228
 				if (isset($matches[3])) {
229 229
 					$range = Array(
230
-					    'from' => (float)$matches[2],
231
-					    'to'   => (float)$matches[4],
230
+					    'from' => (float) $matches[2],
231
+					    'to'   => (float) $matches[4],
232 232
 					    'unit' => $matches[5] ? 'FT' : 'M'
233 233
 					);
234 234
 				}
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                  try {
278 278
                         $sth = $this->db->prepare($query);
279 279
                         $sth->execute($query_values);
280
-                } catch(PDOException $e) {
280
+                } catch (PDOException $e) {
281 281
                         return "error : ".$e->getMessage();
282 282
                 }
283 283
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -287,19 +287,19 @@  discard block
 block discarded – undo
287 287
                 return $all;
288 288
         }
289 289
 
290
-       public function addMETAR($location,$metar,$date) {
290
+       public function addMETAR($location, $metar, $date) {
291 291
 		global $globalDBdriver;
292
-		$date = date('Y-m-d H:i:s',strtotime($date));
292
+		$date = date('Y-m-d H:i:s', strtotime($date));
293 293
 		if ($globalDBdriver == 'mysql') {
294 294
 			$query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar";
295 295
 		} else {
296 296
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
297 297
 		}
298
-                $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
298
+                $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar));
299 299
                  try {
300 300
                         $sth = $this->db->prepare($query);
301 301
                         $sth->execute($query_values);
302
-                } catch(PDOException $e) {
302
+                } catch (PDOException $e) {
303 303
                         return "error : ".$e->getMessage();
304 304
                 }
305 305
         }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
                  try {
311 311
                         $sth = $this->db->prepare($query);
312 312
                         $sth->execute($query_values);
313
-                } catch(PDOException $e) {
313
+                } catch (PDOException $e) {
314 314
                         return "error : ".$e->getMessage();
315 315
                 }
316 316
         }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
                  try {
320 320
                         $sth = $this->db->prepare($query);
321 321
                         $sth->execute();
322
-                } catch(PDOException $e) {
322
+                } catch (PDOException $e) {
323 323
                         return "error : ".$e->getMessage();
324 324
                 }
325 325
         }
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
     		}
337 337
     		if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
338 338
     		$date = '';
339
-    		foreach(explode("\n",$cycle) as $line) {
340
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
339
+    		foreach (explode("\n", $cycle) as $line) {
340
+    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
341 341
     				//echo "date : ".$line."\n";
342 342
     				$date = $line;
343 343
     			} 
@@ -346,11 +346,11 @@  discard block
 block discarded – undo
346 346
     			    //echo $line;
347 347
     			    if ($date == '') $date = date('Y/m/d H:m');
348 348
     			    $pos = 0;
349
-    			    $pieces = preg_split('/\s/',$line);
349
+    			    $pieces = preg_split('/\s/', $line);
350 350
     			    if ($pieces[0] == 'METAR') $pos++;
351 351
     			    if (strlen($pieces[$pos]) != 4) $pos++;
352 352
 	        	    $location = $pieces[$pos];
353
-	        	    echo $this->addMETAR($location,$line,$date);
353
+	        	    echo $this->addMETAR($location, $line, $date);
354 354
     			}
355 355
     			//echo $line."\n";
356 356
     		}
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
     		if ($globalMETARurl == '') return array();
363 363
     		date_default_timezone_set("UTC");
364 364
     		$Common = new Common();
365
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
365
+    		$url = str_replace('{icao}', $icao, $globalMETARurl);
366 366
     		$cycle = $Common->getData($url);
367 367
     		$date = '';
368
-    		foreach(explode("\n",$cycle) as $line) {
369
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
368
+    		foreach (explode("\n", $cycle) as $line) {
369
+    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
370 370
     				//echo "date : ".$line."\n";
371 371
     				$date = $line;
372 372
     			} 
@@ -375,12 +375,12 @@  discard block
 block discarded – undo
375 375
     			    //echo $line;
376 376
     			    if ($date == '') $date = date('Y/m/d H:m');
377 377
     			    $pos = 0;
378
-    			    $pieces = preg_split('/\s/',$line);
378
+    			    $pieces = preg_split('/\s/', $line);
379 379
     			    if ($pieces[0] == 'METAR') $pos++;
380 380
     			    if (strlen($pieces[$pos]) != 4) $pos++;
381 381
 	        	    $location = $pieces[$pos];
382 382
 	        	    if (strlen($location == 4)) {
383
-	        		$this->addMETAR($location,$line,$date);
383
+	        		$this->addMETAR($location, $line, $date);
384 384
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
385 385
 	        	    } else return array();
386 386
     			}
Please login to merge, or discard this patch.
require/class.Scheduler.php 3 patches
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -8,29 +8,29 @@  discard block
 block discarded – undo
8 8
 
9 9
 class Schedule {
10 10
 	protected $cookies = array();
11
-        public $db;
11
+		public $db;
12 12
 	public function __construct($dbc = null) {
13 13
 		$Connection = new Connection($dbc);
14 14
 		$this->db = $Connection->db();
15
-        }
15
+		}
16 16
 	
17 17
 	/**
18
-	* Add schedule data to database
19
-	* @param String $ident aircraft ident
20
-	* @param String $departure_airport_icao departure airport icao
21
-	* @param String $departure_airport_time departure airport time
22
-	* @param String $arrival_airport_icao arrival airport icao
23
-	* @param String $arrival_airport_time arrival airport time
18
+	 * Add schedule data to database
19
+	 * @param String $ident aircraft ident
20
+	 * @param String $departure_airport_icao departure airport icao
21
+	 * @param String $departure_airport_time departure airport time
22
+	 * @param String $arrival_airport_icao arrival airport icao
23
+	 * @param String $arrival_airport_time arrival airport time
24 24
 	/ @param String $source source of data
25
-	*/
25
+	 */
26 26
 	
27 27
 	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
28 28
 		date_default_timezone_set('UTC');
29 29
 		$date = date("Y-m-d H:i:s",time());
30
-	        //if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
31
-	        //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
32
-	        $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
33
-	        $query_values = array(':ident' => $ident);
30
+			//if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
31
+			//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
32
+			$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
33
+			$query_values = array(':ident' => $ident);
34 34
 		 try {
35 35
 			$sth = $this->db->prepare($query);
36 36
 			$sth->execute($query_values);
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		if ($sth->fetchColumn() > 0) {
41 41
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
42
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
43
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
42
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
43
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
44 44
 			} elseif ($arrival_airport_time == '') {
45
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
46
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
45
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
46
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
47 47
 			} elseif ($departure_airport_time == '') {
48
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
49
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
48
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
49
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
50 50
 			} else {
51
-			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
52
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
53
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
51
+				//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
52
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
53
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
54 54
 			}
55 55
 			try {
56 56
 				$sth = $this->db->prepare($query);
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
 			if ($sth->fetchColumn() == 0) {
62 62
 				//$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident';
63 63
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
64
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
65
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
64
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
65
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
66 66
 				} elseif ($arrival_airport_time == '') {
67
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
68
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
67
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
68
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
69 69
 				} elseif ($departure_airport_time == '') {
70
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
71
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
70
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
71
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
72 72
 				} else {
73
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
74
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
73
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
74
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
75 75
 				}
76 76
 				 try {
77 77
 					$sth = $this->db->prepare($query);
@@ -104,15 +104,15 @@  discard block
 block discarded – undo
104 104
 	}
105 105
 
106 106
 	public function getSchedule($ident) {
107
-	        $Translation = new Translation($this->db);
108
-	        $operator = $Translation->checkTranslation($ident,false);
109
-	        if ($ident != $operator) {
110
-	    		$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :operator OR CallSign = :ident LIMIT 1";
111
-	    		$query_values = array(':ident' => $ident,'operator' => $operator);
112
-	    	} else {
113
-		        $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :ident LIMIT 1";
114
-	    		$query_values = array(':ident' => $ident);
115
-	    	}
107
+			$Translation = new Translation($this->db);
108
+			$operator = $Translation->checkTranslation($ident,false);
109
+			if ($ident != $operator) {
110
+				$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :operator OR CallSign = :ident LIMIT 1";
111
+				$query_values = array(':ident' => $ident,'operator' => $operator);
112
+			} else {
113
+				$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :ident LIMIT 1";
114
+				$query_values = array(':ident' => $ident);
115
+			}
116 116
 		 try {
117 117
 			$sth = $this->db->prepare($query);
118 118
 			$sth->execute($query_values);
@@ -127,15 +127,15 @@  discard block
 block discarded – undo
127 127
 
128 128
 	public function checkSchedule($ident) {
129 129
 		global $globalDBdriver;
130
-	        //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
131
-	        if ($globalDBdriver == 'mysql') {
130
+			//$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
131
+			if ($globalDBdriver == 'mysql') {
132 132
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1";
133 133
 		} else {
134 134
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE CallSign = :ident 
135 135
 			AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL)
136 136
 			     OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1";
137 137
 		}
138
-	        $query_values = array(':ident' => $ident);
138
+			$query_values = array(':ident' => $ident);
139 139
 		 try {
140 140
 			$sth = $this->db->prepare($query);
141 141
 			$sth->execute($query_values);
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
 	}
148 148
 
149 149
 	/**
150
-	* Get flight info from Air France
151
-	* @param String $callsign The callsign
152
-	* @param String $date date we want flight number info
153
-	* @param String $carrier IATA code
154
-	* @return Flight departure and arrival airports and time
155
-	*/
150
+	 * Get flight info from Air France
151
+	 * @param String $callsign The callsign
152
+	 * @param String $date date we want flight number info
153
+	 * @param String $carrier IATA code
154
+	 * @return Flight departure and arrival airports and time
155
+	 */
156 156
 	private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
157 157
 		$Common = new Common();
158 158
 		$check_date = new Datetime($date);
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 	}
189 189
 
190 190
 	/**
191
-	* Get flight info from EasyJet
192
-	* @param String $callsign The callsign
193
-	* @param String $date date we want flight number info
194
-	* @return Flight departure and arrival airports and time
195
-	*/
191
+	 * Get flight info from EasyJet
192
+	 * @param String $callsign The callsign
193
+	 * @param String $date date we want flight number info
194
+	 * @return Flight departure and arrival airports and time
195
+	 */
196 196
 	private function getEasyJet($callsign, $date = 'NOW') {
197 197
 		global $globalTimezone;
198 198
 		$Common = new Common();
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
 	}
217 217
 
218 218
 	/**
219
-	* Get flight info from Ryanair
220
-	* @param String $callsign The callsign
221
-	* @return Flight departure and arrival airports and time
222
-	*/
219
+	 * Get flight info from Ryanair
220
+	 * @param String $callsign The callsign
221
+	 * @return Flight departure and arrival airports and time
222
+	 */
223 223
 	private function getRyanair($callsign) {
224 224
 		$Common = new Common();
225 225
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
 	}
243 243
 
244 244
 	/**
245
-	* Get flight info from Swiss
246
-	* @param String $callsign The callsign
247
-	* @return Flight departure and arrival airports and time
248
-	*/
245
+	 * Get flight info from Swiss
246
+	 * @param String $callsign The callsign
247
+	 * @return Flight departure and arrival airports and time
248
+	 */
249 249
 	private function getSwiss($callsign) {
250 250
 		$Common = new Common();
251 251
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
 	}
275 275
 	
276 276
 	/**
277
-	* Get flight info from British Airways API
278
-	* @param String $callsign The callsign
279
-	* @param String $date date we want flight number info
280
-	* @return Flight departure and arrival airports and time
281
-	*/
277
+	 * Get flight info from British Airways API
278
+	 * @param String $callsign The callsign
279
+	 * @param String $date date we want flight number info
280
+	 * @return Flight departure and arrival airports and time
281
+	 */
282 282
 	public function getBritishAirways($callsign, $date = 'NOW') {
283 283
 		global $globalBritishAirwaysKey;
284 284
 		$Common = new Common();
@@ -302,11 +302,11 @@  discard block
 block discarded – undo
302 302
 	}
303 303
 
304 304
 	/**
305
-	* Get flight info from Lutfhansa API
306
-	* @param String $callsign The callsign
307
-	* @param String $date date we want flight number info
308
-	* @return Flight departure and arrival airports and time
309
-	*/
305
+	 * Get flight info from Lutfhansa API
306
+	 * @param String $callsign The callsign
307
+	 * @param String $date date we want flight number info
308
+	 * @return Flight departure and arrival airports and time
309
+	 */
310 310
 	public function getLufthansa($callsign, $date = 'NOW') {
311 311
 		global $globalLufthansaKey;
312 312
 		$Common = new Common();
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 	}
337 337
 
338 338
 	/**
339
-	* Get flight info from Transavia API
340
-	* @param String $callsign The callsign
341
-	* @param String $date date we want flight number info
342
-	* @return Flight departure and arrival airports and time
343
-	*/
339
+	 * Get flight info from Transavia API
340
+	 * @param String $callsign The callsign
341
+	 * @param String $date date we want flight number info
342
+	 * @return Flight departure and arrival airports and time
343
+	 */
344 344
 	public function getTransavia($callsign, $date = 'NOW') {
345 345
 		global $globalTransaviaKey;
346 346
 		$Common = new Common();
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
 	}
367 367
 
368 368
 	/**
369
-	* Get flight info from Tunisair
370
-	* @param String $callsign The callsign
371
-	* @return Flight departure and arrival airports and time
372
-	*/
369
+	 * Get flight info from Tunisair
370
+	 * @param String $callsign The callsign
371
+	 * @return Flight departure and arrival airports and time
372
+	 */
373 373
 	public function getTunisair($callsign) {
374 374
 		$Common = new Common();
375 375
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -386,10 +386,10 @@  discard block
 block discarded – undo
386 386
 	}
387 387
 
388 388
 	/**
389
-	* Get flight info from Vueling
390
-	* @param String $callsign The callsign
391
-	* @return Flight departure and arrival airports and time
392
-	*/
389
+	 * Get flight info from Vueling
390
+	 * @param String $callsign The callsign
391
+	 * @return Flight departure and arrival airports and time
392
+	 */
393 393
 	public function getVueling($callsign,$date = 'NOW') {
394 394
 		$Common = new Common();
395 395
 		$check_date = new Datetime($date);
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
 	}
412 412
 
413 413
 	/**
414
-	* Get flight info from Iberia
415
-	* @param String $callsign The callsign
416
-	* @param String $date date we want flight number info
417
-	* @return Flight departure and arrival airports and time
418
-	*/
414
+	 * Get flight info from Iberia
415
+	 * @param String $callsign The callsign
416
+	 * @param String $date date we want flight number info
417
+	 * @return Flight departure and arrival airports and time
418
+	 */
419 419
 	public function getIberia($callsign, $date = 'NOW') {
420 420
 		$Common = new Common();
421 421
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -445,11 +445,11 @@  discard block
 block discarded – undo
445 445
 	}
446 446
 
447 447
 	/**
448
-	* Get flight info from Star Alliance
449
-	* @param String $callsign The callsign
450
-	* @param String $date date we want flight number info
451
-	* @return Flight departure and arrival airports and time
452
-	*/
448
+	 * Get flight info from Star Alliance
449
+	 * @param String $callsign The callsign
450
+	 * @param String $date date we want flight number info
451
+	 * @return Flight departure and arrival airports and time
452
+	 */
453 453
 
454 454
 	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
455 455
 		$Common = new Common();
@@ -481,11 +481,11 @@  discard block
 block discarded – undo
481 481
 
482 482
 
483 483
 	/**
484
-	* Get flight info from Alitalia
485
-	* @param String $callsign The callsign
486
-	* @param String $date date we want flight number info
487
-	* @return Flight departure and arrival airports and time
488
-	*/
484
+	 * Get flight info from Alitalia
485
+	 * @param String $callsign The callsign
486
+	 * @param String $date date we want flight number info
487
+	 * @return Flight departure and arrival airports and time
488
+	 */
489 489
 	private function getAlitalia($callsign, $date = 'NOW') {
490 490
 		$Common = new Common();
491 491
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -504,11 +504,11 @@  discard block
 block discarded – undo
504 504
 	}
505 505
 
506 506
 	/**
507
-	* Get flight info from Brussels airlines
508
-	* @param String $callsign The callsign
509
-	* @param String $date date we want flight number info
510
-	* @return Flight departure and arrival airports and time
511
-	*/
507
+	 * Get flight info from Brussels airlines
508
+	 * @param String $callsign The callsign
509
+	 * @param String $date date we want flight number info
510
+	 * @return Flight departure and arrival airports and time
511
+	 */
512 512
 	private function getBrussels($callsign, $date = 'NOW') {
513 513
 		$Common = new Common();
514 514
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -518,24 +518,24 @@  discard block
 block discarded – undo
518 518
 		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
519 519
 		$data = $Common->getData($url);
520 520
 		if ($data != '') {
521
-		    //echo $data;
522
-		    $parsed_json = json_decode($data);
523
-		    if (isset($parsed_json[0]->FromAirportCode)) {
521
+			//echo $data;
522
+			$parsed_json = json_decode($data);
523
+			if (isset($parsed_json[0]->FromAirportCode)) {
524 524
 			$DepartureAirportIata = $parsed_json[0]->FromAirportCode;
525 525
 			$ArrivalAirportIata = $parsed_json[0]->ToAirportCode;
526 526
 			$departureTime = date('H:i',strtotime($parsed_json[0]->ScheduledDepatureDate));
527 527
 			$arrivalTime = date('H:i',strtotime($parsed_json[0]->ScheduledArrivalDate));
528 528
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
529
-		    }
529
+			}
530 530
 		}
531 531
 	}
532 532
 
533 533
 	/**
534
-	* Get flight info from FlightRadar24
535
-	* @param String $callsign The callsign
536
-	* @param String $date date we want flight number info
537
-	* @return Flight departure and arrival airports and time
538
-	*/
534
+	 * Get flight info from FlightRadar24
535
+	 * @param String $callsign The callsign
536
+	 * @param String $date date we want flight number info
537
+	 * @return Flight departure and arrival airports and time
538
+	 */
539 539
 /*
540 540
 	public function getFlightRadar24($callsign, $date = 'NOW') {
541 541
 		$Common = new Common();
@@ -564,11 +564,11 @@  discard block
 block discarded – undo
564 564
 	}
565 565
   */
566 566
 	/**
567
-	* Get flight info from Lufthansa
568
-	* @param String $callsign The callsign
569
-	* @param String $date date we want flight number info
570
-	* @return Flight departure and arrival airports and time
571
-	*/
567
+	 * Get flight info from Lufthansa
568
+	 * @param String $callsign The callsign
569
+	 * @param String $date date we want flight number info
570
+	 * @return Flight departure and arrival airports and time
571
+	 */
572 572
 
573 573
 /*	private function getLufthansa($callsign, $date = 'NOW') {
574 574
 		$Common = new Common();
@@ -596,10 +596,10 @@  discard block
 block discarded – undo
596 596
 	}
597 597
   */
598 598
 	/**
599
-	* Get flight info from flytap
600
-	* @param String $callsign The callsign
601
-	* @return Flight departure and arrival airports and time
602
-	*/
599
+	 * Get flight info from flytap
600
+	 * @param String $callsign The callsign
601
+	 * @return Flight departure and arrival airports and time
602
+	 */
603 603
 	private function getFlyTap($callsign) {
604 604
 		$Common = new Common();
605 605
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -622,10 +622,10 @@  discard block
 block discarded – undo
622 622
 	}
623 623
 
624 624
 	/**
625
-	* Get flight info from flightmapper
626
-	* @param String $callsign The callsign
627
-	* @return Flight departure and arrival airports and time
628
-	*/
625
+	 * Get flight info from flightmapper
626
+	 * @param String $callsign The callsign
627
+	 * @return Flight departure and arrival airports and time
628
+	 */
629 629
 	public function getFlightMapper($callsign) {
630 630
 		$Common = new Common();
631 631
 		$airline_icao = '';
@@ -653,11 +653,11 @@  discard block
 block discarded – undo
653 653
 				$aarr = '';
654 654
 				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
655 655
 				if ($n == 7) {
656
-				    $departureTime = $dhour;
657
-				    $arrivalTime = $ahour;
658
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
659
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
660
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
656
+					$departureTime = $dhour;
657
+					$arrivalTime = $ahour;
658
+					$DepartureAirportIata = str_replace(array('(',')'),'',$darr);
659
+					$ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
660
+					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
661 661
 				}
662 662
 			}
663 663
 		}
@@ -665,10 +665,10 @@  discard block
 block discarded – undo
665 665
 	}
666 666
 
667 667
 	/**
668
-	* Get flight info from flightaware
669
-	* @param String $callsign The callsign
670
-	* @return Flight departure and arrival airports and time
671
-	*/
668
+	 * Get flight info from flightaware
669
+	 * @param String $callsign The callsign
670
+	 * @return Flight departure and arrival airports and time
671
+	 */
672 672
 	public function getFlightAware($callsign) {
673 673
 		$Common = new Common();
674 674
 		/*
@@ -701,10 +701,10 @@  discard block
 block discarded – undo
701 701
 	}
702 702
 
703 703
 	/**
704
-	* Get flight info from CostToTravel
705
-	* @param String $callsign The callsign
706
-	* @return Flight departure and arrival airports and time
707
-	*/
704
+	 * Get flight info from CostToTravel
705
+	 * @param String $callsign The callsign
706
+	 * @return Flight departure and arrival airports and time
707
+	 */
708 708
 	public function getCostToTravel($callsign) {
709 709
 		$Common = new Common();
710 710
 		$url= "http://www.costtotravel.com/flight-number/".$callsign;
@@ -726,11 +726,11 @@  discard block
 block discarded – undo
726 726
 	}
727 727
 
728 728
 	/**
729
-	* Get flight info from Air Canada
730
-	* @param String $callsign The callsign
731
-	* @param String $date date we want flight number info
732
-	* @return Flight departure and arrival airports and time
733
-	*/
729
+	 * Get flight info from Air Canada
730
+	 * @param String $callsign The callsign
731
+	 * @param String $date date we want flight number info
732
+	 * @return Flight departure and arrival airports and time
733
+	 */
734 734
 	private function getAirCanada($callsign,$date = 'NOW') {
735 735
 		$Common = new Common();
736 736
 		date_default_timezone_set('UTC');
@@ -754,11 +754,11 @@  discard block
 block discarded – undo
754 754
 	}
755 755
 
756 756
 	/**
757
-	* Get flight info from Vietnam Airlines
758
-	* @param String $callsign The callsign
759
-	* @param String $date date we want flight number info
760
-	* @return Flight departure and arrival airports and time
761
-	*/
757
+	 * Get flight info from Vietnam Airlines
758
+	 * @param String $callsign The callsign
759
+	 * @param String $date date we want flight number info
760
+	 * @return Flight departure and arrival airports and time
761
+	 */
762 762
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
763 763
 		$Common = new Common();
764 764
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -780,12 +780,12 @@  discard block
 block discarded – undo
780 780
 	}
781 781
 
782 782
 	/**
783
-	* Get flight info from Air Berlin
784
-	* @param String $callsign The callsign
785
-	* @param String $date date we want flight number info
786
-	* @param String $carrier airline code
787
-	* @return Flight departure and arrival airports and time
788
-	*/
783
+	 * Get flight info from Air Berlin
784
+	 * @param String $callsign The callsign
785
+	 * @param String $date date we want flight number info
786
+	 * @param String $carrier airline code
787
+	 * @return Flight departure and arrival airports and time
788
+	 */
789 789
 	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
790 790
 		$Common = new Common();
791 791
 		date_default_timezone_set('UTC');
@@ -814,11 +814,11 @@  discard block
 block discarded – undo
814 814
 			$table = $Common->table2array($data);
815 815
 			$flight = $table;
816 816
 			if (isset($flight[5][4])) {
817
-			    $arrivalTime = $flight[5][4];
818
-			    $arrivalAirport = $flight[5][3];
817
+				$arrivalTime = $flight[5][4];
818
+				$arrivalAirport = $flight[5][3];
819 819
 			} else {
820
-			    $arrivalTime = '';
821
-			    $arrivalAirport = '';
820
+				$arrivalTime = '';
821
+				$arrivalAirport = '';
822 822
 			}
823 823
 		} else return array();
824 824
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
 					}
1087 1087
 			}
1088 1088
 		}
1089
-	        return array();
1089
+			return array();
1090 1090
 	}
1091 1091
 }
1092 1092
 
Please login to merge, or discard this patch.
Spacing   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
 	/ @param String $source source of data
25 25
 	*/
26 26
 	
27
-	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
27
+	public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') {
28 28
 		date_default_timezone_set('UTC');
29
-		$date = date("Y-m-d H:i:s",time());
29
+		$date = date("Y-m-d H:i:s", time());
30 30
 	        //if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
31 31
 	        //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
32 32
 	        $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
@@ -34,69 +34,69 @@  discard block
 block discarded – undo
34 34
 		 try {
35 35
 			$sth = $this->db->prepare($query);
36 36
 			$sth->execute($query_values);
37
-		} catch(PDOException $e) {
37
+		} catch (PDOException $e) {
38 38
 			return "error : ".$e->getMessage();
39 39
 		}
40 40
 		if ($sth->fetchColumn() > 0) {
41 41
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
42 42
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
43
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
43
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao);
44 44
 			} elseif ($arrival_airport_time == '') {
45 45
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
46
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
46
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao);
47 47
 			} elseif ($departure_airport_time == '') {
48 48
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
49
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
49
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
50 50
 			} else {
51 51
 			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
52 52
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
53
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
53
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
54 54
 			}
55 55
 			try {
56 56
 				$sth = $this->db->prepare($query);
57 57
 				$sth->execute($query_values);
58
-			} catch(PDOException $e) {
58
+			} catch (PDOException $e) {
59 59
 				return "error : ".$e->getMessage();
60 60
 			}
61 61
 			if ($sth->fetchColumn() == 0) {
62 62
 				//$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident';
63 63
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
64 64
                             	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
65
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
65
+				    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
66 66
 				} elseif ($arrival_airport_time == '') {
67 67
                             	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
68
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
68
+				    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
69 69
 				} elseif ($departure_airport_time == '') {
70 70
                             	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
71
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
71
+				    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
72 72
 				} else {
73 73
                             	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
74
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
74
+				    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
75 75
 				}
76 76
 				 try {
77 77
 					$sth = $this->db->prepare($query);
78 78
 					$sth->execute($query_values);
79
-				} catch(PDOException $e) {
79
+				} catch (PDOException $e) {
80 80
 					return "error : ".$e->getMessage();
81 81
 				}
82 82
 			} else {
83 83
 				//$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident';
84 84
 				$query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident';
85
-				$query_values = array(':ident' => $ident,':date' => $date);
85
+				$query_values = array(':ident' => $ident, ':date' => $date);
86 86
 				 try {
87 87
 					$sth = $this->db->prepare($query);
88 88
 					$sth->execute($query_values);
89
-				} catch(PDOException $e) {
89
+				} catch (PDOException $e) {
90 90
 					return "error : ".$e->getMessage();
91 91
 				}
92 92
 			}
93 93
 		} else {
94 94
 			$query = 'INSERT INTO  routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source)  VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)';
95
-			$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
95
+			$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
96 96
 			 try {
97 97
 				$sth = $this->db->prepare($query);
98 98
 				$sth->execute($query_values);
99
-			} catch(PDOException $e) {
99
+			} catch (PDOException $e) {
100 100
 				return "error : ".$e->getMessage();
101 101
 			}
102 102
 		}
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
 
106 106
 	public function getSchedule($ident) {
107 107
 	        $Translation = new Translation($this->db);
108
-	        $operator = $Translation->checkTranslation($ident,false);
108
+	        $operator = $Translation->checkTranslation($ident, false);
109 109
 	        if ($ident != $operator) {
110 110
 	    		$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :operator OR CallSign = :ident LIMIT 1";
111
-	    		$query_values = array(':ident' => $ident,'operator' => $operator);
111
+	    		$query_values = array(':ident' => $ident, 'operator' => $operator);
112 112
 	    	} else {
113 113
 		        $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :ident LIMIT 1";
114 114
 	    		$query_values = array(':ident' => $ident);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		 try {
117 117
 			$sth = $this->db->prepare($query);
118 118
 			$sth->execute($query_values);
119
-		} catch(PDOException $e) {
119
+		} catch (PDOException $e) {
120 120
 			return "error : ".$e->getMessage();
121 121
 		}
122 122
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		 try {
140 140
 			$sth = $this->db->prepare($query);
141 141
 			$sth->execute($query_values);
142
-		} catch(PDOException $e) {
142
+		} catch (PDOException $e) {
143 143
 			return "error : ".$e->getMessage();
144 144
 		}
145 145
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -153,16 +153,16 @@  discard block
 block discarded – undo
153 153
 	* @param String $carrier IATA code
154 154
 	* @return Flight departure and arrival airports and time
155 155
 	*/
156
-	private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
156
+	private function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') {
157 157
 		$Common = new Common();
158 158
 		$check_date = new Datetime($date);
159
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
160
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
159
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
160
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
161 161
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
162 162
 		$json = $Common->getData($url);
163 163
 	
164 164
 		$parsed_json = json_decode($json);
165
-		if (property_exists($parsed_json,'errors') === false) {
165
+		if (property_exists($parsed_json, 'errors') === false) {
166 166
 			//$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'};
167 167
 			$originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'};
168 168
 			//$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'};
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 			//$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'};
173 173
 			$arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'};
174 174
 
175
-			preg_match('/\((.*?)\)/',$originShort,$originiata);
175
+			preg_match('/\((.*?)\)/', $originShort, $originiata);
176 176
 			$DepartureAirportIata = $originiata[1];
177
-			preg_match('/\((.*?)\)/',$destinationShort,$destinationiata);
177
+			preg_match('/\((.*?)\)/', $destinationShort, $destinationiata);
178 178
 			$ArrivalAirportIata = $destinationiata[1];
179 179
 
180 180
 			/*
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			$arrivalTime = gmdate('H:i',strtotime($arrivalTime));
184 184
 			*/
185 185
 		
186
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
186
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance');
187 187
 		} else return array();
188 188
 	}
189 189
 
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
 		$Common = new Common();
199 199
 		date_default_timezone_set($globalTimezone);
200 200
 		$check_date = new Datetime($date);
201
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
202
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
201
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
202
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
203 203
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
204 204
 		$json = $Common->getData($url);
205 205
 		$parsed_json = json_decode($json);
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 			$departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'};
212 212
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
213 213
 
214
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
214
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet');
215 215
 		} else return array();
216 216
 	}
217 217
 
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
 	*/
223 223
 	private function getRyanair($callsign) {
224 224
 		$Common = new Common();
225
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
226
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
225
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
226
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
227 227
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
228 228
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
229
-		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
230
-		$json = $Common->getData($url,'post',$post,$headers);
229
+		$headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post));
230
+		$json = $Common->getData($url, 'post', $post, $headers);
231 231
 		$parsed_json = json_decode($json);
232 232
 		if (isset($parsed_json->{'flightInfo'})) {
233 233
 			$flights = $parsed_json->{'flightInfo'};
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 				$ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name
237 237
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
238 238
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
239
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
239
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
240 240
 			} else return array();
241 241
 		} else return array();
242 242
 	}
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	*/
249 249
 	private function getSwiss($callsign) {
250 250
 		$Common = new Common();
251
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
252
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
251
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
252
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
253 253
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
254 254
 		$json = $Common->getData($url);
255 255
 		$parsed_json = json_decode($json);
@@ -263,12 +263,12 @@  discard block
 block discarded – undo
263 263
 				if ($flight->{'no'} == "Vol LX ".$numvol) {
264 264
 					$DepartureAirportIata = $flight->{'from'}->{'code'}; //city
265 265
 					$ArrivalAirportIata = $flight->{'to'}->{'code'}; //city
266
-					$departureTime = substr($flight->{'from'}->{'hour'},0,5);
267
-					$arrivalTime = substr($flight->{'to'}->{'hour'},0,5);
266
+					$departureTime = substr($flight->{'from'}->{'hour'},0, 5);
267
+					$arrivalTime = substr($flight->{'to'}->{'hour'},0, 5);
268 268
 				}
269 269
 			}
270 270
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
271
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
271
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss');
272 272
 			} else return array();
273 273
 		} else return array();
274 274
 	}
@@ -283,21 +283,21 @@  discard block
 block discarded – undo
283 283
 		global $globalBritishAirwaysKey;
284 284
 		$Common = new Common();
285 285
 		$check_date = new Datetime($date);
286
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
287
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
286
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
287
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
288 288
 		if ($globalBritishAirwaysKey == '') return array();
289 289
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
290 290
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
291
-		$json = $Common->getData($url,'get','',$headers);
291
+		$json = $Common->getData($url, 'get', '', $headers);
292 292
 		if ($json == '') return array();
293 293
 		$parsed_json = json_decode($json);
294 294
 		$flights = $parsed_json->{'FlightsResponse'};
295 295
 		if (count($flights) > 0) {
296 296
 			$DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'};
297 297
 			$ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'};
298
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
299
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
300
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
298
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
299
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
300
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways');
301 301
 		} else return array();
302 302
 	}
303 303
 
@@ -311,27 +311,27 @@  discard block
 block discarded – undo
311 311
 		global $globalLufthansaKey;
312 312
 		$Common = new Common();
313 313
 		$check_date = new Datetime($date);
314
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
315
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
314
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
315
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
316 316
 		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
317 317
 		$url = "https://api.lufthansa.com/v1/oauth/token";
318
-		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
319
-		$data = $Common->getData($url,'post',$post);
318
+		$post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials');
319
+		$data = $Common->getData($url, 'post', $post);
320 320
 		$parsed_data = json_decode($data);
321 321
 		if (!isset($parsed_data->{'access_token'})) return array();
322 322
 		$token = $parsed_data->{'access_token'};
323 323
 		
324 324
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
325
-		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
326
-		$json = $Common->getData($url,'get','',$headers);
325
+		$headers = array('Authorization: Bearer '.$token, 'Accept: application/json');
326
+		$json = $Common->getData($url, 'get', '', $headers);
327 327
 		if ($json == '') return array();
328 328
 		$parsed_json = json_decode($json);
329 329
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
330 330
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
331
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
331
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
332 332
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
333
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
334
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
333
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
334
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa');
335 335
 		} else return array();
336 336
 	}
337 337
 
@@ -345,23 +345,23 @@  discard block
 block discarded – undo
345 345
 		global $globalTransaviaKey;
346 346
 		$Common = new Common();
347 347
 		$check_date = new Datetime($date);
348
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
349
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
348
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
349
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
350 350
 		if ($globalTransaviaKey == '') return array();
351 351
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
352 352
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
353 353
 		$headers = array('apikey: '.$globalTransaviaKey);
354
-		$json = $Common->getData($url,'get','',$headers);
354
+		$json = $Common->getData($url, 'get', '', $headers);
355 355
 		//echo 'result : '.$json;
356 356
 		if ($json == '') return array();
357 357
 		$parsed_json = json_decode($json);
358 358
 		
359 359
 		if (isset($parsed_json->{'data'}[0])) {
360 360
 			$DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'};
361
-			$departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
361
+			$departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
362 362
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
363
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
364
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
363
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
364
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia');
365 365
 		} else return array();
366 366
 	}
367 367
 
@@ -372,14 +372,14 @@  discard block
 block discarded – undo
372 372
 	*/
373 373
 	public function getTunisair($callsign) {
374 374
 		$Common = new Common();
375
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
376
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
375
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
376
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
377 377
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
378 378
 		$data = $Common->getData($url);
379 379
 		$table = $Common->table2array($data);
380 380
 		foreach ($table as $flight) {
381
-			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) {
382
-				return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair');
381
+			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) {
382
+				return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair');
383 383
 			}
384 384
 		}
385 385
 		return array();
@@ -390,21 +390,21 @@  discard block
 block discarded – undo
390 390
 	* @param String $callsign The callsign
391 391
 	* @return Flight departure and arrival airports and time
392 392
 	*/
393
-	public function getVueling($callsign,$date = 'NOW') {
393
+	public function getVueling($callsign, $date = 'NOW') {
394 394
 		$Common = new Common();
395 395
 		$check_date = new Datetime($date);
396
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
397
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
398
-		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
396
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
397
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
398
+		$final_date = str_replace('/', '%2F', $check_date->format('d/m/Y'));
399 399
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
400 400
 		$data = $Common->getData($url);
401
-		$data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data));
401
+		$data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data));
402 402
 		if ($data != '') {
403
-			preg_match('/flightOri=[A-Z]{3}/',$data,$result);
404
-			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
405
-			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
406
-			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
407
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
403
+			preg_match('/flightOri=[A-Z]{3}/', $data, $result);
404
+			$DepartureAirportIata = str_replace('flightOri=', '', $result[0]);
405
+			preg_match('/flightDest=[A-Z]{3}/', $data, $result);
406
+			$ArrivalAirportIata = str_replace('flightDest=', '', $result[0]);
407
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling');
408 408
 			else return array();
409 409
 		}
410 410
 		return array();
@@ -418,27 +418,27 @@  discard block
 block discarded – undo
418 418
 	*/
419 419
 	public function getIberia($callsign, $date = 'NOW') {
420 420
 		$Common = new Common();
421
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
421
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
422 422
 		$check_date = new Datetime($date);
423
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
423
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
424 424
 		$url = "https://www.iberia.com/web/flightDetail.do";
425
-		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
426
-		$data = $Common->getData($url,'post',$post);
425
+		$post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB');
426
+		$data = $Common->getData($url, 'post', $post);
427 427
 		if ($data != '') {
428 428
 			$table = $Common->table2array($data);
429 429
 			//print_r($table);
430 430
 			if (count($table) > 0) {
431 431
 				$flight = $table;
432
-				preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
433
-				preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch);
432
+				preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
433
+				preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch);
434 434
 				$DepartureAirportIata = $DepartureAirportIataMatch[0];
435 435
 				$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
436
-				$departureTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[3][2]))),0,5);
437
-				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
436
+				$departureTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[3][2]))), 0, 5);
437
+				$arrivalTime = trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][1])));
438 438
 				if ($arrivalTime == 'Hora estimada de llegada') {
439
-					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
440
-				} else $arrivalTime = substr($arrivalTime,0,5);
441
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
439
+					$arrivalTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][2]))), 0, 5);
440
+				} else $arrivalTime = substr($arrivalTime, 0, 5);
441
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia');
442 442
 			}
443 443
 		}
444 444
 		return array();
@@ -451,11 +451,11 @@  discard block
 block discarded – undo
451 451
 	* @return Flight departure and arrival airports and time
452 452
 	*/
453 453
 
454
-	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
454
+	private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') {
455 455
 		$Common = new Common();
456
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
456
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
457 457
 		$check_date = new Datetime($date);
458
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
458
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
459 459
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
460 460
 		$data = $Common->getData($url);
461 461
 		if ($data != '') {
@@ -464,13 +464,13 @@  discard block
 block discarded – undo
464 464
 				$flight = $table;
465 465
 				//print_r($table);
466 466
 				if (isset($flight[25]) && isset($flight[29])) {
467
-					preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch);
468
-					preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch);
467
+					preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch);
468
+					preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch);
469 469
 					$DepartureAirportIata = $DepartureAirportIataMatch[0];
470 470
 					$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
471
-					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
472
-					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
473
-					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
471
+					$departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5);
472
+					$arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5);
473
+					return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance');
474 474
 				} else return array();
475 475
 			}
476 476
 			
@@ -488,10 +488,10 @@  discard block
 block discarded – undo
488 488
 	*/
489 489
 	private function getAlitalia($callsign, $date = 'NOW') {
490 490
 		$Common = new Common();
491
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
491
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
492 492
 		$check_date = new Datetime($date);
493
-		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
494
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
493
+		$url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
494
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
495 495
 		$data = $Common->getData($url);
496 496
 		if ($data != '') {
497 497
 			$table = $Common->text2array($data);
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 			$ArrivalAirportIata = '';
500 500
 			$departureTime = $table[4];
501 501
 			$arrivalTime = $table[5];
502
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia');
502
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia');
503 503
 		}
504 504
 	}
505 505
 
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
 	*/
512 512
 	private function getBrussels($callsign, $date = 'NOW') {
513 513
 		$Common = new Common();
514
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
514
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
515 515
 		$check_date = new Datetime($date);
516
-		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
516
+		$url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
517 517
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
518
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
518
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
519 519
 		$data = $Common->getData($url);
520 520
 		if ($data != '') {
521 521
 		    //echo $data;
@@ -523,9 +523,9 @@  discard block
 block discarded – undo
523 523
 		    if (isset($parsed_json[0]->FromAirportCode)) {
524 524
 			$DepartureAirportIata = $parsed_json[0]->FromAirportCode;
525 525
 			$ArrivalAirportIata = $parsed_json[0]->ToAirportCode;
526
-			$departureTime = date('H:i',strtotime($parsed_json[0]->ScheduledDepatureDate));
527
-			$arrivalTime = date('H:i',strtotime($parsed_json[0]->ScheduledArrivalDate));
528
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
526
+			$departureTime = date('H:i', strtotime($parsed_json[0]->ScheduledDepatureDate));
527
+			$arrivalTime = date('H:i', strtotime($parsed_json[0]->ScheduledArrivalDate));
528
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels');
529 529
 		    }
530 530
 		}
531 531
 	}
@@ -602,21 +602,21 @@  discard block
 block discarded – undo
602 602
 	*/
603 603
 	private function getFlyTap($callsign) {
604 604
 		$Common = new Common();
605
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
606
-		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
605
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
606
+		$url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
607 607
 		//$check_date = new Datetime($date);
608
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
609
-		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
610
-		$data = $Common->getData($url,'post',$post);
608
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
609
+		$post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1');
610
+		$data = $Common->getData($url, 'post', $post);
611 611
 		if ($data != '') {
612 612
 			$table = $Common->table2array($data);
613
-			$departureTime = trim(substr($table[15][0],0,5));
614
-			$arrivalTime = trim(substr($table[35][0],0,5));
615
-			preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch);
616
-			preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch);
613
+			$departureTime = trim(substr($table[15][0], 0, 5));
614
+			$arrivalTime = trim(substr($table[35][0], 0, 5));
615
+			preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch);
616
+			preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch);
617 617
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
618 618
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
619
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap');
619
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap');
620 620
 		}
621 621
 		return array();
622 622
 	}
@@ -638,10 +638,10 @@  discard block
 block discarded – undo
638 638
 			} 
639 639
 		}
640 640
 		if ($airline_icao == '') return array();
641
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
642
-		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
641
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
642
+		$url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
643 643
 		//$check_date = new Datetime($date);
644
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
644
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
645 645
 		$data = $Common->getData($url);
646 646
 		if ($data != '') {
647 647
 			$table = $Common->table2array($data);
@@ -651,13 +651,13 @@  discard block
 block discarded – undo
651 651
 				$darr = '';
652 652
 				$ahour = '';
653 653
 				$aarr = '';
654
-				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
654
+				$n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr);
655 655
 				if ($n == 7) {
656 656
 				    $departureTime = $dhour;
657 657
 				    $arrivalTime = $ahour;
658
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
659
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
660
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
658
+				    $DepartureAirportIata = str_replace(array('(', ')'), '', $darr);
659
+				    $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr);
660
+				    return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper');
661 661
 				}
662 662
 			}
663 663
 		}
@@ -681,20 +681,20 @@  discard block
 block discarded – undo
681 681
 			} 
682 682
 		}
683 683
 		*/
684
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
685
-		$url= "http://fr.flightaware.com/live/flight/".$callsign;
684
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
685
+		$url = "http://fr.flightaware.com/live/flight/".$callsign;
686 686
 		//$check_date = new Datetime($date);
687
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
687
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
688 688
 		$data = $Common->getData($url);
689 689
 		if ($data != '') {
690 690
 			$table = $Common->table2array($data);
691 691
 			if (isset($table[11][0])) {
692
-				$departureTime = str_replace('h',':',substr($table[5][0],0,5));
693
-				$arrivalTime = str_replace('h',':',substr($table[5][1],0,5));
692
+				$departureTime = str_replace('h', ':', substr($table[5][0], 0, 5));
693
+				$arrivalTime = str_replace('h', ':', substr($table[5][1], 0, 5));
694 694
 				echo $table[3][0];
695
-				sscanf($table[3][0],'%*[^(] (%3[A-Z] / %*4[A-Z])',$DepartureAirportIata);
696
-				sscanf($table[3][1],'%*[^(] (%3[A-Z] / %*4[A-Z])',$ArrivalAirportIata);
697
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightaware');
695
+				sscanf($table[3][0], '%*[^(] (%3[A-Z] / %*4[A-Z])', $DepartureAirportIata);
696
+				sscanf($table[3][1], '%*[^(] (%3[A-Z] / %*4[A-Z])', $ArrivalAirportIata);
697
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightaware');
698 698
 			}
699 699
 		}
700 700
 		return array();
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 	*/
708 708
 	public function getCostToTravel($callsign) {
709 709
 		$Common = new Common();
710
-		$url= "http://www.costtotravel.com/flight-number/".$callsign;
710
+		$url = "http://www.costtotravel.com/flight-number/".$callsign;
711 711
 		//$check_date = new Datetime($date);
712 712
 		//if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
713 713
 		$data = $Common->getData($url);
@@ -715,11 +715,11 @@  discard block
 block discarded – undo
715 715
 			$table = $Common->table2array($data);
716 716
 			//print_r($table);
717 717
 			if (isset($table[11][1])) {
718
-				$departureTime = substr($table[11][1],0,5);
719
-				$arrivalTime = substr($table[17][1],0,5);
720
-				$DepartureAirportIata = substr($table[13][1],0,3);
721
-				$ArrivalAirportIata = substr($table[15][1],0,3);
722
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
718
+				$departureTime = substr($table[11][1], 0, 5);
719
+				$arrivalTime = substr($table[17][1], 0, 5);
720
+				$DepartureAirportIata = substr($table[13][1], 0, 3);
721
+				$ArrivalAirportIata = substr($table[15][1], 0, 3);
722
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel');
723 723
 			}
724 724
 		}
725 725
 		return array();
@@ -731,13 +731,13 @@  discard block
 block discarded – undo
731 731
 	* @param String $date date we want flight number info
732 732
 	* @return Flight departure and arrival airports and time
733 733
 	*/
734
-	private function getAirCanada($callsign,$date = 'NOW') {
734
+	private function getAirCanada($callsign, $date = 'NOW') {
735 735
 		$Common = new Common();
736 736
 		date_default_timezone_set('UTC');
737 737
 		$check_date = new Datetime($date);
738
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
739
-		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
740
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
738
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
739
+		$url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
740
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
741 741
 		$data = $Common->getData($url);
742 742
 		$dom = new DomDocument();
743 743
 		$dom->loadXML($data);
@@ -745,11 +745,11 @@  discard block
 block discarded – undo
745 745
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
746 746
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
747 747
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
748
-			$departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
748
+			$departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
749 749
 			$arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0);
750 750
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
751
-			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
752
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
751
+			$arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
752
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada');
753 753
 		} else return array();
754 754
 	}
755 755
 
@@ -761,21 +761,21 @@  discard block
 block discarded – undo
761 761
 	*/
762 762
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
763 763
 		$Common = new Common();
764
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
764
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
765 765
 		$check_date = new Datetime($date);
766
-		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
767
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
766
+		$url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
767
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
768 768
 		$data = $Common->getData($url);
769 769
 		if ($data != '') {
770 770
 			$table = $Common->table2array($data);
771 771
 			$flight = $table;
772
-			preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
773
-			preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch);
772
+			preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
773
+			preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch);
774 774
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
775 775
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
776 776
 			$departureTime = $flight[5][1];
777 777
 			$arrivalTime = $flight[23][1];
778
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines');
778
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines');
779 779
 		}
780 780
 	}
781 781
 
@@ -786,16 +786,16 @@  discard block
 block discarded – undo
786 786
 	* @param String $carrier airline code
787 787
 	* @return Flight departure and arrival airports and time
788 788
 	*/
789
-	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
789
+	private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') {
790 790
 		$Common = new Common();
791 791
 		date_default_timezone_set('UTC');
792 792
 		//AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair 
793
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
793
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
794 794
 		$check_date = new Datetime($date);
795
-		$url= "http://www.airberlin.com/en-US/site/aims.php";
796
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
797
-		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
798
-		$data = $Common->getData($url,'post',$post);
795
+		$url = "http://www.airberlin.com/en-US/site/aims.php";
796
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
797
+		$post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier);
798
+		$data = $Common->getData($url, 'post', $post);
799 799
 		//echo $data;
800 800
 		$DepartureAirportIata = '';
801 801
 		$ArrivalAirportIata = '';
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
 			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
809 809
 			else $departureAirport = '';
810 810
 		} else return array();
811
-		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
812
-		$data = $Common->getData($url,'post',$post);
811
+		$post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB');
812
+		$data = $Common->getData($url, 'post', $post);
813 813
 		if ($data != '') {
814 814
 			$table = $Common->table2array($data);
815 815
 			$flight = $table;
@@ -837,13 +837,13 @@  discard block
 block discarded – undo
837 837
 			}
838 838
 		}
839 839
 		if (isset($DepartureAirportIata)) {
840
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
840
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin');
841 841
 		} else return array();
842 842
 	}
843 843
 
844 844
 
845 845
 	
846
-	public function fetchSchedule($ident,$date = 'NOW') {
846
+	public function fetchSchedule($ident, $date = 'NOW') {
847 847
 		global $globalSchedulesSources, $globalSchedulesFetch;
848 848
 		//$Common = new Common();
849 849
 		if (!$globalSchedulesFetch) return array();
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
 				// Brussels Airlines
914 914
 				case "BEL":
915 915
 				case "SN":
916
-					return $this->getBrussels($ident,$date);
916
+					return $this->getBrussels($ident, $date);
917 917
 /*
918 918
 				// Copa Airlines
919 919
 				case "CMP":
@@ -998,17 +998,17 @@  discard block
 block discarded – undo
998 998
 				// Air France
999 999
 				case "AF":
1000 1000
 				case "AFR":
1001
-					return $this->getAirFrance($ident,$date,'AF');
1001
+					return $this->getAirFrance($ident, $date, 'AF');
1002 1002
 				// HOP
1003 1003
 				case "A5":
1004 1004
 				case "HOP":
1005
-					return $this->getAirFrance($ident,$date,'A5');
1005
+					return $this->getAirFrance($ident, $date, 'A5');
1006 1006
 				// EasyJet
1007 1007
 				case "U2":
1008 1008
 				case "DS":
1009 1009
 				case "EZY":
1010 1010
 				case "EZS":
1011
-					return $this->getEasyJet($ident,$date);
1011
+					return $this->getEasyJet($ident, $date);
1012 1012
 				// Ryanair
1013 1013
 				case "FR":
1014 1014
 				case "RYR":
@@ -1058,25 +1058,25 @@  discard block
 block discarded – undo
1058 1058
 					return $this->getIberia($ident);
1059 1059
 				// Vietnam Airlines
1060 1060
 				case "HVN":
1061
-					return $this->getVietnamAirlines($ident,$date);
1061
+					return $this->getVietnamAirlines($ident, $date);
1062 1062
 				// Air Berlin
1063 1063
 				case "AB":
1064 1064
 				case "BER":
1065
-					return $this->getAirBerlin($ident,$date,'AB');
1065
+					return $this->getAirBerlin($ident, $date, 'AB');
1066 1066
 				// NIKI
1067 1067
 				case "HG":
1068 1068
 				case "NLY":
1069
-					return $this->getAirBerlin($ident,$date,'HG');
1069
+					return $this->getAirBerlin($ident, $date, 'HG');
1070 1070
 				// BelAir
1071 1071
 				case "4T":
1072 1072
 				case "BHP":
1073
-					return $this->getAirBerlin($ident,$date,'4T');
1073
+					return $this->getAirBerlin($ident, $date, '4T');
1074 1074
 				default:
1075 1075
 					// Randomly use a generic function to get hours
1076 1076
 					if (strlen($airline_icao) == 2) {
1077
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1077
+						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1078 1078
 						if (count($globalSchedulesSources) > 0) {
1079
-							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1079
+							$rand = mt_rand(0, count($globalSchedulesSources) - 1);
1080 1080
 							$source = $globalSchedulesSources[$rand];
1081 1081
 							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1082 1082
 							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
Please login to merge, or discard this patch.
Braces   +164 added lines, -56 removed lines patch added patch discarded remove patch
@@ -122,7 +122,9 @@  discard block
 block discarded – undo
122 122
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
123 123
 		if (count($row) > 0) {
124 124
 			return $row;
125
-		} else return array();
125
+		} else {
126
+			return array();
127
+		}
126 128
 	}
127 129
 
128 130
 	public function checkSchedule($ident) {
@@ -157,7 +159,9 @@  discard block
 block discarded – undo
157 159
 		$Common = new Common();
158 160
 		$check_date = new Datetime($date);
159 161
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
160
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
162
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
163
+			return array();
164
+		}
161 165
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
162 166
 		$json = $Common->getData($url);
163 167
 	
@@ -184,7 +188,9 @@  discard block
 block discarded – undo
184 188
 			*/
185 189
 		
186 190
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
187
-		} else return array();
191
+		} else {
192
+			return array();
193
+		}
188 194
 	}
189 195
 
190 196
 	/**
@@ -199,7 +205,9 @@  discard block
 block discarded – undo
199 205
 		date_default_timezone_set($globalTimezone);
200 206
 		$check_date = new Datetime($date);
201 207
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
202
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
208
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
209
+			return array();
210
+		}
203 211
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
204 212
 		$json = $Common->getData($url);
205 213
 		$parsed_json = json_decode($json);
@@ -212,7 +220,9 @@  discard block
 block discarded – undo
212 220
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
213 221
 
214 222
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
215
-		} else return array();
223
+		} else {
224
+			return array();
225
+		}
216 226
 	}
217 227
 
218 228
 	/**
@@ -223,7 +233,9 @@  discard block
 block discarded – undo
223 233
 	private function getRyanair($callsign) {
224 234
 		$Common = new Common();
225 235
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
226
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
236
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
237
+			return array();
238
+		}
227 239
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
228 240
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
229 241
 		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
@@ -237,8 +249,12 @@  discard block
 block discarded – undo
237 249
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
238 250
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
239 251
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
240
-			} else return array();
241
-		} else return array();
252
+			} else {
253
+				return array();
254
+			}
255
+		} else {
256
+			return array();
257
+		}
242 258
 	}
243 259
 
244 260
 	/**
@@ -249,7 +265,9 @@  discard block
 block discarded – undo
249 265
 	private function getSwiss($callsign) {
250 266
 		$Common = new Common();
251 267
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
252
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
268
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
269
+			return array();
270
+		}
253 271
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
254 272
 		$json = $Common->getData($url);
255 273
 		$parsed_json = json_decode($json);
@@ -269,8 +287,12 @@  discard block
 block discarded – undo
269 287
 			}
270 288
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
271 289
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
272
-			} else return array();
273
-		} else return array();
290
+			} else {
291
+				return array();
292
+			}
293
+		} else {
294
+			return array();
295
+		}
274 296
 	}
275 297
 	
276 298
 	/**
@@ -284,12 +306,18 @@  discard block
 block discarded – undo
284 306
 		$Common = new Common();
285 307
 		$check_date = new Datetime($date);
286 308
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
287
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
288
-		if ($globalBritishAirwaysKey == '') return array();
309
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
310
+			return array();
311
+		}
312
+		if ($globalBritishAirwaysKey == '') {
313
+			return array();
314
+		}
289 315
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
290 316
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
291 317
 		$json = $Common->getData($url,'get','',$headers);
292
-		if ($json == '') return array();
318
+		if ($json == '') {
319
+			return array();
320
+		}
293 321
 		$parsed_json = json_decode($json);
294 322
 		$flights = $parsed_json->{'FlightsResponse'};
295 323
 		if (count($flights) > 0) {
@@ -298,7 +326,9 @@  discard block
 block discarded – undo
298 326
 			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
299 327
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
300 328
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
301
-		} else return array();
329
+		} else {
330
+			return array();
331
+		}
302 332
 	}
303 333
 
304 334
 	/**
@@ -312,19 +342,27 @@  discard block
 block discarded – undo
312 342
 		$Common = new Common();
313 343
 		$check_date = new Datetime($date);
314 344
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
315
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
316
-		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
345
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
346
+			return array();
347
+		}
348
+		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') {
349
+			return array();
350
+		}
317 351
 		$url = "https://api.lufthansa.com/v1/oauth/token";
318 352
 		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
319 353
 		$data = $Common->getData($url,'post',$post);
320 354
 		$parsed_data = json_decode($data);
321
-		if (!isset($parsed_data->{'access_token'})) return array();
355
+		if (!isset($parsed_data->{'access_token'})) {
356
+			return array();
357
+		}
322 358
 		$token = $parsed_data->{'access_token'};
323 359
 		
324 360
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
325 361
 		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
326 362
 		$json = $Common->getData($url,'get','',$headers);
327
-		if ($json == '') return array();
363
+		if ($json == '') {
364
+			return array();
365
+		}
328 366
 		$parsed_json = json_decode($json);
329 367
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
330 368
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
@@ -332,7 +370,9 @@  discard block
 block discarded – undo
332 370
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
333 371
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
334 372
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
335
-		} else return array();
373
+		} else {
374
+			return array();
375
+		}
336 376
 	}
337 377
 
338 378
 	/**
@@ -346,14 +386,20 @@  discard block
 block discarded – undo
346 386
 		$Common = new Common();
347 387
 		$check_date = new Datetime($date);
348 388
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
349
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
350
-		if ($globalTransaviaKey == '') return array();
389
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
390
+			return array();
391
+		}
392
+		if ($globalTransaviaKey == '') {
393
+			return array();
394
+		}
351 395
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
352 396
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
353 397
 		$headers = array('apikey: '.$globalTransaviaKey);
354 398
 		$json = $Common->getData($url,'get','',$headers);
355 399
 		//echo 'result : '.$json;
356
-		if ($json == '') return array();
400
+		if ($json == '') {
401
+			return array();
402
+		}
357 403
 		$parsed_json = json_decode($json);
358 404
 		
359 405
 		if (isset($parsed_json->{'data'}[0])) {
@@ -362,7 +408,9 @@  discard block
 block discarded – undo
362 408
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
363 409
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
364 410
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
365
-		} else return array();
411
+		} else {
412
+			return array();
413
+		}
366 414
 	}
367 415
 
368 416
 	/**
@@ -373,7 +421,9 @@  discard block
 block discarded – undo
373 421
 	public function getTunisair($callsign) {
374 422
 		$Common = new Common();
375 423
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
376
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
424
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
425
+			return array();
426
+		}
377 427
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
378 428
 		$data = $Common->getData($url);
379 429
 		$table = $Common->table2array($data);
@@ -394,7 +444,9 @@  discard block
 block discarded – undo
394 444
 		$Common = new Common();
395 445
 		$check_date = new Datetime($date);
396 446
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
397
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
447
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
448
+			return array();
449
+		}
398 450
 		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
399 451
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
400 452
 		$data = $Common->getData($url);
@@ -404,8 +456,11 @@  discard block
 block discarded – undo
404 456
 			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
405 457
 			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
406 458
 			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
407
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
408
-			else return array();
459
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') {
460
+				return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
461
+			} else {
462
+				return array();
463
+			}
409 464
 		}
410 465
 		return array();
411 466
 	}
@@ -420,7 +475,9 @@  discard block
 block discarded – undo
420 475
 		$Common = new Common();
421 476
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
422 477
 		$check_date = new Datetime($date);
423
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
478
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
479
+			return array();
480
+		}
424 481
 		$url = "https://www.iberia.com/web/flightDetail.do";
425 482
 		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
426 483
 		$data = $Common->getData($url,'post',$post);
@@ -437,7 +494,9 @@  discard block
 block discarded – undo
437 494
 				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
438 495
 				if ($arrivalTime == 'Hora estimada de llegada') {
439 496
 					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
440
-				} else $arrivalTime = substr($arrivalTime,0,5);
497
+				} else {
498
+					$arrivalTime = substr($arrivalTime,0,5);
499
+				}
441 500
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
442 501
 			}
443 502
 		}
@@ -455,7 +514,9 @@  discard block
 block discarded – undo
455 514
 		$Common = new Common();
456 515
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
457 516
 		$check_date = new Datetime($date);
458
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
517
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
518
+			return array();
519
+		}
459 520
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
460 521
 		$data = $Common->getData($url);
461 522
 		if ($data != '') {
@@ -471,7 +532,9 @@  discard block
 block discarded – undo
471 532
 					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
472 533
 					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
473 534
 					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
474
-				} else return array();
535
+				} else {
536
+					return array();
537
+				}
475 538
 			}
476 539
 			
477 540
 
@@ -491,7 +554,9 @@  discard block
 block discarded – undo
491 554
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
492 555
 		$check_date = new Datetime($date);
493 556
 		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
494
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
557
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
558
+			return array();
559
+		}
495 560
 		$data = $Common->getData($url);
496 561
 		if ($data != '') {
497 562
 			$table = $Common->text2array($data);
@@ -515,7 +580,9 @@  discard block
 block discarded – undo
515 580
 		$check_date = new Datetime($date);
516 581
 		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
517 582
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
518
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
583
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
584
+			return array();
585
+		}
519 586
 		$data = $Common->getData($url);
520 587
 		if ($data != '') {
521 588
 		    //echo $data;
@@ -605,7 +672,9 @@  discard block
 block discarded – undo
605 672
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
606 673
 		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
607 674
 		//$check_date = new Datetime($date);
608
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
675
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
676
+			return array();
677
+		}
609 678
 		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
610 679
 		$data = $Common->getData($url,'post',$post);
611 680
 		if ($data != '') {
@@ -637,11 +706,15 @@  discard block
 block discarded – undo
637 706
 				$airline_icao = substr($callsign, 0, 3);
638 707
 			} 
639 708
 		}
640
-		if ($airline_icao == '') return array();
709
+		if ($airline_icao == '') {
710
+			return array();
711
+		}
641 712
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
642 713
 		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
643 714
 		//$check_date = new Datetime($date);
644
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
715
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
716
+			return array();
717
+		}
645 718
 		$data = $Common->getData($url);
646 719
 		if ($data != '') {
647 720
 			$table = $Common->table2array($data);
@@ -684,7 +757,9 @@  discard block
 block discarded – undo
684 757
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
685 758
 		$url= "http://fr.flightaware.com/live/flight/".$callsign;
686 759
 		//$check_date = new Datetime($date);
687
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
760
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
761
+			return array();
762
+		}
688 763
 		$data = $Common->getData($url);
689 764
 		if ($data != '') {
690 765
 			$table = $Common->table2array($data);
@@ -737,11 +812,15 @@  discard block
 block discarded – undo
737 812
 		$check_date = new Datetime($date);
738 813
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
739 814
 		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
740
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
815
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
816
+			return array();
817
+		}
741 818
 		$data = $Common->getData($url);
742 819
 		$dom = new DomDocument();
743 820
 		$dom->loadXML($data);
744
-		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array();
821
+		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) {
822
+			return array();
823
+		}
745 824
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
746 825
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
747 826
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
@@ -750,7 +829,9 @@  discard block
 block discarded – undo
750 829
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
751 830
 			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
752 831
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
753
-		} else return array();
832
+		} else {
833
+			return array();
834
+		}
754 835
 	}
755 836
 
756 837
 	/**
@@ -764,7 +845,9 @@  discard block
 block discarded – undo
764 845
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
765 846
 		$check_date = new Datetime($date);
766 847
 		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
767
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
848
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
849
+			return array();
850
+		}
768 851
 		$data = $Common->getData($url);
769 852
 		if ($data != '') {
770 853
 			$table = $Common->table2array($data);
@@ -793,7 +876,9 @@  discard block
 block discarded – undo
793 876
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
794 877
 		$check_date = new Datetime($date);
795 878
 		$url= "http://www.airberlin.com/en-US/site/aims.php";
796
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
879
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
880
+			return array();
881
+		}
797 882
 		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
798 883
 		$data = $Common->getData($url,'post',$post);
799 884
 		//echo $data;
@@ -803,11 +888,19 @@  discard block
 block discarded – undo
803 888
 		if ($data != '') {
804 889
 			$table = $Common->table2array($data);
805 890
 			$flight = $table;
806
-			if (isset($flight[5][4])) $departureTime = $flight[5][4];
807
-			else $departureTime = '';
808
-			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
809
-			else $departureAirport = '';
810
-		} else return array();
891
+			if (isset($flight[5][4])) {
892
+				$departureTime = $flight[5][4];
893
+			} else {
894
+				$departureTime = '';
895
+			}
896
+			if (isset($flight[5][2])) {
897
+				$departureAirport = $flight[5][2];
898
+			} else {
899
+				$departureAirport = '';
900
+			}
901
+		} else {
902
+			return array();
903
+		}
811 904
 		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
812 905
 		$data = $Common->getData($url,'post',$post);
813 906
 		if ($data != '') {
@@ -820,10 +913,14 @@  discard block
 block discarded – undo
820 913
 			    $arrivalTime = '';
821 914
 			    $arrivalAirport = '';
822 915
 			}
823
-		} else return array();
916
+		} else {
917
+			return array();
918
+		}
824 919
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
825 920
 		$json = $Common->getData($url);
826
-		if ($json == '') return array();
921
+		if ($json == '') {
922
+			return array();
923
+		}
827 924
 		$parsed_json = json_decode($json);
828 925
 		$airports = $parsed_json->{'suggestList'};
829 926
 		if (count($airports) > 0) {
@@ -838,7 +935,9 @@  discard block
 block discarded – undo
838 935
 		}
839 936
 		if (isset($DepartureAirportIata)) {
840 937
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
841
-		} else return array();
938
+		} else {
939
+			return array();
940
+		}
842 941
 	}
843 942
 
844 943
 
@@ -846,7 +945,9 @@  discard block
 block discarded – undo
846 945
 	public function fetchSchedule($ident,$date = 'NOW') {
847 946
 		global $globalSchedulesSources, $globalSchedulesFetch;
848 947
 		//$Common = new Common();
849
-		if (!$globalSchedulesFetch) return array();
948
+		if (!$globalSchedulesFetch) {
949
+			return array();
950
+		}
850 951
 		$airline_icao = '';
851 952
 		if (!is_numeric(substr($ident, 0, 3)))
852 953
 		{
@@ -1074,14 +1175,21 @@  discard block
 block discarded – undo
1074 1175
 				default:
1075 1176
 					// Randomly use a generic function to get hours
1076 1177
 					if (strlen($airline_icao) == 2) {
1077
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1178
+						if (!isset($globalSchedulesSources)) {
1179
+							$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1180
+						}
1078 1181
 						if (count($globalSchedulesSources) > 0) {
1079 1182
 							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1080 1183
 							$source = $globalSchedulesSources[$rand];
1081
-							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1082
-							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
1184
+							if ($source == 'flightmapper') {
1185
+								return $this->getFlightMapper($ident);
1186
+							} elseif ($source == 'costtotravel') {
1187
+								return $this->getCostToTravel($ident);
1188
+							}
1083 1189
 							//elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date);
1084
-							elseif ($source == 'flightaware') return $this->getFlightAware($ident);
1190
+							elseif ($source == 'flightaware') {
1191
+								return $this->getFlightAware($ident);
1192
+							}
1085 1193
 						}
1086 1194
 					}
1087 1195
 			}
Please login to merge, or discard this patch.