Completed
Push — master ( 637022...8149d9 )
by Yannick
55:10 queued 27:13
created
getImages.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -4,31 +4,31 @@  discard block
 block discarded – undo
4 4
 	$hex = str_replace("#", "", $hex);
5 5
 	$color = array();
6 6
 	if (strlen($hex) == 3) {
7
-	    $color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1));
8
-	    $color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1));
9
-	    $color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1));
7
+		$color['r'] = hexdec(substr($hex, 0, 1) . substr($hex,0,1));
8
+		$color['g'] = hexdec(substr($hex, 1, 1) . substr($hex,1,1));
9
+		$color['b'] = hexdec(substr($hex, 2, 1) . substr($hex,2,1));
10 10
 	} else if (strlen($hex) == 6) {
11
-	    $color['r'] = hexdec(substr($hex, 0, 2));
12
-	    $color['g'] = hexdec(substr($hex, 2, 2));
13
-	    $color['b'] = hexdec(substr($hex, 4, 2));
11
+		$color['r'] = hexdec(substr($hex, 0, 2));
12
+		$color['g'] = hexdec(substr($hex, 2, 2));
13
+		$color['b'] = hexdec(substr($hex, 4, 2));
14 14
 	}
15 15
 	return $color;
16 16
 }
17 17
 
18 18
 
19 19
 if (!isset($_GET['color']) || $_GET['color'] == '' || !preg_match('/^([a-fA-F0-9]){3}(([a-fA-F0-9]){3})?\b/',$_GET['color'])) { 
20
-    exit(0);
20
+	exit(0);
21 21
 }
22 22
 $color = $_GET['color'];
23 23
 if (!isset($_GET['filename']) || !preg_match('/^[a-z0-9-_]+\.png$/', strtolower($_GET['filename']))) {
24
-    echo "Incorrect filename";
25
-    exit(0);
24
+	echo "Incorrect filename";
25
+	exit(0);
26 26
 }
27 27
 $filename = $_GET['filename'];
28 28
 if (file_exists(dirname(__FILE__).'/cache/'.$color.'-'.$filename) && is_readable(dirname(__FILE__).'/cache/'.$color.'-'.$filename)) {
29
-    header('Content-type: image/png');
30
-    readfile(dirname(__FILE__).'/cache/'.$color.'-'.$filename);
31
-    exit(0);
29
+	header('Content-type: image/png');
30
+	readfile(dirname(__FILE__).'/cache/'.$color.'-'.$filename);
31
+	exit(0);
32 32
 }
33 33
 if (isset($_GET['tracker'])) {
34 34
 	$original = dirname(__FILE__).'/images/vehicules/color/'.$filename;
@@ -45,68 +45,68 @@  discard block
 block discarded – undo
45 45
 	$original = dirname(__FILE__).'/images/aircrafts/new/'.$filename;
46 46
 }
47 47
 if (!file_exists($original)) {
48
-    echo "File not found";
48
+	echo "File not found";
49 49
 }
50 50
 
51 51
 if (extension_loaded('gd') && function_exists('gd_info')) {
52
-    $image = imagecreatefrompng($original);
53
-    $index = imagecolorexact($image,26,49,81);
54
-    if ($index < 0) {
52
+	$image = imagecreatefrompng($original);
53
+	$index = imagecolorexact($image,26,49,81);
54
+	if ($index < 0) {
55 55
 	$index = imagecolorexact($image,25,49,79);
56
-    }
57
-    if ($index < 0) {
56
+	}
57
+	if ($index < 0) {
58 58
 	$index = imagecolorexact($image,0,0,0);
59
-    }
60
-    $c = hexToRGB($color);
61
-    imagecolorset($image,$index,$c['r'],$c['g'],$c['b']);
59
+	}
60
+	$c = hexToRGB($color);
61
+	imagecolorset($image,$index,$c['r'],$c['g'],$c['b']);
62 62
  /*
63 63
     $ig = imagecolorat($image, 0, 0);
64 64
     imagecolortransparent($image, $ig);
65 65
    */
66 66
 
67
-    header('Content-type: image/png');
68
-    if (isset($_GET['resize']) && function_exists('imagecopyresampled')) {
67
+	header('Content-type: image/png');
68
+	if (isset($_GET['resize']) && function_exists('imagecopyresampled')) {
69 69
 	$resize = filter_input(INPUT_GET,'resize',FILTER_SANITIZE_NUMBER_INT);
70 70
 	$newimg = imagecreatetruecolor($resize,$resize);
71
-        imagealphablending($newimg, false);
71
+		imagealphablending($newimg, false);
72 72
 	imagesavealpha($newimg, true);
73 73
 	imagecopyresampled($newimg,$image,0,0,0,0,15,15,imagesx($image),imagesy($image));
74 74
 	if (isset($_GET['heading'])) {
75
-    	    $heading = filter_input(INPUT_GET,'heading',FILTER_SANITIZE_NUMBER_INT);
76
-    	    $rotation = imagerotate($newimg,$heading,imageColorAllocateAlpha($newimg,0,0,0,127));
77
-    	    imagealphablending($rotation, false);
78
-	    imagesavealpha($rotation, true);
79
-    	    imagepng($rotation);
80
-    	    imagedestroy($newimg);
81
-    	    imagedestroy($image);
82
-    	    imagedestroy($rotation);
75
+			$heading = filter_input(INPUT_GET,'heading',FILTER_SANITIZE_NUMBER_INT);
76
+			$rotation = imagerotate($newimg,$heading,imageColorAllocateAlpha($newimg,0,0,0,127));
77
+			imagealphablending($rotation, false);
78
+		imagesavealpha($rotation, true);
79
+			imagepng($rotation);
80
+			imagedestroy($newimg);
81
+			imagedestroy($image);
82
+			imagedestroy($rotation);
83 83
 	
84 84
 	} else {
85
-    	    imagepng($newimg);
86
-    	    imagedestroy($newimg);
87
-    	    imagedestroy($image);
88
-        }
89
-    } else {
85
+			imagepng($newimg);
86
+			imagedestroy($newimg);
87
+			imagedestroy($image);
88
+		}
89
+	} else {
90 90
 	imagealphablending($image, false);
91
-        imagesavealpha($image, true);
91
+		imagesavealpha($image, true);
92 92
 	imagepng($image);
93 93
 	imagepng($image);
94 94
 	if (is_writable(dirname(__FILE__).'/cache')) {
95
-    	    imagepng($image,dirname(__FILE__).'/cache/'.$color.'-'.$filename);
95
+			imagepng($image,dirname(__FILE__).'/cache/'.$color.'-'.$filename);
96
+	}
97
+		imagedestroy($image);
96 98
 	}
97
-        imagedestroy($image);
98
-    }
99 99
 } else {
100
-    header('Content-type: image/png');
101
-    if (isset($_GET['tracker'])) {
102
-        readfile(dirname(__FILE__).'/images/vehicules/'.$filename);
103
-    } elseif (isset($_GET['marine'])) {
104
-        readfile(dirname(__FILE__).'/images/vehicules/'.$filename);
105
-    } elseif (isset($_GET['satellite'])) {
106
-        readfile(dirname(__FILE__).'/images/satellites/'.$filename);
107
-    } else {
108
-        if ($color == 'FF0000') readfile(dirname(__FILE__).'/images/aircrafts/selected/'.$filename);
100
+	header('Content-type: image/png');
101
+	if (isset($_GET['tracker'])) {
102
+		readfile(dirname(__FILE__).'/images/vehicules/'.$filename);
103
+	} elseif (isset($_GET['marine'])) {
104
+		readfile(dirname(__FILE__).'/images/vehicules/'.$filename);
105
+	} elseif (isset($_GET['satellite'])) {
106
+		readfile(dirname(__FILE__).'/images/satellites/'.$filename);
107
+	} else {
108
+		if ($color == 'FF0000') readfile(dirname(__FILE__).'/images/aircrafts/selected/'.$filename);
109 109
 	else readfile(dirname(__FILE__).'/images/aircrafts/'.$filename);
110
-    }
110
+	}
111 111
 }
112 112
 ?>
113 113
\ No newline at end of file
Please login to merge, or discard this patch.
install/install-action.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
 	if ($check_version == '0') {
87 87
 		
88 88
 		if ($globalDBdriver == 'mysql') {
89
-		    $error .= create_db::import_all_db('../db/');
89
+			$error .= create_db::import_all_db('../db/');
90 90
 		} elseif ($globalDBdriver == 'pgsql') {
91
-		    $error .= create_db::import_all_db('../db/pgsql/');
91
+			$error .= create_db::import_all_db('../db/pgsql/');
92 92
 		}
93 93
 		if ($error != '') {
94 94
 			$_SESSION['error'] = $error;
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 			$_SESSION['install'] = 'populate';
99 99
 			$_SESSION['next'] = 'Populate aircraft_modes table with externals data for ADS-B';
100 100
 		} else {
101
-		    $_SESSION['install'] = 'sources';
102
-		    $_SESSION['next'] = 'Insert data in source table';
101
+			$_SESSION['install'] = 'sources';
102
+			$_SESSION['next'] = 'Insert data in source table';
103 103
 		}
104 104
 		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
105 105
 		print json_encode($result);
@@ -156,10 +156,10 @@  discard block
 block discarded – undo
156 156
 		$_SESSION['errorlst'] = array_merge($_SESSION['errorlst'],array('Populate countries database'));
157 157
 	} else $_SESSION['done'] = array_merge($_SESSION['done'],array('Populate countries database'));
158 158
 	if (isset($globalNOTAM) && $globalNOTAM && isset($globalNOTAMSource) && $globalNOTAMSource != '') {
159
-	    $_SESSION['install'] = 'notam';
160
-	    $_SESSION['next'] = 'Populate NOTAM table with externals data';
161
-	    $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
162
-	    print json_encode($result);
159
+		$_SESSION['install'] = 'notam';
160
+		$_SESSION['next'] = 'Populate NOTAM table with externals data';
161
+		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
162
+		print json_encode($result);
163 163
 	/*
164 164
 	} elseif (isset($_SESSION['owner']) && $_SESSION['owner'] == 1) {
165 165
 	    $_SESSION['install'] = 'owner';
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 	    print json_encode($result);
170 170
 	*/
171 171
 	} else {
172
-	    $_SESSION['install'] = 'sources';
173
-	    $_SESSION['next'] = 'Insert data in source table';
174
-	    $result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
175
-	    print json_encode($result);
172
+		$_SESSION['install'] = 'sources';
173
+		$_SESSION['next'] = 'Insert data in source table';
174
+		$result = array('error' => $error,'errorlst' => $_SESSION['errorlst'],'done' => $_SESSION['done'],'next' => $_SESSION['next'],'install' => $_SESSION['install']);
175
+		print json_encode($result);
176 176
 	}
177 177
 } else if (isset($_SESSION['install']) && $_SESSION['install'] == 'populate') {
178 178
 	if (!is_writable('tmp')) {
Please login to merge, or discard this patch.
install/index.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
 			<p>
189 189
 				<label for="siteurl">Site directory</label>
190 190
 				<?php
191
-				    // Try to detect site directory
192
-				    if ((!isset($globalURL) || $globalURL == '') && (!isset($globalDBuser) || $globalDBuser == '')) {
191
+					// Try to detect site directory
192
+					if ((!isset($globalURL) || $globalURL == '') && (!isset($globalDBuser) || $globalDBuser == '')) {
193 193
 					if (isset($_SERVER['REQUEST_URI'])) {
194 194
 						$URL = $_SERVER['REQUEST_URI'];
195 195
 						$globalURL = str_replace('/install','',str_replace('/install/','',str_replace('/install/index.php','',$URL)));
196 196
 					}
197
-				    }
197
+					}
198 198
 				?>
199 199
 				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
200 200
 				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
@@ -373,17 +373,17 @@  discard block
 block discarded – undo
373 373
 				</tr>
374 374
 				
375 375
 		<?php
376
-		    if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') {
376
+			if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') {
377 377
 		?>
378 378
 		<!--
379 379
 		<?php
380
-			    require_once(dirname(__FILE__).'/../require/class.Connection.php');
381
-			    $Connection = new Connection();
380
+				require_once(dirname(__FILE__).'/../require/class.Connection.php');
381
+				$Connection = new Connection();
382 382
 		?>
383 383
 		-->
384 384
 		<?php
385 385
 			if ($Connection->db != NULL) {
386
-			    if ($Connection->tableExists('source_location')) {
386
+				if ($Connection->tableExists('source_location')) {
387 387
 				require_once(dirname(__FILE__).'/../require/class.Source.php');
388 388
 				$Source = new Source();
389 389
 				//$alllocations = $Source->getAllLocationInfo();
@@ -403,9 +403,9 @@  discard block
 block discarded – undo
403 403
 		
404 404
 		<?php
405 405
 				}
406
-			    }
406
+				}
407
+			}
407 408
 			}
408
-		    }
409 409
 		?>
410 410
 
411 411
 				<tr>
@@ -515,12 +515,12 @@  discard block
 block discarded – undo
515 515
 ?>
516 516
 							<tr>
517 517
 								<?php
518
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
518
+									if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
519 519
 								?>
520 520
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
521 521
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
522 522
 								<?php
523
-								    } else {
523
+									} else {
524 524
 									$hostport = explode(':',$source['host']);
525 525
 									if (isset($hostport[1])) {
526 526
 										$host = $hostport[0];
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 								<td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td>
534 534
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php print $port; ?>" /></td>
535 535
 								<?php
536
-								    }
536
+									}
537 537
 								?>
538 538
 								<td>
539 539
 									<select name="format[]" id="format">
@@ -673,9 +673,9 @@  discard block
 block discarded – undo
673 673
 			    </thead>
674 674
 			    <tbody>
675 675
 				<?php
676
-				    if (isset($globalNewsFeeds) && !empty($globalNewsFeeds)) {
676
+					if (isset($globalNewsFeeds) && !empty($globalNewsFeeds)) {
677 677
 					foreach ($globalNewsFeeds as $type => $feedslng) {
678
-					    foreach ($feedslng as $lng => $feeds) {
678
+						foreach ($feedslng as $lng => $feeds) {
679 679
 						foreach ($feeds as $feed) {
680 680
 				?>
681 681
 				<tr>
@@ -700,9 +700,9 @@  discard block
 block discarded – undo
700 700
 				
701 701
 				<?php
702 702
 						}
703
-					    }
703
+						}
704
+					}
704 705
 					}
705
-				    }
706 706
 				?>
707 707
 				<tr>
708 708
 				    <td><input type="url" name="newsurl[]" /></td>
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
 			<br />
1093 1093
 			<p>
1094 1094
 			<?php 
1095
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
1095
+				if (extension_loaded('gd') && function_exists('gd_info')) {
1096 1096
 			?>
1097 1097
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1098 1098
 				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
@@ -1102,11 +1102,11 @@  discard block
 block discarded – undo
1102 1102
 				<b>The directory cache is not writable, aircraft icon will not be cached</b>
1103 1103
 			<?php
1104 1104
 				}
1105
-			    } else {
1105
+				} else {
1106 1106
 			?>
1107 1107
 				<b>PHP GD is not installed, you can't change color of aircraft icon on map</b>
1108 1108
 			<?php
1109
-			    }
1109
+				}
1110 1110
 			?>
1111 1111
 			</p>
1112 1112
 			<br />
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 	</p>
1131 1131
 <?php
1132 1132
 	require('../footer.php');
1133
-        exit;
1133
+		exit;
1134 1134
 }
1135 1135
 // '	
1136 1136
 $settings = array();
@@ -1221,8 +1221,8 @@  discard block
 block discarded – undo
1221 1221
 	
1222 1222
 	$sources = array();
1223 1223
 	foreach ($source_name as $keys => $name) {
1224
-	    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]);
1225
-	    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]);
1224
+		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]);
1225
+		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]);
1226 1226
 	}
1227 1227
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1228 1228
 
@@ -1232,13 +1232,13 @@  discard block
 block discarded – undo
1232 1232
 	
1233 1233
 	$newsfeeds = array();
1234 1234
 	foreach($newsurl as $newskey => $url) {
1235
-	    if ($url != '') {
1235
+		if ($url != '') {
1236 1236
 		$type = $newstype[$newskey];
1237 1237
 		$lng = $newslng[$newskey];
1238 1238
 		if (isset($newsfeeds[$type][$lng])) {
1239
-		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1239
+			$newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1240 1240
 		} else $newsfeeds[$type][$lng] = array($url);
1241
-	    }
1241
+		}
1242 1242
 	}
1243 1243
 	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
1244 1244
 
@@ -1681,14 +1681,14 @@  discard block
 block discarded – undo
1681 1681
 
1682 1682
 	// Set some defaults values...
1683 1683
 	if (!isset($globalAircraftImageSources)) {
1684
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1685
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1684
+		$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1685
+		$settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1686 1686
 	}
1687 1687
 
1688 1688
 	if (!isset($globalSchedulesSources)) {
1689
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1690
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1691
-    	}
1689
+		$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1690
+			$settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1691
+		}
1692 1692
 
1693 1693
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1694 1694
 
@@ -1736,21 +1736,21 @@  discard block
 block discarded – undo
1736 1736
 	$popi = false;
1737 1737
 	$popw = false;
1738 1738
 	foreach ($_SESSION['done'] as $done) {
1739
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1740
-	    if ($done == 'Create database') $pop = true;
1741
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1742
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1743
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1739
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1740
+		if ($done == 'Create database') $pop = true;
1741
+		if ($_SESSION['install'] == 'database_create') $pop = true;
1742
+		if ($_SESSION['install'] == 'database_import') $popi = true;
1743
+		if ($_SESSION['install'] == 'waypoints') $popw = true;
1744 1744
 	}
1745 1745
 	if ($pop) {
1746
-	    sleep(5);
1747
-	    print '<li>Create database....<img src="../images/loading.gif" /></li>';
1746
+		sleep(5);
1747
+		print '<li>Create database....<img src="../images/loading.gif" /></li>';
1748 1748
 	} else if ($popi) {
1749
-	    sleep(5);
1750
-	    print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1749
+		sleep(5);
1750
+		print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1751 1751
 	} else if ($popw) {
1752
-	    sleep(5);
1753
-	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1752
+		sleep(5);
1753
+		print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1754 1754
 	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1755 1755
 	print '</div></ul>';
1756 1756
 	print '<div id="error"></div>';
@@ -1816,7 +1816,7 @@  discard block
 block discarded – undo
1816 1816
 	unset($_COOKIE['install']);
1817 1817
 	print '<div class="info column"><ul>';
1818 1818
 	foreach ($_SESSION['done'] as $done) {
1819
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1819
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1820 1820
 	}
1821 1821
 	print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>';
1822 1822
 	print '</ul></div>';
Please login to merge, or discard this patch.
require/class.TrackerImport.php 1 patch
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
 require_once(dirname(__FILE__).'/class.Source.php');
8 8
 
9 9
 class TrackerImport {
10
-    private $all_tracked = array();
11
-    private $last_delete_hourly = 0;
12
-    private $last_delete = 0;
13
-    private $stats = array();
14
-    private $tmd = 0;
15
-    private $source_location = array();
16
-    public $db = null;
17
-    public $nb = 0;
10
+	private $all_tracked = array();
11
+	private $last_delete_hourly = 0;
12
+	private $last_delete = 0;
13
+	private $stats = array();
14
+	private $tmd = 0;
15
+	private $source_location = array();
16
+	public $db = null;
17
+	public $nb = 0;
18 18
 
19
-    public function __construct($dbc = null) {
19
+	public function __construct($dbc = null) {
20 20
 	global $globalBeta;
21 21
 	$Connection = new Connection($dbc);
22 22
 	$this->db = $Connection->db();
@@ -38,50 +38,50 @@  discard block
 block discarded – undo
38 38
 	    }
39 39
 	}
40 40
 	*/
41
-    }
41
+	}
42 42
 
43
-    public function checkAll() {
43
+	public function checkAll() {
44 44
 	global $globalDebug;
45 45
 	if ($globalDebug) echo "Update last seen tracked data...\n";
46 46
 	foreach ($this->all_tracked as $key => $flight) {
47
-	    if (isset($this->all_tracked[$key]['id'])) {
47
+		if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49
-    		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
-            }
49
+			$Tracker = new Tracker($this->db);
50
+			$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
+			}
52
+	}
52 53
 	}
53
-    }
54 54
 
55
-    public function del() {
55
+	public function del() {
56 56
 	global $globalDebug;
57 57
 	// Delete old infos
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60
-    	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
62
-            	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
60
+			if (isset($flight['lastupdate'])) {
61
+			if ($flight['lastupdate'] < (time()-3000)) {
62
+					if (isset($this->all_tracked[$key]['id'])) {
63
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
65 65
 			$TrackerLive = new TrackerLive();
66 66
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
67 67
 			$TrackerLive->db = null;
68 68
 			*/
69
-            		//$real_arrival = $this->arrival($key);
70
-            		$Tracker = new Tracker($this->db);
71
-            		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
69
+					//$real_arrival = $this->arrival($key);
70
+					$Tracker = new Tracker($this->db);
71
+					if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 72
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
76 76
 //			$Tracker->db = null;
77
-            	    }
78
-            	    unset($this->all_tracked[$key]);
79
-    	        }
80
-	    }
81
-        }
82
-    }
77
+					}
78
+					unset($this->all_tracked[$key]);
79
+				}
80
+		}
81
+		}
82
+	}
83 83
 
84
-    public function add($line) {
84
+	public function add($line) {
85 85
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86 86
 	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015';
87 87
 	date_default_timezone_set('UTC');
@@ -90,47 +90,47 @@  discard block
 block discarded – undo
90 90
 	
91 91
 	// SBS format is CSV format
92 92
 	if(is_array($line) && isset($line['ident'])) {
93
-	    //print_r($line);
94
-  	    if (isset($line['ident'])) {
93
+		//print_r($line);
94
+  		if (isset($line['ident'])) {
95 95
 
96 96
 		
97 97
 		// Increment message number
98 98
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99
-		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
99
+			$current_date = date('Y-m-d');
100
+			if (isset($line['source_name'])) $source = $line['source_name'];
101
+			else $source = '';
102
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
104
+				$this->stats[$current_date][$source]['msg']['date'] = time();
105
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
107 107
 		}
108 108
 		
109 109
 		
110 110
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
111
+			if (!isset($line['id'])) $id = trim($line['ident']);
112
+			else $id = trim($line['id']);
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115
-		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
-		    if (!isset($line['id'])) {
115
+			$this->all_tracked[$id] = array();
116
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
+			if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121 121
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
122
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
+			if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126 126
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
127
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 128
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129
-		    } else {
129
+			} else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133
-		    }
133
+			}
134 134
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
-		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
150
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
+			if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153
-            		$Tracker = new Tracker($this->db);
154
-            		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
153
+					$Tracker = new Tracker($this->db);
154
+					$fromsource = NULL;
155
+					$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158 158
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
159
-		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159
+			}
160
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
-		    if ($distance > 100 && $distance < 10000) {
167
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
+			if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171 171
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173
-		    }
173
+			}
174 174
 		}
175 175
 
176
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
176
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
+				else unset($timediff);
179
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 90 || ($timediff > 60 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
181
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.08)) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -192,30 +192,30 @@  discard block
 block discarded – undo
192 192
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195
-			    }
195
+				}
196 196
 			}
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200 200
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
-				    $dataFound = true;
203
-				    $this->all_tracked[$id]['time_last_coord'] = time();
201
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
+					$dataFound = true;
203
+					$this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205 205
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
208
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210 210
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
-				    $dataFound = true;
213
-				    $this->all_tracked[$id]['time_last_coord'] = time();
211
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
+					$dataFound = true;
213
+					$this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215 215
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218
-		    } else if ($globalDebug && $timediff > 20) {
218
+			} else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
@@ -223,131 +223,131 @@  discard block
 block discarded – undo
223 223
 				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226
-		    }
226
+			}
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
229
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
-		    //$dataFound = true;
239
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
+			//$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
-		    //$dataFound = true;
243
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
+			//$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248
-		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
248
+			//if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249 249
 			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250 250
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 251
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
253
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
-		    //$dataFound = true;
261
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
+			//$dataFound = true;
265 265
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
266
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 272
 
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274
-		    $this->all_tracked[$id]['lastupdate'] = time();
275
-		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
274
+			$this->all_tracked[$id]['lastupdate'] = time();
275
+			if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282
-				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
282
+					$recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285
-				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
285
+					$recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287 287
 				} else $recent_ident = '';
288 288
 				$TrackerLive->db=null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292
-			    } else {
292
+				} else {
293 293
 				$recent_ident = '';
294 294
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
295
-			    }
296
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
298
-			    {
295
+				}
296
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
+				if($recent_ident == "")
298
+				{
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301
-				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
-				    $timeelapsed = microtime(true);
304
-				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
-				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
301
+					$highlight = '';
302
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
+					$timeelapsed = microtime(true);
304
+					$Tracker = new Tracker($this->db);
305
+					$result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
+					$Tracker->db = null;
307
+					if ($globalDebug && isset($result)) echo $result."\n";
308
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
309 309
 				    
310 310
 				    
311
-				    // Add source stat in DB
312
-				    $Stats = new Stats($this->db);
313
-				    if (!empty($this->stats)) {
311
+					// Add source stat in DB
312
+					$Stats = new Stats($this->db);
313
+					if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
317
-					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
-				    		if (isset($sourced['msg'])) {
321
-				    		    if (time() - $sourced['msg']['date'] > 10) {
322
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
-			    			        unset($this->stats[$date][$source]['msg']);
325
-			    			    }
326
-			    			}
327
-			    		    }
328
-			    		    if ($date != date('Y-m-d')) {
329
-			    			unset($this->stats[$date]);
330
-			    		    }
331
-				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
315
+						foreach($this->stats as $date => $data) {
316
+						foreach($data as $source => $sourced) {
317
+							//print_r($sourced);
318
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
+							if (isset($sourced['msg'])) {
321
+								if (time() - $sourced['msg']['date'] > 10) {
322
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
+									echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
+									unset($this->stats[$date][$source]['msg']);
325
+								}
326
+							}
327
+							}
328
+							if ($date != date('Y-m-d')) {
329
+							unset($this->stats[$date]);
330
+							}
331
+						}
332
+						if ($globalDebug) echo 'Done'."\n";
333 333
 
334
-				    }
335
-				    $Stats->db = null;
334
+					}
335
+					$Stats->db = null;
336 336
 				    
337
-				    $this->del();
337
+					$this->del();
338 338
 				//$ignoreImport = false;
339 339
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 340
 				//print_r($this->all_tracked[$id]);
341 341
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
-				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344
-				    $TrackerLive = new TrackerLive($this->db);
345
-				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
348
-				    $this->last_delete = time();
342
+					if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
+					//TrackerLive->deleteLiveTrackerDataNotUpdated();
344
+					$TrackerLive = new TrackerLive($this->db);
345
+					$TrackerLive->deleteLiveTrackerData();
346
+					$TrackerLive->db=null;
347
+					if ($globalDebug) echo " Done\n";
348
+					$this->last_delete = time();
349 349
 				}
350
-			    } else {
350
+				} else {
351 351
 				$this->all_tracked[$id]['id'] = $recent_ident;
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
359
-			    }
359
+				}
360 360
 			}
361
-		    }
362
-		    //adds the spotter LIVE data
363
-		    if ($globalDebug) {
361
+			}
362
+			//adds the spotter LIVE data
363
+			if ($globalDebug) {
364 364
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
365
-		    }
366
-		    $ignoreImport = false;
365
+			}
366
+			$ignoreImport = false;
367 367
 
368
-		    if (!$ignoreImport) {
368
+			if (!$ignoreImport) {
369 369
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 405
 						for ($i=0;$i<=15;$i++) {
406
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
406
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
409 409
 					} else {
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
 					//var_dump($this->stats);
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419
-						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
419
+							end($this->stats[$current_date][$source]['hist']);
420
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
421 421
 						} else $mini = 0;
422 422
 						for ($i=$mini;$i<=$distance;$i+=10) {
423
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
423
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
426 426
 					} else {
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 			
437 437
 			
438 438
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
-			    $TrackerLive = new TrackerLive($this->db);
441
-			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442
-			    $TrackerLive->db = null;
443
-			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
445
-			    $this->last_delete_hourly = time();
439
+				if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
+				$TrackerLive = new TrackerLive($this->db);
441
+				$TrackerLive->deleteLiveTrackerDataNotUpdated();
442
+				$TrackerLive->db = null;
443
+				//TrackerLive->deleteLiveTrackerData();
444
+				if ($globalDebug) echo " Done\n";
445
+				$this->last_delete_hourly = time();
446 446
 			}
447 447
 			
448
-		    }
449
-		    //$ignoreImport = false;
448
+			}
449
+			//$ignoreImport = false;
450 450
 		}
451 451
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452 452
 		if ($send) return $this->all_tracked[$id];
453
-	    }
453
+		}
454
+	}
454 455
 	}
455
-    }
456 456
 }
457 457
 ?>
Please login to merge, or discard this patch.
require/class.TrackerArchive.php 1 patch
Indentation   +594 added lines, -594 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 	}
11 11
 
12 12
 	/**
13
-	* Get SQL query part for filter used
14
-	* @param Array $filter the filter
15
-	* @return Array the SQL part
16
-	*/
13
+	 * Get SQL query part for filter used
14
+	 * @param Array $filter the filter
15
+	 * @return Array the SQL part
16
+	 */
17 17
 	public function getFilter($filter = array(),$where = false,$and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 		$filters = array();
@@ -106,44 +106,44 @@  discard block
 block discarded – undo
106 106
 	}
107 107
 
108 108
 
109
-        /**
110
-        * Gets all the spotter information based on a particular callsign
111
-        *
112
-        * @return Array the spotter information
113
-        *
114
-        */
115
-        public function getLastArchiveTrackerDataByIdent($ident)
116
-        {
109
+		/**
110
+		 * Gets all the spotter information based on a particular callsign
111
+		 *
112
+		 * @return Array the spotter information
113
+		 *
114
+		 */
115
+		public function getLastArchiveTrackerDataByIdent($ident)
116
+		{
117 117
 		$Tracker = new Tracker($this->db);
118
-                date_default_timezone_set('UTC');
118
+				date_default_timezone_set('UTC');
119 119
 
120
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
121
-                //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
122
-                $query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
120
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
121
+				//$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
122
+				$query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
123 123
 
124
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
124
+				$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
125 125
 
126
-                return $spotter_array;
127
-        }
126
+				return $spotter_array;
127
+		}
128 128
 
129 129
 
