Completed
Push — master ( bd938e...e4cf93 )
by Yannick
08:57
created
live-geojson.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -5,23 +5,23 @@  discard block
 block discarded – undo
5 5
 $marine = false;
6 6
 $usecoord = false;
7 7
 if (isset($_GET['tracker'])) {
8
-    $tracker = true;
8
+	$tracker = true;
9 9
 }
10 10
 if (isset($_GET['marine'])) {
11
-    $marine = true;
11
+	$marine = true;
12 12
 }
13 13
 if ($tracker) {
14
-    require_once('require/class.Tracker.php');
15
-    require_once('require/class.TrackerLive.php');
16
-    //require_once('require/class.TrackerArchive.php');
14
+	require_once('require/class.Tracker.php');
15
+	require_once('require/class.TrackerLive.php');
16
+	//require_once('require/class.TrackerArchive.php');
17 17
 } elseif ($marine) {
18
-    require_once('require/class.Marine.php');
19
-    require_once('require/class.MarineLive.php');
20
-    //require_once('require/class.MarineArchive.php');
18
+	require_once('require/class.Marine.php');
19
+	require_once('require/class.MarineLive.php');
20
+	//require_once('require/class.MarineArchive.php');
21 21
 } else {
22
-    require_once('require/class.Spotter.php');
23
-    require_once('require/class.SpotterLive.php');
24
-    require_once('require/class.SpotterArchive.php');
22
+	require_once('require/class.Spotter.php');
23
+	require_once('require/class.SpotterLive.php');
24
+	require_once('require/class.SpotterArchive.php');
25 25
 }
26 26
 
27 27
 $begintime = microtime(true);
@@ -41,10 +41,10 @@  discard block
 block discarded – undo
41 41
 $Common = new Common();
42 42
 
43 43
 if (isset($_GET['download'])) {
44
-    if ($_GET['download'] == "true")
45
-    {
44
+	if ($_GET['download'] == "true")
45
+	{
46 46
 	header('Content-disposition: attachment; filename="flightairmap.json"');
47
-    }
47
+	}
48 48
 }
49 49
 header('Content-Type: text/javascript');
50 50
 
@@ -497,17 +497,17 @@  discard block
 block discarded – undo
497 497
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
498 498
 				
499 499
 				if (
500
-				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
501
-				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
500
+					(isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
501
+					|| ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
502 502
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
503 503
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
504
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
505
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
506
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
507
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
508
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
509
-				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
510
-				    ) {
504
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
505
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
506
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
507
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
508
+					|| (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
509
+					|| (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
510
+					) {
511 511
 					if ($tracker) {
512 512
 						$spotter_history_array = $TrackerLive->getAllLiveTrackerDataById($spotter_item['famtrackid']);
513 513
 					} elseif ($marine) {
@@ -592,26 +592,26 @@  discard block
 block discarded – undo
592 592
 				}
593 593
 				
594 594
 				if (isset($history) && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
595
-				    $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
596
-				    if (isset($spotter_item['departure_airport_latitude'])) {
595
+					$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
596
+					if (isset($spotter_item['departure_airport_latitude'])) {
597 597
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
598
-				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
598
+					} elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
599 599
 					$dairport = $Spotter->getAllAirportInfo($spotter_item['departure_airport']);
600 600
 					if (isset($dairport[0]['latitude'])) {
601
-					    $output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
601
+						$output_air .= '['.$dairport[0]['longitude'].','.$dairport[0]['latitude'].'],';
602 602
 					}
603
-				    }
604
-				    if (isset($spotter_item['arrival_airport_latitude'])) {
603
+					}
604
+					if (isset($spotter_item['arrival_airport_latitude'])) {
605 605
 					$output_air .= '['.$spotter_item['arrival_airport_longitude'].','.$spotter_item['arrival_airport_latitude'].']';
606
-				    } elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
606
+					} elseif (isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
607 607
 					$aairport = $Spotter->getAllAirportInfo($spotter_item['arrival_airport']);
608 608
 					if (isset($aairport[0]['latitude'])) {
609
-					    $output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
609
+						$output_air .= '['.$aairport[0]['longitude'].','.$aairport[0]['latitude'].']';
610 610
 					}
611
-				    }
612
-				    $output_air .= ']}},';
613
-				    $output .= $output_air;
614
-				    unset($output_air);
611
+					}
612
+					$output_air .= ']}},';
613
+					$output .= $output_air;
614
+					unset($output_air);
615 615
 				}
616 616
 			}
617 617
 			$output  = substr($output, 0, -1);
Please login to merge, or discard this patch.
require/class.MarineArchive.php 1 patch
Indentation   +603 added lines, -603 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 	}
10 10
 
11 11
 	/**
12
-	* Get SQL query part for filter used
13
-	* @param Array $filter the filter
14
-	* @return Array the SQL part
15
-	*/
12
+	 * Get SQL query part for filter used
13
+	 * @param Array $filter the filter
14
+	 * @return Array the SQL part
15
+	 */
16 16
 	public function getFilter($filter = array(),$where = false,$and = false) {
17 17
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 		$filters = array();
@@ -110,44 +110,44 @@  discard block
 block discarded – undo
110 110
 	}
111 111
 
112 112
 
113
-        /**
114
-        * Gets all the spotter information based on a particular callsign
115
-        *
116
-        * @return Array the spotter information
117
-        *
118
-        */
119
-        public function getLastArchiveMarineDataByIdent($ident)
120
-        {
113
+		/**
114
+		 * Gets all the spotter information based on a particular callsign
115
+		 *
116
+		 * @return Array the spotter information
117
+		 *
118
+		 */
119
+		public function getLastArchiveMarineDataByIdent($ident)
120
+		{
121 121
 		$Marine = new Marine($this->db);
122
-                date_default_timezone_set('UTC');
122
+				date_default_timezone_set('UTC');
123 123
 
124
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
125
-                //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
126
-                $query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
124
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
125
+				//$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
126
+				$query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
127 127
 
128
-                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
128
+				$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
129 129
 
130
-                return $spotter_array;
131
-        }
130
+				return $spotter_array;
131
+		}
132 132
 
133 133
 
134
-        /**
135
-        * Gets last the spotter information based on a particular id
136
-        *
137
-        * @return Array the spotter information
138
-        *
139
-        */
140
-        public function getLastArchiveMarineDataById($id)
141
-        {
142
-    		$Marine = new Marine($this->db);
143
-                date_default_timezone_set('UTC');
144
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
145
-                //$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
146
-                //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
147
-                $query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
134
+		/**
135
+		 * Gets last the spotter information based on a particular id
136
+		 *
137
+		 * @return Array the spotter information
138
+		 *
139
+		 */
140
+		public function getLastArchiveMarineDataById($id)
141
+		{
142
+			$Marine = new Marine($this->db);
143
+				date_default_timezone_set('UTC');
144
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
145
+				//$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
146
+				//$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
147
+				$query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
148 148
 
149 149
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
150
-                  /*
150
+				  /*
151 151
                 try {
152 152
                         $Connection = new Connection();
153 153
                         $sth = Connection->$db->prepare($query);
@@ -157,232 +157,232 @@  discard block
 block discarded – undo
157 157
                 }
158 158
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
159 159
                 */
160
-                $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
161
-
162
-                return $spotter_array;
163
-        }
164
-
165
-        /**
166
-        * Gets all the spotter information based on a particular id
167
-        *
168
-        * @return Array the spotter information
169
-        *
170
-        */
171
-        public function getAllArchiveMarineDataById($id)
160
+				$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
161
+
162
+				return $spotter_array;
163
+		}
164
+
165
+		/**
166
+		 * Gets all the spotter information based on a particular id
167
+		 *
168
+		 * @return Array the spotter information
169
+		 *
170
+		 */
171
+		public function getAllArchiveMarineDataById($id)
172 172
 	{
173
-                date_default_timezone_set('UTC');
174
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
175
-                $query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
173
+				date_default_timezone_set('UTC');
174
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
175
+				$query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
176 176
 
177 177
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
178 178
 
179
-                try {
180
-                        $sth = $this->db->prepare($query);
181
-                        $sth->execute(array(':id' => $id));
182
-                } catch(PDOException $e) {
183
-                        echo $e->getMessage();
184
-                        die;
185
-                }
186
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
187
-
188
-                return $spotter_array;
189
-        }
190
-
191
-        /**
192
-        * Gets coordinate & time spotter information based on a particular id
193
-        *
194
-        * @return Array the spotter information
195
-        *
196
-        */
197
-        public function getCoordArchiveMarineDataById($id)
198
-        {
199
-                date_default_timezone_set('UTC');
200
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
201
-                $query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
179
+				try {
180
+						$sth = $this->db->prepare($query);
181
+						$sth->execute(array(':id' => $id));
182
+				} catch(PDOException $e) {
183
+						echo $e->getMessage();
184
+						die;
185
+				}
186
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
187
+
188
+				return $spotter_array;
189
+		}
190
+
191
+		/**
192
+		 * Gets coordinate & time spotter information based on a particular id
193
+		 *
194
+		 * @return Array the spotter information
195
+		 *
196
+		 */
197
+		public function getCoordArchiveMarineDataById($id)
198
+		{
199
+				date_default_timezone_set('UTC');
200
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
201
+				$query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
202 202
 
203 203
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
204 204
 
205
-                try {
206
-                        $sth = $this->db->prepare($query);
207
-                        $sth->execute(array(':id' => $id));
208
-                } catch(PDOException $e) {
209
-                        echo $e->getMessage();
210
-                        die;
211
-                }
212
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
205
+				try {
206
+						$sth = $this->db->prepare($query);
207
+						$sth->execute(array(':id' => $id));
208
+				} catch(PDOException $e) {
209
+						echo $e->getMessage();
210
+						die;
211
+				}
212
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
213 213
 
214
-                return $spotter_array;
215
-        }
214
+				return $spotter_array;
215
+		}
216 216
 
217 217
 
218
-        /**
219
-        * Gets altitude information based on a particular callsign
220
-        *
221
-        * @return Array the spotter information
222
-        *
223
-        */
224
-        public function getAltitudeArchiveMarineDataByIdent($ident)
225
-        {
218
+		/**
219
+		 * Gets altitude information based on a particular callsign
220
+		 *
221
+		 * @return Array the spotter information
222
+		 *
223
+		 */
224
+		public function getAltitudeArchiveMarineDataByIdent($ident)
225
+		{
226 226
 
227
-                date_default_timezone_set('UTC');
227
+				date_default_timezone_set('UTC');
228 228
 
229
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
230
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
229
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
230
+				$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
231 231
 
232
-                try {
233
-                        $sth = $this->db->prepare($query);
234
-                        $sth->execute(array(':ident' => $ident));
235
-                } catch(PDOException $e) {
236
-                        echo $e->getMessage();
237
-                        die;
238
-                }
239
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
232
+				try {
233
+						$sth = $this->db->prepare($query);
234
+						$sth->execute(array(':ident' => $ident));
235
+				} catch(PDOException $e) {
236
+						echo $e->getMessage();
237
+						die;
238
+				}
239
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
240 240
 
241
-                return $spotter_array;
242
-        }
241
+				return $spotter_array;
242
+		}
243 243
 
244
-        /**
245
-        * Gets altitude information based on a particular id
246
-        *
247
-        * @return Array the spotter information
248
-        *
249
-        */
250
-        public function getAltitudeArchiveMarineDataById($id)
251
-        {
244
+		/**
245
+		 * Gets altitude information based on a particular id
246
+		 *
247
+		 * @return Array the spotter information
248
+		 *
249
+		 */
250
+		public function getAltitudeArchiveMarineDataById($id)
251
+		{
252 252
 
253
-                date_default_timezone_set('UTC');
253
+				date_default_timezone_set('UTC');
254 254
 
255
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
256
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
255
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
256
+				$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
257 257
 
258
-                try {
259
-                        $sth = $this->db->prepare($query);
260
-                        $sth->execute(array(':id' => $id));
261
-                } catch(PDOException $e) {
262
-                        echo $e->getMessage();
263
-                        die;
264
-                }
265
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
258
+				try {
259
+						$sth = $this->db->prepare($query);
260
+						$sth->execute(array(':id' => $id));
261
+				} catch(PDOException $e) {
262
+						echo $e->getMessage();
263
+						die;
264
+				}
265
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
266 266
 
267
-                return $spotter_array;
268
-        }
267
+				return $spotter_array;
268
+		}
269 269
 
270
-        /**
271
-        * Gets altitude & speed information based on a particular id
272
-        *
273
-        * @return Array the spotter information
274
-        *
275
-        */
276
-        public function getAltitudeSpeedArchiveMarineDataById($id)
277
-        {
270
+		/**
271
+		 * Gets altitude & speed information based on a particular id
272
+		 *
273
+		 * @return Array the spotter information
274
+		 *
275
+		 */
276
+		public function getAltitudeSpeedArchiveMarineDataById($id)
277
+		{
278 278
 
279
-                date_default_timezone_set('UTC');
279
+				date_default_timezone_set('UTC');
280 280
 
281
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
282
-                $query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
281
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
282
+				$query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
283 283
 
284
-                try {
285
-                        $sth = $this->db->prepare($query);
286
-                        $sth->execute(array(':id' => $id));
287
-                } catch(PDOException $e) {
288
-                        echo $e->getMessage();
289
-                        die;
290
-                }
291
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
284
+				try {
285
+						$sth = $this->db->prepare($query);
286
+						$sth->execute(array(':id' => $id));
287
+				} catch(PDOException $e) {
288
+						echo $e->getMessage();
289
+						die;
290
+				}
291
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
292 292
 
293
-                return $spotter_array;
294
-        }
293
+				return $spotter_array;
294
+		}
295 295
 
296 296
 
297
-        /**
298
-        * Gets altitude information based on a particular callsign
299
-        *
300
-        * @return Array the spotter information
301
-        *
302
-        */
303
-        public function getLastAltitudeArchiveMarineDataByIdent($ident)
304
-        {
297
+		/**
298
+		 * Gets altitude information based on a particular callsign
299
+		 *
300
+		 * @return Array the spotter information
301
+		 *
302
+		 */
303
+		public function getLastAltitudeArchiveMarineDataByIdent($ident)
304
+		{
305 305
 
306
-                date_default_timezone_set('UTC');
306
+				date_default_timezone_set('UTC');
307 307
 
308
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
309
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
308
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
309
+				$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
310 310
 //                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";
311 311
 
312
-                try {
313
-                        $sth = $this->db->prepare($query);
314
-                        $sth->execute(array(':ident' => $ident));
315
-                } catch(PDOException $e) {
316
-                        echo $e->getMessage();
317
-                        die;
318
-                }
319
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
312
+				try {
313
+						$sth = $this->db->prepare($query);
314
+						$sth->execute(array(':ident' => $ident));
315
+				} catch(PDOException $e) {
316
+						echo $e->getMessage();
317
+						die;
318
+				}
319
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
320 320
 
321
-                return $spotter_array;
322
-        }
321
+				return $spotter_array;
322
+		}
323 323
 
324 324
 
325 325
 
326
-       /**
327
-        * Gets all the archive spotter information
328
-        *
329
-        * @return Array the spotter information
330
-        *
331
-        */
332
-        public function getMarineArchiveData($ident,$fammarine_id,$date)
333
-        {
334
-    		$Marine = new Marine($this->db);
335
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
336
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";
326
+	   /**
327
+	    * Gets all the archive spotter information
328
+	    *
329
+	    * @return Array the spotter information
330
+	    *
331
+	    */
332
+		public function getMarineArchiveData($ident,$fammarine_id,$date)
333
+		{
334
+			$Marine = new Marine($this->db);
335
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
336
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";
337 337
 
338
-                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%'));
338
+				$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%'));
339 339
 
340
-                return $spotter_array;
341
-        }
340
+				return $spotter_array;
341
+		}
342 342
         
343
-        public function deleteMarineArchiveTrackData()
344
-        {
343
+		public function deleteMarineArchiveTrackData()
344
+		{
345 345
 		global $globalArchiveKeepTrackMonths;
346
-                date_default_timezone_set('UTC');
346
+				date_default_timezone_set('UTC');
347 347
 		$query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
348
-                try {
349
-                        $sth = $this->db->prepare($query);
350
-                        $sth->execute();
351
-                } catch(PDOException $e) {
352
-                        echo $e->getMessage();
353
-                        die;
354
-                }
348
+				try {
349
+						$sth = $this->db->prepare($query);
350
+						$sth->execute();
351
+				} catch(PDOException $e) {
352
+						echo $e->getMessage();
353
+						die;
354
+				}
355 355
 	}
356 356
 
357 357
 	/**
358
-        * Gets Minimal Live Marine data
359
-        *
360
-        * @return Array the spotter information
361
-        *
362
-        */
363
-        public function getMinLiveMarineData($begindate,$enddate,$filter = array())
364
-        {
365
-                global $globalDBdriver, $globalLiveInterval;
366
-                date_default_timezone_set('UTC');
367
-
368
-                $filter_query = '';
369
-                if (isset($filter['source']) && !empty($filter['source'])) {
370
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
371
-                }
372
-                // Use spotter_output also ?
373
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
375
-                }
376
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
378
-                }
379
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
381
-                }
358
+	 * Gets Minimal Live Marine data
359
+	 *
360
+	 * @return Array the spotter information
361
+	 *
362
+	 */
363
+		public function getMinLiveMarineData($begindate,$enddate,$filter = array())
364
+		{
365
+				global $globalDBdriver, $globalLiveInterval;
366
+				date_default_timezone_set('UTC');
367
+
368
+				$filter_query = '';
369
+				if (isset($filter['source']) && !empty($filter['source'])) {
370
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
371
+				}
372
+				// Use spotter_output also ?
373
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
375
+				}
376
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
378
+				}
379
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
381
+				}
382 382
 
383
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
384
-                if ($globalDBdriver == 'mysql') {
385
-                        /*
383
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
384
+				if ($globalDBdriver == 'mysql') {
385
+						/*
386 386
                         $query  = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk 
387 387
                     		    FROM marine_archive 
388 388
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
@@ -401,56 +401,56 @@  discard block
 block discarded – undo
401 401
 				    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
402 402
 				    WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
403 403
                         	    '.$filter_query.' ORDER BY fammarine_id';
404
-                } else {
405
-                        //$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
406
-                        $query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
404
+				} else {
405
+						//$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
406
+						$query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
407 407
                         	    FROM marine_archive 
408 408
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
409 409
                         	    WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'
410 410
                         	    '.$filter_query.' ORDER BY fammarine_id';
411
-                }
412
-                //echo $query;
413
-                try {
414
-                        $sth = $this->db->prepare($query);
415
-                        $sth->execute();
416
-                } catch(PDOException $e) {
417
-                        echo $e->getMessage();
418
-                        die;
419
-                }
420
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
411
+				}
412
+				//echo $query;
413
+				try {
414
+						$sth = $this->db->prepare($query);
415
+						$sth->execute();
416
+				} catch(PDOException $e) {
417
+						echo $e->getMessage();
418
+						die;
419
+				}
420
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
421 421
 
422
-                return $spotter_array;
423
-        }
422
+				return $spotter_array;
423
+		}
424 424
 
425 425
 	/**
426
-        * Gets Minimal Live Marine data
427
-        *
428
-        * @return Array the spotter information
429
-        *
430
-        */
431
-        public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
432
-        {
433
-                global $globalDBdriver, $globalLiveInterval;
434
-                date_default_timezone_set('UTC');
435
-
436
-                $filter_query = '';
437
-                if (isset($filter['source']) && !empty($filter['source'])) {
438
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
439
-                }
440
-                // Should use spotter_output also ?
441
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
443
-                }
444
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
446
-                }
447
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
449
-                }
426
+	 * Gets Minimal Live Marine data
427
+	 *
428
+	 * @return Array the spotter information
429
+	 *
430
+	 */
431
+		public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
432
+		{
433
+				global $globalDBdriver, $globalLiveInterval;
434
+				date_default_timezone_set('UTC');
435
+
436
+				$filter_query = '';
437
+				if (isset($filter['source']) && !empty($filter['source'])) {
438
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
439
+				}
440
+				// Should use spotter_output also ?
441
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
443
+				}
444
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
446
+				}
447
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
449
+				}
450 450
 
451
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
452
-                if ($globalDBdriver == 'mysql') {
453
-                        /*
451
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
452
+				if ($globalDBdriver == 'mysql') {
453
+						/*
454 454
                         $query  = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk 
455 455
                     		    FROM marine_archive 
456 456
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
@@ -461,95 +461,95 @@  discard block
 block discarded – undo
461 461
 				    WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
462 462
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
463 463
 
464
-                } else {
465
-                        //$query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';
466
-                       /*
464
+				} else {
465
+						//$query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';
466
+					   /*
467 467
                         $query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
468 468
                         	    FROM marine_archive_output 
469 469
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
470 470
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
471 471
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
472 472
                         */
473
-                        $query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
473
+						$query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
474 474
                         	    FROM marine_archive_output 
475 475
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
476 476
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
477 477
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
478 478
 //                        	    .' GROUP BY spotter_output.fammarine_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
479 479
                         	    
480
-                }
481
-                //echo $query;
482
-                try {
483
-                        $sth = $this->db->prepare($query);
484
-                        $sth->execute();
485
-                } catch(PDOException $e) {
486
-                        echo $e->getMessage();
487
-                        die;
488
-                }
489
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
480
+				}
481
+				//echo $query;
482
+				try {
483
+						$sth = $this->db->prepare($query);
484
+						$sth->execute();
485
+				} catch(PDOException $e) {
486
+						echo $e->getMessage();
487
+						die;
488
+				}
489
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
490 490
 
491
-                return $spotter_array;
492
-        }
491
+				return $spotter_array;
492
+		}
493 493
 
494 494
 	 /**
495
-        * Gets count Live Marine data
496
-        *
497
-        * @return Array the spotter information
498
-        *
499
-        */
500
-        public function getLiveMarineCount($begindate,$enddate,$filter = array())
501
-        {
502
-                global $globalDBdriver, $globalLiveInterval;
503
-                date_default_timezone_set('UTC');
504
-
505
-                $filter_query = '';
506
-                if (isset($filter['source']) && !empty($filter['source'])) {
507
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
508
-                }
509
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
511
-                }
512
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
514
-                }
515
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
517
-                }
495
+	  * Gets count Live Marine data
496
+	  *
497
+	  * @return Array the spotter information
498
+	  *
499
+	  */
500
+		public function getLiveMarineCount($begindate,$enddate,$filter = array())
501
+		{
502
+				global $globalDBdriver, $globalLiveInterval;
503
+				date_default_timezone_set('UTC');
518 504
 
519
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
520
-                if ($globalDBdriver == 'mysql') {
505
+				$filter_query = '';
506
+				if (isset($filter['source']) && !empty($filter['source'])) {
507
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
508
+				}
509
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
511
+				}
512
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
514
+				}
515
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
517
+				}
518
+
519
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
520
+				if ($globalDBdriver == 'mysql') {
521 521
 			$query = 'SELECT COUNT(DISTINCT fammarine_id) as nb 
522 522
 			FROM marine_archive l 
523 523
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
524
-                } else {
524
+				} else {
525 525
 			$query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
526
-                }
527
-                //echo $query;
528
-                try {
529
-                        $sth = $this->db->prepare($query);
530
-                        $sth->execute();
531
-                } catch(PDOException $e) {
532
-                        echo $e->getMessage();
533
-                        die;
534
-                }
526
+				}
527
+				//echo $query;
528
+				try {
529
+						$sth = $this->db->prepare($query);
530
+						$sth->execute();
531
+				} catch(PDOException $e) {
532
+						echo $e->getMessage();
533
+						die;
534
+				}
535 535
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
536 536
 		$sth->closeCursor();
537
-                return $result['nb'];
537
+				return $result['nb'];
538 538
 
539
-        }
539
+		}
540 540
 
541 541
 
542 542
 
543 543
 	// marine_archive_output
544 544
 	
545
-    /**
546
-    * Gets all the spotter information
547
-    *
548
-    * @return Array the spotter information
549
-    *
550
-    */
551
-    public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
552
-    {
545
+	/**
546
+	 * Gets all the spotter information
547
+	 *
548
+	 * @return Array the spotter information
549
+	 *
550
+	 */
551
+	public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
552
+	{
553 553
 	global $globalTimezone, $globalDBdriver;
554 554
 	require_once(dirname(__FILE__).'/class.Translation.php');
555 555
 	$Translation = new Translation();
@@ -563,159 +563,159 @@  discard block
 block discarded – undo
563 563
 	$filter_query = $this->getFilter($filters);
564 564
 	if ($q != "")
565 565
 	{
566
-	    if (!is_string($q))
567
-	    {
566
+		if (!is_string($q))
567
+		{
568 568
 		return false;
569
-	    } else {
569
+		} else {
570 570
 	        
571 571
 		$q_array = explode(" ", $q);
572 572
 		
573 573
 		foreach ($q_array as $q_item){
574
-		    $additional_query .= " AND (";
575
-		    $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
576
-		    $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
577
-		    $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";
578
-		    $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
579
-		    $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";
580
-		    $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";
581
-		    $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";
582
-		    $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
583
-		    $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";
584
-		    $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";
585
-		    $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";
586
-		    $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
587
-		    $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
588
-		    $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
589
-		    $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
590
-		    $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";
591
-		    $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";
592
-		    $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";
593
-		    $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
594
-		    $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
595
-		    $translate = $Translation->ident2icao($q_item);
596
-		    if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
597
-		    $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
598
-		    $additional_query .= ")";
574
+			$additional_query .= " AND (";
575
+			$additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
576
+			$additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
577
+			$additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";
578
+			$additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
579
+			$additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";
580
+			$additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";
581
+			$additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";
582
+			$additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
583
+			$additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";
584
+			$additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";
585
+			$additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";
586
+			$additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
587
+			$additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
588
+			$additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
589
+			$additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
590
+			$additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";
591
+			$additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";
592
+			$additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";
593
+			$additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
594
+			$additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
595
+			$translate = $Translation->ident2icao($q_item);
596
+			if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
597
+			$additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
598
+			$additional_query .= ")";
599
+		}
599 600
 		}
600
-	    }
601 601
 	}
602 602
 	
603 603
 	if ($registration != "")
604 604
 	{
605
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
606
-	    if (!is_string($registration))
607
-	    {
605
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
606
+		if (!is_string($registration))
607
+		{
608 608
 		return false;
609
-	    } else {
609
+		} else {
610 610
 		$additional_query .= " AND (marine_archive_output.registration = '".$registration."')";
611
-	    }
611
+		}
612 612
 	}
613 613
 	
614 614
 	if ($aircraft_icao != "")
615 615
 	{
616
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
617
-	    if (!is_string($aircraft_icao))
618
-	    {
616
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
617
+		if (!is_string($aircraft_icao))
618
+		{
619 619
 		return false;
620
-	    } else {
620
+		} else {
621 621
 		$additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')";
622
-	    }
622
+		}
623 623
 	}
624 624
 	
625 625
 	if ($aircraft_manufacturer != "")
626 626
 	{
627
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
628
-	    if (!is_string($aircraft_manufacturer))
629
-	    {
627
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
628
+		if (!is_string($aircraft_manufacturer))
629
+		{
630 630
 		return false;
631
-	    } else {
631
+		} else {
632 632
 		$additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
633
-	    }
633
+		}
634 634
 	}
635 635
 	
636 636
 	if ($highlights == "true")
637 637
 	{
638
-	    if (!is_string($highlights))
639
-	    {
638
+		if (!is_string($highlights))
639
+		{
640 640
 		return false;
641
-	    } else {
641
+		} else {
642 642
 		$additional_query .= " AND (marine_archive_output.highlight <> '')";
643
-	    }
643
+		}
644 644
 	}
645 645
 	
646 646
 	if ($airline_icao != "")
647 647
 	{
648
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
649
-	    if (!is_string($airline_icao))
650
-	    {
648
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
649
+		if (!is_string($airline_icao))
650
+		{
651 651
 		return false;
652
-	    } else {
652
+		} else {
653 653
 		$additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')";
654
-	    }
654
+		}
655 655
 	}
656 656
 	
657 657
 	if ($airline_country != "")
658 658
 	{
659
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
660
-	    if (!is_string($airline_country))
661
-	    {
659
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
660
+		if (!is_string($airline_country))
661
+		{
662 662
 		return false;
663
-	    } else {
663
+		} else {
664 664
 		$additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')";
665
-	    }
665
+		}
666 666
 	}
667 667
 	
668 668
 	if ($airline_type != "")
669 669
 	{
670
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
671
-	    if (!is_string($airline_type))
672
-	    {
670
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
671
+		if (!is_string($airline_type))
672
+		{
673 673
 		return false;
674
-	    } else {
674
+		} else {
675 675
 		if ($airline_type == "passenger")
676 676
 		{
677
-		    $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";
677
+			$additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";
678 678
 		}
679 679
 		if ($airline_type == "cargo")
680 680
 		{
681
-		    $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";
681
+			$additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";
682 682
 		}
683 683
 		if ($airline_type == "military")
684 684
 		{
685
-		    $additional_query .= " AND (marine_archive_output.airline_type = 'military')";
685
+			$additional_query .= " AND (marine_archive_output.airline_type = 'military')";
686
+		}
686 687
 		}
687
-	    }
688 688
 	}
689 689
 	
690 690
 	if ($airport != "")
691 691
 	{
692
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
693
-	    if (!is_string($airport))
694
-	    {
692
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
693
+		if (!is_string($airport))
694
+		{
695 695
 		return false;
696
-	    } else {
696
+		} else {
697 697
 		$additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))";
698
-	    }
698
+		}
699 699
 	}
700 700
 	
701 701
 	if ($airport_country != "")
702 702
 	{
703
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
704
-	    if (!is_string($airport_country))
705
-	    {
703
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
704
+		if (!is_string($airport_country))
705
+		{
706 706
 		return false;
707
-	    } else {
707
+		} else {
708 708
 		$additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))";
709
-	    }
709
+		}
710 710
 	}
711 711
     
712 712
 	if ($callsign != "")
713 713
 	{
714
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
715
-	    if (!is_string($callsign))
716
-	    {
714
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
715
+		if (!is_string($callsign))
716
+		{
717 717
 		return false;
718
-	    } else {
718
+		} else {
719 719
 		$translate = $Translation->ident2icao($callsign);
720 720
 		if ($translate != $callsign) {
721 721
 			$additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";
@@ -723,99 +723,99 @@  discard block
 block discarded – undo
723 723
 		} else {
724 724
 			$additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";
725 725
 		}
726
-	    }
726
+		}
727 727
 	}
