Completed
Push — master ( 156634...177cfd )
by Yannick
07:47
created
waypoints-geojson.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		date_default_timezone_set('UTC');
27 27
 		//waypoint plotting
28 28
 		$output .= '{"type": "Feature",';
29
-		    $output .= '"properties": {';
29
+			$output .= '"properties": {';
30 30
 			$output .= '"segment_name": "'.$spotter_item['segment_name'].'",';
31 31
 			$output .= '"base": "'.$spotter_item['base'].'",';
32 32
 			$output .= '"top": "'.$spotter_item['top'].'",';
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
 				$output .= '"stroke": "#f0f0f0",';
50 50
 				$output .= '"stroke-width": 2';
51 51
 //			}
52
-		    $output .= '},';
53
-		    $output .= '"geometry": {';
52
+			$output .= '},';
53
+			$output .= '"geometry": {';
54 54
 			$output .= '"type": "LineString",';
55 55
 			$output .= '"coordinates": [';
56
-			    //$output .= '['.$spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].'], ['.$spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].'], ['.$spotter_item['longitude_end_seg2'].', '.$spotter_item['latitude_end_seg2'].']';
57
-			    $output .= '['.$spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].','.round($spotter_item['base']*100*0.3048).'], ['.$spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].','.round($spotter_item['base']*100*0.3048).']';
56
+				//$output .= '['.$spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].'], ['.$spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].'], ['.$spotter_item['longitude_end_seg2'].', '.$spotter_item['latitude_end_seg2'].']';
57
+				$output .= '['.$spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].','.round($spotter_item['base']*100*0.3048).'], ['.$spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].','.round($spotter_item['base']*100*0.3048).']';
58 58
 			//    $output .= '['.$spotter_item['latitude_begin'].', '.$spotter_item['longitude_begin'].'], ['.$spotter_item['latitude_end'].', '.$spotter_item['longitude_end'].']';
59 59
 			$output .= ']';
60
-		    $output .= '}';
60
+			$output .= '}';
61 61
 /*		    $output .= '"geometry": {';
62 62
 			$output .= '"type": "Point",';
63 63
 			$output .= '"coordinates": [';
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		$output .= '},';
69 69
 		//waypoint plotting
70 70
 		$output .= '{"type": "Feature",';
71
-		    $output .= '"properties": {';
71
+			$output .= '"properties": {';
72 72
 			$output .= '"ident": "'.$spotter_item['name_begin'].'",';
73 73
 			$output .= '"high": "'.$spotter_item['high'].'",';
74 74
 			$output .= '"alt": "'.$spotter_item['base'].'",';
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
 				$output .= '"marker-size": "small",';
99 99
 				$output .= '"marker-color": "#0000ff"';
100 100
 			}
101
-		    $output .= '},';
102
-		    $output .= '"geometry": {';
101
+			$output .= '},';
102
+			$output .= '"geometry": {';
103 103
 			$output .= '"type": "Point",';
104 104
 			$output .= '"coordinates": [';
105
-			    $output .= $spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].', '.round($spotter_item['base']*100*0.3048);;
105
+				$output .= $spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].', '.round($spotter_item['base']*100*0.3048);;
106 106
 			$output .= ']';
107
-		    $output .= '}';
107
+			$output .= '}';
108 108
 
109 109
 		$output .= '},';
110 110
 		$output .= '{"type": "Feature",';
111
-		    $output .= '"properties": {';
111
+			$output .= '"properties": {';
112 112
 			$output .= '"ident": "'.$spotter_item['name_end'].'",';
113 113
 			$output .= '"high": "'.$spotter_item['high'].'",';
114 114
 			$output .= '"alt": "'.$spotter_item['top'].'",';
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
 				$output .= '"marker-size": "small",';
146 146
 				$output .= '"marker-color": "#0000ff"';
147 147
 			}
148
-		    $output .= '},';
149
-		    $output .= '"geometry": {';
148
+			$output .= '},';
149
+			$output .= '"geometry": {';
150 150
 			$output .= '"type": "Point",';
151 151
 			$output .= '"coordinates": [';
152
-			    $output .= $spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].', '.round($spotter_item['base']*100*0.3048);
152
+				$output .= $spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].', '.round($spotter_item['base']*100*0.3048);
153 153
 			$output .= ']';
154
-		    $output .= '}';
154
+			$output .= '}';
155 155
 
156 156
 		$output .= '},';
157 157
 	}
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 if (isset($_GET['coord'])) 
12 12
 {
13
-	$coords = explode(',',$_GET['coord']);
13
+	$coords = explode(',', $_GET['coord']);
14 14
 	$spotter_array = $Spotter->getAllWaypointsInfobyCoord($coords);
15 15
 } else {
16 16
 	die;
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 if (!empty($spotter_array))
22 22
 {	  
23 23
 //	print_r($spotter_array);
24
-	foreach($spotter_array as $spotter_item)
24
+	foreach ($spotter_array as $spotter_item)
25 25
 	{
26 26
 		date_default_timezone_set('UTC');
27 27
 		//waypoint plotting
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 		    $output .= '"geometry": {';
103 103
 			$output .= '"type": "Point",';
104 104
 			$output .= '"coordinates": [';
105
-			    $output .= $spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].', '.round($spotter_item['base']*100*0.3048);;
105
+			    $output .= $spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].', '.round($spotter_item['base']*100*0.3048); ;
106 106
 			$output .= ']';
107 107
 		    $output .= '}';
108 108
 
Please login to merge, or discard this patch.
airspace-data.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 <button type="button" class="close">&times;</button>
8 8
 <?php
9 9
 
10
-$airspaceid = filter_input(INPUT_GET,'airspace',FILTER_SANITIZE_NUMBER_INT);
10
+$airspaceid = filter_input(INPUT_GET, 'airspace', FILTER_SANITIZE_NUMBER_INT);
11 11
 //$notamref = urldecode($notamref);
12 12
 if ($globalDBdriver == 'mysql') {
13 13
 	$query = "SELECT * FROM airspace WHERE ogr_fid = :id";
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 try {
19 19
 	$sth = $Connection->db->prepare($query);
20 20
 	$sth->execute(array(':id' => $airspaceid));
21
-} catch(PDOException $e) {
21
+} catch (PDOException $e) {
22 22
 	echo "error";
23 23
 }
24
-$result=$sth->fetchAll(PDO::FETCH_ASSOC);
24
+$result = $sth->fetchAll(PDO::FETCH_ASSOC);
25 25
 $airspace = $result[0];
26 26
 date_default_timezone_set('UTC');
27 27
 print '<div class="top">';
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@  discard block
 block discarded – undo
25 25
 $airspace = $result[0];
26 26
 date_default_timezone_set('UTC');
27 27
 print '<div class="top">';
28
-if (isset($airspace['name'])) $airspace['title'] = $airspace['name']; 
28
+if (isset($airspace['name'])) {
29
+	$airspace['title'] = $airspace['name'];
30
+}
29 31
 print '<div class="right"><div class="callsign-details"><div class="callsign">'.$airspace['title'].'</a></div>';
30 32
 print '</div>';
31 33
 print '<div class="details">';
@@ -44,13 +46,17 @@  discard block
 block discarded – undo
44 46
 	print '</div>';
45 47
 }
46 48
 
47
-if (isset($airspace['ceiling'])) $airspace['tops'] = $airspace['ceiling'];
49
+if (isset($airspace['ceiling'])) {
50
+	$airspace['tops'] = $airspace['ceiling'];
51
+}
48 52
 print '<div>';
49 53
 print '<span>'._("Tops").'</span>';
50 54
 print $airspace['tops'];
51 55
 print '</div>';
52 56
 
53
-if (isset($airspace['floor'])) $airspace['base'] = $airspace['floor'];
57
+if (isset($airspace['floor'])) {
58
+	$airspace['base'] = $airspace['floor'];
59
+}
54 60
 print '<div>';
55 61
 print '<span>'._("Base").'</span>';
56 62
 print $airspace['base'];
Please login to merge, or discard this patch.
scripts/update_db.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
10 10
 	exec("ps ux", $output, $result);
11 11
 	$j = 0;
12
-	foreach ($output as $line) if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
12
+	foreach ($output as $line) if (strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
13 13
 	if ($j > 1) {
14 14
 		echo "Script is already runnning...";
15 15
 		die();
Please login to merge, or discard this patch.
Braces   +20 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  discard block
 block discarded – undo
9 9
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
10 10
 	exec("ps ux", $output, $result);
11 11
 	$j = 0;
12
-	foreach ($output as $line) if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
12
+	foreach ($output as $line) {
13
+		if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
14
+	}
13 15
 	if ($j > 1) {
14 16
 		echo "Script is already runnning...";
15 17
 		die();
@@ -28,8 +30,10 @@  discard block
 block discarded – undo
28 30
 			$update_db->update_notam();
29 31
 		}
30 32
 		$update_db->insert_last_notam_update();
31
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n";
32
-}
33
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) {
34
+		echo "NOTAM are only updated once a day.\n";
35
+	}
36
+	}
33 37
 
34 38
 if ($update_db->check_last_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
35 39
 	$update_db->update_all();
@@ -37,7 +41,9 @@  discard block
 block discarded – undo
37 41
 //	$Spotter = new Spotter();
38 42
 //	$Spotter->updateFieldsFromOtherTables();
39 43
 	$update_db->insert_last_update();
40
-} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
44
+} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) {
45
+	echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
46
+}
41 47
 
42 48
 
43 49
 if (isset($globalMETAR) && isset($globalMETARcycle) && $globalMETAR && $globalMETARcycle) {
@@ -47,22 +53,28 @@  discard block
 block discarded – undo
47 53
 	if ($METAR->check_last_update()) {
48 54
 		$METAR->addMETARCycle();
49 55
 		$METAR->insert_last_update();
50
-	} else echo "METAR are only updated every 30 minutes.\n";
51
-}
56
+	} else {
57
+		echo "METAR are only updated every 30 minutes.\n";
58
+	}
59
+	}
52 60
 
53 61
 
54 62
 if (isset($globalOwner) && $globalOwner && $update_db->check_last_owner_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
55 63
 	echo "Updating private aircraft's owners...";
56 64
 	$update_db->update_owner();
57 65
 	$update_db->insert_last_owner_update();
58
-} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n";
66
+} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
67
+	echo "Owner are only updated every 15 days.\n";
68
+}
59 69
 
60 70
 if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
61 71
 	echo "Updating schedules...";
62 72
 	$update_db->update_oneworld();
63 73
 	$update_db->update_skyteam();
64 74
 	$update_db->insert_last_schedules_update();
65
-} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n";
75
+} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
76
+	echo "Schedules are only updated every 15 days.\n";
77
+}
66 78
 
67 79
 if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) {
68 80
 	echo "Updating statistics and archive old data...";
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	    die;
38 38
 	}
39 39
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
40
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
40
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
41 41
     }
42 42
 }
43 43
 
44
-$options = getopt('s::',array('source::','server','idsource::'));
44
+$options = getopt('s::', array('source::', 'server', 'idsource::'));
45 45
 //if (isset($options['s'])) $hosts = array($options['s']);
46 46
 //elseif (isset($options['source'])) $hosts = array($options['source']);
47 47
 if (isset($options['s'])) {
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
 else $id_source = 1;
57 57
 if (isset($globalServer) && $globalServer) {
58 58
     if ($globalDebug) echo "Using Server Mode\n";
59
-    $SI=new SpotterServer();
60
-} else $SI=new SpotterImport($Connection->db);
59
+    $SI = new SpotterServer();
60
+} else $SI = new SpotterImport($Connection->db);
61 61
 //$APRS=new APRS($Connection->db);
62
-$SBS=new SBS();
63
-$ACARS=new ACARS($Connection->db);
64
-$Common=new Common();
62
+$SBS = new SBS();
63
+$ACARS = new ACARS($Connection->db);
64
+$Common = new Common();
65 65
 date_default_timezone_set('UTC');
66 66
 //$servertz = system('date +%Z');
67 67
 // signal handler - playing nice with sockets and dump1090
68 68
 if (function_exists('pcntl_fork')) {
69
-    pcntl_signal(SIGINT,  function() {
69
+    pcntl_signal(SIGINT, function() {
70 70
         global $sockets;
71 71
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
72 72
         die("Bye!\n");
@@ -109,34 +109,34 @@  discard block
 block discarded – undo
109 109
 
110 110
 function connect_all($hosts) {
111 111
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
112
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
112
+    global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs;
113 113
     if ($globalDebug) echo 'Connect to all...'."\n";
114 114
     foreach ($hosts as $id => $value) {
115 115
 	$host = $value['host'];
116 116
 	$globalSources[$id]['last_exec'] = 0;
117 117
 	// Here we check type of source(s)
118
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
119
-            if (preg_match('/deltadb.txt$/i',$host)) {
118
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
119
+            if (preg_match('/deltadb.txt$/i', $host)) {
120 120
         	//$formats[$id] = 'deltadbtxt';
121 121
         	$globalSources[$id]['format'] = 'deltadbtxt';
122 122
         	//$last_exec['deltadbtxt'] = 0;
123 123
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
124
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
124
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
125 125
         	//$formats[$id] = 'vatsimtxt';
126 126
         	$globalSources[$id]['format'] = 'vatsimtxt';
127 127
         	//$last_exec['vatsimtxt'] = 0;
128 128
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
129
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
129
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
130 130
         	//$formats[$id] = 'aircraftlistjson';
131 131
         	$globalSources[$id]['format'] = 'aircraftlistjson';
132 132
         	//$last_exec['aircraftlistjson'] = 0;
133 133
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
134
-    	    } else if (preg_match('/opensky/i',$host)) {
134
+    	    } else if (preg_match('/opensky/i', $host)) {
135 135
         	//$formats[$id] = 'aircraftlistjson';
136 136
         	$globalSources[$id]['format'] = 'opensky';
137 137
         	//$last_exec['aircraftlistjson'] = 0;
138 138
         	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
139
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
139
+    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) {
140 140
         	//$formats[$id] = 'radarvirtueljson';
141 141
         	$globalSources[$id]['format'] = 'radarvirtueljson';
142 142
         	//$last_exec['radarvirtueljson'] = 0;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
146 146
         	    exit(0);
147 147
         	}
148
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
148
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
149 149
         	//$formats[$id] = 'planeupdatefaa';
150 150
         	$globalSources[$id]['format'] = 'planeupdatefaa';
151 151
         	//$last_exec['planeupdatefaa'] = 0;
@@ -154,26 +154,26 @@  discard block
 block discarded – undo
154 154
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
155 155
         	    exit(0);
156 156
         	}
157
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
157
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
158 158
         	//$formats[$id] = 'phpvmacars';
159 159
         	$globalSources[$id]['format'] = 'phpvmacars';
160 160
         	//$last_exec['phpvmacars'] = 0;
161 161
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
162
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
162
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
163 163
         	//$formats[$id] = 'phpvmacars';
164 164
         	$globalSources[$id]['format'] = 'vam';
165 165
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
166
-            } else if (preg_match('/whazzup/i',$host)) {
166
+            } else if (preg_match('/whazzup/i', $host)) {
167 167
         	//$formats[$id] = 'whazzup';
168 168
         	$globalSources[$id]['format'] = 'whazzup';
169 169
         	//$last_exec['whazzup'] = 0;
170 170
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
171
-            } else if (preg_match('/recentpireps/i',$host)) {
171
+            } else if (preg_match('/recentpireps/i', $host)) {
172 172
         	//$formats[$id] = 'pirepsjson';
173 173
         	$globalSources[$id]['format'] = 'pirepsjson';
174 174
         	//$last_exec['pirepsjson'] = 0;
175 175
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
176
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
176
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
177 177
         	//$formats[$id] = 'fr24json';
178 178
         	$globalSources[$id]['format'] = 'fr24json';
179 179
         	//$last_exec['fr24json'] = 0;
@@ -183,15 +183,15 @@  discard block
 block discarded – undo
183 183
         	    exit(0);
184 184
         	}
185 185
             //} else if (preg_match('/10001/',$host)) {
186
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
186
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
187 187
         	//$formats[$id] = 'tsv';
188 188
         	$globalSources[$id]['format'] = 'tsv';
189 189
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
190 190
             }
191
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
191
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
192 192
         	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
193
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
194
-	    $hostport = explode(':',$host);
193
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
194
+	    $hostport = explode(':', $host);
195 195
 	    if (isset($hostport[1])) {
196 196
 		$port = $hostport[1];
197 197
 		$hostn = $hostport[0];
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 		$hostn = $globalSources[$id]['host'];
201 201
 	    }
202 202
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
203
-        	$s = create_socket($hostn,$port, $errno, $errstr);
203
+        	$s = create_socket($hostn, $port, $errno, $errstr);
204 204
     	    } else {
205
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
205
+        	$s = create_socket_udp($hostn, $port, $errno, $errstr);
206 206
 	    }
207 207
 	    if ($s) {
208 208
     	        $sockets[$id] = $s;
209 209
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
210
-		    if (preg_match('/aprs/',$hostn)) {
210
+		    if (preg_match('/aprs/', $hostn)) {
211 211
 			//$formats[$id] = 'aprs';
212 212
 			$globalSources[$id]['format'] = 'aprs';
213 213
 			//$aprs_connect = 0;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
249 249
 else $timeout = 20;
250 250
 $errno = '';
251
-$errstr='';
251
+$errstr = '';
252 252
 
253 253
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
254 254
 /* Initiate connections to all the hosts simultaneously */
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 
278 278
 if ($use_aprs) {
279 279
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
280
-	$APRS=new APRS();
280
+	$APRS = new APRS();
281 281
 	$aprs_connect = 0;
282 282
 	$aprs_keep = 120;
283 283
 	$aprs_last_tx = time();
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	else $aprs_ssid = 'FAM';
289 289
 	//else $aprs_ssid = 'PerlEx';
290 290
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
291
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
291
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
292 292
 	if ($aprs_full) $aprs_filter = '';
293 293
 	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
294 294
 	else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
@@ -299,12 +299,12 @@  discard block
 block discarded – undo
299 299
 sleep(1);
300 300
 if ($globalDebug) echo "SCAN MODE \n\n";
301 301
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
302
-$endtime = time()+$globalCronEnd;
302
+$endtime = time() + $globalCronEnd;
303 303
 $i = 1;
304 304
 $tt = array();
305 305
 // Delete all ATC
306 306
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
307
-	$ATC=new ATC($Connection->db);
307
+	$ATC = new ATC($Connection->db);
308 308
 }
309 309
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
310 310
 	$ATC->deleteAll();
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 
313 313
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
314 314
 while ($i > 0) {
315
-    if (!$globalDaemon) $i = $endtime-time();
315
+    if (!$globalDaemon) $i = $endtime - time();
316 316
     // Delete old ATC
317 317
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
318 318
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	}
327 327
 	if ($max != $globalMinFetch) {
328 328
 	    if ($globalDebug) echo 'Sleeping...'."\n";
329
-	    sleep($globalMinFetch-$max+2);
329
+	    sleep($globalMinFetch - $max + 2);
330 330
 	}
331 331
     }
332 332
 
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
338 338
 	    //$buffer = $Common->getData($hosts[$id]);
339 339
 	    $buffer = $Common->getData($value['host']);
