Completed
Push — master ( 898c2a...3b5bd1 )
by Yannick
06:38
created
airport-statistics-registration.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 require_once('require/class.Stats.php');
5 5
 require_once('require/class.Language.php');
6 6
 if (!isset($_GET['airport'])) {
7
-        header('Location: '.$globalURL.'/airport');
8
-        die();
7
+		header('Location: '.$globalURL.'/airport');
8
+		die();
9 9
 }
10 10
 $airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
11 11
 $Spotter = new Spotter();
Please login to merge, or discard this patch.
airline-statistics-route.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 require_once('require/class.Stats.php');
5 5
 require_once('require/class.Language.php');
6 6
 if (!isset($_GET['airline'])) {
7
-        header('Location: '.$globalURL.'/airline');
8
-        die();
7
+		header('Location: '.$globalURL.'/airline');
8
+		die();
9 9
 }
10 10
 $airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
11 11
 $Spotter = new Spotter();
Please login to merge, or discard this patch.
manufacturer-statistics-departure-airport.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 require_once('require/class.Stats.php');
5 5
 require_once('require/class.Language.php');
6 6
 if (!isset($_GET['aircraft_manufacturer'])) {
7
-        header('Location: '.$globalURL.'/manufacturer');
8
-        die();
7
+		header('Location: '.$globalURL.'/manufacturer');
8
+		die();
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING)));
Please login to merge, or discard this patch.
manufacturer-statistics-airline-country.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 require_once('require/class.Stats.php');
5 5
 require_once('require/class.Language.php');
6 6
 if (!isset($_GET['aircraft_manufacturer'])) {
7
-        header('Location: '.$globalURL.'/manufacturer');
8
-        die();
7
+		header('Location: '.$globalURL.'/manufacturer');
8
+		die();
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING)));
Please login to merge, or discard this patch.
require/class.Accident.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@
 block discarded – undo
23 23
 	}
24 24
 	
25 25
 	/**
26
-	* Get Accidents data from DB
27
-	* @param String $limit Limit
28
-	* @param String $type Set type accident or incident
29
-	* @param String $date get data for a date
30
-	* @return Array Return Accidents data in array
31
-	*/
26
+	 * Get Accidents data from DB
27
+	 * @param String $limit Limit
28
+	 * @param String $type Set type accident or incident
29
+	 * @param String $date get data for a date
30
+	 * @return Array Return Accidents data in array
31
+	 */
32 32
 	public function getAccidentData($limit = '',$type = '',$date = '') {
33 33
 		global $globalURL, $globalDBdriver;
34 34
 		$Image = new Image($this->db);
Please login to merge, or discard this patch.
table-output.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -390,17 +390,17 @@  discard block
 block discarded – undo
390 390
 				else {
391 391
 					$planespotter_url_array = explode("_", $spotter_item['image']);
392 392
 					$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
393
-                                        $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
393
+										$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
394 394
 				}
395 395
 				if (isset($spotter_item['airline_name'])) {
396 396
 					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
397 397
 				} else {
398 398
 					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
399 399
 				}
400
-                        } else {
401
-                    		if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
402
-                    		$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
403
-                    		} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
400
+						} else {
401
+							if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
402
+							$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
403
+							} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
404 404
 				if (isset($spotter_item['airline_name'])) {
405 405
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
406 406
 				} else {
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 		}
416 416
 	} elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){
417 417
 		if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) {
418
-		    $spotter_item['squawk'] = '-';
418
+			$spotter_item['squawk'] = '-';
419 419
 		}
420 420
 		if ($spotter_item['image_thumbnail'] != "")
421 421
 		{
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 				else {
427 427
 					$planespotter_url_array = explode("_", $spotter_array[0]['image']);
428 428
 					$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
429
-                                        $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
429
+										$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
430 430
 				}
431 431
 				if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
432 432
 					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
 					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
439 439
 				}
440 440
 			} else {
441
-                    		if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
442
-                    		$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
443
-                    		} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
441
+							if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
442
+							$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
443
+							} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
444 444
 				if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
445 445
 					print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
446 446
 				} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 			print '</td>'."\n";
455 455
 		} else {
456 456
 			print '<td class="aircraft_thumbnail">'."\n";
457
-       //   	 	print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
457
+	   //   	 	print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
458 458
 	//}
459 459
 			if (!isset($spotter_item['airline_name']) && !isset($spotter_item['aircraft_name'])) {
460 460
 				print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '._("Not available").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n";
@@ -559,13 +559,13 @@  discard block
 block discarded – undo
559 559
 				$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
560 560
 			} else $distance = '';
561 561
 			if ($distance != '') {
562
-			    if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
563
-				    echo '<br/><i>'.round($distance*0.539957).' nm</i>';
564
-			    } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
565
-				    echo '<br/><i>'.round($distance*0.621371).' mi</i>';
566
-			    } elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
567
-				    echo '<br/><i>'.$distance.' km</i>';
568
-			    }
562
+				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
563
+					echo '<br/><i>'.round($distance*0.539957).' nm</i>';
564
+				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
565
+					echo '<br/><i>'.round($distance*0.621371).' mi</i>';
566
+				} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
567
+					echo '<br/><i>'.$distance.' km</i>';
568
+				}
569 569
 			}
570 570
 		}
571 571
 		print '</td>'."\n";
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Indentation   +432 added lines, -432 removed lines patch added patch discarded remove patch
@@ -75,38 +75,38 @@  discard block
 block discarded – undo
75 75
 		try {
76 76
 			//$Connection = new Connection();
77 77
 			$sth = $Connection->db->prepare($query);
78
-                        $sth->execute(array(':source' => $database_file));
79
-                } catch(PDOException $e) {
80
-                        return "error : ".$e->getMessage();
81
-                }
78
+						$sth->execute(array(':source' => $database_file));
79
+				} catch(PDOException $e) {
80
+						return "error : ".$e->getMessage();
81
+				}
82 82
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
84
-    		update_db::connect_sqlite($database_file);
83
+			if ($globalDebug) echo " - Add routes to DB -";
84
+			update_db::connect_sqlite($database_file);
85 85
 		//$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID';
86 86
 		$query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID";
87 87
 		try {
88
-                        $sth = update_db::$db_sqlite->prepare($query);
89
-                        $sth->execute();
90
-                } catch(PDOException $e) {
91
-                        return "error : ".$e->getMessage();
92
-                }
88
+						$sth = update_db::$db_sqlite->prepare($query);
89
+						$sth->execute();
90
+				} catch(PDOException $e) {
91
+						return "error : ".$e->getMessage();
92
+				}
93 93
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
94 94
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
95 95
 		$Connection = new Connection();
96 96
 		$sth_dest = $Connection->db->prepare($query_dest);
97 97
 		try {
98 98
 			if ($globalTransaction) $Connection->db->beginTransaction();
99
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
99
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 100
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
101 101
 				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102 102
 				$sth_dest->execute($query_dest_values);
103
-            		}
103
+					}
104 104
 			if ($globalTransaction) $Connection->db->commit();
105 105
 		} catch(PDOException $e) {
106 106
 			if ($globalTransaction) $Connection->db->rollBack(); 
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
109
-                return '';
109
+				return '';
110 110
 	}
111 111
 	public static function retrieve_route_oneworld($database_file) {
112 112
 		global $globalDebug, $globalTransaction;
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 		try {
118 118
 			//$Connection = new Connection();
119 119
 			$sth = $Connection->db->prepare($query);
120
-                        $sth->execute(array(':source' => 'oneworld'));
121
-                } catch(PDOException $e) {
122
-                        return "error : ".$e->getMessage();
123
-                }
120
+						$sth->execute(array(':source' => 'oneworld'));
121
+				} catch(PDOException $e) {
122
+						return "error : ".$e->getMessage();
123
+				}
124 124
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
125
+			if ($globalDebug) echo " - Add routes to DB -";
126 126
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 127
 		$Spotter = new Spotter();
128 128
 		if ($fh = fopen($database_file,"r")) {
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			}
147 147
 			if ($globalTransaction) $Connection->db->commit();
148 148
 		}
149
-                return '';
149
+				return '';
150 150
 	}
151 151
 	
152 152
 	public static function retrieve_route_skyteam($database_file) {
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
 		try {
159 159
 			//$Connection = new Connection();
160 160
 			$sth = $Connection->db->prepare($query);
161
-                        $sth->execute(array(':source' => 'skyteam'));
162
-                } catch(PDOException $e) {
163
-                        return "error : ".$e->getMessage();
164
-                }
161
+						$sth->execute(array(':source' => 'skyteam'));
162
+				} catch(PDOException $e) {
163
+						return "error : ".$e->getMessage();
164
+				}
165 165
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
166
+			if ($globalDebug) echo " - Add routes to DB -";
167 167
 
168 168
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 169
 		$Spotter = new Spotter();
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 				return "error : ".$e->getMessage();
190 190
 			}
191 191
 		}
192
-                return '';
192
+				return '';
193 193
 	}
194 194
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
195 195
 		global $globalTransaction;
@@ -198,27 +198,27 @@  discard block
 block discarded – undo
198 198
 		try {
199 199
 			$Connection = new Connection();
200 200
 			$sth = $Connection->db->prepare($query);
201
-                        $sth->execute(array(':source' => $database_file));
202
-                } catch(PDOException $e) {
203
-                        return "error : ".$e->getMessage();
204
-                }
201
+						$sth->execute(array(':source' => $database_file));
202
+				} catch(PDOException $e) {
203
+						return "error : ".$e->getMessage();
204
+				}
205 205
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
206 206
 		try {
207 207
 			$Connection = new Connection();
208 208
 			$sth = $Connection->db->prepare($query);
209
-                        $sth->execute(array(':source' => $database_file));
210
-                } catch(PDOException $e) {
211
-                        return "error : ".$e->getMessage();
212
-                }
209
+						$sth->execute(array(':source' => $database_file));
210
+				} catch(PDOException $e) {
211
+						return "error : ".$e->getMessage();
212
+				}
213 213
 
214
-    		update_db::connect_sqlite($database_file);
214
+			update_db::connect_sqlite($database_file);
215 215
 		$query = 'select * from Aircraft';
216 216
 		try {
217
-                        $sth = update_db::$db_sqlite->prepare($query);
218
-                        $sth->execute();
219
-                } catch(PDOException $e) {
220
-                        return "error : ".$e->getMessage();
221
-                }
217
+						$sth = update_db::$db_sqlite->prepare($query);
218
+						$sth->execute();
219
+				} catch(PDOException $e) {
220
+						return "error : ".$e->getMessage();
221
+				}
222 222
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
223 223
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
224 224
 		
@@ -229,17 +229,17 @@  discard block
 block discarded – undo
229 229
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 230
 		try {
231 231
 			if ($globalTransaction) $Connection->db->beginTransaction();
232
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
232
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233 233
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
234 234
 				if ($values['UserString4'] == 'M') $type = 'military';
235 235
 				else $type = null;
236 236
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237 237
 				$sth_dest->execute($query_dest_values);
238 238
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
239
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
-				    $sth_dest_owner->execute($query_dest_owner_values);
239
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
+					$sth_dest_owner->execute($query_dest_owner_values);
241 241
 				}
242
-            		}
242
+					}
243 243
 			if ($globalTransaction) $Connection->db->commit();
244 244
 		} catch(PDOException $e) {
245 245
 			return "error : ".$e->getMessage();
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 		try {
251 251
 			$Connection = new Connection();
252 252
 			$sth = $Connection->db->prepare($query);
253
-                        $sth->execute(array(':source' => $database_file));
254
-                } catch(PDOException $e) {
255
-                        return "error : ".$e->getMessage();
256
-                }
253
+						$sth->execute(array(':source' => $database_file));
254
+				} catch(PDOException $e) {
255
+						return "error : ".$e->getMessage();
256
+				}
257 257
 		return '';
258 258
 	}
259 259
 
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 		try {
266 266
 			$Connection = new Connection();
267 267
 			$sth = $Connection->db->prepare($query);
268
-                        $sth->execute(array(':source' => $database_file));
269
-                } catch(PDOException $e) {
270
-                        return "error : ".$e->getMessage();
271
-                }
268
+						$sth->execute(array(':source' => $database_file));
269
+				} catch(PDOException $e) {
270
+						return "error : ".$e->getMessage();
271
+				}
272 272
 		