728 728
 
729 729
 	if ($owner != "")
730 730
 	{
731
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
732
-	    if (!is_string($owner))
733
-	    {
731
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
732
+		if (!is_string($owner))
733
+		{
734 734
 		return false;
735
-	    } else {
735
+		} else {
736 736
 		$additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')";
737
-	    }
737
+		}
738 738
 	}
739 739
 
740 740
 	if ($pilot_name != "")
741 741
 	{
742
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
743
-	    if (!is_string($pilot_name))
744
-	    {
742
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
743
+		if (!is_string($pilot_name))
744
+		{
745 745
 		return false;
746
-	    } else {
746
+		} else {
747 747
 		$additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')";
748
-	    }
748
+		}
749 749
 	}
750 750
 	
751 751
 	if ($pilot_id != "")
752 752
 	{
753
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
754
-	    if (!is_string($pilot_id))
755
-	    {
753
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
754
+		if (!is_string($pilot_id))
755
+		{
756 756
 		return false;
757
-	    } else {
757
+		} else {
758 758
 		$additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')";
759
-	    }
759
+		}
760 760
 	}
761 761
 	
762 762
 	if ($departure_airport_route != "")
763 763
 	{
764
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
765
-	    if (!is_string($departure_airport_route))
766
-	    {
764
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
765
+		if (!is_string($departure_airport_route))
766
+		{
767 767
 		return false;
768
-	    } else {
768
+		} else {
769 769
 		$additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')";
770
-	    }
770
+		}
771 771
 	}
772 772
 	
773 773
 	if ($arrival_airport_route != "")
774 774
 	{
775
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
776
-	    if (!is_string($arrival_airport_route))
777
-	    {
775
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
776
+		if (!is_string($arrival_airport_route))
777
+		{
778 778
 		return false;
779
-	    } else {
779
+		} else {
780 780
 		$additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
781
-	    }
781
+		}
782 782
 	}
783 783
 	
784 784
 	if ($altitude != "")
785 785
 	{
786
-	    $altitude_array = explode(",", $altitude);
786
+		$altitude_array = explode(",", $altitude);
787 787
 	    
788
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
790 790
 	    
791 791
 
792
-	    if ($altitude_array[1] != "")
793
-	    {                
792
+		if ($altitude_array[1] != "")
793
+		{                
794 794
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
795 795
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
796 796
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
797
-	    } else {
797
+		} else {
798 798
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
799 799
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
800
-	    }
800
+		}
801 801
 	}
802 802
 	
803 803
 	if ($date_posted != "")
804 804
 	{
805
-	    $date_array = explode(",", $date_posted);
805
+		$date_array = explode(",", $date_posted);
806 806
 	    
807
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
807
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
809 809
 	    
810
-	    if ($globalTimezone != '') {
810
+		if ($globalTimezone != '') {
811 811
 		date_default_timezone_set($globalTimezone);
812 812
 		$datetime = new DateTime();
813 813
 		$offset = $datetime->format('P');
814
-	    } else $offset = '+00:00';
814
+		} else $offset = '+00:00';
815 815
 
816 816
 
817
-	    if ($date_array[1] != "")
818
-	    {                
817
+		if ($date_array[1] != "")
818
+		{                
819 819
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
820 820
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
821 821
 		if ($globalDBdriver == 'mysql') {
@@ -823,28 +823,28 @@  discard block
 block discarded – undo
823 823
 		} else {
824 824
 			$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
825 825
 		}
826
-	    } else {
826
+		} else {
827 827
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
828
-                if ($globalDBdriver == 'mysql') {
828
+				if ($globalDBdriver == 'mysql') {
829 829
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
830 830
 		} else {
831 831
 			$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
832 832
 		}
833
-	    }
833
+		}
834 834
 	}
835 835
 	
836 836
 	if ($limit != "")
837 837
 	{
838
-	    $limit_array = explode(",", $limit);
838
+		$limit_array = explode(",", $limit);
839 839
 	    
840
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
840
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
842 842
 	    
843
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844
-	    {
843
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844
+		{
845 845
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
846 846
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
847
-	    }
847
+		}
848 848
 	}
849 849
 	
850 850
 
@@ -875,33 +875,33 @@  discard block
 block discarded – undo
875 875
 	$spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);
876 876
 
877 877
 	return $spotter_array;
878
-    }
878
+	}
879 879
 
880
-    public function deleteMarineArchiveData()
881
-    {
880
+	public function deleteMarineArchiveData()
881
+	{
882 882
 		global $globalArchiveKeepMonths, $globalDBdriver;
883
-                date_default_timezone_set('UTC');
884
-                if ($globalDBdriver == 'mysql') {
883
+				date_default_timezone_set('UTC');
884
+				if ($globalDBdriver == 'mysql') {
885 885
 			$query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
886 886
 		} else {
887 887
 			$query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
888 888
 		}
889
-                try {
890
-                        $sth = $this->db->prepare($query);
891
-                        $sth->execute();
892
-                } catch(PDOException $e) {
893
-                        return "error";
894
-                }
889
+				try {
890
+						$sth = $this->db->prepare($query);
891
+						$sth->execute();
892
+				} catch(PDOException $e) {
893
+						return "error";
894
+				}
895 895
 	}
896 896
 
897
-    /**
898
-    * Gets all the spotter information based on the callsign
899
-    *
900
-    * @return Array the spotter information
901
-    *
902
-    */
903
-    public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')
904
-    {
897
+	/**
898
+	 * Gets all the spotter information based on the callsign
899
+	 *
900
+	 * @return Array the spotter information
901
+	 *
902
+	 */
903
+	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')
904
+	{
905 905
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
906 906
 	
907 907
 	date_default_timezone_set('UTC');
@@ -913,35 +913,35 @@  discard block
 block discarded – undo
913 913
 	
914 914
 	if ($ident != "")
915 915
 	{
916
-	    if (!is_string($ident))
917
-	    {
916
+		if (!is_string($ident))
917
+		{
918 918
 		return false;
919
-	    } else {
919
+		} else {
920 920
 		$additional_query = " AND (marine_archive_output.ident = :ident)";
921 921
 		$query_values = array(':ident' => $ident);
922
-	    }
922
+		}
923 923
 	}
924 924
 	
925 925
 	if ($limit != "")
926 926
 	{
927
-	    $limit_array = explode(",", $limit);
927
+		$limit_array = explode(",", $limit);
928 928
 	    
929
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
929
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
931 931
 	    
932
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933
-	    {
932
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933
+		{
934 934
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
935 935
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
936
-	    }
936
+		}
937 937
 	}
938 938
 
939 939
 	if ($sort != "")
940 940
 	{
941
-	    $search_orderby_array = $Marine->getOrderBy();
942
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
941
+		$search_orderby_array = $Marine->getOrderBy();
942
+		$orderby_query = $search_orderby_array[$sort]['sql'];
943 943
 	} else {
944
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
944
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
945 945
 	}
946 946
 
947 947
 	$query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -949,17 +949,17 @@  discard block
 block discarded – undo
949 949
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
950 950
 
951 951
 	return $spotter_array;
952
-    }
952
+	}
953 953
 
954 954
 
955
-    /**
956
-    * Gets all the spotter information based on the owner
957
-    *
958
-    * @return Array the spotter information
959
-    *
960
-    */
961
-    public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
962
-    {
955
+	/**
956
+	 * Gets all the spotter information based on the owner
957
+	 *
958
+	 * @return Array the spotter information
959
+	 *
960
+	 */
961
+	public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
962
+	{
963 963
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
964 964
 	
965 965
 	date_default_timezone_set('UTC');
@@ -972,35 +972,35 @@  discard block
 block discarded – undo
972 972
 	
973 973
 	if ($owner != "")
974 974
 	{
975
-	    if (!is_string($owner))
976
-	    {
975
+		if (!is_string($owner))
976
+		{
977 977
 		return false;
978
-	    } else {
978
+		} else {
979 979
 		$additional_query = " AND (marine_archive_output.owner_name = :owner)";
980 980
 		$query_values = array(':owner' => $owner);
981
-	    }
981
+		}
982 982
 	}
983 983
 	
984 984
 	if ($limit != "")
985 985
 	{
986
-	    $limit_array = explode(",", $limit);
986
+		$limit_array = explode(",", $limit);
987 987
 	    
988
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
990 990
 	    
991
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992
-	    {
991
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992
+		{
993 993
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
994 994
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
995
-	    }
995
+		}
996 996
 	}
997 997
 
998 998
 	if ($sort != "")
999 999
 	{
1000
-	    $search_orderby_array = $Marine->getOrderBy();
1001
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1000
+		$search_orderby_array = $Marine->getOrderBy();
1001
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1002 1002
 	} else {
1003
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1003
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1004 1004
 	}
1005 1005
 
1006 1006
 	$query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1008,16 +1008,16 @@  discard block
 block discarded – undo
1008 1008
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1009 1009
 
1010 1010
 	return $spotter_array;
1011
-    }
1012
-
1013
-    /**
1014
-    * Gets all the spotter information based on the pilot
1015
-    *
1016
-    * @return Array the spotter information
1017
-    *
1018
-    */
1019
-    public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1020
-    {
1011
+	}
1012
+
1013
+	/**
1014
+	 * Gets all the spotter information based on the pilot
1015
+	 *
1016
+	 * @return Array the spotter information
1017
+	 *
1018
+	 */
1019
+	public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1020
+	{
1021 1021
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
1022 1022
 	
1023 1023
 	date_default_timezone_set('UTC');
@@ -1036,24 +1036,24 @@  discard block
 block discarded – undo
1036 1036
 	
1037 1037
 	if ($limit != "")
1038 1038
 	{
1039
-	    $limit_array = explode(",", $limit);
1039
+		$limit_array = explode(",", $limit);
1040 1040
 	    
1041
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1041
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1043 1043
 	    
1044
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045
-	    {
1044
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045
+		{
1046 1046
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1047 1047
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1048
-	    }
1048
+		}
1049 1049
 	}
1050 1050
 
1051 1051
 	if ($sort != "")
1052 1052
 	{
1053
-	    $search_orderby_array = $Marine->getOrderBy();
1054
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1053
+		$search_orderby_array = $Marine->getOrderBy();
1054
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1055 1055
 	} else {
1056
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1056
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1057 1057
 	}
1058 1058
 
1059 1059
 	$query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1061,16 +1061,16 @@  discard block
 block discarded – undo
1061 1061
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1062 1062
 
1063 1063
 	return $spotter_array;
1064
-    }
1065
-
1066
-    /**
1067
-    * Gets all number of flight over countries
1068
-    *
1069
-    * @return Array the airline country list
1070
-    *
1071
-    */
1072
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1073
-    {
1064
+	}
1065
+
1066
+	/**
1067
+	 * Gets all number of flight over countries
1068
+	 *
1069
+	 * @return Array the airline country list
1070
+	 *
1071
+	 */
1072
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1073
+	{
1074 1074
 	global $globalDBdriver;
1075 1075
 	/*
1076 1076
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1080,14 +1080,14 @@  discard block
 block discarded – undo
1080 1080
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1081 1081
 		    FROM countries c, marine_archive s
1082 1082
 		    WHERE c.iso2 = s.over_country ";
1083
-                if ($olderthanmonths > 0) {
1084
-            		if ($globalDBdriver == 'mysql') {
1083
+				if ($olderthanmonths > 0) {
1084
+					if ($globalDBdriver == 'mysql') {
1085 1085
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1086 1086
 			} else {
1087 1087
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1088 1088
 			}
1089 1089
 		}
1090
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1090
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1091 1091
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1092 1092
 	if ($limit) $query .= " LIMIT 0,10";
1093 1093
       
@@ -1100,23 +1100,23 @@  discard block
 block discarded – undo
1100 1100
         
1101 1101
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1102 1102
 	{
1103
-	    $temp_array['flight_count'] = $row['nb'];
1104
-	    $temp_array['flight_country'] = $row['name'];
1105
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1106
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1107
-	    $flight_array[] = $temp_array;
1103
+		$temp_array['flight_count'] = $row['nb'];
1104
+		$temp_array['flight_country'] = $row['name'];
1105
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1106
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1107
+		$flight_array[] = $temp_array;
1108 1108
 	}
1109 1109
 	return $flight_array;
1110
-    }
1111
-
1112
-    /**
1113
-    * Gets all number of flight over countries
1114
-    *
1115
-    * @return Array the airline country list
1116
-    *
1117
-    */
1118
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1119
-    {
1110
+	}
1111
+
1112
+	/**
1113
+	 * Gets all number of flight over countries
1114
+	 *
1115
+	 * @return Array the airline country list
1116
+	 *
1117
+	 */
1118
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1119
+	{
1120 1120
 	global $globalDBdriver;
1121 1121
 	/*
1122 1122
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1126,14 +1126,14 @@  discard block
 block discarded – undo
1126 1126
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1127 1127
 		    FROM countries c, marine_archive s, spotter_output o
1128 1128
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id ";
1129
-                if ($olderthanmonths > 0) {
1130
-            		if ($globalDBdriver == 'mysql') {
1129
+				if ($olderthanmonths > 0) {
1130
+					if ($globalDBdriver == 'mysql') {
1131 1131
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1132 1132
 			} else {
1133 1133
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1134 1134
 			}
1135 1135
 		}
1136
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1136
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1137 1137
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1138 1138
 	if ($limit) $query .= " LIMIT 0,10";
1139 1139
       
@@ -1146,24 +1146,24 @@  discard block
 block discarded – undo
1146 1146
         
1147 1147
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1148 1148
 	{
1149
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1150
-	    $temp_array['flight_count'] = $row['nb'];
1151
-	    $temp_array['flight_country'] = $row['name'];
1152
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1153
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1154
-	    $flight_array[] = $temp_array;
1149
+		$temp_array['airline_icao'] = $row['airline_icao'];
1150
+		$temp_array['flight_count'] = $row['nb'];
1151
+		$temp_array['flight_country'] = $row['name'];
1152
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1153
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1154
+		$flight_array[] = $temp_array;
1155 1155
 	}
1156 1156
 	return $flight_array;
1157
-    }
1158
-
1159
-    /**
1160
-    * Gets last spotter information based on a particular callsign
1161
-    *
1162
-    * @return Array the spotter information
1163
-    *
1164
-    */
1165
-    public function getDateArchiveMarineDataById($id,$date)
1166
-    {
1157
+	}
1158
+
1159
+	/**
1160
+	 * Gets last spotter information based on a particular callsign
1161
+	 *
1162
+	 * @return Array the spotter information
1163
+	 *
1164
+	 */
1165
+	public function getDateArchiveMarineDataById($id,$date)
1166
+	{
1167 1167
 	$Marine = new Marine($this->db);
1168 1168
 	date_default_timezone_set('UTC');
1169 1169
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1171,16 +1171,16 @@  discard block
 block discarded – undo
1171 1171
 	$date = date('c',$date);
1172 1172
 	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date));
1173 1173
 	return $spotter_array;
1174
-    }
1175
-
1176
-    /**
1177
-    * Gets all the spotter information based on a particular callsign
1178
-    *
1179
-    * @return Array the spotter information
1180
-    *
1181
-    */
1182
-    public function getDateArchiveMarineDataByIdent($ident,$date)
1183
-    {
1174
+	}
1175
+
1176
+	/**
1177
+	 * Gets all the spotter information based on a particular callsign
1178
+	 *
1179
+	 * @return Array the spotter information
1180
+	 *
1181
+	 */
1182
+	public function getDateArchiveMarineDataByIdent($ident,$date)
1183
+	{
1184 1184
 	$Marine = new Marine($this->db);
1185 1185
 	date_default_timezone_set('UTC');
1186 1186
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1188,16 +1188,16 @@  discard block
 block discarded – undo
1188 1188
 	$date = date('c',$date);
1189 1189
 	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1190 1190
 	return $spotter_array;
1191
-    }
1192
-
1193
-    /**
1194
-    * Gets all the spotter information based on the airport
1195
-    *
1196
-    * @return Array the spotter information
1197
-    *
1198
-    */
1199
-    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1200
-    {
1191
+	}
1192
+
1193
+	/**
1194
+	 * Gets all the spotter information based on the airport
1195
+	 *
1196
+	 * @return Array the spotter information
1197
+	 *
1198
+	 */
1199
+	public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1200
+	{
1201 1201
 	global $global_query;
1202 1202
 	$Marine = new Marine();
1203 1203
 	date_default_timezone_set('UTC');
@@ -1208,35 +1208,35 @@  discard block
 block discarded – undo
1208 1208
 	
1209 1209
 	if ($airport != "")
1210 1210
 	{
1211
-	    if (!is_string($airport))
1212
-	    {
1211
+		if (!is_string($airport))
1212
+		{
1213 1213
 		return false;
1214
-	    } else {
1214
+		} else {
1215 1215
 		$additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))";
1216 1216
 		$query_values = array(':airport' => $airport);
1217
-	    }
1217
+		}
1218 1218
 	}
1219 1219
 	
1220 1220
 	if ($limit != "")
1221 1221
 	{
1222
-	    $limit_array = explode(",", $limit);
1222
+		$limit_array = explode(",", $limit);
1223 1223
 	    
1224
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1224
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1226 1226
 	    
1227
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228
-	    {
1227
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228
+		{
1229 1229
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1230 1230
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1231
-	    }
1231
+		}
1232 1232
 	}
1233 1233
 	
1234 1234
 	if ($sort != "")
1235 1235
 	{
1236
-	    $search_orderby_array = $Marine->getOrderBy();
1237
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1236
+		$search_orderby_array = $Marine->getOrderBy();
1237
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1238 1238
 	} else {
1239
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1239
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1240 1240
 	}
1241 1241
 
1242 1242
 	$query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1244,6 +1244,6 @@  discard block
 block discarded – undo
1244 1244
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1245 1245
 
1246 1246
 	return $spotter_array;
1247
-    }
1247
+	}
1248 1248
 }
1249 1249
 ?>
1250 1250
\ No newline at end of file
Please login to merge, or discard this patch.
index.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 <div id="showdetails" class="showdetails"></div>
37 37
 <div id="infobox" class="infobox"><h4><?php echo _("Aircrafts detected"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div>
38 38
 <?php
39
-    if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
39
+	if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
40 40
 
41 41
 ?>
42 42
 <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script>
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script>
57 57
 <?php
58 58
 	}
59
-    }
59
+	}
60 60
 ?>
61 61
 <div id="dialog" title="<?php echo _("Session has timed-out"); ?>">
62 62
   <p><?php echo _("In order to save data consumption web page times out after 30 minutes. Close this dialog to continue."); ?></p>
@@ -70,34 +70,34 @@  discard block
 block discarded – undo
70 70
 	<li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li>
71 71
 	<li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li>
72 72
 <?php
73
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
73
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
74 74
 	if (isset($globalArchive) && $globalArchive == TRUE) {
75 75
 ?>
76 76
 	<li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li>
77 77
 <?php
78 78
 	}
79
-    }
79
+	}
80 80
 ?>
81 81
 	<li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li>
82 82
 	<li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li>
83 83
 	<li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li>
84 84
 <?php
85
-    if (isset($globalMap3D) && $globalMap3D) {
85
+	if (isset($globalMap3D) && $globalMap3D) {
86 86
 	if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
87 87
 ?>
88 88
 	<li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li>
89 89
 <?php
90
-        } else {
91
-    	    if (isset($globalMapSatellites) && $globalMapSatellites) {
90
+		} else {
91
+			if (isset($globalMapSatellites) && $globalMapSatellites) {
92 92
 ?>
93 93
 	<li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li>
94 94
 <?php
95
-	    }
95
+		}
96 96
 ?>
97 97
 	<li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li>
98 98
 <?php
99 99
 	}
100
-    }
100
+	}
101 101
 ?>
102 102
     </ul>
103 103
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 ?>
172 172
         </div>
173 173
 <?php
174
-    if (isset($globalArchive) && $globalArchive == TRUE) {
174
+	if (isset($globalArchive) && $globalArchive == TRUE) {
175 175
 ?>
176 176
         <div class="sidebar-pane" id="archive">
177 177
 	    <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	    </form>
232 232
 	</div>
233 233
 <?php
234
-    }
234
+	}
235 235
 ?>
236 236
         <div class="sidebar-pane" id="settings">
237 237
 	    <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -242,56 +242,56 @@  discard block
 block discarded – undo
242 242
 			    <?php
243 243
 				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
244 244
 				else $MapType = $_COOKIE['MapType'];
245
-			    ?>
245
+				?>
246 246
 			    <?php
247 247
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
248
-			    ?>
248
+				?>
249 249
 			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
250 250
 			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
251 251
 			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
252 252
 			    <?php
253 253
 				}
254
-			    ?>
254
+				?>
255 255
 			    <?php
256
-			        if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
257
-			    ?>
256
+					if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
257
+				?>
258 258
 			    <?php
259
-				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
260
-			    ?>
259
+					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
260
+				?>
261 261
 			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
262 262
 			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
263 263
 			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
264 264
 			    <?php
265
-				    }
266
-			    ?>
265
+					}
266
+				?>
267 267
 			    <?php
268
-				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
269
-			    ?>
268
+					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
269
+				?>
270 270
 			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
271 271
 			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
272 272
 			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
273 273
 			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
274 274
 			    <?php
275
-				    }
276
-			    ?>
275
+					}
276
+				?>
277 277
 			    <?php
278
-				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
279
-			    ?>
278
+					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
279
+				?>
280 280
 			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
281 281
 			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
282 282
 			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
283 283
 			    <?php
284
-				    }
285
-			    ?>
284
+					}
285
+				?>
286 286
 			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
287 287
 			    <?php
288 288
 				}
289
-			    ?>
289
+				?>
290 290
 			    <?php
291
-				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
291
+					if (isset($globalMapboxToken) && $globalMapboxToken != '') {
292 292
 					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
293 293
 					else $MapBoxId = $_COOKIE['MapTypeId'];
294
-			    ?>
294
+				?>
295 295
 			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
296 296
 			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
297 297
 			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
 			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
306 306
 			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
307 307
 			    <?php
308
-				    }
309
-			    ?>
308
+					}
309
+				?>
310 310
 			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
311 311
 			</select>
312 312
 		    </li>
313 313
 <?php
314
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
314
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
315 315
 ?>
316 316
 		    <li><?php echo _("Type of Terrain:"); ?>
317 317
 			<select  class="selectpicker" onchange="terrainType(this);">
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
 			</select>
322 322
 		    </li>
323 323
 <?php
324
-    }
324
+	}
325 325
 ?>
326 326
 <?php
327
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
327
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
328 328
 ?>
329 329
 		    
330 330
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
@@ -332,70 +332,70 @@  discard block
 block discarded – undo
332 332
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
333 333
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
334 334
 <?php
335
-    }
335
+	}
336 336
 ?>
337 337
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
338 338
 <?php
339
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
339
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
340 340
 ?>
341 341
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
342 342
 <?php
343
-    }
344
-    if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
343
+	}
344
+	if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
345 345
 ?>
346 346
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li>
347 347
 <?php
348
-    }
348
+	}
349 349
 ?>
350 350
 
351 351
 		    <?php
352 352
 			if (function_exists('array_column')) {
353
-			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
354
-		    ?>
353
+				if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
354
+			?>
355 355
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
356 356
 		    <?php
357
-			    }
357
+				}
358 358
 			} elseif (isset($globalSources)) {
359
-			    $dispolar = false;
360
-			    foreach ($globalSources as $testsource) {
361
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
362
-			    }
363
-			    if ($dispolar) {
364
-		    ?>
359
+				$dispolar = false;
360
+				foreach ($globalSources as $testsource) {
361
+					if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
362
+				}
363
+				if ($dispolar) {
364
+			?>
365 365
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
366 366
 		    <?php
367
-			    }
368
-		        }
369
-		    ?>
367
+				}
368
+				}
369
+			?>
370 370
 <?php
371
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
371
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
372 372
 ?>
373 373
 
374 374
 		    <?php
375
-		        if (extension_loaded('gd') && function_exists('gd_info')) {
376
-		    ?>
375
+				if (extension_loaded('gd') && function_exists('gd_info')) {
376
+			?>
377 377
 		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
378 378
 		    <?php 
379 379
 			if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
380
-		    ?>
380
+			?>
381 381
 		    <li><?php echo _("Aircraft icon color:"); ?>
382 382
 			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
383 383
 		    </li>
384 384
 		    <?php
385
-			    }
386
-		        }
387
-		    ?>
385
+				}
386
+				}
387
+			?>
388 388
 		    <?php
389 389
 			if (isset($globalMarine) && $globalMarine === TRUE) {
390
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
391
-		    ?>
390
+				if (extension_loaded('gd') && function_exists('gd_info')) {
391
+			?>
392 392
 		    <li><?php echo _("Marine icon color:"); ?>
393 393
 			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
394 394
 		    </li>
395 395
 		    <?php
396
-			    }
397
-		        }
398
-		    ?>
396
+				}
397
+				}
398
+			?>
399 399
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
400 400
 			<div class="range">
401 401
 			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 			</div>
404 404
 		    </li>
405 405
 <?php
406
-    } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
406
+	} elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
407 407
 ?>
408 408
 		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Aircraft color"); ?></li>
409 409
 		    <li><?php echo _("Aircraft icon color:"); ?>
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 		    </li>
419 419
 <?php
420 420
 	}
421
-    }
421
+	}
422 422
 ?>
423 423
 		    <li><?php echo _("Distance unit:"); ?>
424 424
 			<select class="selectpicker" onchange="unitdistance(this);">
@@ -451,16 +451,16 @@  discard block
 block discarded – undo
451 451
 		    <ul>
452 452
 		    <?php
453 453
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
454
-		    ?>
454
+			?>
455 455
 			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
456 456
 			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
457 457
 			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
458 458
 		    <?php
459 459
 			}
460
-		    ?>
460
+			?>
461 461
 		    <?php
462 462
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
463
-		    ?>
463
+			?>
464 464
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
465 465
 			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
466 466
 			<?php } ?>
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 			<?php } ?>
470 470
 		    <?php
471 471
 			}
472
-		    ?>
472
+			?>
473 473
 		    <li><?php echo _("Display airlines:"); ?>
474 474
 		    <br/>
475 475
 			<select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines">
@@ -489,14 +489,14 @@  discard block
 block discarded – undo
489 489
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
490 490
 					}
491 491
 				}
492
-			    ?>
492
+				?>
493 493
 			</select>
494 494
 		    </li>
495 495
 		    <?php
496 496
 			$Spotter = new Spotter();
497 497
 			$allalliancenames = $Spotter->getAllAllianceNames();
498 498
 			if (!empty($allalliancenames)) {
499
-		    ?>
499
+			?>
500 500
 		    <li><?php echo _("Display alliance:"); ?>
501 501
 		    <br/>
502 502
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
@@ -510,15 +510,15 @@  discard block
 block discarded – undo
510 510
 						echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>';
511 511
 					}
512 512
 				}
513
-			    ?>
513
+				?>
514 514
 			</select>
515 515
 		    </li>
516 516
 		    <?php
517 517
 			}
518
-		    ?>
518
+			?>
519 519
 		    <?php
520 520
 			if (isset($globalAPRS) && $globalAPRS) {
521
-		    ?>
521
+			?>
522 522
 		    <li><?php echo _("Display APRS sources name:"); ?>
523 523
 			<select class="selectpicker" multiple onchange="sources(this);">
524 524
 			    <?php
@@ -530,15 +530,15 @@  discard block
 block discarded – undo
530 530
 						echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>';
531 531
 					}
532 532
 				}
533
-			    ?>
533
+				?>
534 534
 			</select>
535 535
 		    </li>
536 536
 		    <?php
537 537
 			}
538
-		    ?>
538
+			?>
539 539
 		    <?php
540 540
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
541
-		    ?>
541
+			?>
542 542
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
543 543
 			<select class="selectpicker" onchange="airlinestype(this);">
544 544
 			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 		    </li>
550 550
 		    <?php
551 551
 			}
552
-		    ?>
552
+			?>
553 553
 		    <li>
554 554
 			<?php echo _("Display flight with ident:"); ?>
555 555
 			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 	    </form>
563 563
     	</div>
564 564
 <?php
565
-    if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
565
+	if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
566 566
 ?>
567 567
         <div class="sidebar-pane" id="satellites">
568 568
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -602,14 +602,14 @@  discard block
 block discarded – undo
602 602
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
603 603
 					}
604 604
 				}
605
-			    ?>
605
+				?>
606 606
 			</select>
607 607
 		    </li>
608 608
 		</ul>
609 609
 	    </form>
610 610
 	</div>
611 611
 <?php
612
-    }
612
+	}
613 613
 ?>
614 614
     </div>
615 615
 </div>
Please login to merge, or discard this patch.
header.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 // When button "Remove all filters" is clicked
29 29
 if (isset($_POST['removefilters'])) {
30 30
 	$allfilters = array_filter(array_keys($_COOKIE),function($key) {
31
-	    return strpos($key,'filter_') === 0;
31
+		return strpos($key,'filter_') === 0;
32 32
 	});
33 33
 	foreach ($allfilters as $filt) {
34 34
 		unset($_COOKIE[$filt]);
@@ -168,17 +168,17 @@  discard block
 block discarded – undo
168 168
 	}
169 169
 ?>
170 170
 <?php 
171
-    if (isset($_POST['archive'])) {
171
+	if (isset($_POST['archive'])) {
172 172
 ?>
173 173
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
174 174
 <?php 
175
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
175
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
176 176
 ?>
177 177
 
178 178
 <script src="<?php print $globalURL; ?>/js/map.js.php?<?php print time(); ?>&archive&begindate=<?php print strtotime($_POST['start_date']); ?>&enddate=<?php print strtotime($_POST['end_date']); ?>&archivespeed=<?php print $_POST['archivespeed']; ?>"></script>
179 179
 <?php    
180
-	    }
181
-    } else {
180
+		}
181
+	} else {
182 182
 ?>
183 183
 <?php
184 184
 /*	if (isset($globalBeta) && $globalBeta) {
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 */
191 191
 ?>
192 192
 <?php 
193
-	    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
193
+		if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
194 194
 ?>
195 195
 <?php
196 196
 //		if (isset($globalBeta) && $globalBeta) {
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 <script src="<?php print $globalURL; ?>/js/map-marine.2d.js.php?<?php print time(); ?>"></script>
218 218
 <?php
219 219
 		}