340
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
341
-	    $buffer = explode('\n',$buffer);
340
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
341
+	    $buffer = explode('\n', $buffer);
342 342
 	    foreach ($buffer as $line) {
343 343
     		if ($line != '') {
344 344
     		    $line = explode(',', $line);
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value[' last_exec'] > $globalMinFetch))) {
368 368
 	    //$buffer = $Common->getData($hosts[$id]);
369 369
 	    $buffer = $Common->getData($value['host']);
370
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
371
-	    $buffer = explode('\n',$buffer);
370
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
371
+	    $buffer = explode('\n', $buffer);
372 372
 	    foreach ($buffer as $line) {
373 373
     		if ($line != '') {
374 374
     		    $line = explode(':', $line);
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 			$data['id'] = $line[1].'-'.$line[0];
378 378
 			$data['pilot_id'] = $line[1];
379 379
 			$data['pilot_name'] = $line[2];
380
-			$data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT);
380
+			$data['hex'] = str_pad(dechex($line[1]), 6, '000000', STR_PAD_LEFT);
381 381
 			$data['ident'] = $line[0]; // ident
382 382
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
383 383
 			$data['speed'] = $line[8]; // speed
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
394 394
 			if (isset($line[37])) $data['last_update'] = $line[37];
395 395
 		        $data['departure_airport_icao'] = $line[11];
396
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
396
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
397 397
 		        $data['arrival_airport_icao'] = $line[13];
398 398
 			$data['frequency'] = $line[4];
399 399
 			$data['type'] = $line[18];
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
     			$data['id_source'] = $id_source;
403 403
 	    		//$data['arrival_airport_time'] = ;
404 404
 	    		if ($line[9] != '') {
405
-	    		    $aircraft_data = explode('/',$line[9]);
405
+	    		    $aircraft_data = explode('/', $line[9]);
406 406
 	    		    if (isset($aircraft_data[1])) {
407 407
 	    			$data['aircraft_icao'] = $aircraft_data[1];
408 408
 	    		    }
@@ -416,9 +416,9 @@  discard block
 block discarded – undo
416 416
     			if ($line[3] == 'PILOT') $SI->add($data);
417 417
 			elseif ($line[3] == 'ATC') {
418 418
 				//print_r($data);
419
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
420
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
421
-				$typec = substr($data['ident'],-3);
419
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
420
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
421
+				$typec = substr($data['ident'], -3);
422 422
 				if ($typec == 'APP') $data['type'] = 'Approach';
423 423
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
424 424
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
430 430
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
431 431
 				
432
-				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']);
432
+				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']);
433 433
 			}
434 434
     			unset($data);
435 435
     		    }
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
     	    $last_exec[$id]['last'] = time();
441 441
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
442 442
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
443
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
443
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
444 444
 	    if ($buffer != '') {
445
-	    $all_data = json_decode($buffer,true);
445
+	    $all_data = json_decode($buffer, true);
446 446
 	    if (isset($all_data['acList'])) {
447 447
 		foreach ($all_data['acList'] as $line) {
448 448
 		    $data = array();
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
497 497
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
498 498
 	    $buffer = $Common->getData($value['host']);
499
-	    $all_data = json_decode($buffer,true);
499
+	    $all_data = json_decode($buffer, true);
500 500
 	    if (isset($all_data['planes'])) {
501 501
 		foreach ($all_data['planes'] as $key => $line) {
502 502
 		    $data = array();
@@ -512,12 +512,12 @@  discard block
 block discarded – undo
512 512
 		    $data['emergency'] = ''; // emergency
513 513
 		    $data['registration'] = $line[2];
514 514
 		    $data['aircraft_icao'] = $line[0];
515
-		    $deparr = explode('-',$line[1]);
515
+		    $deparr = explode('-', $line[1]);
516 516
 		    if (count($deparr) == 2) {
517 517
 			$data['departure_airport_icao'] = $deparr[0];
518 518
 			$data['arrival_airport_icao'] = $deparr[1];
519 519
 		    }
520
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
520
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
521 521
 	    	    $data['format_source'] = 'planeupdatefaa';
522 522
     		    $data['id_source'] = $id_source;
523 523
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
     	    $last_exec[$id]['last'] = time();
530 530
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
531 531
 	    $buffer = $Common->getData($value['host']);
532
-	    $all_data = json_decode($buffer,true);
532
+	    $all_data = json_decode($buffer, true);
533 533
 	    if (isset($all_data['states'])) {
534 534
 		foreach ($all_data['states'] as $key => $line) {
535 535
 		    $data = array();
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 		    //$data['emergency'] = ''; // emergency
546 546
 		    //$data['registration'] = $line[2];
547 547
 		    //$data['aircraft_icao'] = $line[0];
548
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
548
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
549 549
 	    	    $data['format_source'] = 'opensky';
550 550
     		    $data['id_source'] = $id_source;
551 551
 		    $SI->add($data);
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
559 559
 	    //$buffer = $Common->getData($hosts[$id]);
560 560
 	    $buffer = $Common->getData($value['host']);
561
-	    $all_data = json_decode($buffer,true);
561
+	    $all_data = json_decode($buffer, true);
562 562
 	    foreach ($all_data as $key => $line) {
563 563
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
564 564
 		    $data = array();
@@ -589,11 +589,11 @@  discard block
 block discarded – undo
589 589
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
590 590
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
591 591
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
592
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
592
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
593 593
 	    //echo $buffer;
594
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
595
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
596
-	    $all_data = json_decode($buffer,true);
594
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
595
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
596
+	    $all_data = json_decode($buffer, true);
597 597
 	    if (json_last_error() != JSON_ERROR_NONE) {
598 598
 		die(json_last_error_msg());
599 599
 	    }
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 			//$data['departure_airport_iata'] = $line[11];
616 616
 			//$data['arrival_airport_iata'] = $line[12];
617 617
 	    		//$data['emergency'] = ''; // emergency
618
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
618
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
619 619
 	    		$data['format_source'] = 'radarvirtueljson';
620 620
     			$data['id_source'] = $id_source;
621 621
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -630,13 +630,13 @@  discard block
 block discarded – undo
630 630
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
631 631
 	    //$buffer = $Common->getData($hosts[$id]);
632 632
 	    $buffer = $Common->getData($value['host'].'?'.time());
633
-	    $all_data = json_decode(utf8_encode($buffer),true);
633
+	    $all_data = json_decode(utf8_encode($buffer), true);
634 634
 	    
635 635
 	    if (isset($all_data['pireps'])) {
636 636
 	        foreach ($all_data['pireps'] as $line) {
637 637
 		    $data = array();
638 638
 		    $data['id'] = $line['id'];
639
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
639
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
640 640
 		    $data['ident'] = $line['callsign']; // ident
641 641
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
642 642
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -665,9 +665,9 @@  discard block
 block discarded – undo
665 665
 			$SI->add($data);
666 666
 		    //    print_r($data);
667 667
     		    } elseif ($line['icon'] == 'ct') {
668
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
669
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
670
-			$typec = substr($data['ident'],-3);
668
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
669
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
670
+			$typec = substr($data['ident'], -3);
671 671
 			$data['type'] = '';
672 672
 			if ($typec == 'APP') $data['type'] = 'Approach';
673 673
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
679 679
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
680 680
 			else $data['type'] = 'Observer';
681
-			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']);
681
+			echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name']);
682 682
 		    }
683 683
 		    unset($data);
684 684
 		}
@@ -690,13 +690,13 @@  discard block
 block discarded – undo
690 690
 	    //$buffer = $Common->getData($hosts[$id]);
691 691
 	    if ($globalDebug) echo 'Get Data...'."\n";
692 692
 	    $buffer = $Common->getData($value['host']);
693
-	    $all_data = json_decode($buffer,true);
693
+	    $all_data = json_decode($buffer, true);
694 694
 	    if ($buffer != '' && is_array($all_data)) {
695 695
 		foreach ($all_data as $line) {
696 696
 	    	    $data = array();
697 697
 	    	    //$data['id'] = $line['id']; // id not usable
698 698
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
699
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
699
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
700 700
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
701 701
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
702 702
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -719,12 +719,12 @@  discard block
 block discarded – undo
719 719
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
720 720
 		    if (isset($line['aircraftname'])) {
721 721
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
722
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
723
-	    		$aircraft_data = explode('-',$line['aircraftname']);
722
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
723
+	    		$aircraft_data = explode('-', $line['aircraftname']);
724 724
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
725 725
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
726 726
 	    		else {
727
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
727
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
728 728
 	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
729 729
 	    		    else $data['aircraft_icao'] = $line['aircraftname'];
730 730
 	    		}
@@ -746,13 +746,13 @@  discard block
 block discarded – undo
746 746
 	    //$buffer = $Common->getData($hosts[$id]);
747 747
 	    if ($globalDebug) echo 'Get Data...'."\n";
748 748
 	    $buffer = $Common->getData($value['host']);
749
-	    $all_data = json_decode($buffer,true);
749
+	    $all_data = json_decode($buffer, true);
750 750
 	    if ($buffer != '' && is_array($all_data)) {
751 751
 		foreach ($all_data as $line) {
752 752
 	    	    $data = array();
753 753
 	    	    //$data['id'] = $line['id']; // id not usable
754 754
 	    	    $data['id'] = $line['flight_id'];
755
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
755
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
756 756
 	    	    $data['pilot_name'] = $line['pilot_name'];
757 757
 	    	    $data['pilot_id'] = $line['pilot_id'];
758 758
 	    	    $data['ident'] = $line['callsign']; // ident
@@ -802,9 +802,9 @@  discard block
 block discarded – undo
802 802
 		    //$value = $formats[$nb];
803 803
 		    $format = $globalSources[$nb]['format'];
804 804
         	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv') {
805
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
805
+        		$buffer = socket_read($r, 6000, PHP_NORMAL_READ);
806 806
         	    } else {
807
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
807
+	    	        $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
808 808
 	    	    }
809 809
         	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
810 810
         	    //echo $buffer."\n";
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
813 813
 		    $error = false;
814 814
 		    //$SI::del();
815
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
815
+		    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
816 816
 		    // SBS format is CSV format
817 817
 		    if ($buffer != '') {
818 818
 			$tt[$format] = 0;
@@ -831,10 +831,10 @@  discard block
 block discarded – undo
831 831
                         } elseif ($format == 'flightgearsp') {
832 832
                     	    //echo $buffer."\n";
833 833
                     	    if (strlen($buffer) > 5) {
834
-				$line = explode(',',$buffer);
834
+				$line = explode(',', $buffer);
835 835
 				$data = array();
836 836
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
837
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
837
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
838 838
 				$data['ident'] = $line[6];
839 839
 				$data['aircraft_name'] = $line[7];
840 840
 				$data['longitude'] = $line[1];
@@ -845,21 +845,21 @@  discard block
 block discarded – undo
845 845
 				$data['datetime'] = date('Y-m-d H:i:s');
846 846
 				$data['format_source'] = 'flightgearsp';
847 847
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
848
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
848
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
849 849
 			    }
850 850
                         } elseif ($format == 'acars') {
851 851
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
852 852
 			    $ACARS->add(trim($buffer));
853
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
853
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
854 854
 			    $ACARS->deleteLiveAcarsData();
855 855
 			} elseif ($format == 'flightgearmp') {
856
-			    if (substr($buffer,0,1) != '#') {
856
+			    if (substr($buffer, 0, 1) != '#') {
857 857
 				$data = array();
858 858
 				//echo $buffer."\n";
859
-				$line = explode(' ',$buffer);
859
+				$line = explode(' ', $buffer);
860 860
 				if (count($line) == 11) {
861
-				    $userserver = explode('@',$line[0]);
862
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
861
+				    $userserver = explode('@', $line[0]);
862
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
863 863
 				    $data['ident'] = $userserver[0];
864 864
 				    $data['registration'] = $userserver[0];
865 865
 				    $data['latitude'] = $line[4];
@@ -867,24 +867,24 @@  discard block
 block discarded – undo
867 867
 				    $data['altitude'] = $line[6];
868 868
 				    $data['datetime'] = date('Y-m-d H:i:s');
869 869
 				    $aircraft_type = $line[10];
870
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
871
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
870
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
871
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
872 872
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
873 873
 				}
874 874
 			    }
875 875
 			} elseif ($format == 'beast') {
876 876
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
877 877
 			    die;
878
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
878
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
879 879
 			    $line = explode("\t", $buffer);
880
-			    for($k = 0; $k < count($line); $k=$k+2) {
880
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
881 881
 				$key = $line[$k];
882
-			        $lined[$key] = $line[$k+1];
882
+			        $lined[$key] = $line[$k + 1];
883 883
 			    }
884 884
     			    if (count($lined) > 3) {
885 885
     				$data['hex'] = $lined['hexid'];
886 886
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
887
-    				$data['datetime'] = date('Y-m-d H:i:s');;
887
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
888 888
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
889 889
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
890 890
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -902,24 +902,24 @@  discard block
 block discarded – undo
902 902
     			    } else $error = true;
903 903
 			} elseif ($format == 'aprs' && $use_aprs) {
904 904
 			    if ($aprs_connect == 0) {
905
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
905
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
906 906
 				$aprs_connect = 1;
907 907
 			    }
908
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
908
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
909 909
 				$aprs_last_tx = time();
910 910
 				$data_aprs = "# Keep alive";
911
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
911
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
912 912
 			    }
913 913
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
914
-			    $buffer = str_replace('APRS <- ','',$buffer);
915
-			    $buffer = str_replace('APRS -> ','',$buffer);
916
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
914
+			    $buffer = str_replace('APRS <- ', '', $buffer);
915
+			    $buffer = str_replace('APRS -> ', '', $buffer);
916
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
917 917
 				$line = $APRS->parse($buffer);
918 918
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
919 919
 				    $data = array();
920 920
 				    //print_r($line);
921 921
 				    $data['hex'] = $line['address'];
922
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
922
+				    $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
923 923
 				    //$data['datetime'] = date('Y-m-d H:i:s');
924 924
 				    $data['ident'] = $line['ident'];
925 925
 				    $data['latitude'] = $line['latitude'];
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
 				    $currentdate = date('Y-m-d H:i:s');
940 940
 				    $aprsdate = strtotime($data['datetime']);
941 941
 				    // Accept data if time <= system time + 20s
942
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
942
+				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
943 943
 				    else {
944 944
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
945 945
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 				connect_all($sourceee);
1025 1025
 				$sourceee = array();
1026 1026
 				//connect_all($globalSources);
1027
-				$tt[$format]=0;
1027
+				$tt[$format] = 0;
1028 1028
 				break;
1029 1029
 			    }
1030 1030
 			}
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 		}
1033 1033
 	    } else {
1034 1034
 		$error = socket_strerror(socket_last_error());
1035
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1035
+		if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1036 1036
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) || time() - $time >= $timeout) {
1037 1037
 			if (isset($globalDebug)) echo "Restarting...\n";
1038 1038
 			// Restart the script if possible
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 			    if ($globalDebug) echo "Shutdown all sockets...";
1041 1041
 			    
1042 1042
 			    foreach ($sockets as $sock) {
1043
-				@socket_shutdown($sock,2);
1043
+				@socket_shutdown($sock, 2);
1044 1044
 				@socket_close($sock);
1045 1045
 			    }
1046 1046
 			    
Please login to merge, or discard this patch.
Braces   +509 added lines, -176 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 
17
-if (!isset($globalDebug)) $globalDebug = FALSE;
17
+if (!isset($globalDebug)) {
18
+	$globalDebug = FALSE;
19
+}
18 20
 
19 21
 // Check if schema is at latest version
20 22
 $Connection = new Connection();
@@ -51,13 +53,22 @@  discard block
 block discarded – undo
51 53
     $globalSources = array();
52 54
     $globalSources[] = array('host' => $options['source']);
53 55
 }
54
-if (isset($options['server'])) $globalServer = TRUE;
55
-if (isset($options['idsource'])) $id_source = $options['idsource'];
56
-else $id_source = 1;
56
+if (isset($options['server'])) {
57
+	$globalServer = TRUE;
58
+}
59
+if (isset($options['idsource'])) {
60
+	$id_source = $options['idsource'];
61
+} else {
62
+	$id_source = 1;
63
+}
57 64
 if (isset($globalServer) && $globalServer) {
58
-    if ($globalDebug) echo "Using Server Mode\n";
65
+    if ($globalDebug) {
66
+    	echo "Using Server Mode\n";
67
+    }
59 68
     $SI=new SpotterServer();
60
-} else $SI=new SpotterImport($Connection->db);
69
+} else {
70
+	$SI=new SpotterImport($Connection->db);
71
+}
61 72
 //$APRS=new APRS($Connection->db);
62 73
 $SBS=new SBS();
63 74
 $ACARS=new ACARS($Connection->db);
@@ -75,7 +86,9 @@  discard block
 block discarded – undo
75 86
 }
76 87
 
77 88
 // let's try and connect
78
-if ($globalDebug) echo "Connecting...\n";
89
+if ($globalDebug) {
90
+	echo "Connecting...\n";
91
+}
79 92
 $use_aprs = false;
80 93
 $aprs_full = false;
81 94
 
@@ -83,7 +96,9 @@  discard block
 block discarded – undo
83 96
     $ip = gethostbyname($host);
84 97
     $s = socket_create(AF_INET, SOCK_STREAM, 0);
85 98
     $r = @socket_connect($s, $ip, $port);
86
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
99
+    if (!socket_set_nonblock($s)) {
100
+    	echo "Unable to set nonblock on socket\n";
101
+    }
87 102
     if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
88 103
         return $s;
89 104
     }
@@ -110,7 +125,9 @@  discard block
 block discarded – undo
110 125
 function connect_all($hosts) {
111 126
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
112 127
     global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
113
-    if ($globalDebug) echo 'Connect to all...'."\n";
128
+    if ($globalDebug) {
129
+    	echo 'Connect to all...'."\n";
130
+    }
114 131
     foreach ($hosts as $id => $value) {
115 132
 	$host = $value['host'];
116 133
 	$globalSources[$id]['last_exec'] = 0;
@@ -120,27 +137,37 @@  discard block
 block discarded – undo
120 137
         	//$formats[$id] = 'deltadbtxt';
121 138
         	$globalSources[$id]['format'] = 'deltadbtxt';
122 139
         	//$last_exec['deltadbtxt'] = 0;
123
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
140
+        	if ($globalDebug) {
141
+        		echo "Connect to deltadb source (".$host.")...\n";
142
+        	}
124 143
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
125 144
         	//$formats[$id] = 'vatsimtxt';
126 145
         	$globalSources[$id]['format'] = 'vatsimtxt';
127 146
         	//$last_exec['vatsimtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
147
+        	if ($globalDebug) {
148
+        		echo "Connect to vatsim source (".$host.")...\n";
149
+        	}
129 150
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
130 151
         	//$formats[$id] = 'aircraftlistjson';
131 152
         	$globalSources[$id]['format'] = 'aircraftlistjson';
132 153
         	//$last_exec['aircraftlistjson'] = 0;
133
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
154
+        	if ($globalDebug) {
155
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
156
+        	}
134 157
     	    } else if (preg_match('/opensky/i',$host)) {
135 158
         	//$formats[$id] = 'aircraftlistjson';
136 159
         	$globalSources[$id]['format'] = 'opensky';
137 160
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
161
+        	if ($globalDebug) {
162
+        		echo "Connect to opensky source (".$host.")...\n";
163
+        	}
139 164
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
140 165
         	//$formats[$id] = 'radarvirtueljson';
141 166
         	$globalSources[$id]['format'] = 'radarvirtueljson';
142 167
         	//$last_exec['radarvirtueljson'] = 0;
143
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
168
+        	if ($globalDebug) {
169
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
170
+        	}
144 171
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
145 172
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
146 173
         	    exit(0);
@@ -149,7 +176,9 @@  discard block
 block discarded – undo
149 176
         	//$formats[$id] = 'planeupdatefaa';
150 177
         	$globalSources[$id]['format'] = 'planeupdatefaa';
151 178
         	//$last_exec['planeupdatefaa'] = 0;
152
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
179
+        	if ($globalDebug) {
180
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
181
+        	}
153 182
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
154 183
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
155 184
         	    exit(0);
@@ -158,26 +187,36 @@  discard block
 block discarded – undo
158 187
         	//$formats[$id] = 'phpvmacars';
159 188
         	$globalSources[$id]['format'] = 'phpvmacars';
160 189
         	//$last_exec['phpvmacars'] = 0;
161
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
190
+        	if ($globalDebug) {
191
+        		echo "Connect to phpvmacars source (".$host.")...\n";
192
+        	}
162 193
             } else if (preg_match('/VAM-json.php$/i',$host)) {
163 194
         	//$formats[$id] = 'phpvmacars';
164 195
         	$globalSources[$id]['format'] = 'vam';
165
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
196
+        	if ($globalDebug) {
197
+        		echo "Connect to Vam source (".$host.")...\n";
198
+        	}
166 199
             } else if (preg_match('/whazzup/i',$host)) {
167 200
         	//$formats[$id] = 'whazzup';
168 201
         	$globalSources[$id]['format'] = 'whazzup';
169 202
         	//$last_exec['whazzup'] = 0;
170
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
203
+        	if ($globalDebug) {
204
+        		echo "Connect to whazzup source (".$host.")...\n";
205
+        	}
171 206
             } else if (preg_match('/recentpireps/i',$host)) {
172 207
         	//$formats[$id] = 'pirepsjson';
173 208
         	$globalSources[$id]['format'] = 'pirepsjson';
174 209
         	//$last_exec['pirepsjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
210
+        	if ($globalDebug) {
211
+        		echo "Connect to pirepsjson source (".$host.")...\n";
212
+        	}
176 213
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
177 214
         	//$formats[$id] = 'fr24json';
178 215
         	$globalSources[$id]['format'] = 'fr24json';
179 216
         	//$last_exec['fr24json'] = 0;
180
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
217
+        	if ($globalDebug) {
218
+        		echo "Connect to fr24 source (".$host.")...\n";
219
+        	}
181 220
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
182 221
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
183 222
         	    exit(0);
@@ -186,10 +225,14 @@  discard block
 block discarded – undo
186 225
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
187 226
         	//$formats[$id] = 'tsv';
188 227
         	$globalSources[$id]['format'] = 'tsv';
189
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to tsv source (".$host.")...\n";
230
+        	}
190 231
             }
191 232
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
192
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
233
+        	if ($globalDebug) {
234
+        		echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
235
+        	}
193 236
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
194 237
 	    $hostport = explode(':',$host);
195 238
 	    if (isset($hostport[1])) {
@@ -226,17 +269,25 @@  discard block
 block discarded – undo
226 269
         		//$formats[$id] = 'beast';
227 270
         		$globalSources[$id]['format'] = 'beast';
228 271
 		    //} else $formats[$id] = 'sbs';
229
-		    } else $globalSources[$id]['format'] = 'sbs';
272
+		    } else {
273
+		    	$globalSources[$id]['format'] = 'sbs';
274
+		    }
230 275
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
231 276
 		}
232
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
277
+		if ($globalDebug) {
278
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
279
+		}
233 280
             } else {
234
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
281
+		if ($globalDebug) {
282
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
283
+		}
235 284
     	    }
236 285
         }
237 286
     }
238 287
 }
239
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
288
+if (!isset($globalMinFetch)) {
289
+	$globalMinFetch = 15;
290
+}
240 291
 
241 292
 // Initialize all
242 293
 $status = array();
@@ -244,13 +295,19 @@  discard block
 block discarded – undo
244 295
 $formats = array();
245 296
 $last_exec = array();
246 297
 $time = time();
247
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
248
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
249
-else $timeout = 20;
298
+if (isset($globalSourcesTimeout)) {
299
+	$timeout = $globalSourcesTimeOut;
300
+} else if (isset($globalSBS1TimeOut)) {
301
+	$timeout = $globalSBS1TimeOut;
302
+} else {
303
+	$timeout = 20;
304
+}
250 305
 $errno = '';
251 306
 $errstr='';
252 307
 
253
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
308
+if (!isset($globalDaemon)) {
309
+	$globalDaemon = TRUE;
310
+}
254 311
 /* Initiate connections to all the hosts simultaneously */
255 312
 //connect_all($hosts);
256 313
 //connect_all($globalSources);
@@ -270,7 +327,9 @@  discard block
 block discarded – undo
270 327
     if (isset($source['format']) && $source['format'] == 'aprs') {
271 328
 	$aprs_connect = 0;
272 329
 	$use_aprs = true;
273
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
330
+	if (isset($source['port']) && $source['port'] == '10152') {
331
+		$aprs_full = true;
332
+	}
274 333
 	break;
275 334
     }
276 335
 }
@@ -281,24 +340,44 @@  discard block
 block discarded – undo
281 340
 	$aprs_connect = 0;
282 341
 	$aprs_keep = 120;
283 342
 	$aprs_last_tx = time();
284
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
285
-	else $aprs_version = $globalName.' using FlightAirMap';
343
+	if (isset($globalAPRSversion)) {
344
+		$aprs_version = $globalAPRSversion;
345
+	} else {
346
+		$aprs_version = $globalName.' using FlightAirMap';
347
+	}
286 348
 	//else $aprs_version = 'Perl Example App';
287
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
288
-	else $aprs_ssid = 'FAM';
349
+	if (isset($globalAPRSssid)) {
350
+		$aprs_ssid = $globalAPRSssid;
351
+	} else {
352
+		$aprs_ssid = 'FAM';
353
+	}
289 354
 	//else $aprs_ssid = 'PerlEx';
290
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
291
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
292
-	if ($aprs_full) $aprs_filter = '';
293
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
294
-	else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
295
-}
355
+	if (isset($globalAPRSfilter)) {
356
+		$aprs_filter = $globalAPRSfilter;
357
+	} else {
358
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
359
+	}
360
+	if ($aprs_full) {
361
+		$aprs_filter = '';
362
+	}
363
+	if ($aprs_filter != '') {
364
+		$aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
365
+	} else {
366
+		$aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
367
+	}
368
+	}
296 369
 
297 370
 // connected - lets do some work
298
-if ($globalDebug) echo "Connected!\n";
371
+if ($globalDebug) {
372
+	echo "Connected!\n";
373
+}
299 374
 sleep(1);
300
-if ($globalDebug) echo "SCAN MODE \n\n";
301
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
375
+if ($globalDebug) {
376
+	echo "SCAN MODE \n\n";
377
+}
378
+if (!isset($globalCronEnd)) {
379
+	$globalCronEnd = 60;
380
+}
302 381
 $endtime = time()+$globalCronEnd;
303 382
 $i = 1;
304 383
 $tt = array();
@@ -312,20 +391,28 @@  discard block
 block discarded – undo
312 391
 
313 392
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
314 393
 while ($i > 0) {
315
-    if (!$globalDaemon) $i = $endtime-time();
394
+    if (!$globalDaemon) {
395
+    	$i = $endtime-time();
396
+    }
316 397
     // Delete old ATC
317 398
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
318
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
399
+	if ($globalDebug) {
400
+		echo 'Delete old ATC...'."\n";
401
+	}
319 402
         $ATC->deleteOldATC();
320 403
     }
321 404
     
322 405
     if (count($last_exec) > 0) {
323 406
 	$max = $globalMinFetch;
324 407
 	foreach ($last_exec as $last) {
325
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
408
+	    if ((time() - $last['last']) < $max) {
409
+	    	$max = time() - $last['last'];
410
+	    }
326 411
 	}
327 412
 	if ($max != $globalMinFetch) {
328
-	    if ($globalDebug) echo 'Sleeping...'."\n";
413
+	    if ($globalDebug) {
414
+	    	echo 'Sleeping...'."\n";
415
+	    }
329 416
 	    sleep($globalMinFetch-$max+2);
330 417
 	}
331 418
     }
@@ -333,7 +420,9 @@  discard block
 block discarded – undo
333 420
     
334 421
     //foreach ($formats as $id => $value) {
335 422
     foreach ($globalSources as $id => $value) {
336
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
423
+	if (!isset($last_exec[$id]['last'])) {
424
+		$last_exec[$id]['last'] = 0;
425
+	}
337 426
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
338 427
 	    //$buffer = $Common->getData($hosts[$id]);
339 428
 	    $buffer = $Common->getData($value['host']);
@@ -356,8 +445,12 @@  discard block
 block discarded – undo
356 445
 		    $data['datetime'] = date('Y-m-d H:i:s');
357 446
 		    $data['format_source'] = 'deltadbtxt';
358 447
     		    $data['id_source'] = $id_source;
359
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
360
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
448
+		    if (isset($value['name']) && $value['name'] != '') {
449
+		    	$data['source_name'] = $value['name'];
450
+		    }
451
+		    if (isset($value['sourcestats'])) {
452
+		    	$data['sourcestats'] = $value['sourcestats'];
453
+		    }
361 454
     		    $SI->add($data);
362 455
 		    unset($data);
363 456
     		}
@@ -379,10 +472,19 @@  discard block
 block discarded – undo
379 472
 			$data['pilot_name'] = $line[2];
380 473
 			$data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT);
381 474
 			$data['ident'] = $line[0]; // ident
382
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
475
+			if ($line[7] != '' && $line[7] != 0) {
476
+				$data['altitude'] = $line[7];
477
+			}
478
+			// altitude
383 479
 			$data['speed'] = $line[8]; // speed
384
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
385
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
480
+			if (isset($line[45])) {
481
+				$data['heading'] = $line[45];
482
+			}
483
+			// heading
484
+			elseif (isset($line[38])) {
485
+				$data['heading'] = $line[38];
486
+			}
487
+			// heading
386 488
 			$data['latitude'] = $line[5]; // lat
387 489
 	        	$data['longitude'] = $line[6]; // long
388 490
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -391,14 +493,18 @@  discard block
 block discarded – undo
391 493
 	        	$data['waypoints'] = $line[30];
392 494
 			$data['datetime'] = date('Y-m-d H:i:s');
393 495
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
394
-			if (isset($line[37])) $data['last_update'] = $line[37];
496
+			if (isset($line[37])) {
497
+				$data['last_update'] = $line[37];
498
+			}
395 499
 		        $data['departure_airport_icao'] = $line[11];
396 500
 		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
397 501
 		        $data['arrival_airport_icao'] = $line[13];
398 502
 			$data['frequency'] = $line[4];
399 503
 			$data['type'] = $line[18];
400 504
 			$data['range'] = $line[19];
401
-			if (isset($line[35])) $data['info'] = $line[35];
505
+			if (isset($line[35])) {
506
+				$data['info'] = $line[35];
507
+			}
402 508
     			$data['id_source'] = $id_source;
403 509
 	    		//$data['arrival_airport_time'] = ;
404 510
 	    		if ($line[9] != '') {
@@ -412,22 +518,35 @@  discard block
 block discarded – undo
412 518
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
413 519
 	    		*/
414 520
 	    		$data['format_source'] = $value['format'];
415
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
416
-    			if ($line[3] == 'PILOT') $SI->add($data);
417
-			elseif ($line[3] == 'ATC') {
521
+			if (isset($value['name']) && $value['name'] != '') {
522
+				$data['source_name'] = $value['name'];
523
+			}
524
+    			if ($line[3] == 'PILOT') {
525
+    				$SI->add($data);
526
+    			} elseif ($line[3] == 'ATC') {
418 527
 				//print_r($data);
419 528
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
420 529
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
421 530
 				$typec = substr($data['ident'],-3);
422
-				if ($typec == 'APP') $data['type'] = 'Approach';
423
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
424
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
425
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
426
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
427
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
428
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
429
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
430
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
531
+				if ($typec == 'APP') {
532
+					$data['type'] = 'Approach';
533
+				} elseif ($typec == 'TWR') {
534
+					$data['type'] = 'Tower';
535
+				} elseif ($typec == 'OBS') {
536
+					$data['type'] = 'Observer';
537
+				} elseif ($typec == 'GND') {
538
+					$data['type'] = 'Ground';
539
+				} elseif ($typec == 'DEL') {
540
+					$data['type'] = 'Delivery';
541
+				} elseif ($typec == 'DEP') {
542
+					$data['type'] = 'Departure';
543
+				} elseif ($typec == 'FSS') {
544
+					$data['type'] = 'Flight Service Station';
545
+				} elseif ($typec == 'CTR') {
546
+					$data['type'] = 'Control Radar or Centre';
547
+				} elseif ($data['type'] == '') {
548
+					$data['type'] = 'Observer';
549
+				}
431 550
 				
432 551
 				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']);
433 552
 			}
@@ -447,26 +566,55 @@  discard block
 block discarded – undo
447 566
 		foreach ($all_data['acList'] as $line) {
448 567
 		    $data = array();
449 568
 		    $data['hex'] = $line['Icao']; // hex
450
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
451
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
452
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
453
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
454
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
455
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
569
+		    if (isset($line['Call'])) {
570
+		    	$data['ident'] = $line['Call'];
571
+		    }
572
+		    // ident
573
+		    if (isset($line['Alt'])) {
574
+		    	$data['altitude'] = $line['Alt'];
575
+		    }
576
+		    // altitude
577
+		    if (isset($line['Spd'])) {
578
+		    	$data['speed'] = $line['Spd'];
579
+		    }
580
+		    // speed
581
+		    if (isset($line['Trak'])) {
582
+		    	$data['heading'] = $line['Trak'];
583
+		    }
584
+		    // heading
585
+		    if (isset($line['Lat'])) {
586
+		    	$data['latitude'] = $line['Lat'];
587
+		    }
588
+		    // lat
589
+		    if (isset($line['Long'])) {
590
+		    	$data['longitude'] = $line['Long'];
591
+		    }
592
+		    // long
456 593
 		    //$data['verticalrate'] = $line['']; // verticale rate
457
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
594
+		    if (isset($line['Sqk'])) {
595
+		    	$data['squawk'] = $line['Sqk'];
596
+		    }
597
+		    // squawk
458 598
 		    $data['emergency'] = ''; // emergency
459
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
599
+		    if (isset($line['Reg'])) {
600
+		    	$data['registration'] = $line['Reg'];
601
+		    }
460 602
 		    /*
461 603
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
462 604
 		    else $data['datetime'] = date('Y-m-d H:i:s');
463 605
 		    */
464 606
 		    $data['datetime'] = date('Y-m-d H:i:s');
465
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
607
+		    if (isset($line['Type'])) {
608
+		    	$data['aircraft_icao'] = $line['Type'];
609
+		    }
466 610
 	    	    $data['format_source'] = 'aircraftlistjson';
467 611
 		    $data['id_source'] = $id_source;
468
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
469
-		    if (isset($data['datetime'])) $SI->add($data);
612
+		    if (isset($value['name']) && $value['name'] != '') {
613
+		    	$data['source_name'] = $value['name'];
614
+		    }
615
+		    if (isset($data['datetime'])) {
616
+		    	$SI->add($data);
617
+		    }
470 618
 		    unset($data);
471 619
 		}
472 620
 	    } else {
@@ -485,7 +633,9 @@  discard block
 block discarded – undo
485 633
 		    $data['datetime'] = date('Y-m-d H:i:s');
486 634
 	    	    $data['format_source'] = 'aircraftlistjson';
487 635
     		    $data['id_source'] = $id_source;
488
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
636
+		    if (isset($value['name']) && $value['name'] != '') {
637
+		    	$data['source_name'] = $value['name'];
638
+		    }
489 639
 		    $SI->add($data);
490 640
 		    unset($data);
491 641
 		}
@@ -520,7 +670,9 @@  discard block
 block discarded – undo
520 670
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
521 671
 	    	    $data['format_source'] = 'planeupdatefaa';
522 672
     		    $data['id_source'] = $id_source;
523
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
673
+		    if (isset($value['name']) && $value['name'] != '') {
674
+		    	$data['source_name'] = $value['name'];
675
+		    }
524 676
 		    $SI->add($data);
525 677
 		    unset($data);
526 678
 		}
@@ -579,7 +731,9 @@  discard block
 block discarded – undo
579 731
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
580 732
 	    	    $data['format_source'] = 'fr24json';
581 733
     		    $data['id_source'] = $id_source;
582
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
734
+		    if (isset($value['name']) && $value['name'] != '') {
735
+		    	$data['source_name'] = $value['name'];
736
+		    }
583 737
 		    $SI->add($data);
584 738
 		    unset($data);
585 739
 		}
@@ -602,23 +756,39 @@  discard block
 block discarded – undo
602 756
 		    if (isset($line['inf'])) {
603 757
 			$data = array();
604 758
 			$data['hex'] = $line['inf']['ia'];
605
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
759
+			if (isset($line['inf']['cs'])) {
760
+				$data['ident'] = $line['inf']['cs'];
761
+			}
762
+			//$line[13]
606 763
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
607
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
608
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
764
+	    		if (isset($line['inf']['gs'])) {
765
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
766
+	    		}
767
+	    		// speed
768
+	    		if (isset($line['inf']['tr'])) {
769
+	    			$data['heading'] = $line['inf']['tr'];
770
+	    		}
771
+	    		// heading
609 772
 	    		$data['latitude'] = $line['pt'][0]; // lat
610 773
 	    		$data['longitude'] = $line['pt'][1]; // long
611 774
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
612
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
775
+	    		if (isset($line['inf']['sq'])) {
776
+	    			$data['squawk'] = $line['inf']['sq'];
777
+	    		}
778
+	    		// squawk
613 779
 	    		//$data['aircraft_icao'] = $line[8];
614
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
780
+	    		if (isset($line['inf']['rc'])) {
781
+	    			$data['registration'] = $line['inf']['rc'];
782
+	    		}
615 783
 			//$data['departure_airport_iata'] = $line[11];
616 784
 			//$data['arrival_airport_iata'] = $line[12];
617 785
 	    		//$data['emergency'] = ''; // emergency
618 786
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
619 787
 	    		$data['format_source'] = 'radarvirtueljson';
620 788
     			$data['id_source'] = $id_source;
621
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
789
+			if (isset($value['name']) && $value['name'] != '') {
790
+				$data['source_name'] = $value['name'];
791
+			}
622 792
 			$SI->add($data);
623 793
 			unset($data);
624 794
 		    }
@@ -638,29 +808,62 @@  discard block
 block discarded – undo
638 808
 		    $data['id'] = $line['id'];
639 809
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
640 810
 		    $data['ident'] = $line['callsign']; // ident
