Completed
Push — master ( 8afa3e...55595d )
by Yannick
06:58
created
require/class.SpotterArchive.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
     /**
12 12
     * Get SQL query part for filter used
13 13
     * @param Array $filter the filter
14
-    * @return Array the SQL part
14
+    * @return string the SQL part
15 15
     */
16 16
     public function getFilter($filter = array(),$where = false,$and = false) {
17 17
 	global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
Please login to merge, or discard this patch.
Indentation   +645 added lines, -645 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
 		$this->db = $Connection->db;
9 9
 	}
10 10
 
11
-    /**
12
-    * Get SQL query part for filter used
13
-    * @param Array $filter the filter
14
-    * @return Array the SQL part
15
-    */
16
-    public function getFilter($filter = array(),$where = false,$and = false) {
11
+	/**
12
+	 * Get SQL query part for filter used
13
+	 * @param Array $filter the filter
14
+	 * @return Array the SQL part
15
+	 */
16
+	public function getFilter($filter = array(),$where = false,$and = false) {
17 17
 	global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 	$filters = array();
19 19
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
@@ -27,74 +27,74 @@  discard block
 block discarded – undo
27 27
 	$filter_query_join = '';
28 28
 	$filter_query_where = '';
29 29
 	foreach($filters as $flt) {
30
-	    if (isset($flt['airlines']) && !empty($flt['airlines'])) {
30
+		if (isset($flt['airlines']) && !empty($flt['airlines'])) {
31 31
 		if ($flt['airlines'][0] != '') {
32
-		    if (isset($flt['source'])) {
32
+			if (isset($flt['source'])) {
33 33
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
34
-		    } else {
34
+			} else {
35 35
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
36
-		    }
36
+			}
37
+		}
37 38
 		}
38
-	    }
39
-	    if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
39
+		if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
40 40
 		if (isset($flt['source'])) {
41
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
41
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
42 42
 		} else {
43
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
43
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
44 44
 		}
45
-	    }
46
-	    if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) {
45
+		}
46
+		if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) {
47 47
 		if (isset($flt['source'])) {
48
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
48
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
49
+		}
49 50
 		}
50
-	    }
51 51
 	}
52 52
 	if (isset($filter['airlines']) && !empty($filter['airlines'])) {
53
-	    if ($filter['airlines'][0] != '') {
53
+		if ($filter['airlines'][0] != '') {
54 54
 		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
55
-	    }
55
+		}
56 56
 	}
57 57
 	
58 58
 	if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
59
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
59
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
60 60
 	}
61 61
 	if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
62
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
62
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
63 63
 	}
64 64
 	if (isset($filter['source']) && !empty($filter['source'])) {
65
-	    $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
65
+		$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
66 66
 	}
67 67
 	if (isset($filter['ident']) && !empty($filter['ident'])) {
68
-	    $filter_query_where .= " AND ident = '".$filter['ident']."'";
68
+		$filter_query_where .= " AND ident = '".$filter['ident']."'";
69 69
 	}
70 70
 	if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
71 71
 		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
72 72
 	}
73 73
 	if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) {
74
-	    $filter_query_date = '';
74
+		$filter_query_date = '';
75 75
 	    
76
-	    if (isset($filter['year']) && $filter['year'] != '') {
76
+		if (isset($filter['year']) && $filter['year'] != '') {
77 77
 		if ($globalDBdriver == 'mysql') {
78
-		    $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'";
78
+			$filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'";
79 79
 		} else {
80
-		    $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'";
80
+			$filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'";
81 81
 		}
82
-	    }
83
-	    if (isset($filter['month']) && $filter['month'] != '') {
82
+		}
83
+		if (isset($filter['month']) && $filter['month'] != '') {
84 84
 		if ($globalDBdriver == 'mysql') {
85
-		    $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'";
85
+			$filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'";
86 86
 		} else {
87
-		    $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'";
87
+			$filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'";
88
+		}
88 89
 		}
89
-	    }
90
-	    if (isset($filter['day']) && $filter['day'] != '') {
90
+		if (isset($filter['day']) && $filter['day'] != '') {
91 91
 		if ($globalDBdriver == 'mysql') {
92
-		    $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'";
92
+			$filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'";
93 93
 		} else {
94
-		    $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
94
+			$filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
95
+		}
95 96
 		}
96
-	    }
97
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
97
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
98 98
 	}
99 99
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
100 100
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	}
104 104
 	$filter_query = $filter_query_join.$filter_query_where;
105 105
 	return $filter_query;
106
-    }
106
+	}
107 107
 
108 108
 	// Spotter_archive
109 109
 	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
@@ -134,44 +134,44 @@  discard block
 block discarded – undo
134 134
 	}
135 135
 
136 136
 
137
-        /**
138
-        * Gets all the spotter information based on a particular callsign
139
-        *
140
-        * @return Array the spotter information
141
-        *
142
-        */
143
-        public function getLastArchiveSpotterDataByIdent($ident)
144
-        {
137
+		/**
138
+		 * Gets all the spotter information based on a particular callsign
139
+		 *
140
+		 * @return Array the spotter information
141
+		 *
142
+		 */
143
+		public function getLastArchiveSpotterDataByIdent($ident)
144
+		{
145 145
 		$Spotter = new Spotter($this->db);
146
-                date_default_timezone_set('UTC');
146
+				date_default_timezone_set('UTC');
147 147
 
148
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
149
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
150
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
148
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
149
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
150
+				$query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
151 151
 
152
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
152
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
153 153
 
154
-                return $spotter_array;
155
-        }
154
+				return $spotter_array;
155
+		}
156 156
 
157 157
 
158
-        /**
159
-        * Gets last the spotter information based on a particular id
160
-        *
161
-        * @return Array the spotter information
162
-        *
163
-        */
164
-        public function getLastArchiveSpotterDataById($id)
165
-        {
166
-    		$Spotter = new Spotter($this->db);
167
-                date_default_timezone_set('UTC');
168
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
169
-                //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
170
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
171
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
158
+		/**
159
+		 * Gets last the spotter information based on a particular id
160
+		 *
161
+		 * @return Array the spotter information
162
+		 *
163
+		 */
164
+		public function getLastArchiveSpotterDataById($id)
165
+		{
166
+			$Spotter = new Spotter($this->db);
167
+				date_default_timezone_set('UTC');
168
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
169
+				//$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
170
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
171
+				$query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
172 172
 
173 173
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
174
-                  /*
174
+				  /*
175 175
                 try {
176 176
                         $Connection = new Connection();
177 177
                         $sth = Connection->$db->prepare($query);
@@ -181,232 +181,232 @@  discard block
 block discarded – undo
181 181
                 }
182 182
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
183 183
                 */
184
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
185
-
186
-                return $spotter_array;
187
-        }
188
-
189
-        /**
190
-        * Gets all the spotter information based on a particular id
191
-        *
192
-        * @return Array the spotter information
193
-        *
194
-        */
195
-        public function getAllArchiveSpotterDataById($id)
196
-        {
197
-                date_default_timezone_set('UTC');
198
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
199
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
184
+				$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
185
+
186
+				return $spotter_array;
187
+		}
188
+
189
+		/**
190
+		 * Gets all the spotter information based on a particular id
191
+		 *
192
+		 * @return Array the spotter information
193
+		 *
194
+		 */
195
+		public function getAllArchiveSpotterDataById($id)
196
+		{
197
+				date_default_timezone_set('UTC');
198
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
199
+				$query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
200 200
 
201 201
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
202 202
 
203
-                try {
204
-                        $sth = $this->db->prepare($query);
205
-                        $sth->execute(array(':id' => $id));
206
-                } catch(PDOException $e) {
207
-                        echo $e->getMessage();
208
-                        die;
209
-                }
210
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
211
-
212
-                return $spotter_array;
213
-        }
214
-
215
-        /**
216
-        * Gets coordinate & time spotter information based on a particular id
217
-        *
218
-        * @return Array the spotter information
219
-        *
220
-        */
221
-        public function getCoordArchiveSpotterDataById($id)
222
-        {
223
-                date_default_timezone_set('UTC');
224
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
225
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
203
+				try {
204
+						$sth = $this->db->prepare($query);
205
+						$sth->execute(array(':id' => $id));
206
+				} catch(PDOException $e) {
207
+						echo $e->getMessage();
208
+						die;
209
+				}
210
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
211
+
212
+				return $spotter_array;
213
+		}
214
+
215
+		/**
216
+		 * Gets coordinate & time spotter information based on a particular id
217
+		 *
218
+		 * @return Array the spotter information
219
+		 *
220
+		 */
221
+		public function getCoordArchiveSpotterDataById($id)
222
+		{
223
+				date_default_timezone_set('UTC');
224
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
225
+				$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
226 226
 
227 227
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
228 228
 
229
-                try {
230
-                        $sth = $this->db->prepare($query);
231
-                        $sth->execute(array(':id' => $id));
232
-                } catch(PDOException $e) {
233
-                        echo $e->getMessage();
234
-                        die;
235
-                }
236
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
229
+				try {
230
+						$sth = $this->db->prepare($query);
231
+						$sth->execute(array(':id' => $id));
232
+				} catch(PDOException $e) {
233
+						echo $e->getMessage();
234
+						die;
235
+				}
236
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
237 237
 
238
-                return $spotter_array;
239
-        }
238
+				return $spotter_array;
239
+		}
240 240
 
241 241
 
242
-        /**
243
-        * Gets altitude information based on a particular callsign
244
-        *
245
-        * @return Array the spotter information
246
-        *
247
-        */
248
-        public function getAltitudeArchiveSpotterDataByIdent($ident)
249
-        {
242
+		/**
243
+		 * Gets altitude information based on a particular callsign
244
+		 *
245
+		 * @return Array the spotter information
246
+		 *
247
+		 */
248
+		public function getAltitudeArchiveSpotterDataByIdent($ident)
249
+		{
250 250
 
251
-                date_default_timezone_set('UTC');
251
+				date_default_timezone_set('UTC');
252 252
 
253
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
254
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
253
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
254
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
255 255
 
256
-                try {
257
-                        $sth = $this->db->prepare($query);
258
-                        $sth->execute(array(':ident' => $ident));
259
-                } catch(PDOException $e) {
260
-                        echo $e->getMessage();
261
-                        die;
262
-                }
263
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
256
+				try {
257
+						$sth = $this->db->prepare($query);
258
+						$sth->execute(array(':ident' => $ident));
259
+				} catch(PDOException $e) {
260
+						echo $e->getMessage();
261
+						die;
262
+				}
263
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
264 264
 
265
-                return $spotter_array;
266
-        }
265
+				return $spotter_array;
266
+		}
267 267
 
268
-        /**
269
-        * Gets altitude information based on a particular id
270
-        *
271
-        * @return Array the spotter information
272
-        *
273
-        */
274
-        public function getAltitudeArchiveSpotterDataById($id)
275
-        {
268
+		/**
269
+		 * Gets altitude information based on a particular id
270
+		 *
271
+		 * @return Array the spotter information
272
+		 *
273
+		 */
274
+		public function getAltitudeArchiveSpotterDataById($id)
275
+		{
276 276
 
277
-                date_default_timezone_set('UTC');
277
+				date_default_timezone_set('UTC');
278 278
 
279
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
280
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
279
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
280
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
281 281
 
282
-                try {
283
-                        $sth = $this->db->prepare($query);
284
-                        $sth->execute(array(':id' => $id));
285
-                } catch(PDOException $e) {
286
-                        echo $e->getMessage();
287
-                        die;
288
-                }
289
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
282
+				try {
283
+						$sth = $this->db->prepare($query);
284
+						$sth->execute(array(':id' => $id));
285
+				} catch(PDOException $e) {
286
+						echo $e->getMessage();
287
+						die;
288
+				}
289
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
290 290
 
291
-                return $spotter_array;
292
-        }
291
+				return $spotter_array;
292
+		}
293 293
 
294
-        /**
295
-        * Gets altitude & speed information based on a particular id
296
-        *
297
-        * @return Array the spotter information
298
-        *
299
-        */
300
-        public function getAltitudeSpeedArchiveSpotterDataById($id)
301
-        {
294
+		/**
295
+		 * Gets altitude & speed information based on a particular id
296
+		 *
297
+		 * @return Array the spotter information
298
+		 *
299
+		 */
300
+		public function getAltitudeSpeedArchiveSpotterDataById($id)
301
+		{
302 302
 
303
-                date_default_timezone_set('UTC');
303
+				date_default_timezone_set('UTC');
304 304
 
305
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
306
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
305
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
306
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
307 307
 
308
-                try {
309
-                        $sth = $this->db->prepare($query);
310
-                        $sth->execute(array(':id' => $id));
311
-                } catch(PDOException $e) {
312
-                        echo $e->getMessage();
313
-                        die;
314
-                }
315
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
308
+				try {
309
+						$sth = $this->db->prepare($query);
310
+						$sth->execute(array(':id' => $id));
311
+				} catch(PDOException $e) {
312
+						echo $e->getMessage();
313
+						die;
314
+				}
315
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
316 316
 
317
-                return $spotter_array;
318
-        }
317
+				return $spotter_array;
318
+		}
319 319
 
320 320
 
321
-        /**
322
-        * Gets altitude information based on a particular callsign
323
-        *
324
-        * @return Array the spotter information
325
-        *
326
-        */
327
-        public function getLastAltitudeArchiveSpotterDataByIdent($ident)
328
-        {
321
+		/**
322
+		 * Gets altitude information based on a particular callsign
323
+		 *
324
+		 * @return Array the spotter information
325
+		 *
326
+		 */
327
+		public function getLastAltitudeArchiveSpotterDataByIdent($ident)
328
+		{
329 329
 
330
-                date_default_timezone_set('UTC');
330
+				date_default_timezone_set('UTC');
331 331
 
332
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
333
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
332
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
333
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
334 334
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
335 335
 
336
-                try {
337
-                        $sth = $this->db->prepare($query);
338
-                        $sth->execute(array(':ident' => $ident));
339
-                } catch(PDOException $e) {
340
-                        echo $e->getMessage();
341
-                        die;
342
-                }
343
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
336
+				try {
337
+						$sth = $this->db->prepare($query);
338
+						$sth->execute(array(':ident' => $ident));
339
+				} catch(PDOException $e) {
340
+						echo $e->getMessage();
341
+						die;
342
+				}
343
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
344 344
 
345
-                return $spotter_array;
346
-        }
345
+				return $spotter_array;
346
+		}
347 347
 
348 348
 
349 349
 
350
-       /**
351
-        * Gets all the archive spotter information
352
-        *
353
-        * @return Array the spotter information
354
-        *
355
-        */
356
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
357
-        {
358
-    		$Spotter = new Spotter($this->db);
359
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
360
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
350
+	   /**
351
+	    * Gets all the archive spotter information
352
+	    *
353
+	    * @return Array the spotter information
354
+	    *
355
+	    */
356
+		public function getSpotterArchiveData($ident,$flightaware_id,$date)
357
+		{
358
+			$Spotter = new Spotter($this->db);
359
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
360
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
361 361
 
362
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
362
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
363 363
 
364
-                return $spotter_array;
365
-        }
364
+				return $spotter_array;
365
+		}
366 366
         
367
-        public function deleteSpotterArchiveTrackData()
368
-        {
367
+		public function deleteSpotterArchiveTrackData()
368
+		{
369 369
 		global $globalArchiveKeepTrackMonths;
370
-                date_default_timezone_set('UTC');
370
+				date_default_timezone_set('UTC');
371 371
 		$query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
372
-                try {
373
-                        $sth = $this->db->prepare($query);
374
-                        $sth->execute();
375
-                } catch(PDOException $e) {
376
-                        echo $e->getMessage();
377
-                        die;
378
-                }
372
+				try {
373
+						$sth = $this->db->prepare($query);
374
+						$sth->execute();
375
+				} catch(PDOException $e) {
376
+						echo $e->getMessage();
377
+						die;
378
+				}
379 379
 	}
380 380
 
381 381
 	/**
382
-        * Gets Minimal Live Spotter data
383
-        *
384
-        * @return Array the spotter information
385
-        *
386
-        */
387
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
388
-        {
389
-                global $globalDBdriver, $globalLiveInterval;
390
-                date_default_timezone_set('UTC');
391
-
392
-                $filter_query = '';
393
-                if (isset($filter['source']) && !empty($filter['source'])) {
394
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
395
-                }
396
-                // Use spotter_output also ?
397
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
398
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
399
-                }
400
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
401
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
402
-                }
403
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
404
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
405
-                }
406
-
407
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
408
-                if ($globalDBdriver == 'mysql') {
409
-                        /*
382
+	 * Gets Minimal Live Spotter data
383
+	 *
384
+	 * @return Array the spotter information
385
+	 *
386
+	 */
387
+		public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
388
+		{
389
+				global $globalDBdriver, $globalLiveInterval;
390
+				date_default_timezone_set('UTC');
391
+
392
+				$filter_query = '';
393
+				if (isset($filter['source']) && !empty($filter['source'])) {
394
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
395
+				}
396
+				// Use spotter_output also ?
397
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
398
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
399
+				}
400
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
401
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
402
+				}
403
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
404
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
405
+				}
406
+
407
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
408
+				if ($globalDBdriver == 'mysql') {
409
+						/*
410 410
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
411 411
                     		    FROM spotter_archive 
412 412
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -425,56 +425,56 @@  discard block
 block discarded – undo
425 425
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
426 426
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
427 427
                         	    '.$filter_query.' ORDER BY flightaware_id';
428
-                } else {
429
-                        //$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
430
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
428
+				} else {
429
+						//$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
430
+						$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
431 431
                         	    FROM spotter_archive 
432 432
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
433 433
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
434 434
                         	    '.$filter_query.' ORDER BY flightaware_id';
435
-                }
436
-                //echo $query;
437
-                try {
438
-                        $sth = $this->db->prepare($query);
439
-                        $sth->execute();
440
-                } catch(PDOException $e) {
441
-                        echo $e->getMessage();
442
-                        die;
443
-                }
444
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
445
-
446
-                return $spotter_array;
447
-        }
435
+				}
436
+				//echo $query;
437
+				try {
438
+						$sth = $this->db->prepare($query);
439
+						$sth->execute();
440
+				} catch(PDOException $e) {
441
+						echo $e->getMessage();
442
+						die;
443
+				}
444
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
445
+
446
+				return $spotter_array;
447
+		}
448 448
 
449 449
 	/**
450
-        * Gets Minimal Live Spotter data
451
-        *
452
-        * @return Array the spotter information
453
-        *
454
-        */
455
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
456
-        {
457
-                global $globalDBdriver, $globalLiveInterval;
458
-                date_default_timezone_set('UTC');
459
-
460
-                $filter_query = '';
461
-                if (isset($filter['source']) && !empty($filter['source'])) {
462
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
463
-                }
464
-                // Should use spotter_output also ?
465
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
466
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
467
-                }
468
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
469
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
470
-                }
471
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
472
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
473
-                }
474
-
475
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
476
-                if ($globalDBdriver == 'mysql') {
477
-                        /*
450
+	 * Gets Minimal Live Spotter data
451
+	 *
452
+	 * @return Array the spotter information
453
+	 *
454
+	 */
455
+		public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
456
+		{
457
+				global $globalDBdriver, $globalLiveInterval;
458
+				date_default_timezone_set('UTC');
459
+
460
+				$filter_query = '';
461
+				if (isset($filter['source']) && !empty($filter['source'])) {
462
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
463
+				}
464
+				// Should use spotter_output also ?
465
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
466
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
467
+				}
468
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
469
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
470
+				}
471
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
472
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
473
+				}
474
+
475
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
476
+				if ($globalDBdriver == 'mysql') {
477
+						/*
478 478
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
479 479
                     		    FROM spotter_archive 
480 480
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -485,95 +485,95 @@  discard block
 block discarded – undo
485 485
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
486 486
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
487 487
 
488
-                } else {
489
-                        //$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
490
-                       /*
488
+				} else {
489
+						//$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
490
+					   /*
491 491
                         $query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
492 492
                         	    FROM spotter_archive_output 
493 493
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
494 494
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
495 495
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
496 496
                         */
497
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
497
+						$query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
498 498
                         	    FROM spotter_archive_output 
499 499
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
500 500
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
501 501
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
502 502
 //                        	    .' GROUP BY spotter_output.flightaware_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';
503 503
                         	    
504
-                }
505
-                //echo $query;
506
-                try {
507
-                        $sth = $this->db->prepare($query);
508
-                        $sth->execute();
509
-                } catch(PDOException $e) {
510
-                        echo $e->getMessage();
511
-                        die;
512
-                }
513
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
514
-
515
-                return $spotter_array;
516
-        }
504
+				}
505
+				//echo $query;
506
+				try {
507
+						$sth = $this->db->prepare($query);
508
+						$sth->execute();
509
+				} catch(PDOException $e) {
510
+						echo $e->getMessage();
511
+						die;
512
+				}
513
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
514
+
515
+				return $spotter_array;
516
+		}
517 517
 
518 518
 	 /**
519
-        * Gets count Live Spotter data
520
-        *
521
-        * @return Array the spotter information
522
-        *
523
-        */
524
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
525
-        {
526
-                global $globalDBdriver, $globalLiveInterval;
527
-                date_default_timezone_set('UTC');
528
-
529
-                $filter_query = '';
530
-                if (isset($filter['source']) && !empty($filter['source'])) {
531
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
532
-                }
533
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
534
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
535
-                }
536
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
537
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
538
-                }
539
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
540
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
541
-                }
542
-
543
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
544
-                if ($globalDBdriver == 'mysql') {
519
+	  * Gets count Live Spotter data
520
+	  *
521
+	  * @return Array the spotter information
522
+	  *
523
+	  */
524
+		public function getLiveSpotterCount($begindate,$enddate,$filter = array())
525
+		{
526
+				global $globalDBdriver, $globalLiveInterval;
527
+				date_default_timezone_set('UTC');
528
+
529
+				$filter_query = '';
530
+				if (isset($filter['source']) && !empty($filter['source'])) {
531
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
532
+				}
533
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
534
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
535
+				}
536
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
537
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
538
+				}
539
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
540
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
541
+				}
542
+
543
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
544
+				if ($globalDBdriver == 'mysql') {
545 545
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb 
546 546
 			FROM spotter_archive l 
547 547
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
548
-                } else {
548
+				} else {
549 549
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
550
-                }
551
-                //echo $query;
552
-                try {
553
-                        $sth = $this->db->prepare($query);
554
-                        $sth->execute();
555
-                } catch(PDOException $e) {
556
-                        echo $e->getMessage();
557
-                        die;
558
-                }
550
+				}
551
+				//echo $query;
552
+				try {
553
+						$sth = $this->db->prepare($query);
554
+						$sth->execute();
555
+				} catch(PDOException $e) {
556
+						echo $e->getMessage();
557
+						die;
558
+				}
559 559
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
560 560
 		$sth->closeCursor();
561
-                return $result['nb'];
561
+				return $result['nb'];
562 562
 
563
-        }
563
+		}
564 564
 
565 565
 
566 566
 
567 567
 	// Spotter_Archive_output
568 568
 	
569
-    /**
570
-    * Gets all the spotter information
571
-    *
572
-    * @return Array the spotter information
573
-    *
574
-    */
575
-    public function searchSpotterData($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())
576
-    {
569
+	/**
570
+	 * Gets all the spotter information
571
+	 *
572
+	 * @return Array the spotter information
573
+	 *
574
+	 */
575
+	public function searchSpotterData($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())
576
+	{
577 577
 	global $globalTimezone, $globalDBdriver;
578 578
 	require_once(dirname(__FILE__).'/class.Translation.php');
579 579
 	$Translation = new Translation();
@@ -587,159 +587,159 @@  discard block
 block discarded – undo
587 587
 	$filter_query = $this->getFilter($filters);
588 588
 	if ($q != "")
589 589
 	{
590
-	    if (!is_string($q))
591
-	    {
590
+		if (!is_string($q))
591
+		{
592 592
 		return false;
593
-	    } else {
593
+		} else {
594 594
 	        
595 595
 		$q_array = explode(" ", $q);
596 596
 		
597 597
 		foreach ($q_array as $q_item){
598
-		    $additional_query .= " AND (";
599
-		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
600
-		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
601
-		    $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
602
-		    $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
603
-		    $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
604
-		    $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
605
-		    $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
606
-		    $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
607
-		    $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
608
-		    $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
609
-		    $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
610
-		    $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
611
-		    $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
612
-		    $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
613
-		    $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
614
-		    $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
615
-		    $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
616
-		    $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
617
-		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
618
-		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
619
-		    $translate = $Translation->ident2icao($q_item);
620
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
621
-		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
622
-		    $additional_query .= ")";
623
-		}
624
-	    }
598
+			$additional_query .= " AND (";
599
+			$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
600
+			$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
601
+			$additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
602
+			$additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
603
+			$additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
604
+			$additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
605
+			$additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
606
+			$additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
607
+			$additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
608
+			$additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
609
+			$additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
610
+			$additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
611
+			$additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
612
+			$additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
613
+			$additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
614
+			$additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
615
+			$additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
616
+			$additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
617
+			$additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
618
+			$additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
619
+			$translate = $Translation->ident2icao($q_item);
620
+			if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
621
+			$additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
622
+			$additional_query .= ")";
623
+		}
624
+		}
625 625
 	}
626 626
 	
627 627
 	if ($registration != "")
628 628
 	{
629
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
630
-	    if (!is_string($registration))
631
-	    {
629
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
630
+		if (!is_string($registration))
631
+		{
632 632
 		return false;
633
-	    } else {
633
+		} else {
634 634
 		$additional_query .= " AND (spotter_archive_output.registration = '".$registration."')";
635
-	    }
635
+		}
636 636
 	}
637 637
 	
638 638
 	if ($aircraft_icao != "")
639 639
 	{
640
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
641
-	    if (!is_string($aircraft_icao))
642
-	    {
640
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
641
+		if (!is_string($aircraft_icao))
642
+		{
643 643
 		return false;
644
-	    } else {
644
+		} else {
645 645
 		$additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')";
646
-	    }
646
+		}
647 647
 	}
648 648
 	
649 649
 	if ($aircraft_manufacturer != "")
650 650
 	{
651
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
652
-	    if (!is_string($aircraft_manufacturer))
653
-	    {
651
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
652
+		if (!is_string($aircraft_manufacturer))
653
+		{
654 654
 		return false;
655
-	    } else {
655
+		} else {
656 656
 		$additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
657
-	    }
657
+		}
658 658
 	}
659 659
 	
660 660
 	if ($highlights == "true")
661 661
 	{
662
-	    if (!is_string($highlights))
663
-	    {
662
+		if (!is_string($highlights))
663
+		{
664 664
 		return false;
665
-	    } else {
665
+		} else {
666 666
 		$additional_query .= " AND (spotter_archive_output.highlight <> '')";
667
-	    }
667
+		}
668 668
 	}
669 669
 	
670 670
 	if ($airline_icao != "")
671 671
 	{
672
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
673
-	    if (!is_string($airline_icao))
674
-	    {
672
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
673
+		if (!is_string($airline_icao))
674
+		{
675 675
 		return false;
676
-	    } else {
676
+		} else {
677 677
 		$additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')";
678
-	    }
678
+		}
679 679
 	}
680 680
 	
681 681
 	if ($airline_country != "")
682 682
 	{
683
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
684
-	    if (!is_string($airline_country))
685
-	    {
683
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
684
+		if (!is_string($airline_country))
685
+		{
686 686
 		return false;
687
-	    } else {
687
+		} else {
688 688
 		$additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')";
689
-	    }
689
+		}
690 690
 	}
691 691
 	
692 692
 	if ($airline_type != "")
693 693
 	{
694
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
695
-	    if (!is_string($airline_type))
696
-	    {
694
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
695
+		if (!is_string($airline_type))
696
+		{
697 697
 		return false;
698
-	    } else {
698
+		} else {
699 699
 		if ($airline_type == "passenger")
700 700
 		{
701
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
701
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
702 702
 		}
703 703
 		if ($airline_type == "cargo")
704 704
 		{
705
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
705
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
706 706
 		}
707 707
 		if ($airline_type == "military")
708 708
 		{
709
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
709
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
710
+		}
710 711
 		}
711
-	    }
712 712
 	}
713 713
 	
714 714
 	if ($airport != "")
715 715
 	{
716
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
717
-	    if (!is_string($airport))
718
-	    {
716
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
717
+		if (!is_string($airport))
718
+		{
719 719
 		return false;
720
-	    } else {
720
+		} else {
721 721
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))";
722
-	    }
722
+		}
723 723
 	}
724 724
 	
725 725
 	if ($airport_country != "")
726 726
 	{
727
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
728
-	    if (!is_string($airport_country))
729
-	    {
727
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
728
+		if (!is_string($airport_country))
729
+		{
730 730
 		return false;
731
-	    } else {
731
+		} else {
732 732
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))";
733
-	    }
733
+		}
734 734
 	}
735 735
     
736 736
 	if ($callsign != "")
737 737
 	{
738
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
739
-	    if (!is_string($callsign))
740
-	    {
738
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
739
+		if (!is_string($callsign))
740
+		{
741 741
 		return false;
742
-	    } else {
742
+		} else {
743 743
 		$translate = $Translation->ident2icao($callsign);
744 744
 		if ($translate != $callsign) {
745 745
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
@@ -747,99 +747,99 @@  discard block
 block discarded – undo
747 747
 		} else {
748 748
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
749 749
 		}
750
-	    }
750
+		}
751 751
 	}
752 752
 
753 753
 	if ($owner != "")
754 754
 	{
755
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
756
-	    if (!is_string($owner))
757
-	    {
755
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
756
+		if (!is_string($owner))
757
+		{
758 758
 		return false;
759
-	    } else {
759
+		} else {
760 760
 		$additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')";
761
-	    }
761
+		}
762 762
 	}
763 763
 
764 764
 	if ($pilot_name != "")
765 765
 	{
766
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
767
-	    if (!is_string($pilot_name))
768
-	    {
766
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
767
+		if (!is_string($pilot_name))
768
+		{
769 769
 		return false;
770
-	    } else {
770
+		} else {
771 771
 		$additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')";
772
-	    }
772
+		}
773 773
 	}
774 774
 	
775 775
 	if ($pilot_id != "")
776 776
 	{
777
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
778
-	    if (!is_string($pilot_id))
779
-	    {
777
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
778
+		if (!is_string($pilot_id))
779
+		{
780 780
 		return false;
781
-	    } else {
781
+		} else {
782 782
 		$additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')";
783
-	    }
783
+		}
784 784
 	}
785 785
 	
786 786
 	if ($departure_airport_route != "")
787 787
 	{
788
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
789
-	    if (!is_string($departure_airport_route))
790
-	    {
788
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
789
+		if (!is_string($departure_airport_route))
790
+		{
791 791
 		return false;
792
-	    } else {
792
+		} else {
793 793
 		$additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')";
794
-	    }
794
+		}
795 795
 	}
796 796
 	
797 797
 	if ($arrival_airport_route != "")
798 798
 	{
799
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
800
-	    if (!is_string($arrival_airport_route))
801
-	    {
799
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
800
+		if (!is_string($arrival_airport_route))
801
+		{
802 802
 		return false;
803
-	    } else {
803
+		} else {
804 804
 		$additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
805
-	    }
805
+		}
806 806
 	}
807 807
 	
808 808
 	if ($altitude != "")
809 809
 	{
810
-	    $altitude_array = explode(",", $altitude);
810
+		$altitude_array = explode(",", $altitude);
811 811
 	    
812
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
813
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
812
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
813
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
814 814
 	    
815 815
 
816
-	    if ($altitude_array[1] != "")
817
-	    {                
816
+		if ($altitude_array[1] != "")
817
+		{                
818 818
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
819 819
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
820 820
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
821
-	    } else {
821
+		} else {
822 822
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
823 823
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
824
-	    }
824
+		}
825 825
 	}
826 826
 	
827 827
 	if ($date_posted != "")
828 828
 	{
829
-	    $date_array = explode(",", $date_posted);
829
+		$date_array = explode(",", $date_posted);
830 830
 	    
831
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
832
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
831
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
832
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
833 833
 	    
834
-	    if ($globalTimezone != '') {
834
+		if ($globalTimezone != '') {
835 835
 		date_default_timezone_set($globalTimezone);
836 836
 		$datetime = new DateTime();
837 837
 		$offset = $datetime->format('P');
838
-	    } else $offset = '+00:00';
838
+		} else $offset = '+00:00';
839 839
 
840 840
 
841
-	    if ($date_array[1] != "")
842
-	    {                
841
+		if ($date_array[1] != "")
842
+		{                
843 843
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
844 844
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
845 845
 		if ($globalDBdriver == 'mysql') {
@@ -847,28 +847,28 @@  discard block
 block discarded – undo
847 847
 		} else {
848 848
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
849 849
 		}
850
-	    } else {
850
+		} else {
851 851
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
852
-                if ($globalDBdriver == 'mysql') {
852
+				if ($globalDBdriver == 'mysql') {
853 853
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
854 854
 		} else {
855 855
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
856 856
 		}
857
-	    }
857
+		}
858 858
 	}
859 859
 	
860 860
 	if ($limit != "")
861 861
 	{
862
-	    $limit_array = explode(",", $limit);
862
+		$limit_array = explode(",", $limit);
863 863
 	    
864
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
865
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
864
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
865
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
866 866
 	    
867
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
868
-	    {
867
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
868
+		{
869 869
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
870 870
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
871
-	    }
871
+		}
872 872
 	}
873 873
 	
874 874
 
@@ -899,33 +899,33 @@  discard block
 block discarded – undo
899 899
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
900 900
 
901 901
 	return $spotter_array;
902
-    }
902
+	}
903 903
 
904
-    public function deleteSpotterArchiveData()
905
-    {
904
+	public function deleteSpotterArchiveData()
905
+	{
906 906
 		global $globalArchiveKeepMonths, $globalDBdriver;
907
-                date_default_timezone_set('UTC');
908
-                if ($globalDBdriver == 'mysql') {
907
+				date_default_timezone_set('UTC');
908
+				if ($globalDBdriver == 'mysql') {
909 909
 			$query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
910 910
 		} else {
911 911
 			$query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
912 912
 		}
913
-                try {
914
-                        $sth = $this->db->prepare($query);
915
-                        $sth->execute();
916
-                } catch(PDOException $e) {
917
-                        return "error";
918
-                }
913
+				try {
914
+						$sth = $this->db->prepare($query);
915
+						$sth->execute();
916
+				} catch(PDOException $e) {
917
+						return "error";
918
+				}
919 919
 	}
920 920
 
921
-    /**
922
-    * Gets all the spotter information based on the callsign
923
-    *
924
-    * @return Array the spotter information
925
-    *
926
-    */
927
-    public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
928
-    {
921
+	/**
922
+	 * Gets all the spotter information based on the callsign
923
+	 *
924
+	 * @return Array the spotter information
925
+	 *
926
+	 */
927
+	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
928
+	{
929 929
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
930 930
 	
931 931
 	date_default_timezone_set('UTC');
@@ -937,35 +937,35 @@  discard block
 block discarded – undo
937 937
 	
938 938
 	if ($ident != "")
939 939
 	{
940
-	    if (!is_string($ident))
941
-	    {
940
+		if (!is_string($ident))
941
+		{
942 942
 		return false;
943
-	    } else {
943
+		} else {
944 944
 		$additional_query = " AND (spotter_archive_output.ident = :ident)";
945 945
 		$query_values = array(':ident' => $ident);
946
-	    }
946
+		}
947 947
 	}
948 948
 	
949 949
 	if ($limit != "")
950 950
 	{
951
-	    $limit_array = explode(",", $limit);
951
+		$limit_array = explode(",", $limit);
952 952
 	    
953
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
954
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
953
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
954
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
955 955
 	    
956
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
957
-	    {
956
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
957
+		{
958 958
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
959 959
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
960
-	    }
960
+		}
961 961
 	}
962 962
 
963 963
 	if ($sort != "")
964 964
 	{
965
-	    $search_orderby_array = $Spotter->getOrderBy();
966
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
965
+		$search_orderby_array = $Spotter->getOrderBy();
966
+		$orderby_query = $search_orderby_array[$sort]['sql'];
967 967
 	} else {
968
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
968
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
969 969
 	}
970 970
 
971 971
 	$query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -973,17 +973,17 @@  discard block
 block discarded – undo
973 973
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
974 974
 
975 975
 	return $spotter_array;
976
-    }
976
+	}
977 977
 
978 978
 
979
-    /**
980
-    * Gets all the spotter information based on the owner
981
-    *
982
-    * @return Array the spotter information
983
-    *
984
-    */
985
-    public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
986
-    {
979
+	/**
980
+	 * Gets all the spotter information based on the owner
981
+	 *
982
+	 * @return Array the spotter information
983
+	 *
984
+	 */
985
+	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
986
+	{
987 987
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
988 988
 	
989 989
 	date_default_timezone_set('UTC');
@@ -996,35 +996,35 @@  discard block
 block discarded – undo
996 996
 	
997 997
 	if ($owner != "")
998 998
 	{
999
-	    if (!is_string($owner))
1000
-	    {
999
+		if (!is_string($owner))
1000
+		{
1001 1001
 		return false;
1002
-	    } else {
1002
+		} else {
1003 1003
 		$additional_query = " AND (spotter_archive_output.owner_name = :owner)";
1004 1004
 		$query_values = array(':owner' => $owner);
1005
-	    }
1005
+		}
1006 1006
 	}
1007 1007
 	
1008 1008
 	if ($limit != "")
1009 1009
 	{
1010
-	    $limit_array = explode(",", $limit);
1010
+		$limit_array = explode(",", $limit);
1011 1011
 	    
1012
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1013
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1012
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1013
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1014 1014
 	    
1015
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1016
-	    {
1015
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1016
+		{
1017 1017
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1018 1018
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1019
-	    }
1019
+		}
1020 1020
 	}
1021 1021
 
1022 1022
 	if ($sort != "")
1023 1023
 	{
1024
-	    $search_orderby_array = $Spotter->getOrderBy();
1025
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1024
+		$search_orderby_array = $Spotter->getOrderBy();
1025
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1026 1026
 	} else {
1027
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1027
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1028 1028
 	}
1029 1029
 
1030 1030
 	$query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1032,16 +1032,16 @@  discard block
 block discarded – undo
1032 1032
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1033 1033
 
1034 1034
 	return $spotter_array;
1035
-    }
1036
-
1037
-    /**
1038
-    * Gets all the spotter information based on the pilot
1039
-    *
1040
-    * @return Array the spotter information
1041
-    *
1042
-    */
1043
-    public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1044
-    {
1035
+	}
1036
+
1037
+	/**
1038
+	 * Gets all the spotter information based on the pilot
1039
+	 *
1040
+	 * @return Array the spotter information
1041
+	 *
1042
+	 */
1043
+	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1044
+	{
1045 1045
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
1046 1046
 	
1047 1047
 	date_default_timezone_set('UTC');
@@ -1060,24 +1060,24 @@  discard block
 block discarded – undo
1060 1060
 	
1061 1061
 	if ($limit != "")
1062 1062
 	{
1063
-	    $limit_array = explode(",", $limit);
1063
+		$limit_array = explode(",", $limit);
1064 1064
 	    
1065
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1066
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1065
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1066
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1067 1067
 	    
1068
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1069
-	    {
1068
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1069
+		{
1070 1070
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1071 1071
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1072
-	    }
1072
+		}
1073 1073
 	}
1074 1074
 
1075 1075
 	if ($sort != "")
1076 1076
 	{
1077
-	    $search_orderby_array = $Spotter->getOrderBy();
1078
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1077
+		$search_orderby_array = $Spotter->getOrderBy();
1078
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1079 1079
 	} else {
1080
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1080
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1081 1081
 	}
1082 1082
 
1083 1083
 	$query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1085,16 +1085,16 @@  discard block
 block discarded – undo
1085 1085
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1086 1086
 
1087 1087
 	return $spotter_array;
1088
-    }
1089
-
1090
-    /**
1091
-    * Gets all number of flight over countries
1092
-    *
1093
-    * @return Array the airline country list
1094
-    *
1095
-    */
1096
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1097
-    {
1088
+	}
1089
+
1090
+	/**
1091
+	 * Gets all number of flight over countries
1092
+	 *
1093
+	 * @return Array the airline country list
1094
+	 *
1095
+	 */
1096
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1097
+	{
1098 1098
 	global $globalDBdriver;
1099 1099
 	/*
1100 1100
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1104,14 +1104,14 @@  discard block
 block discarded – undo
1104 1104
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1105 1105
 		    FROM countries c, spotter_archive s
1106 1106
 		    WHERE c.iso2 = s.over_country ";
1107
-                if ($olderthanmonths > 0) {
1108
-            		if ($globalDBdriver == 'mysql') {
1107
+				if ($olderthanmonths > 0) {
1108
+					if ($globalDBdriver == 'mysql') {
1109 1109
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1110 1110
 			} else {
1111 1111
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1112 1112
 			}
1113 1113
 		}
1114
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1114
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1115 1115
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1116 1116
 	if ($limit) $query .= " LIMIT 0,10";
1117 1117
       
@@ -1124,23 +1124,23 @@  discard block
 block discarded – undo
1124 1124
         
1125 1125
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1126 1126
 	{
1127
-	    $temp_array['flight_count'] = $row['nb'];
1128
-	    $temp_array['flight_country'] = $row['name'];
1129
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1130
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1131
-	    $flight_array[] = $temp_array;
1127
+		$temp_array['flight_count'] = $row['nb'];
1128
+		$temp_array['flight_country'] = $row['name'];
1129
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1130
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1131
+		$flight_array[] = $temp_array;
1132 1132
 	}
1133 1133
 	return $flight_array;
1134
-    }
1135
-
1136
-    /**
1137
-    * Gets all number of flight over countries
1138
-    *
1139
-    * @return Array the airline country list
1140
-    *
1141
-    */
1142
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1143
-    {
1134
+	}
1135
+
1136
+	/**
1137
+	 * Gets all number of flight over countries
1138
+	 *
1139
+	 * @return Array the airline country list
1140
+	 *
1141
+	 */
1142
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1143
+	{
1144 1144
 	global $globalDBdriver;
1145 1145
 	/*
1146 1146
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1150,14 +1150,14 @@  discard block
 block discarded – undo
1150 1150
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1151 1151
 		    FROM countries c, spotter_archive s, spotter_output o
1152 1152
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id ";
1153
-                if ($olderthanmonths > 0) {
1154
-            		if ($globalDBdriver == 'mysql') {
1153
+				if ($olderthanmonths > 0) {
1154
+					if ($globalDBdriver == 'mysql') {
1155 1155
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1156 1156
 			} else {
1157 1157
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1158 1158
 			}
1159 1159
 		}
1160
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1160
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1161 1161
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1162 1162
 	if ($limit) $query .= " LIMIT 0,10";
1163 1163
       
@@ -1170,24 +1170,24 @@  discard block
 block discarded – undo
1170 1170
         
1171 1171
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1172 1172
 	{
1173
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1174
-	    $temp_array['flight_count'] = $row['nb'];
1175
-	    $temp_array['flight_country'] = $row['name'];
1176
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1177
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1178
-	    $flight_array[] = $temp_array;
1173
+		$temp_array['airline_icao'] = $row['airline_icao'];
1174
+		$temp_array['flight_count'] = $row['nb'];
1175
+		$temp_array['flight_country'] = $row['name'];
1176
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1177
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1178
+		$flight_array[] = $temp_array;
1179 1179
 	}
1180 1180
 	return $flight_array;
1181
-    }
1182
-
1183
-    /**
1184
-    * Gets last spotter information based on a particular callsign
1185
-    *
1186
-    * @return Array the spotter information
1187
-    *
1188
-    */
1189
-    public function getDateArchiveSpotterDataById($id,$date)
1190
-    {
1181
+	}
1182
+
1183
+	/**
1184
+	 * Gets last spotter information based on a particular callsign
1185
+	 *
1186
+	 * @return Array the spotter information
1187
+	 *
1188
+	 */
1189
+	public function getDateArchiveSpotterDataById($id,$date)
1190
+	{
1191 1191
 	$Spotter = new Spotter($this->db);
1192 1192
 	date_default_timezone_set('UTC');
1193 1193
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1195,16 +1195,16 @@  discard block
 block discarded – undo
1195 1195
 	$date = date('c',$date);
1196 1196
 	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1197 1197
 	return $spotter_array;
1198
-    }
1199
-
1200
-    /**
1201
-    * Gets all the spotter information based on a particular callsign
1202
-    *
1203
-    * @return Array the spotter information
1204
-    *
1205
-    */
1206
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1207
-    {
1198
+	}
1199
+
1200
+	/**
1201
+	 * Gets all the spotter information based on a particular callsign
1202
+	 *
1203
+	 * @return Array the spotter information
1204
+	 *
1205
+	 */
1206
+	public function getDateArchiveSpotterDataByIdent($ident,$date)
1207
+	{
1208 1208
 	$Spotter = new Spotter($this->db);
1209 1209
 	date_default_timezone_set('UTC');
1210 1210
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1212,16 +1212,16 @@  discard block
 block discarded – undo
1212 1212
 	$date = date('c',$date);
1213 1213
 	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1214 1214
 	return $spotter_array;
1215
-    }
1216
-
1217
-    /**
1218
-    * Gets all the spotter information based on the airport
1219
-    *
1220
-    * @return Array the spotter information
1221
-    *
1222
-    */
1223
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1224
-    {
1215
+	}
1216
+
1217
+	/**
1218
+	 * Gets all the spotter information based on the airport
1219
+	 *
1220
+	 * @return Array the spotter information
1221
+	 *
1222
+	 */
1223
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1224
+	{
1225 1225
 	global $global_query;
1226 1226
 	$Spotter = new Spotter();
1227 1227
 	date_default_timezone_set('UTC');
@@ -1232,35 +1232,35 @@  discard block
 block discarded – undo
1232 1232
 	
1233 1233
 	if ($airport != "")
1234 1234
 	{
1235
-	    if (!is_string($airport))
1236
-	    {
1235
+		if (!is_string($airport))
1236
+		{
1237 1237
 		return false;
1238
-	    } else {
1238
+		} else {
1239 1239
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))";
1240 1240
 		$query_values = array(':airport' => $airport);
1241
-	    }
1241
+		}
1242 1242
 	}
1243 1243
 	
1244 1244
 	if ($limit != "")
1245 1245
 	{
1246
-	    $limit_array = explode(",", $limit);
1246
+		$limit_array = explode(",", $limit);
1247 1247
 	    
1248
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1249
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1248
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1249
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1250 1250
 	    
1251
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1252
-	    {
1251
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1252
+		{
1253 1253
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1254 1254
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1255
-	    }
1255
+		}
1256 1256
 	}
1257 1257
 	
1258 1258
 	if ($sort != "")
1259 1259
 	{
1260
-	    $search_orderby_array = $Spotter->getOrderBy();
1261
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1260
+		$search_orderby_array = $Spotter->getOrderBy();
1261
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1262 1262
 	} else {
1263
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1263
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1264 1264
 	}
1265 1265
 
1266 1266
 	$query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1268,6 +1268,6 @@  discard block
 block discarded – undo
1268 1268
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1269 1269
 
1270 1270
 	return $spotter_array;
1271
-    }
1271
+	}
1272 1272
 }
1273 1273
 ?>
1274 1274
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -13,48 +13,48 @@  discard block
 block discarded – undo
13 13
     * @param Array $filter the filter
14 14
     * @return Array the SQL part
15 15
     */
16
-    public function getFilter($filter = array(),$where = false,$and = false) {
16
+    public function getFilter($filter = array(), $where = false, $and = false) {
17 17
 	global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 	$filters = array();
19 19
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
20 20
 		if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
21 21
 			$filters = $globalStatsFilters[$globalFilterName];
22 22
 		} else {
23
-			$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
23
+			$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
24 24
 		}
25 25
 	}
26 26
 	if (isset($filter[0]['source'])) {
27
-		$filters = array_merge($filters,$filter);
27
+		$filters = array_merge($filters, $filter);
28 28
 	}
29
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+	if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 	$filter_query_join = '';
31 31
 	$filter_query_where = '';
32
-	foreach($filters as $flt) {
32
+	foreach ($filters as $flt) {
33 33
 	    if (isset($flt['airlines']) && !empty($flt['airlines'])) {
34 34
 		if ($flt['airlines'][0] != '') {
35 35
 		    if (isset($flt['source'])) {
36
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
36
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
37 37
 		    } else {
38
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
38
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
39 39
 		    }
40 40
 		}
41 41
 	    }
42 42
 	    if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
43 43
 		if (isset($flt['source'])) {
44
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
44
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
45 45
 		} else {
46
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
46
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
47 47
 		}
48 48
 	    }
49 49
 	    if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) {
50 50
 		if (isset($flt['source'])) {
51
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
51
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
52 52
 		}
53 53
 	    }
54 54
 	}
55 55
 	if (isset($filter['airlines']) && !empty($filter['airlines'])) {
56 56
 	    if ($filter['airlines'][0] != '') {
57
-		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
57
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
58 58
 	    }
59 59
 	}
60 60
 	
@@ -62,16 +62,16 @@  discard block
 block discarded – undo
62 62
 	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
63 63
 	}
64 64
 	if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
65
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
65
+	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
66 66
 	}
67 67
 	if (isset($filter['source']) && !empty($filter['source'])) {
68
-	    $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
68
+	    $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
69 69
 	}
70 70
 	if (isset($filter['ident']) && !empty($filter['ident'])) {
71 71
 	    $filter_query_where .= " AND ident = '".$filter['ident']."'";
72 72
 	}
73 73
 	if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
74
-		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
74
+		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
75 75
 	}
76 76
 	if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) {
77 77
 	    $filter_query_date = '';
@@ -97,40 +97,40 @@  discard block
 block discarded – undo
97 97
 		    $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
98 98
 		}
99 99
 	    }
100
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
100
+	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
101 101
 	}
102 102
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
103 103
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
104 104
 	if ($filter_query_where != '') {
105
-		$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
105
+		$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
106 106
 	}
107 107
 	$filter_query = $filter_query_join.$filter_query_where;
108 108
 	return $filter_query;
109 109
     }
110 110
 
111 111
 	// Spotter_archive
112
-	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
112
+	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') {
113 113
 		require_once(dirname(__FILE__).'/class.Spotter.php');
114 114
 		if ($over_country == '') {
115 115
 			$Spotter = new Spotter($this->db);
116
-			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
116
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
117 117
 			if (!empty($data_country)) $country = $data_country['iso2'];
118 118
 			else $country = '';
119 119
 		} else $country = $over_country;
120
-		if ($airline_type === NULL) $airline_type ='';
120
+		if ($airline_type === NULL) $airline_type = '';
121 121
 	
122 122
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
123 123
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
124 124
 
125 125
 		// Route is not added in spotter_archive
126
-		$query  = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
126
+		$query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
127 127
 		        VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)";
128 128
 
129
-		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
129
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
130 130
 		try {
131 131
 			$sth = $this->db->prepare($query);
132 132
 			$sth->execute($query_values);
133
-		} catch(PDOException $e) {
133
+		} catch (PDOException $e) {
134 134
 			return "error : ".$e->getMessage();
135 135
 		}
136 136
 		return "success";
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
 
151 151
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
152 152
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
153
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
153
+                $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
154 154
 
155
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
155
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
156 156
 
157 157
                 return $spotter_array;
158 158
         }
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
172 172
                 //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
173 173
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
174
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
174
+                $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
175 175
 
176 176
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
177 177
                   /*
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                 }
185 185
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
186 186
                 */
187
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
187
+                $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
188 188
 
189 189
                 return $spotter_array;
190 190
         }
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
         {
200 200
                 date_default_timezone_set('UTC');
201 201
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
202
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
202
+                $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
203 203
 
204 204
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
205 205
 
206 206
                 try {
207 207
                         $sth = $this->db->prepare($query);
208 208
                         $sth->execute(array(':id' => $id));
209
-                } catch(PDOException $e) {
209
+                } catch (PDOException $e) {
210 210
                         echo $e->getMessage();
211 211
                         die;
212 212
                 }
@@ -225,14 +225,14 @@  discard block
 block discarded – undo
225 225
         {
226 226
                 date_default_timezone_set('UTC');
227 227
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
228
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
228
+                $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
229 229
 
230 230
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
231 231
 
232 232
                 try {
233 233
                         $sth = $this->db->prepare($query);
234 234
                         $sth->execute(array(':id' => $id));
235
-                } catch(PDOException $e) {
235
+                } catch (PDOException $e) {
236 236
                         echo $e->getMessage();
237 237
                         die;
238 238
                 }
@@ -254,12 +254,12 @@  discard block
 block discarded – undo
254 254
                 date_default_timezone_set('UTC');
255 255
 
256 256
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
257
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
257
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
258 258
 
259 259
                 try {
260 260
                         $sth = $this->db->prepare($query);
261 261
                         $sth->execute(array(':ident' => $ident));
262
-                } catch(PDOException $e) {
262
+                } catch (PDOException $e) {
263 263
                         echo $e->getMessage();
264 264
                         die;
265 265
                 }
@@ -280,12 +280,12 @@  discard block
 block discarded – undo
280 280
                 date_default_timezone_set('UTC');
281 281
 
282 282
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
283
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
283
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
284 284
 
285 285
                 try {
286 286
                         $sth = $this->db->prepare($query);
287 287
                         $sth->execute(array(':id' => $id));
288
-                } catch(PDOException $e) {
288
+                } catch (PDOException $e) {
289 289
                         echo $e->getMessage();
290 290
                         die;
291 291
                 }
@@ -306,12 +306,12 @@  discard block
 block discarded – undo
306 306
                 date_default_timezone_set('UTC');
307 307
 
308 308
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
309
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
309
+                $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
310 310
 
311 311
                 try {
312 312
                         $sth = $this->db->prepare($query);
313 313
                         $sth->execute(array(':id' => $id));
314
-                } catch(PDOException $e) {
314
+                } catch (PDOException $e) {
315 315
                         echo $e->getMessage();
316 316
                         die;
317 317
                 }
@@ -333,13 +333,13 @@  discard block
 block discarded – undo
333 333
                 date_default_timezone_set('UTC');
334 334
 
335 335
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
336
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
336
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
337 337
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
338 338
 
339 339
                 try {
340 340
                         $sth = $this->db->prepare($query);
341 341
                         $sth->execute(array(':ident' => $ident));
342
-                } catch(PDOException $e) {
342
+                } catch (PDOException $e) {
343 343
                         echo $e->getMessage();
344 344
                         die;
345 345
                 }
@@ -356,13 +356,13 @@  discard block
 block discarded – undo
356 356
         * @return Array the spotter information
357 357
         *
358 358
         */
359
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
359
+        public function getSpotterArchiveData($ident, $flightaware_id, $date)
360 360
         {
361 361
     		$Spotter = new Spotter($this->db);
362 362
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
363
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
363
+                $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
364 364
 
365
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
365
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
366 366
 
367 367
                 return $spotter_array;
368 368
         }
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
                 try {
376 376
                         $sth = $this->db->prepare($query);
377 377
                         $sth->execute();
378
-                } catch(PDOException $e) {
378
+                } catch (PDOException $e) {
379 379
                         echo $e->getMessage();
380 380
                         die;
381 381
                 }
@@ -387,24 +387,24 @@  discard block
 block discarded – undo
387 387
         * @return Array the spotter information
388 388
         *
389 389
         */
390
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
390
+        public function getMinLiveSpotterData($begindate, $enddate, $filter = array())
391 391
         {
392 392
                 global $globalDBdriver, $globalLiveInterval;
393 393
                 date_default_timezone_set('UTC');
394 394
 
395 395
                 $filter_query = '';
396 396
                 if (isset($filter['source']) && !empty($filter['source'])) {
397
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
397
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
398 398
                 }
399 399
                 // Use spotter_output also ?
400 400
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
401
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
401
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
402 402
                 }
403 403
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
404 404
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
405 405
                 }
406 406
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
407
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
407
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
408 408
                 }
409 409
 
410 410
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -423,14 +423,14 @@  discard block
 block discarded – undo
423 423
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
424 424
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
425 425
 */
426
-			$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
426
+			$query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
427 427
 				    FROM spotter_archive 
428 428
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
429 429
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
430 430
                         	    '.$filter_query.' ORDER BY flightaware_id';
431 431
                 } else {
432 432
                         //$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
433
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
433
+                        $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
434 434
                         	    FROM spotter_archive 
435 435
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
436 436
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
                 try {
441 441
                         $sth = $this->db->prepare($query);
442 442
                         $sth->execute();
443
-                } catch(PDOException $e) {
443
+                } catch (PDOException $e) {
444 444
                         echo $e->getMessage();
445 445
                         die;
446 446
                 }
@@ -455,24 +455,24 @@  discard block
 block discarded – undo
455 455
         * @return Array the spotter information
456 456
         *
457 457
         */
458
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
458
+        public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array())
459 459
         {
460 460
                 global $globalDBdriver, $globalLiveInterval;
461 461
                 date_default_timezone_set('UTC');
462 462
 
463 463
                 $filter_query = '';
464 464
                 if (isset($filter['source']) && !empty($filter['source'])) {
465
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
465
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
466 466
                 }
467 467
                 // Should use spotter_output also ?
468 468
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
469
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
469
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
470 470
                 }
471 471
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
472 472
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
473 473
                 }
474 474
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
475
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
475
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
476 476
                 }
477 477
 
478 478
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
                     		    FROM spotter_archive 
483 483
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
484 484
 			*/
485
-			$query  = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
485
+			$query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
486 486
 				    FROM spotter_archive_output 
487 487
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao 
488 488
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
498 498
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
499 499
                         */
500
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
500
+                        $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
501 501
                         	    FROM spotter_archive_output 
502 502
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
503 503
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
                 try {
510 510
                         $sth = $this->db->prepare($query);
511 511
                         $sth->execute();
512
-                } catch(PDOException $e) {
512
+                } catch (PDOException $e) {
513 513
                         echo $e->getMessage();
514 514
                         die;
515 515
                 }
@@ -524,23 +524,23 @@  discard block
 block discarded – undo
524 524
         * @return Array the spotter information
525 525
         *
526 526
         */
527
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
527
+        public function getLiveSpotterCount($begindate, $enddate, $filter = array())
528 528
         {
529 529
                 global $globalDBdriver, $globalLiveInterval;
530 530
                 date_default_timezone_set('UTC');
531 531
 
532 532
                 $filter_query = '';
533 533
                 if (isset($filter['source']) && !empty($filter['source'])) {
534
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
534
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
535 535
                 }
536 536
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
537
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
537
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
538 538
                 }
539 539
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
540 540
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
541 541
                 }
542 542
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
543
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
543
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
544 544
                 }
545 545
 
546 546
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
                 try {
556 556
                         $sth = $this->db->prepare($query);
557 557
                         $sth->execute();
558
-                } catch(PDOException $e) {
558
+                } catch (PDOException $e) {
559 559
                         echo $e->getMessage();
560 560
                         die;
561 561
                 }
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
     * @return Array the spotter information
576 576
     *
577 577
     */
578
-    public function searchSpotterData($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())
578
+    public function searchSpotterData($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())
579 579
     {
580 580
 	global $globalTimezone, $globalDBdriver;
581 581
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 	        
598 598
 		$q_array = explode(" ", $q);
599 599
 		
600
-		foreach ($q_array as $q_item){
600
+		foreach ($q_array as $q_item) {
601 601
 		    $additional_query .= " AND (";
602 602
 		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
603 603
 		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 	
630 630
 	if ($registration != "")
631 631
 	{
632
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
632
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
633 633
 	    if (!is_string($registration))
634 634
 	    {
635 635
 		return false;
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 	
641 641
 	if ($aircraft_icao != "")
642 642
 	{
643
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
643
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
644 644
 	    if (!is_string($aircraft_icao))
645 645
 	    {
646 646
 		return false;
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 	
652 652
 	if ($aircraft_manufacturer != "")
653 653
 	{
654
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
654
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
655 655
 	    if (!is_string($aircraft_manufacturer))
656 656
 	    {
657 657
 		return false;
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 	
673 673
 	if ($airline_icao != "")
674 674
 	{
675
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
675
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
676 676
 	    if (!is_string($airline_icao))
677 677
 	    {
678 678
 		return false;
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 	
684 684
 	if ($airline_country != "")
685 685
 	{
686
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
686
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
687 687
 	    if (!is_string($airline_country))
688 688
 	    {
689 689
 		return false;
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 	
695 695
 	if ($airline_type != "")
696 696
 	{
697
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
697
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
698 698
 	    if (!is_string($airline_type))
699 699
 	    {
700 700
 		return false;
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 	
717 717
 	if ($airport != "")
718 718
 	{
719
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
719
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
720 720
 	    if (!is_string($airport))
721 721
 	    {
722 722
 		return false;
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 	
728 728
 	if ($airport_country != "")
729 729
 	{
730
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
730
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
731 731
 	    if (!is_string($airport_country))
732 732
 	    {
733 733
 		return false;
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
     
739 739
 	if ($callsign != "")
740 740
 	{
741
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
741
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
742 742
 	    if (!is_string($callsign))
743 743
 	    {
744 744
 		return false;
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 		$translate = $Translation->ident2icao($callsign);
747 747
 		if ($translate != $callsign) {
748 748
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
749
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
749
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
750 750
 		} else {
751 751
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
752 752
 		}
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 
756 756
 	if ($owner != "")
757 757
 	{
758
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
758
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
759 759
 	    if (!is_string($owner))
760 760
 	    {
761 761
 		return false;
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 
767 767
 	if ($pilot_name != "")
768 768
 	{
769
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
769
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
770 770
 	    if (!is_string($pilot_name))
771 771
 	    {
772 772
 		return false;
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 	
778 778
 	if ($pilot_id != "")
779 779
 	{
780
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
780
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
781 781
 	    if (!is_string($pilot_id))
782 782
 	    {
783 783
 		return false;
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 	
789 789
 	if ($departure_airport_route != "")
790 790
 	{
791
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
791
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
792 792
 	    if (!is_string($departure_airport_route))
793 793
 	    {
794 794
 		return false;
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 	
800 800
 	if ($arrival_airport_route != "")
801 801
 	{
802
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
802
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
803 803
 	    if (!is_string($arrival_airport_route))
804 804
 	    {
805 805
 		return false;
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
 	{
813 813
 	    $altitude_array = explode(",", $altitude);
814 814
 	    
815
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
816
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
815
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
816
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
817 817
 	    
818 818
 
819 819
 	    if ($altitude_array[1] != "")
@@ -831,8 +831,8 @@  discard block
 block discarded – undo
831 831
 	{
832 832
 	    $date_array = explode(",", $date_posted);
833 833
 	    
834
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
835
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
834
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
835
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
836 836
 	    
837 837
 	    if ($globalTimezone != '') {
838 838
 		date_default_timezone_set($globalTimezone);
@@ -864,8 +864,8 @@  discard block
 block discarded – undo
864 864
 	{
865 865
 	    $limit_array = explode(",", $limit);
866 866
 	    
867
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
868
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
867
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
868
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
869 869
 	    
870 870
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
871 871
 	    {
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
 	
877 877
 
878 878
 	if ($origLat != "" && $origLon != "" && $dist != "") {
879
-		$dist = number_format($dist*0.621371,2,'.','');
880
-		$query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
879
+		$dist = number_format($dist*0.621371, 2, '.', '');
880
+		$query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
881 881
                           FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
882 882
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
883 883
 	} else {
@@ -894,12 +894,12 @@  discard block
 block discarded – undo
894 894
 			$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
895 895
 		}
896 896
 
897
-		$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output 
897
+		$query = "SELECT spotter_archive_output.* FROM spotter_archive_output 
898 898
 		    WHERE spotter_archive_output.ident <> '' 
899 899
 		    ".$additional_query."
900 900
 		    ".$filter_query.$orderby_query;
901 901
 	}
902
-	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
902
+	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
903 903
 
904 904
 	return $spotter_array;
905 905
     }
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
                 try {
917 917
                         $sth = $this->db->prepare($query);
918 918
                         $sth->execute();
919
-                } catch(PDOException $e) {
919
+                } catch (PDOException $e) {
920 920
                         return "error";
921 921
                 }
922 922
 	}
@@ -953,8 +953,8 @@  discard block
 block discarded – undo
953 953
 	{
954 954
 	    $limit_array = explode(",", $limit);
955 955
 	    
956
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
957
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
956
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
957
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
958 958
 	    
959 959
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
960 960
 	    {
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 	$query_values = array();
996 996
 	$limit_query = '';
997 997
 	$additional_query = '';
998
-	$filter_query = $this->getFilter($filter,true,true);
998
+	$filter_query = $this->getFilter($filter, true, true);
999 999
 	
1000 1000
 	if ($owner != "")
1001 1001
 	{
@@ -1012,8 +1012,8 @@  discard block
 block discarded – undo
1012 1012
 	{
1013 1013
 	    $limit_array = explode(",", $limit);
1014 1014
 	    
1015
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1016
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1015
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1016
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1017 1017
 	    
1018 1018
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1019 1019
 	    {
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 	$query_values = array();
1054 1054
 	$limit_query = '';
1055 1055
 	$additional_query = '';
1056
-	$filter_query = $this->getFilter($filter,true,true);
1056
+	$filter_query = $this->getFilter($filter, true, true);
1057 1057
 	
1058 1058
 	if ($pilot != "")
1059 1059
 	{
@@ -1065,8 +1065,8 @@  discard block
 block discarded – undo
1065 1065
 	{
1066 1066
 	    $limit_array = explode(",", $limit);
1067 1067
 	    
1068
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1069
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1068
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1069
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1070 1070
 	    
1071 1071
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1072 1072
 	    {
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
     * @return Array the airline country list
1097 1097
     *
1098 1098
     */
1099
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1099
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1100 1100
     {
1101 1101
 	global $globalDBdriver;
1102 1102
 	/*
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 	$flight_array = array();
1126 1126
 	$temp_array = array();
1127 1127
         
1128
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1128
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1129 1129
 	{
1130 1130
 	    $temp_array['flight_count'] = $row['nb'];
1131 1131
 	    $temp_array['flight_country'] = $row['name'];
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
     * @return Array the airline country list
1143 1143
     *
1144 1144
     */
1145
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1145
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1146 1146
     {
1147 1147
 	global $globalDBdriver;
1148 1148
 	/*
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
 	$flight_array = array();
1172 1172
 	$temp_array = array();
1173 1173
         
1174
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1174
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1175 1175
 	{
1176 1176
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1177 1177
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1189,14 +1189,14 @@  discard block
 block discarded – undo
1189 1189
     * @return Array the spotter information
1190 1190
     *
1191 1191
     */
1192
-    public function getDateArchiveSpotterDataById($id,$date)
1192
+    public function getDateArchiveSpotterDataById($id, $date)
1193 1193
     {
1194 1194
 	$Spotter = new Spotter($this->db);
1195 1195
 	date_default_timezone_set('UTC');
1196 1196
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1197
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1198
-	$date = date('c',$date);
1199
-	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1197
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1198
+	$date = date('c', $date);
1199
+	$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1200 1200
 	return $spotter_array;
1201 1201
     }
1202 1202
 
@@ -1206,14 +1206,14 @@  discard block
 block discarded – undo
1206 1206
     * @return Array the spotter information
1207 1207
     *
1208 1208
     */
1209
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1209
+    public function getDateArchiveSpotterDataByIdent($ident, $date)
1210 1210
     {
1211 1211
 	$Spotter = new Spotter($this->db);
1212 1212
 	date_default_timezone_set('UTC');
1213 1213
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1214
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1215
-	$date = date('c',$date);
1216
-	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1214
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1215
+	$date = date('c', $date);
1216
+	$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1217 1217
 	return $spotter_array;
1218 1218
     }
1219 1219
 
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
     * @return Array the spotter information
1224 1224
     *
1225 1225
     */
1226
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1226
+    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1227 1227
     {
1228 1228
 	global $global_query;
1229 1229
 	$Spotter = new Spotter();
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 	$query_values = array();
1232 1232
 	$limit_query = '';
1233 1233
 	$additional_query = '';
1234
-	$filter_query = $this->getFilter($filters,true,true);
1234
+	$filter_query = $this->getFilter($filters, true, true);
1235 1235
 	
1236 1236
 	if ($airport != "")
1237 1237
 	{
@@ -1248,8 +1248,8 @@  discard block
 block discarded – undo
1248 1248
 	{
1249 1249
 	    $limit_array = explode(",", $limit);
1250 1250
 	    
1251
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1252
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1251
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1252
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1253 1253
 	    
1254 1254
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1255 1255
 	    {
Please login to merge, or discard this patch.
Braces   +37 added lines, -13 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 	if (isset($filter[0]['source'])) {
27 27
 		$filters = array_merge($filters,$filter);
28 28
 	}
29
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+	if (is_array($globalFilter)) {
30
+		$filter = array_merge($filter,$globalFilter);
31
+	}
30 32
 	$filter_query_join = '';
31 33
 	$filter_query_where = '';
32 34
 	foreach($filters as $flt) {
@@ -99,8 +101,11 @@  discard block
 block discarded – undo
99 101
 	    }
100 102
 	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
101 103
 	}
102
-	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
103
-	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
104
+	if ($filter_query_where == '' && $where) {
105
+		$filter_query_where = ' WHERE';
106
+	} elseif ($filter_query_where != '' && $and) {
107
+		$filter_query_where .= ' AND';
108
+	}
104 109
 	if ($filter_query_where != '') {
105 110
 		$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
106 111
 	}
@@ -114,10 +119,17 @@  discard block
 block discarded – undo
114 119
 		if ($over_country == '') {
115 120
 			$Spotter = new Spotter($this->db);
116 121
 			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
117
-			if (!empty($data_country)) $country = $data_country['iso2'];
118
-			else $country = '';
119
-		} else $country = $over_country;
120
-		if ($airline_type === NULL) $airline_type ='';
122
+			if (!empty($data_country)) {
123
+				$country = $data_country['iso2'];
124
+			} else {
125
+				$country = '';
126
+			}
127
+		} else {
128
+			$country = $over_country;
129
+		}
130
+		if ($airline_type === NULL) {
131
+			$airline_type ='';
132
+		}
121 133
 	
122 134
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
123 135
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
@@ -620,7 +632,9 @@  discard block
 block discarded – undo
620 632
 		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
621 633
 		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
622 634
 		    $translate = $Translation->ident2icao($q_item);
623
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
635
+		    if ($translate != $q_item) {
636
+		    	$additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
637
+		    }
624 638
 		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
625 639
 		    $additional_query .= ")";
626 640
 		}
@@ -838,7 +852,9 @@  discard block
 block discarded – undo
838 852
 		date_default_timezone_set($globalTimezone);
839 853
 		$datetime = new DateTime();
840 854
 		$offset = $datetime->format('P');
841
-	    } else $offset = '+00:00';
855
+	    } else {
856
+	    	$offset = '+00:00';
857
+	    }
842 858
 
843 859
 
844 860
 	    if ($date_array[1] != "")
@@ -1114,9 +1130,13 @@  discard block
 block discarded – undo
1114 1130
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1115 1131
 			}
1116 1132
 		}
1117
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1133
+                if ($sincedate != '') {
1134
+                	$query .= "AND date > '".$sincedate."' ";
1135
+                }
1118 1136
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1119
-	if ($limit) $query .= " LIMIT 0,10";
1137
+	if ($limit) {
1138
+		$query .= " LIMIT 0,10";
1139
+	}
1120 1140
       
1121 1141
 	
1122 1142
 	$sth = $this->db->prepare($query);
@@ -1160,9 +1180,13 @@  discard block
 block discarded – undo
1160 1180
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1161 1181
 			}
1162 1182
 		}
1163
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1183
+                if ($sincedate != '') {
1184
+                	$query .= "AND s.date > '".$sincedate."' ";
1185
+                }
1164 1186
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1165
-	if ($limit) $query .= " LIMIT 0,10";
1187
+	if ($limit) {
1188
+		$query .= " LIMIT 0,10";
1189
+	}
1166 1190
       
1167 1191
 	
1168 1192
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
pilot-detailed.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@  discard block
 block discarded – undo
6 6
 //require_once('require/class.SpotterLive.php');
7 7
 require_once('require/class.SpotterArchive.php');
8 8
 
9
-if (!isset($_GET['pilot'])){
9
+if (!isset($_GET['pilot'])) {
10 10
 	header('Location: '.$globalURL.'/');
11 11
 } else {
12 12
 	$Spotter = new Spotter();
13 13
 	$SpotterArchive = new SpotterArchive();
14 14
 	$Translation = new Translation();
15 15
 	//calculuation for the pagination
16
-	if(!isset($_GET['limit']))
16
+	if (!isset($_GET['limit']))
17 17
 	{
18 18
 		$limit_start = 0;
19 19
 		$limit_end = 25;
@@ -34,29 +34,29 @@  discard block
 block discarded – undo
34 34
 	
35 35
 	$page_url = $globalURL.'/pilot/'.$_GET['pilot'];
36 36
 	
37
-	$pilot = filter_input(INPUT_GET,'pilot',FILTER_SANITIZE_STRING);
38
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
39
-	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
40
-	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
37
+	$pilot = filter_input(INPUT_GET, 'pilot', FILTER_SANITIZE_STRING);
38
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
39
+	$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
40
+	$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
41 41
 	$filter = array();
42
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
43
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
42
+	if ($year != '') $filter = array_merge($filter, array('year' => $year));
43
+	if ($month != '') $filter = array_merge($filter, array('month' => $month));
44 44
 	if ($sort != '') 
45 45
 	{
46
-		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort,$filter);
46
+		$spotter_array = $Spotter->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, $sort, $filter);
47 47
 		if (empty($spotter_array)) {
48
-			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort,$filter);
48
+			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, $sort, $filter);
49 49
 		}
50 50
 	} else {
51
-		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference,'',$filter);
51
+		$spotter_array = $Spotter->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, '', $filter);
52 52
 		if (empty($spotter_array)) {
53
-			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference,'',$filter);
53
+			$spotter_array = $SpotterArchive->getSpotterDataByPilot($pilot, $limit_start.",".$absolute_difference, '', $filter);
54 54
 		}
55 55
 	}
56 56
 
57 57
 	if (!empty($spotter_array))
58 58
 	{
59
-		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['pilot_name']);
59
+		$title = sprintf(_("Detailed View for %s"), $spotter_array[0]['pilot_name']);
60 60
 		$ident = $spotter_array[0]['ident'];
61 61
 		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
62 62
 		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
@@ -117,23 +117,23 @@  discard block
 block discarded – undo
117 117
 			$Stats = new Stats();
118 118
 			$flights = $Stats->getStatsPilot($pilot);
119 119
 		} else $flights = 0;
120
-		if ($flight == 0) $flights = $Spotter->countFlightsByPilot($pilot,$filter);
120
+		if ($flight == 0) $flights = $Spotter->countFlightsByPilot($pilot, $filter);
121 121
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
122
-		$aircraft_type = count($Spotter->countAllAircraftTypesByPilot($pilot,$filter));
122
+		$aircraft_type = count($Spotter->countAllAircraftTypesByPilot($pilot, $filter));
123 123
 		print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>';
124
-		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByPilot($pilot,$filter));
124
+		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByPilot($pilot, $filter));
125 125
 		print '<div><span class="label">'._("Aircrafts").'</span>'.$aircraft_registration.'</div>';
126
-		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByPilot($pilot,$filter));
126
+		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByPilot($pilot, $filter));
127 127
 		print '<div><span class="label">'._("Manufacturers").'</span>'.$aircraft_manufacturer.'</div>';
128
-		$airlines = count($Spotter->countAllAirlinesByPilot($pilot,$filter));
128
+		$airlines = count($Spotter->countAllAirlinesByPilot($pilot, $filter));
129 129
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
130
-		$duration = $Spotter->getFlightDurationByPilot($pilot,$filter);
130
+		$duration = $Spotter->getFlightDurationByPilot($pilot, $filter);
131 131
 		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
132 132
 		print '</div>';
133 133
 	
134 134
 		include('owner-sub-menu.php');
135 135
 		print '<div class="table column">';
136
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the pilot <strong>%s</strong>."),$spotter_array[0]['pilot_name']).'</p>';
136
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the pilot <strong>%s</strong>."), $spotter_array[0]['pilot_name']).'</p>';
137 137
 
138 138
 		include('table-output.php'); 
139 139
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -39,8 +39,12 @@  discard block
 block discarded – undo
39 39
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
40 40
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
41 41
 	$filter = array();
42
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
43
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
42
+	if ($year != '') {
43
+		$filter = array_merge($filter,array('year' => $year));
44
+	}
45
+	if ($month != '') {
46
+		$filter = array_merge($filter,array('month' => $month));
47
+	}
44 48
 	if ($sort != '') 
45 49
 	{
46 50
 		$spotter_array = $Spotter->getSpotterDataByPilot($pilot,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -58,8 +62,12 @@  discard block
 block discarded – undo
58 62
 	{
59 63
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['pilot_name']);
60 64
 		$ident = $spotter_array[0]['ident'];
61
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
62
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
65
+		if (isset($spotter_array[0]['latitude'])) {
66
+			$latitude = $spotter_array[0]['latitude'];
67
+		}
68
+		if (isset($spotter_array[0]['longitude'])) {
69
+			$longitude = $spotter_array[0]['longitude'];
70
+		}
63 71
 		require_once('header.php');
64 72
 		/*
65 73
 		if (isset($globalArchive) && $globalArchive) {
@@ -112,12 +120,18 @@  discard block
 block discarded – undo
112 120
 		*/
113 121
 		print '<div class="info column">';
114 122
 		print '<h1>'.$spotter_array[0]['pilot_name'].'</h1>';
115
-		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
123
+		if (isset($spotter_array[0]['pilot_id']) && $spotter_array[0]['pilot_id'] != '') {
124
+			print '<div><span class="label">'._("Pilot ID").'</span>'.$spotter_array[0]['pilot_id'].'</div>';
125
+		}
116 126
 		if ($year == '' && $month == '') {
117 127
 			$Stats = new Stats();
118 128
 			$flights = $Stats->getStatsPilot($pilot);
119
-		} else $flights = 0;
120
-		if ($flight == 0) $flights = $Spotter->countFlightsByPilot($pilot,$filter);
129
+		} else {
130
+			$flights = 0;
131
+		}
132
+		if ($flight == 0) {
133
+			$flights = $Spotter->countFlightsByPilot($pilot,$filter);
134
+		}
121 135
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
122 136
 		$aircraft_type = count($Spotter->countAllAircraftTypesByPilot($pilot,$filter));
123 137
 		print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>';
@@ -128,7 +142,9 @@  discard block
 block discarded – undo
128 142
 		$airlines = count($Spotter->countAllAirlinesByPilot($pilot,$filter));
129 143
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
130 144
 		$duration = $Spotter->getFlightDurationByPilot($pilot,$filter);
131
-		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
145
+		if ($duration != '0') {
146
+			print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
147
+		}
132 148
 		print '</div>';
133 149
 	
134 150
 		include('owner-sub-menu.php');
Please login to merge, or discard this patch.
owner-detailed.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
7 7
 //require_once('require/class.SpotterLive.php');
8 8
 require_once('require/class.SpotterArchive.php');
9 9
 
10
-if (!isset($_GET['owner'])){
10
+if (!isset($_GET['owner'])) {
11 11
 	header('Location: '.$globalURL.'');
12 12
 } else {
13 13
 	$Spotter = new Spotter();
14 14
 	$SpotterArchive = new SpotterArchive();
15 15
 	//$Translation = new Translation();
16 16
 	//calculuation for the pagination
17
-	if(!isset($_GET['limit']))
17
+	if (!isset($_GET['limit']))
18 18
 	{
19 19
 		$limit_start = 0;
20 20
 		$limit_end = 25;
@@ -35,29 +35,29 @@  discard block
 block discarded – undo
35 35
 	
36 36
 	$page_url = $globalURL.'/owner/'.$_GET['owner'];
37 37
 	
38
-	$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
39
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
40
-	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
41
-	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
38
+	$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
39
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
40
+	$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
41
+	$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
42 42
 	$filter = array();
43
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
44
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
43
+	if ($year != '') $filter = array_merge($filter, array('year' => $year));
44
+	if ($month != '') $filter = array_merge($filter, array('month' => $month));
45 45
 	if ($sort != '') 
46 46
 	{
47
-		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
47
+		$spotter_array = $Spotter->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, $sort, $filter);
48 48
 		if (empty($spotter_array)) {
49
-			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
49
+			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, $sort, $filter);
50 50
 		}
51 51
 	} else {
52
-		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference,'',$filter);
52
+		$spotter_array = $Spotter->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, '', $filter);
53 53
 		if (empty($spotter_array)) {
54
-			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference,'',$filter);
54
+			$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, '', $filter);
55 55
 		}
56 56
 	}
57 57
 
58 58
 	if (!empty($spotter_array))
59 59
 	{
60
-		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']);
60
+		$title = sprintf(_("Detailed View for %s"), $spotter_array[0]['aircraft_owner']);
61 61
 		//$ident = $spotter_array[0]['ident'];
62 62
 		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
63 63
 		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
@@ -117,23 +117,23 @@  discard block
 block discarded – undo
117 117
 		$Stats = new Stats();
118 118
 		if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner);
119 119
 		else $flights = 0;
120
-		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter);
120
+		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner, $filter);
121 121
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
122
-		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter));
122
+		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner, $filter));
123 123
 		print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>';
124
-		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner,$filter));
124
+		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner, $filter));
125 125
 		print '<div><span class="label">'._("Aircrafts").'</span>'.$aircraft_registration.'</div>';
126
-		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner,$filter));
126
+		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner, $filter));
127 127
 		print '<div><span class="label">'._("Manufacturers").'</span>'.$aircraft_manufacturer.'</div>';
128
-		$airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter));
128
+		$airlines = count($Spotter->countAllAirlinesByOwner($owner, $filter));
129 129
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
130
-		$duration = $Spotter->getFlightDurationByOwner($owner,$filter);
130
+		$duration = $Spotter->getFlightDurationByOwner($owner, $filter);
131 131
 		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
132 132
 		print '</div>';
133 133
 	
134 134
 		include('owner-sub-menu.php');
135 135
 		print '<div class="table column">';
136
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the owner <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
136
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the owner <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>';
137 137
 
138 138
 		include('table-output.php'); 
139 139
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Braces   +23 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,8 +40,12 @@  discard block
 block discarded – undo
40 40
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
41 41
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
42 42
 	$filter = array();
43
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
44
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
43
+	if ($year != '') {
44
+		$filter = array_merge($filter,array('year' => $year));
45
+	}
46
+	if ($month != '') {
47
+		$filter = array_merge($filter,array('month' => $month));
48
+	}
45 49
 	if ($sort != '') 
46 50
 	{
47 51
 		$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -59,8 +63,12 @@  discard block
 block discarded – undo
59 63
 	{
60 64
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']);
61 65
 		//$ident = $spotter_array[0]['ident'];
62
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
63
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
66
+		if (isset($spotter_array[0]['latitude'])) {
67
+			$latitude = $spotter_array[0]['latitude'];
68
+		}
69
+		if (isset($spotter_array[0]['longitude'])) {
70
+			$longitude = $spotter_array[0]['longitude'];
71
+		}
64 72
 		require_once('header.php');
65 73
 		/*
66 74
 		if (isset($globalArchive) && $globalArchive) {
@@ -115,9 +123,14 @@  discard block
 block discarded – undo
115 123
 		print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
116 124
 		//print '<div><span class="label">'._("Owner").'</span>'.$spotter_array[0]['aircraft_owner'].'</div>';
117 125
 		$Stats = new Stats();
118
-		if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner);
119
-		else $flights = 0;
120
-		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter);
126
+		if ($year == '' && $month == '') {
127
+			$flights = $Stats->getStatsOwner($owner);
128
+		} else {
129
+			$flights = 0;
130
+		}
131
+		if ($flights == 0) {
132
+			$flights = $Spotter->countFlightsByOwner($owner,$filter);
133
+		}
121 134
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
122 135
 		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter));
123 136
 		print '<div><span class="label">'._("Aircrafts type").'</span>'.$aircraft_type.'</div>';
@@ -128,7 +141,9 @@  discard block
 block discarded – undo
128 141
 		$airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter));
129 142
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
130 143
 		$duration = $Spotter->getFlightDurationByOwner($owner,$filter);
131
-		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
144
+		if ($duration != '0') {
145
+			print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
146
+		}
132 147
 		print '</div>';
133 148
 	
134 149
 		include('owner-sub-menu.php');
Please login to merge, or discard this patch.
require/class.APRS.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -84,6 +84,10 @@
 block discarded – undo
84 84
 	'y' => 'Yagi At QTH');
85 85
 	
86 86
 
87
+    /**
88
+     * @param integer $n
89
+     * @param integer $s
90
+     */
87 91
     private function urshift($n, $s) {
88 92
 	return ($n >= 0) ? ($n >> $s) :
89 93
     	    (($n & 0x7fffffff) >> $s) | 
Please login to merge, or discard this patch.
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class aprs {
3
-    protected $symbols = array('!' => 'Police',
3
+	protected $symbols = array('!' => 'Police',
4 4
 	'#' => 'DIGI',
5 5
 	'$' => 'Phone',
6 6
 	'%' => 'DX Cluster',
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
 	'y' => 'Yagi At QTH');
85 85
 	
86 86
 
87
-    private function urshift($n, $s) {
87
+	private function urshift($n, $s) {
88 88
 	return ($n >= 0) ? ($n >> $s) :
89
-    	    (($n & 0x7fffffff) >> $s) | 
90
-        	(0x40000000 >> ($s - 1));
91
-    }
89
+			(($n & 0x7fffffff) >> $s) | 
90
+			(0x40000000 >> ($s - 1));
91
+	}
92 92
 
93
-    public function parse($input) {
93
+	public function parse($input) {
94 94
 	global $globalDebug;
95 95
 	$debug = false;
96 96
 	$result = array();
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	
103 103
 	/* Check that end was found and body has at least one byte. */
104 104
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
105
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
106
-	    return false;
105
+		if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
106
+		return false;
107 107
 	}
108 108
 	
109 109
 	/* Save header and body. */
@@ -116,23 +116,23 @@  discard block
 block discarded – undo
116 116
 	/* Parse source, target and path. */
117 117
 	//FLRDF0A52>APRS,qAS,LSTB
118 118
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
119
-	    $ident = $matches[1];
120
-	    $all_elements = $matches[2];
121
-	    if ($debug) echo 'ident : '.$ident."\n";
122
-	    $result['ident'] = $ident;
119
+		$ident = $matches[1];
120
+		$all_elements = $matches[2];
121
+		if ($debug) echo 'ident : '.$ident."\n";
122
+		$result['ident'] = $ident;
123 123
 	} else return false;
124 124
 	$elements = explode(',',$all_elements);
125 125
 	$source = end($elements);
126 126
 	$result['source'] = $source;
127 127
 	foreach ($elements as $element) {
128
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
129
-	        //echo "ok";
130
-	        //if ($element == 'TCPIP*') return false;
131
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
128
+		if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
129
+			//echo "ok";
130
+			//if ($element == 'TCPIP*') return false;
131
+		} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
132 132
 		echo 'element : '.$element."\n";
133 133
 		return false;
134
-	    }
135
-	    /*
134
+		}
135
+		/*
136 136
 	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) {
137 137
 		//echo "ok";
138 138
 	    } else {
@@ -145,49 +145,49 @@  discard block
 block discarded – undo
145 145
 	$body_parse = substr($body,1);
146 146
 	//echo 'Body : '.$body."\n";
147 147
 	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
148
-	    $body_parse = substr($body_parse,10);
149
-	    $find = true;
150
-	    //echo $body_parse."\n";
148
+		$body_parse = substr($body_parse,10);
149
+		$find = true;
150
+		//echo $body_parse."\n";
151 151
 	}
152 152
 	if (preg_match('/^`(.*)\//',$body,$matches)) {
153
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
154
-	    $find = true;
155
-	    //echo $body_parse."\n";
153
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
154
+		$find = true;
155
+		//echo $body_parse."\n";
156 156
 	}
157 157
 	if (preg_match("/^'(.*)\//",$body,$matches)) {
158
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
159
-	    $find = true;
160
-	    //echo $body_parse."\n";
158
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
159
+		$find = true;
160
+		//echo $body_parse."\n";
161 161
 	}
162 162
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
163
-	    $find = true;
164
-	    //print_r($matches);
165
-	    $timestamp = $matches[0];
166
-	    if ($matches[4] == 'h') {
163
+		$find = true;
164
+		//print_r($matches);
165
+		$timestamp = $matches[0];
166
+		if ($matches[4] == 'h') {
167 167
 		$timestamp = strtotime($matches[1].':'.$matches[2].':'.$matches[3]);
168 168
 		//echo 'timestamp : '.$timestamp.' - now : '.time()."\n";
169 169
 		/*
170 170
 		if (time() + 3900 < $timestamp) $timestamp -= 86400;
171 171
 		elseif (time() - 82500 > $timestamp) $timestamp += 86400;
172 172
 		*/
173
-	    } elseif ($matches[4] == 'z' || $matches[4] == '/') {
173
+		} elseif ($matches[4] == 'z' || $matches[4] == '/') {
174 174
 		// This work or not ?
175 175
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
176
-	    }
177
-	    $body_parse = substr($body_parse,7);
178
-	    $result['timestamp'] = $timestamp;
179
-	    //echo date('Ymd H:i:s',$timestamp);
176
+		}
177
+		$body_parse = substr($body_parse,7);
178
+		$result['timestamp'] = $timestamp;
179
+		//echo date('Ymd H:i:s',$timestamp);
180 180
 	}
181 181
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
182
-	    $find = true;
183
-	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
184
-	    $body_parse = substr($body_parse,8);
185
-	    $result['timestamp'] = $timestamp;
186
-	    //echo date('Ymd H:i:s',$timestamp);
182
+		$find = true;
183
+		$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
184
+		$body_parse = substr($body_parse,8);
185
+		$result['timestamp'] = $timestamp;
186
+		//echo date('Ymd H:i:s',$timestamp);
187 187
 	}
188 188
 	//if (strlen($body_parse) > 19) {
189
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
190
-	    $find = true;
189
+		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
190
+		$find = true;
191 191
 		// 4658.70N/00707.78Ez
192 192
 		//print_r(str_split($body_parse));
193 193
 		
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		$lon = intval($lon_deg);
205 205
 		if ($lat > 89 || $lon > 179) return false;
206 206
 	    
207
-	    /*
207
+		/*
208 208
 	    $tmp_5b = str_replace('.','',$lat_min);
209 209
 	    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) {
210 210
 	        print_r($matches);
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 		$result['longitude'] = $longitude;
219 219
 		$body_parse = substr($body_parse,18);
220 220
 		$body_parse_len = strlen($body_parse);
221
-	    }
222
-	    $body_parse_len = strlen($body_parse);
223
-	    if ($body_parse_len > 0) {
221
+		}
222
+		$body_parse_len = strlen($body_parse);
223
+		if ($body_parse_len > 0) {
224 224
 		/*
225 225
 		if (!isset($result['timestamp']) && !isset($result['latitude'])) {
226 226
 			$body_split = str_split($body);
@@ -247,61 +247,61 @@  discard block
 block discarded – undo
247 247
 			$result['symbol_code'] = $symbol_code;
248 248
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
249 249
 			if ($symbol_code != '_') {
250
-		    //$body_parse = substr($body_parse,1);
251
-		    //$body_parse = trim($body_parse);
252
-		    //$body_parse_len = strlen($body_parse);
253
-		    if ($body_parse_len >= 7) {
250
+			//$body_parse = substr($body_parse,1);
251
+			//$body_parse = trim($body_parse);
252
+			//$body_parse_len = strlen($body_parse);
253
+			if ($body_parse_len >= 7) {
254 254
 			
255
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
256
-		    	    $course = substr($body_parse,0,3);
257
-		    	    $tmp_s = intval($course);
258
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
259
-		    	    $speed = substr($body_parse,4,3);
260
-		    	    $result['speed'] = round($speed*1.852);
261
-		    	    $body_parse = substr($body_parse,7);
262
-		        }
263
-		        // Check PHGR, PHG, RNG
264
-		    } 
265
-		    /*
255
+				if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
256
+					$course = substr($body_parse,0,3);
257
+					$tmp_s = intval($course);
258
+					if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
259
+					$speed = substr($body_parse,4,3);
260
+					$result['speed'] = round($speed*1.852);
261
+					$body_parse = substr($body_parse,7);
262
+				}
263
+				// Check PHGR, PHG, RNG
264
+			} 
265
+			/*
266 266
 		    else if ($body_parse_len > 0) {
267 267
 			$rest = $body_parse;
268 268
 		    }
269 269
 		    */
270
-		    if (strlen($body_parse) > 0) {
271
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
272
-		            $altitude = intval($matches[1]);
273
-		            //$result['altitude'] = round($altitude*0.3048);
274
-		            $result['altitude'] = $altitude;
275
-		            $body_parse = trim(substr($body_parse,strlen($matches[0])));
276
-		        }
277
-		    }
270
+			if (strlen($body_parse) > 0) {
271
+				if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
272
+					$altitude = intval($matches[1]);
273
+					//$result['altitude'] = round($altitude*0.3048);
274
+					$result['altitude'] = $altitude;
275
+					$body_parse = trim(substr($body_parse,strlen($matches[0])));
276
+				}
277
+			}
278 278
 		    
279
-		    // Telemetry
280
-		    /*
279
+			// Telemetry
280
+			/*
281 281
 		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) {
282 282
 		        // Nothing yet...
283 283
 		    }
284 284
 		    */
285
-		    // DAO
286
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
287
-			    $dao = $matches[1];
288
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
285
+			// DAO
286
+			if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
287
+				$dao = $matches[1];
288
+				if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
289 289
 				$dao_split = str_split($dao);
290
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
291
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
290
+					$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
291
+					$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
292 292
 			    
293 293
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
294 294
 				else $result['latitude'] += $lat_off;
295 295
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
296 296
 				else $result['longitude'] += $lon_off;
297
-			    }
298
-		            $body_parse = substr($body_parse,6);
299
-		    }
297
+				}
298
+					$body_parse = substr($body_parse,6);
299
+			}
300 300
 		    
301
-		    // OGN comment
301
+			// OGN comment
302 302
 		   // echo "Before OGN : ".$body_parse."\n";
303
-		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
304
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
303
+			//if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
304
+			if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
305 305
 			$id = $matches[1];
306 306
 			//$mode = substr($id,0,2);
307 307
 			$address = substr($id,2);
@@ -331,51 +331,51 @@  discard block
 block discarded – undo
331 331
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
332 332
 			$result['stealth'] = $stealth;
333 333
 			$result['address'] = $address;
334
-		    }
334
+			}
335 335
 		    
336
-		    //Comment
337
-		    $result['comment'] = trim($body_parse);
336
+			//Comment
337
+			$result['comment'] = trim($body_parse);
338 338
 		} else {
339
-		    // parse weather
340
-		    //$body_parse = substr($body_parse,1);
341
-		    //$body_parse_len = strlen($body_parse);
339
+			// parse weather
340
+			//$body_parse = substr($body_parse,1);
341
+			//$body_parse_len = strlen($body_parse);
342 342
 
343
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
344
-			    $result['wind_dir'] = intval($matches[1]);
345
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
346
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
347
-			    $result['temp'] = round(5/9*(($matches[4])-32),1);
348
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
349
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
343
+			if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
344
+				$result['wind_dir'] = intval($matches[1]);
345
+				$result['wind_speed'] = round(intval($matches[2])*1.60934,1);
346
+				$result['wind_gust'] = round(intval($matches[3])*1.60934,1);
347
+				$result['temp'] = round(5/9*(($matches[4])-32),1);
348
+					$body_parse = substr($body_parse,strlen($matches[0])+1);
349
+			} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
350 350
 			$result['wind_dir'] = intval($matches[1]);
351 351
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
352 352
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
353 353
 			$result['temp'] = round(5/9*(($matches[4])-32),1);
354
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
355
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
354
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
355
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
356 356
 			$result['wind_dir'] = intval($matches[1]);
357 357
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
358 358
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
359
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
360
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
359
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
360
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
361 361
 			$result['wind_dir'] = intval($matches[1]);
362 362
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
363 363
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
364
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
365
-		    }
366
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
364
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
365
+			}
366
+			if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
367 367
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
368
-		    }
368
+			}
369 369
 		}
370 370
 		} else $result['comment'] = trim($body_parse);
371 371
 
372
-	    }
372
+		}
373 373
 	//}
374 374
 	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
375 375
 	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
376 376
 	//print_r($result);
377 377
 	return $result;
378
-    }
378
+	}
379 379
 }
380 380
 /*
381 381
 $aprs = new aprs();
Please login to merge, or discard this patch.
Spacing   +62 added lines, -63 removed lines patch added patch discarded remove patch
@@ -85,8 +85,7 @@  discard block
 block discarded – undo
85 85
 	
86 86
 
87 87
     private function urshift($n, $s) {
88
-	return ($n >= 0) ? ($n >> $s) :
89
-    	    (($n & 0x7fffffff) >> $s) | 
88
+	return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
90 89
         	(0x40000000 >> ($s - 1));
91 90
     }
92 91
 
@@ -98,7 +97,7 @@  discard block
 block discarded – undo
98 97
 	//$split_input = str_split($input);
99 98
 
100 99
 	/* Find the end of header checking for NULL bytes while doing it. */
101
-	$splitpos = strpos($input,':');
100
+	$splitpos = strpos($input, ':');
102 101
 	
103 102
 	/* Check that end was found and body has at least one byte. */
104 103
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -107,28 +106,28 @@  discard block
 block discarded – undo
107 106
 	}
108 107
 	
109 108
 	/* Save header and body. */
110
-	$body = substr($input,$splitpos+1,$input_len);
109
+	$body = substr($input, $splitpos + 1, $input_len);
111 110
 	$body_len = strlen($body);
112
-	$header = substr($input,0,$splitpos);
111
+	$header = substr($input, 0, $splitpos);
113 112
 	//$header_len = strlen($header);
114 113
 	if ($debug) echo 'header : '.$header."\n";
115 114
 	
116 115
 	/* Parse source, target and path. */
117 116
 	//FLRDF0A52>APRS,qAS,LSTB
118
-	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
117
+	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
119 118
 	    $ident = $matches[1];
120 119
 	    $all_elements = $matches[2];
121 120
 	    if ($debug) echo 'ident : '.$ident."\n";
122 121
 	    $result['ident'] = $ident;
123 122
 	} else return false;
124
-	$elements = explode(',',$all_elements);
123
+	$elements = explode(',', $all_elements);
125 124
 	$source = end($elements);
126 125
 	$result['source'] = $source;
127 126
 	foreach ($elements as $element) {
128
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
127
+	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
129 128
 	        //echo "ok";
130 129
 	        //if ($element == 'TCPIP*') return false;
131
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
130
+	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
132 131
 		echo 'element : '.$element."\n";
133 132
 		return false;
134 133
 	    }
@@ -142,24 +141,24 @@  discard block
 block discarded – undo
142 141
 	}
143 142
 	// Check for Timestamp
144 143
 	$find = false;
145
-	$body_parse = substr($body,1);
144
+	$body_parse = substr($body, 1);
146 145
 	//echo 'Body : '.$body."\n";
147
-	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
148
-	    $body_parse = substr($body_parse,10);
146
+	if (preg_match('/^;(.){9}\*/', $body, $matches)) {
147
+	    $body_parse = substr($body_parse, 10);
149 148
 	    $find = true;
150 149
 	    //echo $body_parse."\n";
151 150
 	}
152
-	if (preg_match('/^`(.*)\//',$body,$matches)) {
153
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
151
+	if (preg_match('/^`(.*)\//', $body, $matches)) {
152
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
154 153
 	    $find = true;
155 154
 	    //echo $body_parse."\n";
156 155
 	}
157
-	if (preg_match("/^'(.*)\//",$body,$matches)) {
158
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
156
+	if (preg_match("/^'(.*)\//", $body, $matches)) {
157
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
159 158
 	    $find = true;
160 159
 	    //echo $body_parse."\n";
161 160
 	}
162
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
161
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
163 162
 	    $find = true;
164 163
 	    //print_r($matches);
165 164
 	    $timestamp = $matches[0];
@@ -174,19 +173,19 @@  discard block
 block discarded – undo
174 173
 		// This work or not ?
175 174
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
176 175
 	    }
177
-	    $body_parse = substr($body_parse,7);
176
+	    $body_parse = substr($body_parse, 7);
178 177
 	    $result['timestamp'] = $timestamp;
179 178
 	    //echo date('Ymd H:i:s',$timestamp);
180 179
 	}
181
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
180
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
182 181
 	    $find = true;
183 182
 	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
184
-	    $body_parse = substr($body_parse,8);
183
+	    $body_parse = substr($body_parse, 8);
185 184
 	    $result['timestamp'] = $timestamp;
186 185
 	    //echo date('Ymd H:i:s',$timestamp);
187 186
 	}
188 187
 	//if (strlen($body_parse) > 19) {
189
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
188
+	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
190 189
 	    $find = true;
191 190
 		// 4658.70N/00707.78Ez
192 191
 		//print_r(str_split($body_parse));
@@ -212,11 +211,11 @@  discard block
 block discarded – undo
212 211
 	    */
213 212
 		$latitude = $lat + floatval($lat_min)/60;
214 213
 		$longitude = $lon + floatval($lon_min)/60;
215
-		if ($sind == 'S') $latitude = 0-$latitude;
216
-		if ($wind == 'W') $longitude = 0-$longitude;
214
+		if ($sind == 'S') $latitude = 0 - $latitude;
215
+		if ($wind == 'W') $longitude = 0 - $longitude;
217 216
 		$result['latitude'] = $latitude;
218 217
 		$result['longitude'] = $longitude;
219
-		$body_parse = substr($body_parse,18);
218
+		$body_parse = substr($body_parse, 18);
220 219
 		$body_parse_len = strlen($body_parse);
221 220
 	    }
222 221
 	    $body_parse_len = strlen($body_parse);
@@ -240,7 +239,7 @@  discard block
 block discarded – undo
240 239
 		if ($find) {
241 240
 			$body_split = str_split($body_parse);
242 241
 			$symbol_code = $body_split[0];
243
-			$body_parse = substr($body_parse,1);
242
+			$body_parse = substr($body_parse, 1);
244 243
 			$body_parse_len = strlen($body_parse);
245 244
 		//}
246 245
 		//echo $body_parse;
@@ -252,13 +251,13 @@  discard block
 block discarded – undo
252 251
 		    //$body_parse_len = strlen($body_parse);
253 252
 		    if ($body_parse_len >= 7) {
254 253
 			
255
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
256
-		    	    $course = substr($body_parse,0,3);
254
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
255
+		    	    $course = substr($body_parse, 0, 3);
257 256
 		    	    $tmp_s = intval($course);
258 257
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
259
-		    	    $speed = substr($body_parse,4,3);
258
+		    	    $speed = substr($body_parse, 4, 3);
260 259
 		    	    $result['speed'] = round($speed*1.852);
261
-		    	    $body_parse = substr($body_parse,7);
260
+		    	    $body_parse = substr($body_parse, 7);
262 261
 		        }
263 262
 		        // Check PHGR, PHG, RNG
264 263
 		    } 
@@ -268,11 +267,11 @@  discard block
 block discarded – undo
268 267
 		    }
269 268
 		    */
270 269
 		    if (strlen($body_parse) > 0) {
271
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
270
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
272 271
 		            $altitude = intval($matches[1]);
273 272
 		            //$result['altitude'] = round($altitude*0.3048);
274 273
 		            $result['altitude'] = $altitude;
275
-		            $body_parse = trim(substr($body_parse,strlen($matches[0])));
274
+		            $body_parse = trim(substr($body_parse, strlen($matches[0])));
276 275
 		        }
277 276
 		    }
278 277
 		    
@@ -283,35 +282,35 @@  discard block
 block discarded – undo
283 282
 		    }
284 283
 		    */
285 284
 		    // DAO
286
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
285
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
287 286
 			    $dao = $matches[1];
288
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
287
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
289 288
 				$dao_split = str_split($dao);
290
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
291
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
289
+			        $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
290
+			        $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
292 291
 			    
293 292
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
294 293
 				else $result['latitude'] += $lat_off;
295 294
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
296 295
 				else $result['longitude'] += $lon_off;
297 296
 			    }
298
-		            $body_parse = substr($body_parse,6);
297
+		            $body_parse = substr($body_parse, 6);
299 298
 		    }
300 299
 		    
301 300
 		    // OGN comment
302 301
 		   // echo "Before OGN : ".$body_parse."\n";
303 302
 		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
304
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
303
+		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
305 304
 			$id = $matches[1];
306 305
 			//$mode = substr($id,0,2);
307
-			$address = substr($id,2);
306
+			$address = substr($id, 2);
308 307
 			//print_r($matches);
309
-			$addressType = (intval(substr($id,0,2),16))&3;
308
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
310 309
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
311 310
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
312 311
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
313 312
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
314
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
313
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
315 314
 			$result['aircrafttype_code'] = $aircraftType;
316 315
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
317 316
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -328,7 +327,7 @@  discard block
 block discarded – undo
328 327
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
329 328
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
330 329
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
331
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
330
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
332 331
 			$result['stealth'] = $stealth;
333 332
 			$result['address'] = $address;
334 333
 		    }
@@ -340,39 +339,39 @@  discard block
 block discarded – undo
340 339
 		    //$body_parse = substr($body_parse,1);
341 340
 		    //$body_parse_len = strlen($body_parse);
342 341
 
343
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
342
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
344 343
 			    $result['wind_dir'] = intval($matches[1]);
345
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
346
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
347
-			    $result['temp'] = round(5/9*(($matches[4])-32),1);
348
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
349
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
344
+			    $result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
345
+			    $result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
346
+			    $result['temp'] = round(5/9*(($matches[4]) - 32), 1);
347
+		    	    $body_parse = substr($body_parse, strlen($matches[0]) + 1);
348
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
350 349
 			$result['wind_dir'] = intval($matches[1]);
351
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
352
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
353
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
354
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
355
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
350
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
351
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
352
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
353
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
354
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
356 355
 			$result['wind_dir'] = intval($matches[1]);
357
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
358
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
359
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
360
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
356
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
357
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
358
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
359
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
361 360
 			$result['wind_dir'] = intval($matches[1]);
362
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
363
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
364
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
361
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
362
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
363
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
365 364
 		    }
366
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
367
-			$result['temp'] = round(5/9*(($matches[1])-32),1);
365
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) {
366
+			$result['temp'] = round(5/9*(($matches[1]) - 32), 1);
368 367
 		    }
369 368
 		}
370 369
 		} else $result['comment'] = trim($body_parse);
371 370
 
372 371
 	    }
373 372
 	//}
374
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
375
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
373
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
374
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
376 375
 	//print_r($result);
377 376
 	return $result;
378 377
     }
Please login to merge, or discard this patch.
Braces   +86 added lines, -35 removed lines patch added patch discarded remove patch
@@ -102,7 +102,9 @@  discard block
 block discarded – undo
102 102
 	
103 103
 	/* Check that end was found and body has at least one byte. */
104 104
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
105
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
105
+	    if ($globalDebug) {
106
+	    	echo '!!! APRS invalid : '.$input."\n";
107
+	    }
106 108
 	    return false;
107 109
 	}
108 110
 	
@@ -111,16 +113,22 @@  discard block
 block discarded – undo
111 113
 	$body_len = strlen($body);
112 114
 	$header = substr($input,0,$splitpos);
113 115
 	//$header_len = strlen($header);
114
-	if ($debug) echo 'header : '.$header."\n";
116
+	if ($debug) {
117
+		echo 'header : '.$header."\n";
118
+	}
115 119
 	
116 120
 	/* Parse source, target and path. */
117 121
 	//FLRDF0A52>APRS,qAS,LSTB
118 122
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
119 123
 	    $ident = $matches[1];
120 124
 	    $all_elements = $matches[2];
121
-	    if ($debug) echo 'ident : '.$ident."\n";
125
+	    if ($debug) {
126
+	    	echo 'ident : '.$ident."\n";
127
+	    }
122 128
 	    $result['ident'] = $ident;
123
-	} else return false;
129
+	} else {
130
+		return false;
131
+	}
124 132
 	$elements = explode(',',$all_elements);
125 133
 	$source = end($elements);
126 134
 	$result['source'] = $source;
@@ -202,7 +210,9 @@  discard block
 block discarded – undo
202 210
 		//$symbol_table = $matches[4];
203 211
 		$lat = intval($lat_deg);
204 212
 		$lon = intval($lon_deg);
205
-		if ($lat > 89 || $lon > 179) return false;
213
+		if ($lat > 89 || $lon > 179) {
214
+			return false;
215
+		}
206 216
 	    
207 217
 	    /*
208 218
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -212,8 +222,12 @@  discard block
 block discarded – undo
212 222
 	    */
213 223
 		$latitude = $lat + floatval($lat_min)/60;
214 224
 		$longitude = $lon + floatval($lon_min)/60;
215
-		if ($sind == 'S') $latitude = 0-$latitude;
216
-		if ($wind == 'W') $longitude = 0-$longitude;
225
+		if ($sind == 'S') {
226
+			$latitude = 0-$latitude;
227
+		}
228
+		if ($wind == 'W') {
229
+			$longitude = 0-$longitude;
230
+		}
217 231
 		$result['latitude'] = $latitude;
218 232
 		$result['longitude'] = $longitude;
219 233
 		$body_parse = substr($body_parse,18);
@@ -245,7 +259,9 @@  discard block
 block discarded – undo
245 259
 		//}
246 260
 		//echo $body_parse;
247 261
 			$result['symbol_code'] = $symbol_code;
248
-			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
262
+			if (isset($this->symbols[$symbol_code])) {
263
+				$result['symbol'] = $this->symbols[$symbol_code];
264
+			}
249 265
 			if ($symbol_code != '_') {
250 266
 		    //$body_parse = substr($body_parse,1);
251 267
 		    //$body_parse = trim($body_parse);
@@ -255,7 +271,9 @@  discard block
 block discarded – undo
255 271
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
256 272
 		    	    $course = substr($body_parse,0,3);
257 273
 		    	    $tmp_s = intval($course);
258
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
274
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
275
+		    	    	$result['heading'] = intval($course);
276
+		    	    }
259 277
 		    	    $speed = substr($body_parse,4,3);
260 278
 		    	    $result['speed'] = round($speed*1.852);
261 279
 		    	    $body_parse = substr($body_parse,7);
@@ -290,10 +308,16 @@  discard block
 block discarded – undo
290 308
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
291 309
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
292 310
 			    
293
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
294
-				else $result['latitude'] += $lat_off;
295
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
296
-				else $result['longitude'] += $lon_off;
311
+				if ($result['latitude'] < 0) {
312
+					$result['latitude'] -= $lat_off;
313
+				} else {
314
+					$result['latitude'] += $lat_off;
315
+				}
316
+				if ($result['longitude'] < 0) {
317
+					$result['longitude'] -= $lon_off;
318
+				} else {
319
+					$result['longitude'] += $lon_off;
320
+				}
297 321
 			    }
298 322
 		            $body_parse = substr($body_parse,6);
299 323
 		    }
@@ -307,27 +331,48 @@  discard block
 block discarded – undo
307 331
 			$address = substr($id,2);
308 332
 			//print_r($matches);
309 333
 			$addressType = (intval(substr($id,0,2),16))&3;
310
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
311
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
312
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
313
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
334
+			if ($addressType == 0) {
335
+				$result['addresstype'] = "RANDOM";
336
+			} elseif ($addressType == 1) {
337
+				$result['addresstype'] = "ICAO";
338
+			} elseif ($addressType == 2) {
339
+				$result['addresstype'] = "FLARM";
340
+			} elseif ($addressType == 3) {
341
+				$result['addresstype'] = "OGN";
342
+			}
314 343
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
315 344
 			$result['aircrafttype_code'] = $aircraftType;
316
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
317
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
318
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
319
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
320
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
321
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
322
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
323
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
324
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
325
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
326
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
327
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
328
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
329
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
330
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
345
+			if ($aircraftType == 0) {
346
+				$result['aircrafttype'] = "UNKNOWN";
347
+			} elseif ($aircraftType == 1) {
348
+				$result['aircrafttype'] = "GLIDER";
349
+			} elseif ($aircraftType == 2) {
350
+				$result['aircrafttype'] = "TOW_PLANE";
351
+			} elseif ($aircraftType == 3) {
352
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
353
+			} elseif ($aircraftType == 4) {
354
+				$result['aircrafttype'] = "PARACHUTE";
355
+			} elseif ($aircraftType == 5) {
356
+				$result['aircrafttype'] = "DROP_PLANE";
357
+			} elseif ($aircraftType == 6) {
358
+				$result['aircrafttype'] = "HANG_GLIDER";
359
+			} elseif ($aircraftType == 7) {
360
+				$result['aircrafttype'] = "PARA_GLIDER";
361
+			} elseif ($aircraftType == 8) {
362
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
363
+			} elseif ($aircraftType == 9) {
364
+				$result['aircrafttype'] = "JET_AIRCRAFT";
365
+			} elseif ($aircraftType == 10) {
366
+				$result['aircrafttype'] = "UFO";
367
+			} elseif ($aircraftType == 11) {
368
+				$result['aircrafttype'] = "BALLOON";
369
+			} elseif ($aircraftType == 12) {
370
+				$result['aircrafttype'] = "AIRSHIP";
371
+			} elseif ($aircraftType == 13) {
372
+				$result['aircrafttype'] = "UAV";
373
+			} elseif ($aircraftType == 15) {
374
+				$result['aircrafttype'] = "STATIC_OBJECT";
375
+			}
331 376
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
332 377
 			$result['stealth'] = $stealth;
333 378
 			$result['address'] = $address;
@@ -367,12 +412,18 @@  discard block
 block discarded – undo
367 412
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
368 413
 		    }
369 414
 		}
370
-		} else $result['comment'] = trim($body_parse);
415
+		} else {
416
+			$result['comment'] = trim($body_parse);
417
+		}
371 418
 
372 419
 	    }
373 420
 	//}
374
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
375
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
421
+	if (isset($result['latitude'])) {
422
+		$result['latitude'] = round($result['latitude'],4);
423
+	}
424
+	if (isset($result['longitude'])) {
425
+		$result['longitude'] = round($result['longitude'],4);
426
+	}
376 427
 	//print_r($result);
377 428
 	return $result;
378 429
     }
Please login to merge, or discard this patch.
install/class.update_schema.php 3 patches
Indentation   +603 added lines, -603 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@  discard block
 block discarded – undo
8 8
 class update_schema {
9 9
 
10 10
 	public static function update_schedule() {
11
-	    $Connection = new Connection();
12
-	    $Schedule = new Schedule();
13
-	    $query = "SELECT * FROM schedule";
14
-            try {
15
-            	$sth = $Connection->db->prepare($query);
11
+		$Connection = new Connection();
12
+		$Schedule = new Schedule();
13
+		$query = "SELECT * FROM schedule";
14
+			try {
15
+				$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+			} catch(PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19
-    	    }
20
-    	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
-    	    }
19
+			}
20
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
+			$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
22
+			}
23 23
 	
24 24
 	}
25 25
 /*
@@ -43,198 +43,198 @@  discard block
 block discarded – undo
43 43
     	}
44 44
 */	
45 45
 	private static function update_from_1() {
46
-    		$Connection = new Connection();
47
-    		// Add new column to routes table
48
-    		//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
46
+			$Connection = new Connection();
47
+			// Add new column to routes table
48
+			//$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME";
49 49
 		$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL";
50
-        	try {
51
-            	    $sth = $Connection->db->prepare($query);
52
-		    $sth->execute();
53
-    		} catch(PDOException $e) {
54
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
-    		}
56
-    		// Copy schedules data to routes table
57
-    		self::update_schedule();
58
-    		// Delete schedule table
50
+			try {
51
+					$sth = $Connection->db->prepare($query);
52
+			$sth->execute();
53
+			} catch(PDOException $e) {
54
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55
+			}
56
+			// Copy schedules data to routes table
57
+			self::update_schedule();
58
+			// Delete schedule table
59 59
 		$query = "DROP TABLE `schedule`";
60
-        	try {
61
-            	    $sth = $Connection->db->prepare($query);
62
-		    $sth->execute();
63
-    		} catch(PDOException $e) {
64
-		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65
-    		}
66
-    		// Add source column
67
-    		$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
-    		try {
69
-            	    $sth = $Connection->db->prepare($query);
70
-		    $sth->execute();
71
-    		} catch(PDOException $e) {
72
-		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
-    		}
60
+			try {
61
+					$sth = $Connection->db->prepare($query);
62
+			$sth->execute();
63
+			} catch(PDOException $e) {
64
+			return "error (delete schedule table) : ".$e->getMessage()."\n";
65
+			}
66
+			// Add source column
67
+			$query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL";
68
+			try {
69
+					$sth = $Connection->db->prepare($query);
70
+			$sth->execute();
71
+			} catch(PDOException $e) {
72
+			return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73
+			}
74 74
 		// Delete unused column
75 75
 		$query = "ALTER TABLE `aircraft_modes`  DROP `SerialNo`,  DROP `OperatorFlagCode`,  DROP `Manufacturer`,  DROP `Type`,  DROP `FirstRegDate`,  DROP `CurrentRegDate`,  DROP `Country`,  DROP `PreviousID`,  DROP `DeRegDate`,  DROP `Status`,  DROP `PopularName`,  DROP `GenericName`,  DROP `AircraftClass`,  DROP `Engines`,  DROP `OwnershipStatus`,  DROP `RegisteredOwners`,  DROP `MTOW`,  DROP `TotalHours`,  DROP `YearBuilt`,  DROP `CofACategory`,  DROP `CofAExpiry`,  DROP `UserNotes`,  DROP `Interested`,  DROP `UserTag`,  DROP `InfoUrl`,  DROP `PictureUrl1`,  DROP `PictureUrl2`,  DROP `PictureUrl3`,  DROP `UserBool1`,  DROP `UserBool2`,  DROP `UserBool3`,  DROP `UserBool4`,  DROP `UserBool5`,  DROP `UserString1`,  DROP `UserString2`,  DROP `UserString3`,  DROP `UserString4`,  DROP `UserString5`,  DROP `UserInt1`,  DROP `UserInt2`,  DROP `UserInt3`,  DROP `UserInt4`,  DROP `UserInt5`";
76
-    		try {
77
-            	    $sth = $Connection->db->prepare($query);
78
-		    $sth->execute();
79
-    		} catch(PDOException $e) {
80
-		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
-    		}
76
+			try {
77
+					$sth = $Connection->db->prepare($query);
78
+			$sth->execute();
79
+			} catch(PDOException $e) {
80
+			return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81
+			}
82 82
 		// Add ModeS column
83 83
 		$query = "ALTER TABLE `spotter_output`  ADD `ModeS` VARCHAR(255) NULL";
84
-    		try {
85
-            	    $sth = $Connection->db->prepare($query);
86
-		    $sth->execute();
87
-    		} catch(PDOException $e) {
88
-		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
-    		}
84
+			try {
85
+					$sth = $Connection->db->prepare($query);
86
+			$sth->execute();
87
+			} catch(PDOException $e) {
88
+			return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89
+			}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91
-    		try {
92
-            	    $sth = $Connection->db->prepare($query);
93
-		    $sth->execute();
94
-    		} catch(PDOException $e) {
95
-		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
-    		}
97
-    		// Add auto_increment for aircraft_modes
98
-    		$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
-    		try {
100
-            	    $sth = $Connection->db->prepare($query);
101
-		    $sth->execute();
102
-    		} catch(PDOException $e) {
103
-		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
-    		}
105
-    		$error = '';
91
+			try {
92
+					$sth = $Connection->db->prepare($query);
93
+			$sth->execute();
94
+			} catch(PDOException $e) {
95
+			return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96
+			}
97
+			// Add auto_increment for aircraft_modes
98
+			$query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT";
99
+			try {
100
+					$sth = $Connection->db->prepare($query);
101
+			$sth->execute();
102
+			} catch(PDOException $e) {
103
+			return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104
+			}
105
+			$error = '';
106 106
 		$error .= create_db::import_file('../db/acars_live.sql');
107 107
 		$error .= create_db::import_file('../db/config.sql');
108 108
 		// Update schema_version to 2
109 109
 		$query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'";
110
-        	try {
111
-            	    $sth = $Connection->db->prepare($query);
112
-		    $sth->execute();
113
-    		} catch(PDOException $e) {
114
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
115
-    		}
110
+			try {
111
+					$sth = $Connection->db->prepare($query);
112
+			$sth->execute();
113
+			} catch(PDOException $e) {
114
+			return "error (update schema_version) : ".$e->getMessage()."\n";
115
+			}
116 116
 		return $error;
117
-        }
117
+		}
118 118
 
119 119
 	private static function update_from_2() {
120
-    		$Connection = new Connection();
121
-    		// Add new column decode to acars_live table
120
+			$Connection = new Connection();
121
+			// Add new column decode to acars_live table
122 122
 		$query = "ALTER TABLE `acars_live` ADD `decode` TEXT";
123
-        	try {
124
-            	    $sth = $Connection->db->prepare($query);
125
-		    $sth->execute();
126
-    		} catch(PDOException $e) {
127
-		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
-    		}
129
-    		$error = '';
130
-    		// Create table acars_archive
123
+			try {
124
+					$sth = $Connection->db->prepare($query);
125
+			$sth->execute();
126
+			} catch(PDOException $e) {
127
+			return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128
+			}
129
+			$error = '';
130
+			// Create table acars_archive
131 131
 		$error .= create_db::import_file('../db/acars_archive.sql');
132 132
 		// Update schema_version to 3
133 133
 		$query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'";
134
-        	try {
135
-            	    $sth = $Connection->db->prepare($query);
136
-		    $sth->execute();
137
-    		} catch(PDOException $e) {
138
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
139
-    		}
134
+			try {
135
+					$sth = $Connection->db->prepare($query);
136
+			$sth->execute();
137
+			} catch(PDOException $e) {
138
+			return "error (update schema_version) : ".$e->getMessage()."\n";
139
+			}
140 140
 		return $error;
141 141
 	}
142 142
 
143 143
 	private static function update_from_3() {
144
-    		$Connection = new Connection();
145
-    		// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
144
+			$Connection = new Connection();
145
+			// Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated
146 146
 		$query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP";
147
-        	try {
148
-            	    $sth = $Connection->db->prepare($query);
149
-		    $sth->execute();
150
-    		} catch(PDOException $e) {
151
-		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
-    		}
153
-    		// Add image_source_website column to spotter_image
147
+			try {
148
+					$sth = $Connection->db->prepare($query);
149
+			$sth->execute();
150
+			} catch(PDOException $e) {
151
+			return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152
+			}
153
+			// Add image_source_website column to spotter_image
154 154
 		$query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL";
155
-        	try {
156
-            	    $sth = $Connection->db->prepare($query);
157
-		    $sth->execute();
158
-    		} catch(PDOException $e) {
159
-		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
-    		}
161
-    		$error = '';
155
+			try {
156
+					$sth = $Connection->db->prepare($query);
157
+			$sth->execute();
158
+			} catch(PDOException $e) {
159
+			return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160
+			}
161
+			$error = '';
162 162
 		// Update schema_version to 4
163 163
 		$query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'";
164
-        	try {
165
-            	    $sth = $Connection->db->prepare($query);
166
-		    $sth->execute();
167
-    		} catch(PDOException $e) {
168
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
169
-    		}
164
+			try {
165
+					$sth = $Connection->db->prepare($query);
166
+			$sth->execute();
167
+			} catch(PDOException $e) {
168
+			return "error (update schema_version) : ".$e->getMessage()."\n";
169
+			}
170 170
 		return $error;
171 171
 	}
172 172
 	
173 173
 	private static function update_from_4() {
174
-    		$Connection = new Connection();
174
+			$Connection = new Connection();
175 175
 	
176
-    		$error = '';
177
-    		// Create table acars_label
176
+			$error = '';
177
+			// Create table acars_label
178 178
 		$error .= create_db::import_file('../db/acars_label.sql');
179 179
 		if ($error == '') {
180
-		    // Update schema_version to 5
181
-		    $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
-        	    try {
183
-            		$sth = $Connection->db->prepare($query);
180
+			// Update schema_version to 5
181
+			$query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'";
182
+				try {
183
+					$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+				} catch(PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187
-    		    }
188
-    		}
187
+				}
188
+			}
189 189
 		return $error;
190 190
 	}
191 191
 
192 192
 	private static function update_from_5() {
193
-    		$Connection = new Connection();
194
-    		// Add columns to translation
193
+			$Connection = new Connection();
194
+			// Add columns to translation
195 195
 		$query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;";
196
-        	try {
197
-            	    $sth = $Connection->db->prepare($query);
198
-		    $sth->execute();
199
-    		} catch(PDOException $e) {
200
-		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
-    		}
202
-    		// Add aircraft_shadow column to aircraft
203
-    		$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
-        	try {
205
-            	    $sth = $Connection->db->prepare($query);
206
-		    $sth->execute();
207
-    		} catch(PDOException $e) {
208
-		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
-    		}
210
-    		// Add aircraft_shadow column to spotter_live
211
-    		$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
-        	try {
213
-            	    $sth = $Connection->db->prepare($query);
214
-		    $sth->execute();
215
-    		} catch(PDOException $e) {
216
-		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
-    		}
218
-    		$error = '';
219
-    		// Update table aircraft
196
+			try {
197
+					$sth = $Connection->db->prepare($query);
198
+			$sth->execute();
199
+			} catch(PDOException $e) {
200
+			return "error (add new columns to translation) : ".$e->getMessage()."\n";
201
+			}
202
+			// Add aircraft_shadow column to aircraft
203
+			$query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL";
204
+			try {
205
+					$sth = $Connection->db->prepare($query);
206
+			$sth->execute();
207
+			} catch(PDOException $e) {
208
+			return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209
+			}
210
+			// Add aircraft_shadow column to spotter_live
211
+			$query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL";
212
+			try {
213
+					$sth = $Connection->db->prepare($query);
214
+			$sth->execute();
215
+			} catch(PDOException $e) {
216
+			return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217
+			}
218
+			$error = '';
219
+			// Update table aircraft
220 220
 		$error .= create_db::import_file('../db/aircraft.sql');
221 221
 		$error .= create_db::import_file('../db/spotter_archive.sql');
222 222
 
223 223
 		// Update schema_version to 6
224 224
 		$query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'";
225
-        	try {
226
-            	    $sth = $Connection->db->prepare($query);
227
-		    $sth->execute();
228
-    		} catch(PDOException $e) {
229
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
230
-    		}
225
+			try {
226
+					$sth = $Connection->db->prepare($query);
227
+			$sth->execute();
228
+			} catch(PDOException $e) {
229
+			return "error (update schema_version) : ".$e->getMessage()."\n";
230
+			}
231 231
 		return $error;
232 232
 	}
233 233
 
234 234
 	private static function update_from_6() {
235
-    		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
-    		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
235
+			$Connection = new Connection();
236
+			if (!$Connection->indexExists('spotter_output','flightaware_id')) {
237
+				$query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
240 240
 			ALTER TABLE spotter_live ADD INDEX(flightaware_id);
@@ -247,147 +247,147 @@  discard block
 block discarded – undo
247 247
 			ALTER TABLE aircraft ADD INDEX(icao);
248 248
 			ALTER TABLE airport ADD INDEX(icao);
249 249
 			ALTER TABLE translation ADD INDEX(Operator);";
250
-        	    try {
251
-            		$sth = $Connection->db->prepare($query);
250
+				try {
251
+					$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+				} catch(PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255
-    		    }
256
-    		}
257
-    		$error = '';
258
-    		// Update table countries
259
-    		if ($Connection->tableExists('airspace')) {
260
-    		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
255
+				}
256
+			}
257
+			$error = '';
258
+			// Update table countries
259
+			if ($Connection->tableExists('airspace')) {
260
+				$error .= update_db::update_countries();
261
+			if ($error != '') return $error;
262 262
 		}
263 263
 		// Update schema_version to 7
264 264
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
265
-        	try {
266
-            	    $sth = $Connection->db->prepare($query);
267
-		    $sth->execute();
268
-    		} catch(PDOException $e) {
269
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
270
-    		}
265
+			try {
266
+					$sth = $Connection->db->prepare($query);
267
+			$sth->execute();
268
+			} catch(PDOException $e) {
269
+			return "error (update schema_version) : ".$e->getMessage()."\n";
270
+			}
271 271
 		return $error;
272
-    	}
272
+		}
273 273
 
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276
-    		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
276
+			$Connection = new Connection();
277
+			$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279
-        	try {
280
-            	    $sth = $Connection->db->prepare($query);
281
-		    $sth->execute();
282
-    		} catch(PDOException $e) {
283
-		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
-    		}
285
-    		if ($globalDBdriver == 'mysql') {
286
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
-		    try {
288
-            		$sth = $Connection->db->prepare($query);
279
+			try {
280
+					$sth = $Connection->db->prepare($query);
281
+			$sth->execute();
282
+			} catch(PDOException $e) {
283
+			return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284
+			}
285
+			if ($globalDBdriver == 'mysql') {
286
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
287
+			try {
288
+					$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+				} catch(PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292
-    		    }
293
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
294
-    		    if ($row['engine'] == 'ARCHIVE') {
292
+				}
293
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
294
+				if ($row['engine'] == 'ARCHIVE') {
295 295
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
296 296
 				ALTER TABLE copy ENGINE=ARCHIVE;
297 297
 				ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
298 298
 				INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`;
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301
-            	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
-            	    }
304
-                } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
-                }
307
-        	try {
308
-            	    $sth = $Connection->db->prepare($query);
309
-		    $sth->execute();
310
-    		} catch(PDOException $e) {
311
-		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
-    		}
301
+					} else {
302
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303
+					}
304
+				} else {
305
+				$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306
+				}
307
+			try {
308
+					$sth = $Connection->db->prepare($query);
309
+			$sth->execute();
310
+			} catch(PDOException $e) {
311
+			return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312
+			}
313 313
 
314
-    		$error = '';
315
-    		// Update table aircraft
314
+			$error = '';
315
+			// Update table aircraft
316 316
 		$error .= create_db::import_file('../db/source_location.sql');
317 317
 		if ($error != '') return $error;
318 318
 		// Update schema_version to 6
319 319
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320
-        	try {
321
-            	    $sth = $Connection->db->prepare($query);
322
-		    $sth->execute();
323
-    		} catch(PDOException $e) {
324
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
325
-    		}
320
+			try {
321
+					$sth = $Connection->db->prepare($query);
322
+			$sth->execute();
323
+			} catch(PDOException $e) {
324
+			return "error (update schema_version) : ".$e->getMessage()."\n";
325
+			}
326 326
 		return $error;
327 327
 	}
328 328
 
329 329
 	private static function update_from_8() {
330
-    		$Connection = new Connection();
331
-    		$error = '';
332
-    		// Update table aircraft
330
+			$Connection = new Connection();
331
+			$error = '';
332
+			// Update table aircraft
333 333
 		$error .= create_db::import_file('../db/notam.sql');
334 334
 		if ($error != '') return $error;
335 335
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 336
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 337
                         DELETE FROM config WHERE name = 'last_update_notam_db';
338 338
                         INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());";
339
-        	try {
340
-            	    $sth = $Connection->db->prepare($query);
341
-		    $sth->execute();
342
-    		} catch(PDOException $e) {
343
-		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344
-    		}
339
+			try {
340
+					$sth = $Connection->db->prepare($query);
341
+			$sth->execute();
342
+			} catch(PDOException $e) {
343
+			return "error (insert last_update values) : ".$e->getMessage()."\n";
344
+			}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346
-        	try {
347
-            	    $sth = $Connection->db->prepare($query);
348
-		    $sth->execute();
349
-    		} catch(PDOException $e) {
350
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
351
-    		}
346
+			try {
347
+					$sth = $Connection->db->prepare($query);
348
+			$sth->execute();
349
+			} catch(PDOException $e) {
350
+			return "error (update schema_version) : ".$e->getMessage()."\n";
351
+			}
352 352
 		return $error;
353 353
 	}
354 354
 
355 355
 	private static function update_from_9() {
356
-    		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
356
+			$Connection = new Connection();
357
+			$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359
-        	try {
360
-            	    $sth = $Connection->db->prepare($query);
361
-		    $sth->execute();
362
-    		} catch(PDOException $e) {
363
-		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
-    		}
359
+			try {
360
+					$sth = $Connection->db->prepare($query);
361
+			$sth->execute();
362
+			} catch(PDOException $e) {
363
+			return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364
+			}
365 365
 		$error = '';
366
-    		// Update table atc
366
+			// Update table atc
367 367
 		$error .= create_db::import_file('../db/atc.sql');
368 368
 		if ($error != '') return $error;
369 369
 		
370 370
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371
-        	try {
372
-            	    $sth = $Connection->db->prepare($query);
373
-		    $sth->execute();
374
-    		} catch(PDOException $e) {
375
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
376
-    		}
371
+			try {
372
+					$sth = $Connection->db->prepare($query);
373
+			$sth->execute();
374
+			} catch(PDOException $e) {
375
+			return "error (update schema_version) : ".$e->getMessage()."\n";
376
+			}
377 377
 		return $error;
378 378
 	}
379 379
 
380 380
 	private static function update_from_10() {
381
-    		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
-        	try {
384
-            	    $sth = $Connection->db->prepare($query);
385
-		    $sth->execute();
386
-    		} catch(PDOException $e) {
387
-		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
-    		}
381
+			$Connection = new Connection();
382
+			$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383
+			try {
384
+					$sth = $Connection->db->prepare($query);
385
+			$sth->execute();
386
+			} catch(PDOException $e) {
387
+			return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388
+			}
389 389
 		$error = '';
390
-    		// Add tables
390
+			// Add tables
391 391
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392 392
 		if ($error != '') return $error;
393 393
 		$error .= create_db::import_file('../db/metar.sql');
@@ -398,76 +398,76 @@  discard block
 block discarded – undo
398 398
 		if ($error != '') return $error;
399 399
 		
400 400
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401
-        	try {
402
-            	    $sth = $Connection->db->prepare($query);
403
-		    $sth->execute();
404
-    		} catch(PDOException $e) {
405
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
406
-    		}
401
+			try {
402
+					$sth = $Connection->db->prepare($query);
403
+			$sth->execute();
404
+			} catch(PDOException $e) {
405
+			return "error (update schema_version) : ".$e->getMessage()."\n";
406
+			}
407 407
 		return $error;
408 408
 	}
409 409
 
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412
-    		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
-        	try {
415
-            	    $sth = $Connection->db->prepare($query);
416
-		    $sth->execute();
417
-    		} catch(PDOException $e) {
418
-		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
-    		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
-        	try {
422
-            	    $sth = $Connection->db->prepare($query);
423
-		    $sth->execute();
424
-    		} catch(PDOException $e) {
425
-		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
-    		}
427
-    		if ($globalDBdriver == 'mysql') {
428
-    		    $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
-		    try {
430
-            		$sth = $Connection->db->prepare($query);
412
+			$Connection = new Connection();
413
+			$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414
+			try {
415
+					$sth = $Connection->db->prepare($query);
416
+			$sth->execute();
417
+			} catch(PDOException $e) {
418
+			return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419
+			}
420
+			$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421
+			try {
422
+					$sth = $Connection->db->prepare($query);
423
+			$sth->execute();
424
+			} catch(PDOException $e) {
425
+			return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426
+			}
427
+			if ($globalDBdriver == 'mysql') {
428
+				$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
429
+			try {
430
+					$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+				} catch(PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434
-    		    }
435
-    		    $row = $sth->fetch(PDO::FETCH_ASSOC);
436
-    		    if ($row['engine'] == 'ARCHIVE') {
434
+				}
435
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
436
+				if ($row['engine'] == 'ARCHIVE') {
437 437
 			$query = "CREATE TABLE copy LIKE spotter_archive; 
438 438
 				ALTER TABLE copy ENGINE=ARCHIVE;
439 439
 				ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE;
440 440
 				INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`;
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443
-            	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
-            	    }
446
-                } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
-                }
449
-        	try {
450
-            	    $sth = $Connection->db->prepare($query);
451
-		    $sth->execute();
452
-    		} catch(PDOException $e) {
453
-		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
-    		}
443
+					} else {
444
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445
+					}
446
+				} else {
447
+				$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448
+				}
449
+			try {
450
+					$sth = $Connection->db->prepare($query);
451
+			$sth->execute();
452
+			} catch(PDOException $e) {
453
+			return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454
+			}
455 455
 
456 456
 		$error = '';
457 457
 		
458 458
 		$query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'";
459
-        	try {
460
-            	    $sth = $Connection->db->prepare($query);
461
-		    $sth->execute();
462
-    		} catch(PDOException $e) {
463
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
464
-    		}
459
+			try {
460
+					$sth = $Connection->db->prepare($query);
461
+			$sth->execute();
462
+			} catch(PDOException $e) {
463
+			return "error (update schema_version) : ".$e->getMessage()."\n";
464
+			}
465 465
 		return $error;
466 466
 	}
467 467
 	private static function update_from_12() {
468
-    		$Connection = new Connection();
468
+			$Connection = new Connection();
469 469
 		$error = '';
470
-    		// Add tables
470
+			// Add tables
471 471
 		$error .= create_db::import_file('../db/stats.sql');
472 472
 		if ($error != '') return $error;
473 473
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
@@ -484,166 +484,166 @@  discard block
 block discarded – undo
484 484
 		if ($error != '') return $error;
485 485
 		
486 486
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487
-        	try {
488
-            	    $sth = $Connection->db->prepare($query);
489
-		    $sth->execute();
490
-    		} catch(PDOException $e) {
491
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
492
-    		}
487
+			try {
488
+					$sth = $Connection->db->prepare($query);
489
+			$sth->execute();
490
+			} catch(PDOException $e) {
491
+			return "error (update schema_version) : ".$e->getMessage()."\n";
492
+			}
493 493
 		return $error;
494 494
 	}
495 495
 
496 496
 	private static function update_from_13() {
497
-    		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
497
+			$Connection = new Connection();
498
+			if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
+				$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+				} catch(PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505
-    			}
505
+				}
506 506
 		}
507
-    		$error = '';
507
+			$error = '';
508 508
 		$query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'";
509
-        	try {
510
-            	    $sth = $Connection->db->prepare($query);
511
-		    $sth->execute();
512
-    		} catch(PDOException $e) {
513
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
514
-    		}
509
+			try {
510
+					$sth = $Connection->db->prepare($query);
511
+			$sth->execute();
512
+			} catch(PDOException $e) {
513
+			return "error (update schema_version) : ".$e->getMessage()."\n";
514
+			}
515 515
 		return $error;
516 516
 	}
517 517
 
518 518
 	private static function update_from_14() {
519
-    		$Connection = new Connection();
519
+			$Connection = new Connection();
520 520
 		$error = '';
521
-    		// Add tables
522
-    		if (!$Connection->tableExists('stats_flight')) {
521
+			// Add tables
522
+			if (!$Connection->tableExists('stats_flight')) {
523 523
 			$error .= create_db::import_file('../db/stats_flight.sql');
524 524
 			if ($error != '') return $error;
525 525
 		}
526 526
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527
-        	try {
528
-            	    $sth = $Connection->db->prepare($query);
529
-		    $sth->execute();
530
-    		} catch(PDOException $e) {
531
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
532
-    		}
527
+			try {
528
+					$sth = $Connection->db->prepare($query);
529
+			$sth->execute();
530
+			} catch(PDOException $e) {
531
+			return "error (update schema_version) : ".$e->getMessage()."\n";
532
+			}
533 533
 		return $error;
534 534
 	}
535 535
 
536 536
 
537 537
 	private static function update_from_15() {
538
-    		$Connection = new Connection();
538
+			$Connection = new Connection();
539 539
 		$error = '';
540
-    		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
-        	try {
543
-            	    $sth = $Connection->db->prepare($query);
544
-		    $sth->execute();
545
-    		} catch(PDOException $e) {
546
-		    return "error (update stats) : ".$e->getMessage()."\n";
547
-    		}
540
+			// Add tables
541
+			$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542
+			try {
543
+					$sth = $Connection->db->prepare($query);
544
+			$sth->execute();
545
+			} catch(PDOException $e) {
546
+			return "error (update stats) : ".$e->getMessage()."\n";
547
+			}
548 548
 		if ($error != '') return $error;
549 549
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550
-        	try {
551
-            	    $sth = $Connection->db->prepare($query);
552
-		    $sth->execute();
553
-    		} catch(PDOException $e) {
554
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
555
-    		}
550
+			try {
551
+					$sth = $Connection->db->prepare($query);
552
+			$sth->execute();
553
+			} catch(PDOException $e) {
554
+			return "error (update schema_version) : ".$e->getMessage()."\n";
555
+			}
556 556
 		return $error;
557 557
 	}
558 558
 
559 559
 	private static function update_from_16() {
560
-    		$Connection = new Connection();
560
+			$Connection = new Connection();
561 561
 		$error = '';
562
-    		// Add tables
563
-    		if (!$Connection->tableExists('stats_registration')) {
562
+			// Add tables
563
+			if (!$Connection->tableExists('stats_registration')) {
564 564
 			$error .= create_db::import_file('../db/stats_registration.sql');
565 565
 		}
566
-    		if (!$Connection->tableExists('stats_callsign')) {
566
+			if (!$Connection->tableExists('stats_callsign')) {
567 567
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 568
 		}
569 569
 		if ($error != '') return $error;
570 570
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571
-        	try {
572
-            	    $sth = $Connection->db->prepare($query);
573
-		    $sth->execute();
574
-    		} catch(PDOException $e) {
575
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
576
-    		}
571
+			try {
572
+					$sth = $Connection->db->prepare($query);
573
+			$sth->execute();
574
+			} catch(PDOException $e) {
575
+			return "error (update schema_version) : ".$e->getMessage()."\n";
576
+			}
577 577
 		return $error;
578 578
 	}
579 579
 
580 580
 	private static function update_from_17() {
581
-    		$Connection = new Connection();
581
+			$Connection = new Connection();
582 582
 		$error = '';
583
-    		// Add tables
584
-    		if (!$Connection->tableExists('stats_country')) {
583
+			// Add tables
584
+			if (!$Connection->tableExists('stats_country')) {
585 585
 			$error .= create_db::import_file('../db/stats_country.sql');
586 586
 		}
587 587
 		if ($error != '') return $error;
588 588
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589
-        	try {
590
-            	    $sth = $Connection->db->prepare($query);
591
-		    $sth->execute();
592
-    		} catch(PDOException $e) {
593
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
594
-    		}
589
+			try {
590
+					$sth = $Connection->db->prepare($query);
591
+			$sth->execute();
592
+			} catch(PDOException $e) {
593
+			return "error (update schema_version) : ".$e->getMessage()."\n";
594
+			}
595 595
 		return $error;
596 596
 	}
597 597
 	private static function update_from_18() {
598
-    		$Connection = new Connection();
598
+			$Connection = new Connection();
599 599
 		$error = '';
600
-    		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
-    			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
-    	        	try {
604
-	            	    $sth = $Connection->db->prepare($query);
605
-			    $sth->execute();
606
-    			} catch(PDOException $e) {
607
-			    return "error (update stats) : ".$e->getMessage()."\n";
608
-    			}
609
-    		}
600
+			// Modify stats_airport table
601
+			if (!$Connection->checkColumnName('stats_airport','airport_name')) {
602
+				$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603
+					try {
604
+						$sth = $Connection->db->prepare($query);
605
+				$sth->execute();
606
+				} catch(PDOException $e) {
607
+				return "error (update stats) : ".$e->getMessage()."\n";
608
+				}
609
+			}
610 610
 		if ($error != '') return $error;
611 611
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612
-        	try {
613
-            	    $sth = $Connection->db->prepare($query);
614
-		    $sth->execute();
615
-    		} catch(PDOException $e) {
616
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
617
-    		}
612
+			try {
613
+					$sth = $Connection->db->prepare($query);
614
+			$sth->execute();
615
+			} catch(PDOException $e) {
616
+			return "error (update schema_version) : ".$e->getMessage()."\n";
617
+			}
618 618
 		return $error;
619 619
 	}
620 620
 
621 621
 	private static function update_from_19() {
622
-    		$Connection = new Connection();
622
+			$Connection = new Connection();
623 623
 		$error = '';
624
-    		// Update airport table
624
+			// Update airport table
625 625
 		$error .= create_db::import_file('../db/airport.sql');
626 626
 		if ($error != '') return 'Import airport.sql : '.$error;
627 627
 		// Remove primary key on Spotter_Archive
628 628
 		$query = "alter table spotter_archive drop spotter_archive_id";
629
-        	try {
630
-            	    $sth = $Connection->db->prepare($query);
631
-		    $sth->execute();
632
-    		} catch(PDOException $e) {
633
-		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
-    		}
629
+			try {
630
+					$sth = $Connection->db->prepare($query);
631
+			$sth->execute();
632
+			} catch(PDOException $e) {
633
+			return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634
+			}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636
-        	try {
637
-            	    $sth = $Connection->db->prepare($query);
638
-		    $sth->execute();
639
-    		} catch(PDOException $e) {
640
-		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
-    		}
636
+			try {
637
+					$sth = $Connection->db->prepare($query);
638
+			$sth->execute();
639
+			} catch(PDOException $e) {
640
+			return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641
+			}
642 642
 		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
643 643
 			// Add column over_country
644
-    			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
644
+				$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646
-            			$sth = $Connection->db->prepare($query);
646
+						$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648 648
 			} catch(PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 		}
652 652
 		if (!$Connection->checkColumnName('spotter_live','over_country')) {
653 653
 			// Add column over_country
654
-    			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
654
+				$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656
-            			$sth = $Connection->db->prepare($query);
656
+						$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658 658
 			} catch(PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
@@ -661,74 +661,74 @@  discard block
 block discarded – undo
661 661
 		}
662 662
 		if (!$Connection->checkColumnName('spotter_output','source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664
-    			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
664
+				$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668 668
 			} catch(PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670
-    			}
671
-    		}
670
+				}
671
+			}
672 672
 		if (!$Connection->checkColumnName('spotter_live','source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674
-    			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
674
+				$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678 678
 			} catch(PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680
-    			}
681
-    		}
680
+				}
681
+			}
682 682
 		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684
-    			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
684
+				$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688 688
 			} catch(PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690
-    			}
691
-    		}
690
+				}
691
+			}
692 692
 		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694
-    			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
694
+				$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698 698
 			} catch(PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700
-    			}
701
-    		}
700
+				}
701
+			}
702 702
 		if ($error != '') return $error;
703 703
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704
-        	try {
705
-            	    $sth = $Connection->db->prepare($query);
706
-		    $sth->execute();
707
-    		} catch(PDOException $e) {
708
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
709
-    		}
704
+			try {
705
+					$sth = $Connection->db->prepare($query);
706
+			$sth->execute();
707
+			} catch(PDOException $e) {
708
+			return "error (update schema_version) : ".$e->getMessage()."\n";
709
+			}
710 710
 		return $error;
711 711
 	}
712 712
 
713 713
 	private static function update_from_20() {
714 714
 		global $globalIVAO, $globalVATSIM, $globalphpVMS;
715
-    		$Connection = new Connection();
715
+			$Connection = new Connection();
716 716
 		$error = '';
717
-    		// Update airline table
718
-    		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
717
+			// Update airline table
718
+			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722 722
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 723
 			// Add column over_country
724
-    			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
-        		try {
724
+				$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725
+				try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728 728
 			} catch(PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730
-    			}
731
-    		}
730
+				}
731
+			}
732 732
 		if ($error != '') return $error;
733 733
 		/*
734 734
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 		}
739 739
 		*/
740 740
 		$query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'";
741
-        	try {
742
-            	    $sth = $Connection->db->prepare($query);
743
-		    $sth->execute();
744
-    		} catch(PDOException $e) {
745
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
746
-    		}
741
+			try {
742
+					$sth = $Connection->db->prepare($query);
743
+			$sth->execute();
744
+			} catch(PDOException $e) {
745
+			return "error (update schema_version) : ".$e->getMessage()."\n";
746
+			}
747 747
 		return $error;
748 748
 	}
749 749
 
@@ -762,35 +762,35 @@  discard block
 block discarded – undo
762 762
 			if ($error != '') return $error;
763 763
 		}
764 764
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765
-        	try {
766
-            	    $sth = $Connection->db->prepare($query);
767
-		    $sth->execute();
768
-    		} catch(PDOException $e) {
769
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
770
-    		}
765
+			try {
766
+					$sth = $Connection->db->prepare($query);
767
+			$sth->execute();
768
+			} catch(PDOException $e) {
769
+			return "error (update schema_version) : ".$e->getMessage()."\n";
770
+			}
771 771
 		return $error;
772 772
 	}
773 773
 
774 774
 	private static function update_from_22() {
775 775
 		global $globalDBdriver;
776
-    		$Connection = new Connection();
776
+			$Connection = new Connection();
777 777
 		$error = '';
778 778
 		// Add table stats polar
779
-    		if (!$Connection->tableExists('stats_source')) {
779
+			if (!$Connection->tableExists('stats_source')) {
780 780
 			if ($globalDBdriver == 'mysql') {
781
-    				$error .= create_db::import_file('../db/stats_source.sql');
781
+					$error .= create_db::import_file('../db/stats_source.sql');
782 782
 			} else {
783 783
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 784
 			}
785 785
 			if ($error != '') return $error;
786 786
 		}
787 787
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788
-        	try {
789
-            	    $sth = $Connection->db->prepare($query);
790
-		    $sth->execute();
791
-    		} catch(PDOException $e) {
792
-		    return "error (update schema_version) : ".$e->getMessage()."\n";
793
-    		}
788
+			try {
789
+					$sth = $Connection->db->prepare($query);
790
+			$sth->execute();
791
+			} catch(PDOException $e) {
792
+			return "error (update schema_version) : ".$e->getMessage()."\n";
793
+			}
794 794
 		return $error;
795 795
 	}
796 796
 
@@ -821,14 +821,14 @@  discard block
 block discarded – undo
821 821
 		}
822 822
 		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824
-    			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
824
+				$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828 828
 			} catch(PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830
-    			}
831
-    		}
830
+				}
831
+			}
832 832
 		
833 833
 		$query = "UPDATE config SET value = '24' WHERE name = 'schema_version'";
834 834
 		try {
@@ -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);
@@ -1574,169 +1574,169 @@  discard block
 block discarded – undo
1574 1574
 	}
1575 1575
 
1576 1576
 
1577
-    	public static function check_version($update = false) {
1578
-    	    global $globalDBname;
1579
-    	    $version = 0;
1580
-    	    $Connection = new Connection();
1581
-    	    if ($Connection->tableExists('aircraft')) {
1582
-    		if (!$Connection->tableExists('config')) {
1583
-    		    $version = '1';
1584
-    		    if ($update) return self::update_from_1();
1585
-    		    else return $version;
1577
+		public static function check_version($update = false) {
1578
+			global $globalDBname;
1579
+			$version = 0;
1580
+			$Connection = new Connection();
1581
+			if ($Connection->tableExists('aircraft')) {
1582
+			if (!$Connection->tableExists('config')) {
1583
+				$version = '1';
1584
+				if ($update) return self::update_from_1();
1585
+				else return $version;
1586 1586
 		} else {
1587
-    		    $Connection = new Connection();
1588
-		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1589
-		    try {
1590
-            		$sth = $Connection->db->prepare($query);
1591
-		        $sth->execute();
1592
-		    } catch(PDOException $e) {
1587
+				$Connection = new Connection();
1588
+			$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
1589
+			try {
1590
+					$sth = $Connection->db->prepare($query);
1591
+				$sth->execute();
1592
+			} catch(PDOException $e) {
1593 1593
 			return "error : ".$e->getMessage()."\n";
1594
-    		    }
1595
-    		    $result = $sth->fetch(PDO::FETCH_ASSOC);
1596
-    		    if ($update) {
1597
-    			if ($result['value'] == '2') {
1598
-    			    $error = self::update_from_2();
1599
-    			    if ($error != '') return $error;
1600
-    			    else return self::check_version(true);
1601
-    			} elseif ($result['value'] == '3') {
1602
-    			    $error = self::update_from_3();
1603
-    			    if ($error != '') return $error;
1604
-    			    else return self::check_version(true);
1605
-    			} elseif ($result['value'] == '4') {
1606
-    			    $error = self::update_from_4();
1607
-    			    if ($error != '') return $error;
1608
-    			    else return self::check_version(true);
1609
-    			} elseif ($result['value'] == '5') {
1610
-    			    $error = self::update_from_5();
1611
-    			    if ($error != '') return $error;
1612
-    			    else return self::check_version(true);
1613
-    			} elseif ($result['value'] == '6') {
1614
-    			    $error = self::update_from_6();
1615
-    			    if ($error != '') return $error;
1616
-    			    else return self::check_version(true);
1617
-    			} elseif ($result['value'] == '7') {
1618
-    			    $error = self::update_from_7();
1619
-    			    if ($error != '') return $error;
1620
-    			    else return self::check_version(true);
1621
-    			} elseif ($result['value'] == '8') {
1622
-    			    $error = self::update_from_8();
1623
-    			    if ($error != '') return $error;
1624
-    			    else return self::check_version(true);
1625
-    			} elseif ($result['value'] == '9') {
1626
-    			    $error = self::update_from_9();
1627
-    			    if ($error != '') return $error;
1628
-    			    else return self::check_version(true);
1629
-    			} elseif ($result['value'] == '10') {
1630
-    			    $error = self::update_from_10();
1631
-    			    if ($error != '') return $error;
1632
-    			    else return self::check_version(true);
1633
-    			} elseif ($result['value'] == '11') {
1634
-    			    $error = self::update_from_11();
1635
-    			    if ($error != '') return $error;
1636
-    			    else return self::check_version(true);
1637
-    			} elseif ($result['value'] == '12') {
1638
-    			    $error = self::update_from_12();
1639
-    			    if ($error != '') return $error;
1640
-    			    else return self::check_version(true);
1641
-    			} elseif ($result['value'] == '13') {
1642
-    			    $error = self::update_from_13();
1643
-    			    if ($error != '') return $error;
1644
-    			    else return self::check_version(true);
1645
-    			} elseif ($result['value'] == '14') {
1646
-    			    $error = self::update_from_14();
1647
-    			    if ($error != '') return $error;
1648
-    			    else return self::check_version(true);
1649
-    			} elseif ($result['value'] == '15') {
1650
-    			    $error = self::update_from_15();
1651
-    			    if ($error != '') return $error;
1652
-    			    else return self::check_version(true);
1653
-    			} elseif ($result['value'] == '16') {
1654
-    			    $error = self::update_from_16();
1655
-    			    if ($error != '') return $error;
1656
-    			    else return self::check_version(true);
1657
-    			} elseif ($result['value'] == '17') {
1658
-    			    $error = self::update_from_17();
1659
-    			    if ($error != '') return $error;
1660
-    			    else return self::check_version(true);
1661
-    			} elseif ($result['value'] == '18') {
1662
-    			    $error = self::update_from_18();
1663
-    			    if ($error != '') return $error;
1664
-    			    else return self::check_version(true);
1665
-    			} elseif ($result['value'] == '19') {
1666
-    			    $error = self::update_from_19();
1667
-    			    if ($error != '') return $error;
1668
-    			    else return self::check_version(true);
1669
-    			} elseif ($result['value'] == '20') {
1670
-    			    $error = self::update_from_20();
1671
-    			    if ($error != '') return $error;
1672
-    			    else return self::check_version(true);
1673
-    			} elseif ($result['value'] == '21') {
1674
-    			    $error = self::update_from_21();
1675
-    			    if ($error != '') return $error;
1676
-    			    else return self::check_version(true);
1677
-    			} elseif ($result['value'] == '22') {
1678
-    			    $error = self::update_from_22();
1679
-    			    if ($error != '') return $error;
1680
-    			    else return self::check_version(true);
1681
-    			} elseif ($result['value'] == '23') {
1682
-    			    $error = self::update_from_23();
1683
-    			    if ($error != '') return $error;
1684
-    			    else return self::check_version(true);
1685
-    			} elseif ($result['value'] == '24') {
1686
-    			    $error = self::update_from_24();
1687
-    			    if ($error != '') return $error;
1688
-    			    else return self::check_version(true);
1689
-    			} elseif ($result['value'] == '25') {
1690
-    			    $error = self::update_from_25();
1691
-    			    if ($error != '') return $error;
1692
-    			    else return self::check_version(true);
1693
-    			} elseif ($result['value'] == '26') {
1694
-    			    $error = self::update_from_26();
1695
-    			    if ($error != '') return $error;
1696
-    			    else return self::check_version(true);
1697
-    			} elseif ($result['value'] == '27') {
1698
-    			    $error = self::update_from_27();
1699
-    			    if ($error != '') return $error;
1700
-    			    else return self::check_version(true);
1701
-    			} elseif ($result['value'] == '28') {
1702
-    			    $error = self::update_from_28();
1703
-    			    if ($error != '') return $error;
1704
-    			    else return self::check_version(true);
1705
-    			} elseif ($result['value'] == '29') {
1706
-    			    $error = self::update_from_29();
1707
-    			    if ($error != '') return $error;
1708
-    			    else return self::check_version(true);
1709
-    			} elseif ($result['value'] == '30') {
1710
-    			    $error = self::update_from_30();
1711
-    			    if ($error != '') return $error;
1712
-    			    else return self::check_version(true);
1713
-    			} elseif ($result['value'] == '31') {
1714
-    			    $error = self::update_from_31();
1715
-    			    if ($error != '') return $error;
1716
-    			    else return self::check_version(true);
1717
-    			} elseif ($result['value'] == '32') {
1718
-    			    $error = self::update_from_32();
1719
-    			    if ($error != '') return $error;
1720
-    			    else return self::check_version(true);
1721
-    			} elseif ($result['value'] == '33') {
1722
-    			    $error = self::update_from_33();
1723
-    			    if ($error != '') return $error;
1724
-    			    else return self::check_version(true);
1725
-    			} elseif ($result['value'] == '34') {
1726
-    			    $error = self::update_from_34();
1727
-    			    if ($error != '') return $error;
1728
-    			    else return self::check_version(true);
1729
-    			} elseif ($result['value'] == '35') {
1730
-    			    $error = self::update_from_35();
1731
-    			    if ($error != '') return $error;
1732
-    			    else return self::check_version(true);
1733
-    			} else return '';
1734
-    		    }
1735
-    		    else return $result['value'];
1594
+				}
1595
+				$result = $sth->fetch(PDO::FETCH_ASSOC);
1596
+				if ($update) {
1597
+				if ($result['value'] == '2') {
1598
+					$error = self::update_from_2();
1599
+					if ($error != '') return $error;
1600
+					else return self::check_version(true);
1601
+				} elseif ($result['value'] == '3') {
1602
+					$error = self::update_from_3();
1603
+					if ($error != '') return $error;
1604
+					else return self::check_version(true);
1605
+				} elseif ($result['value'] == '4') {
1606
+					$error = self::update_from_4();
1607
+					if ($error != '') return $error;
1608
+					else return self::check_version(true);
1609
+				} elseif ($result['value'] == '5') {
1610
+					$error = self::update_from_5();
1611
+					if ($error != '') return $error;
1612
+					else return self::check_version(true);
1613
+				} elseif ($result['value'] == '6') {
1614
+					$error = self::update_from_6();
1615
+					if ($error != '') return $error;
1616
+					else return self::check_version(true);
1617
+				} elseif ($result['value'] == '7') {
1618
+					$error = self::update_from_7();
1619
+					if ($error != '') return $error;
1620
+					else return self::check_version(true);
1621
+				} elseif ($result['value'] == '8') {
1622
+					$error = self::update_from_8();
1623
+					if ($error != '') return $error;
1624
+					else return self::check_version(true);
1625
+				} elseif ($result['value'] == '9') {
1626
+					$error = self::update_from_9();
1627
+					if ($error != '') return $error;
1628
+					else return self::check_version(true);
1629
+				} elseif ($result['value'] == '10') {
1630
+					$error = self::update_from_10();
1631
+					if ($error != '') return $error;
1632
+					else return self::check_version(true);
1633
+				} elseif ($result['value'] == '11') {
1634
+					$error = self::update_from_11();
1635
+					if ($error != '') return $error;
1636
+					else return self::check_version(true);
1637
+				} elseif ($result['value'] == '12') {
1638
+					$error = self::update_from_12();
1639
+					if ($error != '') return $error;
1640
+					else return self::check_version(true);
1641
+				} elseif ($result['value'] == '13') {
1642
+					$error = self::update_from_13();
1643
+					if ($error != '') return $error;
1644
+					else return self::check_version(true);
1645
+				} elseif ($result['value'] == '14') {
1646
+					$error = self::update_from_14();
1647
+					if ($error != '') return $error;
1648
+					else return self::check_version(true);
1649
+				} elseif ($result['value'] == '15') {
1650
+					$error = self::update_from_15();
1651
+					if ($error != '') return $error;
1652
+					else return self::check_version(true);
1653
+				} elseif ($result['value'] == '16') {
1654
+					$error = self::update_from_16();
1655
+					if ($error != '') return $error;
1656
+					else return self::check_version(true);
1657
+				} elseif ($result['value'] == '17') {
1658
+					$error = self::update_from_17();
1659
+					if ($error != '') return $error;
1660
+					else return self::check_version(true);
1661
+				} elseif ($result['value'] == '18') {
1662
+					$error = self::update_from_18();
1663
+					if ($error != '') return $error;
1664
+					else return self::check_version(true);
1665
+				} elseif ($result['value'] == '19') {
1666
+					$error = self::update_from_19();
1667
+					if ($error != '') return $error;
1668
+					else return self::check_version(true);
1669
+				} elseif ($result['value'] == '20') {
1670
+					$error = self::update_from_20();
1671
+					if ($error != '') return $error;
1672
+					else return self::check_version(true);
1673
+				} elseif ($result['value'] == '21') {
1674
+					$error = self::update_from_21();
1675
+					if ($error != '') return $error;
1676
+					else return self::check_version(true);
1677
+				} elseif ($result['value'] == '22') {
1678
+					$error = self::update_from_22();
1679
+					if ($error != '') return $error;
1680
+					else return self::check_version(true);
1681
+				} elseif ($result['value'] == '23') {
1682
+					$error = self::update_from_23();
1683
+					if ($error != '') return $error;
1684
+					else return self::check_version(true);
1685
+				} elseif ($result['value'] == '24') {
1686
+					$error = self::update_from_24();
1687
+					if ($error != '') return $error;
1688
+					else return self::check_version(true);
1689
+				} elseif ($result['value'] == '25') {
1690
+					$error = self::update_from_25();
1691
+					if ($error != '') return $error;
1692
+					else return self::check_version(true);
1693
+				} elseif ($result['value'] == '26') {
1694
+					$error = self::update_from_26();
1695
+					if ($error != '') return $error;
1696
+					else return self::check_version(true);
1697
+				} elseif ($result['value'] == '27') {
1698
+					$error = self::update_from_27();
1699
+					if ($error != '') return $error;
1700
+					else return self::check_version(true);
1701
+				} elseif ($result['value'] == '28') {
1702
+					$error = self::update_from_28();
1703
+					if ($error != '') return $error;
1704
+					else return self::check_version(true);
1705
+				} elseif ($result['value'] == '29') {
1706
+					$error = self::update_from_29();
1707
+					if ($error != '') return $error;
1708
+					else return self::check_version(true);
1709
+				} elseif ($result['value'] == '30') {
1710
+					$error = self::update_from_30();
1711
+					if ($error != '') return $error;
1712
+					else return self::check_version(true);
1713
+				} elseif ($result['value'] == '31') {
1714
+					$error = self::update_from_31();
1715
+					if ($error != '') return $error;
1716
+					else return self::check_version(true);
1717
+				} elseif ($result['value'] == '32') {
1718
+					$error = self::update_from_32();
1719
+					if ($error != '') return $error;
1720
+					else return self::check_version(true);
1721
+				} elseif ($result['value'] == '33') {
1722
+					$error = self::update_from_33();
1723
+					if ($error != '') return $error;
1724
+					else return self::check_version(true);
1725
+				} elseif ($result['value'] == '34') {
1726
+					$error = self::update_from_34();
1727
+					if ($error != '') return $error;
1728
+					else return self::check_version(true);
1729
+				} elseif ($result['value'] == '35') {
1730
+					$error = self::update_from_35();
1731
+					if ($error != '') return $error;
1732
+					else return self::check_version(true);
1733
+				} else return '';
1734
+				}
1735
+				else return $result['value'];
1736 1736
 		}
1737 1737
 		
1738
-	    } else return $version;
1739
-    	}
1738
+		} else return $version;
1739
+		}
1740 1740
     	
1741 1741
 }
1742 1742
 //echo update_schema::check_version();
Please login to merge, or discard this patch.
Spacing   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
             try {
15 15
             	$sth = $Connection->db->prepare($query);
16 16
 		$sth->execute();
17
-    	    } catch(PDOException $e) {
17
+    	    } catch (PDOException $e) {
18 18
 		return "error : ".$e->getMessage()."\n";
19 19
     	    }
20 20
     	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
21
-    		$Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']);
21
+    		$Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']);
22 22
     	    }
23 23
 	
24 24
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         	try {
51 51
             	    $sth = $Connection->db->prepare($query);
52 52
 		    $sth->execute();
53
-    		} catch(PDOException $e) {
53
+    		} catch (PDOException $e) {
54 54
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
55 55
     		}
56 56
     		// Copy schedules data to routes table
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         	try {
61 61
             	    $sth = $Connection->db->prepare($query);
62 62
 		    $sth->execute();
63
-    		} catch(PDOException $e) {
63
+    		} catch (PDOException $e) {
64 64
 		    return "error (delete schedule table) : ".$e->getMessage()."\n";
65 65
     		}
66 66
     		// Add source column
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     		try {
69 69
             	    $sth = $Connection->db->prepare($query);
70 70
 		    $sth->execute();
71
-    		} catch(PDOException $e) {
71
+    		} catch (PDOException $e) {
72 72
 		    return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n";
73 73
     		}
74 74
 		// Delete unused column
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     		try {
77 77
             	    $sth = $Connection->db->prepare($query);
78 78
 		    $sth->execute();
79
-    		} catch(PDOException $e) {
79
+    		} catch (PDOException $e) {
80 80
 		    return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n";
81 81
     		}
82 82
 		// Add ModeS column
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
     		try {
85 85
             	    $sth = $Connection->db->prepare($query);
86 86
 		    $sth->execute();
87
-    		} catch(PDOException $e) {
87
+    		} catch (PDOException $e) {
88 88
 		    return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n";
89 89
     		}
90 90
 		$query = "ALTER TABLE `spotter_live`  ADD `ModeS` VARCHAR(255)";
91 91
     		try {
92 92
             	    $sth = $Connection->db->prepare($query);
93 93
 		    $sth->execute();
94
-    		} catch(PDOException $e) {
94
+    		} catch (PDOException $e) {
95 95
 		    return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n";
96 96
     		}
97 97
     		// Add auto_increment for aircraft_modes
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     		try {
100 100
             	    $sth = $Connection->db->prepare($query);
101 101
 		    $sth->execute();
102
-    		} catch(PDOException $e) {
102
+    		} catch (PDOException $e) {
103 103
 		    return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n";
104 104
     		}
105 105
     		$error = '';
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         	try {
111 111
             	    $sth = $Connection->db->prepare($query);
112 112
 		    $sth->execute();
113
-    		} catch(PDOException $e) {
113
+    		} catch (PDOException $e) {
114 114
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
115 115
     		}
116 116
 		return $error;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         	try {
124 124
             	    $sth = $Connection->db->prepare($query);
125 125
 		    $sth->execute();
126
-    		} catch(PDOException $e) {
126
+    		} catch (PDOException $e) {
127 127
 		    return "error (add new columns to routes table) : ".$e->getMessage()."\n";
128 128
     		}
129 129
     		$error = '';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         	try {
135 135
             	    $sth = $Connection->db->prepare($query);
136 136
 		    $sth->execute();
137
-    		} catch(PDOException $e) {
137
+    		} catch (PDOException $e) {
138 138
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
139 139
     		}
140 140
 		return $error;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         	try {
148 148
             	    $sth = $Connection->db->prepare($query);
149 149
 		    $sth->execute();
150
-    		} catch(PDOException $e) {
150
+    		} catch (PDOException $e) {
151 151
 		    return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n";
152 152
     		}
153 153
     		// Add image_source_website column to spotter_image
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         	try {
156 156
             	    $sth = $Connection->db->prepare($query);
157 157
 		    $sth->execute();
158
-    		} catch(PDOException $e) {
158
+    		} catch (PDOException $e) {
159 159
 		    return "error (add new columns to spotter_image) : ".$e->getMessage()."\n";
160 160
     		}
161 161
     		$error = '';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         	try {
165 165
             	    $sth = $Connection->db->prepare($query);
166 166
 		    $sth->execute();
167
-    		} catch(PDOException $e) {
167
+    		} catch (PDOException $e) {
168 168
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
169 169
     		}
170 170
 		return $error;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         	    try {
183 183
             		$sth = $Connection->db->prepare($query);
184 184
 			$sth->execute();
185
-    		    } catch(PDOException $e) {
185
+    		    } catch (PDOException $e) {
186 186
 			return "error (update schema_version) : ".$e->getMessage()."\n";
187 187
     		    }
188 188
     		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         	try {
197 197
             	    $sth = $Connection->db->prepare($query);
198 198
 		    $sth->execute();
199
-    		} catch(PDOException $e) {
199
+    		} catch (PDOException $e) {
200 200
 		    return "error (add new columns to translation) : ".$e->getMessage()."\n";
201 201
     		}
202 202
     		// Add aircraft_shadow column to aircraft
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         	try {
205 205
             	    $sth = $Connection->db->prepare($query);
206 206
 		    $sth->execute();
207
-    		} catch(PDOException $e) {
207
+    		} catch (PDOException $e) {
208 208
 		    return "error (add new column to aircraft) : ".$e->getMessage()."\n";
209 209
     		}
210 210
     		// Add aircraft_shadow column to spotter_live
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         	try {
213 213
             	    $sth = $Connection->db->prepare($query);
214 214
 		    $sth->execute();
215
-    		} catch(PDOException $e) {
215
+    		} catch (PDOException $e) {
216 216
 		    return "error (add new column to spotter_live) : ".$e->getMessage()."\n";
217 217
     		}
218 218
     		$error = '';
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         	try {
226 226
             	    $sth = $Connection->db->prepare($query);
227 227
 		    $sth->execute();
228
-    		} catch(PDOException $e) {
228
+    		} catch (PDOException $e) {
229 229
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
230 230
     		}
231 231
 		return $error;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
 	private static function update_from_6() {
235 235
     		$Connection = new Connection();
236
-    		if (!$Connection->indexExists('spotter_output','flightaware_id')) {
236
+    		if (!$Connection->indexExists('spotter_output', 'flightaware_id')) {
237 237
     		    $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id);
238 238
 			ALTER TABLE spotter_output ADD INDEX(date);
239 239
 			ALTER TABLE spotter_output ADD INDEX(ident);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         	    try {
251 251
             		$sth = $Connection->db->prepare($query);
252 252
 			$sth->execute();
253
-    		    } catch(PDOException $e) {
253
+    		    } catch (PDOException $e) {
254 254
 			return "error (add some indexes) : ".$e->getMessage()."\n";
255 255
     		    }
256 256
     		}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         	try {
266 266
             	    $sth = $Connection->db->prepare($query);
267 267
 		    $sth->execute();
268
-    		} catch(PDOException $e) {
268
+    		} catch (PDOException $e) {
269 269
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
270 270
     		}
271 271
 		return $error;
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	private static function update_from_7() {
275 275
 		global $globalDBname, $globalDBdriver;
276 276
     		$Connection = new Connection();
277
-    		$query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
277
+    		$query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;
278 278
     			ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;";
279 279
         	try {
280 280
             	    $sth = $Connection->db->prepare($query);
281 281
 		    $sth->execute();
282
-    		} catch(PDOException $e) {
282
+    		} catch (PDOException $e) {
283 283
 		    return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
284 284
     		}
285 285
     		if ($globalDBdriver == 'mysql') {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		    try {
288 288
             		$sth = $Connection->db->prepare($query);
289 289
 			$sth->execute();
290
-    		    } catch(PDOException $e) {
290
+    		    } catch (PDOException $e) {
291 291
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
292 292
     		    }
293 293
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 				DROP TABLE spotter_archive;
300 300
 				RENAME TABLE copy TO spotter_archive;";
301 301
             	    } else {
302
-    			$query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
302
+    			$query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
303 303
             	    }
304 304
                 } else {
305
-    		    $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
305
+    		    $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL";
306 306
                 }
307 307
         	try {
308 308
             	    $sth = $Connection->db->prepare($query);
309 309
 		    $sth->execute();
310
-    		} catch(PDOException $e) {
310
+    		} catch (PDOException $e) {
311 311
 		    return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n";
312 312
     		}
313 313
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         	try {
321 321
             	    $sth = $Connection->db->prepare($query);
322 322
 		    $sth->execute();
323
-    		} catch(PDOException $e) {
323
+    		} catch (PDOException $e) {
324 324
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
325 325
     		}
326 326
 		return $error;
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
         	try {
340 340
             	    $sth = $Connection->db->prepare($query);
341 341
 		    $sth->execute();
342
-    		} catch(PDOException $e) {
342
+    		} catch (PDOException $e) {
343 343
 		    return "error (insert last_update values) : ".$e->getMessage()."\n";
344 344
     		}
345 345
 		$query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'";
346 346
         	try {
347 347
             	    $sth = $Connection->db->prepare($query);
348 348
 		    $sth->execute();
349
-    		} catch(PDOException $e) {
349
+    		} catch (PDOException $e) {
350 350
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
351 351
     		}
352 352
 		return $error;
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 
355 355
 	private static function update_from_9() {
356 356
     		$Connection = new Connection();
357
-    		$query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
357
+    		$query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL;
358 358
     			ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;";
359 359
         	try {
360 360
             	    $sth = $Connection->db->prepare($query);
361 361
 		    $sth->execute();
362
-    		} catch(PDOException $e) {
362
+    		} catch (PDOException $e) {
363 363
 		    return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n";
364 364
     		}
365 365
 		$error = '';
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
         	try {
372 372
             	    $sth = $Connection->db->prepare($query);
373 373
 		    $sth->execute();
374
-    		} catch(PDOException $e) {
374
+    		} catch (PDOException $e) {
375 375
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
376 376
     		}
377 377
 		return $error;
@@ -379,11 +379,11 @@  discard block
 block discarded – undo
379 379
 
380 380
 	private static function update_from_10() {
381 381
     		$Connection = new Connection();
382
-    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
382
+    		$query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL";
383 383
         	try {
384 384
             	    $sth = $Connection->db->prepare($query);
385 385
 		    $sth->execute();
386
-    		} catch(PDOException $e) {
386
+    		} catch (PDOException $e) {
387 387
 		    return "error (add new enum to ATC table) : ".$e->getMessage()."\n";
388 388
     		}
389 389
 		$error = '';
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         	try {
402 402
             	    $sth = $Connection->db->prepare($query);
403 403
 		    $sth->execute();
404
-    		} catch(PDOException $e) {
404
+    		} catch (PDOException $e) {
405 405
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
406 406
     		}
407 407
 		return $error;
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 	private static function update_from_11() {
411 411
 		global $globalDBdriver, $globalDBname;
412 412
     		$Connection = new Connection();
413
-    		$query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
413
+    		$query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)";
414 414
         	try {
415 415
             	    $sth = $Connection->db->prepare($query);
416 416
 		    $sth->execute();
417
-    		} catch(PDOException $e) {
417
+    		} catch (PDOException $e) {
418 418
 		    return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n";
419 419
     		}
420
-    		$query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
420
+    		$query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
421 421
         	try {
422 422
             	    $sth = $Connection->db->prepare($query);
423 423
 		    $sth->execute();
424
-    		} catch(PDOException $e) {
424
+    		} catch (PDOException $e) {
425 425
 		    return "error (format_source column to spotter_live) : ".$e->getMessage()."\n";
426 426
     		}
427 427
     		if ($globalDBdriver == 'mysql') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		    try {
430 430
             		$sth = $Connection->db->prepare($query);
431 431
 			$sth->execute();
432
-    		    } catch(PDOException $e) {
432
+    		    } catch (PDOException $e) {
433 433
 			return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n";
434 434
     		    }
435 435
     		    $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -441,15 +441,15 @@  discard block
 block discarded – undo
441 441
 				DROP TABLE spotter_archive;
442 442
 				RENAME TABLE copy TO spotter_archive;";
443 443
             	    } else {
444
-    			$query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
444
+    			$query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
445 445
             	    }
446 446
                 } else {
447
-    		    $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
447
+    		    $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE";
448 448
                 }
449 449
         	try {
450 450
             	    $sth = $Connection->db->prepare($query);
451 451
 		    $sth->execute();
452
-    		} catch(PDOException $e) {
452
+    		} catch (PDOException $e) {
453 453
 		    return "error (add columns to spotter_archive) : ".$e->getMessage()."\n";
454 454
     		}
455 455
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
         	try {
460 460
             	    $sth = $Connection->db->prepare($query);
461 461
 		    $sth->execute();
462
-    		} catch(PDOException $e) {
462
+    		} catch (PDOException $e) {
463 463
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
464 464
     		}
465 465
 		return $error;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         	try {
488 488
             	    $sth = $Connection->db->prepare($query);
489 489
 		    $sth->execute();
490
-    		} catch(PDOException $e) {
490
+    		} catch (PDOException $e) {
491 491
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
492 492
     		}
493 493
 		return $error;
@@ -495,12 +495,12 @@  discard block
 block discarded – undo
495 495
 
496 496
 	private static function update_from_13() {
497 497
     		$Connection = new Connection();
498
-    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) {
499
-    			$query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
498
+    		if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) {
499
+    			$query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)";
500 500
 			try {
501 501
 				$sth = $Connection->db->prepare($query);
502 502
 				$sth->execute();
503
-	    		} catch(PDOException $e) {
503
+	    		} catch (PDOException $e) {
504 504
 				return "error (update spotter_archive_output) : ".$e->getMessage()."\n";
505 505
     			}
506 506
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         	try {
510 510
             	    $sth = $Connection->db->prepare($query);
511 511
 		    $sth->execute();
512
-    		} catch(PDOException $e) {
512
+    		} catch (PDOException $e) {
513 513
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
514 514
     		}
515 515
 		return $error;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
         	try {
528 528
             	    $sth = $Connection->db->prepare($query);
529 529
 		    $sth->execute();
530
-    		} catch(PDOException $e) {
530
+    		} catch (PDOException $e) {
531 531
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
532 532
     		}
533 533
 		return $error;
@@ -538,11 +538,11 @@  discard block
 block discarded – undo
538 538
     		$Connection = new Connection();
539 539
 		$error = '';
540 540
     		// Add tables
541
-    		$query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
541
+    		$query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP";
542 542
         	try {
543 543
             	    $sth = $Connection->db->prepare($query);
544 544
 		    $sth->execute();
545
-    		} catch(PDOException $e) {
545
+    		} catch (PDOException $e) {
546 546
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 547
     		}
548 548
 		if ($error != '') return $error;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
         	try {
551 551
             	    $sth = $Connection->db->prepare($query);
552 552
 		    $sth->execute();
553
-    		} catch(PDOException $e) {
553
+    		} catch (PDOException $e) {
554 554
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
555 555
     		}
556 556
 		return $error;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
         	try {
572 572
             	    $sth = $Connection->db->prepare($query);
573 573
 		    $sth->execute();
574
-    		} catch(PDOException $e) {
574
+    		} catch (PDOException $e) {
575 575
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
576 576
     		}
577 577
 		return $error;
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         	try {
590 590
             	    $sth = $Connection->db->prepare($query);
591 591
 		    $sth->execute();
592
-    		} catch(PDOException $e) {
592
+    		} catch (PDOException $e) {
593 593
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
594 594
     		}
595 595
 		return $error;
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
     		$Connection = new Connection();
599 599
 		$error = '';
600 600
     		// Modify stats_airport table
601
-    		if (!$Connection->checkColumnName('stats_airport','airport_name')) {
601
+    		if (!$Connection->checkColumnName('stats_airport', 'airport_name')) {
602 602
     			$query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)";
603 603
     	        	try {
604 604
 	            	    $sth = $Connection->db->prepare($query);
605 605
 			    $sth->execute();
606
-    			} catch(PDOException $e) {
606
+    			} catch (PDOException $e) {
607 607
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 608
     			}
609 609
     		}
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
         	try {
613 613
             	    $sth = $Connection->db->prepare($query);
614 614
 		    $sth->execute();
615
-    		} catch(PDOException $e) {
615
+    		} catch (PDOException $e) {
616 616
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
617 617
     		}
618 618
 		return $error;
@@ -629,73 +629,73 @@  discard block
 block discarded – undo
629 629
         	try {
630 630
             	    $sth = $Connection->db->prepare($query);
631 631
 		    $sth->execute();
632
-    		} catch(PDOException $e) {
632
+    		} catch (PDOException $e) {
633 633
 		    return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n";
634 634
     		}
635 635
 		$query = "alter table spotter_archive add spotter_archive_id INT(11)";
636 636
         	try {
637 637
             	    $sth = $Connection->db->prepare($query);
638 638
 		    $sth->execute();
639
-    		} catch(PDOException $e) {
639
+    		} catch (PDOException $e) {
640 640
 		    return "error (add id again on spotter_archive) : ".$e->getMessage()."\n";
641 641
     		}
642
-		if (!$Connection->checkColumnName('spotter_archive','over_country')) {
642
+		if (!$Connection->checkColumnName('spotter_archive', 'over_country')) {
643 643
 			// Add column over_country
644 644
     			$query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
645 645
 			try {
646 646
             			$sth = $Connection->db->prepare($query);
647 647
 				$sth->execute();
648
-			} catch(PDOException $e) {
648
+			} catch (PDOException $e) {
649 649
 				return "error (add over_country) : ".$e->getMessage()."\n";
650 650
 			}
651 651
 		}
652
-		if (!$Connection->checkColumnName('spotter_live','over_country')) {
652
+		if (!$Connection->checkColumnName('spotter_live', 'over_country')) {
653 653
 			// Add column over_country
654 654
     			$query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL";
655 655
 			try {
656 656
             			$sth = $Connection->db->prepare($query);
657 657
 				$sth->execute();
658
-			} catch(PDOException $e) {
658
+			} catch (PDOException $e) {
659 659
 				return "error (add over_country) : ".$e->getMessage()."\n";
660 660
 			}
661 661
 		}
662
-		if (!$Connection->checkColumnName('spotter_output','source_name')) {
662
+		if (!$Connection->checkColumnName('spotter_output', 'source_name')) {
663 663
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
664 664
     			$query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
665 665
 			try {
666 666
 				$sth = $Connection->db->prepare($query);
667 667
 				$sth->execute();
668
-			} catch(PDOException $e) {
668
+			} catch (PDOException $e) {
669 669
 				return "error (add source_name column) : ".$e->getMessage()."\n";
670 670
     			}
671 671
     		}
672
-		if (!$Connection->checkColumnName('spotter_live','source_name')) {
672
+		if (!$Connection->checkColumnName('spotter_live', 'source_name')) {
673 673
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
674 674
     			$query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
675 675
 			try {
676 676
 				$sth = $Connection->db->prepare($query);
677 677
 				$sth->execute();
678
-			} catch(PDOException $e) {
678
+			} catch (PDOException $e) {
679 679
 				return "error (add source_name column) : ".$e->getMessage()."\n";
680 680
     			}
681 681
     		}
682
-		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) {
682
+		if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) {
683 683
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
684 684
     			$query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`";
685 685
 			try {
686 686
 				$sth = $Connection->db->prepare($query);
687 687
 				$sth->execute();
688
-			} catch(PDOException $e) {
688
+			} catch (PDOException $e) {
689 689
 				return "error (add source_name column) : ".$e->getMessage()."\n";
690 690
     			}
691 691
     		}
692
-		if (!$Connection->checkColumnName('spotter_archive','source_name')) {
692
+		if (!$Connection->checkColumnName('spotter_archive', 'source_name')) {
693 693
 			// Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output
694 694
     			$query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;";
695 695
 			try {
696 696
 				$sth = $Connection->db->prepare($query);
697 697
 				$sth->execute();
698
-			} catch(PDOException $e) {
698
+			} catch (PDOException $e) {
699 699
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 700
     			}
701 701
     		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
         	try {
705 705
             	    $sth = $Connection->db->prepare($query);
706 706
 		    $sth->execute();
707
-    		} catch(PDOException $e) {
707
+    		} catch (PDOException $e) {
708 708
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
709 709
     		}
710 710
 		return $error;
@@ -719,13 +719,13 @@  discard block
 block discarded – undo
719 719
 			$error .= create_db::import_file('../db/airlines.sql');
720 720
 			if ($error != '') return 'Import airlines.sql : '.$error;
721 721
 		}
722
-		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
722
+		if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) {
723 723
 			// Add column over_country
724 724
     			$query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;";
725 725
         		try {
726 726
 				$sth = $Connection->db->prepare($query);
727 727
 				$sth->execute();
728
-			} catch(PDOException $e) {
728
+			} catch (PDOException $e) {
729 729
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 730
     			}
731 731
     		}
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
         	try {
742 742
             	    $sth = $Connection->db->prepare($query);
743 743
 		    $sth->execute();
744
-    		} catch(PDOException $e) {
744
+    		} catch (PDOException $e) {
745 745
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
746 746
     		}
747 747
 		return $error;
@@ -750,13 +750,13 @@  discard block
 block discarded – undo
750 750
 	private static function update_from_21() {
751 751
 		$Connection = new Connection();
752 752
 		$error = '';
753
-		if (!$Connection->checkColumnName('stats_airport','stats_type')) {
753
+		if (!$Connection->checkColumnName('stats_airport', 'stats_type')) {
754 754
 			// Rename type to stats_type
755 755
 			$query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);";
756 756
 			try {
757 757
 				$sth = $Connection->db->prepare($query);
758 758
 				$sth->execute();
759
-			} catch(PDOException $e) {
759
+			} catch (PDOException $e) {
760 760
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 761
 			}
762 762
 			if ($error != '') return $error;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
         	try {
766 766
             	    $sth = $Connection->db->prepare($query);
767 767
 		    $sth->execute();
768
-    		} catch(PDOException $e) {
768
+    		} catch (PDOException $e) {
769 769
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
770 770
     		}
771 771
 		return $error;
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
         	try {
789 789
             	    $sth = $Connection->db->prepare($query);
790 790
 		    $sth->execute();
791
-    		} catch(PDOException $e) {
791
+    		} catch (PDOException $e) {
792 792
 		    return "error (update schema_version) : ".$e->getMessage()."\n";
793 793
     		}
794 794
 		return $error;
@@ -815,17 +815,17 @@  discard block
 block discarded – undo
815 815
 			try {
816 816
 				$sth = $Connection->db->prepare($query);
817 817
 				$sth->execute();
818
-			} catch(PDOException $e) {
818
+			} catch (PDOException $e) {
819 819
 				return "error (create index on spotter_archive) : ".$e->getMessage()."\n";
820 820
 			}
821 821
 		}
822
-		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) {
822
+		if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) {
823 823
 			// Add aircraft_manufacturer to stats_aircraft
824 824
     			$query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL";
825 825
 			try {
826 826
 				$sth = $Connection->db->prepare($query);
827 827
 				$sth->execute();
828
-			} catch(PDOException $e) {
828
+			} catch (PDOException $e) {
829 829
 				return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n";
830 830
     			}
831 831
     		}
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 		try {
835 835
 			$sth = $Connection->db->prepare($query);
836 836
 			$sth->execute();
837
-		} catch(PDOException $e) {
837
+		} catch (PDOException $e) {
838 838
 			return "error (update schema_version) : ".$e->getMessage()."\n";
839 839
 		}
840 840
 		return $error;
@@ -850,23 +850,23 @@  discard block
 block discarded – undo
850 850
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 851
 		}
852 852
 		if ($error != '') return 'Import airlines.sql : '.$error;
853
-		if (!$Connection->checkColumnName('airlines','forsource')) {
853
+		if (!$Connection->checkColumnName('airlines', 'forsource')) {
854 854
 			// Add forsource to airlines
855 855
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
856 856
 			try {
857 857
 				$sth = $Connection->db->prepare($query);
858 858
 				$sth->execute();
859
-			} catch(PDOException $e) {
859
+			} catch (PDOException $e) {
860 860
 				return "error (add forsource column) : ".$e->getMessage()."\n";
861 861
 			}
862 862
 		}
863
-		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) {
863
+		if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) {
864 864
 			// Add forsource to airlines
865 865
 			$query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
866 866
 			try {
867 867
 				$sth = $Connection->db->prepare($query);
868 868
 				$sth->execute();
869
-			} catch(PDOException $e) {
869
+			} catch (PDOException $e) {
870 870
 				return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n";
871 871
 			}
872 872
 			// Add unique key
@@ -878,17 +878,17 @@  discard block
 block discarded – undo
878 878
 			try {
879 879
 				$sth = $Connection->db->prepare($query);
880 880
 				$sth->execute();
881
-			} catch(PDOException $e) {
881
+			} catch (PDOException $e) {
882 882
 				return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n";
883 883
 			}
884 884
 		}
885
-		if (!$Connection->checkColumnName('stats_airport','stats_airline')) {
885
+		if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) {
886 886
 			// Add forsource to airlines
887 887
 			$query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
888 888
 			try {
889 889
 				$sth = $Connection->db->prepare($query);
890 890
 				$sth->execute();
891
-			} catch(PDOException $e) {
891
+			} catch (PDOException $e) {
892 892
 				return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n";
893 893
 			}
894 894
 			// Add unique key
@@ -900,17 +900,17 @@  discard block
 block discarded – undo
900 900
 			try {
901 901
 				$sth = $Connection->db->prepare($query);
902 902
 				$sth->execute();
903
-			} catch(PDOException $e) {
903
+			} catch (PDOException $e) {
904 904
 				return "error (add unique key in stats_airport) : ".$e->getMessage()."\n";
905 905
 			}
906 906
 		}
907
-		if (!$Connection->checkColumnName('stats_country','stats_airline')) {
907
+		if (!$Connection->checkColumnName('stats_country', 'stats_airline')) {
908 908
 			// Add forsource to airlines
909 909
 			$query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
910 910
 			try {
911 911
 				$sth = $Connection->db->prepare($query);
912 912
 				$sth->execute();
913
-			} catch(PDOException $e) {
913
+			} catch (PDOException $e) {
914 914
 				return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n";
915 915
 			}
916 916
 			// Add unique key
@@ -922,36 +922,36 @@  discard block
 block discarded – undo
922 922
 			try {
923 923
 				$sth = $Connection->db->prepare($query);
924 924
 				$sth->execute();
925
-			} catch(PDOException $e) {
925
+			} catch (PDOException $e) {
926 926
 				return "error (add unique key in stats_airline) : ".$e->getMessage()."\n";
927 927
 			}
928 928
 		}
929
-		if (!$Connection->checkColumnName('stats_flight','stats_airline')) {
929
+		if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) {
930 930
 			// Add forsource to airlines
931 931
 			$query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
932 932
 			try {
933 933
 				$sth = $Connection->db->prepare($query);
934 934
 				$sth->execute();
935
-			} catch(PDOException $e) {
935
+			} catch (PDOException $e) {
936 936
 				return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n";
937 937
 			}
938 938
 		}
939
-		if (!$Connection->checkColumnName('stats','stats_airline')) {
939
+		if (!$Connection->checkColumnName('stats', 'stats_airline')) {
940 940
 			// Add forsource to airlines
941 941
 			$query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
942 942
 			try {
943 943
 				$sth = $Connection->db->prepare($query);
944 944
 				$sth->execute();
945
-			} catch(PDOException $e) {
945
+			} catch (PDOException $e) {
946 946
 				return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n";
947 947
 			}
948
-			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) {
948
+			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) {
949 949
 				// Add unique key
950 950
 				$query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);";
951 951
 				try {
952 952
 					$sth = $Connection->db->prepare($query);
953 953
 					$sth->execute();
954
-				} catch(PDOException $e) {
954
+				} catch (PDOException $e) {
955 955
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
956 956
 				}
957 957
 			} else {
@@ -964,18 +964,18 @@  discard block
 block discarded – undo
964 964
 				try {
965 965
 					$sth = $Connection->db->prepare($query);
966 966
 					$sth->execute();
967
-				} catch(PDOException $e) {
967
+				} catch (PDOException $e) {
968 968
 					return "error (add unique key in stats) : ".$e->getMessage()."\n";
969 969
 				}
970 970
 			}
971 971
 		}
972
-		if (!$Connection->checkColumnName('stats_registration','stats_airline')) {
972
+		if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) {
973 973
 			// Add forsource to airlines
974 974
 			$query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
975 975
 			try {
976 976
 				$sth = $Connection->db->prepare($query);
977 977
 				$sth->execute();
978
-			} catch(PDOException $e) {
978
+			} catch (PDOException $e) {
979 979
 				return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n";
980 980
 			}
981 981
 			// Add unique key
@@ -987,17 +987,17 @@  discard block
 block discarded – undo
987 987
 			try {
988 988
 				$sth = $Connection->db->prepare($query);
989 989
 				$sth->execute();
990
-			} catch(PDOException $e) {
990
+			} catch (PDOException $e) {
991 991
 				return "error (add unique key in stats_registration) : ".$e->getMessage()."\n";
992 992
 			}
993 993
 		}
994
-		if (!$Connection->checkColumnName('stats_callsign','filter_name')) {
994
+		if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) {
995 995
 			// Add forsource to airlines
996 996
 			$query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''";
997 997
 			try {
998 998
 				$sth = $Connection->db->prepare($query);
999 999
 				$sth->execute();
1000
-			} catch(PDOException $e) {
1000
+			} catch (PDOException $e) {
1001 1001
 				return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n";
1002 1002
 			}
1003 1003
 			// Add unique key
@@ -1009,17 +1009,17 @@  discard block
 block discarded – undo
1009 1009
 			try {
1010 1010
 				$sth = $Connection->db->prepare($query);
1011 1011
 				$sth->execute();
1012
-			} catch(PDOException $e) {
1012
+			} catch (PDOException $e) {
1013 1013
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1014 1014
 			}
1015 1015
 		}
1016
-		if (!$Connection->checkColumnName('stats_airline','filter_name')) {
1016
+		if (!$Connection->checkColumnName('stats_airline', 'filter_name')) {
1017 1017
 			// Add forsource to airlines
1018 1018
 			$query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1019 1019
 			try {
1020 1020
 				$sth = $Connection->db->prepare($query);
1021 1021
 				$sth->execute();
1022
-			} catch(PDOException $e) {
1022
+			} catch (PDOException $e) {
1023 1023
 				return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n";
1024 1024
 			}
1025 1025
 			// Add unique key
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 			try {
1032 1032
 				$sth = $Connection->db->prepare($query);
1033 1033
 				$sth->execute();
1034
-			} catch(PDOException $e) {
1034
+			} catch (PDOException $e) {
1035 1035
 				return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n";
1036 1036
 			}
1037 1037
 		}
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 		try {
1041 1041
 			$sth = $Connection->db->prepare($query);
1042 1042
 			$sth->execute();
1043
-		} catch(PDOException $e) {
1043
+		} catch (PDOException $e) {
1044 1044
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1045 1045
 		}
1046 1046
 		return $error;
@@ -1050,13 +1050,13 @@  discard block
 block discarded – undo
1050 1050
 		global $globalDBdriver;
1051 1051
 		$Connection = new Connection();
1052 1052
 		$error = '';
1053
-		if (!$Connection->checkColumnName('stats_owner','stats_airline')) {
1053
+		if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) {
1054 1054
 			// Add forsource to airlines
1055 1055
 			$query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1056 1056
 			try {
1057 1057
 				$sth = $Connection->db->prepare($query);
1058 1058
 				$sth->execute();
1059
-			} catch(PDOException $e) {
1059
+			} catch (PDOException $e) {
1060 1060
 				return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n";
1061 1061
 			}
1062 1062
 			// Add unique key
@@ -1068,17 +1068,17 @@  discard block
 block discarded – undo
1068 1068
 			try {
1069 1069
 				$sth = $Connection->db->prepare($query);
1070 1070
 				$sth->execute();
1071
-			} catch(PDOException $e) {
1071
+			} catch (PDOException $e) {
1072 1072
 				return "error (add unique key in stats_owner) : ".$e->getMessage()."\n";
1073 1073
 			}
1074 1074
 		}
1075
-		if (!$Connection->checkColumnName('stats_pilot','stats_airline')) {
1075
+		if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) {
1076 1076
 			// Add forsource to airlines
1077 1077
 			$query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''";
1078 1078
 			try {
1079 1079
 				$sth = $Connection->db->prepare($query);
1080 1080
 				$sth->execute();
1081
-			} catch(PDOException $e) {
1081
+			} catch (PDOException $e) {
1082 1082
 				return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n";
1083 1083
 			}
1084 1084
 			// Add unique key
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			try {
1091 1091
 				$sth = $Connection->db->prepare($query);
1092 1092
 				$sth->execute();
1093
-			} catch(PDOException $e) {
1093
+			} catch (PDOException $e) {
1094 1094
 				return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n";
1095 1095
 			}
1096 1096
 		}
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 		try {
1099 1099
 			$sth = $Connection->db->prepare($query);
1100 1100
 			$sth->execute();
1101
-		} catch(PDOException $e) {
1101
+		} catch (PDOException $e) {
1102 1102
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1103 1103
 		}
1104 1104
 		return $error;
@@ -1108,12 +1108,12 @@  discard block
 block discarded – undo
1108 1108
 		global $globalDBdriver;
1109 1109
 		$Connection = new Connection();
1110 1110
 		$error = '';
1111
-		if (!$Connection->checkColumnName('atc','format_source')) {
1111
+		if (!$Connection->checkColumnName('atc', 'format_source')) {
1112 1112
 			$query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL";
1113 1113
 			try {
1114 1114
 				$sth = $Connection->db->prepare($query);
1115 1115
 				$sth->execute();
1116
-			} catch(PDOException $e) {
1116
+			} catch (PDOException $e) {
1117 1117
 				return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n";
1118 1118
 			}
1119 1119
 		}
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 		try {
1122 1122
 			$sth = $Connection->db->prepare($query);
1123 1123
 			$sth->execute();
1124
-		} catch(PDOException $e) {
1124
+		} catch (PDOException $e) {
1125 1125
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1126 1126
 		}
1127 1127
 		return $error;
@@ -1131,13 +1131,13 @@  discard block
 block discarded – undo
1131 1131
 		global $globalDBdriver;
1132 1132
 		$Connection = new Connection();
1133 1133
 		$error = '';
1134
-		if (!$Connection->checkColumnName('stats_pilot','format_source')) {
1134
+		if (!$Connection->checkColumnName('stats_pilot', 'format_source')) {
1135 1135
 			// Add forsource to airlines
1136 1136
 			$query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''";
1137 1137
 			try {
1138 1138
 				$sth = $Connection->db->prepare($query);
1139 1139
 				$sth->execute();
1140
-			} catch(PDOException $e) {
1140
+			} catch (PDOException $e) {
1141 1141
 				return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n";
1142 1142
 			}
1143 1143
 			// Add unique key
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 			try {
1150 1150
 				$sth = $Connection->db->prepare($query);
1151 1151
 				$sth->execute();
1152
-			} catch(PDOException $e) {
1152
+			} catch (PDOException $e) {
1153 1153
 				return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n";
1154 1154
 			}
1155 1155
 		}
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 		try {
1158 1158
 			$sth = $Connection->db->prepare($query);
1159 1159
 			$sth->execute();
1160
-		} catch(PDOException $e) {
1160
+		} catch (PDOException $e) {
1161 1161
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1162 1162
 		}
1163 1163
 		return $error;
@@ -1167,23 +1167,23 @@  discard block
 block discarded – undo
1167 1167
 		global $globalDBdriver;
1168 1168
 		$Connection = new Connection();
1169 1169
 		$error = '';
1170
-		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) {
1170
+		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) {
1171 1171
 			// Add unique key
1172 1172
 			$query = "alter table spotter_live add index(latitude,longitude)";
1173 1173
 			try {
1174 1174
 				$sth = $Connection->db->prepare($query);
1175 1175
 				$sth->execute();
1176
-			} catch(PDOException $e) {
1176
+			} catch (PDOException $e) {
1177 1177
 				return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n";
1178 1178
 			}
1179 1179
                 }
1180
-		if (!$Connection->checkColumnName('aircraft','mfr')) {
1180
+		if (!$Connection->checkColumnName('aircraft', 'mfr')) {
1181 1181
 			// Add mfr to aircraft
1182 1182
 			$query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL";
1183 1183
 			try {
1184 1184
 				$sth = $Connection->db->prepare($query);
1185 1185
 				$sth->execute();
1186
-			} catch(PDOException $e) {
1186
+			} catch (PDOException $e) {
1187 1187
 				return "error (add mfr column in aircraft) : ".$e->getMessage()."\n";
1188 1188
 			}
1189 1189
 		}
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 		try {
1200 1200
 			$sth = $Connection->db->prepare($query);
1201 1201
 			$sth->execute();
1202
-		} catch(PDOException $e) {
1202
+		} catch (PDOException $e) {
1203 1203
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1204 1204
 		}
1205 1205
 		return $error;
@@ -1209,13 +1209,13 @@  discard block
 block discarded – undo
1209 1209
 		global $globalDBdriver;
1210 1210
 		$Connection = new Connection();
1211 1211
 		$error = '';
1212
-		if ($Connection->checkColumnName('aircraft','mfr')) {
1212
+		if ($Connection->checkColumnName('aircraft', 'mfr')) {
1213 1213
 			// drop mfr to aircraft
1214 1214
 			$query = "ALTER TABLE aircraft DROP COLUMN mfr";
1215 1215
 			try {
1216 1216
 				$sth = $Connection->db->prepare($query);
1217 1217
 				$sth->execute();
1218
-			} catch(PDOException $e) {
1218
+			} catch (PDOException $e) {
1219 1219
 				return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n";
1220 1220
 			}
1221 1221
 		}
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 		try {
1232 1232
 			$sth = $Connection->db->prepare($query);
1233 1233
 			$sth->execute();
1234
-		} catch(PDOException $e) {
1234
+		} catch (PDOException $e) {
1235 1235
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1236 1236
 		}
1237 1237
 		return $error;
@@ -1241,33 +1241,33 @@  discard block
 block discarded – undo
1241 1241
 		global $globalDBdriver;
1242 1242
 		$Connection = new Connection();
1243 1243
 		$error = '';
1244
-		if (!$Connection->indexExists('notam','ref_idx')) {
1244
+		if (!$Connection->indexExists('notam', 'ref_idx')) {
1245 1245
 			// Add index key
1246 1246
 			$query = "create index ref_idx on notam (ref)";
1247 1247
 			try {
1248 1248
 				$sth = $Connection->db->prepare($query);
1249 1249
 				$sth->execute();
1250
-			} catch(PDOException $e) {
1250
+			} catch (PDOException $e) {
1251 1251
 				return "error (add index ref on notam) : ".$e->getMessage()."\n";
1252 1252
 			}
1253 1253
                 }
1254
-		if (!$Connection->indexExists('accidents','registration_idx')) {
1254
+		if (!$Connection->indexExists('accidents', 'registration_idx')) {
1255 1255
 			// Add index key
1256 1256
 			$query = "create index registration_idx on accidents (registration)";
1257 1257
 			try {
1258 1258
 				$sth = $Connection->db->prepare($query);
1259 1259
 				$sth->execute();
1260
-			} catch(PDOException $e) {
1260
+			} catch (PDOException $e) {
1261 1261
 				return "error (add index registration on accidents) : ".$e->getMessage()."\n";
1262 1262
 			}
1263 1263
                 }
1264
-		if (!$Connection->indexExists('accidents','rdts')) {
1264
+		if (!$Connection->indexExists('accidents', 'rdts')) {
1265 1265
 			// Add index key
1266 1266
 			$query = "create index rdts on accidents (registration,date,type,source)";
1267 1267
 			try {
1268 1268
 				$sth = $Connection->db->prepare($query);
1269 1269
 				$sth->execute();
1270
-			} catch(PDOException $e) {
1270
+			} catch (PDOException $e) {
1271 1271
 				return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n";
1272 1272
 			}
1273 1273
                 }
@@ -1276,7 +1276,7 @@  discard block
 block discarded – undo
1276 1276
 		try {
1277 1277
 			$sth = $Connection->db->prepare($query);
1278 1278
 			$sth->execute();
1279
-		} catch(PDOException $e) {
1279
+		} catch (PDOException $e) {
1280 1280
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1281 1281
 		}
1282 1282
 		return $error;
@@ -1286,23 +1286,23 @@  discard block
 block discarded – undo
1286 1286
 		global $globalDBdriver;
1287 1287
 		$Connection = new Connection();
1288 1288
 		$error = '';
1289
-		if (!$Connection->checkColumnName('accidents','airline_name')) {
1289
+		if (!$Connection->checkColumnName('accidents', 'airline_name')) {
1290 1290
 			// Add airline_name to accidents
1291 1291
 			$query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL";
1292 1292
 			try {
1293 1293
 				$sth = $Connection->db->prepare($query);
1294 1294
 				$sth->execute();
1295
-			} catch(PDOException $e) {
1295
+			} catch (PDOException $e) {
1296 1296
 				return "error (add airline_name column in accidents) : ".$e->getMessage()."\n";
1297 1297
 			}
1298 1298
 		}
1299
-		if (!$Connection->checkColumnName('accidents','airline_icao')) {
1299
+		if (!$Connection->checkColumnName('accidents', 'airline_icao')) {
1300 1300
 			// Add airline_icao to accidents
1301 1301
 			$query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL";
1302 1302
 			try {
1303 1303
 				$sth = $Connection->db->prepare($query);
1304 1304
 				$sth->execute();
1305
-			} catch(PDOException $e) {
1305
+			} catch (PDOException $e) {
1306 1306
 				return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n";
1307 1307
 			}
1308 1308
 		}
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 		try {
1311 1311
 			$sth = $Connection->db->prepare($query);
1312 1312
 			$sth->execute();
1313
-		} catch(PDOException $e) {
1313
+		} catch (PDOException $e) {
1314 1314
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1315 1315
 		}
1316 1316
 		return $error;
@@ -1320,13 +1320,13 @@  discard block
 block discarded – undo
1320 1320
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1321 1321
 		$Connection = new Connection();
1322 1322
 		$error = '';
1323
-		if (!$Connection->checkColumnName('airlines','alliance')) {
1323
+		if (!$Connection->checkColumnName('airlines', 'alliance')) {
1324 1324
 			// Add alliance to airlines
1325 1325
 			$query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL";
1326 1326
 			try {
1327 1327
 				$sth = $Connection->db->prepare($query);
1328 1328
 				$sth->execute();
1329
-			} catch(PDOException $e) {
1329
+			} catch (PDOException $e) {
1330 1330
 				return "error (add alliance column in airlines) : ".$e->getMessage()."\n";
1331 1331
 			}
1332 1332
 		}
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
 		try {
1354 1354
 			$sth = $Connection->db->prepare($query);
1355 1355
 			$sth->execute();
1356
-		} catch(PDOException $e) {
1356
+		} catch (PDOException $e) {
1357 1357
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1358 1358
 		}
1359 1359
 		return $error;
@@ -1363,13 +1363,13 @@  discard block
 block discarded – undo
1363 1363
 		global $globalDBdriver, $globalVATSIM, $globalIVAO;
1364 1364
 		$Connection = new Connection();
1365 1365
 		$error = '';
1366
-		if (!$Connection->checkColumnName('airlines','ban_eu')) {
1366
+		if (!$Connection->checkColumnName('airlines', 'ban_eu')) {
1367 1367
 			// Add ban_eu to airlines
1368 1368
 			$query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'";
1369 1369
 			try {
1370 1370
 				$sth = $Connection->db->prepare($query);
1371 1371
 				$sth->execute();
1372
-			} catch(PDOException $e) {
1372
+			} catch (PDOException $e) {
1373 1373
 				return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n";
1374 1374
 			}
1375 1375
 		}
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 		try {
1378 1378
 			$sth = $Connection->db->prepare($query);
1379 1379
 			$sth->execute();
1380
-		} catch(PDOException $e) {
1380
+		} catch (PDOException $e) {
1381 1381
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1382 1382
 		}
1383 1383
 		return $error;
@@ -1388,19 +1388,19 @@  discard block
 block discarded – undo
1388 1388
 		$Connection = new Connection();
1389 1389
 		$error = '';
1390 1390
 		if ($globalDBdriver == 'mysql') {
1391
-			if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') {
1391
+			if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') {
1392 1392
 				$query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL";
1393 1393
 				try {
1394 1394
 					$sth = $Connection->db->prepare($query);
1395 1395
 					$sth->execute();
1396
-				} catch(PDOException $e) {
1396
+				} catch (PDOException $e) {
1397 1397
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1398 1398
 				}
1399 1399
 				$query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()";
1400 1400
 				try {
1401 1401
 					$sth = $Connection->db->prepare($query);
1402 1402
 					$sth->execute();
1403
-				} catch(PDOException $e) {
1403
+				} catch (PDOException $e) {
1404 1404
 					return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n";
1405 1405
 				}
1406 1406
 				
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
 				try {
1409 1409
 					$sth = $Connection->db->prepare($query);
1410 1410
 					$sth->execute();
1411
-				} catch(PDOException $e) {
1411
+				} catch (PDOException $e) {
1412 1412
 					return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n";
1413 1413
 				}
1414 1414
 				/*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150";
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
 				try {
1460 1460
 					$sth = $Connection->db->prepare($query);
1461 1461
 					$sth->execute();
1462
-				} catch(PDOException $e) {
1462
+				} catch (PDOException $e) {
1463 1463
 					return "error (fix date) : ".$e->getMessage()."\n";
1464 1464
 				}
1465 1465
 			}
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
 		try {
1545 1545
 			$sth = $Connection->db->prepare($query);
1546 1546
 			$sth->execute();
1547
-		} catch(PDOException $e) {
1547
+		} catch (PDOException $e) {
1548 1548
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1549 1549
 		}
1550 1550
 		return $error;
@@ -1553,13 +1553,13 @@  discard block
 block discarded – undo
1553 1553
 		global $globalDBdriver;
1554 1554
 		$Connection = new Connection();
1555 1555
 		$error = '';
1556
-		if (!$Connection->indexExists('accidents','type')) {
1556
+		if (!$Connection->indexExists('accidents', 'type')) {
1557 1557
 			// Add index key
1558 1558
 			$query = "create index type on accidents (type,date)";
1559 1559
 			try {
1560 1560
 				$sth = $Connection->db->prepare($query);
1561 1561
 				$sth->execute();
1562
-			} catch(PDOException $e) {
1562
+			} catch (PDOException $e) {
1563 1563
 				return "error (add index type on accidents) : ".$e->getMessage()."\n";
1564 1564
 			}
1565 1565
                 }
@@ -1567,7 +1567,7 @@  discard block
 block discarded – undo
1567 1567
 		try {
1568 1568
 			$sth = $Connection->db->prepare($query);
1569 1569
 			$sth->execute();
1570
-		} catch(PDOException $e) {
1570
+		} catch (PDOException $e) {
1571 1571
 			return "error (update schema_version) : ".$e->getMessage()."\n";
1572 1572
 		}
1573 1573
 		return $error;
@@ -1589,7 +1589,7 @@  discard block
 block discarded – undo
1589 1589
 		    try {
1590 1590
             		$sth = $Connection->db->prepare($query);
1591 1591
 		        $sth->execute();
1592
-		    } catch(PDOException $e) {
1592
+		    } catch (PDOException $e) {
1593 1593
 			return "error : ".$e->getMessage()."\n";
1594 1594
     		    }
1595 1595
     		    $result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Braces   +282 added lines, -106 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1332,20 +1390,28 @@  discard block
 block discarded – undo
1332 1390
 		}
1333 1391
 		if ($globalDBdriver == 'mysql') {
1334 1392
 			$error .= create_db::import_file('../db/airlines.sql');
1335
-			if ($error != '') return $error;
1393
+			if ($error != '') {
1394
+				return $error;
1395
+			}
1336 1396
 		} else {
1337 1397
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1338
-			if ($error != '') return $error;
1398
+			if ($error != '') {
1399
+				return $error;
1400
+			}
1339 1401
 		}
1340 1402
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1341 1403
 			include_once(dirname(__FILE__).'/class.update_db.php');
1342 1404
 			if (isset($globalVATSIM) && $globalVATSIM) {
1343 1405
 				$error .= update_db::update_vatsim();
1344
-				if ($error != '') return $error;
1406
+				if ($error != '') {
1407
+					return $error;
1408
+				}
1345 1409
 			}
1346 1410
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1347 1411
 				$error .= update_db::update_IVAO();
1348
-				if ($error != '') return $error;
1412
+				if ($error != '') {
1413
+					return $error;
1414
+				}
1349 1415
 			}
1350 1416
 		}
1351 1417
 
@@ -1581,8 +1647,11 @@  discard block
 block discarded – undo
1581 1647
     	    if ($Connection->tableExists('aircraft')) {
1582 1648
     		if (!$Connection->tableExists('config')) {
1583 1649
     		    $version = '1';
1584
-    		    if ($update) return self::update_from_1();
1585
-    		    else return $version;
1650
+    		    if ($update) {
1651
+    		    	return self::update_from_1();
1652
+    		    } else {
1653
+    		    	return $version;
1654
+    		    }
1586 1655
 		} else {
1587 1656
     		    $Connection = new Connection();
1588 1657
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1596,146 +1665,253 @@  discard block
 block discarded – undo
1596 1665
     		    if ($update) {
1597 1666
     			if ($result['value'] == '2') {
1598 1667
     			    $error = self::update_from_2();
1599
-    			    if ($error != '') return $error;
1600
-    			    else return self::check_version(true);
1668
+    			    if ($error != '') {
1669
+    			    	return $error;
1670
+    			    } else {
1671
+    			    	return self::check_version(true);
1672
+    			    }
1601 1673
     			} elseif ($result['value'] == '3') {
1602 1674
     			    $error = self::update_from_3();
1603
-    			    if ($error != '') return $error;
1604
-    			    else return self::check_version(true);
1675
+    			    if ($error != '') {
1676
+    			    	return $error;
1677
+    			    } else {
1678
+    			    	return self::check_version(true);
1679
+    			    }
1605 1680
     			} elseif ($result['value'] == '4') {
1606 1681
     			    $error = self::update_from_4();
1607
-    			    if ($error != '') return $error;
1608
-    			    else return self::check_version(true);
1682
+    			    if ($error != '') {
1683
+    			    	return $error;
1684
+    			    } else {
1685
+    			    	return self::check_version(true);
1686
+    			    }
1609 1687
     			} elseif ($result['value'] == '5') {
1610 1688
     			    $error = self::update_from_5();
1611
-    			    if ($error != '') return $error;
1612
-    			    else return self::check_version(true);
1689
+    			    if ($error != '') {
1690
+    			    	return $error;
1691
+    			    } else {
1692
+    			    	return self::check_version(true);
1693
+    			    }
1613 1694
     			} elseif ($result['value'] == '6') {
1614 1695
     			    $error = self::update_from_6();
1615
-    			    if ($error != '') return $error;
1616
-    			    else return self::check_version(true);
1696
+    			    if ($error != '') {
1697
+    			    	return $error;
1698
+    			    } else {
1699
+    			    	return self::check_version(true);
1700
+    			    }
1617 1701
     			} elseif ($result['value'] == '7') {
1618 1702
     			    $error = self::update_from_7();
1619
-    			    if ($error != '') return $error;
1620
-    			    else return self::check_version(true);
1703
+    			    if ($error != '') {
1704
+    			    	return $error;
1705
+    			    } else {
1706
+    			    	return self::check_version(true);
1707
+    			    }
1621 1708
     			} elseif ($result['value'] == '8') {
1622 1709
     			    $error = self::update_from_8();
1623
-    			    if ($error != '') return $error;
1624
-    			    else return self::check_version(true);
1710
+    			    if ($error != '') {
1711
+    			    	return $error;
1712
+    			    } else {
1713
+    			    	return self::check_version(true);
1714
+    			    }
1625 1715
     			} elseif ($result['value'] == '9') {
1626 1716
     			    $error = self::update_from_9();
1627
-    			    if ($error != '') return $error;
1628
-    			    else return self::check_version(true);
1717
+    			    if ($error != '') {
1718
+    			    	return $error;
1719
+    			    } else {
1720
+    			    	return self::check_version(true);
1721
+    			    }
1629 1722
     			} elseif ($result['value'] == '10') {
1630 1723
     			    $error = self::update_from_10();
1631
-    			    if ($error != '') return $error;
1632
-    			    else return self::check_version(true);
1724
+    			    if ($error != '') {
1725
+    			    	return $error;
1726
+    			    } else {
1727
+    			    	return self::check_version(true);
1728
+    			    }
1633 1729
     			} elseif ($result['value'] == '11') {
1634 1730
     			    $error = self::update_from_11();
1635
-    			    if ($error != '') return $error;
1636
-    			    else return self::check_version(true);
1731
+    			    if ($error != '') {
1732
+    			    	return $error;
1733
+    			    } else {
1734
+    			    	return self::check_version(true);
1735
+    			    }
1637 1736
     			} elseif ($result['value'] == '12') {
1638 1737
     			    $error = self::update_from_12();
1639
-    			    if ($error != '') return $error;
1640
-    			    else return self::check_version(true);
1738
+    			    if ($error != '') {
1739
+    			    	return $error;
1740
+    			    } else {
1741
+    			    	return self::check_version(true);
1742
+    			    }
1641 1743
     			} elseif ($result['value'] == '13') {
1642 1744
     			    $error = self::update_from_13();
1643
-    			    if ($error != '') return $error;
1644
-    			    else return self::check_version(true);
1745
+    			    if ($error != '') {
1746
+    			    	return $error;
1747
+    			    } else {
1748
+    			    	return self::check_version(true);
1749
+    			    }
1645 1750
     			} elseif ($result['value'] == '14') {
1646 1751
     			    $error = self::update_from_14();
1647
-    			    if ($error != '') return $error;
1648
-    			    else return self::check_version(true);
1752
+    			    if ($error != '') {
1753
+    			    	return $error;
1754
+    			    } else {
1755
+    			    	return self::check_version(true);
1756
+    			    }
1649 1757
     			} elseif ($result['value'] == '15') {
1650 1758
     			    $error = self::update_from_15();
1651
-    			    if ($error != '') return $error;
1652
-    			    else return self::check_version(true);
1759
+    			    if ($error != '') {
1760
+    			    	return $error;
1761
+    			    } else {
1762
+    			    	return self::check_version(true);
1763
+    			    }
1653 1764
     			} elseif ($result['value'] == '16') {
1654 1765
     			    $error = self::update_from_16();
1655
-    			    if ($error != '') return $error;
1656
-    			    else return self::check_version(true);
1766
+    			    if ($error != '') {
1767
+    			    	return $error;
1768
+    			    } else {
1769
+    			    	return self::check_version(true);
1770
+    			    }
1657 1771
     			} elseif ($result['value'] == '17') {
1658 1772
     			    $error = self::update_from_17();
1659
-    			    if ($error != '') return $error;
1660
-    			    else return self::check_version(true);
1773
+    			    if ($error != '') {
1774
+    			    	return $error;
1775
+    			    } else {
1776
+    			    	return self::check_version(true);
1777
+    			    }
1661 1778
     			} elseif ($result['value'] == '18') {
1662 1779
     			    $error = self::update_from_18();
1663
-    			    if ($error != '') return $error;
1664
-    			    else return self::check_version(true);
1780
+    			    if ($error != '') {
1781
+    			    	return $error;
1782
+    			    } else {
1783
+    			    	return self::check_version(true);
1784
+    			    }
1665 1785
     			} elseif ($result['value'] == '19') {
1666 1786
     			    $error = self::update_from_19();
1667
-    			    if ($error != '') return $error;
1668
-    			    else return self::check_version(true);
1787
+    			    if ($error != '') {
1788
+    			    	return $error;
1789
+    			    } else {
1790
+    			    	return self::check_version(true);
1791
+    			    }
1669 1792
     			} elseif ($result['value'] == '20') {
1670 1793
     			    $error = self::update_from_20();
1671
-    			    if ($error != '') return $error;
1672
-    			    else return self::check_version(true);
1794
+    			    if ($error != '') {
1795
+    			    	return $error;
1796
+    			    } else {
1797
+    			    	return self::check_version(true);
1798
+    			    }
1673 1799
     			} elseif ($result['value'] == '21') {
1674 1800
     			    $error = self::update_from_21();
1675
-    			    if ($error != '') return $error;
1676
-    			    else return self::check_version(true);
1801
+    			    if ($error != '') {
1802
+    			    	return $error;
1803
+    			    } else {
1804
+    			    	return self::check_version(true);
1805
+    			    }
1677 1806
     			} elseif ($result['value'] == '22') {
1678 1807
     			    $error = self::update_from_22();
1679
-    			    if ($error != '') return $error;
1680
-    			    else return self::check_version(true);
1808
+    			    if ($error != '') {
1809
+    			    	return $error;
1810
+    			    } else {
1811
+    			    	return self::check_version(true);
1812
+    			    }
1681 1813
     			} elseif ($result['value'] == '23') {
1682 1814
     			    $error = self::update_from_23();
1683
-    			    if ($error != '') return $error;
1684
-    			    else return self::check_version(true);
1815
+    			    if ($error != '') {
1816
+    			    	return $error;
1817
+    			    } else {
1818
+    			    	return self::check_version(true);
1819
+    			    }
1685 1820
     			} elseif ($result['value'] == '24') {
1686 1821
     			    $error = self::update_from_24();
1687
-    			    if ($error != '') return $error;
1688
-    			    else return self::check_version(true);
1822
+    			    if ($error != '') {
1823
+    			    	return $error;
1824
+    			    } else {
1825
+    			    	return self::check_version(true);
1826
+    			    }
1689 1827
     			} elseif ($result['value'] == '25') {
1690 1828
     			    $error = self::update_from_25();
1691
-    			    if ($error != '') return $error;
1692
-    			    else return self::check_version(true);
1829
+    			    if ($error != '') {
1830
+    			    	return $error;
1831
+    			    } else {
1832
+    			    	return self::check_version(true);
1833
+    			    }
1693 1834
     			} elseif ($result['value'] == '26') {
1694 1835
     			    $error = self::update_from_26();
1695
-    			    if ($error != '') return $error;
1696
-    			    else return self::check_version(true);
1836
+    			    if ($error != '') {
1837
+    			    	return $error;
1838
+    			    } else {
1839
+    			    	return self::check_version(true);
1840
+    			    }
1697 1841
     			} elseif ($result['value'] == '27') {
1698 1842
     			    $error = self::update_from_27();
1699
-    			    if ($error != '') return $error;
1700
-    			    else return self::check_version(true);
1843
+    			    if ($error != '') {
1844
+    			    	return $error;
1845
+    			    } else {
1846
+    			    	return self::check_version(true);
1847
+    			    }
1701 1848
     			} elseif ($result['value'] == '28') {
1702 1849
     			    $error = self::update_from_28();
1703
-    			    if ($error != '') return $error;
1704
-    			    else return self::check_version(true);
1850
+    			    if ($error != '') {
1851
+    			    	return $error;
1852
+    			    } else {
1853
+    			    	return self::check_version(true);
1854
+    			    }
1705 1855
     			} elseif ($result['value'] == '29') {
1706 1856
     			    $error = self::update_from_29();
1707
-    			    if ($error != '') return $error;
1708
-    			    else return self::check_version(true);
1857
+    			    if ($error != '') {
1858
+    			    	return $error;
1859
+    			    } else {
1860
+    			    	return self::check_version(true);
1861
+    			    }
1709 1862
     			} elseif ($result['value'] == '30') {
1710 1863
     			    $error = self::update_from_30();
1711
-    			    if ($error != '') return $error;
1712
-    			    else return self::check_version(true);
1864
+    			    if ($error != '') {
1865
+    			    	return $error;
1866
+    			    } else {
1867
+    			    	return self::check_version(true);
1868
+    			    }
1713 1869
     			} elseif ($result['value'] == '31') {
1714 1870
     			    $error = self::update_from_31();
1715
-    			    if ($error != '') return $error;
1716
-    			    else return self::check_version(true);
1871
+    			    if ($error != '') {
1872
+    			    	return $error;
1873
+    			    } else {
1874
+    			    	return self::check_version(true);
1875
+    			    }
1717 1876
     			} elseif ($result['value'] == '32') {
1718 1877
     			    $error = self::update_from_32();
1719
-    			    if ($error != '') return $error;
1720
-    			    else return self::check_version(true);
1878
+    			    if ($error != '') {
1879
+    			    	return $error;
1880
+    			    } else {
1881
+    			    	return self::check_version(true);
1882
+    			    }
1721 1883
     			} elseif ($result['value'] == '33') {
1722 1884
     			    $error = self::update_from_33();
1723
-    			    if ($error != '') return $error;
1724
-    			    else return self::check_version(true);
1885
+    			    if ($error != '') {
1886
+    			    	return $error;
1887
+    			    } else {
1888
+    			    	return self::check_version(true);
1889
+    			    }
1725 1890
     			} elseif ($result['value'] == '34') {
1726 1891
     			    $error = self::update_from_34();
1727
-    			    if ($error != '') return $error;
1728
-    			    else return self::check_version(true);
1892
+    			    if ($error != '') {
1893
+    			    	return $error;
1894
+    			    } else {
1895
+    			    	return self::check_version(true);
1896
+    			    }
1729 1897
     			} elseif ($result['value'] == '35') {
1730 1898
     			    $error = self::update_from_35();
1731
-    			    if ($error != '') return $error;
1732
-    			    else return self::check_version(true);
1733
-    			} else return '';
1899
+    			    if ($error != '') {
1900
+    			    	return $error;
1901
+    			    } else {
1902
+    			    	return self::check_version(true);
1903
+    			    }
1904
+    			} else {
1905
+    				return '';
1906
+    			}
1907
+    		    } else {
1908
+    		    	return $result['value'];
1734 1909
     		    }
1735
-    		    else return $result['value'];
1736 1910
 		}
1737 1911
 		
1738
-	    } else return $version;
1912
+	    } else {
1913
+	    	return $version;
1914
+	    }
1739 1915
     	}
1740 1916
     	
1741 1917
 }
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Indentation   +696 added lines, -696 removed lines patch added patch discarded remove patch
@@ -19,47 +19,47 @@  discard block
 block discarded – undo
19 19
 // Check if schema is at latest version
20 20
 $Connection = new Connection();
21 21
 if ($Connection->latest() === false) {
22
-    echo "You MUST update to latest schema. Run install/index.php";
23
-    exit();
22
+	echo "You MUST update to latest schema. Run install/index.php";
23
+	exit();
24 24
 }
25 25
 if (PHP_SAPI != 'cli') {
26
-    echo "This script MUST be called from console, not a web browser.";
26
+	echo "This script MUST be called from console, not a web browser.";
27 27
 //    exit();
28 28
 }
29 29
 
30 30
 // This is to be compatible with old version of settings.php
31 31
 if (!isset($globalSources)) {
32
-    if (isset($globalSBS1Hosts)) {
33
-        //$hosts = $globalSBS1Hosts;
34
-        foreach ($globalSBS1Hosts as $host) {
35
-	    $globalSources[] = array('host' => $host);
36
-    	}
37
-    } else {
38
-        if (!isset($globalSBS1Host)) {
39
-	    echo '$globalSources MUST be defined !';
40
-	    die;
32
+	if (isset($globalSBS1Hosts)) {
33
+		//$hosts = $globalSBS1Hosts;
34
+		foreach ($globalSBS1Hosts as $host) {
35
+		$globalSources[] = array('host' => $host);
36
+		}
37
+	} else {
38
+		if (!isset($globalSBS1Host)) {
39
+		echo '$globalSources MUST be defined !';
40
+		die;
41 41
 	}
42 42
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
43 43
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
44
-    }
44
+	}
45 45
 }
46 46
 
47 47
 $options = getopt('s::',array('source::','server','idsource::'));
48 48
 //if (isset($options['s'])) $hosts = array($options['s']);
49 49
 //elseif (isset($options['source'])) $hosts = array($options['source']);
50 50
 if (isset($options['s'])) {
51
-    $globalSources = array();
52
-    $globalSources[] = array('host' => $options['s']);
51
+	$globalSources = array();
52
+	$globalSources[] = array('host' => $options['s']);
53 53
 } elseif (isset($options['source'])) {
54
-    $globalSources = array();
55
-    $globalSources[] = array('host' => $options['source']);
54
+	$globalSources = array();
55
+	$globalSources[] = array('host' => $options['source']);
56 56
 }
57 57
 if (isset($options['server'])) $globalServer = TRUE;
58 58
 if (isset($options['idsource'])) $id_source = $options['idsource'];
59 59
 else $id_source = 1;
60 60
 if (isset($globalServer) && $globalServer) {
61
-    if ($globalDebug) echo "Using Server Mode\n";
62
-    $SI=new SpotterServer();
61
+	if ($globalDebug) echo "Using Server Mode\n";
62
+	$SI=new SpotterServer();
63 63
 } else $SI=new SpotterImport($Connection->db);
64 64
 //$APRS=new APRS($Connection->db);
65 65
 $SBS=new SBS();
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 //$servertz = system('date +%Z');
70 70
 // signal handler - playing nice with sockets and dump1090
71 71
 if (function_exists('pcntl_fork')) {
72
-    pcntl_signal(SIGINT,  function() {
73
-        global $sockets;
74
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75
-        die("Bye!\n");
76
-    });
77
-    pcntl_signal_dispatch();
72
+	pcntl_signal(SIGINT,  function() {
73
+		global $sockets;
74
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75
+		die("Bye!\n");
76
+	});
77
+	pcntl_signal_dispatch();
78 78
 }
79 79
 
80 80
 // let's try and connect
@@ -84,162 +84,162 @@  discard block
 block discarded – undo
84 84
 $reset = 0;
85 85
 
86 86
 function create_socket($host, $port, &$errno, &$errstr) {
87
-    $ip = gethostbyname($host);
88
-    $s = socket_create(AF_INET, SOCK_STREAM, 0);
89
-    $r = @socket_connect($s, $ip, $port);
90
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
91
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92
-        return $s;
93
-    }
94
-    $errno = socket_last_error($s);
95
-    $errstr = socket_strerror($errno);
96
-    socket_close($s);
97
-    return false;
87
+	$ip = gethostbyname($host);
88
+	$s = socket_create(AF_INET, SOCK_STREAM, 0);
89
+	$r = @socket_connect($s, $ip, $port);
90
+	if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
91
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92
+		return $s;
93
+	}
94
+	$errno = socket_last_error($s);
95
+	$errstr = socket_strerror($errno);
96
+	socket_close($s);
97
+	return false;
98 98
 }
99 99
 
100 100
 function create_socket_udp($host, $port, &$errno, &$errstr) {
101
-    echo "Create an UDP socket...\n";
102
-    $ip = gethostbyname($host);
103
-    $s = socket_create(AF_INET, SOCK_DGRAM, 0);
104
-    $r = @socket_bind($s, $ip, $port);
105
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
106
-        return $s;
107
-    }
108
-    $errno = socket_last_error($s);
109
-    $errstr = socket_strerror($errno);
110
-    socket_close($s);
111
-    return false;
101
+	echo "Create an UDP socket...\n";
102
+	$ip = gethostbyname($host);
103
+	$s = socket_create(AF_INET, SOCK_DGRAM, 0);
104
+	$r = @socket_bind($s, $ip, $port);
105
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
106
+		return $s;
107
+	}
108
+	$errno = socket_last_error($s);
109
+	$errstr = socket_strerror($errno);
110
+	socket_close($s);
111
+	return false;
112 112
 }
113 113
 
114 114
 function connect_all($hosts) {
115
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117
-    $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
119
-    foreach ($hosts as $id => $value) {
115
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
+	global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117
+	$reset++;
118
+	if ($globalDebug) echo 'Connect to all...'."\n";
119
+	foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123 123
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
125
-        	//$formats[$id] = 'deltadbtxt';
126
-        	$globalSources[$id]['format'] = 'deltadbtxt';
127
-        	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
-        	//$formats[$id] = 'vatsimtxt';
131
-        	$globalSources[$id]['format'] = 'vatsimtxt';
132
-        	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135
-        	//$formats[$id] = 'aircraftlistjson';
136
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
137
-        	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
140
-        	//$formats[$id] = 'aircraftlistjson';
141
-        	$globalSources[$id]['format'] = 'opensky';
142
-        	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145
-        	//$formats[$id] = 'radarvirtueljson';
146
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
147
-        	//$last_exec['radarvirtueljson'] = 0;
148
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
149
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151
-        	    exit(0);
152
-        	}
153
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
154
-        	//$formats[$id] = 'planeupdatefaa';
155
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
156
-        	//$last_exec['planeupdatefaa'] = 0;
157
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
158
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160
-        	    exit(0);
161
-        	}
162
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
163
-        	//$formats[$id] = 'phpvmacars';
164
-        	$globalSources[$id]['format'] = 'phpvmacars';
165
-        	//$last_exec['phpvmacars'] = 0;
166
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
168
-        	//$formats[$id] = 'phpvmacars';
169
-        	$globalSources[$id]['format'] = 'vam';
170
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
-            } else if (preg_match('/whazzup/i',$host)) {
172
-        	//$formats[$id] = 'whazzup';
173
-        	$globalSources[$id]['format'] = 'whazzup';
174
-        	//$last_exec['whazzup'] = 0;
175
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
-            } else if (preg_match('/recentpireps/i',$host)) {
177
-        	//$formats[$id] = 'pirepsjson';
178
-        	$globalSources[$id]['format'] = 'pirepsjson';
179
-        	//$last_exec['pirepsjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182
-        	//$formats[$id] = 'fr24json';
183
-        	$globalSources[$id]['format'] = 'fr24json';
184
-        	//$last_exec['fr24json'] = 0;
185
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
186
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188
-        	    exit(0);
189
-        	}
190
-            //} else if (preg_match('/10001/',$host)) {
191
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192
-        	//$formats[$id] = 'tsv';
193
-        	$globalSources[$id]['format'] = 'tsv';
194
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195
-            }
196
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
-	    $hostport = explode(':',$host);
200
-	    if (isset($hostport[1])) {
124
+			if (preg_match('/deltadb.txt$/i',$host)) {
125
+			//$formats[$id] = 'deltadbtxt';
126
+			$globalSources[$id]['format'] = 'deltadbtxt';
127
+			//$last_exec['deltadbtxt'] = 0;
128
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
+			//$formats[$id] = 'vatsimtxt';
131
+			$globalSources[$id]['format'] = 'vatsimtxt';
132
+			//$last_exec['vatsimtxt'] = 0;
133
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
135
+			//$formats[$id] = 'aircraftlistjson';
136
+			$globalSources[$id]['format'] = 'aircraftlistjson';
137
+			//$last_exec['aircraftlistjson'] = 0;
138
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
+			} else if (preg_match('/opensky/i',$host)) {
140
+			//$formats[$id] = 'aircraftlistjson';
141
+			$globalSources[$id]['format'] = 'opensky';
142
+			//$last_exec['aircraftlistjson'] = 0;
143
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145
+			//$formats[$id] = 'radarvirtueljson';
146
+			$globalSources[$id]['format'] = 'radarvirtueljson';
147
+			//$last_exec['radarvirtueljson'] = 0;
148
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
149
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151
+				exit(0);
152
+			}
153
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
154
+			//$formats[$id] = 'planeupdatefaa';
155
+			$globalSources[$id]['format'] = 'planeupdatefaa';
156
+			//$last_exec['planeupdatefaa'] = 0;
157
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
158
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160
+				exit(0);
161
+			}
162
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
163
+			//$formats[$id] = 'phpvmacars';
164
+			$globalSources[$id]['format'] = 'phpvmacars';
165
+			//$last_exec['phpvmacars'] = 0;
166
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
168
+			//$formats[$id] = 'phpvmacars';
169
+			$globalSources[$id]['format'] = 'vam';
170
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
+			} else if (preg_match('/whazzup/i',$host)) {
172
+			//$formats[$id] = 'whazzup';
173
+			$globalSources[$id]['format'] = 'whazzup';
174
+			//$last_exec['whazzup'] = 0;
175
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
+			} else if (preg_match('/recentpireps/i',$host)) {
177
+			//$formats[$id] = 'pirepsjson';
178
+			$globalSources[$id]['format'] = 'pirepsjson';
179
+			//$last_exec['pirepsjson'] = 0;
180
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182
+			//$formats[$id] = 'fr24json';
183
+			$globalSources[$id]['format'] = 'fr24json';
184
+			//$last_exec['fr24json'] = 0;
185
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
186
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188
+				exit(0);
189
+			}
190
+			//} else if (preg_match('/10001/',$host)) {
191
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192
+			//$formats[$id] = 'tsv';
193
+			$globalSources[$id]['format'] = 'tsv';
194
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195
+			}
196
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
+			if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
+		$hostport = explode(':',$host);
200
+		if (isset($hostport[1])) {
201 201
 		$port = $hostport[1];
202 202
 		$hostn = $hostport[0];
203
-	    } else {
203
+		} else {
204 204
 		$port = $globalSources[$id]['port'];
205 205
 		$hostn = $globalSources[$id]['host'];
206
-	    }
207
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
-        	$s = create_socket($hostn,$port, $errno, $errstr);
209
-    	    } else {
210
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
211
-	    }
212
-	    if ($s) {
213
-    	        $sockets[$id] = $s;
214
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
-		    if (preg_match('/aprs/',$hostn)) {
206
+		}
207
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
+			$s = create_socket($hostn,$port, $errno, $errstr);
209
+			} else {
210
+			$s = create_socket_udp($hostn,$port, $errno, $errstr);
211
+		}
212
+		if ($s) {
213
+				$sockets[$id] = $s;
214
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
+			if (preg_match('/aprs/',$hostn)) {
216 216
 			//$formats[$id] = 'aprs';
217 217
 			$globalSources[$id]['format'] = 'aprs';
218 218
 			//$aprs_connect = 0;
219 219
 			//$use_aprs = true;
220
-    		    } elseif ($port == '10001') {
221
-        		//$formats[$id] = 'tsv';
222
-        		$globalSources[$id]['format'] = 'tsv';
223
-		    } elseif ($port == '30002') {
224
-        		//$formats[$id] = 'raw';
225
-        		$globalSources[$id]['format'] = 'raw';
226
-		    } elseif ($port == '5001') {
227
-        		//$formats[$id] = 'raw';
228
-        		$globalSources[$id]['format'] = 'flightgearmp';
229
-		    } elseif ($port == '30005') {
220
+				} elseif ($port == '10001') {
221
+				//$formats[$id] = 'tsv';
222
+				$globalSources[$id]['format'] = 'tsv';
223
+			} elseif ($port == '30002') {
224
+				//$formats[$id] = 'raw';
225
+				$globalSources[$id]['format'] = 'raw';
226
+			} elseif ($port == '5001') {
227
+				//$formats[$id] = 'raw';
228
+				$globalSources[$id]['format'] = 'flightgearmp';
229
+			} elseif ($port == '30005') {
230 230
 			// Not yet supported
231
-        		//$formats[$id] = 'beast';
232
-        		$globalSources[$id]['format'] = 'beast';
233
-		    //} else $formats[$id] = 'sbs';
234
-		    } else $globalSources[$id]['format'] = 'sbs';
235
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
231
+				//$formats[$id] = 'beast';
232
+				$globalSources[$id]['format'] = 'beast';
233
+			//} else $formats[$id] = 'sbs';
234
+			} else $globalSources[$id]['format'] = 'sbs';
235
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
236 236
 		}
237 237
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
238
-            } else {
238
+			} else {
239 239
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
240
-    	    }
241
-        }
242
-    }
240
+			}
241
+		}
242
+	}
243 243
 }
244 244
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
245 245
 
@@ -266,18 +266,18 @@  discard block
 block discarded – undo
266 266
 	die;
267 267
 }
268 268
 foreach ($globalSources as $key => $source) {
269
-    if (!isset($source['format'])) {
270
-        $globalSources[$key]['format'] = 'auto';
271
-    }
269
+	if (!isset($source['format'])) {
270
+		$globalSources[$key]['format'] = 'auto';
271
+	}
272 272
 }
273 273
 connect_all($globalSources);
274 274
 foreach ($globalSources as $key => $source) {
275
-    if (isset($source['format']) && $source['format'] == 'aprs') {
275
+	if (isset($source['format']) && $source['format'] == 'aprs') {
276 276
 	$aprs_connect = 0;
277 277
 	$use_aprs = true;
278 278
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
279 279
 	break;
280
-    }
280
+	}
281 281
 }
282 282
 
283 283
 if ($use_aprs) {
@@ -316,70 +316,70 @@  discard block
 block discarded – undo
316 316
 
317 317
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
318 318
 while ($i > 0) {
319
-    if (!$globalDaemon) $i = $endtime-time();
320
-    // Delete old ATC
321
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
319
+	if (!$globalDaemon) $i = $endtime-time();
320
+	// Delete old ATC
321
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
322 322
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
323
-        $ATC->deleteOldATC();
324
-    }
323
+		$ATC->deleteOldATC();
324
+	}
325 325
     
326
-    if (count($last_exec) > 0) {
326
+	if (count($last_exec) > 0) {
327 327
 	$max = $globalMinFetch;
328 328
 	foreach ($last_exec as $last) {
329
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
329
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
330 330
 	}
331 331
 	if ($max != $globalMinFetch) {
332
-	    if ($globalDebug) echo 'Sleeping...'."\n";
333
-	    sleep($globalMinFetch-$max+2);
332
+		if ($globalDebug) echo 'Sleeping...'."\n";
333
+		sleep($globalMinFetch-$max+2);
334
+	}
334 335
 	}
335
-    }
336 336
 
337 337
     
338
-    //foreach ($formats as $id => $value) {
339
-    foreach ($globalSources as $id => $value) {
338
+	//foreach ($formats as $id => $value) {
339
+	foreach ($globalSources as $id => $value) {
340 340
 	date_default_timezone_set('UTC');
341 341
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
342 342
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
343
-	    //$buffer = $Common->getData($hosts[$id]);
344
-	    $buffer = $Common->getData($value['host']);
345
-	    if ($buffer != '') $reset = 0;
346
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347
-	    $buffer = explode('\n',$buffer);
348
-	    foreach ($buffer as $line) {
349
-    		if ($line != '' && count($line) > 7) {
350
-    		    $line = explode(',', $line);
351
-	            $data = array();
352
-	            $data['hex'] = $line[1]; // hex
353
-	            $data['ident'] = $line[2]; // ident
354
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
355
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
356
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
357
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
358
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
359
-	            $data['verticalrate'] = ''; // vertical rate
360
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
361
-	            $data['emergency'] = ''; // emergency
362
-		    $data['datetime'] = date('Y-m-d H:i:s');
363
-		    $data['format_source'] = 'deltadbtxt';
364
-    		    $data['id_source'] = $id_source;
365
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
366
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
367
-    		    $SI->add($data);
368
-		    unset($data);
369
-    		}
370
-    	    }
371
-    	    $last_exec[$id]['last'] = time();
343
+		//$buffer = $Common->getData($hosts[$id]);
344
+		$buffer = $Common->getData($value['host']);
345
+		if ($buffer != '') $reset = 0;
346
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347
+		$buffer = explode('\n',$buffer);
348
+		foreach ($buffer as $line) {
349
+			if ($line != '' && count($line) > 7) {
350
+				$line = explode(',', $line);
351
+				$data = array();
352
+				$data['hex'] = $line[1]; // hex
353
+				$data['ident'] = $line[2]; // ident
354
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
355
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
356
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
357
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
358
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
359
+				$data['verticalrate'] = ''; // vertical rate
360
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
361
+				$data['emergency'] = ''; // emergency
362
+			$data['datetime'] = date('Y-m-d H:i:s');
363
+			$data['format_source'] = 'deltadbtxt';
364
+				$data['id_source'] = $id_source;
365
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
366
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
367
+				$SI->add($data);
368
+			unset($data);
369
+			}
370
+			}
371
+			$last_exec[$id]['last'] = time();
372 372
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
373 373
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
374
-	    //$buffer = $Common->getData($hosts[$id]);
375
-	    $buffer = $Common->getData($value['host']);
376
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
-	    $buffer = explode('\n',$buffer);
378
-	    $reset = 0;
379
-	    foreach ($buffer as $line) {
380
-    		if ($line != '') {
381
-    		    $line = explode(':', $line);
382
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
374
+		//$buffer = $Common->getData($hosts[$id]);
375
+		$buffer = $Common->getData($value['host']);
376
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
+		$buffer = explode('\n',$buffer);
378
+		$reset = 0;
379
+		foreach ($buffer as $line) {
380
+			if ($line != '') {
381
+				$line = explode(':', $line);
382
+				if (count($line) > 30 && $line[0] != 'callsign') {
383 383
 			$data = array();
384 384
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
385 385
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -392,36 +392,36 @@  discard block
 block discarded – undo
392 392
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
393 393
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
394 394
 			$data['latitude'] = $line[5]; // lat
395
-	        	$data['longitude'] = $line[6]; // long
396
-	        	$data['verticalrate'] = ''; // vertical rate
397
-	        	$data['squawk'] = ''; // squawk
398
-	        	$data['emergency'] = ''; // emergency
399
-	        	$data['waypoints'] = $line[30];
395
+				$data['longitude'] = $line[6]; // long
396
+				$data['verticalrate'] = ''; // vertical rate
397
+				$data['squawk'] = ''; // squawk
398
+				$data['emergency'] = ''; // emergency
399
+				$data['waypoints'] = $line[30];
400 400
 			$data['datetime'] = date('Y-m-d H:i:s');
401 401
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
402 402
 			//if (isset($line[37])) $data['last_update'] = $line[37];
403
-		        $data['departure_airport_icao'] = $line[11];
404
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
405
-		        $data['arrival_airport_icao'] = $line[13];
403
+				$data['departure_airport_icao'] = $line[11];
404
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
405
+				$data['arrival_airport_icao'] = $line[13];
406 406
 			$data['frequency'] = $line[4];
407 407
 			$data['type'] = $line[18];
408 408
 			$data['range'] = $line[19];
409 409
 			if (isset($line[35])) $data['info'] = $line[35];
410
-    			$data['id_source'] = $id_source;
411
-	    		//$data['arrival_airport_time'] = ;
412
-	    		if ($line[9] != '') {
413
-	    		    $aircraft_data = explode('/',$line[9]);
414
-	    		    if (isset($aircraft_data[1])) {
415
-	    			$data['aircraft_icao'] = $aircraft_data[1];
416
-	    		    }
417
-        		}
418
-	    		/*
410
+				$data['id_source'] = $id_source;
411
+				//$data['arrival_airport_time'] = ;
412
+				if ($line[9] != '') {
413
+					$aircraft_data = explode('/',$line[9]);
414
+					if (isset($aircraft_data[1])) {
415
+					$data['aircraft_icao'] = $aircraft_data[1];
416
+					}
417
+				}
418
+				/*
419 419
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
420 420
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
421 421
 	    		*/
422
-	    		$data['format_source'] = $value['format'];
422
+				$data['format_source'] = $value['format'];
423 423
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
424
-    			if ($line[3] == 'PILOT') $SI->add($data);
424
+				if ($line[3] == 'PILOT') $SI->add($data);
425 425
 			elseif ($line[3] == 'ATC') {
426 426
 				//print_r($data);
427 427
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -439,247 +439,247 @@  discard block
 block discarded – undo
439 439
 				if (!isset($data['source_name'])) $data['source_name'] = '';
440 440
 				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']);
441 441
 			}
442
-    			unset($data);
443
-    		    }
444
-    		}
445
-    	    }
446
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
447
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
448
-    	    $last_exec[$id]['last'] = time();
449
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
450
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
451
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
452
-	    if ($buffer != '') {
453
-	    $all_data = json_decode($buffer,true);
454
-	    if (isset($all_data['acList'])) {
442
+				unset($data);
443
+				}
444
+			}
445
+			}
446
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
447
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
448
+			$last_exec[$id]['last'] = time();
449
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
450
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
451
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
452
+		if ($buffer != '') {
453
+		$all_data = json_decode($buffer,true);
454
+		if (isset($all_data['acList'])) {
455 455
 		$reset = 0;
456 456
 		foreach ($all_data['acList'] as $line) {
457
-		    $data = array();
458
-		    $data['hex'] = $line['Icao']; // hex
459
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
460
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
461
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
462
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
463
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
464
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
465
-		    //$data['verticalrate'] = $line['']; // verticale rate
466
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
467
-		    $data['emergency'] = ''; // emergency
468
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
469
-		    /*
457
+			$data = array();
458
+			$data['hex'] = $line['Icao']; // hex
459
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
460
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
461
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
462
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
463
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
464
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
465
+			//$data['verticalrate'] = $line['']; // verticale rate
466
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
467
+			$data['emergency'] = ''; // emergency
468
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
469
+			/*
470 470
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
471 471
 		    else $data['datetime'] = date('Y-m-d H:i:s');
472 472
 		    */
473
-		    $data['datetime'] = date('Y-m-d H:i:s');
474
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
475
-	    	    $data['format_source'] = 'aircraftlistjson';
476
-		    $data['id_source'] = $id_source;
477
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
478
-		    if (isset($data['datetime'])) $SI->add($data);
479
-		    unset($data);
473
+			$data['datetime'] = date('Y-m-d H:i:s');
474
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
475
+				$data['format_source'] = 'aircraftlistjson';
476
+			$data['id_source'] = $id_source;
477
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
478
+			if (isset($data['datetime'])) $SI->add($data);
479
+			unset($data);
480 480
 		}
481
-	    } else {
481
+		} else {
482 482
 		$reset = 0;
483 483
 		foreach ($all_data as $line) {
484
-		    $data = array();
485
-		    $data['hex'] = $line['hex']; // hex
486
-		    $data['ident'] = $line['flight']; // ident
487
-		    $data['altitude'] = $line['altitude']; // altitude
488
-		    $data['speed'] = $line['speed']; // speed
489
-		    $data['heading'] = $line['track']; // heading
490
-		    $data['latitude'] = $line['lat']; // lat
491
-		    $data['longitude'] = $line['lon']; // long
492
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
493
-		    $data['squawk'] = $line['squawk']; // squawk
494
-		    $data['emergency'] = ''; // emergency
495
-		    $data['datetime'] = date('Y-m-d H:i:s');
496
-	    	    $data['format_source'] = 'aircraftlistjson';
497
-    		    $data['id_source'] = $id_source;
498
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
499
-		    $SI->add($data);
500
-		    unset($data);
484
+			$data = array();
485
+			$data['hex'] = $line['hex']; // hex
486
+			$data['ident'] = $line['flight']; // ident
487
+			$data['altitude'] = $line['altitude']; // altitude
488
+			$data['speed'] = $line['speed']; // speed
489
+			$data['heading'] = $line['track']; // heading
490
+			$data['latitude'] = $line['lat']; // lat
491
+			$data['longitude'] = $line['lon']; // long
492
+			$data['verticalrate'] = $line['vrt']; // verticale rate
493
+			$data['squawk'] = $line['squawk']; // squawk
494
+			$data['emergency'] = ''; // emergency
495
+			$data['datetime'] = date('Y-m-d H:i:s');
496
+				$data['format_source'] = 'aircraftlistjson';
497
+				$data['id_source'] = $id_source;
498
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
499
+			$SI->add($data);
500
+			unset($data);
501
+		}
501 502
 		}
502
-	    }
503
-	    }
504
-    	    //$last_exec['aircraftlistjson'] = time();
505
-    	    $last_exec[$id]['last'] = time();
506
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
507
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
508
-	    $buffer = $Common->getData($value['host']);
509
-	    $all_data = json_decode($buffer,true);
510
-	    if (isset($all_data['planes'])) {
503
+		}
504
+			//$last_exec['aircraftlistjson'] = time();
505
+			$last_exec[$id]['last'] = time();
506
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
507
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
508
+		$buffer = $Common->getData($value['host']);
509
+		$all_data = json_decode($buffer,true);
510
+		if (isset($all_data['planes'])) {
511 511
 		$reset = 0;
512 512
 		foreach ($all_data['planes'] as $key => $line) {
513
-		    $data = array();
514
-		    $data['hex'] = $key; // hex
515
-		    $data['ident'] = $line[3]; // ident
516
-		    $data['altitude'] = $line[6]; // altitude
517
-		    $data['speed'] = $line[8]; // speed
518
-		    $data['heading'] = $line[7]; // heading
519
-		    $data['latitude'] = $line[4]; // lat
520
-		    $data['longitude'] = $line[5]; // long
521
-		    //$data['verticalrate'] = $line[]; // verticale rate
522
-		    $data['squawk'] = $line[10]; // squawk
523
-		    $data['emergency'] = ''; // emergency
524
-		    $data['registration'] = $line[2];
525
-		    $data['aircraft_icao'] = $line[0];
526
-		    $deparr = explode('-',$line[1]);
527
-		    if (count($deparr) == 2) {
513
+			$data = array();
514
+			$data['hex'] = $key; // hex
515
+			$data['ident'] = $line[3]; // ident
516
+			$data['altitude'] = $line[6]; // altitude
517
+			$data['speed'] = $line[8]; // speed
518
+			$data['heading'] = $line[7]; // heading
519
+			$data['latitude'] = $line[4]; // lat
520
+			$data['longitude'] = $line[5]; // long
521
+			//$data['verticalrate'] = $line[]; // verticale rate
522
+			$data['squawk'] = $line[10]; // squawk
523
+			$data['emergency'] = ''; // emergency
524
+			$data['registration'] = $line[2];
525
+			$data['aircraft_icao'] = $line[0];
526
+			$deparr = explode('-',$line[1]);
527
+			if (count($deparr) == 2) {
528 528
 			$data['departure_airport_icao'] = $deparr[0];
529 529
 			$data['arrival_airport_icao'] = $deparr[1];
530
-		    }
531
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
532
-	    	    $data['format_source'] = 'planeupdatefaa';
533
-    		    $data['id_source'] = $id_source;
534
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
535
-		    $SI->add($data);
536
-		    unset($data);
530
+			}
531
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
532
+				$data['format_source'] = 'planeupdatefaa';
533
+				$data['id_source'] = $id_source;
534
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
535
+			$SI->add($data);
536
+			unset($data);
537
+		}
537 538
 		}
538
-	    }
539
-    	    //$last_exec['planeupdatefaa'] = time();
540
-    	    $last_exec[$id]['last'] = time();
541
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
542
-	    $buffer = $Common->getData($value['host']);
543
-	    $all_data = json_decode($buffer,true);
544
-	    if (isset($all_data['states'])) {
539
+			//$last_exec['planeupdatefaa'] = time();
540
+			$last_exec[$id]['last'] = time();
541
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
542
+		$buffer = $Common->getData($value['host']);
543
+		$all_data = json_decode($buffer,true);
544
+		if (isset($all_data['states'])) {
545 545
 		$reset = 0;
546 546
 		foreach ($all_data['states'] as $key => $line) {
547
-		    $data = array();
548
-		    $data['hex'] = $line[0]; // hex
549
-		    $data['ident'] = trim($line[1]); // ident
550
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
551
-		    $data['speed'] = round($line[9]*1.94384); // speed
552
-		    $data['heading'] = round($line[10]); // heading
553
-		    $data['latitude'] = $line[5]; // lat
554
-		    $data['longitude'] = $line[6]; // long
555
-		    $data['verticalrate'] = $line[11]; // verticale rate
556
-		    //$data['squawk'] = $line[10]; // squawk
557
-		    //$data['emergency'] = ''; // emergency
558
-		    //$data['registration'] = $line[2];
559
-		    //$data['aircraft_icao'] = $line[0];
560
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
561
-	    	    $data['format_source'] = 'opensky';
562
-    		    $data['id_source'] = $id_source;
563
-		    $SI->add($data);
564
-		    unset($data);
547
+			$data = array();
548
+			$data['hex'] = $line[0]; // hex
549
+			$data['ident'] = trim($line[1]); // ident
550
+			$data['altitude'] = round($line[7]*3.28084); // altitude
551
+			$data['speed'] = round($line[9]*1.94384); // speed
552
+			$data['heading'] = round($line[10]); // heading
553
+			$data['latitude'] = $line[5]; // lat
554
+			$data['longitude'] = $line[6]; // long
555
+			$data['verticalrate'] = $line[11]; // verticale rate
556
+			//$data['squawk'] = $line[10]; // squawk
557
+			//$data['emergency'] = ''; // emergency
558
+			//$data['registration'] = $line[2];
559
+			//$data['aircraft_icao'] = $line[0];
560
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
561
+				$data['format_source'] = 'opensky';
562
+				$data['id_source'] = $id_source;
563
+			$SI->add($data);
564
+			unset($data);
565
+		}
565 566
 		}
566
-	    }
567
-    	    //$last_exec['planeupdatefaa'] = time();
568
-    	    $last_exec[$id]['last'] = time();
569
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
570
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
571
-	    //$buffer = $Common->getData($hosts[$id]);
572
-	    $buffer = $Common->getData($value['host']);
573
-	    $all_data = json_decode($buffer,true);
574
-	    if (!empty($all_data)) $reset = 0;
575
-	    foreach ($all_data as $key => $line) {
567
+			//$last_exec['planeupdatefaa'] = time();
568
+			$last_exec[$id]['last'] = time();
569
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
570
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
571
+		//$buffer = $Common->getData($hosts[$id]);
572
+		$buffer = $Common->getData($value['host']);
573
+		$all_data = json_decode($buffer,true);
574
+		if (!empty($all_data)) $reset = 0;
575
+		foreach ($all_data as $key => $line) {
576 576
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
577
-		    $data = array();
578
-		    $data['hex'] = $line[0];
579
-		    $data['ident'] = $line[16]; //$line[13]
580
-	    	    $data['altitude'] = $line[4]; // altitude
581
-	    	    $data['speed'] = $line[5]; // speed
582
-	    	    $data['heading'] = $line[3]; // heading
583
-	    	    $data['latitude'] = $line[1]; // lat
584
-	    	    $data['longitude'] = $line[2]; // long
585
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
586
-	    	    $data['squawk'] = $line[6]; // squawk
587
-	    	    $data['aircraft_icao'] = $line[8];
588
-	    	    $data['registration'] = $line[9];
589
-		    $data['departure_airport_iata'] = $line[11];
590
-		    $data['arrival_airport_iata'] = $line[12];
591
-	    	    $data['emergency'] = ''; // emergency
592
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
593
-	    	    $data['format_source'] = 'fr24json';
594
-    		    $data['id_source'] = $id_source;
595
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
596
-		    $SI->add($data);
597
-		    unset($data);
577
+			$data = array();
578
+			$data['hex'] = $line[0];
579
+			$data['ident'] = $line[16]; //$line[13]
580
+				$data['altitude'] = $line[4]; // altitude
581
+				$data['speed'] = $line[5]; // speed
582
+				$data['heading'] = $line[3]; // heading
583
+				$data['latitude'] = $line[1]; // lat
584
+				$data['longitude'] = $line[2]; // long
585
+				$data['verticalrate'] = $line[15]; // verticale rate
586
+				$data['squawk'] = $line[6]; // squawk
587
+				$data['aircraft_icao'] = $line[8];
588
+				$data['registration'] = $line[9];
589
+			$data['departure_airport_iata'] = $line[11];
590
+			$data['arrival_airport_iata'] = $line[12];
591
+				$data['emergency'] = ''; // emergency
592
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
593
+				$data['format_source'] = 'fr24json';
594
+				$data['id_source'] = $id_source;
595
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
596
+			$SI->add($data);
597
+			unset($data);
598
+		}
598 599
 		}
599
-	    }
600
-    	    //$last_exec['fr24json'] = time();
601
-    	    $last_exec[$id]['last'] = time();
602
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
603
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
604
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
605
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
606
-	    //echo $buffer;
607
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
608
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
609
-	    $all_data = json_decode($buffer,true);
610
-	    if (json_last_error() != JSON_ERROR_NONE) {
600
+			//$last_exec['fr24json'] = time();
601
+			$last_exec[$id]['last'] = time();
602
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
603
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
604
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
605
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
606
+		//echo $buffer;
607
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
608
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
609
+		$all_data = json_decode($buffer,true);
610
+		if (json_last_error() != JSON_ERROR_NONE) {
611 611
 		die(json_last_error_msg());
612
-	    }
613
-	    if (isset($all_data['mrkrs'])) {
612
+		}
613
+		if (isset($all_data['mrkrs'])) {
614 614
 		$reset = 0;
615 615
 		foreach ($all_data['mrkrs'] as $key => $line) {
616
-		    if (isset($line['inf'])) {
616
+			if (isset($line['inf'])) {
617 617
 			$data = array();
618 618
 			$data['hex'] = $line['inf']['ia'];
619 619
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
620
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
621
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
622
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
623
-	    		$data['latitude'] = $line['pt'][0]; // lat
624
-	    		$data['longitude'] = $line['pt'][1]; // long
625
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
626
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
627
-	    		//$data['aircraft_icao'] = $line[8];
628
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
620
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
621
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
622
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
623
+				$data['latitude'] = $line['pt'][0]; // lat
624
+				$data['longitude'] = $line['pt'][1]; // long
625
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
626
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
627
+				//$data['aircraft_icao'] = $line[8];
628
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
629 629
 			//$data['departure_airport_iata'] = $line[11];
630 630
 			//$data['arrival_airport_iata'] = $line[12];
631
-	    		//$data['emergency'] = ''; // emergency
631
+				//$data['emergency'] = ''; // emergency
632 632
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
633
-	    		$data['format_source'] = 'radarvirtueljson';
634
-    			$data['id_source'] = $id_source;
633
+				$data['format_source'] = 'radarvirtueljson';
634
+				$data['id_source'] = $id_source;
635 635
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
636 636
 			$SI->add($data);
637 637
 			unset($data);
638
-		    }
638
+			}
639
+		}
639 640
 		}
640
-	    }
641
-    	    //$last_exec['radarvirtueljson'] = time();
642
-    	    $last_exec[$id]['last'] = time();
643
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
644
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
645
-	    //$buffer = $Common->getData($hosts[$id]);
646
-	    $buffer = $Common->getData($value['host'].'?'.time());
647
-	    $all_data = json_decode(utf8_encode($buffer),true);
641
+			//$last_exec['radarvirtueljson'] = time();
642
+			$last_exec[$id]['last'] = time();
643
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
644
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
645
+		//$buffer = $Common->getData($hosts[$id]);
646
+		$buffer = $Common->getData($value['host'].'?'.time());
647
+		$all_data = json_decode(utf8_encode($buffer),true);
648 648
 	    
649
-	    if (isset($all_data['pireps'])) {
649
+		if (isset($all_data['pireps'])) {
650 650
 		$reset = 0;
651
-	        foreach ($all_data['pireps'] as $line) {
652
-		    $data = array();
653
-		    $data['id'] = $line['id'];
654
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
655
-		    $data['ident'] = $line['callsign']; // ident
656
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
657
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
658
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
659
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
660
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
661
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
662
-		    $data['latitude'] = $line['lat']; // lat
663
-		    $data['longitude'] = $line['lon']; // long
664
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
665
-		    //$data['squawk'] = $line['squawk']; // squawk
666
-		    //$data['emergency'] = ''; // emergency
667
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
668
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
669
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
670
-		    //$data['arrival_airport_time'] = $line['arrtime'];
671
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
672
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
673
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
674
-		    else $data['info'] = '';
675
-		    $data['format_source'] = 'pireps';
676
-    		    $data['id_source'] = $id_source;
677
-		    $data['datetime'] = date('Y-m-d H:i:s');
678
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
679
-		    if ($line['icon'] == 'plane') {
651
+			foreach ($all_data['pireps'] as $line) {
652
+			$data = array();
653
+			$data['id'] = $line['id'];
654
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
655
+			$data['ident'] = $line['callsign']; // ident
656
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
657
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
658
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
659
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
660
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
661
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
662
+			$data['latitude'] = $line['lat']; // lat
663
+			$data['longitude'] = $line['lon']; // long
664
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
665
+			//$data['squawk'] = $line['squawk']; // squawk
666
+			//$data['emergency'] = ''; // emergency
667
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
668
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
669
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
670
+			//$data['arrival_airport_time'] = $line['arrtime'];
671
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
672
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
673
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
674
+			else $data['info'] = '';
675
+			$data['format_source'] = 'pireps';
676
+				$data['id_source'] = $id_source;
677
+			$data['datetime'] = date('Y-m-d H:i:s');
678
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
679
+			if ($line['icon'] == 'plane') {
680 680
 			$SI->add($data);
681
-		    //    print_r($data);
682
-    		    } elseif ($line['icon'] == 'ct') {
681
+			//    print_r($data);
682
+				} elseif ($line['icon'] == 'ct') {
683 683
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
684 684
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
685 685
 			$typec = substr($data['ident'],-3);
@@ -694,163 +694,163 @@  discard block
 block discarded – undo
694 694
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
695 695
 			else $data['type'] = 'Observer';
696 696
 			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']);
697
-		    }
698
-		    unset($data);
697
+			}
698
+			unset($data);
699
+		}
699 700
 		}
700
-	    }
701
-    	    //$last_exec['pirepsjson'] = time();
702
-    	    $last_exec[$id]['last'] = time();
703
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
704
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
705
-	    //$buffer = $Common->getData($hosts[$id]);
706
-	    if ($globalDebug) echo 'Get Data...'."\n";
707
-	    $buffer = $Common->getData($value['host']);
708
-	    $all_data = json_decode($buffer,true);
709
-	    if ($buffer != '' && is_array($all_data)) {
701
+			//$last_exec['pirepsjson'] = time();
702
+			$last_exec[$id]['last'] = time();
703
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
704
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
705
+		//$buffer = $Common->getData($hosts[$id]);
706
+		if ($globalDebug) echo 'Get Data...'."\n";
707
+		$buffer = $Common->getData($value['host']);
708
+		$all_data = json_decode($buffer,true);
709
+		if ($buffer != '' && is_array($all_data)) {
710 710
 		$reset = 0;
711 711
 		foreach ($all_data as $line) {
712
-	    	    $data = array();
713
-	    	    //$data['id'] = $line['id']; // id not usable
714
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
715
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
716
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
717
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
718
-	    	    $data['ident'] = $line['flightnum']; // ident
719
-	    	    $data['altitude'] = $line['alt']; // altitude
720
-	    	    $data['speed'] = $line['gs']; // speed
721
-	    	    $data['heading'] = $line['heading']; // heading
722
-	    	    $data['latitude'] = $line['lat']; // lat
723
-	    	    $data['longitude'] = $line['lng']; // long
724
-	    	    $data['verticalrate'] = ''; // verticale rate
725
-	    	    $data['squawk'] = ''; // squawk
726
-	    	    $data['emergency'] = ''; // emergency
727
-	    	    //$data['datetime'] = $line['lastupdate'];
728
-	    	    $data['last_update'] = $line['lastupdate'];
729
-		    $data['datetime'] = date('Y-m-d H:i:s');
730
-	    	    $data['departure_airport_icao'] = $line['depicao'];
731
-	    	    $data['departure_airport_time'] = $line['deptime'];
732
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
733
-    		    $data['arrival_airport_time'] = $line['arrtime'];
734
-    		    $data['registration'] = $line['aircraft'];
735
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
736
-		    if (isset($line['aircraftname'])) {
712
+				$data = array();
713
+				//$data['id'] = $line['id']; // id not usable
714
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
715
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
716
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
717
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
718
+				$data['ident'] = $line['flightnum']; // ident
719
+				$data['altitude'] = $line['alt']; // altitude
720
+				$data['speed'] = $line['gs']; // speed
721
+				$data['heading'] = $line['heading']; // heading
722
+				$data['latitude'] = $line['lat']; // lat
723
+				$data['longitude'] = $line['lng']; // long
724
+				$data['verticalrate'] = ''; // verticale rate
725
+				$data['squawk'] = ''; // squawk
726
+				$data['emergency'] = ''; // emergency
727
+				//$data['datetime'] = $line['lastupdate'];
728
+				$data['last_update'] = $line['lastupdate'];
729
+			$data['datetime'] = date('Y-m-d H:i:s');
730
+				$data['departure_airport_icao'] = $line['depicao'];
731
+				$data['departure_airport_time'] = $line['deptime'];
732
+				$data['arrival_airport_icao'] = $line['arricao'];
733
+				$data['arrival_airport_time'] = $line['arrtime'];
734
+				$data['registration'] = $line['aircraft'];
735
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
736
+			if (isset($line['aircraftname'])) {
737 737
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
738 738
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
739
-	    		$aircraft_data = explode('-',$line['aircraftname']);
740
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
741
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
742
-	    		else {
743
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
744
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
745
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
746
-	    		}
747
-	    	    }
748
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
749
-    		    $data['id_source'] = $id_source;
750
-	    	    $data['format_source'] = 'phpvmacars';
751
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
752
-		    $SI->add($data);
753
-		    unset($data);
739
+				$aircraft_data = explode('-',$line['aircraftname']);
740
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
741
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
742
+				else {
743
+					$aircraft_data = explode(' ',$line['aircraftname']);
744
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
745
+					else $data['aircraft_icao'] = $line['aircraftname'];
746
+				}
747
+				}
748
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
749
+				$data['id_source'] = $id_source;
750
+				$data['format_source'] = 'phpvmacars';
751
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
752
+			$SI->add($data);
753
+			unset($data);
754 754
 		}
755 755
 		if ($globalDebug) echo 'No more data...'."\n";
756 756
 		unset($buffer);
757 757
 		unset($all_data);
758
-	    }
759
-    	    //$last_exec['phpvmacars'] = time();
760
-    	    $last_exec[$id]['last'] = time();
761
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
762
-	    //$buffer = $Common->getData($hosts[$id]);
763
-	    if ($globalDebug) echo 'Get Data...'."\n";
764
-	    $buffer = $Common->getData($value['host']);
765
-	    $all_data = json_decode($buffer,true);
766
-	    if ($buffer != '' && is_array($all_data)) {
758
+		}
759
+			//$last_exec['phpvmacars'] = time();
760
+			$last_exec[$id]['last'] = time();
761
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
762
+		//$buffer = $Common->getData($hosts[$id]);
763
+		if ($globalDebug) echo 'Get Data...'."\n";
764
+		$buffer = $Common->getData($value['host']);
765
+		$all_data = json_decode($buffer,true);
766
+		if ($buffer != '' && is_array($all_data)) {
767 767
 		$reset = 0;
768 768
 		foreach ($all_data as $line) {
769
-	    	    $data = array();
770
-	    	    //$data['id'] = $line['id']; // id not usable
771
-	    	    $data['id'] = trim($line['flight_id']);
772
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
773
-	    	    $data['pilot_name'] = $line['pilot_name'];
774
-	    	    $data['pilot_id'] = $line['pilot_id'];
775
-	    	    $data['ident'] = trim($line['callsign']); // ident
776
-	    	    $data['altitude'] = $line['altitude']; // altitude
777
-	    	    $data['speed'] = $line['gs']; // speed
778
-	    	    $data['heading'] = $line['heading']; // heading
779
-	    	    $data['latitude'] = $line['latitude']; // lat
780
-	    	    $data['longitude'] = $line['longitude']; // long
781
-	    	    $data['verticalrate'] = ''; // verticale rate
782
-	    	    $data['squawk'] = ''; // squawk
783
-	    	    $data['emergency'] = ''; // emergency
784
-	    	    //$data['datetime'] = $line['lastupdate'];
785
-	    	    $data['last_update'] = $line['last_update'];
786
-		    $data['datetime'] = date('Y-m-d H:i:s');
787
-	    	    $data['departure_airport_icao'] = $line['departure'];
788
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
789
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
790
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
791
-    		    //$data['registration'] = $line['aircraft'];
792
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
793
-	    	    $data['aircraft_icao'] = $line['plane_type'];
794
-    		    $data['id_source'] = $id_source;
795
-	    	    $data['format_source'] = 'vam';
796
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
797
-		    $SI->add($data);
798
-		    unset($data);
769
+				$data = array();
770
+				//$data['id'] = $line['id']; // id not usable
771
+				$data['id'] = trim($line['flight_id']);
772
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
773
+				$data['pilot_name'] = $line['pilot_name'];
774
+				$data['pilot_id'] = $line['pilot_id'];
775
+				$data['ident'] = trim($line['callsign']); // ident
776
+				$data['altitude'] = $line['altitude']; // altitude
777
+				$data['speed'] = $line['gs']; // speed
778
+				$data['heading'] = $line['heading']; // heading
779
+				$data['latitude'] = $line['latitude']; // lat
780
+				$data['longitude'] = $line['longitude']; // long
781
+				$data['verticalrate'] = ''; // verticale rate
782
+				$data['squawk'] = ''; // squawk
783
+				$data['emergency'] = ''; // emergency
784
+				//$data['datetime'] = $line['lastupdate'];
785
+				$data['last_update'] = $line['last_update'];
786
+			$data['datetime'] = date('Y-m-d H:i:s');
787
+				$data['departure_airport_icao'] = $line['departure'];
788
+				//$data['departure_airport_time'] = $line['departure_time'];
789
+				$data['arrival_airport_icao'] = $line['arrival'];
790
+				//$data['arrival_airport_time'] = $line['arrival_time'];
791
+				//$data['registration'] = $line['aircraft'];
792
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
793
+				$data['aircraft_icao'] = $line['plane_type'];
794
+				$data['id_source'] = $id_source;
795
+				$data['format_source'] = 'vam';
796
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
797
+			$SI->add($data);
798
+			unset($data);
799 799
 		}
800 800
 		if ($globalDebug) echo 'No more data...'."\n";
801 801
 		unset($buffer);
802 802
 		unset($all_data);
803
-	    }
804
-    	    //$last_exec['phpvmacars'] = time();
805
-    	    $last_exec[$id]['last'] = time();
803
+		}
804
+			//$last_exec['phpvmacars'] = time();
805
+			$last_exec[$id]['last'] = time();
806 806
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
807 807
 	} 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') {
808
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
809
-    	    //$last_exec[$id]['last'] = time();
808
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
809
+			//$last_exec[$id]['last'] = time();
810 810
 
811
-	    //$read = array( $sockets[$id] );
812
-	    $read = $sockets;
813
-	    $write = NULL;
814
-	    $e = NULL;
815
-	    $n = socket_select($read, $write, $e, $timeout);
816
-	    if ($e != NULL) var_dump($e);
817
-	    if ($n > 0) {
811
+		//$read = array( $sockets[$id] );
812
+		$read = $sockets;
813
+		$write = NULL;
814
+		$e = NULL;
815
+		$n = socket_select($read, $write, $e, $timeout);
816
+		if ($e != NULL) var_dump($e);
817
+		if ($n > 0) {
818 818
 		$reset = 0;
819 819
 		foreach ($read as $nb => $r) {
820
-		    //$value = $formats[$nb];
821
-		    $format = $globalSources[$nb]['format'];
822
-        	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
823
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
824
-        	    } else {
825
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
826
-	    	    }
827
-        	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
828
-        	    //echo $buffer."\n";
829
-		    // lets play nice and handle signals such as ctrl-c/kill properly
830
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
831
-		    $error = false;
832
-		    //$SI::del();
833
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
834
-		    // SBS format is CSV format
835
-		    if ($buffer != '') {
820
+			//$value = $formats[$nb];
821
+			$format = $globalSources[$nb]['format'];
822
+				if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
823
+				$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
824
+				} else {
825
+					$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
826
+				}
827
+				//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
828
+				//echo $buffer."\n";
829
+			// lets play nice and handle signals such as ctrl-c/kill properly
830
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
831
+			$error = false;
832
+			//$SI::del();
833
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
834
+			// SBS format is CSV format
835
+			if ($buffer != '') {
836 836
 			$tt[$format] = 0;
837 837
 			if ($format == 'acarssbs3') {
838
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
839
-			    $ACARS->add(trim($buffer));
840
-			    $ACARS->deleteLiveAcarsData();
838
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
839
+				$ACARS->add(trim($buffer));
840
+				$ACARS->deleteLiveAcarsData();
841 841
 			} elseif ($format == 'raw') {
842
-			    // AVR format
843
-			    $data = $SBS->parse($buffer);
844
-			    if (is_array($data)) {
842
+				// AVR format
843
+				$data = $SBS->parse($buffer);
844
+				if (is_array($data)) {
845 845
 				$data['datetime'] = date('Y-m-d H:i:s');
846 846
 				$data['format_source'] = 'raw';
847 847
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
848
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
849
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
850
-                            }
851
-                        } elseif ($format == 'flightgearsp') {
852
-                    	    //echo $buffer."\n";
853
-                    	    if (strlen($buffer) > 5) {
848
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
849
+								if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
850
+							}
851
+						} elseif ($format == 'flightgearsp') {
852
+							//echo $buffer."\n";
853
+							if (strlen($buffer) > 5) {
854 854
 				$line = explode(',',$buffer);
855 855
 				$data = array();
856 856
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -866,124 +866,124 @@  discard block
 block discarded – undo
866 866
 				$data['format_source'] = 'flightgearsp';
867 867
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
868 868
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
869
-			    }
870
-                        } elseif ($format == 'acars') {
871
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
872
-			    $ACARS->add(trim($buffer));
873
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
874
-			    $ACARS->deleteLiveAcarsData();
869
+				}
870
+						} elseif ($format == 'acars') {
871
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
872
+				$ACARS->add(trim($buffer));
873
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
874
+				$ACARS->deleteLiveAcarsData();
875 875
 			} elseif ($format == 'flightgearmp') {
876
-			    if (substr($buffer,0,1) != '#') {
876
+				if (substr($buffer,0,1) != '#') {
877 877
 				$data = array();
878 878
 				//echo $buffer."\n";
879 879
 				$line = explode(' ',$buffer);
880 880
 				if (count($line) == 11) {
881
-				    $userserver = explode('@',$line[0]);
882
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
883
-				    $data['ident'] = $userserver[0];
884
-				    $data['registration'] = $userserver[0];
885
-				    $data['latitude'] = $line[4];
886
-				    $data['longitude'] = $line[5];
887
-				    $data['altitude'] = $line[6];
888
-				    $data['datetime'] = date('Y-m-d H:i:s');
889
-				    $aircraft_type = $line[10];
890
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
891
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
892
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
881
+					$userserver = explode('@',$line[0]);
882
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
883
+					$data['ident'] = $userserver[0];
884
+					$data['registration'] = $userserver[0];
885
+					$data['latitude'] = $line[4];
886
+					$data['longitude'] = $line[5];
887
+					$data['altitude'] = $line[6];
888
+					$data['datetime'] = date('Y-m-d H:i:s');
889
+					$aircraft_type = $line[10];
890
+					$aircraft_type = preg_split(':/:',$aircraft_type);
891
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
892
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
893
+				}
893 894
 				}
894
-			    }
895 895
 			} elseif ($format == 'beast') {
896
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
897
-			    die;
896
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
897
+				die;
898 898
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
899
-			    $line = explode("\t", $buffer);
900
-			    for($k = 0; $k < count($line); $k=$k+2) {
899
+				$line = explode("\t", $buffer);
900
+				for($k = 0; $k < count($line); $k=$k+2) {
901 901
 				$key = $line[$k];
902
-			        $lined[$key] = $line[$k+1];
903
-			    }
904
-    			    if (count($lined) > 3) {
905
-    				$data['hex'] = $lined['hexid'];
906
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
907
-    				$data['datetime'] = date('Y-m-d H:i:s');;
908
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
909
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
910
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
911
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
912
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
913
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
914
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
915
-    				$data['id_source'] = $id_source;
916
-    				$data['format_source'] = 'tsv';
917
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
918
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
919
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
920
-    				unset($lined);
921
-    				unset($data);
922
-    			    } else $error = true;
902
+					$lined[$key] = $line[$k+1];
903
+				}
904
+					if (count($lined) > 3) {
905
+					$data['hex'] = $lined['hexid'];
906
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
907
+					$data['datetime'] = date('Y-m-d H:i:s');;
908
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
909
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
910
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
911
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
912
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
913
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
914
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
915
+					$data['id_source'] = $id_source;
916
+					$data['format_source'] = 'tsv';
917
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
918
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
919
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
920
+					unset($lined);
921
+					unset($data);
922
+					} else $error = true;
923 923
 			} elseif ($format == 'aprs' && $use_aprs) {
924
-			    if ($aprs_connect == 0) {
924
+				if ($aprs_connect == 0) {
925 925
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
926 926
 				$aprs_connect = 1;
927
-			    }
927
+				}
928 928
 			    
929
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
929
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
930 930
 				$aprs_last_tx = time();
931 931
 				$data_aprs = "# Keep alive";
932 932
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
933
-			    }
933
+				}
934 934
 			    
935
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
936
-			    $buffer = str_replace('APRS <- ','',$buffer);
937
-			    $buffer = str_replace('APRS -> ','',$buffer);
938
-			    //echo $buffer."\n";
939
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
935
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
936
+				$buffer = str_replace('APRS <- ','',$buffer);
937
+				$buffer = str_replace('APRS -> ','',$buffer);
938
+				//echo $buffer."\n";
939
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
940 940
 				$line = $APRS->parse($buffer);
941 941
 				//print_r($line);
942 942
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
943
-				    $aprs_last_tx = time();
944
-				    $data = array();
945
-				    //print_r($line);
946
-				    $data['hex'] = $line['address'];
947
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
948
-				    else $data['datetime'] = date('Y-m-d H:i:s');
949
-				    //$data['datetime'] = date('Y-m-d H:i:s');
950
-				    $data['ident'] = $line['ident'];
951
-				    $data['latitude'] = $line['latitude'];
952
-				    $data['longitude'] = $line['longitude'];
953
-				    //$data['verticalrate'] = $line[16];
954
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
955
-				    else $data['speed'] = 0;
956
-				    $data['altitude'] = $line['altitude'];
957
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
958
-				    //else $data['heading'] = 0;
959
-				    $data['aircraft_type'] = $line['stealth'];
960
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
961
-    				    $data['id_source'] = $id_source;
962
-				    $data['format_source'] = 'aprs';
963
-				    $data['source_name'] = $line['source'];
964
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
965
-				    $currentdate = date('Y-m-d H:i:s');
966
-				    $aprsdate = strtotime($data['datetime']);
967
-				    // Accept data if time <= system time + 20s
968
-				    if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
943
+					$aprs_last_tx = time();
944
+					$data = array();
945
+					//print_r($line);
946
+					$data['hex'] = $line['address'];
947
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
948
+					else $data['datetime'] = date('Y-m-d H:i:s');
949
+					//$data['datetime'] = date('Y-m-d H:i:s');
950
+					$data['ident'] = $line['ident'];
951
+					$data['latitude'] = $line['latitude'];
952
+					$data['longitude'] = $line['longitude'];
953
+					//$data['verticalrate'] = $line[16];
954
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
955
+					else $data['speed'] = 0;
956
+					$data['altitude'] = $line['altitude'];
957
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
958
+					//else $data['heading'] = 0;
959
+					$data['aircraft_type'] = $line['stealth'];
960
+					if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
961
+						$data['id_source'] = $id_source;
962
+					$data['format_source'] = 'aprs';
963
+					$data['source_name'] = $line['source'];
964
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
965
+					$currentdate = date('Y-m-d H:i:s');
966
+					$aprsdate = strtotime($data['datetime']);
967
+					// Accept data if time <= system time + 20s
968
+					if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
969 969
 					$send = $SI->add($data);
970
-				    } else {
970
+					} else {
971 971
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
972 972
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
973
-				    }
974
-				    unset($data);
973
+					}
974
+					unset($data);
975 975
 				} 
976 976
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
977 977
 					echo '!! Weather Station not yet supported'."\n";
978 978
 				}
979 979
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
980 980
 				//elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
981
-			    }
981
+				}
982 982
 			} else {
983
-			    $line = explode(',', $buffer);
984
-    			    if (count($line) > 20) {
985
-    			    	$data['hex'] = $line[4];
986
-    				/*
983
+				$line = explode(',', $buffer);
984
+					if (count($line) > 20) {
985
+						$data['hex'] = $line[4];
986
+					/*
987 987
     				$data['datetime'] = $line[6].' '.$line[7];
988 988
     					date_default_timezone_set($globalTimezone);
989 989
     					$datetime = new DateTime($data['datetime']);
@@ -991,29 +991,29 @@  discard block
 block discarded – undo
991 991
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
992 992
     					date_default_timezone_set('UTC');
993 993
     				*/
994
-    				// Force datetime to current UTC datetime
995
-    				date_default_timezone_set('UTC');
996
-    				$data['datetime'] = date('Y-m-d H:i:s');
997
-    				$data['ident'] = trim($line[10]);
998
-    				$data['latitude'] = $line[14];
999
-    				$data['longitude'] = $line[15];
1000
-    				$data['verticalrate'] = $line[16];
1001
-    				$data['emergency'] = $line[20];
1002
-    				$data['speed'] = $line[12];
1003
-    				$data['squawk'] = $line[17];
1004
-    				$data['altitude'] = $line[11];
1005
-    				$data['heading'] = $line[13];
1006
-    				$data['ground'] = $line[21];
1007
-    				$data['emergency'] = $line[19];
1008
-    				$data['format_source'] = 'sbs';
994
+					// Force datetime to current UTC datetime
995
+					date_default_timezone_set('UTC');
996
+					$data['datetime'] = date('Y-m-d H:i:s');
997
+					$data['ident'] = trim($line[10]);
998
+					$data['latitude'] = $line[14];
999
+					$data['longitude'] = $line[15];
1000
+					$data['verticalrate'] = $line[16];
1001
+					$data['emergency'] = $line[20];
1002
+					$data['speed'] = $line[12];
1003
+					$data['squawk'] = $line[17];
1004
+					$data['altitude'] = $line[11];
1005
+					$data['heading'] = $line[13];
1006
+					$data['ground'] = $line[21];
1007
+					$data['emergency'] = $line[19];
1008
+					$data['format_source'] = 'sbs';
1009 1009
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1010
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1011
-    				$data['id_source'] = $id_source;
1012
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1013
-    				else $error = true;
1014
-    				unset($data);
1015
-    			    } else $error = true;
1016
-			    if ($error) {
1010
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1011
+					$data['id_source'] = $id_source;
1012
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1013
+					else $error = true;
1014
+					unset($data);
1015
+					} else $error = true;
1016
+				if ($error) {
1017 1017
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1018 1018
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1019 1019
 				} else {
@@ -1029,13 +1029,13 @@  discard block
 block discarded – undo
1029 1029
 					connect_all($sourceer);
1030 1030
 					$sourceer = array();
1031 1031
 				}
1032
-			    }
1032
+				}
1033 1033
 			}
1034 1034
 			// Sleep for xxx microseconds
1035 1035
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1036
-		    } else {
1036
+			} else {
1037 1037
 			if ($format == 'flightgearmp') {
1038
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1038
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1039 1039
 				//@socket_close($r);
1040 1040
 				sleep($globalMinFetch);
1041 1041
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1044,9 +1044,9 @@  discard block
 block discarded – undo
1044 1044
 				break;
1045 1045
 				
1046 1046
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1047
-			    if (isset($tt[$format])) $tt[$format]++;
1048
-			    else $tt[$format] = 0;
1049
-			    if ($tt[$format] > 30) {
1047
+				if (isset($tt[$format])) $tt[$format]++;
1048
+				else $tt[$format] = 0;
1049
+				if ($tt[$format] > 30) {
1050 1050
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1051 1051
 				//@socket_close($r);
1052 1052
 				sleep(2);
@@ -1057,23 +1057,23 @@  discard block
 block discarded – undo
1057 1057
 				//connect_all($globalSources);
1058 1058
 				$tt[$format]=0;
1059 1059
 				break;
1060
-			    }
1060
+				}
1061
+			}
1061 1062
 			}
1062
-		    }
1063 1063
 		}
1064
-	    } else {
1064
+		} else {
1065 1065
 		$error = socket_strerror(socket_last_error());
1066 1066
 		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1067 1067
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1068 1068
 			if (isset($globalDebug)) echo "Restarting...\n";
1069 1069
 			// Restart the script if possible
1070 1070
 			if (is_array($sockets)) {
1071
-			    if ($globalDebug) echo "Shutdown all sockets...";
1071
+				if ($globalDebug) echo "Shutdown all sockets...";
1072 1072
 			    
1073
-			    foreach ($sockets as $sock) {
1073
+				foreach ($sockets as $sock) {
1074 1074
 				@socket_shutdown($sock,2);
1075 1075
 				@socket_close($sock);
1076
-			    }
1076
+				}
1077 1077
 			    
1078 1078
 			}
1079 1079
 			if ($globalDebug) echo "Restart all connections...";
@@ -1084,13 +1084,13 @@  discard block
 block discarded – undo
1084 1084
 			if ($reset > 40) exit('Too many attempts...');
1085 1085
 			connect_all($globalSources);
1086 1086
 		}
1087
-	    }
1087
+		}
1088 1088
 	}
1089 1089
 	if ($globalDaemon === false) {
1090
-	    if ($globalDebug) echo 'Check all...'."\n";
1091
-	    $SI->checkAll();
1090
+		if ($globalDebug) echo 'Check all...'."\n";
1091
+		$SI->checkAll();
1092
+	}
1092 1093
 	}
1093
-    }
1094 1094
 }
1095 1095
 
1096 1096
 ?>
Please login to merge, or discard this patch.
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 	    die;
41 41
 	}
42 42
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
43
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
43
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
44 44
     }
45 45
 }
46 46
 
47
-$options = getopt('s::',array('source::','server','idsource::'));
47
+$options = getopt('s::', array('source::', 'server', 'idsource::'));
48 48
 //if (isset($options['s'])) $hosts = array($options['s']);
49 49
 //elseif (isset($options['source'])) $hosts = array($options['source']);
50 50
 if (isset($options['s'])) {
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
 else $id_source = 1;
60 60
 if (isset($globalServer) && $globalServer) {
61 61
     if ($globalDebug) echo "Using Server Mode\n";
62
-    $SI=new SpotterServer();
63
-} else $SI=new SpotterImport($Connection->db);
62
+    $SI = new SpotterServer();
63
+} else $SI = new SpotterImport($Connection->db);
64 64
 //$APRS=new APRS($Connection->db);
65
-$SBS=new SBS();
66
-$ACARS=new ACARS($Connection->db);
67
-$Common=new Common();
65
+$SBS = new SBS();
66
+$ACARS = new ACARS($Connection->db);
67
+$Common = new Common();
68 68
 date_default_timezone_set('UTC');
69 69
 //$servertz = system('date +%Z');
70 70
 // signal handler - playing nice with sockets and dump1090
71 71
 if (function_exists('pcntl_fork')) {
72
-    pcntl_signal(SIGINT,  function() {
72
+    pcntl_signal(SIGINT, function() {
73 73
         global $sockets;
74 74
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75 75
         die("Bye!\n");
@@ -113,35 +113,35 @@  discard block
 block discarded – undo
113 113
 
114 114
 function connect_all($hosts) {
115 115
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
116
+    global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset;
117 117
     $reset++;
118 118
     if ($globalDebug) echo 'Connect to all...'."\n";
119 119
     foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
+            if (preg_match('/deltadb.txt$/i', $host)) {
125 125
         	//$formats[$id] = 'deltadbtxt';
126 126
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 127
         	//$last_exec['deltadbtxt'] = 0;
128 128
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
129
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
130 130
         	//$formats[$id] = 'vatsimtxt';
131 131
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 132
         	//$last_exec['vatsimtxt'] = 0;
133 133
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
134
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
135 135
         	//$formats[$id] = 'aircraftlistjson';
136 136
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 137
         	//$last_exec['aircraftlistjson'] = 0;
138 138
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
139
+    	    } else if (preg_match('/opensky/i', $host)) {
140 140
         	//$formats[$id] = 'aircraftlistjson';
141 141
         	$globalSources[$id]['format'] = 'opensky';
142 142
         	//$last_exec['aircraftlistjson'] = 0;
143 143
         	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
144
+    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) {
145 145
         	//$formats[$id] = 'radarvirtueljson';
146 146
         	$globalSources[$id]['format'] = 'radarvirtueljson';
147 147
         	//$last_exec['radarvirtueljson'] = 0;
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151 151
         	    exit(0);
152 152
         	}
153
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
153
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
154 154
         	//$formats[$id] = 'planeupdatefaa';
155 155
         	$globalSources[$id]['format'] = 'planeupdatefaa';
156 156
         	//$last_exec['planeupdatefaa'] = 0;
@@ -159,26 +159,26 @@  discard block
 block discarded – undo
159 159
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160 160
         	    exit(0);
161 161
         	}
162
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
162
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
163 163
         	//$formats[$id] = 'phpvmacars';
164 164
         	$globalSources[$id]['format'] = 'phpvmacars';
165 165
         	//$last_exec['phpvmacars'] = 0;
166 166
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
167
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
168 168
         	//$formats[$id] = 'phpvmacars';
169 169
         	$globalSources[$id]['format'] = 'vam';
170 170
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
-            } else if (preg_match('/whazzup/i',$host)) {
171
+            } else if (preg_match('/whazzup/i', $host)) {
172 172
         	//$formats[$id] = 'whazzup';
173 173
         	$globalSources[$id]['format'] = 'whazzup';
174 174
         	//$last_exec['whazzup'] = 0;
175 175
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
-            } else if (preg_match('/recentpireps/i',$host)) {
176
+            } else if (preg_match('/recentpireps/i', $host)) {
177 177
         	//$formats[$id] = 'pirepsjson';
178 178
         	$globalSources[$id]['format'] = 'pirepsjson';
179 179
         	//$last_exec['pirepsjson'] = 0;
180 180
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
181
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
182 182
         	//$formats[$id] = 'fr24json';
183 183
         	$globalSources[$id]['format'] = 'fr24json';
184 184
         	//$last_exec['fr24json'] = 0;
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
         	    exit(0);
189 189
         	}
190 190
             //} else if (preg_match('/10001/',$host)) {
191
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
191
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192 192
         	//$formats[$id] = 'tsv';
193 193
         	$globalSources[$id]['format'] = 'tsv';
194 194
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195 195
             }
196
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
196
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
197 197
         	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
-	    $hostport = explode(':',$host);
198
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
199
+	    $hostport = explode(':', $host);
200 200
 	    if (isset($hostport[1])) {
201 201
 		$port = $hostport[1];
202 202
 		$hostn = $hostport[0];
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
 		$hostn = $globalSources[$id]['host'];
206 206
 	    }
207 207
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
-        	$s = create_socket($hostn,$port, $errno, $errstr);
208
+        	$s = create_socket($hostn, $port, $errno, $errstr);
209 209
     	    } else {
210
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
210
+        	$s = create_socket_udp($hostn, $port, $errno, $errstr);
211 211
 	    }
212 212
 	    if ($s) {
213 213
     	        $sockets[$id] = $s;
214 214
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
-		    if (preg_match('/aprs/',$hostn)) {
215
+		    if (preg_match('/aprs/', $hostn)) {
216 216
 			//$formats[$id] = 'aprs';
217 217
 			$globalSources[$id]['format'] = 'aprs';
218 218
 			//$aprs_connect = 0;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
254 254
 else $timeout = 20;
255 255
 $errno = '';
256
-$errstr='';
256
+$errstr = '';
257 257
 
258 258
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
259 259
 /* Initiate connections to all the hosts simultaneously */
@@ -282,16 +282,16 @@  discard block
 block discarded – undo
282 282
 
283 283
 if ($use_aprs) {
284 284
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
285
-	$APRS=new APRS();
285
+	$APRS = new APRS();
286 286
 	$aprs_connect = 0;
287 287
 	$aprs_keep = 120;
288 288
 	$aprs_last_tx = time();
289 289
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
290
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
290
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
291 291
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
292
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
292
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
293 293
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
294
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
294
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
295 295
 	if ($aprs_full) $aprs_filter = '';
296 296
 
297 297
 	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n";
@@ -303,12 +303,12 @@  discard block
 block discarded – undo
303 303
 sleep(1);
304 304
 if ($globalDebug) echo "SCAN MODE \n\n";
305 305
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
306
-$endtime = time()+$globalCronEnd;
306
+$endtime = time() + $globalCronEnd;
307 307
 $i = 1;
308 308
 $tt = array();
309 309
 // Delete all ATC
310 310
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
311
-	$ATC=new ATC($Connection->db);
311
+	$ATC = new ATC($Connection->db);
312 312
 }
313 313
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
314 314
 	$ATC->deleteAll();
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 
317 317
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
318 318
 while ($i > 0) {
319
-    if (!$globalDaemon) $i = $endtime-time();
319
+    if (!$globalDaemon) $i = $endtime - time();
320 320
     // Delete old ATC
321 321
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
322 322
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	}
331 331
 	if ($max != $globalMinFetch) {
332 332
 	    if ($globalDebug) echo 'Sleeping...'."\n";
333
-	    sleep($globalMinFetch-$max+2);
333
+	    sleep($globalMinFetch - $max + 2);
334 334
 	}
335 335
     }
336 336
 
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	    //$buffer = $Common->getData($hosts[$id]);
344 344
 	    $buffer = $Common->getData($value['host']);
345 345
 	    if ($buffer != '') $reset = 0;
346
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347
-	    $buffer = explode('\n',$buffer);
346
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
347
+	    $buffer = explode('\n', $buffer);
348 348
 	    foreach ($buffer as $line) {
349 349
     		if ($line != '' && count($line) > 7) {
350 350
     		    $line = explode(',', $line);
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
374 374
 	    //$buffer = $Common->getData($hosts[$id]);
375 375
 	    $buffer = $Common->getData($value['host']);
376
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
-	    $buffer = explode('\n',$buffer);
376
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
377
+	    $buffer = explode('\n', $buffer);
378 378
 	    $reset = 0;
379 379
 	    foreach ($buffer as $line) {
380 380
     		if ($line != '') {
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
386 386
 			$data['pilot_id'] = $line[1];
387 387
 			$data['pilot_name'] = $line[2];
388
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
388
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
389 389
 			$data['ident'] = $line[0]; // ident
390 390
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
391 391
 			$data['speed'] = $line[8]; // speed
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
402 402
 			//if (isset($line[37])) $data['last_update'] = $line[37];
403 403
 		        $data['departure_airport_icao'] = $line[11];
404
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
404
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
405 405
 		        $data['arrival_airport_icao'] = $line[13];
406 406
 			$data['frequency'] = $line[4];
407 407
 			$data['type'] = $line[18];
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
     			$data['id_source'] = $id_source;
411 411
 	    		//$data['arrival_airport_time'] = ;
412 412
 	    		if ($line[9] != '') {
413
-	    		    $aircraft_data = explode('/',$line[9]);
413
+	    		    $aircraft_data = explode('/', $line[9]);
414 414
 	    		    if (isset($aircraft_data[1])) {
415 415
 	    			$data['aircraft_icao'] = $aircraft_data[1];
416 416
 	    		    }
@@ -424,9 +424,9 @@  discard block
 block discarded – undo
424 424
     			if ($line[3] == 'PILOT') $SI->add($data);
425 425
 			elseif ($line[3] == 'ATC') {
426 426
 				//print_r($data);
427
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
428
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
429
-				$typec = substr($data['ident'],-3);
427
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
428
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
429
+				$typec = substr($data['ident'], -3);
430 430
 				if ($typec == 'APP') $data['type'] = 'Approach';
431 431
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
432 432
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
438 438
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
439 439
 				if (!isset($data['source_name'])) $data['source_name'] = '';
440
-				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']);
440
+				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']);
441 441
 			}
442 442
     			unset($data);
443 443
     		    }
@@ -448,9 +448,9 @@  discard block
 block discarded – undo
448 448
     	    $last_exec[$id]['last'] = time();
449 449
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
450 450
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
451
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
451
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
452 452
 	    if ($buffer != '') {
453
-	    $all_data = json_decode($buffer,true);
453
+	    $all_data = json_decode($buffer, true);
454 454
 	    if (isset($all_data['acList'])) {
455 455
 		$reset = 0;
456 456
 		foreach ($all_data['acList'] as $line) {
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
507 507
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
508 508
 	    $buffer = $Common->getData($value['host']);
509
-	    $all_data = json_decode($buffer,true);
509
+	    $all_data = json_decode($buffer, true);
510 510
 	    if (isset($all_data['planes'])) {
511 511
 		$reset = 0;
512 512
 		foreach ($all_data['planes'] as $key => $line) {
@@ -523,12 +523,12 @@  discard block
 block discarded – undo
523 523
 		    $data['emergency'] = ''; // emergency
524 524
 		    $data['registration'] = $line[2];
525 525
 		    $data['aircraft_icao'] = $line[0];
526
-		    $deparr = explode('-',$line[1]);
526
+		    $deparr = explode('-', $line[1]);
527 527
 		    if (count($deparr) == 2) {
528 528
 			$data['departure_airport_icao'] = $deparr[0];
529 529
 			$data['arrival_airport_icao'] = $deparr[1];
530 530
 		    }
531
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
531
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
532 532
 	    	    $data['format_source'] = 'planeupdatefaa';
533 533
     		    $data['id_source'] = $id_source;
534 534
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
     	    $last_exec[$id]['last'] = time();
541 541
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
542 542
 	    $buffer = $Common->getData($value['host']);
543
-	    $all_data = json_decode($buffer,true);
543
+	    $all_data = json_decode($buffer, true);
544 544
 	    if (isset($all_data['states'])) {
545 545
 		$reset = 0;
546 546
 		foreach ($all_data['states'] as $key => $line) {
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 		    //$data['emergency'] = ''; // emergency
558 558
 		    //$data['registration'] = $line[2];
559 559
 		    //$data['aircraft_icao'] = $line[0];
560
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
560
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
561 561
 	    	    $data['format_source'] = 'opensky';
562 562
     		    $data['id_source'] = $id_source;
563 563
 		    $SI->add($data);
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
571 571
 	    //$buffer = $Common->getData($hosts[$id]);
572 572
 	    $buffer = $Common->getData($value['host']);
573
-	    $all_data = json_decode($buffer,true);
573
+	    $all_data = json_decode($buffer, true);
574 574
 	    if (!empty($all_data)) $reset = 0;
575 575
 	    foreach ($all_data as $key => $line) {
576 576
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -602,11 +602,11 @@  discard block
 block discarded – undo
602 602
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
603 603
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
604 604
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
605
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
605
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
606 606
 	    //echo $buffer;
607
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
608
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
609
-	    $all_data = json_decode($buffer,true);
607
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
608
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
609
+	    $all_data = json_decode($buffer, true);
610 610
 	    if (json_last_error() != JSON_ERROR_NONE) {
611 611
 		die(json_last_error_msg());
612 612
 	    }
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 			//$data['departure_airport_iata'] = $line[11];
630 630
 			//$data['arrival_airport_iata'] = $line[12];
631 631
 	    		//$data['emergency'] = ''; // emergency
632
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
632
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
633 633
 	    		$data['format_source'] = 'radarvirtueljson';
634 634
     			$data['id_source'] = $id_source;
635 635
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -644,14 +644,14 @@  discard block
 block discarded – undo
644 644
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
645 645
 	    //$buffer = $Common->getData($hosts[$id]);
646 646
 	    $buffer = $Common->getData($value['host'].'?'.time());
647
-	    $all_data = json_decode(utf8_encode($buffer),true);
647
+	    $all_data = json_decode(utf8_encode($buffer), true);
648 648
 	    
649 649
 	    if (isset($all_data['pireps'])) {
650 650
 		$reset = 0;
651 651
 	        foreach ($all_data['pireps'] as $line) {
652 652
 		    $data = array();
653 653
 		    $data['id'] = $line['id'];
654
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
654
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
655 655
 		    $data['ident'] = $line['callsign']; // ident
656 656
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
657 657
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -680,9 +680,9 @@  discard block
 block discarded – undo
680 680
 			$SI->add($data);
681 681
 		    //    print_r($data);
682 682
     		    } elseif ($line['icon'] == 'ct') {
683
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
684
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
685
-			$typec = substr($data['ident'],-3);
683
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
684
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
685
+			$typec = substr($data['ident'], -3);
686 686
 			$data['type'] = '';
687 687
 			if ($typec == 'APP') $data['type'] = 'Approach';
688 688
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
694 694
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
695 695
 			else $data['type'] = 'Observer';
696
-			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']);
696
+			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']);
697 697
 		    }
698 698
 		    unset($data);
699 699
 		}
@@ -705,14 +705,14 @@  discard block
 block discarded – undo
705 705
 	    //$buffer = $Common->getData($hosts[$id]);
706 706
 	    if ($globalDebug) echo 'Get Data...'."\n";
707 707
 	    $buffer = $Common->getData($value['host']);
708
-	    $all_data = json_decode($buffer,true);
708
+	    $all_data = json_decode($buffer, true);
709 709
 	    if ($buffer != '' && is_array($all_data)) {
710 710
 		$reset = 0;
711 711
 		foreach ($all_data as $line) {
712 712
 	    	    $data = array();
713 713
 	    	    //$data['id'] = $line['id']; // id not usable
714 714
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
715
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
715
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
716 716
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
717 717
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
718 718
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -735,12 +735,12 @@  discard block
 block discarded – undo
735 735
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
736 736
 		    if (isset($line['aircraftname'])) {
737 737
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
738
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
739
-	    		$aircraft_data = explode('-',$line['aircraftname']);
738
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
739
+	    		$aircraft_data = explode('-', $line['aircraftname']);
740 740
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
741 741
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
742 742
 	    		else {
743
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
743
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
744 744
 	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
745 745
 	    		    else $data['aircraft_icao'] = $line['aircraftname'];
746 746
 	    		}
@@ -762,14 +762,14 @@  discard block
 block discarded – undo
762 762
 	    //$buffer = $Common->getData($hosts[$id]);
763 763
 	    if ($globalDebug) echo 'Get Data...'."\n";
764 764
 	    $buffer = $Common->getData($value['host']);
765
-	    $all_data = json_decode($buffer,true);
765
+	    $all_data = json_decode($buffer, true);
766 766
 	    if ($buffer != '' && is_array($all_data)) {
767 767
 		$reset = 0;
768 768
 		foreach ($all_data as $line) {
769 769
 	    	    $data = array();
770 770
 	    	    //$data['id'] = $line['id']; // id not usable
771 771
 	    	    $data['id'] = trim($line['flight_id']);
772
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
772
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
773 773
 	    	    $data['pilot_name'] = $line['pilot_name'];
774 774
 	    	    $data['pilot_id'] = $line['pilot_id'];
775 775
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -820,9 +820,9 @@  discard block
 block discarded – undo
820 820
 		    //$value = $formats[$nb];
821 821
 		    $format = $globalSources[$nb]['format'];
822 822
         	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
823
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
823
+        		$buffer = socket_read($r, 6000, PHP_NORMAL_READ);
824 824
         	    } else {
825
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
825
+	    	        $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
826 826
 	    	    }
827 827
         	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
828 828
         	    //echo $buffer."\n";
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
831 831
 		    $error = false;
832 832
 		    //$SI::del();
833
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
833
+		    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
834 834
 		    // SBS format is CSV format
835 835
 		    if ($buffer != '') {
836 836
 			$tt[$format] = 0;
@@ -851,10 +851,10 @@  discard block
 block discarded – undo
851 851
                         } elseif ($format == 'flightgearsp') {
852 852
                     	    //echo $buffer."\n";
853 853
                     	    if (strlen($buffer) > 5) {
854
-				$line = explode(',',$buffer);
854
+				$line = explode(',', $buffer);
855 855
 				$data = array();
856 856
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
857
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
857
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
858 858
 				$data['ident'] = $line[6];
859 859
 				$data['aircraft_name'] = $line[7];
860 860
 				$data['longitude'] = $line[1];
@@ -865,21 +865,21 @@  discard block
 block discarded – undo
865 865
 				$data['datetime'] = date('Y-m-d H:i:s');
866 866
 				$data['format_source'] = 'flightgearsp';
867 867
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
868
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
868
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
869 869
 			    }
870 870
                         } elseif ($format == 'acars') {
871 871
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
872 872
 			    $ACARS->add(trim($buffer));
873
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
873
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
874 874
 			    $ACARS->deleteLiveAcarsData();
875 875
 			} elseif ($format == 'flightgearmp') {
876
-			    if (substr($buffer,0,1) != '#') {
876
+			    if (substr($buffer, 0, 1) != '#') {
877 877
 				$data = array();
878 878
 				//echo $buffer."\n";
879
-				$line = explode(' ',$buffer);
879
+				$line = explode(' ', $buffer);
880 880
 				if (count($line) == 11) {
881
-				    $userserver = explode('@',$line[0]);
882
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
881
+				    $userserver = explode('@', $line[0]);
882
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
883 883
 				    $data['ident'] = $userserver[0];
884 884
 				    $data['registration'] = $userserver[0];
885 885
 				    $data['latitude'] = $line[4];
@@ -887,24 +887,24 @@  discard block
 block discarded – undo
887 887
 				    $data['altitude'] = $line[6];
888 888
 				    $data['datetime'] = date('Y-m-d H:i:s');
889 889
 				    $aircraft_type = $line[10];
890
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
891
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
890
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
891
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
892 892
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
893 893
 				}
894 894
 			    }
895 895
 			} elseif ($format == 'beast') {
896 896
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
897 897
 			    die;
898
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
898
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
899 899
 			    $line = explode("\t", $buffer);
900
-			    for($k = 0; $k < count($line); $k=$k+2) {
900
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
901 901
 				$key = $line[$k];
902
-			        $lined[$key] = $line[$k+1];
902
+			        $lined[$key] = $line[$k + 1];
903 903
 			    }
904 904
     			    if (count($lined) > 3) {
905 905
     				$data['hex'] = $lined['hexid'];
906 906
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
907
-    				$data['datetime'] = date('Y-m-d H:i:s');;
907
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
908 908
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
909 909
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
910 910
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -922,21 +922,21 @@  discard block
 block discarded – undo
922 922
     			    } else $error = true;
923 923
 			} elseif ($format == 'aprs' && $use_aprs) {
924 924
 			    if ($aprs_connect == 0) {
925
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
925
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
926 926
 				$aprs_connect = 1;
927 927
 			    }
928 928
 			    
929
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
929
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
930 930
 				$aprs_last_tx = time();
931 931
 				$data_aprs = "# Keep alive";
932
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
932
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
933 933
 			    }
934 934
 			    
935 935
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
936
-			    $buffer = str_replace('APRS <- ','',$buffer);
937
-			    $buffer = str_replace('APRS -> ','',$buffer);
936
+			    $buffer = str_replace('APRS <- ', '', $buffer);
937
+			    $buffer = str_replace('APRS -> ', '', $buffer);
938 938
 			    //echo $buffer."\n";
939
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
939
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
940 940
 				$line = $APRS->parse($buffer);
941 941
 				//print_r($line);
942 942
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 				    $data = array();
945 945
 				    //print_r($line);
946 946
 				    $data['hex'] = $line['address'];
947
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
947
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
948 948
 				    else $data['datetime'] = date('Y-m-d H:i:s');
949 949
 				    //$data['datetime'] = date('Y-m-d H:i:s');
950 950
 				    $data['ident'] = $line['ident'];
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
 				    $currentdate = date('Y-m-d H:i:s');
966 966
 				    $aprsdate = strtotime($data['datetime']);
967 967
 				    // Accept data if time <= system time + 20s
968
-				    if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
968
+				    if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
969 969
 					$send = $SI->add($data);
970 970
 				    } else {
971 971
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
 				connect_all($sourceee);
1056 1056
 				$sourceee = array();
1057 1057
 				//connect_all($globalSources);
1058
-				$tt[$format]=0;
1058
+				$tt[$format] = 0;
1059 1059
 				break;
1060 1060
 			    }
1061 1061
 			}
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 		}
1064 1064
 	    } else {
1065 1065
 		$error = socket_strerror(socket_last_error());
1066
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1066
+		if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1067 1067
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1068 1068
 			if (isset($globalDebug)) echo "Restarting...\n";
1069 1069
 			// Restart the script if possible
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 			    if ($globalDebug) echo "Shutdown all sockets...";
1072 1072
 			    
1073 1073
 			    foreach ($sockets as $sock) {
1074
-				@socket_shutdown($sock,2);
1074
+				@socket_shutdown($sock, 2);
1075 1075
 				@socket_close($sock);
1076 1076
 			    }
1077 1077
 			    
Please login to merge, or discard this patch.
Braces   +552 added lines, -190 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 
17
-if (!isset($globalDebug)) $globalDebug = FALSE;
17
+if (!isset($globalDebug)) {
18
+	$globalDebug = FALSE;
19
+}
18 20
 
19 21
 // Check if schema is at latest version
20 22
 $Connection = new Connection();
@@ -54,13 +56,22 @@  discard block
 block discarded – undo
54 56
     $globalSources = array();
55 57
     $globalSources[] = array('host' => $options['source']);
56 58
 }
57
-if (isset($options['server'])) $globalServer = TRUE;
58
-if (isset($options['idsource'])) $id_source = $options['idsource'];
59
-else $id_source = 1;
59
+if (isset($options['server'])) {
60
+	$globalServer = TRUE;
61
+}
62
+if (isset($options['idsource'])) {
63
+	$id_source = $options['idsource'];
64
+} else {
65
+	$id_source = 1;
66
+}
60 67
 if (isset($globalServer) && $globalServer) {
61
-    if ($globalDebug) echo "Using Server Mode\n";
68
+    if ($globalDebug) {
69
+    	echo "Using Server Mode\n";
70
+    }
62 71
     $SI=new SpotterServer();
63
-} else $SI=new SpotterImport($Connection->db);
72
+} else {
73
+	$SI=new SpotterImport($Connection->db);
74
+}
64 75
 //$APRS=new APRS($Connection->db);
65 76
 $SBS=new SBS();
66 77
 $ACARS=new ACARS($Connection->db);
@@ -78,7 +89,9 @@  discard block
 block discarded – undo
78 89
 }
79 90
 
80 91
 // let's try and connect
81
-if ($globalDebug) echo "Connecting...\n";
92
+if ($globalDebug) {
93
+	echo "Connecting...\n";
94
+}
82 95
 $use_aprs = false;
83 96
 $aprs_full = false;
84 97
 $reset = 0;
@@ -87,7 +100,9 @@  discard block
 block discarded – undo
87 100
     $ip = gethostbyname($host);
88 101
     $s = socket_create(AF_INET, SOCK_STREAM, 0);
89 102
     $r = @socket_connect($s, $ip, $port);
90
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
103
+    if (!socket_set_nonblock($s)) {
104
+    	echo "Unable to set nonblock on socket\n";
105
+    }
91 106
     if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92 107
         return $s;
93 108
     }
@@ -115,7 +130,9 @@  discard block
 block discarded – undo
115 130
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116 131
     global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117 132
     $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
133
+    if ($globalDebug) {
134
+    	echo 'Connect to all...'."\n";
135
+    }
119 136
     foreach ($hosts as $id => $value) {
120 137
 	$host = $value['host'];
121 138
 	$globalSources[$id]['last_exec'] = 0;
@@ -125,27 +142,37 @@  discard block
 block discarded – undo
125 142
         	//$formats[$id] = 'deltadbtxt';
126 143
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 144
         	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
145
+        	if ($globalDebug) {
146
+        		echo "Connect to deltadb source (".$host.")...\n";
147
+        	}
129 148
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130 149
         	//$formats[$id] = 'vatsimtxt';
131 150
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 151
         	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
152
+        	if ($globalDebug) {
153
+        		echo "Connect to vatsim source (".$host.")...\n";
154
+        	}
134 155
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135 156
         	//$formats[$id] = 'aircraftlistjson';
136 157
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 158
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
159
+        	if ($globalDebug) {
160
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
161
+        	}
139 162
     	    } else if (preg_match('/opensky/i',$host)) {
140 163
         	//$formats[$id] = 'aircraftlistjson';
141 164
         	$globalSources[$id]['format'] = 'opensky';
142 165
         	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
166
+        	if ($globalDebug) {
167
+        		echo "Connect to opensky source (".$host.")...\n";
168
+        	}
144 169
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145 170
         	//$formats[$id] = 'radarvirtueljson';
146 171
         	$globalSources[$id]['format'] = 'radarvirtueljson';
147 172
         	//$last_exec['radarvirtueljson'] = 0;
148
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
173
+        	if ($globalDebug) {
174
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
175
+        	}
149 176
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150 177
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151 178
         	    exit(0);
@@ -154,7 +181,9 @@  discard block
 block discarded – undo
154 181
         	//$formats[$id] = 'planeupdatefaa';
155 182
         	$globalSources[$id]['format'] = 'planeupdatefaa';
156 183
         	//$last_exec['planeupdatefaa'] = 0;
157
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
184
+        	if ($globalDebug) {
185
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
186
+        	}
158 187
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159 188
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160 189
         	    exit(0);
@@ -163,26 +192,36 @@  discard block
 block discarded – undo
163 192
         	//$formats[$id] = 'phpvmacars';
164 193
         	$globalSources[$id]['format'] = 'phpvmacars';
165 194
         	//$last_exec['phpvmacars'] = 0;
166
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
195
+        	if ($globalDebug) {
196
+        		echo "Connect to phpvmacars source (".$host.")...\n";
197
+        	}
167 198
             } else if (preg_match('/VAM-json.php$/i',$host)) {
168 199
         	//$formats[$id] = 'phpvmacars';
169 200
         	$globalSources[$id]['format'] = 'vam';
170
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
201
+        	if ($globalDebug) {
202
+        		echo "Connect to Vam source (".$host.")...\n";
203
+        	}
171 204
             } else if (preg_match('/whazzup/i',$host)) {
172 205
         	//$formats[$id] = 'whazzup';
173 206
         	$globalSources[$id]['format'] = 'whazzup';
174 207
         	//$last_exec['whazzup'] = 0;
175
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
208
+        	if ($globalDebug) {
209
+        		echo "Connect to whazzup source (".$host.")...\n";
210
+        	}
176 211
             } else if (preg_match('/recentpireps/i',$host)) {
177 212
         	//$formats[$id] = 'pirepsjson';
178 213
         	$globalSources[$id]['format'] = 'pirepsjson';
179 214
         	//$last_exec['pirepsjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
215
+        	if ($globalDebug) {
216
+        		echo "Connect to pirepsjson source (".$host.")...\n";
217
+        	}
181 218
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182 219
         	//$formats[$id] = 'fr24json';
183 220
         	$globalSources[$id]['format'] = 'fr24json';
184 221
         	//$last_exec['fr24json'] = 0;
185
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
222
+        	if ($globalDebug) {
223
+        		echo "Connect to fr24 source (".$host.")...\n";
224
+        	}
186 225
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187 226
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188 227
         	    exit(0);
@@ -191,10 +230,14 @@  discard block
 block discarded – undo
191 230
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192 231
         	//$formats[$id] = 'tsv';
193 232
         	$globalSources[$id]['format'] = 'tsv';
194
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
233
+        	if ($globalDebug) {
234
+        		echo "Connect to tsv source (".$host.")...\n";
235
+        	}
195 236
             }
196 237
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
238
+        	if ($globalDebug) {
239
+        		echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
240
+        	}
198 241
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199 242
 	    $hostport = explode(':',$host);
200 243
 	    if (isset($hostport[1])) {
@@ -231,17 +274,25 @@  discard block
 block discarded – undo
231 274
         		//$formats[$id] = 'beast';
232 275
         		$globalSources[$id]['format'] = 'beast';
233 276
 		    //} else $formats[$id] = 'sbs';
234
-		    } else $globalSources[$id]['format'] = 'sbs';
277
+		    } else {
278
+		    	$globalSources[$id]['format'] = 'sbs';
279
+		    }
235 280
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
236 281
 		}
237
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
282
+		if ($globalDebug) {
283
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
284
+		}
238 285
             } else {
239
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
286
+		if ($globalDebug) {
287
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
288
+		}
240 289
     	    }
241 290
         }
242 291
     }
243 292
 }
244
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
293
+if (!isset($globalMinFetch)) {
294
+	$globalMinFetch = 15;
295
+}
245 296
 
246 297
 // Initialize all
247 298
 $status = array();
@@ -249,13 +300,19 @@  discard block
 block discarded – undo
249 300
 $formats = array();
250 301
 $last_exec = array();
251 302
 $time = time();
252
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
253
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
254
-else $timeout = 20;
303
+if (isset($globalSourcesTimeout)) {
304
+	$timeout = $globalSourcesTimeOut;
305
+} else if (isset($globalSBS1TimeOut)) {
306
+	$timeout = $globalSBS1TimeOut;
307
+} else {
308
+	$timeout = 20;
309
+}
255 310
 $errno = '';
256 311
 $errstr='';
257 312
 
258
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
313
+if (!isset($globalDaemon)) {
314
+	$globalDaemon = TRUE;
315
+}
259 316
 /* Initiate connections to all the hosts simultaneously */
260 317
 //connect_all($hosts);
261 318
 //connect_all($globalSources);
@@ -275,7 +332,9 @@  discard block
 block discarded – undo
275 332
     if (isset($source['format']) && $source['format'] == 'aprs') {
276 333
 	$aprs_connect = 0;
277 334
 	$use_aprs = true;
278
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
335
+	if (isset($source['port']) && $source['port'] == '10152') {
336
+		$aprs_full = true;
337
+	}
279 338
 	break;
280 339
     }
281 340
 }
@@ -286,23 +345,43 @@  discard block
 block discarded – undo
286 345
 	$aprs_connect = 0;
287 346
 	$aprs_keep = 120;
288 347
 	$aprs_last_tx = time();
289
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
290
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
291
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
292
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
293
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
294
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
295
-	if ($aprs_full) $aprs_filter = '';
348
+	if (isset($globalAPRSversion)) {
349
+		$aprs_version = $globalAPRSversion;
350
+	} else {
351
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
352
+	}
353
+	if (isset($globalAPRSssid)) {
354
+		$aprs_ssid = $globalAPRSssid;
355
+	} else {
356
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
357
+	}
358
+	if (isset($globalAPRSfilter)) {
359
+		$aprs_filter = $globalAPRSfilter;
360
+	} else {
361
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
362
+	}
363
+	if ($aprs_full) {
364
+		$aprs_filter = '';
365
+	}
296 366
 
297
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n";
298
-	else $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version}\n";
299
-}
367
+	if ($aprs_filter != '') {
368
+		$aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n";
369
+	} else {
370
+		$aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version}\n";
371
+	}
372
+	}
300 373
 
301 374
 // connected - lets do some work
302
-if ($globalDebug) echo "Connected!\n";
375
+if ($globalDebug) {
376
+	echo "Connected!\n";
377
+}
303 378
 sleep(1);
304
-if ($globalDebug) echo "SCAN MODE \n\n";
305
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
379
+if ($globalDebug) {
380
+	echo "SCAN MODE \n\n";
381
+}
382
+if (!isset($globalCronEnd)) {
383
+	$globalCronEnd = 60;
384
+}
306 385
 $endtime = time()+$globalCronEnd;
307 386
 $i = 1;
308 387
 $tt = array();
@@ -316,20 +395,28 @@  discard block
 block discarded – undo
316 395
 
317 396
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
318 397
 while ($i > 0) {
319
-    if (!$globalDaemon) $i = $endtime-time();
398
+    if (!$globalDaemon) {
399
+    	$i = $endtime-time();
400
+    }
320 401
     // Delete old ATC
321 402
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
322
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
403
+	if ($globalDebug) {
404
+		echo 'Delete old ATC...'."\n";
405
+	}
323 406
         $ATC->deleteOldATC();
324 407
     }
325 408
     
326 409
     if (count($last_exec) > 0) {
327 410
 	$max = $globalMinFetch;
328 411
 	foreach ($last_exec as $last) {
329
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
412
+	    if ((time() - $last['last']) < $max) {
413
+	    	$max = time() - $last['last'];
414
+	    }
330 415
 	}
331 416
 	if ($max != $globalMinFetch) {
332
-	    if ($globalDebug) echo 'Sleeping...'."\n";
417
+	    if ($globalDebug) {
418
+	    	echo 'Sleeping...'."\n";
419
+	    }
333 420
 	    sleep($globalMinFetch-$max+2);
334 421
 	}
335 422
     }
@@ -338,11 +425,15 @@  discard block
 block discarded – undo
338 425
     //foreach ($formats as $id => $value) {
339 426
     foreach ($globalSources as $id => $value) {
340 427
 	date_default_timezone_set('UTC');
341
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
428
+	if (!isset($last_exec[$id]['last'])) {
429
+		$last_exec[$id]['last'] = 0;
430
+	}
342 431
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
343 432
 	    //$buffer = $Common->getData($hosts[$id]);
344 433
 	    $buffer = $Common->getData($value['host']);
345
-	    if ($buffer != '') $reset = 0;
434
+	    if ($buffer != '') {
435
+	    	$reset = 0;
436
+	    }
346 437
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347 438
 	    $buffer = explode('\n',$buffer);
348 439
 	    foreach ($buffer as $line) {
@@ -351,19 +442,38 @@  discard block
 block discarded – undo
351 442
 	            $data = array();
352 443
 	            $data['hex'] = $line[1]; // hex
353 444
 	            $data['ident'] = $line[2]; // ident
354
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
355
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
356
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
357
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
358
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
445
+	            if (isset($line[3])) {
446
+	            	$data['altitude'] = $line[3];
447
+	            }
448
+	            // altitude
449
+	            if (isset($line[4])) {
450
+	            	$data['speed'] = $line[4];
451
+	            }
452
+	            // speed
453
+	            if (isset($line[5])) {
454
+	            	$data['heading'] = $line[5];
455
+	            }
456
+	            // heading
457
+	            if (isset($line[6])) {
458
+	            	$data['latitude'] = $line[6];
459
+	            }
460
+	            // lat
461
+	            if (isset($line[7])) {
462
+	            	$data['longitude'] = $line[7];
463
+	            }
464
+	            // long
359 465
 	            $data['verticalrate'] = ''; // vertical rate
360 466
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
361 467
 	            $data['emergency'] = ''; // emergency
362 468
 		    $data['datetime'] = date('Y-m-d H:i:s');
363 469
 		    $data['format_source'] = 'deltadbtxt';
364 470
     		    $data['id_source'] = $id_source;
365
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
366
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
471
+		    if (isset($value['name']) && $value['name'] != '') {
472
+		    	$data['source_name'] = $value['name'];
473
+		    }
474
+		    if (isset($value['sourcestats'])) {
475
+		    	$data['sourcestats'] = $value['sourcestats'];
476
+		    }
367 477
     		    $SI->add($data);
368 478
 		    unset($data);
369 479
     		}
@@ -381,16 +491,28 @@  discard block
 block discarded – undo
381 491
     		    $line = explode(':', $line);
382 492
     		    if (count($line) > 30 && $line[0] != 'callsign') {
383 493
 			$data = array();
384
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
385
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
494
+			if (isset($line[37]) && $line[37] != '') {
495
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
496
+			} else {
497
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
498
+			}
386 499
 			$data['pilot_id'] = $line[1];
387 500
 			$data['pilot_name'] = $line[2];
388 501
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
389 502
 			$data['ident'] = $line[0]; // ident
390
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
503
+			if ($line[7] != '' && $line[7] != 0) {
504
+				$data['altitude'] = $line[7];
505
+			}
506
+			// altitude
391 507
 			$data['speed'] = $line[8]; // speed
392
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
393
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
508
+			if (isset($line[45])) {
509
+				$data['heading'] = $line[45];
510
+			}
511
+			// heading
512
+			elseif (isset($line[38])) {
513
+				$data['heading'] = $line[38];
514
+			}
515
+			// heading
394 516
 			$data['latitude'] = $line[5]; // lat
395 517
 	        	$data['longitude'] = $line[6]; // long
396 518
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -406,7 +528,9 @@  discard block
 block discarded – undo
406 528
 			$data['frequency'] = $line[4];
407 529
 			$data['type'] = $line[18];
408 530
 			$data['range'] = $line[19];
409
-			if (isset($line[35])) $data['info'] = $line[35];
531
+			if (isset($line[35])) {
532
+				$data['info'] = $line[35];
533
+			}
410 534
     			$data['id_source'] = $id_source;
411 535
 	    		//$data['arrival_airport_time'] = ;
412 536
 	    		if ($line[9] != '') {
@@ -420,24 +544,41 @@  discard block
 block discarded – undo
420 544
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
421 545
 	    		*/
422 546
 	    		$data['format_source'] = $value['format'];
423
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
424
-    			if ($line[3] == 'PILOT') $SI->add($data);
425
-			elseif ($line[3] == 'ATC') {
547
+			if (isset($value['name']) && $value['name'] != '') {
548
+				$data['source_name'] = $value['name'];
549
+			}
550
+    			if ($line[3] == 'PILOT') {
551
+    				$SI->add($data);
552
+    			} elseif ($line[3] == 'ATC') {
426 553
 				//print_r($data);
427 554
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
428 555
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
429 556
 				$typec = substr($data['ident'],-3);
430
-				if ($typec == 'APP') $data['type'] = 'Approach';
431
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
432
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
433
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
434
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
435
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
436
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
437
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
438
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
439
-				if (!isset($data['source_name'])) $data['source_name'] = '';
440
-				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']);
557
+				if ($typec == 'APP') {
558
+					$data['type'] = 'Approach';
559
+				} elseif ($typec == 'TWR') {
560
+					$data['type'] = 'Tower';
561
+				} elseif ($typec == 'OBS') {
562
+					$data['type'] = 'Observer';
563
+				} elseif ($typec == 'GND') {
564
+					$data['type'] = 'Ground';
565
+				} elseif ($typec == 'DEL') {
566
+					$data['type'] = 'Delivery';
567
+				} elseif ($typec == 'DEP') {
568
+					$data['type'] = 'Departure';
569
+				} elseif ($typec == 'FSS') {
570
+					$data['type'] = 'Flight Service Station';
571
+				} elseif ($typec == 'CTR') {
572
+					$data['type'] = 'Control Radar or Centre';
573
+				} elseif ($data['type'] == '') {
574
+					$data['type'] = 'Observer';
575
+				}
576
+				if (!isset($data['source_name'])) {
577
+					$data['source_name'] = '';
578
+				}
579
+				if (isset($ATC)) {
580
+					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']);
581
+				}
441 582
 			}
442 583
     			unset($data);
443 584
     		    }
@@ -456,26 +597,55 @@  discard block
 block discarded – undo
456 597
 		foreach ($all_data['acList'] as $line) {
457 598
 		    $data = array();
458 599
 		    $data['hex'] = $line['Icao']; // hex
459
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
460
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
461
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
462
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
463
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
464
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
600
+		    if (isset($line['Call'])) {
601
+		    	$data['ident'] = $line['Call'];
602
+		    }
603
+		    // ident
604
+		    if (isset($line['Alt'])) {
605
+		    	$data['altitude'] = $line['Alt'];
606
+		    }
607
+		    // altitude
608
+		    if (isset($line['Spd'])) {
609
+		    	$data['speed'] = $line['Spd'];
610
+		    }
611
+		    // speed
612
+		    if (isset($line['Trak'])) {
613
+		    	$data['heading'] = $line['Trak'];
614
+		    }
615
+		    // heading
616
+		    if (isset($line['Lat'])) {
617
+		    	$data['latitude'] = $line['Lat'];
618
+		    }
619
+		    // lat
620
+		    if (isset($line['Long'])) {
621
+		    	$data['longitude'] = $line['Long'];
622
+		    }
623
+		    // long
465 624
 		    //$data['verticalrate'] = $line['']; // verticale rate
466
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
625
+		    if (isset($line['Sqk'])) {
626
+		    	$data['squawk'] = $line['Sqk'];
627
+		    }
628
+		    // squawk
467 629
 		    $data['emergency'] = ''; // emergency
468
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
630
+		    if (isset($line['Reg'])) {
631
+		    	$data['registration'] = $line['Reg'];
632
+		    }
469 633
 		    /*
470 634
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
471 635
 		    else $data['datetime'] = date('Y-m-d H:i:s');
472 636
 		    */
473 637
 		    $data['datetime'] = date('Y-m-d H:i:s');
474
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
638
+		    if (isset($line['Type'])) {
639
+		    	$data['aircraft_icao'] = $line['Type'];
640
+		    }
475 641
 	    	    $data['format_source'] = 'aircraftlistjson';
476 642
 		    $data['id_source'] = $id_source;
477
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
478
-		    if (isset($data['datetime'])) $SI->add($data);
643
+		    if (isset($value['name']) && $value['name'] != '') {
644
+		    	$data['source_name'] = $value['name'];
645
+		    }
646
+		    if (isset($data['datetime'])) {
647
+		    	$SI->add($data);
648
+		    }
479 649
 		    unset($data);
480 650
 		}
481 651
 	    } else {
@@ -495,7 +665,9 @@  discard block
 block discarded – undo
495 665
 		    $data['datetime'] = date('Y-m-d H:i:s');
496 666
 	    	    $data['format_source'] = 'aircraftlistjson';
497 667
     		    $data['id_source'] = $id_source;
498
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
668
+		    if (isset($value['name']) && $value['name'] != '') {
669
+		    	$data['source_name'] = $value['name'];
670
+		    }
499 671
 		    $SI->add($data);
500 672
 		    unset($data);
501 673
 		}
@@ -531,7 +703,9 @@  discard block
 block discarded – undo
531 703
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
532 704
 	    	    $data['format_source'] = 'planeupdatefaa';
533 705
     		    $data['id_source'] = $id_source;
534
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
706
+		    if (isset($value['name']) && $value['name'] != '') {
707
+		    	$data['source_name'] = $value['name'];
708
+		    }
535 709
 		    $SI->add($data);
536 710
 		    unset($data);
537 711
 		}
@@ -571,7 +745,9 @@  discard block
 block discarded – undo
571 745
 	    //$buffer = $Common->getData($hosts[$id]);
572 746
 	    $buffer = $Common->getData($value['host']);
573 747
 	    $all_data = json_decode($buffer,true);
574
-	    if (!empty($all_data)) $reset = 0;
748
+	    if (!empty($all_data)) {
749
+	    	$reset = 0;
750
+	    }
575 751
 	    foreach ($all_data as $key => $line) {
576 752
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
577 753
 		    $data = array();
@@ -592,7 +768,9 @@  discard block
 block discarded – undo
592 768
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
593 769
 	    	    $data['format_source'] = 'fr24json';
594 770
     		    $data['id_source'] = $id_source;
595
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
771
+		    if (isset($value['name']) && $value['name'] != '') {
772
+		    	$data['source_name'] = $value['name'];
773
+		    }
596 774
 		    $SI->add($data);
597 775
 		    unset($data);
598 776
 		}
@@ -616,23 +794,39 @@  discard block
 block discarded – undo
616 794
 		    if (isset($line['inf'])) {
617 795
 			$data = array();
618 796
 			$data['hex'] = $line['inf']['ia'];
619
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
797
+			if (isset($line['inf']['cs'])) {
798
+				$data['ident'] = $line['inf']['cs'];
799
+			}
800
+			//$line[13]
620 801
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
621
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
622
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
802
+	    		if (isset($line['inf']['gs'])) {
803
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
804
+	    		}
805
+	    		// speed
806
+	    		if (isset($line['inf']['tr'])) {
807
+	    			$data['heading'] = $line['inf']['tr'];
808
+	    		}
809
+	    		// heading
623 810
 	    		$data['latitude'] = $line['pt'][0]; // lat
624 811
 	    		$data['longitude'] = $line['pt'][1]; // long
625 812
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
626
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
813
+	    		if (isset($line['inf']['sq'])) {
814
+	    			$data['squawk'] = $line['inf']['sq'];
815
+	    		}
816
+	    		// squawk
627 817
 	    		//$data['aircraft_icao'] = $line[8];
628
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
818
+	    		if (isset($line['inf']['rc'])) {
819
+	    			$data['registration'] = $line['inf']['rc'];
820
+	    		}
629 821
 			//$data['departure_airport_iata'] = $line[11];
630 822
 			//$data['arrival_airport_iata'] = $line[12];
631 823
 	    		//$data['emergency'] = ''; // emergency
632 824
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
633 825
 	    		$data['format_source'] = 'radarvirtueljson';
634 826
     			$data['id_source'] = $id_source;
635
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
827
+			if (isset($value['name']) && $value['name'] != '') {
828
+				$data['source_name'] = $value['name'];
829
+			}
636 830
 			$SI->add($data);
637 831
 			unset($data);
638 832
 		    }
@@ -653,29 +847,62 @@  discard block
 block discarded – undo
653 847
 		    $data['id'] = $line['id'];
654 848
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
655 849
 		    $data['ident'] = $line['callsign']; // ident
656
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
657
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
658
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
659
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
660
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
661
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
850
+		    if (isset($line['pilotid'])) {
851
+		    	$data['pilot_id'] = $line['pilotid'];
852
+		    }
853
+		    // pilot id
854
+		    if (isset($line['name'])) {
855
+		    	$data['pilot_name'] = $line['name'];
856
+		    }
857
+		    // pilot name
858
+		    if (isset($line['alt'])) {
859
+		    	$data['altitude'] = $line['alt'];
860
+		    }
861
+		    // altitude
862
+		    if (isset($line['gs'])) {
863
+		    	$data['speed'] = $line['gs'];
864
+		    }
865
+		    // speed
866
+		    if (isset($line['heading'])) {
867
+		    	$data['heading'] = $line['heading'];
868
+		    }
869
+		    // heading
870
+		    if (isset($line['route'])) {
871
+		    	$data['waypoints'] = $line['route'];
872
+		    }
873
+		    // route
662 874
 		    $data['latitude'] = $line['lat']; // lat
663 875
 		    $data['longitude'] = $line['lon']; // long
664 876
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
665 877
 		    //$data['squawk'] = $line['squawk']; // squawk
666 878
 		    //$data['emergency'] = ''; // emergency
667
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
668
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
669
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
879
+		    if (isset($line['depicao'])) {
880
+		    	$data['departure_airport_icao'] = $line['depicao'];
881
+		    }
882
+		    if (isset($line['deptime'])) {
883
+		    	$data['departure_airport_time'] = $line['deptime'];
884
+		    }
885
+		    if (isset($line['arricao'])) {
886
+		    	$data['arrival_airport_icao'] = $line['arricao'];
887
+		    }
670 888
 		    //$data['arrival_airport_time'] = $line['arrtime'];
671
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
672
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
673
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
674
-		    else $data['info'] = '';
889
+		    if (isset($line['aircraft'])) {
890
+		    	$data['aircraft_icao'] = $line['aircraft'];
891
+		    }
892
+		    if (isset($line['transponder'])) {
893
+		    	$data['squawk'] = $line['transponder'];
894
+		    }
895
+		    if (isset($line['atis'])) {
896
+		    	$data['info'] = $line['atis'];
897
+		    } else {
898
+		    	$data['info'] = '';
899
+		    }
675 900
 		    $data['format_source'] = 'pireps';
676 901
     		    $data['id_source'] = $id_source;
677 902
 		    $data['datetime'] = date('Y-m-d H:i:s');
678
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
903
+		    if (isset($value['name']) && $value['name'] != '') {
904
+		    	$data['source_name'] = $value['name'];
905
+		    }
679 906
 		    if ($line['icon'] == 'plane') {
680 907
 			$SI->add($data);
681 908
 		    //    print_r($data);
@@ -684,16 +911,28 @@  discard block
 block discarded – undo
684 911
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
685 912
 			$typec = substr($data['ident'],-3);
686 913
 			$data['type'] = '';
687
-			if ($typec == 'APP') $data['type'] = 'Approach';
688
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
689
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
690
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
691
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
692
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
693
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
694
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
695
-			else $data['type'] = 'Observer';
696
-			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']);
914
+			if ($typec == 'APP') {
915
+				$data['type'] = 'Approach';
916
+			} elseif ($typec == 'TWR') {
917
+				$data['type'] = 'Tower';
918
+			} elseif ($typec == 'OBS') {
919
+				$data['type'] = 'Observer';
920
+			} elseif ($typec == 'GND') {
921
+				$data['type'] = 'Ground';
922
+			} elseif ($typec == 'DEL') {
923
+				$data['type'] = 'Delivery';
924
+			} elseif ($typec == 'DEP') {
925
+				$data['type'] = 'Departure';
926
+			} elseif ($typec == 'FSS') {
927
+				$data['type'] = 'Flight Service Station';
928
+			} elseif ($typec == 'CTR') {
929
+				$data['type'] = 'Control Radar or Centre';
930
+			} else {
931
+				$data['type'] = 'Observer';
932
+			}
933
+			if (isset($ATC)) {
934
+				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']);
935
+			}
697 936
 		    }
698 937
 		    unset($data);
699 938
 		}
@@ -703,7 +942,9 @@  discard block
 block discarded – undo
703 942
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
704 943
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
705 944
 	    //$buffer = $Common->getData($hosts[$id]);
706
-	    if ($globalDebug) echo 'Get Data...'."\n";
945
+	    if ($globalDebug) {
946
+	    	echo 'Get Data...'."\n";
947
+	    }
707 948
 	    $buffer = $Common->getData($value['host']);
708 949
 	    $all_data = json_decode($buffer,true);
709 950
 	    if ($buffer != '' && is_array($all_data)) {
@@ -711,10 +952,16 @@  discard block
 block discarded – undo
711 952
 		foreach ($all_data as $line) {
712 953
 	    	    $data = array();
713 954
 	    	    //$data['id'] = $line['id']; // id not usable
714
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
955
+	    	    if (isset($line['pilotid'])) {
956
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
957
+	    	    }
715 958
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
716
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
717
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
959
+	    	    if (isset($line['pilotname'])) {
960
+	    	    	$data['pilot_name'] = $line['pilotname'];
961
+	    	    }
962
+	    	    if (isset($line['pilotid'])) {
963
+	    	    	$data['pilot_id'] = $line['pilotid'];
964
+	    	    }
718 965
 	    	    $data['ident'] = $line['flightnum']; // ident
719 966
 	    	    $data['altitude'] = $line['alt']; // altitude
720 967
 	    	    $data['speed'] = $line['gs']; // speed
@@ -732,27 +979,41 @@  discard block
 block discarded – undo
732 979
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
733 980
     		    $data['arrival_airport_time'] = $line['arrtime'];
734 981
     		    $data['registration'] = $line['aircraft'];
735
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
982
+		    if (isset($line['route'])) {
983
+		    	$data['waypoints'] = $line['route'];
984
+		    }
985
+		    // route
736 986
 		    if (isset($line['aircraftname'])) {
737 987
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
738 988
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
739 989
 	    		$aircraft_data = explode('-',$line['aircraftname']);
740
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
741
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
742
-	    		else {
990
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) {
991
+	    			$data['aircraft_icao'] = $aircraft_data[0];
992
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) {
993
+	    			$data['aircraft_icao'] = $aircraft_data[1];
994
+	    		} else {
743 995
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
744
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
745
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
996
+	    		    if (isset($aircraft_data[1])) {
997
+	    		    	$data['aircraft_icao'] = $aircraft_data[1];
998
+	    		    } else {
999
+	    		    	$data['aircraft_icao'] = $line['aircraftname'];
1000
+	    		    }
746 1001
 	    		}
747 1002
 	    	    }
748
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1003
+    		    if (isset($line['route'])) {
1004
+    		    	$data['waypoints'] = $line['route'];
1005
+    		    }
749 1006
     		    $data['id_source'] = $id_source;
750 1007
 	    	    $data['format_source'] = 'phpvmacars';
751
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1008
+		    if (isset($value['name']) && $value['name'] != '') {
1009
+		    	$data['source_name'] = $value['name'];
1010
+		    }
752 1011
 		    $SI->add($data);
753 1012
 		    unset($data);
754 1013
 		}
755
-		if ($globalDebug) echo 'No more data...'."\n";
1014
+		if ($globalDebug) {
1015
+			echo 'No more data...'."\n";
1016
+		}
756 1017
 		unset($buffer);
757 1018
 		unset($all_data);
758 1019
 	    }
@@ -760,7 +1021,9 @@  discard block
 block discarded – undo
760 1021
     	    $last_exec[$id]['last'] = time();
761 1022
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
762 1023
 	    //$buffer = $Common->getData($hosts[$id]);
763
-	    if ($globalDebug) echo 'Get Data...'."\n";
1024
+	    if ($globalDebug) {
1025
+	    	echo 'Get Data...'."\n";
1026
+	    }
764 1027
 	    $buffer = $Common->getData($value['host']);
765 1028
 	    $all_data = json_decode($buffer,true);
766 1029
 	    if ($buffer != '' && is_array($all_data)) {
@@ -789,15 +1052,22 @@  discard block
 block discarded – undo
789 1052
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
790 1053
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
791 1054
     		    //$data['registration'] = $line['aircraft'];
792
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1055
+		    if (isset($line['route'])) {
1056
+		    	$data['waypoints'] = $line['route'];
1057
+		    }
1058
+		    // route
793 1059
 	    	    $data['aircraft_icao'] = $line['plane_type'];
794 1060
     		    $data['id_source'] = $id_source;
795 1061
 	    	    $data['format_source'] = 'vam';
796
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1062
+		    if (isset($value['name']) && $value['name'] != '') {
1063
+		    	$data['source_name'] = $value['name'];
1064
+		    }
797 1065
 		    $SI->add($data);
798 1066
 		    unset($data);
799 1067
 		}
800
-		if ($globalDebug) echo 'No more data...'."\n";
1068
+		if ($globalDebug) {
1069
+			echo 'No more data...'."\n";
1070
+		}
801 1071
 		unset($buffer);
802 1072
 		unset($all_data);
803 1073
 	    }
@@ -805,7 +1075,9 @@  discard block
 block discarded – undo
805 1075
     	    $last_exec[$id]['last'] = time();
806 1076
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
807 1077
 	} 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') {
808
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1078
+	    if (function_exists('pcntl_fork')) {
1079
+	    	pcntl_signal_dispatch();
1080
+	    }
809 1081
     	    //$last_exec[$id]['last'] = time();
810 1082
 
811 1083
 	    //$read = array( $sockets[$id] );
@@ -813,7 +1085,9 @@  discard block
 block discarded – undo
813 1085
 	    $write = NULL;
814 1086
 	    $e = NULL;
815 1087
 	    $n = socket_select($read, $write, $e, $timeout);
816
-	    if ($e != NULL) var_dump($e);
1088
+	    if ($e != NULL) {
1089
+	    	var_dump($e);
1090
+	    }
817 1091
 	    if ($n > 0) {
818 1092
 		$reset = 0;
819 1093
 		foreach ($read as $nb => $r) {
@@ -835,7 +1109,9 @@  discard block
 block discarded – undo
835 1109
 		    if ($buffer != '') {
836 1110
 			$tt[$format] = 0;
837 1111
 			if ($format == 'acarssbs3') {
838
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1112
+                    	    if ($globalDebug) {
1113
+                    	    	echo 'ACARS : '.$buffer."\n";
1114
+                    	    }
839 1115
 			    $ACARS->add(trim($buffer));
840 1116
 			    $ACARS->deleteLiveAcarsData();
841 1117
 			} elseif ($format == 'raw') {
@@ -844,9 +1120,15 @@  discard block
 block discarded – undo
844 1120
 			    if (is_array($data)) {
845 1121
 				$data['datetime'] = date('Y-m-d H:i:s');
846 1122
 				$data['format_source'] = 'raw';
847
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
848
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
849
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1123
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1124
+					$data['source_name'] = $globalSources[$nb]['name'];
1125
+				}
1126
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1127
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1128
+    				}
1129
+                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1130
+                                	$SI->add($data);
1131
+                                }
850 1132
                             }
851 1133
                         } elseif ($format == 'flightgearsp') {
852 1134
                     	    //echo $buffer."\n";
@@ -864,11 +1146,15 @@  discard block
 block discarded – undo
864 1146
 				$data['speed'] = round($line[5]*1.94384);
865 1147
 				$data['datetime'] = date('Y-m-d H:i:s');
866 1148
 				$data['format_source'] = 'flightgearsp';
867
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1149
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1150
+					$SI->add($data);
1151
+				}
868 1152
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
869 1153
 			    }
870 1154
                         } elseif ($format == 'acars') {
871
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1155
+                    	    if ($globalDebug) {
1156
+                    	    	echo 'ACARS : '.$buffer."\n";
1157
+                    	    }
872 1158
 			    $ACARS->add(trim($buffer));
873 1159
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
874 1160
 			    $ACARS->deleteLiveAcarsData();
@@ -889,7 +1175,9 @@  discard block
 block discarded – undo
889 1175
 				    $aircraft_type = $line[10];
890 1176
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
891 1177
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
892
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1178
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1179
+				    	$SI->add($data);
1180
+				    }
893 1181
 				}
894 1182
 			    }
895 1183
 			} elseif ($format == 'beast') {
@@ -905,21 +1193,43 @@  discard block
 block discarded – undo
905 1193
     				$data['hex'] = $lined['hexid'];
906 1194
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
907 1195
     				$data['datetime'] = date('Y-m-d H:i:s');;
908
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
909
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
910
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
911
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
912
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
913
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
914
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1196
+    				if (isset($lined['ident'])) {
1197
+    					$data['ident'] = $lined['ident'];
1198
+    				}
1199
+    				if (isset($lined['lat'])) {
1200
+    					$data['latitude'] = $lined['lat'];
1201
+    				}
1202
+    				if (isset($lined['lon'])) {
1203
+    					$data['longitude'] = $lined['lon'];
1204
+    				}
1205
+    				if (isset($lined['speed'])) {
1206
+    					$data['speed'] = $lined['speed'];
1207
+    				}
1208
+    				if (isset($lined['squawk'])) {
1209
+    					$data['squawk'] = $lined['squawk'];
1210
+    				}
1211
+    				if (isset($lined['alt'])) {
1212
+    					$data['altitude'] = $lined['alt'];
1213
+    				}
1214
+    				if (isset($lined['heading'])) {
1215
+    					$data['heading'] = $lined['heading'];
1216
+    				}
915 1217
     				$data['id_source'] = $id_source;
916 1218
     				$data['format_source'] = 'tsv';
917
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
918
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
919
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1219
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1220
+    					$data['source_name'] = $globalSources[$nb]['name'];
1221
+    				}
1222
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1223
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1224
+    				}
1225
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1226
+    					$SI->add($data);
1227
+    				}
920 1228
     				unset($lined);
921 1229
     				unset($data);
922
-    			    } else $error = true;
1230
+    			    } else {
1231
+    			    	$error = true;
1232
+    			    }
923 1233
 			} elseif ($format == 'aprs' && $use_aprs) {
924 1234
 			    if ($aprs_connect == 0) {
925 1235
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -944,36 +1254,50 @@  discard block
 block discarded – undo
944 1254
 				    $data = array();
945 1255
 				    //print_r($line);
946 1256
 				    $data['hex'] = $line['address'];
947
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
948
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1257
+				    if (isset($line['timestamp'])) {
1258
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1259
+				    } else {
1260
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1261
+				    }
949 1262
 				    //$data['datetime'] = date('Y-m-d H:i:s');
950 1263
 				    $data['ident'] = $line['ident'];
951 1264
 				    $data['latitude'] = $line['latitude'];
952 1265
 				    $data['longitude'] = $line['longitude'];
953 1266
 				    //$data['verticalrate'] = $line[16];
954
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
955
-				    else $data['speed'] = 0;
1267
+				    if (isset($line['speed'])) {
1268
+				    	$data['speed'] = $line['speed'];
1269
+				    } else {
1270
+				    	$data['speed'] = 0;
1271
+				    }
956 1272
 				    $data['altitude'] = $line['altitude'];
957
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1273
+				    if (isset($line['heading'])) {
1274
+				    	$data['heading'] = $line['heading'];
1275
+				    }
958 1276
 				    //else $data['heading'] = 0;
959 1277
 				    $data['aircraft_type'] = $line['stealth'];
960
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1278
+				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) {
1279
+				    	$data['noarchive'] = true;
1280
+				    }
961 1281
     				    $data['id_source'] = $id_source;
962 1282
 				    $data['format_source'] = 'aprs';
963 1283
 				    $data['source_name'] = $line['source'];
964
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1284
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1285
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1286
+    				    }
965 1287
 				    $currentdate = date('Y-m-d H:i:s');
966 1288
 				    $aprsdate = strtotime($data['datetime']);
967 1289
 				    // Accept data if time <= system time + 20s
968 1290
 				    if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
969 1291
 					$send = $SI->add($data);
970 1292
 				    } else {
971
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
972
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1293
+					if ($line['stealth'] != 0) {
1294
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1295
+					} else {
1296
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1297
+					}
973 1298
 				    }
974 1299
 				    unset($data);
975
-				} 
976
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1300
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
977 1301
 					echo '!! Weather Station not yet supported'."\n";
978 1302
 				}
979 1303
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
@@ -1006,25 +1330,42 @@  discard block
 block discarded – undo
1006 1330
     				$data['ground'] = $line[21];
1007 1331
     				$data['emergency'] = $line[19];
1008 1332
     				$data['format_source'] = 'sbs';
1009
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1010
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1333
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1334
+					$data['source_name'] = $globalSources[$nb]['name'];
1335
+				}
1336
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1337
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1338
+    				}
1011 1339
     				$data['id_source'] = $id_source;
1012
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1013
-    				else $error = true;
1340
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1341
+    					$send = $SI->add($data);
1342
+    				} else {
1343
+    					$error = true;
1344
+    				}
1014 1345
     				unset($data);
1015
-    			    } else $error = true;
1346
+    			    } else {
1347
+    			    	$error = true;
1348
+    			    }
1016 1349
 			    if ($error) {
1017 1350
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1018
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1351
+					if ($globalDebug) {
1352
+						echo "Not a message. Ignoring... \n";
1353
+					}
1019 1354
 				} else {
1020
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1355
+					if ($globalDebug) {
1356
+						echo "Wrong line format. Ignoring... \n";
1357
+					}
1021 1358
 					if ($globalDebug) {
1022 1359
 						echo $buffer;
1023 1360
 						print_r($line);
1024 1361
 					}
1025 1362
 					//socket_close($r);
1026
-					if ($globalDebug) echo "Reconnect after an error...\n";
1027
-					if ($format == 'aprs') $aprs_connect = 0;
1363
+					if ($globalDebug) {
1364
+						echo "Reconnect after an error...\n";
1365
+					}
1366
+					if ($format == 'aprs') {
1367
+						$aprs_connect = 0;
1368
+					}
1028 1369
 					$sourceer[$nb] = $globalSources[$nb];
1029 1370
 					connect_all($sourceer);
1030 1371
 					$sourceer = array();
@@ -1032,10 +1373,14 @@  discard block
 block discarded – undo
1032 1373
 			    }
1033 1374
 			}
1034 1375
 			// Sleep for xxx microseconds
1035
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1376
+			if (isset($globalSBSSleep)) {
1377
+				usleep($globalSBSSleep);
1378
+			}
1036 1379
 		    } else {
1037 1380
 			if ($format == 'flightgearmp') {
1038
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1381
+			    	if ($globalDebug) {
1382
+			    		echo "Reconnect FlightGear MP...";
1383
+			    	}
1039 1384
 				//@socket_close($r);
1040 1385
 				sleep($globalMinFetch);
1041 1386
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1044,10 +1389,15 @@  discard block
 block discarded – undo
1044 1389
 				break;
1045 1390
 				
1046 1391
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1047
-			    if (isset($tt[$format])) $tt[$format]++;
1048
-			    else $tt[$format] = 0;
1392
+			    if (isset($tt[$format])) {
1393
+			    	$tt[$format]++;
1394
+			    } else {
1395
+			    	$tt[$format] = 0;
1396
+			    }
1049 1397
 			    if ($tt[$format] > 30) {
1050
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1398
+				if ($globalDebug) {
1399
+					echo "ERROR : Reconnect ".$format."...";
1400
+				}
1051 1401
 				//@socket_close($r);
1052 1402
 				sleep(2);
1053 1403
 				$aprs_connect = 0;
@@ -1063,12 +1413,18 @@  discard block
 block discarded – undo
1063 1413
 		}
1064 1414
 	    } else {
1065 1415
 		$error = socket_strerror(socket_last_error());
1066
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1416
+		if ($globalDebug) {
1417
+			echo "ERROR : socket_select give this error ".$error . "\n";
1418
+		}
1067 1419
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1068
-			if (isset($globalDebug)) echo "Restarting...\n";
1420
+			if (isset($globalDebug)) {
1421
+				echo "Restarting...\n";
1422
+			}
1069 1423
 			// Restart the script if possible
1070 1424
 			if (is_array($sockets)) {
1071
-			    if ($globalDebug) echo "Shutdown all sockets...";
1425
+			    if ($globalDebug) {
1426
+			    	echo "Shutdown all sockets...";
1427
+			    }
1072 1428
 			    
1073 1429
 			    foreach ($sockets as $sock) {
1074 1430
 				@socket_shutdown($sock,2);
@@ -1076,18 +1432,24 @@  discard block
 block discarded – undo
1076 1432
 			    }
1077 1433
 			    
1078 1434
 			}
1079
-			if ($globalDebug) echo "Restart all connections...";
1435
+			if ($globalDebug) {
1436
+				echo "Restart all connections...";
1437
+			}
1080 1438
 			sleep(2);
1081 1439
 			$time = time();
1082 1440
 			//connect_all($hosts);
1083 1441
 			$aprs_connect = 0;
1084
-			if ($reset > 40) exit('Too many attempts...');
1442
+			if ($reset > 40) {
1443
+				exit('Too many attempts...');
1444
+			}
1085 1445
 			connect_all($globalSources);
1086 1446
 		}
1087 1447
 	    }
1088 1448
 	}
1089 1449
 	if ($globalDaemon === false) {
1090
-	    if ($globalDebug) echo 'Check all...'."\n";
1450
+	    if ($globalDebug) {
1451
+	    	echo 'Check all...'."\n";
1452
+	    }
1091 1453
 	    $SI->checkAll();
1092 1454
 	}
1093 1455
     }
Please login to merge, or discard this patch.