220
-	    }
220
+		}
221 221
 ?>
222 222
 <?php
223 223
 //	}
224 224
 ?>
225 225
 <?php
226
-    }
226
+	}
227 227
 }
228 228
 ?>
229 229
 <?php
@@ -380,15 +380,15 @@  discard block
 block discarded – undo
380 380
 			<li><a href="<?php print $globalURL; ?>/airline"><?php echo _("Airlines"); ?></a></li>
381 381
 			<li><a href="<?php print $globalURL; ?>/airport"><?php echo _("Airports"); ?></a></li>
382 382
 <?php
383
-    if ((!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
383
+	if ((!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
384 384
 ?>
385 385
 			<li><a href="<?php print $globalURL; ?>/owner"><?php echo _("Owners"); ?></a></li>
386 386
 <?php
387
-    } else {
387
+	} else {
388 388
 ?>
389 389
 			<li><a href="<?php print $globalURL; ?>/pilot"><?php echo _("Pilots"); ?></a></li>
390 390
 <?php
391
-    }
391
+	}
392 392
 ?>
393 393
 			<li><hr /></li>
394 394
             <li><a href="<?php print $globalURL; ?>/currently"><?php echo _("Current Activity"); ?></a></li>
@@ -396,34 +396,34 @@  discard block
 block discarded – undo
396 396
             <li><a href="<?php print $globalURL; ?>/date/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Activity"); ?></a></li>
397 397
             <li><a href="<?php print $globalURL; ?>/newest"><?php echo _("Newest by Category"); ?></a></li>
398 398
             <?php
399
-        	if ($globalACARS) {
400
-        	    if (isset($globalDemo) && $globalDemo) {
401
-    	    ?>
399
+			if ($globalACARS) {
400
+				if (isset($globalDemo) && $globalDemo) {
401
+			?>
402 402
             <li><hr /></li>
403 403
             <li><i><?php echo _('ACARS data not available publicly'); ?></i></li>
404 404
             <li><a href=""><?php echo _('Latest ACARS messages'); ?></a></li>
405 405
             <li><a href=""><?php echo _('Archive ACARS messages'); ?></a></li>
406 406
             <?php
407
-        	    } else {
408
-    	    ?>
407
+				} else {
408
+			?>
409 409
             <li><hr /></li>
410 410
             <li><a href="<?php print $globalURL; ?>/acars-latest"><?php echo _("Latest ACARS messages"); ?></a></li>
411 411
             <li><a href="<?php print $globalURL; ?>/acars-archive"><?php echo _("Archive ACARS messages"); ?></a></li>
412 412
             <?php
413
-        	    }
414
-        	}
415
-    	    ?>
413
+				}
414
+			}
415
+			?>
416 416
     	    <?php
417
-    	        if (isset($globalAccidents) && $globalAccidents) {
418
-    	    ?>
417
+				if (isset($globalAccidents) && $globalAccidents) {
418
+			?>
419 419
             <li><hr /></li>
420 420
             <li><a href="<?php print $globalURL; ?>/accident-latest"><?php echo _("Latest accident"); ?></a></li>
421 421
             <li><a href="<?php print $globalURL; ?>/accident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Accident"); ?></a></li>
422 422
             <li><a href="<?php print $globalURL; ?>/incident-latest"><?php echo _("Latest incident"); ?></a></li>
423 423
             <li><a href="<?php print $globalURL; ?>/incident/<?php print date("Y-m-d"); ?>"><?php echo _("Today's Incident"); ?></a></li>
424 424
             <?php
425
-        	}
426
-    	    ?>
425
+			}
426
+			?>
427 427
             <li><hr /></li>
428 428
             <li><a href="<?php print $globalURL; ?>/highlights/table"><?php echo _("Special Highlights"); ?></a></li>
429 429
             <li><a href="<?php print $globalURL; ?>/upcoming"><?php echo _("Upcoming Flights"); ?></a></li>
@@ -465,14 +465,14 @@  discard block
 block discarded – undo
465 465
   	    <form>
466 466
   		<select class="selectpicker" data-width="120px" onchange="language(this);">
467 467
   		    <?php
468
-  		        $Language = new Language();
469
-  		        $alllang = $Language->getLanguages();
470
-  		        foreach ($alllang as $key => $lang) {
471
-  		            print '<option value="'.$key.'"';
472
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
473
-  		            print '>'.$lang[0].'</option>';
474
-  		        }
475
-  		    ?>
468
+  				$Language = new Language();
469
+  				$alllang = $Language->getLanguages();
470
+  				foreach ($alllang as $key => $lang) {
471
+  					print '<option value="'.$key.'"';
472
+  					if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
473
+  					print '>'.$lang[0].'</option>';
474
+  				}
475
+  			?>
476 476
   		</select>
477 477
   	    </form>
478 478
   	</div>
@@ -503,18 +503,18 @@  discard block
 block discarded – undo
503 503
 ?>
504 504
     <div class="top-header clear" role="main">
505 505
 <?php
506
-    if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
506
+	if (isset($longitude) && isset($latitude) && $longitude != 0 && $latitude != 0) {
507 507
 ?>
508 508
     <div id="archive-map"></div>
509 509
 <?php
510
-    }
510
+	}
511 511
 ?>
512 512
     </div>
513 513
 <?php
514 514
 }
515 515
 if ((strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) || (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false))
516 516
 {
517
-    ?>
517
+	?>
518 518
     <div class="top-header clear" role="main">
519 519
         <div id="map"></div>
520 520
 	<link rel="stylesheet" href="<?php print $globalURL; ?>/css/leaflet.css" />
@@ -525,15 +525,15 @@  discard block
 block discarded – undo
525 525
         var zoom = 13;
526 526
 //create the map
527 527
 <?php
528
-    if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
528
+	if (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($airport_array[0]['latitude'])) {
529 529
 ?>
530 530
   map = L.map('map', { zoomControl:true }).setView([<?php print $airport_array[0]['latitude']; ?>,<?php print $airport_array[0]['longitude']; ?>], zoom);
531 531
 <?php
532
-    } elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
532
+	} elseif (strpos(strtolower($current_page),'airport-') !== false && strpos(strtolower($current_page),'statistics-') === false) {
533 533
 ?>
534 534
   map = L.map('map', { zoomControl:true });
535 535
 <?php
536
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
536
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && isset($spotter_array[0]['departure_airport_latitude'])) {
537 537
 ?>
538 538
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['departure_airport_latitude']; ?>,<?php print $spotter_array[0]['arrival_airport_longitude']; ?>]);
539 539
     var line = L.polyline([[<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>],[<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>]]).addTo(map);
@@ -541,22 +541,22 @@  discard block
 block discarded – undo
541 541
     var departure_airport = L.marker([<?php print $spotter_array[0]['departure_airport_latitude']; ?>, <?php print $spotter_array[0]['departure_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/departure_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
542 542
     var arrival_airport = L.marker([<?php print $spotter_array[0]['arrival_airport_latitude']; ?>, <?php print $spotter_array[0]['arrival_airport_longitude']; ?>], {icon: L.icon({iconUrl: '<?php print $globalURL; ?>/images/arrival_airport.png',iconSize: [16,18],iconAnchor: [8,16]})}).addTo(map);
543 543
 <?php
544
-    } elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
544
+	} elseif (strpos(strtolower($current_page),'route-') !== false && strpos(strtolower($current_page),'statistics-') === false && !isset($spotter_array[0]['departure_airport_latitude'])) {
545 545
 ?>
546 546
   map = L.map('map', { zoomControl:true }).setView([<?php print $spotter_array[0]['latitude']; ?>,<?php print $spotter_array[0]['longitude']; ?>]);
547 547
 <?php
548
-    } elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
548
+	} elseif (!isset($spotter_array[0]['latitude']) && !isset($spotter_array[0]['longitude'])) {
549 549
 ?>
550 550
   map = L.map('map', { zoomControl:true });
551 551
 <?php
552
-    }
552
+	}
553 553
 ?>
554 554
   //initialize the layer group for the aircrft markers
555 555
   var layer_data = L.layerGroup();
556 556
 
557 557
   //a few title layers
558 558
 <?php
559
-    if ($globalMapProvider == 'Mapbox') {
559
+	if ($globalMapProvider == 'Mapbox') {
560 560
 ?>
561 561
   L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
562 562
     maxZoom: 18,
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
     token : '<?php print $globalMapboxToken; ?>'
568 568
   }).addTo(map);
569 569
 <?php
570
-    } elseif ($globalMapProvider == 'OpenStreetMap') {
570
+	} elseif ($globalMapProvider == 'OpenStreetMap') {
571 571
 ?>
572 572
   L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
573 573
     maxZoom: 18,
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
       '<a href="http://www.openstreetmap.org/copyright">Open Database Licence</a>'
576 576
   }).addTo(map);
577 577
 <?php
578
-    } elseif ($globalMapProvider == 'MapQuest-OSM') {
578
+	} elseif ($globalMapProvider == 'MapQuest-OSM') {
579 579
 ?>
580 580
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
581 581
     maxZoom: 18,
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>'
585 585
   }).addTo(map);
586 586
 <?php
587
-    } elseif ($globalMapProvider == 'MapQuest-Aerial') {
587
+	} elseif ($globalMapProvider == 'MapQuest-Aerial') {
588 588
 ?>
589 589
   L.tileLayer('http://otile1.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
590 590
     maxZoom: 18,
@@ -593,27 +593,27 @@  discard block
 block discarded – undo
593 593
       'Tiles Courtesy of <a href="http://www.mapquest.com">MapQuest</a>, Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency"'
594 594
   }).addTo(map);
595 595
 <?php
596
-    } elseif ($globalMapProvider == 'Google-Roadmap') {
596
+	} elseif ($globalMapProvider == 'Google-Roadmap') {
597 597
 ?>
598 598
     var googleLayer = new L.Google('ROADMAP');
599 599
     map.addLayer(googleLayer);
600 600
 <?php
601
-    } elseif ($globalMapProvider == 'Google-Satellite') {
601
+	} elseif ($globalMapProvider == 'Google-Satellite') {
602 602
 ?>
603 603
     var googleLayer = new L.Google('SATELLITE');
604 604
     map.addLayer(googleLayer);
605 605
 <?php
606
-    } elseif ($globalMapProvider == 'Google-Hybrid') {
606
+	} elseif ($globalMapProvider == 'Google-Hybrid') {
607 607
 ?>
608 608
     var googleLayer = new L.Google('HYBRID');
609 609
     map.addLayer(googleLayer);
610 610
 <?php
611
-    } elseif ($globalMapProvider == 'Google-Terrain') {
611
+	} elseif ($globalMapProvider == 'Google-Terrain') {
612 612
 ?>
613 613
     var googleLayer = new L.Google('Terrain');
614 614
     map.addLayer(googleLayer);
615 615
 <?php
616
-    }
616
+	}
617 617
 ?>
618 618
         </script>
619 619
     </div>
Please login to merge, or discard this patch.
statistics.php 1 patch
Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
52 52
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
53 53
 	}
54
-    ?>
54
+	?>
55 55
     </div>
56 56
     <?php include('statistics-sub-menu.php'); ?>
57 57
     <p class="global-stats">
@@ -60,23 +60,23 @@  discard block
 block discarded – undo
60 60
         <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
61 61
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
62 62
 	<?php
63
-	    if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
63
+		if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
64 64
 	?>
65 65
     	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
66 66
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
67 67
         <?php
68
-    	    } else {
69
-    	?>
68
+			} else {
69
+		?>
70 70
     	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
71 71
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
72 72
     	<?php
73
-    	    }
74
-    	?>
73
+			}
74
+		?>
75 75
         <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
76 76
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
77 77
         <?php
78
-    		if ($airline_icao == '') {
79
-    	?>
78
+			if ($airline_icao == '') {
79
+		?>
80 80
         <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
81 81
 	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
82 82
 	<?php
@@ -99,88 +99,88 @@  discard block
 block discarded – undo
99 99
             <div class="col-md-6">
100 100
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
101 101
                  <?php
102
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
103
-		    if (count($aircraft_array) == 0) print _("No data available");
104
-		    else {
105
-                    print '<div id="chart1" class="chart" width="100%"></div><script>';
106
-                    $aircraft_data = '';
107
-                    foreach($aircraft_array as $aircraft_item)
108
-                    {
109
-                        $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
110
-                    }
111
-                    $aircraft_data = substr($aircraft_data, 0, -1);
112
-		    print 'var series = ['.$aircraft_data.'];';
113
-		    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
114
-		    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
115
-		    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
116
-                    print 'var aircraftype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
117
-                    print 'dataset';
118
-                    print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
119
-                    print '</script>';
120
-                  }
121
-                  ?>
102
+				  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
103
+			if (count($aircraft_array) == 0) print _("No data available");
104
+			else {
105
+					print '<div id="chart1" class="chart" width="100%"></div><script>';
106
+					$aircraft_data = '';
107
+					foreach($aircraft_array as $aircraft_item)
108
+					{
109
+						$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
110
+					}
111
+					$aircraft_data = substr($aircraft_data, 0, -1);
112
+			print 'var series = ['.$aircraft_data.'];';
113
+			print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
114
+			print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#e6e6f6","#1a3151"]);';
115
+			print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
116
+					print 'var aircraftype = new d3pie("chart1",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
117
+					print 'dataset';
118
+					print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
119
+					print '</script>';
120
+				  }
121
+				  ?>
122 122
                 <div class="more">
123 123
             	    <?php
124
-            		if ($year != '' && $month != '') {
125
-            	    ?>
124
+					if ($year != '' && $month != '') {
125
+					?>
126 126
             	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
127 127
             	    <?php
128
-            		} else {
129
-            	    ?>
128
+					} else {
129
+					?>
130 130
             	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
131 131
             	    <?php
132
-            		}
133
-            	    ?>
132
+					}
133
+					?>
134 134
                 </div>
135 135
             </div>
136 136
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
137 137
 <?php
138 138
 //    echo $airline_icao;
139
-    if ($airline_icao == '' || $airline_icao == 'all') {
139
+	if ($airline_icao == '' || $airline_icao == 'all') {
140 140
 	$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
141 141
 	if (count($airline_array) > 0) {
142
-            print '<div class="col-md-6">';
143
-	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
144
-	    print '<div id="chart2" class="chart" width="100%"></div><script>';
145
-	    $airline_data = '';
146
-	    foreach($airline_array as $airline_item)
147
-	    {
142
+			print '<div class="col-md-6">';
143
+		print '<h2>'._("Top 10 Most Common Airline").'</h2>';
144
+		print '<div id="chart2" class="chart" width="100%"></div><script>';
145
+		$airline_data = '';
146
+		foreach($airline_array as $airline_item)
147
+		{
148 148
 		$airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
149
-	    }
150
-	    $airline_data = substr($airline_data, 0, -1);
151
-	    print 'var series = ['.$airline_data.'];';
152
-	    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
153
-	    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
154
-	    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
155
-            print 'var airlinescnt = new d3pie("chart2",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
156
-	    print 'dataset';
157
-            print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
158
-            print '</script>';
159
-	    if ($year != '' && $month != '') {
149
+		}
150
+		$airline_data = substr($airline_data, 0, -1);
151
+		print 'var series = ['.$airline_data.'];';
152
+		print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
153
+		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
154
+		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
155
+			print 'var airlinescnt = new d3pie("chart2",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
156
+		print 'dataset';
157
+			print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
158
+			print '</script>';
159
+		if ($year != '' && $month != '') {
160 160
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
161 161
 		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
162 162
 		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
163
-	    } else {
163
+		} else {
164 164
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
165 165
 		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
166 166
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
167
-	    }
168
-    	    print '</div>';
167
+		}
168
+			print '</div>';
169 169
 	}
170 170
 ?>
171 171
         </div>
172 172
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
173 173
 <?php
174
-    }
174
+	}
175 175
 ?>
176 176
         <div class="row column">
177 177
 <?php
178
-    $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
179
-    if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
178
+	$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
179
+	if ((isset($globalVA) && $globalVA) ||(isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
180 180
 	if (empty($flightover_array)) {
181
-	    print '<div class="col-md-12">';
181
+		print '<div class="col-md-12">';
182 182
 	} else {
183
-            print '<div class="col-md-6">';
183
+			print '<div class="col-md-6">';
184 184
 	}
185 185
 ?>
186 186
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
@@ -188,23 +188,23 @@  discard block
 block discarded – undo
188 188
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
189 189
 	if (count($pilot_array) == 0) print _("No data available");
190 190
 	else {
191
-	    print '<div id="chart7" class="chart" width="100%"></div><script>';
192
-	    $pilot_data = '';
193
-	    foreach($pilot_array as $pilot_item)
194
-	    {
191
+		print '<div id="chart7" class="chart" width="100%"></div><script>';
192
+		$pilot_data = '';
193
+		foreach($pilot_array as $pilot_item)
194
+		{
195 195
 		$pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
196
-	    }
197
-	    $pilot_data = substr($pilot_data, 0, -1);
198
-	    print 'var series = ['.$pilot_data.'];';
199
-	    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
200
-	    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
201
-	    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
202
-            print 'var pilotcnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
203
-	    print 'dataset';
204
-            print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
205
-            print '</script>';
206
-        }
207
-        print '<div class="more">';
196
+		}
197
+		$pilot_data = substr($pilot_data, 0, -1);
198
+		print 'var series = ['.$pilot_data.'];';
199
+		print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
200
+		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
201
+		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
202
+			print 'var pilotcnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
203
+		print 'dataset';
204
+			print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
205
+			print '</script>';
206
+		}
207
+		print '<div class="more">';
208 208
 	print '<a href="'.$globalURL.'/statistics/pilot'; 
209 209
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
210 210
 	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         
215 215
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
216 216
 <?php
217
-    } else {
217
+	} else {
218 218
 ?>
219 219
             <div class="col-md-6">
220 220
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
@@ -222,21 +222,21 @@  discard block
 block discarded – undo
222 222
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
223 223
 	if (count($owner_array) == 0) print _("No data available");
224 224
 	else {
225
-	    print '<div id="chart7" class="chart" width="100%"></div><script>';
226
-	    $owner_data = '';
227
-	    foreach($owner_array as $owner_item)
228
-	    {
225
+		print '<div id="chart7" class="chart" width="100%"></div><script>';
226
+		$owner_data = '';
227
+		foreach($owner_array as $owner_item)
228
+		{
229 229
 		$owner_data .= '["'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
230
-	    }
231
-	    $owner_data = substr($owner_data, 0, -1);
232
-	    print 'var series = ['.$owner_data.'];';
233
-	    print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
234
-	    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
235
-	    print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
236
-            print 'var ownercnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
237
-	    print 'dataset';
238
-            print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
239
-	    print '</script>';
230
+		}
231
+		$owner_data = substr($owner_data, 0, -1);
232
+		print 'var series = ['.$owner_data.'];';
233
+		print 'var dataset = [];var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
234
+		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
235
+		print 'series.forEach(function(item){var lab = item[0], value = item[1]; dataset.push({"label":lab,"value":value,"color":paletteScale(value)});});';
236
+			print 'var ownercnt = new d3pie("chart7",{"header":{"title":{"fontSize":24,"font":"open sans"},"subtitle":{"color":"#999999","fontSize":12,"font":"open sans"},"titleSubtitlePadding":9},"footer":{"color":"#999999","fontSize":10,"font":"open sans","location":"bottom-left"},"size":{"canvasWidth":700,"pieOuterRadius":"60%"},"data":{"sortOrder":"value-desc","content":';
237
+		print 'dataset';
238
+			print '},"labels":{"outer":{"pieDistance":32},"inner":{"hideWhenLessThanPercentage":3},"mainLabel":{"fontSize":11},"percentage":{"color":"#ffffff","decimalPlaces":0},"value":{"color":"#adadad","fontSize":11},"lines":{"enabled":true},"truncation":{"enabled":true}},"effects":{"pullOutSegmentOnClick":{"effect":"linear","speed":400,"size":8}},"misc":{"gradient":{"enabled":true,"percentage":100}}});';
239
+		print '</script>';
240 240
 	}
241 241
 ?>
242 242
                 <div class="more">
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
         
247 247
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
248 248
 <?php
249
-    }
250
-    if (!empty($flightover_array)) {
249
+	}
250
+	if (!empty($flightover_array)) {
251 251
 ?>
252 252
             <div class="col-md-6">
253 253
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
@@ -255,20 +255,20 @@  discard block
 block discarded – undo
255 255
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
256 256
 	if (count($flightover_array) == 0) print _("No data available");
257 257
 	else {
258
-	    print '<div id="chart10" class="chart" width="100%"></div><script>';
259
-	    print 'var series = [';
260
-            $flightover_data = '';
261
-	    foreach($flightover_array as $flightover_item)
262
-	    {
258
+		print '<div id="chart10" class="chart" width="100%"></div><script>';
259
+		print 'var series = [';
260
+			$flightover_data = '';
261
+		foreach($flightover_array as $flightover_item)
262
+		{
263 263
 		$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
264
-	    }
265
-	    $flightover_data = substr($flightover_data, 0, -1);
266
-	    print $flightover_data;
267
-	    print '];';
268
-	    print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
269
-	    print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
270
-	    print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
271
-	    print 'new Datamap({
264
+		}
265
+		$flightover_data = substr($flightover_data, 0, -1);
266
+		print $flightover_data;
267
+		print '];';
268
+		print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
269
+		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
270
+		print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
271
+		print 'new Datamap({
272 272
 		element: document.getElementById("chart10"),
273 273
 		projection: "mercator", // big world map
274 274
 		fills: { defaultFill: "#F5F5F5" },
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         	    }
294 294
 		}
295 295
 	    });";
296
-	    print '</script>';
296
+		print '</script>';
297 297
 	}
298 298
 ?>
299 299
                 <div class="more">
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
                 </div>
302 302
             </div>
303 303
 <?php
304
-    }
304
+	}
305 305
 ?>
306 306
         </div>
307 307
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -311,13 +311,13 @@  discard block
 block discarded – undo
311 311
         <div class="row column">
312 312
             <div class="col-md-6">
313 313
 <?php
314
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
315
-    if (count($airport_airport_array) > 0) {
314
+	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
315
+	if (count($airport_airport_array) > 0) {
316 316
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
317 317
 	print '<div id="chart3" class="chart" width="100%"></div><script>';
318
-        print "\n";
319
-        print 'var series = [';
320
-        $airport_data = '';
318
+		print "\n";
319
+		print 'var series = [';
320
+		$airport_data = '';
321 321
 	foreach($airport_airport_array as $airport_item)
322 322
 	{
323 323
 		$airport_data .= '[ "'.$airport_item['airport_departure_icao_count'].'", "'.$airport_item['airport_departure_icao'].'",'.$airport_item['airport_departure_latitude'].','.$airport_item['airport_departure_longitude'].'],';
@@ -366,20 +366,20 @@  discard block
 block discarded – undo
366 366
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
367 367
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
368 368
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
369
-    }
369
+	}
370 370
 ?>
371 371
             </div>
372 372
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
373 373
 
374 374
             <div class="col-md-6">
375 375
 <?php
376
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
377
-    if (count($airport_airport_array2) > 0) {
376
+	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
377
+	if (count($airport_airport_array2) > 0) {
378 378
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
379 379
 	print '<div id="chart4" class="chart" width="100%"></div><script>';
380
-        print "\n";
381
-        print 'var series = [';
382
-        $airport_data = '';
380
+		print "\n";
381
+		print 'var series = [';
382
+		$airport_data = '';
383 383
 	foreach($airport_airport_array2 as $airport_item)
384 384
 	{
385 385
 		$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
@@ -429,28 +429,28 @@  discard block
 block discarded – undo
429 429
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
430 430
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
431 431
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
432
-    }
432
+	}
433 433
 ?>
434 434
             </div>
435 435
         </div>
436 436
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
437 437
 <?php
438
-    if ($year == '' && $month == '') {
438
+	if ($year == '' && $month == '') {
439 439
 ?>
440 440
         <div class="row column">
441 441
             <div class="col-md-6">
442 442
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
443 443
                 <?php
444
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
445
-		    if (count($year_array) == 0) print _("No data available");
446
-		    else {
444
+				  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
445
+			if (count($year_array) == 0) print _("No data available");
446
+			else {
447 447
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
448 448
 			$year_data = '';
449 449
 			$year_cnt = '';
450 450
 			foreach($year_array as $year_item)
451 451
 			{
452
-			    $year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
453
-			    $year_cnt .= $year_item['date_count'].',';
452
+				$year_data .= '"'.$year_item['year_name'].'-'.$year_item['month_name'].'-01'.'",';
453
+				$year_cnt .= $year_item['date_count'].',';
454 454
 			}
455 455
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
456 456
 			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
                 	     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
461 461
                 	     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m"}}, y: { label: "# of Flights"}},legend: { show: false }});';
462 462
 			print '</script>';
463
-                    }
464
-                  ?>
463
+					}
464
+				  ?>
465 465
                 <div class="more">
466 466
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
467 467
                 </div>
@@ -470,16 +470,16 @@  discard block
 block discarded – undo
470 470
             <div class="col-md-6">
471 471
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
472 472
                 <?php
473
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
474
-		    if (count($month_array) == 0) print _("No data available");
475
-		    else {
476
-                	print '<div id="chart9" class="chart" width="100%"></div><script>';
477
-                        $month_data = '';
473
+				  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
474
+			if (count($month_array) == 0) print _("No data available");
475
+			else {
476
+					print '<div id="chart9" class="chart" width="100%"></div><script>';
477
+						$month_data = '';
478 478
 			$month_cnt = '';
479 479
 			foreach($month_array as $month_item)
480 480
 			{
481
-			    $month_data .= '"'.$month_item['date_name'].'",';
482
-			    $month_cnt .= $month_item['date_count'].',';
481
+				$month_data .= '"'.$month_item['date_name'].'",';
482
+				$month_cnt .= $month_item['date_count'].',';
483 483
 			}
484 484
 			$month_data = "['x',".substr($month_data, 0, -1)."]";
485 485
 			$month_cnt = "['flights',".substr($month_cnt,0,-1)."]";
@@ -489,9 +489,9 @@  discard block
 block discarded – undo
489 489
                 	     columns: ['.$month_data.','.$month_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
490 490
                 	     axis: { x: { type: "timeseries", localtime: false,tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
491 491
 			
492
-            		print '</script>';
493
-                    }
494
-                  ?>
492
+					print '</script>';
493
+					}
494
+				  ?>
495 495
                 <div class="more">
496 496
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
497 497
                 </div>
@@ -501,16 +501,16 @@  discard block
 block discarded – undo
501 501
             <div class="col-md-6">
502 502
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
503 503
                 <?php
504
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
505
-		    if (empty($date_array)) print _("No data available");
506
-		    else {
507
-                	print '<div id="chart5" class="chart" width="100%"></div><script>';
508
-                        $date_data = '';
504
+					$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
505
+			if (empty($date_array)) print _("No data available");
506
+			else {
507
+					print '<div id="chart5" class="chart" width="100%"></div><script>';
508
+						$date_data = '';
509 509
 			$date_cnt = '';
510 510
 			foreach($date_array as $date_item)
511 511
 			{
512
-			    $date_data .= '"'.$date_item['date_name'].'",';
513
-			    $date_cnt .= $date_item['date_count'].',';
512
+				$date_data .= '"'.$date_item['date_name'].'",';
513
+				$date_cnt .= $date_item['date_count'].',';
514 514
 			}
515 515
 			$date_data = "['x',".substr($date_data, 0, -1)."]";
516 516
 			$date_cnt = "['flights',".substr($date_cnt,0,-1)."]";
@@ -520,9 +520,9 @@  discard block
 block discarded – undo
520 520
                 	     columns: ['.$date_data.','.$date_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
521 521
                 	     axis: { x: { type: "timeseries",tick: { format: "%Y-%m-%d"}}, y: { label: "# of Flights"}},legend: { show: false }});';
522 522
 			
523
-                	print '</script>';
524
-                    }
525
-                  ?>
523
+					print '</script>';
524
+					}
525
+				  ?>
526 526
                 <div class="more">
527 527
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
528 528
                 </div>
@@ -531,16 +531,16 @@  discard block
 block discarded – undo
531 531
             <div class="col-md-6">
532 532
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
533 533
                 <?php
534
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
535
-		    if (empty($hour_array)) print _("No data available");
536
-		    else {
537
-                	print '<div id="chart6" class="chart" width="100%"></div><script>';
538
-                        $hour_data = '';
534
+				  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
535
+			if (empty($hour_array)) print _("No data available");
536
+			else {
537
+					print '<div id="chart6" class="chart" width="100%"></div><script>';
538
+						$hour_data = '';
539 539
 			$hour_cnt = '';
540 540
 			foreach($hour_array as $hour_item)
541 541
 			{
542
-			    $hour_data .= '"'.$hour_item['hour_name'].':00",';
543
-			    $hour_cnt .= $hour_item['hour_count'].',';
542
+				$hour_data .= '"'.$hour_item['hour_name'].':00",';
543
+				$hour_cnt .= $hour_item['hour_count'].',';
544 544
 			}
545 545
 			$hour_data = "[".substr($hour_data, 0, -1)."]";
546 546
 			$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
                 	     columns: ['.$hour_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
551 551
                 	     axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});';
552 552
 
553
-            	     print '</script>';
554
-                  }
555
-                ?>
553
+					 print '</script>';
554
+				  }
555
+				?>
556 556
                 <div class="more">
557 557
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
558 558
                 </div>
@@ -560,26 +560,26 @@  discard block
 block discarded – undo
560 560
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
561 561
         </div>
562 562
 <?php
563
-    }
563
+	}
564 564
 ?>
565 565
 
566 566
 <?php
567
-    if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
567
+	if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
568 568
 ?>
569 569
         <div class="row column">
570 570
             <div class="col-md-6">
571 571
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
572 572
                 <?php
573
-                  $year_array = $Stats->countFatalitiesByYear();
574
-		    if (count($year_array) == 0) print _("No data available");
575
-		    else {
573
+				  $year_array = $Stats->countFatalitiesByYear();
574
+			if (count($year_array) == 0) print _("No data available");
575
+			else {
576 576
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
577
-                        $year_data = '';
577
+						$year_data = '';
578 578
 			$year_cnt = '';
579 579
 			foreach($year_array as $year_item)
580 580
 			{
581
-			    $year_data .= '"'.$year_item['year'].'-01-01",';
582
-			    $year_cnt .= $year_item['count'].',';
581
+				$year_data .= '"'.$year_item['year'].'-01-01",';
582
+				$year_cnt .= $year_item['count'].',';
583 583
 			}
584 584
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
585 585
 			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
                 	     axis: { x: { type: "timeseries",tick: { format: "%Y"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
591 591
 
592 592
 			print '</script>';
593
-		    }
594
-                  ?>
593
+			}
594
+				  ?>
595 595
                 <div class="more">
596 596
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
597 597
                 </div>
@@ -602,16 +602,16 @@  discard block
 block discarded – undo
602 602
             <div class="col-md-6">
603 603
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
604 604
                 <?php
605
-                  $year_array = $Stats->countFatalitiesLast12Months();
606
-		    if (count($year_array) == 0) print _("No data available");
607
-		    else {
605
+				  $year_array = $Stats->countFatalitiesLast12Months();
606
+			if (count($year_array) == 0) print _("No data available");
607
+			else {
608 608
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
609
-                        $year_data = '';
609
+						$year_data = '';
610 610
 			$year_cnt = '';
611 611
 			foreach($year_array as $year_item)
612 612
 			{
613
-			    $year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
614
-			    $year_cnt .= $year_item['count'].',';
613
+				$year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",';
614
+				$year_cnt .= $year_item['count'].',';
615 615
 			}
616 616
 			$year_data = "['x',".substr($year_data, 0, -1)."]";
617 617
 			$year_cnt = "['flights',".substr($year_cnt,0,-1)."]";
@@ -621,8 +621,8 @@  discard block
 block discarded – undo
621 621
                 	     columns: ['.$year_data.','.$year_cnt.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
622 622
                 	     axis: { x: { type: "timeseries",tick: { format: "%Y-%m"}}, y: { label: "# of Fatalities"}},legend: { show: false }});';
623 623
 			print '</script>';
624
-		    }
625
-                  ?>
624
+			}
625
+				  ?>
626 626
                 <div class="more">
627 627
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
628 628
                 </div>
@@ -630,30 +630,30 @@  discard block
 block discarded – undo
630 630
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
631 631
 <br/>
632 632
 <?php
633
-    }
633
+	}
634 634
 ?>
635 635
 
636 636
 <?php
637
-    if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
637
+	if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
638 638
 ?>
639 639
         <div class="row column">
640 640
         	<?php
641
-        	    //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
642
-        	    if ($year == '' && $month == '') {
643
-		        $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
644
-		    } else {
645
-        		$polar = $Stats->getStatsSource('polar',$year,$month);
646
-        	    }
647
-        	    if (!empty($polar)) {
648
-            		print '<h2>'._("Coverage pattern").'</h2>';
649
-        		foreach ($polar as $eachpolar) {
650
-        		    unset($polar_data);
651
-	        	    $Spotter = new Spotter();
652
-        		    $data = json_decode($eachpolar['source_data']);
653
-        		    foreach($data as $value => $key) {
654
-        			$direction = $Spotter->parseDirection(($value*22.5));
655
-        			$distance = $key;
656
-        			$unit = 'km';
641
+				//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
642
+				if ($year == '' && $month == '') {
643
+				$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
644
+			} else {
645
+				$polar = $Stats->getStatsSource('polar',$year,$month);
646
+				}
647
+				if (!empty($polar)) {
648
+					print '<h2>'._("Coverage pattern").'</h2>';
649
+				foreach ($polar as $eachpolar) {
650
+					unset($polar_data);
651
+					$Spotter = new Spotter();
652
+					$data = json_decode($eachpolar['source_data']);
653
+					foreach($data as $value => $key) {
654
+					$direction = $Spotter->parseDirection(($value*22.5));
655
+					$distance = $key;
656
+					$unit = 'km';
657 657
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
658 658
 					$distance = round($distance*0.539957);
659 659
 					$unit = 'nm';
@@ -664,10 +664,10 @@  discard block
 block discarded – undo
664 664
 					$distance = $distance;
665 665
 					$unit = 'km';
666 666
 				}
667
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
668
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
669
-        		    }
670
-        	?>
667
+					if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
668
+						else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
669
+					}
670
+			?>
671 671
             <div class="col-md-6">
672 672
                 <h4><?php print $eachpolar['source_name']; ?></h4>
673 673
         	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
@@ -699,27 +699,27 @@  discard block
 block discarded – undo
699 699
 		</script>
700 700
             </div>
701 701
             <?php
702
-        	    }
703
-        	}
704
-            ?>
702
+				}
703
+			}
704
+			?>
705 705
         </div>
706 706
         <div class="row column">
707 707
             <div class="col-md-6">
708 708
         	<?php
709
-        	    //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
710
-        	    if ($year == '' && $month == '') {
711
-        		$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
712
-        	    } else {
713
-        		$msg = $Stats->getStatsSource('msg',$year,$month);
714
-        	    }
715
-        	    if (!empty($msg)) {
716
-            		print '<h2>'._("Messages received").'</h2>';
717
-        		foreach ($msg as $eachmsg) {
718
-        		    //$eachmsg = $msg[0];
719
-        		    $data = $eachmsg['source_data'];
720
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
721
-        		    else $max = 500;
722
-        	?>
709
+				//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
710
+				if ($year == '' && $month == '') {
711
+				$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
712
+				} else {
713
+				$msg = $Stats->getStatsSource('msg',$year,$month);
714
+				}
715
+				if (!empty($msg)) {
716
+					print '<h2>'._("Messages received").'</h2>';
717
+				foreach ($msg as $eachmsg) {
718
+					//$eachmsg = $msg[0];
719
+					$data = $eachmsg['source_data'];
720
+					if ($data > 500) $max = (round(($data+100)/100))*100;
721
+					else $max = 500;
722
+			?>
723 723
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
724 724
         	<script>
725 725
 		      var g = new JustGage({
@@ -735,9 +735,9 @@  discard block
 block discarded – undo
735 735
 			  });
736 736
 		</script>
737 737
             <?php
738
-        	   }
739
-        	}
740
-            ?>
738
+			   }
739
+			}
740
+			?>
741 741
             </div>
742 742
         </div>
743 743
         <div class="row column">
@@ -775,26 +775,26 @@  discard block
 block discarded – undo
775 775
 			//$hist_data = substr($hist_data, 0, -1);
776 776
 			$distance_data = "['x',".substr($distance_data, 0, -1)."]";
777 777
 			$nb_data = "['flights',".substr($nb_data, 0, -1)."]";
778
-            ?>
778
+			?>
779 779
             <div class="col-md-6">
780 780
                 <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
781 781
                 <?php
782
-                    print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
783
-		    print 'c3.generate({
782
+					print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div><script>';
783
+			print 'c3.generate({
784 784
 			bindto: "#charthist-'.str_replace(' ','_',strtolower($source)).'",
785 785
 			data: { x: "x",
786 786
 			columns: ['.$distance_data.','.$nb_data.'], types: { flights: "area"}, colors: { flights: "#1a3151"}},
787 787
 			axis: { x: {label : { text: "Distance in '.$unit.'", position: "outer-right"}}, y: { label: "# of Flights"}},legend: { show: false }});';