641
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
642
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
643
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
644
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
645
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
646
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
811
+		    if (isset($line['pilotid'])) {
812
+		    	$data['pilot_id'] = $line['pilotid'];
813
+		    }
814
+		    // pilot id
815
+		    if (isset($line['name'])) {
816
+		    	$data['pilot_name'] = $line['name'];
817
+		    }
818
+		    // pilot name
819
+		    if (isset($line['alt'])) {
820
+		    	$data['altitude'] = $line['alt'];
821
+		    }
822
+		    // altitude
823
+		    if (isset($line['gs'])) {
824
+		    	$data['speed'] = $line['gs'];
825
+		    }
826
+		    // speed
827
+		    if (isset($line['heading'])) {
828
+		    	$data['heading'] = $line['heading'];
829
+		    }
830
+		    // heading
831
+		    if (isset($line['route'])) {
832
+		    	$data['waypoints'] = $line['route'];
833
+		    }
834
+		    // route
647 835
 		    $data['latitude'] = $line['lat']; // lat
648 836
 		    $data['longitude'] = $line['lon']; // long
649 837
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
650 838
 		    //$data['squawk'] = $line['squawk']; // squawk
651 839
 		    //$data['emergency'] = ''; // emergency
652
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
653
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
654
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
840
+		    if (isset($line['depicao'])) {
841
+		    	$data['departure_airport_icao'] = $line['depicao'];
842
+		    }
843
+		    if (isset($line['deptime'])) {
844
+		    	$data['departure_airport_time'] = $line['deptime'];
845
+		    }
846
+		    if (isset($line['arricao'])) {
847
+		    	$data['arrival_airport_icao'] = $line['arricao'];
848
+		    }
655 849
 		    //$data['arrival_airport_time'] = $line['arrtime'];
656
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
657
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
658
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
659
-		    else $data['info'] = '';
850
+		    if (isset($line['aircraft'])) {
851
+		    	$data['aircraft_icao'] = $line['aircraft'];
852
+		    }
853
+		    if (isset($line['transponder'])) {
854
+		    	$data['squawk'] = $line['transponder'];
855
+		    }
856
+		    if (isset($line['atis'])) {
857
+		    	$data['info'] = $line['atis'];
858
+		    } else {
859
+		    	$data['info'] = '';
860
+		    }
660 861
 		    $data['format_source'] = 'pireps';
661 862
     		    $data['id_source'] = $id_source;
662 863
 		    $data['datetime'] = date('Y-m-d H:i:s');
663
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
864
+		    if (isset($value['name']) && $value['name'] != '') {
865
+		    	$data['source_name'] = $value['name'];
866
+		    }
664 867
 		    if ($line['icon'] == 'plane') {
665 868
 			$SI->add($data);
666 869
 		    //    print_r($data);
@@ -669,15 +872,25 @@  discard block
 block discarded – undo
669 872
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
670 873
 			$typec = substr($data['ident'],-3);
671 874
 			$data['type'] = '';
672
-			if ($typec == 'APP') $data['type'] = 'Approach';
673
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
674
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
675
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
676
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
677
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
678
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
679
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
680
-			else $data['type'] = 'Observer';
875
+			if ($typec == 'APP') {
876
+				$data['type'] = 'Approach';
877
+			} elseif ($typec == 'TWR') {
878
+				$data['type'] = 'Tower';
879
+			} elseif ($typec == 'OBS') {
880
+				$data['type'] = 'Observer';
881
+			} elseif ($typec == 'GND') {
882
+				$data['type'] = 'Ground';
883
+			} elseif ($typec == 'DEL') {
884
+				$data['type'] = 'Delivery';
885
+			} elseif ($typec == 'DEP') {
886
+				$data['type'] = 'Departure';
887
+			} elseif ($typec == 'FSS') {
888
+				$data['type'] = 'Flight Service Station';
889
+			} elseif ($typec == 'CTR') {
890
+				$data['type'] = 'Control Radar or Centre';
891
+			} else {
892
+				$data['type'] = 'Observer';
893
+			}
681 894
 			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']);
682 895
 		    }
683 896
 		    unset($data);
@@ -688,17 +901,25 @@  discard block
 block discarded – undo
688 901
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
689 902
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
690 903
 	    //$buffer = $Common->getData($hosts[$id]);
691
-	    if ($globalDebug) echo 'Get Data...'."\n";
904
+	    if ($globalDebug) {
905
+	    	echo 'Get Data...'."\n";
906
+	    }
692 907
 	    $buffer = $Common->getData($value['host']);
693 908
 	    $all_data = json_decode($buffer,true);
694 909
 	    if ($buffer != '' && is_array($all_data)) {
695 910
 		foreach ($all_data as $line) {
696 911
 	    	    $data = array();
697 912
 	    	    //$data['id'] = $line['id']; // id not usable
698
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
913
+	    	    if (isset($line['pilotid'])) {
914
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
915
+	    	    }
699 916
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
700
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
701
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
917
+	    	    if (isset($line['pilotname'])) {
918
+	    	    	$data['pilot_name'] = $line['pilotname'];
919
+	    	    }
920
+	    	    if (isset($line['pilotid'])) {
921
+	    	    	$data['pilot_id'] = $line['pilotid'];
922
+	    	    }
702 923
 	    	    $data['ident'] = $line['flightnum']; // ident
703 924
 	    	    $data['altitude'] = $line['alt']; // altitude
704 925
 	    	    $data['speed'] = $line['gs']; // speed
@@ -716,27 +937,41 @@  discard block
 block discarded – undo
716 937
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
717 938
     		    $data['arrival_airport_time'] = $line['arrtime'];
718 939
     		    $data['registration'] = $line['aircraft'];
719
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
940
+		    if (isset($line['route'])) {
941
+		    	$data['waypoints'] = $line['route'];
942
+		    }
943
+		    // route
720 944
 		    if (isset($line['aircraftname'])) {
721 945
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
722 946
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
723 947
 	    		$aircraft_data = explode('-',$line['aircraftname']);
724
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
725
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
726
-	    		else {
948
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) {
949
+	    			$data['aircraft_icao'] = $aircraft_data[0];
950
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) {
951
+	    			$data['aircraft_icao'] = $aircraft_data[1];
952
+	    		} else {
727 953
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
728
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
729
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
954
+	    		    if (isset($aircraft_data[1])) {
955
+	    		    	$data['aircraft_icao'] = $aircraft_data[1];
956
+	    		    } else {
957
+	    		    	$data['aircraft_icao'] = $line['aircraftname'];
958
+	    		    }
730 959
 	    		}
731 960
 	    	    }
732
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
961
+    		    if (isset($line['route'])) {
962
+    		    	$data['waypoints'] = $line['route'];
963
+    		    }
733 964
     		    $data['id_source'] = $id_source;
734 965
 	    	    $data['format_source'] = 'phpvmacars';
735
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
966
+		    if (isset($value['name']) && $value['name'] != '') {
967
+		    	$data['source_name'] = $value['name'];
968
+		    }
736 969
 		    $SI->add($data);
737 970
 		    unset($data);
738 971
 		}
739
-		if ($globalDebug) echo 'No more data...'."\n";
972
+		if ($globalDebug) {
973
+			echo 'No more data...'."\n";
974
+		}
740 975
 		unset($buffer);
741 976
 		unset($all_data);
742 977
 	    }
@@ -744,7 +979,9 @@  discard block
 block discarded – undo
744 979
     	    $last_exec[$id]['last'] = time();
745 980
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
746 981
 	    //$buffer = $Common->getData($hosts[$id]);
747
-	    if ($globalDebug) echo 'Get Data...'."\n";
982
+	    if ($globalDebug) {
983
+	    	echo 'Get Data...'."\n";
984
+	    }
748 985
 	    $buffer = $Common->getData($value['host']);
749 986
 	    $all_data = json_decode($buffer,true);
750 987
 	    if ($buffer != '' && is_array($all_data)) {
@@ -772,15 +1009,22 @@  discard block
 block discarded – undo
772 1009
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
773 1010
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
774 1011
     		    //$data['registration'] = $line['aircraft'];
775
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1012
+		    if (isset($line['route'])) {
1013
+		    	$data['waypoints'] = $line['route'];
1014
+		    }
1015
+		    // route
776 1016
 	    	    $data['aircraft_icao'] = $line['plane_type'];
777 1017
     		    $data['id_source'] = $id_source;
778 1018
 	    	    $data['format_source'] = 'vam';
779
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1019
+		    if (isset($value['name']) && $value['name'] != '') {
1020
+		    	$data['source_name'] = $value['name'];
1021
+		    }
780 1022
 		    $SI->add($data);
781 1023
 		    unset($data);
782 1024
 		}
783
-		if ($globalDebug) echo 'No more data...'."\n";
1025
+		if ($globalDebug) {
1026
+			echo 'No more data...'."\n";
1027
+		}
784 1028
 		unset($buffer);
785 1029
 		unset($all_data);
786 1030
 	    }
@@ -788,7 +1032,9 @@  discard block
 block discarded – undo
788 1032
     	    $last_exec[$id]['last'] = time();
789 1033
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
790 1034
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars') {
791
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1035
+	    if (function_exists('pcntl_fork')) {
1036
+	    	pcntl_signal_dispatch();
1037
+	    }
792 1038
     	    //$last_exec[$id]['last'] = time();
793 1039
 
794 1040
 	    //$read = array( $sockets[$id] );
@@ -796,7 +1042,9 @@  discard block
 block discarded – undo
796 1042
 	    $write = NULL;
797 1043
 	    $e = NULL;
798 1044
 	    $n = socket_select($read, $write, $e, $timeout);
799
-	    if ($e != NULL) var_dump($e);
1045
+	    if ($e != NULL) {
1046
+	    	var_dump($e);
1047
+	    }
800 1048
 	    if ($n > 0) {
801 1049
 		foreach ($read as $nb => $r) {
802 1050
 		    //$value = $formats[$nb];
@@ -824,9 +1072,15 @@  discard block
 block discarded – undo
824 1072
 			    if (is_array($data)) {
825 1073
 				$data['datetime'] = date('Y-m-d H:i:s');
826 1074
 				$data['format_source'] = 'raw';
827
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
828
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
829
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1075
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1076
+					$data['source_name'] = $globalSources[$nb]['name'];
1077
+				}
1078
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1079
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1080
+    				}
1081
+                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1082
+                                	$SI->add($data);
1083
+                                }
830 1084
                             }
831 1085
                         } elseif ($format == 'flightgearsp') {
832 1086
                     	    //echo $buffer."\n";
@@ -844,11 +1098,15 @@  discard block
 block discarded – undo
844 1098
 				$data['speed'] = round($line[5]*1.94384);
845 1099
 				$data['datetime'] = date('Y-m-d H:i:s');
846 1100
 				$data['format_source'] = 'flightgearsp';
847
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1101
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1102
+					$SI->add($data);
1103
+				}
848 1104
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
849 1105
 			    }
850 1106
                         } elseif ($format == 'acars') {
851
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1107
+                    	    if ($globalDebug) {
1108
+                    	    	echo 'ACARS : '.$buffer."\n";
1109
+                    	    }
852 1110
 			    $ACARS->add(trim($buffer));
853 1111
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
854 1112
 			    $ACARS->deleteLiveAcarsData();
@@ -869,7 +1127,9 @@  discard block
 block discarded – undo
869 1127
 				    $aircraft_type = $line[10];
870 1128
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
871 1129
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
872
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1130
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1131
+				    	$SI->add($data);
1132
+				    }
873 1133
 				}
874 1134
 			    }
875 1135
 			} elseif ($format == 'beast') {
@@ -885,21 +1145,43 @@  discard block
 block discarded – undo
885 1145
     				$data['hex'] = $lined['hexid'];
886 1146
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
887 1147
     				$data['datetime'] = date('Y-m-d H:i:s');;
888
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
889
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
890
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
891
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
892
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
893
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
894
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1148
+    				if (isset($lined['ident'])) {
1149
+    					$data['ident'] = $lined['ident'];
1150
+    				}
1151
+    				if (isset($lined['lat'])) {
1152
+    					$data['latitude'] = $lined['lat'];
1153
+    				}
1154
+    				if (isset($lined['lon'])) {
1155
+    					$data['longitude'] = $lined['lon'];
1156
+    				}
1157
+    				if (isset($lined['speed'])) {
1158
+    					$data['speed'] = $lined['speed'];
1159
+    				}
1160
+    				if (isset($lined['squawk'])) {
1161
+    					$data['squawk'] = $lined['squawk'];
1162
+    				}
1163
+    				if (isset($lined['alt'])) {
1164
+    					$data['altitude'] = $lined['alt'];
1165
+    				}
1166
+    				if (isset($lined['heading'])) {
1167
+    					$data['heading'] = $lined['heading'];
1168
+    				}
895 1169
     				$data['id_source'] = $id_source;
896 1170
     				$data['format_source'] = 'tsv';
897
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
898
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
899
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1171
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1172
+    					$data['source_name'] = $globalSources[$nb]['name'];
1173
+    				}
1174
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1175
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1176
+    				}
1177
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1178
+    					$SI->add($data);
1179
+    				}
900 1180
     				unset($lined);
901 1181
     				unset($data);
902
-    			    } else $error = true;
1182
+    			    } else {
1183
+    			    	$error = true;
1184
+    			    }
903 1185
 			} elseif ($format == 'aprs' && $use_aprs) {
904 1186
 			    if ($aprs_connect == 0) {
905 1187
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -925,29 +1207,44 @@  discard block
 block discarded – undo
925 1207
 				    $data['latitude'] = $line['latitude'];
926 1208
 				    $data['longitude'] = $line['longitude'];
927 1209
 				    //$data['verticalrate'] = $line[16];
928
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
929
-				    else $data['speed'] = 0;
1210
+				    if (isset($line['speed'])) {
1211
+				    	$data['speed'] = $line['speed'];
1212
+				    } else {
1213
+				    	$data['speed'] = 0;
1214
+				    }
930 1215
 				    $data['altitude'] = $line['altitude'];
931
-				    if (isset($line['course'])) $data['heading'] = $line['course'];
1216
+				    if (isset($line['course'])) {
1217
+				    	$data['heading'] = $line['course'];
1218
+				    }
932 1219
 				    //else $data['heading'] = 0;
933 1220
 				    $data['aircraft_type'] = $line['stealth'];
934
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1221
+				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) {
1222
+				    	$data['noarchive'] = true;
1223
+				    }
935 1224
     				    $data['id_source'] = $id_source;
936 1225
 				    $data['format_source'] = 'aprs';
937 1226
 				    $data['source_name'] = $line['source'];
938
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1227
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1228
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1229
+    				    }
939 1230
 				    $currentdate = date('Y-m-d H:i:s');
940 1231
 				    $aprsdate = strtotime($data['datetime']);
941 1232
 				    // Accept data if time <= system time + 20s
942
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
943
-				    else {
944
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
945
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1233
+				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1234
+				    	$send = $SI->add($data);
1235
+				    } else {
1236
+					if ($line['stealth'] != 0) {
1237
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1238
+					} else {
1239
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1240
+					}
946 1241
 				    }
947 1242
 				    unset($data);
948 1243
 				} 
949 1244
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
950
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1245
+				elseif ($line == true && $globalDebug) {
1246
+					echo '!! Failed : '.$buffer."!!\n";
1247
+				}
951 1248
 			    }
952 1249
 			} else {
953 1250
 			    $line = explode(',', $buffer);
@@ -975,25 +1272,42 @@  discard block
 block discarded – undo
975 1272
     				$data['ground'] = $line[21];
976 1273
     				$data['emergency'] = $line[19];
977 1274
     				$data['format_source'] = 'sbs';
978
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
979
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1275
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1276
+					$data['source_name'] = $globalSources[$nb]['name'];
1277
+				}
1278
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1279
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1280
+    				}
980 1281
     				$data['id_source'] = $id_source;
981
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
982
-    				else $error = true;
1282
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1283
+    					$send = $SI->add($data);
1284
+    				} else {
1285
+    					$error = true;
1286
+    				}
983 1287
     				unset($data);
984
-    			    } else $error = true;
1288
+    			    } else {
1289
+    			    	$error = true;
1290
+    			    }
985 1291
 			    if ($error) {
986 1292
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
987
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1293
+					if ($globalDebug) {
1294
+						echo "Not a message. Ignoring... \n";
1295
+					}
988 1296
 				} else {
989
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1297
+					if ($globalDebug) {
1298
+						echo "Wrong line format. Ignoring... \n";
1299
+					}
990 1300
 					if ($globalDebug) {
991 1301
 						echo $buffer;
992 1302
 						print_r($line);
993 1303
 					}
994 1304
 					//socket_close($r);
995
-					if ($globalDebug) echo "Reconnect after an error...\n";
996
-					if ($format == 'aprs') $aprs_connect = 0;
1305
+					if ($globalDebug) {
1306
+						echo "Reconnect after an error...\n";
1307
+					}
1308
+					if ($format == 'aprs') {
1309
+						$aprs_connect = 0;
1310
+					}
997 1311
 					$sourceer[$nb] = $globalSources[$nb];
998 1312
 					connect_all($sourceer);
999 1313
 					$sourceer = array();
@@ -1001,10 +1315,14 @@  discard block
 block discarded – undo
1001 1315
 			    }
1002 1316
 			}
1003 1317
 			// Sleep for xxx microseconds
1004
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1318
+			if (isset($globalSBSSleep)) {
1319
+				usleep($globalSBSSleep);
1320
+			}
1005 1321
 		    } else {
1006 1322
 			if ($format == 'flightgearmp') {
1007
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1323
+			    	if ($globalDebug) {
1324
+			    		echo "Reconnect FlightGear MP...";
1325
+			    	}
1008 1326
 				//@socket_close($r);
1009 1327
 				sleep($globalMinFetch);
1010 1328
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1013,10 +1331,15 @@  discard block
 block discarded – undo
1013 1331
 				break;
1014 1332
 				
1015 1333
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1016
-			    if (isset($tt[$format])) $tt[$format]++;
1017
-			    else $tt[$format] = 0;
1334
+			    if (isset($tt[$format])) {
1335
+			    	$tt[$format]++;
1336
+			    } else {
1337
+			    	$tt[$format] = 0;
1338
+			    }
1018 1339
 			    if ($tt[$format] > 30) {
1019
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1340
+				if ($globalDebug) {
1341
+					echo "ERROR : Reconnect ".$format."...";
1342
+				}
1020 1343
 				//@socket_close($r);
1021 1344
 				sleep(2);
1022 1345
 				$aprs_connect = 0;
@@ -1032,12 +1355,18 @@  discard block
 block discarded – undo
1032 1355
 		}
1033 1356
 	    } else {
1034 1357
 		$error = socket_strerror(socket_last_error());
1035
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1358
+		if ($globalDebug) {
1359
+			echo "ERROR : socket_select give this error ".$error . "\n";
1360
+		}
1036 1361
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) || time() - $time >= $timeout) {
1037
-			if (isset($globalDebug)) echo "Restarting...\n";
1362
+			if (isset($globalDebug)) {
1363
+				echo "Restarting...\n";
1364
+			}
1038 1365
 			// Restart the script if possible
1039 1366
 			if (is_array($sockets)) {
1040
-			    if ($globalDebug) echo "Shutdown all sockets...";
1367
+			    if ($globalDebug) {
1368
+			    	echo "Shutdown all sockets...";
1369
+			    }
1041 1370
 			    
1042 1371
 			    foreach ($sockets as $sock) {
1043 1372
 				@socket_shutdown($sock,2);
@@ -1045,7 +1374,9 @@  discard block
 block discarded – undo
1045 1374
 			    }
1046 1375
 			    
1047 1376
 			}
1048
-			    if ($globalDebug) echo "Restart all connections...";
1377
+			    if ($globalDebug) {
1378
+			    	echo "Restart all connections...";
1379
+			    }
1049 1380
 			    sleep(2);
1050 1381
 			    $time = time();
1051 1382
 			    //connect_all($hosts);
@@ -1056,7 +1387,9 @@  discard block
 block discarded – undo
1056 1387
 	    }
1057 1388
 	}
1058 1389
 	if ($globalDaemon === false) {
1059
-	    if ($globalDebug) echo 'Check all...'."\n";
1390
+	    if ($globalDebug) {
1391
+	    	echo 'Check all...'."\n";
1392
+	    }
1060 1393
 	    $SI->checkAll();
1061 1394
 	}
1062 1395
     }
Please login to merge, or discard this patch.
Indentation   +691 added lines, -691 removed lines patch added patch discarded remove patch
@@ -19,44 +19,44 @@  discard block
 block discarded – undo
19 19
 // Check if schema is at latest version
20 20
 $Connection = new Connection();
21 21
 if ($Connection->latest() === false) {
22
-    echo "You MUST update to latest schema. Run install/index.php";
23
-    exit();
22
+	echo "You MUST update to latest schema. Run install/index.php";
23
+	exit();
24 24
 }
25 25
 
26 26
 
27 27
 // This is to be compatible with old version of settings.php
28 28
 if (!isset($globalSources)) {
29
-    if (isset($globalSBS1Hosts)) {
30
-        //$hosts = $globalSBS1Hosts;
31
-        foreach ($globalSBS1Hosts as $host) {
32
-	    $globalSources[] = array('host' => $host);
33
-    	}
34
-    } else {
35
-        if (!isset($globalSBS1Host)) {
36
-	    echo '$globalSources MUST be defined !';
37
-	    die;
29
+	if (isset($globalSBS1Hosts)) {
30
+		//$hosts = $globalSBS1Hosts;
31
+		foreach ($globalSBS1Hosts as $host) {
32
+		$globalSources[] = array('host' => $host);
33
+		}
34
+	} else {
35
+		if (!isset($globalSBS1Host)) {
36
+		echo '$globalSources MUST be defined !';
37
+		die;
38 38
 	}
39 39
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
40 40
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
41
-    }
41
+	}
42 42
 }
43 43
 
44 44
 $options = getopt('s::',array('source::','server','idsource::'));
45 45
 //if (isset($options['s'])) $hosts = array($options['s']);
46 46
 //elseif (isset($options['source'])) $hosts = array($options['source']);
47 47
 if (isset($options['s'])) {
48
-    $globalSources = array();
49
-    $globalSources[] = array('host' => $options['s']);
48
+	$globalSources = array();
49
+	$globalSources[] = array('host' => $options['s']);
50 50
 } elseif (isset($options['source'])) {
51
-    $globalSources = array();
52
-    $globalSources[] = array('host' => $options['source']);
51
+	$globalSources = array();
52
+	$globalSources[] = array('host' => $options['source']);
53 53
 }
54 54
 if (isset($options['server'])) $globalServer = TRUE;
55 55
 if (isset($options['idsource'])) $id_source = $options['idsource'];
56 56
 else $id_source = 1;
57 57
 if (isset($globalServer) && $globalServer) {
58
-    if ($globalDebug) echo "Using Server Mode\n";
59
-    $SI=new SpotterServer();
58
+	if ($globalDebug) echo "Using Server Mode\n";
59
+	$SI=new SpotterServer();
60 60
 } else $SI=new SpotterImport($Connection->db);
61 61
 //$APRS=new APRS($Connection->db);
62 62
 $SBS=new SBS();
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 //$servertz = system('date +%Z');
67 67
 // signal handler - playing nice with sockets and dump1090
68 68
 if (function_exists('pcntl_fork')) {
69
-    pcntl_signal(SIGINT,  function() {
70
-        global $sockets;
71
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
72
-        die("Bye!\n");
73
-    });
74
-    pcntl_signal_dispatch();
69
+	pcntl_signal(SIGINT,  function() {
70
+		global $sockets;
71
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
72
+		die("Bye!\n");
73
+	});
74
+	pcntl_signal_dispatch();
75 75
 }
76 76
 
77 77
 // let's try and connect
@@ -80,161 +80,161 @@  discard block
 block discarded – undo
80 80
 $aprs_full = false;
81 81
 
82 82
 function create_socket($host, $port, &$errno, &$errstr) {
83
-    $ip = gethostbyname($host);
84
-    $s = socket_create(AF_INET, SOCK_STREAM, 0);
85
-    $r = @socket_connect($s, $ip, $port);
86
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
87
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
88
-        return $s;
89
-    }
90
-    $errno = socket_last_error($s);
91
-    $errstr = socket_strerror($errno);
92
-    socket_close($s);
93
-    return false;
83
+	$ip = gethostbyname($host);
84
+	$s = socket_create(AF_INET, SOCK_STREAM, 0);
85
+	$r = @socket_connect($s, $ip, $port);
86
+	if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
87
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
88
+		return $s;
89
+	}
90
+	$errno = socket_last_error($s);
91
+	$errstr = socket_strerror($errno);
92
+	socket_close($s);
93
+	return false;
94 94
 }
95 95
 
96 96
 function create_socket_udp($host, $port, &$errno, &$errstr) {
97
-    echo "UDP !!";
98
-    $ip = gethostbyname($host);
99
-    $s = socket_create(AF_INET, SOCK_DGRAM, 0);
100
-    $r = @socket_bind($s, $ip, $port);
101
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
102
-        return $s;
103
-    }
104
-    $errno = socket_last_error($s);
105
-    $errstr = socket_strerror($errno);
106
-    socket_close($s);
107
-    return false;
97
+	echo "UDP !!";
98
+	$ip = gethostbyname($host);
99
+	$s = socket_create(AF_INET, SOCK_DGRAM, 0);
100
+	$r = @socket_bind($s, $ip, $port);
101
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
102
+		return $s;
103
+	}
104
+	$errno = socket_last_error($s);
105
+	$errstr = socket_strerror($errno);
106
+	socket_close($s);
107
+	return false;
108 108
 }
109 109
 