130
-        /**
131
-        * Gets last the spotter information based on a particular id
132
-        *
133
-        * @return Array the spotter information
134
-        *
135
-        */
136
-        public function getLastArchiveTrackerDataById($id)
137
-        {
138
-    		$Tracker = new Tracker($this->db);
139
-                date_default_timezone_set('UTC');
140
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
141
-                //$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
142
-                //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
143
-                $query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
130
+		/**
131
+		 * Gets last the spotter information based on a particular id
132
+		 *
133
+		 * @return Array the spotter information
134
+		 *
135
+		 */
136
+		public function getLastArchiveTrackerDataById($id)
137
+		{
138
+			$Tracker = new Tracker($this->db);
139
+				date_default_timezone_set('UTC');
140
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
141
+				//$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
142
+				//$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
143
+				$query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
144 144
 
145 145
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
146
-                  /*
146
+				  /*
147 147
                 try {
148 148
                         $Connection = new Connection();
149 149
                         $sth = Connection->$db->prepare($query);
@@ -153,189 +153,189 @@  discard block
 block discarded – undo
153 153
                 }
154 154
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
155 155
                 */
156
-                $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
157
-
158
-                return $spotter_array;
159
-        }
160
-
161
-        /**
162
-        * Gets all the spotter information based on a particular id
163
-        *
164
-        * @return Array the spotter information
165
-        *
166
-        */
167
-        public function getAllArchiveTrackerDataById($id,$date = '')
156
+				$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
157
+
158
+				return $spotter_array;
159
+		}
160
+
161
+		/**
162
+		 * Gets all the spotter information based on a particular id
163
+		 *
164
+		 * @return Array the spotter information
165
+		 *
166
+		 */
167
+		public function getAllArchiveTrackerDataById($id,$date = '')
168 168
 	{
169
-                date_default_timezone_set('UTC');
170
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
171
-                if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
172
-                else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
169
+				date_default_timezone_set('UTC');
170
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
171
+				if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
172
+				else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
173 173
 
174 174
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
175 175
 
176
-                try {
177
-                        $sth = $this->db->prepare($query);
178
-                        $sth->execute(array(':id' => $id));
179
-                } catch(PDOException $e) {
180
-                        echo $e->getMessage();
181
-                        die;
182
-                }
183
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
184
-
185
-                return $spotter_array;
186
-        }
187
-
188
-        /**
189
-        * Gets coordinate & time spotter information based on a particular id
190
-        *
191
-        * @return Array the spotter information
192
-        *
193
-        */
194
-        public function getCoordArchiveTrackerDataById($id)
195
-        {
196
-                date_default_timezone_set('UTC');
197
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
198
-                $query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
176
+				try {
177
+						$sth = $this->db->prepare($query);
178
+						$sth->execute(array(':id' => $id));
179
+				} catch(PDOException $e) {
180
+						echo $e->getMessage();
181
+						die;
182
+				}
183
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
184
+
185
+				return $spotter_array;
186
+		}
187
+
188
+		/**
189
+		 * Gets coordinate & time spotter information based on a particular id
190
+		 *
191
+		 * @return Array the spotter information
192
+		 *
193
+		 */
194
+		public function getCoordArchiveTrackerDataById($id)
195
+		{
196
+				date_default_timezone_set('UTC');
197
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
198
+				$query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
199 199
 
200 200
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
201 201
 
202
-                try {
203
-                        $sth = $this->db->prepare($query);
204
-                        $sth->execute(array(':id' => $id));
205
-                } catch(PDOException $e) {
206
-                        echo $e->getMessage();
207
-                        die;
208
-                }
209
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
202
+				try {
203
+						$sth = $this->db->prepare($query);
204
+						$sth->execute(array(':id' => $id));
205
+				} catch(PDOException $e) {
206
+						echo $e->getMessage();
207
+						die;
208
+				}
209
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
210 210
 
211
-                return $spotter_array;
212
-        }
211
+				return $spotter_array;
212
+		}
213 213
 
214 214
 
215
-        /**
216
-        * Gets altitude information based on a particular callsign
217
-        *
218
-        * @return Array the spotter information
219
-        *
220
-        */
221
-        public function getAltitudeArchiveTrackerDataByIdent($ident)
222
-        {
215
+		/**
216
+		 * Gets altitude information based on a particular callsign
217
+		 *
218
+		 * @return Array the spotter information
219
+		 *
220
+		 */
221
+		public function getAltitudeArchiveTrackerDataByIdent($ident)
222
+		{
223 223
 
224
-                date_default_timezone_set('UTC');
224
+				date_default_timezone_set('UTC');
225 225
 
226
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
227
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
226
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
227
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
228 228
 
229
-                try {
230
-                        $sth = $this->db->prepare($query);
231
-                        $sth->execute(array(':ident' => $ident));
232
-                } catch(PDOException $e) {
233
-                        echo $e->getMessage();
234
-                        die;
235
-                }
236
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
229
+				try {
230
+						$sth = $this->db->prepare($query);
231
+						$sth->execute(array(':ident' => $ident));
232
+				} catch(PDOException $e) {
233
+						echo $e->getMessage();
234
+						die;
235
+				}
236
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
237 237
 
238
-                return $spotter_array;
239
-        }
238
+				return $spotter_array;
239
+		}
240 240
 
241
-        /**
242
-        * Gets altitude information based on a particular id
243
-        *
244
-        * @return Array the spotter information
245
-        *
246
-        */
247
-        public function getAltitudeArchiveTrackerDataById($id)
248
-        {
241
+		/**
242
+		 * Gets altitude information based on a particular id
243
+		 *
244
+		 * @return Array the spotter information
245
+		 *
246
+		 */
247
+		public function getAltitudeArchiveTrackerDataById($id)
248
+		{
249 249
 
250
-                date_default_timezone_set('UTC');
250
+				date_default_timezone_set('UTC');
251 251
 
252
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
253
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
252
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
253
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
254 254
 
255
-                try {
256
-                        $sth = $this->db->prepare($query);
257
-                        $sth->execute(array(':id' => $id));
258
-                } catch(PDOException $e) {
259
-                        echo $e->getMessage();
260
-                        die;
261
-                }
262
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
255
+				try {
256
+						$sth = $this->db->prepare($query);
257
+						$sth->execute(array(':id' => $id));
258
+				} catch(PDOException $e) {
259
+						echo $e->getMessage();
260
+						die;
261
+				}
262
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
263 263
 
264
-                return $spotter_array;
265
-        }
264
+				return $spotter_array;
265
+		}
266 266
 
267
-        /**
268
-        * Gets altitude & speed information based on a particular id
269
-        *
270
-        * @return Array the spotter information
271
-        *
272
-        */
273
-        public function getAltitudeSpeedArchiveTrackerDataById($id)
274
-        {
267
+		/**
268
+		 * Gets altitude & speed information based on a particular id
269
+		 *
270
+		 * @return Array the spotter information
271
+		 *
272
+		 */
273
+		public function getAltitudeSpeedArchiveTrackerDataById($id)
274
+		{
275 275
 
276
-                date_default_timezone_set('UTC');
276
+				date_default_timezone_set('UTC');
277 277
 
278
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
279
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
278
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
279
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
280 280
 
281
-                try {
282
-                        $sth = $this->db->prepare($query);
283
-                        $sth->execute(array(':id' => $id));
284
-                } catch(PDOException $e) {
285
-                        echo $e->getMessage();
286
-                        die;
287
-                }
288
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
281
+				try {
282
+						$sth = $this->db->prepare($query);
283
+						$sth->execute(array(':id' => $id));
284
+				} catch(PDOException $e) {
285
+						echo $e->getMessage();
286
+						die;
287
+				}
288
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
289 289
 
290
-                return $spotter_array;
291
-        }
290
+				return $spotter_array;
291
+		}
292 292
 
293 293
 
294
-        /**
295
-        * Gets altitude information based on a particular callsign
296
-        *
297
-        * @return Array the spotter information
298
-        *
299
-        */
300
-        public function getLastAltitudeArchiveTrackerDataByIdent($ident)
301
-        {
294
+		/**
295
+		 * Gets altitude information based on a particular callsign
296
+		 *
297
+		 * @return Array the spotter information
298
+		 *
299
+		 */
300
+		public function getLastAltitudeArchiveTrackerDataByIdent($ident)
301
+		{
302 302
 
303
-                date_default_timezone_set('UTC');
303
+				date_default_timezone_set('UTC');
304 304
 
305
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
306
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
305
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
306
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
307 307
 //                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident";
308 308
 
309
-                try {
310
-                        $sth = $this->db->prepare($query);
311
-                        $sth->execute(array(':ident' => $ident));
312
-                } catch(PDOException $e) {
313
-                        echo $e->getMessage();
314
-                        die;
315
-                }
316
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
309
+				try {
310
+						$sth = $this->db->prepare($query);
311
+						$sth->execute(array(':ident' => $ident));
312
+				} catch(PDOException $e) {
313
+						echo $e->getMessage();
314
+						die;
315
+				}
316
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
317 317
 
318
-                return $spotter_array;
319
-        }
318
+				return $spotter_array;
319
+		}
320 320
 
321 321
 
322 322
 
323
-       /**
324
-        * Gets all the archive spotter information
325
-        *
326
-        * @return Array the spotter information
327
-        *
328
-        */
329
-        public function getTrackerArchiveData($ident,$famtrackid,$date)
330
-        {
331
-    		$Tracker = new Tracker($this->db);
332
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
333
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
323
+	   /**
324
+	    * Gets all the archive spotter information
325
+	    *
326
+	    * @return Array the spotter information
327
+	    *
328
+	    */
329
+		public function getTrackerArchiveData($ident,$famtrackid,$date)
330
+		{
331
+			$Tracker = new Tracker($this->db);
332
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
333
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
334 334
 
335
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
335
+				$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
336 336
 
337
-                return $spotter_array;
338
-        }
337
+				return $spotter_array;
338
+		}
339 339
 
340 340
 	public function deleteTrackerArchiveTrackData()
341 341
 	{
@@ -355,34 +355,34 @@  discard block
 block discarded – undo
355 355
 	}
356 356
 
357 357
 	/**
358
-        * Gets Minimal Live Tracker data
359
-        *
360
-        * @return Array the spotter information
361
-        *
362
-        */
363
-        public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
364
-        {
365
-                global $globalDBdriver, $globalLiveInterval;
366
-                date_default_timezone_set('UTC');
367
-
368
-                $filter_query = '';
369
-                if (isset($filter['source']) && !empty($filter['source'])) {
370
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
371
-                }
372
-                // Use spotter_output also ?
373
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
375
-                }
376
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
378
-                }
379
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
381
-                }
358
+	 * Gets Minimal Live Tracker data
359
+	 *
360
+	 * @return Array the spotter information
361
+	 *
362
+	 */
363
+		public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
364
+		{
365
+				global $globalDBdriver, $globalLiveInterval;
366
+				date_default_timezone_set('UTC');
382 367
 
383
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
384
-                if ($globalDBdriver == 'mysql') {
385
-                        /*
368
+				$filter_query = '';
369
+				if (isset($filter['source']) && !empty($filter['source'])) {
370
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
371
+				}
372
+				// Use spotter_output also ?
373
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
375
+				}
376
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
378
+				}
379
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
381
+				}
382
+
383
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
384
+				if ($globalDBdriver == 'mysql') {
385
+						/*
386 386
                         $query  = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk 
387 387
                     		    FROM tracker_archive 
388 388
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
@@ -401,56 +401,56 @@  discard block
 block discarded – undo
401 401
 				    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
402 402
 				    WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
403 403
                         	    '.$filter_query.' ORDER BY famtrackid';
404
-                } else {
405
-                        //$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
406
-                        $query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
404
+				} else {
405
+						//$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
406
+						$query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
407 407
                         	    FROM tracker_archive 
408 408
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
409 409
                         	    WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".'
410 410
                         	    '.$filter_query.' ORDER BY famtrackid';
411
-                }
412
-                //echo $query;
413
-                try {
414
-                        $sth = $this->db->prepare($query);
415
-                        $sth->execute();
416
-                } catch(PDOException $e) {
417
-                        echo $e->getMessage();
418
-                        die;
419
-                }
420
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
411
+				}
412
+				//echo $query;
413
+				try {
414
+						$sth = $this->db->prepare($query);
415
+						$sth->execute();
416
+				} catch(PDOException $e) {
417
+						echo $e->getMessage();
418
+						die;
419
+				}
420
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
421 421
 
422
-                return $spotter_array;
423
-        }
422
+				return $spotter_array;
423
+		}
424 424
 
425 425
 	/**
426
-        * Gets Minimal Live Tracker data
427
-        *
428
-        * @return Array the spotter information
429
-        *
430
-        */
431
-        public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
432
-        {
433
-                global $globalDBdriver, $globalLiveInterval;
434
-                date_default_timezone_set('UTC');
435
-
436
-                $filter_query = '';
437
-                if (isset($filter['source']) && !empty($filter['source'])) {
438
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
439
-                }
440
-                // Should use spotter_output also ?
441
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
443
-                }
444
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
446
-                }
447
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
449
-                }
426
+	 * Gets Minimal Live Tracker data
427
+	 *
428
+	 * @return Array the spotter information
429
+	 *
430
+	 */
431
+		public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
432
+		{
433
+				global $globalDBdriver, $globalLiveInterval;
434
+				date_default_timezone_set('UTC');
435
+
436
+				$filter_query = '';
437
+				if (isset($filter['source']) && !empty($filter['source'])) {
438
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
439
+				}
440
+				// Should use spotter_output also ?
441
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
443
+				}
444
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
446
+				}
447
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
449
+				}
450 450
 
451
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
452
-                if ($globalDBdriver == 'mysql') {
453
-                        /*
451
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
452
+				if ($globalDBdriver == 'mysql') {
453
+						/*
454 454
                         $query  = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk 
455 455
                     		    FROM tracker_archive 
456 456
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
@@ -461,95 +461,95 @@  discard block
 block discarded – undo
461 461
 				    WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
462 462
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
463 463
 
464
-                } else {
465
-                        //$query  = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao';
466
-                       /*
464
+				} else {
465
+						//$query  = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao';
466
+					   /*
467 467
                         $query  = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
468 468
                         	    FROM tracker_archive_output 
469 469
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
470 470
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
471 471
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
472 472
                         */
473
-                        $query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
473
+						$query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
474 474
                         	    FROM tracker_archive_output 
475 475
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
476 476
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
477 477
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
478 478
 //                        	    .' GROUP BY spotter_output.famtrackid, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
479 479
                         	    
480
-                }
481
-                //echo $query;
482
-                try {
483
-                        $sth = $this->db->prepare($query);
484
-                        $sth->execute();
485
-                } catch(PDOException $e) {
486
-                        echo $e->getMessage();
487
-                        die;
488
-                }
489
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
480
+				}
481
+				//echo $query;
482
+				try {
483
+						$sth = $this->db->prepare($query);
484
+						$sth->execute();
485
+				} catch(PDOException $e) {
486
+						echo $e->getMessage();
487
+						die;
488
+				}
489
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
490 490
 
491
-                return $spotter_array;
492
-        }
491
+				return $spotter_array;
492
+		}
493 493
 
494 494
 	 /**
495
-        * Gets count Live Tracker data
496
-        *
497
-        * @return Array the spotter information
498
-        *
499
-        */
500
-        public function getLiveTrackerCount($begindate,$enddate,$filter = array())
501
-        {
502
-                global $globalDBdriver, $globalLiveInterval;
503
-                date_default_timezone_set('UTC');
504
-
505
-                $filter_query = '';
506
-                if (isset($filter['source']) && !empty($filter['source'])) {
507
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
508
-                }
509
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
511
-                }
512
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
514
-                }
515
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
517
-                }
495
+	  * Gets count Live Tracker data
496
+	  *
497
+	  * @return Array the spotter information
498
+	  *
499
+	  */
500
+		public function getLiveTrackerCount($begindate,$enddate,$filter = array())
501
+		{
502
+				global $globalDBdriver, $globalLiveInterval;
503
+				date_default_timezone_set('UTC');
518 504
 
519
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
520
-                if ($globalDBdriver == 'mysql') {
505
+				$filter_query = '';
506
+				if (isset($filter['source']) && !empty($filter['source'])) {
507
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
508
+				}
509
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
511
+				}
512
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
514
+				}
515
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
517
+				}
518
+
519
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
520
+				if ($globalDBdriver == 'mysql') {
521 521
 			$query = 'SELECT COUNT(DISTINCT famtrackid) as nb 
522 522
 			FROM tracker_archive l 
523 523
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
524
-                } else {
524
+				} else {
525 525
 			$query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
526
-                }
527
-                //echo $query;
528
-                try {
529
-                        $sth = $this->db->prepare($query);
530
-                        $sth->execute();
531
-                } catch(PDOException $e) {
532
-                        echo $e->getMessage();
533
-                        die;
534
-                }
526
+				}
527
+				//echo $query;
528
+				try {
529
+						$sth = $this->db->prepare($query);
530
+						$sth->execute();
531
+				} catch(PDOException $e) {
532
+						echo $e->getMessage();
533
+						die;
534
+				}
535 535
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
536 536
 		$sth->closeCursor();
537
-                return $result['nb'];
537
+				return $result['nb'];
538 538
 
539
-        }
539
+		}
540 540
 
541 541
 
542 542
 
543 543
 	// tracker_archive_output
544 544
 	
545
-    /**
546
-    * Gets all the spotter information
547
-    *
548
-    * @return Array the spotter information
549
-    *
550
-    */
551
-    public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
552
-    {
545
+	/**
546
+	 * Gets all the spotter information
547
+	 *
548
+	 * @return Array the spotter information
549
+	 *
550
+	 */
551
+	public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
552
+	{
553 553
 	global $globalTimezone, $globalDBdriver;
554 554
 	require_once(dirname(__FILE__).'/class.Translation.php');
555 555
 	$Translation = new Translation($this->db);
@@ -563,159 +563,159 @@  discard block
 block discarded – undo
563 563
 	$filter_query = $this->getFilter($filters);
564 564
 	if ($q != "")
565 565
 	{
566
-	    if (!is_string($q))
567
-	    {
566
+		if (!is_string($q))
567
+		{
568 568
 		return false;
569
-	    } else {
569
+		} else {
570 570
 	        
571 571
 		$q_array = explode(" ", $q);
572 572
 		
573 573
 		foreach ($q_array as $q_item){
574
-		    $additional_query .= " AND (";
575
-		    $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
576
-		    $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
577
-		    $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR ";
578
-		    $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
579
-		    $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR ";
580
-		    $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR ";
581
-		    $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR ";
582
-		    $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
583
-		    $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR ";
584
-		    $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR ";
585
-		    $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR ";
586
-		    $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
587
-		    $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
588
-		    $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
589
-		    $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
590
-		    $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR ";
591
-		    $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR ";
592
-		    $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR ";
593
-		    $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
594
-		    $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
595
-		    $translate = $Translation->ident2icao($q_item);
596
-		    if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
597
-		    $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
598
-		    $additional_query .= ")";
574
+			$additional_query .= " AND (";
575
+			$additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
576
+			$additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
577
+			$additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR ";
578
+			$additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
579
+			$additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR ";
580
+			$additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR ";
581
+			$additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR ";
582
+			$additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
583
+			$additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR ";
584
+			$additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR ";
585
+			$additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR ";
586
+			$additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
587
+			$additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
588
+			$additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
589
+			$additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
590
+			$additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR ";
591
+			$additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR ";
592
+			$additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR ";
593
+			$additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
594
+			$additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
595
+			$translate = $Translation->ident2icao($q_item);
596
+			if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
597
+			$additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
598
+			$additional_query .= ")";
599
+		}
599 600
 		}
600
-	    }
601 601
 	}
602 602
 	
603 603
 	if ($registration != "")
604 604
 	{
605
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
606
-	    if (!is_string($registration))
607
-	    {
605
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
606
+		if (!is_string($registration))
607
+		{
608 608
 		return false;
609
-	    } else {
609
+		} else {
610 610
 		$additional_query .= " AND (tracker_archive_output.registration = '".$registration."')";
611
-	    }
611
+		}
612 612
 	}
613 613
 	
614 614
 	if ($aircraft_icao != "")
615 615
 	{
616
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
617
-	    if (!is_string($aircraft_icao))
618
-	    {
616
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
617
+		if (!is_string($aircraft_icao))
618
+		{
619 619
 		return false;
620
-	    } else {
620
+		} else {
621 621
 		$additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')";
622
-	    }
622
+		}
623 623
 	}
624 624
 	
625 625
 	if ($aircraft_manufacturer != "")
626 626
 	{
627
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
628
-	    if (!is_string($aircraft_manufacturer))
629
-	    {
627
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
628
+		if (!is_string($aircraft_manufacturer))
629
+		{
630 630
 		return false;
631
-	    } else {
631
+		} else {
632 632
 		$additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
633
-	    }
633
+		}
634 634
 	}
635 635
 	
636 636
 	if ($highlights == "true")
637 637
 	{
638
-	    if (!is_string($highlights))
639
-	    {
638
+		if (!is_string($highlights))
639
+		{
640 640
 		return false;
641
-	    } else {
641
+		} else {
642 642
 		$additional_query .= " AND (tracker_archive_output.highlight <> '')";
643
-	    }
643
+		}
644 644
 	}
645 645
 	
646 646
 	if ($airline_icao != "")
647 647
 	{
648
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
649
-	    if (!is_string($airline_icao))
650
-	    {
648
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
649
+		if (!is_string($airline_icao))
650
+		{
651 651
 		return false;
652
-	    } else {
652
+		} else {
653 653
 		$additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')";
654
-	    }
654
+		}
655 655
 	}
656 656
 	
657 657
 	if ($airline_country != "")
658 658
 	{
659
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
660
-	    if (!is_string($airline_country))
661
-	    {
659
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
660
+		if (!is_string($airline_country))
661
+		{
662 662
 		return false;
663
-	    } else {
663
+		} else {
664 664
 		$additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')";
665
-	    }
665
+		}
666 666
 	}
667 667
 	
668 668
 	if ($airline_type != "")
669 669
 	{
670
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
671
-	    if (!is_string($airline_type))
672
-	    {
670
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
671
+		if (!is_string($airline_type))
672
+		{
673 673
 		return false;
674
-	    } else {
674
+		} else {
675 675
 		if ($airline_type == "passenger")
676 676
 		{
677
-		    $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')";
677
+			$additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')";
678 678
 		}
679 679
 		if ($airline_type == "cargo")
680 680
 		{
681
-		    $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')";
681
+			$additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')";
682 682
 		}
683 683
 		if ($airline_type == "military")
684 684
 		{
685
-		    $additional_query .= " AND (tracker_archive_output.airline_type = 'military')";
685
+			$additional_query .= " AND (tracker_archive_output.airline_type = 'military')";
686
+		}
686 687
 		}
687
-	    }
688 688
 	}
689 689
 	
690 690
 	if ($airport != "")
691 691
 	{
692
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
693
-	    if (!is_string($airport))
694
-	    {
692
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
693
+		if (!is_string($airport))
694
+		{
695 695
 		return false;
696
-	    } else {
696
+		} else {
697 697
 		$additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))";
698
-	    }
698
+		}
699 699
 	}
700 700
 	
701 701
 	if ($airport_country != "")
702 702
 	{
703
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
704
-	    if (!is_string($airport_country))
705
-	    {
703
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
704
+		if (!is_string($airport_country))
705
+		{
706 706
 		return false;
707
-	    } else {
707
+		} else {
708 708
 		$additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))";
709
-	    }
709
+		}
710 710
 	}
711 711
     
712 712
 	if ($callsign != "")
713 713
 	{
714
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
715
-	    if (!is_string($callsign))
716
-	    {
714
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
715
+		if (!is_string($callsign))
716
+		{
717 717
 		return false;
718
-	    } else {
718
+		} else {
719 719
 		$translate = $Translation->ident2icao($callsign);
720 720
 		if ($translate != $callsign) {
721 721
 			$additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)";
@@ -723,99 +723,99 @@  discard block
 block discarded – undo
723 723
 		} else {
724 724
 			$additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')";
725 725
 		}
726
-	    }
726
+		}
727 727
 	}
728 728
 
729 729
 	if ($owner != "")
730 730
 	{
731
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
732
-	    if (!is_string($owner))
733
-	    {
731
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
732
+		if (!is_string($owner))
733
+		{
734 734
 		return false;
735
-	    } else {
735
+		} else {
736 736
 		$additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')";
737
-	    }
737
+		}
738 738
 	}
739 739
 
740 740
 	if ($pilot_name != "")
741 741
 	{
742
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
743
-	    if (!is_string($pilot_name))
744
-	    {
742
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
743
+		if (!is_string($pilot_name))
744
+		{
745 745
 		return false;
746
-	    } else {
746
+		} else {
747 747
 		$additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')";
748
-	    }
748
+		}
749 749
 	}
750 750
 	
751 751
 	if ($pilot_id != "")
752 752
 	{
753
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
754
-	    if (!is_string($pilot_id))
755
-	    {
753
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
754
+		if (!is_string($pilot_id))
755
+		{
756 756
 		return false;
757
-	    } else {
757
+		} else {
758 758
 		$additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')";
759
-	    }
759
+		}
760 760
 	}
761 761
 	
762 762
 	if ($departure_airport_route != "")
763 763
 	{
764
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
765
-	    if (!is_string($departure_airport_route))
766
-	    {
764
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
765
+		if (!is_string($departure_airport_route))
766
+		{
767 767
 		return false;
768
-	    } else {
768
+		} else {
769 769
 		$additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')";
770
-	    }
770
+		}
771 771
 	}
772 772
 	
773 773
 	if ($arrival_airport_route != "")
774 774
 	{
775
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
776
-	    if (!is_string($arrival_airport_route))
777
-	    {
775
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
776
+		if (!is_string($arrival_airport_route))
777
+		{
778 778
 		return false;
779
-	    } else {
779
+		} else {
780 780
 		$additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
781
-	    }
781
+		}
782 782
 	}
783 783
 	
784 784
 	if ($altitude != "")
785 785
 	{
786
-	    $altitude_array = explode(",", $altitude);
786
+		$altitude_array = explode(",", $altitude);
787 787
 	    
788
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
790 790
 	    
791 791
 
792
-	    if ($altitude_array[1] != "")
793
-	    {                
792
+		if ($altitude_array[1] != "")
793
+		{                
794 794
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
795 795
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
796 796
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
797
-	    } else {
797
+		} else {
798 798
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
799 799
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
800
-	    }
800
+		}
801 801
 	}
802 802
 	
803 803
 	if ($date_posted != "")
804 804
 	{
805
-	    $date_array = explode(",", $date_posted);
805
+		$date_array = explode(",", $date_posted);
806 806
 	    
807
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
807
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
809 809
 	    
810
-	    if ($globalTimezone != '') {
810
+		if ($globalTimezone != '') {
811 811
 		date_default_timezone_set($globalTimezone);
812 812
 		$datetime = new DateTime();
813 813
 		$offset = $datetime->format('P');
814
-	    } else $offset = '+00:00';
814
+		} else $offset = '+00:00';
815 815
 
816 816
 
817
-	    if ($date_array[1] != "")
818
-	    {                
817
+		if ($date_array[1] != "")
818
+		{                
819 819
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
820 820
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
821 821
 		if ($globalDBdriver == 'mysql') {
@@ -823,28 +823,28 @@  discard block
 block discarded – undo
823 823
 		} else {
824 824
 			$additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
825 825
 		}
826
-	    } else {
826
+		} else {
827 827
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
828
-                if ($globalDBdriver == 'mysql') {
828
+				if ($globalDBdriver == 'mysql') {
829 829
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
830 830
 		} else {
831 831
 			$additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
832 832
 		}
833
-	    }
833
+		}
834 834
 	}
835 835
 	
836 836
 	if ($limit != "")
837 837
 	{
838
-	    $limit_array = explode(",", $limit);
838
+		$limit_array = explode(",", $limit);
839 839
 	    
840
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
840
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
842 842
 	    
843
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844
-	    {
843
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844
+		{
845 845
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
846 846
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
847
-	    }
847
+		}
848 848
 	}
849 849
 	
850 850
 
@@ -875,33 +875,33 @@  discard block
 block discarded – undo
875 875
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query);
876 876
 
877 877
 	return $spotter_array;
878
-    }
878
+	}
879 879
 
880
-    public function deleteTrackerArchiveData()
881
-    {
880
+	public function deleteTrackerArchiveData()
881
+	{
882 882
 		global $globalArchiveKeepMonths, $globalDBdriver;
883
-                date_default_timezone_set('UTC');
884
-                if ($globalDBdriver == 'mysql') {
883
+				date_default_timezone_set('UTC');
884
+				if ($globalDBdriver == 'mysql') {
885 885
 			$query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
886 886
 		} else {
887 887
 			$query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
888 888
 		}
889
-                try {
890
-                        $sth = $this->db->prepare($query);
891
-                        $sth->execute();
892
-                } catch(PDOException $e) {
893
-                        return "error";
894
-                }
889
+				try {
890
+						$sth = $this->db->prepare($query);
891
+						$sth->execute();
892
+				} catch(PDOException $e) {
893
+						return "error";
894
+				}
895 895
 	}
896 896
 
897
-    /**
898
-    * Gets all the spotter information based on the callsign
899
-    *
900
-    * @return Array the spotter information
901
-    *
902
-    */
903
-    public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '')
904
-    {
897
+	/**
898
+	 * Gets all the spotter information based on the callsign
899
+	 *
900
+	 * @return Array the spotter information
901
+	 *
902
+	 */
903
+	public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '')
904
+	{
905 905
 	$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
906 906
 	
907 907
 	date_default_timezone_set('UTC');
@@ -913,35 +913,35 @@  discard block
 block discarded – undo
913 913
 	
914 914
 	if ($ident != "")
915 915
 	{
916
-	    if (!is_string($ident))
917
-	    {
916
+		if (!is_string($ident))
917
+		{
918 918
 		return false;
919
-	    } else {
919
+		} else {
920 920
 		$additional_query = " AND (tracker_archive_output.ident = :ident)";
921 921
 		$query_values = array(':ident' => $ident);
922
-	    }
922
+		}
923 923
 	}
924 924
 	
925 925
 	if ($limit != "")
926 926
 	{
927
-	    $limit_array = explode(",", $limit);
927
+		$limit_array = explode(",", $limit);
928 928
 	    
929
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
929
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
931 931
 	    
932
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933
-	    {
932
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933
+		{
934 934
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
935 935
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
936
-	    }
936
+		}
937 937
 	}
938 938
 
939 939
 	if ($sort != "")
940 940
 	{
941
-	    $search_orderby_array = $Tracker->getOrderBy();
942
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
941
+		$search_orderby_array = $Tracker->getOrderBy();
942
+		$orderby_query = $search_orderby_array[$sort]['sql'];
943 943
 	} else {
944
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
944
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
945 945
 	}
946 946
 
947 947
 	$query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -949,17 +949,17 @@  discard block
 block discarded – undo
949 949
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
950 950
 
951 951
 	return $spotter_array;
952
-    }
952
+	}
953 953
 
954 954
 