788
-		    print '</script>';
789
-        	?>
788
+			print '</script>';
789
+			?>
790 790
     	    </div>
791 791
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
792 792
         	<?php
793
-                  }
794
-                ?>
793
+				  }
794
+				?>
795 795
         </div>
796 796
 <?php
797
-    }
797
+	}
798 798
 ?>
799 799
     </div>
800 800
 </div>  
Please login to merge, or discard this patch.
require/class.Image.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
 	}
13 13
 
14 14
 	/**
15
-	* Gets the images based on the aircraft registration
16
-	*
17
-	* @return Array the images list
18
-	*
19
-	*/
15
+	 * Gets the images based on the aircraft registration
16
+	 *
17
+	 * @return Array the images list
18
+	 *
19
+	 */
20 20
 	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
21 21
 	{
22 22
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	}
38 38
 
39 39
 	/**
40
-	* Gets the images based on the ship name
41
-	*
42
-	* @return Array the images list
43
-	*
44
-	*/
40
+	 * Gets the images based on the ship name
41
+	 *
42
+	 * @return Array the images list
43
+	 *
44
+	 */
45 45
 	public function getMarineImage($mmsi,$imo = '',$name = '')
46 46
 	{
47 47
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 	}
69 69
 
70 70
 	/**
71
-	* Gets the image copyright based on the Exif data
72
-	*
73
-	* @return String image copyright
74
-	*
75
-	*/
71
+	 * Gets the image copyright based on the Exif data
72
+	 *
73
+	 * @return String image copyright
74
+	 *
75
+	 */
76 76
 	public function getExifCopyright($url) {
77 77
 		$exif = exif_read_data($url);
78 78
 		$copyright = '';
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 	}
88 88
 
89 89
 	/**
90
-	* Adds the images based on the aircraft registration
91
-	*
92
-	* @return String either success or error
93
-	*
94
-	*/
90
+	 * Adds the images based on the aircraft registration
91
+	 *
92
+	 * @return String either success or error
93
+	 *
94
+	 */
95 95
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
96 96
 	{
97 97
 		global $globalDebug,$globalAircraftImageFetch;
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 	}
120 120
 
121 121
 	/**
122
-	* Adds the images based on the marine name
123
-	*
124
-	* @return String either success or error
125
-	*
126
-	*/
122
+	 * Adds the images based on the marine name
123
+	 *
124
+	 * @return String either success or error
125
+	 *
126
+	 */
127 127
 	public function addMarineImage($mmsi,$imo = '',$name = '')
128 128
 	{
129 129
 		global $globalDebug,$globalMarineImageFetch;
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
 	}
161 161
 
162 162
 	/**
163
-	* Gets the aircraft image
164
-	*
165
-	* @param String $aircraft_registration the registration of the aircraft
166
-	* @return Array the aircraft thumbnail, orignal url and copyright
167
-	*
168
-	*/
163
+	 * Gets the aircraft image
164
+	 *
165
+	 * @param String $aircraft_registration the registration of the aircraft
166
+	 * @return Array the aircraft thumbnail, orignal url and copyright
167
+	 *
168
+	 */
169 169
 	public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '')
170 170
 	{
171 171
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
 	}
210 210
 
211 211
 	/**
212
-	* Gets the vessel image
213
-	*
214
-	* @param String $mmsi the vessel mmsi
215
-	* @param String $imo the vessel imo
216
-	* @param String $name the vessel name
217
-	* @return Array the aircraft thumbnail, orignal url and copyright
218
-	*
219
-	*/
212
+	 * Gets the vessel image
213
+	 *
214
+	 * @param String $mmsi the vessel mmsi
215
+	 * @param String $imo the vessel imo
216
+	 * @param String $name the vessel name
217
+	 * @return Array the aircraft thumbnail, orignal url and copyright
218
+	 *
219
+	 */
220 220
 	public function findMarineImage($mmsi,$imo = '',$name = '')
221 221
 	{
222 222
 		global $globalMarineImageSources;
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
 	}
251 251
 
252 252
 	/**
253
-	* Gets the aircraft image from Planespotters
254
-	*
255
-	* @param String $aircraft_registration the registration of the aircraft
256
-	* @param String $aircraft_name type of the aircraft
257
-	* @return Array the aircraft thumbnail, orignal url and copyright
258
-	*
259
-	*/
253
+	 * Gets the aircraft image from Planespotters
254
+	 *
255
+	 * @param String $aircraft_registration the registration of the aircraft
256
+	 * @param String $aircraft_name type of the aircraft
257
+	 * @return Array the aircraft thumbnail, orignal url and copyright
258
+	 *
259
+	 */
260 260
 	public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') {
261 261
 		$Common = new Common();
262 262
 		// If aircraft registration is only number, also check with aircraft model
@@ -283,13 +283,13 @@  discard block
 block discarded – undo
283 283
 	}
284 284
 
285 285
 	/**
286
-	* Gets the aircraft image from Deviantart
287
-	*
288
-	* @param String $registration the registration of the aircraft
289
-	* @param String $name type of the aircraft
290
-	* @return Array the aircraft thumbnail, orignal url and copyright
291
-	*
292
-	*/
286
+	 * Gets the aircraft image from Deviantart
287
+	 *
288
+	 * @param String $registration the registration of the aircraft
289
+	 * @param String $name type of the aircraft
290
+	 * @return Array the aircraft thumbnail, orignal url and copyright
291
+	 *
292
+	 */
293 293
 	public function fromDeviantart($type,$registration, $name='') {
294 294
 		$Common = new Common();
295 295
 		if ($type == 'aircraft') {
@@ -321,13 +321,13 @@  discard block
 block discarded – undo
321 321
 	}
322 322
 
323 323
 	/**
324
-	* Gets the aircraft image from JetPhotos
325
-	*
326
-	* @param String $aircraft_registration the registration of the aircraft
327
-	* @param String $aircraft_name type of the aircraft
328
-	* @return Array the aircraft thumbnail, orignal url and copyright
329
-	*
330
-	*/
324
+	 * Gets the aircraft image from JetPhotos
325
+	 *
326
+	 * @param String $aircraft_registration the registration of the aircraft
327
+	 * @param String $aircraft_name type of the aircraft
328
+	 * @return Array the aircraft thumbnail, orignal url and copyright
329
+	 *
330
+	 */
331 331
 	public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
332 332
 		$Common = new Common();
333 333
 		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
@@ -363,13 +363,13 @@  discard block
 block discarded – undo
363 363
 	}
364 364
 
365 365
 	/**
366
-	* Gets the aircraft image from PlanePictures
367
-	*
368
-	* @param String $aircraft_registration the registration of the aircraft
369
-	* @param String $aircraft_name type of the aircraft
370
-	* @return Array the aircraft thumbnail, orignal url and copyright
371
-	*
372
-	*/
366
+	 * Gets the aircraft image from PlanePictures
367
+	 *
368
+	 * @param String $aircraft_registration the registration of the aircraft
369
+	 * @param String $aircraft_name type of the aircraft
370
+	 * @return Array the aircraft thumbnail, orignal url and copyright
371
+	 *
372
+	 */
373 373
 	public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
374 374
 		$Common = new Common();
375 375
 		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
 	}
398 398
 
399 399
 	/**
400
-	* Gets the aircraft image from Flickr
401
-	*
402
-	* @param String $registration the registration of the aircraft
403
-	* @param String $name type of the aircraft
404
-	* @return Array the aircraft thumbnail, orignal url and copyright
405
-	*
406
-	*/
400
+	 * Gets the aircraft image from Flickr
401
+	 *
402
+	 * @param String $registration the registration of the aircraft
403
+	 * @param String $name type of the aircraft
404
+	 * @return Array the aircraft thumbnail, orignal url and copyright
405
+	 *
406
+	 */
407 407
 	public function fromFlickr($type,$registration,$name='') {
408 408
 		$Common = new Common();
409 409
 		if ($type == 'aircraft') {
@@ -446,13 +446,13 @@  discard block
 block discarded – undo
446 446
 	}
447 447
 
448 448
 	/**
449
-	* Gets the aircraft image from Bing
450
-	*
451
-	* @param String $aircraft_registration the registration of the aircraft
452
-	* @param String $aircraft_name type of the aircraft
453
-	* @return Array the aircraft thumbnail, orignal url and copyright
454
-	*
455
-	*/
449
+	 * Gets the aircraft image from Bing
450
+	 *
451
+	 * @param String $aircraft_registration the registration of the aircraft
452
+	 * @param String $aircraft_name type of the aircraft
453
+	 * @return Array the aircraft thumbnail, orignal url and copyright
454
+	 *
455
+	 */
456 456
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
457 457
 		global $globalImageBingKey;
458 458
 		$Common = new Common();
@@ -478,13 +478,13 @@  discard block
 block discarded – undo
478 478
 	}
479 479
 
480 480
 	/**
481
-	* Gets the aircraft image from airport-data
482
-	*
483
-	* @param String $aircraft_registration the registration of the aircraft
484
-	* @param String $aircraft_name type of the aircraft
485
-	* @return Array the aircraft thumbnail, orignal url and copyright
486
-	*
487
-	*/
481
+	 * Gets the aircraft image from airport-data
482
+	 *
483
+	 * @param String $aircraft_registration the registration of the aircraft
484
+	 * @param String $aircraft_name type of the aircraft
485
+	 * @return Array the aircraft thumbnail, orignal url and copyright
486
+	 *
487
+	 */
488 488
 	public function fromAirportData($type,$aircraft_registration,$aircraft_name='') {
489 489
 		$Common = new Common();
490 490
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
@@ -503,13 +503,13 @@  discard block
 block discarded – undo
503 503
 	}
504 504
 