110 110
 function connect_all($hosts) {
111
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
112
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
113
-    if ($globalDebug) echo 'Connect to all...'."\n";
114
-    foreach ($hosts as $id => $value) {
111
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
112
+	global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
113
+	if ($globalDebug) echo 'Connect to all...'."\n";
114
+	foreach ($hosts as $id => $value) {
115 115
 	$host = $value['host'];
116 116
 	$globalSources[$id]['last_exec'] = 0;
117 117
 	// Here we check type of source(s)
118 118
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
119
-            if (preg_match('/deltadb.txt$/i',$host)) {
120
-        	//$formats[$id] = 'deltadbtxt';
121
-        	$globalSources[$id]['format'] = 'deltadbtxt';
122
-        	//$last_exec['deltadbtxt'] = 0;
123
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
124
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
125
-        	//$formats[$id] = 'vatsimtxt';
126
-        	$globalSources[$id]['format'] = 'vatsimtxt';
127
-        	//$last_exec['vatsimtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
129
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
130
-        	//$formats[$id] = 'aircraftlistjson';
131
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
132
-        	//$last_exec['aircraftlistjson'] = 0;
133
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
134
-    	    } else if (preg_match('/opensky/i',$host)) {
135
-        	//$formats[$id] = 'aircraftlistjson';
136
-        	$globalSources[$id]['format'] = 'opensky';
137
-        	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
139
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
140
-        	//$formats[$id] = 'radarvirtueljson';
141
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
142
-        	//$last_exec['radarvirtueljson'] = 0;
143
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
144
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
145
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
146
-        	    exit(0);
147
-        	}
148
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
149
-        	//$formats[$id] = 'planeupdatefaa';
150
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
151
-        	//$last_exec['planeupdatefaa'] = 0;
152
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
153
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
154
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
155
-        	    exit(0);
156
-        	}
157
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
158
-        	//$formats[$id] = 'phpvmacars';
159
-        	$globalSources[$id]['format'] = 'phpvmacars';
160
-        	//$last_exec['phpvmacars'] = 0;
161
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
162
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
163
-        	//$formats[$id] = 'phpvmacars';
164
-        	$globalSources[$id]['format'] = 'vam';
165
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
166
-            } else if (preg_match('/whazzup/i',$host)) {
167
-        	//$formats[$id] = 'whazzup';
168
-        	$globalSources[$id]['format'] = 'whazzup';
169
-        	//$last_exec['whazzup'] = 0;
170
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
171
-            } else if (preg_match('/recentpireps/i',$host)) {
172
-        	//$formats[$id] = 'pirepsjson';
173
-        	$globalSources[$id]['format'] = 'pirepsjson';
174
-        	//$last_exec['pirepsjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
176
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
177
-        	//$formats[$id] = 'fr24json';
178
-        	$globalSources[$id]['format'] = 'fr24json';
179
-        	//$last_exec['fr24json'] = 0;
180
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
181
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
182
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
183
-        	    exit(0);
184
-        	}
185
-            //} else if (preg_match('/10001/',$host)) {
186
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
187
-        	//$formats[$id] = 'tsv';
188
-        	$globalSources[$id]['format'] = 'tsv';
189
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
190
-            }
191
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
192
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
193
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
194
-	    $hostport = explode(':',$host);
195
-	    if (isset($hostport[1])) {
119
+			if (preg_match('/deltadb.txt$/i',$host)) {
120
+			//$formats[$id] = 'deltadbtxt';
121
+			$globalSources[$id]['format'] = 'deltadbtxt';
122
+			//$last_exec['deltadbtxt'] = 0;
123
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
124
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
125
+			//$formats[$id] = 'vatsimtxt';
126
+			$globalSources[$id]['format'] = 'vatsimtxt';
127
+			//$last_exec['vatsimtxt'] = 0;
128
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
129
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
130
+			//$formats[$id] = 'aircraftlistjson';
131
+			$globalSources[$id]['format'] = 'aircraftlistjson';
132
+			//$last_exec['aircraftlistjson'] = 0;
133
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
134
+			} else if (preg_match('/opensky/i',$host)) {
135
+			//$formats[$id] = 'aircraftlistjson';
136
+			$globalSources[$id]['format'] = 'opensky';
137
+			//$last_exec['aircraftlistjson'] = 0;
138
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
139
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
140
+			//$formats[$id] = 'radarvirtueljson';
141
+			$globalSources[$id]['format'] = 'radarvirtueljson';
142
+			//$last_exec['radarvirtueljson'] = 0;
143
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
144
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
145
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
146
+				exit(0);
147
+			}
148
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
149
+			//$formats[$id] = 'planeupdatefaa';
150
+			$globalSources[$id]['format'] = 'planeupdatefaa';
151
+			//$last_exec['planeupdatefaa'] = 0;
152
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
153
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
154
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
155
+				exit(0);
156
+			}
157
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
158
+			//$formats[$id] = 'phpvmacars';
159
+			$globalSources[$id]['format'] = 'phpvmacars';
160
+			//$last_exec['phpvmacars'] = 0;
161
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
162
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
163
+			//$formats[$id] = 'phpvmacars';
164
+			$globalSources[$id]['format'] = 'vam';
165
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
166
+			} else if (preg_match('/whazzup/i',$host)) {
167
+			//$formats[$id] = 'whazzup';
168
+			$globalSources[$id]['format'] = 'whazzup';
169
+			//$last_exec['whazzup'] = 0;
170
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
171
+			} else if (preg_match('/recentpireps/i',$host)) {
172
+			//$formats[$id] = 'pirepsjson';
173
+			$globalSources[$id]['format'] = 'pirepsjson';
174
+			//$last_exec['pirepsjson'] = 0;
175
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
176
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
177
+			//$formats[$id] = 'fr24json';
178
+			$globalSources[$id]['format'] = 'fr24json';
179
+			//$last_exec['fr24json'] = 0;
180
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
181
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
182
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
183
+				exit(0);
184
+			}
185
+			//} else if (preg_match('/10001/',$host)) {
186
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
187
+			//$formats[$id] = 'tsv';
188
+			$globalSources[$id]['format'] = 'tsv';
189
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
190
+			}
191
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
192
+			if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
193
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
194
+		$hostport = explode(':',$host);
195
+		if (isset($hostport[1])) {
196 196
 		$port = $hostport[1];
197 197
 		$hostn = $hostport[0];
198
-	    } else {
198
+		} else {
199 199
 		$port = $globalSources[$id]['port'];
200 200
 		$hostn = $globalSources[$id]['host'];
201
-	    }
202
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
203
-        	$s = create_socket($hostn,$port, $errno, $errstr);
204
-    	    } else {
205
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
206
-	    }
207
-	    if ($s) {
208
-    	        $sockets[$id] = $s;
209
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
210
-		    if (preg_match('/aprs/',$hostn)) {
201
+		}
202
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
203
+			$s = create_socket($hostn,$port, $errno, $errstr);
204
+			} else {
205
+			$s = create_socket_udp($hostn,$port, $errno, $errstr);
206
+		}
207
+		if ($s) {
208
+				$sockets[$id] = $s;
209
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
210
+			if (preg_match('/aprs/',$hostn)) {
211 211
 			//$formats[$id] = 'aprs';
212 212
 			$globalSources[$id]['format'] = 'aprs';
213 213
 			//$aprs_connect = 0;
214 214
 			//$use_aprs = true;
215
-    		    } elseif ($port == '10001') {
216
-        		//$formats[$id] = 'tsv';
217
-        		$globalSources[$id]['format'] = 'tsv';
218
-		    } elseif ($port == '30002') {
219
-        		//$formats[$id] = 'raw';
220
-        		$globalSources[$id]['format'] = 'raw';
221
-		    } elseif ($port == '5001') {
222
-        		//$formats[$id] = 'raw';
223
-        		$globalSources[$id]['format'] = 'flightgearmp';
224
-		    } elseif ($port == '30005') {
215
+				} elseif ($port == '10001') {
216
+				//$formats[$id] = 'tsv';
217
+				$globalSources[$id]['format'] = 'tsv';
218
+			} elseif ($port == '30002') {
219
+				//$formats[$id] = 'raw';
220
+				$globalSources[$id]['format'] = 'raw';
221
+			} elseif ($port == '5001') {
222
+				//$formats[$id] = 'raw';
223
+				$globalSources[$id]['format'] = 'flightgearmp';
224
+			} elseif ($port == '30005') {
225 225
 			// Not yet supported
226
-        		//$formats[$id] = 'beast';
227
-        		$globalSources[$id]['format'] = 'beast';
228
-		    //} else $formats[$id] = 'sbs';
229
-		    } else $globalSources[$id]['format'] = 'sbs';
230
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
226
+				//$formats[$id] = 'beast';
227
+				$globalSources[$id]['format'] = 'beast';
228
+			//} else $formats[$id] = 'sbs';
229
+			} else $globalSources[$id]['format'] = 'sbs';
230
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
231 231
 		}
232 232
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
233
-            } else {
233
+			} else {
234 234
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
235
-    	    }
236
-        }
237
-    }
235
+			}
236
+		}
237
+	}
238 238
 }
239 239
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
240 240
 
@@ -261,18 +261,18 @@  discard block
 block discarded – undo
261 261
 	die;
262 262
 }
263 263
 foreach ($globalSources as $key => $source) {
264
-    if (!isset($source['format'])) {
265
-        $globalSources[$key]['format'] = 'auto';
266
-    }
264
+	if (!isset($source['format'])) {
265
+		$globalSources[$key]['format'] = 'auto';
266
+	}
267 267
 }
268 268
 connect_all($globalSources);
269 269
 foreach ($globalSources as $key => $source) {
270
-    if (isset($source['format']) && $source['format'] == 'aprs') {
270
+	if (isset($source['format']) && $source['format'] == 'aprs') {
271 271
 	$aprs_connect = 0;
272 272
 	$use_aprs = true;
273 273
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
274 274
 	break;
275
-    }
275
+	}
276 276
 }
277 277
 
278 278
 if ($use_aprs) {
@@ -312,67 +312,67 @@  discard block
 block discarded – undo
312 312
 
313 313
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
314 314
 while ($i > 0) {
315
-    if (!$globalDaemon) $i = $endtime-time();
316
-    // Delete old ATC
317
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
315
+	if (!$globalDaemon) $i = $endtime-time();
316
+	// Delete old ATC
317
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
318 318
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
319
-        $ATC->deleteOldATC();
320
-    }
319
+		$ATC->deleteOldATC();
320
+	}
321 321
     
322
-    if (count($last_exec) > 0) {
322
+	if (count($last_exec) > 0) {
323 323
 	$max = $globalMinFetch;
324 324
 	foreach ($last_exec as $last) {
325
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
325
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
326 326
 	}
327 327
 	if ($max != $globalMinFetch) {
328
-	    if ($globalDebug) echo 'Sleeping...'."\n";
329
-	    sleep($globalMinFetch-$max+2);
328
+		if ($globalDebug) echo 'Sleeping...'."\n";
329
+		sleep($globalMinFetch-$max+2);
330
+	}
330 331
 	}
331
-    }
332 332
 
333 333
     
334
-    //foreach ($formats as $id => $value) {
335
-    foreach ($globalSources as $id => $value) {
334
+	//foreach ($formats as $id => $value) {
335
+	foreach ($globalSources as $id => $value) {
336 336
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
337 337
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
338
-	    //$buffer = $Common->getData($hosts[$id]);
339
-	    $buffer = $Common->getData($value['host']);
340
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
341
-	    $buffer = explode('\n',$buffer);
342
-	    foreach ($buffer as $line) {
343
-    		if ($line != '') {
344
-    		    $line = explode(',', $line);
345
-	            $data = array();
346
-	            $data['hex'] = $line[1]; // hex
347
-	            $data['ident'] = $line[2]; // ident
348
-	            $data['altitude'] = $line[3]; // altitude
349
-	            $data['speed'] = $line[4]; // speed
350
-	            $data['heading'] = $line[5]; // heading
351
-	            $data['latitude'] = $line[6]; // lat
352
-	            $data['longitude'] = $line[7]; // long
353
-	            $data['verticalrate'] = ''; // vertical rate
354
-	            $data['squawk'] = ''; // squawk
355
-	            $data['emergency'] = ''; // emergency
356
-		    $data['datetime'] = date('Y-m-d H:i:s');
357
-		    $data['format_source'] = 'deltadbtxt';
358
-    		    $data['id_source'] = $id_source;
359
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
360
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
361
-    		    $SI->add($data);
362
-		    unset($data);
363
-    		}
364
-    	    }
365
-    	    $last_exec[$id]['last'] = time();
338
+		//$buffer = $Common->getData($hosts[$id]);
339
+		$buffer = $Common->getData($value['host']);
340
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
341
+		$buffer = explode('\n',$buffer);
342
+		foreach ($buffer as $line) {
343
+			if ($line != '') {
344
+				$line = explode(',', $line);
345
+				$data = array();
346
+				$data['hex'] = $line[1]; // hex
347
+				$data['ident'] = $line[2]; // ident
348
+				$data['altitude'] = $line[3]; // altitude
349
+				$data['speed'] = $line[4]; // speed
350
+				$data['heading'] = $line[5]; // heading
351
+				$data['latitude'] = $line[6]; // lat
352
+				$data['longitude'] = $line[7]; // long
353
+				$data['verticalrate'] = ''; // vertical rate
354
+				$data['squawk'] = ''; // squawk
355
+				$data['emergency'] = ''; // emergency
356
+			$data['datetime'] = date('Y-m-d H:i:s');
357
+			$data['format_source'] = 'deltadbtxt';
358
+				$data['id_source'] = $id_source;
359
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
360
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
361
+				$SI->add($data);
362
+			unset($data);
363
+			}
364
+			}
365
+			$last_exec[$id]['last'] = time();
366 366
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
367 367
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value[' last_exec'] > $globalMinFetch))) {
368
-	    //$buffer = $Common->getData($hosts[$id]);
369
-	    $buffer = $Common->getData($value['host']);
370
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
371
-	    $buffer = explode('\n',$buffer);
372
-	    foreach ($buffer as $line) {
373
-    		if ($line != '') {
374
-    		    $line = explode(':', $line);
375
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
368
+		//$buffer = $Common->getData($hosts[$id]);
369
+		$buffer = $Common->getData($value['host']);
370
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
371
+		$buffer = explode('\n',$buffer);
372
+		foreach ($buffer as $line) {
373
+			if ($line != '') {
374
+				$line = explode(':', $line);
375
+				if (count($line) > 30 && $line[0] != 'callsign') {
376 376
 			$data = array();
377 377
 			$data['id'] = $line[1].'-'.$line[0];
378 378
 			$data['pilot_id'] = $line[1];
@@ -384,36 +384,36 @@  discard block
 block discarded – undo
384 384
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
385 385
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
386 386
 			$data['latitude'] = $line[5]; // lat
387
-	        	$data['longitude'] = $line[6]; // long
388
-	        	$data['verticalrate'] = ''; // vertical rate
389
-	        	$data['squawk'] = ''; // squawk
390
-	        	$data['emergency'] = ''; // emergency
391
-	        	$data['waypoints'] = $line[30];
387
+				$data['longitude'] = $line[6]; // long
388
+				$data['verticalrate'] = ''; // vertical rate
389
+				$data['squawk'] = ''; // squawk
390
+				$data['emergency'] = ''; // emergency
391
+				$data['waypoints'] = $line[30];
392 392
 			$data['datetime'] = date('Y-m-d H:i:s');
393 393
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
394 394
 			if (isset($line[37])) $data['last_update'] = $line[37];
395
-		        $data['departure_airport_icao'] = $line[11];
396
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
397
-		        $data['arrival_airport_icao'] = $line[13];
395
+				$data['departure_airport_icao'] = $line[11];
396
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
397
+				$data['arrival_airport_icao'] = $line[13];
398 398
 			$data['frequency'] = $line[4];
399 399
 			$data['type'] = $line[18];
400 400
 			$data['range'] = $line[19];
401 401
 			if (isset($line[35])) $data['info'] = $line[35];
402
-    			$data['id_source'] = $id_source;
403
-	    		//$data['arrival_airport_time'] = ;
404
-	    		if ($line[9] != '') {
405
-	    		    $aircraft_data = explode('/',$line[9]);
406
-	    		    if (isset($aircraft_data[1])) {
407
-	    			$data['aircraft_icao'] = $aircraft_data[1];
408
-	    		    }
409
-        		}
410
-	    		/*
402
+				$data['id_source'] = $id_source;
403
+				//$data['arrival_airport_time'] = ;
404
+				if ($line[9] != '') {
405
+					$aircraft_data = explode('/',$line[9]);
406
+					if (isset($aircraft_data[1])) {
407
+					$data['aircraft_icao'] = $aircraft_data[1];
408
+					}
409
+				}
410
+				/*
411 411
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
412 412
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
413 413
 	    		*/
414
-	    		$data['format_source'] = $value['format'];
414
+				$data['format_source'] = $value['format'];
415 415
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
416
-    			if ($line[3] == 'PILOT') $SI->add($data);
416
+				if ($line[3] == 'PILOT') $SI->add($data);
417 417
 			elseif ($line[3] == 'ATC') {
418 418
 				//print_r($data);
419 419
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -431,240 +431,240 @@  discard block
 block discarded – undo
431 431
 				
432 432
 				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']);
433 433
 			}
434
-    			unset($data);
435
-    		    }
436
-    		}
437
-    	    }
438
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
439
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
440
-    	    $last_exec[$id]['last'] = time();
441
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
442
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
443
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
444
-	    if ($buffer != '') {
445
-	    $all_data = json_decode($buffer,true);
446
-	    if (isset($all_data['acList'])) {
434
+				unset($data);
435
+				}
436
+			}
437
+			}
438
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
439
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
440
+			$last_exec[$id]['last'] = time();
441
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
442
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
443
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
444
+		if ($buffer != '') {
445
+		$all_data = json_decode($buffer,true);
446
+		if (isset($all_data['acList'])) {
447 447
 		foreach ($all_data['acList'] as $line) {
448
-		    $data = array();
449
-		    $data['hex'] = $line['Icao']; // hex
450
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
451
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
452
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
453
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
454
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
455
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
456
-		    //$data['verticalrate'] = $line['']; // verticale rate
457
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
458
-		    $data['emergency'] = ''; // emergency
459
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
460
-		    /*
448
+			$data = array();
449
+			$data['hex'] = $line['Icao']; // hex
450
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
451
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
452
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
453
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
454
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
455
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
456
+			//$data['verticalrate'] = $line['']; // verticale rate
457
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
458
+			$data['emergency'] = ''; // emergency
459
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
460
+			/*
461 461
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
462 462
 		    else $data['datetime'] = date('Y-m-d H:i:s');
463 463
 		    */
464
-		    $data['datetime'] = date('Y-m-d H:i:s');
465
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
466
-	    	    $data['format_source'] = 'aircraftlistjson';
467
-		    $data['id_source'] = $id_source;
468
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
469
-		    if (isset($data['datetime'])) $SI->add($data);
470
-		    unset($data);
464
+			$data['datetime'] = date('Y-m-d H:i:s');
465
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
466
+				$data['format_source'] = 'aircraftlistjson';
467
+			$data['id_source'] = $id_source;
468
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
469
+			if (isset($data['datetime'])) $SI->add($data);
470
+			unset($data);
471 471
 		}
472
-	    } else {
472
+		} else {
473 473
 		foreach ($all_data as $line) {
474
-		    $data = array();
475
-		    $data['hex'] = $line['hex']; // hex
476
-		    $data['ident'] = $line['flight']; // ident
477
-		    $data['altitude'] = $line['altitude']; // altitude
478
-		    $data['speed'] = $line['speed']; // speed
479
-		    $data['heading'] = $line['track']; // heading
480
-		    $data['latitude'] = $line['lat']; // lat
481
-		    $data['longitude'] = $line['lon']; // long
482
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
483
-		    $data['squawk'] = $line['squawk']; // squawk
484
-		    $data['emergency'] = ''; // emergency
485
-		    $data['datetime'] = date('Y-m-d H:i:s');
486
-	    	    $data['format_source'] = 'aircraftlistjson';
487
-    		    $data['id_source'] = $id_source;
488
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
489
-		    $SI->add($data);
490
-		    unset($data);
474
+			$data = array();
475
+			$data['hex'] = $line['hex']; // hex
476
+			$data['ident'] = $line['flight']; // ident
477
+			$data['altitude'] = $line['altitude']; // altitude
478
+			$data['speed'] = $line['speed']; // speed
479
+			$data['heading'] = $line['track']; // heading
480
+			$data['latitude'] = $line['lat']; // lat
481
+			$data['longitude'] = $line['lon']; // long
482
+			$data['verticalrate'] = $line['vrt']; // verticale rate
483
+			$data['squawk'] = $line['squawk']; // squawk
484
+			$data['emergency'] = ''; // emergency
485
+			$data['datetime'] = date('Y-m-d H:i:s');
486
+				$data['format_source'] = 'aircraftlistjson';
487
+				$data['id_source'] = $id_source;
488
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
489
+			$SI->add($data);
490
+			unset($data);
491
+		}
492
+		}
491 493
 		}
492
-	    }
493
-	    }
494
-    	    //$last_exec['aircraftlistjson'] = time();
495
-    	    $last_exec[$id]['last'] = time();
496
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
497
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
498
-	    $buffer = $Common->getData($value['host']);
499
-	    $all_data = json_decode($buffer,true);
500
-	    if (isset($all_data['planes'])) {
494
+			//$last_exec['aircraftlistjson'] = time();
495
+			$last_exec[$id]['last'] = time();
496
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
497
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
498
+		$buffer = $Common->getData($value['host']);
499
+		$all_data = json_decode($buffer,true);
500
+		if (isset($all_data['planes'])) {
501 501
 		foreach ($all_data['planes'] as $key => $line) {
502
-		    $data = array();
503
-		    $data['hex'] = $key; // hex
504
-		    $data['ident'] = $line[3]; // ident
505
-		    $data['altitude'] = $line[6]; // altitude
506
-		    $data['speed'] = $line[8]; // speed
507
-		    $data['heading'] = $line[7]; // heading
508
-		    $data['latitude'] = $line[4]; // lat
509
-		    $data['longitude'] = $line[5]; // long
510
-		    //$data['verticalrate'] = $line[]; // verticale rate
511
-		    $data['squawk'] = $line[10]; // squawk
512
-		    $data['emergency'] = ''; // emergency
513
-		    $data['registration'] = $line[2];
514
-		    $data['aircraft_icao'] = $line[0];
515
-		    $deparr = explode('-',$line[1]);
516
-		    if (count($deparr) == 2) {
502
+			$data = array();
503
+			$data['hex'] = $key; // hex
504
+			$data['ident'] = $line[3]; // ident
505
+			$data['altitude'] = $line[6]; // altitude
506
+			$data['speed'] = $line[8]; // speed
507
+			$data['heading'] = $line[7]; // heading
508
+			$data['latitude'] = $line[4]; // lat
509
+			$data['longitude'] = $line[5]; // long
510
+			//$data['verticalrate'] = $line[]; // verticale rate
511
+			$data['squawk'] = $line[10]; // squawk
512
+			$data['emergency'] = ''; // emergency
513
+			$data['registration'] = $line[2];
514
+			$data['aircraft_icao'] = $line[0];
515
+			$deparr = explode('-',$line[1]);
516
+			if (count($deparr) == 2) {
517 517
 			$data['departure_airport_icao'] = $deparr[0];
518 518
 			$data['arrival_airport_icao'] = $deparr[1];
519
-		    }
520
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
521
-	    	    $data['format_source'] = 'planeupdatefaa';
522
-    		    $data['id_source'] = $id_source;
523
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
524
-		    $SI->add($data);
525
-		    unset($data);
519
+			}
520
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
521
+				$data['format_source'] = 'planeupdatefaa';
522
+				$data['id_source'] = $id_source;
523
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
524
+			$SI->add($data);
525
+			unset($data);
526 526
 		}
527
-	    }
528
-    	    //$last_exec['planeupdatefaa'] = time();
529
-    	    $last_exec[$id]['last'] = time();
530
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
531
-	    $buffer = $Common->getData($value['host']);
532
-	    $all_data = json_decode($buffer,true);
533
-	    if (isset($all_data['states'])) {
527
+		}
528
+			//$last_exec['planeupdatefaa'] = time();
529
+			$last_exec[$id]['last'] = time();
530
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
531
+		$buffer = $Common->getData($value['host']);
532
+		$all_data = json_decode($buffer,true);
533
+		if (isset($all_data['states'])) {
534 534
 		foreach ($all_data['states'] as $key => $line) {
535
-		    $data = array();
536
-		    $data['hex'] = $line[0]; // hex
537
-		    $data['ident'] = trim($line[1]); // ident
538
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
539
-		    $data['speed'] = round($line[9]*1.94384); // speed
540
-		    $data['heading'] = round($line[10]); // heading
541
-		    $data['latitude'] = $line[5]; // lat
542
-		    $data['longitude'] = $line[6]; // long
543
-		    $data['verticalrate'] = $line[11]; // verticale rate
544
-		    //$data['squawk'] = $line[10]; // squawk
545
-		    //$data['emergency'] = ''; // emergency
546
-		    //$data['registration'] = $line[2];
547
-		    //$data['aircraft_icao'] = $line[0];
548
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
549
-	    	    $data['format_source'] = 'opensky';
550
-    		    $data['id_source'] = $id_source;
551
-		    $SI->add($data);
552
-		    unset($data);
535
+			$data = array();
536
+			$data['hex'] = $line[0]; // hex
537
+			$data['ident'] = trim($line[1]); // ident
538
+			$data['altitude'] = round($line[7]*3.28084); // altitude
539
+			$data['speed'] = round($line[9]*1.94384); // speed
540
+			$data['heading'] = round($line[10]); // heading
541
+			$data['latitude'] = $line[5]; // lat
542
+			$data['longitude'] = $line[6]; // long
543
+			$data['verticalrate'] = $line[11]; // verticale rate
544
+			//$data['squawk'] = $line[10]; // squawk
545
+			//$data['emergency'] = ''; // emergency
546
+			//$data['registration'] = $line[2];
547
+			//$data['aircraft_icao'] = $line[0];
548
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
549
+				$data['format_source'] = 'opensky';
550
+				$data['id_source'] = $id_source;
551
+			$SI->add($data);
552
+			unset($data);
553 553
 		}
554
-	    }
555
-    	    //$last_exec['planeupdatefaa'] = time();
556
-    	    $last_exec[$id]['last'] = time();
557
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
558
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
559
-	    //$buffer = $Common->getData($hosts[$id]);
560
-	    $buffer = $Common->getData($value['host']);
561
-	    $all_data = json_decode($buffer,true);
562
-	    foreach ($all_data as $key => $line) {
554
+		}
555
+			//$last_exec['planeupdatefaa'] = time();
556
+			$last_exec[$id]['last'] = time();
557
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
558
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
559
+		//$buffer = $Common->getData($hosts[$id]);
560
+		$buffer = $Common->getData($value['host']);
561
+		$all_data = json_decode($buffer,true);
562
+		foreach ($all_data as $key => $line) {
563 563
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
564
-		    $data = array();
565
-		    $data['hex'] = $line[0];
566
-		    $data['ident'] = $line[16]; //$line[13]
567
-	    	    $data['altitude'] = $line[4]; // altitude
568
-	    	    $data['speed'] = $line[5]; // speed
569
-	    	    $data['heading'] = $line[3]; // heading
570
-	    	    $data['latitude'] = $line[1]; // lat
571
-	    	    $data['longitude'] = $line[2]; // long
572
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
573
-	    	    $data['squawk'] = $line[6]; // squawk
574
-	    	    $data['aircraft_icao'] = $line[8];
575
-	    	    $data['registration'] = $line[9];
576
-		    $data['departure_airport_iata'] = $line[11];
577
-		    $data['arrival_airport_iata'] = $line[12];
578
-	    	    $data['emergency'] = ''; // emergency
579
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
580
-	    	    $data['format_source'] = 'fr24json';
581
-    		    $data['id_source'] = $id_source;
582
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
583
-		    $SI->add($data);
584
-		    unset($data);
564
+			$data = array();
565
+			$data['hex'] = $line[0];
566
+			$data['ident'] = $line[16]; //$line[13]
567
+				$data['altitude'] = $line[4]; // altitude
568
+				$data['speed'] = $line[5]; // speed
569
+				$data['heading'] = $line[3]; // heading
570
+				$data['latitude'] = $line[1]; // lat
571
+				$data['longitude'] = $line[2]; // long
572
+				$data['verticalrate'] = $line[15]; // verticale rate
573
+				$data['squawk'] = $line[6]; // squawk
574
+				$data['aircraft_icao'] = $line[8];
575
+				$data['registration'] = $line[9];
576
+			$data['departure_airport_iata'] = $line[11];
577
+			$data['arrival_airport_iata'] = $line[12];
578
+				$data['emergency'] = ''; // emergency
579
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
580
+				$data['format_source'] = 'fr24json';
581
+				$data['id_source'] = $id_source;
582
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
583
+			$SI->add($data);
584
+			unset($data);
585 585
 		}
586
-	    }
587
-    	    //$last_exec['fr24json'] = time();
588
-    	    $last_exec[$id]['last'] = time();
589
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
590
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
591
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
592
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
593
-	    //echo $buffer;
594
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
595
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
596
-	    $all_data = json_decode($buffer,true);
597
-	    if (json_last_error() != JSON_ERROR_NONE) {
586
+		}
587
+			//$last_exec['fr24json'] = time();
588
+			$last_exec[$id]['last'] = time();
589
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
590
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
591
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
592
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
593
+		//echo $buffer;
594
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
595
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
596
+		$all_data = json_decode($buffer,true);
597
+		if (json_last_error() != JSON_ERROR_NONE) {
598 598
 		die(json_last_error_msg());
599
-	    }
600
-	    if (isset($all_data['mrkrs'])) {
599
+		}
600
+		if (isset($all_data['mrkrs'])) {
601 601
 		foreach ($all_data['mrkrs'] as $key => $line) {
602
-		    if (isset($line['inf'])) {
602
+			if (isset($line['inf'])) {
603 603
 			$data = array();
604 604
 			$data['hex'] = $line['inf']['ia'];
605 605
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
606
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
607
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
608
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
609
-	    		$data['latitude'] = $line['pt'][0]; // lat
610
-	    		$data['longitude'] = $line['pt'][1]; // long
611
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
612
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
613
-	    		//$data['aircraft_icao'] = $line[8];
614
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
606
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
607
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
608
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
609
+				$data['latitude'] = $line['pt'][0]; // lat
610
+				$data['longitude'] = $line['pt'][1]; // long
611
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
612
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
613
+				//$data['aircraft_icao'] = $line[8];
614
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
615 615
 			//$data['departure_airport_iata'] = $line[11];
616 616
 			//$data['arrival_airport_iata'] = $line[12];
617
-	    		//$data['emergency'] = ''; // emergency
617
+				//$data['emergency'] = ''; // emergency
618 618
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
619
-	    		$data['format_source'] = 'radarvirtueljson';
620
-    			$data['id_source'] = $id_source;
619
+				$data['format_source'] = 'radarvirtueljson';
620
+				$data['id_source'] = $id_source;
621 621
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
622 622
 			$SI->add($data);
623 623
 			unset($data);
624
-		    }
624
+			}
625 625
 		}
626
-	    }
627
-    	    //$last_exec['radarvirtueljson'] = time();
628
-    	    $last_exec[$id]['last'] = time();
629
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
630
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
631
-	    //$buffer = $Common->getData($hosts[$id]);
632
-	    $buffer = $Common->getData($value['host'].'?'.time());
633
-	    $all_data = json_decode(utf8_encode($buffer),true);
626
+		}
627
+			//$last_exec['radarvirtueljson'] = time();
628
+			$last_exec[$id]['last'] = time();
629
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
630
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
631
+		//$buffer = $Common->getData($hosts[$id]);
632
+		$buffer = $Common->getData($value['host'].'?'.time());
633
+		$all_data = json_decode(utf8_encode($buffer),true);
634 634
 	    