955
-    /**
956
-    * Gets all the spotter information based on the owner
957
-    *
958
-    * @return Array the spotter information
959
-    *
960
-    */
961
-    public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
962
-    {
955
+	/**
956
+	 * Gets all the spotter information based on the owner
957
+	 *
958
+	 * @return Array the spotter information
959
+	 *
960
+	 */
961
+	public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
962
+	{
963 963
 	$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
964 964
 	
965 965
 	date_default_timezone_set('UTC');
@@ -972,35 +972,35 @@  discard block
 block discarded – undo
972 972
 	
973 973
 	if ($owner != "")
974 974
 	{
975
-	    if (!is_string($owner))
976
-	    {
975
+		if (!is_string($owner))
976
+		{
977 977
 		return false;
978
-	    } else {
978
+		} else {
979 979
 		$additional_query = " AND (tracker_archive_output.owner_name = :owner)";
980 980
 		$query_values = array(':owner' => $owner);
981
-	    }
981
+		}
982 982
 	}
983 983
 	
984 984
 	if ($limit != "")
985 985
 	{
986
-	    $limit_array = explode(",", $limit);
986
+		$limit_array = explode(",", $limit);
987 987
 	    
988
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
990 990
 	    
991
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992
-	    {
991
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992
+		{
993 993
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
994 994
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
995
-	    }
995
+		}
996 996
 	}
997 997
 
998 998
 	if ($sort != "")
999 999
 	{
1000
-	    $search_orderby_array = $Tracker->getOrderBy();
1001
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1000
+		$search_orderby_array = $Tracker->getOrderBy();
1001
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1002 1002
 	} else {
1003
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1003
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1004 1004
 	}
1005 1005
 
1006 1006
 	$query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1008,16 +1008,16 @@  discard block
 block discarded – undo
1008 1008
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1009 1009
 
1010 1010
 	return $spotter_array;
1011
-    }
1012
-
1013
-    /**
1014
-    * Gets all the spotter information based on the pilot
1015
-    *
1016
-    * @return Array the spotter information
1017
-    *
1018
-    */
1019
-    public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1020
-    {
1011
+	}
1012
+
1013
+	/**
1014
+	 * Gets all the spotter information based on the pilot
1015
+	 *
1016
+	 * @return Array the spotter information
1017
+	 *
1018
+	 */
1019
+	public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1020
+	{
1021 1021
 	$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
1022 1022
 	
1023 1023
 	date_default_timezone_set('UTC');
@@ -1036,24 +1036,24 @@  discard block
 block discarded – undo
1036 1036
 	
1037 1037
 	if ($limit != "")
1038 1038
 	{
1039
-	    $limit_array = explode(",", $limit);
1039
+		$limit_array = explode(",", $limit);
1040 1040
 	    
1041
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1041
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1043 1043
 	    
1044
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045
-	    {
1044
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045
+		{
1046 1046
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1047 1047
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1048
-	    }
1048
+		}
1049 1049
 	}
1050 1050
 
1051 1051
 	if ($sort != "")
1052 1052
 	{
1053
-	    $search_orderby_array = $Tracker->getOrderBy();
1054
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1053
+		$search_orderby_array = $Tracker->getOrderBy();
1054
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1055 1055
 	} else {
1056
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1056
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1057 1057
 	}
1058 1058
 
1059 1059
 	$query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1061,16 +1061,16 @@  discard block
 block discarded – undo
1061 1061
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1062 1062
 
1063 1063
 	return $spotter_array;
1064
-    }
1065
-
1066
-    /**
1067
-    * Gets all number of flight over countries
1068
-    *
1069
-    * @return Array the airline country list
1070
-    *
1071
-    */
1072
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1073
-    {
1064
+	}
1065
+
1066
+	/**
1067
+	 * Gets all number of flight over countries
1068
+	 *
1069
+	 * @return Array the airline country list
1070
+	 *
1071
+	 */
1072
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1073
+	{
1074 1074
 	global $globalDBdriver;
1075 1075
 	/*
1076 1076
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1080,14 +1080,14 @@  discard block
 block discarded – undo
1080 1080
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1081 1081
 		    FROM countries c, tracker_archive s
1082 1082
 		    WHERE c.iso2 = s.over_country ";
1083
-                if ($olderthanmonths > 0) {
1084
-            		if ($globalDBdriver == 'mysql') {
1083
+				if ($olderthanmonths > 0) {
1084
+					if ($globalDBdriver == 'mysql') {
1085 1085
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1086 1086
 			} else {
1087 1087
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1088 1088
 			}
1089 1089
 		}
1090
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1090
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1091 1091
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1092 1092
 	if ($limit) $query .= " LIMIT 0,10";
1093 1093
       
@@ -1100,23 +1100,23 @@  discard block
 block discarded – undo
1100 1100
         
1101 1101
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1102 1102
 	{
1103
-	    $temp_array['flight_count'] = $row['nb'];
1104
-	    $temp_array['flight_country'] = $row['name'];
1105
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1106
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1107
-	    $flight_array[] = $temp_array;
1103
+		$temp_array['flight_count'] = $row['nb'];
1104
+		$temp_array['flight_country'] = $row['name'];
1105
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1106
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1107
+		$flight_array[] = $temp_array;
1108 1108
 	}
1109 1109
 	return $flight_array;
1110
-    }
1111
-
1112
-    /**
1113
-    * Gets all number of flight over countries
1114
-    *
1115
-    * @return Array the airline country list
1116
-    *
1117
-    */
1118
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1119
-    {
1110
+	}
1111
+
1112
+	/**
1113
+	 * Gets all number of flight over countries
1114
+	 *
1115
+	 * @return Array the airline country list
1116
+	 *
1117
+	 */
1118
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1119
+	{
1120 1120
 	global $globalDBdriver;
1121 1121
 	/*
1122 1122
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1126,14 +1126,14 @@  discard block
 block discarded – undo
1126 1126
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1127 1127
 		    FROM countries c, tracker_archive s, spotter_output o
1128 1128
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.famtrackid = s.famtrackid ";
1129
-                if ($olderthanmonths > 0) {
1130
-            		if ($globalDBdriver == 'mysql') {
1129
+				if ($olderthanmonths > 0) {
1130
+					if ($globalDBdriver == 'mysql') {
1131 1131
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1132 1132
 			} else {
1133 1133
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1134 1134
 			}
1135 1135
 		}
1136
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1136
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1137 1137
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1138 1138
 	if ($limit) $query .= " LIMIT 0,10";
1139 1139
       
@@ -1146,24 +1146,24 @@  discard block
 block discarded – undo
1146 1146
         
1147 1147
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1148 1148
 	{
1149
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1150
-	    $temp_array['flight_count'] = $row['nb'];
1151
-	    $temp_array['flight_country'] = $row['name'];
1152
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1153
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1154
-	    $flight_array[] = $temp_array;
1149
+		$temp_array['airline_icao'] = $row['airline_icao'];
1150
+		$temp_array['flight_count'] = $row['nb'];
1151
+		$temp_array['flight_country'] = $row['name'];
1152
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1153
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1154
+		$flight_array[] = $temp_array;
1155 1155
 	}
1156 1156
 	return $flight_array;
1157
-    }
1158
-
1159
-    /**
1160
-    * Gets last spotter information based on a particular callsign
1161
-    *
1162
-    * @return Array the spotter information
1163
-    *
1164
-    */
1165
-    public function getDateArchiveTrackerDataById($id,$date)
1166
-    {
1157
+	}
1158
+
1159
+	/**
1160
+	 * Gets last spotter information based on a particular callsign
1161
+	 *
1162
+	 * @return Array the spotter information
1163
+	 *
1164
+	 */
1165
+	public function getDateArchiveTrackerDataById($id,$date)
1166
+	{
1167 1167
 	$Tracker = new Tracker($this->db);
1168 1168
 	date_default_timezone_set('UTC');
1169 1169
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1171,16 +1171,16 @@  discard block
 block discarded – undo
1171 1171
 	$date = date('c',$date);
1172 1172
 	$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date));
1173 1173
 	return $spotter_array;
1174
-    }
1175
-
1176
-    /**
1177
-    * Gets all the spotter information based on a particular callsign
1178
-    *
1179
-    * @return Array the spotter information
1180
-    *
1181
-    */
1182
-    public function getDateArchiveTrackerDataByIdent($ident,$date)
1183
-    {
1174
+	}
1175
+
1176
+	/**
1177
+	 * Gets all the spotter information based on a particular callsign
1178
+	 *
1179
+	 * @return Array the spotter information
1180
+	 *
1181
+	 */
1182
+	public function getDateArchiveTrackerDataByIdent($ident,$date)
1183
+	{
1184 1184
 	$Tracker = new Tracker($this->db);
1185 1185
 	date_default_timezone_set('UTC');
1186 1186
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1188,16 +1188,16 @@  discard block
 block discarded – undo
1188 1188
 	$date = date('c',$date);
1189 1189
 	$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1190 1190
 	return $spotter_array;
1191
-    }
1192
-
1193
-    /**
1194
-    * Gets all the spotter information based on the airport
1195
-    *
1196
-    * @return Array the spotter information
1197
-    *
1198
-    */
1199
-    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1200
-    {
1191
+	}
1192
+
1193
+	/**
1194
+	 * Gets all the spotter information based on the airport
1195
+	 *
1196
+	 * @return Array the spotter information
1197
+	 *
1198
+	 */
1199
+	public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1200
+	{
1201 1201
 	global $global_query;
1202 1202
 	$Tracker = new Tracker($this->db);
1203 1203
 	date_default_timezone_set('UTC');
@@ -1208,35 +1208,35 @@  discard block
 block discarded – undo
1208 1208
 	
1209 1209
 	if ($airport != "")
1210 1210
 	{
1211
-	    if (!is_string($airport))
1212
-	    {
1211
+		if (!is_string($airport))
1212
+		{
1213 1213
 		return false;
1214
-	    } else {
1214
+		} else {
1215 1215
 		$additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))";
1216 1216
 		$query_values = array(':airport' => $airport);
1217
-	    }
1217
+		}
1218 1218
 	}
1219 1219
 	
1220 1220
 	if ($limit != "")
1221 1221
 	{
1222
-	    $limit_array = explode(",", $limit);
1222
+		$limit_array = explode(",", $limit);
1223 1223
 	    
1224
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1224
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1226 1226
 	    
1227
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228
-	    {
1227
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228
+		{
1229 1229
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1230 1230
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1231
-	    }
1231
+		}
1232 1232
 	}
1233 1233
 	
1234 1234
 	if ($sort != "")
1235 1235
 	{
1236
-	    $search_orderby_array = $Tracker->getOrderBy();
1237
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1236
+		$search_orderby_array = $Tracker->getOrderBy();
1237
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1238 1238
 	} else {
1239
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1239
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1240 1240
 	}
1241 1241
 
1242 1242
 	$query = $global_query.$filter_query." tracker_archive_output.ident <> '' ".$additional_query." AND ((tracker_archive_output.departure_airport_icao <> 'NA') AND (tracker_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1244,6 +1244,6 @@  discard block
 block discarded – undo
1244 1244
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1245 1245
 
1246 1246
 	return $spotter_array;
1247
-    }
1247
+	}
1248 1248
 }
1249 1249
 ?>
1250 1250
\ No newline at end of file
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Indentation   +357 added lines, -357 removed lines patch added patch discarded remove patch
@@ -85,38 +85,38 @@  discard block
 block discarded – undo
85 85
 		try {
86 86
 			//$Connection = new Connection();
87 87
 			$sth = $Connection->db->prepare($query);
88
-                        $sth->execute(array(':source' => $database_file));
89
-                } catch(PDOException $e) {
90
-                        return "error : ".$e->getMessage();
91
-                }
88
+						$sth->execute(array(':source' => $database_file));
89
+				} catch(PDOException $e) {
90
+						return "error : ".$e->getMessage();
91
+				}
92 92
 
93
-    		if ($globalDebug) echo " - Add routes to DB -";
94
-    		update_db::connect_sqlite($database_file);
93
+			if ($globalDebug) echo " - Add routes to DB -";
94
+			update_db::connect_sqlite($database_file);
95 95
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
96 96
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
97 97
 		try {
98
-                        $sth = update_db::$db_sqlite->prepare($query);
99
-                        $sth->execute();
100
-                } catch(PDOException $e) {
101
-                        return "error : ".$e->getMessage();
102
-                }
98
+						$sth = update_db::$db_sqlite->prepare($query);
99
+						$sth->execute();
100
+				} catch(PDOException $e) {
101
+						return "error : ".$e->getMessage();
102
+				}
103 103
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
104 104
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
105 105
 		$Connection = new Connection();
106 106
 		$sth_dest = $Connection->db->prepare($query_dest);
107 107
 		try {
108 108
 			if ($globalTransaction) $Connection->db->beginTransaction();
109
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
109
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 110
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
111 111
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
112 112
 				$sth_dest->execute($query_dest_values);
113
-            		}
113
+					}
114 114
 			if ($globalTransaction) $Connection->db->commit();
115 115
 		} catch(PDOException $e) {
116 116
 			if ($globalTransaction) $Connection->db->rollBack(); 
117 117
 			return "error : ".$e->getMessage();
118 118
 		}
119
-                return '';
119
+				return '';
120 120
 	}
121 121
 	public static function retrieve_route_oneworld($database_file) {
122 122
 		global $globalDebug, $globalTransaction;
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
 		try {
128 128
 			//$Connection = new Connection();
129 129
 			$sth = $Connection->db->prepare($query);
130
-                        $sth->execute(array(':source' => 'oneworld'));
131
-                } catch(PDOException $e) {
132
-                        return "error : ".$e->getMessage();
133
-                }
130
+						$sth->execute(array(':source' => 'oneworld'));
131
+				} catch(PDOException $e) {
132
+						return "error : ".$e->getMessage();
133
+				}
134 134
 
135
-    		if ($globalDebug) echo " - Add routes to DB -";
135
+			if ($globalDebug) echo " - Add routes to DB -";
136 136
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 137
 		$Spotter = new Spotter();
138 138
 		if ($fh = fopen($database_file,"r")) {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			}
157 157
 			if ($globalTransaction) $Connection->db->commit();
158 158
 		}
159
-                return '';
159
+				return '';
160 160
 	}
161 161
 	
162 162
 	public static function retrieve_route_skyteam($database_file) {
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
 		try {
169 169
 			//$Connection = new Connection();
170 170
 			$sth = $Connection->db->prepare($query);
171
-                        $sth->execute(array(':source' => 'skyteam'));
172
-                } catch(PDOException $e) {
173
-                        return "error : ".$e->getMessage();
174
-                }
171
+						$sth->execute(array(':source' => 'skyteam'));
172
+				} catch(PDOException $e) {
173
+						return "error : ".$e->getMessage();
174
+				}
175 175
 
176
-    		if ($globalDebug) echo " - Add routes to DB -";
176
+			if ($globalDebug) echo " - Add routes to DB -";
177 177
 
178 178
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 179
 		$Spotter = new Spotter();
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 				return "error : ".$e->getMessage();
200 200
 			}
201 201
 		}
202
-                return '';
202
+				return '';
203 203
 	}
204 204
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
205 205
 		global $globalTransaction;
@@ -208,27 +208,27 @@  discard block
 block discarded – undo
208 208
 		try {
209 209
 			$Connection = new Connection();
210 210
 			$sth = $Connection->db->prepare($query);
211
-                        $sth->execute(array(':source' => $database_file));
212
-                } catch(PDOException $e) {
213
-                        return "error : ".$e->getMessage();
214
-                }
211
+						$sth->execute(array(':source' => $database_file));
212
+				} catch(PDOException $e) {
213
+						return "error : ".$e->getMessage();
214
+				}
215 215
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
216 216
 		try {
217 217
 			$Connection = new Connection();
218 218
 			$sth = $Connection->db->prepare($query);
219
-                        $sth->execute(array(':source' => $database_file));
220
-                } catch(PDOException $e) {
221
-                        return "error : ".$e->getMessage();
222
-                }
219
+						$sth->execute(array(':source' => $database_file));
220
+				} catch(PDOException $e) {
221
+						return "error : ".$e->getMessage();
222
+				}
223 223
 
224
-    		update_db::connect_sqlite($database_file);
224
+			update_db::connect_sqlite($database_file);
225 225
 		$query = 'select * from Aircraft';
226 226
 		try {
227
-                        $sth = update_db::$db_sqlite->prepare($query);
228
-                        $sth->execute();
229
-                } catch(PDOException $e) {
230
-                        return "error : ".$e->getMessage();
231
-                }
227
+						$sth = update_db::$db_sqlite->prepare($query);
228
+						$sth->execute();
229
+				} catch(PDOException $e) {
230
+						return "error : ".$e->getMessage();
231
+				}
232 232
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
233 233
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
234 234
 		
@@ -239,17 +239,17 @@  discard block
 block discarded – undo
239 239
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
240 240
 		try {
241 241
 			if ($globalTransaction) $Connection->db->beginTransaction();
242
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
242
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
243 243
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
244 244
 				if ($values['UserString4'] == 'M') $type = 'military';
245 245
 				else $type = null;
246 246
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
247 247
 				$sth_dest->execute($query_dest_values);
248 248
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
249
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
250
-				    $sth_dest_owner->execute($query_dest_owner_values);
249
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
250
+					$sth_dest_owner->execute($query_dest_owner_values);
251 251
 				}
252
-            		}
252
+					}
253 253
 			if ($globalTransaction) $Connection->db->commit();
254 254
 		} catch(PDOException $e) {
255 255
 			return "error : ".$e->getMessage();
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 		try {
261 261
 			$Connection = new Connection();
262 262
 			$sth = $Connection->db->prepare($query);
263
-                        $sth->execute(array(':source' => $database_file));
264
-                } catch(PDOException $e) {
265
-                        return "error : ".$e->getMessage();
266
-                }
263
+						$sth->execute(array(':source' => $database_file));
264
+				} catch(PDOException $e) {
265
+						return "error : ".$e->getMessage();
266
+				}
267 267
 		return '';
268 268
 	}
269 269
 
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
 		try {
276 276
 			$Connection = new Connection();
277 277
 			$sth = $Connection->db->prepare($query);
278
-                        $sth->execute(array(':source' => $database_file));
279
-                } catch(PDOException $e) {
280
-                        return "error : ".$e->getMessage();
281
-                }
278
+						$sth->execute(array(':source' => $database_file));
279
+				} catch(PDOException $e) {
280
+						return "error : ".$e->getMessage();
281
+				}
282 282
 		
283 283
 		if ($fh = fopen($database_file,"r")) {
284 284
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -288,26 +288,26 @@  discard block
 block discarded – undo
288 288
 			$sth_dest = $Connection->db->prepare($query_dest);
289 289
 			try {
290 290
 				if ($globalTransaction) $Connection->db->beginTransaction();
291
-            			while (!feof($fh)) {
292
-            				$values = array();
293
-            				$line = $Common->hex2str(fgets($fh,9999));
291
+						while (!feof($fh)) {
292
+							$values = array();
293
+							$line = $Common->hex2str(fgets($fh,9999));
294 294
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
295
-            				$values['ModeS'] = substr($line,0,6);
296
-            				$values['Registration'] = trim(substr($line,69,6));
297
-            				$aircraft_name = trim(substr($line,48,6));
298
-            				// Check if we can find ICAO, else set it to GLID
299
-            				$aircraft_name_split = explode(' ',$aircraft_name);
300
-            				$search_more = '';
301
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
302
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303
-            				$sth_search = $Connection->db->prepare($query_search);
295
+							$values['ModeS'] = substr($line,0,6);
296
+							$values['Registration'] = trim(substr($line,69,6));
297
+							$aircraft_name = trim(substr($line,48,6));
298
+							// Check if we can find ICAO, else set it to GLID
299
+							$aircraft_name_split = explode(' ',$aircraft_name);
300
+							$search_more = '';
301
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
302
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303
+							$sth_search = $Connection->db->prepare($query_search);
304 304
 					try {
305
-                                    		$sth_search->execute();
306
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
307
-	            				//if (count($result) > 0) {
308
-	            				if (isset($result['icao']) && $result['icao'] != '') {
309
-	            				    $values['ICAOTypeCode'] = $result['icao'];
310
-	            				} 
305
+											$sth_search->execute();
306
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
307
+								//if (count($result) > 0) {
308
+								if (isset($result['icao']) && $result['icao'] != '') {
309
+									$values['ICAOTypeCode'] = $result['icao'];
310
+								} 
311 311
 					} catch(PDOException $e) {
312 312
 						return "error : ".$e->getMessage();
313 313
 					}
@@ -330,10 +330,10 @@  discard block
 block discarded – undo
330 330
 		try {
331 331
 			$Connection = new Connection();
332 332
 			$sth = $Connection->db->prepare($query);
333
-                        $sth->execute(array(':source' => $database_file));
334
-                } catch(PDOException $e) {
335
-                        return "error : ".$e->getMessage();
336
-                }
333
+						$sth->execute(array(':source' => $database_file));
334
+				} catch(PDOException $e) {
335
+						return "error : ".$e->getMessage();
336
+				}
337 337
 		return '';
338 338
 	}
339 339
 
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
 		try {
345 345
 			$Connection = new Connection();
346 346
 			$sth = $Connection->db->prepare($query);
347
-                        $sth->execute(array(':source' => $database_file));
348
-                } catch(PDOException $e) {
349
-                        return "error : ".$e->getMessage();
350
-                }
347
+						$sth->execute(array(':source' => $database_file));
348
+				} catch(PDOException $e) {
349
+						return "error : ".$e->getMessage();
350
+				}
351 351
 		
352 352
 		if ($fh = fopen($database_file,"r")) {
353 353
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -358,25 +358,25 @@  discard block
 block discarded – undo
358 358
 			try {
359 359
 				if ($globalTransaction) $Connection->db->beginTransaction();
360 360
 				$tmp = fgetcsv($fh,9999,',',"'");
361
-            			while (!feof($fh)) {
362
-            				$line = fgetcsv($fh,9999,',',"'");
361
+						while (!feof($fh)) {
362
+							$line = fgetcsv($fh,9999,',',"'");
363 363
             				
364 364
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
365 365
 					//print_r($line);
366
-            				$values['ModeS'] = $line[1];
367
-            				$values['Registration'] = $line[3];
368
-            				$values['ICAOTypeCode'] = '';
369
-            				$aircraft_name = $line[2];
370
-            				// Check if we can find ICAO, else set it to GLID
371
-            				$aircraft_name_split = explode(' ',$aircraft_name);
372
-            				$search_more = '';
373
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
374
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375
-            				$sth_search = $Connection->db->prepare($query_search);
366
+							$values['ModeS'] = $line[1];
367
+							$values['Registration'] = $line[3];
368
+							$values['ICAOTypeCode'] = '';
369
+							$aircraft_name = $line[2];
370
+							// Check if we can find ICAO, else set it to GLID
371
+							$aircraft_name_split = explode(' ',$aircraft_name);
372
+							$search_more = '';
373
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
374
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375
+							$sth_search = $Connection->db->prepare($query_search);
376 376
 					try {
377
-                                    		$sth_search->execute();
378
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
377
+											$sth_search->execute();
378
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
380 380
 					} catch(PDOException $e) {
381 381
 						return "error : ".$e->getMessage();
382 382
 					}
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
 		try {
400 400
 			$Connection = new Connection();
401 401
 			$sth = $Connection->db->prepare($query);
402
-                        $sth->execute(array(':source' => $database_file));
403
-                } catch(PDOException $e) {
404
-                        return "error : ".$e->getMessage();
405
-                }
402
+						$sth->execute(array(':source' => $database_file));
403
+				} catch(PDOException $e) {
404
+						return "error : ".$e->getMessage();
405
+				}
406 406
 		return '';
407 407
 	}
408 408
 
@@ -413,16 +413,16 @@  discard block
 block discarded – undo
413 413
 		try {
414 414
 			$Connection = new Connection();
415 415
 			$sth = $Connection->db->prepare($query);
416
-                        $sth->execute(array(':source' => $database_file));
417
-                } catch(PDOException $e) {
418
-                        return "error : ".$e->getMessage();
419
-                }
416
+						$sth->execute(array(':source' => $database_file));
417
+				} catch(PDOException $e) {
418
+						return "error : ".$e->getMessage();
419
+				}
420 420
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
421 421
 		$Spotter = new Spotter();
422 422
 		if ($fh = fopen($database_file,"r")) {
423 423
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
424 424
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
425
-		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
425
+				$query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
426 426
 		        
427 427
 			$Connection = new Connection();
428 428
 			$sth_dest = $Connection->db->prepare($query_dest);
@@ -430,126 +430,126 @@  discard block
 block discarded – undo
430 430
 			try {
431 431
 				if ($globalTransaction) $Connection->db->beginTransaction();
432 432
 				$tmp = fgetcsv($fh,9999,',','"');
433
-            			while (!feof($fh)) {
434
-            				$line = fgetcsv($fh,9999,',','"');
435
-            				$values = array();
436
-            				//print_r($line);
437
-            				if ($country == 'F') {
438
-            				    $values['registration'] = $line[0];
439
-            				    $values['base'] = $line[4];
440
-            				    $values['owner'] = $line[5];
441
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
443
-					    $values['cancel'] = $line[7];
433
+						while (!feof($fh)) {
434
+							$line = fgetcsv($fh,9999,',','"');
435
+							$values = array();
436
+							//print_r($line);
437
+							if ($country == 'F') {
438
+								$values['registration'] = $line[0];
439
+								$values['base'] = $line[4];
440
+								$values['owner'] = $line[5];
441
+								if ($line[6] == '') $values['date_first_reg'] = null;
442
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
443
+						$values['cancel'] = $line[7];
444 444
 					} elseif ($country == 'EI') {
445
-					    // TODO : add modeS & reg to aircraft_modes
446
-            				    $values['registration'] = $line[0];
447
-            				    $values['base'] = $line[3];
448
-            				    $values['owner'] = $line[2];
449
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
451
-					    $values['cancel'] = '';
452
-					    $values['modes'] = $line[7];
453
-					    $values['icao'] = $line[8];
445
+						// TODO : add modeS & reg to aircraft_modes
446
+								$values['registration'] = $line[0];
447
+								$values['base'] = $line[3];
448
+								$values['owner'] = $line[2];
449
+								if ($line[1] == '') $values['date_first_reg'] = null;
450
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
451
+						$values['cancel'] = '';
452
+						$values['modes'] = $line[7];
453
+						$values['icao'] = $line[8];
454 454
 					    
455 455
 					} elseif ($country == 'HB') {
456
-					    // TODO : add modeS & reg to aircraft_modes
457
-            				    $values['registration'] = $line[0];
458
-            				    $values['base'] = null;
459
-            				    $values['owner'] = $line[5];
460
-            				    $values['date_first_reg'] = null;
461
-					    $values['cancel'] = '';
462
-					    $values['modes'] = $line[4];
463
-					    $values['icao'] = $line[7];
456
+						// TODO : add modeS & reg to aircraft_modes
457
+								$values['registration'] = $line[0];
458
+								$values['base'] = null;
459
+								$values['owner'] = $line[5];
460
+								$values['date_first_reg'] = null;
461
+						$values['cancel'] = '';
462
+						$values['modes'] = $line[4];
463
+						$values['icao'] = $line[7];
464 464
 					} elseif ($country == 'OK') {
465
-					    // TODO : add modeS & reg to aircraft_modes
466
-            				    $values['registration'] = $line[3];
467
-            				    $values['base'] = null;
468
-            				    $values['owner'] = $line[5];
469
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
471
-					    $values['cancel'] = '';
465
+						// TODO : add modeS & reg to aircraft_modes
466
+								$values['registration'] = $line[3];
467
+								$values['base'] = null;
468
+								$values['owner'] = $line[5];
469
+								if ($line[18] == '') $values['date_first_reg'] = null;
470
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
471
+						$values['cancel'] = '';
472 472
 					} elseif ($country == 'VH') {
473
-					    // TODO : add modeS & reg to aircraft_modes
474
-            				    $values['registration'] = $line[0];
475
-            				    $values['base'] = null;
476
-            				    $values['owner'] = $line[12];
477
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
479
-
480
-					    $values['cancel'] = $line[39];
473
+						// TODO : add modeS & reg to aircraft_modes
474
+								$values['registration'] = $line[0];
475
+								$values['base'] = null;
476
+								$values['owner'] = $line[12];
477
+								if ($line[28] == '') $values['date_first_reg'] = null;
478
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
479
+
480
+						$values['cancel'] = $line[39];
481 481
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
482
-            				    $values['registration'] = $line[0];
483
-            				    $values['base'] = null;
484
-            				    $values['owner'] = $line[4];
485
-            				    $values['date_first_reg'] = null;
486
-					    $values['cancel'] = '';
482
+								$values['registration'] = $line[0];
483
+								$values['base'] = null;
484
+								$values['owner'] = $line[4];
485
+								$values['date_first_reg'] = null;
486
+						$values['cancel'] = '';
487 487
 					} elseif ($country == 'CC') {
488
-            				    $values['registration'] = $line[0];
489
-            				    $values['base'] = null;
490
-            				    $values['owner'] = $line[6];
491
-            				    $values['date_first_reg'] = null;
492
-					    $values['cancel'] = '';
488
+								$values['registration'] = $line[0];
489
+								$values['base'] = null;
490
+								$values['owner'] = $line[6];
491
+								$values['date_first_reg'] = null;
492
+						$values['cancel'] = '';
493 493
 					} elseif ($country == 'HJ') {
494
-            				    $values['registration'] = $line[0];
495
-            				    $values['base'] = null;
496
-            				    $values['owner'] = $line[8];
497
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
499
-					    $values['cancel'] = '';
494
+								$values['registration'] = $line[0];
495
+								$values['base'] = null;
496
+								$values['owner'] = $line[8];
497
+								if ($line[7] == '') $values['date_first_reg'] = null;
498
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
499
+						$values['cancel'] = '';
500 500
 					} elseif ($country == 'PP') {
501
-            				    $values['registration'] = $line[0];
502
-            				    $values['base'] = null;
503
-            				    $values['owner'] = $line[4];
504
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
-					    $values['cancel'] = $line[7];
501
+								$values['registration'] = $line[0];
502
+								$values['base'] = null;
503
+								$values['owner'] = $line[4];
504
+								if ($line[6] == '') $values['date_first_reg'] = null;
505
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
+						$values['cancel'] = $line[7];
507 507
 					} elseif ($country == 'E7') {
508
-            				    $values['registration'] = $line[0];
509
-            				    $values['base'] = null;
510
-            				    $values['owner'] = $line[4];
511
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
513
-					    $values['cancel'] = '';
508
+								$values['registration'] = $line[0];
509
+								$values['base'] = null;
510
+								$values['owner'] = $line[4];
511
+								if ($line[5] == '') $values['date_first_reg'] = null;
512
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
513
+						$values['cancel'] = '';
514 514
 					} elseif ($country == '8Q') {
515
-            				    $values['registration'] = $line[0];
516
-            				    $values['base'] = null;
517
-            				    $values['owner'] = $line[3];
518
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
520
-					    $values['cancel'] = '';
515
+								$values['registration'] = $line[0];
516
+								$values['base'] = null;
517
+								$values['owner'] = $line[3];
518
+								if ($line[7] == '') $values['date_first_reg'] = null;
519
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
520
+						$values['cancel'] = '';
521 521
 					} elseif ($country == 'ZK') {
522
-            				    $values['registration'] = $line[0];
523
-            				    $values['base'] = null;
524
-            				    $values['owner'] = $line[3];
525
-            				    $values['date_first_reg'] = null;
526
-					    $values['cancel'] = '';
527
-					    $values['modes'] = $line[5];
528
-					    $values['icao'] = $line[9];
522
+								$values['registration'] = $line[0];
523
+								$values['base'] = null;
524
+								$values['owner'] = $line[3];
525
+								$values['date_first_reg'] = null;
526
+						$values['cancel'] = '';
527
+						$values['modes'] = $line[5];
528
+						$values['icao'] = $line[9];
529 529
 					} elseif ($country == 'M') {
530
-            				    $values['registration'] = $line[0];
531
-            				    $values['base'] = null;
532
-            				    $values['owner'] = $line[6];
533
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
534
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
535
-					    $values['modes'] = $line[4];
536
-					    $values['icao'] = $line[10];
530
+								$values['registration'] = $line[0];
531
+								$values['base'] = null;
532
+								$values['owner'] = $line[6];
533
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
534
+						$values['cancel'] = date("Y-m-d",strtotime($line[8]));
535
+						$values['modes'] = $line[4];
536
+						$values['icao'] = $line[10];
537 537
 					} elseif ($country == 'OY') {
538
-            				    $values['registration'] = $line[0];
539
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
540
-					    $values['modes'] = $line[5];
541
-					    $values['icao'] = $line[6];
538
+								$values['registration'] = $line[0];
539
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
540
+						$values['modes'] = $line[5];
541
+						$values['icao'] = $line[6];
542 542
 					} elseif ($country == 'PH') {
543
-            				    $values['registration'] = $line[0];
544
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
545
-					    $values['modes'] = $line[4];
546
-					    $values['icao'] = $line[5];
543
+								$values['registration'] = $line[0];
544
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
545
+						$values['modes'] = $line[4];
546
+						$values['icao'] = $line[5];
547 547
 					} elseif ($country == 'OM' || $country == 'TF') {
548
-            				    $values['registration'] = $line[0];
549
-            				    $values['base'] = null;
550
-            				    $values['owner'] = $line[3];
551
-            				    $values['date_first_reg'] = null;
552
-					    $values['cancel'] = '';
548
+								$values['registration'] = $line[0];
549
+								$values['base'] = null;
550
+								$values['owner'] = $line[3];
551
+								$values['date_first_reg'] = null;
552
+						$values['cancel'] = '';
553 553
 					}
554 554
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
555 555
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
                         return "error : ".$e->getMessage();
683 683
                 }
684 684
                 */
685
-                /*
685
+				/*
686 686
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
687 687
 		try {
688 688
 			$Connection = new Connection();
@@ -927,10 +927,10 @@  discard block
 block discarded – undo
927 927
 		try {
928 928
 			$Connection = new Connection();
929 929
 			$sth = $Connection->db->prepare($query);
930
-                        $sth->execute(array(':source' => 'translation.csv'));
931
-                } catch(PDOException $e) {
932
-                        return "error : ".$e->getMessage();
933
-                }
930
+						$sth->execute(array(':source' => 'translation.csv'));
931
+				} catch(PDOException $e) {
932
+						return "error : ".$e->getMessage();
933
+				}
934 934
 
935 935
 		
936 936
 		//update_db::unzip($out_file);
@@ -949,21 +949,21 @@  discard block
 block discarded – undo
949 949
 					$data = $row;
950 950
 					$operator = $data[2];
951 951
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
952
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
953
-                                                //echo substr($operator, 0, 2)."\n";;
954
-                                                if (count($airline_array) > 0) {
952
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
953
+												//echo substr($operator, 0, 2)."\n";;
954
+												if (count($airline_array) > 0) {
955 955
 							//print_r($airline_array);
956 956
 							$operator = $airline_array[0]['icao'].substr($operator,2);
957
-                                                }
958
-                                        }
957
+												}
958
+										}
959 959
 					
960 960
 					$operator_correct = $data[3];
961 961
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
962
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
963
-                                                if (count($airline_array) > 0) {
964
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
965
-                                            	}
966
-                                        }
962
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
963
+												if (count($airline_array) > 0) {
964
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
965
+												}
966
+										}
967 967
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
968 968
 					try {
969 969
 						$sth = $Connection->db->prepare($query);
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 			//$Connection->db->commit();
978 978
 		}
979 979
 		return '';
980
-        }
980
+		}
981 981
 	
982 982
 	public static function translation_fam() {
983 983
 		global $tmp_dir, $globalTransaction;
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 			//$Connection->db->commit();
1016 1016
 		}
1017 1017
 		return '';
1018
-        }
1018
+		}
1019 1019
 
1020 1020
 	/*
1021 1021
 	* This function use FAA public data.
@@ -1027,19 +1027,19 @@  discard block
 block discarded – undo
1027 1027
 		try {
1028 1028
 			$Connection = new Connection();
1029 1029
 			$sth = $Connection->db->prepare($query);
1030
-                        $sth->execute(array(':source' => 'website_faa'));
1031
-                } catch(PDOException $e) {
1032
-                        return "error : ".$e->getMessage();
1033
-                }
1030
+						$sth->execute(array(':source' => 'website_faa'));
1031
+				} catch(PDOException $e) {
1032
+						return "error : ".$e->getMessage();
1033
+				}
1034 1034
 
1035 1035
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
1036 1036
 		try {
1037 1037
 			$Connection = new Connection();
1038 1038
 			$sth = $Connection->db->prepare($query);
1039
-                        $sth->execute(array(':source' => 'website_faa'));
1040
-                } catch(PDOException $e) {
1041
-                        return "error : ".$e->getMessage();
1042
-                }
1039
+						$sth->execute(array(':source' => 'website_faa'));
1040
+				} catch(PDOException $e) {
1041
+						return "error : ".$e->getMessage();
1042
+				}
1043 1043
 
1044 1044
 		$delimiter = ",";
1045 1045
 		$mfr = array();
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
 		}
1208 1208
 		*/
1209 1209
 		return '';
1210
-        }
1210
+		}
1211 1211
         
1212 1212
 	public static function owner_fam() {
1213 1213
 		global $tmp_dir, $globalTransaction;
@@ -1215,10 +1215,10 @@  discard block
 block discarded – undo
1215 1215
 		try {
1216 1216
 			$Connection = new Connection();
1217 1217
 			$sth = $Connection->db->prepare($query);
1218
-                        $sth->execute(array(':source' => 'website_fam'));
1219
-                } catch(PDOException $e) {
1220
-                        return "error : ".$e->getMessage();
1221
-                }
1218
+						$sth->execute(array(':source' => 'website_fam'));
1219
+				} catch(PDOException $e) {
1220
+						return "error : ".$e->getMessage();
1221
+				}
1222 1222
 
1223 1223
 		$delimiter = "\t";
1224 1224
 		$Connection = new Connection();
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 			if ($globalTransaction) $Connection->db->commit();
1245 1245
 		}
1246 1246
 		return '';
1247
-        }
1247
+		}
1248 1248
 
1249 1249
 	public static function routes_fam() {
1250 1250
 		global $tmp_dir, $globalTransaction, $globalDebug;
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
 			if ($globalTransaction) $Connection->db->commit();
1287 1287
 		}
1288 1288
 		return '';
1289
-        }
1289
+		}
1290 1290
 