505 505
 	/**
506
-	* Gets image from WikiMedia
507
-	*
508
-	* @param String $registration the registration of the aircraft/mmsi
509
-	* @param String $name name
510
-	* @return Array the aircraft thumbnail, orignal url and copyright
511
-	*
512
-	*/
506
+	 * Gets image from WikiMedia
507
+	 *
508
+	 * @param String $registration the registration of the aircraft/mmsi
509
+	 * @param String $name name
510
+	 * @return Array the aircraft thumbnail, orignal url and copyright
511
+	 *
512
+	 */
513 513
 	public function fromWikimedia($type,$registration,$name='') {
514 514
 		$Common = new Common();
515 515
 		if ($type == 'aircraft') {
@@ -564,13 +564,13 @@  discard block
 block discarded – undo
564 564
 	}
565 565
 
566 566
 	/**
567
-	* Gets the aircraft image from custom url
568
-	*
569
-	* @param String $registration the registration of the aircraft
570
-	* @param String $name type of the aircraft
571
-	* @return Array the aircraft thumbnail, orignal url and copyright
572
-	*
573
-	*/
567
+	 * Gets the aircraft image from custom url
568
+	 *
569
+	 * @param String $registration the registration of the aircraft
570
+	 * @param String $name type of the aircraft
571
+	 * @return Array the aircraft thumbnail, orignal url and copyright
572
+	 *
573
+	 */
574 574
 	public function fromCustomSource($type,$registration,$name='') {
575 575
 		global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug;
576 576
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Indentation   +863 added lines, -863 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17 17
 if (isset($globalMarine) && $globalMarine) {
18
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
18
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 20
 }
21 21
 
22 22
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -24,42 +24,42 @@  discard block
 block discarded – undo
24 24
 // Check if schema is at latest version
25 25
 $Connection = new Connection();
26 26
 if ($Connection->latest() === false) {
27
-    echo "You MUST update to latest schema. Run install/index.php";
28
-    exit();
27
+	echo "You MUST update to latest schema. Run install/index.php";
28
+	exit();
29 29
 }
30 30
 if (PHP_SAPI != 'cli') {
31
-    echo "This script MUST be called from console, not a web browser.";
31
+	echo "This script MUST be called from console, not a web browser.";
32 32
 //    exit();
33 33
 }
34 34
 
35 35
 // This is to be compatible with old version of settings.php
36 36
 if (!isset($globalSources)) {
37
-    if (isset($globalSBS1Hosts)) {
38
-        //$hosts = $globalSBS1Hosts;
39
-        foreach ($globalSBS1Hosts as $host) {
40
-	    $globalSources[] = array('host' => $host);
41
-    	}
42
-    } else {
43
-        if (!isset($globalSBS1Host)) {
44
-	    echo '$globalSources MUST be defined !';
45
-	    die;
37
+	if (isset($globalSBS1Hosts)) {
38
+		//$hosts = $globalSBS1Hosts;
39
+		foreach ($globalSBS1Hosts as $host) {
40
+		$globalSources[] = array('host' => $host);
41
+		}
42
+	} else {
43
+		if (!isset($globalSBS1Host)) {
44
+		echo '$globalSources MUST be defined !';
45
+		die;
46 46
 	}
47 47
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
48 48
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
49
-    }
49
+	}
50 50
 }
51 51
 
52 52
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
53 53
 //if (isset($options['s'])) $hosts = array($options['s']);
54 54
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 55
 if (isset($options['s'])) {
56
-    $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
-    else $globalSources[] = array('host' => $options['s']);
56
+	$globalSources = array();
57
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
+	else $globalSources[] = array('host' => $options['s']);
59 59
 } elseif (isset($options['source'])) {
60
-    $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
-    else $globalSources[] = array('host' => $options['source']);
60
+	$globalSources = array();
61
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
+	else $globalSources[] = array('host' => $options['source']);
63 63
 }
64 64
 if (isset($options['aprsserverhost'])) {
65 65
 	$globalServerAPRS = TRUE;
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 if (isset($options['idsource'])) $id_source = $options['idsource'];
75 75
 else $id_source = 1;
76 76
 if (isset($globalServer) && $globalServer) {
77
-    if ($globalDebug) echo "Using Server Mode\n";
78
-    $SI=new SpotterServer();
77
+	if ($globalDebug) echo "Using Server Mode\n";
78
+	$SI=new SpotterServer();
79 79
 /*
80 80
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 81
     $SI = new adsb2aprs();
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 } else $SI=new SpotterImport($Connection->db);
85 85
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
86 86
 if (isset($globalMarine) && $globalMarine) {
87
-    $AIS = new AIS();
88
-    $MI = new MarineImport($Connection->db);
87
+	$AIS = new AIS();
88
+	$MI = new MarineImport($Connection->db);
89 89
 }
90 90
 //$APRS=new APRS($Connection->db);
91 91
 $SBS=new SBS();
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 //$servertz = system('date +%Z');
96 96
 // signal handler - playing nice with sockets and dump1090
97 97
 if (function_exists('pcntl_fork')) {
98
-    pcntl_signal(SIGINT,  function() {
99
-        global $sockets;
100
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101
-        die("Bye!\n");
102
-    });
103
-    pcntl_signal_dispatch();
98
+	pcntl_signal(SIGINT,  function() {
99
+		global $sockets;
100
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101
+		die("Bye!\n");
102
+	});
103
+	pcntl_signal_dispatch();
104 104
 }
105 105
 
106 106
 // let's try and connect
@@ -110,153 +110,153 @@  discard block
 block discarded – undo
110 110
 $reset = 0;
111 111
 
112 112
 function connect_all($hosts) {
113
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115
-    $reset++;
116
-    if ($globalDebug) echo 'Connect to all...'."\n";
117
-    foreach ($hosts as $id => $value) {
113
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115
+	$reset++;
116
+	if ($globalDebug) echo 'Connect to all...'."\n";
117
+	foreach ($hosts as $id => $value) {
118 118
 	$host = $value['host'];
119 119
 	$globalSources[$id]['last_exec'] = 0;
120 120
 	// Here we check type of source(s)
121 121
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
-        	//$formats[$id] = 'deltadbtxt';
124
-        	$globalSources[$id]['format'] = 'deltadbtxt';
125
-        	//$last_exec['deltadbtxt'] = 0;
126
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
128
-        	//$formats[$id] = 'vatsimtxt';
129
-        	$globalSources[$id]['format'] = 'vatsimtxt';
130
-        	//$last_exec['vatsimtxt'] = 0;
131
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
133
-        	//$formats[$id] = 'aircraftlistjson';
134
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
135
-        	//$last_exec['aircraftlistjson'] = 0;
136
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
-    	    } else if (preg_match('/opensky/i',$host)) {
138
-        	//$formats[$id] = 'aircraftlistjson';
139
-        	$globalSources[$id]['format'] = 'opensky';
140
-        	//$last_exec['aircraftlistjson'] = 0;
141
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
143
-        	//$formats[$id] = 'radarvirtueljson';
144
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
145
-        	//$last_exec['radarvirtueljson'] = 0;
146
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
147
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
148
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149
-        	    exit(0);
150
-        	}
151
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
152
-        	//$formats[$id] = 'planeupdatefaa';
153
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
154
-        	//$last_exec['planeupdatefaa'] = 0;
155
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
156
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
157
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158
-        	    exit(0);
159
-        	}
160
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
161
-        	//$formats[$id] = 'phpvmacars';
162
-        	$globalSources[$id]['format'] = 'phpvmacars';
163
-        	//$last_exec['phpvmacars'] = 0;
164
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
165
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
166
-        	//$formats[$id] = 'phpvmacars';
167
-        	$globalSources[$id]['format'] = 'vam';
168
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
169
-            } else if (preg_match('/whazzup/i',$host)) {
170
-        	//$formats[$id] = 'whazzup';
171
-        	$globalSources[$id]['format'] = 'whazzup';
172
-        	//$last_exec['whazzup'] = 0;
173
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
174
-            } else if (preg_match('/recentpireps/i',$host)) {
175
-        	//$formats[$id] = 'pirepsjson';
176
-        	$globalSources[$id]['format'] = 'pirepsjson';
177
-        	//$last_exec['pirepsjson'] = 0;
178
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
179
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
180
-        	//$formats[$id] = 'fr24json';
181
-        	$globalSources[$id]['format'] = 'fr24json';
182
-        	//$last_exec['fr24json'] = 0;
183
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
184
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
185
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
186
-        	    exit(0);
187
-        	}
188
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
189
-        	//$formats[$id] = 'fr24json';
190
-        	$globalSources[$id]['format'] = 'myshiptracking';
191
-        	//$last_exec['fr24json'] = 0;
192
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
193
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
194
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
195
-        	    exit(0);
196
-        	}
197
-            //} else if (preg_match('/10001/',$host)) {
198
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
199
-        	//$formats[$id] = 'tsv';
200
-        	$globalSources[$id]['format'] = 'tsv';
201
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
202
-            }
203
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
204
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
205
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
206
-    		    if ($idf !== false) {
207
-    			$httpfeeds[$id] = $idf;
208
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
209
-    		    }
210
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
211
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
212
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
213
-	    $hostport = explode(':',$host);
214
-	    if (isset($hostport[1])) {
122
+			if (preg_match('/deltadb.txt$/i',$host)) {
123
+			//$formats[$id] = 'deltadbtxt';
124
+			$globalSources[$id]['format'] = 'deltadbtxt';
125
+			//$last_exec['deltadbtxt'] = 0;
126
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
128
+			//$formats[$id] = 'vatsimtxt';
129
+			$globalSources[$id]['format'] = 'vatsimtxt';
130
+			//$last_exec['vatsimtxt'] = 0;
131
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
133
+			//$formats[$id] = 'aircraftlistjson';
134
+			$globalSources[$id]['format'] = 'aircraftlistjson';
135
+			//$last_exec['aircraftlistjson'] = 0;
136
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
+			} else if (preg_match('/opensky/i',$host)) {
138
+			//$formats[$id] = 'aircraftlistjson';
139
+			$globalSources[$id]['format'] = 'opensky';
140
+			//$last_exec['aircraftlistjson'] = 0;
141
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
143
+			//$formats[$id] = 'radarvirtueljson';
144
+			$globalSources[$id]['format'] = 'radarvirtueljson';
145
+			//$last_exec['radarvirtueljson'] = 0;
146
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
147
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
148
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149
+				exit(0);
150
+			}
151
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
152
+			//$formats[$id] = 'planeupdatefaa';
153
+			$globalSources[$id]['format'] = 'planeupdatefaa';
154
+			//$last_exec['planeupdatefaa'] = 0;
155
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
156
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
157
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158
+				exit(0);
159
+			}
160
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
161
+			//$formats[$id] = 'phpvmacars';
162
+			$globalSources[$id]['format'] = 'phpvmacars';
163
+			//$last_exec['phpvmacars'] = 0;
164
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
165
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
166
+			//$formats[$id] = 'phpvmacars';
167
+			$globalSources[$id]['format'] = 'vam';
168
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
169
+			} else if (preg_match('/whazzup/i',$host)) {
170
+			//$formats[$id] = 'whazzup';
171
+			$globalSources[$id]['format'] = 'whazzup';
172
+			//$last_exec['whazzup'] = 0;
173
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
174
+			} else if (preg_match('/recentpireps/i',$host)) {
175
+			//$formats[$id] = 'pirepsjson';
176
+			$globalSources[$id]['format'] = 'pirepsjson';
177
+			//$last_exec['pirepsjson'] = 0;
178
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
179
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
180
+			//$formats[$id] = 'fr24json';
181
+			$globalSources[$id]['format'] = 'fr24json';
182
+			//$last_exec['fr24json'] = 0;
183
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
184
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
185
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
186
+				exit(0);
187
+			}
188
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
189
+			//$formats[$id] = 'fr24json';
190
+			$globalSources[$id]['format'] = 'myshiptracking';
191
+			//$last_exec['fr24json'] = 0;
192
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
193
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
194
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
195
+				exit(0);
196
+			}
197
+			//} else if (preg_match('/10001/',$host)) {
198
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
199
+			//$formats[$id] = 'tsv';
200
+			$globalSources[$id]['format'] = 'tsv';
201
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
202
+			}
203
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
204
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
205
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
206
+				if ($idf !== false) {
207
+				$httpfeeds[$id] = $idf;
208
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
209
+				}
210
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
211
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
212
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
213
+		$hostport = explode(':',$host);
214
+		if (isset($hostport[1])) {
215 215
 		$port = $hostport[1];
216 216
 		$hostn = $hostport[0];
217
-	    } else {
217
+		} else {
218 218
 		$port = $globalSources[$id]['port'];
219 219
 		$hostn = $globalSources[$id]['host'];
220
-	    }
221
-	    $Common = new Common();
222
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
223
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
224
-    	    } else {
225
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
226
-	    }
227
-	    if ($s) {
228
-    	        $sockets[$id] = $s;
229
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
230
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
220
+		}
221
+		$Common = new Common();
222
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
223
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
224
+			} else {
225
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
226
+		}
227
+		if ($s) {
228
+				$sockets[$id] = $s;
229
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
230
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
231 231
 			//$formats[$id] = 'aprs';
232 232
 			$globalSources[$id]['format'] = 'aprs';
233 233
 			//$aprs_connect = 0;
234 234
 			//$use_aprs = true;
235
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
235
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
236 236
 			$globalSources[$id]['format'] = 'vrstcp';
237
-    		    } elseif ($port == '10001') {
238
-        		//$formats[$id] = 'tsv';
239
-        		$globalSources[$id]['format'] = 'tsv';
240
-		    } elseif ($port == '30002') {
241
-        		//$formats[$id] = 'raw';
242
-        		$globalSources[$id]['format'] = 'raw';
243
-		    } elseif ($port == '5001') {
244
-        		//$formats[$id] = 'raw';
245
-        		$globalSources[$id]['format'] = 'flightgearmp';
246
-		    } elseif ($port == '30005') {
237
+				} elseif ($port == '10001') {
238
+				//$formats[$id] = 'tsv';
239
+				$globalSources[$id]['format'] = 'tsv';
240
+			} elseif ($port == '30002') {
241
+				//$formats[$id] = 'raw';
242
+				$globalSources[$id]['format'] = 'raw';
243
+			} elseif ($port == '5001') {
244
+				//$formats[$id] = 'raw';
245
+				$globalSources[$id]['format'] = 'flightgearmp';
246
+			} elseif ($port == '30005') {
247 247
 			// Not yet supported
248
-        		//$formats[$id] = 'beast';
249
-        		$globalSources[$id]['format'] = 'beast';
250
-		    //} else $formats[$id] = 'sbs';
251
-		    } else $globalSources[$id]['format'] = 'sbs';
252
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
248
+				//$formats[$id] = 'beast';
249
+				$globalSources[$id]['format'] = 'beast';
250
+			//} else $formats[$id] = 'sbs';
251
+			} else $globalSources[$id]['format'] = 'sbs';
252
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
253 253
 		}
254 254
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
255
-            } else {
255
+			} else {
256 256
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
257
-    	    }
258
-        }
259
-    }
257
+			}
258
+		}
259
+	}
260 260
 }
261 261
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
262 262
 
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
 //connect_all($globalSources);
280 280
 
281 281
 if (isset($globalProxy) && $globalProxy) {
282
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
282
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
283 283
 } else {
284
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
284
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
285 285
 }
286 286
 
287 287
 // APRS Configuration
@@ -290,18 +290,18 @@  discard block
 block discarded – undo
290 290
 	die;
291 291
 }
292 292
 foreach ($globalSources as $key => $source) {
293
-    if (!isset($source['format'])) {
294
-        $globalSources[$key]['format'] = 'auto';
295
-    }
293
+	if (!isset($source['format'])) {
294
+		$globalSources[$key]['format'] = 'auto';
295
+	}
296 296
 }
297 297
 connect_all($globalSources);
298 298
 foreach ($globalSources as $key => $source) {
299
-    if (isset($source['format']) && $source['format'] == 'aprs') {
299
+	if (isset($source['format']) && $source['format'] == 'aprs') {
300 300
 	$aprs_connect = 0;
301 301
 	$use_aprs = true;
302 302
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
303 303
 	break;
304
-    }
304
+	}
305 305
 }
306 306
 
307 307
 if ($use_aprs) {
@@ -342,117 +342,117 @@  discard block
 block discarded – undo
342 342
 
343 343
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
344 344
 while ($i > 0) {
345
-    if (!$globalDaemon) $i = $endtime-time();
346
-    // Delete old ATC
347
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
345
+	if (!$globalDaemon) $i = $endtime-time();
346
+	// Delete old ATC
347
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
348 348
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
349
-        $ATC->deleteOldATC();
350
-    }
349
+		$ATC->deleteOldATC();
350
+	}
351 351
     
352
-    //if (count($last_exec) > 0) {
353
-    if (count($last_exec) == count($globalSources)) {
352
+	//if (count($last_exec) > 0) {
353
+	if (count($last_exec) == count($globalSources)) {
354 354
 	$max = $globalMinFetch;
355 355
 	foreach ($last_exec as $last) {
356
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
356
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
357 357
 	}
358 358
 	if ($max != $globalMinFetch) {
359
-	    if ($globalDebug) echo 'Sleeping...'."\n";
360
-	    sleep($globalMinFetch-$max+2);
359
+		if ($globalDebug) echo 'Sleeping...'."\n";
360
+		sleep($globalMinFetch-$max+2);
361
+	}
361 362
 	}
362
-    }
363 363
 
364 364
     
365
-    //foreach ($formats as $id => $value) {
366
-    foreach ($globalSources as $id => $value) {
365
+	//foreach ($formats as $id => $value) {
366
+	foreach ($globalSources as $id => $value) {
367 367
 	date_default_timezone_set('UTC');
368 368
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
369 369
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
370
-	    //$buffer = $Common->getData($hosts[$id]);
371
-	    $buffer = $Common->getData($value['host']);
372
-	    if ($buffer != '') $reset = 0;
373
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374
-	    $buffer = explode('\n',$buffer);
375
-	    foreach ($buffer as $line) {
376
-    		if ($line != '' && count($line) > 7) {
377
-    		    $line = explode(',', $line);
378
-	            $data = array();
379
-	            $data['hex'] = $line[1]; // hex
380
-	            $data['ident'] = $line[2]; // ident
381
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
382
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
383
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
384
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
385
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
386
-	            $data['verticalrate'] = ''; // vertical rate
387
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
388
-	            $data['emergency'] = ''; // emergency
389
-		    $data['datetime'] = date('Y-m-d H:i:s');
390
-		    $data['format_source'] = 'deltadbtxt';
391
-    		    $data['id_source'] = $id_source;
392
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
393
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
394
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
395
-    		    $SI->add($data);
396
-		    unset($data);
397
-    		}
398
-    	    }
399
-    	    $last_exec[$id]['last'] = time();
370
+		//$buffer = $Common->getData($hosts[$id]);
371
+		$buffer = $Common->getData($value['host']);
372
+		if ($buffer != '') $reset = 0;
373
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374
+		$buffer = explode('\n',$buffer);
375
+		foreach ($buffer as $line) {
376
+			if ($line != '' && count($line) > 7) {
377
+				$line = explode(',', $line);
378
+				$data = array();
379
+				$data['hex'] = $line[1]; // hex
380
+				$data['ident'] = $line[2]; // ident
381
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
382
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
383
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
384
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
385
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
386
+				$data['verticalrate'] = ''; // vertical rate
387
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
388
+				$data['emergency'] = ''; // emergency
389
+			$data['datetime'] = date('Y-m-d H:i:s');
390
+			$data['format_source'] = 'deltadbtxt';
391
+				$data['id_source'] = $id_source;
392
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
393
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
394
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
395
+				$SI->add($data);
396
+			unset($data);
397
+			}
398
+			}
399
+			$last_exec[$id]['last'] = time();
400 400
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
401
-	    date_default_timezone_set('CET');
402
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
403
-	    date_default_timezone_set('UTC');
404
-	    if ($buffer != '') $reset = 0;
405
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
406
-	    $buffer = explode('\n',$buffer);
407
-	    foreach ($buffer as $line) {
401
+		date_default_timezone_set('CET');
402
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
403
+		date_default_timezone_set('UTC');
404
+		if ($buffer != '') $reset = 0;
405
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
406
+		$buffer = explode('\n',$buffer);
407
+		foreach ($buffer as $line) {
408 408
 		if ($line != '') {
409
-		    echo "'".$line."'\n";
410
-		    $add = false;
411
-		    $ais_data = $AIS->parse_line(trim($line));
412
-		    $data = array();
413
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
414
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
415
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
416
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
417
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
418
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
419
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
420
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
421
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
422
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
423
-		    if (isset($ais_data['timestamp'])) {
409
+			echo "'".$line."'\n";
410
+			$add = false;
411
+			$ais_data = $AIS->parse_line(trim($line));
412
+			$data = array();
413
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
414
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
415
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
416
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
417
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
418
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
419
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
420
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
421
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
422
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
423
+			if (isset($ais_data['timestamp'])) {
424 424
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
425 425
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
426
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
427
-			    $add = true;
426
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
427
+				$add = true;
428 428
 			}
429
-		    } else {
429
+			} else {
430 430
 			$data['datetime'] = date('Y-m-d H:i:s');
431 431
 			$add = true;
432
-		    }
433
-		    $data['format_source'] = 'aisnmeatxt';
434
-    		    $data['id_source'] = $id_source;
435
-		    //print_r($data);
436
-		    echo 'Add...'."\n";
437
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
438
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
439
-		    unset($data);
432
+			}
433
+			$data['format_source'] = 'aisnmeatxt';
434
+				$data['id_source'] = $id_source;
435
+			//print_r($data);
436
+			echo 'Add...'."\n";
437
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
438
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
439
+			unset($data);
440 440
 		}
441
-    	    }
442
-    	    $last_exec[$id]['last'] = time();
441
+			}
442
+			$last_exec[$id]['last'] = time();
443 443
 	} elseif ($value['format'] == 'aisnmeahttp') {
444
-	    $arr = $httpfeeds;
445
-	    $w = $e = null;
444
+		$arr = $httpfeeds;
445
+		$w = $e = null;
446 446
 	    
447
-	    if (isset($arr[$id])) {
447
+		if (isset($arr[$id])) {
448 448
 		$nn = stream_select($arr,$w,$e,$timeout);
449 449
 		if ($nn > 0) {
450
-		    foreach ($httpfeeds as $feed) {
450
+			foreach ($httpfeeds as $feed) {
451 451
 			$buffer = stream_get_line($feed,2000,"\n");
452 452
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
453 453
 			$buffer = explode('\n',$buffer);
454 454
 			foreach ($buffer as $line) {
455
-			    if ($line != '') {
455
+				if ($line != '') {
456 456
 				$ais_data = $AIS->parse_line(trim($line));
457 457
 				$data = array();
458 458
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -469,39 +469,39 @@  discard block
 block discarded – undo
469 469
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
470 470
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
471 471
 				if (isset($ais_data['timestamp'])) {
472
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
472
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
473 473
 				} else {
474
-				    $data['datetime'] = date('Y-m-d H:i:s');
474
+					$data['datetime'] = date('Y-m-d H:i:s');
475 475
 				}
476 476
 				$data['format_source'] = 'aisnmeahttp';
477 477
 				$data['id_source'] = $id_source;
478 478
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
479 479
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
480 480
 				unset($data);
481
-			    }
481
+				}
482
+			}
482 483
 			}
483
-		    }
484 484
 		} else {
485
-		    $format = $value['format'];
486
-		    if (isset($tt[$format])) $tt[$format]++;
487
-		    else $tt[$format] = 0;
488
-		    if ($tt[$format] > 30) {
485
+			$format = $value['format'];
486
+			if (isset($tt[$format])) $tt[$format]++;
487
+			else $tt[$format] = 0;
488
+			if ($tt[$format] > 30) {
489 489
 			sleep(2);
490 490
 			$sourceeen[] = $value;
491 491
 			connect_all($sourceeen);
492 492
 			$sourceeen = array();
493
-		    }
493
+			}
494
+		}
494 495
 		}
495
-	    }
496 496
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
497
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
498
-	    if ($buffer != '') {
497
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
498
+		if ($buffer != '') {
499 499
 		//echo $buffer;
500 500
 		$all_data = json_decode($buffer,true);
501 501
 		//print_r($all_data);
502 502
 		if (isset($all_data[0]['DATA'])) {
503 503
 		foreach ($all_data[0]['DATA'] as $line) {
504
-		    if ($line != '') {
504
+			if ($line != '') {
505 505
 			$data = array();
506 506
 			$data['ident'] = $line['NAME'];
507 507
 			$data['mmsi'] = $line['MMSI'];
@@ -518,89 +518,89 @@  discard block
 block discarded – undo
518 518
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
519 519
 			$MI->add($data);
520 520
 			unset($data);
521
-		    }
521
+			}
522 522
 		}
523 523
 		}
524 524
 		
525
-	    }
526
-    	    $last_exec[$id]['last'] = time();
525
+		}
526
+			$last_exec[$id]['last'] = time();
527 527
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
528
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
529
-	    if ($buffer != '') {
528
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
529
+		if ($buffer != '') {
530 530
 		$all_data = json_decode($buffer,true);
531 531
 		if (isset($all_data[0]['mmsi'])) {
532
-		    foreach ($all_data as $line) {
532
+			foreach ($all_data as $line) {
533 533
 			if ($line != '') {
534
-			    $data = array();
535
-			    $data['ident'] = $line['shipname'];
536
-			    $data['callsign'] = $line['callsign'];
537
-			    $data['mmsi'] = $line['mmsi'];
538
-			    $data['speed'] = $line['sog'];
539
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
540
-			    $data['latitude'] = $line['latitude'];
541
-			    $data['longitude'] = $line['longitude'];
542
-			    $data['type_id'] = $line['shiptype'];
543
-			    $data['arrival_code'] = $line['destination'];
544
-			    $data['datetime'] = $line['time'];
545
-			    $data['format_source'] = 'boatbeaconapp';
546
-			    $data['id_source'] = $id_source;
547
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
548
-			    $MI->add($data);
549
-			    unset($data);
534
+				$data = array();
535
+				$data['ident'] = $line['shipname'];
536
+				$data['callsign'] = $line['callsign'];
537
+				$data['mmsi'] = $line['mmsi'];
538
+				$data['speed'] = $line['sog'];
539
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
540
+				$data['latitude'] = $line['latitude'];
541
+				$data['longitude'] = $line['longitude'];
542
+				$data['type_id'] = $line['shiptype'];
543
+				$data['arrival_code'] = $line['destination'];
544
+				$data['datetime'] = $line['time'];
545
+				$data['format_source'] = 'boatbeaconapp';
546
+				$data['id_source'] = $id_source;
547
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
548
+				$MI->add($data);
549
+				unset($data);
550
+			}
550 551
 			}
551
-		    }
552 552
 		}
553 553
 		
554
-	    }
555
-    	    $last_exec[$id]['last'] = time();
554
+		}
555
+			$last_exec[$id]['last'] = time();
556 556
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
557
-	    echo 'download...';
558
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
559
-	    echo 'done !'."\n";
560
-	    if ($buffer != '') $reset = 0;
561
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
562
-	    $buffer = explode('\n',$buffer);
563
-	    foreach ($buffer as $line) {
557
+		echo 'download...';
558
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
559
+		echo 'done !'."\n";
560
+		if ($buffer != '') $reset = 0;
561
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
562
+		$buffer = explode('\n',$buffer);
563
+		foreach ($buffer as $line) {
564 564
 		if ($line != '') {
565
-		    $data = array();
566
-		    $data['mmsi'] = (int)substr($line,0,9);
567
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
568
-		    //$data['status'] = substr($line,21,2);
569
-		    //$data['type'] = substr($line,24,3);
570
-		    $data['latitude'] = substr($line,29,9);
571
-		    $data['longitude'] = substr($line,41,9);
572
-		    $data['speed'] = round(substr($line,51,5));
573
-		    //$data['course'] = substr($line,57,5);
574
-		    $data['heading'] = round(substr($line,63,3));
575
-		    //$data['draft'] = substr($line,67,4);
576
-		    //$data['length'] = substr($line,72,3);
577
-		    //$data['beam'] = substr($line,76,2);
578
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
579
-		    //$data['callsign'] = trim(substr($line,100,7);
580
-		    //$data['dest'] = substr($line,108,20);
581
-		    //$data['etaDate'] = substr($line,129,5);
582
-		    //$data['etaTime'] = substr($line,135,5);
583
-		    $data['format_source'] = 'shipplotter';
584
-    		    $data['id_source'] = $id_source;
585
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
586
-		    //print_r($data);
587
-		    echo 'Add...'."\n";
588
-		    $MI->add($data);
589
-		    unset($data);
565
+			$data = array();
566
+			$data['mmsi'] = (int)substr($line,0,9);
567
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
568
+			//$data['status'] = substr($line,21,2);
569
+			//$data['type'] = substr($line,24,3);
570
+			$data['latitude'] = substr($line,29,9);
571
+			$data['longitude'] = substr($line,41,9);
572
+			$data['speed'] = round(substr($line,51,5));
573
+			//$data['course'] = substr($line,57,5);
574
+			$data['heading'] = round(substr($line,63,3));
575
+			//$data['draft'] = substr($line,67,4);
576
+			//$data['length'] = substr($line,72,3);
577
+			//$data['beam'] = substr($line,76,2);
578
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
579
+			//$data['callsign'] = trim(substr($line,100,7);
580
+			//$data['dest'] = substr($line,108,20);
581
+			//$data['etaDate'] = substr($line,129,5);
582
+			//$data['etaTime'] = substr($line,135,5);
583
+			$data['format_source'] = 'shipplotter';
584
+				$data['id_source'] = $id_source;
585
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
586
+			//print_r($data);
587
+			echo 'Add...'."\n";
588
+			$MI->add($data);
589
+			unset($data);
590 590
 		}
591
-    	    }
592
-    	    $last_exec[$id]['last'] = time();
591
+			}
592
+			$last_exec[$id]['last'] = time();
593 593
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
594 594
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
595
-	    //$buffer = $Common->getData($hosts[$id]);
596
-	    $buffer = $Common->getData($value['host']);
597
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598
-	    $buffer = explode('\n',$buffer);
599
-	    $reset = 0;
600
-	    foreach ($buffer as $line) {
601
-    		if ($line != '') {
602
-    		    $line = explode(':', $line);
603
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
595
+		//$buffer = $Common->getData($hosts[$id]);
596
+		$buffer = $Common->getData($value['host']);
597
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598
+		$buffer = explode('\n',$buffer);
599
+		$reset = 0;
600
+		foreach ($buffer as $line) {
601
+			if ($line != '') {
602
+				$line = explode(':', $line);
603
+				if (count($line) > 30 && $line[0] != 'callsign') {
604 604
 			$data = array();
605 605
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
606 606
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -613,37 +613,37 @@  discard block
 block discarded – undo
613 613
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
614 614
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
615 615
 			$data['latitude'] = $line[5]; // lat
616
-	        	$data['longitude'] = $line[6]; // long
617
-	        	$data['verticalrate'] = ''; // vertical rate
618
-	        	$data['squawk'] = ''; // squawk
619
-	        	$data['emergency'] = ''; // emergency
620
-	        	$data['waypoints'] = $line[30];
616
+				$data['longitude'] = $line[6]; // long
617
+				$data['verticalrate'] = ''; // vertical rate
618
+				$data['squawk'] = ''; // squawk
619
+				$data['emergency'] = ''; // emergency
620
+				$data['waypoints'] = $line[30];
621 621
 			$data['datetime'] = date('Y-m-d H:i:s');
622 622
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
623 623
 			//if (isset($line[37])) $data['last_update'] = $line[37];
624
-		        $data['departure_airport_icao'] = $line[11];
625
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
626
-		        $data['arrival_airport_icao'] = $line[13];
624
+				$data['departure_airport_icao'] = $line[11];
625
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
626
+				$data['arrival_airport_icao'] = $line[13];
627 627
 			$data['frequency'] = $line[4];
628 628
 			$data['type'] = $line[18];
629 629
 			$data['range'] = $line[19];
630 630
 			if (isset($line[35])) $data['info'] = $line[35];
631
-    			$data['id_source'] = $id_source;
632
-	    		//$data['arrival_airport_time'] = ;
633
-	    		if ($line[9] != '') {
634
-	    		    $aircraft_data = explode('/',$line[9]);
635
-	    		    if (isset($aircraft_data[1])) {
636
-	    			$data['aircraft_icao'] = $aircraft_data[1];
637
-	    		    }
638
-        		}
639
-	    		/*
631
+				$data['id_source'] = $id_source;
632
+				//$data['arrival_airport_time'] = ;
633
+				if ($line[9] != '') {
634
+					$aircraft_data = explode('/',$line[9]);
635
+					if (isset($aircraft_data[1])) {
636
+					$data['aircraft_icao'] = $aircraft_data[1];
637
+					}
638
+				}
639
+				/*
640 640
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
641 641
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
642 642
 	    		*/
643
-	    		$data['format_source'] = $value['format'];
643
+				$data['format_source'] = $value['format'];
644 644
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
645 645
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
646
-    			if ($line[3] == 'PILOT') $SI->add($data);
646
+				if ($line[3] == 'PILOT') $SI->add($data);
647 647
 			elseif ($line[3] == 'ATC') {
648 648
 				//print_r($data);
649 649
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -661,255 +661,255 @@  discard block
 block discarded – undo
661 661
 				if (!isset($data['source_name'])) $data['source_name'] = '';
662 662
 				if (isset($ATC)) 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']);
663 663
 			}
664
-    			unset($data);
665
-    		    }
666
-    		}
667
-    	    }
668
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
669
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
670
-    	    $last_exec[$id]['last'] = time();
671
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
672
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
673
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
674
-	    if ($buffer != '') {
675
-	    $all_data = json_decode($buffer,true);
676
-	    if (isset($all_data['acList'])) {
664
+				unset($data);
665
+				}
666
+			}
667
+			}
668
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
669
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
670
+			$last_exec[$id]['last'] = time();
671
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
672
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
673
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
674
+		if ($buffer != '') {
675
+		$all_data = json_decode($buffer,true);
676
+		if (isset($all_data['acList'])) {
677 677
 		$reset = 0;
678 678
 		foreach ($all_data['acList'] as $line) {
679
-		    $data = array();
680
-		    $data['hex'] = $line['Icao']; // hex
681
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
682
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
683
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
684
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
685
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
686
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
687
-		    //$data['verticalrate'] = $line['']; // verticale rate
688
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
689
-		    $data['emergency'] = ''; // emergency
690
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
679
+			$data = array();
680
+			$data['hex'] = $line['Icao']; // hex
681
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
682
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
683
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
684
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
685
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
686
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
687
+			//$data['verticalrate'] = $line['']; // verticale rate
688
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
689
+			$data['emergency'] = ''; // emergency
690
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
691 691
 		    
692
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
693
-		    else $data['datetime'] = date('Y-m-d H:i:s');
692
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
693
+			else $data['datetime'] = date('Y-m-d H:i:s');
694 694
 		    
695
-		    //$data['datetime'] = date('Y-m-d H:i:s');
696
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
697
-	    	    $data['format_source'] = 'aircraftlistjson';
698
-		    $data['id_source'] = $id_source;
699
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
700
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
701
-		    if (isset($data['latitude'])) $SI->add($data);
702
-		    unset($data);
695
+			//$data['datetime'] = date('Y-m-d H:i:s');
696
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
697
+				$data['format_source'] = 'aircraftlistjson';
698
+			$data['id_source'] = $id_source;
699
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
700
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
701
+			if (isset($data['latitude'])) $SI->add($data);
702
+			unset($data);
703 703
 		}
704
-	    } elseif (is_array($all_data)) {
704
+		} elseif (is_array($all_data)) {
705 705
 		$reset = 0;
706 706
 		foreach ($all_data as $line) {
707
-		    $data = array();
708
-		    $data['hex'] = $line['hex']; // hex
709
-		    $data['ident'] = $line['flight']; // ident
710
-		    $data['altitude'] = $line['altitude']; // altitude
711
-		    $data['speed'] = $line['speed']; // speed
712
-		    $data['heading'] = $line['track']; // heading
713
-		    $data['latitude'] = $line['lat']; // lat
714
-		    $data['longitude'] = $line['lon']; // long
715
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
716
-		    $data['squawk'] = $line['squawk']; // squawk
717
-		    $data['emergency'] = ''; // emergency
718
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
719
-		    else $data['datetime'] = date('Y-m-d H:i:s');
720
-	    	    $data['format_source'] = 'aircraftlistjson';
721
-    		    $data['id_source'] = $id_source;
722
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
723
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
724
-		    $SI->add($data);
725
-		    unset($data);
707
+			$data = array();
708
+			$data['hex'] = $line['hex']; // hex
709
+			$data['ident'] = $line['flight']; // ident
710
+			$data['altitude'] = $line['altitude']; // altitude
711
+			$data['speed'] = $line['speed']; // speed
712
+			$data['heading'] = $line['track']; // heading
713
+			$data['latitude'] = $line['lat']; // lat
714
+			$data['longitude'] = $line['lon']; // long
715
+			$data['verticalrate'] = $line['vrt']; // verticale rate
716
+			$data['squawk'] = $line['squawk']; // squawk
717
+			$data['emergency'] = ''; // emergency
718
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
719
+			else $data['datetime'] = date('Y-m-d H:i:s');
720
+				$data['format_source'] = 'aircraftlistjson';
721
+				$data['id_source'] = $id_source;
722
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
723
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
724
+			$SI->add($data);
725
+			unset($data);
726
+		}
726 727
 		}
727
-	    }
728
-	    }
729
-    	    //$last_exec['aircraftlistjson'] = time();
730
-    	    $last_exec[$id]['last'] = time();
731
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
732
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
733
-	    $buffer = $Common->getData($value['host']);
734
-	    $all_data = json_decode($buffer,true);
735
-	    if (isset($all_data['planes'])) {
728
+		}
729
+			//$last_exec['aircraftlistjson'] = time();
730
+			$last_exec[$id]['last'] = time();
731
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
732
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
733
+		$buffer = $Common->getData($value['host']);
734
+		$all_data = json_decode($buffer,true);
735
+		if (isset($all_data['planes'])) {
736 736
 		$reset = 0;
737 737
 		foreach ($all_data['planes'] as $key => $line) {
738
-		    $data = array();
739
-		    $data['hex'] = $key; // hex
740
-		    $data['ident'] = $line[3]; // ident
741
-		    $data['altitude'] = $line[6]; // altitude
742
-		    $data['speed'] = $line[8]; // speed
743
-		    $data['heading'] = $line[7]; // heading
744
-		    $data['latitude'] = $line[4]; // lat
745
-		    $data['longitude'] = $line[5]; // long
746
-		    //$data['verticalrate'] = $line[]; // verticale rate
747
-		    $data['squawk'] = $line[10]; // squawk
748
-		    $data['emergency'] = ''; // emergency
749
-		    $data['registration'] = $line[2];
750
-		    $data['aircraft_icao'] = $line[0];
751
-		    $deparr = explode('-',$line[1]);
752
-		    if (count($deparr) == 2) {
738
+			$data = array();
739
+			$data['hex'] = $key; // hex
740
+			$data['ident'] = $line[3]; // ident
741
+			$data['altitude'] = $line[6]; // altitude
742
+			$data['speed'] = $line[8]; // speed
743
+			$data['heading'] = $line[7]; // heading
744
+			$data['latitude'] = $line[4]; // lat
745
+			$data['longitude'] = $line[5]; // long
746
+			//$data['verticalrate'] = $line[]; // verticale rate
747
+			$data['squawk'] = $line[10]; // squawk
748
+			$data['emergency'] = ''; // emergency
749
+			$data['registration'] = $line[2];
750
+			$data['aircraft_icao'] = $line[0];
751
+			$deparr = explode('-',$line[1]);
752
+			if (count($deparr) == 2) {
753 753
 			$data['departure_airport_icao'] = $deparr[0];
754 754
 			$data['arrival_airport_icao'] = $deparr[1];
755
-		    }
756
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
757
-	    	    $data['format_source'] = 'planeupdatefaa';
758
-    		    $data['id_source'] = $id_source;
759
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
760
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
761
-		    $SI->add($data);
762
-		    unset($data);
755
+			}
756
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
757
+				$data['format_source'] = 'planeupdatefaa';
758
+				$data['id_source'] = $id_source;
759
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
760
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
761
+			$SI->add($data);
762
+			unset($data);
763
+		}
763 764
 		}
764
-	    }
765
-    	    //$last_exec['planeupdatefaa'] = time();
766
-    	    $last_exec[$id]['last'] = time();
767
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
768
-	    $buffer = $Common->getData($value['host']);
769
-	    $all_data = json_decode($buffer,true);
770
-	    if (isset($all_data['states'])) {
765
+			//$last_exec['planeupdatefaa'] = time();
766
+			$last_exec[$id]['last'] = time();
767
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
768
+		$buffer = $Common->getData($value['host']);
769
+		$all_data = json_decode($buffer,true);
770
+		if (isset($all_data['states'])) {
771 771
 		$reset = 0;
772 772
 		foreach ($all_data['states'] as $key => $line) {
773
-		    $data = array();
774
-		    $data['hex'] = $line[0]; // hex
775
-		    $data['ident'] = trim($line[1]); // ident
776
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
777
-		    $data['speed'] = round($line[9]*1.94384); // speed
778
-		    $data['heading'] = round($line[10]); // heading
779
-		    $data['latitude'] = $line[5]; // lat
780
-		    $data['longitude'] = $line[6]; // long
781
-		    $data['verticalrate'] = $line[11]; // verticale rate
782
-		    //$data['squawk'] = $line[10]; // squawk
783
-		    //$data['emergency'] = ''; // emergency
784
-		    //$data['registration'] = $line[2];
785
-		    //$data['aircraft_icao'] = $line[0];
786
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
787
-	    	    $data['format_source'] = 'opensky';
788
-    		    $data['id_source'] = $id_source;
789
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
790
-		    $SI->add($data);
791
-		    unset($data);
773
+			$data = array();
774
+			$data['hex'] = $line[0]; // hex
775
+			$data['ident'] = trim($line[1]); // ident
776
+			$data['altitude'] = round($line[7]*3.28084); // altitude
777
+			$data['speed'] = round($line[9]*1.94384); // speed
778
+			$data['heading'] = round($line[10]); // heading
779
+			$data['latitude'] = $line[5]; // lat
780
+			$data['longitude'] = $line[6]; // long
781
+			$data['verticalrate'] = $line[11]; // verticale rate
782
+			//$data['squawk'] = $line[10]; // squawk
783
+			//$data['emergency'] = ''; // emergency
784
+			//$data['registration'] = $line[2];
785
+			//$data['aircraft_icao'] = $line[0];
786
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
787
+				$data['format_source'] = 'opensky';
788
+				$data['id_source'] = $id_source;
789
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
790
+			$SI->add($data);
791
+			unset($data);
792
+		}
792 793
 		}
793
-	    }
794
-    	    //$last_exec['planeupdatefaa'] = time();
795
-    	    $last_exec[$id]['last'] = time();
796
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
797
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
798
-	    //$buffer = $Common->getData($hosts[$id]);
799
-	    $buffer = $Common->getData($value['host']);
800
-	    $all_data = json_decode($buffer,true);
801
-	    if (!empty($all_data)) $reset = 0;
802
-	    foreach ($all_data as $key => $line) {
794
+			//$last_exec['planeupdatefaa'] = time();
795
+			$last_exec[$id]['last'] = time();
796
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
797
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
798
+		//$buffer = $Common->getData($hosts[$id]);
799
+		$buffer = $Common->getData($value['host']);
800
+		$all_data = json_decode($buffer,true);
801
+		if (!empty($all_data)) $reset = 0;
802
+		foreach ($all_data as $key => $line) {
803 803
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
804
-		    $data = array();
805
-		    $data['hex'] = $line[0];
806
-		    $data['ident'] = $line[16]; //$line[13]
807
-	    	    $data['altitude'] = $line[4]; // altitude
808
-	    	    $data['speed'] = $line[5]; // speed
809
-	    	    $data['heading'] = $line[3]; // heading
810
-	    	    $data['latitude'] = $line[1]; // lat
811
-	    	    $data['longitude'] = $line[2]; // long
812
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
813
-	    	    $data['squawk'] = $line[6]; // squawk
814
-	    	    $data['aircraft_icao'] = $line[8];
815
-	    	    $data['registration'] = $line[9];
816
-		    $data['departure_airport_iata'] = $line[11];
817
-		    $data['arrival_airport_iata'] = $line[12];
818
-	    	    $data['emergency'] = ''; // emergency
819
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
820
-	    	    $data['format_source'] = 'fr24json';
821
-    		    $data['id_source'] = $id_source;
822
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
823
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
824
-		    $SI->add($data);
825
-		    unset($data);
804
+			$data = array();
805
+			$data['hex'] = $line[0];
806
+			$data['ident'] = $line[16]; //$line[13]
807
+				$data['altitude'] = $line[4]; // altitude
808
+				$data['speed'] = $line[5]; // speed
809
+				$data['heading'] = $line[3]; // heading
810
+				$data['latitude'] = $line[1]; // lat
811
+				$data['longitude'] = $line[2]; // long
812
+				$data['verticalrate'] = $line[15]; // verticale rate
813
+				$data['squawk'] = $line[6]; // squawk
814
+				$data['aircraft_icao'] = $line[8];
815
+				$data['registration'] = $line[9];
816
+			$data['departure_airport_iata'] = $line[11];
817
+			$data['arrival_airport_iata'] = $line[12];
818
+				$data['emergency'] = ''; // emergency
819
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
820
+				$data['format_source'] = 'fr24json';
821
+				$data['id_source'] = $id_source;
822
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
823
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
824
+			$SI->add($data);
825
+			unset($data);
826
+		}
826 827
 		}