635
-	    if (isset($all_data['pireps'])) {
636
-	        foreach ($all_data['pireps'] as $line) {
637
-		    $data = array();
638
-		    $data['id'] = $line['id'];
639
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
640
-		    $data['ident'] = $line['callsign']; // ident
641
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
642
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
643
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
644
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
645
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
646
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
647
-		    $data['latitude'] = $line['lat']; // lat
648
-		    $data['longitude'] = $line['lon']; // long
649
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
650
-		    //$data['squawk'] = $line['squawk']; // squawk
651
-		    //$data['emergency'] = ''; // emergency
652
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
653
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
654
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
655
-		    //$data['arrival_airport_time'] = $line['arrtime'];
656
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
657
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
658
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
659
-		    else $data['info'] = '';
660
-		    $data['format_source'] = 'pireps';
661
-    		    $data['id_source'] = $id_source;
662
-		    $data['datetime'] = date('Y-m-d H:i:s');
663
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
664
-		    if ($line['icon'] == 'plane') {
635
+		if (isset($all_data['pireps'])) {
636
+			foreach ($all_data['pireps'] as $line) {
637
+			$data = array();
638
+			$data['id'] = $line['id'];
639
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
640
+			$data['ident'] = $line['callsign']; // ident
641
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
642
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
643
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
644
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
645
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
646
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
647
+			$data['latitude'] = $line['lat']; // lat
648
+			$data['longitude'] = $line['lon']; // long
649
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
650
+			//$data['squawk'] = $line['squawk']; // squawk
651
+			//$data['emergency'] = ''; // emergency
652
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
653
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
654
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
655
+			//$data['arrival_airport_time'] = $line['arrtime'];
656
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
657
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
658
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
659
+			else $data['info'] = '';
660
+			$data['format_source'] = 'pireps';
661
+				$data['id_source'] = $id_source;
662
+			$data['datetime'] = date('Y-m-d H:i:s');
663
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
664
+			if ($line['icon'] == 'plane') {
665 665
 			$SI->add($data);
666
-		    //    print_r($data);
667
-    		    } elseif ($line['icon'] == 'ct') {
666
+			//    print_r($data);
667
+				} elseif ($line['icon'] == 'ct') {
668 668
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
669 669
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
670 670
 			$typec = substr($data['ident'],-3);
@@ -679,158 +679,158 @@  discard block
 block discarded – undo
679 679
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
680 680
 			else $data['type'] = 'Observer';
681 681
 			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']);
682
-		    }
683
-		    unset($data);
682
+			}
683
+			unset($data);
684 684
 		}
685
-	    }
686
-    	    //$last_exec['pirepsjson'] = time();
687
-    	    $last_exec[$id]['last'] = time();
688
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
689
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
690
-	    //$buffer = $Common->getData($hosts[$id]);
691
-	    if ($globalDebug) echo 'Get Data...'."\n";
692
-	    $buffer = $Common->getData($value['host']);
693
-	    $all_data = json_decode($buffer,true);
694
-	    if ($buffer != '' && is_array($all_data)) {
685
+		}
686
+			//$last_exec['pirepsjson'] = time();
687
+			$last_exec[$id]['last'] = time();
688
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
689
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
690
+		//$buffer = $Common->getData($hosts[$id]);
691
+		if ($globalDebug) echo 'Get Data...'."\n";
692
+		$buffer = $Common->getData($value['host']);
693
+		$all_data = json_decode($buffer,true);
694
+		if ($buffer != '' && is_array($all_data)) {
695 695
 		foreach ($all_data as $line) {
696
-	    	    $data = array();
697
-	    	    //$data['id'] = $line['id']; // id not usable
698
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
699
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
700
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
701
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
702
-	    	    $data['ident'] = $line['flightnum']; // ident
703
-	    	    $data['altitude'] = $line['alt']; // altitude
704
-	    	    $data['speed'] = $line['gs']; // speed
705
-	    	    $data['heading'] = $line['heading']; // heading
706
-	    	    $data['latitude'] = $line['lat']; // lat
707
-	    	    $data['longitude'] = $line['lng']; // long
708
-	    	    $data['verticalrate'] = ''; // verticale rate
709
-	    	    $data['squawk'] = ''; // squawk
710
-	    	    $data['emergency'] = ''; // emergency
711
-	    	    //$data['datetime'] = $line['lastupdate'];
712
-	    	    $data['last_update'] = $line['lastupdate'];
713
-		    $data['datetime'] = date('Y-m-d H:i:s');
714
-	    	    $data['departure_airport_icao'] = $line['depicao'];
715
-	    	    $data['departure_airport_time'] = $line['deptime'];
716
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
717
-    		    $data['arrival_airport_time'] = $line['arrtime'];
718
-    		    $data['registration'] = $line['aircraft'];
719
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
720
-		    if (isset($line['aircraftname'])) {
696
+				$data = array();
697
+				//$data['id'] = $line['id']; // id not usable
698
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
699
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
700
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
701
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
702
+				$data['ident'] = $line['flightnum']; // ident
703
+				$data['altitude'] = $line['alt']; // altitude
704
+				$data['speed'] = $line['gs']; // speed
705
+				$data['heading'] = $line['heading']; // heading
706
+				$data['latitude'] = $line['lat']; // lat
707
+				$data['longitude'] = $line['lng']; // long
708
+				$data['verticalrate'] = ''; // verticale rate
709
+				$data['squawk'] = ''; // squawk
710
+				$data['emergency'] = ''; // emergency
711
+				//$data['datetime'] = $line['lastupdate'];
712
+				$data['last_update'] = $line['lastupdate'];
713
+			$data['datetime'] = date('Y-m-d H:i:s');
714
+				$data['departure_airport_icao'] = $line['depicao'];
715
+				$data['departure_airport_time'] = $line['deptime'];
716
+				$data['arrival_airport_icao'] = $line['arricao'];
717
+				$data['arrival_airport_time'] = $line['arrtime'];
718
+				$data['registration'] = $line['aircraft'];
719
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
720
+			if (isset($line['aircraftname'])) {
721 721
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
722 722
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
723
-	    		$aircraft_data = explode('-',$line['aircraftname']);
724
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
725
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
726
-	    		else {
727
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
728
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
729
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
730
-	    		}
731
-	    	    }
732
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
733
-    		    $data['id_source'] = $id_source;
734
-	    	    $data['format_source'] = 'phpvmacars';
735
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
736
-		    $SI->add($data);
737
-		    unset($data);
723
+				$aircraft_data = explode('-',$line['aircraftname']);
724
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
725
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
726
+				else {
727
+					$aircraft_data = explode(' ',$line['aircraftname']);
728
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
729
+					else $data['aircraft_icao'] = $line['aircraftname'];
730
+				}
731
+				}
732
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
733
+				$data['id_source'] = $id_source;
734
+				$data['format_source'] = 'phpvmacars';
735
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
736
+			$SI->add($data);
737
+			unset($data);
738 738
 		}
739 739
 		if ($globalDebug) echo 'No more data...'."\n";
740 740
 		unset($buffer);
741 741
 		unset($all_data);
742
-	    }
743
-    	    //$last_exec['phpvmacars'] = time();
744
-    	    $last_exec[$id]['last'] = time();
745
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
746
-	    //$buffer = $Common->getData($hosts[$id]);
747
-	    if ($globalDebug) echo 'Get Data...'."\n";
748
-	    $buffer = $Common->getData($value['host']);
749
-	    $all_data = json_decode($buffer,true);
750
-	    if ($buffer != '' && is_array($all_data)) {
742
+		}
743
+			//$last_exec['phpvmacars'] = time();
744
+			$last_exec[$id]['last'] = time();
745
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
746
+		//$buffer = $Common->getData($hosts[$id]);
747
+		if ($globalDebug) echo 'Get Data...'."\n";
748
+		$buffer = $Common->getData($value['host']);
749
+		$all_data = json_decode($buffer,true);
750
+		if ($buffer != '' && is_array($all_data)) {
751 751
 		foreach ($all_data as $line) {
752
-	    	    $data = array();
753
-	    	    //$data['id'] = $line['id']; // id not usable
754
-	    	    $data['id'] = trim($line['flight_id']);
755
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
756
-	    	    $data['pilot_name'] = $line['pilot_name'];
757
-	    	    $data['pilot_id'] = $line['pilot_id'];
758
-	    	    $data['ident'] = trim($line['callsign']); // ident
759
-	    	    $data['altitude'] = $line['altitude']; // altitude
760
-	    	    $data['speed'] = $line['gs']; // speed
761
-	    	    $data['heading'] = $line['heading']; // heading
762
-	    	    $data['latitude'] = $line['latitude']; // lat
763
-	    	    $data['longitude'] = $line['longitude']; // long
764
-	    	    $data['verticalrate'] = ''; // verticale rate
765
-	    	    $data['squawk'] = ''; // squawk
766
-	    	    $data['emergency'] = ''; // emergency
767
-	    	    //$data['datetime'] = $line['lastupdate'];
768
-	    	    $data['last_update'] = $line['last_update'];
769
-		    $data['datetime'] = date('Y-m-d H:i:s');
770
-	    	    $data['departure_airport_icao'] = $line['departure'];
771
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
772
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
773
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
774
-    		    //$data['registration'] = $line['aircraft'];
775
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
776
-	    	    $data['aircraft_icao'] = $line['plane_type'];
777
-    		    $data['id_source'] = $id_source;
778
-	    	    $data['format_source'] = 'vam';
779
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
780
-		    $SI->add($data);
781
-		    unset($data);
752
+				$data = array();
753
+				//$data['id'] = $line['id']; // id not usable
754
+				$data['id'] = trim($line['flight_id']);
755
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
756
+				$data['pilot_name'] = $line['pilot_name'];
757
+				$data['pilot_id'] = $line['pilot_id'];
758
+				$data['ident'] = trim($line['callsign']); // ident
759
+				$data['altitude'] = $line['altitude']; // altitude
760
+				$data['speed'] = $line['gs']; // speed
761
+				$data['heading'] = $line['heading']; // heading
762
+				$data['latitude'] = $line['latitude']; // lat
763
+				$data['longitude'] = $line['longitude']; // long
764
+				$data['verticalrate'] = ''; // verticale rate
765
+				$data['squawk'] = ''; // squawk
766
+				$data['emergency'] = ''; // emergency
767
+				//$data['datetime'] = $line['lastupdate'];
768
+				$data['last_update'] = $line['last_update'];
769
+			$data['datetime'] = date('Y-m-d H:i:s');
770
+				$data['departure_airport_icao'] = $line['departure'];
771
+				//$data['departure_airport_time'] = $line['departure_time'];
772
+				$data['arrival_airport_icao'] = $line['arrival'];
773
+				//$data['arrival_airport_time'] = $line['arrival_time'];
774
+				//$data['registration'] = $line['aircraft'];
775
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
776
+				$data['aircraft_icao'] = $line['plane_type'];
777
+				$data['id_source'] = $id_source;
778
+				$data['format_source'] = 'vam';
779
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
780
+			$SI->add($data);
781
+			unset($data);
782 782
 		}
783 783
 		if ($globalDebug) echo 'No more data...'."\n";
784 784
 		unset($buffer);
785 785
 		unset($all_data);
786
-	    }
787
-    	    //$last_exec['phpvmacars'] = time();
788
-    	    $last_exec[$id]['last'] = time();
786
+		}
787
+			//$last_exec['phpvmacars'] = time();
788
+			$last_exec[$id]['last'] = time();
789 789
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
790 790
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars') {
791
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
792
-    	    //$last_exec[$id]['last'] = time();
791
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
792
+			//$last_exec[$id]['last'] = time();
793 793
 
794
-	    //$read = array( $sockets[$id] );
795
-	    $read = $sockets;
796
-	    $write = NULL;
797
-	    $e = NULL;
798
-	    $n = socket_select($read, $write, $e, $timeout);
799
-	    if ($e != NULL) var_dump($e);
800
-	    if ($n > 0) {
794
+		//$read = array( $sockets[$id] );
795
+		$read = $sockets;
796
+		$write = NULL;
797
+		$e = NULL;
798
+		$n = socket_select($read, $write, $e, $timeout);
799
+		if ($e != NULL) var_dump($e);
800
+		if ($n > 0) {
801 801
 		foreach ($read as $nb => $r) {
802
-		    //$value = $formats[$nb];
803
-		    $format = $globalSources[$nb]['format'];
804
-        	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv') {
805
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
806
-        	    } else {
807
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
808
-	    	    }
809
-        	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
810
-        	    //echo $buffer."\n";
811
-		    // lets play nice and handle signals such as ctrl-c/kill properly
812
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
813
-		    $error = false;
814
-		    //$SI::del();
815
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
816
-		    // SBS format is CSV format
817
-		    if ($buffer != '') {
802
+			//$value = $formats[$nb];
803
+			$format = $globalSources[$nb]['format'];
804
+				if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv') {
805
+				$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
806
+				} else {
807
+					$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
808
+				}
809
+				//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
810
+				//echo $buffer."\n";
811
+			// lets play nice and handle signals such as ctrl-c/kill properly
812
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
813
+			$error = false;
814
+			//$SI::del();
815
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
816
+			// SBS format is CSV format
817
+			if ($buffer != '') {
818 818
 			$tt[$format] = 0;
819 819
 			if ($format == 'acarssbs3') {
820
-			    echo $buffer."\n";
820
+				echo $buffer."\n";
821 821
 			} elseif ($format == 'raw') {
822
-			    // AVR format
823
-			    $data = $SBS->parse($buffer);
824
-			    if (is_array($data)) {
822
+				// AVR format
823
+				$data = $SBS->parse($buffer);
824
+				if (is_array($data)) {
825 825
 				$data['datetime'] = date('Y-m-d H:i:s');
826 826
 				$data['format_source'] = 'raw';
827 827
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
828
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
829
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
830
-                            }
831
-                        } elseif ($format == 'flightgearsp') {
832
-                    	    //echo $buffer."\n";
833
-                    	    if (strlen($buffer) > 5) {
828
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
829
+								if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
830
+							}
831
+						} elseif ($format == 'flightgearsp') {
832
+							//echo $buffer."\n";
833
+							if (strlen($buffer) > 5) {
834 834
 				$line = explode(',',$buffer);
835 835
 				$data = array();
836 836
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -846,114 +846,114 @@  discard block
 block discarded – undo
846 846
 				$data['format_source'] = 'flightgearsp';
847 847
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
848 848
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
849
-			    }
850
-                        } elseif ($format == 'acars') {
851
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
852
-			    $ACARS->add(trim($buffer));
853
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
854
-			    $ACARS->deleteLiveAcarsData();
849
+				}
850
+						} elseif ($format == 'acars') {
851
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
852
+				$ACARS->add(trim($buffer));
853
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
854
+				$ACARS->deleteLiveAcarsData();
855 855
 			} elseif ($format == 'flightgearmp') {
856
-			    if (substr($buffer,0,1) != '#') {
856
+				if (substr($buffer,0,1) != '#') {
857 857
 				$data = array();
858 858
 				//echo $buffer."\n";
859 859
 				$line = explode(' ',$buffer);
860 860
 				if (count($line) == 11) {
861
-				    $userserver = explode('@',$line[0]);
862
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
863
-				    $data['ident'] = $userserver[0];
864
-				    $data['registration'] = $userserver[0];
865
-				    $data['latitude'] = $line[4];
866
-				    $data['longitude'] = $line[5];
867
-				    $data['altitude'] = $line[6];
868
-				    $data['datetime'] = date('Y-m-d H:i:s');
869
-				    $aircraft_type = $line[10];
870
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
871
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
872
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
861
+					$userserver = explode('@',$line[0]);
862
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
863
+					$data['ident'] = $userserver[0];
864
+					$data['registration'] = $userserver[0];
865
+					$data['latitude'] = $line[4];
866
+					$data['longitude'] = $line[5];
867
+					$data['altitude'] = $line[6];
868
+					$data['datetime'] = date('Y-m-d H:i:s');
869
+					$aircraft_type = $line[10];
870
+					$aircraft_type = preg_split(':/:',$aircraft_type);
871
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
872
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
873
+				}
873 874
 				}
874
-			    }
875 875
 			} elseif ($format == 'beast') {
876
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
877
-			    die;
876
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
877
+				die;
878 878
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
879
-			    $line = explode("\t", $buffer);
880
-			    for($k = 0; $k < count($line); $k=$k+2) {
879
+				$line = explode("\t", $buffer);
880
+				for($k = 0; $k < count($line); $k=$k+2) {
881 881
 				$key = $line[$k];
882
-			        $lined[$key] = $line[$k+1];
883
-			    }
884
-    			    if (count($lined) > 3) {
885
-    				$data['hex'] = $lined['hexid'];
886
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
887
-    				$data['datetime'] = date('Y-m-d H:i:s');;
888
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
889
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
890
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
891
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
892
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
893
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
894
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
895
-    				$data['id_source'] = $id_source;
896
-    				$data['format_source'] = 'tsv';
897
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
898
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
899
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
900
-    				unset($lined);
901
-    				unset($data);
902
-    			    } else $error = true;
882
+					$lined[$key] = $line[$k+1];
883
+				}
884
+					if (count($lined) > 3) {
885
+					$data['hex'] = $lined['hexid'];
886
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
887
+					$data['datetime'] = date('Y-m-d H:i:s');;
888
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
889
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
890
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
891
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
892
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
893
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
894
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
895
+					$data['id_source'] = $id_source;
896
+					$data['format_source'] = 'tsv';
897
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
898
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
899
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
900
+					unset($lined);
901
+					unset($data);
902
+					} else $error = true;
903 903
 			} elseif ($format == 'aprs' && $use_aprs) {
904
-			    if ($aprs_connect == 0) {
904
+				if ($aprs_connect == 0) {
905 905
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
906 906
 				$aprs_connect = 1;
907
-			    }
908
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
907
+				}
908
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
909 909
 				$aprs_last_tx = time();
910 910
 				$data_aprs = "# Keep alive";
911 911
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
912
-			    }
913
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
914
-			    $buffer = str_replace('APRS <- ','',$buffer);
915
-			    $buffer = str_replace('APRS -> ','',$buffer);
916
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
912
+				}
913
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
914
+				$buffer = str_replace('APRS <- ','',$buffer);
915
+				$buffer = str_replace('APRS -> ','',$buffer);
916
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
917 917
 				$line = $APRS->parse($buffer);
918 918
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
919
-				    $data = array();
920
-				    //print_r($line);
921
-				    $data['hex'] = $line['address'];
922
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
923
-				    //$data['datetime'] = date('Y-m-d H:i:s');
924
-				    $data['ident'] = $line['ident'];
925
-				    $data['latitude'] = $line['latitude'];
926
-				    $data['longitude'] = $line['longitude'];
927
-				    //$data['verticalrate'] = $line[16];
928
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
929
-				    else $data['speed'] = 0;
930
-				    $data['altitude'] = $line['altitude'];
931
-				    if (isset($line['course'])) $data['heading'] = $line['course'];
932
-				    //else $data['heading'] = 0;
933
-				    $data['aircraft_type'] = $line['stealth'];
934
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
935
-    				    $data['id_source'] = $id_source;
936
-				    $data['format_source'] = 'aprs';
937
-				    $data['source_name'] = $line['source'];
938
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
939
-				    $currentdate = date('Y-m-d H:i:s');
940
-				    $aprsdate = strtotime($data['datetime']);
941
-				    // Accept data if time <= system time + 20s
942
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
943
-				    else {
919
+					$data = array();
920
+					//print_r($line);
921
+					$data['hex'] = $line['address'];
922
+					$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
923
+					//$data['datetime'] = date('Y-m-d H:i:s');
924
+					$data['ident'] = $line['ident'];
925
+					$data['latitude'] = $line['latitude'];
926
+					$data['longitude'] = $line['longitude'];
927
+					//$data['verticalrate'] = $line[16];
928
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
929
+					else $data['speed'] = 0;
930
+					$data['altitude'] = $line['altitude'];
931
+					if (isset($line['course'])) $data['heading'] = $line['course'];
932
+					//else $data['heading'] = 0;
933
+					$data['aircraft_type'] = $line['stealth'];
934
+					if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
935
+						$data['id_source'] = $id_source;
936
+					$data['format_source'] = 'aprs';
937
+					$data['source_name'] = $line['source'];
938
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
939
+					$currentdate = date('Y-m-d H:i:s');
940
+					$aprsdate = strtotime($data['datetime']);
941
+					// Accept data if time <= system time + 20s
942
+					if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
943
+					else {
944 944
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
945 945
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
946
-				    }
947
-				    unset($data);
946
+					}
947
+					unset($data);
948 948
 				} 
949 949
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
950 950
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
951
-			    }
951
+				}
952 952
 			} else {
953
-			    $line = explode(',', $buffer);
954
-    			    if (count($line) > 20) {
955
-    			    	$data['hex'] = $line[4];
956
-    				/*
953
+				$line = explode(',', $buffer);
954
+					if (count($line) > 20) {
955
+						$data['hex'] = $line[4];
956
+					/*
957 957
     				$data['datetime'] = $line[6].' '.$line[7];
958 958
     					date_default_timezone_set($globalTimezone);
959 959
     					$datetime = new DateTime($data['datetime']);
@@ -961,28 +961,28 @@  discard block
 block discarded – undo
961 961
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
962 962
     					date_default_timezone_set('UTC');
963 963
     				*/
964
-    				// Force datetime to current UTC datetime
965
-    				$data['datetime'] = date('Y-m-d H:i:s');
966
-    				$data['ident'] = trim($line[10]);
967
-    				$data['latitude'] = $line[14];
968
-    				$data['longitude'] = $line[15];
969
-    				$data['verticalrate'] = $line[16];
970
-    				$data['emergency'] = $line[20];
971
-    				$data['speed'] = $line[12];
972
-    				$data['squawk'] = $line[17];
973
-    				$data['altitude'] = $line[11];
974
-    				$data['heading'] = $line[13];
975
-    				$data['ground'] = $line[21];
976
-    				$data['emergency'] = $line[19];
977
-    				$data['format_source'] = 'sbs';
964
+					// Force datetime to current UTC datetime
965
+					$data['datetime'] = date('Y-m-d H:i:s');
966
+					$data['ident'] = trim($line[10]);
967
+					$data['latitude'] = $line[14];
968
+					$data['longitude'] = $line[15];
969
+					$data['verticalrate'] = $line[16];
970
+					$data['emergency'] = $line[20];
971
+					$data['speed'] = $line[12];
972
+					$data['squawk'] = $line[17];
973
+					$data['altitude'] = $line[11];
974
+					$data['heading'] = $line[13];
975
+					$data['ground'] = $line[21];
976
+					$data['emergency'] = $line[19];
977
+					$data['format_source'] = 'sbs';
978 978
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
979
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
980
-    				$data['id_source'] = $id_source;
981
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
982
-    				else $error = true;
983
-    				unset($data);
984
-    			    } else $error = true;
985
-			    if ($error) {
979
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
980
+					$data['id_source'] = $id_source;
981
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
982
+					else $error = true;
983
+					unset($data);
984
+					} else $error = true;
985
+				if ($error) {
986 986
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
987 987
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
988 988
 				} else {
@@ -998,13 +998,13 @@  discard block
 block discarded – undo
998 998
 					connect_all($sourceer);
999 999
 					$sourceer = array();
1000 1000
 				}
1001
-			    }
1001
+				}
1002 1002
 			}
1003 1003
 			// Sleep for xxx microseconds
1004 1004
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1005
-		    } else {
1005
+			} else {
1006 1006
 			if ($format == 'flightgearmp') {
1007
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1007
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1008 1008
 				//@socket_close($r);
1009 1009
 				sleep($globalMinFetch);
1010 1010
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1013,9 +1013,9 @@  discard block
 block discarded – undo
1013 1013
 				break;
1014 1014
 				
1015 1015
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1016
-			    if (isset($tt[$format])) $tt[$format]++;
1017
-			    else $tt[$format] = 0;
1018
-			    if ($tt[$format] > 30) {
1016
+				if (isset($tt[$format])) $tt[$format]++;
1017
+				else $tt[$format] = 0;
1018
+				if ($tt[$format] > 30) {
1019 1019
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1020 1020
 				//@socket_close($r);
1021 1021
 				sleep(2);
@@ -1026,40 +1026,40 @@  discard block
 block discarded – undo
1026 1026
 				//connect_all($globalSources);
1027 1027
 				$tt[$format]=0;
1028 1028
 				break;
1029
-			    }
1029
+				}
1030
+			}
1030 1031
 			}
1031
-		    }
1032 1032
 		}
1033
-	    } else {
1033
+		} else {
1034 1034
 		$error = socket_strerror(socket_last_error());
1035 1035
 		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1036 1036
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) || time() - $time >= $timeout) {
1037 1037
 			if (isset($globalDebug)) echo "Restarting...\n";
1038 1038
 			// Restart the script if possible
1039 1039
 			if (is_array($sockets)) {
1040
-			    if ($globalDebug) echo "Shutdown all sockets...";
1040
+				if ($globalDebug) echo "Shutdown all sockets...";
1041 1041
 			    
1042
-			    foreach ($sockets as $sock) {
1042
+				foreach ($sockets as $sock) {
1043 1043
 				@socket_shutdown($sock,2);
1044 1044
 				@socket_close($sock);
1045
-			    }
1045
+				}
1046 1046
 			    
1047 1047
 			}
1048
-			    if ($globalDebug) echo "Restart all connections...";
1049
-			    sleep(2);
1050
-			    $time = time();
1051
-			    //connect_all($hosts);
1052
-			    $aprs_connect = 0;
1053
-			    connect_all($globalSources);
1048
+				if ($globalDebug) echo "Restart all connections...";
1049
+				sleep(2);
1050
+				$time = time();
1051
+				//connect_all($hosts);
1052
+				$aprs_connect = 0;
1053
+				connect_all($globalSources);
1054 1054
 
1055 1055
 		}
1056
-	    }
1056
+		}
1057 1057
 	}
1058 1058
 	if ($globalDaemon === false) {
1059
-	    if ($globalDebug) echo 'Check all...'."\n";
1060
-	    $SI->checkAll();
1059
+		if ($globalDebug) echo 'Check all...'."\n";
1060
+		$SI->checkAll();
1061
+	}
1061 1062
 	}
1062
-    }
1063 1063
 }
1064 1064
 
1065 1065
 ?>
Please login to merge, or discard this patch.
install/VAM/VAM-json.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,27 +11,27 @@
 block discarded – undo
11 11
 	die();
12 12
 }
13 13
 $query = 'select * from vam_live_flights rc, gvausers gu where gu.gvauser_id = rc.gvauser_id';  
14
-$json_data=array();  
14
+$json_data = array();  
15 15
 $result = $db->query($query);
16 16
 while ($rec = $result->fetch_assoc())
17 17
 {  
18
-	$json_array['gvauser_id']=$rec['gvauser_id']; // users "pilot unique ID" "40"
19
-	$json_array['flight_id']=$rec['flight_id']; // flight_id
20
-	$json_array['pilot_id']=$rec['callsign']; // users pilot_id "VAM500"
21
-	$json_array['callsign']=substr($rec['flight_id'],-7);  // substr icao Flight "AFR524"
22
-	$json_array['pilot_name']=$rec['name'] .' '.$rec['surname'] ;  // Users "name + surname"
23
-	$json_array['plane_type']=$rec['plane_type'];  // type Plane "B739"
24
-	$json_array['departure']=$rec['departure'];  // departure ICAO
25
-	$json_array['arrival']=$rec['arrival'];     // arrival Ident
26
-	$json_array['latitude']=$rec['latitude'];  // return 55.7328860921521
27
-	$json_array['longitude']=$rec['longitude'];  // return 8.87433614409404
28
-	$json_array['altitude']=$rec['altitude'];  // return "147"
29
-	$json_array['heading']=$rec['heading'];  // return "307"
30
-	$json_array['ias']=$rec['ias'];  // return speed "IAS"
31
-	$json_array['gs']=$rec['gs'];  // return speed "GS"
18
+	$json_array['gvauser_id'] = $rec['gvauser_id']; // users "pilot unique ID" "40"
19
+	$json_array['flight_id'] = $rec['flight_id']; // flight_id
20
+	$json_array['pilot_id'] = $rec['callsign']; // users pilot_id "VAM500"
21
+	$json_array['callsign'] = substr($rec['flight_id'], -7); // substr icao Flight "AFR524"
22
+	$json_array['pilot_name'] = $rec['name'].' '.$rec['surname']; // Users "name + surname"
23
+	$json_array['plane_type'] = $rec['plane_type']; // type Plane "B739"
24
+	$json_array['departure'] = $rec['departure']; // departure ICAO
25
+	$json_array['arrival'] = $rec['arrival']; // arrival Ident
26
+	$json_array['latitude'] = $rec['latitude']; // return 55.7328860921521
27
+	$json_array['longitude'] = $rec['longitude']; // return 8.87433614409404
28
+	$json_array['altitude'] = $rec['altitude']; // return "147"
29
+	$json_array['heading'] = $rec['heading']; // return "307"
30
+	$json_array['ias'] = $rec['ias']; // return speed "IAS"
31
+	$json_array['gs'] = $rec['gs']; // return speed "GS"
32 32
 	// $json_array['routes']=$rec['routes'];  // (unusable)
33
-	$json_array['flight_status']=$rec['flight_status'];  // "return Status"
34
-	$json_array['last_update']=$rec['last_update'];  // return "DateTime"
33
+	$json_array['flight_status'] = $rec['flight_status']; // "return Status"
34
+	$json_array['last_update'] = $rec['last_update']; // return "DateTime"
35 35
 	$json_data[] = $json_array;
36 36
  }  