1291 1291
 	public static function marine_identity_fam() {
1292 1292
 		global $tmp_dir, $globalTransaction;
@@ -1294,10 +1294,10 @@  discard block
 block discarded – undo
1294 1294
 		try {
1295 1295
 			$Connection = new Connection();
1296 1296
 			$sth = $Connection->db->prepare($query);
1297
-                        $sth->execute();
1298
-                } catch(PDOException $e) {
1299
-                        return "error : ".$e->getMessage();
1300
-                }
1297
+						$sth->execute();
1298
+				} catch(PDOException $e) {
1299
+						return "error : ".$e->getMessage();
1300
+				}
1301 1301
 
1302 1302
 		
1303 1303
 		//update_db::unzip($out_file);
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
 			if ($globalTransaction) $Connection->db->commit();
1328 1328
 		}
1329 1329
 		return '';
1330
-        }
1330
+		}
1331 1331
 
1332 1332
 	public static function satellite_fam() {
1333 1333
 		global $tmp_dir, $globalTransaction;
@@ -1398,7 +1398,7 @@  discard block
 block discarded – undo
1398 1398
 			if ($globalTransaction) $Connection->db->commit();
1399 1399
 		}
1400 1400
 		return '';
1401
-        }
1401
+		}
1402 1402
 
1403 1403
 	public static function tle($filename,$tletype) {
1404 1404
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1409,10 +1409,10 @@  discard block
 block discarded – undo
1409 1409
 		try {
1410 1410
 			$Connection = new Connection();
1411 1411
 			$sth = $Connection->db->prepare($query);
1412
-                        $sth->execute(array(':source' => $filename));
1413
-                } catch(PDOException $e) {
1414
-                        return "error : ".$e->getMessage();
1415
-                }
1412
+						$sth->execute(array(':source' => $filename));
1413
+				} catch(PDOException $e) {
1414
+						return "error : ".$e->getMessage();
1415
+				}
1416 1416
 		
1417 1417
 		$Connection = new Connection();
1418 1418
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1447,7 +1447,7 @@  discard block
 block discarded – undo
1447 1447
 			//$Connection->db->commit();
1448 1448
 		}
1449 1449
 		return '';
1450
-        }
1450
+		}
1451 1451
 
1452 1452
 	public static function satellite_ucsdb($filename) {
1453 1453
 		global $tmp_dir, $globalTransaction;
@@ -1706,11 +1706,11 @@  discard block
 block discarded – undo
1706 1706
 							try {
1707 1707
 								$sth = $Connection->db->prepare($query);
1708 1708
 								$sth->execute(array(
1709
-								    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1710
-								    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1711
-								    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1712
-								    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1713
-								    )
1709
+									':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1710
+									':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1711
+									':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1712
+									':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1713
+									)
1714 1714
 								);
1715 1715
 							} catch(PDOException $e) {
1716 1716
 								return "error : ".$e->getMessage();
@@ -1734,13 +1734,13 @@  discard block
 block discarded – undo
1734 1734
 			//$Connection->db->commit();
1735 1735
 		}
1736 1736
 		return '';
1737
-        }
1737
+		}
1738 1738
 
1739 1739
 	/**
1740
-        * Convert a HTML table to an array
1741
-        * @param String $data HTML page
1742
-        * @return Array array of the tables in HTML page
1743
-        */
1740
+	 * Convert a HTML table to an array
1741
+	 * @param String $data HTML page
1742
+	 * @return Array array of the tables in HTML page
1743
+	 */
1744 1744
 /*
1745 1745
         private static function table2array($data) {
1746 1746
                 $html = str_get_html($data);
@@ -1770,11 +1770,11 @@  discard block
 block discarded – undo
1770 1770
                 return(array_filter($tabledata));
1771 1771
         }
1772 1772
 */
1773
-       /**
1774
-        * Get data from form result
1775
-        * @param String $url form URL
1776
-        * @return String the result
1777
-        */
1773
+	   /**
1774
+	    * Get data from form result
1775
+	    * @param String $url form URL
1776
+	    * @return String the result
1777
+	    */
1778 1778
 /*
1779 1779
         private static function getData($url) {
1780 1780
                 $ch = curl_init();
@@ -1924,7 +1924,7 @@  discard block
 block discarded – undo
1924 1924
 			if ($globalTransaction) $Connection->db->commit();
1925 1925
 		}
1926 1926
 		return '';
1927
-        }
1927
+		}
1928 1928
 	
1929 1929
 	public static function update_airspace() {
1930 1930
 		global $tmp_dir, $globalDBdriver;
@@ -1934,11 +1934,11 @@  discard block
 block discarded – undo
1934 1934
 			$query = 'DROP TABLE airspace';
1935 1935
 			try {
1936 1936
 				$sth = $Connection->db->prepare($query);
1937
-                    		$sth->execute();
1938
-	                } catch(PDOException $e) {
1937
+							$sth->execute();
1938
+					} catch(PDOException $e) {
1939 1939
 				return "error : ".$e->getMessage();
1940
-	                }
1941
-	        }
1940
+					}
1941
+			}
1942 1942
 
1943 1943
 
1944 1944
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -2003,10 +2003,10 @@  discard block
 block discarded – undo
2003 2003
 			$query = 'DROP TABLE countries';
2004 2004
 			try {
2005 2005
 				$sth = $Connection->db->prepare($query);
2006
-            	        	$sth->execute();
2007
-	                } catch(PDOException $e) {
2008
-    	                	echo "error : ".$e->getMessage();
2009
-	                }
2006
+							$sth->execute();
2007
+					} catch(PDOException $e) {
2008
+							echo "error : ".$e->getMessage();
2009
+					}
2010 2010
 		}
2011 2011
 		if ($globalDBdriver == 'mysql') {
2012 2012
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -2465,7 +2465,7 @@  discard block
 block discarded – undo
2465 2465
 						$error = update_db::airlines_fam();
2466 2466
 						update_db::insert_airlines_version($airlines_md5);
2467 2467
 					} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2468
-			    } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2468
+				} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2469 2469
 			} elseif ($globalDebug) echo "No update.";
2470 2470
 		} else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
2471 2471
 		if ($error != '') {
@@ -2956,10 +2956,10 @@  discard block
 block discarded – undo
2956 2956
 		try {
2957 2957
 			$Connection = new Connection();
2958 2958
 			$sth = $Connection->db->prepare($query);
2959
-                        $sth->execute();
2960
-                } catch(PDOException $e) {
2961
-                        return "error : ".$e->getMessage();
2962
-                }
2959
+						$sth->execute();
2960
+				} catch(PDOException $e) {
2961
+						return "error : ".$e->getMessage();
2962
+				}
2963 2963
 
2964 2964
 		$error = '';
2965 2965
 		if ($globalDebug) echo "Notam : Download...";
@@ -3015,8 +3015,8 @@  discard block
 block discarded – undo
3015 3015
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
3016 3016
 					$data['permanent'] = 0;
3017 3017
 				} else {
3018
-				    $data['date_end'] = NULL;
3019
-				    $data['permanent'] = 1;
3018
+					$data['date_end'] = NULL;
3019
+					$data['permanent'] = 1;
3020 3020
 				}
3021 3021
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
3022 3022
 				$NOTAM = new NOTAM();
@@ -3090,13 +3090,13 @@  discard block
 block discarded – undo
3090 3090
 		try {
3091 3091
 			$Connection = new Connection();
3092 3092
 			$sth = $Connection->db->prepare($query);
3093
-                        $sth->execute();
3094
-                } catch(PDOException $e) {
3095
-                        return "error : ".$e->getMessage();
3096
-                }
3097
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3098
-                if ($row['nb'] > 0) return false;
3099
-                else return true;
3093
+						$sth->execute();
3094
+				} catch(PDOException $e) {
3095
+						return "error : ".$e->getMessage();
3096
+				}
3097
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3098
+				if ($row['nb'] > 0) return false;
3099
+				else return true;
3100 3100
 	}
3101 3101
 
3102 3102
 	public static function insert_last_update() {
@@ -3105,10 +3105,10 @@  discard block
 block discarded – undo
3105 3105
 		try {
3106 3106
 			$Connection = new Connection();
3107 3107
 			$sth = $Connection->db->prepare($query);
3108
-                        $sth->execute();
3109
-                } catch(PDOException $e) {
3110
-                        return "error : ".$e->getMessage();
3111
-                }
3108
+						$sth->execute();
3109
+				} catch(PDOException $e) {
3110
+						return "error : ".$e->getMessage();
3111
+				}
3112 3112
 	}
3113 3113
 
3114 3114
 	public static function check_airspace_version($version) {
@@ -3116,13 +3116,13 @@  discard block
 block discarded – undo
3116 3116
 		try {
3117 3117
 			$Connection = new Connection();
3118 3118
 			$sth = $Connection->db->prepare($query);
3119
-                        $sth->execute(array(':version' => $version));
3120
-                } catch(PDOException $e) {
3121
-                        return "error : ".$e->getMessage();
3122
-                }
3123
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3124
-                if ($row['nb'] > 0) return true;
3125
-                else return false;
3119
+						$sth->execute(array(':version' => $version));
3120
+				} catch(PDOException $e) {
3121
+						return "error : ".$e->getMessage();
3122
+				}
3123
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3124
+				if ($row['nb'] > 0) return true;
3125
+				else return false;
3126 3126
 	}
3127 3127
 
3128 3128
 	public static function check_geoid_version($version) {
@@ -3130,13 +3130,13 @@  discard block
 block discarded – undo
3130 3130
 		try {
3131 3131
 			$Connection = new Connection();
3132 3132
 			$sth = $Connection->db->prepare($query);
3133
-                        $sth->execute(array(':version' => $version));
3134
-                } catch(PDOException $e) {
3135
-                        return "error : ".$e->getMessage();
3136
-                }
3137
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3138
-                if ($row['nb'] > 0) return true;
3139
-                else return false;
3133
+						$sth->execute(array(':version' => $version));
3134
+				} catch(PDOException $e) {
3135
+						return "error : ".$e->getMessage();
3136
+				}
3137
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3138
+				if ($row['nb'] > 0) return true;
3139
+				else return false;
3140 3140
 	}
3141 3141
 
3142 3142
 	public static function check_marine_identity_version($version) {
@@ -3237,10 +3237,10 @@  discard block
 block discarded – undo
3237 3237
 		try {
3238 3238
 			$Connection = new Connection();
3239 3239
 			$sth = $Connection->db->prepare($query);
3240
-                        $sth->execute(array(':version' => $version));
3241
-                } catch(PDOException $e) {
3242
-                        return "error : ".$e->getMessage();
3243
-                }
3240
+						$sth->execute(array(':version' => $version));
3241
+				} catch(PDOException $e) {
3242
+						return "error : ".$e->getMessage();
3243
+				}
3244 3244
 	}
3245 3245
 
3246 3246
 	public static function insert_marine_identity_version($version) {
@@ -3277,13 +3277,13 @@  discard block
 block discarded – undo
3277 3277
 		try {
3278 3278
 			$Connection = new Connection();
3279 3279
 			$sth = $Connection->db->prepare($query);
3280
-                        $sth->execute();
3281
-                } catch(PDOException $e) {
3282
-                        return "error : ".$e->getMessage();
3283
-                }
3284
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3285
-                if ($row['nb'] > 0) return false;
3286
-                else return true;
3280
+						$sth->execute();
3281
+				} catch(PDOException $e) {
3282
+						return "error : ".$e->getMessage();
3283
+				}
3284
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3285
+				if ($row['nb'] > 0) return false;
3286
+				else return true;
3287 3287
 	}
3288 3288
 
3289 3289
 	public static function insert_last_notam_update() {
@@ -3292,10 +3292,10 @@  discard block
 block discarded – undo
3292 3292
 		try {
3293 3293
 			$Connection = new Connection();
3294 3294
 			$sth = $Connection->db->prepare($query);
3295
-                        $sth->execute();
3296
-                } catch(PDOException $e) {
3297
-                        return "error : ".$e->getMessage();
3298
-                }
3295
+						$sth->execute();
3296
+				} catch(PDOException $e) {
3297
+						return "error : ".$e->getMessage();
3298
+				}
3299 3299
 	}
3300 3300
 
3301 3301
 	public static function check_last_airspace_update() {
@@ -3308,13 +3308,13 @@  discard block
 block discarded – undo
3308 3308
 		try {
3309 3309
 			$Connection = new Connection();
3310 3310
 			$sth = $Connection->db->prepare($query);
3311
-                        $sth->execute();
3312
-                } catch(PDOException $e) {
3313
-                        return "error : ".$e->getMessage();
3314
-                }
3315
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3316
-                if ($row['nb'] > 0) return false;
3317
-                else return true;
3311
+						$sth->execute();
3312
+				} catch(PDOException $e) {
3313
+						return "error : ".$e->getMessage();
3314
+				}
3315
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3316
+				if ($row['nb'] > 0) return false;
3317
+				else return true;
3318 3318
 	}
3319 3319
 
3320 3320
 	public static function insert_last_airspace_update() {
@@ -3323,10 +3323,10 @@  discard block
 block discarded – undo
3323 3323
 		try {
3324 3324
 			$Connection = new Connection();
3325 3325
 			$sth = $Connection->db->prepare($query);
3326
-                        $sth->execute();
3327
-                } catch(PDOException $e) {
3328
-                        return "error : ".$e->getMessage();
3329
-                }
3326
+						$sth->execute();
3327
+				} catch(PDOException $e) {
3328
+						return "error : ".$e->getMessage();
3329
+				}
3330 3330
 	}
3331 3331
 
3332 3332
 	public static function check_last_geoid_update() {
@@ -3339,13 +3339,13 @@  discard block
 block discarded – undo
3339 3339
 		try {
3340 3340
 			$Connection = new Connection();
3341 3341
 			$sth = $Connection->db->prepare($query);
3342
-                        $sth->execute();
3343
-                } catch(PDOException $e) {
3344
-                        return "error : ".$e->getMessage();
3345
-                }
3346
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3347
-                if ($row['nb'] > 0) return false;
3348
-                else return true;
3342
+						$sth->execute();
3343
+				} catch(PDOException $e) {
3344
+						return "error : ".$e->getMessage();
3345
+				}
3346
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3347
+				if ($row['nb'] > 0) return false;
3348
+				else return true;
3349 3349
 	}
3350 3350
 
3351 3351
 	public static function insert_last_geoid_update() {
@@ -3354,10 +3354,10 @@  discard block
 block discarded – undo
3354 3354
 		try {
3355 3355
 			$Connection = new Connection();
3356 3356
 			$sth = $Connection->db->prepare($query);
3357
-                        $sth->execute();
3358
-                } catch(PDOException $e) {
3359
-                        return "error : ".$e->getMessage();
3360
-                }
3357
+						$sth->execute();
3358
+				} catch(PDOException $e) {
3359
+						return "error : ".$e->getMessage();
3360
+				}
3361 3361
 	}
3362 3362
 
3363 3363
 	public static function check_last_owner_update() {
@@ -3463,13 +3463,13 @@  discard block
 block discarded – undo
3463 3463
 		try {
3464 3464
 			$Connection = new Connection();
3465 3465
 			$sth = $Connection->db->prepare($query);
3466
-                        $sth->execute();
3467
-                } catch(PDOException $e) {
3468
-                        return "error : ".$e->getMessage();
3469
-                }
3470
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
3471
-                if ($row['nb'] > 0) return false;
3472
-                else return true;
3466
+						$sth->execute();
3467
+				} catch(PDOException $e) {
3468
+						return "error : ".$e->getMessage();
3469
+				}
3470
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
3471
+				if ($row['nb'] > 0) return false;
3472
+				else return true;
3473 3473
 	}
3474 3474
 
3475 3475
 	public static function insert_last_schedules_update() {
@@ -3649,10 +3649,10 @@  discard block
 block discarded – undo
3649 3649
 		try {
3650 3650
 			$Connection = new Connection();
3651 3651
 			$sth = $Connection->db->prepare($query);
3652
-                        $sth->execute();
3653
-                } catch(PDOException $e) {
3654
-                        return "error : ".$e->getMessage();
3655
-                }
3652
+						$sth->execute();
3653
+				} catch(PDOException $e) {
3654
+						return "error : ".$e->getMessage();
3655
+				}
3656 3656
 	}
3657 3657
 	public static function delete_duplicateowner() {
3658 3658
 		global $globalDBdriver;
@@ -3664,10 +3664,10 @@  discard block
 block discarded – undo
3664 3664
 		try {
3665 3665
 			$Connection = new Connection();
3666 3666
 			$sth = $Connection->db->prepare($query);
3667
-                        $sth->execute();
3668
-                } catch(PDOException $e) {
3669
-                        return "error : ".$e->getMessage();
3670
-                }
3667
+						$sth->execute();
3668
+				} catch(PDOException $e) {
3669
+						return "error : ".$e->getMessage();
3670
+				}
3671 3671
 	}
3672 3672
 	
3673 3673
 	public static function update_all() {
Please login to merge, or discard this patch.
header.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 // When button "Remove all filters" is clicked
39 39
 if (isset($_POST['removefilters'])) {
40 40
 	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
41
-	    return strpos($key,'filter_') === 0;
41
+		return strpos($key,'filter_') === 0;
42 42
 	});
43 43
 	foreach ($allfilters as $filt) {
44 44
 		unset($_COOKIE[$filt]);
@@ -188,17 +188,17 @@  discard block
 block discarded – undo
188 188
 	}
189 189
 ?>
190 190
 <?php 
191
-    if (isset($_POST['archive'])) {
191
+	if (isset($_POST['archive'])) {
192 192
 ?>
193 193
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
194 194
 <?php 
195
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
195
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
196 196
 ?>
197 197
 
198 198
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>&archive&begindate=<?php print strtotime($_POST['start_date']); ?>&enddate=<?php print strtotime($_POST['end_date']); ?>&archivespeed=<?php print $_POST['archivespeed']; ?>"></script>
199 199
 <?php    
200
-	    }
201
-    } else {
200
+		}
201
+	} else {
202 202
 ?>
203 203
 <?php
204 204
 /*	if (isset($globalBeta) && $globalBeta) {
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 */
211 211
 ?>
212 212
 <?php 
213
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
213
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
214 214
 ?>
215 215
 <?php
216 216
 //		if (isset($globalBeta) && $globalBeta) {
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
 <script src="<?php print $globalURL; ?>/js/map-satellite.2d.js.php?<?php print time(); ?>"></script>
242 242
 <?php
243 243
 		}
244
-	    }
244
+		}
245 245
 ?>
246 246
 <?php
247 247
 //	}
248 248
 ?>
249 249
 <?php
250
-    }
250
+	}
251 251
 }
252 252
 ?>
253 253
 <?php
@@ -424,34 +424,34 @@  discard block
 block discarded – undo
424 424
 
425 425
       <ul class="nav navbar-nav">
426 426
 <?php
427
-    if (isset($globalNewsFeeds['global']) && !empty($globalNewsFeeds['global'])) {
427
+	if (isset($globalNewsFeeds['global']) && !empty($globalNewsFeeds['global'])) {
428 428
 ?>
429 429
     <li><a href="<?php print $globalURL; ?>/news"><?php echo _("News"); ?></a></li>
430 430
 <?php
431
-    }
431
+	}
432 432
 ?>
433 433
 
434 434
 <?php 
435
-    $sub = false;
436
-    if (
435
+	$sub = false;
436
+	if (
437 437
 	(
438
-	    (!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
438
+		(!isset($globalAircraft) || (isset($globalAircraft) && $globalAircraft === TRUE)) && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
439 439
 	) || 
440 440
 	(
441
-	    isset($globalMarine) && $globalMarine === TRUE && ((isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
441
+		isset($globalMarine) && $globalMarine === TRUE && ((isset($globalTracker) && $globalTracker === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
442 442
 	) || 
443 443
 	(
444
-	    isset($globalTracker) && $globalTracker === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
444
+		isset($globalTracker) && $globalTracker === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalSatellite) && $globalSatellite === TRUE))
445 445
 	) || 
446 446
 	(
447
-	    isset($globalSatellite) && $globalSatellite === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))
447
+		isset($globalSatellite) && $globalSatellite === TRUE && ((isset($globalMarine) && $globalMarine === TRUE) || (isset($globalTracker) && $globalTracker === TRUE))
448 448
 	)
449
-    ) {
449
+	) {
450 450
 	$sub = true;
451
-    }
451
+	}
452 452
 ?>
453 453
 <?php
454
-    if (!isset($globalAircraft) || $globalAircraft === TRUE) {
454
+	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
455 455
 ?>
456 456
     <li class="dropdown">
457 457
 <?php
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 	<ul class="dropdown-menu multi-level">
463 463
       	<li class="dropdown-submenu">
464 464
 <?php
465
-        }
465
+		}
466 466
 ?>
467 467
 <?php
468 468
 	if (isset($globalNewsFeeds['aircraft']) && !empty($globalNewsFeeds['aircraft'])) {
@@ -477,25 +477,25 @@  discard block
 block discarded – undo
477 477
           <ul class="dropdown-menu">
478 478
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircraft Types"); ?></a></li>
479 479
 <?php
480
-    if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
480
+	if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
481 481
 ?>
482 482
 			<li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li>
483 483
 <?php
484
-    }
484
+	}
485 485
 ?>
486 486
 			<li><a href="<?php print $globalURL; ?>/airport"><?php echo _("Airports"); ?></a></li>
487 487
 <?php
488
-    if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
488
+	if ((isset($globalUseOwner) && $globalUseOwner) || (!isset($globalUseOwner) && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM))) {
489 489
 ?>
490 490
 			<li><a href="<?php print $globalURL; ?>/owner"><?php echo _("Owners"); ?></a></li>
491 491
 <?php
492
-    } 
493
-    if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
492
+	} 
493
+	if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
494 494
 
495 495
 ?>
496 496
 			<li><a href="<?php print $globalURL; ?>/pilot"><?php echo _("Pilots"); ?></a></li>
497 497
 <?php
498
-    }
498
+	}
499 499
 ?>
500 500
 			<li><hr /></li>
501 501
             <li><a href="<?php print $globalURL; ?>/currently"><?php echo _("Current Activity"); ?></a></li>
@@ -503,43 +503,43 @@  discard block
 block discarded – undo
503 503
             <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li>
504 504
             <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li>
505 505
             <?php
506
-        	if ($globalACARS) {
507
-        	    if (isset($globalDemo) && $globalDemo) {
508
-    	    ?>
506
+			if ($globalACARS) {
507
+				if (isset($globalDemo) && $globalDemo) {
508
+			?>
509 509
             <li><hr /></li>
510 510
             <li><i><?php echo _('ACARS data not available publicly'); ?></i></li>
511 511
             <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li>
512 512
             <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li>
513 513
             <?php
514
-        	    } else {
515
-    	    ?>
514
+				} else {
515
+			?>
516 516
             <li><hr /></li>
517 517
             <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li>
518 518
             <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li>
519 519
             <?php
520
-        	    }
521
-        	}
522
-    	    ?>
520
+				}
521
+			}
522
+			?>
523 523
     	    <?php
524
-    	        if (isset($globalAccidents) && $globalAccidents) {
525
-    	    ?>
524
+				if (isset($globalAccidents) && $globalAccidents) {
525
+			?>
526 526
             <li><hr /></li>
527 527
             <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident"); ?></a></li>
528 528
             <li><a href="<?php print $globalURL; ?>/accident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Accident"); ?></a></li>
529 529
             <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident"); ?></a></li>
530 530
             <li><a href="<?php print $globalURL; ?>/incident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Incident"); ?></a></li>