827
-	    }
828
-    	    //$last_exec['fr24json'] = time();
829
-    	    $last_exec[$id]['last'] = time();
830
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
831
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
832
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
833
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
834
-	    //echo $buffer;
835
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
836
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
837
-	    $all_data = json_decode($buffer,true);
838
-	    if (json_last_error() != JSON_ERROR_NONE) {
828
+			//$last_exec['fr24json'] = time();
829
+			$last_exec[$id]['last'] = time();
830
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
831
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
832
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
833
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
834
+		//echo $buffer;
835
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
836
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
837
+		$all_data = json_decode($buffer,true);
838
+		if (json_last_error() != JSON_ERROR_NONE) {
839 839
 		die(json_last_error_msg());
840
-	    }
841
-	    if (isset($all_data['mrkrs'])) {
840
+		}
841
+		if (isset($all_data['mrkrs'])) {
842 842
 		$reset = 0;
843 843
 		foreach ($all_data['mrkrs'] as $key => $line) {
844
-		    if (isset($line['inf'])) {
844
+			if (isset($line['inf'])) {
845 845
 			$data = array();
846 846
 			$data['hex'] = $line['inf']['ia'];
847 847
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
848
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
849
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
850
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
851
-	    		$data['latitude'] = $line['pt'][0]; // lat
852
-	    		$data['longitude'] = $line['pt'][1]; // long
853
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
854
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
855
-	    		//$data['aircraft_icao'] = $line[8];
856
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
848
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
849
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
850
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
851
+				$data['latitude'] = $line['pt'][0]; // lat
852
+				$data['longitude'] = $line['pt'][1]; // long
853
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
854
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
855
+				//$data['aircraft_icao'] = $line[8];
856
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
857 857
 			//$data['departure_airport_iata'] = $line[11];
858 858
 			//$data['arrival_airport_iata'] = $line[12];
859
-	    		//$data['emergency'] = ''; // emergency
859
+				//$data['emergency'] = ''; // emergency
860 860
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
861
-	    		$data['format_source'] = 'radarvirtueljson';
862
-    			$data['id_source'] = $id_source;
861
+				$data['format_source'] = 'radarvirtueljson';
862
+				$data['id_source'] = $id_source;
863 863
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
864 864
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
865 865
 			$SI->add($data);
866 866
 			unset($data);
867
-		    }
867
+			}
868
+		}
868 869
 		}
869
-	    }
870
-    	    //$last_exec['radarvirtueljson'] = time();
871
-    	    $last_exec[$id]['last'] = time();
872
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
873
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
874
-	    //$buffer = $Common->getData($hosts[$id]);
875
-	    $buffer = $Common->getData($value['host'].'?'.time());
876
-	    $all_data = json_decode(utf8_encode($buffer),true);
870
+			//$last_exec['radarvirtueljson'] = time();
871
+			$last_exec[$id]['last'] = time();
872
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
873
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
874
+		//$buffer = $Common->getData($hosts[$id]);
875
+		$buffer = $Common->getData($value['host'].'?'.time());
876
+		$all_data = json_decode(utf8_encode($buffer),true);
877 877
 	    
878
-	    if (isset($all_data['pireps'])) {
878
+		if (isset($all_data['pireps'])) {
879 879
 		$reset = 0;
880
-	        foreach ($all_data['pireps'] as $line) {
881
-		    $data = array();
882
-		    $data['id'] = $line['id'];
883
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
884
-		    $data['ident'] = $line['callsign']; // ident
885
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
886
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
887
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
888
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
889
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
890
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
891
-		    $data['latitude'] = $line['lat']; // lat
892
-		    $data['longitude'] = $line['lon']; // long
893
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
894
-		    //$data['squawk'] = $line['squawk']; // squawk
895
-		    //$data['emergency'] = ''; // emergency
896
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
897
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
898
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
899
-		    //$data['arrival_airport_time'] = $line['arrtime'];
900
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
901
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
902
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
903
-		    else $data['info'] = '';
904
-		    $data['format_source'] = 'pireps';
905
-    		    $data['id_source'] = $id_source;
906
-		    $data['datetime'] = date('Y-m-d H:i:s');
907
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
909
-		    if ($line['icon'] == 'plane') {
880
+			foreach ($all_data['pireps'] as $line) {
881
+			$data = array();
882
+			$data['id'] = $line['id'];
883
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
884
+			$data['ident'] = $line['callsign']; // ident
885
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
886
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
887
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
888
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
889
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
890
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
891
+			$data['latitude'] = $line['lat']; // lat
892
+			$data['longitude'] = $line['lon']; // long
893
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
894
+			//$data['squawk'] = $line['squawk']; // squawk
895
+			//$data['emergency'] = ''; // emergency
896
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
897
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
898
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
899
+			//$data['arrival_airport_time'] = $line['arrtime'];
900
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
901
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
902
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
903
+			else $data['info'] = '';
904
+			$data['format_source'] = 'pireps';
905
+				$data['id_source'] = $id_source;
906
+			$data['datetime'] = date('Y-m-d H:i:s');
907
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
909
+			if ($line['icon'] == 'plane') {
910 910
 			$SI->add($data);
911
-		    //    print_r($data);
912
-    		    } elseif ($line['icon'] == 'ct') {
911
+			//    print_r($data);
912
+				} elseif ($line['icon'] == 'ct') {
913 913
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
914 914
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
915 915
 			$typec = substr($data['ident'],-3);
@@ -924,197 +924,197 @@  discard block
 block discarded – undo
924 924
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
925 925
 			else $data['type'] = 'Observer';
926 926
 			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
927
-		    }
928
-		    unset($data);
927
+			}
928
+			unset($data);
929 929
 		}
930
-	    }
931
-    	    //$last_exec['pirepsjson'] = time();
932
-    	    $last_exec[$id]['last'] = time();
933
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
934
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
935
-	    //$buffer = $Common->getData($hosts[$id]);
936
-	    if ($globalDebug) echo 'Get Data...'."\n";
937
-	    $buffer = $Common->getData($value['host']);
938
-	    $all_data = json_decode($buffer,true);
939
-	    if ($buffer != '' && is_array($all_data)) {
930
+		}
931
+			//$last_exec['pirepsjson'] = time();
932
+			$last_exec[$id]['last'] = time();
933
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
934
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
935
+		//$buffer = $Common->getData($hosts[$id]);
936
+		if ($globalDebug) echo 'Get Data...'."\n";
937
+		$buffer = $Common->getData($value['host']);
938
+		$all_data = json_decode($buffer,true);
939
+		if ($buffer != '' && is_array($all_data)) {
940 940
 		$reset = 0;
941 941
 		foreach ($all_data as $line) {
942
-	    	    $data = array();
943
-	    	    //$data['id'] = $line['id']; // id not usable
944
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
945
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
946
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
947
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
948
-	    	    $data['ident'] = $line['flightnum']; // ident
949
-	    	    $data['altitude'] = $line['alt']; // altitude
950
-	    	    $data['speed'] = $line['gs']; // speed
951
-	    	    $data['heading'] = $line['heading']; // heading
952
-	    	    $data['latitude'] = $line['lat']; // lat
953
-	    	    $data['longitude'] = $line['lng']; // long
954
-	    	    $data['verticalrate'] = ''; // verticale rate
955
-	    	    $data['squawk'] = ''; // squawk
956
-	    	    $data['emergency'] = ''; // emergency
957
-	    	    //$data['datetime'] = $line['lastupdate'];
958
-	    	    $data['last_update'] = $line['lastupdate'];
959
-		    $data['datetime'] = date('Y-m-d H:i:s');
960
-	    	    $data['departure_airport_icao'] = $line['depicao'];
961
-	    	    $data['departure_airport_time'] = $line['deptime'];
962
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
963
-    		    $data['arrival_airport_time'] = $line['arrtime'];
964
-    		    $data['registration'] = $line['aircraft'];
965
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
966
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
967
-		    if (isset($line['aircraftname'])) {
942
+				$data = array();
943
+				//$data['id'] = $line['id']; // id not usable
944
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
945
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
946
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
947
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
948
+				$data['ident'] = $line['flightnum']; // ident
949
+				$data['altitude'] = $line['alt']; // altitude
950
+				$data['speed'] = $line['gs']; // speed
951
+				$data['heading'] = $line['heading']; // heading
952
+				$data['latitude'] = $line['lat']; // lat
953
+				$data['longitude'] = $line['lng']; // long
954
+				$data['verticalrate'] = ''; // verticale rate
955
+				$data['squawk'] = ''; // squawk
956
+				$data['emergency'] = ''; // emergency
957
+				//$data['datetime'] = $line['lastupdate'];
958
+				$data['last_update'] = $line['lastupdate'];
959
+			$data['datetime'] = date('Y-m-d H:i:s');
960
+				$data['departure_airport_icao'] = $line['depicao'];
961
+				$data['departure_airport_time'] = $line['deptime'];
962
+				$data['arrival_airport_icao'] = $line['arricao'];
963
+				$data['arrival_airport_time'] = $line['arrtime'];
964
+				$data['registration'] = $line['aircraft'];
965
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
966
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
967
+			if (isset($line['aircraftname'])) {
968 968
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
969 969
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
970
-	    		$aircraft_data = explode('-',$line['aircraftname']);
971
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
972
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
973
-	    		else {
974
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
975
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
976
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
977
-	    		}
978
-	    	    }
979
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
980
-    		    $data['id_source'] = $id_source;
981
-	    	    $data['format_source'] = 'phpvmacars';
982
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
983
-		    $SI->add($data);
984
-		    unset($data);
970
+				$aircraft_data = explode('-',$line['aircraftname']);
971
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
972
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
973
+				else {
974
+					$aircraft_data = explode(' ',$line['aircraftname']);
975
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
976
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
977
+				}
978
+				}
979
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
980
+				$data['id_source'] = $id_source;
981
+				$data['format_source'] = 'phpvmacars';
982
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
983
+			$SI->add($data);
984
+			unset($data);
985 985
 		}
986 986
 		if ($globalDebug) echo 'No more data...'."\n";
987 987
 		unset($buffer);
988 988
 		unset($all_data);
989
-	    }
990
-    	    //$last_exec['phpvmacars'] = time();
991
-    	    $last_exec[$id]['last'] = time();
992
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
993
-	    //$buffer = $Common->getData($hosts[$id]);
994
-	    if ($globalDebug) echo 'Get Data...'."\n";
995
-	    $buffer = $Common->getData($value['host']);
996
-	    $all_data = json_decode($buffer,true);
997
-	    if ($buffer != '' && is_array($all_data)) {
989
+		}
990
+			//$last_exec['phpvmacars'] = time();
991
+			$last_exec[$id]['last'] = time();
992
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
993
+		//$buffer = $Common->getData($hosts[$id]);
994
+		if ($globalDebug) echo 'Get Data...'."\n";
995
+		$buffer = $Common->getData($value['host']);
996
+		$all_data = json_decode($buffer,true);
997
+		if ($buffer != '' && is_array($all_data)) {
998 998
 		$reset = 0;
999 999
 		foreach ($all_data as $line) {
1000
-	    	    $data = array();
1001
-	    	    //$data['id'] = $line['id']; // id not usable
1002
-	    	    $data['id'] = trim($line['flight_id']);
1003
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1004
-	    	    $data['pilot_name'] = $line['pilot_name'];
1005
-	    	    $data['pilot_id'] = $line['pilot_id'];
1006
-	    	    $data['ident'] = trim($line['callsign']); // ident
1007
-	    	    $data['altitude'] = $line['altitude']; // altitude
1008
-	    	    $data['speed'] = $line['gs']; // speed
1009
-	    	    $data['heading'] = $line['heading']; // heading
1010
-	    	    $data['latitude'] = $line['latitude']; // lat
1011
-	    	    $data['longitude'] = $line['longitude']; // long
1012
-	    	    $data['verticalrate'] = ''; // verticale rate
1013
-	    	    $data['squawk'] = ''; // squawk
1014
-	    	    $data['emergency'] = ''; // emergency
1015
-	    	    //$data['datetime'] = $line['lastupdate'];
1016
-	    	    $data['last_update'] = $line['last_update'];
1017
-		    $data['datetime'] = date('Y-m-d H:i:s');
1018
-	    	    $data['departure_airport_icao'] = $line['departure'];
1019
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1020
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1021
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1022
-    		    //$data['registration'] = $line['aircraft'];
1023
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1024
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1025
-    		    $data['id_source'] = $id_source;
1026
-	    	    $data['format_source'] = 'vam';
1027
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1028
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1029
-		    $SI->add($data);
1030
-		    unset($data);
1000
+				$data = array();
1001
+				//$data['id'] = $line['id']; // id not usable
1002
+				$data['id'] = trim($line['flight_id']);
1003
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1004
+				$data['pilot_name'] = $line['pilot_name'];
1005
+				$data['pilot_id'] = $line['pilot_id'];
1006
+				$data['ident'] = trim($line['callsign']); // ident
1007
+				$data['altitude'] = $line['altitude']; // altitude
1008
+				$data['speed'] = $line['gs']; // speed
1009
+				$data['heading'] = $line['heading']; // heading
1010
+				$data['latitude'] = $line['latitude']; // lat
1011
+				$data['longitude'] = $line['longitude']; // long
1012
+				$data['verticalrate'] = ''; // verticale rate
1013
+				$data['squawk'] = ''; // squawk
1014
+				$data['emergency'] = ''; // emergency
1015
+				//$data['datetime'] = $line['lastupdate'];
1016
+				$data['last_update'] = $line['last_update'];
1017
+			$data['datetime'] = date('Y-m-d H:i:s');
1018
+				$data['departure_airport_icao'] = $line['departure'];
1019
+				//$data['departure_airport_time'] = $line['departure_time'];
1020
+				$data['arrival_airport_icao'] = $line['arrival'];
1021
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1022
+				//$data['registration'] = $line['aircraft'];
1023
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1024
+				$data['aircraft_icao'] = $line['plane_type'];
1025
+				$data['id_source'] = $id_source;
1026
+				$data['format_source'] = 'vam';
1027
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1028
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1029
+			$SI->add($data);
1030
+			unset($data);
1031 1031
 		}
1032 1032
 		if ($globalDebug) echo 'No more data...'."\n";
1033 1033
 		unset($buffer);
1034 1034
 		unset($all_data);
1035
-	    }
1036
-    	    //$last_exec['phpvmacars'] = time();
1037
-    	    $last_exec[$id]['last'] = time();
1035
+		}
1036
+			//$last_exec['phpvmacars'] = time();
1037
+			$last_exec[$id]['last'] = time();
1038 1038
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1039 1039
 	} 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' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1040
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1041
-    	    //$last_exec[$id]['last'] = time();
1040
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1041
+			//$last_exec[$id]['last'] = time();
1042 1042
 
1043
-	    //$read = array( $sockets[$id] );
1044
-	    $read = $sockets;
1045
-	    $write = NULL;
1046
-	    $e = NULL;
1047
-	    $n = socket_select($read, $write, $e, $timeout);
1048
-	    if ($e != NULL) var_dump($e);
1049
-	    if ($n > 0) {
1043
+		//$read = array( $sockets[$id] );
1044
+		$read = $sockets;
1045
+		$write = NULL;
1046
+		$e = NULL;
1047
+		$n = socket_select($read, $write, $e, $timeout);
1048
+		if ($e != NULL) var_dump($e);
1049
+		if ($n > 0) {
1050 1050
 		$reset = 0;
1051 1051
 		foreach ($read as $nb => $r) {
1052
-		    //$value = $formats[$nb];
1053
-		    $format = $globalSources[$nb]['format'];
1054
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1052
+			//$value = $formats[$nb];
1053
+			$format = $globalSources[$nb]['format'];
1054
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1055 1055
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1056
-		    } elseif ($format == 'vrstcp') {
1056
+			} elseif ($format == 'vrstcp') {
1057 1057
 			$buffer = @socket_read($r, 6000);
1058
-		    } else {
1058
+			} else {
1059 1059
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1060
-		    }
1061
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1062
-		    //echo $buffer."\n";
1063
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1064
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1065
-		    $error = false;
1066
-		    //$SI::del();
1067
-		    if ($format == 'vrstcp') {
1060
+			}
1061
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1062
+			//echo $buffer."\n";
1063
+			// lets play nice and handle signals such as ctrl-c/kill properly
1064
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1065
+			$error = false;
1066
+			//$SI::del();
1067
+			if ($format == 'vrstcp') {
1068 1068
 			$buffer = explode('},{',$buffer);
1069
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1070
-		    // SBS format is CSV format
1071
-		    if ($buffer !== FALSE && $buffer != '') {
1069
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1070
+			// SBS format is CSV format
1071
+			if ($buffer !== FALSE && $buffer != '') {
1072 1072
 			$tt[$format] = 0;
1073 1073
 			if ($format == 'acarssbs3') {
1074
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1075
-			    $ACARS->add(trim($buffer));
1076
-			    $ACARS->deleteLiveAcarsData();
1074
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1075
+				$ACARS->add(trim($buffer));
1076
+				$ACARS->deleteLiveAcarsData();
1077 1077
 			} elseif ($format == 'raw') {
1078
-			    // AVR format
1079
-			    $data = $SBS->parse($buffer);
1080
-			    if (is_array($data)) {
1078
+				// AVR format
1079
+				$data = $SBS->parse($buffer);
1080
+				if (is_array($data)) {
1081 1081
 				$data['datetime'] = date('Y-m-d H:i:s');
1082 1082
 				$data['format_source'] = 'raw';
1083 1083
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1084 1084
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1085 1085
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1086 1086
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1087
-			    }
1087
+				}
1088 1088
 			} elseif ($format == 'ais') {
1089
-			    $ais_data = $AIS->parse_line(trim($buffer));
1090
-			    $data = array();
1091
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1092
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1093
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1094
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1095
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1096
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1097
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1098
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1099
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1100
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1101
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1102
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1103
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1104
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1089
+				$ais_data = $AIS->parse_line(trim($buffer));
1090
+				$data = array();
1091
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1092
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1093
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1094
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1095
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1096
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1097
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1098
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1099
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1100
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1101
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1102
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1103
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1104
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1105 1105
 
1106
-			    if (isset($ais_data['timestamp'])) {
1106
+				if (isset($ais_data['timestamp'])) {
1107 1107
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1108
-			    } else {
1108
+				} else {
1109 1109
 				$data['datetime'] = date('Y-m-d H:i:s');
1110
-			    }
1111
-			    $data['format_source'] = 'aisnmea';
1112
-    			    $data['id_source'] = $id_source;
1113
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1114
-			    unset($data);
1115
-                        } elseif ($format == 'flightgearsp') {
1116
-                    	    //echo $buffer."\n";
1117
-                    	    if (strlen($buffer) > 5) {
1110
+				}
1111
+				$data['format_source'] = 'aisnmea';
1112
+					$data['id_source'] = $id_source;
1113
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1114
+				unset($data);
1115
+						} elseif ($format == 'flightgearsp') {
1116
+							//echo $buffer."\n";
1117
+							if (strlen($buffer) > 5) {
1118 1118
 				$line = explode(',',$buffer);
1119 1119
 				$data = array();
1120 1120
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1131,38 +1131,38 @@  discard block
 block discarded – undo
1131 1131
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1132 1132
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1133 1133
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1134
-			    }
1135
-                        } elseif ($format == 'acars') {
1136
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1137
-			    $ACARS->add(trim($buffer));
1138
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1139
-			    $ACARS->deleteLiveAcarsData();
1134
+				}
1135
+						} elseif ($format == 'acars') {
1136
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1137
+				$ACARS->add(trim($buffer));
1138
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1139
+				$ACARS->deleteLiveAcarsData();
1140 1140
 			} elseif ($format == 'flightgearmp') {
1141
-			    if (substr($buffer,0,1) != '#') {
1141
+				if (substr($buffer,0,1) != '#') {
1142 1142
 				$data = array();
1143 1143
 				//echo $buffer."\n";
1144 1144
 				$line = explode(' ',$buffer);
1145 1145
 				if (count($line) == 11) {
1146
-				    $userserver = explode('@',$line[0]);
1147
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1148
-				    $data['ident'] = $userserver[0];
1149
-				    $data['registration'] = $userserver[0];
1150
-				    $data['latitude'] = $line[4];
1151
-				    $data['longitude'] = $line[5];
1152
-				    $data['altitude'] = $line[6];
1153
-				    $data['datetime'] = date('Y-m-d H:i:s');
1154
-				    $aircraft_type = $line[10];
1155
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1156
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1157
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1158
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1146
+					$userserver = explode('@',$line[0]);
1147
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1148
+					$data['ident'] = $userserver[0];
1149
+					$data['registration'] = $userserver[0];
1150
+					$data['latitude'] = $line[4];
1151
+					$data['longitude'] = $line[5];
1152
+					$data['altitude'] = $line[6];
1153
+					$data['datetime'] = date('Y-m-d H:i:s');
1154
+					$aircraft_type = $line[10];
1155
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1156
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1157
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1158
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1159
+				}
1159 1160
 				}
1160
-			    }
1161 1161
 			} elseif ($format == 'beast') {
1162
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1163
-			    die;
1162
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1163
+				die;
1164 1164
 			} elseif ($format == 'vrstcp') {
1165
-			    foreach($buffer as $all_data) {
1165
+				foreach($buffer as $all_data) {
1166 1166
 				$line = json_decode('{'.$all_data.'}',true);
1167 1167
 				$data = array();
1168 1168
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1182,109 +1182,109 @@  discard block
 block discarded – undo
1182 1182
 				*/
1183 1183
 				$data['datetime'] = date('Y-m-d H:i:s');
1184 1184
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1185
-		    		$data['format_source'] = 'vrstcp';
1185
+					$data['format_source'] = 'vrstcp';
1186 1186
 				$data['id_source'] = $id_source;
1187 1187
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1188 1188
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1189 1189
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1190 1190
 				unset($data);
1191
-			    }
1191
+				}
1192 1192
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1193
-			    $line = explode("\t", $buffer);
1194
-			    for($k = 0; $k < count($line); $k=$k+2) {
1193
+				$line = explode("\t", $buffer);
1194
+				for($k = 0; $k < count($line); $k=$k+2) {
1195 1195
 				$key = $line[$k];
1196
-			        $lined[$key] = $line[$k+1];
1197
-			    }
1198
-    			    if (count($lined) > 3) {
1199
-    				$data['hex'] = $lined['hexid'];
1200
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1201
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1202
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1203
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1204
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1205
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1206
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1207
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1208
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1209
-    				$data['id_source'] = $id_source;
1210
-    				$data['format_source'] = 'tsv';
1211
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1212
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1196
+					$lined[$key] = $line[$k+1];
1197
+				}
1198
+					if (count($lined) > 3) {
1199
+					$data['hex'] = $lined['hexid'];
1200
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1201
+					$data['datetime'] = date('Y-m-d H:i:s');;
1202
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1203
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1204
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1205
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1206
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1207
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1208
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1209
+					$data['id_source'] = $id_source;
1210
+					$data['format_source'] = 'tsv';
1211
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1212
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1213 1213
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1214
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1215
-    				unset($lined);
1216
-    				unset($data);
1217
-    			    } else $error = true;
1214
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1215
+					unset($lined);
1216
+					unset($data);
1217
+					} else $error = true;
1218 1218
 			} elseif ($format == 'aprs' && $use_aprs) {
1219
-			    if ($aprs_connect == 0) {
1219
+				if ($aprs_connect == 0) {
1220 1220
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1221 1221
 				$aprs_connect = 1;
1222
-			    }
1222
+				}
1223 1223
 			    
1224
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1224
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1225 1225
 				$aprs_last_tx = time();
1226 1226
 				$data_aprs = "# Keep alive";
1227 1227
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1228
-			    }
1228
+				}
1229 1229
 			    
1230
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1231
-			    //echo 'APRS data : '.$buffer."\n";
1232
-			    $buffer = str_replace('APRS <- ','',$buffer);
1233
-			    $buffer = str_replace('APRS -> ','',$buffer);
1234
-			    //echo $buffer."\n";
1235
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1230
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1231
+				//echo 'APRS data : '.$buffer."\n";
1232
+				$buffer = str_replace('APRS <- ','',$buffer);
1233
+				$buffer = str_replace('APRS -> ','',$buffer);
1234
+				//echo $buffer."\n";
1235
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1236 1236
 				$line = $APRS->parse($buffer);
1237 1237
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1238 1238
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1239
-				    $aprs_last_tx = time();
1240
-				    $data = array();
1241
-				    //print_r($line);
1242
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1243
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1244
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1245
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1246
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1247
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1248
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1249
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1250
-				    $data['latitude'] = $line['latitude'];
1251
-				    $data['longitude'] = $line['longitude'];
1252
-				    //$data['verticalrate'] = $line[16];
1253
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1254
-				    else $data['speed'] = 0;
1255
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1256
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1257
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1258
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1259
-				    //else $data['heading'] = 0;
1260
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1261
-				    if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1262
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1263
-    				    $data['id_source'] = $id_source;
1264
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1265
-				    else $data['format_source'] = 'aprs';
1266
-				    $data['source_name'] = $line['source'];
1267
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1268
-				    else $data['source_type'] = 'flarm';
1269
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1270
-				    $currentdate = date('Y-m-d H:i:s');
1271
-				    $aprsdate = strtotime($data['datetime']);
1272
-				    // Accept data if time <= system time + 20s
1273
-				    //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1274
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1239
+					$aprs_last_tx = time();
1240
+					$data = array();
1241
+					//print_r($line);
1242
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1243
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1244
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1245
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1246
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1247
+					else $data['datetime'] = date('Y-m-d H:i:s');
1248
+					//$data['datetime'] = date('Y-m-d H:i:s');
1249
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1250
+					$data['latitude'] = $line['latitude'];
1251
+					$data['longitude'] = $line['longitude'];
1252
+					//$data['verticalrate'] = $line[16];
1253
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1254
+					else $data['speed'] = 0;
1255
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1256
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1257
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1258
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1259
+					//else $data['heading'] = 0;
1260
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1261
+					if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1262
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1263
+						$data['id_source'] = $id_source;
1264
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1265
+					else $data['format_source'] = 'aprs';
1266
+					$data['source_name'] = $line['source'];
1267
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1268
+					else $data['source_type'] = 'flarm';
1269
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1270
+					$currentdate = date('Y-m-d H:i:s');
1271
+					$aprsdate = strtotime($data['datetime']);
1272
+					// Accept data if time <= system time + 20s
1273
+					//if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1274
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1275 1275
 					$send = $SI->add($data);
1276
-				    } elseif ($data['source_type'] == 'ais') {
1276
+					} elseif ($data['source_type'] == 'ais') {
1277 1277
 					echo 'add...'."\n";
1278 1278
 					$send = $MI->add($data);
1279
-				    } elseif (isset($line['stealth'])) {
1279
+					} elseif (isset($line['stealth'])) {
1280 1280
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1281 1281
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1282
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1283
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1282
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1283
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1284 1284
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1285 1285
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1286
-				    }
1287
-				    unset($data);
1286
+					}
1287
+					unset($data);
1288 1288
 				} 
1289 1289
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1290 1290
 					echo '!! Weather Station not yet supported'."\n";
@@ -1294,12 +1294,12 @@  discard block
 block discarded – undo
1294 1294
 				}
1295 1295
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1296 1296
 				//elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1297