37 37
 echo json_encode($json_data);
Please login to merge, or discard this patch.
install/class.update_schema.php 3 patches
Indentation   +558 added lines, -558 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@  discard block
 block discarded – undo
8 8
 class update_schema {
9 9
 
10 10
 	public static function update_schedule() {
11
-	    $Connection = new Connection();
12
-	    $Schedule = new Schedule();
13
-	    $query = "SELECT * FROM schedule";
14
-            try {
15
-            	$sth = $Connection->db->prepare($query);
11
+		$Connection = new Connection();
12
+		$Schedule = new Schedule();
13
+		$query = "SELECT * FROM schedule";
14
+			try {
15
+				$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+			} catch(PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19
-    	    }
20
-    	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
-    	    }
19
+			}
20
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
+			$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
+			}
23 23
 	
24 24
 	}
25 25
 /*
@@ -43,198 +43,198 @@  discard block
 block discarded – undo
43 43
     	}
44 44
 */	
45 45
 	private static function update_from_1() {
46
-    		$Connection = new Connection();
47
-    		// Add new column to routes table
48
-    		//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
46
+			$Connection = new Connection();
47
+			// Add new column to routes table
48
+			//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
49 49
 		$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL";
50
-        	try {
51
-            	    $sth = $Connection->db->prepare($query);
52
-		    $sth->execute();
53
-    		} catch(PDOException $e) {
54
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
-    		}
56
-    		// Copy schedules data to routes table
57
-    		self::update_schedule();
58
-    		// Delete schedule table
50
+			try {
51
+					$sth = $Connection->db->prepare($query);
52
+			$sth->execute();
53
+			} catch(PDOException $e) {
54
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
+			}
56
+			// Copy schedules data to routes table
57
+			self::update_schedule();
58
+			// Delete schedule table
59 59
 		$query = "DROP TABLE `schedule`";
60
-        	try {
61
-            	    $sth = $Connection->db->prepare($query);
62
-		    $sth->execute();
63
-    		} catch(PDOException $e) {
64
-		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65
-    		}
66
-    		// Add source column
67
-    		$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
-    		try {
69
-            	    $sth = $Connection->db->prepare($query);
70
-		    $sth->execute();
71
-    		} catch(PDOException $e) {
72
-		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
-    		}
60
+			try {
61
+					$sth = $Connection->db->prepare($query);
62
+			$sth->execute();
63
+			} catch(PDOException $e) {
64
+			return "error (delete schedule table) : ".$e->getMessage()."\n";
65
+			}
66
+			// Add source column
67
+			$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
+			try {
69
+					$sth = $Connection->db->prepare($query);
70
+			$sth->execute();
71
+			} catch(PDOException $e) {
72
+			return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
+			}
74 74
 		// Delete unused column
75 75
 		$query = "ALTER TABLE `aircraft_modes`  DROP `SerialNo`,  DROP `OperatorFlagCode`,  DROP `Manufacturer`,  DROP `Type`,  DROP `FirstRegDate`,  DROP `CurrentRegDate`,  DROP `Country`,  DROP `PreviousID`,  DROP `DeRegDate`,  DROP `Status`,  DROP `PopularName`,  DROP `GenericName`,  DROP `AircraftClass`,  DROP `Engines`,  DROP `OwnershipStatus`,  DROP `RegisteredOwners`,  DROP `MTOW`,  DROP `TotalHours`,  DROP `YearBuilt`,  DROP `CofACategory`,  DROP `CofAExpiry`,  DROP `UserNotes`,  DROP `Interested`,  DROP `UserTag`,  DROP `InfoUrl`,  DROP `PictureUrl1`,  DROP `PictureUrl2`,  DROP `PictureUrl3`,  DROP `UserBool1`,  DROP `UserBool2`,  DROP `UserBool3`,  DROP `UserBool4`,  DROP `UserBool5`,  DROP `UserString1`,  DROP `UserString2`,  DROP `UserString3`,  DROP `UserString4`,  DROP `UserString5`,  DROP `UserInt1`,  DROP `UserInt2`,  DROP `UserInt3`,  DROP `UserInt4`,  DROP `UserInt5`";
76
-    		try {
77
-            	    $sth = $Connection->db->prepare($query);
78
-		    $sth->execute();
79
-    		} catch(PDOException $e) {
80
-		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
-    		}
76
+			try {
77
+					$sth = $Connection->db->prepare($query);
78
+			$sth->execute();
79
+			} catch(PDOException $e) {
80
+			return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
+			}
82 82
 		// Add ModeS column
83 83
 		$query = "ALTER TABLE `spotter_output`  ADD `ModeS` VARCHAR(255) NULL";
84
-    		try {
85
-            	    $sth = $Connection->db->prepare($query);
86
-		    $sth->execute();
87
-    		} catch(PDOException $e) {
88
-		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
-    		}
84
+			try {
85
+					$sth = $Connection->db->prepare($query);
86
+			$sth->execute();
87
+			} catch(PDOException $e) {
88
+			return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
+			}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91
-    		try {
92
-            	    $sth = $Connection->db->prepare($query);
93
-		    $sth->execute();
94
-    		} catch(PDOException $e) {
95
-		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
-    		}
97
-    		// Add auto_increment for aircraft_modes
98
-    		$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
-    		try {
100
-            	    $sth = $Connection->db->prepare($query);
101
-		    $sth->execute();
102
-    		} catch(PDOException $e) {
103
-		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
-    		}
105
-    		$error = '';
91
+			try {
92
+					$sth = $Connection->db->prepare($query);
93
+			$sth->execute();
94
+			} catch(PDOException $e) {
95
+			return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
+			}
97
+			// Add auto_increment for aircraft_modes
98
+			$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
+			try {
100
+					$sth = $Connection->db->prepare($query);
101
+			$sth->execute();
102
+			} catch(PDOException $e) {
103
+			return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
+			}
105
+			$error = '';
106 106
 		$error .= create_db::import_file('../db/acars_live.sql');
107 107
 		$error .= create_db::import_file('../db/config.sql');
108 108
 		// Update schema_version to 2
109 109
 		$query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'";
110
-        	try {
111
-            	    $sth = $Connection->db->prepare($query);
112
-		    $sth->execute();
113
-    		} catch(PDOException $e) {
114
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
115
-    		}
110
+			try {
111
+					$sth = $Connection->db->prepare($query);
112
+			$sth->execute();
113
+			} catch(PDOException $e) {
114
+			return "error (update schema_version) : ".$e->getMessage()."\n";
115
+			}
116 116
 		return $error;
117
-        }
117
+		}
118 118
 
119 119
 	private static function update_from_2() {
120
-    		$Connection = new Connection();
121
-    		// Add new column decode to acars_live table
120
+			$Connection = new Connection();
121
+			// Add new column decode to acars_live table
122 122
 		$query = "ALTER TABLE `acars_live` ADD `decode` TEXT";
123
-        	try {
124
-            	    $sth = $Connection->db->prepare($query);
125
-		    $sth->execute();
126
-    		} catch(PDOException $e) {
127
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
-    		}
129
-    		$error = '';
130
-    		// Create table acars_archive
123
+			try {
124
+					$sth = $Connection->db->prepare($query);
125
+			$sth->execute();
126
+			} catch(PDOException $e) {
127
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
+			}
129
+			$error = '';
130
+			// Create table acars_archive
131 131
 		$error .= create_db::import_file('../db/acars_archive.sql');
132 132
 		// Update schema_version to 3
133 133
 		$query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'";
134
-        	try {
135
-            	    $sth = $Connection->db->prepare($query);
136
-		    $sth->execute();
137
-    		} catch(PDOException $e) {
138
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
139
-    		}
134
+			try {
135
+					$sth = $Connection->db->prepare($query);
136
+			$sth->execute();
137
+			} catch(PDOException $e) {
138
+			return "error (update schema_version) : ".$e->getMessage()."\n";
139
+			}
140 140
 		return $error;
141 141
 	}
142 142
 
143 143
 	private static function update_from_3() {
144
-    		$Connection = new Connection();
145
-    		// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
144
+			$Connection = new Connection();
145
+			// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
146 146
 		$query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP";
147
-        	try {
148
-            	    $sth = $Connection->db->prepare($query);
149
-		    $sth->execute();
150
-    		} catch(PDOException $e) {
151
-		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
-    		}
153
-    		// Add image_source_website column to spotter_image
147
+			try {
148
+					$sth = $Connection->db->prepare($query);
149
+			$sth->execute();
150
+			} catch(PDOException $e) {
151
+			return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
+			}
153
+			// Add image_source_website column to spotter_image
154 154
 		$query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL";
155
-        	try {
156
-            	    $sth = $Connection->db->prepare($query);
157
-		    $sth->execute();
158
-    		} catch(PDOException $e) {
159
-		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
-    		}
161
-    		$error = '';
155
+			try {
156
+					$sth = $Connection->db->prepare($query);
157
+			$sth->execute();
158
+			} catch(PDOException $e) {
159
+			return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
+			}
161
+			$error = '';
162 162
 		// Update schema_version to 4
163 163
 		$query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'";
164
-        	try {
165
-            	    $sth = $Connection->db->prepare($query);
166
-		    $sth->execute();
167
-    		} catch(PDOException $e) {
168
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
169
-    		}
164
+			try {
165
+					$sth = $Connection->db->prepare($query);
166
+			$sth->execute();
167
+			} catch(PDOException $e) {
168
+			return "error (update schema_version) : ".$e->getMessage()."\n";
169
+			}
170 170
 		return $error;
171 171
 	}
172 172
 	
173 173
 	private static function update_from_4() {
174
-    		$Connection = new Connection();
174
+			$Connection = new Connection();
175 175
 	
176
-    		$error = '';
177
-    		// Create table acars_label
176
+			$error = '';
177
+			// Create table acars_label
178 178
 		$error .= create_db::import_file('../db/acars_label.sql');
179 179
 		if ($error == '') {
180
-		    // Update schema_version to 5
181
-		    $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
-        	    try {
183
-            		$sth = $Connection->db->prepare($query);
180
+			// Update schema_version to 5
181
+			$query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
+				try {
183
+					$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+				} catch(PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187
-    		    }
188
-    		}
187
+				}
188
+			}
189 189
 		return $error;
190 190
 	}
191 191
 
192 192
 	private static function update_from_5() {
193
-    		$Connection = new Connection();
194
-    		// Add columns to translation
193
+			$Connection = new Connection();
194
+			// Add columns to translation
195 195
 		$query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;";
196
-        	try {
197
-            	    $sth = $Connection->db->prepare($query);
198
-		    $sth->execute();
199
-    		} catch(PDOException $e) {
200
-		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
-    		}
202
-    		// Add aircraft_shadow column to aircraft
203
-    		$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
-        	try {
205
-            	    $sth = $Connection->db->prepare($query);
206
-		    $sth->execute();
207
-    		} catch(PDOException $e) {
208
-		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
-    		}
210
-    		// Add aircraft_shadow column to spotter_live
211
-    		$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
-        	try {
213
-            	    $sth = $Connection->db->prepare($query);
214
-		    $sth->execute();
215
-    		} catch(PDOException $e) {
216
-		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
-    		}
218
-    		$error = '';
219
-    		// Update table aircraft
196
+			try {
197
+					$sth = $Connection->db->prepare($query);
198
+			$sth->execute();
199
+			} catch(PDOException $e) {
200
+			return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
+			}
202
+			// Add aircraft_shadow column to aircraft
203
+			$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
+			try {
205
+					$sth = $Connection->db->prepare($query);
206
+			$sth->execute();
207
+			} catch(PDOException $e) {
208
+			return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
+			}
210
+			// Add aircraft_shadow column to spotter_live
211
+			$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
+			try {
213
+					$sth = $Connection->db->prepare($query);
214
+			$sth->execute();
215
+			} catch(PDOException $e) {
216
+			return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
+			}
218
+			$error = '';
219
+			// Update table aircraft
220 220
 		$error .= create_db::import_file('../db/aircraft.sql');
221 221
 		$error .= create_db::import_file('../db/spotter_archive.sql');
222 222
 
223 223
 		// Update schema_version to 6
224 224
 		$query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'";
225
-        	try {
226
-            	    $sth = $Connection->db->prepare($query);
227
-		    $sth->execute();
228
-    		} catch(PDOException $e) {
229
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
230
-    		}
225
+			try {
226
+					$sth = $Connection->db->prepare($query);
227
+			$sth->execute();
228
+			} catch(PDOException $e) {
229
+			return "error (update schema_version) : ".$e->getMessage()."\n";
230
+			}
231 231
 		return $error;
232 232
 	}
233 233
 
234 234
 	private static function update_from_6() {
235
-    		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
-    		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
235
+			$Connection = new Connection();
236
+			if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
+				$query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
240 240
 			ALTER TABLE spotter_live ADD INDEX(flightaware_id);
@@ -247,147 +247,147 @@  discard block
 block discarded – undo
247 247
 			ALTER TABLE aircraft ADD INDEX(icao);
248 248
 			ALTER TABLE airport ADD INDEX(icao);
249 249
 			ALTER TABLE translation ADD INDEX(Operator);";
250
-        	    try {
251
-            		$sth = $Connection->db->prepare($query);
250
+				try {
251
+					$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+				} catch(PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255
-    		    }
256
-    		}
257
-    		$error = '';
258
-    		// Update table countries
259
-    		if ($Connection->tableExists('airspace')) {
260
-    		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
255
+				}
256
+			}
257
+			$error = '';
258
+			// Update table countries
259
+			if ($Connection->tableExists('airspace')) {
260
+				$error .= update_db::update_countries();
261
+			if ($error != '') return $error;
262 262
 		}
263 263
 		// Update schema_version to 7
264 264
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
265
-        	try {
266
-            	    $sth = $Connection->db->prepare($query);
267
-		    $sth->execute();
268
-    		} catch(PDOException $e) {
269
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
270
-    		}
265
+			try {
266
+					$sth = $Connection->db->prepare($query);
267
+			$sth->execute();
268
+			} catch(PDOException $e) {
269
+			return "error (update schema_version) : ".$e->getMessage()."\n";
270
+			}
271 271
 		return $error;
272
-    	}
272
+		}
273 273
 
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276
-    		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
276
+			$Connection = new Connection();
277
+			$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279
-        	try {
280
-            	    $sth = $Connection->db->prepare($query);
281
-		    $sth->execute();
282
-    		} catch(PDOException $e) {
283
-		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
-    		}
285
-    		if ($globalDBdriver == 'mysql') {
286
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
-		    try {
288
-            		$sth = $Connection->db->prepare($query);
279
+			try {
280
+					$sth = $Connection->db->prepare($query);
281
+			$sth->execute();
282
+			} catch(PDOException $e) {
283
+			return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
+			}
285
+			if ($globalDBdriver == 'mysql') {
286
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
+			try {
288
+					$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+				} catch(PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292
-    		    }
293
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
294
-    		    if ($row['engine'] == 'ARCHIVE') {
292
+				}
293
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
294
+				if ($row['engine'] == 'ARCHIVE') {
295 295
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
296 296
 				ALTER TABLE copy ENGINE=ARCHIVE;
297 297
 				ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
298 298
 				INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`;
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301
-            	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
-            	    }
304
-                } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
-                }
307
-        	try {
308
-            	    $sth = $Connection->db->prepare($query);
309
-		    $sth->execute();
310
-    		} catch(PDOException $e) {
311
-		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
-    		}
301
+					} else {
302
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
+					}
304
+				} else {
305
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
+				}
307
+			try {
308
+					$sth = $Connection->db->prepare($query);
309
+			$sth->execute();
310
+			} catch(PDOException $e) {
311
+			return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
+			}
313 313
 
314
-    		$error = '';
315
-    		// Update table aircraft
314
+			$error = '';
315
+			// Update table aircraft
316 316
 		$error .= create_db::import_file('../db/source_location.sql');
317 317
 		if ($error != '') return $error;
318 318
 		// Update schema_version to 6
319 319
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320
-        	try {
321
-            	    $sth = $Connection->db->prepare($query);
322
-		    $sth->execute();
323
-    		} catch(PDOException $e) {
324
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
325
-    		}
320
+			try {
321
+					$sth = $Connection->db->prepare($query);
322
+			$sth->execute();
323
+			} catch(PDOException $e) {
324
+			return "error (update schema_version) : ".$e->getMessage()."\n";
325
+			}
326 326
 		return $error;
327 327
 	}
328 328
 
329 329
 	private static function update_from_8() {
330
-    		$Connection = new Connection();
331
-    		$error = '';
332
-    		// Update table aircraft
330
+			$Connection = new Connection();
331
+			$error = '';
332
+			// Update table aircraft
333 333
 		$error .= create_db::import_file('../db/notam.sql');
334 334
 		if ($error != '') return $error;
335 335
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 336
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 337
                         DELETE FROM config WHERE name = 'last_update_notam_db';
338 338
                         INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());";
339
-        	try {
340
-            	    $sth = $Connection->db->prepare($query);
341
-		    $sth->execute();
342
-    		} catch(PDOException $e) {
343
-		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344
-    		}
339
+			try {
340
+					$sth = $Connection->db->prepare($query);
341
+			$sth->execute();
342
+			} catch(PDOException $e) {
343
+			return "error (insert last_update values) : ".$e->getMessage()."\n";
344
+			}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346
-        	try {
347
-            	    $sth = $Connection->db->prepare($query);
348
-		    $sth->execute();
349
-    		} catch(PDOException $e) {
350
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
351
-    		}
346
+			try {
347
+					$sth = $Connection->db->prepare($query);
348
+			$sth->execute();
349
+			} catch(PDOException $e) {
350
+			return "error (update schema_version) : ".$e->getMessage()."\n";
351
+			}
352 352
 		return $error;
353 353
 	}
354 354
 
355 355
 	private static function update_from_9() {
356
-    		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
356
+			$Connection = new Connection();
357
+			$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359
-        	try {
360
-            	    $sth = $Connection->db->prepare($query);
361
-		    $sth->execute();
362
-    		} catch(PDOException $e) {
363
-		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
-    		}
359
+			try {
360
+					$sth = $Connection->db->prepare($query);
361
+			$sth->execute();
362
+			} catch(PDOException $e) {
363
+			return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
+			}
365 365
 		$error = '';
366
-    		// Update table atc
366
+			// Update table atc
367 367
 		$error .= create_db::import_file('../db/atc.sql');
368 368
 		if ($error != '') return $error;
369 369
 		
370 370
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371
-        	try {
372
-            	    $sth = $Connection->db->prepare($query);
373
-		    $sth->execute();
374
-    		} catch(PDOException $e) {
375
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
376
-    		}
371
+			try {
372
+					$sth = $Connection->db->prepare($query);
373
+			$sth->execute();
374
+			} catch(PDOException $e) {
375
+			return "error (update schema_version) : ".$e->getMessage()."\n";
376
+			}
377 377
 		return $error;
378 378
 	}
379 379
 
380 380
 	private static function update_from_10() {
381
-    		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
-        	try {
384
-            	    $sth = $Connection->db->prepare($query);
385
-		    $sth->execute();
386
-    		} catch(PDOException $e) {
387
-		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
-    		}
381
+			$Connection = new Connection();
382
+			$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
+			try {
384
+					$sth = $Connection->db->prepare($query);
385
+			$sth->execute();
386
+			} catch(PDOException $e) {
387
+			return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
+			}
389 389
 		$error = '';
390
-    		// Add tables
390
+			// Add tables
391 391
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392 392
 		if ($error != '') return $error;
393 393
 		$error .= create_db::import_file('../db/metar.sql');
@@ -398,76 +398,76 @@  discard block
 block discarded – undo
398 398
 		if ($error != '') return $error;
399 399
 		
400 400
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401
-        	try {
402
-            	    $sth = $Connection->db->prepare($query);
403
-		    $sth->execute();
404
-    		} catch(PDOException $e) {
405
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
406
-    		}
401
+			try {
402
+					$sth = $Connection->db->prepare($query);
403
+			$sth->execute();
404
+			} catch(PDOException $e) {
405
+			return "error (update schema_version) : ".$e->getMessage()."\n";
406
+			}
407 407
 		return $error;
408 408
 	}
409 409
 
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412
-    		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
-        	try {
415
-            	    $sth = $Connection->db->prepare($query);
416
-		    $sth->execute();
417
-    		} catch(PDOException $e) {
418
-		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
-    		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
-        	try {
422
-            	    $sth = $Connection->db->prepare($query);
423
-		    $sth->execute();
424
-    		} catch(PDOException $e) {
425
-		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
-    		}
427
-    		if ($globalDBdriver == 'mysql') {
428
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
-		    try {
430
-            		$sth = $Connection->db->prepare($query);
412
+			$Connection = new Connection();
413
+			$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
+			try {
415
+					$sth = $Connection->db->prepare($query);
416
+			$sth->execute();
417
+			} catch(PDOException $e) {
418
+			return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
+			}
420
+			$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
+			try {
422
+					$sth = $Connection->db->prepare($query);
423
+			$sth->execute();
424
+			} catch(PDOException $e) {
425
+			return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
+			}
427
+			if ($globalDBdriver == 'mysql') {
428
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
+			try {
430
+					$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+				} catch(PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434
-    		    }
435
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
436
-    		    if ($row['engine'] == 'ARCHIVE') {
434
+				}
435
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
436
+				if ($row['engine'] == 'ARCHIVE') {
437 437
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
438 438
 				ALTER TABLE copy ENGINE=ARCHIVE;
439 439
 				ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE;
440 440
 				INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`;
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443
-            	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
-            	    }
446
-                } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
-                }
449
-        	try {
450
-            	    $sth = $Connection->db->prepare($query);
451
-		    $sth->execute();
452
-    		} catch(PDOException $e) {
453
-		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
-    		}
443
+					} else {
444
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
+					}
446
+				} else {
447
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
+				}
449
+			try {
450
+					$sth = $Connection->db->prepare($query);
451
+			$sth->execute();
452
+			} catch(PDOException $e) {
453
+			return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
+			}
455 455
 
456 456
 		$error = '';
457 457
 		
458 458
 		$query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'";
459
-        	try {
460
-            	    $sth = $Connection->db->prepare($query);
461
-		    $sth->execute();
462
-    		} catch(PDOException $e) {
463
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
464
-    		}
459
+			try {
460
+					$sth = $Connection->db->prepare($query);
461
+			$sth->execute();
462
+			} catch(PDOException $e) {
463
+			return "error (update schema_version) : ".$e->getMessage()."\n";
464
+			}
465 465
 		return $error;
466 466
 	}
467 467
 	private static function update_from_12() {
468
-    		$Connection = new Connection();
468
+			$Connection = new Connection();
469 469
 		$error = '';
470
-    		// Add tables
470
+			// Add tables
471 471
 		$error .= create_db::import_file('../db/stats.sql');
472 472
 		if ($error != '') return $error;
473 473
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
@@ -484,166 +484,166 @@  discard block
 block discarded – undo
484 484
 		if ($error != '') return $error;
485 485
 		
486 486
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487
-        	try {
488
-            	    $sth = $Connection->db->prepare($query);
489
-		    $sth->execute();
490
-    		} catch(PDOException $e) {
491
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
492
-    		}
487
+			try {
488
+					$sth = $Connection->db->prepare($query);
489
+			$sth->execute();
490
+			} catch(PDOException $e) {
491
+			return "error (update schema_version) : ".$e->getMessage()."\n";
492
+			}
493 493
 		return $error;
494 494
 	}
495 495
 
496 496
 	private static function update_from_13() {
497
-    		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
497
+			$Connection = new Connection();
498
+			if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
+				$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+				} catch(PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505
-    			}
505
+				}
506 506
 		}
507
-    		$error = '';
507
+			$error = '';
508 508
 		$query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'";
509
-        	try {
510
-            	    $sth = $Connection->db->prepare($query);
511
-		    $sth->execute();
512
-    		} catch(PDOException $e) {
513
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
514
-    		}
509
+			try {
510
+					$sth = $Connection->db->prepare($query);
511
+			$sth->execute();
512
+			} catch(PDOException $e) {
513
+			return "error (update schema_version) : ".$e->getMessage()."\n";
514
+			}
515 515
 		return $error;
516 516
 	}
517 517
 