531 531
             <?php
532
-        	}
533
-    	    ?>
532
+			}
533
+			?>
534 534
             <li><hr /></li>
535 535
             <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li>
536 536
             <?php
537 537
 		if (!isset($globalNoUpcoming) || $globalNoUpcoming === FALSE) {
538
-	    ?>
538
+		?>
539 539
             <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li>
540 540
 	    <?php
541 541
 		}
542
-	    ?>
542
+		?>
543 543
           </ul>
544 544
         </li>
545 545
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
@@ -566,14 +566,14 @@  discard block
 block discarded – undo
566 566
     </ul>
567 567
 <?php
568 568
 	}
569
-    }
569
+	}
570 570
 ?>
571 571
 <?php
572
-    if (isset($globalMarine) && $globalMarine) {
572
+	if (isset($globalMarine) && $globalMarine) {
573 573
 ?>
574 574
     <li class="dropdown">
575 575
 <?php
576
-        if ($sub) {
576
+		if ($sub) {
577 577
 ?>
578 578
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Marines"); ?> <b class="caret"></b></a>
579 579
 	<ul class="dropdown-menu multi-level">
@@ -607,14 +607,14 @@  discard block
 block discarded – undo
607 607
 	}
608 608
 ?>
609 609
 <?php
610
-    }
610
+	}
611 611
 ?>
612 612
 <?php
613
-    if (isset($globalTracker) && $globalTracker) {
613
+	if (isset($globalTracker) && $globalTracker) {
614 614
 ?>
615 615
     <li class="dropdown">
616 616
 <?php
617
-        if ($sub) {
617
+		if ($sub) {
618 618
 ?>
619 619
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Trackers"); ?> <b class="caret"></b></a>
620 620
 	<ul class="dropdown-menu multi-level">
@@ -648,14 +648,14 @@  discard block
 block discarded – undo
648 648
 	}
649 649
 ?>
650 650
 <?php
651
-    }
651
+	}
652 652
 ?>
653 653
 <?php
654
-    if (isset($globalSatellite) && $globalSatellite) {
654
+	if (isset($globalSatellite) && $globalSatellite) {
655 655
 ?>
656 656
     <li class="dropdown">
657 657
 <?php
658
-        if ($sub) {
658
+		if ($sub) {
659 659
 ?>
660 660
     <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Satellites"); ?> <b class="caret"></b></a>
661 661
 	<ul class="dropdown-menu multi-level">
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 	}
692 692
 ?>
693 693
 <?php
694
-    }
694
+	}
695 695
 ?>
696 696
 
697 697
         <li class="dropdown">
@@ -700,12 +700,12 @@  discard block
 block discarded – undo
700 700
           	<li><a href="<?php print $globalURL; ?>/about"><?php echo _("About The Project"); ?></a></li>
701 701
           	<li><a href="<?php print $globalURL; ?>/about/export"><?php echo _("Exporting Data"); ?></a></li>
702 702
 <?php
703
-    if (!isset($globalAircraft) || $globalAircraft === TRUE) {
703
+	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
704 704
 ?>
705 705
 		<li><hr /></li>
706 706
 		<li><a href="<?php print $globalURL; ?>/about/tv"><?php echo _("Spotter TV"); ?></a></li>
707 707
 <?php
708
-    }
708
+	}
709 709
 ?>
710 710
 	    <?php if (isset($globalContribute) && $globalContribute) { ?>
711 711
                 <li><hr /></li>
@@ -726,14 +726,14 @@  discard block
 block discarded – undo
726 726
   	    <form>
727 727
   		<select class="selectpicker" data-width="120px" onchange="language(this);">
728 728
   		    <?php
729
-  		        $Language = new Language();
730
-  		        $alllang = $Language->getLanguages();
731
-  		        foreach ($alllang as $key => $lang) {
732
-  		            print '<option value="'.$key.'"';
733
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
734
-  		            print '>'.$lang[0].'</option>';
735
-  		        }
736
-  		    ?>
729
+  				$Language = new Language();
730
+  				$alllang = $Language->getLanguages();
731
+  				foreach ($alllang as $key => $lang) {
732
+  					print '<option value="'.$key.'"';
733
+  					if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
734
+  					print '>'.$lang[0].'</option>';
735
+  				}
736
+  			?>
737 737
   		</select>
738 738
   	    </form>
739 739
   	</div>
@@ -765,18 +765,18 @@  discard block
 block discarded – undo
765 765
 ?>
766 766
     <div class="top-header clear" role="main">
767 767
 <?php
768
-    if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
768
+	if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
769 769
 ?>
770 770
     <div id="archive-map"></div>
771 771
 <?php
772
-    }
772
+	}
773 773
 ?>
774 774
     </div>
775 775
 <?php
776 776
 }
777 777
 if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
778 778
 {
779
-    ?>
779
+	?>
780 780
     <div class="top-header clear" role="main">
781 781
         <div id="map"></div>
782 782
 	<link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" />
@@ -787,15 +787,15 @@  discard block
 block discarded – undo
787 787
         var zoom = 13;
788 788
 //create the map
789 789
 <?php
790
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
790
+	if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
791 791
 ?>
792 792
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
793 793
 <?php
794
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
794
+	} elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
795 795
 ?>
796 796
   map = L.map('map', { zoomControl:true });
797 797
 <?php
798
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
798
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
799 799
 ?>
800 800
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
801 801
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -803,22 +803,22 @@  discard block
 block discarded – undo
803 803
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
804 804
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
805 805
 <?php
806
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
806
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude']) && isset($spotter_array[0]['latitude'])) {
807 807
 ?>
808 808
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
809 809
 <?php
810
-    } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
810
+	} elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
811 811
 ?>
812 812
   map = L.map('map', { zoomControl:true });
813 813
 <?php
814
-    }
814
+	}
815 815
 ?>
816 816
   //initialize the layer group for the aircrft markers
817 817
   var layer_data = L.layerGroup();
818 818
 
819 819
   //a few title layers
820 820
 <?php
821
-    if ($globalMapProvider == 'Mapbox') {
821
+	if ($globalMapProvider == 'Mapbox') {
822 822
 ?>
823 823
   L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
824 824
     maxZoom: 18,
@@ -829,14 +829,14 @@  discard block
 block discarded – undo
829 829
     token : '<?php print $globalMapboxToken; ?>'
830 830
   }).addTo(map);
831 831
 <?php
832
-    } elseif ($globalMapProvider == 'Mapbox-GL') {
832
+	} elseif ($globalMapProvider == 'Mapbox-GL') {
833 833
 ?>
834 834
     L.mapboxGL({
835 835
 	accessToken: '<?php print $globalMapboxToken; ?>',
836 836
 	style: 'mapbox://styles/mapbox/bright-v8'
837 837
   }).addTo(map);
838 838
 <?php
839
-    } elseif ($globalMapProvider == 'MapQuest-OSM') {
839
+	} elseif ($globalMapProvider == 'MapQuest-OSM') {
840 840
 ?>
841 841
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
842 842
     maxZoom: 18,
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>'
846 846
   }).addTo(map);
847 847
 <?php
848
-    } elseif ($globalMapProvider == 'MapQuest-Aerial') {
848
+	} elseif ($globalMapProvider == 'MapQuest-Aerial') {
849 849
 ?>
850 850
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
851 851
     maxZoom: 18,
@@ -854,27 +854,27 @@  discard block
 block discarded – undo
854 854
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"'
855 855
   }).addTo(map);
856 856
 <?php
857
-    } elseif ($globalMapProvider == 'Google-Roadmap') {
857
+	} elseif ($globalMapProvider == 'Google-Roadmap') {
858 858
 ?>
859 859
     var googleLayer = new L.Google('ROADMAP');
860 860
     map.addLayer(googleLayer);
861 861
 <?php
862
-    } elseif ($globalMapProvider == 'Google-Satellite') {
862
+	} elseif ($globalMapProvider == 'Google-Satellite') {
863 863
 ?>
864 864
     var googleLayer = new L.Google('SATELLITE');
865 865
     map.addLayer(googleLayer);
866 866
 <?php
867
-    } elseif ($globalMapProvider == 'Google-Hybrid') {
867
+	} elseif ($globalMapProvider == 'Google-Hybrid') {
868 868
 ?>
869 869
     var googleLayer = new L.Google('HYBRID');
870 870
     map.addLayer(googleLayer);
871 871
 <?php
872
-    } elseif ($globalMapProvider == 'Google-Terrain') {
872
+	} elseif ($globalMapProvider == 'Google-Terrain') {
873 873
 ?>
874 874
     var googleLayer = new L.Google('Terrain');
875 875
     map.addLayer(googleLayer);
876 876
 <?php
877
-    } elseif (isset($globalMapCustomLayer[$globalMapProvider])) {
877
+	} elseif (isset($globalMapCustomLayer[$globalMapProvider])) {
878 878
 	$customid = $globalMapProvider;
879 879
 ?>
880 880
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
885 885
     }).addTo(map);
886 886
 <?php
887
-    } elseif ($globalMapProvider == 'offline' || (isset($globalMapOffline) && $globalMapOffline === TRUE)) {
887
+	} elseif ($globalMapProvider == 'offline' || (isset($globalMapOffline) && $globalMapOffline === TRUE)) {
888 888
 ?>
889 889
     var center = map.getCenter();
890 890
     map.options.crs = L.CRS.EPSG4326;
@@ -899,8 +899,8 @@  discard block
 block discarded – undo
899 899
         attribution: 'Natural Earth'
900 900
     }).addTo(map);
901 901
 <?php
902
-    //} elseif ($globalMapProvider == 'OpenStreetMap') {
903
-    } else {
902
+	//} elseif ($globalMapProvider == 'OpenStreetMap') {
903
+	} else {
904 904
 ?>
905 905
   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
906 906
     maxZoom: 18,
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
   }).addTo(map);
910 910
 
911 911
 <?php
912
-    }
912
+	}
913 913
 ?>
914 914
         </script>
915 915
     </div>
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Indentation   +1091 added lines, -1091 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 57
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 if (isset($options['idsource'])) $id_source = $options['idsource'];
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
106
+	if ($globalDebug) echo "Using Server Mode\n";
107
+	$SI=new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
117
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
117
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 119
 }
120 120
 
121 121
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
122 122
 if (isset($globalMarine) && $globalMarine) {
123
-    $AIS = new AIS();
124
-    $MI = new MarineImport($Connection->db);
123
+	$AIS = new AIS();
124
+	$MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127 127
 $SBS=new SBS();
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
138
-        global $sockets;
139
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
-        die("Bye!\n");
141
-    });
142
-    pcntl_signal_dispatch();
137
+	pcntl_signal(SIGINT,  function() {
138
+		global $sockets;
139
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
+		die("Bye!\n");
141
+	});
142
+	pcntl_signal_dispatch();
143 143
 }
144 144
 
145 145
 // let's try and connect
@@ -149,46 +149,46 @@  discard block
 block discarded – undo
149 149
 $reset = 0;
150 150
 
151 151
 function connect_all($hosts) {
152
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
-    $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
156
-    foreach ($hosts as $id => $value) {
152
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
+	$reset++;
155
+	if ($globalDebug) echo 'Connect to all...'."\n";
156
+	foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160 160
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
162
-        	//$formats[$id] = 'deltadbtxt';
163
-        	$globalSources[$id]['format'] = 'deltadbtxt';
164
-        	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
-        	//$formats[$id] = 'vatsimtxt';
168
-        	$globalSources[$id]['format'] = 'vatsimtxt';
169
-        	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172
-        	//$formats[$id] = 'aircraftlistjson';
173
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
174
-        	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
177
-        	//$formats[$id] = 'aircraftjson';
178
-        	$globalSources[$id]['format'] = 'aircraftjson';
179
-        	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraft$/i',$host)) {
182
-        	//$formats[$id] = 'planefinderclient';
183
-        	$globalSources[$id]['format'] = 'planefinderclient';
184
-        	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
-    	    } else if (preg_match('/opensky/i',$host)) {
187
-        	//$formats[$id] = 'aircraftlistjson';
188
-        	$globalSources[$id]['format'] = 'opensky';
189
-        	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
191
-    	    /*
161
+			if (preg_match('/deltadb.txt$/i',$host)) {
162
+			//$formats[$id] = 'deltadbtxt';
163
+			$globalSources[$id]['format'] = 'deltadbtxt';
164
+			//$last_exec['deltadbtxt'] = 0;
165
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
+			//$formats[$id] = 'vatsimtxt';
168
+			$globalSources[$id]['format'] = 'vatsimtxt';
169
+			//$last_exec['vatsimtxt'] = 0;
170
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
172
+			//$formats[$id] = 'aircraftlistjson';
173
+			$globalSources[$id]['format'] = 'aircraftlistjson';
174
+			//$last_exec['aircraftlistjson'] = 0;
175
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
+			} else if (preg_match('/aircraft.json$/i',$host)) {
177
+			//$formats[$id] = 'aircraftjson';
178
+			$globalSources[$id]['format'] = 'aircraftjson';
179
+			//$last_exec['aircraftlistjson'] = 0;
180
+			if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
+			} else if (preg_match('/aircraft$/i',$host)) {
182
+			//$formats[$id] = 'planefinderclient';
183
+			$globalSources[$id]['format'] = 'planefinderclient';
184
+			//$last_exec['aircraftlistjson'] = 0;
185
+			if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
+			} else if (preg_match('/opensky/i',$host)) {
187
+			//$formats[$id] = 'aircraftlistjson';
188
+			$globalSources[$id]['format'] = 'opensky';
189
+			//$last_exec['aircraftlistjson'] = 0;
190
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
191
+			/*
192 192
     	    // Disabled for now, site change source format
193 193
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
194 194
         	//$formats[$id] = 'radarvirtueljson';
@@ -200,127 +200,127 @@  discard block
 block discarded – undo
200 200
         	    exit(0);
201 201
         	}
202 202
     	    */
203
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
204
-        	//$formats[$id] = 'planeupdatefaa';
205
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
206
-        	//$last_exec['planeupdatefaa'] = 0;
207
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
208
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
-        	    exit(0);
211
-        	}
212
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
213
-        	//$formats[$id] = 'phpvmacars';
214
-        	$globalSources[$id]['format'] = 'phpvmacars';
215
-        	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218
-        	//$formats[$id] = 'phpvmacars';
219
-        	$globalSources[$id]['format'] = 'vaos';
220
-        	//$last_exec['phpvmacars'] = 0;
221
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
223
-        	//$formats[$id] = 'phpvmacars';
224
-        	$globalSources[$id]['format'] = 'vam';
225
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
-            } else if (preg_match('/whazzup/i',$host)) {
227
-        	//$formats[$id] = 'whazzup';
228
-        	$globalSources[$id]['format'] = 'whazzup';
229
-        	//$last_exec['whazzup'] = 0;
230
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
-            } else if (preg_match('/blitzortung/i',$host)) {
232
-        	$globalSources[$id]['format'] = 'blitzortung';
233
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
-            } else if (preg_match('/airwhere/i',$host)) {
235
-        	$globalSources[$id]['format'] = 'airwhere';
236
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
-            } else if (preg_match('/recentpireps/i',$host)) {
238
-        	//$formats[$id] = 'pirepsjson';
239
-        	$globalSources[$id]['format'] = 'pirepsjson';
240
-        	//$last_exec['pirepsjson'] = 0;
241
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243
-        	//$formats[$id] = 'fr24json';
244
-        	$globalSources[$id]['format'] = 'fr24json';
245
-        	//$last_exec['fr24json'] = 0;
246
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
247
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249
-        	    exit(0);
250
-        	}
251
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
252
-        	//$formats[$id] = 'fr24json';
253
-        	$globalSources[$id]['format'] = 'myshiptracking';
254
-        	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
256
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
-        	    exit(0);
259
-        	}
260
-            //} else if (preg_match('/10001/',$host)) {
261
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262
-        	//$formats[$id] = 'tsv';
263
-        	$globalSources[$id]['format'] = 'tsv';
264
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265
-            }
266
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
267
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
269
-    		    if ($idf !== false) {
270
-    			$httpfeeds[$id] = $idf;
271
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
274
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
275
-	    $hostport = explode(':',$host);
276
-	    if (isset($hostport[1])) {
203
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
204
+			//$formats[$id] = 'planeupdatefaa';
205
+			$globalSources[$id]['format'] = 'planeupdatefaa';
206
+			//$last_exec['planeupdatefaa'] = 0;
207
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
208
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
+				exit(0);
211
+			}
212
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
213
+			//$formats[$id] = 'phpvmacars';
214
+			$globalSources[$id]['format'] = 'phpvmacars';
215
+			//$last_exec['phpvmacars'] = 0;
216
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218
+			//$formats[$id] = 'phpvmacars';
219
+			$globalSources[$id]['format'] = 'vaos';
220
+			//$last_exec['phpvmacars'] = 0;
221
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
223
+			//$formats[$id] = 'phpvmacars';
224
+			$globalSources[$id]['format'] = 'vam';
225
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
+			} else if (preg_match('/whazzup/i',$host)) {
227
+			//$formats[$id] = 'whazzup';
228
+			$globalSources[$id]['format'] = 'whazzup';
229
+			//$last_exec['whazzup'] = 0;
230
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
+			} else if (preg_match('/blitzortung/i',$host)) {
232
+			$globalSources[$id]['format'] = 'blitzortung';
233
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
+			} else if (preg_match('/airwhere/i',$host)) {
235
+			$globalSources[$id]['format'] = 'airwhere';
236
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
+			} else if (preg_match('/recentpireps/i',$host)) {
238
+			//$formats[$id] = 'pirepsjson';
239
+			$globalSources[$id]['format'] = 'pirepsjson';
240
+			//$last_exec['pirepsjson'] = 0;
241
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243
+			//$formats[$id] = 'fr24json';
244
+			$globalSources[$id]['format'] = 'fr24json';
245
+			//$last_exec['fr24json'] = 0;
246
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
247
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249
+				exit(0);
250
+			}
251
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
252
+			//$formats[$id] = 'fr24json';
253
+			$globalSources[$id]['format'] = 'myshiptracking';
254
+			//$last_exec['fr24json'] = 0;
255
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
256
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
+				exit(0);
259
+			}
260
+			//} else if (preg_match('/10001/',$host)) {
261
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262
+			//$formats[$id] = 'tsv';
263
+			$globalSources[$id]['format'] = 'tsv';
264
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265
+			}
266
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
267
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
269
+				if ($idf !== false) {
270
+				$httpfeeds[$id] = $idf;
271
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
274
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
275
+		$hostport = explode(':',$host);
276
+		if (isset($hostport[1])) {
277 277
 		$port = $hostport[1];
278 278
 		$hostn = $hostport[0];
279
-	    } else {
279
+		} else {
280 280
 		$port = $globalSources[$id]['port'];
281 281
 		$hostn = $globalSources[$id]['host'];
282
-	    }
283
-	    $Common = new Common();
284
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
285
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
286
-    	    } else {
287
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
288
-	    }
289
-	    if ($s) {
290
-    	        $sockets[$id] = $s;
291
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
292
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
282
+		}
283
+		$Common = new Common();
284
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
285
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
286
+			} else {
287
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
288
+		}
289
+		if ($s) {
290
+				$sockets[$id] = $s;
291
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
292
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
293 293
 			//$formats[$id] = 'aprs';
294 294
 			$globalSources[$id]['format'] = 'aprs';
295 295
 			//$aprs_connect = 0;
296 296
 			//$use_aprs = true;
297
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
297
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
298 298
 			$globalSources[$id]['format'] = 'vrstcp';
299
-    		    } elseif ($port == '10001') {
300
-        		//$formats[$id] = 'tsv';
301
-        		$globalSources[$id]['format'] = 'tsv';
302
-		    } elseif ($port == '30002') {
303
-        		//$formats[$id] = 'raw';
304
-        		$globalSources[$id]['format'] = 'raw';
305
-		    } elseif ($port == '5001') {
306
-        		//$formats[$id] = 'raw';
307
-        		$globalSources[$id]['format'] = 'flightgearmp';
308
-		    } elseif ($port == '30005') {
299
+				} elseif ($port == '10001') {
300
+				//$formats[$id] = 'tsv';
301
+				$globalSources[$id]['format'] = 'tsv';
302
+			} elseif ($port == '30002') {
303
+				//$formats[$id] = 'raw';
304
+				$globalSources[$id]['format'] = 'raw';
305
+			} elseif ($port == '5001') {
306
+				//$formats[$id] = 'raw';
307
+				$globalSources[$id]['format'] = 'flightgearmp';
308
+			} elseif ($port == '30005') {
309 309
 			// Not yet supported
310
-        		//$formats[$id] = 'beast';
311
-        		$globalSources[$id]['format'] = 'beast';
312
-		    //} else $formats[$id] = 'sbs';
313
-		    } else $globalSources[$id]['format'] = 'sbs';
314
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
310
+				//$formats[$id] = 'beast';
311
+				$globalSources[$id]['format'] = 'beast';
312
+			//} else $formats[$id] = 'sbs';
313
+			} else $globalSources[$id]['format'] = 'sbs';
314
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
315 315
 		}
316 316
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
317
-            } else {
317
+			} else {
318 318
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
319 319
 		sleep(10);
320 320
 		connect_all($hosts);
321
-    	    }
322
-        }
323
-    }
321
+			}
322
+		}
323
+	}
324 324
 }
325 325
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
326 326
 
@@ -343,9 +343,9 @@  discard block
 block discarded – undo
343 343
 //connect_all($globalSources);
344 344
 
345 345
 if (isset($globalProxy) && $globalProxy) {
346
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
346
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
347 347
 } else {
348
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
348
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
349 349
 }
350 350
 
351 351
 // APRS Configuration
@@ -354,21 +354,21 @@  discard block
 block discarded – undo
354 354
 	die;
355 355
 }
356 356
 foreach ($globalSources as $key => $source) {
357
-    if (!isset($source['format'])) {
358
-        $globalSources[$key]['format'] = 'auto';
359
-    }
360
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
361
-        unset($globalSources[$key]);
362
-    }
357
+	if (!isset($source['format'])) {
358
+		$globalSources[$key]['format'] = 'auto';
359
+	}
360
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
361
+		unset($globalSources[$key]);
362
+	}
363 363
 }
364 364
 connect_all($globalSources);
365 365
 foreach ($globalSources as $key => $source) {
366
-    if (isset($source['format']) && $source['format'] == 'aprs') {
366
+	if (isset($source['format']) && $source['format'] == 'aprs') {
367 367
 	$aprs_connect = 0;
368 368
 	$use_aprs = true;
369 369
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
370 370
 	break;
371
-    }
371
+	}
372 372
 }
373 373
 
374 374
 if ($use_aprs) {
@@ -409,133 +409,133 @@  discard block
 block discarded – undo
409 409
 
410 410
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
411 411
 while ($i > 0) {
412
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
412
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
413 413
 
414
-    if (!$globalDaemon) $i = $endtime-time();
415
-    // Delete old ATC
416
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
414
+	if (!$globalDaemon) $i = $endtime-time();
415
+	// Delete old ATC
416
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
417 417
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
418
-        $ATC->deleteOldATC();
419
-    }
418
+		$ATC->deleteOldATC();
419
+	}
420 420
     
421
-    if (count($last_exec) == count($globalSources)) {
421
+	if (count($last_exec) == count($globalSources)) {
422 422
 	$max = $globalMinFetch;
423 423
 	foreach ($last_exec as $last) {
424
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
424
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
425 425
 	}
426 426
 	if ($max < $globalMinFetch) {
427
-	    if ($globalDebug) echo 'Sleeping...'."\n";
428
-	    sleep($globalMinFetch-$max+2);
427
+		if ($globalDebug) echo 'Sleeping...'."\n";
428
+		sleep($globalMinFetch-$max+2);
429
+	}
429 430
 	}
430
-    }
431 431
 
432 432
     