-			    }
1297
+				}
1298 1298
 			} else {
1299
-			    $line = explode(',', $buffer);
1300
-    			    if (count($line) > 20) {
1301
-    			    	$data['hex'] = $line[4];
1302
-    				/*
1299
+				$line = explode(',', $buffer);
1300
+					if (count($line) > 20) {
1301
+						$data['hex'] = $line[4];
1302
+					/*
1303 1303
     				$data['datetime'] = $line[6].' '.$line[7];
1304 1304
     					date_default_timezone_set($globalTimezone);
1305 1305
     					$datetime = new DateTime($data['datetime']);
@@ -1307,30 +1307,30 @@  discard block
 block discarded – undo
1307 1307
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1308 1308
     					date_default_timezone_set('UTC');
1309 1309
     				*/
1310
-    				// Force datetime to current UTC datetime
1311
-    				date_default_timezone_set('UTC');
1312
-    				$data['datetime'] = date('Y-m-d H:i:s');
1313
-    				$data['ident'] = trim($line[10]);
1314
-    				$data['latitude'] = $line[14];
1315
-    				$data['longitude'] = $line[15];
1316
-    				$data['verticalrate'] = $line[16];
1317
-    				$data['emergency'] = $line[20];
1318
-    				$data['speed'] = $line[12];
1319
-    				$data['squawk'] = $line[17];
1320
-    				$data['altitude'] = $line[11];
1321
-    				$data['heading'] = $line[13];
1322
-    				$data['ground'] = $line[21];
1323
-    				$data['emergency'] = $line[19];
1324
-    				$data['format_source'] = 'sbs';
1310
+					// Force datetime to current UTC datetime
1311
+					date_default_timezone_set('UTC');
1312
+					$data['datetime'] = date('Y-m-d H:i:s');
1313
+					$data['ident'] = trim($line[10]);
1314
+					$data['latitude'] = $line[14];
1315
+					$data['longitude'] = $line[15];
1316
+					$data['verticalrate'] = $line[16];
1317
+					$data['emergency'] = $line[20];
1318
+					$data['speed'] = $line[12];
1319
+					$data['squawk'] = $line[17];
1320
+					$data['altitude'] = $line[11];
1321
+					$data['heading'] = $line[13];
1322
+					$data['ground'] = $line[21];
1323
+					$data['emergency'] = $line[19];
1324
+					$data['format_source'] = 'sbs';
1325 1325
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1326
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1326
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1327 1327
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1328
-    				$data['id_source'] = $id_source;
1329
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1330
-    				else $error = true;
1331
-    				unset($data);
1332
-    			    } else $error = true;
1333
-			    if ($error) {
1328
+					$data['id_source'] = $id_source;
1329
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1330
+					else $error = true;
1331
+					unset($data);
1332
+					} else $error = true;
1333
+				if ($error) {
1334 1334
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1335 1335
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1336 1336
 				} else {
@@ -1346,13 +1346,13 @@  discard block
 block discarded – undo
1346 1346
 					connect_all($sourceer);
1347 1347
 					$sourceer = array();
1348 1348
 				}
1349
-			    }
1349
+				}
1350 1350
 			}
1351 1351
 			// Sleep for xxx microseconds
1352 1352
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1353
-		    } else {
1353
+			} else {
1354 1354
 			if ($format == 'flightgearmp') {
1355
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1355
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1356 1356
 				//@socket_close($r);
1357 1357
 				sleep($globalMinFetch);
1358 1358
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1361,9 +1361,9 @@  discard block
 block discarded – undo
1361 1361
 				break;
1362 1362
 				
1363 1363
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1364
-			    if (isset($tt[$format])) $tt[$format]++;
1365
-			    else $tt[$format] = 0;
1366
-			    if ($tt[$format] > 30) {
1364
+				if (isset($tt[$format])) $tt[$format]++;
1365
+				else $tt[$format] = 0;
1366
+				if ($tt[$format] > 30) {
1367 1367
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1368 1368
 				//@socket_close($r);
1369 1369
 				sleep(2);
@@ -1374,23 +1374,23 @@  discard block
 block discarded – undo
1374 1374
 				//connect_all($globalSources);
1375 1375
 				$tt[$format]=0;
1376 1376
 				break;
1377
-			    }
1377
+				}
1378
+			}
1378 1379
 			}
1379
-		    }
1380 1380
 		}
1381
-	    } else {
1381
+		} else {
1382 1382
 		$error = socket_strerror(socket_last_error());
1383 1383
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1384 1384
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1385 1385
 			if (isset($globalDebug)) echo "Restarting...\n";
1386 1386
 			// Restart the script if possible
1387 1387
 			if (is_array($sockets)) {
1388
-			    if ($globalDebug) echo "Shutdown all sockets...";
1388
+				if ($globalDebug) echo "Shutdown all sockets...";
1389 1389
 			    
1390
-			    foreach ($sockets as $sock) {
1390
+				foreach ($sockets as $sock) {
1391 1391
 				@socket_shutdown($sock,2);
1392 1392
 				@socket_close($sock);
1393
-			    }
1393
+				}
1394 1394
 			    
1395 1395
 			}
1396 1396
 			if ($globalDebug) echo "Waiting...";
@@ -1405,13 +1405,13 @@  discard block
 block discarded – undo
1405 1405
 			if ($globalDebug) echo "Restart all connections...";
1406 1406
 			connect_all($globalSources);
1407 1407
 		}
1408
-	    }
1408
+		}
1409 1409
 	}
1410 1410
 	if ($globalDaemon === false) {
1411
-	    if ($globalDebug) echo 'Check all...'."\n";
1412
-	    $SI->checkAll();
1411
+		if ($globalDebug) echo 'Check all...'."\n";
1412
+		$SI->checkAll();
1413
+	}
1413 1414
 	}
1414
-    }
1415 1415
 }
1416 1416
 
1417 1417
 ?>
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Indentation   +618 added lines, -618 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@  discard block
 block discarded – undo
8 8
 class update_schema {
9 9
 
10 10
 	public static function update_schedule() {
11
-	    $Connection = new Connection();
12
-	    $Schedule = new Schedule();
13
-	    $query = "SELECT * FROM schedule";
14
-            try {
15
-            	$sth = $Connection->db->prepare($query);
11
+		$Connection = new Connection();
12
+		$Schedule = new Schedule();
13
+		$query = "SELECT * FROM schedule";
14
+			try {
15
+				$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+			} catch(PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19
-    	    }
20
-    	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
-    	    }
19
+			}
20
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
+			$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
+			}
23 23
 	
24 24
 	}
25 25
 /*
@@ -43,198 +43,198 @@  discard block
 block discarded – undo
43 43
     	}
44 44
 */	
45 45
 	private static function update_from_1() {
46
-    		$Connection = new Connection();
47
-    		// Add new column to routes table
48
-    		//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
46
+			$Connection = new Connection();
47
+			// Add new column to routes table
48
+			//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
49 49
 		$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL";
50
-        	try {
51
-            	    $sth = $Connection->db->prepare($query);
52
-		    $sth->execute();
53
-    		} catch(PDOException $e) {
54
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
-    		}
56
-    		// Copy schedules data to routes table
57
-    		self::update_schedule();
58
-    		// Delete schedule table
50
+			try {
51
+					$sth = $Connection->db->prepare($query);
52
+			$sth->execute();
53
+			} catch(PDOException $e) {
54
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
+			}
56
+			// Copy schedules data to routes table
57
+			self::update_schedule();
58
+			// Delete schedule table
59 59
 		$query = "DROP TABLE `schedule`";
60
-        	try {
61
-            	    $sth = $Connection->db->prepare($query);
62
-		    $sth->execute();
63
-    		} catch(PDOException $e) {
64
-		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65
-    		}
66
-    		// Add source column
67
-    		$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
-    		try {
69
-            	    $sth = $Connection->db->prepare($query);
70
-		    $sth->execute();
71
-    		} catch(PDOException $e) {
72
-		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
-    		}
60
+			try {
61
+					$sth = $Connection->db->prepare($query);
62
+			$sth->execute();
63
+			} catch(PDOException $e) {
64
+			return "error (delete schedule table) : ".$e->getMessage()."\n";
65
+			}
66
+			// Add source column
67
+			$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
+			try {
69
+					$sth = $Connection->db->prepare($query);
70
+			$sth->execute();
71
+			} catch(PDOException $e) {
72
+			return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
+			}
74 74
 		// Delete unused column
75 75
 		$query = "ALTER TABLE `aircraft_modes`  DROP `SerialNo`,  DROP `OperatorFlagCode`,  DROP `Manufacturer`,  DROP `Type`,  DROP `FirstRegDate`,  DROP `CurrentRegDate`,  DROP `Country`,  DROP `PreviousID`,  DROP `DeRegDate`,  DROP `Status`,  DROP `PopularName`,  DROP `GenericName`,  DROP `AircraftClass`,  DROP `Engines`,  DROP `OwnershipStatus`,  DROP `RegisteredOwners`,  DROP `MTOW`,  DROP `TotalHours`,  DROP `YearBuilt`,  DROP `CofACategory`,  DROP `CofAExpiry`,  DROP `UserNotes`,  DROP `Interested`,  DROP `UserTag`,  DROP `InfoUrl`,  DROP `PictureUrl1`,  DROP `PictureUrl2`,  DROP `PictureUrl3`,  DROP `UserBool1`,  DROP `UserBool2`,  DROP `UserBool3`,  DROP `UserBool4`,  DROP `UserBool5`,  DROP `UserString1`,  DROP `UserString2`,  DROP `UserString3`,  DROP `UserString4`,  DROP `UserString5`,  DROP `UserInt1`,  DROP `UserInt2`,  DROP `UserInt3`,  DROP `UserInt4`,  DROP `UserInt5`";
76
-    		try {
77
-            	    $sth = $Connection->db->prepare($query);
78
-		    $sth->execute();
79
-    		} catch(PDOException $e) {
80
-		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
-    		}
76
+			try {
77
+					$sth = $Connection->db->prepare($query);
78
+			$sth->execute();
79
+			} catch(PDOException $e) {
80
+			return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
+			}
82 82
 		// Add ModeS column
83 83
 		$query = "ALTER TABLE `spotter_output`  ADD `ModeS` VARCHAR(255) NULL";
84
-    		try {
85
-            	    $sth = $Connection->db->prepare($query);
86
-		    $sth->execute();
87
-    		} catch(PDOException $e) {
88
-		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
-    		}
84
+			try {
85
+					$sth = $Connection->db->prepare($query);
86
+			$sth->execute();
87
+			} catch(PDOException $e) {
88
+			return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
+			}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91
-    		try {
92
-            	    $sth = $Connection->db->prepare($query);
93
-		    $sth->execute();
94
-    		} catch(PDOException $e) {
95
-		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
-    		}
97
-    		// Add auto_increment for aircraft_modes
98
-    		$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
-    		try {
100
-            	    $sth = $Connection->db->prepare($query);
101
-		    $sth->execute();
102
-    		} catch(PDOException $e) {
103
-		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
-    		}
105
-    		$error = '';
91
+			try {
92
+					$sth = $Connection->db->prepare($query);
93
+			$sth->execute();
94
+			} catch(PDOException $e) {
95
+			return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
+			}
97
+			// Add auto_increment for aircraft_modes
98
+			$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
+			try {
100
+					$sth = $Connection->db->prepare($query);
101
+			$sth->execute();
102
+			} catch(PDOException $e) {
103
+			return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
+			}
105
+			$error = '';
106 106
 		$error .= create_db::import_file('../db/acars_live.sql');
107 107
 		$error .= create_db::import_file('../db/config.sql');
108 108
 		// Update schema_version to 2
109 109
 		$query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'";
110
-        	try {
111
-            	    $sth = $Connection->db->prepare($query);
112
-		    $sth->execute();
113
-    		} catch(PDOException $e) {
114
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
115
-    		}
110
+			try {
111
+					$sth = $Connection->db->prepare($query);
112
+			$sth->execute();
113
+			} catch(PDOException $e) {
114
+			return "error (update schema_version) : ".$e->getMessage()."\n";
115
+			}
116 116
 		return $error;
117
-        }
117
+		}
118 118
 
119 119
 	private static function update_from_2() {
120
-    		$Connection = new Connection();
121
-    		// Add new column decode to acars_live table
120
+			$Connection = new Connection();
121
+			// Add new column decode to acars_live table
122 122
 		$query = "ALTER TABLE `acars_live` ADD `decode` TEXT";
123
-        	try {
124
-            	    $sth = $Connection->db->prepare($query);
125
-		    $sth->execute();
126
-    		} catch(PDOException $e) {
127
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
-    		}
129
-    		$error = '';
130
-    		// Create table acars_archive
123
+			try {
124
+					$sth = $Connection->db->prepare($query);
125
+			$sth->execute();
126
+			} catch(PDOException $e) {
127
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
+			}
129
+			$error = '';
130
+			// Create table acars_archive
131 131
 		$error .= create_db::import_file('../db/acars_archive.sql');
132 132
 		// Update schema_version to 3
133 133
 		$query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'";
134
-        	try {
135
-            	    $sth = $Connection->db->prepare($query);
136
-		    $sth->execute();
137
-    		} catch(PDOException $e) {
138
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
139
-    		}
134
+			try {
135
+					$sth = $Connection->db->prepare($query);
136
+			$sth->execute();
137
+			} catch(PDOException $e) {
138
+			return "error (update schema_version) : ".$e->getMessage()."\n";
139
+			}
140 140
 		return $error;
141 141
 	}
142 142
 
143 143
 	private static function update_from_3() {
144
-    		$Connection = new Connection();
145
-    		// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
144
+			$Connection = new Connection();
145
+			// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
146 146
 		$query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP";
147
-        	try {
148
-            	    $sth = $Connection->db->prepare($query);
149
-		    $sth->execute();
150
-    		} catch(PDOException $e) {
151
-		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
-    		}
153
-    		// Add image_source_website column to spotter_image
147
+			try {
148
+					$sth = $Connection->db->prepare($query);
149
+			$sth->execute();
150
+			} catch(PDOException $e) {
151
+			return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
+			}
153
+			// Add image_source_website column to spotter_image
154 154
 		$query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL";
155
-        	try {
156
-            	    $sth = $Connection->db->prepare($query);
157
-		    $sth->execute();
158
-    		} catch(PDOException $e) {
159
-		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
-    		}
161
-    		$error = '';
155
+			try {
156
+					$sth = $Connection->db->prepare($query);
157
+			$sth->execute();
158
+			} catch(PDOException $e) {
159
+			return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
+			}
161
+			$error = '';
162 162
 		// Update schema_version to 4
163 163
 		$query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'";
164
-        	try {
165
-            	    $sth = $Connection->db->prepare($query);
166
-		    $sth->execute();
167
-    		} catch(PDOException $e) {
168
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
169
-    		}
164
+			try {
165
+					$sth = $Connection->db->prepare($query);
166
+			$sth->execute();
167
+			} catch(PDOException $e) {
168
+			return "error (update schema_version) : ".$e->getMessage()."\n";
169
+			}
170 170
 		return $error;
171 171
 	}
172 172
 	
173 173
 	private static function update_from_4() {
174
-    		$Connection = new Connection();
174
+			$Connection = new Connection();
175 175
 	
176
-    		$error = '';
177
-    		// Create table acars_label
176
+			$error = '';
177
+			// Create table acars_label
178 178
 		$error .= create_db::import_file('../db/acars_label.sql');
179 179
 		if ($error == '') {
180
-		    // Update schema_version to 5
181
-		    $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
-        	    try {
183
-            		$sth = $Connection->db->prepare($query);
180
+			// Update schema_version to 5
181
+			$query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
+				try {
183
+					$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+				} catch(PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187
-    		    }
188
-    		}
187
+				}
188
+			}
189 189
 		return $error;
190 190
 	}
191 191
 
192 192
 	private static function update_from_5() {
193
-    		$Connection = new Connection();
194
-    		// Add columns to translation
193
+			$Connection = new Connection();
194
+			// Add columns to translation
195 195
 		$query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;";
196
-        	try {
197
-            	    $sth = $Connection->db->prepare($query);
198
-		    $sth->execute();
199
-    		} catch(PDOException $e) {
200
-		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
-    		}
202
-    		// Add aircraft_shadow column to aircraft
203
-    		$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
-        	try {
205
-            	    $sth = $Connection->db->prepare($query);
206
-		    $sth->execute();
207
-    		} catch(PDOException $e) {
208
-		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
-    		}
210
-    		// Add aircraft_shadow column to spotter_live
211
-    		$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
-        	try {
213
-            	    $sth = $Connection->db->prepare($query);
214
-		    $sth->execute();
215
-    		} catch(PDOException $e) {
216
-		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
-    		}
218
-    		$error = '';
219
-    		// Update table aircraft
196
+			try {
197
+					$sth = $Connection->db->prepare($query);
198
+			$sth->execute();
199
+			} catch(PDOException $e) {
200
+			return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
+			}
202
+			// Add aircraft_shadow column to aircraft
203
+			$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
+			try {
205
+					$sth = $Connection->db->prepare($query);
206
+			$sth->execute();
207
+			} catch(PDOException $e) {
208
+			return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
+			}
210
+			// Add aircraft_shadow column to spotter_live
211
+			$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
+			try {
213
+					$sth = $Connection->db->prepare($query);
214
+			$sth->execute();
215
+			} catch(PDOException $e) {
216
+			return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
+			}
218
+			$error = '';
219
+			// Update table aircraft
220 220
 		$error .= create_db::import_file('../db/aircraft.sql');
221 221
 		$error .= create_db::import_file('../db/spotter_archive.sql');
222 222
 
223 223
 		// Update schema_version to 6
224 224
 		$query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'";
225
-        	try {
226
-            	    $sth = $Connection->db->prepare($query);
227
-		    $sth->execute();
228
-    		} catch(PDOException $e) {
229
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
230
-    		}
225
+			try {
226
+					$sth = $Connection->db->prepare($query);
227
+			$sth->execute();
228
+			} catch(PDOException $e) {
229
+			return "error (update schema_version) : ".$e->getMessage()."\n";
230
+			}
231 231
 		return $error;
232 232
 	}
233 233
 
234 234
 	private static function update_from_6() {
235
-    		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
-    		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
235
+			$Connection = new Connection();
236
+			if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
+				$query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
240 240
 			ALTER TABLE spotter_live ADD INDEX(flightaware_id);
@@ -247,147 +247,147 @@  discard block
 block discarded – undo
247 247
 			ALTER TABLE aircraft ADD INDEX(icao);
248 248
 			ALTER TABLE airport ADD INDEX(icao);
249 249
 			ALTER TABLE translation ADD INDEX(Operator);";
250
-        	    try {
251
-            		$sth = $Connection->db->prepare($query);
250
+				try {
251
+					$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+				} catch(PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255
-    		    }
256
-    		}
257
-    		$error = '';
258
-    		// Update table countries
259
-    		if ($Connection->tableExists('airspace')) {
260
-    		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
255
+				}
256
+			}
257
+			$error = '';
258
+			// Update table countries
259
+			if ($Connection->tableExists('airspace')) {
260
+				$error .= update_db::update_countries();
261
+			if ($error != '') return $error;
262 262
 		}
263 263
 		// Update schema_version to 7
264 264
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
265
-        	try {
266
-            	    $sth = $Connection->db->prepare($query);
267
-		    $sth->execute();
268
-    		} catch(PDOException $e) {
269
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
270
-    		}
265
+			try {
266
+					$sth = $Connection->db->prepare($query);
267
+			$sth->execute();
268
+			} catch(PDOException $e) {
269
+			return "error (update schema_version) : ".$e->getMessage()."\n";
270
+			}
271 271
 		return $error;
272
-    	}
272
+		}
273 273
 
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276
-    		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
276
+			$Connection = new Connection();
277
+			$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279
-        	try {
280
-            	    $sth = $Connection->db->prepare($query);
281
-		    $sth->execute();
282
-    		} catch(PDOException $e) {
283
-		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
-    		}
285
-    		if ($globalDBdriver == 'mysql') {
286
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
-		    try {
288
-            		$sth = $Connection->db->prepare($query);
289
-			$sth->execute();
290
-    		    } catch(PDOException $e) {
279
+			try {
280
+					$sth = $Connection->db->prepare($query);
281
+			$sth->execute();
282
+			} catch(PDOException $e) {
283
+			return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
+			}
285
+			if ($globalDBdriver == 'mysql') {
286
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
+			try {
288
+					$sth = $Connection->db->prepare($query);
289
+			$sth->execute();
290
+				} catch(PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292
-    		    }
293
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
294
-    		    if ($row['engine'] == 'ARCHIVE') {
292
+				}
293
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
294
+				if ($row['engine'] == 'ARCHIVE') {
295 295
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
296 296
 				ALTER TABLE copy ENGINE=ARCHIVE;
297 297
 				ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
298 298
 				INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`;
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301
-            	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
-            	    }
304
-                } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
-                }
307
-        	try {
308
-            	    $sth = $Connection->db->prepare($query);
309
-		    $sth->execute();
310
-    		} catch(PDOException $e) {
311
-		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
-    		}
301
+					} else {
302
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
+					}
304
+				} else {
305
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
+				}
307
+			try {
308
+					$sth = $Connection->db->prepare($query);
309
+			$sth->execute();
310
+			} catch(PDOException $e) {
311
+			return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
+			}
313 313
 
314
-    		$error = '';
315
-    		// Update table aircraft
314
+			$error = '';
315
+			// Update table aircraft
316 316
 		$error .= create_db::import_file('../db/source_location.sql');
317 317
 		if ($error != '') return $error;
318 318
 		// Update schema_version to 6
319 319
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320
-        	try {
321
-            	    $sth = $Connection->db->prepare($query);
322
-		    $sth->execute();
323
-    		} catch(PDOException $e) {
324
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
325
-    		}
320
+			try {
321
+					$sth = $Connection->db->prepare($query);
322
+			$sth->execute();
323
+			} catch(PDOException $e) {
324
+			return "error (update schema_version) : ".$e->getMessage()."\n";
325
+			}
326 326
 		return $error;
327 327
 	}
328 328
 
329 329
 	private static function update_from_8() {
330
-    		$Connection = new Connection();
331
-    		$error = '';
332
-    		// Update table aircraft
330
+			$Connection = new Connection();
331
+			$error = '';
332
+			// Update table aircraft
333 333
 		$error .= create_db::import_file('../db/notam.sql');
334 334
 		if ($error != '') return $error;
335 335
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 336
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 337
                         DELETE FROM config WHERE name = 'last_update_notam_db';
338 338
                         INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());";
339
-        	try {
340
-            	    $sth = $Connection->db->prepare($query);
341
-		    $sth->execute();
342
-    		} catch(PDOException $e) {
343
-		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344
-    		}
339
+			try {
340
+					$sth = $Connection->db->prepare($query);
341
+			$sth->execute();
342
+			} catch(PDOException $e) {
343
+			return "error (insert last_update values) : ".$e->getMessage()."\n";
344
+			}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346
-        	try {
347
-            	    $sth = $Connection->db->prepare($query);
348
-		    $sth->execute();
349
-    		} catch(PDOException $e) {
350
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
351
-    		}
346
+			try {
347
+					$sth = $Connection->db->prepare($query);
348
+			$sth->execute();
349
+			} catch(PDOException $e) {
350
+			return "error (update schema_version) : ".$e->getMessage()."\n";
351
+			}
352 352
 		return $error;
353 353
 	}
354 354
 
355 355
 	private static function update_from_9() {
356
-    		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
356
+			$Connection = new Connection();
357
+			$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359
-        	try {
360
-            	    $sth = $Connection->db->prepare($query);
361
-		    $sth->execute();
362
-    		} catch(PDOException $e) {
363
-		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
-    		}
359
+			try {
360
+					$sth = $Connection->db->prepare($query);
361
+			$sth->execute();
362
+			} catch(PDOException $e) {
363
+			return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
+			}
365 365
 		$error = '';
366
-    		// Update table atc
366
+			// Update table atc
367 367
 		$error .= create_db::import_file('../db/atc.sql');
368 368
 		if ($error != '') return $error;
369 369
 		
370 370
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371
-        	try {
372
-            	    $sth = $Connection->db->prepare($query);
373
-		    $sth->execute();
374
-    		} catch(PDOException $e) {
375
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
376
-    		}
371
+			try {
372
+					$sth = $Connection->db->prepare($query);
373
+			$sth->execute();
374
+			} catch(PDOException $e) {
375
+			return "error (update schema_version) : ".$e->getMessage()."\n";
376
+			}
377 377
 		return $error;
378 378
 	}
379 379
 
380 380
 	private static function update_from_10() {
381
-    		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
-        	try {
384
-            	    $sth = $Connection->db->prepare($query);
385
-		    $sth->execute();
386
-    		} catch(PDOException $e) {
387
-		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
-    		}
381
+			$Connection = new Connection();
382
+			$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
+			try {
384
+					$sth = $Connection->db->prepare($query);
385
+			$sth->execute();
386
+			} catch(PDOException $e) {
387
+			return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
+			}
389 389
 		$error = '';
390
-    		// Add tables
390
+			// Add tables
391 391
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392 392
 		if ($error != '') return $error;
393 393
 		$error .= create_db::import_file('../db/metar.sql');
@@ -398,76 +398,76 @@  discard block
 block discarded – undo
398 398
 		if ($error != '') return $error;
399 399
 		
400 400
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401
-        	try {
402
-            	    $sth = $Connection->db->prepare($query);
403
-		    $sth->execute();
404
-    		} catch(PDOException $e) {
405
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
406
-    		}
401
+			try {
402
+					$sth = $Connection->db->prepare($query);
403
+			$sth->execute();
404
+			} catch(PDOException $e) {
405
+			return "error (update schema_version) : ".$e->getMessage()."\n";
406
+			}
407 407
 		return $error;
408 408
 	}
409 409
 
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412
-    		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
-        	try {
415
-            	    $sth = $Connection->db->prepare($query);
416
-		    $sth->execute();
417
-    		} catch(PDOException $e) {
418
-		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
-    		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
-        	try {
422
-            	    $sth = $Connection->db->prepare($query);
423
-		    $sth->execute();
424
-    		} catch(PDOException $e) {
425
-		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
-    		}
427
-    		if ($globalDBdriver == 'mysql') {
428
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
-		    try {
430
-            		$sth = $Connection->db->prepare($query);
431
-			$sth->execute();
432
-    		    } catch(PDOException $e) {
412
+			$Connection = new Connection();
413
+			$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
+			try {
415
+					$sth = $Connection->db->prepare($query);
416
+			$sth->execute();
417
+			} catch(PDOException $e) {
418
+			return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
+			}
420
+			$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
+			try {
422
+					$sth = $Connection->db->prepare($query);
423
+			$sth->execute();
424
+			} catch(PDOException $e) {
425
+			return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
+			}
427
+			if ($globalDBdriver == 'mysql') {
428
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
+			try {
430
+					$sth = $Connection->db->prepare($query);
431
+			$sth->execute();
432
+				} catch(PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434
-    		    }
435
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
436
-    		    if ($row['engine'] == 'ARCHIVE') {
434
+				}
435
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
436
+				if ($row['engine'] == 'ARCHIVE') {
437 437
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
438 438
 				ALTER TABLE copy ENGINE=ARCHIVE;
439 439
 				ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE;
440 440
 				INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`;
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443
-            	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
-            	    }
446
-                } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
-                }
449
-        	try {
450
-            	    $sth = $Connection->db->prepare($query);
451
-		    $sth->execute();
452
-    		} catch(PDOException $e) {
453
-		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
-    		}
443
+					} else {
444
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
+					}
446
+				} else {
447
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
+				}
449
+			try {
450
+					$sth = $Connection->db->prepare($query);
451
+			$sth->execute();
452
+			} catch(PDOException $e) {
453
+			return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
+			}
455 455
 
456 456
 		$error = '';
457 457
 		
458 458
 		$query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'";
459
-        	try {
460
-            	    $sth = $Connection->db->prepare($query);
461
-		    $sth->execute();
462
-    		} catch(PDOException $e) {
463
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
464
-    		}
459
+			try {
460
+					$sth = $Connection->db->prepare($query);
461
+			$sth->execute();
462
+			} catch(PDOException $e) {
463
+			return "error (update schema_version) : ".$e->getMessage()."\n";
464
+			}
465 465
 		return $error;
466 466
 	}
467 467
 	private static function update_from_12() {
468
-    		$Connection = new Connection();
468
+			$Connection = new Connection();
469 469
 		$error = '';
470
-    		// Add tables
470
+			// Add tables
471 471
 		$error .= create_db::import_file('../db/stats.sql');
472 472
 		if ($error != '') return $error;
473 473
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
@@ -484,166 +484,166 @@  discard block
 block discarded – undo
484 484
 		if ($error != '') return $error;
485 485
 		
486 486
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487
-        	try {
488
-            	    $sth = $Connection->db->prepare($query);
489
-		    $sth->execute();
490
-    		} catch(PDOException $e) {
491
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
492
-    		}
487
+			try {
488
+					$sth = $Connection->db->prepare($query);
489
+			$sth->execute();
490
+			} catch(PDOException $e) {
491
+			return "error (update schema_version) : ".$e->getMessage()."\n";
492
+			}
493 493
 		return $error;
494 494
 	}
495 495
 
496 496
 	private static function update_from_13() {
497
-    		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
497
+			$Connection = new Connection();
498
+			if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
+				$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+				} catch(PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505
-    			}
505
+				}
506 506
 		}
507
-    		$error = '';
507
+			$error = '';
508 508
 		$query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'";
509
-        	try {
510
-            	    $sth = $Connection->db->prepare($query);
511
-		    $sth->execute();
512
-    		} catch(PDOException $e) {
513
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
514
-    		}
509
+			try {
510
+					$sth = $Connection->db->prepare($query);
511
+			$sth->execute();
512
+			} catch(PDOException $e) {
513
+			return "error (update schema_version) : ".$e->getMessage()."\n";
514
+			}
515 515
 		return $error;
516 516
 	}
517 517
 