518 518
 	private static function update_from_14() {
519
-    		$Connection = new Connection();
519
+			$Connection = new Connection();
520 520
 		$error = '';
521
-    		// Add tables
522
-    		if (!$Connection->tableExists('stats_flight')) {
521
+			// Add tables
522
+			if (!$Connection->tableExists('stats_flight')) {
523 523
 			$error .= create_db::import_file('../db/stats_flight.sql');
524 524
 			if ($error != '') return $error;
525 525
 		}
526 526
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527
-        	try {
528
-            	    $sth = $Connection->db->prepare($query);
529
-		    $sth->execute();
530
-    		} catch(PDOException $e) {
531
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
532
-    		}
527
+			try {
528
+					$sth = $Connection->db->prepare($query);
529
+			$sth->execute();
530
+			} catch(PDOException $e) {
531
+			return "error (update schema_version) : ".$e->getMessage()."\n";
532
+			}
533 533
 		return $error;
534 534
 	}
535 535
 
536 536
 
537 537
 	private static function update_from_15() {
538
-    		$Connection = new Connection();
538
+			$Connection = new Connection();
539 539
 		$error = '';
540
-    		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
-        	try {
543
-            	    $sth = $Connection->db->prepare($query);
544
-		    $sth->execute();
545
-    		} catch(PDOException $e) {
546
-		    return "error (update stats) : ".$e->getMessage()."\n";
547
-    		}
540
+			// Add tables
541
+			$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
+			try {
543
+					$sth = $Connection->db->prepare($query);
544
+			$sth->execute();
545
+			} catch(PDOException $e) {
546
+			return "error (update stats) : ".$e->getMessage()."\n";
547
+			}
548 548
 		if ($error != '') return $error;
549 549
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550
-        	try {
551
-            	    $sth = $Connection->db->prepare($query);
552
-		    $sth->execute();
553
-    		} catch(PDOException $e) {
554
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
555
-    		}
550
+			try {
551
+					$sth = $Connection->db->prepare($query);
552
+			$sth->execute();
553
+			} catch(PDOException $e) {
554
+			return "error (update schema_version) : ".$e->getMessage()."\n";
555
+			}
556 556
 		return $error;
557 557
 	}
558 558
 
559 559
 	private static function update_from_16() {
560
-    		$Connection = new Connection();
560
+			$Connection = new Connection();
561 561
 		$error = '';
562
-    		// Add tables
563
-    		if (!$Connection->tableExists('stats_registration')) {
562
+			// Add tables
563
+			if (!$Connection->tableExists('stats_registration')) {
564 564
 			$error .= create_db::import_file('../db/stats_registration.sql');
565 565
 		}
566
-    		if (!$Connection->tableExists('stats_callsign')) {
566
+			if (!$Connection->tableExists('stats_callsign')) {
567 567
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 568
 		}
569 569
 		if ($error != '') return $error;
570 570
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571
-        	try {
572
-            	    $sth = $Connection->db->prepare($query);
573
-		    $sth->execute();
574
-    		} catch(PDOException $e) {
575
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
576
-    		}
571
+			try {
572
+					$sth = $Connection->db->prepare($query);
573
+			$sth->execute();
574
+			} catch(PDOException $e) {
575
+			return "error (update schema_version) : ".$e->getMessage()."\n";
576
+			}
577 577
 		return $error;
578 578
 	}
579 579
 
580 580
 	private static function update_from_17() {
581
-    		$Connection = new Connection();
581
+			$Connection = new Connection();
582 582
 		$error = '';
583
-    		// Add tables
584
-    		if (!$Connection->tableExists('stats_country')) {
583
+			// Add tables
584
+			if (!$Connection->tableExists('stats_country')) {
585 585
 			$error .= create_db::import_file('../db/stats_country.sql');
586 586
 		}
587 587
 		if ($error != '') return $error;
588 588
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589
-        	try {
590
-            	    $sth = $Connection->db->prepare($query);
591
-		    $sth->execute();
592
-    		} catch(PDOException $e) {
593
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
594
-    		}
589
+			try {
590
+					$sth = $Connection->db->prepare($query);
591
+			$sth->execute();
592
+			} catch(PDOException $e) {
593
+			return "error (update schema_version) : ".$e->getMessage()."\n";
594
+			}
595 595
 		return $error;
596 596
 	}
597 597
 	private static function update_from_18() {
598
-    		$Connection = new Connection();
598
+			$Connection = new Connection();
599 599
 		$error = '';
600
-    		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
-    			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
-    	        	try {
604
-	            	    $sth = $Connection->db->prepare($query);
605
-			    $sth->execute();
606
-    			} catch(PDOException $e) {
607
-			    return "error (update stats) : ".$e->getMessage()."\n";
608
-    			}
609
-    		}
600
+			// Modify stats_airport table
601
+			if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
+				$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
+					try {
604
+						$sth = $Connection->db->prepare($query);
605
+				$sth->execute();
606
+				} catch(PDOException $e) {
607
+				return "error (update stats) : ".$e->getMessage()."\n";
608
+				}
609
+			}
610 610
 		if ($error != '') return $error;
611 611
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612
-        	try {
613
-            	    $sth = $Connection->db->prepare($query);
614
-		    $sth->execute();
615
-    		} catch(PDOException $e) {
616
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
617
-    		}
612
+			try {
613
+					$sth = $Connection->db->prepare($query);
614
+			$sth->execute();
615
+			} catch(PDOException $e) {
616
+			return "error (update schema_version) : ".$e->getMessage()."\n";
617
+			}
618 618
 		return $error;
619 619
 	}
620 620
 
621 621
 	private static function update_from_19() {
622
-    		$Connection = new Connection();
622
+			$Connection = new Connection();
623 623
 		$error = '';
624
-    		// Update airport table
624
+			// Update airport table
625 625
 		$error .= create_db::import_file('../db/airport.sql');
626 626
 		if ($error != '') return 'Import airport.sql : '.$error;
627 627
 		// Remove primary key on Spotter_Archive
628 628
 		$query = "alter table spotter_archive drop spotter_archive_id";
629
-        	try {
630
-            	    $sth = $Connection->db->prepare($query);
631
-		    $sth->execute();
632
-    		} catch(PDOException $e) {
633
-		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
-    		}
629
+			try {
630
+					$sth = $Connection->db->prepare($query);
631
+			$sth->execute();
632
+			} catch(PDOException $e) {
633
+			return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
+			}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636
-        	try {
637
-            	    $sth = $Connection->db->prepare($query);
638
-		    $sth->execute();
639
-    		} catch(PDOException $e) {
640
-		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
-    		}
636
+			try {
637
+					$sth = $Connection->db->prepare($query);
638
+			$sth->execute();
639
+			} catch(PDOException $e) {
640
+			return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
+			}
642 642
 		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
643 643
 			// Add column over_country
644
-    			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
644
+				$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646
-            			$sth = $Connection->db->prepare($query);
646
+						$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648 648
 			} catch(PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 		}
652 652
 		if (!$Connection->checkColumnName('spotter_live','over_country')) {
653 653
 			// Add column over_country
654
-    			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
654
+				$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656
-            			$sth = $Connection->db->prepare($query);
656
+						$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658 658
 			} catch(PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -661,74 +661,74 @@  discard block
 block discarded – undo
661 661
 		}
662 662
 		if (!$Connection->checkColumnName('spotter_output','source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664
-    			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
664
+				$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668 668
 			} catch(PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670
-    			}
671
-    		}
670
+				}
671
+			}
672 672
 		if (!$Connection->checkColumnName('spotter_live','source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674
-    			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
674
+				$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678 678
 			} catch(PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680
-    			}
681
-    		}
680
+				}
681
+			}
682 682
 		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684
-    			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
684
+				$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688 688
 			} catch(PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690
-    			}
691
-    		}
690
+				}
691
+			}
692 692
 		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694
-    			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
694
+				$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698 698
 			} catch(PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700
-    			}
701
-    		}
700
+				}
701
+			}
702 702
 		if ($error != '') return $error;
703 703
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704
-        	try {
705
-            	    $sth = $Connection->db->prepare($query);
706
-		    $sth->execute();
707
-    		} catch(PDOException $e) {
708
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
709
-    		}
704
+			try {
705
+					$sth = $Connection->db->prepare($query);
706
+			$sth->execute();
707
+			} catch(PDOException $e) {
708
+			return "error (update schema_version) : ".$e->getMessage()."\n";
709
+			}
710 710
 		return $error;
711 711
 	}
712 712
 
713 713
 	private static function update_from_20() {
714 714
 		global $globalIVAO, $globalVATSIM, $globalphpVMS;
715
-    		$Connection = new Connection();
715
+			$Connection = new Connection();
716 716
 		$error = '';
717
-    		// Update airline table
718
-    		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
717
+			// Update airline table
718
+			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722 722
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 723
 			// Add column over_country
724
-    			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
-        		try {
724
+				$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
+				try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728 728
 			} catch(PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730
-    			}
731
-    		}
730
+				}
731
+			}
732 732
 		if ($error != '') return $error;
733 733
 		/*
734 734
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 		}
739 739
 		*/
740 740
 		$query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'";
741
-        	try {
742
-            	    $sth = $Connection->db->prepare($query);
743
-		    $sth->execute();
744
-    		} catch(PDOException $e) {
745
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
746
-    		}
741
+			try {
742
+					$sth = $Connection->db->prepare($query);
743
+			$sth->execute();
744
+			} catch(PDOException $e) {
745
+			return "error (update schema_version) : ".$e->getMessage()."\n";
746
+			}
747 747
 		return $error;
748 748
 	}
749 749
 
@@ -762,35 +762,35 @@  discard block
 block discarded – undo
762 762
 			if ($error != '') return $error;
763 763
 		}
764 764
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765
-        	try {
766
-            	    $sth = $Connection->db->prepare($query);
767
-		    $sth->execute();
768
-    		} catch(PDOException $e) {
769
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
770
-    		}
765
+			try {
766
+					$sth = $Connection->db->prepare($query);
767
+			$sth->execute();
768
+			} catch(PDOException $e) {
769
+			return "error (update schema_version) : ".$e->getMessage()."\n";
770
+			}
771 771
 		return $error;
772 772
 	}
773 773
 
774 774
 	private static function update_from_22() {
775 775
 		global $globalDBdriver;
776
-    		$Connection = new Connection();
776
+			$Connection = new Connection();
777 777
 		$error = '';
778 778
 		// Add table stats polar
779
-    		if (!$Connection->tableExists('stats_source')) {
779
+			if (!$Connection->tableExists('stats_source')) {
780 780
 			if ($globalDBdriver == 'mysql') {
781
-    				$error .= create_db::import_file('../db/stats_source.sql');
781
+					$error .= create_db::import_file('../db/stats_source.sql');
782 782
 			} else {
783 783
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 784
 			}
785 785
 			if ($error != '') return $error;
786 786
 		}
787 787
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788
-        	try {
789
-            	    $sth = $Connection->db->prepare($query);
790
-		    $sth->execute();
791
-    		} catch(PDOException $e) {
792
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
793
-    		}
788
+			try {
789
+					$sth = $Connection->db->prepare($query);
790
+			$sth->execute();
791
+			} catch(PDOException $e) {
792
+			return "error (update schema_version) : ".$e->getMessage()."\n";
793
+			}
794 794
 		return $error;
795 795
 	}
796 796
 
@@ -821,14 +821,14 @@  discard block
 block discarded – undo
821 821
 		}
822 822
 		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824
-    			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824
+				$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828 828
 			} catch(PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830
-    			}
831
-    		}
830
+				}
831
+			}
832 832
 		
833 833
 		$query = "UPDATE config SET value = '24' WHERE name = 'schema_version'";
834 834
 		try {
@@ -1112,129 +1112,129 @@  discard block
 block discarded – undo
1112 1112
 
1113 1113
 
1114 1114
 
1115
-    	public static function check_version($update = false) {
1116
-    	    global $globalDBname;
1117
-    	    $version = 0;
1118
-    	    $Connection = new Connection();
1119
-    	    if ($Connection->tableExists('aircraft')) {
1120
-    		if (!$Connection->tableExists('config')) {
1121
-    		    $version = '1';
1122
-    		    if ($update) return self::update_from_1();
1123
-    		    else return $version;
1115
+		public static function check_version($update = false) {
1116
+			global $globalDBname;
1117
+			$version = 0;
1118
+			$Connection = new Connection();
1119
+			if ($Connection->tableExists('aircraft')) {
1120
+			if (!$Connection->tableExists('config')) {
1121
+				$version = '1';
1122
+				if ($update) return self::update_from_1();
1123
+				else return $version;
1124 1124
 		} else {
1125
-    		    $Connection = new Connection();
1126
-		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1127
-		    try {
1128
-            		$sth = $Connection->db->prepare($query);
1129
-		        $sth->execute();
1130
-		    } catch(PDOException $e) {
1125
+				$Connection = new Connection();
1126
+			$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1127
+			try {
1128
+					$sth = $Connection->db->prepare($query);
1129
+				$sth->execute();
1130
+			} catch(PDOException $e) {
1131 1131
 			return "error : ".$e->getMessage()."\n";
1132
-    		    }
1133
-    		    $result = $sth->fetch(PDO::FETCH_ASSOC);
1134
-    		    if ($update) {
1135
-    			if ($result['value'] == '2') {
1136
-    			    $error = self::update_from_2();
1137
-    			    if ($error != '') return $error;
1138
-    			    else return self::check_version(true);
1139
-    			} elseif ($result['value'] == '3') {
1140
-    			    $error = self::update_from_3();
1141
-    			    if ($error != '') return $error;
1142
-    			    else return self::check_version(true);
1143
-    			} elseif ($result['value'] == '4') {
1144
-    			    $error = self::update_from_4();
1145
-    			    if ($error != '') return $error;
1146
-    			    else return self::check_version(true);
1147
-    			} elseif ($result['value'] == '5') {
1148
-    			    $error = self::update_from_5();
1149
-    			    if ($error != '') return $error;
1150
-    			    else return self::check_version(true);
1151
-    			} elseif ($result['value'] == '6') {
1152
-    			    $error = self::update_from_6();
1153
-    			    if ($error != '') return $error;
1154
-    			    else return self::check_version(true);
1155
-    			} elseif ($result['value'] == '7') {
1156
-    			    $error = self::update_from_7();
1157
-    			    if ($error != '') return $error;
1158
-    			    else return self::check_version(true);
1159
-    			} elseif ($result['value'] == '8') {
1160
-    			    $error = self::update_from_8();
1161
-    			    if ($error != '') return $error;
1162
-    			    else return self::check_version(true);
1163
-    			} elseif ($result['value'] == '9') {
1164
-    			    $error = self::update_from_9();
1165
-    			    if ($error != '') return $error;
1166
-    			    else return self::check_version(true);
1167
-    			} elseif ($result['value'] == '10') {
1168
-    			    $error = self::update_from_10();
1169
-    			    if ($error != '') return $error;
1170
-    			    else return self::check_version(true);
1171
-    			} elseif ($result['value'] == '11') {
1172
-    			    $error = self::update_from_11();
1173
-    			    if ($error != '') return $error;
1174
-    			    else return self::check_version(true);
1175
-    			} elseif ($result['value'] == '12') {
1176
-    			    $error = self::update_from_12();
1177
-    			    if ($error != '') return $error;
1178
-    			    else return self::check_version(true);
1179
-    			} elseif ($result['value'] == '13') {
1180
-    			    $error = self::update_from_13();
1181
-    			    if ($error != '') return $error;
1182
-    			    else return self::check_version(true);
1183
-    			} elseif ($result['value'] == '14') {
1184
-    			    $error = self::update_from_14();
1185
-    			    if ($error != '') return $error;
1186
-    			    else return self::check_version(true);
1187
-    			} elseif ($result['value'] == '15') {
1188
-    			    $error = self::update_from_15();
1189
-    			    if ($error != '') return $error;
1190
-    			    else return self::check_version(true);
1191
-    			} elseif ($result['value'] == '16') {
1192
-    			    $error = self::update_from_16();
1193
-    			    if ($error != '') return $error;
1194
-    			    else return self::check_version(true);
1195
-    			} elseif ($result['value'] == '17') {
1196
-    			    $error = self::update_from_17();
1197
-    			    if ($error != '') return $error;
1198
-    			    else return self::check_version(true);
1199
-    			} elseif ($result['value'] == '18') {
1200
-    			    $error = self::update_from_18();
1201
-    			    if ($error != '') return $error;
1202
-    			    else return self::check_version(true);
1203
-    			} elseif ($result['value'] == '19') {
1204
-    			    $error = self::update_from_19();
1205
-    			    if ($error != '') return $error;
1206
-    			    else return self::check_version(true);
1207
-    			} elseif ($result['value'] == '20') {
1208
-    			    $error = self::update_from_20();
1209
-    			    if ($error != '') return $error;
1210
-    			    else return self::check_version(true);
1211
-    			} elseif ($result['value'] == '21') {
1212
-    			    $error = self::update_from_21();
1213
-    			    if ($error != '') return $error;
1214
-    			    else return self::check_version(true);
1215
-    			} elseif ($result['value'] == '22') {
1216
-    			    $error = self::update_from_22();
1217
-    			    if ($error != '') return $error;
1218
-    			    else return self::check_version(true);
1219
-    			} elseif ($result['value'] == '23') {
1220
-    			    $error = self::update_from_23();
1221
-    			    if ($error != '') return $error;
1222
-    			    else return self::check_version(true);
1223
-    			} elseif ($result['value'] == '24') {
1224
-    			    $error = self::update_from_24();
1225
-    			    if ($error != '') return $error;
1226
-    			    else return self::check_version(true);
1227
-    			} elseif ($result['value'] == '25') {
1228
-    			    $error = self::update_from_25();
1229
-    			    if ($error != '') return $error;
1230
-    			    else return self::check_version(true);
1231
-    			} else return '';
1232
-    		    }
1233
-    		    else return $result['value'];
1132
+				}
1133
+				$result = $sth->fetch(PDO::FETCH_ASSOC);
1134
+				if ($update) {
1135
+				if ($result['value'] == '2') {
1136
+					$error = self::update_from_2();
1137
+					if ($error != '') return $error;
1138
+					else return self::check_version(true);
1139
+				} elseif ($result['value'] == '3') {
1140
+					$error = self::update_from_3();
1141
+					if ($error != '') return $error;
1142
+					else return self::check_version(true);
1143
+				} elseif ($result['value'] == '4') {
1144
+					$error = self::update_from_4();
1145
+					if ($error != '') return $error;
1146
+					else return self::check_version(true);
1147
+				} elseif ($result['value'] == '5') {
1148
+					$error = self::update_from_5();
1149
+					if ($error != '') return $error;
1150
+					else return self::check_version(true);
1151
+				} elseif ($result['value'] == '6') {
1152
+					$error = self::update_from_6();
1153
+					if ($error != '') return $error;
1154
+					else return self::check_version(true);
1155
+				} elseif ($result['value'] == '7') {
1156
+					$error = self::update_from_7();
1157
+					if ($error != '') return $error;
1158
+					else return self::check_version(true);
1159
+				} elseif ($result['value'] == '8') {
1160
+					$error = self::update_from_8();
1161
+					if ($error != '') return $error;
1162
+					else return self::check_version(true);
1163
+				} elseif ($result['value'] == '9') {
1164
+					$error = self::update_from_9();
1165
+					if ($error != '') return $error;
1166
+					else return self::check_version(true);
1167
+				} elseif ($result['value'] == '10') {
1168
+					$error = self::update_from_10();
1169
+					if ($error != '') return $error;
1170
+					else return self::check_version(true);
1171
+				} elseif ($result['value'] == '11') {
1172
+					$error = self::update_from_11();
1173
+					if ($error != '') return $error;
1174
+					else return self::check_version(true);
1175
+				} elseif ($result['value'] == '12') {
1176
+					$error = self::update_from_12();
1177
+					if ($error != '') return $error;
1178
+					else return self::check_version(true);
1179
+				} elseif ($result['value'] == '13') {
1180
+					$error = self::update_from_13();
1181
+					if ($error != '') return $error;
1182
+					else return self::check_version(true);
1183
+				} elseif ($result['value'] == '14') {
1184
+					$error = self::update_from_14();
1185
+					if ($error != '') return $error;
1186
+					else return self::check_version(true);
1187
+				} elseif ($result['value'] == '15') {
1188
+					$error = self::update_from_15();
1189
+					if ($error != '') return $error;
1190
+					else return self::check_version(true);
1191
+				} elseif ($result['value'] == '16') {
1192
+					$error = self::update_from_16();
1193
+					if ($error != '') return $error;
1194
+					else return self::check_version(true);
1195
+				} elseif ($result['value'] == '17') {
1196
+					$error = self::update_from_17();
1197
+					if ($error != '') return $error;
1198
+					else return self::check_version(true);
1199
+				} elseif ($result['value'] == '18') {
1200
+					$error = self::update_from_18();
1201
+					if ($error != '') return $error;
1202
+					else return self::check_version(true);
1203
+				} elseif ($result['value'] == '19') {
1204
+					$error = self::update_from_19();
1205
+					if ($error != '') return $error;
1206
+					else return self::check_version(true);
1207
+				} elseif ($result['value'] == '20') {
1208
+					$error = self::update_from_20();
1209
+					if ($error != '') return $error;
1210
+					else return self::check_version(true);
1211
+				} elseif ($result['value'] == '21') {
1212
+					$error = self::update_from_21();
1213
+					if ($error != '') return $error;
1214
+					else return self::check_version(true);
1215
+				} elseif ($result['value'] == '22') {
1216
+					$error = self::update_from_22();
1217
+					if ($error != '') return $error;
1218
+					else return self::check_version(true);
1219
+				} elseif ($result['value'] == '23') {
1220
+					$error = self::update_from_23();
1221
+					if ($error != '') return $error;
1222
+					else return self::check_version(true);
1223
+				} elseif ($result['value'] == '24') {
1224
+					$error = self::update_from_24();
1225
+					if ($error != '') return $error;
1226
+					else return self::check_version(true);
1227
+				} elseif ($result['value'] == '25') {
1228
+					$error = self::update_from_25();
1229
+					if ($error != '') return $error;
1230
+					else return self::check_version(true);
1231
+				} else return '';
1232
+				}
1233
+				else return $result['value'];
1234 1234
 		}
1235 1235
 		
1236
-	    } else return $version;
1237
-    	}
1236
+		} else return $version;
1237
+		}
1238 1238
     	
1239 1239
 }
1240 1240
 //echo update_schema::check_version();
Please login to merge, or discard this patch.
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
             try {
15 15
             	$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+    	    } catch (PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19 19
     	    }
20 20
     	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
21
+    		$Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']);
22 22
     	    }
23 23
 	
24 24
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         	try {
51 51
             	    $sth = $Connection->db->prepare($query);
52 52
 		    $sth->execute();
53
-    		} catch(PDOException $e) {
53
+    		} catch (PDOException $e) {
54 54
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55 55
     		}
56 56
     		// Copy schedules data to routes table
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         	try {
61 61
             	    $sth = $Connection->db->prepare($query);
62 62
 		    $sth->execute();
63
-    		} catch(PDOException $e) {
63
+    		} catch (PDOException $e) {
64 64
 		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65 65
     		}
66 66
     		// Add source column
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     		try {
69 69
             	    $sth = $Connection->db->prepare($query);
70 70
 		    $sth->execute();
71
-    		} catch(PDOException $e) {
71
+    		} catch (PDOException $e) {
72 72
 		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73 73
     		}
74 74
 		// Delete unused column
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     		try {
77 77
             	    $sth = $Connection->db->prepare($query);
78 78
 		    $sth->execute();
79
-    		} catch(PDOException $e) {
79
+    		} catch (PDOException $e) {
80 80
 		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81 81
     		}
82 82
 		// Add ModeS column
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
     		try {
85 85
             	    $sth = $Connection->db->prepare($query);
86 86
 		    $sth->execute();
87
-    		} catch(PDOException $e) {
87
+    		} catch (PDOException $e) {
88 88
 		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89 89
     		}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91 91
     		try {
92 92
             	    $sth = $Connection->db->prepare($query);
93 93
 		    $sth->execute();
94
-    		} catch(PDOException $e) {
94
+    		} catch (PDOException $e) {
95 95
 		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96 96
     		}
97 97
     		// Add auto_increment for aircraft_modes
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     		try {
100 100
             	    $sth = $Connection->db->prepare($query);
101 101
 		    $sth->execute();
102
-    		} catch(PDOException $e) {
102
+    		} catch (PDOException $e) {
103 103
 		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104 104
     		}
105 105
     		$error = '';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         	try {
111 111
             	    $sth = $Connection->db->prepare($query);
112 112
 		    $sth->execute();
113
-    		} catch(PDOException $e) {
113
+    		} catch (PDOException $e) {
114 114
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
115 115
     		}
116 116
 		return $error;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         	try {
124 124
             	    $sth = $Connection->db->prepare($query);
125 125
 		    $sth->execute();
126
-    		} catch(PDOException $e) {
126
+    		} catch (PDOException $e) {
127 127
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128 128
     		}
129 129
     		$error = '';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         	try {
135 135
             	    $sth = $Connection->db->prepare($query);
136 136
 		    $sth->execute();
137
-    		} catch(PDOException $e) {
137
+    		} catch (PDOException $e) {
138 138
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
139 139
     		}
140 140
 		return $error;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         	try {
148 148
             	    $sth = $Connection->db->prepare($query);
149 149
 		    $sth->execute();
150
-    		} catch(PDOException $e) {
150
+    		} catch (PDOException $e) {
151 151
 		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152 152
     		}
153 153
     		// Add image_source_website column to spotter_image
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         	try {
156 156
             	    $sth = $Connection->db->prepare($query);
157 157
 		    $sth->execute();
158
-    		} catch(PDOException $e) {
158
+    		} catch (PDOException $e) {
159 159
 		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160 160
     		}
161 161
     		$error = '';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         	try {
165 165
             	    $sth = $Connection->db->prepare($query);
166 166
 		    $sth->execute();
167
-    		} catch(PDOException $e) {
167
+    		} catch (PDOException $e) {
168 168
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
169 169
     		}
170 170
 		return $error;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         	    try {
183 183
             		$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+    		    } catch (PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187 187
     		    }
188 188
     		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         	try {
197 197
             	    $sth = $Connection->db->prepare($query);
198 198
 		    $sth->execute();
199
-    		} catch(PDOException $e) {
199
+    		} catch (PDOException $e) {
200 200
 		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201 201
     		}
202 202
     		// Add aircraft_shadow column to aircraft
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         	try {
205 205
             	    $sth = $Connection->db->prepare($query);
206 206
 		    $sth->execute();
207
-    		} catch(PDOException $e) {
207
+    		} catch (PDOException $e) {
208 208
 		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209 209
     		}
210 210
     		// Add aircraft_shadow column to spotter_live
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         	try {
213 213
             	    $sth = $Connection->db->prepare($query);
214 214
 		    $sth->execute();
215
-    		} catch(PDOException $e) {
215
+    		} catch (PDOException $e) {
216 216
 		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217 217
     		}
218 218
     		$error = '';
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         	try {
226 226
             	    $sth = $Connection->db->prepare($query);
227 227
 		    $sth->execute();
228
-    		} catch(PDOException $e) {
228
+    		} catch (PDOException $e) {
229 229
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
230 230
     		}
231 231
 		return $error;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 	private static function update_from_6() {
235 235
     		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
236
+    		if (!$Connection->indexExists('spotter_output', 'flightaware_id')) {
237 237
     		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         	    try {
251 251
             		$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+    		    } catch (PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255 255
     		    }
256 256
     		}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         	try {
266 266
             	    $sth = $Connection->db->prepare($query);
267 267
 		    $sth->execute();
268
-    		} catch(PDOException $e) {
268
+    		} catch (PDOException $e) {
269 269
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
270 270
     		}
271 271
 		return $error;
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276 276
     		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
277
+    		$query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279 279
         	try {
280 280
             	    $sth = $Connection->db->prepare($query);
281 281
 		    $sth->execute();
282
-    		} catch(PDOException $e) {
282
+    		} catch (PDOException $e) {
283 283
 		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284 284
     		}
285 285
     		if ($globalDBdriver == 'mysql') {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		    try {
288 288
             		$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+    		    } catch (PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292 292
     		    }
293 293
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301 301
             	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
302
+    			$query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303 303
             	    }
304 304
                 } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
305
+    		    $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306 306
                 }
307 307
         	try {
308 308
             	    $sth = $Connection->db->prepare($query);
309 309
 		    $sth->execute();
310
-    		} catch(PDOException $e) {
310
+    		} catch (PDOException $e) {
311 311
 		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312 312
     		}
313 313
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         	try {
321 321
             	    $sth = $Connection->db->prepare($query);
322 322
 		    $sth->execute();
323
-    		} catch(PDOException $e) {
323
+    		} catch (PDOException $e) {
324 324
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
325 325
     		}
326 326
 		return $error;
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
         	try {
340 340
             	    $sth = $Connection->db->prepare($query);
341 341
 		    $sth->execute();
342
-    		} catch(PDOException $e) {
342
+    		} catch (PDOException $e) {
343 343
 		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344 344
     		}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346 346
         	try {
347 347
             	    $sth = $Connection->db->prepare($query);
348 348
 		    $sth->execute();
349
-    		} catch(PDOException $e) {
349
+    		} catch (PDOException $e) {
350 350
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
351 351
     		}
352 352
 		return $error;
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 
355 355
 	private static function update_from_9() {
356 356
     		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
357
+    		$query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359 359
         	try {
360 360
             	    $sth = $Connection->db->prepare($query);
361 361
 		    $sth->execute();
362
-    		} catch(PDOException $e) {
362
+    		} catch (PDOException $e) {
363 363
 		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364 364
     		}
365 365
 		$error = '';
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         	try {
372 372
             	    $sth = $Connection->db->prepare($query);
373 373
 		    $sth->execute();
374
-    		} catch(PDOException $e) {
374
+    		} catch (PDOException $e) {
375 375
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
376 376
     		}
377 377
 		return $error;
@@ -379,11 +379,11 @@  discard block
 block discarded – undo
379 379
 
380 380
 	private static function update_from_10() {
381 381
     		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
382
+    		$query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383 383
         	try {
384 384
             	    $sth = $Connection->db->prepare($query);
385 385
 		    $sth->execute();
386
-    		} catch(PDOException $e) {
386
+    		} catch (PDOException $e) {
387 387
 		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388 388
     		}
389 389
 		$error = '';
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         	try {
402 402
             	    $sth = $Connection->db->prepare($query);
403 403
 		    $sth->execute();
404
-    		} catch(PDOException $e) {
404
+    		} catch (PDOException $e) {
405 405
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
406 406
     		}
407 407
 		return $error;
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412 412
     		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
413
+    		$query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414 414
         	try {
415 415
             	    $sth = $Connection->db->prepare($query);
416 416
 		    $sth->execute();
417
-    		} catch(PDOException $e) {
417
+    		} catch (PDOException $e) {
418 418
 		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419 419
     		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
420
+    		$query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421 421
         	try {
422 422
             	    $sth = $Connection->db->prepare($query);
423 423
 		    $sth->execute();
424
-    		} catch(PDOException $e) {
424
+    		} catch (PDOException $e) {
425 425
 		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426 426
     		}
427 427
     		if ($globalDBdriver == 'mysql') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		    try {
430 430
             		$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+    		    } catch (PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434 434
     		    }
435 435
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443 443
             	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
444
+    			$query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445 445
             	    }
446 446
                 } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
447
+    		    $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448 448
                 }
449 449
         	try {
450 450
             	    $sth = $Connection->db->prepare($query);
451 451
 		    $sth->execute();
452
-    		} catch(PDOException $e) {
452
+    		} catch (PDOException $e) {
453 453
 		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454 454
     		}
455 455
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         	try {
460 460
             	    $sth = $Connection->db->prepare($query);
461 461
 		    $sth->execute();
462
-    		} catch(PDOException $e) {
462
+    		} catch (PDOException $e) {
463 463
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
464 464
     		}
465 465
 		return $error;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         	try {
488 488
             	    $sth = $Connection->db->prepare($query);
489 489
 		    $sth->execute();
490
-    		} catch(PDOException $e) {
490
+    		} catch (PDOException $e) {
491 491
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
492 492
     		}
493 493
 		return $error;
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 
496 496
 	private static function update_from_13() {
497 497
     		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
498
+    		if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) {
499
+    			$query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+	    		} catch (PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505 505
     			}