433
-    //foreach ($formats as $id => $value) {
434
-    foreach ($globalSources as $id => $value) {
433
+	//foreach ($formats as $id => $value) {
434
+	foreach ($globalSources as $id => $value) {
435 435
 	date_default_timezone_set('UTC');
436 436
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
437 437
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
438 438
 	if ($value['format'] === 'deltadbtxt' && 
439
-	    (
439
+		(
440 440
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
441 441
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
442
-	    )
442
+		)
443 443
 	) {
444
-	    //$buffer = $Common->getData($hosts[$id]);
445
-	    $buffer = $Common->getData($value['host']);
446
-	    if ($buffer != '') $reset = 0;
447
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
448
-	    $buffer = explode('\n',$buffer);
449
-	    foreach ($buffer as $line) {
450
-    		if ($line != '' && count($line) > 7) {
451
-    		    $line = explode(',', $line);
452
-	            $data = array();
453
-	            $data['hex'] = $line[1]; // hex
454
-	            $data['ident'] = $line[2]; // ident
455
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
456
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
457
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
458
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
459
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
460
-	            $data['verticalrate'] = ''; // vertical rate
461
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
462
-	            $data['emergency'] = ''; // emergency
463
-		    $data['datetime'] = date('Y-m-d H:i:s');
464
-		    $data['format_source'] = 'deltadbtxt';
465
-    		    $data['id_source'] = $id_source;
466
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
467
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
468
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
469
-    		    $SI->add($data);
470
-		    unset($data);
471
-    		}
472
-    	    }
473
-    	    $last_exec[$id]['last'] = time();
444
+		//$buffer = $Common->getData($hosts[$id]);
445
+		$buffer = $Common->getData($value['host']);
446
+		if ($buffer != '') $reset = 0;
447
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
448
+		$buffer = explode('\n',$buffer);
449
+		foreach ($buffer as $line) {
450
+			if ($line != '' && count($line) > 7) {
451
+				$line = explode(',', $line);
452
+				$data = array();
453
+				$data['hex'] = $line[1]; // hex
454
+				$data['ident'] = $line[2]; // ident
455
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
456
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
457
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
458
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
459
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
460
+				$data['verticalrate'] = ''; // vertical rate
461
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
462
+				$data['emergency'] = ''; // emergency
463
+			$data['datetime'] = date('Y-m-d H:i:s');
464
+			$data['format_source'] = 'deltadbtxt';
465
+				$data['id_source'] = $id_source;
466
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
467
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
468
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
469
+				$SI->add($data);
470
+			unset($data);
471
+			}
472
+			}
473
+			$last_exec[$id]['last'] = time();
474 474
 	} elseif ($value['format'] === 'aisnmeatxt' && 
475
-	    (
475
+		(
476 476
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
477 477
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
478
-	    )
478
+		)
479 479
 	) {
480
-	    date_default_timezone_set('CET');
481
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
482
-	    date_default_timezone_set('UTC');
483
-	    if ($buffer != '') $reset = 0;
484
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
485
-	    $buffer = explode('\n',$buffer);
486
-	    foreach ($buffer as $line) {
480
+		date_default_timezone_set('CET');
481
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
482
+		date_default_timezone_set('UTC');
483
+		if ($buffer != '') $reset = 0;
484
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
485
+		$buffer = explode('\n',$buffer);
486
+		foreach ($buffer as $line) {
487 487
 		if ($line != '') {
488
-		    //echo "'".$line."'\n";
489
-		    $add = false;
490
-		    $ais_data = $AIS->parse_line(trim($line));
491
-		    $data = array();
492
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
493
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
494
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
495
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
496
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
497
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
498
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
499
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
500
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
501
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
502
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
503
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
504
-		    if (isset($ais_data['timestamp'])) {
488
+			//echo "'".$line."'\n";
489
+			$add = false;
490
+			$ais_data = $AIS->parse_line(trim($line));
491
+			$data = array();
492
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
493
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
494
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
495
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
496
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
497
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
498
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
499
+			if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
500
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
501
+			if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
502
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
503
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
504
+			if (isset($ais_data['timestamp'])) {
505 505
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
506 506
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
507
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
508
-			    $add = true;
507
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
508
+				$add = true;
509 509
 			}
510
-		    } else {
510
+			} else {
511 511
 			$data['datetime'] = date('Y-m-d H:i:s');
512 512
 			$add = true;
513
-		    }
514
-		    $data['format_source'] = 'aisnmeatxt';
515
-    		    $data['id_source'] = $id_source;
516
-		    //print_r($data);
517
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
518
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
519
-		    unset($data);
513
+			}
514
+			$data['format_source'] = 'aisnmeatxt';
515
+				$data['id_source'] = $id_source;
516
+			//print_r($data);
517
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
518
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
519
+			unset($data);
520 520
 		}
521
-    	    }
522
-    	    $last_exec[$id]['last'] = time();
521
+			}
522
+			$last_exec[$id]['last'] = time();
523 523
 	} elseif ($value['format'] === 'aisnmeahttp') {
524
-	    $arr = $httpfeeds;
525
-	    $w = $e = null;
524
+		$arr = $httpfeeds;
525
+		$w = $e = null;
526 526
 	    
527
-	    if (isset($arr[$id])) {
527
+		if (isset($arr[$id])) {
528 528
 		$nn = stream_select($arr,$w,$e,$timeout);
529 529
 		if ($nn > 0) {
530
-		    foreach ($httpfeeds as $feed) {
530
+			foreach ($httpfeeds as $feed) {
531 531
 			$buffer = stream_get_line($feed,2000,"\n");
532 532
 			if ($buffer === FALSE) {
533
-			    connect_all($globalSources);
533
+				connect_all($globalSources);
534 534
 			}
535 535
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
536 536
 			$buffer = explode('\n',$buffer);
537 537
 			foreach ($buffer as $line) {
538
-			    if ($line != '') {
538
+				if ($line != '') {
539 539
 				$ais_data = $AIS->parse_line(trim($line));
540 540
 				$data = array();
541 541
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -553,117 +553,117 @@  discard block
 block discarded – undo
553 553
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
554 554
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
555 555
 				if (isset($ais_data['timestamp'])) {
556
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
556
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
557 557
 				} else {
558
-				    $data['datetime'] = date('Y-m-d H:i:s');
558
+					$data['datetime'] = date('Y-m-d H:i:s');
559 559
 				}
560 560
 				$data['format_source'] = 'aisnmeahttp';
561 561
 				$data['id_source'] = $id_source;
562 562
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
563 563
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
564 564
 				unset($data);
565
-			    }
565
+				}
566
+			}
566 567
 			}
567
-		    }
568 568
 		} else {
569
-		    $format = $value['format'];
570
-		    if (isset($tt[$format])) $tt[$format]++;
571
-		    else $tt[$format] = 0;
572
-		    if ($tt[$format] > 30) {
569
+			$format = $value['format'];
570
+			if (isset($tt[$format])) $tt[$format]++;
571
+			else $tt[$format] = 0;
572
+			if ($tt[$format] > 30) {
573 573
 			if ($globalDebug) echo 'Reconnect...'."\n";
574 574
 			sleep(2);
575 575
 			//$sourceeen[] = $value;
576 576
 			//connect_all($sourceeen);
577 577
 			//$sourceeen = array();
578 578
 			connect_all($globalSources);
579
-		    }
579
+			}
580
+		}
580 581
 		}
581
-	    }
582 582
 	} elseif ($value['format'] === 'myshiptracking' && 
583
-	    (
583
+		(
584 584
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
585 585
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
586
-	    )
586
+		)
587 587
 	) {
588
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
589
-	    if ($buffer != '') {
588
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
589
+		if ($buffer != '') {
590 590
 		//echo $buffer;
591 591
 		$all_data = json_decode($buffer,true);
592 592
 		//print_r($all_data);
593 593
 		if (isset($all_data[0]['DATA'])) {
594
-		    foreach ($all_data[0]['DATA'] as $line) {
594
+			foreach ($all_data[0]['DATA'] as $line) {
595 595
 			if ($line != '') {
596
-			    $data = array();
597
-			    $data['ident'] = $line['NAME'];
598
-			    $data['mmsi'] = $line['MMSI'];
599
-			    if (strlen($data['mmsi']) > 9) {
596
+				$data = array();
597
+				$data['ident'] = $line['NAME'];
598
+				$data['mmsi'] = $line['MMSI'];
599
+				if (strlen($data['mmsi']) > 9) {
600 600
 				$data['mmsi'] = substr($data['mmsi'],-9);
601
-			    }
602
-			    $data['speed'] = $line['SOG'];
603
-			    $data['heading'] = $line['COG'];
604
-			    $data['latitude'] = $line['LAT'];
605
-			    $data['longitude'] = $line['LNG'];
606
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
607
-			    //$data['type_id'] = $line['TYPE'];
608
-			    $data['imo'] = $line['IMO'];
609
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
610
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
611
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
612
-			    $data['format_source'] = 'myshiptracking';
613
-			    $data['id_source'] = $id_source;
614
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
615
-			    $MI->add($data);
616
-			    unset($data);
601
+				}
602
+				$data['speed'] = $line['SOG'];
603
+				$data['heading'] = $line['COG'];
604
+				$data['latitude'] = $line['LAT'];
605
+				$data['longitude'] = $line['LNG'];
606
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
607
+				//$data['type_id'] = $line['TYPE'];
608
+				$data['imo'] = $line['IMO'];
609
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
610
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
611
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
612
+				$data['format_source'] = 'myshiptracking';
613
+				$data['id_source'] = $id_source;
614
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
615
+				$MI->add($data);
616
+				unset($data);
617 617
 			}
618
-		    }
618
+			}
619
+		}
619 620
 		}
620
-	    }
621
-	    $last_exec[$id]['last'] = time();
621
+		$last_exec[$id]['last'] = time();
622 622
 	} elseif ($value['format'] === 'boatbeaconapp' && 
623
-	    (
623
+		(
624 624
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
625 625
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
626
-	    )
626
+		)
627 627
 	) {
628
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
629
-	    if ($buffer != '') {
628
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
629
+		if ($buffer != '') {
630 630
 		$all_data = json_decode($buffer,true);
631 631
 		if (isset($all_data[0]['mmsi'])) {
632
-		    foreach ($all_data as $line) {
632
+			foreach ($all_data as $line) {
633 633
 			if ($line != '') {
634
-			    $data = array();
635
-			    $data['ident'] = $line['shipname'];
636
-			    $data['callsign'] = $line['callsign'];
637
-			    $data['mmsi'] = substr($line['mmsi'],-9);
638
-			    $data['speed'] = $line['sog'];
639
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
640
-			    $data['latitude'] = $line['latitude'];
641
-			    $data['longitude'] = $line['longitude'];
642
-			    $data['type_id'] = $line['shiptype'];
643
-			    $data['arrival_code'] = $line['destination'];
644
-			    $data['datetime'] = $line['time'];
645
-			    $data['format_source'] = 'boatbeaconapp';
646
-			    $data['id_source'] = $id_source;
647
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
648
-			    $MI->add($data);
649
-			    unset($data);
634
+				$data = array();
635
+				$data['ident'] = $line['shipname'];
636
+				$data['callsign'] = $line['callsign'];
637
+				$data['mmsi'] = substr($line['mmsi'],-9);
638
+				$data['speed'] = $line['sog'];
639
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
640
+				$data['latitude'] = $line['latitude'];
641
+				$data['longitude'] = $line['longitude'];
642
+				$data['type_id'] = $line['shiptype'];
643
+				$data['arrival_code'] = $line['destination'];
644
+				$data['datetime'] = $line['time'];
645
+				$data['format_source'] = 'boatbeaconapp';
646
+				$data['id_source'] = $id_source;
647
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
648
+				$MI->add($data);
649
+				unset($data);
650
+			}
650 651
 			}
651
-		    }
652 652
 		}
653 653
 		
654
-	    }
655
-    	    $last_exec[$id]['last'] = time();
654
+		}
655
+			$last_exec[$id]['last'] = time();
656 656
 	} elseif ($value['format'] === 'boatnerd' && 
657
-	    (
657
+		(
658 658
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
659 659
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
660
-	    )
660
+		)
661 661
 	) {
662
-	    $buffer = $Common->getData($value['host']);
663
-	    if ($buffer != '') {
662
+		$buffer = $Common->getData($value['host']);
663
+		if ($buffer != '') {
664 664
 		$all_data = json_decode($buffer,true);
665 665
 		if (isset($all_data['features'][0]['id'])) {
666
-		    foreach ($all_data['features'] as $line) {
666
+			foreach ($all_data['features'] as $line) {
667 667
 			print_r($line);
668 668
 			$data = array();
669 669
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -683,80 +683,80 @@  discard block
 block discarded – undo
683 683
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
684 684
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
685 685
 			unset($data);
686
-		    }
686
+			}
687 687
 		}
688 688
 		
689
-	    }
690
-    	    $last_exec[$id]['last'] = time();
689
+		}
690
+			$last_exec[$id]['last'] = time();
691 691
 	} elseif ($value['format'] === 'shipplotter' && 
692
-	    (
692
+		(
693 693
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
694 694
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
695
-	    )
695
+		)
696 696
 	) {
697
-	    echo 'download...';
698
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
699
-	    echo 'done !'."\n";
700
-	    // FIXME: Need more work
701
-	    if ($buffer != '') $reset = 0;
702
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
703
-	    $buffer = explode('\n',$buffer);
704
-	    foreach ($buffer as $line) {
697
+		echo 'download...';
698
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
699
+		echo 'done !'."\n";
700
+		// FIXME: Need more work
701
+		if ($buffer != '') $reset = 0;
702
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
703
+		$buffer = explode('\n',$buffer);
704
+		foreach ($buffer as $line) {
705 705
 		if ($line != '') {
706
-		    $data = array();
707
-		    echo $line."\n";
708
-		    $data['mmsi'] = (int)substr($line,0,9);
709
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
710
-		    $data['status_id'] = substr($line,21,2);
711
-		    $data['type_id'] = substr($line,24,3);
712
-		    $data['latitude'] = substr($line,29,9);
713
-		    $data['longitude'] = substr($line,41,9);
714
-		    $data['speed'] = round(substr($line,51,5));
715
-		    //$data['course'] = substr($line,57,5);
716
-		    $data['heading'] = round(substr($line,63,3));
717
-		    //$data['draft'] = substr($line,67,4);
718
-		    //$data['length'] = substr($line,72,3);
719
-		    //$data['beam'] = substr($line,76,2);
720
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
721
-		    //$data['callsign'] = trim(substr($line,100,7);
722
-		    $data['arrival_code'] = substr($line,108,20);
723
-		    //$data['etaDate'] = substr($line,129,5);
724
-		    //$data['etaTime'] = substr($line,135,5);
725
-		    $data['format_source'] = 'shipplotter';
726
-    		    $data['id_source'] = $id_source;
727
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
728
-		    //print_r($data);
729
-		    echo 'Add...'."\n";
730
-		    $MI->add($data);
731
-		    unset($data);
706
+			$data = array();
707
+			echo $line."\n";
708
+			$data['mmsi'] = (int)substr($line,0,9);
709
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
710
+			$data['status_id'] = substr($line,21,2);
711
+			$data['type_id'] = substr($line,24,3);
712
+			$data['latitude'] = substr($line,29,9);
713
+			$data['longitude'] = substr($line,41,9);
714
+			$data['speed'] = round(substr($line,51,5));
715
+			//$data['course'] = substr($line,57,5);
716
+			$data['heading'] = round(substr($line,63,3));
717
+			//$data['draft'] = substr($line,67,4);
718
+			//$data['length'] = substr($line,72,3);
719
+			//$data['beam'] = substr($line,76,2);
720
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
721
+			//$data['callsign'] = trim(substr($line,100,7);
722
+			$data['arrival_code'] = substr($line,108,20);
723
+			//$data['etaDate'] = substr($line,129,5);
724
+			//$data['etaTime'] = substr($line,135,5);
725
+			$data['format_source'] = 'shipplotter';
726
+				$data['id_source'] = $id_source;
727
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
728
+			//print_r($data);
729
+			echo 'Add...'."\n";
730
+			$MI->add($data);
731
+			unset($data);
732 732
 		}
733
-    	    }
734
-    	    $last_exec[$id]['last'] = time();
733
+			}
734
+			$last_exec[$id]['last'] = time();
735 735
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
736 736
 	} elseif (
737
-	    (
737
+		(
738 738
 		$value['format'] === 'whazzup' && 
739 739
 		(
740
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
741
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
740
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
741
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
742 742
 		)
743
-	    ) || (
743
+		) || (
744 744
 		$value['format'] === 'vatsimtxt' && 
745 745
 		(
746
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
747
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
746
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
747
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
748
+		)
748 749
 		)
749
-	    )
750 750
 	) {
751
-	    //$buffer = $Common->getData($hosts[$id]);
752
-	    $buffer = $Common->getData($value['host']);
753
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
754
-	    $buffer = explode('\n',$buffer);
755
-	    $reset = 0;
756
-	    foreach ($buffer as $line) {
757
-    		if ($line != '') {
758
-    		    $line = explode(':', $line);
759
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
751
+		//$buffer = $Common->getData($hosts[$id]);
752
+		$buffer = $Common->getData($value['host']);
753
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
754
+		$buffer = explode('\n',$buffer);
755
+		$reset = 0;
756
+		foreach ($buffer as $line) {
757
+			if ($line != '') {
758
+				$line = explode(':', $line);
759
+				if (count($line) > 30 && $line[0] != 'callsign') {
760 760
 			$data = array();
761 761
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
762 762
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -769,37 +769,37 @@  discard block
 block discarded – undo
769 769
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
770 770
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
771 771
 			$data['latitude'] = $line[5]; // lat
772
-	        	$data['longitude'] = $line[6]; // long
773
-	        	$data['verticalrate'] = ''; // vertical rate
774
-	        	$data['squawk'] = ''; // squawk
775
-	        	$data['emergency'] = ''; // emergency
776
-	        	$data['waypoints'] = $line[30];
772
+				$data['longitude'] = $line[6]; // long
773
+				$data['verticalrate'] = ''; // vertical rate
774
+				$data['squawk'] = ''; // squawk
775
+				$data['emergency'] = ''; // emergency
776
+				$data['waypoints'] = $line[30];
777 777
 			$data['datetime'] = date('Y-m-d H:i:s');
778 778
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
779 779
 			//if (isset($line[37])) $data['last_update'] = $line[37];
780
-		        $data['departure_airport_icao'] = $line[11];
781
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
782
-		        $data['arrival_airport_icao'] = $line[13];
780
+				$data['departure_airport_icao'] = $line[11];
781
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
782
+				$data['arrival_airport_icao'] = $line[13];
783 783
 			$data['frequency'] = $line[4];
784 784
 			$data['type'] = $line[18];
785 785
 			$data['range'] = $line[19];
786 786
 			if (isset($line[35])) $data['info'] = $line[35];
787
-    			$data['id_source'] = $id_source;
788
-	    		//$data['arrival_airport_time'] = ;
789
-	    		if ($line[9] != '') {
790
-	    		    $aircraft_data = explode('/',$line[9]);
791
-	    		    if (isset($aircraft_data[1])) {
792
-	    			$data['aircraft_icao'] = $aircraft_data[1];
793
-	    		    }
794
-        		}
795
-	    		/*
787
+				$data['id_source'] = $id_source;
788
+				//$data['arrival_airport_time'] = ;
789
+				if ($line[9] != '') {
790
+					$aircraft_data = explode('/',$line[9]);
791
+					if (isset($aircraft_data[1])) {
792
+					$data['aircraft_icao'] = $aircraft_data[1];
793
+					}
794
+				}
795
+				/*
796 796
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
797 797
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
798 798
 	    		*/
799
-	    		$data['format_source'] = $value['format'];
799
+				$data['format_source'] = $value['format'];
800 800
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
801 801
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
802
-    			if ($line[3] === 'PILOT') $SI->add($data);
802
+				if ($line[3] === 'PILOT') $SI->add($data);
803 803
 			elseif ($line[3] === 'ATC') {
804 804
 				//print_r($data);
805 805
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -820,21 +820,21 @@  discard block
 block discarded – undo
820 820
 					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
821 821
 				}
822 822
 			}
823
-    			unset($data);
824
-    		    }
825
-    		}
826
-    	    }
827
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
828
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
829
-    	    $last_exec[$id]['last'] = time();
830
-    	} elseif ($value['format'] === 'airwhere' && 
831
-    	    (
832
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
833
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
834
-    	    )
835
-    	) {
836
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
837
-	    if ($buffer != '') {
823
+				unset($data);
824
+				}
825
+			}
826
+			}
827
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
828
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
829
+			$last_exec[$id]['last'] = time();
830
+		} elseif ($value['format'] === 'airwhere' && 
831
+			(
832
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
833
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
834
+			)
835
+		) {
836
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
837
+		if ($buffer != '') {
838 838
 		$all_data = simplexml_load_string($buffer);
839 839
 		foreach($all_data->children() as $childdata) {
840 840
 			$data = array();
@@ -856,10 +856,10 @@  discard block
 block discarded – undo
856 856
 			$SI->add($data);
857 857
 			unset($data);
858 858
 		}
859
-	    }
860
-	    $Source->deleteOldLocationByType('gs');
861
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
862
-	    if ($buffer != '') {
859
+		}
860
+		$Source->deleteOldLocationByType('gs');
861
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
862
+		if ($buffer != '') {
863 863
 		$all_data = simplexml_load_string($buffer);
864 864
 		foreach($all_data->children() as $childdata) {
865 865
 			$data = array();
@@ -877,8 +877,8 @@  discard block
 block discarded – undo
877 877
 			}
878 878
 			unset($data);
879 879
 		}
880
-	    }
881
-	    $last_exec[$id]['last'] = time();
880
+		}
881
+		$last_exec[$id]['last'] = time();
882 882
 	/*
883 883
 	} if ($value['format'] === 'aircraftlistjson') {
884 884
 	    print_r($globalSources);
@@ -886,17 +886,17 @@  discard block
 block discarded – undo
886 886
 	    echo $globalMinFetch;
887 887
 	*/