518 518
 	private static function update_from_14() {
519
-    		$Connection = new Connection();
519
+			$Connection = new Connection();
520 520
 		$error = '';
521
-    		// Add tables
522
-    		if (!$Connection->tableExists('stats_flight')) {
521
+			// Add tables
522
+			if (!$Connection->tableExists('stats_flight')) {
523 523
 			$error .= create_db::import_file('../db/stats_flight.sql');
524 524
 			if ($error != '') return $error;
525 525
 		}
526 526
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527
-        	try {
528
-            	    $sth = $Connection->db->prepare($query);
529
-		    $sth->execute();
530
-    		} catch(PDOException $e) {
531
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
532
-    		}
527
+			try {
528
+					$sth = $Connection->db->prepare($query);
529
+			$sth->execute();
530
+			} catch(PDOException $e) {
531
+			return "error (update schema_version) : ".$e->getMessage()."\n";
532
+			}
533 533
 		return $error;
534 534
 	}
535 535
 
536 536
 
537 537
 	private static function update_from_15() {
538
-    		$Connection = new Connection();
538
+			$Connection = new Connection();
539 539
 		$error = '';
540
-    		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
-        	try {
543
-            	    $sth = $Connection->db->prepare($query);
544
-		    $sth->execute();
545
-    		} catch(PDOException $e) {
546
-		    return "error (update stats) : ".$e->getMessage()."\n";
547
-    		}
540
+			// Add tables
541
+			$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
+			try {
543
+					$sth = $Connection->db->prepare($query);
544
+			$sth->execute();
545
+			} catch(PDOException $e) {
546
+			return "error (update stats) : ".$e->getMessage()."\n";
547
+			}
548 548
 		if ($error != '') return $error;
549 549
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550
-        	try {
551
-            	    $sth = $Connection->db->prepare($query);
552
-		    $sth->execute();
553
-    		} catch(PDOException $e) {
554
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
555
-    		}
550
+			try {
551
+					$sth = $Connection->db->prepare($query);
552
+			$sth->execute();
553
+			} catch(PDOException $e) {
554
+			return "error (update schema_version) : ".$e->getMessage()."\n";
555
+			}
556 556
 		return $error;
557 557
 	}
558 558
 
559 559
 	private static function update_from_16() {
560
-    		$Connection = new Connection();
560
+			$Connection = new Connection();
561 561
 		$error = '';
562
-    		// Add tables
563
-    		if (!$Connection->tableExists('stats_registration')) {
562
+			// Add tables
563
+			if (!$Connection->tableExists('stats_registration')) {
564 564
 			$error .= create_db::import_file('../db/stats_registration.sql');
565 565
 		}
566
-    		if (!$Connection->tableExists('stats_callsign')) {
566
+			if (!$Connection->tableExists('stats_callsign')) {
567 567
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 568
 		}
569 569
 		if ($error != '') return $error;
570 570
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571
-        	try {
572
-            	    $sth = $Connection->db->prepare($query);
573
-		    $sth->execute();
574
-    		} catch(PDOException $e) {
575
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
576
-    		}
571
+			try {
572
+					$sth = $Connection->db->prepare($query);
573
+			$sth->execute();
574
+			} catch(PDOException $e) {
575
+			return "error (update schema_version) : ".$e->getMessage()."\n";
576
+			}
577 577
 		return $error;
578 578
 	}
579 579
 
580 580
 	private static function update_from_17() {
581
-    		$Connection = new Connection();
581
+			$Connection = new Connection();
582 582
 		$error = '';
583
-    		// Add tables
584
-    		if (!$Connection->tableExists('stats_country')) {
583
+			// Add tables
584
+			if (!$Connection->tableExists('stats_country')) {
585 585
 			$error .= create_db::import_file('../db/stats_country.sql');
586 586
 		}
587 587
 		if ($error != '') return $error;
588 588
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589
-        	try {
590
-            	    $sth = $Connection->db->prepare($query);
591
-		    $sth->execute();
592
-    		} catch(PDOException $e) {
593
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
594
-    		}
589
+			try {
590
+					$sth = $Connection->db->prepare($query);
591
+			$sth->execute();
592
+			} catch(PDOException $e) {
593
+			return "error (update schema_version) : ".$e->getMessage()."\n";
594
+			}
595 595
 		return $error;
596 596
 	}
597 597
 	private static function update_from_18() {
598
-    		$Connection = new Connection();
598
+			$Connection = new Connection();
599 599
 		$error = '';
600
-    		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
-    			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
-    	        	try {
604
-	            	    $sth = $Connection->db->prepare($query);
605
-			    $sth->execute();
606
-    			} catch(PDOException $e) {
607
-			    return "error (update stats) : ".$e->getMessage()."\n";
608
-    			}
609
-    		}
600
+			// Modify stats_airport table
601
+			if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
+				$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
+					try {
604
+						$sth = $Connection->db->prepare($query);
605
+				$sth->execute();
606
+				} catch(PDOException $e) {
607
+				return "error (update stats) : ".$e->getMessage()."\n";
608
+				}
609
+			}
610 610
 		if ($error != '') return $error;
611 611
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612
-        	try {
613
-            	    $sth = $Connection->db->prepare($query);
614
-		    $sth->execute();
615
-    		} catch(PDOException $e) {
616
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
617
-    		}
612
+			try {
613
+					$sth = $Connection->db->prepare($query);
614
+			$sth->execute();
615
+			} catch(PDOException $e) {
616
+			return "error (update schema_version) : ".$e->getMessage()."\n";
617
+			}
618 618
 		return $error;
619 619
 	}
620 620
 
621 621
 	private static function update_from_19() {
622
-    		$Connection = new Connection();
622
+			$Connection = new Connection();
623 623
 		$error = '';
624
-    		// Update airport table
624
+			// Update airport table
625 625
 		$error .= create_db::import_file('../db/airport.sql');
626 626
 		if ($error != '') return 'Import airport.sql : '.$error;
627 627
 		// Remove primary key on Spotter_Archive
628 628
 		$query = "alter table spotter_archive drop spotter_archive_id";
629
-        	try {
630
-            	    $sth = $Connection->db->prepare($query);
631
-		    $sth->execute();
632
-    		} catch(PDOException $e) {
633
-		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
-    		}
629
+			try {
630
+					$sth = $Connection->db->prepare($query);
631
+			$sth->execute();
632
+			} catch(PDOException $e) {
633
+			return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
+			}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636
-        	try {
637
-            	    $sth = $Connection->db->prepare($query);
638
-		    $sth->execute();
639
-    		} catch(PDOException $e) {
640
-		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
-    		}
636
+			try {
637
+					$sth = $Connection->db->prepare($query);
638
+			$sth->execute();
639
+			} catch(PDOException $e) {
640
+			return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
+			}
642 642
 		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
643 643
 			// Add column over_country
644
-    			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
644
+				$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646
-            			$sth = $Connection->db->prepare($query);
646
+						$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648 648
 			} catch(PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 		}
652 652
 		if (!$Connection->checkColumnName('spotter_live','over_country')) {
653 653
 			// Add column over_country
654
-    			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
654
+				$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656
-            			$sth = $Connection->db->prepare($query);
656
+						$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658 658
 			} catch(PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -661,74 +661,74 @@  discard block
 block discarded – undo
661 661
 		}
662 662
 		if (!$Connection->checkColumnName('spotter_output','source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664
-    			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
664
+				$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668 668
 			} catch(PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670
-    			}
671
-    		}
670
+				}
671
+			}
672 672
 		if (!$Connection->checkColumnName('spotter_live','source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674
-    			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
674
+				$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678 678
 			} catch(PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680
-    			}
681
-    		}
680
+				}
681
+			}
682 682
 		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684
-    			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
684
+				$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688 688
 			} catch(PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690
-    			}
691
-    		}
690
+				}
691
+			}
692 692
 		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694
-    			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
694
+				$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698 698
 			} catch(PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700
-    			}
701
-    		}
700
+				}
701
+			}
702 702
 		if ($error != '') return $error;
703 703
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704
-        	try {
705
-            	    $sth = $Connection->db->prepare($query);
706
-		    $sth->execute();
707
-    		} catch(PDOException $e) {
708
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
709
-    		}
704
+			try {
705
+					$sth = $Connection->db->prepare($query);
706
+			$sth->execute();
707
+			} catch(PDOException $e) {
708
+			return "error (update schema_version) : ".$e->getMessage()."\n";
709
+			}
710 710
 		return $error;
711 711
 	}
712 712
 
713 713
 	private static function update_from_20() {
714 714
 		global $globalIVAO, $globalVATSIM, $globalphpVMS;
715
-    		$Connection = new Connection();
715
+			$Connection = new Connection();
716 716
 		$error = '';
717
-    		// Update airline table
718
-    		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
717
+			// Update airline table
718
+			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722 722
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 723
 			// Add column over_country
724
-    			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
-        		try {
724
+				$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
+				try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728 728
 			} catch(PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730
-    			}
731
-    		}
730
+				}
731
+			}
732 732
 		if ($error != '') return $error;
733 733
 		/*
734 734
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 		}
739 739
 		*/
740 740
 		$query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'";
741
-        	try {
742
-            	    $sth = $Connection->db->prepare($query);
743
-		    $sth->execute();
744
-    		} catch(PDOException $e) {
745
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
746
-    		}
741
+			try {
742
+					$sth = $Connection->db->prepare($query);
743
+			$sth->execute();
744
+			} catch(PDOException $e) {
745
+			return "error (update schema_version) : ".$e->getMessage()."\n";
746
+			}
747 747
 		return $error;
748 748
 	}
749 749
 
@@ -762,35 +762,35 @@  discard block
 block discarded – undo
762 762
 			if ($error != '') return $error;
763 763
 		}
764 764
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765
-        	try {
766
-            	    $sth = $Connection->db->prepare($query);
767
-		    $sth->execute();
768
-    		} catch(PDOException $e) {
769
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
770
-    		}
765
+			try {
766
+					$sth = $Connection->db->prepare($query);
767
+			$sth->execute();
768
+			} catch(PDOException $e) {
769
+			return "error (update schema_version) : ".$e->getMessage()."\n";
770
+			}
771 771
 		return $error;
772 772
 	}
773 773
 
774 774
 	private static function update_from_22() {
775 775
 		global $globalDBdriver;
776
-    		$Connection = new Connection();
776
+			$Connection = new Connection();
777 777
 		$error = '';
778 778
 		// Add table stats polar
779
-    		if (!$Connection->tableExists('stats_source')) {
779
+			if (!$Connection->tableExists('stats_source')) {
780 780
 			if ($globalDBdriver == 'mysql') {
781
-    				$error .= create_db::import_file('../db/stats_source.sql');
781
+					$error .= create_db::import_file('../db/stats_source.sql');
782 782
 			} else {
783 783
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 784
 			}
785 785
 			if ($error != '') return $error;
786 786
 		}
787 787
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788
-        	try {
789
-            	    $sth = $Connection->db->prepare($query);
790
-		    $sth->execute();
791
-    		} catch(PDOException $e) {
792
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
793
-    		}
788
+			try {
789
+					$sth = $Connection->db->prepare($query);
790
+			$sth->execute();
791
+			} catch(PDOException $e) {
792
+			return "error (update schema_version) : ".$e->getMessage()."\n";
793
+			}
794 794
 		return $error;
795 795
 	}
796 796
 
@@ -821,14 +821,14 @@  discard block
 block discarded – undo
821 821
 		}
822 822
 		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824
-    			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824
+				$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828 828
 			} catch(PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830
-    			}
831
-    		}
830
+				}
831
+			}
832 832
 		
833 833
 		$query = "UPDATE config SET value = '24' WHERE name = 'schema_version'";
834 834
 		try {
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 			} catch(PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179
-                }
1179
+				}
1180 1180
 		if (!$Connection->checkColumnName('aircraft','mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 			} catch(PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253
-                }
1253
+				}
1254 1254
 		if (!$Connection->indexExists('accidents','registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
 			} catch(PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263
-                }
1263
+				}
1264 1264
 		if (!$Connection->indexExists('accidents','rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 			} catch(PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273
-                }
1273
+				}
1274 1274
 
1275 1275
 		$query = "UPDATE config SET value = '31' WHERE name = 'schema_version'";
1276 1276
 		try {
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
 			} catch(PDOException $e) {
1563 1563
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1564 1564
 			}
1565
-                }
1565
+				}
1566 1566
 		$query = "UPDATE config SET value = '36' WHERE name = 'schema_version'";
1567 1567
 		try {
1568 1568
 			$sth = $Connection->db->prepare($query);
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
 			} catch(PDOException $e) {
1701 1701
 				return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n";
1702 1702
 			}
1703
-                }
1703
+				}
1704 1704
 		$query = "UPDATE config SET value = '38' WHERE name = 'schema_version'";
1705 1705
 		try {
1706 1706
 			$sth = $Connection->db->prepare($query);
@@ -1873,181 +1873,181 @@  discard block
 block discarded – undo
1873 1873
 	}
1874 1874
 
1875 1875
 
1876
-    	public static function check_version($update = false) {
1877
-    	    global $globalDBname;
1878
-    	    $version = 0;
1879
-    	    $Connection = new Connection();
1880
-    	    if ($Connection->tableExists('aircraft')) {
1881
-    		if (!$Connection->tableExists('config')) {
1882
-    		    $version = '1';
1883
-    		    if ($update) return self::update_from_1();
1884
-    		    else return $version;
1876
+		public static function check_version($update = false) {
1877
+			global $globalDBname;
1878
+			$version = 0;
1879
+			$Connection = new Connection();
1880
+			if ($Connection->tableExists('aircraft')) {
1881
+			if (!$Connection->tableExists('config')) {
1882
+				$version = '1';
1883
+				if ($update) return self::update_from_1();
1884
+				else return $version;
1885 1885
 		} else {
1886
-    		    $Connection = new Connection();
1887
-		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1888
-		    try {
1889
-            		$sth = $Connection->db->prepare($query);
1890
-		        $sth->execute();
1891
-		    } catch(PDOException $e) {
1886
+				$Connection = new Connection();
1887
+			$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1888
+			try {
1889
+					$sth = $Connection->db->prepare($query);
1890
+				$sth->execute();
1891
+			} catch(PDOException $e) {
1892 1892
 			return "error : ".$e->getMessage()."\n";
1893
-    		    }
1894
-    		    $result = $sth->fetch(PDO::FETCH_ASSOC);
1895
-    		    if ($update) {
1896
-    			if ($result['value'] == '2') {
1897
-    			    $error = self::update_from_2();
1898
-    			    if ($error != '') return $error;
1899
-    			    else return self::check_version(true);
1900
-    			} elseif ($result['value'] == '3') {
1901
-    			    $error = self::update_from_3();
1902
-    			    if ($error != '') return $error;
1903
-    			    else return self::check_version(true);
1904
-    			} elseif ($result['value'] == '4') {
1905
-    			    $error = self::update_from_4();
1906
-    			    if ($error != '') return $error;
1907
-    			    else return self::check_version(true);
1908
-    			} elseif ($result['value'] == '5') {
1909
-    			    $error = self::update_from_5();
1910
-    			    if ($error != '') return $error;
1911
-    			    else return self::check_version(true);
1912
-    			} elseif ($result['value'] == '6') {
1913
-    			    $error = self::update_from_6();
1914
-    			    if ($error != '') return $error;
1915
-    			    else return self::check_version(true);
1916
-    			} elseif ($result['value'] == '7') {
1917
-    			    $error = self::update_from_7();
1918
-    			    if ($error != '') return $error;
1919
-    			    else return self::check_version(true);
1920
-    			} elseif ($result['value'] == '8') {
1921
-    			    $error = self::update_from_8();
1922
-    			    if ($error != '') return $error;
1923
-    			    else return self::check_version(true);
1924
-    			} elseif ($result['value'] == '9') {
1925
-    			    $error = self::update_from_9();
1926
-    			    if ($error != '') return $error;
1927
-    			    else return self::check_version(true);
1928
-    			} elseif ($result['value'] == '10') {
1929
-    			    $error = self::update_from_10();
1930
-    			    if ($error != '') return $error;
1931
-    			    else return self::check_version(true);
1932
-    			} elseif ($result['value'] == '11') {
1933
-    			    $error = self::update_from_11();
1934
-    			    if ($error != '') return $error;
1935
-    			    else return self::check_version(true);
1936
-    			} elseif ($result['value'] == '12') {
1937
-    			    $error = self::update_from_12();
1938
-    			    if ($error != '') return $error;
1939
-    			    else return self::check_version(true);
1940
-    			} elseif ($result['value'] == '13') {
1941
-    			    $error = self::update_from_13();
1942
-    			    if ($error != '') return $error;
1943
-    			    else return self::check_version(true);
1944
-    			} elseif ($result['value'] == '14') {
1945
-    			    $error = self::update_from_14();
1946
-    			    if ($error != '') return $error;
1947
-    			    else return self::check_version(true);
1948
-    			} elseif ($result['value'] == '15') {
1949
-    			    $error = self::update_from_15();
1950
-    			    if ($error != '') return $error;
1951
-    			    else return self::check_version(true);
1952
-    			} elseif ($result['value'] == '16') {
1953
-    			    $error = self::update_from_16();
1954
-    			    if ($error != '') return $error;
1955
-    			    else return self::check_version(true);
1956
-    			} elseif ($result['value'] == '17') {
1957
-    			    $error = self::update_from_17();
1958
-    			    if ($error != '') return $error;
1959
-    			    else return self::check_version(true);
1960
-    			} elseif ($result['value'] == '18') {
1961
-    			    $error = self::update_from_18();
1962
-    			    if ($error != '') return $error;
1963
-    			    else return self::check_version(true);
1964
-    			} elseif ($result['value'] == '19') {
1965
-    			    $error = self::update_from_19();
1966
-    			    if ($error != '') return $error;
1967
-    			    else return self::check_version(true);
1968
-    			} elseif ($result['value'] == '20') {
1969
-    			    $error = self::update_from_20();
1970
-    			    if ($error != '') return $error;
1971
-    			    else return self::check_version(true);
1972
-    			} elseif ($result['value'] == '21') {
1973
-    			    $error = self::update_from_21();
1974
-    			    if ($error != '') return $error;
1975
-    			    else return self::check_version(true);
1976
-    			} elseif ($result['value'] == '22') {
1977
-    			    $error = self::update_from_22();
1978
-    			    if ($error != '') return $error;
1979
-    			    else return self::check_version(true);
1980
-    			} elseif ($result['value'] == '23') {
1981
-    			    $error = self::update_from_23();
1982
-    			    if ($error != '') return $error;
1983
-    			    else return self::check_version(true);
1984
-    			} elseif ($result['value'] == '24') {
1985
-    			    $error = self::update_from_24();
1986
-    			    if ($error != '') return $error;
1987
-    			    else return self::check_version(true);
1988
-    			} elseif ($result['value'] == '25') {
1989
-    			    $error = self::update_from_25();
1990
-    			    if ($error != '') return $error;
1991
-    			    else return self::check_version(true);
1992
-    			} elseif ($result['value'] == '26') {
1993
-    			    $error = self::update_from_26();
1994
-    			    if ($error != '') return $error;
1995
-    			    else return self::check_version(true);
1996
-    			} elseif ($result['value'] == '27') {
1997
-    			    $error = self::update_from_27();
1998
-    			    if ($error != '') return $error;
1999
-    			    else return self::check_version(true);
2000
-    			} elseif ($result['value'] == '28') {
2001
-    			    $error = self::update_from_28();
2002
-    			    if ($error != '') return $error;
2003
-    			    else return self::check_version(true);
2004
-    			} elseif ($result['value'] == '29') {
2005
-    			    $error = self::update_from_29();
2006
-    			    if ($error != '') return $error;
2007
-    			    else return self::check_version(true);
2008
-    			} elseif ($result['value'] == '30') {
2009
-    			    $error = self::update_from_30();
2010
-    			    if ($error != '') return $error;
2011
-    			    else return self::check_version(true);
2012
-    			} elseif ($result['value'] == '31') {
2013
-    			    $error = self::update_from_31();
2014
-    			    if ($error != '') return $error;
2015
-    			    else return self::check_version(true);
2016
-    			} elseif ($result['value'] == '32') {
2017
-    			    $error = self::update_from_32();
2018
-    			    if ($error != '') return $error;
2019
-    			    else return self::check_version(true);
2020
-    			} elseif ($result['value'] == '33') {
2021
-    			    $error = self::update_from_33();
2022
-    			    if ($error != '') return $error;
2023
-    			    else return self::check_version(true);
2024
-    			} elseif ($result['value'] == '34') {
2025
-    			    $error = self::update_from_34();
2026
-    			    if ($error != '') return $error;
2027
-    			    else return self::check_version(true);
2028
-    			} elseif ($result['value'] == '35') {
2029
-    			    $error = self::update_from_35();
2030
-    			    if ($error != '') return $error;
2031
-    			    else return self::check_version(true);
2032
-    			} elseif ($result['value'] == '36') {
2033
-    			    $error = self::update_from_36();
2034
-    			    if ($error != '') return $error;
2035
-    			    else return self::check_version(true);
2036
-    			} elseif ($result['value'] == '37') {
2037
-    			    $error = self::update_from_37();
2038
-    			    if ($error != '') return $error;
2039
-    			    else return self::check_version(true);
2040
-    			} elseif ($result['value'] == '38') {
2041
-    			    $error = self::update_from_38();
2042
-    			    if ($error != '') return $error;
2043
-    			    else return self::check_version(true);
2044
-    			} else return '';
2045
-    		    }
2046
-    		    else return $result['value'];
1893
+				}
1894
+				$result = $sth->fetch(PDO::FETCH_ASSOC);
1895
+				if ($update) {
1896
+				if ($result['value'] == '2') {
1897
+					$error = self::update_from_2();
1898
+					if ($error != '') return $error;
1899
+					else return self::check_version(true);
1900
+				} elseif ($result['value'] == '3') {
1901
+					$error = self::update_from_3();
1902
+					if ($error != '') return $error;
1903
+					else return self::check_version(true);
1904
+				} elseif ($result['value'] == '4') {
1905
+					$error = self::update_from_4();
1906
+					if ($error != '') return $error;
1907
+					else return self::check_version(true);
1908
+				} elseif ($result['value'] == '5') {
1909
+					$error = self::update_from_5();
1910
+					if ($error != '') return $error;
1911
+					else return self::check_version(true);
1912
+				} elseif ($result['value'] == '6') {
1913
+					$error = self::update_from_6();
1914
+					if ($error != '') return $error;
1915
+					else return self::check_version(true);
1916
+				} elseif ($result['value'] == '7') {
1917
+					$error = self::update_from_7();
1918
+					if ($error != '') return $error;
1919
+					else return self::check_version(true);
1920
+				} elseif ($result['value'] == '8') {
1921
+					$error = self::update_from_8();
1922
+					if ($error != '') return $error;
1923
+					else return self::check_version(true);
1924
+				} elseif ($result['value'] == '9') {
1925
+					$error = self::update_from_9();
1926
+					if ($error != '') return $error;
1927
+					else return self::check_version(true);
1928
+				} elseif ($result['value'] == '10') {
1929
+					$error = self::update_from_10();
1930
+					if ($error != '') return $error;
1931
+					else return self::check_version(true);
1932
+				} elseif ($result['value'] == '11') {
1933
+					$error = self::update_from_11();
1934
+					if ($error != '') return $error;
1935
+					else return self::check_version(true);
1936
+				} elseif ($result['value'] == '12') {
1937
+					$error = self::update_from_12();
1938
+					if ($error != '') return $error;
1939
+					else return self::check_version(true);
1940
+				} elseif ($result['value'] == '13') {
1941
+					$error = self::update_from_13();
1942
+					if ($error != '') return $error;
1943
+					else return self::check_version(true);
1944
+				} elseif ($result['value'] == '14') {
1945
+					$error = self::update_from_14();
1946
+					if ($error != '') return $error;
1947
+					else return self::check_version(true);
1948
+				} elseif ($result['value'] == '15') {
1949
+					$error = self::update_from_15();
1950
+					if ($error != '') return $error;
1951
+					else return self::check_version(true);
1952
+				} elseif ($result['value'] == '16') {
1953
+					$error = self::update_from_16();
1954
+					if ($error != '') return $error;
1955
+					else return self::check_version(true);
1956
+				} elseif ($result['value'] == '17') {
1957
+					$error = self::update_from_17();
1958
+					if ($error != '') return $error;
1959
+					else return self::check_version(true);
1960
+				} elseif ($result['value'] == '18') {
1961
+					$error = self::update_from_18();
1962
+					if ($error != '') return $error;
1963
+					else return self::check_version(true);
1964
+				} elseif ($result['value'] == '19') {
1965
+					$error = self::update_from_19();
1966
+					if ($error != '') return $error;
1967
+					else return self::check_version(true);
1968
+				} elseif ($result['value'] == '20') {
1969
+					$error = self::update_from_20();
1970
+					if ($error != '') return $error;
1971
+					else return self::check_version(true);
1972
+				} elseif ($result['value'] == '21') {
1973
+					$error = self::update_from_21();
1974
+					if ($error != '') return $error;
1975
+					else return self::check_version(true);
1976
+				} elseif ($result['value'] == '22') {
1977
+					$error = self::update_from_22();
1978
+					if ($error != '') return $error;
1979
+					else return self::check_version(true);
1980
+				} elseif ($result['value'] == '23') {
1981
+					$error = self::update_from_23();
1982
+					if ($error != '') return $error;
1983
+					else return self::check_version(true);
1984
+				} elseif ($result['value'] == '24') {
1985
+					$error = self::update_from_24();
1986
+					if ($error != '') return $error;
1987
+					else return self::check_version(true);
1988
+				} elseif ($result['value'] == '25') {
1989
+					$error = self::update_from_25();
1990
+					if ($error != '') return $error;
1991
+					else return self::check_version(true);
1992
+				} elseif ($result['value'] == '26') {
1993
+					$error = self::update_from_26();
1994
+					if ($error != '') return $error;
1995
+					else return self::check_version(true);
1996
+				} elseif ($result['value'] == '27') {
1997
+					$error = self::update_from_27();
1998
+					if ($error != '') return $error;
1999
+					else return self::check_version(true);
2000
+				} elseif ($result['value'] == '28') {
2001
+					$error = self::update_from_28();
2002
+					if ($error != '') return $error;
2003
+					else return self::check_version(true);
2004
+				} elseif ($result['value'] == '29') {
2005
+					$error = self::update_from_29();
2006
+					if ($error != '') return $error;
2007
+					else return self::check_version(true);
2008
+				} elseif ($result['value'] == '30') {
2009
+					$error = self::update_from_30();
2010
+					if ($error != '') return $error;
2011
+					else return self::check_version(true);
2012
+				} elseif ($result['value'] == '31') {
2013
+					$error = self::update_from_31();
2014
+					if ($error != '') return $error;
2015
+					else return self::check_version(true);
2016
+				} elseif ($result['value'] == '32') {
2017
+					$error = self::update_from_32();
2018
+					if ($error != '') return $error;
2019
+					else return self::check_version(true);
2020
+				} elseif ($result['value'] == '33') {
2021
+					$error = self::update_from_33();
2022
+					if ($error != '') return $error;
2023
+					else return self::check_version(true);
2024
+				} elseif ($result['value'] == '34') {
2025
+					$error = self::update_from_34();
2026
+					if ($error != '') return $error;
2027
+					else return self::check_version(true);
2028
+				} elseif ($result['value'] == '35') {
2029
+					$error = self::update_from_35();
2030
+					if ($error != '') return $error;
2031
+					else return self::check_version(true);
2032
+				} elseif ($result['value'] == '36') {
2033
+					$error = self::update_from_36();
2034
+					if ($error != '') return $error;
2035
+					else return self::check_version(true);
2036
+				} elseif ($result['value'] == '37') {
2037
+					$error = self::update_from_37();
2038
+					if ($error != '') return $error;
2039
+					else return self::check_version(true);
2040
+				} elseif ($result['value'] == '38') {
2041
+					$error = self::update_from_38();
2042
+					if ($error != '') return $error;
2043
+					else return self::check_version(true);
2044
+				} else return '';
2045
+				}
2046
+				else return $result['value'];
2047 2047
 		}
2048 2048
 		
2049
-	    } else return $version;
2050
-    	}
2049
+		} else return $version;
2050
+		}
2051 2051
     	
2052 2052
 }
2053 2053
 //echo update_schema::check_version();
Please login to merge, or discard this patch.
require/class.Connection.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -7,35 +7,35 @@  discard block
 block discarded – undo
7 7
 	public $latest_schema = 39;
8 8
 	
9 9
 	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
10
-	    global $globalDBdriver, $globalNoDB;
11
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
10
+		global $globalDBdriver, $globalNoDB;
11
+		if (isset($globalNoDB) && $globalNoDB === TRUE) {
12 12
 		$this->db = null;
13
-	    } else {
13
+		} else {
14 14
 		if ($dbc === null) {
15
-		    if ($this->db === null && $dbname === null) {
15
+			if ($this->db === null && $dbname === null) {
16 16
 			if ($user === null && $pass === null) {
17
-			    $this->createDBConnection();
17
+				$this->createDBConnection();
18 18
 			} else {
19
-			    $this->createDBConnection(null,$user,$pass);
19
+				$this->createDBConnection(null,$user,$pass);
20 20
 			}
21
-		    } else {
21
+			} else {
22 22
 			$this->createDBConnection($dbname);
23
-		    }
23
+			}
24 24
 		} elseif ($dbname === null || $dbname === 'default') {
25
-	    	    $this->db = $dbc;
26
-	    	    if ($this->connectionExists() === false) {
25
+				$this->db = $dbc;
26
+				if ($this->connectionExists() === false) {
27 27
 			/*
28 28
 			echo 'Restart Connection !!!'."\n";
29 29
 			$e = new \Exception;
30 30
 			var_dump($e->getTraceAsString());
31 31
 			*/
32 32
 			$this->createDBConnection();
33
-		    }
33
+			}
34 34
 		} else {
35
-		    //$this->connectionExists();
36
-		    $this->dbs[$dbname] = $dbc;
35
+			//$this->connectionExists();
36
+			$this->dbs[$dbname] = $dbc;
37
+		}
37 38
 		}
38
-	    }
39 39
 	}
40 40
 
41 41
 	public function db() {
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 	}
57 57
 
58 58
 	/**
59
-	* Creates the database connection
60
-	*
61
-	* @return Boolean of the database connection
62
-	*
63
-	*/
59
+	 * Creates the database connection
60
+	 *
61
+	 * @return Boolean of the database connection
62
+	 *
63
+	 */
64 64
 
65 65
 	public function createDBConnection($DBname = null, $user = null, $pass = null)
66 66
 	{
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 			return false;
158 158
 		}
159 159
 		if($results->rowCount()>0) {
160
-		    return true; 
160
+			return true; 
161 161
 		}
162 162
 		else return false;
163 163
 	}
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 				$sum = $sum->fetchColumn(0);
175 175
 			} else $sum = 0;
176 176
 			if (intval($sum) !== 2) {
177
-			     return false;
177
+				 return false;
178 178
 			}
179 179
 			
180 180
 		} catch(PDOException $e) {
181 181
 			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
182
-            			throw $e;
183
-	                }
184
-	                //echo 'error ! '.$e->getMessage();
182
+						throw $e;
183
+					}
184
+					//echo 'error ! '.$e->getMessage();
185 185
 			return false;
186 186
 		}
187 187
 		return true; 
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 		$version = 0;
286 286
 		if ($this->tableExists('aircraft')) {
287 287
 			if (!$this->tableExists('config')) {
288
-	    			$version = '1';
289
-	    			return $version;
288
+					$version = '1';
289
+					return $version;
290 290
 			} else {
291 291
 				$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
292 292
 				try {
@@ -307,10 +307,10 @@  discard block
 block discarded – undo
307 307
 	* @return Boolean if latest version or not
308 308
 	*/
309 309
 	public function latest() {
310
-	    global $globalNoDB;
311
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
312
-	    if ($this->check_schema_version() == $this->latest_schema) return true;
313
-	    else return false;
310
+		global $globalNoDB;
311
+		if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
312
+		if ($this->check_schema_version() == $this->latest_schema) return true;
313
+		else return false;
314 314
 	}
315 315
 
316 316
 }
Please login to merge, or discard this patch.