506 506
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         	try {
510 510
             	    $sth = $Connection->db->prepare($query);
511 511
 		    $sth->execute();
512
-    		} catch(PDOException $e) {
512
+    		} catch (PDOException $e) {
513 513
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
514 514
     		}
515 515
 		return $error;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         	try {
528 528
             	    $sth = $Connection->db->prepare($query);
529 529
 		    $sth->execute();
530
-    		} catch(PDOException $e) {
530
+    		} catch (PDOException $e) {
531 531
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
532 532
     		}
533 533
 		return $error;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
     		$Connection = new Connection();
539 539
 		$error = '';
540 540
     		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
541
+    		$query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542 542
         	try {
543 543
             	    $sth = $Connection->db->prepare($query);
544 544
 		    $sth->execute();
545
-    		} catch(PDOException $e) {
545
+    		} catch (PDOException $e) {
546 546
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 547
     		}
548 548
 		if ($error != '') return $error;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         	try {
551 551
             	    $sth = $Connection->db->prepare($query);
552 552
 		    $sth->execute();
553
-    		} catch(PDOException $e) {
553
+    		} catch (PDOException $e) {
554 554
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
555 555
     		}
556 556
 		return $error;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
         	try {
572 572
             	    $sth = $Connection->db->prepare($query);
573 573
 		    $sth->execute();
574
-    		} catch(PDOException $e) {
574
+    		} catch (PDOException $e) {
575 575
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
576 576
     		}
577 577
 		return $error;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         	try {
590 590
             	    $sth = $Connection->db->prepare($query);
591 591
 		    $sth->execute();
592
-    		} catch(PDOException $e) {
592
+    		} catch (PDOException $e) {
593 593
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
594 594
     		}
595 595
 		return $error;
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
     		$Connection = new Connection();
599 599
 		$error = '';
600 600
     		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
601
+    		if (!$Connection->checkColumnName('stats_airport', 'airport_name')) {
602 602
     			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603 603
     	        	try {
604 604
 	            	    $sth = $Connection->db->prepare($query);
605 605
 			    $sth->execute();
606
-    			} catch(PDOException $e) {
606
+    			} catch (PDOException $e) {
607 607
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 608
     			}
609 609
     		}
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
         	try {
613 613
             	    $sth = $Connection->db->prepare($query);
614 614
 		    $sth->execute();
615
-    		} catch(PDOException $e) {
615
+    		} catch (PDOException $e) {
616 616
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
617 617
     		}
618 618
 		return $error;
@@ -629,73 +629,73 @@  discard block
 block discarded – undo
629 629
         	try {
630 630
             	    $sth = $Connection->db->prepare($query);
631 631
 		    $sth->execute();
632
-    		} catch(PDOException $e) {
632
+    		} catch (PDOException $e) {
633 633
 		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634 634
     		}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636 636
         	try {
637 637
             	    $sth = $Connection->db->prepare($query);
638 638
 		    $sth->execute();
639
-    		} catch(PDOException $e) {
639
+    		} catch (PDOException $e) {
640 640
 		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641 641
     		}
642
-		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
642
+		if (!$Connection->checkColumnName('spotter_archive', 'over_country')) {
643 643
 			// Add column over_country
644 644
     			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646 646
             			$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648
-			} catch(PDOException $e) {
648
+			} catch (PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
650 650
 			}
651 651
 		}
652
-		if (!$Connection->checkColumnName('spotter_live','over_country')) {
652
+		if (!$Connection->checkColumnName('spotter_live', 'over_country')) {
653 653
 			// Add column over_country
654 654
     			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656 656
             			$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658
-			} catch(PDOException $e) {
658
+			} catch (PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
660 660
 			}
661 661
 		}
662
-		if (!$Connection->checkColumnName('spotter_output','source_name')) {
662
+		if (!$Connection->checkColumnName('spotter_output', 'source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664 664
     			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668
-			} catch(PDOException $e) {
668
+			} catch (PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670 670
     			}
671 671
     		}
672
-		if (!$Connection->checkColumnName('spotter_live','source_name')) {
672
+		if (!$Connection->checkColumnName('spotter_live', 'source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674 674
     			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678
-			} catch(PDOException $e) {
678
+			} catch (PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680 680
     			}
681 681
     		}
682
-		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
682
+		if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684 684
     			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688
-			} catch(PDOException $e) {
688
+			} catch (PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690 690
     			}
691 691
     		}
692
-		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
692
+		if (!$Connection->checkColumnName('spotter_archive', 'source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694 694
     			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698
-			} catch(PDOException $e) {
698
+			} catch (PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 700
     			}
701 701
     		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         	try {
705 705
             	    $sth = $Connection->db->prepare($query);
706 706
 		    $sth->execute();
707
-    		} catch(PDOException $e) {
707
+    		} catch (PDOException $e) {
708 708
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
709 709
     		}
710 710
 		return $error;
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722
-		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
722
+		if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) {
723 723
 			// Add column over_country
724 724
     			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725 725
         		try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728
-			} catch(PDOException $e) {
728
+			} catch (PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 730
     			}
731 731
     		}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
         	try {
742 742
             	    $sth = $Connection->db->prepare($query);
743 743
 		    $sth->execute();
744
-    		} catch(PDOException $e) {
744
+    		} catch (PDOException $e) {
745 745
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
746 746
     		}
747 747
 		return $error;
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 	private static function update_from_21() {
751 751
 		$Connection = new Connection();
752 752
 		$error = '';
753
-		if (!$Connection->checkColumnName('stats_airport','stats_type')) {
753
+		if (!$Connection->checkColumnName('stats_airport', 'stats_type')) {
754 754
 			// Rename type to stats_type
755 755
 			$query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);";
756 756
 			try {
757 757
 				$sth = $Connection->db->prepare($query);
758 758
 				$sth->execute();
759
-			} catch(PDOException $e) {
759
+			} catch (PDOException $e) {
760 760
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 761
 			}
762 762
 			if ($error != '') return $error;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
         	try {
766 766
             	    $sth = $Connection->db->prepare($query);
767 767
 		    $sth->execute();
768
-    		} catch(PDOException $e) {
768
+    		} catch (PDOException $e) {
769 769
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
770 770
     		}
771 771
 		return $error;
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         	try {
789 789
             	    $sth = $Connection->db->prepare($query);
790 790
 		    $sth->execute();
791
-    		} catch(PDOException $e) {
791
+    		} catch (PDOException $e) {
792 792
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
793 793
     		}
794 794
 		return $error;
@@ -815,17 +815,17 @@  discard block
 block discarded – undo
815 815
 			try {
816 816
 				$sth = $Connection->db->prepare($query);
817 817
 				$sth->execute();
818
-			} catch(PDOException $e) {
818
+			} catch (PDOException $e) {
819 819
 				return "error (create index on spotter_archive) : ".$e->getMessage()."\n";
820 820
 			}
821 821
 		}
822
-		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
822
+		if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824 824
     			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828
-			} catch(PDOException $e) {
828
+			} catch (PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830 830
     			}
831 831
     		}
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 		try {
835 835
 			$sth = $Connection->db->prepare($query);
836 836
 			$sth->execute();
837
-		} catch(PDOException $e) {
837
+		} catch (PDOException $e) {
838 838
 			return "error (update schema_version) : ".$e->getMessage()."\n";
839 839
 		}
840 840
 		return $error;
@@ -850,26 +850,26 @@  discard block
 block discarded – undo
850 850
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 851
 		}
852 852
 		if ($error != '') return 'Import airlines.sql : '.$error;
853
-		if (!$Connection->checkColumnName('airlines','forsource')) {
853
+		if (!$Connection->checkColumnName('airlines', 'forsource')) {
854 854
 			// Add forsource to airlines
855 855
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
856 856
 			try {
857 857
 				$sth = $Connection->db->prepare($query);
858 858
 				$sth->execute();
859
-			} catch(PDOException $e) {
859
+			} catch (PDOException $e) {
860 860
 				return "error (add forsource column) : ".$e->getMessage()."\n";
861 861
 			}
862 862
 		} else {
863
-			$errort = $Connection->checkColumnName('airlines','forsource');
863
+			$errort = $Connection->checkColumnName('airlines', 'forsource');
864 864
 			if ($errort !== true && $errort !== false) return 'Error check column airlines : '.$errort;
865 865
 		}
866
-		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) {
866
+		if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) {
867 867
 			// Add forsource to airlines
868 868
 			$query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
869 869
 			try {
870 870
 				$sth = $Connection->db->prepare($query);
871 871
 				$sth->execute();
872
-			} catch(PDOException $e) {
872
+			} catch (PDOException $e) {
873 873
 				return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n";
874 874
 			}
875 875
 			// Add unique key
@@ -881,17 +881,17 @@  discard block
 block discarded – undo
881 881
 			try {
882 882
 				$sth = $Connection->db->prepare($query);
883 883
 				$sth->execute();
884
-			} catch(PDOException $e) {
884
+			} catch (PDOException $e) {
885 885
 				return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n";
886 886
 			}
887 887
 		}
888
-		if (!$Connection->checkColumnName('stats_airport','stats_airline')) {
888
+		if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) {
889 889
 			// Add forsource to airlines
890 890
 			$query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
891 891
 			try {
892 892
 				$sth = $Connection->db->prepare($query);
893 893
 				$sth->execute();
894
-			} catch(PDOException $e) {
894
+			} catch (PDOException $e) {
895 895
 				return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n";
896 896
 			}
897 897
 			// Add unique key
@@ -903,20 +903,20 @@  discard block
 block discarded – undo
903 903
 			try {
904 904
 				$sth = $Connection->db->prepare($query);
905 905
 				$sth->execute();
906
-			} catch(PDOException $e) {
906
+			} catch (PDOException $e) {
907 907
 				return "error (add unique key in stats_airport) : ".$e->getMessage()."\n";
908 908
 			}
909 909
 		} else {
910
-			$errort = $Connection->checkColumnName('stats_airport','stats_airline');
910
+			$errort = $Connection->checkColumnName('stats_airport', 'stats_airline');
911 911
 			if ($errort !== true && $errort !== false) return 'Error check column stats_airport : '.$errort;
912 912
 		}
913
-		if (!$Connection->checkColumnName('stats_country','stats_airline')) {
913
+		if (!$Connection->checkColumnName('stats_country', 'stats_airline')) {
914 914
 			// Add forsource to airlines
915 915
 			$query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
916 916
 			try {
917 917
 				$sth = $Connection->db->prepare($query);
918 918
 				$sth->execute();
919
-			} catch(PDOException $e) {
919
+			} catch (PDOException $e) {
920 920
 				return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n";
921 921
 			}
922 922
 			// Add unique key
@@ -928,36 +928,36 @@  discard block
 block discarded – undo
928 928
 			try {
929 929
 				$sth = $Connection->db->prepare($query);
930 930
 				$sth->execute();
931
-			} catch(PDOException $e) {
931
+			} catch (PDOException $e) {
932 932
 				return "error (add unique key in stats_airline) : ".$e->getMessage()."\n";
933 933
 			}
934 934
 		}
935
-		if (!$Connection->checkColumnName('stats_flight','stats_airline')) {
935
+		if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) {
936 936
 			// Add forsource to airlines
937 937
 			$query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
938 938
 			try {
939 939
 				$sth = $Connection->db->prepare($query);
940 940
 				$sth->execute();
941
-			} catch(PDOException $e) {
941
+			} catch (PDOException $e) {
942 942
 				return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n";
943 943
 			}
944 944
 		}
945
-		if (!$Connection->checkColumnName('stats','stats_airline')) {
945
+		if (!$Connection->checkColumnName('stats', 'stats_airline')) {
946 946
 			// Add forsource to airlines
947 947
 			$query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
948 948
 			try {
949 949
 				$sth = $Connection->db->prepare($query);
950 950
 				$sth->execute();
951
-			} catch(PDOException $e) {
951
+			} catch (PDOException $e) {
952 952
 				return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n";
953 953
 			}
954
-			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) {
954
+			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) {
955 955
 				// Add unique key
956 956
 				$query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);";
957 957
 				try {
958 958
 					$sth = $Connection->db->prepare($query);
959 959
 					$sth->execute();
960
-				} catch(PDOException $e) {
960
+				} catch (PDOException $e) {
961 961
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
962 962
 				}
963 963
 			} else {
@@ -970,18 +970,18 @@  discard block
 block discarded – undo
970 970
 				try {
971 971
 					$sth = $Connection->db->prepare($query);
972 972
 					$sth->execute();
973
-				} catch(PDOException $e) {
973
+				} catch (PDOException $e) {
974 974
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
975 975
 				}
976 976
 			}
977 977
 		}
978
-		if (!$Connection->checkColumnName('stats_registration','stats_airline')) {
978
+		if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) {
979 979
 			// Add forsource to airlines
980 980
 			$query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
981 981
 			try {
982 982
 				$sth = $Connection->db->prepare($query);
983 983
 				$sth->execute();
984
-			} catch(PDOException $e) {
984
+			} catch (PDOException $e) {
985 985
 				return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n";
986 986
 			}
987 987
 			// Add unique key
@@ -993,17 +993,17 @@  discard block
 block discarded – undo
993 993
 			try {
994 994
 				$sth = $Connection->db->prepare($query);
995 995
 				$sth->execute();
996
-			} catch(PDOException $e) {
996
+			} catch (PDOException $e) {
997 997
 				return "error (add unique key in stats_registration) : ".$e->getMessage()."\n";
998 998
 			}
999 999
 		}
1000
-		if (!$Connection->checkColumnName('stats_callsign','filter_name')) {
1000
+		if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) {
1001 1001
 			// Add forsource to airlines
1002 1002
 			$query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1003 1003
 			try {
1004 1004
 				$sth = $Connection->db->prepare($query);
1005 1005
 				$sth->execute();
1006
-			} catch(PDOException $e) {
1006
+			} catch (PDOException $e) {
1007 1007
 				return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n";
1008 1008
 			}
1009 1009
 			// Add unique key
@@ -1015,17 +1015,17 @@  discard block
 block discarded – undo
1015 1015
 			try {
1016 1016
 				$sth = $Connection->db->prepare($query);
1017 1017
 				$sth->execute();
1018
-			} catch(PDOException $e) {
1018
+			} catch (PDOException $e) {
1019 1019
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1020 1020
 			}
1021 1021
 		}
1022
-		if (!$Connection->checkColumnName('stats_airline','filter_name')) {
1022
+		if (!$Connection->checkColumnName('stats_airline', 'filter_name')) {
1023 1023
 			// Add forsource to airlines
1024 1024
 			$query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1025 1025
 			try {
1026 1026
 				$sth = $Connection->db->prepare($query);
1027 1027
 				$sth->execute();
1028
-			} catch(PDOException $e) {
1028
+			} catch (PDOException $e) {
1029 1029
 				return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n";
1030 1030
 			}
1031 1031
 			// Add unique key
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 			try {
1038 1038
 				$sth = $Connection->db->prepare($query);
1039 1039
 				$sth->execute();
1040
-			} catch(PDOException $e) {
1040
+			} catch (PDOException $e) {
1041 1041
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1042 1042
 			}
1043 1043
 		}
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 		try {
1047 1047
 			$sth = $Connection->db->prepare($query);
1048 1048
 			$sth->execute();
1049
-		} catch(PDOException $e) {
1049
+		} catch (PDOException $e) {
1050 1050
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1051 1051
 		}
1052 1052
 		return $error;
@@ -1056,13 +1056,13 @@  discard block
 block discarded – undo
1056 1056
 		global $globalDBdriver;
1057 1057
 		$Connection = new Connection();
1058 1058
 		$error = '';
1059
-		if (!$Connection->checkColumnName('stats_owner','stats_airline')) {
1059
+		if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) {
1060 1060
 			// Add forsource to airlines
1061 1061
 			$query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1062 1062
 			try {
1063 1063
 				$sth = $Connection->db->prepare($query);
1064 1064
 				$sth->execute();
1065
-			} catch(PDOException $e) {
1065
+			} catch (PDOException $e) {
1066 1066
 				return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n";
1067 1067
 			}
1068 1068
 			// Add unique key
@@ -1074,17 +1074,17 @@  discard block
 block discarded – undo
1074 1074
 			try {
1075 1075
 				$sth = $Connection->db->prepare($query);
1076 1076
 				$sth->execute();
1077
-			} catch(PDOException $e) {
1077
+			} catch (PDOException $e) {
1078 1078
 				return "error (add unique key in stats_owner) : ".$e->getMessage()."\n";
1079 1079
 			}
1080 1080
 		}
1081
-		if (!$Connection->checkColumnName('stats_pilot','stats_airline')) {
1081
+		if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) {
1082 1082
 			// Add forsource to airlines
1083 1083
 			$query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1084 1084
 			try {
1085 1085
 				$sth = $Connection->db->prepare($query);
1086 1086
 				$sth->execute();
1087
-			} catch(PDOException $e) {
1087
+			} catch (PDOException $e) {
1088 1088
 				return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n";
1089 1089
 			}
1090 1090
 			// Add unique key
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
 			try {
1097 1097
 				$sth = $Connection->db->prepare($query);
1098 1098
 				$sth->execute();
1099
-			} catch(PDOException $e) {
1099
+			} catch (PDOException $e) {
1100 1100
 				return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n";
1101 1101
 			}
1102 1102
 		}
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 		try {
1105 1105
 			$sth = $Connection->db->prepare($query);
1106 1106
 			$sth->execute();
1107
-		} catch(PDOException $e) {
1107
+		} catch (PDOException $e) {
1108 1108
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1109 1109
 		}
1110 1110
 		return $error;
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 		    try {
1128 1128
             		$sth = $Connection->db->prepare($query);
1129 1129
 		        $sth->execute();
1130
-		    } catch(PDOException $e) {
1130
+		    } catch (PDOException $e) {
1131 1131
 			return "error : ".$e->getMessage()."\n";
1132 1132
     		    }
1133 1133
     		    $result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Braces   +226 added lines, -84 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -861,7 +919,9 @@  discard block
 block discarded – undo
861 919
 			}
862 920
 		} else {
863 921
 			$errort = $Connection->checkColumnName('airlines','forsource');
864
-			if ($errort !== true && $errort !== false) return 'Error check column airlines : '.$errort;
922
+			if ($errort !== true && $errort !== false) {
923
+				return 'Error check column airlines : '.$errort;
924
+			}
865 925
 		}
866 926
 		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) {
867 927
 			// Add forsource to airlines
@@ -908,7 +968,9 @@  discard block
 block discarded – undo
908 968
 			}
909 969
 		} else {
910 970
 			$errort = $Connection->checkColumnName('stats_airport','stats_airline');
911
-			if ($errort !== true && $errort !== false) return 'Error check column stats_airport : '.$errort;
971
+			if ($errort !== true && $errort !== false) {
972
+				return 'Error check column stats_airport : '.$errort;
973
+			}
912 974
 		}
913 975
 		if (!$Connection->checkColumnName('stats_country','stats_airline')) {
914 976
 			// Add forsource to airlines
@@ -1119,8 +1181,11 @@  discard block
 block discarded – undo
1119 1181
     	    if ($Connection->tableExists('aircraft')) {
1120 1182
     		if (!$Connection->tableExists('config')) {
1121 1183
     		    $version = '1';
1122
-    		    if ($update) return self::update_from_1();
1123
-    		    else return $version;
1184
+    		    if ($update) {
1185
+    		    	return self::update_from_1();
1186
+    		    } else {
1187
+    		    	return $version;
1188
+    		    }
1124 1189
 		} else {
1125 1190
     		    $Connection = new Connection();
1126 1191
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1134,106 +1199,183 @@  discard block
 block discarded – undo
1134 1199
     		    if ($update) {
1135 1200
     			if ($result['value'] == '2') {
1136 1201
     			    $error = self::update_from_2();
1137
-    			    if ($error != '') return $error;
1138
-    			    else return self::check_version(true);
1202
+    			    if ($error != '') {
1203
+    			    	return $error;
1204
+    			    } else {
1205
+    			    	return self::check_version(true);
1206
+    			    }
1139 1207
     			} elseif ($result['value'] == '3') {
1140 1208
     			    $error = self::update_from_3();
1141
-    			    if ($error != '') return $error;
1142
-    			    else return self::check_version(true);
1209
+    			    if ($error != '') {
1210
+    			    	return $error;
1211
+    			    } else {
1212
+    			    	return self::check_version(true);
1213
+    			    }
1143 1214
     			} elseif ($result['value'] == '4') {
1144 1215
     			    $error = self::update_from_4();
1145
-    			    if ($error != '') return $error;
1146
-    			    else return self::check_version(true);
1216
+    			    if ($error != '') {
1217
+    			    	return $error;
1218
+    			    } else {
1219
+    			    	return self::check_version(true);
1220
+    			    }
1147 1221
     			} elseif ($result['value'] == '5') {
1148 1222
     			    $error = self::update_from_5();
1149
-    			    if ($error != '') return $error;
1150
-    			    else return self::check_version(true);
1223
+    			    if ($error != '') {
1224
+    			    	return $error;
1225
+    			    } else {
1226
+    			    	return self::check_version(true);
1227
+    			    }
1151 1228
     			} elseif ($result['value'] == '6') {
1152 1229
     			    $error = self::update_from_6();
1153
-    			    if ($error != '') return $error;
1154
-    			    else return self::check_version(true);
1230
+    			    if ($error != '') {
1231
+    			    	return $error;
1232
+    			    } else {
1233
+    			    	return self::check_version(true);
1234
+    			    }
1155 1235
     			} elseif ($result['value'] == '7') {
1156 1236
     			    $error = self::update_from_7();
1157
-    			    if ($error != '') return $error;
1158
-    			    else return self::check_version(true);
1237
+    			    if ($error != '') {
1238
+    			    	return $error;
1239
+    			    } else {
1240
+    			    	return self::check_version(true);
1241
+    			    }
1159 1242
     			} elseif ($result['value'] == '8') {
1160 1243
     			    $error = self::update_from_8();
1161
-    			    if ($error != '') return $error;
1162
-    			    else return self::check_version(true);
1244
+    			    if ($error != '') {
1245
+    			    	return $error;
1246
+    			    } else {
1247
+    			    	return self::check_version(true);
1248
+    			    }
1163 1249
     			} elseif ($result['value'] == '9') {
1164 1250
     			    $error = self::update_from_9();
1165
-    			    if ($error != '') return $error;
1166
-    			    else return self::check_version(true);
1251
+    			    if ($error != '') {
1252
+    			    	return $error;
1253
+    			    } else {
1254
+    			    	return self::check_version(true);
1255
+    			    }
1167 1256
     			} elseif ($result['value'] == '10') {
1168 1257
     			    $error = self::update_from_10();
1169
-    			    if ($error != '') return $error;
1170
-    			    else return self::check_version(true);
1258
+    			    if ($error != '') {
1259
+    			    	return $error;
1260
+    			    } else {
1261
+    			    	return self::check_version(true);
1262
+    			    }
1171 1263
     			} elseif ($result['value'] == '11') {
1172 1264
     			    $error = self::update_from_11();
1173
-    			    if ($error != '') return $error;
1174
-    			    else return self::check_version(true);
1265
+    			    if ($error != '') {
1266
+    			    	return $error;
1267
+    			    } else {
1268
+    			    	return self::check_version(true);
1269
+    			    }
1175 1270
     			} elseif ($result['value'] == '12') {
1176 1271
     			    $error = self::update_from_12();
1177
-    			    if ($error != '') return $error;
1178
-    			    else return self::check_version(true);
1272
+    			    if ($error != '') {
1273
+    			    	return $error;
1274
+    			    } else {
1275
+    			    	return self::check_version(true);
1276
+    			    }
1179 1277
     			} elseif ($result['value'] == '13') {
1180 1278
     			    $error = self::update_from_13();
1181
-    			    if ($error != '') return $error;
1182
-    			    else return self::check_version(true);
1279
+    			    if ($error != '') {
1280
+    			    	return $error;
1281
+    			    } else {
1282
+    			    	return self::check_version(true);
1283
+    			    }
1183 1284
     			} elseif ($result['value'] == '14') {
1184 1285
     			    $error = self::update_from_14();
1185
-    			    if ($error != '') return $error;
1186
-    			    else return self::check_version(true);
1286
+    			    if ($error != '') {
1287
+    			    	return $error;
1288
+    			    } else {
1289
+    			    	return self::check_version(true);
1290
+    			    }
1187 1291
     			} elseif ($result['value'] == '15') {
1188 1292
     			    $error = self::update_from_15();
1189
-    			    if ($error != '') return $error;
1190
-    			    else return self::check_version(true);
1293
+    			    if ($error != '') {
1294
+    			    	return $error;
1295
+    			    } else {
1296
+    			    	return self::check_version(true);
1297
+    			    }
1191 1298
     			} elseif ($result['value'] == '16') {
1192 1299
     			    $error = self::update_from_16();
1193
-    			    if ($error != '') return $error;
1194
-    			    else return self::check_version(true);
1300
+    			    if ($error != '') {
1301
+    			    	return $error;
1302
+    			    } else {
1303
+    			    	return self::check_version(true);
1304
+    			    }
1195 1305
     			} elseif ($result['value'] == '17') {
1196 1306
     			    $error = self::update_from_17();
1197
-    			    if ($error != '') return $error;
1198
-    			    else return self::check_version(true);
1307
+    			    if ($error != '') {
1308
+    			    	return $error;
1309
+    			    } else {
1310
+    			    	return self::check_version(true);
1311
+    			    }
1199 1312
     			} elseif ($result['value'] == '18') {
1200 1313
     			    $error = self::update_from_18();
1201
-    			    if ($error != '') return $error;
1202
-    			    else return self::check_version(true);
1314
+    			    if ($error != '') {
1315
+    			    	return $error;
1316
+    			    } else {
1317
+    			    	return self::check_version(true);
1318
+    			    }
1203 1319
     			} elseif ($result['value'] == '19') {
1204 1320
     			    $error = self::update_from_19();
1205
-    			    if ($error != '') return $error;
1206
-    			    else return self::check_version(true);
1321
+    			    if ($error != '') {
1322
+    			    	return $error;
1323
+    			    } else {
1324
+    			    	return self::check_version(true);
1325
+    			    }
1207 1326
     			} elseif ($result['value'] == '20') {
1208 1327
     			    $error = self::update_from_20();
1209
-    			    if ($error != '') return $error;
1210
-    			    else return self::check_version(true);
1328
+    			    if ($error != '') {
1329
+    			    	return $error;
1330
+    			    } else {
1331
+    			    	return self::check_version(true);
1332
+    			    }
1211 1333
     			} elseif ($result['value'] == '21') {
1212 1334
     			    $error = self::update_from_21();
1213
-    			    if ($error != '') return $error;
1214
-    			    else return self::check_version(true);
1335
+    			    if ($error != '') {
1336
+    			    	return $error;
1337
+    			    } else {
1338
+    			    	return self::check_version(true);
1339
+    			    }
1215 1340
     			} elseif ($result['value'] == '22') {
1216 1341
     			    $error = self::update_from_22();
1217
-    			    if ($error != '') return $error;
1218
-    			    else return self::check_version(true);
1342
+    			    if ($error != '') {
1343
+    			    	return $error;
1344
+    			    } else {
1345
+    			    	return self::check_version(true);
1346
+    			    }
1219 1347
     			} elseif ($result['value'] == '23') {
1220 1348
     			    $error = self::update_from_23();
1221
-    			    if ($error != '') return $error;
1222
-    			    else return self::check_version(true);
1349
+    			    if ($error != '') {
1350
+    			    	return $error;
1351
+    			    } else {
1352
+    			    	return self::check_version(true);
1353
+    			    }
1223 1354
     			} elseif ($result['value'] == '24') {
1224 1355
     			    $error = self::update_from_24();
1225
-    			    if ($error != '') return $error;
1226
-    			    else return self::check_version(true);
1356
+    			    if ($error != '') {
1357
+    			    	return $error;
1358
+    			    } else {
1359
+    			    	return self::check_version(true);
1360
+    			    }
1227 1361
     			} elseif ($result['value'] == '25') {
1228 1362
     			    $error = self::update_from_25();
1229
-    			    if ($error != '') return $error;
1230
-    			    else return self::check_version(true);
1231
-    			} else return '';
1363
+    			    if ($error != '') {
1364
+    			    	return $error;
1365
+    			    } else {
1366
+    			    	return self::check_version(true);
1367
+    			    }
1368
+    			} else {
1369
+    				return '';
1370
+    			}
1371
+    		    } else {
1372
+    		    	return $result['value'];
1232 1373
     		    }
1233
-    		    else return $result['value'];
1234 1374
 		}
1235 1375
 		
1236
-	    } else return $version;
1376
+	    } else {
1377
+	    	return $version;
1378
+	    }
1237 1379
     	}
1238 1380
     	
1239 1381
 }
Please login to merge, or discard this patch.