888 888
 	} elseif ($value['format'] === 'aircraftlistjson' && 
889
-	    (
889
+		(
890 890
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
891 891
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
892
-	    )
892
+		)
893 893
 	) {
894
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
895
-	    if ($buffer != '') {
896
-	        $all_data = json_decode($buffer,true);
894
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
895
+		if ($buffer != '') {
896
+			$all_data = json_decode($buffer,true);
897 897
 		if (isset($all_data['acList'])) {
898
-		    $reset = 0;
899
-		    foreach ($all_data['acList'] as $line) {
898
+			$reset = 0;
899
+			foreach ($all_data['acList'] as $line) {
900 900
 			$data = array();
901 901
 			$data['hex'] = $line['Icao']; // hex
902 902
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -919,10 +919,10 @@  discard block
 block discarded – undo
919 919
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
920 920
 			if (isset($data['latitude'])) $SI->add($data);
921 921
 			unset($data);
922
-		    }
922
+			}
923 923
 		} elseif (is_array($all_data)) {
924
-		    $reset = 0;
925
-		    foreach ($all_data as $line) {
924
+			$reset = 0;
925
+			foreach ($all_data as $line) {
926 926
 			$data = array();
927 927
 			$data['hex'] = $line['hex']; // hex
928 928
 			$data['ident'] = $line['flight']; // ident
@@ -942,291 +942,291 @@  discard block
 block discarded – undo
942 942
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
943 943
 			$SI->add($data);
944 944
 			unset($data);
945
-		    }
945
+			}
946 946
 		}
947
-	    } elseif ($globalDebug) echo 'No data'."\n";
948
-    	    //$last_exec['aircraftlistjson'] = time();
949
-    	    $last_exec[$id]['last'] = time();
950
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
951
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
952
-    	    (
953
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
954
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
955
-    	    )
956
-    	) {
957
-	    $buffer = $Common->getData($value['host']);
958
-	    $all_data = json_decode($buffer,true);
959
-	    if (isset($all_data['planes'])) {
947
+		} elseif ($globalDebug) echo 'No data'."\n";
948
+			//$last_exec['aircraftlistjson'] = time();
949
+			$last_exec[$id]['last'] = time();
950
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
951
+		} elseif ($value['format'] === 'planeupdatefaa' && 
952
+			(
953
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
954
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
955
+			)
956
+		) {
957
+		$buffer = $Common->getData($value['host']);
958
+		$all_data = json_decode($buffer,true);
959
+		if (isset($all_data['planes'])) {
960 960
 		$reset = 0;
961 961
 		foreach ($all_data['planes'] as $key => $line) {
962
-		    $data = array();
963
-		    $data['hex'] = $key; // hex
964
-		    $data['ident'] = $line[3]; // ident
965
-		    $data['altitude'] = $line[6]; // altitude
966
-		    $data['speed'] = $line[8]; // speed
967
-		    $data['heading'] = $line[7]; // heading
968
-		    $data['latitude'] = $line[4]; // lat
969
-		    $data['longitude'] = $line[5]; // long
970
-		    //$data['verticalrate'] = $line[]; // verticale rate
971
-		    $data['squawk'] = $line[10]; // squawk
972
-		    $data['emergency'] = ''; // emergency
973
-		    $data['registration'] = $line[2];
974
-		    $data['aircraft_icao'] = $line[0];
975
-		    $deparr = explode('-',$line[1]);
976
-		    if (count($deparr) === 2) {
962
+			$data = array();
963
+			$data['hex'] = $key; // hex
964
+			$data['ident'] = $line[3]; // ident
965
+			$data['altitude'] = $line[6]; // altitude
966
+			$data['speed'] = $line[8]; // speed
967
+			$data['heading'] = $line[7]; // heading
968
+			$data['latitude'] = $line[4]; // lat
969
+			$data['longitude'] = $line[5]; // long
970
+			//$data['verticalrate'] = $line[]; // verticale rate
971
+			$data['squawk'] = $line[10]; // squawk
972
+			$data['emergency'] = ''; // emergency
973
+			$data['registration'] = $line[2];
974
+			$data['aircraft_icao'] = $line[0];
975
+			$deparr = explode('-',$line[1]);
976
+			if (count($deparr) === 2) {
977 977
 			$data['departure_airport_icao'] = $deparr[0];
978 978
 			$data['arrival_airport_icao'] = $deparr[1];
979
-		    }
980
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
981
-	    	    $data['format_source'] = 'planeupdatefaa';
982
-    		    $data['id_source'] = $id_source;
983
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
984
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
985
-		    $SI->add($data);
986
-		    unset($data);
979
+			}
980
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
981
+				$data['format_source'] = 'planeupdatefaa';
982
+				$data['id_source'] = $id_source;
983
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
984
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
985
+			$SI->add($data);
986
+			unset($data);
987 987
 		}
988
-	    }
989
-	    //$last_exec['planeupdatefaa'] = time();
990
-	    $last_exec[$id]['last'] = time();
988
+		}
989
+		//$last_exec['planeupdatefaa'] = time();
990
+		$last_exec[$id]['last'] = time();
991 991
 	} elseif ($value['format'] === 'opensky' && 
992
-	    (
992
+		(
993 993
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
994 994
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
995
-	    )
995
+		)
996 996
 	) {
997
-	    $buffer = $Common->getData($value['host']);
998
-	    $all_data = json_decode($buffer,true);
999
-	    if (isset($all_data['states'])) {
997
+		$buffer = $Common->getData($value['host']);
998
+		$all_data = json_decode($buffer,true);
999
+		if (isset($all_data['states'])) {
1000 1000
 		$reset = 0;
1001 1001
 		foreach ($all_data['states'] as $key => $line) {
1002
-		    $data = array();
1003
-		    $data['hex'] = $line[0]; // hex
1004
-		    $data['ident'] = trim($line[1]); // ident
1005
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1006
-		    $data['speed'] = round($line[9]*1.94384); // speed
1007
-		    $data['heading'] = round($line[10]); // heading
1008
-		    $data['latitude'] = $line[6]; // lat
1009
-		    $data['longitude'] = $line[5]; // long
1010
-		    $data['verticalrate'] = $line[11]; // verticale rate
1011
-		    //$data['squawk'] = $line[10]; // squawk
1012
-		    //$data['emergency'] = ''; // emergency
1013
-		    //$data['registration'] = $line[2];
1014
-		    //$data['aircraft_icao'] = $line[0];
1015
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1016
-		    $data['format_source'] = 'opensky';
1017
-		    $data['id_source'] = $id_source;
1018
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1019
-		    $SI->add($data);
1020
-		    unset($data);
1002
+			$data = array();
1003
+			$data['hex'] = $line[0]; // hex
1004
+			$data['ident'] = trim($line[1]); // ident
1005
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1006
+			$data['speed'] = round($line[9]*1.94384); // speed
1007
+			$data['heading'] = round($line[10]); // heading
1008
+			$data['latitude'] = $line[6]; // lat
1009
+			$data['longitude'] = $line[5]; // long
1010
+			$data['verticalrate'] = $line[11]; // verticale rate
1011
+			//$data['squawk'] = $line[10]; // squawk
1012
+			//$data['emergency'] = ''; // emergency
1013
+			//$data['registration'] = $line[2];
1014
+			//$data['aircraft_icao'] = $line[0];
1015
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1016
+			$data['format_source'] = 'opensky';
1017
+			$data['id_source'] = $id_source;
1018
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1019
+			$SI->add($data);
1020
+			unset($data);
1021
+		}
1021 1022
 		}
1022
-	    }
1023
-	    //$last_exec['planeupdatefaa'] = time();
1024
-	    $last_exec[$id]['last'] = time();
1023
+		//$last_exec['planeupdatefaa'] = time();
1024
+		$last_exec[$id]['last'] = time();
1025 1025
 	} elseif ($value['format'] === 'aircraftjson' && 
1026
-	    (
1026
+		(
1027 1027
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1028 1028
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1029
-	    )
1029
+		)
1030 1030
 	) {
1031
-	    $buffer = $Common->getData($value['host']);
1032
-	    $all_data = json_decode($buffer,true);
1033
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1031
+		$buffer = $Common->getData($value['host']);
1032
+		$all_data = json_decode($buffer,true);
1033
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1034 1034
 		$reset = 0;
1035 1035
 		foreach ($all_data['aircraft'] as $key => $line) {
1036
-		    $data = array();
1037
-		    // add support for ground vehicule with ~ in front of hex
1038
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1039
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1040
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1041
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1042
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1043
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1044
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1045
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1046
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1047
-		    //$data['emergency'] = ''; // emergency
1048
-		    //$data['registration'] = $line[2];
1049
-		    //$data['aircraft_icao'] = $line[0];
1050
-		    $data['datetime'] = date('Y-m-d H:i:s');
1051
-		    $data['format_source'] = 'aircraftjson';
1052
-		    $data['id_source'] = $id_source;
1053
-		    if (isset($value['name']) && $value['name'] != '') {
1054
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1055
-			    else $data['source_name'] = $value['name'];
1056
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1057
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1058
-		    $SI->add($data);
1059
-		    unset($data);
1036
+			$data = array();
1037
+			// add support for ground vehicule with ~ in front of hex
1038
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1039
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1040
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1041
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1042
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1043
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1044
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1045
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1046
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1047
+			//$data['emergency'] = ''; // emergency
1048
+			//$data['registration'] = $line[2];
1049
+			//$data['aircraft_icao'] = $line[0];
1050
+			$data['datetime'] = date('Y-m-d H:i:s');
1051
+			$data['format_source'] = 'aircraftjson';
1052
+			$data['id_source'] = $id_source;
1053
+			if (isset($value['name']) && $value['name'] != '') {
1054
+				if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1055
+				else $data['source_name'] = $value['name'];
1056
+			} elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1057
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1058
+			$SI->add($data);
1059
+			unset($data);
1060 1060
 		}
1061
-	    }
1062
-	    //$last_exec['planeupdatefaa'] = time();
1063
-	    $last_exec[$id]['last'] = time();
1061
+		}
1062
+		//$last_exec['planeupdatefaa'] = time();
1063
+		$last_exec[$id]['last'] = time();
1064 1064
 	} elseif ($value['format'] === 'planefinderclient' && 
1065
-	    (
1065
+		(
1066 1066
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1067 1067
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1068
-	    )
1068
+		)
1069 1069
 	) {
1070
-	    $buffer = $Common->getData($value['host']);
1071
-	    $all_data = json_decode($buffer,true);
1072
-	    if (isset($all_data['aircraft'])) {
1070
+		$buffer = $Common->getData($value['host']);
1071
+		$all_data = json_decode($buffer,true);
1072
+		if (isset($all_data['aircraft'])) {
1073 1073
 		$reset = 0;
1074 1074
 		foreach ($all_data['aircraft'] as $key => $line) {
1075
-		    $data = array();
1076
-		    $data['hex'] = $key; // hex
1077
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1078
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1079
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1080
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1081
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1082
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1083
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1084
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1085
-		    //$data['emergency'] = ''; // emergency
1086
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1087
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1088
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1089
-		    $data['format_source'] = 'planefinderclient';
1090
-		    $data['id_source'] = $id_source;
1091
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1092
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1093
-		    $SI->add($data);
1094
-		    unset($data);
1075
+			$data = array();
1076
+			$data['hex'] = $key; // hex
1077
+			if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1078
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1079
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1080
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1081
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1082
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1083
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1084
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1085
+			//$data['emergency'] = ''; // emergency
1086
+			if (isset($line['reg'])) $data['registration'] = $line['reg'];
1087
+			if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1088
+			$data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1089
+			$data['format_source'] = 'planefinderclient';
1090
+			$data['id_source'] = $id_source;
1091
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1092
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1093
+			$SI->add($data);
1094
+			unset($data);
1095 1095
 		}
1096
-	    }
1097
-	    $last_exec[$id]['last'] = time();
1096
+		}
1097
+		$last_exec[$id]['last'] = time();
1098 1098
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1099 1099
 	} elseif ($value['format'] === 'fr24json' && 
1100
-	    (
1100
+		(
1101 1101
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1102 1102
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1103
-	    )
1103
+		)
1104 1104
 	) {
1105
-	    //$buffer = $Common->getData($hosts[$id]);
1106
-	    $buffer = $Common->getData($value['host']);
1107
-	    $all_data = json_decode($buffer,true);
1108
-	    if (!empty($all_data)) $reset = 0;
1109
-	    foreach ($all_data as $key => $line) {
1105
+		//$buffer = $Common->getData($hosts[$id]);
1106
+		$buffer = $Common->getData($value['host']);
1107
+		$all_data = json_decode($buffer,true);
1108
+		if (!empty($all_data)) $reset = 0;
1109
+		foreach ($all_data as $key => $line) {
1110 1110
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1111
-		    $data = array();
1112
-		    $data['hex'] = $line[0];
1113
-		    $data['ident'] = $line[16]; //$line[13]
1114
-	    	    $data['altitude'] = $line[4]; // altitude
1115
-	    	    $data['speed'] = $line[5]; // speed
1116
-	    	    $data['heading'] = $line[3]; // heading
1117
-	    	    $data['latitude'] = $line[1]; // lat
1118
-	    	    $data['longitude'] = $line[2]; // long
1119
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1120
-	    	    $data['squawk'] = $line[6]; // squawk
1121
-	    	    $data['aircraft_icao'] = $line[8];
1122
-	    	    $data['registration'] = $line[9];
1123
-		    $data['departure_airport_iata'] = $line[11];
1124
-		    $data['arrival_airport_iata'] = $line[12];
1125
-	    	    $data['emergency'] = ''; // emergency
1126
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1127
-	    	    $data['format_source'] = 'fr24json';
1128
-    		    $data['id_source'] = $id_source;
1129
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1130
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1131
-		    $SI->add($data);
1132
-		    unset($data);
1111
+			$data = array();
1112
+			$data['hex'] = $line[0];
1113
+			$data['ident'] = $line[16]; //$line[13]
1114
+				$data['altitude'] = $line[4]; // altitude
1115
+				$data['speed'] = $line[5]; // speed
1116
+				$data['heading'] = $line[3]; // heading
1117
+				$data['latitude'] = $line[1]; // lat
1118
+				$data['longitude'] = $line[2]; // long
1119
+				$data['verticalrate'] = $line[15]; // verticale rate
1120
+				$data['squawk'] = $line[6]; // squawk
1121
+				$data['aircraft_icao'] = $line[8];
1122
+				$data['registration'] = $line[9];
1123
+			$data['departure_airport_iata'] = $line[11];
1124
+			$data['arrival_airport_iata'] = $line[12];
1125
+				$data['emergency'] = ''; // emergency
1126
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1127
+				$data['format_source'] = 'fr24json';
1128
+				$data['id_source'] = $id_source;
1129
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1130
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1131
+			$SI->add($data);
1132
+			unset($data);
1133
+		}
1133 1134
 		}
1134
-	    }
1135
-	    //$last_exec['fr24json'] = time();
1136
-	    $last_exec[$id]['last'] = time();
1135
+		//$last_exec['fr24json'] = time();
1136
+		$last_exec[$id]['last'] = time();
1137 1137
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1138 1138
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1139
-	    (
1139
+		(
1140 1140
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1141 1141
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1142
-	    )
1142
+		)
1143 1143
 	) {
1144
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1145
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1146
-	    //echo $buffer;
1147
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1148
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1149
-	    $all_data = json_decode($buffer,true);
1150
-	    if (json_last_error() != JSON_ERROR_NONE) {
1144
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1145
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1146
+		//echo $buffer;
1147
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1148
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1149
+		$all_data = json_decode($buffer,true);
1150
+		if (json_last_error() != JSON_ERROR_NONE) {
1151 1151
 		die(json_last_error_msg());
1152
-	    }
1153
-	    if (isset($all_data['mrkrs'])) {
1152
+		}
1153
+		if (isset($all_data['mrkrs'])) {
1154 1154
 		$reset = 0;
1155 1155
 		foreach ($all_data['mrkrs'] as $key => $line) {
1156
-		    if (isset($line['inf'])) {
1156
+			if (isset($line['inf'])) {
1157 1157
 			$data = array();
1158 1158
 			$data['hex'] = $line['inf']['ia'];
1159 1159
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1160
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1161
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1162
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1163
-	    		$data['latitude'] = $line['pt'][0]; // lat
1164
-	    		$data['longitude'] = $line['pt'][1]; // long
1165
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1166
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1167
-	    		//$data['aircraft_icao'] = $line[8];
1168
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1160
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1161
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1162
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1163
+				$data['latitude'] = $line['pt'][0]; // lat
1164
+				$data['longitude'] = $line['pt'][1]; // long
1165
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1166
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1167
+				//$data['aircraft_icao'] = $line[8];
1168
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1169 1169
 			//$data['departure_airport_iata'] = $line[11];
1170 1170
 			//$data['arrival_airport_iata'] = $line[12];
1171
-	    		//$data['emergency'] = ''; // emergency
1171
+				//$data['emergency'] = ''; // emergency
1172 1172
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1173
-	    		$data['format_source'] = 'radarvirtueljson';
1174
-    			$data['id_source'] = $id_source;
1173
+				$data['format_source'] = 'radarvirtueljson';
1174
+				$data['id_source'] = $id_source;
1175 1175
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1176 1176
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1177 1177
 			$SI->add($data);
1178 1178
 			unset($data);
1179
-		    }
1179
+			}
1180 1180
 		}
1181
-	    }
1182
-	    //$last_exec['radarvirtueljson'] = time();
1183
-	    $last_exec[$id]['last'] = time();
1181
+		}
1182
+		//$last_exec['radarvirtueljson'] = time();
1183
+		$last_exec[$id]['last'] = time();
1184 1184
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1185 1185
 	} elseif ($value['format'] === 'pirepsjson' && 
1186
-	    (
1186
+		(
1187 1187
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1188 1188
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1189
-	    )
1189
+		)
1190 1190
 	) {
1191
-	    //$buffer = $Common->getData($hosts[$id]);
1192
-	    $buffer = $Common->getData($value['host'].'?'.time());
1193
-	    $all_data = json_decode(utf8_encode($buffer),true);
1191
+		//$buffer = $Common->getData($hosts[$id]);
1192
+		$buffer = $Common->getData($value['host'].'?'.time());
1193
+		$all_data = json_decode(utf8_encode($buffer),true);
1194 1194
 	    
1195
-	    if (isset($all_data['pireps'])) {
1195
+		if (isset($all_data['pireps'])) {
1196 1196
 		$reset = 0;
1197
-	        foreach ($all_data['pireps'] as $line) {
1198
-		    $data = array();
1199
-		    $data['id'] = $line['id'];
1200
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1201
-		    $data['ident'] = $line['callsign']; // ident
1202
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1203
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1204
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1205
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1206
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1207
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1208
-		    $data['latitude'] = $line['lat']; // lat
1209
-		    $data['longitude'] = $line['lon']; // long
1210
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1211
-		    //$data['squawk'] = $line['squawk']; // squawk
1212
-		    //$data['emergency'] = ''; // emergency
1213
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1214
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1215
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1216
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1217
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1218
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1219
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1220
-		    else $data['info'] = '';
1221
-		    $data['format_source'] = 'pireps';
1222
-    		    $data['id_source'] = $id_source;
1223
-		    $data['datetime'] = date('Y-m-d H:i:s');
1224
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1225
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1226
-		    if ($line['icon'] === 'plane') {
1197
+			foreach ($all_data['pireps'] as $line) {
1198
+			$data = array();
1199
+			$data['id'] = $line['id'];
1200
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1201
+			$data['ident'] = $line['callsign']; // ident
1202
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1203
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1204
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1205
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1206
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1207
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1208
+			$data['latitude'] = $line['lat']; // lat
1209
+			$data['longitude'] = $line['lon']; // long
1210
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1211
+			//$data['squawk'] = $line['squawk']; // squawk
1212
+			//$data['emergency'] = ''; // emergency
1213
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1214
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1215
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1216
+			//$data['arrival_airport_time'] = $line['arrtime'];
1217
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1218
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1219
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1220
+			else $data['info'] = '';
1221
+			$data['format_source'] = 'pireps';
1222
+				$data['id_source'] = $id_source;
1223
+			$data['datetime'] = date('Y-m-d H:i:s');
1224
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1225
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1226
+			if ($line['icon'] === 'plane') {
1227 1227
 			$SI->add($data);
1228
-		    //    print_r($data);
1229
-    		    } elseif ($line['icon'] === 'ct') {
1228
+			//    print_r($data);
1229
+				} elseif ($line['icon'] === 'ct') {
1230 1230
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1231 1231
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1232 1232
 			$typec = substr($data['ident'],-3);
@@ -1241,209 +1241,209 @@  discard block
 block discarded – undo
1241 1241
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1242 1242
 			else $data['type'] = 'Observer';
1243 1243
 			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1244
-		    }
1245
-		    unset($data);
1244
+			}
1245
+			unset($data);
1246 1246
 		}
1247
-	    }
1248
-	    //$last_exec['pirepsjson'] = time();
1249
-	    $last_exec[$id]['last'] = time();
1247
+		}
1248
+		//$last_exec['pirepsjson'] = time();
1249
+		$last_exec[$id]['last'] = time();
1250 1250
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1251 1251
 	} elseif ($value['format'] === 'phpvmacars' && 
1252
-	    (
1252
+		(
1253 1253
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1254 1254
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1255
-	    )
1255
+		)
1256 1256
 	) {
1257
-	    //$buffer = $Common->getData($hosts[$id]);
1258
-	    if ($globalDebug) echo 'Get Data...'."\n";
1259
-	    $buffer = $Common->getData($value['host']);
1260
-	    $all_data = json_decode($buffer,true);
1261
-	    if ($buffer != '' && is_array($all_data)) {
1257
+		//$buffer = $Common->getData($hosts[$id]);
1258
+		if ($globalDebug) echo 'Get Data...'."\n";
1259
+		$buffer = $Common->getData($value['host']);
1260
+		$all_data = json_decode($buffer,true);
1261
+		if ($buffer != '' && is_array($all_data)) {
1262 1262
 		$reset = 0;
1263 1263
 		foreach ($all_data as $line) {
1264
-	    	    $data = array();
1265
-	    	    //$data['id'] = $line['id']; // id not usable
1266
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1267
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1268
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1269
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1270
-	    	    $data['ident'] = $line['flightnum']; // ident
1271
-	    	    $data['altitude'] = $line['alt']; // altitude
1272
-	    	    $data['speed'] = $line['gs']; // speed
1273
-	    	    $data['heading'] = $line['heading']; // heading
1274
-	    	    $data['latitude'] = $line['lat']; // lat
1275
-	    	    $data['longitude'] = $line['lng']; // long
1276
-	    	    $data['verticalrate'] = ''; // verticale rate
1277
-	    	    $data['squawk'] = ''; // squawk
1278
-	    	    $data['emergency'] = ''; // emergency
1279
-	    	    //$data['datetime'] = $line['lastupdate'];
1280
-	    	    //$data['last_update'] = $line['lastupdate'];
1281
-	    	    if (isset($value['timezone'])) {
1282
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1283
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1284
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1285
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1286
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1287
-	    	    $data['departure_airport_time'] = $line['deptime'];
1288
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1289
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1290
-    		    if (isset($line['registration'])) {
1291
-    			$data['registration'] = $line['registration'];
1292
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1293
-    		    } else $data['registration'] = $line['aircraft'];
1294
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1295
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1296
-		    if (isset($line['aircraftname'])) {
1264
+				$data = array();
1265
+				//$data['id'] = $line['id']; // id not usable
1266
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1267
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1268
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1269
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1270
+				$data['ident'] = $line['flightnum']; // ident
1271
+				$data['altitude'] = $line['alt']; // altitude
1272
+				$data['speed'] = $line['gs']; // speed
1273
+				$data['heading'] = $line['heading']; // heading
1274
+				$data['latitude'] = $line['lat']; // lat
1275
+				$data['longitude'] = $line['lng']; // long
1276
+				$data['verticalrate'] = ''; // verticale rate
1277
+				$data['squawk'] = ''; // squawk
1278
+				$data['emergency'] = ''; // emergency
1279
+				//$data['datetime'] = $line['lastupdate'];
1280
+				//$data['last_update'] = $line['lastupdate'];
1281
+				if (isset($value['timezone'])) {
1282
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1283
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1284
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1285
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1286
+				$data['departure_airport_icao'] = $line['depicao'];
1287
+				$data['departure_airport_time'] = $line['deptime'];
1288
+				$data['arrival_airport_icao'] = $line['arricao'];
1289
+				$data['arrival_airport_time'] = $line['arrtime'];
1290
+				if (isset($line['registration'])) {
1291
+				$data['registration'] = $line['registration'];
1292
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1293
+				} else $data['registration'] = $line['aircraft'];
1294
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1295
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1296
+			if (isset($line['aircraftname'])) {
1297 1297
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1298 1298
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1299
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1300
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1301
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1302
-	    		else {
1303
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1304
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1305
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1306
-	    		}
1307
-	    	    }
1308
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1309
-    		    $data['id_source'] = $id_source;
1310
-	    	    $data['format_source'] = 'phpvmacars';
1311
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1312
-		    $SI->add($data);
1313
-		    unset($data);
1299
+				$aircraft_data = explode('-',$line['aircraftname']);
1300
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1301
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1302
+				else {
1303
+					$aircraft_data = explode(' ',$line['aircraftname']);
1304
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1305
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1306
+				}
1307
+				}
1308
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1309
+				$data['id_source'] = $id_source;
1310
+				$data['format_source'] = 'phpvmacars';
1311
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1312
+			$SI->add($data);
1313
+			unset($data);
1314 1314
 		}
1315 1315
 		if ($globalDebug) echo 'No more data...'."\n";
1316 1316
 		unset($buffer);
1317 1317
 		unset($all_data);
1318
-	    }
1319
-	    //$last_exec['phpvmacars'] = time();
1320
-	    $last_exec[$id]['last'] = time();
1318
+		}
1319
+		//$last_exec['phpvmacars'] = time();
1320
+		$last_exec[$id]['last'] = time();
1321 1321
 	} elseif ($value['format'] === 'vaos' && 
1322
-	    (
1322
+		(
1323 1323
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1324 1324
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1325
-	    )
1325
+		)
1326 1326
 	) {
1327
-	    //$buffer = $Common->getData($hosts[$id]);
1328
-	    if ($globalDebug) echo 'Get Data...'."\n";
1329
-	    $buffer = $Common->getData($value['host']);
1330
-	    $all_data = json_decode($buffer,true);
1331
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1327
+		//$buffer = $Common->getData($hosts[$id]);
1328
+		if ($globalDebug) echo 'Get Data...'."\n";
1329
+		$buffer = $Common->getData($value['host']);
1330
+		$all_data = json_decode($buffer,true);
1331
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1332 1332
 		$reset = 0;
1333 1333
 		foreach ($all_data['ACARSData'] as $line) {
1334
-		    //print_r($line);
1335
-	    	    $data = array();
1336
-	    	    //$data['id'] = $line['id']; // id not usable
1337
-	    	    $data['id'] = $line['id'];
1338
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1339
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1340
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1341
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1342
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1343
-	    	    $data['altitude'] = $line['altitude']; // altitude
1344
-	    	    $data['speed'] = $line['groundspeed']; // speed
1345
-	    	    $data['heading'] = $line['heading']; // heading
1346
-	    	    $data['latitude'] = $line['lat']; // lat
1347
-	    	    $data['longitude'] = $line['lon']; // long
1348
-	    	    //$data['verticalrate'] = ''; // verticale rate
1349
-	    	    //$data['squawk'] = ''; // squawk
1350
-	    	    //$data['emergency'] = ''; // emergency
1351
-	    	    if (isset($value['timezone'])) {
1352
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1353
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1354
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1355
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1334
+			//print_r($line);
1335
+				$data = array();
1336
+				//$data['id'] = $line['id']; // id not usable
1337
+				$data['id'] = $line['id'];
1338
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1339
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1340
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1341
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1342
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1343
+				$data['altitude'] = $line['altitude']; // altitude
1344
+				$data['speed'] = $line['groundspeed']; // speed
1345
+				$data['heading'] = $line['heading']; // heading
1346
+				$data['latitude'] = $line['lat']; // lat
1347
+				$data['longitude'] = $line['lon']; // long
1348
+				//$data['verticalrate'] = ''; // verticale rate
1349
+				//$data['squawk'] = ''; // squawk
1350
+				//$data['emergency'] = ''; // emergency
1351
+				if (isset($value['timezone'])) {
1352
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1353
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1354
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1355
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1356 1356
 	    	    
1357
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1358
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1359
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1360
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1361
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1357
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1358
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1359
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1360
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1361
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1362 1362
 
1363
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1364
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1365
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1363
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1364
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1365
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1366 1366
 
1367
-    		    $data['id_source'] = $id_source;
1368
-	    	    $data['format_source'] = 'vaos';
1369
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1370
-		    $SI->add($data);
1371
-		    unset($data);
1367
+				$data['id_source'] = $id_source;
1368
+				$data['format_source'] = 'vaos';
1369
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1370
+			$SI->add($data);
1371
+			unset($data);
1372 1372
 		}
1373 1373
 		if ($globalDebug) echo 'No more data...'."\n";
1374 1374
 		unset($buffer);
1375 1375
 		unset($all_data);
1376
-	    }
1377
-	    //$last_exec['phpvmacars'] = time();
1378
-	    $last_exec[$id]['last'] = time();
1376
+		}
1377
+		//$last_exec['phpvmacars'] = time();
1378
+		$last_exec[$id]['last'] = time();
1379 1379
 	} elseif ($value['format'] === 'vam' && 
1380
-	    (
1380
+		(
1381 1381
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1382 1382
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1383
-	    )
1383
+		)
1384 1384
 	) {
1385
-	    //$buffer = $Common->getData($hosts[$id]);
1386
-	    if ($globalDebug) echo 'Get Data...'."\n";
1387
-	    $buffer = $Common->getData($value['host']);
1388
-	    $all_data = json_decode($buffer,true);
1389
-	    if ($buffer != '' && is_array($all_data)) {
1385
+		//$buffer = $Common->getData($hosts[$id]);
1386
+		if ($globalDebug) echo 'Get Data...'."\n";
1387
+		$buffer = $Common->getData($value['host']);
1388
+		$all_data = json_decode($buffer,true);
1389
+		if ($buffer != '' && is_array($all_data)) {
1390 1390
 		$reset = 0;
1391 1391
 		foreach ($all_data as $line) {
1392
-	    	    $data = array();
1393
-	    	    //$data['id'] = $line['id']; // id not usable
1394
-	    	    $data['id'] = trim($line['flight_id']);
1395
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1396
-	    	    $data['pilot_name'] = $line['pilot_name'];
1397
-	    	    $data['pilot_id'] = $line['pilot_id'];
1398
-	    	    $data['ident'] = trim($line['callsign']); // ident
1399
-	    	    $data['altitude'] = $line['altitude']; // altitude
1400
-	    	    $data['speed'] = $line['gs']; // speed
1401
-	    	    $data['heading'] = $line['heading']; // heading
1402
-	    	    $data['latitude'] = $line['latitude']; // lat
1403
-	    	    $data['longitude'] = $line['longitude']; // long
1404
-	    	    $data['verticalrate'] = ''; // verticale rate
1405
-	    	    $data['squawk'] = ''; // squawk
1406
-	    	    $data['emergency'] = ''; // emergency
1407
-	    	    //$data['datetime'] = $line['lastupdate'];
1408
-	    	    $data['last_update'] = $line['last_update'];
1409
-		    $data['datetime'] = date('Y-m-d H:i:s');
1410
-	    	    $data['departure_airport_icao'] = $line['departure'];
1411
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1412
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1413
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1414
-    		    //$data['registration'] = $line['aircraft'];
1415
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1416
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1417
-    		    $data['id_source'] = $id_source;
1418
-	    	    $data['format_source'] = 'vam';
1419
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1420
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1421
-		    $SI->add($data);
1422
-		    unset($data);
1392
+				$data = array();
1393
+				//$data['id'] = $line['id']; // id not usable
1394
+				$data['id'] = trim($line['flight_id']);
1395
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1396
+				$data['pilot_name'] = $line['pilot_name'];
1397
+				$data['pilot_id'] = $line['pilot_id'];
1398
+				$data['ident'] = trim($line['callsign']); // ident
1399
+				$data['altitude'] = $line['altitude']; // altitude
1400
+				$data['speed'] = $line['gs']; // speed
1401
+				$data['heading'] = $line['heading']; // heading
1402
+				$data['latitude'] = $line['latitude']; // lat
1403
+				$data['longitude'] = $line['longitude']; // long
1404
+				$data['verticalrate'] = ''; // verticale rate
1405
+				$data['squawk'] = ''; // squawk
1406
+				$data['emergency'] = ''; // emergency
1407
+				//$data['datetime'] = $line['lastupdate'];
1408
+				$data['last_update'] = $line['last_update'];
1409
+			$data['datetime'] = date('Y-m-d H:i:s');
1410
+				$data['departure_airport_icao'] = $line['departure'];
1411
+				//$data['departure_airport_time'] = $line['departure_time'];
1412
+				$data['arrival_airport_icao'] = $line['arrival'];
1413
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1414
+				//$data['registration'] = $line['aircraft'];
1415
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1416
+				$data['aircraft_icao'] = $line['plane_type'];
1417
+				$data['id_source'] = $id_source;
1418
+				$data['format_source'] = 'vam';
1419
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1420
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1421
+			$SI->add($data);
1422
+			unset($data);
1423 1423
 		}
1424 1424
 		if ($globalDebug) echo 'No more data...'."\n";
1425 1425
 		unset($buffer);
1426 1426
 		unset($all_data);
1427
-	    }
1428
-	    //$last_exec['phpvmacars'] = time();
1429
-	    $last_exec[$id]['last'] = time();
1427
+		}
1428
+		//$last_exec['phpvmacars'] = time();
1429
+		$last_exec[$id]['last'] = time();
1430 1430
 	} elseif ($value['format'] === 'blitzortung' && 
1431
-	    (
1431
+		(
1432 1432
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1433 1433
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1434
-	    )
1434
+		)
1435 1435
 	) {
1436
-	    //$buffer = $Common->getData($hosts[$id]);
1437
-	    if ($globalDebug) echo 'Get Data...'."\n";
1438
-	    $buffer = $Common->getData($value['host']);
1439
-	    $all_data = json_decode($buffer,true);
1440
-	    if ($buffer != '') {
1436
+		//$buffer = $Common->getData($hosts[$id]);
1437
+		if ($globalDebug) echo 'Get Data...'."\n";
1438
+		$buffer = $Common->getData($value['host']);
1439
+		$all_data = json_decode($buffer,true);
1440
+		if ($buffer != '') {
1441 1441
 		$Source->deleteLocationBySource('blitzortung');
1442 1442
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1443 1443
 		$buffer = explode('\n',$buffer);
1444 1444
 		foreach ($buffer as $buffer_line) {
1445
-		    $line = json_decode($buffer_line,true);
1446
-		    if (isset($line['time'])) {
1445
+			$line = json_decode($buffer_line,true);
1446
+			if (isset($line['time'])) {
1447 1447
 			$data = array();
1448 1448
 			$data['altitude'] = $line['alt']; // altitude
1449 1449
 			$data['latitude'] = $line['lat']; // lat
@@ -1455,94 +1455,94 @@  discard block
 block discarded – undo
1455 1455
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1456 1456
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1457 1457
 			unset($data);
1458
-		    }
1458
+			}
1459 1459
 		}
1460 1460
 		if ($globalDebug) echo 'No more data...'."\n";
1461 1461
 		unset($buffer);
1462
-	    }
1463
-	    $last_exec[$id]['last'] = time();
1462
+		}
1463
+		$last_exec[$id]['last'] = time();
1464 1464
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1465 1465
 	} elseif ($value['format'] === 'sbs' || $value['format'] === 'tsv' || $value['format'] === 'raw' || $value['format'] === 'aprs' || $value['format'] === 'famaprs' || $value['format'] === 'beast' || $value['format'] === 'flightgearmp' || $value['format'] === 'flightgearsp' || $value['format'] === 'acars' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') {
1466
-	    //$last_exec[$id]['last'] = time();
1467
-	    //$read = array( $sockets[$id] );
1468
-	    $read = $sockets;
1469
-	    $write = NULL;
1470
-	    $e = NULL;
1471
-	    $n = socket_select($read, $write, $e, $timeout);
1472
-	    if ($e != NULL) var_dump($e);
1473
-	    if ($n > 0) {
1466
+		//$last_exec[$id]['last'] = time();
1467
+		//$read = array( $sockets[$id] );
1468
+		$read = $sockets;
1469
+		$write = NULL;
1470
+		$e = NULL;
1471
+		$n = socket_select($read, $write, $e, $timeout);
1472
+		if ($e != NULL) var_dump($e);
1473
+		if ($n > 0) {
1474 1474
 		$reset = 0;
1475 1475
 		foreach ($read as $nb => $r) {
1476
-		    //$value = $formats[$nb];
1477
-		    $format = $globalSources[$nb]['format'];
1478
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1476
+			//$value = $formats[$nb];
1477
+			$format = $globalSources[$nb]['format'];
1478
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1479 1479
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1480
-		    } elseif ($format === 'vrstcp') {
1480
+			} elseif ($format === 'vrstcp') {
1481 1481
 			$buffer = @socket_read($r, 6000);
1482
-		    } else {
1482
+			} else {
1483 1483
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1484
-		    }
1485
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1486
-		    //echo $buffer."\n";
1487
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1488
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1489
-		    $error = false;
1490
-		    //$SI::del();
1491
-		    if ($buffer !== FALSE) {
1484
+			}
1485
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1486
+			//echo $buffer."\n";
1487
+			// lets play nice and handle signals such as ctrl-c/kill properly
1488
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1489
+			$error = false;
1490
+			//$SI::del();
1491
+			if ($buffer !== FALSE) {
1492 1492
 			if ($format === 'vrstcp') {
1493
-			    $buffer = explode('},{',$buffer);
1493
+				$buffer = explode('},{',$buffer);
1494 1494
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1495
-		    }
1496
-		    // SBS format is CSV format
1497
-		    if ($buffer !== FALSE && $buffer !== '') {
1495
+			}
1496
+			// SBS format is CSV format
1497
+			if ($buffer !== FALSE && $buffer !== '') {
1498 1498
 			$tt[$format] = 0;
1499 1499
 			if ($format === 'acarssbs3') {
1500
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1501
-			    $ACARS->add(trim($buffer));
1502
-			    $ACARS->deleteLiveAcarsData();
1500
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1501
+				$ACARS->add(trim($buffer));
1502
+				$ACARS->deleteLiveAcarsData();
1503 1503
 			} elseif ($format === 'raw') {
1504
-			    // AVR format
1505
-			    $data = $SBS->parse($buffer);
1506
-			    if (is_array($data)) {
1504
+				// AVR format
1505
+				$data = $SBS->parse($buffer);
1506
+				if (is_array($data)) {
1507 1507
 				$data['datetime'] = date('Y-m-d H:i:s');
1508 1508
 				$data['format_source'] = 'raw';
1509 1509
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1510 1510
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1511 1511
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1512 1512
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1513
-			    }
1513
+				}
1514 1514
 			} elseif ($format === 'ais') {
1515
-			    $ais_data = $AIS->parse_line(trim($buffer));
1516
-			    $data = array();
1517
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1518
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1519
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1520
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1521
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1522
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1523
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1524
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1525
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1526
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1527
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1528
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1529
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1530
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1531
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1532
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1515
+				$ais_data = $AIS->parse_line(trim($buffer));
1516
+				$data = array();
1517
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1518
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1519
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1520
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1521
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1522
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1523
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1524
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1525
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1526
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1527
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1528
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1529
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1530
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1531
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1532
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1533 1533
 
1534
-			    if (isset($ais_data['timestamp'])) {
1534
+				if (isset($ais_data['timestamp'])) {
1535 1535
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1536
-			    } else {
1536
+				} else {
1537 1537
 				$data['datetime'] = date('Y-m-d H:i:s');
1538
-			    }
1539
-			    $data['format_source'] = 'aisnmea';
1540
-    			    $data['id_source'] = $id_source;
1541
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1542
-			    unset($data);
1543
-                        } elseif ($format === 'flightgearsp') {
1544
-                    	    //echo $buffer."\n";
1545
-                    	    if (strlen($buffer) > 5) {
1538
+				}
1539
+				$data['format_source'] = 'aisnmea';
1540
+					$data['id_source'] = $id_source;
1541
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1542
+				unset($data);
1543
+						} elseif ($format === 'flightgearsp') {
1544
+							//echo $buffer."\n";
1545
+							if (strlen($buffer) > 5) {
1546 1546
 				$line = explode(',',$buffer);
1547 1547
 				$data = array();
1548 1548
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1559,38 +1559,38 @@  discard block
 block discarded – undo
1559 1559
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1560 1560
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1561 1561
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1562
-			    }
1563
-                        } elseif ($format === 'acars') {
1564
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1565
-			    $ACARS->add(trim($buffer));
1566
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1567
-			    $ACARS->deleteLiveAcarsData();
1562
+				}
1563
+						} elseif ($format === 'acars') {
1564
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1565
+				$ACARS->add(trim($buffer));
1566
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1567
+				$ACARS->deleteLiveAcarsData();
1568 1568
 			} elseif ($format === 'flightgearmp') {
1569
-			    if (substr($buffer,0,1) != '#') {
1569
+				if (substr($buffer,0,1) != '#') {
1570 1570
 				$data = array();
1571 1571
 				//echo $buffer."\n";
1572 1572
 				$line = explode(' ',$buffer);
1573 1573
 				if (count($line) === 11) {
1574
-				    $userserver = explode('@',$line[0]);
1575
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1576
-				    $data['ident'] = $userserver[0];
1577
-				    $data['registration'] = $userserver[0];
1578
-				    $data['latitude'] = $line[4];
1579
-				    $data['longitude'] = $line[5];
1580
-				    $data['altitude'] = $line[6];
1581
-				    $data['datetime'] = date('Y-m-d H:i:s');
1582
-				    $aircraft_type = $line[10];
1583
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1584
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1585
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1586
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1574
+					$userserver = explode('@',$line[0]);
1575
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1576
+					$data['ident'] = $userserver[0];
1577
+					$data['registration'] = $userserver[0];
1578
+					$data['latitude'] = $line[4];
1579
+					$data['longitude'] = $line[5];
1580
+					$data['altitude'] = $line[6];
1581
+					$data['datetime'] = date('Y-m-d H:i:s');
1582
+					$aircraft_type = $line[10];
1583
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1584
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1585
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1586
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1587
+				}
1587 1588
 				}
1588
-			    }
1589 1589
 			} elseif ($format === 'beast') {
1590
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1591
-			    die;
1590
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1591
+				die;
1592 1592
 			} elseif ($format === 'vrstcp') {
1593
-			    foreach($buffer as $all_data) {
1593
+				foreach($buffer as $all_data) {
1594 1594
 				$line = json_decode('{'.$all_data.'}',true);
1595 1595
 				$data = array();
1596 1596
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1610,153 +1610,153 @@  discard block
 block discarded – undo
1610 1610
 				*/
1611 1611
 				$data['datetime'] = date('Y-m-d H:i:s');
1612 1612
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1613
-		    		$data['format_source'] = 'vrstcp';
1613
+					$data['format_source'] = 'vrstcp';
1614 1614
 				$data['id_source'] = $id_source;
1615 1615
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1616 1616
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1617 1617
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1618 1618
 				unset($data);
1619
-			    }
1619
+				}
1620 1620
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1621
-			    $line = explode("\t", $buffer);
1622
-			    for($k = 0; $k < count($line); $k=$k+2) {
1621
+				$line = explode("\t", $buffer);
1622
+				for($k = 0; $k < count($line); $k=$k+2) {
1623 1623
 				$key = $line[$k];
1624
-			        $lined[$key] = $line[$k+1];
1625
-			    }
1626
-    			    if (count($lined) > 3) {
1627
-    				$data['hex'] = $lined['hexid'];
1628
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1629
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1630
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1631
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1632
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1633
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1634
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1635
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1636
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1637
-    				$data['id_source'] = $id_source;
1638
-    				$data['format_source'] = 'tsv';
1639
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1640
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1624
+					$lined[$key] = $line[$k+1];
1625
+				}
1626
+					if (count($lined) > 3) {
1627
+					$data['hex'] = $lined['hexid'];
1628
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1629
+					$data['datetime'] = date('Y-m-d H:i:s');;
1630
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1631
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1632
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1633
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1634
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1635
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1636
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1637
+					$data['id_source'] = $id_source;
1638
+					$data['format_source'] = 'tsv';
1639
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1640
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1641 1641
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1642
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1643
-    				unset($lined);
1644
-    				unset($data);
1645
-    			    } else $error = true;
1642
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1643
+					unset($lined);
1644
+					unset($data);
1645
+					} else $error = true;
1646 1646
 			} elseif ($format === 'aprs' && $use_aprs) {
1647
-			    if ($aprs_connect === 0) {
1647
+				if ($aprs_connect === 0) {
1648 1648
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1649 1649
 				$aprs_connect = 1;
1650
-			    }
1650
+				}
1651 1651
 			    
1652
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1652
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1653 1653
 				$aprs_last_tx = time();
1654 1654
 				$data_aprs = "# Keep alive";
1655 1655
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1656
-			    }
1656
+				}
1657 1657
 			    
1658
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1659
-			    //echo 'APRS data : '.$buffer."\n";
1660
-			    $buffer = str_replace('APRS <- ','',$buffer);
1661
-			    $buffer = str_replace('APRS -> ','',$buffer);
1662
-			    //echo $buffer."\n";
1663
-			    date_default_timezone_set('UTC');
1664
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1658
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1659
+				//echo 'APRS data : '.$buffer."\n";
1660
+				$buffer = str_replace('APRS <- ','',$buffer);
1661
+				$buffer = str_replace('APRS -> ','',$buffer);
1662
+				//echo $buffer."\n";
1663
+				date_default_timezone_set('UTC');
1664
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1665 1665
 				$line = $APRS->parse($buffer);
1666 1666
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1667 1667
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1668
-				    $aprs_last_tx = time();
1669
-				    $data = array();
1670
-				    //print_r($line);
1671
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1672
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1673
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1674
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1675
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1676
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1677
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1678
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1679
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1680
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1681
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1682
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1683
-				    $data['latitude'] = $line['latitude'];
1684
-				    $data['longitude'] = $line['longitude'];
1685
-				    //$data['verticalrate'] = $line[16];
1686
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1687
-				    //else $data['speed'] = 0;
1688
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1689
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1690
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1691
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1668
+					$aprs_last_tx = time();
1669
+					$data = array();
1670
+					//print_r($line);
1671
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1672
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1673
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1674
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1675
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1676
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1677
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1678
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1679
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1680
+					else $data['datetime'] = date('Y-m-d H:i:s');
1681
+					//$data['datetime'] = date('Y-m-d H:i:s');
1682
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1683
+					$data['latitude'] = $line['latitude'];
1684
+					$data['longitude'] = $line['longitude'];
1685
+					//$data['verticalrate'] = $line[16];
1686
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1687
+					//else $data['speed'] = 0;
1688
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1689
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1690
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1691
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1692 1692
 				    
1693
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1694
-				    //else echo 'No heading...'."\n";
1695
-				    //else $data['heading'] = 0;
1696
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1697
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1698
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1699
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1700
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1701
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1702
-    				    $data['id_source'] = $id_source;
1703
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1704
-				    else $data['format_source'] = 'aprs';
1705
-				    $data['source_name'] = $line['source'];
1706
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1707
-				    else $data['source_type'] = 'flarm';
1708
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1709
-				    $currentdate = date('Y-m-d H:i:s');
1710
-				    $aprsdate = strtotime($data['datetime']);
1711
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1712
-				    // Accept data if time <= system time + 20s
1713
-				    //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1714
-				    if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1693
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1694
+					//else echo 'No heading...'."\n";
1695
+					//else $data['heading'] = 0;
1696
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1697
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1698
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1699
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1700
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1701
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1702
+						$data['id_source'] = $id_source;
1703
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1704
+					else $data['format_source'] = 'aprs';
1705
+					$data['source_name'] = $line['source'];
1706
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1707
+					else $data['source_type'] = 'flarm';
1708
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1709
+					$currentdate = date('Y-m-d H:i:s');
1710
+					$aprsdate = strtotime($data['datetime']);
1711
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1712
+					// Accept data if time <= system time + 20s
1713
+					//if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1714
+					if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1715 1715
 					$send = $SI->add($data);
1716
-				    } elseif ($data['source_type'] === 'ais') {
1716
+					} elseif ($data['source_type'] === 'ais') {
1717 1717
 					$data['type'] = '';
1718 1718
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1719
-				    } elseif (isset($line['stealth'])) {
1719
+					} elseif (isset($line['stealth'])) {
1720 1720
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1721 1721
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1722
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1723
-					    //$line['symbol'] === 'Balloon' ||
1724
-					    $line['symbol'] === 'Glider' || 
1725
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1726
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1727
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1728
-					    $send = $SI->add($data);
1729
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1730
-					    $line['symbol'] === 'Yacht (Sail)' || 
1731
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1732
-					    $send = $MI->add($data);
1733
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1734
-					    $line['symbol'] === 'Car' || 
1735
-					    $line['symbol'] === 'Ambulance' || 
1736
-					    $line['symbol'] === 'Van' || 
1737
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1738
-					    $line['symbol'] === 'Motorcycle' || 
1739
-					    $line['symbol'] === 'Tractor' || 
1740
-					    $line['symbol'] === 'Police' || 
1741
-					    $line['symbol'] === 'Bike' || 
1742
-					    $line['symbol'] === 'Jogger' || 
1743
-					    $line['symbol'] === 'Horse' || 
1744
-					    $line['symbol'] === 'Bus' || 
1745
-					    $line['symbol'] === 'Jeep' || 
1746
-					    $line['symbol'] === 'Recreational Vehicle' || 
1747
-					    $line['symbol'] === 'Yacht (Sail)' || 
1748
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1749
-					    $line['symbol'] === 'Firetruck' || 
1750
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1751
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1752
-					    $line['symbol'] === 'SUV' ||
1753
-					    $line['symbol'] === 'Snowmobile' ||
1754
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1755
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1722
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1723
+						//$line['symbol'] === 'Balloon' ||
1724
+						$line['symbol'] === 'Glider' || 
1725
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1726
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1727
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1728
+						$send = $SI->add($data);
1729
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1730
+						$line['symbol'] === 'Yacht (Sail)' || 
1731
+						$line['symbol'] === 'Ship (Power Boat)')) {
1732
+						$send = $MI->add($data);
1733
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1734
+						$line['symbol'] === 'Car' || 
1735
+						$line['symbol'] === 'Ambulance' || 
1736
+						$line['symbol'] === 'Van' || 
1737
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1738
+						$line['symbol'] === 'Motorcycle' || 
1739
+						$line['symbol'] === 'Tractor' || 
1740
+						$line['symbol'] === 'Police' || 
1741
+						$line['symbol'] === 'Bike' || 
1742
+						$line['symbol'] === 'Jogger' || 
1743
+						$line['symbol'] === 'Horse' || 
1744
+						$line['symbol'] === 'Bus' || 
1745
+						$line['symbol'] === 'Jeep' || 
1746
+						$line['symbol'] === 'Recreational Vehicle' || 
1747
+						$line['symbol'] === 'Yacht (Sail)' || 
1748
+						$line['symbol'] === 'Ship (Power Boat)' || 
1749
+						$line['symbol'] === 'Firetruck' || 
1750
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1751
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1752
+						$line['symbol'] === 'SUV' ||
1753
+						$line['symbol'] === 'Snowmobile' ||
1754
+						$line['symbol'] === 'Mobile Satellite Station')) {
1755
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1756 1756
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1757 1757
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1758 1758
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1759
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1759
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1760 1760
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1761 1761
 					$Source->deleteOldLocationByType('gs');
1762 1762
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1764,7 +1764,7 @@  discard block
 block discarded – undo
1764 1764
 					} else {
1765 1765
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1766 1766
 					}
1767
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1767
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1768 1768
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1769 1769
 					if ($globalDebug) echo '# Weather Station added'."\n";
1770 1770
 					$Source->deleteOldLocationByType('wx');
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
 					} else {
1775 1775
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1776 1776
 					}
1777
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1777
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1778 1778
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1779 1779
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1780 1780
 					$Source->deleteOldLocationByType('lightning');
@@ -1783,11 +1783,11 @@  discard block
 block discarded – undo
1783 1783
 					} else {
1784 1784
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1785 1785
 					}
1786
-				    } elseif ($globalDebug) {
1787
-				    	echo '/!\ Not added: '.$buffer."\n";
1788
-				    	print_r($line);
1789
-				    }
1790
-				    unset($data);
1786
+					} elseif ($globalDebug) {
1787
+						echo '/!\ Not added: '.$buffer."\n";
1788
+						print_r($line);
1789
+					}
1790
+					unset($data);
1791 1791
 				}