273 273
 		if ($fh = fopen($database_file,"r")) {
274 274
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -278,26 +278,26 @@  discard block
 block discarded – undo
278 278
 			$sth_dest = $Connection->db->prepare($query_dest);
279 279
 			try {
280 280
 				if ($globalTransaction) $Connection->db->beginTransaction();
281
-            			while (!feof($fh)) {
282
-            				$values = array();
283
-            				$line = $Common->hex2str(fgets($fh,9999));
281
+						while (!feof($fh)) {
282
+							$values = array();
283
+							$line = $Common->hex2str(fgets($fh,9999));
284 284
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
285
-            				$values['ModeS'] = substr($line,0,6);
286
-            				$values['Registration'] = trim(substr($line,69,6));
287
-            				$aircraft_name = trim(substr($line,48,6));
288
-            				// Check if we can find ICAO, else set it to GLID
289
-            				$aircraft_name_split = explode(' ',$aircraft_name);
290
-            				$search_more = '';
291
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293
-            				$sth_search = $Connection->db->prepare($query_search);
285
+							$values['ModeS'] = substr($line,0,6);
286
+							$values['Registration'] = trim(substr($line,69,6));
287
+							$aircraft_name = trim(substr($line,48,6));
288
+							// Check if we can find ICAO, else set it to GLID
289
+							$aircraft_name_split = explode(' ',$aircraft_name);
290
+							$search_more = '';
291
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293
+							$sth_search = $Connection->db->prepare($query_search);
294 294
 					try {
295
-                                    		$sth_search->execute();
296
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
297
-	            				//if (count($result) > 0) {
298
-	            				if (isset($result['icao']) && $result['icao'] != '') {
299
-	            				    $values['ICAOTypeCode'] = $result['icao'];
300
-	            				} 
295
+											$sth_search->execute();
296
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
297
+								//if (count($result) > 0) {
298
+								if (isset($result['icao']) && $result['icao'] != '') {
299
+									$values['ICAOTypeCode'] = $result['icao'];
300
+								} 
301 301
 					} catch(PDOException $e) {
302 302
 						return "error : ".$e->getMessage();
303 303
 					}
@@ -320,10 +320,10 @@  discard block
 block discarded – undo
320 320
 		try {
321 321
 			$Connection = new Connection();
322 322
 			$sth = $Connection->db->prepare($query);
323
-                        $sth->execute(array(':source' => $database_file));
324
-                } catch(PDOException $e) {
325
-                        return "error : ".$e->getMessage();
326
-                }
323
+						$sth->execute(array(':source' => $database_file));
324
+				} catch(PDOException $e) {
325
+						return "error : ".$e->getMessage();
326
+				}
327 327
 		return '';
328 328
 	}
329 329
 
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
 		try {
335 335
 			$Connection = new Connection();
336 336
 			$sth = $Connection->db->prepare($query);
337
-                        $sth->execute(array(':source' => $database_file));
338
-                } catch(PDOException $e) {
339
-                        return "error : ".$e->getMessage();
340
-                }
337
+						$sth->execute(array(':source' => $database_file));
338
+				} catch(PDOException $e) {
339
+						return "error : ".$e->getMessage();
340
+				}
341 341
 		
342 342
 		if ($fh = fopen($database_file,"r")) {
343 343
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -348,24 +348,24 @@  discard block
 block discarded – undo
348 348
 			try {
349 349
 				if ($globalTransaction) $Connection->db->beginTransaction();
350 350
 				$tmp = fgetcsv($fh,9999,',',"'");
351
-            			while (!feof($fh)) {
352
-            				$line = fgetcsv($fh,9999,',',"'");
351
+						while (!feof($fh)) {
352
+							$line = fgetcsv($fh,9999,',',"'");
353 353
             				
354 354
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
355 355
 					//print_r($line);
356
-            				$values['ModeS'] = $line[1];
357
-            				$values['Registration'] = $line[3];
358
-            				$aircraft_name = $line[2];
359
-            				// Check if we can find ICAO, else set it to GLID
360
-            				$aircraft_name_split = explode(' ',$aircraft_name);
361
-            				$search_more = '';
362
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364
-            				$sth_search = $Connection->db->prepare($query_search);
356
+							$values['ModeS'] = $line[1];
357
+							$values['Registration'] = $line[3];
358
+							$aircraft_name = $line[2];
359
+							// Check if we can find ICAO, else set it to GLID
360
+							$aircraft_name_split = explode(' ',$aircraft_name);
361
+							$search_more = '';
362
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364
+							$sth_search = $Connection->db->prepare($query_search);
365 365
 					try {
366
-                                    		$sth_search->execute();
367
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
366
+											$sth_search->execute();
367
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
369 369
 					} catch(PDOException $e) {
370 370
 						return "error : ".$e->getMessage();
371 371
 					}
@@ -388,10 +388,10 @@  discard block
 block discarded – undo
388 388
 		try {
389 389
 			$Connection = new Connection();
390 390
 			$sth = $Connection->db->prepare($query);
391
-                        $sth->execute(array(':source' => $database_file));
392
-                } catch(PDOException $e) {
393
-                        return "error : ".$e->getMessage();
394
-                }
391
+						$sth->execute(array(':source' => $database_file));
392
+				} catch(PDOException $e) {
393
+						return "error : ".$e->getMessage();
394
+				}
395 395
 		return '';
396 396
 	}
397 397
 
@@ -402,16 +402,16 @@  discard block
 block discarded – undo
402 402
 		try {
403 403
 			$Connection = new Connection();
404 404
 			$sth = $Connection->db->prepare($query);
405
-                        $sth->execute(array(':source' => $database_file));
406
-                } catch(PDOException $e) {
407
-                        return "error : ".$e->getMessage();
408
-                }
405
+						$sth->execute(array(':source' => $database_file));
406
+				} catch(PDOException $e) {
407
+						return "error : ".$e->getMessage();
408
+				}
409 409
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
410 410
 		$Spotter = new Spotter();
411 411
 		if ($fh = fopen($database_file,"r")) {
412 412
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
413 413
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
414
-		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
414
+				$query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
415 415
 		        
416 416
 			$Connection = new Connection();
417 417
 			$sth_dest = $Connection->db->prepare($query_dest);
@@ -419,126 +419,126 @@  discard block
 block discarded – undo
419 419
 			try {
420 420
 				if ($globalTransaction) $Connection->db->beginTransaction();
421 421
 				$tmp = fgetcsv($fh,9999,',','"');
422
-            			while (!feof($fh)) {
423
-            				$line = fgetcsv($fh,9999,',','"');
424
-            				$values = array();
425
-            				//print_r($line);
426
-            				if ($country == 'F') {
427
-            				    $values['registration'] = $line[0];
428
-            				    $values['base'] = $line[4];
429
-            				    $values['owner'] = $line[5];
430
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
431
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
432
-					    $values['cancel'] = $line[7];
422
+						while (!feof($fh)) {
423
+							$line = fgetcsv($fh,9999,',','"');
424
+							$values = array();
425
+							//print_r($line);
426
+							if ($country == 'F') {
427
+								$values['registration'] = $line[0];
428
+								$values['base'] = $line[4];
429
+								$values['owner'] = $line[5];
430
+								if ($line[6] == '') $values['date_first_reg'] = null;
431
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
432
+						$values['cancel'] = $line[7];
433 433
 					} elseif ($country == 'EI') {
434
-					    // TODO : add modeS & reg to aircraft_modes
435
-            				    $values['registration'] = $line[0];
436
-            				    $values['base'] = $line[3];
437
-            				    $values['owner'] = $line[2];
438
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
439
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
440
-					    $values['cancel'] = '';
441
-					    $values['modes'] = $line[7];
442
-					    $values['icao'] = $line[8];
434
+						// TODO : add modeS & reg to aircraft_modes
435
+								$values['registration'] = $line[0];
436
+								$values['base'] = $line[3];
437
+								$values['owner'] = $line[2];
438
+								if ($line[1] == '') $values['date_first_reg'] = null;
439
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
440
+						$values['cancel'] = '';
441
+						$values['modes'] = $line[7];
442
+						$values['icao'] = $line[8];
443 443
 					    
444 444
 					} elseif ($country == 'HB') {
445
-					    // TODO : add modeS & reg to aircraft_modes
446
-            				    $values['registration'] = $line[0];
447
-            				    $values['base'] = null;
448
-            				    $values['owner'] = $line[5];
449
-            				    $values['date_first_reg'] = null;
450
-					    $values['cancel'] = '';
451
-					    $values['modes'] = $line[4];
452
-					    $values['icao'] = $line[7];
445
+						// TODO : add modeS & reg to aircraft_modes
446
+								$values['registration'] = $line[0];
447
+								$values['base'] = null;
448
+								$values['owner'] = $line[5];
449
+								$values['date_first_reg'] = null;
450
+						$values['cancel'] = '';
451
+						$values['modes'] = $line[4];
452
+						$values['icao'] = $line[7];
453 453
 					} elseif ($country == 'OK') {
454
-					    // TODO : add modeS & reg to aircraft_modes
455
-            				    $values['registration'] = $line[3];
456
-            				    $values['base'] = null;
457
-            				    $values['owner'] = $line[5];
458
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
460
-					    $values['cancel'] = '';
454
+						// TODO : add modeS & reg to aircraft_modes
455
+								$values['registration'] = $line[3];
456
+								$values['base'] = null;
457
+								$values['owner'] = $line[5];
458
+								if ($line[18] == '') $values['date_first_reg'] = null;
459
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
460
+						$values['cancel'] = '';
461 461
 					} elseif ($country == 'VH') {
462
-					    // TODO : add modeS & reg to aircraft_modes
463
-            				    $values['registration'] = $line[0];
464
-            				    $values['base'] = null;
465
-            				    $values['owner'] = $line[12];
466
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
467
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
468
-
469
-					    $values['cancel'] = $line[39];
462
+						// TODO : add modeS & reg to aircraft_modes
463
+								$values['registration'] = $line[0];
464
+								$values['base'] = null;
465
+								$values['owner'] = $line[12];
466
+								if ($line[28] == '') $values['date_first_reg'] = null;
467
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
468
+
469
+						$values['cancel'] = $line[39];
470 470
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
471
-            				    $values['registration'] = $line[0];
472
-            				    $values['base'] = null;
473
-            				    $values['owner'] = $line[4];
474
-            				    $values['date_first_reg'] = null;
475
-					    $values['cancel'] = '';
471
+								$values['registration'] = $line[0];
472
+								$values['base'] = null;
473
+								$values['owner'] = $line[4];
474
+								$values['date_first_reg'] = null;
475
+						$values['cancel'] = '';
476 476
 					} elseif ($country == 'CC') {
477
-            				    $values['registration'] = $line[0];
478
-            				    $values['base'] = null;
479
-            				    $values['owner'] = $line[6];
480
-            				    $values['date_first_reg'] = null;
481
-					    $values['cancel'] = '';
477
+								$values['registration'] = $line[0];
478
+								$values['base'] = null;
479
+								$values['owner'] = $line[6];
480
+								$values['date_first_reg'] = null;
481
+						$values['cancel'] = '';
482 482
 					} elseif ($country == 'HJ') {
483
-            				    $values['registration'] = $line[0];
484
-            				    $values['base'] = null;
485
-            				    $values['owner'] = $line[8];
486
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
487
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
488
-					    $values['cancel'] = '';
483
+								$values['registration'] = $line[0];
484
+								$values['base'] = null;
485
+								$values['owner'] = $line[8];
486
+								if ($line[7] == '') $values['date_first_reg'] = null;
487
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
488
+						$values['cancel'] = '';
489 489
 					} elseif ($country == 'PP') {
490
-            				    $values['registration'] = $line[0];
491
-            				    $values['base'] = null;
492
-            				    $values['owner'] = $line[4];
493
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
494
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
495
-					    $values['cancel'] = $line[7];
490
+								$values['registration'] = $line[0];
491
+								$values['base'] = null;
492
+								$values['owner'] = $line[4];
493
+								if ($line[6] == '') $values['date_first_reg'] = null;
494
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
495
+						$values['cancel'] = $line[7];
496 496
 					} elseif ($country == 'E7') {
497
-            				    $values['registration'] = $line[0];
498
-            				    $values['base'] = null;
499
-            				    $values['owner'] = $line[4];
500
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
501
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
502
-					    $values['cancel'] = '';
497
+								$values['registration'] = $line[0];
498
+								$values['base'] = null;
499
+								$values['owner'] = $line[4];
500
+								if ($line[5] == '') $values['date_first_reg'] = null;
501
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
502
+						$values['cancel'] = '';
503 503
 					} elseif ($country == '8Q') {
504
-            				    $values['registration'] = $line[0];
505
-            				    $values['base'] = null;
506
-            				    $values['owner'] = $line[3];
507
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
508
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
509
-					    $values['cancel'] = '';
504
+								$values['registration'] = $line[0];
505
+								$values['base'] = null;
506
+								$values['owner'] = $line[3];
507
+								if ($line[7] == '') $values['date_first_reg'] = null;
508
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
509
+						$values['cancel'] = '';
510 510
 					} elseif ($country == 'ZK') {
511
-            				    $values['registration'] = $line[0];
512
-            				    $values['base'] = null;
513
-            				    $values['owner'] = $line[3];
514
-            				    $values['date_first_reg'] = null;
515
-					    $values['cancel'] = '';
516
-					    $values['modes'] = $line[5];
517
-					    $values['icao'] = $line[9];
511
+								$values['registration'] = $line[0];
512
+								$values['base'] = null;
513
+								$values['owner'] = $line[3];
514
+								$values['date_first_reg'] = null;
515
+						$values['cancel'] = '';
516
+						$values['modes'] = $line[5];
517
+						$values['icao'] = $line[9];
518 518
 					} elseif ($country == 'M') {
519
-            				    $values['registration'] = $line[0];
520
-            				    $values['base'] = null;
521
-            				    $values['owner'] = $line[6];
522
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
523
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
524
-					    $values['modes'] = $line[4];
525
-					    $values['icao'] = $line[10];
519
+								$values['registration'] = $line[0];
520
+								$values['base'] = null;
521
+								$values['owner'] = $line[6];
522
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
523
+						$values['cancel'] = date("Y-m-d",strtotime($line[8]));
524
+						$values['modes'] = $line[4];
525
+						$values['icao'] = $line[10];
526 526
 					} elseif ($country == 'OY') {
527
-            				    $values['registration'] = $line[0];
528
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
529
-					    $values['modes'] = $line[5];
530
-					    $values['icao'] = $line[6];
527
+								$values['registration'] = $line[0];
528
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
529
+						$values['modes'] = $line[5];
530
+						$values['icao'] = $line[6];
531 531
 					} elseif ($country == 'PH') {
532
-            				    $values['registration'] = $line[0];
533
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
534
-					    $values['modes'] = $line[4];
535
-					    $values['icao'] = $line[5];
532
+								$values['registration'] = $line[0];
533
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
534
+						$values['modes'] = $line[4];
535
+						$values['icao'] = $line[5];
536 536
 					} elseif ($country == 'OM' || $country == 'TF') {
537
-            				    $values['registration'] = $line[0];
538
-            				    $values['base'] = null;
539
-            				    $values['owner'] = $line[3];
540
-            				    $values['date_first_reg'] = null;
541
-					    $values['cancel'] = '';
537
+								$values['registration'] = $line[0];
538
+								$values['base'] = null;
539
+								$values['owner'] = $line[3];
540
+								$values['date_first_reg'] = null;
541
+						$values['cancel'] = '';
542 542
 					}
543 543
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
544 544
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -665,20 +665,20 @@  discard block
 block discarded – undo
665 665
 		try {
666 666
 			$Connection = new Connection();
667 667
 			$sth = $Connection->db->prepare($query);
668
-                        $sth->execute();
669
-                } catch(PDOException $e) {
670
-                        return "error : ".$e->getMessage();
671
-                }
668
+						$sth->execute();
669
+				} catch(PDOException $e) {
670
+						return "error : ".$e->getMessage();
671
+				}
672 672
 
673 673
 
674 674
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
675 675
 		try {
676 676
 			$Connection = new Connection();
677 677
 			$sth = $Connection->db->prepare($query);
678
-                        $sth->execute();
679
-                } catch(PDOException $e) {
680
-                        return "error : ".$e->getMessage();
681
-                }
678
+						$sth->execute();
679
+				} catch(PDOException $e) {
680
+						return "error : ".$e->getMessage();
681
+				}
682 682
 
683 683
 		$query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`)
684 684
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
@@ -744,10 +744,10 @@  discard block
 block discarded – undo
744 744
 		try {
745 745
 			$Connection = new Connection();
746 746
 			$sth = $Connection->db->prepare($query);
747
-                        $sth->execute();
748
-                } catch(PDOException $e) {
749
-                        return "error : ".$e->getMessage();
750
-                }
747
+						$sth->execute();
748
+				} catch(PDOException $e) {
749
+						return "error : ".$e->getMessage();
750
+				}
751 751
 
752 752
 
753 753
 		if ($globalDebug) echo "Insert Not available Airport...\n";
@@ -757,10 +757,10 @@  discard block
 block discarded – undo
757 757
 		try {
758 758
 			$Connection = new Connection();
759 759
 			$sth = $Connection->db->prepare($query);
760
-                        $sth->execute($query_values);
761
-                } catch(PDOException $e) {
762
-                        return "error : ".$e->getMessage();
763
-                }
760
+						$sth->execute($query_values);
761
+				} catch(PDOException $e) {
762
+						return "error : ".$e->getMessage();
763
+				}
764 764
 		$i++;
765 765
 /*
766 766
 		$query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)';
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 
875 875
 
876 876
 
877
-                return "success";
877
+				return "success";
878 878
 	}
879 879
 	
880 880
 	public static function translation() {
@@ -890,10 +890,10 @@  discard block
 block discarded – undo
890 890
 		try {
891 891
 			$Connection = new Connection();
892 892
 			$sth = $Connection->db->prepare($query);
893
-                        $sth->execute(array(':source' => 'translation.csv'));
894
-                } catch(PDOException $e) {
895
-                        return "error : ".$e->getMessage();
896
-                }
893
+						$sth->execute(array(':source' => 'translation.csv'));
894
+				} catch(PDOException $e) {
895
+						return "error : ".$e->getMessage();
896
+				}
897 897
 
898 898
 		
899 899
 		//update_db::unzip($out_file);
@@ -912,21 +912,21 @@  discard block
 block discarded – undo
912 912
 					$data = $row;
913 913
 					$operator = $data[2];
914 914
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
915
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
916
-                                                //echo substr($operator, 0, 2)."\n";;
917
-                                                if (count($airline_array) > 0) {
915
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
916
+												//echo substr($operator, 0, 2)."\n";;
917
+												if (count($airline_array) > 0) {
918 918
 							//print_r($airline_array);
919 919
 							$operator = $airline_array[0]['icao'].substr($operator,2);
920
-                                                }
921
-                                        }
920
+												}
921
+										}
922 922
 					
923 923
 					$operator_correct = $data[3];
924 924
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
925
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
926
-                                                if (count($airline_array) > 0) {
927
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
928
-                                            	}
929
-                                        }
925
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
926
+												if (count($airline_array) > 0) {
927
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
928
+												}
929
+										}
930 930
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
931 931
 					try {
932 932
 						$sth = $Connection->db->prepare($query);
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 			//$Connection->db->commit();
941 941
 		}
942 942
 		return '';
943
-        }
943
+		}
944 944
 	
945 945
 	public static function translation_fam() {
946 946
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -950,10 +950,10 @@  discard block
 block discarded – undo
950 950
 		try {
951 951
 			$Connection = new Connection();
952 952
 			$sth = $Connection->db->prepare($query);
953
-                        $sth->execute(array(':source' => 'website_fam'));
954
-                } catch(PDOException $e) {
955
-                        return "error : ".$e->getMessage();
956
-                }
953
+						$sth->execute(array(':source' => 'website_fam'));
954
+				} catch(PDOException $e) {
955
+						return "error : ".$e->getMessage();
956
+				}
957 957
 
958 958
 		
959 959
 		//update_db::unzip($out_file);
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 			//$Connection->db->commit();
983 983
 		}
984 984
 		return '';
985
-        }
985
+		}
986 986
 
987 987
 	/*
988 988
 	* This function use FAA public data.
@@ -994,19 +994,19 @@  discard block
 block discarded – undo
994 994
 		try {
995 995
 			$Connection = new Connection();
996 996
 			$sth = $Connection->db->prepare($query);
997
-                        $sth->execute(array(':source' => 'website_faa'));
998
-                } catch(PDOException $e) {
999
-                        return "error : ".$e->getMessage();
1000
-                }
997
+						$sth->execute(array(':source' => 'website_faa'));
998
+				} catch(PDOException $e) {
999
+						return "error : ".$e->getMessage();
1000
+				}
1001 1001
 
1002 1002
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
1003 1003
 		try {
1004 1004
 			$Connection = new Connection();
1005 1005
 			$sth = $Connection->db->prepare($query);
1006
-                        $sth->execute(array(':source' => 'website_faa'));
1007
-                } catch(PDOException $e) {
1008
-                        return "error : ".$e->getMessage();
1009
-                }
1006
+						$sth->execute(array(':source' => 'website_faa'));
1007
+				} catch(PDOException $e) {
1008
+						return "error : ".$e->getMessage();
1009
+				}
1010 1010
 
1011 1011
 		$delimiter = ",";
1012 1012
 		$mfr = array();
@@ -1082,17 +1082,17 @@  discard block
 block discarded – undo
1082 1082
 		}
1083 1083
 		print_r($mfr);
1084 1084
 		return '';
1085
-        }
1085
+		}
1086 1086
 	public static function modes_fam() {
1087 1087
 		global $tmp_dir, $globalTransaction;
1088 1088
 		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source";
1089 1089
 		try {
1090 1090
 			$Connection = new Connection();
1091 1091
 			$sth = $Connection->db->prepare($query);
1092
-                        $sth->execute(array(':source' => 'website_fam'));
1093
-                } catch(PDOException $e) {
1094
-                        return "error : ".$e->getMessage();
1095
-                }
1092
+						$sth->execute(array(':source' => 'website_fam'));
1093
+				} catch(PDOException $e) {
1094
+						return "error : ".$e->getMessage();
1095
+				}
1096 1096
 
1097 1097
 		
1098 1098
 		//update_db::unzip($out_file);
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
 			if ($globalTransaction) $Connection->db->commit();
1123 1123
 		}
1124 1124
 		return '';
1125
-        }
1125
+		}
1126 1126
         
1127 1127
 	public static function owner_fam() {
1128 1128
 		global $tmp_dir, $globalTransaction;
@@ -1130,10 +1130,10 @@  discard block
 block discarded – undo
1130 1130
 		try {
1131 1131
 			$Connection = new Connection();
1132 1132
 			$sth = $Connection->db->prepare($query);
1133
-                        $sth->execute(array(':source' => 'website_fam'));
1134
-                } catch(PDOException $e) {
1135
-                        return "error : ".$e->getMessage();
1136
-                }
1133
+						$sth->execute(array(':source' => 'website_fam'));
1134
+				} catch(PDOException $e) {
1135
+						return "error : ".$e->getMessage();
1136
+				}
1137 1137
 
1138 1138
 		$delimiter = "\t";
1139 1139
 		$Connection = new Connection();
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
 			if ($globalTransaction) $Connection->db->commit();
1160 1160
 		}
1161 1161
 		return '';
1162
-        }
1162
+		}
1163 1163
 
1164 1164
 	public static function routes_fam() {
1165 1165
 		global $tmp_dir, $globalTransaction;
@@ -1167,10 +1167,10 @@  discard block
 block discarded – undo
1167 1167
 		try {
1168 1168
 			$Connection = new Connection();
1169 1169
 			$sth = $Connection->db->prepare($query);
1170
-                        $sth->execute(array(':source' => 'website_fam'));
1171
-                } catch(PDOException $e) {
1172
-                        return "error : ".$e->getMessage();
1173
-                }
1170
+						$sth->execute(array(':source' => 'website_fam'));
1171
+				} catch(PDOException $e) {
1172
+						return "error : ".$e->getMessage();
1173
+				}
1174 1174
 
1175 1175
 		
1176 1176
 		//update_db::unzip($out_file);
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 			if ($globalTransaction) $Connection->db->commit();
1200 1200
 		}
1201 1201
 		return '';
1202
-        }
1202
+		}
1203 1203
 
1204 1204
 	public static function banned_fam() {
1205 1205
 		global $tmp_dir, $globalTransaction;
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 			if ($globalTransaction) $Connection->db->commit();
1234 1234
 		}
1235 1235
 		return '';
1236
-        }
1236
+		}
1237 1237
 
1238 1238
 	public static function tle($filename,$tletype) {
1239 1239
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1244,10 +1244,10 @@  discard block
 block discarded – undo
1244 1244
 		try {
1245 1245
 			$Connection = new Connection();
1246 1246
 			$sth = $Connection->db->prepare($query);
1247
-                        $sth->execute(array(':source' => $filename));
1248
-                } catch(PDOException $e) {
1249
-                        return "error : ".$e->getMessage();
1250
-                }
1247
+						$sth->execute(array(':source' => $filename));
1248
+				} catch(PDOException $e) {
1249
+						return "error : ".$e->getMessage();
1250
+				}
1251 1251
 		
1252 1252
 		$Connection = new Connection();
1253 1253
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1282,54 +1282,54 @@  discard block
 block discarded – undo
1282 1282
 			//$Connection->db->commit();
1283 1283
 		}
1284 1284
 		return '';
1285
-        }
1285
+		}
1286 1286
 
1287 1287
 	/**
1288
-        * Convert a HTML table to an array
1289
-        * @param String $data HTML page
1290
-        * @return Array array of the tables in HTML page
1291
-        */
1292
-        private static function table2array($data) {
1293
-                $html = str_get_html($data);
1294
-                $tabledata=array();
1295
-                foreach($html->find('tr') as $element)
1296
-                {
1297
-                        $td = array();
1298
-                        foreach( $element->find('th') as $row)
1299
-                        {
1300
-                                $td [] = trim($row->plaintext);
1301
-                        }
1302
-                        $td=array_filter($td);
1303
-                        $tabledata[] = $td;
1304
-
1305
-                        $td = array();
1306
-                        $tdi = array();
1307
-                        foreach( $element->find('td') as $row)
1308
-                        {
1309
-                                $td [] = trim($row->plaintext);
1310
-                                $tdi [] = trim($row->innertext);
1311
-                        }
1312
-                        $td=array_filter($td);
1313
-                        $tdi=array_filter($tdi);
1314
-                    //    $tabledata[]=array_merge($td,$tdi);
1315
-                        $tabledata[]=$td;
1316
-                }
1317
-                return(array_filter($tabledata));
1318
-        }
1319
-
1320
-       /**
1321
-        * Get data from form result
1322
-        * @param String $url form URL
1323
-        * @return String the result
1324
-        */
1325
-        private static function getData($url) {
1326
-                $ch = curl_init();
1327
-                curl_setopt($ch, CURLOPT_URL, $url);
1328
-                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1329
-                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1330
-                curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
1331
-                return curl_exec($ch);
1332
-        }
1288
+	 * Convert a HTML table to an array
1289
+	 * @param String $data HTML page
1290
+	 * @return Array array of the tables in HTML page
1291
+	 */
1292
+		private static function table2array($data) {
1293
+				$html = str_get_html($data);
1294
+				$tabledata=array();
1295
+				foreach($html->find('tr') as $element)
1296
+				{
1297
+						$td = array();
1298
+						foreach( $element->find('th') as $row)
1299
+						{
1300
+								$td [] = trim($row->plaintext);
1301
+						}
1302
+						$td=array_filter($td);
1303
+						$tabledata[] = $td;
1304
+
1305
+						$td = array();
1306
+						$tdi = array();
1307
+						foreach( $element->find('td') as $row)
1308
+						{
1309
+								$td [] = trim($row->plaintext);
1310
+								$tdi [] = trim($row->innertext);
1311
+						}
1312
+						$td=array_filter($td);
1313
+						$tdi=array_filter($tdi);
1314
+					//    $tabledata[]=array_merge($td,$tdi);
1315
+						$tabledata[]=$td;
1316
+				}
1317
+				return(array_filter($tabledata));
1318
+		}
1319
+
1320
+	   /**
1321
+	    * Get data from form result
1322
+	    * @param String $url form URL
1323
+	    * @return String the result
1324
+	    */
1325
+		private static function getData($url) {
1326
+				$ch = curl_init();
1327
+				curl_setopt($ch, CURLOPT_URL, $url);
1328
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1329
+				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1330
+				curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
1331
+				return curl_exec($ch);
1332
+		}
1333 1333
 /*
1334 1334
 	public static function waypoints() {
1335 1335
 		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html');
@@ -1412,7 +1412,7 @@  discard block
 block discarded – undo
1412 1412
 			if ($globalTransaction) $Connection->db->commit();
1413 1413
 		}
1414 1414
 		return '';
1415
-        }
1415
+		}
1416 1416
 
1417 1417
 	public static function ivao_airlines($filename) {
1418 1418
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1422,10 +1422,10 @@  discard block
 block discarded – undo
1422 1422
 		try {
1423 1423
 			$Connection = new Connection();
1424 1424
 			$sth = $Connection->db->prepare($query);
1425
-                        $sth->execute();
1426
-                } catch(PDOException $e) {
1427
-                        return "error : ".$e->getMessage();
1428
-                }
1425
+						$sth->execute();
1426
+				} catch(PDOException $e) {
1427
+						return "error : ".$e->getMessage();
1428
+				}
1429 1429
 
1430 1430
 		$header = NULL;
1431 1431
 		$delimiter = ':';
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 			if ($globalTransaction) $Connection->db->commit();
1450 1450
 		}
1451 1451
 		return '';
1452
-        }
1452
+		}
1453 1453
 	
1454 1454
 	public static function update_airspace() {
1455 1455
 		global $tmp_dir, $globalDBdriver;
@@ -1459,11 +1459,11 @@  discard block
 block discarded – undo
1459 1459
 			$query = 'DROP TABLE airspace';
1460 1460
 			try {
1461 1461
 				$sth = $Connection->db->prepare($query);
1462
-                    		$sth->execute();
1463
-	                } catch(PDOException $e) {
1462
+							$sth->execute();
1463
+					} catch(PDOException $e) {
1464 1464
 				return "error : ".$e->getMessage();
1465
-	                }
1466
-	        }
1465
+					}
1466
+			}
1467 1467
 
1468 1468
 
1469 1469
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1518,10 +1518,10 @@  discard block
 block discarded – undo
1518 1518
 			$query = 'DROP TABLE countries';
1519 1519
 			try {
1520 1520
 				$sth = $Connection->db->prepare($query);
1521
-            	        	$sth->execute();
1522
-	                } catch(PDOException $e) {
1523
-    	                	echo "error : ".$e->getMessage();
1524
-	                }
1521
+							$sth->execute();
1522
+					} catch(PDOException $e) {
1523
+							echo "error : ".$e->getMessage();
1524
+					}
1525 1525
 		}
1526 1526
 		if ($globalDBdriver == 'mysql') {
1527 1527
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -2025,11 +2025,11 @@  discard block
 block discarded – undo
2025 2025
 						$query = 'DROP TABLE airspace';
2026 2026
 						try {
2027 2027
 							$sth = $Connection->db->prepare($query);
2028
-    	    	    					$sth->execute();
2029
-			            		} catch(PDOException $e) {
2028
+										$sth->execute();
2029
+								} catch(PDOException $e) {
2030 2030
 							return "error : ".$e->getMessage();
2031
-		            			}
2032
-		    			}
2031
+								}
2032
+						}
2033 2033
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2034 2034
 					update_db::insert_airspace_version($airspace_md5);
2035 2035
 				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
@@ -2149,12 +2149,12 @@  discard block
 block discarded – undo
2149 2149
 		echo $data;
2150 2150
 		*/
2151 2151
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2152
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2153
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2154
-		    $result = fread($fh,100000000);
2155
-		    //echo $result;
2156
-		    //var_dump(str_get_html($result));
2157
-		    //print_r(self::table2array($result));
2152
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2153
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
2154
+			$result = fread($fh,100000000);
2155
+			//echo $result;
2156
+			//var_dump(str_get_html($result));
2157
+			//print_r(self::table2array($result));
2158 2158
 		}
2159 2159
 
2160 2160
 	}
@@ -2168,10 +2168,10 @@  discard block
 block discarded – undo
2168 2168
 		try {
2169 2169
 			$Connection = new Connection();
2170 2170
 			$sth = $Connection->db->prepare($query);
2171
-                        $sth->execute();
2172
-                } catch(PDOException $e) {
2173
-                        return "error : ".$e->getMessage();
2174
-                }
2171
+						$sth->execute();
2172
+				} catch(PDOException $e) {
2173
+						return "error : ".$e->getMessage();
2174
+				}
2175 2175
 
2176 2176
 		$error = '';
2177 2177
 		if ($globalDebug) echo "Notam : Download...";
@@ -2227,8 +2227,8 @@  discard block
 block discarded – undo
2227 2227
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2228 2228
 					$data['permanent'] = 0;
2229 2229
 				} else {
2230
-				    $data['date_end'] = NULL;
2231
-				    $data['permanent'] = 1;
2230
+					$data['date_end'] = NULL;
2231
+					$data['permanent'] = 1;
2232 2232
 				}
2233 2233
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2234 2234
 				$NOTAM = new NOTAM();
@@ -2302,13 +2302,13 @@  discard block
 block discarded – undo
2302 2302
 		try {
2303 2303
 			$Connection = new Connection();
2304 2304
 			$sth = $Connection->db->prepare($query);
2305
-                        $sth->execute();
2306
-                } catch(PDOException $e) {
2307
-                        return "error : ".$e->getMessage();
2308
-                }
2309
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2310
-                if ($row['nb'] > 0) return false;
2311
-                else return true;
2305
+						$sth->execute();
2306
+				} catch(PDOException $e) {
2307
+						return "error : ".$e->getMessage();
2308
+				}
2309
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2310
+				if ($row['nb'] > 0) return false;
2311
+				else return true;
2312 2312
 	}
2313 2313
 
2314 2314
 	public static function insert_last_update() {
@@ -2317,10 +2317,10 @@  discard block
 block discarded – undo
2317 2317
 		try {
2318 2318
 			$Connection = new Connection();
2319 2319
 			$sth = $Connection->db->prepare($query);
2320
-                        $sth->execute();
2321
-                } catch(PDOException $e) {
2322
-                        return "error : ".$e->getMessage();
2323
-                }
2320
+						$sth->execute();
2321
+				} catch(PDOException $e) {
2322
+						return "error : ".$e->getMessage();
2323
+				}
2324 2324
 	}
2325 2325
 
2326 2326
 	public static function check_airspace_version($version) {
@@ -2328,13 +2328,13 @@  discard block
 block discarded – undo
2328 2328
 		try {
2329 2329
 			$Connection = new Connection();
2330 2330
 			$sth = $Connection->db->prepare($query);
2331
-                        $sth->execute(array(':version' => $version));
2332
-                } catch(PDOException $e) {
2333
-                        return "error : ".$e->getMessage();
2334
-                }
2335
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2336
-                if ($row['nb'] > 0) return true;
2337
-                else return false;
2331
+						$sth->execute(array(':version' => $version));
2332
+				} catch(PDOException $e) {
2333
+						return "error : ".$e->getMessage();
2334
+				}
2335
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2336
+				if ($row['nb'] > 0) return true;
2337
+				else return false;
2338 2338
 	}
2339 2339
 
2340 2340
 
@@ -2344,10 +2344,10 @@  discard block
 block discarded – undo
2344 2344
 		try {
2345 2345
 			$Connection = new Connection();
2346 2346
 			$sth = $Connection->db->prepare($query);
2347
-                        $sth->execute(array(':version' => $version));
2348
-                } catch(PDOException $e) {
2349
-                        return "error : ".$e->getMessage();
2350
-                }
2347
+						$sth->execute(array(':version' => $version));
2348
+				} catch(PDOException $e) {
2349
+						return "error : ".$e->getMessage();
2350
+				}
2351 2351
 	}
2352 2352
 
2353 2353
 	public static function check_last_notam_update() {
@@ -2360,13 +2360,13 @@  discard block
 block discarded – undo
2360 2360
 		try {
2361 2361
 			$Connection = new Connection();
2362 2362
 			$sth = $Connection->db->prepare($query);
2363
-                        $sth->execute();
2364
-                } catch(PDOException $e) {
2365
-                        return "error : ".$e->getMessage();
2366
-                }
2367
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2368
-                if ($row['nb'] > 0) return false;
2369
-                else return true;
2363
+						$sth->execute();
2364
+				} catch(PDOException $e) {
2365
+						return "error : ".$e->getMessage();
2366
+				}
2367
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2368
+				if ($row['nb'] > 0) return false;
2369
+				else return true;
2370 2370
 	}
2371 2371
 
2372 2372
 	public static function insert_last_notam_update() {
@@ -2375,10 +2375,10 @@  discard block
 block discarded – undo
2375 2375
 		try {
2376 2376
 			$Connection = new Connection();
2377 2377
 			$sth = $Connection->db->prepare($query);
2378
-                        $sth->execute();
2379
-                } catch(PDOException $e) {
2380
-                        return "error : ".$e->getMessage();
2381
-                }
2378
+						$sth->execute();
2379
+				} catch(PDOException $e) {
2380
+						return "error : ".$e->getMessage();
2381
+				}
2382 2382
 	}
2383 2383
 	public static function check_last_airspace_update() {
2384 2384
 		global $globalDBdriver;
@@ -2390,13 +2390,13 @@  discard block
 block discarded – undo
2390 2390
 		try {
2391 2391
 			$Connection = new Connection();
2392 2392
 			$sth = $Connection->db->prepare($query);
2393
-                        $sth->execute();
2394
-                } catch(PDOException $e) {
2395
-                        return "error : ".$e->getMessage();
2396
-                }
2397
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2398
-                if ($row['nb'] > 0) return false;
2399
-                else return true;
2393
+						$sth->execute();
2394
+				} catch(PDOException $e) {
2395
+						return "error : ".$e->getMessage();
2396
+				}
2397
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2398
+				if ($row['nb'] > 0) return false;
2399
+				else return true;
2400 2400
 	}
2401 2401
 
2402 2402
 	public static function insert_last_airspace_update() {
@@ -2405,10 +2405,10 @@  discard block
 block discarded – undo
2405 2405
 		try {
2406 2406
 			$Connection = new Connection();
2407 2407
 			$sth = $Connection->db->prepare($query);
2408
-                        $sth->execute();
2409
-                } catch(PDOException $e) {
2410
-                        return "error : ".$e->getMessage();
2411
-                }
2408
+						$sth->execute();
2409
+				} catch(PDOException $e) {
2410
+						return "error : ".$e->getMessage();
2411
+				}
2412 2412
 	}
2413 2413
 
2414 2414
 	public static function check_last_owner_update() {
@@ -2421,13 +2421,13 @@  discard block
 block discarded – undo
2421 2421
 		try {
2422 2422
 			$Connection = new Connection();
2423 2423
 			$sth = $Connection->db->prepare($query);
2424
-                        $sth->execute();
2425
-                } catch(PDOException $e) {
2426
-                        return "error : ".$e->getMessage();
2427
-                }
2428
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2429
-                if ($row['nb'] > 0) return false;
2430
-                else return true;
2424
+						$sth->execute();
2425
+				} catch(PDOException $e) {
2426
+						return "error : ".$e->getMessage();
2427
+				}
2428
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2429
+				if ($row['nb'] > 0) return false;
2430
+				else return true;
2431 2431
 	}
2432 2432
 
2433 2433
 	public static function insert_last_owner_update() {
@@ -2436,10 +2436,10 @@  discard block
 block discarded – undo
2436 2436
 		try {
2437 2437
 			$Connection = new Connection();
2438 2438
 			$sth = $Connection->db->prepare($query);
2439
-                        $sth->execute();
2440
-                } catch(PDOException $e) {
2441
-                        return "error : ".$e->getMessage();
2442
-                }
2439
+						$sth->execute();
2440
+				} catch(PDOException $e) {
2441
+						return "error : ".$e->getMessage();
2442
+				}
2443 2443
 	}
2444 2444
 	public static function check_last_schedules_update() {
2445 2445
 		global $globalDBdriver;
@@ -2451,13 +2451,13 @@  discard block
 block discarded – undo
2451 2451
 		try {
2452 2452
 			$Connection = new Connection();
2453 2453
 			$sth = $Connection->db->prepare($query);
2454
-                        $sth->execute();
2455
-                } catch(PDOException $e) {
2456
-                        return "error : ".$e->getMessage();
2457
-                }
2458
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2459
-                if ($row['nb'] > 0) return false;
2460
-                else return true;
2454
+						$sth->execute();
2455
+				} catch(PDOException $e) {
2456
+						return "error : ".$e->getMessage();
2457
+				}
2458
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2459
+				if ($row['nb'] > 0) return false;
2460
+				else return true;
2461 2461
 	}
2462 2462
 
2463 2463
 	public static function insert_last_schedules_update() {
@@ -2466,10 +2466,10 @@  discard block
 block discarded – undo
2466 2466
 		try {
2467 2467
 			$Connection = new Connection();
2468 2468
 			$sth = $Connection->db->prepare($query);
2469
-                        $sth->execute();
2470
-                } catch(PDOException $e) {
2471
-                        return "error : ".$e->getMessage();
2472
-                }
2469
+						$sth->execute();
2470
+				} catch(PDOException $e) {
2471
+						return "error : ".$e->getMessage();
2472
+				}
2473 2473
 	}
2474 2474
 	public static function check_last_tle_update() {
2475 2475
 		global $globalDBdriver;
@@ -2481,13 +2481,13 @@  discard block
 block discarded – undo
2481 2481
 		try {
2482 2482
 			$Connection = new Connection();
2483 2483
 			$sth = $Connection->db->prepare($query);
2484
-                        $sth->execute();
2485
-                } catch(PDOException $e) {
2486
-                        return "error : ".$e->getMessage();
2487
-                }
2488
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2489
-                if ($row['nb'] > 0) return false;
2490
-                else return true;
2484
+						$sth->execute();
2485
+				} catch(PDOException $e) {
2486
+						return "error : ".$e->getMessage();
2487
+				}
2488
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2489
+				if ($row['nb'] > 0) return false;
2490
+				else return true;
2491 2491
 	}
2492 2492
 
2493 2493
 	public static function insert_last_tle_update() {
@@ -2496,10 +2496,10 @@  discard block
 block discarded – undo
2496 2496
 		try {
2497 2497
 			$Connection = new Connection();
2498 2498
 			$sth = $Connection->db->prepare($query);
2499
-                        $sth->execute();
2500
-                } catch(PDOException $e) {
2501
-                        return "error : ".$e->getMessage();
2502
-                }
2499
+						$sth->execute();
2500
+				} catch(PDOException $e) {
2501
+						return "error : ".$e->getMessage();
2502
+				}
2503 2503
 	}
2504 2504
 	public static function delete_duplicatemodes() {
2505 2505
 		global $globalDBdriver;
@@ -2511,10 +2511,10 @@  discard block
 block discarded – undo
2511 2511
 		try {
2512 2512
 			$Connection = new Connection();
2513 2513
 			$sth = $Connection->db->prepare($query);
2514
-                        $sth->execute();
2515
-                } catch(PDOException $e) {
2516
-                        return "error : ".$e->getMessage();
2517
-                }
2514
+						$sth->execute();
2515
+				} catch(PDOException $e) {
2516
+						return "error : ".$e->getMessage();
2517
+				}
2518 2518
 	}
2519 2519
 	public static function delete_duplicateowner() {
2520 2520
 		global $globalDBdriver;
@@ -2526,10 +2526,10 @@  discard block
 block discarded – undo
2526 2526
 		try {
2527 2527
 			$Connection = new Connection();
2528 2528
 			$sth = $Connection->db->prepare($query);
2529
-                        $sth->execute();
2530
-                } catch(PDOException $e) {
2531
-                        return "error : ".$e->getMessage();
2532
-                }
2529
+						$sth->execute();
2530
+				} catch(PDOException $e) {
2531
+						return "error : ".$e->getMessage();
2532
+				}
2533 2533
 	}
2534 2534
 	
2535 2535
 	public static function update_all() {
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Indentation   +693 added lines, -693 removed lines patch added patch discarded remove patch
@@ -19,47 +19,47 @@  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
 if (PHP_SAPI != 'cli') {
26
-    echo "This script MUST be called from console, not a web browser.";
26
+	echo "This script MUST be called from console, not a web browser.";
27 27
 //    exit();
28 28
 }
29 29
 
30 30
 // This is to be compatible with old version of settings.php
31 31
 if (!isset($globalSources)) {
32
-    if (isset($globalSBS1Hosts)) {
33
-        //$hosts = $globalSBS1Hosts;
34
-        foreach ($globalSBS1Hosts as $host) {
35
-	    $globalSources[] = array('host' => $host);
36
-    	}
37
-    } else {
38
-        if (!isset($globalSBS1Host)) {
39
-	    echo '$globalSources MUST be defined !';
40
-	    die;
32
+	if (isset($globalSBS1Hosts)) {
33
+		//$hosts = $globalSBS1Hosts;
34
+		foreach ($globalSBS1Hosts as $host) {
35
+		$globalSources[] = array('host' => $host);
36
+		}
37
+	} else {
38
+		if (!isset($globalSBS1Host)) {
39
+		echo '$globalSources MUST be defined !';
40
+		die;
41 41
 	}
42 42
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
43 43
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
44
-    }
44
+	}
45 45
 }
46 46
 
47 47
 $options = getopt('s::',array('source::','server','idsource::'));
48 48
 //if (isset($options['s'])) $hosts = array($options['s']);
49 49
 //elseif (isset($options['source'])) $hosts = array($options['source']);
50 50
 if (isset($options['s'])) {
51
-    $globalSources = array();
52
-    $globalSources[] = array('host' => $options['s']);
51
+	$globalSources = array();
52
+	$globalSources[] = array('host' => $options['s']);
53 53
 } elseif (isset($options['source'])) {
54
-    $globalSources = array();
55
-    $globalSources[] = array('host' => $options['source']);
54
+	$globalSources = array();
55
+	$globalSources[] = array('host' => $options['source']);
56 56
 }
57 57
 if (isset($options['server'])) $globalServer = TRUE;
58 58
 if (isset($options['idsource'])) $id_source = $options['idsource'];
59 59
 else $id_source = 1;
60 60
 if (isset($globalServer) && $globalServer) {
61
-    if ($globalDebug) echo "Using Server Mode\n";
62
-    $SI=new SpotterServer();
61
+	if ($globalDebug) echo "Using Server Mode\n";
62
+	$SI=new SpotterServer();
63 63
 } else $SI=new SpotterImport($Connection->db);
64 64
 //$APRS=new APRS($Connection->db);
65 65
 $SBS=new SBS();
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 //$servertz = system('date +%Z');
70 70
 // signal handler - playing nice with sockets and dump1090
71 71
 if (function_exists('pcntl_fork')) {
72
-    pcntl_signal(SIGINT,  function() {
73
-        global $sockets;
74
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75
-        die("Bye!\n");
76
-    });
77
-    pcntl_signal_dispatch();
72
+	pcntl_signal(SIGINT,  function() {
73
+		global $sockets;
74
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75
+		die("Bye!\n");
76
+	});
77
+	pcntl_signal_dispatch();
78 78
 }
79 79
 
80 80
 // let's try and connect
@@ -84,162 +84,162 @@  discard block
 block discarded – undo
84 84
 $reset = 0;
85 85
 
86 86
 function create_socket($host, $port, &$errno, &$errstr) {
87
-    $ip = gethostbyname($host);
88
-    $s = socket_create(AF_INET, SOCK_STREAM, 0);
89
-    $r = @socket_connect($s, $ip, $port);
90
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
91
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92
-        return $s;
93
-    }
94
-    $errno = socket_last_error($s);
95
-    $errstr = socket_strerror($errno);
96
-    socket_close($s);
97
-    return false;
87
+	$ip = gethostbyname($host);
88
+	$s = socket_create(AF_INET, SOCK_STREAM, 0);
89
+	$r = @socket_connect($s, $ip, $port);
90
+	if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
91
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92
+		return $s;
93
+	}
94
+	$errno = socket_last_error($s);
95
+	$errstr = socket_strerror($errno);
96
+	socket_close($s);
97
+	return false;
98 98
 }
99 99
 
100 100
 function create_socket_udp($host, $port, &$errno, &$errstr) {
101
-    echo "Create an UDP socket...\n";
102
-    $ip = gethostbyname($host);
103
-    $s = socket_create(AF_INET, SOCK_DGRAM, 0);
104
-    $r = @socket_bind($s, $ip, $port);
105
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
106
-        return $s;
107
-    }
108
-    $errno = socket_last_error($s);
109
-    $errstr = socket_strerror($errno);
110
-    socket_close($s);
111
-    return false;
101
+	echo "Create an UDP socket...\n";
102
+	$ip = gethostbyname($host);
103
+	$s = socket_create(AF_INET, SOCK_DGRAM, 0);
104
+	$r = @socket_bind($s, $ip, $port);
105
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
106
+		return $s;
107
+	}
108
+	$errno = socket_last_error($s);
109
+	$errstr = socket_strerror($errno);
110
+	socket_close($s);
111
+	return false;
112 112
 }
113 113
 
114 114
 function connect_all($hosts) {
115
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117
-    $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
119
-    foreach ($hosts as $id => $value) {
115
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
+	global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117
+	$reset++;
118
+	if ($globalDebug) echo 'Connect to all...'."\n";
119
+	foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123 123
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
125
-        	//$formats[$id] = 'deltadbtxt';
126
-        	$globalSources[$id]['format'] = 'deltadbtxt';
127
-        	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
-        	//$formats[$id] = 'vatsimtxt';
131
-        	$globalSources[$id]['format'] = 'vatsimtxt';
132
-        	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135
-        	//$formats[$id] = 'aircraftlistjson';
136
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
137
-        	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
140
-        	//$formats[$id] = 'aircraftlistjson';
141
-        	$globalSources[$id]['format'] = 'opensky';
142
-        	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145
-        	//$formats[$id] = 'radarvirtueljson';
146
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
147
-        	//$last_exec['radarvirtueljson'] = 0;
148
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
149
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151
-        	    exit(0);
152
-        	}
153
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
154
-        	//$formats[$id] = 'planeupdatefaa';
155
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
156
-        	//$last_exec['planeupdatefaa'] = 0;
157
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
158
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160
-        	    exit(0);
161
-        	}
162
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
163
-        	//$formats[$id] = 'phpvmacars';
164
-        	$globalSources[$id]['format'] = 'phpvmacars';
165
-        	//$last_exec['phpvmacars'] = 0;
166
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
168
-        	//$formats[$id] = 'phpvmacars';
169
-        	$globalSources[$id]['format'] = 'vam';
170
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
-            } else if (preg_match('/whazzup/i',$host)) {
172
-        	//$formats[$id] = 'whazzup';
173
-        	$globalSources[$id]['format'] = 'whazzup';
174
-        	//$last_exec['whazzup'] = 0;
175
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
-            } else if (preg_match('/recentpireps/i',$host)) {
177
-        	//$formats[$id] = 'pirepsjson';
178
-        	$globalSources[$id]['format'] = 'pirepsjson';
179
-        	//$last_exec['pirepsjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182
-        	//$formats[$id] = 'fr24json';
183
-        	$globalSources[$id]['format'] = 'fr24json';
184
-        	//$last_exec['fr24json'] = 0;
185
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
186
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188
-        	    exit(0);
189
-        	}
190
-            //} else if (preg_match('/10001/',$host)) {
191
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192
-        	//$formats[$id] = 'tsv';
193
-        	$globalSources[$id]['format'] = 'tsv';
194
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195
-            }
196
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
-	    $hostport = explode(':',$host);
200
-	    if (isset($hostport[1])) {
124
+			if (preg_match('/deltadb.txt$/i',$host)) {
125
+			//$formats[$id] = 'deltadbtxt';
126
+			$globalSources[$id]['format'] = 'deltadbtxt';
127
+			//$last_exec['deltadbtxt'] = 0;
128
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
+			//$formats[$id] = 'vatsimtxt';
131
+			$globalSources[$id]['format'] = 'vatsimtxt';
132
+			//$last_exec['vatsimtxt'] = 0;
133
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
135
+			//$formats[$id] = 'aircraftlistjson';
136
+			$globalSources[$id]['format'] = 'aircraftlistjson';
137
+			//$last_exec['aircraftlistjson'] = 0;
138
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
+			} else if (preg_match('/opensky/i',$host)) {
140
+			//$formats[$id] = 'aircraftlistjson';
141
+			$globalSources[$id]['format'] = 'opensky';
142
+			//$last_exec['aircraftlistjson'] = 0;
143
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145
+			//$formats[$id] = 'radarvirtueljson';
146
+			$globalSources[$id]['format'] = 'radarvirtueljson';
147
+			//$last_exec['radarvirtueljson'] = 0;
148
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
149
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151
+				exit(0);
152
+			}
153
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
154
+			//$formats[$id] = 'planeupdatefaa';
155
+			$globalSources[$id]['format'] = 'planeupdatefaa';
156
+			//$last_exec['planeupdatefaa'] = 0;
157
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
158
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160
+				exit(0);
161
+			}
162
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
163
+			//$formats[$id] = 'phpvmacars';
164
+			$globalSources[$id]['format'] = 'phpvmacars';
165
+			//$last_exec['phpvmacars'] = 0;
166
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
168
+			//$formats[$id] = 'phpvmacars';
169
+			$globalSources[$id]['format'] = 'vam';
170
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
+			} else if (preg_match('/whazzup/i',$host)) {
172
+			//$formats[$id] = 'whazzup';
173
+			$globalSources[$id]['format'] = 'whazzup';
174
+			//$last_exec['whazzup'] = 0;
175
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
+			} else if (preg_match('/recentpireps/i',$host)) {
177
+			//$formats[$id] = 'pirepsjson';
178
+			$globalSources[$id]['format'] = 'pirepsjson';
179
+			//$last_exec['pirepsjson'] = 0;
180
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182
+			//$formats[$id] = 'fr24json';
183
+			$globalSources[$id]['format'] = 'fr24json';
184
+			//$last_exec['fr24json'] = 0;
185
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
186
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188
+				exit(0);
189
+			}
190
+			//} else if (preg_match('/10001/',$host)) {
191
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192
+			//$formats[$id] = 'tsv';
193
+			$globalSources[$id]['format'] = 'tsv';
194
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195
+			}
196
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
+			if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
+		$hostport = explode(':',$host);
200
+		if (isset($hostport[1])) {
201 201
 		$port = $hostport[1];
202 202
 		$hostn = $hostport[0];
203
-	    } else {
203
+		} else {
204 204
 		$port = $globalSources[$id]['port'];
205 205
 		$hostn = $globalSources[$id]['host'];
206
-	    }
207
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
-        	$s = create_socket($hostn,$port, $errno, $errstr);
209
-    	    } else {
210
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
211
-	    }
212
-	    if ($s) {
213
-    	        $sockets[$id] = $s;
214
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
-		    if (preg_match('/aprs/',$hostn)) {
206
+		}
207
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
+			$s = create_socket($hostn,$port, $errno, $errstr);
209
+			} else {
210
+			$s = create_socket_udp($hostn,$port, $errno, $errstr);
211
+		}
212
+		if ($s) {
213
+				$sockets[$id] = $s;
214
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
+			if (preg_match('/aprs/',$hostn)) {
216 216
 			//$formats[$id] = 'aprs';
217 217
 			$globalSources[$id]['format'] = 'aprs';
218 218
 			//$aprs_connect = 0;
219 219
 			//$use_aprs = true;
220
-    		    } elseif ($port == '10001') {
221
-        		//$formats[$id] = 'tsv';
222
-        		$globalSources[$id]['format'] = 'tsv';
223
-		    } elseif ($port == '30002') {
224
-        		//$formats[$id] = 'raw';
225
-        		$globalSources[$id]['format'] = 'raw';
226
-		    } elseif ($port == '5001') {
227
-        		//$formats[$id] = 'raw';
228
-        		$globalSources[$id]['format'] = 'flightgearmp';
229
-		    } elseif ($port == '30005') {
220
+				} elseif ($port == '10001') {
221
+				//$formats[$id] = 'tsv';
222
+				$globalSources[$id]['format'] = 'tsv';
223
+			} elseif ($port == '30002') {
224
+				//$formats[$id] = 'raw';
225
+				$globalSources[$id]['format'] = 'raw';
226
+			} elseif ($port == '5001') {
227
+				//$formats[$id] = 'raw';
228
+				$globalSources[$id]['format'] = 'flightgearmp';
229
+			} elseif ($port == '30005') {
230 230
 			// Not yet supported
231
-        		//$formats[$id] = 'beast';
232
-        		$globalSources[$id]['format'] = 'beast';
233
-		    //} else $formats[$id] = 'sbs';
234
-		    } else $globalSources[$id]['format'] = 'sbs';
235
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
231
+				//$formats[$id] = 'beast';
232
+				$globalSources[$id]['format'] = 'beast';
233
+			//} else $formats[$id] = 'sbs';
234
+			} else $globalSources[$id]['format'] = 'sbs';
235
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
236 236
 		}
237 237
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
238
-            } else {
238
+			} else {
239 239
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
240
-    	    }
241
-        }
242
-    }
240
+			}
241
+		}
242
+	}
243 243
 }
244 244
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
245 245
 
@@ -266,18 +266,18 @@  discard block
 block discarded – undo
266 266
 	die;
267 267
 }
268 268
 foreach ($globalSources as $key => $source) {
269
-    if (!isset($source['format'])) {
270
-        $globalSources[$key]['format'] = 'auto';
271
-    }
269
+	if (!isset($source['format'])) {
270
+		$globalSources[$key]['format'] = 'auto';
271
+	}
272 272
 }
273 273
 connect_all($globalSources);
274 274
 foreach ($globalSources as $key => $source) {
275
-    if (isset($source['format']) && $source['format'] == 'aprs') {
275
+	if (isset($source['format']) && $source['format'] == 'aprs') {
276 276
 	$aprs_connect = 0;
277 277
 	$use_aprs = true;
278 278
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
279 279
 	break;
280
-    }
280
+	}
281 281
 }
282 282
 
283 283
 if ($use_aprs) {
@@ -317,69 +317,69 @@  discard block
 block discarded – undo
317 317
 
318 318
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
319 319
 while ($i > 0) {
320
-    if (!$globalDaemon) $i = $endtime-time();
321
-    // Delete old ATC
322
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
320
+	if (!$globalDaemon) $i = $endtime-time();
321
+	// Delete old ATC
322
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
323 323
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
324
-        $ATC->deleteOldATC();
325
-    }
324
+		$ATC->deleteOldATC();
325
+	}
326 326
     
327
-    if (count($last_exec) > 0) {
327
+	if (count($last_exec) > 0) {
328 328
 	$max = $globalMinFetch;
329 329
 	foreach ($last_exec as $last) {
330
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
330
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
331 331
 	}
332 332
 	if ($max != $globalMinFetch) {
333
-	    if ($globalDebug) echo 'Sleeping...'."\n";
334
-	    sleep($globalMinFetch-$max+2);
333
+		if ($globalDebug) echo 'Sleeping...'."\n";
334
+		sleep($globalMinFetch-$max+2);
335
+	}
335 336
 	}
336
-    }
337 337
 
338 338
     
339
-    //foreach ($formats as $id => $value) {
340
-    foreach ($globalSources as $id => $value) {
339
+	//foreach ($formats as $id => $value) {
340
+	foreach ($globalSources as $id => $value) {
341 341
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
342 342
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
343
-	    //$buffer = $Common->getData($hosts[$id]);
344
-	    $buffer = $Common->getData($value['host']);
345
-	    if ($buffer != '') $reset = 0;
346
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347
-	    $buffer = explode('\n',$buffer);
348
-	    foreach ($buffer as $line) {
349
-    		if ($line != '' && count($line) > 7) {
350
-    		    $line = explode(',', $line);
351
-	            $data = array();
352
-	            $data['hex'] = $line[1]; // hex
353
-	            $data['ident'] = $line[2]; // ident
354
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
355
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
356
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
357
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
358
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
359
-	            $data['verticalrate'] = ''; // vertical rate
360
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
361
-	            $data['emergency'] = ''; // emergency
362
-		    $data['datetime'] = date('Y-m-d H:i:s');
363
-		    $data['format_source'] = 'deltadbtxt';
364
-    		    $data['id_source'] = $id_source;
365
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
366
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
367
-    		    $SI->add($data);
368
-		    unset($data);
369
-    		}
370
-    	    }
371
-    	    $last_exec[$id]['last'] = time();
343
+		//$buffer = $Common->getData($hosts[$id]);
344
+		$buffer = $Common->getData($value['host']);
345
+		if ($buffer != '') $reset = 0;
346
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347
+		$buffer = explode('\n',$buffer);
348
+		foreach ($buffer as $line) {
349
+			if ($line != '' && count($line) > 7) {
350
+				$line = explode(',', $line);
351
+				$data = array();
352
+				$data['hex'] = $line[1]; // hex
353
+				$data['ident'] = $line[2]; // ident
354
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
355
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
356
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
357
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
358
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
359
+				$data['verticalrate'] = ''; // vertical rate
360
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
361
+				$data['emergency'] = ''; // emergency
362
+			$data['datetime'] = date('Y-m-d H:i:s');
363
+			$data['format_source'] = 'deltadbtxt';
364
+				$data['id_source'] = $id_source;
365
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
366
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
367
+				$SI->add($data);
368
+			unset($data);
369
+			}
370
+			}
371
+			$last_exec[$id]['last'] = time();
372 372
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
373 373
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
374
-	    //$buffer = $Common->getData($hosts[$id]);
375
-	    $buffer = $Common->getData($value['host']);
376
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
-	    $buffer = explode('\n',$buffer);
378
-	    $reset = 0;
379
-	    foreach ($buffer as $line) {
380
-    		if ($line != '') {
381
-    		    $line = explode(':', $line);
382
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
374
+		//$buffer = $Common->getData($hosts[$id]);
375
+		$buffer = $Common->getData($value['host']);
376
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
+		$buffer = explode('\n',$buffer);
378
+		$reset = 0;
379
+		foreach ($buffer as $line) {
380
+			if ($line != '') {
381
+				$line = explode(':', $line);
382
+				if (count($line) > 30 && $line[0] != 'callsign') {
383 383
 			$data = array();
384 384
 			$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
385 385
 			$data['pilot_id'] = $line[1];
@@ -391,36 +391,36 @@  discard block
 block discarded – undo
391 391
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
392 392
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
393 393
 			$data['latitude'] = $line[5]; // lat
394
-	        	$data['longitude'] = $line[6]; // long
395
-	        	$data['verticalrate'] = ''; // vertical rate
396
-	        	$data['squawk'] = ''; // squawk
397
-	        	$data['emergency'] = ''; // emergency
398
-	        	$data['waypoints'] = $line[30];
394
+				$data['longitude'] = $line[6]; // long
395
+				$data['verticalrate'] = ''; // vertical rate
396
+				$data['squawk'] = ''; // squawk
397
+				$data['emergency'] = ''; // emergency
398
+				$data['waypoints'] = $line[30];
399 399
 			$data['datetime'] = date('Y-m-d H:i:s');
400 400
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
401 401
 			if (isset($line[37])) $data['last_update'] = $line[37];
402
-		        $data['departure_airport_icao'] = $line[11];
403
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
404
-		        $data['arrival_airport_icao'] = $line[13];
402
+				$data['departure_airport_icao'] = $line[11];
403
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
404
+				$data['arrival_airport_icao'] = $line[13];
405 405
 			$data['frequency'] = $line[4];
406 406
 			$data['type'] = $line[18];
407 407
 			$data['range'] = $line[19];
408 408
 			if (isset($line[35])) $data['info'] = $line[35];
409
-    			$data['id_source'] = $id_source;
410
-	    		//$data['arrival_airport_time'] = ;
411
-	    		if ($line[9] != '') {
412
-	    		    $aircraft_data = explode('/',$line[9]);
413
-	    		    if (isset($aircraft_data[1])) {
414
-	    			$data['aircraft_icao'] = $aircraft_data[1];
415
-	    		    }
416
-        		}
417
-	    		/*
409
+				$data['id_source'] = $id_source;
410
+				//$data['arrival_airport_time'] = ;
411
+				if ($line[9] != '') {
412
+					$aircraft_data = explode('/',$line[9]);
413
+					if (isset($aircraft_data[1])) {
414
+					$data['aircraft_icao'] = $aircraft_data[1];
415
+					}
416
+				}
417
+				/*
418 418
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
419 419
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
420 420
 	    		*/
421
-	    		$data['format_source'] = $value['format'];
421
+				$data['format_source'] = $value['format'];
422 422
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
423
-    			if ($line[3] == 'PILOT') $SI->add($data);
423
+				if ($line[3] == 'PILOT') $SI->add($data);
424 424
 			elseif ($line[3] == 'ATC') {
425 425
 				//print_r($data);
426 426
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -438,247 +438,247 @@  discard block
 block discarded – undo
438 438
 				if (!isset($data['source_name'])) $data['source_name'] = '';
439 439
 				echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
440 440
 			}
441
-    			unset($data);
442
-    		    }
443
-    		}
444
-    	    }
445
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
446
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
447
-    	    $last_exec[$id]['last'] = time();
448
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
449
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
450
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
451
-	    if ($buffer != '') {
452
-	    $all_data = json_decode($buffer,true);
453
-	    if (isset($all_data['acList'])) {
441
+				unset($data);
442
+				}
443
+			}
444
+			}
445
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
446
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
447
+			$last_exec[$id]['last'] = time();
448
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
449
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
450
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
451
+		if ($buffer != '') {
452
+		$all_data = json_decode($buffer,true);
453
+		if (isset($all_data['acList'])) {
454 454
 		$reset = 0;
455 455
 		foreach ($all_data['acList'] as $line) {
456
-		    $data = array();
457
-		    $data['hex'] = $line['Icao']; // hex
458
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
459
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
460
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
461
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
462
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
463
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
464
-		    //$data['verticalrate'] = $line['']; // verticale rate
465
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
466
-		    $data['emergency'] = ''; // emergency
467
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
468
-		    /*
456
+			$data = array();
457
+			$data['hex'] = $line['Icao']; // hex
458
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
459
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
460
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
461
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
462
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
463
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
464
+			//$data['verticalrate'] = $line['']; // verticale rate
465
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
466
+			$data['emergency'] = ''; // emergency
467
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
468
+			/*
469 469
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
470 470
 		    else $data['datetime'] = date('Y-m-d H:i:s');
471 471
 		    */
472
-		    $data['datetime'] = date('Y-m-d H:i:s');
473
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
474
-	    	    $data['format_source'] = 'aircraftlistjson';
475
-		    $data['id_source'] = $id_source;
476
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
477
-		    if (isset($data['datetime'])) $SI->add($data);
478
-		    unset($data);
472
+			$data['datetime'] = date('Y-m-d H:i:s');
473
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
474
+				$data['format_source'] = 'aircraftlistjson';
475
+			$data['id_source'] = $id_source;
476
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
477
+			if (isset($data['datetime'])) $SI->add($data);
478
+			unset($data);
479 479
 		}
480
-	    } else {
480
+		} else {
481 481
 		$reset = 0;
482 482
 		foreach ($all_data as $line) {
483
-		    $data = array();
484
-		    $data['hex'] = $line['hex']; // hex
485
-		    $data['ident'] = $line['flight']; // ident
486
-		    $data['altitude'] = $line['altitude']; // altitude
487
-		    $data['speed'] = $line['speed']; // speed
488
-		    $data['heading'] = $line['track']; // heading
489
-		    $data['latitude'] = $line['lat']; // lat
490
-		    $data['longitude'] = $line['lon']; // long
491
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
492
-		    $data['squawk'] = $line['squawk']; // squawk
493
-		    $data['emergency'] = ''; // emergency
494
-		    $data['datetime'] = date('Y-m-d H:i:s');
495
-	    	    $data['format_source'] = 'aircraftlistjson';
496
-    		    $data['id_source'] = $id_source;
497
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
498
-		    $SI->add($data);
499
-		    unset($data);
483
+			$data = array();
484
+			$data['hex'] = $line['hex']; // hex
485
+			$data['ident'] = $line['flight']; // ident
486
+			$data['altitude'] = $line['altitude']; // altitude
487
+			$data['speed'] = $line['speed']; // speed
488
+			$data['heading'] = $line['track']; // heading
489
+			$data['latitude'] = $line['lat']; // lat
490
+			$data['longitude'] = $line['lon']; // long
491
+			$data['verticalrate'] = $line['vrt']; // verticale rate
492
+			$data['squawk'] = $line['squawk']; // squawk
493
+			$data['emergency'] = ''; // emergency
494
+			$data['datetime'] = date('Y-m-d H:i:s');
495
+				$data['format_source'] = 'aircraftlistjson';
496
+				$data['id_source'] = $id_source;
497
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
498
+			$SI->add($data);
499
+			unset($data);
500
+		}
500 501
 		}
501
-	    }
502
-	    }
503
-    	    //$last_exec['aircraftlistjson'] = time();
504
-    	    $last_exec[$id]['last'] = time();
505
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
506
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
507
-	    $buffer = $Common->getData($value['host']);
508
-	    $all_data = json_decode($buffer,true);
509
-	    if (isset($all_data['planes'])) {
502
+		}
503
+			//$last_exec['aircraftlistjson'] = time();
504
+			$last_exec[$id]['last'] = time();
505
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
506
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
507
+		$buffer = $Common->getData($value['host']);
508
+		$all_data = json_decode($buffer,true);
509
+		if (isset($all_data['planes'])) {
510 510
 		$reset = 0;
511 511
 		foreach ($all_data['planes'] as $key => $line) {
512
-		    $data = array();
513
-		    $data['hex'] = $key; // hex
514
-		    $data['ident'] = $line[3]; // ident
515
-		    $data['altitude'] = $line[6]; // altitude
516
-		    $data['speed'] = $line[8]; // speed
517
-		    $data['heading'] = $line[7]; // heading
518
-		    $data['latitude'] = $line[4]; // lat
519
-		    $data['longitude'] = $line[5]; // long
520
-		    //$data['verticalrate'] = $line[]; // verticale rate
521
-		    $data['squawk'] = $line[10]; // squawk
522
-		    $data['emergency'] = ''; // emergency
523
-		    $data['registration'] = $line[2];
524
-		    $data['aircraft_icao'] = $line[0];
525
-		    $deparr = explode('-',$line[1]);
526
-		    if (count($deparr) == 2) {
512
+			$data = array();
513
+			$data['hex'] = $key; // hex
514
+			$data['ident'] = $line[3]; // ident
515
+			$data['altitude'] = $line[6]; // altitude
516
+			$data['speed'] = $line[8]; // speed
517
+			$data['heading'] = $line[7]; // heading
518
+			$data['latitude'] = $line[4]; // lat
519
+			$data['longitude'] = $line[5]; // long
520
+			//$data['verticalrate'] = $line[]; // verticale rate
521
+			$data['squawk'] = $line[10]; // squawk
522
+			$data['emergency'] = ''; // emergency
523
+			$data['registration'] = $line[2];
524
+			$data['aircraft_icao'] = $line[0];
525
+			$deparr = explode('-',$line[1]);
526
+			if (count($deparr) == 2) {
527 527
 			$data['departure_airport_icao'] = $deparr[0];
528 528
 			$data['arrival_airport_icao'] = $deparr[1];
529
-		    }
530
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
531
-	    	    $data['format_source'] = 'planeupdatefaa';
532
-    		    $data['id_source'] = $id_source;
533
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
534
-		    $SI->add($data);
535
-		    unset($data);
529
+			}
530
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
531
+				$data['format_source'] = 'planeupdatefaa';
532
+				$data['id_source'] = $id_source;
533
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
534
+			$SI->add($data);
535
+			unset($data);
536
+		}
536 537
 		}
537
-	    }
538
-    	    //$last_exec['planeupdatefaa'] = time();
539
-    	    $last_exec[$id]['last'] = time();
540
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
541
-	    $buffer = $Common->getData($value['host']);
542
-	    $all_data = json_decode($buffer,true);
543
-	    if (isset($all_data['states'])) {
538
+			//$last_exec['planeupdatefaa'] = time();
539
+			$last_exec[$id]['last'] = time();
540
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
541
+		$buffer = $Common->getData($value['host']);
542
+		$all_data = json_decode($buffer,true);
543
+		if (isset($all_data['states'])) {
544 544
 		$reset = 0;
545 545
 		foreach ($all_data['states'] as $key => $line) {
546
-		    $data = array();
547
-		    $data['hex'] = $line[0]; // hex
548
-		    $data['ident'] = trim($line[1]); // ident
549
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
550
-		    $data['speed'] = round($line[9]*1.94384); // speed
551
-		    $data['heading'] = round($line[10]); // heading
552
-		    $data['latitude'] = $line[5]; // lat
553
-		    $data['longitude'] = $line[6]; // long
554
-		    $data['verticalrate'] = $line[11]; // verticale rate
555
-		    //$data['squawk'] = $line[10]; // squawk
556
-		    //$data['emergency'] = ''; // emergency
557
-		    //$data['registration'] = $line[2];
558
-		    //$data['aircraft_icao'] = $line[0];
559
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
560
-	    	    $data['format_source'] = 'opensky';
561
-    		    $data['id_source'] = $id_source;
562
-		    $SI->add($data);
563
-		    unset($data);
546
+			$data = array();
547
+			$data['hex'] = $line[0]; // hex
548
+			$data['ident'] = trim($line[1]); // ident
549
+			$data['altitude'] = round($line[7]*3.28084); // altitude
550
+			$data['speed'] = round($line[9]*1.94384); // speed
551
+			$data['heading'] = round($line[10]); // heading
552
+			$data['latitude'] = $line[5]; // lat
553
+			$data['longitude'] = $line[6]; // long
554
+			$data['verticalrate'] = $line[11]; // verticale rate
555
+			//$data['squawk'] = $line[10]; // squawk
556
+			//$data['emergency'] = ''; // emergency
557
+			//$data['registration'] = $line[2];
558
+			//$data['aircraft_icao'] = $line[0];
559
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
560
+				$data['format_source'] = 'opensky';
561
+				$data['id_source'] = $id_source;
562
+			$SI->add($data);
563
+			unset($data);
564
+		}
564 565
 		}
565
-	    }
566
-    	    //$last_exec['planeupdatefaa'] = time();
567
-    	    $last_exec[$id]['last'] = time();
568
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
569
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
570
-	    //$buffer = $Common->getData($hosts[$id]);
571
-	    $buffer = $Common->getData($value['host']);
572
-	    $all_data = json_decode($buffer,true);
573
-	    if (!empty($all_data)) $reset = 0;
574
-	    foreach ($all_data as $key => $line) {
566
+			//$last_exec['planeupdatefaa'] = time();
567
+			$last_exec[$id]['last'] = time();
568
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
569
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
570
+		//$buffer = $Common->getData($hosts[$id]);
571
+		$buffer = $Common->getData($value['host']);
572
+		$all_data = json_decode($buffer,true);
573
+		if (!empty($all_data)) $reset = 0;
574
+		foreach ($all_data as $key => $line) {
575 575
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
576
-		    $data = array();
577
-		    $data['hex'] = $line[0];
578
-		    $data['ident'] = $line[16]; //$line[13]
579
-	    	    $data['altitude'] = $line[4]; // altitude
580
-	    	    $data['speed'] = $line[5]; // speed
581
-	    	    $data['heading'] = $line[3]; // heading
582
-	    	    $data['latitude'] = $line[1]; // lat
583
-	    	    $data['longitude'] = $line[2]; // long
584
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
585
-	    	    $data['squawk'] = $line[6]; // squawk
586
-	    	    $data['aircraft_icao'] = $line[8];
587
-	    	    $data['registration'] = $line[9];
588
-		    $data['departure_airport_iata'] = $line[11];
589
-		    $data['arrival_airport_iata'] = $line[12];
590
-	    	    $data['emergency'] = ''; // emergency
591
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
592
-	    	    $data['format_source'] = 'fr24json';
593
-    		    $data['id_source'] = $id_source;
594
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
595
-		    $SI->add($data);
596
-		    unset($data);
576
+			$data = array();
577
+			$data['hex'] = $line[0];
578
+			$data['ident'] = $line[16]; //$line[13]
579
+				$data['altitude'] = $line[4]; // altitude
580
+				$data['speed'] = $line[5]; // speed
581
+				$data['heading'] = $line[3]; // heading
582
+				$data['latitude'] = $line[1]; // lat
583
+				$data['longitude'] = $line[2]; // long
584
+				$data['verticalrate'] = $line[15]; // verticale rate
585
+				$data['squawk'] = $line[6]; // squawk
586
+				$data['aircraft_icao'] = $line[8];
587
+				$data['registration'] = $line[9];
588
+			$data['departure_airport_iata'] = $line[11];
589
+			$data['arrival_airport_iata'] = $line[12];
590
+				$data['emergency'] = ''; // emergency
591
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
592
+				$data['format_source'] = 'fr24json';
593
+				$data['id_source'] = $id_source;
594
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
595
+			$SI->add($data);
596
+			unset($data);
597
+		}
597 598
 		}
598
-	    }
599
-    	    //$last_exec['fr24json'] = time();
600
-    	    $last_exec[$id]['last'] = time();
601
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
602
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
603
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
604
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
605
-	    //echo $buffer;
606
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
607
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
608
-	    $all_data = json_decode($buffer,true);
609
-	    if (json_last_error() != JSON_ERROR_NONE) {
599
+			//$last_exec['fr24json'] = time();
600
+			$last_exec[$id]['last'] = time();
601
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
602
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
603
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
604
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
605
+		//echo $buffer;
606
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
607
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
608
+		$all_data = json_decode($buffer,true);
609
+		if (json_last_error() != JSON_ERROR_NONE) {
610 610
 		die(json_last_error_msg());
611
-	    }
612
-	    if (isset($all_data['mrkrs'])) {
611
+		}
612
+		if (isset($all_data['mrkrs'])) {
613 613
 		$reset = 0;
614 614
 		foreach ($all_data['mrkrs'] as $key => $line) {
615
-		    if (isset($line['inf'])) {
615
+			if (isset($line['inf'])) {
616 616
 			$data = array();
617 617
 			$data['hex'] = $line['inf']['ia'];
618 618
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
619
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
620
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
621
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
622
-	    		$data['latitude'] = $line['pt'][0]; // lat
623
-	    		$data['longitude'] = $line['pt'][1]; // long
624
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
625
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
626
-	    		//$data['aircraft_icao'] = $line[8];
627
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
619
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
620
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
621
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
622
+				$data['latitude'] = $line['pt'][0]; // lat
623
+				$data['longitude'] = $line['pt'][1]; // long
624
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
625
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
626
+				//$data['aircraft_icao'] = $line[8];
627
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
628 628
 			//$data['departure_airport_iata'] = $line[11];
629 629
 			//$data['arrival_airport_iata'] = $line[12];
630
-	    		//$data['emergency'] = ''; // emergency
630
+				//$data['emergency'] = ''; // emergency
631 631
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
632
-	    		$data['format_source'] = 'radarvirtueljson';
633
-    			$data['id_source'] = $id_source;
632
+				$data['format_source'] = 'radarvirtueljson';
633
+				$data['id_source'] = $id_source;
634 634
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
635 635
 			$SI->add($data);
636 636
 			unset($data);
637
-		    }
637
+			}
638
+		}
638 639
 		}
639
-	    }
640
-    	    //$last_exec['radarvirtueljson'] = time();
641
-    	    $last_exec[$id]['last'] = time();
642
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
643
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
644
-	    //$buffer = $Common->getData($hosts[$id]);
645
-	    $buffer = $Common->getData($value['host'].'?'.time());
646
-	    $all_data = json_decode(utf8_encode($buffer),true);
640
+			//$last_exec['radarvirtueljson'] = time();
641
+			$last_exec[$id]['last'] = time();
642
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
643
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
644
+		//$buffer = $Common->getData($hosts[$id]);
645
+		$buffer = $Common->getData($value['host'].'?'.time());
646
+		$all_data = json_decode(utf8_encode($buffer),true);
647 647
 	    
648
-	    if (isset($all_data['pireps'])) {
648
+		if (isset($all_data['pireps'])) {
649 649
 		$reset = 0;
650
-	        foreach ($all_data['pireps'] as $line) {
651
-		    $data = array();
652
-		    $data['id'] = $line['id'];
653
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
654
-		    $data['ident'] = $line['callsign']; // ident
655
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
656
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
657
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
658
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
659
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
660
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
661
-		    $data['latitude'] = $line['lat']; // lat
662
-		    $data['longitude'] = $line['lon']; // long
663
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
664
-		    //$data['squawk'] = $line['squawk']; // squawk
665
-		    //$data['emergency'] = ''; // emergency
666
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
667
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
668
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
669
-		    //$data['arrival_airport_time'] = $line['arrtime'];
670
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
671
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
672
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
673
-		    else $data['info'] = '';
674
-		    $data['format_source'] = 'pireps';
675
-    		    $data['id_source'] = $id_source;
676
-		    $data['datetime'] = date('Y-m-d H:i:s');
677
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
678
-		    if ($line['icon'] == 'plane') {
650
+			foreach ($all_data['pireps'] as $line) {
651
+			$data = array();
652
+			$data['id'] = $line['id'];
653
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
654
+			$data['ident'] = $line['callsign']; // ident
655
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
656
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
657
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
658
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
659
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
660
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
661
+			$data['latitude'] = $line['lat']; // lat
662
+			$data['longitude'] = $line['lon']; // long
663
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
664
+			//$data['squawk'] = $line['squawk']; // squawk
665
+			//$data['emergency'] = ''; // emergency
666
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
667
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
668
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
669
+			//$data['arrival_airport_time'] = $line['arrtime'];
670
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
671
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
672
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
673
+			else $data['info'] = '';
674
+			$data['format_source'] = 'pireps';
675
+				$data['id_source'] = $id_source;
676
+			$data['datetime'] = date('Y-m-d H:i:s');
677
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
678
+			if ($line['icon'] == 'plane') {
679 679
 			$SI->add($data);
680
-		    //    print_r($data);
681
-    		    } elseif ($line['icon'] == 'ct') {
680
+			//    print_r($data);
681
+				} elseif ($line['icon'] == 'ct') {
682 682
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
683 683
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
684 684
 			$typec = substr($data['ident'],-3);
@@ -693,163 +693,163 @@  discard block
 block discarded – undo
693 693
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
694 694
 			else $data['type'] = 'Observer';
695 695
 			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
696
-		    }
697
-		    unset($data);
696
+			}
697
+			unset($data);
698
+		}
698 699
 		}
699
-	    }
700
-    	    //$last_exec['pirepsjson'] = time();
701
-    	    $last_exec[$id]['last'] = time();
702
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
703
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
704
-	    //$buffer = $Common->getData($hosts[$id]);
705
-	    if ($globalDebug) echo 'Get Data...'."\n";
706
-	    $buffer = $Common->getData($value['host']);
707
-	    $all_data = json_decode($buffer,true);
708
-	    if ($buffer != '' && is_array($all_data)) {
700
+			//$last_exec['pirepsjson'] = time();
701
+			$last_exec[$id]['last'] = time();
702
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
703
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
704
+		//$buffer = $Common->getData($hosts[$id]);
705
+		if ($globalDebug) echo 'Get Data...'."\n";
706
+		$buffer = $Common->getData($value['host']);
707
+		$all_data = json_decode($buffer,true);
708
+		if ($buffer != '' && is_array($all_data)) {
709 709
 		$reset = 0;
710 710
 		foreach ($all_data as $line) {
711
-	    	    $data = array();
712
-	    	    //$data['id'] = $line['id']; // id not usable
713
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
714
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
715
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
716
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
717
-	    	    $data['ident'] = $line['flightnum']; // ident
718
-	    	    $data['altitude'] = $line['alt']; // altitude
719
-	    	    $data['speed'] = $line['gs']; // speed
720
-	    	    $data['heading'] = $line['heading']; // heading
721
-	    	    $data['latitude'] = $line['lat']; // lat
722
-	    	    $data['longitude'] = $line['lng']; // long
723
-	    	    $data['verticalrate'] = ''; // verticale rate
724
-	    	    $data['squawk'] = ''; // squawk
725
-	    	    $data['emergency'] = ''; // emergency
726
-	    	    //$data['datetime'] = $line['lastupdate'];
727
-	    	    $data['last_update'] = $line['lastupdate'];
728
-		    $data['datetime'] = date('Y-m-d H:i:s');
729
-	    	    $data['departure_airport_icao'] = $line['depicao'];
730
-	    	    $data['departure_airport_time'] = $line['deptime'];
731
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
732
-    		    $data['arrival_airport_time'] = $line['arrtime'];
733
-    		    $data['registration'] = $line['aircraft'];
734
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
735
-		    if (isset($line['aircraftname'])) {
711
+				$data = array();
712
+				//$data['id'] = $line['id']; // id not usable
713
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
714
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
715
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
716
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
717
+				$data['ident'] = $line['flightnum']; // ident
718
+				$data['altitude'] = $line['alt']; // altitude
719
+				$data['speed'] = $line['gs']; // speed
720
+				$data['heading'] = $line['heading']; // heading
721
+				$data['latitude'] = $line['lat']; // lat
722
+				$data['longitude'] = $line['lng']; // long
723
+				$data['verticalrate'] = ''; // verticale rate
724
+				$data['squawk'] = ''; // squawk
725
+				$data['emergency'] = ''; // emergency
726
+				//$data['datetime'] = $line['lastupdate'];
727
+				$data['last_update'] = $line['lastupdate'];
728
+			$data['datetime'] = date('Y-m-d H:i:s');
729
+				$data['departure_airport_icao'] = $line['depicao'];
730
+				$data['departure_airport_time'] = $line['deptime'];
731
+				$data['arrival_airport_icao'] = $line['arricao'];
732
+				$data['arrival_airport_time'] = $line['arrtime'];
733
+				$data['registration'] = $line['aircraft'];
734
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
735
+			if (isset($line['aircraftname'])) {
736 736
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
737 737
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
738
-	    		$aircraft_data = explode('-',$line['aircraftname']);
739
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
740
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
741
-	    		else {
742
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
743
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
744
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
745
-	    		}
746
-	    	    }
747
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
748
-    		    $data['id_source'] = $id_source;
749
-	    	    $data['format_source'] = 'phpvmacars';
750
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
751
-		    $SI->add($data);
752
-		    unset($data);
738
+				$aircraft_data = explode('-',$line['aircraftname']);
739
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
740
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
741
+				else {
742
+					$aircraft_data = explode(' ',$line['aircraftname']);
743
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
744
+					else $data['aircraft_icao'] = $line['aircraftname'];
745
+				}
746
+				}
747
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
748
+				$data['id_source'] = $id_source;
749
+				$data['format_source'] = 'phpvmacars';
750
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
751
+			$SI->add($data);
752
+			unset($data);
753 753
 		}
754 754
 		if ($globalDebug) echo 'No more data...'."\n";
755 755
 		unset($buffer);
756 756
 		unset($all_data);
757
-	    }
758
-    	    //$last_exec['phpvmacars'] = time();
759
-    	    $last_exec[$id]['last'] = time();
760
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
761
-	    //$buffer = $Common->getData($hosts[$id]);
762
-	    if ($globalDebug) echo 'Get Data...'."\n";
763
-	    $buffer = $Common->getData($value['host']);
764
-	    $all_data = json_decode($buffer,true);
765
-	    if ($buffer != '' && is_array($all_data)) {
757
+		}
758
+			//$last_exec['phpvmacars'] = time();
759
+			$last_exec[$id]['last'] = time();
760
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
761
+		//$buffer = $Common->getData($hosts[$id]);
762
+		if ($globalDebug) echo 'Get Data...'."\n";
763
+		$buffer = $Common->getData($value['host']);
764
+		$all_data = json_decode($buffer,true);
765
+		if ($buffer != '' && is_array($all_data)) {
766 766
 		$reset = 0;
767 767
 		foreach ($all_data as $line) {
768
-	    	    $data = array();
769
-	    	    //$data['id'] = $line['id']; // id not usable
770
-	    	    $data['id'] = trim($line['flight_id']);
771
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
772
-	    	    $data['pilot_name'] = $line['pilot_name'];
773
-	    	    $data['pilot_id'] = $line['pilot_id'];
774
-	    	    $data['ident'] = trim($line['callsign']); // ident
775
-	    	    $data['altitude'] = $line['altitude']; // altitude
776
-	    	    $data['speed'] = $line['gs']; // speed
777
-	    	    $data['heading'] = $line['heading']; // heading
778
-	    	    $data['latitude'] = $line['latitude']; // lat
779
-	    	    $data['longitude'] = $line['longitude']; // long
780
-	    	    $data['verticalrate'] = ''; // verticale rate
781
-	    	    $data['squawk'] = ''; // squawk
782
-	    	    $data['emergency'] = ''; // emergency
783
-	    	    //$data['datetime'] = $line['lastupdate'];
784
-	    	    $data['last_update'] = $line['last_update'];
785
-		    $data['datetime'] = date('Y-m-d H:i:s');
786
-	    	    $data['departure_airport_icao'] = $line['departure'];
787
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
788
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
789
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
790
-    		    //$data['registration'] = $line['aircraft'];
791
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
792
-	    	    $data['aircraft_icao'] = $line['plane_type'];
793
-    		    $data['id_source'] = $id_source;
794
-	    	    $data['format_source'] = 'vam';
795
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
796
-		    $SI->add($data);
797
-		    unset($data);
768
+				$data = array();
769
+				//$data['id'] = $line['id']; // id not usable
770
+				$data['id'] = trim($line['flight_id']);
771
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
772
+				$data['pilot_name'] = $line['pilot_name'];
773
+				$data['pilot_id'] = $line['pilot_id'];
774
+				$data['ident'] = trim($line['callsign']); // ident
775
+				$data['altitude'] = $line['altitude']; // altitude
776
+				$data['speed'] = $line['gs']; // speed
777
+				$data['heading'] = $line['heading']; // heading
778
+				$data['latitude'] = $line['latitude']; // lat
779
+				$data['longitude'] = $line['longitude']; // long
780
+				$data['verticalrate'] = ''; // verticale rate
781
+				$data['squawk'] = ''; // squawk
782
+				$data['emergency'] = ''; // emergency
783
+				//$data['datetime'] = $line['lastupdate'];
784
+				$data['last_update'] = $line['last_update'];
785
+			$data['datetime'] = date('Y-m-d H:i:s');
786
+				$data['departure_airport_icao'] = $line['departure'];
787
+				//$data['departure_airport_time'] = $line['departure_time'];
788
+				$data['arrival_airport_icao'] = $line['arrival'];
789
+				//$data['arrival_airport_time'] = $line['arrival_time'];
790
+				//$data['registration'] = $line['aircraft'];
791
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
792
+				$data['aircraft_icao'] = $line['plane_type'];
793
+				$data['id_source'] = $id_source;
794
+				$data['format_source'] = 'vam';
795
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
796
+			$SI->add($data);
797
+			unset($data);
798 798
 		}
799 799
 		if ($globalDebug) echo 'No more data...'."\n";
800 800
 		unset($buffer);
801 801
 		unset($all_data);
802
-	    }
803
-    	    //$last_exec['phpvmacars'] = time();
804
-    	    $last_exec[$id]['last'] = time();
802
+		}
803
+			//$last_exec['phpvmacars'] = time();
804
+			$last_exec[$id]['last'] = time();
805 805
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
806 806
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') {
807
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
808
-    	    //$last_exec[$id]['last'] = time();
807
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
808
+			//$last_exec[$id]['last'] = time();
809 809
 
810
-	    //$read = array( $sockets[$id] );
811
-	    $read = $sockets;
812
-	    $write = NULL;
813
-	    $e = NULL;
814
-	    $n = socket_select($read, $write, $e, $timeout);
815
-	    if ($e != NULL) var_dump($e);
816
-	    if ($n > 0) {
810
+		//$read = array( $sockets[$id] );
811
+		$read = $sockets;
812
+		$write = NULL;
813
+		$e = NULL;
814
+		$n = socket_select($read, $write, $e, $timeout);
815
+		if ($e != NULL) var_dump($e);
816
+		if ($n > 0) {
817 817
 		$reset = 0;
818 818
 		foreach ($read as $nb => $r) {
819
-		    //$value = $formats[$nb];
820
-		    $format = $globalSources[$nb]['format'];
821
-        	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
822
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
823
-        	    } else {
824
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
825
-	    	    }
826
-        	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
827
-        	    //echo $buffer."\n";
828
-		    // lets play nice and handle signals such as ctrl-c/kill properly
829
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
830
-		    $error = false;
831
-		    //$SI::del();
832
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
833
-		    // SBS format is CSV format
834
-		    if ($buffer != '') {
819
+			//$value = $formats[$nb];
820
+			$format = $globalSources[$nb]['format'];
821
+				if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
822
+				$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
823
+				} else {
824
+					$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
825
+				}
826
+				//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
827
+				//echo $buffer."\n";
828
+			// lets play nice and handle signals such as ctrl-c/kill properly
829
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
830
+			$error = false;
831
+			//$SI::del();
832
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
833
+			// SBS format is CSV format
834
+			if ($buffer != '') {
835 835
 			$tt[$format] = 0;
836 836
 			if ($format == 'acarssbs3') {
837
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
838
-			    $ACARS->add(trim($buffer));
839
-			    $ACARS->deleteLiveAcarsData();
837
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
838
+				$ACARS->add(trim($buffer));
839
+				$ACARS->deleteLiveAcarsData();
840 840
 			} elseif ($format == 'raw') {
841
-			    // AVR format
842
-			    $data = $SBS->parse($buffer);
843
-			    if (is_array($data)) {
841
+				// AVR format
842
+				$data = $SBS->parse($buffer);
843
+				if (is_array($data)) {
844 844
 				$data['datetime'] = date('Y-m-d H:i:s');
845 845
 				$data['format_source'] = 'raw';
846 846
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
847
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
848
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
849
-                            }
850
-                        } elseif ($format == 'flightgearsp') {
851
-                    	    //echo $buffer."\n";
852
-                    	    if (strlen($buffer) > 5) {
847
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
848
+								if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
849
+							}
850
+						} elseif ($format == 'flightgearsp') {
851
+							//echo $buffer."\n";
852
+							if (strlen($buffer) > 5) {
853 853
 				$line = explode(',',$buffer);
854 854
 				$data = array();
855 855
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -865,114 +865,114 @@  discard block
 block discarded – undo
865 865
 				$data['format_source'] = 'flightgearsp';
866 866
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
867 867
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
868
-			    }
869
-                        } elseif ($format == 'acars') {
870
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
871
-			    $ACARS->add(trim($buffer));
872
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
873
-			    $ACARS->deleteLiveAcarsData();
868
+				}
869
+						} elseif ($format == 'acars') {
870
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
871
+				$ACARS->add(trim($buffer));
872
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
873
+				$ACARS->deleteLiveAcarsData();
874 874
 			} elseif ($format == 'flightgearmp') {
875
-			    if (substr($buffer,0,1) != '#') {
875
+				if (substr($buffer,0,1) != '#') {
876 876
 				$data = array();
877 877
 				//echo $buffer."\n";
878 878
 				$line = explode(' ',$buffer);
879 879
 				if (count($line) == 11) {
880
-				    $userserver = explode('@',$line[0]);
881
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
882
-				    $data['ident'] = $userserver[0];
883
-				    $data['registration'] = $userserver[0];
884
-				    $data['latitude'] = $line[4];
885
-				    $data['longitude'] = $line[5];
886
-				    $data['altitude'] = $line[6];
887
-				    $data['datetime'] = date('Y-m-d H:i:s');
888
-				    $aircraft_type = $line[10];
889
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
890
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
891
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
880
+					$userserver = explode('@',$line[0]);
881
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
882
+					$data['ident'] = $userserver[0];
883
+					$data['registration'] = $userserver[0];
884
+					$data['latitude'] = $line[4];
885
+					$data['longitude'] = $line[5];
886
+					$data['altitude'] = $line[6];
887
+					$data['datetime'] = date('Y-m-d H:i:s');
888
+					$aircraft_type = $line[10];
889
+					$aircraft_type = preg_split(':/:',$aircraft_type);
890
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
891
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
892
+				}
892 893
 				}
893
-			    }
894 894
 			} elseif ($format == 'beast') {
895
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
896
-			    die;
895
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
896
+				die;
897 897
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
898
-			    $line = explode("\t", $buffer);
899
-			    for($k = 0; $k < count($line); $k=$k+2) {
898
+				$line = explode("\t", $buffer);
899
+				for($k = 0; $k < count($line); $k=$k+2) {
900 900
 				$key = $line[$k];
901
-			        $lined[$key] = $line[$k+1];
902
-			    }
903
-    			    if (count($lined) > 3) {
904
-    				$data['hex'] = $lined['hexid'];
905
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
906
-    				$data['datetime'] = date('Y-m-d H:i:s');;
907
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
908
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
909
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
910
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
911
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
912
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
913
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
914
-    				$data['id_source'] = $id_source;
915
-    				$data['format_source'] = 'tsv';
916
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
917
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
918
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
919
-    				unset($lined);
920
-    				unset($data);
921
-    			    } else $error = true;
901
+					$lined[$key] = $line[$k+1];
902
+				}
903
+					if (count($lined) > 3) {
904
+					$data['hex'] = $lined['hexid'];
905
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
906
+					$data['datetime'] = date('Y-m-d H:i:s');;
907
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
908
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
909
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
910
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
911
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
912
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
913
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
914
+					$data['id_source'] = $id_source;
915
+					$data['format_source'] = 'tsv';
916
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
917
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
918
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
919
+					unset($lined);
920
+					unset($data);
921
+					} else $error = true;
922 922
 			} elseif ($format == 'aprs' && $use_aprs) {
923
-			    if ($aprs_connect == 0) {
923
+				if ($aprs_connect == 0) {
924 924
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
925 925
 				$aprs_connect = 1;
926
-			    }
927
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
926
+				}
927
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
928 928
 				$aprs_last_tx = time();
929 929
 				$data_aprs = "# Keep alive";
930 930
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
931
-			    }
932
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
933
-			    $buffer = str_replace('APRS <- ','',$buffer);
934
-			    $buffer = str_replace('APRS -> ','',$buffer);
935
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
931
+				}
932
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
933
+				$buffer = str_replace('APRS <- ','',$buffer);
934
+				$buffer = str_replace('APRS -> ','',$buffer);
935
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
936 936
 				$line = $APRS->parse($buffer);
937 937
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
938
-				    $data = array();
939
-				    //print_r($line);
940
-				    $data['hex'] = $line['address'];
941
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
942
-				    //$data['datetime'] = date('Y-m-d H:i:s');
943
-				    $data['ident'] = $line['ident'];
944
-				    $data['latitude'] = $line['latitude'];
945
-				    $data['longitude'] = $line['longitude'];
946
-				    //$data['verticalrate'] = $line[16];
947
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
948
-				    else $data['speed'] = 0;
949
-				    $data['altitude'] = $line['altitude'];
950
-				    if (isset($line['course'])) $data['heading'] = $line['course'];
951
-				    //else $data['heading'] = 0;
952
-				    $data['aircraft_type'] = $line['stealth'];
953
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
954
-    				    $data['id_source'] = $id_source;
955
-				    $data['format_source'] = 'aprs';
956
-				    $data['source_name'] = $line['source'];
957
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
958
-				    $currentdate = date('Y-m-d H:i:s');
959
-				    $aprsdate = strtotime($data['datetime']);
960
-				    // Accept data if time <= system time + 20s
961
-				    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);
962
-				    else {
938
+					$data = array();
939
+					//print_r($line);
940
+					$data['hex'] = $line['address'];
941
+					$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
942
+					//$data['datetime'] = date('Y-m-d H:i:s');
943
+					$data['ident'] = $line['ident'];
944
+					$data['latitude'] = $line['latitude'];
945
+					$data['longitude'] = $line['longitude'];
946
+					//$data['verticalrate'] = $line[16];
947
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
948
+					else $data['speed'] = 0;
949
+					$data['altitude'] = $line['altitude'];
950
+					if (isset($line['course'])) $data['heading'] = $line['course'];
951
+					//else $data['heading'] = 0;
952
+					$data['aircraft_type'] = $line['stealth'];
953
+					if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
954
+						$data['id_source'] = $id_source;
955
+					$data['format_source'] = 'aprs';
956
+					$data['source_name'] = $line['source'];
957
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
958
+					$currentdate = date('Y-m-d H:i:s');
959
+					$aprsdate = strtotime($data['datetime']);
960
+					// Accept data if time <= system time + 20s
961
+					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);
962
+					else {
963 963
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
964 964
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
965
-				    }
966
-				    unset($data);
965
+					}
966
+					unset($data);
967 967
 				} 
968 968
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
969 969
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
970
-			    }
970
+				}
971 971
 			} else {
972
-			    $line = explode(',', $buffer);
973
-    			    if (count($line) > 20) {
974
-    			    	$data['hex'] = $line[4];
975
-    				/*
972
+				$line = explode(',', $buffer);
973
+					if (count($line) > 20) {
974
+						$data['hex'] = $line[4];
975
+					/*
976 976
     				$data['datetime'] = $line[6].' '.$line[7];
977 977
     					date_default_timezone_set($globalTimezone);
978 978
     					$datetime = new DateTime($data['datetime']);
@@ -980,29 +980,29 @@  discard block
 block discarded – undo
980 980
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
981 981
     					date_default_timezone_set('UTC');
982 982
     				*/
983
-    				// Force datetime to current UTC datetime
984
-    				date_default_timezone_set('UTC');
985
-    				$data['datetime'] = date('Y-m-d H:i:s');
986
-    				$data['ident'] = trim($line[10]);
987
-    				$data['latitude'] = $line[14];
988
-    				$data['longitude'] = $line[15];
989
-    				$data['verticalrate'] = $line[16];
990
-    				$data['emergency'] = $line[20];
991
-    				$data['speed'] = $line[12];
992
-    				$data['squawk'] = $line[17];
993
-    				$data['altitude'] = $line[11];
994
-    				$data['heading'] = $line[13];
995
-    				$data['ground'] = $line[21];
996
-    				$data['emergency'] = $line[19];
997
-    				$data['format_source'] = 'sbs';
983
+					// Force datetime to current UTC datetime
984
+					date_default_timezone_set('UTC');
985
+					$data['datetime'] = date('Y-m-d H:i:s');
986
+					$data['ident'] = trim($line[10]);
987
+					$data['latitude'] = $line[14];
988
+					$data['longitude'] = $line[15];
989
+					$data['verticalrate'] = $line[16];
990
+					$data['emergency'] = $line[20];
991
+					$data['speed'] = $line[12];
992
+					$data['squawk'] = $line[17];
993
+					$data['altitude'] = $line[11];
994
+					$data['heading'] = $line[13];
995
+					$data['ground'] = $line[21];
996
+					$data['emergency'] = $line[19];
997
+					$data['format_source'] = 'sbs';
998 998
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
999
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1000
-    				$data['id_source'] = $id_source;
1001
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1002
-    				else $error = true;
1003
-    				unset($data);
1004
-    			    } else $error = true;
1005
-			    if ($error) {
999
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1000
+					$data['id_source'] = $id_source;
1001
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1002
+					else $error = true;
1003
+					unset($data);
1004
+					} else $error = true;
1005
+				if ($error) {
1006 1006
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1007 1007
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1008 1008
 				} else {
@@ -1018,13 +1018,13 @@  discard block
 block discarded – undo
1018 1018
 					connect_all($sourceer);
1019 1019
 					$sourceer = array();
1020 1020
 				}
1021
-			    }
1021
+				}
1022 1022
 			}
1023 1023
 			// Sleep for xxx microseconds
1024 1024
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1025
-		    } else {
1025
+			} else {
1026 1026
 			if ($format == 'flightgearmp') {
1027
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1027
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1028 1028
 				//@socket_close($r);
1029 1029
 				sleep($globalMinFetch);
1030 1030
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1033,9 +1033,9 @@  discard block
 block discarded – undo
1033 1033
 				break;
1034 1034
 				
1035 1035
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1036
-			    if (isset($tt[$format])) $tt[$format]++;
1037
-			    else $tt[$format] = 0;
1038
-			    if ($tt[$format] > 30) {
1036
+				if (isset($tt[$format])) $tt[$format]++;
1037
+				else $tt[$format] = 0;
1038
+				if ($tt[$format] > 30) {
1039 1039
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1040 1040
 				//@socket_close($r);
1041 1041
 				sleep(2);
@@ -1046,23 +1046,23 @@  discard block
 block discarded – undo
1046 1046
 				//connect_all($globalSources);
1047 1047
 				$tt[$format]=0;
1048 1048
 				break;
1049
-			    }
1049
+				}
1050
+			}
1050 1051
 			}
1051
-		    }
1052 1052
 		}
1053
-	    } else {
1053
+		} else {
1054 1054
 		$error = socket_strerror(socket_last_error());
1055 1055
 		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1056 1056
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1057 1057
 			if (isset($globalDebug)) echo "Restarting...\n";
1058 1058
 			// Restart the script if possible
1059 1059
 			if (is_array($sockets)) {
1060
-			    if ($globalDebug) echo "Shutdown all sockets...";
1060
+				if ($globalDebug) echo "Shutdown all sockets...";
1061 1061
 			    
1062
-			    foreach ($sockets as $sock) {
1062
+				foreach ($sockets as $sock) {
1063 1063
 				@socket_shutdown($sock,2);
1064 1064
 				@socket_close($sock);
1065
-			    }
1065
+				}
1066 1066
 			    
1067 1067
 			}
1068 1068
 			if ($globalDebug) echo "Restart all connections...";
@@ -1073,13 +1073,13 @@  discard block
 block discarded – undo
1073 1073
 			if ($reset > 40) exit('Too many attempts...');
1074 1074
 			connect_all($globalSources);
1075 1075
 		}
1076
-	    }
1076
+		}
1077 1077
 	}
1078 1078
 	if ($globalDaemon === false) {
1079
-	    if ($globalDebug) echo 'Check all...'."\n";
1080
-	    $SI->checkAll();
1079
+		if ($globalDebug) echo 'Check all...'."\n";
1080
+		$SI->checkAll();
1081
+	}
1081 1082
 	}
1082
-    }
1083 1083
 }
1084 1084
 
1085 1085
 ?>
Please login to merge, or discard this patch.
owner-statistics-aircraft.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 if (!isset($_GET['owner'])) {
6
-        header('Location: '.$globalURL.'/owner');
7
-        die();
6
+		header('Location: '.$globalURL.'/owner');
7
+		die();
8 8
 }
9 9
 $Spotter = new Spotter();
10 10
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.