1792 1792
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1793 1793
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1806,12 +1806,12 @@  discard block
 block discarded – undo
1806 1806
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1807 1807
 					$globalSources[$nb]['last_weather_clean'] = time();
1808 1808
 				}
1809
-			    }
1809
+				}
1810 1810
 			} else {
1811
-			    $line = explode(',', $buffer);
1812
-    			    if (count($line) > 20) {
1813
-    			    	$data['hex'] = $line[4];
1814
-    				/*
1811
+				$line = explode(',', $buffer);
1812
+					if (count($line) > 20) {
1813
+						$data['hex'] = $line[4];
1814
+					/*
1815 1815
     				$data['datetime'] = $line[6].' '.$line[7];
1816 1816
     					date_default_timezone_set($globalTimezone);
1817 1817
     					$datetime = new DateTime($data['datetime']);
@@ -1819,30 +1819,30 @@  discard block
 block discarded – undo
1819 1819
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1820 1820
     					date_default_timezone_set('UTC');
1821 1821
     				*/
1822
-    				// Force datetime to current UTC datetime
1823
-    				date_default_timezone_set('UTC');
1824
-    				$data['datetime'] = date('Y-m-d H:i:s');
1825
-    				$data['ident'] = trim($line[10]);
1826
-    				$data['latitude'] = $line[14];
1827
-    				$data['longitude'] = $line[15];
1828
-    				$data['verticalrate'] = $line[16];
1829
-    				$data['emergency'] = $line[20];
1830
-    				$data['speed'] = $line[12];
1831
-    				$data['squawk'] = $line[17];
1832
-    				$data['altitude'] = $line[11];
1833
-    				$data['heading'] = $line[13];
1834
-    				$data['ground'] = $line[21];
1835
-    				$data['emergency'] = $line[19];
1836
-    				$data['format_source'] = 'sbs';
1822
+					// Force datetime to current UTC datetime
1823
+					date_default_timezone_set('UTC');
1824
+					$data['datetime'] = date('Y-m-d H:i:s');
1825
+					$data['ident'] = trim($line[10]);
1826
+					$data['latitude'] = $line[14];
1827
+					$data['longitude'] = $line[15];
1828
+					$data['verticalrate'] = $line[16];
1829
+					$data['emergency'] = $line[20];
1830
+					$data['speed'] = $line[12];
1831
+					$data['squawk'] = $line[17];
1832
+					$data['altitude'] = $line[11];
1833
+					$data['heading'] = $line[13];
1834
+					$data['ground'] = $line[21];
1835
+					$data['emergency'] = $line[19];
1836
+					$data['format_source'] = 'sbs';
1837 1837
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1838
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1838
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1839 1839
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1840
-    				$data['id_source'] = $id_source;
1841
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1842
-    				else $error = true;
1843
-    				unset($data);
1844
-    			    } else $error = true;
1845
-			    if ($error) {
1840
+					$data['id_source'] = $id_source;
1841
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1842
+					else $error = true;
1843
+					unset($data);
1844
+					} else $error = true;
1845
+				if ($error) {
1846 1846
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1847 1847
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1848 1848
 				} else {
@@ -1858,13 +1858,13 @@  discard block
 block discarded – undo
1858 1858
 					connect_all($sourceer);
1859 1859
 					$sourceer = array();
1860 1860
 				}
1861
-			    }
1861
+				}
1862 1862
 			}
1863 1863
 			// Sleep for xxx microseconds
1864 1864
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1865
-		    } else {
1865
+			} else {
1866 1866
 			if ($format === 'flightgearmp') {
1867
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1867
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1868 1868
 				//@socket_close($r);
1869 1869
 				sleep($globalMinFetch);
1870 1870
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1873,9 +1873,9 @@  discard block
 block discarded – undo
1873 1873
 				break;
1874 1874
 				
1875 1875
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1876
-			    if (isset($tt[$format])) $tt[$format]++;
1877
-			    else $tt[$format] = 0;
1878
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
1876
+				if (isset($tt[$format])) $tt[$format]++;
1877
+				else $tt[$format] = 0;
1878
+				if ($tt[$format] > 30 || $buffer === FALSE) {
1879 1879
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1880 1880
 				//@socket_close($r);
1881 1881
 				sleep(2);
@@ -1886,24 +1886,24 @@  discard block
 block discarded – undo
1886 1886
 				//connect_all($globalSources);
1887 1887
 				$tt[$format]=0;
1888 1888
 				break;
1889
-			    } 
1890
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1889
+				} 
1890
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1891
+			}
1891 1892
 			}
1892
-		    }
1893 1893
 		}
1894
-	    } else {
1894
+		} else {
1895 1895
 		$error = socket_strerror(socket_last_error());
1896 1896
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1897 1897
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1898 1898
 			if (isset($globalDebug)) echo "Restarting...\n";
1899 1899
 			// Restart the script if possible
1900 1900
 			if (is_array($sockets)) {
1901
-			    if ($globalDebug) echo "Shutdown all sockets...";
1901
+				if ($globalDebug) echo "Shutdown all sockets...";
1902 1902
 			    
1903
-			    foreach ($sockets as $sock) {
1903
+				foreach ($sockets as $sock) {
1904 1904
 				@socket_shutdown($sock,2);
1905 1905
 				@socket_close($sock);
1906
-			    }
1906
+				}
1907 1907
 			    
1908 1908
 			}
1909 1909
 			if ($globalDebug) echo "Waiting...";
@@ -1918,15 +1918,15 @@  discard block
 block discarded – undo
1918 1918
 			if ($globalDebug) echo "Restart all connections...";
1919 1919
 			connect_all($globalSources);
1920 1920
 		}
1921
-	    }
1921
+		}
1922 1922
 	}
1923 1923
 	if ($globalDaemon === false) {
1924
-	    if ($globalDebug) echo 'Check all...'."\n";
1925
-	    if (isset($SI)) $SI->checkAll();
1926
-	    if (isset($TI)) $TI->checkAll();
1927
-	    if (isset($MI)) $MI->checkAll();
1924
+		if ($globalDebug) echo 'Check all...'."\n";
1925
+		if (isset($SI)) $SI->checkAll();
1926
+		if (isset($TI)) $TI->checkAll();
1927
+		if (isset($MI)) $MI->checkAll();
1928
+	}
1928 1929
 	}
1929
-    }
1930 1930
 }
1931 1931
 
1932 1932
 ?>
Please login to merge, or discard this patch.
require/class.Scheduler.php 1 patch
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
 	}
29 29
 
30 30
 	/**
31
-	* Add schedule data to database
32
-	* @param String $ident aircraft ident
33
-	* @param String $departure_airport_icao departure airport icao
34
-	* @param String $departure_airport_time departure airport time
35
-	* @param String $arrival_airport_icao arrival airport icao
36
-	* @param String $arrival_airport_time arrival airport time
31
+	 * Add schedule data to database
32
+	 * @param String $ident aircraft ident
33
+	 * @param String $departure_airport_icao departure airport icao
34
+	 * @param String $departure_airport_time departure airport time
35
+	 * @param String $arrival_airport_icao arrival airport icao
36
+	 * @param String $arrival_airport_time arrival airport time
37 37
 	/ @param String $source source of data
38
-	*/
38
+	 */
39 39
 	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
40 40
 		date_default_timezone_set('UTC');
41 41
 		$date = date("Y-m-d H:i:s",time());
@@ -51,18 +51,18 @@  discard block
 block discarded – undo
51 51
 		}
52 52
 		if ($sth->fetchColumn() > 0) {
53 53
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
54
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
55
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
54
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
55
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
56 56
 			} elseif ($arrival_airport_time == '') {
57
-			    $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";
58
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
57
+				$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";
58
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
59 59
 			} elseif ($departure_airport_time == '') {
60
-			    $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";
61
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
60
+				$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";
61
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
62 62
 			} else {
63
-			    //$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";
64
-			    $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";
65
-			    $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);
63
+				//$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";
64
+				$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";
65
+				$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);
66 66
 			}
67 67
 			try {
68 68
 				$sth = $this->db->prepare($query);
@@ -149,15 +149,15 @@  discard block
 block discarded – undo
149 149
 	*/
150 150
 	public function checkSchedule($ident) {
151 151
 		global $globalDBdriver;
152
-	        //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
153
-	        if ($globalDBdriver == 'mysql') {
152
+			//$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
153
+			if ($globalDBdriver == 'mysql') {
154 154
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND 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";
155 155
 		} else {
156 156
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident 
157 157
 			AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL)
158 158
 			     OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1";
159 159
 		}
160
-	        $query_values = array(':ident' => $ident);
160
+			$query_values = array(':ident' => $ident);
161 161
 		 try {
162 162
 			$sth = $this->db->prepare($query);
163 163
 			$sth->execute($query_values);
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
 	}
171 171
 
172 172
 	/**
173
-	* Get flight info from Air France
174
-	* @param String $callsign The callsign
175
-	* @param String $date date we want flight number info
176
-	* @param String $carrier IATA code
177
-	* @return Flight departure and arrival airports and time
178
-	*/
173
+	 * Get flight info from Air France
174
+	 * @param String $callsign The callsign
175
+	 * @param String $date date we want flight number info
176
+	 * @param String $carrier IATA code
177
+	 * @return Flight departure and arrival airports and time
178
+	 */
179 179
 	public function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
180 180
 		$Common = new Common();
181 181
 		$check_date = new Datetime($date);
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
 	}
212 212
 
213 213
 	/**
214
-	* Get flight info from EasyJet
215
-	* @param String $callsign The callsign
216
-	* @param String $date date we want flight number info
217
-	* @return Flight departure and arrival airports and time
218
-	*/
214
+	 * Get flight info from EasyJet
215
+	 * @param String $callsign The callsign
216
+	 * @param String $date date we want flight number info
217
+	 * @return Flight departure and arrival airports and time
218
+	 */
219 219
 	private function getEasyJet($callsign, $date = 'NOW') {
220 220
 		global $globalTimezone;
221 221
 		$Common = new Common();
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
 	}
240 240
 
241 241
 	/**
242
-	* Get flight info from Ryanair
243
-	* @param String $callsign The callsign
244
-	* @return Flight departure and arrival airports and time
245
-	*/
242
+	 * Get flight info from Ryanair
243
+	 * @param String $callsign The callsign
244
+	 * @return Flight departure and arrival airports and time
245
+	 */
246 246
 	private function getRyanair($callsign) {
247 247
 		$Common = new Common();
248 248
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 	}
266 266
 
267 267
 	/**
268
-	* Get flight info from Swiss
269
-	* @param String $callsign The callsign
270
-	* @return Flight departure and arrival airports and time
271
-	*/
268
+	 * Get flight info from Swiss
269
+	 * @param String $callsign The callsign
270
+	 * @return Flight departure and arrival airports and time
271
+	 */
272 272
 	private function getSwiss($callsign) {
273 273
 		$Common = new Common();
274 274
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
 	}
298 298
 	
299 299
 	/**
300
-	* Get flight info from British Airways API
301
-	* @param String $callsign The callsign
302
-	* @param String $date date we want flight number info
303
-	* @return Flight departure and arrival airports and time
304
-	*/
300
+	 * Get flight info from British Airways API
301
+	 * @param String $callsign The callsign
302
+	 * @param String $date date we want flight number info
303
+	 * @return Flight departure and arrival airports and time
304
+	 */
305 305
 	public function getBritishAirways($callsign, $date = 'NOW') {
306 306
 		global $globalBritishAirwaysKey;
307 307
 		$Common = new Common();
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
 	}
326 326
 
327 327
 	/**
328
-	* Get flight info from Lutfhansa API
329
-	* @param String $callsign The callsign
330
-	* @param String $date date we want flight number info
331
-	* @return Flight departure and arrival airports and time
332
-	*/
328
+	 * Get flight info from Lutfhansa API
329
+	 * @param String $callsign The callsign
330
+	 * @param String $date date we want flight number info
331
+	 * @return Flight departure and arrival airports and time
332
+	 */
333 333
 	public function getLufthansa($callsign, $date = 'NOW') {
334 334
 		global $globalLufthansaKey;
335 335
 		$Common = new Common();
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
 	}
360 360
 
361 361
 	/**
362
-	* Get flight info from Transavia API
363
-	* @param String $callsign The callsign
364
-	* @param String $date date we want flight number info
365
-	* @return Flight departure and arrival airports and time
366
-	*/
362
+	 * Get flight info from Transavia API
363
+	 * @param String $callsign The callsign
364
+	 * @param String $date date we want flight number info
365
+	 * @return Flight departure and arrival airports and time
366
+	 */
367 367
 	public function getTransavia($callsign, $date = 'NOW') {
368 368
 		global $globalTransaviaKey;
369 369
 		$Common = new Common();
@@ -389,10 +389,10 @@  discard block
 block discarded – undo
389 389
 	}
390 390
 
391 391
 	/**
392
-	* Get flight info from Tunisair
393
-	* @param String $callsign The callsign
394
-	* @return Flight departure and arrival airports and time
395
-	*/
392
+	 * Get flight info from Tunisair
393
+	 * @param String $callsign The callsign
394
+	 * @return Flight departure and arrival airports and time
395
+	 */
396 396
 	public function getTunisair($callsign) {
397 397
 		$Common = new Common();
398 398
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
 	}
410 410
 
411 411
 	/**
412
-	* Get flight info from Vueling
413
-	* @param String $callsign The callsign
414
-	* @return Flight departure and arrival airports and time
415
-	*/
412
+	 * Get flight info from Vueling
413
+	 * @param String $callsign The callsign
414
+	 * @return Flight departure and arrival airports and time
415
+	 */
416 416
 	public function getVueling($callsign,$date = 'NOW') {
417 417
 		$Common = new Common();
418 418
 		$check_date = new Datetime($date);
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
 	}
435 435
 
436 436
 	/**
437
-	* Get flight info from Iberia
438
-	* @param String $callsign The callsign
439
-	* @param String $date date we want flight number info
440
-	* @return Flight departure and arrival airports and time
441
-	*/
437
+	 * Get flight info from Iberia
438
+	 * @param String $callsign The callsign
439
+	 * @param String $date date we want flight number info
440
+	 * @return Flight departure and arrival airports and time
441
+	 */
442 442
 	public function getIberia($callsign, $date = 'NOW') {
443 443
 		$Common = new Common();
444 444
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -468,11 +468,11 @@  discard block
 block discarded – undo
468 468
 	}
469 469
 
470 470
 	/**
471
-	* Get flight info from Star Alliance
472
-	* @param String $callsign The callsign
473
-	* @param String $date date we want flight number info
474
-	* @return Flight departure and arrival airports and time
475
-	*/
471
+	 * Get flight info from Star Alliance
472
+	 * @param String $callsign The callsign
473
+	 * @param String $date date we want flight number info
474
+	 * @return Flight departure and arrival airports and time
475
+	 */
476 476
 
477 477
 	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
478 478
 		$Common = new Common();
@@ -504,11 +504,11 @@  discard block
 block discarded – undo
504 504
 
505 505
 
506 506
 	/**
507
-	* Get flight info from Alitalia
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 Alitalia
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 getAlitalia($callsign, $date = 'NOW') {
513 513
 		$Common = new Common();
514 514
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -527,11 +527,11 @@  discard block
 block discarded – undo
527 527
 	}
528 528
 
529 529
 	/**
530
-	* Get flight info from Brussels airlines
531
-	* @param String $callsign The callsign
532
-	* @param String $date date we want flight number info
533
-	* @return Flight departure and arrival airports and time
534
-	*/
530
+	 * Get flight info from Brussels airlines
531
+	 * @param String $callsign The callsign
532
+	 * @param String $date date we want flight number info
533
+	 * @return Flight departure and arrival airports and time
534
+	 */
535 535
 	private function getBrussels($callsign, $date = 'NOW') {
536 536
 		$Common = new Common();
537 537
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -541,24 +541,24 @@  discard block
 block discarded – undo
541 541
 		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
542 542
 		$data = $Common->getData($url);
543 543
 		if ($data != '') {
544
-		    //echo $data;
545
-		    $parsed_json = json_decode($data,true);
546
-		    if (isset($parsed_json[0]['FromAirportCode'])) {
544
+			//echo $data;
545
+			$parsed_json = json_decode($data,true);
546
+			if (isset($parsed_json[0]['FromAirportCode'])) {
547 547
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
548 548
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
549 549
 			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
550 550
 			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
551 551
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
552
-		    }
552
+			}
553 553
 		}
554 554
 	}
555 555
 
556 556
 	/**
557
-	* Get flight info from FlightRadar24
558
-	* @param String $callsign The callsign
559
-	* @param String $date date we want flight number info
560
-	* @return Flight departure and arrival airports and time
561
-	*/
557
+	 * Get flight info from FlightRadar24
558
+	 * @param String $callsign The callsign
559
+	 * @param String $date date we want flight number info
560
+	 * @return Flight departure and arrival airports and time
561
+	 */
562 562
 /*
563 563
 	public function getFlightRadar24($callsign, $date = 'NOW') {
564 564
 		$Common = new Common();
@@ -587,11 +587,11 @@  discard block
 block discarded – undo
587 587
 	}
588 588
   */
589 589
 	/**
590
-	* Get flight info from Lufthansa
591
-	* @param String $callsign The callsign
592
-	* @param String $date date we want flight number info
593
-	* @return Flight departure and arrival airports and time
594
-	*/
590
+	 * Get flight info from Lufthansa
591
+	 * @param String $callsign The callsign
592
+	 * @param String $date date we want flight number info
593
+	 * @return Flight departure and arrival airports and time
594
+	 */
595 595
 
596 596
 /*	private function getLufthansa($callsign, $date = 'NOW') {
597 597
 		$Common = new Common();
@@ -619,10 +619,10 @@  discard block
 block discarded – undo
619 619
 	}
620 620
   */
621 621
 	/**
622
-	* Get flight info from flytap
623
-	* @param String $callsign The callsign
624
-	* @return Flight departure and arrival airports and time
625
-	*/
622
+	 * Get flight info from flytap
623
+	 * @param String $callsign The callsign
624
+	 * @return Flight departure and arrival airports and time
625
+	 */
626 626
 	private function getFlyTap($callsign) {
627 627
 		$Common = new Common();
628 628
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -645,10 +645,10 @@  discard block
 block discarded – undo
645 645
 	}
646 646
 
647 647
 	/**
648
-	* Get flight info from flightmapper
649
-	* @param String $callsign The callsign
650
-	* @return Flight departure and arrival airports and time
651
-	*/
648
+	 * Get flight info from flightmapper
649
+	 * @param String $callsign The callsign
650
+	 * @return Flight departure and arrival airports and time
651
+	 */
652 652
 	public function getFlightMapper($callsign) {
653 653
 		$Common = new Common();
654 654
 		$airline_icao = '';
@@ -676,11 +676,11 @@  discard block
 block discarded – undo
676 676
 				$aarr = '';
677 677
 				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
678 678
 				if ($n == 7) {
679
-				    $departureTime = $dhour;
680
-				    $arrivalTime = $ahour;
681
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
682
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
683
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
679
+					$departureTime = $dhour;
680
+					$arrivalTime = $ahour;
681
+					$DepartureAirportIata = str_replace(array('(',')'),'',$darr);
682
+					$ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
683
+					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
684 684
 				}
685 685
 			}
686 686
 		}
@@ -688,10 +688,10 @@  discard block
 block discarded – undo
688 688
 	}
689 689
 
690 690
 	/**
691
-	* Get flight info from flightaware
692
-	* @param String $callsign The callsign
693
-	* @return Flight departure and arrival airports and time
694
-	*/
691
+	 * Get flight info from flightaware
692
+	 * @param String $callsign The callsign
693
+	 * @return Flight departure and arrival airports and time
694
+	 */
695 695
 	public function getFlightAware($callsign) {
696 696
 		global $globalFlightAwareUsername, $globalFlightAwarePassword;
697 697
 		date_default_timezone_set('UTC');
@@ -716,11 +716,11 @@  discard block
 block discarded – undo
716 716
 				$flight = $result['FlightInfoStatusResult']['flights'][0];
717 717
 				if (isset($flight['origin'])) {
718 718
 					return array(
719
-					    'DepartureAirportIATA' => $flight['origin']['alternate_ident'],
720
-					    'DepartureTime' => $flight['filed_departure_time']['time'],
721
-					    'ArrivalAirportIATA' => $flight['destination']['alternate_ident'],
722
-					    'ArrivalTime' => $flight['filed_arrival_time']['time'],
723
-					    'Source' => 'website_flightaware');
719
+						'DepartureAirportIATA' => $flight['origin']['alternate_ident'],
720
+						'DepartureTime' => $flight['filed_departure_time']['time'],
721
+						'ArrivalAirportIATA' => $flight['destination']['alternate_ident'],
722
+						'ArrivalTime' => $flight['filed_arrival_time']['time'],
723
+						'Source' => 'website_flightaware');
724 724
 				}
725 725
 			}
726 726
 		}
@@ -733,21 +733,21 @@  discard block
 block discarded – undo
733 733
 			$flight = reset($flights['flights']);
734 734
 			if (isset($flight['activityLog']['flights'][0]['origin'])) {
735 735
 				return array(
736
-				    'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
737
-				    'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
738
-				    'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
739
-				    'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
740
-				    'Source' => 'website_flightaware');
736
+					'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
737
+					'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
738
+					'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
739
+					'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
740
+					'Source' => 'website_flightaware');
741 741
 			}
742 742
 		}
743 743
 		return array();
744 744
 	}
745 745
 
746 746
 	/**
747
-	* Get flight info from CostToTravel
748
-	* @param String $callsign The callsign
749
-	* @return Flight departure and arrival airports and time
750
-	*/
747
+	 * Get flight info from CostToTravel
748
+	 * @param String $callsign The callsign
749
+	 * @return Flight departure and arrival airports and time
750
+	 */
751 751
 	public function getCostToTravel($callsign) {
752 752
 		$Common = new Common();
753 753
 		$url= "http://www.costtotravel.com/flight-number/".$callsign;
@@ -770,11 +770,11 @@  discard block
 block discarded – undo
770 770
 	}
771 771
 
772 772
 	/**
773
-	* Get flight info from Air Canada
774
-	* @param String $callsign The callsign
775
-	* @param String $date date we want flight number info
776
-	* @return Flight departure and arrival airports and time
777
-	*/
773
+	 * Get flight info from Air Canada
774
+	 * @param String $callsign The callsign
775
+	 * @param String $date date we want flight number info
776
+	 * @return Flight departure and arrival airports and time
777
+	 */
778 778
 	private function getAirCanada($callsign,$date = 'NOW') {
779 779
 		$Common = new Common();
780 780
 		if (class_exists("DomDocument") === FALSE) return array();
@@ -799,11 +799,11 @@  discard block
 block discarded – undo
799 799
 	}
800 800
 
801 801
 	/**
802
-	* Get flight info from Vietnam Airlines
803
-	* @param String $callsign The callsign
804
-	* @param String $date date we want flight number info
805
-	* @return Flight departure and arrival airports and time
806
-	*/
802
+	 * Get flight info from Vietnam Airlines
803
+	 * @param String $callsign The callsign
804
+	 * @param String $date date we want flight number info
805
+	 * @return Flight departure and arrival airports and time
806
+	 */
807 807
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
808 808
 		$Common = new Common();
809 809
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -825,12 +825,12 @@  discard block
 block discarded – undo
825 825
 	}
826 826
 
827 827
 	/**
828
-	* Get flight info from Air Berlin
829
-	* @param String $callsign The callsign
830
-	* @param String $date date we want flight number info
831
-	* @param String $carrier airline code
832
-	* @return Flight departure and arrival airports and time
833
-	*/
828
+	 * Get flight info from Air Berlin
829
+	 * @param String $callsign The callsign
830
+	 * @param String $date date we want flight number info
831
+	 * @param String $carrier airline code
832
+	 * @return Flight departure and arrival airports and time
833
+	 */
834 834
 	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
835 835
 		$Common = new Common();
836 836
 		date_default_timezone_set('UTC');
@@ -859,11 +859,11 @@  discard block
 block discarded – undo
859 859
 			$table = $Common->table2array($data);
860 860
 			$flight = $table;
861 861
 			if (isset($flight[5][4])) {
862
-			    $arrivalTime = $flight[5][4];
863
-			    $arrivalAirport = $flight[5][3];
862
+				$arrivalTime = $flight[5][4];
863
+				$arrivalAirport = $flight[5][3];
864 864
 			} else {
865
-			    $arrivalTime = '';
866
-			    $arrivalAirport = '';
865
+				$arrivalTime = '';
866
+				$arrivalAirport = '';
867 867
 			}
868 868
 		} else return array();
869 869
 		$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';
Please login to merge, or discard this patch.