Completed
Push — master ( 87b863...3be42e )
by Yannick
104:15 queued 75:58
created
require/class.MarineArchive.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 	/**
15 15
 	* Get SQL query part for filter used
16 16
 	* @param Array $filter the filter
17
-	* @return Array the SQL part
17
+	* @return string the SQL part
18 18
 	*/
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
Please login to merge, or discard this patch.
Indentation   +589 added lines, -589 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 	}
11 11
 
12 12
 	/**
13
-	* Get SQL query part for filter used
14
-	* @param Array $filter the filter
15
-	* @return Array the SQL part
16
-	*/
13
+	 * Get SQL query part for filter used
14
+	 * @param Array $filter the filter
15
+	 * @return Array the SQL part
16
+	 */
17 17
 	public function getFilter($filter = array(),$where = false,$and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 		$filters = array();
@@ -110,44 +110,44 @@  discard block
 block discarded – undo
110 110
 	}
111 111
 
112 112
 
113
-        /**
114
-        * Gets all the spotter information based on a particular callsign
115
-        *
116
-        * @return Array the spotter information
117
-        *
118
-        */
119
-        public function getLastArchiveMarineDataByIdent($ident)
120
-        {
113
+		/**
114
+		 * Gets all the spotter information based on a particular callsign
115
+		 *
116
+		 * @return Array the spotter information
117
+		 *
118
+		 */
119
+		public function getLastArchiveMarineDataByIdent($ident)
120
+		{
121 121
 		$Marine = new Marine($this->db);
122
-                date_default_timezone_set('UTC');
122
+				date_default_timezone_set('UTC');
123 123
 
124
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
125
-                //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
126
-                $query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
124
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
125
+				//$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
126
+				$query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
127 127
 
128
-                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
128
+				$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
129 129
 
130
-                return $spotter_array;
131
-        }
130
+				return $spotter_array;
131
+		}
132 132
 
133 133
 
134
-        /**
135
-        * Gets last the spotter information based on a particular id
136
-        *
137
-        * @return Array the spotter information
138
-        *
139
-        */
140
-        public function getLastArchiveMarineDataById($id)
141
-        {
142
-    		$Marine = new Marine($this->db);
143
-                date_default_timezone_set('UTC');
144
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
145
-                //$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
146
-                //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
147
-                $query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
134
+		/**
135
+		 * Gets last the spotter information based on a particular id
136
+		 *
137
+		 * @return Array the spotter information
138
+		 *
139
+		 */
140
+		public function getLastArchiveMarineDataById($id)
141
+		{
142
+			$Marine = new Marine($this->db);
143
+				date_default_timezone_set('UTC');
144
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
145
+				//$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
146
+				//$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
147
+				$query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
148 148
 
149 149
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
150
-                  /*
150
+				  /*
151 151
                 try {
152 152
                         $Connection = new Connection();
153 153
                         $sth = Connection->$db->prepare($query);
@@ -157,178 +157,178 @@  discard block
 block discarded – undo
157 157
                 }
158 158
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
159 159
                 */
160
-                $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
161
-
162
-                return $spotter_array;
163
-        }
164
-
165
-        /**
166
-        * Gets all the spotter information based on a particular id
167
-        *
168
-        * @return Array the spotter information
169
-        *
170
-        */
171
-        public function getAllArchiveMarineDataById($id)
160
+				$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
161
+
162
+				return $spotter_array;
163
+		}
164
+
165
+		/**
166
+		 * Gets all the spotter information based on a particular id
167
+		 *
168
+		 * @return Array the spotter information
169
+		 *
170
+		 */
171
+		public function getAllArchiveMarineDataById($id)
172 172
 	{
173
-                date_default_timezone_set('UTC');
174
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
175
-                $query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
173
+				date_default_timezone_set('UTC');
174
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
175
+				$query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
176 176
 
177 177
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
178 178
 
179
-                try {
180
-                        $sth = $this->db->prepare($query);
181
-                        $sth->execute(array(':id' => $id));
182
-                } catch(PDOException $e) {
183
-                        echo $e->getMessage();
184
-                        die;
185
-                }
186
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
187
-
188
-                return $spotter_array;
189
-        }
190
-
191
-        /**
192
-        * Gets coordinate & time spotter information based on a particular id
193
-        *
194
-        * @return Array the spotter information
195
-        *
196
-        */
197
-        public function getCoordArchiveMarineDataById($id)
198
-        {
199
-                date_default_timezone_set('UTC');
200
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
201
-                $query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
179
+				try {
180
+						$sth = $this->db->prepare($query);
181
+						$sth->execute(array(':id' => $id));
182
+				} catch(PDOException $e) {
183
+						echo $e->getMessage();
184
+						die;
185
+				}
186
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
187
+
188
+				return $spotter_array;
189
+		}
190
+
191
+		/**
192
+		 * Gets coordinate & time spotter information based on a particular id
193
+		 *
194
+		 * @return Array the spotter information
195
+		 *
196
+		 */
197
+		public function getCoordArchiveMarineDataById($id)
198
+		{
199
+				date_default_timezone_set('UTC');
200
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
201
+				$query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
202 202
 
203 203
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
204 204
 
205
-                try {
206
-                        $sth = $this->db->prepare($query);
207
-                        $sth->execute(array(':id' => $id));
208
-                } catch(PDOException $e) {
209
-                        echo $e->getMessage();
210
-                        die;
211
-                }
212
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
205
+				try {
206
+						$sth = $this->db->prepare($query);
207
+						$sth->execute(array(':id' => $id));
208
+				} catch(PDOException $e) {
209
+						echo $e->getMessage();
210
+						die;
211
+				}
212
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
213 213
 
214
-                return $spotter_array;
215
-        }
214
+				return $spotter_array;
215
+		}
216 216
 
217 217
 
218
-        /**
219
-        * Gets altitude information based on a particular callsign
220
-        *
221
-        * @return Array the spotter information
222
-        *
223
-        */
224
-        public function getAltitudeArchiveMarineDataByIdent($ident)
225
-        {
218
+		/**
219
+		 * Gets altitude information based on a particular callsign
220
+		 *
221
+		 * @return Array the spotter information
222
+		 *
223
+		 */
224
+		public function getAltitudeArchiveMarineDataByIdent($ident)
225
+		{
226 226
 
227
-                date_default_timezone_set('UTC');
227
+				date_default_timezone_set('UTC');
228 228
 
229
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
230
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
229
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
230
+				$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
231 231
 
232
-                try {
233
-                        $sth = $this->db->prepare($query);
234
-                        $sth->execute(array(':ident' => $ident));
235
-                } catch(PDOException $e) {
236
-                        echo $e->getMessage();
237
-                        die;
238
-                }
239
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
232
+				try {
233
+						$sth = $this->db->prepare($query);
234
+						$sth->execute(array(':ident' => $ident));
235
+				} catch(PDOException $e) {
236
+						echo $e->getMessage();
237
+						die;
238
+				}
239
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
240 240
 
241
-                return $spotter_array;
242
-        }
241
+				return $spotter_array;
242
+		}
243 243
 
244
-        /**
245
-        * Gets altitude information based on a particular id
246
-        *
247
-        * @return Array the spotter information
248
-        *
249
-        */
250
-        public function getAltitudeArchiveMarineDataById($id)
251
-        {
244
+		/**
245
+		 * Gets altitude information based on a particular id
246
+		 *
247
+		 * @return Array the spotter information
248
+		 *
249
+		 */
250
+		public function getAltitudeArchiveMarineDataById($id)
251
+		{
252 252
 
253
-                date_default_timezone_set('UTC');
253
+				date_default_timezone_set('UTC');
254 254
 
255
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
256
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
255
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
256
+				$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
257 257
 
258
-                try {
259
-                        $sth = $this->db->prepare($query);
260
-                        $sth->execute(array(':id' => $id));
261
-                } catch(PDOException $e) {
262
-                        echo $e->getMessage();
263
-                        die;
264
-                }
265
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
258
+				try {
259
+						$sth = $this->db->prepare($query);
260
+						$sth->execute(array(':id' => $id));
261
+				} catch(PDOException $e) {
262
+						echo $e->getMessage();
263
+						die;
264
+				}
265
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
266 266
 
267
-                return $spotter_array;
268
-        }
267
+				return $spotter_array;
268
+		}
269 269
 
270
-        /**
271
-        * Gets altitude & speed information based on a particular id
272
-        *
273
-        * @return Array the spotter information
274
-        *
275
-        */
276
-        public function getAltitudeSpeedArchiveMarineDataById($id)
277
-        {
270
+		/**
271
+		 * Gets altitude & speed information based on a particular id
272
+		 *
273
+		 * @return Array the spotter information
274
+		 *
275
+		 */
276
+		public function getAltitudeSpeedArchiveMarineDataById($id)
277
+		{
278 278
 
279
-                date_default_timezone_set('UTC');
279
+				date_default_timezone_set('UTC');
280 280
 
281
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
282
-                $query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
281
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
282
+				$query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
283 283
 
284
-                try {
285
-                        $sth = $this->db->prepare($query);
286
-                        $sth->execute(array(':id' => $id));
287
-                } catch(PDOException $e) {
288
-                        echo $e->getMessage();
289
-                        die;
290
-                }
291
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
284
+				try {
285
+						$sth = $this->db->prepare($query);
286
+						$sth->execute(array(':id' => $id));
287
+				} catch(PDOException $e) {
288
+						echo $e->getMessage();
289
+						die;
290
+				}
291
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
292 292
 
293
-                return $spotter_array;
294
-        }
293
+				return $spotter_array;
294
+		}
295 295
 
296 296
 
297
-        /**
298
-        * Gets altitude information based on a particular callsign
299
-        *
300
-        * @return Array the spotter information
301
-        *
302
-        */
303
-        public function getLastAltitudeArchiveMarineDataByIdent($ident)
304
-        {
297
+		/**
298
+		 * Gets altitude information based on a particular callsign
299
+		 *
300
+		 * @return Array the spotter information
301
+		 *
302
+		 */
303
+		public function getLastAltitudeArchiveMarineDataByIdent($ident)
304
+		{
305 305
 
306
-                date_default_timezone_set('UTC');
306
+				date_default_timezone_set('UTC');
307 307
 
308
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
309
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
308
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
309
+				$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
310 310
 //                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";
311 311
 
312
-                try {
313
-                        $sth = $this->db->prepare($query);
314
-                        $sth->execute(array(':ident' => $ident));
315
-                } catch(PDOException $e) {
316
-                        echo $e->getMessage();
317
-                        die;
318
-                }
319
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
312
+				try {
313
+						$sth = $this->db->prepare($query);
314
+						$sth->execute(array(':ident' => $ident));
315
+				} catch(PDOException $e) {
316
+						echo $e->getMessage();
317
+						die;
318
+				}
319
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
320 320
 
321
-                return $spotter_array;
322
-        }
321
+				return $spotter_array;
322
+		}
323 323
 
324 324
 
325 325
 
326
-       /**
327
-        * Gets all the archive spotter information
328
-        *
329
-        * @return Array the spotter information
330
-        *
331
-        */
326
+	   /**
327
+	    * Gets all the archive spotter information
328
+	    *
329
+	    * @return Array the spotter information
330
+	    *
331
+	    */
332 332
 	public function getMarineArchiveData($ident,$fammarine_id,$date)
333 333
 	{
334 334
 		$Marine = new Marine($this->db);
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
 		return $spotter_array;
339 339
 	}
340 340
 
341
-       /**
342
-        * Delete all tracking data
343
-        *
344
-        */
341
+	   /**
342
+	    * Delete all tracking data
343
+	    *
344
+	    */
345 345
 	public function deleteMarineArchiveTrackData()
346 346
 	{
347 347
 		global $globalArchiveKeepTrackMonths, $globalDBdriver;
@@ -360,34 +360,34 @@  discard block
 block discarded – undo
360 360
 	}
361 361
 
362 362
 	/**
363
-        * Gets Minimal Live Marine data
364
-        *
365
-        * @return Array the spotter information
366
-        *
367
-        */
368
-        public function getMinLiveMarineData($begindate,$enddate,$filter = array())
369
-        {
370
-                global $globalDBdriver, $globalLiveInterval;
371
-                date_default_timezone_set('UTC');
372
-
373
-                $filter_query = '';
374
-                if (isset($filter['source']) && !empty($filter['source'])) {
375
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
376
-                }
377
-                // Use spotter_output also ?
378
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
379
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
380
-                }
381
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
382
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
383
-                }
384
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
385
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
386
-                }
363
+	 * Gets Minimal Live Marine data
364
+	 *
365
+	 * @return Array the spotter information
366
+	 *
367
+	 */
368
+		public function getMinLiveMarineData($begindate,$enddate,$filter = array())
369
+		{
370
+				global $globalDBdriver, $globalLiveInterval;
371
+				date_default_timezone_set('UTC');
387 372
 
388
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
389
-                if ($globalDBdriver == 'mysql') {
390
-                        /*
373
+				$filter_query = '';
374
+				if (isset($filter['source']) && !empty($filter['source'])) {
375
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
376
+				}
377
+				// Use spotter_output also ?
378
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
379
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
380
+				}
381
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
382
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
383
+				}
384
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
385
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
386
+				}
387
+
388
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
389
+				if ($globalDBdriver == 'mysql') {
390
+						/*
391 391
                         $query  = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk 
392 392
                     		    FROM marine_archive 
393 393
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
@@ -406,56 +406,56 @@  discard block
 block discarded – undo
406 406
 				    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
407 407
 				    WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
408 408
                         	    '.$filter_query.' ORDER BY fammarine_id';
409
-                } else {
410
-                        //$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
411
-                        $query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
409
+				} else {
410
+						//$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
411
+						$query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
412 412
                         	    FROM marine_archive 
413 413
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
414 414
                         	    WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'
415 415
                         	    '.$filter_query.' ORDER BY fammarine_id';
416
-                }
417
-                //echo $query;
418
-                try {
419
-                        $sth = $this->db->prepare($query);
420
-                        $sth->execute();
421
-                } catch(PDOException $e) {
422
-                        echo $e->getMessage();
423
-                        die;
424
-                }
425
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
416
+				}
417
+				//echo $query;
418
+				try {
419
+						$sth = $this->db->prepare($query);
420
+						$sth->execute();
421
+				} catch(PDOException $e) {
422
+						echo $e->getMessage();
423
+						die;
424
+				}
425
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
426 426
 
427
-                return $spotter_array;
428
-        }
427
+				return $spotter_array;
428
+		}
429 429
 
430 430
 	/**
431
-        * Gets Minimal Live Marine data
432
-        *
433
-        * @return Array the spotter information
434
-        *
435
-        */
436
-        public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
437
-        {
438
-                global $globalDBdriver, $globalLiveInterval;
439
-                date_default_timezone_set('UTC');
440
-
441
-                $filter_query = '';
442
-                if (isset($filter['source']) && !empty($filter['source'])) {
443
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
444
-                }
445
-                // Should use spotter_output also ?
446
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
447
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
448
-                }
449
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
450
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
451
-                }
452
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
453
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
454
-                }
431
+	 * Gets Minimal Live Marine data
432
+	 *
433
+	 * @return Array the spotter information
434
+	 *
435
+	 */
436
+		public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
437
+		{
438
+				global $globalDBdriver, $globalLiveInterval;
439
+				date_default_timezone_set('UTC');
455 440
 
456
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
457
-                if ($globalDBdriver == 'mysql') {
458
-                        /*
441
+				$filter_query = '';
442
+				if (isset($filter['source']) && !empty($filter['source'])) {
443
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
444
+				}
445
+				// Should use spotter_output also ?
446
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
447
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
448
+				}
449
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
450
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
451
+				}
452
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
453
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
454
+				}
455
+
456
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
457
+				if ($globalDBdriver == 'mysql') {
458
+						/*
459 459
                         $query  = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk 
460 460
                     		    FROM marine_archive 
461 461
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
@@ -466,95 +466,95 @@  discard block
 block discarded – undo
466 466
 				    WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
467 467
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
468 468
 
469
-                } else {
470
-                        //$query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';
471
-                       /*
469
+				} else {
470
+						//$query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';
471
+					   /*
472 472
                         $query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
473 473
                         	    FROM marine_archive_output 
474 474
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
475 475
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
476 476
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
477 477
                         */
478
-                        $query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
478
+						$query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
479 479
                         	    FROM marine_archive_output 
480 480
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
481 481
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
482 482
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
483 483
 //                        	    .' GROUP BY spotter_output.fammarine_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
484 484
                         	    
485
-                }
486
-                //echo $query;
487
-                try {
488
-                        $sth = $this->db->prepare($query);
489
-                        $sth->execute();
490
-                } catch(PDOException $e) {
491
-                        echo $e->getMessage();
492
-                        die;
493
-                }
494
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
485
+				}
486
+				//echo $query;
487
+				try {
488
+						$sth = $this->db->prepare($query);
489
+						$sth->execute();
490
+				} catch(PDOException $e) {
491
+						echo $e->getMessage();
492
+						die;
493
+				}
494
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
495 495
 
496
-                return $spotter_array;
497
-        }
496
+				return $spotter_array;
497
+		}
498 498
 
499 499
 	 /**
500
-        * Gets count Live Marine data
501
-        *
502
-        * @return Array the spotter information
503
-        *
504
-        */
505
-        public function getLiveMarineCount($begindate,$enddate,$filter = array())
506
-        {
507
-                global $globalDBdriver, $globalLiveInterval;
508
-                date_default_timezone_set('UTC');
509
-
510
-                $filter_query = '';
511
-                if (isset($filter['source']) && !empty($filter['source'])) {
512
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
513
-                }
514
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
515
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
516
-                }
517
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
518
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
519
-                }
520
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
521
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
522
-                }
500
+	  * Gets count Live Marine data
501
+	  *
502
+	  * @return Array the spotter information
503
+	  *
504
+	  */
505
+		public function getLiveMarineCount($begindate,$enddate,$filter = array())
506
+		{
507
+				global $globalDBdriver, $globalLiveInterval;
508
+				date_default_timezone_set('UTC');
523 509
 
524
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
525
-                if ($globalDBdriver == 'mysql') {
510
+				$filter_query = '';
511
+				if (isset($filter['source']) && !empty($filter['source'])) {
512
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
513
+				}
514
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
515
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
516
+				}
517
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
518
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
519
+				}
520
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
521
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
522
+				}
523
+
524
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
525
+				if ($globalDBdriver == 'mysql') {
526 526
 			$query = 'SELECT COUNT(DISTINCT fammarine_id) as nb 
527 527
 			FROM marine_archive l 
528 528
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
529
-                } else {
529
+				} else {
530 530
 			$query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
531
-                }
532
-                //echo $query;
533
-                try {
534
-                        $sth = $this->db->prepare($query);
535
-                        $sth->execute();
536
-                } catch(PDOException $e) {
537
-                        echo $e->getMessage();
538
-                        die;
539
-                }
531
+				}
532
+				//echo $query;
533
+				try {
534
+						$sth = $this->db->prepare($query);
535
+						$sth->execute();
536
+				} catch(PDOException $e) {
537
+						echo $e->getMessage();
538
+						die;
539
+				}
540 540
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
541 541
 		$sth->closeCursor();
542
-                return $result['nb'];
542
+				return $result['nb'];
543 543
 
544
-        }
544
+		}
545 545
 
546 546
 
547 547
 
548 548
 	// marine_archive_output
549 549
 	
550
-    /**
551
-    * Gets all the spotter information
552
-    *
553
-    * @return Array the spotter information
554
-    *
555
-    */
556
-    public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
557
-    {
550
+	/**
551
+	 * Gets all the spotter information
552
+	 *
553
+	 * @return Array the spotter information
554
+	 *
555
+	 */
556
+	public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
557
+	{
558 558
 	global $globalTimezone, $globalDBdriver;
559 559
 	require_once(dirname(__FILE__).'/class.Translation.php');
560 560
 	$Translation = new Translation($this->db);
@@ -568,159 +568,159 @@  discard block
 block discarded – undo
568 568
 	$filter_query = $this->getFilter($filters);
569 569
 	if ($q != "")
570 570
 	{
571
-	    if (!is_string($q))
572
-	    {
571
+		if (!is_string($q))
572
+		{
573 573
 		return false;
574
-	    } else {
574
+		} else {
575 575
 	        
576 576
 		$q_array = explode(" ", $q);
577 577
 		
578 578
 		foreach ($q_array as $q_item){
579
-		    $additional_query .= " AND (";
580
-		    $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
581
-		    $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
582
-		    $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";
583
-		    $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
584
-		    $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";
585
-		    $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";
586
-		    $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";
587
-		    $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
588
-		    $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";
589
-		    $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";
590
-		    $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";
591
-		    $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
592
-		    $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
593
-		    $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
594
-		    $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
595
-		    $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";
596
-		    $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";
597
-		    $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";
598
-		    $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
599
-		    $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
600
-		    $translate = $Translation->ident2icao($q_item);
601
-		    if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
602
-		    $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
603
-		    $additional_query .= ")";
579
+			$additional_query .= " AND (";
580
+			$additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
581
+			$additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
582
+			$additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";
583
+			$additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
584
+			$additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";
585
+			$additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";
586
+			$additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";
587
+			$additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
588
+			$additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";
589
+			$additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";
590
+			$additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";
591
+			$additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
592
+			$additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
593
+			$additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
594
+			$additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
595
+			$additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";
596
+			$additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";
597
+			$additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";
598
+			$additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
599
+			$additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
600
+			$translate = $Translation->ident2icao($q_item);
601
+			if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
602
+			$additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
603
+			$additional_query .= ")";
604
+		}
604 605
 		}
605
-	    }
606 606
 	}
607 607
 	
608 608
 	if ($registration != "")
609 609
 	{
610
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
611
-	    if (!is_string($registration))
612
-	    {
610
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
611
+		if (!is_string($registration))
612
+		{
613 613
 		return false;
614
-	    } else {
614
+		} else {
615 615
 		$additional_query .= " AND (marine_archive_output.registration = '".$registration."')";
616
-	    }
616
+		}
617 617
 	}
618 618
 	
619 619
 	if ($aircraft_icao != "")
620 620
 	{
621
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
622
-	    if (!is_string($aircraft_icao))
623
-	    {
621
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
622
+		if (!is_string($aircraft_icao))
623
+		{
624 624
 		return false;
625
-	    } else {
625
+		} else {
626 626
 		$additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')";
627
-	    }
627
+		}
628 628
 	}
629 629
 	
630 630
 	if ($aircraft_manufacturer != "")
631 631
 	{
632
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
633
-	    if (!is_string($aircraft_manufacturer))
634
-	    {
632
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
633
+		if (!is_string($aircraft_manufacturer))
634
+		{
635 635
 		return false;
636
-	    } else {
636
+		} else {
637 637
 		$additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
638
-	    }
638
+		}
639 639
 	}
640 640
 	
641 641
 	if ($highlights == "true")
642 642
 	{
643
-	    if (!is_string($highlights))
644
-	    {
643
+		if (!is_string($highlights))
644
+		{
645 645
 		return false;
646
-	    } else {
646
+		} else {
647 647
 		$additional_query .= " AND (marine_archive_output.highlight <> '')";
648
-	    }
648
+		}
649 649
 	}
650 650
 	
651 651
 	if ($airline_icao != "")
652 652
 	{
653
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
654
-	    if (!is_string($airline_icao))
655
-	    {
653
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
654
+		if (!is_string($airline_icao))
655
+		{
656 656
 		return false;
657
-	    } else {
657
+		} else {
658 658
 		$additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')";
659
-	    }
659
+		}
660 660
 	}
661 661
 	
662 662
 	if ($airline_country != "")
663 663
 	{
664
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
665
-	    if (!is_string($airline_country))
666
-	    {
664
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
665
+		if (!is_string($airline_country))
666
+		{
667 667
 		return false;
668
-	    } else {
668
+		} else {
669 669
 		$additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')";
670
-	    }
670
+		}
671 671
 	}
672 672
 	
673 673
 	if ($airline_type != "")
674 674
 	{
675
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
676
-	    if (!is_string($airline_type))
677
-	    {
675
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
676
+		if (!is_string($airline_type))
677
+		{
678 678
 		return false;
679
-	    } else {
679
+		} else {
680 680
 		if ($airline_type == "passenger")
681 681
 		{
682
-		    $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";
682
+			$additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";
683 683
 		}
684 684
 		if ($airline_type == "cargo")
685 685
 		{
686
-		    $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";
686
+			$additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";
687 687
 		}
688 688
 		if ($airline_type == "military")
689 689
 		{
690
-		    $additional_query .= " AND (marine_archive_output.airline_type = 'military')";
690
+			$additional_query .= " AND (marine_archive_output.airline_type = 'military')";
691
+		}
691 692
 		}
692
-	    }
693 693
 	}
694 694
 	
695 695
 	if ($airport != "")
696 696
 	{
697
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
698
-	    if (!is_string($airport))
699
-	    {
697
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
698
+		if (!is_string($airport))
699
+		{
700 700
 		return false;
701
-	    } else {
701
+		} else {
702 702
 		$additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))";
703
-	    }
703
+		}
704 704
 	}
705 705
 	
706 706
 	if ($airport_country != "")
707 707
 	{
708
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
709
-	    if (!is_string($airport_country))
710
-	    {
708
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
709
+		if (!is_string($airport_country))
710
+		{
711 711
 		return false;
712
-	    } else {
712
+		} else {
713 713
 		$additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))";
714
-	    }
714
+		}
715 715
 	}
716 716
     
717 717
 	if ($callsign != "")
718 718
 	{
719
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
720
-	    if (!is_string($callsign))
721
-	    {
719
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
720
+		if (!is_string($callsign))
721
+		{
722 722
 		return false;
723
-	    } else {
723
+		} else {
724 724
 		$translate = $Translation->ident2icao($callsign);
725 725
 		if ($translate != $callsign) {
726 726
 			$additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";
@@ -728,99 +728,99 @@  discard block
 block discarded – undo
728 728
 		} else {
729 729
 			$additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";
730 730
 		}
731
-	    }
731
+		}
732 732
 	}
733 733
 
734 734
 	if ($owner != "")
735 735
 	{
736
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
737
-	    if (!is_string($owner))
738
-	    {
736
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
737
+		if (!is_string($owner))
738
+		{
739 739
 		return false;
740
-	    } else {
740
+		} else {
741 741
 		$additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')";
742
-	    }
742
+		}
743 743
 	}
744 744
 
745 745
 	if ($pilot_name != "")
746 746
 	{
747
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
748
-	    if (!is_string($pilot_name))
749
-	    {
747
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
748
+		if (!is_string($pilot_name))
749
+		{
750 750
 		return false;
751
-	    } else {
751
+		} else {
752 752
 		$additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')";
753
-	    }
753
+		}
754 754
 	}
755 755
 	
756 756
 	if ($pilot_id != "")
757 757
 	{
758
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
759
-	    if (!is_string($pilot_id))
760
-	    {
758
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
759
+		if (!is_string($pilot_id))
760
+		{
761 761
 		return false;
762
-	    } else {
762
+		} else {
763 763
 		$additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')";
764
-	    }
764
+		}
765 765
 	}
766 766
 	
767 767
 	if ($departure_airport_route != "")
768 768
 	{
769
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
770
-	    if (!is_string($departure_airport_route))
771
-	    {
769
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
770
+		if (!is_string($departure_airport_route))
771
+		{
772 772
 		return false;
773
-	    } else {
773
+		} else {
774 774
 		$additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')";
775
-	    }
775
+		}
776 776
 	}
777 777
 	
778 778
 	if ($arrival_airport_route != "")
779 779
 	{
780
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
781
-	    if (!is_string($arrival_airport_route))
782
-	    {
780
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
781
+		if (!is_string($arrival_airport_route))
782
+		{
783 783
 		return false;
784
-	    } else {
784
+		} else {
785 785
 		$additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
786
-	    }
786
+		}
787 787
 	}
788 788
 	
789 789
 	if ($altitude != "")
790 790
 	{
791
-	    $altitude_array = explode(",", $altitude);
791
+		$altitude_array = explode(",", $altitude);
792 792
 	    
793
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
794
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
793
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
794
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
795 795
 	    
796 796
 
797
-	    if ($altitude_array[1] != "")
798
-	    {                
797
+		if ($altitude_array[1] != "")
798
+		{                
799 799
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
800 800
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
801 801
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
802
-	    } else {
802
+		} else {
803 803
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
804 804
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
805
-	    }
805
+		}
806 806
 	}
807 807
 	
808 808
 	if ($date_posted != "")
809 809
 	{
810
-	    $date_array = explode(",", $date_posted);
810
+		$date_array = explode(",", $date_posted);
811 811
 	    
812
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
813
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
812
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
813
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
814 814
 	    
815
-	    if ($globalTimezone != '') {
815
+		if ($globalTimezone != '') {
816 816
 		date_default_timezone_set($globalTimezone);
817 817
 		$datetime = new DateTime();
818 818
 		$offset = $datetime->format('P');
819
-	    } else $offset = '+00:00';
819
+		} else $offset = '+00:00';
820 820
 
821 821
 
822
-	    if ($date_array[1] != "")
823
-	    {                
822
+		if ($date_array[1] != "")
823
+		{                
824 824
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
825 825
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
826 826
 		if ($globalDBdriver == 'mysql') {
@@ -828,28 +828,28 @@  discard block
 block discarded – undo
828 828
 		} else {
829 829
 			$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
830 830
 		}
831
-	    } else {
831
+		} else {
832 832
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
833
-                if ($globalDBdriver == 'mysql') {
833
+				if ($globalDBdriver == 'mysql') {
834 834
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
835 835
 		} else {
836 836
 			$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
837 837
 		}
838
-	    }
838
+		}
839 839
 	}
840 840
 	
841 841
 	if ($limit != "")
842 842
 	{
843
-	    $limit_array = explode(",", $limit);
843
+		$limit_array = explode(",", $limit);
844 844
 	    
845
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
846
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
845
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
846
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
847 847
 	    
848
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
849
-	    {
848
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
849
+		{
850 850
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
851 851
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
852
-	    }
852
+		}
853 853
 	}
854 854
 	
855 855
 
@@ -880,33 +880,33 @@  discard block
 block discarded – undo
880 880
 	$spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);
881 881
 
882 882
 	return $spotter_array;
883
-    }
883
+	}
884 884
 
885
-    public function deleteMarineArchiveData()
886
-    {
885
+	public function deleteMarineArchiveData()
886
+	{
887 887
 		global $globalArchiveKeepMonths, $globalDBdriver;
888
-                date_default_timezone_set('UTC');
889
-                if ($globalDBdriver == 'mysql') {
888
+				date_default_timezone_set('UTC');
889
+				if ($globalDBdriver == 'mysql') {
890 890
 			$query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
891 891
 		} else {
892 892
 			$query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
893 893
 		}
894
-                try {
895
-                        $sth = $this->db->prepare($query);
896
-                        $sth->execute();
897
-                } catch(PDOException $e) {
898
-                        return "error";
899
-                }
894
+				try {
895
+						$sth = $this->db->prepare($query);
896
+						$sth->execute();
897
+				} catch(PDOException $e) {
898
+						return "error";
899
+				}
900 900
 	}
901 901
 
902
-    /**
903
-    * Gets all the spotter information based on the callsign
904
-    *
905
-    * @return Array the spotter information
906
-    *
907
-    */
908
-    public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')
909
-    {
902
+	/**
903
+	 * Gets all the spotter information based on the callsign
904
+	 *
905
+	 * @return Array the spotter information
906
+	 *
907
+	 */
908
+	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')
909
+	{
910 910
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
911 911
 	
912 912
 	date_default_timezone_set('UTC');
@@ -918,35 +918,35 @@  discard block
 block discarded – undo
918 918
 	
919 919
 	if ($ident != "")
920 920
 	{
921
-	    if (!is_string($ident))
922
-	    {
921
+		if (!is_string($ident))
922
+		{
923 923
 		return false;
924
-	    } else {
924
+		} else {
925 925
 		$additional_query = " AND (marine_archive_output.ident = :ident)";
926 926
 		$query_values = array(':ident' => $ident);
927
-	    }
927
+		}
928 928
 	}
929 929
 	
930 930
 	if ($limit != "")
931 931
 	{
932
-	    $limit_array = explode(",", $limit);
932
+		$limit_array = explode(",", $limit);
933 933
 	    
934
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
935
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
934
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
935
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
936 936
 	    
937
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
938
-	    {
937
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
938
+		{
939 939
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
940 940
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
941
-	    }
941
+		}
942 942
 	}
943 943
 
944 944
 	if ($sort != "")
945 945
 	{
946
-	    $search_orderby_array = $Marine->getOrderBy();
947
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
946
+		$search_orderby_array = $Marine->getOrderBy();
947
+		$orderby_query = $search_orderby_array[$sort]['sql'];
948 948
 	} else {
949
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
949
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
950 950
 	}
951 951
 
952 952
 	$query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -954,17 +954,17 @@  discard block
 block discarded – undo
954 954
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
955 955
 
956 956
 	return $spotter_array;
957
-    }
957
+	}
958 958
 
959 959
 
960
-    /**
961
-    * Gets all the spotter information based on the owner
962
-    *
963
-    * @return Array the spotter information
964
-    *
965
-    */
966
-    public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
967
-    {
960
+	/**
961
+	 * Gets all the spotter information based on the owner
962
+	 *
963
+	 * @return Array the spotter information
964
+	 *
965
+	 */
966
+	public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
967
+	{
968 968
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
969 969
 	
970 970
 	date_default_timezone_set('UTC');
@@ -977,35 +977,35 @@  discard block
 block discarded – undo
977 977
 	
978 978
 	if ($owner != "")
979 979
 	{
980
-	    if (!is_string($owner))
981
-	    {
980
+		if (!is_string($owner))
981
+		{
982 982
 		return false;
983
-	    } else {
983
+		} else {
984 984
 		$additional_query = " AND (marine_archive_output.owner_name = :owner)";
985 985
 		$query_values = array(':owner' => $owner);
986
-	    }
986
+		}
987 987
 	}
988 988
 	
989 989
 	if ($limit != "")
990 990
 	{
991
-	    $limit_array = explode(",", $limit);
991
+		$limit_array = explode(",", $limit);
992 992
 	    
993
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
994
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
993
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
994
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
995 995
 	    
996
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
997
-	    {
996
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
997
+		{
998 998
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
999 999
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1000
-	    }
1000
+		}
1001 1001
 	}
1002 1002
 
1003 1003
 	if ($sort != "")
1004 1004
 	{
1005
-	    $search_orderby_array = $Marine->getOrderBy();
1006
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1005
+		$search_orderby_array = $Marine->getOrderBy();
1006
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1007 1007
 	} else {
1008
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1008
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1009 1009
 	}
1010 1010
 
1011 1011
 	$query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1013,16 +1013,16 @@  discard block
 block discarded – undo
1013 1013
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1014 1014
 
1015 1015
 	return $spotter_array;
1016
-    }
1017
-
1018
-    /**
1019
-    * Gets all the spotter information based on the pilot
1020
-    *
1021
-    * @return Array the spotter information
1022
-    *
1023
-    */
1024
-    public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1025
-    {
1016
+	}
1017
+
1018
+	/**
1019
+	 * Gets all the spotter information based on the pilot
1020
+	 *
1021
+	 * @return Array the spotter information
1022
+	 *
1023
+	 */
1024
+	public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1025
+	{
1026 1026
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
1027 1027
 	
1028 1028
 	date_default_timezone_set('UTC');
@@ -1041,24 +1041,24 @@  discard block
 block discarded – undo
1041 1041
 	
1042 1042
 	if ($limit != "")
1043 1043
 	{
1044
-	    $limit_array = explode(",", $limit);
1044
+		$limit_array = explode(",", $limit);
1045 1045
 	    
1046
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1047
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1046
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1047
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1048 1048
 	    
1049
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1050
-	    {
1049
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1050
+		{
1051 1051
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1052 1052
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1053
-	    }
1053
+		}
1054 1054
 	}
1055 1055
 
1056 1056
 	if ($sort != "")
1057 1057
 	{
1058
-	    $search_orderby_array = $Marine->getOrderBy();
1059
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1058
+		$search_orderby_array = $Marine->getOrderBy();
1059
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1060 1060
 	} else {
1061
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1061
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1062 1062
 	}
1063 1063
 
1064 1064
 	$query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1066,16 +1066,16 @@  discard block
 block discarded – undo
1066 1066
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1067 1067
 
1068 1068
 	return $spotter_array;
1069
-    }
1070
-
1071
-    /**
1072
-    * Gets all number of flight over countries
1073
-    *
1074
-    * @return Array the airline country list
1075
-    *
1076
-    */
1077
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1078
-    {
1069
+	}
1070
+
1071
+	/**
1072
+	 * Gets all number of flight over countries
1073
+	 *
1074
+	 * @return Array the airline country list
1075
+	 *
1076
+	 */
1077
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1078
+	{
1079 1079
 	global $globalDBdriver;
1080 1080
 	/*
1081 1081
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1085,14 +1085,14 @@  discard block
 block discarded – undo
1085 1085
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1086 1086
 		    FROM countries c, marine_archive s
1087 1087
 		    WHERE c.iso2 = s.over_country ";
1088
-                if ($olderthanmonths > 0) {
1089
-            		if ($globalDBdriver == 'mysql') {
1088
+				if ($olderthanmonths > 0) {
1089
+					if ($globalDBdriver == 'mysql') {
1090 1090
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1091 1091
 			} else {
1092 1092
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1093 1093
 			}
1094 1094
 		}
1095
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1095
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1096 1096
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1097 1097
 	if ($limit) $query .= " LIMIT 0,10";
1098 1098
       
@@ -1105,23 +1105,23 @@  discard block
 block discarded – undo
1105 1105
         
1106 1106
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1107 1107
 	{
1108
-	    $temp_array['flight_count'] = $row['nb'];
1109
-	    $temp_array['flight_country'] = $row['name'];
1110
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1111
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1112
-	    $flight_array[] = $temp_array;
1108
+		$temp_array['flight_count'] = $row['nb'];
1109
+		$temp_array['flight_country'] = $row['name'];
1110
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1111
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1112
+		$flight_array[] = $temp_array;
1113 1113
 	}
1114 1114
 	return $flight_array;
1115
-    }
1116
-
1117
-    /**
1118
-    * Gets all number of flight over countries
1119
-    *
1120
-    * @return Array the airline country list
1121
-    *
1122
-    */
1123
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1124
-    {
1115
+	}
1116
+
1117
+	/**
1118
+	 * Gets all number of flight over countries
1119
+	 *
1120
+	 * @return Array the airline country list
1121
+	 *
1122
+	 */
1123
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1124
+	{
1125 1125
 	global $globalDBdriver;
1126 1126
 	/*
1127 1127
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1131,14 +1131,14 @@  discard block
 block discarded – undo
1131 1131
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1132 1132
 		    FROM countries c, marine_archive s, spotter_output o
1133 1133
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id ";
1134
-                if ($olderthanmonths > 0) {
1135
-            		if ($globalDBdriver == 'mysql') {
1134
+				if ($olderthanmonths > 0) {
1135
+					if ($globalDBdriver == 'mysql') {
1136 1136
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1137 1137
 			} else {
1138 1138
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1139 1139
 			}
1140 1140
 		}
1141
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1141
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1142 1142
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1143 1143
 	if ($limit) $query .= " LIMIT 0,10";
1144 1144
       
@@ -1151,24 +1151,24 @@  discard block
 block discarded – undo
1151 1151
         
1152 1152
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1153 1153
 	{
1154
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1155
-	    $temp_array['flight_count'] = $row['nb'];
1156
-	    $temp_array['flight_country'] = $row['name'];
1157
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1158
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1159
-	    $flight_array[] = $temp_array;
1154
+		$temp_array['airline_icao'] = $row['airline_icao'];
1155
+		$temp_array['flight_count'] = $row['nb'];
1156
+		$temp_array['flight_country'] = $row['name'];
1157
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1158
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1159
+		$flight_array[] = $temp_array;
1160 1160
 	}
1161 1161
 	return $flight_array;
1162
-    }
1163
-
1164
-    /**
1165
-    * Gets last spotter information based on a particular callsign
1166
-    *
1167
-    * @return Array the spotter information
1168
-    *
1169
-    */
1170
-    public function getDateArchiveMarineDataById($id,$date)
1171
-    {
1162
+	}
1163
+
1164
+	/**
1165
+	 * Gets last spotter information based on a particular callsign
1166
+	 *
1167
+	 * @return Array the spotter information
1168
+	 *
1169
+	 */
1170
+	public function getDateArchiveMarineDataById($id,$date)
1171
+	{
1172 1172
 	$Marine = new Marine($this->db);
1173 1173
 	date_default_timezone_set('UTC');
1174 1174
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1176,16 +1176,16 @@  discard block
 block discarded – undo
1176 1176
 	$date = date('c',$date);
1177 1177
 	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date));
1178 1178
 	return $spotter_array;
1179
-    }
1180
-
1181
-    /**
1182
-    * Gets all the spotter information based on a particular callsign
1183
-    *
1184
-    * @return Array the spotter information
1185
-    *
1186
-    */
1187
-    public function getDateArchiveMarineDataByIdent($ident,$date)
1188
-    {
1179
+	}
1180
+
1181
+	/**
1182
+	 * Gets all the spotter information based on a particular callsign
1183
+	 *
1184
+	 * @return Array the spotter information
1185
+	 *
1186
+	 */
1187
+	public function getDateArchiveMarineDataByIdent($ident,$date)
1188
+	{
1189 1189
 	$Marine = new Marine($this->db);
1190 1190
 	date_default_timezone_set('UTC');
1191 1191
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1193,16 +1193,16 @@  discard block
 block discarded – undo
1193 1193
 	$date = date('c',$date);
1194 1194
 	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1195 1195
 	return $spotter_array;
1196
-    }
1197
-
1198
-    /**
1199
-    * Gets all the spotter information based on the airport
1200
-    *
1201
-    * @return Array the spotter information
1202
-    *
1203
-    */
1204
-    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1205
-    {
1196
+	}
1197
+
1198
+	/**
1199
+	 * Gets all the spotter information based on the airport
1200
+	 *
1201
+	 * @return Array the spotter information
1202
+	 *
1203
+	 */
1204
+	public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1205
+	{
1206 1206
 	global $global_query;
1207 1207
 	$Marine = new Marine($this->db);
1208 1208
 	date_default_timezone_set('UTC');
@@ -1213,35 +1213,35 @@  discard block
 block discarded – undo
1213 1213
 	
1214 1214
 	if ($airport != "")
1215 1215
 	{
1216
-	    if (!is_string($airport))
1217
-	    {
1216
+		if (!is_string($airport))
1217
+		{
1218 1218
 		return false;
1219
-	    } else {
1219
+		} else {
1220 1220
 		$additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))";
1221 1221
 		$query_values = array(':airport' => $airport);
1222
-	    }
1222
+		}
1223 1223
 	}
1224 1224
 	
1225 1225
 	if ($limit != "")
1226 1226
 	{
1227
-	    $limit_array = explode(",", $limit);
1227
+		$limit_array = explode(",", $limit);
1228 1228
 	    
1229
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1230
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1229
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1230
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1231 1231
 	    
1232
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1233
-	    {
1232
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1233
+		{
1234 1234
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1235 1235
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1236
-	    }
1236
+		}
1237 1237
 	}
1238 1238
 	
1239 1239
 	if ($sort != "")
1240 1240
 	{
1241
-	    $search_orderby_array = $Marine->getOrderBy();
1242
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1241
+		$search_orderby_array = $Marine->getOrderBy();
1242
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1243 1243
 	} else {
1244
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1244
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1245 1245
 	}
1246 1246
 
1247 1247
 	$query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1249,6 +1249,6 @@  discard block
 block discarded – undo
1249 1249
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1250 1250
 
1251 1251
 	return $spotter_array;
1252
-    }
1252
+	}
1253 1253
 }
1254 1254
 ?>
1255 1255
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +37 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 	public function __construct($dbc = null) {
7 7
 		$Connection = new Connection($dbc);
8 8
 		$this->db = $Connection->db;
9
-		if ($this->db === null) die('Error: No DB connection. (MarineArchive)');
9
+		if ($this->db === null) {
10
+			die('Error: No DB connection. (MarineArchive)');
11
+		}
10 12
 	}
11 13
 
12 14
 	/**
@@ -27,7 +29,9 @@  discard block
 block discarded – undo
27 29
 		if (isset($filter[0]['source'])) {
28 30
 			$filters = array_merge($filters,$filter);
29 31
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
31 35
 		$filter_query_join = '';
32 36
 		$filter_query_where = '';
33 37
 		foreach($filters as $flt) {
@@ -73,8 +77,11 @@  discard block
 block discarded – undo
73 77
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
74 78
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
75 79
 		}
76
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
77
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
80
+		if ($filter_query_where == '' && $where) {
81
+			$filter_query_where = ' WHERE';
82
+		} elseif ($filter_query_where != '' && $and) {
83
+			$filter_query_where .= ' AND';
84
+		}
78 85
 		if ($filter_query_where != '') {
79 86
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
80 87
 		}
@@ -88,9 +95,14 @@  discard block
 block discarded – undo
88 95
 		if ($over_country == '') {
89 96
 			$Marine = new Marine($this->db);
90 97
 			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude);
91
-			if (!empty($data_country)) $country = $data_country['iso2'];
92
-			else $country = '';
93
-		} else $country = $over_country;
98
+			if (!empty($data_country)) {
99
+				$country = $data_country['iso2'];
100
+			} else {
101
+				$country = '';
102
+			}
103
+		} else {
104
+			$country = $over_country;
105
+		}
94 106
 		
95 107
 		//$country = $over_country;
96 108
 		// Route is not added in marine_archive
@@ -598,7 +610,9 @@  discard block
 block discarded – undo
598 610
 		    $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
599 611
 		    $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
600 612
 		    $translate = $Translation->ident2icao($q_item);
601
-		    if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
613
+		    if ($translate != $q_item) {
614
+		    	$additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
615
+		    }
602 616
 		    $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
603 617
 		    $additional_query .= ")";
604 618
 		}
@@ -816,7 +830,9 @@  discard block
 block discarded – undo
816 830
 		date_default_timezone_set($globalTimezone);
817 831
 		$datetime = new DateTime();
818 832
 		$offset = $datetime->format('P');
819
-	    } else $offset = '+00:00';
833
+	    } else {
834
+	    	$offset = '+00:00';
835
+	    }
820 836
 
821 837
 
822 838
 	    if ($date_array[1] != "")
@@ -1092,9 +1108,13 @@  discard block
 block discarded – undo
1092 1108
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1093 1109
 			}
1094 1110
 		}
1095
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1111
+                if ($sincedate != '') {
1112
+                	$query .= "AND date > '".$sincedate."' ";
1113
+                }
1096 1114
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1097
-	if ($limit) $query .= " LIMIT 0,10";
1115
+	if ($limit) {
1116
+		$query .= " LIMIT 0,10";
1117
+	}
1098 1118
       
1099 1119
 	
1100 1120
 	$sth = $this->db->prepare($query);
@@ -1138,9 +1158,13 @@  discard block
 block discarded – undo
1138 1158
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1139 1159
 			}
1140 1160
 		}
1141
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1161
+                if ($sincedate != '') {
1162
+                	$query .= "AND s.date > '".$sincedate."' ";
1163
+                }
1142 1164
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1143
-	if ($limit) $query .= " LIMIT 0,10";
1165
+	if ($limit) {
1166
+		$query .= " LIMIT 0,10";
1167
+	}
1144 1168
       
1145 1169
 	
1146 1170
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -14,33 +14,33 @@  discard block
 block discarded – undo
14 14
 	* @param Array $filter the filter
15 15
 	* @return Array the SQL part
16 16
 	*/
17
-	public function getFilter($filter = array(),$where = false,$and = false) {
17
+	public function getFilter($filter = array(), $where = false, $and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 		$filters = array();
20 20
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 22
 				$filters = $globalStatsFilters[$globalFilterName];
23 23
 			} else {
24
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
24
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
25 25
 			}
26 26
 		}
27 27
 		if (isset($filter[0]['source'])) {
28
-			$filters = array_merge($filters,$filter);
28
+			$filters = array_merge($filters, $filter);
29 29
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
30
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
31 31
 		$filter_query_join = '';
32 32
 		$filter_query_where = '';
33
-		foreach($filters as $flt) {
33
+		foreach ($filters as $flt) {
34 34
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
35 35
 				if (isset($flt['source'])) {
36
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
36
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
37 37
 				} else {
38
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
38
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
39 39
 				}
40 40
 			}
41 41
 		}
42 42
 		if (isset($filter['source']) && !empty($filter['source'])) {
43
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
43
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
44 44
 		}
45 45
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
46 46
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -68,42 +68,42 @@  discard block
 block discarded – undo
68 68
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'";
69 69
 				}
70 70
 			}
71
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id";
71
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id";
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 ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
77 77
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
78 78
 		if ($filter_query_where != '') {
79
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
79
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
80 80
 		}
81 81
 		$filter_query = $filter_query_join.$filter_query_where;
82 82
 		return $filter_query;
83 83
 	}
84 84
 
85 85
 	// marine_archive
86
-	public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') {
86
+	public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') {
87 87
 		require_once(dirname(__FILE__).'/class.Marine.php');
88 88
 		if ($over_country == '') {
89 89
 			$Marine = new Marine($this->db);
90
-			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude);
90
+			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude, $longitude);
91 91
 			if (!empty($data_country)) $country = $data_country['iso2'];
92 92
 			else $country = '';
93 93
 		} else $country = $over_country;
94 94
 		
95 95
 		//$country = $over_country;
96 96
 		// Route is not added in marine_archive
97
-		$query  = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date) 
97
+		$query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date) 
98 98
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date)';
99 99
 
100
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country,':mmsi' => $mmsi,':type' => $type,':type_id' => $typeid,':status' => $status,':status_id' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
100
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $typeid, ':status' => $status, ':status_id' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
101 101
 
102 102
 		try {
103 103
 			$sth = $this->db->prepare($query);
104 104
 			$sth->execute($query_values);
105 105
 			$sth->closeCursor();
106
-		} catch(PDOException $e) {
106
+		} catch (PDOException $e) {
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
109 109
 		return "success";
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 
124 124
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
125 125
                 //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
126
-                $query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
126
+                $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
127 127
 
128
-                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
128
+                $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident));
129 129
 
130 130
                 return $spotter_array;
131 131
         }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
145 145
                 //$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
146 146
                 //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
147
-                $query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
147
+                $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
148 148
 
149 149
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
150 150
                   /*
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
                 }
158 158
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
159 159
                 */
160
-                $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
160
+                $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id));
161 161
 
162 162
                 return $spotter_array;
163 163
         }
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 	{
173 173
                 date_default_timezone_set('UTC');
174 174
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
175
-                $query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
175
+                $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
176 176
 
177 177
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
178 178
 
179 179
                 try {
180 180
                         $sth = $this->db->prepare($query);
181 181
                         $sth->execute(array(':id' => $id));
182
-                } catch(PDOException $e) {
182
+                } catch (PDOException $e) {
183 183
                         echo $e->getMessage();
184 184
                         die;
185 185
                 }
@@ -198,14 +198,14 @@  discard block
 block discarded – undo
198 198
         {
199 199
                 date_default_timezone_set('UTC');
200 200
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
201
-                $query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
201
+                $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
202 202
 
203 203
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
204 204
 
205 205
                 try {
206 206
                         $sth = $this->db->prepare($query);
207 207
                         $sth->execute(array(':id' => $id));
208
-                } catch(PDOException $e) {
208
+                } catch (PDOException $e) {
209 209
                         echo $e->getMessage();
210 210
                         die;
211 211
                 }
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
                 date_default_timezone_set('UTC');
228 228
 
229 229
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
230
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
230
+                $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
231 231
 
232 232
                 try {
233 233
                         $sth = $this->db->prepare($query);
234 234
                         $sth->execute(array(':ident' => $ident));
235
-                } catch(PDOException $e) {
235
+                } catch (PDOException $e) {
236 236
                         echo $e->getMessage();
237 237
                         die;
238 238
                 }
@@ -253,12 +253,12 @@  discard block
 block discarded – undo
253 253
                 date_default_timezone_set('UTC');
254 254
 
255 255
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
256
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
256
+                $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
257 257
 
258 258
                 try {
259 259
                         $sth = $this->db->prepare($query);
260 260
                         $sth->execute(array(':id' => $id));
261
-                } catch(PDOException $e) {
261
+                } catch (PDOException $e) {
262 262
                         echo $e->getMessage();
263 263
                         die;
264 264
                 }
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
                 date_default_timezone_set('UTC');
280 280
 
281 281
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
282
-                $query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
282
+                $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
283 283
 
284 284
                 try {
285 285
                         $sth = $this->db->prepare($query);
286 286
                         $sth->execute(array(':id' => $id));
287
-                } catch(PDOException $e) {
287
+                } catch (PDOException $e) {
288 288
                         echo $e->getMessage();
289 289
                         die;
290 290
                 }
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
                 date_default_timezone_set('UTC');
307 307
 
308 308
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
309
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
309
+                $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
310 310
 //                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";
311 311
 
312 312
                 try {
313 313
                         $sth = $this->db->prepare($query);
314 314
                         $sth->execute(array(':ident' => $ident));
315
-                } catch(PDOException $e) {
315
+                } catch (PDOException $e) {
316 316
                         echo $e->getMessage();
317 317
                         die;
318 318
                 }
@@ -329,12 +329,12 @@  discard block
 block discarded – undo
329 329
         * @return Array the spotter information
330 330
         *
331 331
         */
332
-	public function getMarineArchiveData($ident,$fammarine_id,$date)
332
+	public function getMarineArchiveData($ident, $fammarine_id, $date)
333 333
 	{
334 334
 		$Marine = new Marine($this->db);
335 335
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
336 336
 		$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";
337
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%'));
337
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%'));
338 338
 		return $spotter_array;
339 339
 	}
340 340
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		try {
354 354
 			$sth = $this->db->prepare($query);
355 355
 			$sth->execute();
356
-		} catch(PDOException $e) {
356
+		} catch (PDOException $e) {
357 357
 			echo $e->getMessage();
358 358
 			die;
359 359
 		}
@@ -365,24 +365,24 @@  discard block
 block discarded – undo
365 365
         * @return Array the spotter information
366 366
         *
367 367
         */
368
-        public function getMinLiveMarineData($begindate,$enddate,$filter = array())
368
+        public function getMinLiveMarineData($begindate, $enddate, $filter = array())
369 369
         {
370 370
                 global $globalDBdriver, $globalLiveInterval;
371 371
                 date_default_timezone_set('UTC');
372 372
 
373 373
                 $filter_query = '';
374 374
                 if (isset($filter['source']) && !empty($filter['source'])) {
375
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
375
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
376 376
                 }
377 377
                 // Use spotter_output also ?
378 378
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
379
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
379
+                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
380 380
                 }
381 381
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
382 382
                         $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
383 383
                 }
384 384
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
385
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
385
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
386 386
                 }
387 387
 
388 388
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -401,14 +401,14 @@  discard block
 block discarded – undo
401 401
 						GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id 
402 402
 				    AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
403 403
 */
404
-			$query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
404
+			$query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
405 405
 				    FROM marine_archive 
406 406
 				    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
407 407
 				    WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
408 408
                         	    '.$filter_query.' ORDER BY fammarine_id';
409 409
                 } else {
410 410
                         //$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
411
-                        $query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
411
+                        $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
412 412
                         	    FROM marine_archive 
413 413
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
414 414
                         	    WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
                 try {
419 419
                         $sth = $this->db->prepare($query);
420 420
                         $sth->execute();
421
-                } catch(PDOException $e) {
421
+                } catch (PDOException $e) {
422 422
                         echo $e->getMessage();
423 423
                         die;
424 424
                 }
@@ -433,24 +433,24 @@  discard block
 block discarded – undo
433 433
         * @return Array the spotter information
434 434
         *
435 435
         */
436
-        public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
436
+        public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array())
437 437
         {
438 438
                 global $globalDBdriver, $globalLiveInterval;
439 439
                 date_default_timezone_set('UTC');
440 440
 
441 441
                 $filter_query = '';
442 442
                 if (isset($filter['source']) && !empty($filter['source'])) {
443
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
443
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
444 444
                 }
445 445
                 // Should use spotter_output also ?
446 446
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
447
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
447
+                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
448 448
                 }
449 449
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
450 450
                         $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
451 451
                 }
452 452
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
453
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
453
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
454 454
                 }
455 455
 
456 456
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
                     		    FROM marine_archive 
461 461
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
462 462
 			*/
463
-			$query  = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk 
463
+			$query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk 
464 464
 				    FROM marine_archive_output 
465 465
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao 
466 466
 				    WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
476 476
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
477 477
                         */
478
-                        $query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
478
+                        $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
479 479
                         	    FROM marine_archive_output 
480 480
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
481 481
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
                 try {
488 488
                         $sth = $this->db->prepare($query);
489 489
                         $sth->execute();
490
-                } catch(PDOException $e) {
490
+                } catch (PDOException $e) {
491 491
                         echo $e->getMessage();
492 492
                         die;
493 493
                 }
@@ -502,23 +502,23 @@  discard block
 block discarded – undo
502 502
         * @return Array the spotter information
503 503
         *
504 504
         */
505
-        public function getLiveMarineCount($begindate,$enddate,$filter = array())
505
+        public function getLiveMarineCount($begindate, $enddate, $filter = array())
506 506
         {
507 507
                 global $globalDBdriver, $globalLiveInterval;
508 508
                 date_default_timezone_set('UTC');
509 509
 
510 510
                 $filter_query = '';
511 511
                 if (isset($filter['source']) && !empty($filter['source'])) {
512
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
512
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
513 513
                 }
514 514
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
515
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
515
+                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
516 516
                 }
517 517
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
518 518
                         $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
519 519
                 }
520 520
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
521
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
521
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
522 522
                 }
523 523
 
524 524
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
                 try {
534 534
                         $sth = $this->db->prepare($query);
535 535
                         $sth->execute();
536
-                } catch(PDOException $e) {
536
+                } catch (PDOException $e) {
537 537
                         echo $e->getMessage();
538 538
                         die;
539 539
                 }
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
     * @return Array the spotter information
554 554
     *
555 555
     */
556
-    public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
556
+    public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
557 557
     {
558 558
 	global $globalTimezone, $globalDBdriver;
559 559
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 	        
576 576
 		$q_array = explode(" ", $q);
577 577
 		
578
-		foreach ($q_array as $q_item){
578
+		foreach ($q_array as $q_item) {
579 579
 		    $additional_query .= " AND (";
580 580
 		    $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
581 581
 		    $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 	
608 608
 	if ($registration != "")
609 609
 	{
610
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
610
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
611 611
 	    if (!is_string($registration))
612 612
 	    {
613 613
 		return false;
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 	
619 619
 	if ($aircraft_icao != "")
620 620
 	{
621
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
621
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
622 622
 	    if (!is_string($aircraft_icao))
623 623
 	    {
624 624
 		return false;
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 	
630 630
 	if ($aircraft_manufacturer != "")
631 631
 	{
632
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
632
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
633 633
 	    if (!is_string($aircraft_manufacturer))
634 634
 	    {
635 635
 		return false;
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 	
651 651
 	if ($airline_icao != "")
652 652
 	{
653
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
653
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
654 654
 	    if (!is_string($airline_icao))
655 655
 	    {
656 656
 		return false;
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 	
662 662
 	if ($airline_country != "")
663 663
 	{
664
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
664
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
665 665
 	    if (!is_string($airline_country))
666 666
 	    {
667 667
 		return false;
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 	
673 673
 	if ($airline_type != "")
674 674
 	{
675
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
675
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
676 676
 	    if (!is_string($airline_type))
677 677
 	    {
678 678
 		return false;
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 	
695 695
 	if ($airport != "")
696 696
 	{
697
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
697
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
698 698
 	    if (!is_string($airport))
699 699
 	    {
700 700
 		return false;
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 	
706 706
 	if ($airport_country != "")
707 707
 	{
708
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
708
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
709 709
 	    if (!is_string($airport_country))
710 710
 	    {
711 711
 		return false;
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
     
717 717
 	if ($callsign != "")
718 718
 	{
719
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
719
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
720 720
 	    if (!is_string($callsign))
721 721
 	    {
722 722
 		return false;
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 		$translate = $Translation->ident2icao($callsign);
725 725
 		if ($translate != $callsign) {
726 726
 			$additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";
727
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
727
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
728 728
 		} else {
729 729
 			$additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";
730 730
 		}
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
 
734 734
 	if ($owner != "")
735 735
 	{
736
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
736
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
737 737
 	    if (!is_string($owner))
738 738
 	    {
739 739
 		return false;
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 
745 745
 	if ($pilot_name != "")
746 746
 	{
747
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
747
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
748 748
 	    if (!is_string($pilot_name))
749 749
 	    {
750 750
 		return false;
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 	
756 756
 	if ($pilot_id != "")
757 757
 	{
758
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
758
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
759 759
 	    if (!is_string($pilot_id))
760 760
 	    {
761 761
 		return false;
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 	
767 767
 	if ($departure_airport_route != "")
768 768
 	{
769
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
769
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
770 770
 	    if (!is_string($departure_airport_route))
771 771
 	    {
772 772
 		return false;
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 	
778 778
 	if ($arrival_airport_route != "")
779 779
 	{
780
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
780
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
781 781
 	    if (!is_string($arrival_airport_route))
782 782
 	    {
783 783
 		return false;
@@ -790,8 +790,8 @@  discard block
 block discarded – undo
790 790
 	{
791 791
 	    $altitude_array = explode(",", $altitude);
792 792
 	    
793
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
794
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
793
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
794
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
795 795
 	    
796 796
 
797 797
 	    if ($altitude_array[1] != "")
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
 	{
810 810
 	    $date_array = explode(",", $date_posted);
811 811
 	    
812
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
813
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
812
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
813
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
814 814
 	    
815 815
 	    if ($globalTimezone != '') {
816 816
 		date_default_timezone_set($globalTimezone);
@@ -842,8 +842,8 @@  discard block
 block discarded – undo
842 842
 	{
843 843
 	    $limit_array = explode(",", $limit);
844 844
 	    
845
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
846
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
845
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
846
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
847 847
 	    
848 848
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
849 849
 	    {
@@ -854,8 +854,8 @@  discard block
 block discarded – undo
854 854
 	
855 855
 
856 856
 	if ($origLat != "" && $origLon != "" && $dist != "") {
857
-		$dist = number_format($dist*0.621371,2,'.','');
858
-		$query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
857
+		$dist = number_format($dist*0.621371, 2, '.', '');
858
+		$query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
859 859
                           FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
860 860
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
861 861
 	} else {
@@ -872,12 +872,12 @@  discard block
 block discarded – undo
872 872
 			$additional_query .= " AND (marine_archive_output.waypoints <> '')";
873 873
 		}
874 874
 
875
-		$query  = "SELECT marine_archive_output.* FROM marine_archive_output 
875
+		$query = "SELECT marine_archive_output.* FROM marine_archive_output 
876 876
 		    WHERE marine_archive_output.ident <> '' 
877 877
 		    ".$additional_query."
878 878
 		    ".$filter_query.$orderby_query;
879 879
 	}
880
-	$spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);
880
+	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
881 881
 
882 882
 	return $spotter_array;
883 883
     }
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
                 try {
895 895
                         $sth = $this->db->prepare($query);
896 896
                         $sth->execute();
897
-                } catch(PDOException $e) {
897
+                } catch (PDOException $e) {
898 898
                         return "error";
899 899
                 }
900 900
 	}
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 	{
932 932
 	    $limit_array = explode(",", $limit);
933 933
 	    
934
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
935
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
934
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
935
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
936 936
 	    
937 937
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
938 938
 	    {
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
 	$query_values = array();
974 974
 	$limit_query = '';
975 975
 	$additional_query = '';
976
-	$filter_query = $this->getFilter($filter,true,true);
976
+	$filter_query = $this->getFilter($filter, true, true);
977 977
 	
978 978
 	if ($owner != "")
979 979
 	{
@@ -990,8 +990,8 @@  discard block
 block discarded – undo
990 990
 	{
991 991
 	    $limit_array = explode(",", $limit);
992 992
 	    
993
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
994
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
993
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
994
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
995 995
 	    
996 996
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
997 997
 	    {
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 	$query_values = array();
1032 1032
 	$limit_query = '';
1033 1033
 	$additional_query = '';
1034
-	$filter_query = $this->getFilter($filter,true,true);
1034
+	$filter_query = $this->getFilter($filter, true, true);
1035 1035
 	
1036 1036
 	if ($pilot != "")
1037 1037
 	{
@@ -1043,8 +1043,8 @@  discard block
 block discarded – undo
1043 1043
 	{
1044 1044
 	    $limit_array = explode(",", $limit);
1045 1045
 	    
1046
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1047
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1046
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1047
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1048 1048
 	    
1049 1049
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1050 1050
 	    {
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
     * @return Array the airline country list
1075 1075
     *
1076 1076
     */
1077
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1077
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1078 1078
     {
1079 1079
 	global $globalDBdriver;
1080 1080
 	/*
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
 	$flight_array = array();
1104 1104
 	$temp_array = array();
1105 1105
         
1106
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1106
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1107 1107
 	{
1108 1108
 	    $temp_array['flight_count'] = $row['nb'];
1109 1109
 	    $temp_array['flight_country'] = $row['name'];
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
     * @return Array the airline country list
1121 1121
     *
1122 1122
     */
1123
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1123
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1124 1124
     {
1125 1125
 	global $globalDBdriver;
1126 1126
 	/*
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 	$flight_array = array();
1150 1150
 	$temp_array = array();
1151 1151
         
1152
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1152
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1153 1153
 	{
1154 1154
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1155 1155
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1167,14 +1167,14 @@  discard block
 block discarded – undo
1167 1167
     * @return Array the spotter information
1168 1168
     *
1169 1169
     */
1170
-    public function getDateArchiveMarineDataById($id,$date)
1170
+    public function getDateArchiveMarineDataById($id, $date)
1171 1171
     {
1172 1172
 	$Marine = new Marine($this->db);
1173 1173
 	date_default_timezone_set('UTC');
1174 1174
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1175 1175
 	$query  = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC';
1176
-	$date = date('c',$date);
1177
-	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date));
1176
+	$date = date('c', $date);
1177
+	$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1178 1178
 	return $spotter_array;
1179 1179
     }
1180 1180
 
@@ -1184,14 +1184,14 @@  discard block
 block discarded – undo
1184 1184
     * @return Array the spotter information
1185 1185
     *
1186 1186
     */
1187
-    public function getDateArchiveMarineDataByIdent($ident,$date)
1187
+    public function getDateArchiveMarineDataByIdent($ident, $date)
1188 1188
     {
1189 1189
 	$Marine = new Marine($this->db);
1190 1190
 	date_default_timezone_set('UTC');
1191 1191
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1192 1192
 	$query  = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC';
1193
-	$date = date('c',$date);
1194
-	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1193
+	$date = date('c', $date);
1194
+	$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1195 1195
 	return $spotter_array;
1196 1196
     }
1197 1197
 
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
     * @return Array the spotter information
1202 1202
     *
1203 1203
     */
1204
-    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1204
+    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1205 1205
     {
1206 1206
 	global $global_query;
1207 1207
 	$Marine = new Marine($this->db);
@@ -1209,7 +1209,7 @@  discard block
 block discarded – undo
1209 1209
 	$query_values = array();
1210 1210
 	$limit_query = '';
1211 1211
 	$additional_query = '';
1212
-	$filter_query = $this->getFilter($filters,true,true);
1212
+	$filter_query = $this->getFilter($filters, true, true);
1213 1213
 	
1214 1214
 	if ($airport != "")
1215 1215
 	{
@@ -1226,8 +1226,8 @@  discard block
 block discarded – undo
1226 1226
 	{
1227 1227
 	    $limit_array = explode(",", $limit);
1228 1228
 	    
1229
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1230
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1229
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1230
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1231 1231
 	    
1232 1232
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1233 1233
 	    {
Please login to merge, or discard this patch.
require/class.MarineLive.php 4 patches
Doc Comments   +1 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	* Get SQL query part for filter used
16 16
 	* @param Array $filter the filter
17
-	* @return Array the SQL part
17
+	* @return string the SQL part
18 18
 	*/
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -794,10 +794,6 @@  discard block
 block discarded – undo
794 794
 	*
795 795
 	* @param String $fammarine_id the ID from flightaware
796 796
 	* @param String $ident the flight ident
797
-	* @param String $aircraft_icao the aircraft type
798
-	* @param String $departure_airport_icao the departure airport
799
-	* @param String $arrival_airport_icao the arrival airport
800
-	* @return String success or false
801 797
 	*
802 798
 	*/
803 799
 	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
Please login to merge, or discard this patch.
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 	/**
16
-	* Get SQL query part for filter used
17
-	* @param Array $filter the filter
18
-	* @return Array the SQL part
19
-	*/
16
+	 * Get SQL query part for filter used
17
+	 * @param Array $filter the filter
18
+	 * @return Array the SQL part
19
+	 */
20 20
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 	}
91 91
 
92 92
 	/**
93
-	* Gets all the spotter information based on the latest data entry
94
-	*
95
-	* @return Array the spotter information
96
-	*
97
-	*/
93
+	 * Gets all the spotter information based on the latest data entry
94
+	 *
95
+	 * @return Array the spotter information
96
+	 *
97
+	 */
98 98
 	public function getLiveMarineData($limit = '', $sort = '', $filter = array())
99 99
 	{
100 100
 		global $globalDBdriver, $globalLiveInterval;
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
 	}
138 138
 
139 139
 	/**
140
-	* Gets Minimal Live Spotter data
141
-	*
142
-	* @return Array the spotter information
143
-	*
144
-	*/
140
+	 * Gets Minimal Live Spotter data
141
+	 *
142
+	 * @return Array the spotter information
143
+	 *
144
+	 */
145 145
 	public function getMinLiveMarineData($filter = array())
146 146
 	{
147 147
 		global $globalDBdriver, $globalLiveInterval;
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 	}
172 172
 
173 173
 	/**
174
-	* Gets Minimal Live Spotter data since xx seconds
175
-	*
176
-	* @return Array the spotter information
177
-	*
178
-	*/
174
+	 * Gets Minimal Live Spotter data since xx seconds
175
+	 *
176
+	 * @return Array the spotter information
177
+	 *
178
+	 */
179 179
 	public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false)
180 180
 	{
181 181
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
@@ -246,11 +246,11 @@  discard block
 block discarded – undo
246 246
 	}
247 247
 
248 248
 	/**
249
-	* Gets number of latest data entry
250
-	*
251
-	* @return String number of entry
252
-	*
253
-	*/
249
+	 * Gets number of latest data entry
250
+	 *
251
+	 * @return String number of entry
252
+	 *
253
+	 */
254 254
 	public function getLiveMarineCount($filter = array())
255 255
 	{
256 256
 		global $globalDBdriver, $globalLiveInterval;
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
 	}
276 276
 
277 277
 	/**
278
-	* Gets all the spotter information based on the latest data entry and coord
279
-	*
280
-	* @return Array the spotter information
281
-	*
282
-	*/
278
+	 * Gets all the spotter information based on the latest data entry and coord
279
+	 *
280
+	 * @return Array the spotter information
281
+	 *
282
+	 */
283 283
 	public function getLiveMarineDatabyCoord($coord, $filter = array())
284 284
 	{
285 285
 		global $globalDBdriver, $globalLiveInterval;
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 	}
304 304
 
305 305
 	/**
306
-	* Gets all the spotter information based on the latest data entry and coord
307
-	*
308
-	* @return Array the spotter information
309
-	*
310
-	*/
306
+	 * Gets all the spotter information based on the latest data entry and coord
307
+	 *
308
+	 * @return Array the spotter information
309
+	 *
310
+	 */
311 311
 	public function getMinLiveMarineDatabyCoord($coord, $filter = array())
312 312
 	{
313 313
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -376,11 +376,11 @@  discard block
 block discarded – undo
376 376
 	}
377 377
 
378 378
 	/**
379
-	* Gets all the spotter information based on a user's latitude and longitude
380
-	*
381
-	* @return Array the spotter information
382
-	*
383
-	*/
379
+	 * Gets all the spotter information based on a user's latitude and longitude
380
+	 *
381
+	 * @return Array the spotter information
382
+	 *
383
+	 */
384 384
 	public function getLatestMarineForLayar($lat, $lng, $radius, $interval)
385 385
 	{
386 386
 		$Marine = new Marine($this->db);
@@ -393,75 +393,75 @@  discard block
 block discarded – undo
393 393
 		if ($lng != '')
394 394
 		{
395 395
 			if (!is_numeric($lng))
396
-                        {
397
-                                return false;
398
-                        }
399
-                }
400
-
401
-                if ($radius != '')
402
-                {
403
-                        if (!is_numeric($radius))
404
-                        {
405
-                                return false;
406
-                        }
407
-                }
396
+						{
397
+								return false;
398
+						}
399
+				}
400
+
401
+				if ($radius != '')
402
+				{
403
+						if (!is_numeric($radius))
404
+						{
405
+								return false;
406
+						}
407
+				}
408 408
 		$additional_query = '';
409 409
 		if ($interval != '')
410
-                {
411
-                        if (!is_string($interval))
412
-                        {
413
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
414
-			        return false;
415
-                        } else {
416
-                if ($interval == '1m')
417
-                {
418
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
419
-                } else if ($interval == '15m'){
420
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
421
-                } 
422
-            }
423
-                } else {
424
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
425
-        }
426
-
427
-                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
410
+				{
411
+						if (!is_string($interval))
412
+						{
413
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
414
+					return false;
415
+						} else {
416
+				if ($interval == '1m')
417
+				{
418
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
419
+				} else if ($interval == '15m'){
420
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
421
+				} 
422
+			}
423
+				} else {
424
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
425
+		}
426
+
427
+				$query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
428 428
                    WHERE marine_live.latitude <> '' 
429 429
                                    AND marine_live.longitude <> '' 
430 430
                    ".$additional_query."
431 431
                    HAVING distance < :radius  
432 432
                                    ORDER BY distance";
433 433
 
434
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
434
+				$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
435 435
 
436
-                return $spotter_array;
437
-        }
436
+				return $spotter_array;
437
+		}
438 438
 
439 439
     
440
-        /**
441
-	* Gets all the spotter information based on a particular callsign
442
-	*
443
-	* @return Array the spotter information
444
-	*
445
-	*/
440
+		/**
441
+		 * Gets all the spotter information based on a particular callsign
442
+		 *
443
+		 * @return Array the spotter information
444
+		 *
445
+		 */
446 446
 	public function getLastLiveMarineDataByIdent($ident)
447 447
 	{
448 448
 		$Marine = new Marine($this->db);
449 449
 		date_default_timezone_set('UTC');
450 450
 
451 451
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
452
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
452
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
453 453
 
454 454
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
455 455
 
456 456
 		return $spotter_array;
457 457
 	}
458 458
 
459
-        /**
460
-	* Gets all the spotter information based on a particular callsign
461
-	*
462
-	* @return Array the spotter information
463
-	*
464
-	*/
459
+		/**
460
+		 * Gets all the spotter information based on a particular callsign
461
+		 *
462
+		 * @return Array the spotter information
463
+		 *
464
+		 */
465 465
 	public function getDateLiveMarineDataByIdent($ident,$date)
466 466
 	{
467 467
 		$Marine = new Marine($this->db);
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
 	}
475 475
 
476 476
 	/**
477
-	* Gets all the spotter information based on a particular MMSI
478
-	*
479
-	* @return Array the spotter information
480
-	*
481
-	*/
477
+	 * Gets all the spotter information based on a particular MMSI
478
+	 *
479
+	 * @return Array the spotter information
480
+	 *
481
+	 */
482 482
 	public function getDateLiveMarineDataByMMSI($mmsi,$date)
483 483
 	{
484 484
 		$Marine = new Marine($this->db);
@@ -490,51 +490,51 @@  discard block
 block discarded – undo
490 490
 		return $spotter_array;
491 491
 	}
492 492
 
493
-        /**
494
-	* Gets last spotter information based on a particular callsign
495
-	*
496
-	* @return Array the spotter information
497
-	*
498
-	*/
493
+		/**
494
+		 * Gets last spotter information based on a particular callsign
495
+		 *
496
+		 * @return Array the spotter information
497
+		 *
498
+		 */
499 499
 	public function getLastLiveMarineDataById($id)
500 500
 	{
501 501
 		$Marine = new Marine($this->db);
502 502
 		date_default_timezone_set('UTC');
503 503
 
504 504
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
505
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
505
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
506 506
 
507 507
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
508 508
 
509 509
 		return $spotter_array;
510 510
 	}
511 511
 
512
-        /**
513
-	* Gets last spotter information based on a particular callsign
514
-	*
515
-	* @return Array the spotter information
516
-	*
517
-	*/
512
+		/**
513
+		 * Gets last spotter information based on a particular callsign
514
+		 *
515
+		 * @return Array the spotter information
516
+		 *
517
+		 */
518 518
 	public function getDateLiveMarineDataById($id,$date)
519 519
 	{
520 520
 		$Marine = new Marine($this->db);
521 521
 		date_default_timezone_set('UTC');
522 522
 
523 523
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
524
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
525
-                $date = date('c',$date);
524
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
525
+				$date = date('c',$date);
526 526
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
527 527
 
528 528
 		return $spotter_array;
529 529
 	}
530 530
 
531 531
 
532
-        /**
533
-	* Gets all the spotter information based on a particular id
534
-	*
535
-	* @return Array the spotter information
536
-	*
537
-	*/
532
+		/**
533
+		 * Gets all the spotter information based on a particular id
534
+		 *
535
+		 * @return Array the spotter information
536
+		 *
537
+		 */
538 538
 	public function getAllLiveMarineDataById($id,$liveinterval = false)
539 539
 	{
540 540
 		global $globalDBdriver, $globalLiveInterval;
@@ -562,18 +562,18 @@  discard block
 block discarded – undo
562 562
 		return $spotter_array;
563 563
 	}
564 564
 
565
-        /**
566
-	* Gets all the spotter information based on a particular ident
567
-	*
568
-	* @return Array the spotter information
569
-	*
570
-	*/
565
+		/**
566
+		 * Gets all the spotter information based on a particular ident
567
+		 *
568
+		 * @return Array the spotter information
569
+		 *
570
+		 */
571 571
 	public function getAllLiveMarineDataByIdent($ident)
572 572
 	{
573 573
 		date_default_timezone_set('UTC');
574 574
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
575 575
 		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
576
-    		try {
576
+			try {
577 577
 			
578 578
 			$sth = $this->db->prepare($query);
579 579
 			$sth->execute(array(':ident' => $ident));
@@ -587,23 +587,23 @@  discard block
 block discarded – undo
587 587
 
588 588
 
589 589
 	/**
590
-	* Deletes all info in the table
591
-	*
592
-	* @return String success or false
593
-	*
594
-	*/
590
+	 * Deletes all info in the table
591
+	 *
592
+	 * @return String success or false
593
+	 *
594
+	 */
595 595
 	public function deleteLiveMarineData()
596 596
 	{
597 597
 		global $globalDBdriver;
598 598
 		if ($globalDBdriver == 'mysql') {
599 599
 			//$query  = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date";
600 600
 			$query  = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date';
601
-            		//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
601
+					//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
602 602
 		} else {
603 603
 			$query  = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date";
604 604
 		}
605 605
         
606
-    		try {
606
+			try {
607 607
 			
608 608
 			$sth = $this->db->prepare($query);
609 609
 			$sth->execute();
@@ -615,18 +615,18 @@  discard block
 block discarded – undo
615 615
 	}
616 616
 
617 617
 	/**
618
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
619
-	*
620
-	* @return String success or false
621
-	*
622
-	*/
618
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
619
+	 *
620
+	 * @return String success or false
621
+	 *
622
+	 */
623 623
 	public function deleteLiveMarineDataNotUpdated()
624 624
 	{
625 625
 		global $globalDBdriver, $globalDebug;
626 626
 		if ($globalDBdriver == 'mysql') {
627 627
 			//$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0';
628
-    			$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
629
-    			try {
628
+				$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
629
+				try {
630 630
 				
631 631
 				$sth = $this->db->prepare($query);
632 632
 				$sth->execute();
@@ -634,8 +634,8 @@  discard block
 block discarded – undo
634 634
 				return "error";
635 635
 			}
636 636
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
637
-                        $i = 0;
638
-                        $j =0;
637
+						$i = 0;
638
+						$j =0;
639 639
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
640 640
 			foreach($all as $row)
641 641
 			{
@@ -643,20 +643,20 @@  discard block
 block discarded – undo
643 643
 				$j++;
644 644
 				if ($j == 30) {
645 645
 					if ($globalDebug) echo ".";
646
-				    	try {
646
+						try {
647 647
 						
648 648
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
649 649
 						$sth->execute();
650 650
 					} catch(PDOException $e) {
651 651
 						return "error";
652 652
 					}
653
-                                	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
654
-                                	$j = 0;
653
+									$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
654
+									$j = 0;
655 655
 				}
656 656
 				$query_delete .= "'".$row['fammarine_id']."',";
657 657
 			}
658 658
 			if ($i > 0) {
659
-    				try {
659
+					try {
660 660
 					
661 661
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
662 662
 					$sth->execute();
@@ -667,9 +667,9 @@  discard block
 block discarded – undo
667 667
 			return "success";
668 668
 		} elseif ($globalDBdriver == 'pgsql') {
669 669
 			//$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0";
670
-    			//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
671
-    			$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
672
-    			try {
670
+				//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
671
+				$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
672
+				try {
673 673
 				
674 674
 				$sth = $this->db->prepare($query);
675 675
 				$sth->execute();
@@ -713,17 +713,17 @@  discard block
 block discarded – undo
713 713
 	}
714 714
 
715 715
 	/**
716
-	* Deletes all info in the table for an ident
717
-	*
718
-	* @return String success or false
719
-	*
720
-	*/
716
+	 * Deletes all info in the table for an ident
717
+	 *
718
+	 * @return String success or false
719
+	 *
720
+	 */
721 721
 	public function deleteLiveMarineDataByIdent($ident)
722 722
 	{
723 723
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
724 724
 		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
725 725
         
726
-    		try {
726
+			try {
727 727
 			
728 728
 			$sth = $this->db->prepare($query);
729 729
 			$sth->execute(array(':ident' => $ident));
@@ -735,17 +735,17 @@  discard block
 block discarded – undo
735 735
 	}
736 736
 
737 737
 	/**
738
-	* Deletes all info in the table for an id
739
-	*
740
-	* @return String success or false
741
-	*
742
-	*/
738
+	 * Deletes all info in the table for an id
739
+	 *
740
+	 * @return String success or false
741
+	 *
742
+	 */
743 743
 	public function deleteLiveMarineDataById($id)
744 744
 	{
745 745
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
746 746
 		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
747 747
         
748
-    		try {
748
+			try {
749 749
 			
750 750
 			$sth = $this->db->prepare($query);
751 751
 			$sth->execute(array(':id' => $id));
@@ -758,11 +758,11 @@  discard block
 block discarded – undo
758 758
 
759 759
 
760 760
 	/**
761
-	* Gets the aircraft ident within the last hour
762
-	*
763
-	* @return String the ident
764
-	*
765
-	*/
761
+	 * Gets the aircraft ident within the last hour
762
+	 *
763
+	 * @return String the ident
764
+	 *
765
+	 */
766 766
 	public function getIdentFromLastHour($ident)
767 767
 	{
768 768
 		global $globalDBdriver, $globalTimezone;
@@ -788,14 +788,14 @@  discard block
 block discarded – undo
788 788
 			$ident_result = $row['ident'];
789 789
 		}
790 790
 		return $ident_result;
791
-        }
791
+		}
792 792
 
793 793
 	/**
794
-	* Check recent aircraft
795
-	*
796
-	* @return String the ident
797
-	*
798
-	*/
794
+	 * Check recent aircraft
795
+	 *
796
+	 * @return String the ident
797
+	 *
798
+	 */
799 799
 	public function checkIdentRecent($ident)
800 800
 	{
801 801
 		global $globalDBdriver, $globalTimezone;
@@ -821,14 +821,14 @@  discard block
 block discarded – undo
821 821
 			$ident_result = $row['fammarine_id'];
822 822
 		}
823 823
 		return $ident_result;
824
-        }
824
+		}
825 825
 
826 826
 	/**
827
-	* Check recent aircraft by id
828
-	*
829
-	* @return String the ident
830
-	*
831
-	*/
827
+	 * Check recent aircraft by id
828
+	 *
829
+	 * @return String the ident
830
+	 *
831
+	 */
832 832
 	public function checkIdRecent($id)
833 833
 	{
834 834
 		global $globalDBdriver, $globalTimezone;
@@ -854,14 +854,14 @@  discard block
 block discarded – undo
854 854
 			$ident_result = $row['fammarine_id'];
855 855
 		}
856 856
 		return $ident_result;
857
-        }
857
+		}
858 858
 
859 859
 	/**
860
-	* Check recent aircraft by mmsi
861
-	*
862
-	* @return String the ident
863
-	*
864
-	*/
860
+	 * Check recent aircraft by mmsi
861
+	 *
862
+	 * @return String the ident
863
+	 *
864
+	 */
865 865
 	public function checkMMSIRecent($mmsi)
866 866
 	{
867 867
 		global $globalDBdriver, $globalTimezone;
@@ -887,19 +887,19 @@  discard block
 block discarded – undo
887 887
 			$ident_result = $row['fammarine_id'];
888 888
 		}
889 889
 		return $ident_result;
890
-        }
890
+		}
891 891
 
892 892
 	/**
893
-	* Adds a new spotter data
894
-	*
895
-	* @param String $fammarine_id the ID from flightaware
896
-	* @param String $ident the flight ident
897
-	* @param String $aircraft_icao the aircraft type
898
-	* @param String $departure_airport_icao the departure airport
899
-	* @param String $arrival_airport_icao the arrival airport
900
-	* @return String success or false
901
-	*
902
-	*/
893
+	 * Adds a new spotter data
894
+	 *
895
+	 * @param String $fammarine_id the ID from flightaware
896
+	 * @param String $ident the flight ident
897
+	 * @param String $aircraft_icao the aircraft type
898
+	 * @param String $departure_airport_icao the departure airport
899
+	 * @param String $arrival_airport_icao the arrival airport
900
+	 * @return String success or false
901
+	 *
902
+	 */
903 903
 	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
904 904
 	{
905 905
 		global $globalURL, $globalArchive, $globalDebug;
@@ -973,10 +973,10 @@  discard block
 block discarded – undo
973 973
 		if ($typeid == '') $typeid = NULL;
974 974
 		if ($statusid == '') $statusid = NULL;
975 975
 
976
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
977
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
978
-            	if ($arrival_date == '') $arrival_date = NULL;
979
-            	$query = '';
976
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
977
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
978
+				if ($arrival_date == '') $arrival_date = NULL;
979
+				$query = '';
980 980
 		if ($globalArchive) {
981 981
 			if ($globalDebug) echo '-- Delete previous data -- ';
982 982
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
Please login to merge, or discard this patch.
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 	* @param Array $filter the filter
18 18
 	* @return Array the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
38 38
 				if (isset($flt['source'])) {
39
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
39
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
40 40
 				} else {
41
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
41
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
42 42
 				}
43 43
 			}
44 44
 		}
45 45
 		if (isset($filter['source']) && !empty($filter['source'])) {
46
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
46
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
47 47
 		}
48 48
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
49 49
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
76 76
 				}
77 77
 			}
78
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
78
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
79 79
 		}
80 80
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
81
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
81
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
82 82
 		}
83 83
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
84 84
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
85 85
 		if ($filter_query_where != '') {
86
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
86
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
87 87
 		}
88 88
 		$filter_query = $filter_query_join.$filter_query_where;
89 89
 		return $filter_query;
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 		if ($limit != '')
107 107
 		{
108 108
 			$limit_array = explode(',', $limit);
109
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
110
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
109
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
110
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
111 111
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
112 112
 			{
113 113
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
123 123
 			}
124 124
 		}
125
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
125
+		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
126 126
 
127 127
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
128 128
 		if ($globalDBdriver == 'mysql') {
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		} else {
132 132
 			$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query;
133 133
 		}
134
-		$spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true);
134
+		$spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true);
135 135
 
136 136
 		return $spotter_array;
137 137
 	}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 		global $globalDBdriver, $globalLiveInterval;
148 148
 		date_default_timezone_set('UTC');
149 149
 
150
-		$filter_query = $this->getFilter($filter,true,true);
150
+		$filter_query = $this->getFilter($filter, true, true);
151 151
 
152 152
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
153 153
 		if ($globalDBdriver == 'mysql') {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		try {
162 162
 			$sth = $this->db->prepare($query);
163 163
 			$sth->execute();
164
-		} catch(PDOException $e) {
164
+		} catch (PDOException $e) {
165 165
 			echo $e->getMessage();
166 166
 			die;
167 167
 		}
@@ -176,19 +176,19 @@  discard block
 block discarded – undo
176 176
 	* @return Array the spotter information
177 177
 	*
178 178
 	*/
179
-	public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false)
179
+	public function getMinLastLiveMarineData($coord = array(), $filter = array(), $limit = false)
180 180
 	{
181 181
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
182 182
 		date_default_timezone_set('UTC');
183 183
 		$usecoord = false;
184 184
 		if (is_array($coord) && !empty($coord)) {
185
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
186
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
187
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
188
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
185
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
186
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
187
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
188
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
189 189
 			$usecoord = true;
190 190
 		}
191
-		$filter_query = $this->getFilter($filter,true,true);
191
+		$filter_query = $this->getFilter($filter, true, true);
192 192
 
193 193
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194 194
 		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		try {
238 238
 			$sth = $this->db->prepare($query);
239 239
 			$sth->execute();
240
-		} catch(PDOException $e) {
240
+		} catch (PDOException $e) {
241 241
 			echo $e->getMessage();
242 242
 			die;
243 243
 		}
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	public function getLiveMarineCount($filter = array())
255 255
 	{
256 256
 		global $globalDBdriver, $globalLiveInterval;
257
-		$filter_query = $this->getFilter($filter,true,true);
257
+		$filter_query = $this->getFilter($filter, true, true);
258 258
 
259 259
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
260 260
 		if ($globalDBdriver == 'mysql') {
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 		try {
266 266
 			$sth = $this->db->prepare($query);
267 267
 			$sth->execute();
268
-		} catch(PDOException $e) {
268
+		} catch (PDOException $e) {
269 269
 			echo $e->getMessage();
270 270
 			die;
271 271
 		}
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
 		$filter_query = $this->getFilter($filter);
289 289
 
290 290
 		if (is_array($coord)) {
291
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
292
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
293
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
294
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
291
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
292
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
293
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
294
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
295 295
 		} else return array();
296 296
 		if ($globalDBdriver == 'mysql') {
297 297
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;
@@ -313,13 +313,13 @@  discard block
 block discarded – undo
313 313
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
314 314
 		$Marine = new Marine($this->db);
315 315
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
316
-		$filter_query = $this->getFilter($filter,true,true);
316
+		$filter_query = $this->getFilter($filter, true, true);
317 317
 
318 318
 		if (is_array($coord)) {
319
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
320
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
321
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
322
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
319
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
320
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
321
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
322
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
323 323
 		} else return array();
324 324
 		/*
325 325
 		if ($globalDBdriver == 'mysql') {
@@ -334,13 +334,13 @@  discard block
 block discarded – undo
334 334
 		*/
335 335
 		if ($globalDBdriver == 'mysql') {
336 336
 			if (isset($globalArchive) && $globalArchive === TRUE) {
337
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
337
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
338 338
 				    FROM marine_live 
339 339
 				    '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= marine_live.date 
340 340
 				    AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
341 341
 				    AND marine_live.latitude <> 0 AND marine_live.longitude <> 0';
342 342
 			} else {
343
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
343
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
344 344
 				    FROM marine_live 
345 345
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
346 346
 				    FROM marine_live l 
@@ -352,14 +352,14 @@  discard block
 block discarded – undo
352 352
 			}
353 353
 		} else {
354 354
 			if (isset($globalArchive) && $globalArchive === TRUE) {
355
-				$query  = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
355
+				$query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
356 356
 				    FROM marine_live 
357 357
 				    ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date 
358 358
 				    AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
359 359
 				    AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
360 360
 				    AND marine_live.latitude <> '0' AND marine_live.longitude <> '0'";
361 361
 			} else {
362
-				$query  = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
362
+				$query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
363 363
 				    FROM marine_live 
364 364
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
365 365
 				    FROM marine_live l 
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
                 if ($interval == '1m')
417 417
                 {
418 418
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
419
-                } else if ($interval == '15m'){
419
+                } else if ($interval == '15m') {
420 420
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
421 421
                 } 
422 422
             }
@@ -424,14 +424,14 @@  discard block
 block discarded – undo
424 424
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
425 425
         }
426 426
 
427
-                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
427
+                $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
428 428
                    WHERE marine_live.latitude <> '' 
429 429
                                    AND marine_live.longitude <> '' 
430 430
                    ".$additional_query."
431 431
                    HAVING distance < :radius  
432 432
                                    ORDER BY distance";
433 433
 
434
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
434
+                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
435 435
 
436 436
                 return $spotter_array;
437 437
         }
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 		date_default_timezone_set('UTC');
450 450
 
451 451
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
452
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
452
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
453 453
 
454
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
454
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true);
455 455
 
456 456
 		return $spotter_array;
457 457
 	}
@@ -462,14 +462,14 @@  discard block
 block discarded – undo
462 462
 	* @return Array the spotter information
463 463
 	*
464 464
 	*/
465
-	public function getDateLiveMarineDataByIdent($ident,$date)
465
+	public function getDateLiveMarineDataByIdent($ident, $date)
466 466
 	{
467 467
 		$Marine = new Marine($this->db);
468 468
 		date_default_timezone_set('UTC');
469 469
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
470 470
 		$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
471
-		$date = date('c',$date);
472
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
471
+		$date = date('c', $date);
472
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
473 473
 		return $spotter_array;
474 474
 	}
475 475
 
@@ -479,14 +479,14 @@  discard block
 block discarded – undo
479 479
 	* @return Array the spotter information
480 480
 	*
481 481
 	*/
482
-	public function getDateLiveMarineDataByMMSI($mmsi,$date)
482
+	public function getDateLiveMarineDataByMMSI($mmsi, $date)
483 483
 	{
484 484
 		$Marine = new Marine($this->db);
485 485
 		date_default_timezone_set('UTC');
486 486
 		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
487 487
 		$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.mmsi = :mmsi AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
488
-		$date = date('c',$date);
489
-		$spotter_array = $Marine->getDataFromDB($query,array(':mmsi' => $mmsi,':date' => $date));
488
+		$date = date('c', $date);
489
+		$spotter_array = $Marine->getDataFromDB($query, array(':mmsi' => $mmsi, ':date' => $date));
490 490
 		return $spotter_array;
491 491
 	}
492 492
 
@@ -502,9 +502,9 @@  discard block
 block discarded – undo
502 502
 		date_default_timezone_set('UTC');
503 503
 
504 504
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
505
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
505
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
506 506
 
507
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
507
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true);
508 508
 
509 509
 		return $spotter_array;
510 510
 	}
@@ -515,15 +515,15 @@  discard block
 block discarded – undo
515 515
 	* @return Array the spotter information
516 516
 	*
517 517
 	*/
518
-	public function getDateLiveMarineDataById($id,$date)
518
+	public function getDateLiveMarineDataById($id, $date)
519 519
 	{
520 520
 		$Marine = new Marine($this->db);
521 521
 		date_default_timezone_set('UTC');
522 522
 
523 523
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
524
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
525
-                $date = date('c',$date);
526
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
524
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
525
+                $date = date('c', $date);
526
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
527 527
 
528 528
 		return $spotter_array;
529 529
 	}
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 	* @return Array the spotter information
536 536
 	*
537 537
 	*/
538
-	public function getAllLiveMarineDataById($id,$liveinterval = false)
538
+	public function getAllLiveMarineDataById($id, $liveinterval = false)
539 539
 	{
540 540
 		global $globalDBdriver, $globalLiveInterval;
541 541
 		date_default_timezone_set('UTC');
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 		try {
555 555
 			$sth = $this->db->prepare($query);
556 556
 			$sth->execute(array(':id' => $id));
557
-		} catch(PDOException $e) {
557
+		} catch (PDOException $e) {
558 558
 			echo $e->getMessage();
559 559
 			die;
560 560
 		}
@@ -572,12 +572,12 @@  discard block
 block discarded – undo
572 572
 	{
573 573
 		date_default_timezone_set('UTC');
574 574
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
575
-		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
575
+		$query = self::$global_query.' WHERE marine_live.ident = :ident';
576 576
     		try {
577 577
 			
578 578
 			$sth = $this->db->prepare($query);
579 579
 			$sth->execute(array(':ident' => $ident));
580
-		} catch(PDOException $e) {
580
+		} catch (PDOException $e) {
581 581
 			echo $e->getMessage();
582 582
 			die;
583 583
 		}
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 			
608 608
 			$sth = $this->db->prepare($query);
609 609
 			$sth->execute();
610
-		} catch(PDOException $e) {
610
+		} catch (PDOException $e) {
611 611
 			return "error";
612 612
 		}
613 613
 
@@ -630,14 +630,14 @@  discard block
 block discarded – undo
630 630
 				
631 631
 				$sth = $this->db->prepare($query);
632 632
 				$sth->execute();
633
-			} catch(PDOException $e) {
633
+			} catch (PDOException $e) {
634 634
 				return "error";
635 635
 			}
636 636
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
637 637
                         $i = 0;
638
-                        $j =0;
638
+                        $j = 0;
639 639
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
640
-			foreach($all as $row)
640
+			foreach ($all as $row)
641 641
 			{
642 642
 				$i++;
643 643
 				$j++;
@@ -645,9 +645,9 @@  discard block
 block discarded – undo
645 645
 					if ($globalDebug) echo ".";
646 646
 				    	try {
647 647
 						
648
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
648
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
649 649
 						$sth->execute();
650
-					} catch(PDOException $e) {
650
+					} catch (PDOException $e) {
651 651
 						return "error";
652 652
 					}
653 653
                                 	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
@@ -658,9 +658,9 @@  discard block
 block discarded – undo
658 658
 			if ($i > 0) {
659 659
     				try {
660 660
 					
661
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
661
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
662 662
 					$sth->execute();
663
-				} catch(PDOException $e) {
663
+				} catch (PDOException $e) {
664 664
 					return "error";
665 665
 				}
666 666
 			}
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 				
674 674
 				$sth = $this->db->prepare($query);
675 675
 				$sth->execute();
676
-			} catch(PDOException $e) {
676
+			} catch (PDOException $e) {
677 677
 				return "error";
678 678
 			}
679 679
 /*			$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN (";
@@ -721,13 +721,13 @@  discard block
 block discarded – undo
721 721
 	public function deleteLiveMarineDataByIdent($ident)
722 722
 	{
723 723
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
724
-		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
724
+		$query = 'DELETE FROM marine_live WHERE ident = :ident';
725 725
         
726 726
     		try {
727 727
 			
728 728
 			$sth = $this->db->prepare($query);
729 729
 			$sth->execute(array(':ident' => $ident));
730
-		} catch(PDOException $e) {
730
+		} catch (PDOException $e) {
731 731
 			return "error";
732 732
 		}
733 733
 
@@ -743,13 +743,13 @@  discard block
 block discarded – undo
743 743
 	public function deleteLiveMarineDataById($id)
744 744
 	{
745 745
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
746
-		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
746
+		$query = 'DELETE FROM marine_live WHERE fammarine_id = :id';
747 747
         
748 748
     		try {
749 749
 			
750 750
 			$sth = $this->db->prepare($query);
751 751
 			$sth->execute(array(':id' => $id));
752
-		} catch(PDOException $e) {
752
+		} catch (PDOException $e) {
753 753
 			return "error";
754 754
 		}
755 755
 
@@ -767,13 +767,13 @@  discard block
 block discarded – undo
767 767
 	{
768 768
 		global $globalDBdriver, $globalTimezone;
769 769
 		if ($globalDBdriver == 'mysql') {
770
-			$query  = 'SELECT marine_live.ident FROM marine_live 
770
+			$query = 'SELECT marine_live.ident FROM marine_live 
771 771
 				WHERE marine_live.ident = :ident 
772 772
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
773 773
 				AND marine_live.date < UTC_TIMESTAMP()';
774 774
 			$query_data = array(':ident' => $ident);
775 775
 		} else {
776
-			$query  = "SELECT marine_live.ident FROM marine_live 
776
+			$query = "SELECT marine_live.ident FROM marine_live 
777 777
 				WHERE marine_live.ident = :ident 
778 778
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
779 779
 				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -782,8 +782,8 @@  discard block
 block discarded – undo
782 782
 		
783 783
 		$sth = $this->db->prepare($query);
784 784
 		$sth->execute($query_data);
785
-		$ident_result='';
786
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
785
+		$ident_result = '';
786
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
787 787
 		{
788 788
 			$ident_result = $row['ident'];
789 789
 		}
@@ -800,13 +800,13 @@  discard block
 block discarded – undo
800 800
 	{
801 801
 		global $globalDBdriver, $globalTimezone;
802 802
 		if ($globalDBdriver == 'mysql') {
803
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
803
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
804 804
 				WHERE marine_live.ident = :ident 
805 805
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
806 806
 //				AND marine_live.date < UTC_TIMESTAMP()";
807 807
 			$query_data = array(':ident' => $ident);
808 808
 		} else {
809
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
809
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
810 810
 				WHERE marine_live.ident = :ident 
811 811
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
812 812
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -815,8 +815,8 @@  discard block
 block discarded – undo
815 815
 		
816 816
 		$sth = $this->db->prepare($query);
817 817
 		$sth->execute($query_data);
818
-		$ident_result='';
819
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
818
+		$ident_result = '';
819
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
820 820
 		{
821 821
 			$ident_result = $row['fammarine_id'];
822 822
 		}
@@ -833,13 +833,13 @@  discard block
 block discarded – undo
833 833
 	{
834 834
 		global $globalDBdriver, $globalTimezone;
835 835
 		if ($globalDBdriver == 'mysql') {
836
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
836
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
837 837
 				WHERE marine_live.fammarine_id = :id 
838 838
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
839 839
 //				AND marine_live.date < UTC_TIMESTAMP()";
840 840
 			$query_data = array(':id' => $id);
841 841
 		} else {
842
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
842
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
843 843
 				WHERE marine_live.fammarine_id = :id 
844 844
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
845 845
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
 		
849 849
 		$sth = $this->db->prepare($query);
850 850
 		$sth->execute($query_data);
851
-		$ident_result='';
852
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
851
+		$ident_result = '';
852
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
853 853
 		{
854 854
 			$ident_result = $row['fammarine_id'];
855 855
 		}
@@ -866,13 +866,13 @@  discard block
 block discarded – undo
866 866
 	{
867 867
 		global $globalDBdriver, $globalTimezone;
868 868
 		if ($globalDBdriver == 'mysql') {
869
-			$query  = 'SELECT marine_live.fammarine_id FROM marine_live 
869
+			$query = 'SELECT marine_live.fammarine_id FROM marine_live 
870 870
 				WHERE marine_live.mmsi = :mmsi 
871 871
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
872 872
 //				AND marine_live.date < UTC_TIMESTAMP()";
873 873
 			$query_data = array(':mmsi' => $mmsi);
874 874
 		} else {
875
-			$query  = "SELECT marine_live.fammarine_id FROM marine_live 
875
+			$query = "SELECT marine_live.fammarine_id FROM marine_live 
876 876
 				WHERE marine_live.mmsi = :mmsi 
877 877
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
878 878
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -881,8 +881,8 @@  discard block
 block discarded – undo
881 881
 		
882 882
 		$sth = $this->db->prepare($query);
883 883
 		$sth->execute($query_data);
884
-		$ident_result='';
885
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
884
+		$ident_result = '';
885
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
886 886
 		{
887 887
 			$ident_result = $row['fammarine_id'];
888 888
 		}
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 	* @return String success or false
901 901
 	*
902 902
 	*/
903
-	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
903
+	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
904 904
 	{
905 905
 		global $globalURL, $globalArchive, $globalDebug;
906 906
 		$Common = new Common();
@@ -952,29 +952,29 @@  discard block
 block discarded – undo
952 952
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
953 953
 
954 954
         
955
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
956
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
957
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
958
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
959
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
960
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
961
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
962
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
963
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
964
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
965
-		$typeid = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT);
966
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
967
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
968
-		$statusid = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT);
969
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
970
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
971
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
972
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
955
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
956
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
957
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
958
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
959
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
960
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
961
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
962
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
963
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
964
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
965
+		$typeid = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT);
966
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
967
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
968
+		$statusid = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT);
969
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
970
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
971
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
972
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
973 973
 		if ($typeid == '') $typeid = NULL;
974 974
 		if ($statusid == '') $statusid = NULL;
975 975
 
976
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
977
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
976
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
977
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
978 978
             	if ($arrival_date == '') $arrival_date = NULL;
979 979
             	$query = '';
980 980
 		if ($globalArchive) {
@@ -983,19 +983,19 @@  discard block
 block discarded – undo
983 983
 		}
984 984
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date) 
985 985
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:typeid,:status,:statusid,:imo,:arrival_port_name,:arrival_port_date)';
986
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':typeid' => $typeid,':status' => $status,':statusid' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
986
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':typeid' => $typeid, ':status' => $status, ':statusid' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
987 987
 		try {
988 988
 			$sth = $this->db->prepare($query);
989 989
 			$sth->execute($query_values);
990 990
 			$sth->closeCursor();
991
-		} catch(PDOException $e) {
991
+		} catch (PDOException $e) {
992 992
 			return "error : ".$e->getMessage();
993 993
 		}
994 994
 		
995 995
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
996 996
 			if ($globalDebug) echo '(Add to Marine archive : ';
997 997
 			$MarineArchive = new MarineArchive($this->db);
998
-			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country);
998
+			$result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country);
999 999
 			if ($globalDebug) echo $result.')';
1000 1000
 		}
1001 1001
 		return "success";
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 
1004 1004
 	public function getOrderBy()
1005 1005
 	{
1006
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
1006
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
1007 1007
 		return $orderby;
1008 1008
 	}
1009 1009
 
Please login to merge, or discard this patch.
Braces   +119 added lines, -40 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (MarineLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (MarineLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -80,8 +84,11 @@  discard block
 block discarded – undo
80 84
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
81 85
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
82 86
 		}
83
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
84
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
87
+		if ($filter_query_where == '' && $where) {
88
+			$filter_query_where = ' WHERE';
89
+		} elseif ($filter_query_where != '' && $and) {
90
+			$filter_query_where .= ' AND';
91
+		}
85 92
 		if ($filter_query_where != '') {
86 93
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
87 94
 		}
@@ -122,9 +129,13 @@  discard block
 block discarded – undo
122 129
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
123 130
 			}
124 131
 		}
125
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
132
+		if ($orderby_query == '') {
133
+			$orderby_query= ' ORDER BY date DESC';
134
+		}
126 135
 
127
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
136
+		if (!isset($globalLiveInterval)) {
137
+			$globalLiveInterval = '200';
138
+		}
128 139
 		if ($globalDBdriver == 'mysql') {
129 140
 			//$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate";
130 141
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -149,7 +160,9 @@  discard block
 block discarded – undo
149 160
 
150 161
 		$filter_query = $this->getFilter($filter,true,true);
151 162
 
152
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
163
+		if (!isset($globalLiveInterval)) {
164
+			$globalLiveInterval = '200';
165
+		}
153 166
 		if ($globalDBdriver == 'mysql') {
154 167
 			$query  = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
155 168
 			FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0";
@@ -190,48 +203,72 @@  discard block
 block discarded – undo
190 203
 		}
191 204
 		$filter_query = $this->getFilter($filter,true,true);
192 205
 
193
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194
-		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
206
+		if (!isset($globalLiveInterval)) {
207
+			$globalLiveInterval = '200';
208
+		}
209
+		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') {
210
+			$globalMap3DMarinesLimit = '300';
211
+		}
195 212
 		if ($globalDBdriver == 'mysql') {
196 213
 			if (isset($globalArchive) && $globalArchive === TRUE) {
197 214
 				$query  = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source 
198 215
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
199
-				if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
216
+				if ($usecoord) {
217
+					$query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
218
+				}
200 219
 				$query .= "UNION
201 220
 				    SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
202 221
 				    FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date";
203
-				if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
222
+				if ($usecoord) {
223
+					$query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
224
+				}
204 225
 				$query .= ") AS marine 
205 226
 				    WHERE latitude <> '0' AND longitude <> '0' 
206 227
 				    ORDER BY fammarine_id, date";
207
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
228
+				if ($limit) {
229
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
230
+				}
208 231
 			} else {
209 232
 				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
210 233
 				    FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date ";
211
-				if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
234
+				if ($usecoord) {
235
+					$query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
236
+				}
212 237
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
213 238
 				ORDER BY marine_live.fammarine_id, marine_live.date";
214
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
239
+				if ($limit) {
240
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
241
+				}
215 242
 			}
216 243
 		} else {
217 244
 			if (isset($globalArchive) && $globalArchive === TRUE) {
218 245
 				$query  = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source 
219 246
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
220
-				if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
247
+				if ($usecoord) {
248
+					$query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
249
+				}
221 250
 				$query .= "UNION
222 251
 				    SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
223 252
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date";
224
-				if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
253
+				if ($usecoord) {
254
+					$query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
255
+				}
225 256
 				$query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' ";
226 257
 				$query .= "ORDER BY fammarine_id, date";
227
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
258
+				if ($limit) {
259
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
260
+				}
228 261
 			} else {
229 262
 				$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
230 263
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date ";
231
-				if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
264
+				if ($usecoord) {
265
+					$query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
266
+				}
232 267
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
233 268
 				ORDER BY marine_live.fammarine_id, marine_live.date";
234
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
269
+				if ($limit) {
270
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
271
+				}
235 272
 			}
236 273
 		}
237 274
 		try {
@@ -256,7 +293,9 @@  discard block
 block discarded – undo
256 293
 		global $globalDBdriver, $globalLiveInterval;
257 294
 		$filter_query = $this->getFilter($filter,true,true);
258 295
 
259
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
296
+		if (!isset($globalLiveInterval)) {
297
+			$globalLiveInterval = '200';
298
+		}
260 299
 		if ($globalDBdriver == 'mysql') {
261 300
 			$query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
262 301
 		} else {
@@ -284,7 +323,9 @@  discard block
 block discarded – undo
284 323
 	{
285 324
 		global $globalDBdriver, $globalLiveInterval;
286 325
 		$Marine = new Marine($this->db);
287
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
326
+		if (!isset($globalLiveInterval)) {
327
+			$globalLiveInterval = '200';
328
+		}
288 329
 		$filter_query = $this->getFilter($filter);
289 330
 
290 331
 		if (is_array($coord)) {
@@ -292,7 +333,9 @@  discard block
 block discarded – undo
292 333
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
293 334
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
294 335
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
295
-		} else return array();
336
+		} else {
337
+			return array();
338
+		}
296 339
 		if ($globalDBdriver == 'mysql') {
297 340
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;
298 341
 		} else {
@@ -312,7 +355,9 @@  discard block
 block discarded – undo
312 355
 	{
313 356
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
314 357
 		$Marine = new Marine($this->db);
315
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
358
+		if (!isset($globalLiveInterval)) {
359
+			$globalLiveInterval = '200';
360
+		}
316 361
 		$filter_query = $this->getFilter($filter,true,true);
317 362
 
318 363
 		if (is_array($coord)) {
@@ -320,7 +365,9 @@  discard block
 block discarded – undo
320 365
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
321 366
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
322 367
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
323
-		} else return array();
368
+		} else {
369
+			return array();
370
+		}
324 371
 		/*
325 372
 		if ($globalDBdriver == 'mysql') {
326 373
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
@@ -543,11 +590,15 @@  discard block
 block discarded – undo
543 590
 		//$query  = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';
544 591
 		if ($globalDBdriver == 'mysql') {
545 592
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
546
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
593
+			if ($liveinterval) {
594
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
595
+			}
547 596
 			$query .= ' ORDER BY date';
548 597
 		} else {
549 598
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
550
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
599
+			if ($liveinterval) {
600
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
601
+			}
551 602
 			$query .= ' ORDER BY date';
552 603
 		}
553 604
 
@@ -642,7 +693,9 @@  discard block
 block discarded – undo
642 693
 				$i++;
643 694
 				$j++;
644 695
 				if ($j == 30) {
645
-					if ($globalDebug) echo ".";
696
+					if ($globalDebug) {
697
+						echo ".";
698
+					}
646 699
 				    	try {
647 700
 						
648 701
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -922,7 +975,9 @@  discard block
 block discarded – undo
922 975
 			{
923 976
 				return false;
924 977
 			}
925
-		} else return '';
978
+		} else {
979
+			return '';
980
+		}
926 981
 
927 982
 		if ($longitude != '')
928 983
 		{
@@ -930,7 +985,9 @@  discard block
 block discarded – undo
930 985
 			{
931 986
 				return false;
932 987
 			}
933
-		} else return '';
988
+		} else {
989
+			return '';
990
+		}
934 991
 
935 992
 
936 993
 		if ($heading != '')
@@ -939,7 +996,9 @@  discard block
 block discarded – undo
939 996
 			{
940 997
 				return false;
941 998
 			}
942
-		} else $heading = 0;
999
+		} else {
1000
+			$heading = 0;
1001
+		}
943 1002
 
944 1003
 		if ($groundspeed != '')
945 1004
 		{
@@ -947,9 +1006,13 @@  discard block
 block discarded – undo
947 1006
 			{
948 1007
 				return false;
949 1008
 			}
950
-		} else $groundspeed = 0;
1009
+		} else {
1010
+			$groundspeed = 0;
1011
+		}
951 1012
 		date_default_timezone_set('UTC');
952
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1013
+		if ($date == '') {
1014
+			$date = date("Y-m-d H:i:s", time());
1015
+		}
953 1016
 
954 1017
         
955 1018
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -970,15 +1033,27 @@  discard block
 block discarded – undo
970 1033
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
971 1034
 		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
972 1035
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
973
-		if ($typeid == '') $typeid = NULL;
974
-		if ($statusid == '') $statusid = NULL;
1036
+		if ($typeid == '') {
1037
+			$typeid = NULL;
1038
+		}
1039
+		if ($statusid == '') {
1040
+			$statusid = NULL;
1041
+		}
975 1042
 
976
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
977
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
978
-            	if ($arrival_date == '') $arrival_date = NULL;
1043
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1044
+            		$groundspeed = 0;
1045
+            	}
1046
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1047
+            		$heading = 0;
1048
+            	}
1049
+            	if ($arrival_date == '') {
1050
+            		$arrival_date = NULL;
1051
+            	}
979 1052
             	$query = '';
980 1053
 		if ($globalArchive) {
981
-			if ($globalDebug) echo '-- Delete previous data -- ';
1054
+			if ($globalDebug) {
1055
+				echo '-- Delete previous data -- ';
1056
+			}
982 1057
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
983 1058
 		}
984 1059
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date) 
@@ -993,10 +1068,14 @@  discard block
 block discarded – undo
993 1068
 		}
994 1069
 		
995 1070
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
996
-			if ($globalDebug) echo '(Add to Marine archive : ';
1071
+			if ($globalDebug) {
1072
+				echo '(Add to Marine archive : ';
1073
+			}
997 1074
 			$MarineArchive = new MarineArchive($this->db);
998 1075
 			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country);
999
-			if ($globalDebug) echo $result.')';
1076
+			if ($globalDebug) {
1077
+				echo $result.')';
1078
+			}
1000 1079
 		}
1001 1080
 		return "success";
1002 1081
 	}
Please login to merge, or discard this patch.
ident.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $ident = '';
4
-if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING);
5
-if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
4
+if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST, 'ident', FILTER_SANITIZE_STRING);
5
+if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
6 6
 if ($ident != '')
7 7
 {
8 8
 	if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident);
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,13 +1,20 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $ident = '';
4
-if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING);
5
-if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
4
+if (isset($_POST['ident'])) {
5
+	$ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING);
6
+}
7
+if (isset($_GET['ident'])) {
8
+	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
9
+}
6 10
 if ($ident != '')
7 11
 {
8
-	if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident);
9
-	else header('Location: '.$globalURL.'/ident/'.$ident);
10
-} else {
12
+	if (isset($_GET['marine'])) {
13
+		header('Location: '.$globalURL.'/marine/ident/'.$ident);
14
+	} else {
15
+		header('Location: '.$globalURL.'/ident/'.$ident);
16
+	}
17
+	} else {
11 18
 	if ($globalURL == '') {
12 19
 		header('Location: /');
13 20
 	} else {
Please login to merge, or discard this patch.
currently.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,21 +4,21 @@  discard block
 block discarded – undo
4 4
 
5 5
 $type = '';
6 6
 if (isset($_GET['marine'])) {
7
-	require_once('require/class.Marine.php');;
7
+	require_once('require/class.Marine.php'); ;
8 8
 	require_once('require/class.MarineLive.php');
9
-	$MarineLive=new MarineLive();
9
+	$MarineLive = new MarineLive();
10 10
 	$type = 'marine';
11 11
 	$page_url = $globalURL.'/marine/currently';
12 12
 } elseif (isset($_GET['tracker'])) {
13
-	require_once('require/class.Tracker.php');;
13
+	require_once('require/class.Tracker.php'); ;
14 14
 	require_once('require/class.TrackerLive.php');
15
-	$TrackerLive=new TrackerLive();
15
+	$TrackerLive = new TrackerLive();
16 16
 	$type = 'tracker';
17 17
 	$page_url = $globalURL.'/tracker/currently';
18 18
 } else {
19
-	require_once('require/class.Spotter.php');;
19
+	require_once('require/class.Spotter.php'); ;
20 20
 	require_once('require/class.SpotterLive.php');
21
-	$SpotterLive=new SpotterLive();
21
+	$SpotterLive = new SpotterLive();
22 22
 	$type = 'aircraft';
23 23
 	$page_url = $globalURL.'/currently';
24 24
 }
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 $title = "Current Activity";
27 27
 require_once('header.php');
28 28
 //calculuation for the pagination
29
-if(!isset($_GET['limit']))
29
+if (!isset($_GET['limit']))
30 30
 {
31 31
 	$limit_start = 0;
32 32
 	$limit_end = 25;
33 33
 	$absolute_difference = 25;
34
-}  else {
34
+} else {
35 35
 	$limit_explode = explode(",", $_GET['limit']);
36 36
 	$limit_start = $limit_explode[0];
37 37
 	$limit_end = $limit_explode[1];
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>';
55 55
 elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>';
56 56
 
57
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
57
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
58 58
 if ($sort != '') {
59 59
 	if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort);
60 60
 	elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort);
Please login to merge, or discard this patch.
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	$limit_start = 0;
32 32
 	$limit_end = 25;
33 33
 	$absolute_difference = 25;
34
-}  else {
34
+} else {
35 35
 	$limit_explode = explode(",", $_GET['limit']);
36 36
 	$limit_start = $limit_explode[0];
37 37
 	$limit_end = $limit_explode[1];
@@ -50,20 +50,32 @@  discard block
 block discarded – undo
50 50
 print '</div>';
51 51
 
52 52
 print '<div class="table column">';
53
-if ($type == 'aircraft') print '<p>'._("The table below shows the detailed information of all current flights.").'</p>';
54
-elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>';
55
-elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>';
53
+if ($type == 'aircraft') {
54
+	print '<p>'._("The table below shows the detailed information of all current flights.").'</p>';
55
+} elseif ($type == 'marine') {
56
+	print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>';
57
+} elseif ($type == 'tracker') {
58
+	print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>';
59
+}
56 60
 
57 61
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
58 62
 if ($sort != '') {
59
-	if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort);
60
-	elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort);
61
-	elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort);
62
-} else {
63
-	if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference);
64
-	elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference);
65
-	elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference);
66
-}
63
+	if ($type == 'aircraft') {
64
+		$spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort);
65
+	} elseif ($type == 'marine') {
66
+		$spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort);
67
+	} elseif ($type == 'tracker') {
68
+		$spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort);
69
+	}
70
+	} else {
71
+	if ($type == 'aircraft') {
72
+		$spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference);
73
+	} elseif ($type == 'marine') {
74
+		$spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference);
75
+	} elseif ($type == 'tracker') {
76
+		$spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference);
77
+	}
78
+	}
67 79
 
68 80
 if (!empty($spotter_array))
69 81
 {
Please login to merge, or discard this patch.
date.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 $type = 'aircraft';
4 4
 if (isset($_GET['marine'])) $type = 'marine';
5 5
 elseif (isset($_GET['tracker'])) $type = 'tracker';
6
-$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
6
+$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING);
7 7
 if ($date == '') $date = date('Y-m-d');
8 8
 if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date);
9 9
 elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date);
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,20 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $type = 'aircraft';
4
-if (isset($_GET['marine'])) $type = 'marine';
5
-elseif (isset($_GET['tracker'])) $type = 'tracker';
4
+if (isset($_GET['marine'])) {
5
+	$type = 'marine';
6
+} elseif (isset($_GET['tracker'])) {
7
+	$type = 'tracker';
8
+}
6 9
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
7
-if ($date == '') $date = date('Y-m-d');
8
-if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date);
9
-elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date);
10
-else header('Location: '.$globalURL.'/date/'.$date);
10
+if ($date == '') {
11
+	$date = date('Y-m-d');
12
+}
13
+if ($type == 'marine') {
14
+	header('Location: '.$globalURL.'/marine/date/'.$date);
15
+} elseif ($type == 'tracker') {
16
+	header('Location: '.$globalURL.'/tracker/date/'.$date);
17
+} else {
18
+	header('Location: '.$globalURL.'/date/'.$date);
19
+}
11 20
 ?>
12 21
\ No newline at end of file
Please login to merge, or discard this patch.
date-detailed.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -2,34 +2,34 @@  discard block
 block discarded – undo
2 2
 require_once('require/class.Connection.php');
3 3
 require_once('require/class.Language.php');
4 4
 $type = '';
5
-$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
5
+$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING);
6 6
 if (isset($_GET['marine'])) {
7
-	require_once('require/class.Marine.php');;
7
+	require_once('require/class.Marine.php'); ;
8 8
 	$Marine = new Marine();
9 9
 	$type = 'marine';
10 10
 	$page_url = $globalURL.'/marine/date/'.$date;
11 11
 } elseif (isset($_GET['tracker'])) {
12
-	require_once('require/class.Tracker.php');;
12
+	require_once('require/class.Tracker.php'); ;
13 13
 	$Tracker = new Tracker();
14 14
 	$type = 'tracker';
15 15
 	$page_url = $globalURL.'/tracker/date/'.$date;
16 16
 } else {
17
-	require_once('require/class.Spotter.php');;
17
+	require_once('require/class.Spotter.php'); ;
18 18
 	$Spotter = new Spotter();
19 19
 	$type = 'aircraft';
20 20
 	$page_url = $globalURL.'/date/'.$date;
21 21
 }
22 22
 
23
-if (!isset($_GET['date'])){
23
+if (!isset($_GET['date'])) {
24 24
 	header('Location: '.$globalURL.'');
25 25
 } else {
26 26
 	//calculuation for the pagination
27
-	if(!isset($_GET['limit']))
27
+	if (!isset($_GET['limit']))
28 28
 	{
29 29
 		$limit_start = 0;
30 30
 		$limit_end = 25;
31 31
 		$absolute_difference = 25;
32
-	}  else {
32
+	} else {
33 33
 		$limit_explode = explode(",", $_GET['limit']);
34 34
 		$limit_start = $limit_explode[0];
35 35
 		$limit_end = $limit_explode[1];
@@ -43,24 +43,24 @@  discard block
 block discarded – undo
43 43
 	$limit_previous_1 = $limit_start - $absolute_difference;
44 44
 	$limit_previous_2 = $limit_end - $absolute_difference;
45 45
 	
46
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
46
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
47 47
 	if ($sort != '') 
48 48
 	{
49
-		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort);
50
-		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort);
51
-		else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort);
49
+		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date, $limit_start.",".$absolute_difference, $sort);
50
+		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date, $limit_start.",".$absolute_difference, $sort);
51
+		else $spotter_array = $Spotter->getSpotterDataByDate($date, $limit_start.",".$absolute_difference, $sort);
52 52
 	} else {
53
-		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference);
54
-		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference);
55
-		else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference);
53
+		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date, $limit_start.",".$absolute_difference);
54
+		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date, $limit_start.",".$absolute_difference);
55
+		else $spotter_array = $Spotter->getSpotterDataByDate($date, $limit_start.",".$absolute_difference);
56 56
 	}
57 57
 	
58 58
 	if (!empty($spotter_array))
59 59
 	{
60 60
 		date_default_timezone_set($globalTimezone);
61
-		if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
62
-		elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
63
-		else $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
61
+		if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
62
+		elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
63
+		else $title = sprintf(_("Detailed View for flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
64 64
 
65 65
 		require_once('header.php');
66 66
 		print '<div class="select-item">';
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 		print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
79 79
 		print '<br />';
80 80
 		print '<div class="info column">';
81
-		if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
82
-		else print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
81
+		if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
82
+		else print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
83 83
 		print '</div>';
84 84
 
85 85
 		if ($type == 'aircraft') include('date-sub-menu.php');
86 86
 		print '<div class="table column">';
87
-		if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
88
-		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
89
-		else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
87
+		if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
88
+		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
89
+		else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
90 90
  
91 91
 		include('table-output.php');
92 92
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Braces   +37 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		$limit_start = 0;
30 30
 		$limit_end = 25;
31 31
 		$absolute_difference = 25;
32
-	}  else {
32
+	} else {
33 33
 		$limit_explode = explode(",", $_GET['limit']);
34 34
 		$limit_start = $limit_explode[0];
35 35
 		$limit_end = $limit_explode[1];
@@ -46,21 +46,33 @@  discard block
 block discarded – undo
46 46
 	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
47 47
 	if ($sort != '') 
48 48
 	{
49
-		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort);
50
-		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort);
51
-		else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort);
49
+		if ($type == 'marine') {
50
+			$spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort);
51
+		} elseif ($type == 'tracker') {
52
+			$spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort);
53
+		} else {
54
+			$spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort);
55
+		}
52 56
 	} else {
53
-		if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference);
54
-		elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference);
55
-		else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference);
57
+		if ($type == 'marine') {
58
+			$spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference);
59
+		} elseif ($type == 'tracker') {
60
+			$spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference);
61
+		} else {
62
+			$spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference);
63
+		}
56 64
 	}
57 65
 	
58 66
 	if (!empty($spotter_array))
59 67
 	{
60 68
 		date_default_timezone_set($globalTimezone);
61
-		if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
62
-		elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
63
-		else $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
69
+		if ($type == 'marine') {
70
+			$title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
71
+		} elseif ($type == 'tracker') {
72
+			$title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
73
+		} else {
74
+			$title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
75
+		}
64 76
 
65 77
 		require_once('header.php');
66 78
 		print '<div class="select-item">';
@@ -78,15 +90,24 @@  discard block
 block discarded – undo
78 90
 		print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
79 91
 		print '<br />';
80 92
 		print '<div class="info column">';
81
-		if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
82
-		else print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
93
+		if ($type == 'marine') {
94
+			print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
95
+		} else {
96
+			print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
97
+		}
83 98
 		print '</div>';
84 99
 
85
-		if ($type == 'aircraft') include('date-sub-menu.php');
100
+		if ($type == 'aircraft') {
101
+			include('date-sub-menu.php');
102
+		}
86 103
 		print '<div class="table column">';
87
-		if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
88
-		elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
89
-		else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
104
+		if ($type == 'marine') {
105
+			print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
106
+		} elseif ($type == 'tracker') {
107
+			print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
108
+		} else {
109
+			print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
110
+		}
90 111
  
91 112
 		include('table-output.php');
92 113
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
latest.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
 require_once('header.php');
24 24
 
25 25
 //calculuation for the pagination
26
-if(!isset($_GET['limit']))
26
+if (!isset($_GET['limit']))
27 27
 {
28 28
 	$limit_start = 0;
29 29
 	$limit_end = 25;
30 30
 	$absolute_difference = 25;
31
-}  else {
31
+} else {
32 32
 	$limit_explode = explode(",", $_GET['limit']);
33 33
 	$limit_start = $limit_explode[0];
34 34
 	$limit_end = $limit_explode[1];
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>';
52 52
 else print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>';
53 53
 
54
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
54
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
55 55
 $sql_begin = microtime(true);
56 56
 if ($type == 'marine') {
57 57
 	$spotter_array = $Marine->getLatestMarineData($limit_start.",".$absolute_difference, $sort);
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 } else {
61 61
 	$spotter_array = $Spotter->getLatestSpotterData($limit_start.",".$absolute_difference, $sort);
62 62
 }
63
-$sql_time = microtime(true)-$sql_begin;
63
+$sql_time = microtime(true) - $sql_begin;
64 64
 $page_begin = microtime(true);
65 65
 if (!empty($spotter_array))
66 66
 {
@@ -77,6 +77,6 @@  discard block
 block discarded – undo
77 77
 	print '</div>';
78 78
 	print '</div>';
79 79
 }
80
-$page_time = microtime(true)-$page_begin;
80
+$page_time = microtime(true) - $page_begin;
81 81
 require_once('footer.php');
82 82
 ?>
83 83
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	$limit_start = 0;
29 29
 	$limit_end = 25;
30 30
 	$absolute_difference = 25;
31
-}  else {
31
+} else {
32 32
 	$limit_explode = explode(",", $_GET['limit']);
33 33
 	$limit_start = $limit_explode[0];
34 34
 	$limit_end = $limit_explode[1];
@@ -47,9 +47,13 @@  discard block
 block discarded – undo
47 47
 print '<h1>'._("Latest Activity").'</h1>';
48 48
 print '</div>';
49 49
 print '<div class="table column">';
50
-if ($type == 'marine') print '<p>'._("The table below shows the detailed information of all recent vessels.").'</p>';
51
-elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>';
52
-else print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>';
50
+if ($type == 'marine') {
51
+	print '<p>'._("The table below shows the detailed information of all recent vessels.").'</p>';
52
+} elseif ($type == 'tracker') {
53
+	print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>';
54
+} else {
55
+	print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>';
56
+}
53 57
 
54 58
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
55 59
 $sql_begin = microtime(true);
Please login to merge, or discard this patch.
require/class.TrackerArchive.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 	/**
15 15
 	* Get SQL query part for filter used
16 16
 	* @param Array $filter the filter
17
-	* @return Array the SQL part
17
+	* @return string the SQL part
18 18
 	*/
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
Please login to merge, or discard this patch.
Indentation   +594 added lines, -594 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 	}
11 11
 
12 12
 	/**
13
-	* Get SQL query part for filter used
14
-	* @param Array $filter the filter
15
-	* @return Array the SQL part
16
-	*/
13
+	 * Get SQL query part for filter used
14
+	 * @param Array $filter the filter
15
+	 * @return Array the SQL part
16
+	 */
17 17
 	public function getFilter($filter = array(),$where = false,$and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 		$filters = array();
@@ -106,44 +106,44 @@  discard block
 block discarded – undo
106 106
 	}
107 107
 
108 108
 
109
-        /**
110
-        * Gets all the spotter information based on a particular callsign
111
-        *
112
-        * @return Array the spotter information
113
-        *
114
-        */
115
-        public function getLastArchiveTrackerDataByIdent($ident)
116
-        {
109
+		/**
110
+		 * Gets all the spotter information based on a particular callsign
111
+		 *
112
+		 * @return Array the spotter information
113
+		 *
114
+		 */
115
+		public function getLastArchiveTrackerDataByIdent($ident)
116
+		{
117 117
 		$Tracker = new Tracker($this->db);
118
-                date_default_timezone_set('UTC');
118
+				date_default_timezone_set('UTC');
119 119
 
120
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
121
-                //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
122
-                $query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
120
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
121
+				//$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
122
+				$query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
123 123
 
124
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
124
+				$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
125 125
 
126
-                return $spotter_array;
127
-        }
126
+				return $spotter_array;
127
+		}
128 128
 
129 129
 
130
-        /**
131
-        * Gets last the spotter information based on a particular id
132
-        *
133
-        * @return Array the spotter information
134
-        *
135
-        */
136
-        public function getLastArchiveTrackerDataById($id)
137
-        {
138
-    		$Tracker = new Tracker($this->db);
139
-                date_default_timezone_set('UTC');
140
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
141
-                //$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
142
-                //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
143
-                $query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
130
+		/**
131
+		 * Gets last the spotter information based on a particular id
132
+		 *
133
+		 * @return Array the spotter information
134
+		 *
135
+		 */
136
+		public function getLastArchiveTrackerDataById($id)
137
+		{
138
+			$Tracker = new Tracker($this->db);
139
+				date_default_timezone_set('UTC');
140
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
141
+				//$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
142
+				//$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
143
+				$query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
144 144
 
145 145
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
146
-                  /*
146
+				  /*
147 147
                 try {
148 148
                         $Connection = new Connection();
149 149
                         $sth = Connection->$db->prepare($query);
@@ -153,189 +153,189 @@  discard block
 block discarded – undo
153 153
                 }
154 154
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
155 155
                 */
156
-                $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
157
-
158
-                return $spotter_array;
159
-        }
160
-
161
-        /**
162
-        * Gets all the spotter information based on a particular id
163
-        *
164
-        * @return Array the spotter information
165
-        *
166
-        */
167
-        public function getAllArchiveTrackerDataById($id,$date = '')
156
+				$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
157
+
158
+				return $spotter_array;
159
+		}
160
+
161
+		/**
162
+		 * Gets all the spotter information based on a particular id
163
+		 *
164
+		 * @return Array the spotter information
165
+		 *
166
+		 */
167
+		public function getAllArchiveTrackerDataById($id,$date = '')
168 168
 	{
169
-                date_default_timezone_set('UTC');
170
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
171
-                if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
172
-                else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
169
+				date_default_timezone_set('UTC');
170
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
171
+				if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
172
+				else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
173 173
 
174 174
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
175 175
 
176
-                try {
177
-                        $sth = $this->db->prepare($query);
178
-                        $sth->execute(array(':id' => $id));
179
-                } catch(PDOException $e) {
180
-                        echo $e->getMessage();
181
-                        die;
182
-                }
183
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
184
-
185
-                return $spotter_array;
186
-        }
187
-
188
-        /**
189
-        * Gets coordinate & time spotter information based on a particular id
190
-        *
191
-        * @return Array the spotter information
192
-        *
193
-        */
194
-        public function getCoordArchiveTrackerDataById($id)
195
-        {
196
-                date_default_timezone_set('UTC');
197
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
198
-                $query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
176
+				try {
177
+						$sth = $this->db->prepare($query);
178
+						$sth->execute(array(':id' => $id));
179
+				} catch(PDOException $e) {
180
+						echo $e->getMessage();
181
+						die;
182
+				}
183
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
184
+
185
+				return $spotter_array;
186
+		}
187
+
188
+		/**
189
+		 * Gets coordinate & time spotter information based on a particular id
190
+		 *
191
+		 * @return Array the spotter information
192
+		 *
193
+		 */
194
+		public function getCoordArchiveTrackerDataById($id)
195
+		{
196
+				date_default_timezone_set('UTC');
197
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
198
+				$query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
199 199
 
200 200
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
201 201
 
202
-                try {
203
-                        $sth = $this->db->prepare($query);
204
-                        $sth->execute(array(':id' => $id));
205
-                } catch(PDOException $e) {
206
-                        echo $e->getMessage();
207
-                        die;
208
-                }
209
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
202
+				try {
203
+						$sth = $this->db->prepare($query);
204
+						$sth->execute(array(':id' => $id));
205
+				} catch(PDOException $e) {
206
+						echo $e->getMessage();
207
+						die;
208
+				}
209
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
210 210
 
211
-                return $spotter_array;
212
-        }
211
+				return $spotter_array;
212
+		}
213 213
 
214 214
 
215
-        /**
216
-        * Gets altitude information based on a particular callsign
217
-        *
218
-        * @return Array the spotter information
219
-        *
220
-        */
221
-        public function getAltitudeArchiveTrackerDataByIdent($ident)
222
-        {
215
+		/**
216
+		 * Gets altitude information based on a particular callsign
217
+		 *
218
+		 * @return Array the spotter information
219
+		 *
220
+		 */
221
+		public function getAltitudeArchiveTrackerDataByIdent($ident)
222
+		{
223 223
 
224
-                date_default_timezone_set('UTC');
224
+				date_default_timezone_set('UTC');
225 225
 
226
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
227
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
226
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
227
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
228 228
 
229
-                try {
230
-                        $sth = $this->db->prepare($query);
231
-                        $sth->execute(array(':ident' => $ident));
232
-                } catch(PDOException $e) {
233
-                        echo $e->getMessage();
234
-                        die;
235
-                }
236
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
229
+				try {
230
+						$sth = $this->db->prepare($query);
231
+						$sth->execute(array(':ident' => $ident));
232
+				} catch(PDOException $e) {
233
+						echo $e->getMessage();
234
+						die;
235
+				}
236
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
237 237
 
238
-                return $spotter_array;
239
-        }
238
+				return $spotter_array;
239
+		}
240 240
 
241
-        /**
242
-        * Gets altitude information based on a particular id
243
-        *
244
-        * @return Array the spotter information
245
-        *
246
-        */
247
-        public function getAltitudeArchiveTrackerDataById($id)
248
-        {
241
+		/**
242
+		 * Gets altitude information based on a particular id
243
+		 *
244
+		 * @return Array the spotter information
245
+		 *
246
+		 */
247
+		public function getAltitudeArchiveTrackerDataById($id)
248
+		{
249 249
 
250
-                date_default_timezone_set('UTC');
250
+				date_default_timezone_set('UTC');
251 251
 
252
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
253
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
252
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
253
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
254 254
 
255
-                try {
256
-                        $sth = $this->db->prepare($query);
257
-                        $sth->execute(array(':id' => $id));
258
-                } catch(PDOException $e) {
259
-                        echo $e->getMessage();
260
-                        die;
261
-                }
262
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
255
+				try {
256
+						$sth = $this->db->prepare($query);
257
+						$sth->execute(array(':id' => $id));
258
+				} catch(PDOException $e) {
259
+						echo $e->getMessage();
260
+						die;
261
+				}
262
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
263 263
 
264
-                return $spotter_array;
265
-        }
264
+				return $spotter_array;
265
+		}
266 266
 
267
-        /**
268
-        * Gets altitude & speed information based on a particular id
269
-        *
270
-        * @return Array the spotter information
271
-        *
272
-        */
273
-        public function getAltitudeSpeedArchiveTrackerDataById($id)
274
-        {
267
+		/**
268
+		 * Gets altitude & speed information based on a particular id
269
+		 *
270
+		 * @return Array the spotter information
271
+		 *
272
+		 */
273
+		public function getAltitudeSpeedArchiveTrackerDataById($id)
274
+		{
275 275
 
276
-                date_default_timezone_set('UTC');
276
+				date_default_timezone_set('UTC');
277 277
 
278
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
279
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
278
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
279
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
280 280
 
281
-                try {
282
-                        $sth = $this->db->prepare($query);
283
-                        $sth->execute(array(':id' => $id));
284
-                } catch(PDOException $e) {
285
-                        echo $e->getMessage();
286
-                        die;
287
-                }
288
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
281
+				try {
282
+						$sth = $this->db->prepare($query);
283
+						$sth->execute(array(':id' => $id));
284
+				} catch(PDOException $e) {
285
+						echo $e->getMessage();
286
+						die;
287
+				}
288
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
289 289
 
290
-                return $spotter_array;
291
-        }
290
+				return $spotter_array;
291
+		}
292 292
 
293 293
 
294
-        /**
295
-        * Gets altitude information based on a particular callsign
296
-        *
297
-        * @return Array the spotter information
298
-        *
299
-        */
300
-        public function getLastAltitudeArchiveTrackerDataByIdent($ident)
301
-        {
294
+		/**
295
+		 * Gets altitude information based on a particular callsign
296
+		 *
297
+		 * @return Array the spotter information
298
+		 *
299
+		 */
300
+		public function getLastAltitudeArchiveTrackerDataByIdent($ident)
301
+		{
302 302
 
303
-                date_default_timezone_set('UTC');
303
+				date_default_timezone_set('UTC');
304 304
 
305
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
306
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
305
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
306
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
307 307
 //                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident";
308 308
 
309
-                try {
310
-                        $sth = $this->db->prepare($query);
311
-                        $sth->execute(array(':ident' => $ident));
312
-                } catch(PDOException $e) {
313
-                        echo $e->getMessage();
314
-                        die;
315
-                }
316
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
309
+				try {
310
+						$sth = $this->db->prepare($query);
311
+						$sth->execute(array(':ident' => $ident));
312
+				} catch(PDOException $e) {
313
+						echo $e->getMessage();
314
+						die;
315
+				}
316
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
317 317
 
318
-                return $spotter_array;
319
-        }
318
+				return $spotter_array;
319
+		}
320 320
 
321 321
 
322 322
 
323
-       /**
324
-        * Gets all the archive spotter information
325
-        *
326
-        * @return Array the spotter information
327
-        *
328
-        */
329
-        public function getTrackerArchiveData($ident,$famtrackid,$date)
330
-        {
331
-    		$Tracker = new Tracker($this->db);
332
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
333
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
323
+	   /**
324
+	    * Gets all the archive spotter information
325
+	    *
326
+	    * @return Array the spotter information
327
+	    *
328
+	    */
329
+		public function getTrackerArchiveData($ident,$famtrackid,$date)
330
+		{
331
+			$Tracker = new Tracker($this->db);
332
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
333
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
334 334
 
335
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
335
+				$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
336 336
 
337
-                return $spotter_array;
338
-        }
337
+				return $spotter_array;
338
+		}
339 339
 
340 340
 	public function deleteTrackerArchiveTrackData()
341 341
 	{
@@ -355,34 +355,34 @@  discard block
 block discarded – undo
355 355
 	}
356 356
 
357 357
 	/**
358
-        * Gets Minimal Live Tracker data
359
-        *
360
-        * @return Array the spotter information
361
-        *
362
-        */
363
-        public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
364
-        {
365
-                global $globalDBdriver, $globalLiveInterval;
366
-                date_default_timezone_set('UTC');
367
-
368
-                $filter_query = '';
369
-                if (isset($filter['source']) && !empty($filter['source'])) {
370
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
371
-                }
372
-                // Use spotter_output also ?
373
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
375
-                }
376
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
378
-                }
379
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
381
-                }
358
+	 * Gets Minimal Live Tracker data
359
+	 *
360
+	 * @return Array the spotter information
361
+	 *
362
+	 */
363
+		public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
364
+		{
365
+				global $globalDBdriver, $globalLiveInterval;
366
+				date_default_timezone_set('UTC');
382 367
 
383
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
384
-                if ($globalDBdriver == 'mysql') {
385
-                        /*
368
+				$filter_query = '';
369
+				if (isset($filter['source']) && !empty($filter['source'])) {
370
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
371
+				}
372
+				// Use spotter_output also ?
373
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
375
+				}
376
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
378
+				}
379
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
381
+				}
382
+
383
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
384
+				if ($globalDBdriver == 'mysql') {
385
+						/*
386 386
                         $query  = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk 
387 387
                     		    FROM tracker_archive 
388 388
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
@@ -401,56 +401,56 @@  discard block
 block discarded – undo
401 401
 				    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
402 402
 				    WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
403 403
                         	    '.$filter_query.' ORDER BY famtrackid';
404
-                } else {
405
-                        //$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
406
-                        $query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
404
+				} else {
405
+						//$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
406
+						$query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
407 407
                         	    FROM tracker_archive 
408 408
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
409 409
                         	    WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".'
410 410
                         	    '.$filter_query.' ORDER BY famtrackid';
411
-                }
412
-                //echo $query;
413
-                try {
414
-                        $sth = $this->db->prepare($query);
415
-                        $sth->execute();
416
-                } catch(PDOException $e) {
417
-                        echo $e->getMessage();
418
-                        die;
419
-                }
420
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
411
+				}
412
+				//echo $query;
413
+				try {
414
+						$sth = $this->db->prepare($query);
415
+						$sth->execute();
416
+				} catch(PDOException $e) {
417
+						echo $e->getMessage();
418
+						die;
419
+				}
420
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
421 421
 
422
-                return $spotter_array;
423
-        }
422
+				return $spotter_array;
423
+		}
424 424
 
425 425
 	/**
426
-        * Gets Minimal Live Tracker data
427
-        *
428
-        * @return Array the spotter information
429
-        *
430
-        */
431
-        public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
432
-        {
433
-                global $globalDBdriver, $globalLiveInterval;
434
-                date_default_timezone_set('UTC');
435
-
436
-                $filter_query = '';
437
-                if (isset($filter['source']) && !empty($filter['source'])) {
438
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
439
-                }
440
-                // Should use spotter_output also ?
441
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
443
-                }
444
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
446
-                }
447
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
449
-                }
426
+	 * Gets Minimal Live Tracker data
427
+	 *
428
+	 * @return Array the spotter information
429
+	 *
430
+	 */
431
+		public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
432
+		{
433
+				global $globalDBdriver, $globalLiveInterval;
434
+				date_default_timezone_set('UTC');
435
+
436
+				$filter_query = '';
437
+				if (isset($filter['source']) && !empty($filter['source'])) {
438
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
439
+				}
440
+				// Should use spotter_output also ?
441
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
443
+				}
444
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
446
+				}
447
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
449
+				}
450 450
 
451
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
452
-                if ($globalDBdriver == 'mysql') {
453
-                        /*
451
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
452
+				if ($globalDBdriver == 'mysql') {
453
+						/*
454 454
                         $query  = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk 
455 455
                     		    FROM tracker_archive 
456 456
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
@@ -461,95 +461,95 @@  discard block
 block discarded – undo
461 461
 				    WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
462 462
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
463 463
 
464
-                } else {
465
-                        //$query  = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao';
466
-                       /*
464
+				} else {
465
+						//$query  = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao';
466
+					   /*
467 467
                         $query  = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
468 468
                         	    FROM tracker_archive_output 
469 469
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
470 470
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
471 471
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
472 472
                         */
473
-                        $query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
473
+						$query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
474 474
                         	    FROM tracker_archive_output 
475 475
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
476 476
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
477 477
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
478 478
 //                        	    .' GROUP BY spotter_output.famtrackid, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
479 479
                         	    
480
-                }
481
-                //echo $query;
482
-                try {
483
-                        $sth = $this->db->prepare($query);
484
-                        $sth->execute();
485
-                } catch(PDOException $e) {
486
-                        echo $e->getMessage();
487
-                        die;
488
-                }
489
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
480
+				}
481
+				//echo $query;
482
+				try {
483
+						$sth = $this->db->prepare($query);
484
+						$sth->execute();
485
+				} catch(PDOException $e) {
486
+						echo $e->getMessage();
487
+						die;
488
+				}
489
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
490 490
 
491
-                return $spotter_array;
492
-        }
491
+				return $spotter_array;
492
+		}
493 493
 
494 494
 	 /**
495
-        * Gets count Live Tracker data
496
-        *
497
-        * @return Array the spotter information
498
-        *
499
-        */
500
-        public function getLiveTrackerCount($begindate,$enddate,$filter = array())
501
-        {
502
-                global $globalDBdriver, $globalLiveInterval;
503
-                date_default_timezone_set('UTC');
504
-
505
-                $filter_query = '';
506
-                if (isset($filter['source']) && !empty($filter['source'])) {
507
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
508
-                }
509
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
511
-                }
512
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
514
-                }
515
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
517
-                }
495
+	  * Gets count Live Tracker data
496
+	  *
497
+	  * @return Array the spotter information
498
+	  *
499
+	  */
500
+		public function getLiveTrackerCount($begindate,$enddate,$filter = array())
501
+		{
502
+				global $globalDBdriver, $globalLiveInterval;
503
+				date_default_timezone_set('UTC');
518 504
 
519
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
520
-                if ($globalDBdriver == 'mysql') {
505
+				$filter_query = '';
506
+				if (isset($filter['source']) && !empty($filter['source'])) {
507
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
508
+				}
509
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
511
+				}
512
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
514
+				}
515
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
517
+				}
518
+
519
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
520
+				if ($globalDBdriver == 'mysql') {
521 521
 			$query = 'SELECT COUNT(DISTINCT famtrackid) as nb 
522 522
 			FROM tracker_archive l 
523 523
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
524
-                } else {
524
+				} else {
525 525
 			$query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
526
-                }
527
-                //echo $query;
528
-                try {
529
-                        $sth = $this->db->prepare($query);
530
-                        $sth->execute();
531
-                } catch(PDOException $e) {
532
-                        echo $e->getMessage();
533
-                        die;
534
-                }
526
+				}
527
+				//echo $query;
528
+				try {
529
+						$sth = $this->db->prepare($query);
530
+						$sth->execute();
531
+				} catch(PDOException $e) {
532
+						echo $e->getMessage();
533
+						die;
534
+				}
535 535
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
536 536
 		$sth->closeCursor();
537
-                return $result['nb'];
537
+				return $result['nb'];
538 538
 
539
-        }
539
+		}
540 540
 
541 541
 
542 542
 
543 543
 	// tracker_archive_output
544 544
 	
545
-    /**
546
-    * Gets all the spotter information
547
-    *
548
-    * @return Array the spotter information
549
-    *
550
-    */
551
-    public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
552
-    {
545
+	/**
546
+	 * Gets all the spotter information
547
+	 *
548
+	 * @return Array the spotter information
549
+	 *
550
+	 */
551
+	public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
552
+	{
553 553
 	global $globalTimezone, $globalDBdriver;
554 554
 	require_once(dirname(__FILE__).'/class.Translation.php');
555 555
 	$Translation = new Translation($this->db);
@@ -563,159 +563,159 @@  discard block
 block discarded – undo
563 563
 	$filter_query = $this->getFilter($filters);
564 564
 	if ($q != "")
565 565
 	{
566
-	    if (!is_string($q))
567
-	    {
566
+		if (!is_string($q))
567
+		{
568 568
 		return false;
569
-	    } else {
569
+		} else {
570 570
 	        
571 571
 		$q_array = explode(" ", $q);
572 572
 		
573 573
 		foreach ($q_array as $q_item){
574
-		    $additional_query .= " AND (";
575
-		    $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
576
-		    $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
577
-		    $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR ";
578
-		    $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
579
-		    $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR ";
580
-		    $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR ";
581
-		    $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR ";
582
-		    $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
583
-		    $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR ";
584
-		    $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR ";
585
-		    $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR ";
586
-		    $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
587
-		    $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
588
-		    $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
589
-		    $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
590
-		    $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR ";
591
-		    $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR ";
592
-		    $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR ";
593
-		    $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
594
-		    $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
595
-		    $translate = $Translation->ident2icao($q_item);
596
-		    if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
597
-		    $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
598
-		    $additional_query .= ")";
574
+			$additional_query .= " AND (";
575
+			$additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
576
+			$additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
577
+			$additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR ";
578
+			$additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
579
+			$additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR ";
580
+			$additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR ";
581
+			$additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR ";
582
+			$additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
583
+			$additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR ";
584
+			$additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR ";
585
+			$additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR ";
586
+			$additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
587
+			$additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
588
+			$additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
589
+			$additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
590
+			$additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR ";
591
+			$additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR ";
592
+			$additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR ";
593
+			$additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
594
+			$additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
595
+			$translate = $Translation->ident2icao($q_item);
596
+			if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
597
+			$additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
598
+			$additional_query .= ")";
599
+		}
599 600
 		}
600
-	    }
601 601
 	}
602 602
 	
603 603
 	if ($registration != "")
604 604
 	{
605
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
606
-	    if (!is_string($registration))
607
-	    {
605
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
606
+		if (!is_string($registration))
607
+		{
608 608
 		return false;
609
-	    } else {
609
+		} else {
610 610
 		$additional_query .= " AND (tracker_archive_output.registration = '".$registration."')";
611
-	    }
611
+		}
612 612
 	}
613 613
 	
614 614
 	if ($aircraft_icao != "")
615 615
 	{
616
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
617
-	    if (!is_string($aircraft_icao))
618
-	    {
616
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
617
+		if (!is_string($aircraft_icao))
618
+		{
619 619
 		return false;
620
-	    } else {
620
+		} else {
621 621
 		$additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')";
622
-	    }
622
+		}
623 623
 	}
624 624
 	
625 625
 	if ($aircraft_manufacturer != "")
626 626
 	{
627
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
628
-	    if (!is_string($aircraft_manufacturer))
629
-	    {
627
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
628
+		if (!is_string($aircraft_manufacturer))
629
+		{
630 630
 		return false;
631
-	    } else {
631
+		} else {
632 632
 		$additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
633
-	    }
633
+		}
634 634
 	}
635 635
 	
636 636
 	if ($highlights == "true")
637 637
 	{
638
-	    if (!is_string($highlights))
639
-	    {
638
+		if (!is_string($highlights))
639
+		{
640 640
 		return false;
641
-	    } else {
641
+		} else {
642 642
 		$additional_query .= " AND (tracker_archive_output.highlight <> '')";
643
-	    }
643
+		}
644 644
 	}
645 645
 	
646 646
 	if ($airline_icao != "")
647 647
 	{
648
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
649
-	    if (!is_string($airline_icao))
650
-	    {
648
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
649
+		if (!is_string($airline_icao))
650
+		{
651 651
 		return false;
652
-	    } else {
652
+		} else {
653 653
 		$additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')";
654
-	    }
654
+		}
655 655
 	}
656 656
 	
657 657
 	if ($airline_country != "")
658 658
 	{
659
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
660
-	    if (!is_string($airline_country))
661
-	    {
659
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
660
+		if (!is_string($airline_country))
661
+		{
662 662
 		return false;
663
-	    } else {
663
+		} else {
664 664
 		$additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')";
665
-	    }
665
+		}
666 666
 	}
667 667
 	
668 668
 	if ($airline_type != "")
669 669
 	{
670
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
671
-	    if (!is_string($airline_type))
672
-	    {
670
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
671
+		if (!is_string($airline_type))
672
+		{
673 673
 		return false;
674
-	    } else {
674
+		} else {
675 675
 		if ($airline_type == "passenger")
676 676
 		{
677
-		    $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')";
677
+			$additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')";
678 678
 		}
679 679
 		if ($airline_type == "cargo")
680 680
 		{
681
-		    $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')";
681
+			$additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')";
682 682
 		}
683 683
 		if ($airline_type == "military")
684 684
 		{
685
-		    $additional_query .= " AND (tracker_archive_output.airline_type = 'military')";
685
+			$additional_query .= " AND (tracker_archive_output.airline_type = 'military')";
686
+		}
686 687
 		}
687
-	    }
688 688
 	}
689 689
 	
690 690
 	if ($airport != "")
691 691
 	{
692
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
693
-	    if (!is_string($airport))
694
-	    {
692
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
693
+		if (!is_string($airport))
694
+		{
695 695
 		return false;
696
-	    } else {
696
+		} else {
697 697
 		$additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))";
698
-	    }
698
+		}
699 699
 	}
700 700
 	
701 701
 	if ($airport_country != "")
702 702
 	{
703
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
704
-	    if (!is_string($airport_country))
705
-	    {
703
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
704
+		if (!is_string($airport_country))
705
+		{
706 706
 		return false;
707
-	    } else {
707
+		} else {
708 708
 		$additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))";
709
-	    }
709
+		}
710 710
 	}
711 711
     
712 712
 	if ($callsign != "")
713 713
 	{
714
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
715
-	    if (!is_string($callsign))
716
-	    {
714
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
715
+		if (!is_string($callsign))
716
+		{
717 717
 		return false;
718
-	    } else {
718
+		} else {
719 719
 		$translate = $Translation->ident2icao($callsign);
720 720
 		if ($translate != $callsign) {
721 721
 			$additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)";
@@ -723,99 +723,99 @@  discard block
 block discarded – undo
723 723
 		} else {
724 724
 			$additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')";
725 725
 		}
726
-	    }
726
+		}
727 727
 	}
728 728
 
729 729
 	if ($owner != "")
730 730
 	{
731
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
732
-	    if (!is_string($owner))
733
-	    {
731
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
732
+		if (!is_string($owner))
733
+		{
734 734
 		return false;
735
-	    } else {
735
+		} else {
736 736
 		$additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')";
737
-	    }
737
+		}
738 738
 	}
739 739
 
740 740
 	if ($pilot_name != "")
741 741
 	{
742
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
743
-	    if (!is_string($pilot_name))
744
-	    {
742
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
743
+		if (!is_string($pilot_name))
744
+		{
745 745
 		return false;
746
-	    } else {
746
+		} else {
747 747
 		$additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')";
748
-	    }
748
+		}
749 749
 	}
750 750
 	
751 751
 	if ($pilot_id != "")
752 752
 	{
753
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
754
-	    if (!is_string($pilot_id))
755
-	    {
753
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
754
+		if (!is_string($pilot_id))
755
+		{
756 756
 		return false;
757
-	    } else {
757
+		} else {
758 758
 		$additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')";
759
-	    }
759
+		}
760 760
 	}
761 761
 	
762 762
 	if ($departure_airport_route != "")
763 763
 	{
764
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
765
-	    if (!is_string($departure_airport_route))
766
-	    {
764
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
765
+		if (!is_string($departure_airport_route))
766
+		{
767 767
 		return false;
768
-	    } else {
768
+		} else {
769 769
 		$additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')";
770
-	    }
770
+		}
771 771
 	}
772 772
 	
773 773
 	if ($arrival_airport_route != "")
774 774
 	{
775
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
776
-	    if (!is_string($arrival_airport_route))
777
-	    {
775
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
776
+		if (!is_string($arrival_airport_route))
777
+		{
778 778
 		return false;
779
-	    } else {
779
+		} else {
780 780
 		$additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
781
-	    }
781
+		}
782 782
 	}
783 783
 	
784 784
 	if ($altitude != "")
785 785
 	{
786
-	    $altitude_array = explode(",", $altitude);
786
+		$altitude_array = explode(",", $altitude);
787 787
 	    
788
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
790 790
 	    
791 791
 
792
-	    if ($altitude_array[1] != "")
793
-	    {                
792
+		if ($altitude_array[1] != "")
793
+		{                
794 794
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
795 795
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
796 796
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
797
-	    } else {
797
+		} else {
798 798
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
799 799
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
800
-	    }
800
+		}
801 801
 	}
802 802
 	
803 803
 	if ($date_posted != "")
804 804
 	{
805
-	    $date_array = explode(",", $date_posted);
805
+		$date_array = explode(",", $date_posted);
806 806
 	    
807
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
807
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
809 809
 	    
810
-	    if ($globalTimezone != '') {
810
+		if ($globalTimezone != '') {
811 811
 		date_default_timezone_set($globalTimezone);
812 812
 		$datetime = new DateTime();
813 813
 		$offset = $datetime->format('P');
814
-	    } else $offset = '+00:00';
814
+		} else $offset = '+00:00';
815 815
 
816 816
 
817
-	    if ($date_array[1] != "")
818
-	    {                
817
+		if ($date_array[1] != "")
818
+		{                
819 819
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
820 820
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
821 821
 		if ($globalDBdriver == 'mysql') {
@@ -823,28 +823,28 @@  discard block
 block discarded – undo
823 823
 		} else {
824 824
 			$additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
825 825
 		}
826
-	    } else {
826
+		} else {
827 827
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
828
-                if ($globalDBdriver == 'mysql') {
828
+				if ($globalDBdriver == 'mysql') {
829 829
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
830 830
 		} else {
831 831
 			$additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
832 832
 		}
833
-	    }
833
+		}
834 834
 	}
835 835
 	
836 836
 	if ($limit != "")
837 837
 	{
838
-	    $limit_array = explode(",", $limit);
838
+		$limit_array = explode(",", $limit);
839 839
 	    
840
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
840
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
842 842
 	    
843
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844
-	    {
843
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844
+		{
845 845
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
846 846
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
847
-	    }
847
+		}
848 848
 	}
849 849
 	
850 850
 
@@ -875,33 +875,33 @@  discard block
 block discarded – undo
875 875
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query);
876 876
 
877 877
 	return $spotter_array;
878
-    }
878
+	}
879 879
 
880
-    public function deleteTrackerArchiveData()
881
-    {
880
+	public function deleteTrackerArchiveData()
881
+	{
882 882
 		global $globalArchiveKeepMonths, $globalDBdriver;
883
-                date_default_timezone_set('UTC');
884
-                if ($globalDBdriver == 'mysql') {
883
+				date_default_timezone_set('UTC');
884
+				if ($globalDBdriver == 'mysql') {
885 885
 			$query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
886 886
 		} else {
887 887
 			$query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
888 888
 		}
889
-                try {
890
-                        $sth = $this->db->prepare($query);
891
-                        $sth->execute();
892
-                } catch(PDOException $e) {
893
-                        return "error";
894
-                }
889
+				try {
890
+						$sth = $this->db->prepare($query);
891
+						$sth->execute();
892
+				} catch(PDOException $e) {
893
+						return "error";
894
+				}
895 895
 	}
896 896
 
897
-    /**
898
-    * Gets all the spotter information based on the callsign
899
-    *
900
-    * @return Array the spotter information
901
-    *
902
-    */
903
-    public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '')
904
-    {
897
+	/**
898
+	 * Gets all the spotter information based on the callsign
899
+	 *
900
+	 * @return Array the spotter information
901
+	 *
902
+	 */
903
+	public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '')
904
+	{
905 905
 	$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
906 906
 	
907 907
 	date_default_timezone_set('UTC');
@@ -913,35 +913,35 @@  discard block
 block discarded – undo
913 913
 	
914 914
 	if ($ident != "")
915 915
 	{
916
-	    if (!is_string($ident))
917
-	    {
916
+		if (!is_string($ident))
917
+		{
918 918
 		return false;
919
-	    } else {
919
+		} else {
920 920
 		$additional_query = " AND (tracker_archive_output.ident = :ident)";
921 921
 		$query_values = array(':ident' => $ident);
922
-	    }
922
+		}
923 923
 	}
924 924
 	
925 925
 	if ($limit != "")
926 926
 	{
927
-	    $limit_array = explode(",", $limit);
927
+		$limit_array = explode(",", $limit);
928 928
 	    
929
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
929
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
931 931
 	    
932
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933
-	    {
932
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933
+		{
934 934
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
935 935
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
936
-	    }
936
+		}
937 937
 	}
938 938
 
939 939
 	if ($sort != "")
940 940
 	{
941
-	    $search_orderby_array = $Tracker->getOrderBy();
942
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
941
+		$search_orderby_array = $Tracker->getOrderBy();
942
+		$orderby_query = $search_orderby_array[$sort]['sql'];
943 943
 	} else {
944
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
944
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
945 945
 	}
946 946
 
947 947
 	$query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -949,17 +949,17 @@  discard block
 block discarded – undo
949 949
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
950 950
 
951 951
 	return $spotter_array;
952
-    }
952
+	}
953 953
 
954 954
 
955
-    /**
956
-    * Gets all the spotter information based on the owner
957
-    *
958
-    * @return Array the spotter information
959
-    *
960
-    */
961
-    public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
962
-    {
955
+	/**
956
+	 * Gets all the spotter information based on the owner
957
+	 *
958
+	 * @return Array the spotter information
959
+	 *
960
+	 */
961
+	public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
962
+	{
963 963
 	$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
964 964
 	
965 965
 	date_default_timezone_set('UTC');
@@ -972,35 +972,35 @@  discard block
 block discarded – undo
972 972
 	
973 973
 	if ($owner != "")
974 974
 	{
975
-	    if (!is_string($owner))
976
-	    {
975
+		if (!is_string($owner))
976
+		{
977 977
 		return false;
978
-	    } else {
978
+		} else {
979 979
 		$additional_query = " AND (tracker_archive_output.owner_name = :owner)";
980 980
 		$query_values = array(':owner' => $owner);
981
-	    }
981
+		}
982 982
 	}
983 983
 	
984 984
 	if ($limit != "")
985 985
 	{
986
-	    $limit_array = explode(",", $limit);
986
+		$limit_array = explode(",", $limit);
987 987
 	    
988
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
990 990
 	    
991
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992
-	    {
991
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992
+		{
993 993
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
994 994
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
995
-	    }
995
+		}
996 996
 	}
997 997
 
998 998
 	if ($sort != "")
999 999
 	{
1000
-	    $search_orderby_array = $Tracker->getOrderBy();
1001
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1000
+		$search_orderby_array = $Tracker->getOrderBy();
1001
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1002 1002
 	} else {
1003
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1003
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1004 1004
 	}
1005 1005
 
1006 1006
 	$query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1008,16 +1008,16 @@  discard block
 block discarded – undo
1008 1008
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1009 1009
 
1010 1010
 	return $spotter_array;
1011
-    }
1012
-
1013
-    /**
1014
-    * Gets all the spotter information based on the pilot
1015
-    *
1016
-    * @return Array the spotter information
1017
-    *
1018
-    */
1019
-    public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1020
-    {
1011
+	}
1012
+
1013
+	/**
1014
+	 * Gets all the spotter information based on the pilot
1015
+	 *
1016
+	 * @return Array the spotter information
1017
+	 *
1018
+	 */
1019
+	public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1020
+	{
1021 1021
 	$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
1022 1022
 	
1023 1023
 	date_default_timezone_set('UTC');
@@ -1036,24 +1036,24 @@  discard block
 block discarded – undo
1036 1036
 	
1037 1037
 	if ($limit != "")
1038 1038
 	{
1039
-	    $limit_array = explode(",", $limit);
1039
+		$limit_array = explode(",", $limit);
1040 1040
 	    
1041
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1041
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1043 1043
 	    
1044
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045
-	    {
1044
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045
+		{
1046 1046
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1047 1047
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1048
-	    }
1048
+		}
1049 1049
 	}
1050 1050
 
1051 1051
 	if ($sort != "")
1052 1052
 	{
1053
-	    $search_orderby_array = $Tracker->getOrderBy();
1054
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1053
+		$search_orderby_array = $Tracker->getOrderBy();
1054
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1055 1055
 	} else {
1056
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1056
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1057 1057
 	}
1058 1058
 
1059 1059
 	$query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1061,16 +1061,16 @@  discard block
 block discarded – undo
1061 1061
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1062 1062
 
1063 1063
 	return $spotter_array;
1064
-    }
1065
-
1066
-    /**
1067
-    * Gets all number of flight over countries
1068
-    *
1069
-    * @return Array the airline country list
1070
-    *
1071
-    */
1072
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1073
-    {
1064
+	}
1065
+
1066
+	/**
1067
+	 * Gets all number of flight over countries
1068
+	 *
1069
+	 * @return Array the airline country list
1070
+	 *
1071
+	 */
1072
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1073
+	{
1074 1074
 	global $globalDBdriver;
1075 1075
 	/*
1076 1076
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1080,14 +1080,14 @@  discard block
 block discarded – undo
1080 1080
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1081 1081
 		    FROM countries c, tracker_archive s
1082 1082
 		    WHERE c.iso2 = s.over_country ";
1083
-                if ($olderthanmonths > 0) {
1084
-            		if ($globalDBdriver == 'mysql') {
1083
+				if ($olderthanmonths > 0) {
1084
+					if ($globalDBdriver == 'mysql') {
1085 1085
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1086 1086
 			} else {
1087 1087
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1088 1088
 			}
1089 1089
 		}
1090
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1090
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1091 1091
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1092 1092
 	if ($limit) $query .= " LIMIT 0,10";
1093 1093
       
@@ -1100,23 +1100,23 @@  discard block
 block discarded – undo
1100 1100
         
1101 1101
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1102 1102
 	{
1103
-	    $temp_array['flight_count'] = $row['nb'];
1104
-	    $temp_array['flight_country'] = $row['name'];
1105
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1106
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1107
-	    $flight_array[] = $temp_array;
1103
+		$temp_array['flight_count'] = $row['nb'];
1104
+		$temp_array['flight_country'] = $row['name'];
1105
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1106
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1107
+		$flight_array[] = $temp_array;
1108 1108
 	}
1109 1109
 	return $flight_array;
1110
-    }
1111
-
1112
-    /**
1113
-    * Gets all number of flight over countries
1114
-    *
1115
-    * @return Array the airline country list
1116
-    *
1117
-    */
1118
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1119
-    {
1110
+	}
1111
+
1112
+	/**
1113
+	 * Gets all number of flight over countries
1114
+	 *
1115
+	 * @return Array the airline country list
1116
+	 *
1117
+	 */
1118
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1119
+	{
1120 1120
 	global $globalDBdriver;
1121 1121
 	/*
1122 1122
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1126,14 +1126,14 @@  discard block
 block discarded – undo
1126 1126
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1127 1127
 		    FROM countries c, tracker_archive s, spotter_output o
1128 1128
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.famtrackid = s.famtrackid ";
1129
-                if ($olderthanmonths > 0) {
1130
-            		if ($globalDBdriver == 'mysql') {
1129
+				if ($olderthanmonths > 0) {
1130
+					if ($globalDBdriver == 'mysql') {
1131 1131
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1132 1132
 			} else {
1133 1133
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1134 1134
 			}
1135 1135
 		}
1136
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1136
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1137 1137
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1138 1138
 	if ($limit) $query .= " LIMIT 0,10";
1139 1139
       
@@ -1146,24 +1146,24 @@  discard block
 block discarded – undo
1146 1146
         
1147 1147
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1148 1148
 	{
1149
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1150
-	    $temp_array['flight_count'] = $row['nb'];
1151
-	    $temp_array['flight_country'] = $row['name'];
1152
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1153
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1154
-	    $flight_array[] = $temp_array;
1149
+		$temp_array['airline_icao'] = $row['airline_icao'];
1150
+		$temp_array['flight_count'] = $row['nb'];
1151
+		$temp_array['flight_country'] = $row['name'];
1152
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1153
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1154
+		$flight_array[] = $temp_array;
1155 1155
 	}
1156 1156
 	return $flight_array;
1157
-    }
1158
-
1159
-    /**
1160
-    * Gets last spotter information based on a particular callsign
1161
-    *
1162
-    * @return Array the spotter information
1163
-    *
1164
-    */
1165
-    public function getDateArchiveTrackerDataById($id,$date)
1166
-    {
1157
+	}
1158
+
1159
+	/**
1160
+	 * Gets last spotter information based on a particular callsign
1161
+	 *
1162
+	 * @return Array the spotter information
1163
+	 *
1164
+	 */
1165
+	public function getDateArchiveTrackerDataById($id,$date)
1166
+	{
1167 1167
 	$Tracker = new Tracker($this->db);
1168 1168
 	date_default_timezone_set('UTC');
1169 1169
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1171,16 +1171,16 @@  discard block
 block discarded – undo
1171 1171
 	$date = date('c',$date);
1172 1172
 	$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date));
1173 1173
 	return $spotter_array;
1174
-    }
1175
-
1176
-    /**
1177
-    * Gets all the spotter information based on a particular callsign
1178
-    *
1179
-    * @return Array the spotter information
1180
-    *
1181
-    */
1182
-    public function getDateArchiveTrackerDataByIdent($ident,$date)
1183
-    {
1174
+	}
1175
+
1176
+	/**
1177
+	 * Gets all the spotter information based on a particular callsign
1178
+	 *
1179
+	 * @return Array the spotter information
1180
+	 *
1181
+	 */
1182
+	public function getDateArchiveTrackerDataByIdent($ident,$date)
1183
+	{
1184 1184
 	$Tracker = new Tracker($this->db);
1185 1185
 	date_default_timezone_set('UTC');
1186 1186
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1188,16 +1188,16 @@  discard block
 block discarded – undo
1188 1188
 	$date = date('c',$date);
1189 1189
 	$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1190 1190
 	return $spotter_array;
1191
-    }
1192
-
1193
-    /**
1194
-    * Gets all the spotter information based on the airport
1195
-    *
1196
-    * @return Array the spotter information
1197
-    *
1198
-    */
1199
-    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1200
-    {
1191
+	}
1192
+
1193
+	/**
1194
+	 * Gets all the spotter information based on the airport
1195
+	 *
1196
+	 * @return Array the spotter information
1197
+	 *
1198
+	 */
1199
+	public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1200
+	{
1201 1201
 	global $global_query;
1202 1202
 	$Tracker = new Tracker($this->db);
1203 1203
 	date_default_timezone_set('UTC');
@@ -1208,35 +1208,35 @@  discard block
 block discarded – undo
1208 1208
 	
1209 1209
 	if ($airport != "")
1210 1210
 	{
1211
-	    if (!is_string($airport))
1212
-	    {
1211
+		if (!is_string($airport))
1212
+		{
1213 1213
 		return false;
1214
-	    } else {
1214
+		} else {
1215 1215
 		$additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))";
1216 1216
 		$query_values = array(':airport' => $airport);
1217
-	    }
1217
+		}
1218 1218
 	}
1219 1219
 	
1220 1220
 	if ($limit != "")
1221 1221
 	{
1222
-	    $limit_array = explode(",", $limit);
1222
+		$limit_array = explode(",", $limit);
1223 1223
 	    
1224
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1224
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1226 1226
 	    
1227
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228
-	    {
1227
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228
+		{
1229 1229
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1230 1230
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1231
-	    }
1231
+		}
1232 1232
 	}
1233 1233
 	
1234 1234
 	if ($sort != "")
1235 1235
 	{
1236
-	    $search_orderby_array = $Tracker->getOrderBy();
1237
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1236
+		$search_orderby_array = $Tracker->getOrderBy();
1237
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1238 1238
 	} else {
1239
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1239
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1240 1240
 	}
1241 1241
 
1242 1242
 	$query = $global_query.$filter_query." tracker_archive_output.ident <> '' ".$additional_query." AND ((tracker_archive_output.departure_airport_icao <> 'NA') AND (tracker_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1244,6 +1244,6 @@  discard block
 block discarded – undo
1244 1244
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1245 1245
 
1246 1246
 	return $spotter_array;
1247
-    }
1247
+	}
1248 1248
 }
1249 1249
 ?>
1250 1250
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -14,33 +14,33 @@  discard block
 block discarded – undo
14 14
 	* @param Array $filter the filter
15 15
 	* @return Array the SQL part
16 16
 	*/
17
-	public function getFilter($filter = array(),$where = false,$and = false) {
17
+	public function getFilter($filter = array(), $where = false, $and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 		$filters = array();
20 20
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 22
 				$filters = $globalStatsFilters[$globalFilterName];
23 23
 			} else {
24
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
24
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
25 25
 			}
26 26
 		}
27 27
 		if (isset($filter[0]['source'])) {
28
-			$filters = array_merge($filters,$filter);
28
+			$filters = array_merge($filters, $filter);
29 29
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
30
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
31 31
 		$filter_query_join = '';
32 32
 		$filter_query_where = '';
33
-		foreach($filters as $flt) {
33
+		foreach ($filters as $flt) {
34 34
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
35 35
 				if (isset($flt['source'])) {
36
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
36
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
37 37
 				} else {
38
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
38
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
39 39
 				}
40 40
 			}
41 41
 		}
42 42
 		if (isset($filter['source']) && !empty($filter['source'])) {
43
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
43
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
44 44
 		}
45 45
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
46 46
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -68,38 +68,38 @@  discard block
 block discarded – undo
68 68
 					$filter_query_date .= " AND EXTRACT(DAY FROM tracker_archive_output.date) = '".$filter['day']."'";
69 69
 				}
70 70
 			}
71
-			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid";
71
+			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid";
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 ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
77 77
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
78 78
 		if ($filter_query_where != '') {
79
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
79
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
80 80
 		}
81 81
 		$filter_query = $filter_query_join.$filter_query_where;
82 82
 		return $filter_query;
83 83
 	}
84 84
 
85 85
 	// tracker_archive
86
-	public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') {
86
+	public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') {
87 87
 		require_once(dirname(__FILE__).'/class.Tracker.php');
88 88
 		if ($over_country == '') {
89 89
 			$Tracker = new Tracker($this->db);
90
-			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude);
90
+			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude, $longitude);
91 91
 			if (!empty($data_country)) $country = $data_country['iso2'];
92 92
 			else $country = '';
93 93
 		} else $country = $over_country;
94 94
 		// Route is not added in tracker_archive
95
-		$query  = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
95
+		$query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
96 96
 		    VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
97
-		$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country,':comment' => $comment,':type' => $type);
97
+		$query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country, ':comment' => $comment, ':type' => $type);
98 98
 		try {
99 99
 			$sth = $this->db->prepare($query);
100 100
 			$sth->execute($query_values);
101 101
 			$sth->closeCursor();
102
-		} catch(PDOException $e) {
102
+		} catch (PDOException $e) {
103 103
 			return "error : ".$e->getMessage();
104 104
 		}
105 105
 		return "success";
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 
120 120
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
121 121
                 //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
122
-                $query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
122
+                $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
123 123
 
124
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
124
+                $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident));
125 125
 
126 126
                 return $spotter_array;
127 127
         }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
141 141
                 //$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
142 142
                 //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
143
-                $query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
143
+                $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
144 144
 
145 145
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
146 146
                   /*
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
                 }
154 154
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
155 155
                 */
156
-                $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
156
+                $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id));
157 157
 
158 158
                 return $spotter_array;
159 159
         }
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
         * @return Array the spotter information
165 165
         *
166 166
         */
167
-        public function getAllArchiveTrackerDataById($id,$date = '')
167
+        public function getAllArchiveTrackerDataById($id, $date = '')
168 168
 	{
169 169
                 date_default_timezone_set('UTC');
170 170
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
171
-                if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
172
-                else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
171
+                if ($date == '') $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
172
+                else $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c', $date)."' ORDER BY date";
173 173
 
174 174
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
175 175
 
176 176
                 try {
177 177
                         $sth = $this->db->prepare($query);
178 178
                         $sth->execute(array(':id' => $id));
179
-                } catch(PDOException $e) {
179
+                } catch (PDOException $e) {
180 180
                         echo $e->getMessage();
181 181
                         die;
182 182
                 }
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
         {
196 196
                 date_default_timezone_set('UTC');
197 197
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
198
-                $query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
198
+                $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
199 199
 
200 200
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
201 201
 
202 202
                 try {
203 203
                         $sth = $this->db->prepare($query);
204 204
                         $sth->execute(array(':id' => $id));
205
-                } catch(PDOException $e) {
205
+                } catch (PDOException $e) {
206 206
                         echo $e->getMessage();
207 207
                         die;
208 208
                 }
@@ -224,12 +224,12 @@  discard block
 block discarded – undo
224 224
                 date_default_timezone_set('UTC');
225 225
 
226 226
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
227
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
227
+                $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
228 228
 
229 229
                 try {
230 230
                         $sth = $this->db->prepare($query);
231 231
                         $sth->execute(array(':ident' => $ident));
232
-                } catch(PDOException $e) {
232
+                } catch (PDOException $e) {
233 233
                         echo $e->getMessage();
234 234
                         die;
235 235
                 }
@@ -250,12 +250,12 @@  discard block
 block discarded – undo
250 250
                 date_default_timezone_set('UTC');
251 251
 
252 252
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
253
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
253
+                $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
254 254
 
255 255
                 try {
256 256
                         $sth = $this->db->prepare($query);
257 257
                         $sth->execute(array(':id' => $id));
258
-                } catch(PDOException $e) {
258
+                } catch (PDOException $e) {
259 259
                         echo $e->getMessage();
260 260
                         die;
261 261
                 }
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
                 date_default_timezone_set('UTC');
277 277
 
278 278
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
279
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
279
+                $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
280 280
 
281 281
                 try {
282 282
                         $sth = $this->db->prepare($query);
283 283
                         $sth->execute(array(':id' => $id));
284
-                } catch(PDOException $e) {
284
+                } catch (PDOException $e) {
285 285
                         echo $e->getMessage();
286 286
                         die;
287 287
                 }
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
                 date_default_timezone_set('UTC');
304 304
 
305 305
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
306
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
306
+                $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
307 307
 //                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident";
308 308
 
309 309
                 try {
310 310
                         $sth = $this->db->prepare($query);
311 311
                         $sth->execute(array(':ident' => $ident));
312
-                } catch(PDOException $e) {
312
+                } catch (PDOException $e) {
313 313
                         echo $e->getMessage();
314 314
                         die;
315 315
                 }
@@ -326,13 +326,13 @@  discard block
 block discarded – undo
326 326
         * @return Array the spotter information
327 327
         *
328 328
         */
329
-        public function getTrackerArchiveData($ident,$famtrackid,$date)
329
+        public function getTrackerArchiveData($ident, $famtrackid, $date)
330 330
         {
331 331
     		$Tracker = new Tracker($this->db);
332 332
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
333
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
333
+                $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
334 334
 
335
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
335
+                $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':famtrackid' => $famtrackid, ':date' => $date.'%'));
336 336
 
337 337
                 return $spotter_array;
338 338
         }
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 		try {
349 349
 			$sth = $this->db->prepare($query);
350 350
 			$sth->execute();
351
-		} catch(PDOException $e) {
351
+		} catch (PDOException $e) {
352 352
 			echo $e->getMessage();
353 353
 			die;
354 354
 		}
@@ -360,24 +360,24 @@  discard block
 block discarded – undo
360 360
         * @return Array the spotter information
361 361
         *
362 362
         */
363
-        public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
363
+        public function getMinLiveTrackerData($begindate, $enddate, $filter = array())
364 364
         {
365 365
                 global $globalDBdriver, $globalLiveInterval;
366 366
                 date_default_timezone_set('UTC');
367 367
 
368 368
                 $filter_query = '';
369 369
                 if (isset($filter['source']) && !empty($filter['source'])) {
370
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
370
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
371 371
                 }
372 372
                 // Use spotter_output also ?
373 373
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
374
+                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
375 375
                 }
376 376
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377 377
                         $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
378 378
                 }
379 379
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
380
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
381 381
                 }
382 382
 
383 383
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -396,14 +396,14 @@  discard block
 block discarded – undo
396 396
 						GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid 
397 397
 				    AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
398 398
 */
399
-			$query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
399
+			$query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
400 400
 				    FROM tracker_archive 
401 401
 				    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
402 402
 				    WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
403 403
                         	    '.$filter_query.' ORDER BY famtrackid';
404 404
                 } else {
405 405
                         //$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
406
-                        $query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
406
+                        $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
407 407
                         	    FROM tracker_archive 
408 408
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
409 409
                         	    WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".'
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                 try {
414 414
                         $sth = $this->db->prepare($query);
415 415
                         $sth->execute();
416
-                } catch(PDOException $e) {
416
+                } catch (PDOException $e) {
417 417
                         echo $e->getMessage();
418 418
                         die;
419 419
                 }
@@ -428,24 +428,24 @@  discard block
 block discarded – undo
428 428
         * @return Array the spotter information
429 429
         *
430 430
         */
431
-        public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
431
+        public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array())
432 432
         {
433 433
                 global $globalDBdriver, $globalLiveInterval;
434 434
                 date_default_timezone_set('UTC');
435 435
 
436 436
                 $filter_query = '';
437 437
                 if (isset($filter['source']) && !empty($filter['source'])) {
438
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
438
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
439 439
                 }
440 440
                 // Should use spotter_output also ?
441 441
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
442
+                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
443 443
                 }
444 444
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445 445
                         $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
446 446
                 }
447 447
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
448
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
449 449
                 }
450 450
 
451 451
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
                     		    FROM tracker_archive 
456 456
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
457 457
 			*/
458
-			$query  = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
458
+			$query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
459 459
 				    FROM tracker_archive_output 
460 460
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao 
461 461
 				    WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
471 471
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
472 472
                         */
473
-                        $query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
473
+                        $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
474 474
                         	    FROM tracker_archive_output 
475 475
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
476 476
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
                 try {
483 483
                         $sth = $this->db->prepare($query);
484 484
                         $sth->execute();
485
-                } catch(PDOException $e) {
485
+                } catch (PDOException $e) {
486 486
                         echo $e->getMessage();
487 487
                         die;
488 488
                 }
@@ -497,23 +497,23 @@  discard block
 block discarded – undo
497 497
         * @return Array the spotter information
498 498
         *
499 499
         */
500
-        public function getLiveTrackerCount($begindate,$enddate,$filter = array())
500
+        public function getLiveTrackerCount($begindate, $enddate, $filter = array())
501 501
         {
502 502
                 global $globalDBdriver, $globalLiveInterval;
503 503
                 date_default_timezone_set('UTC');
504 504
 
505 505
                 $filter_query = '';
506 506
                 if (isset($filter['source']) && !empty($filter['source'])) {
507
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
507
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
508 508
                 }
509 509
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
510
+                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
511 511
                 }
512 512
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513 513
                         $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
514 514
                 }
515 515
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
516
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
517 517
                 }
518 518
 
519 519
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
                 try {
529 529
                         $sth = $this->db->prepare($query);
530 530
                         $sth->execute();
531
-                } catch(PDOException $e) {
531
+                } catch (PDOException $e) {
532 532
                         echo $e->getMessage();
533 533
                         die;
534 534
                 }
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
     * @return Array the spotter information
549 549
     *
550 550
     */
551
-    public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
551
+    public function searchTrackerData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
552 552
     {
553 553
 	global $globalTimezone, $globalDBdriver;
554 554
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 	        
571 571
 		$q_array = explode(" ", $q);
572 572
 		
573
-		foreach ($q_array as $q_item){
573
+		foreach ($q_array as $q_item) {
574 574
 		    $additional_query .= " AND (";
575 575
 		    $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
576 576
 		    $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	
603 603
 	if ($registration != "")
604 604
 	{
605
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
605
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
606 606
 	    if (!is_string($registration))
607 607
 	    {
608 608
 		return false;
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 	
614 614
 	if ($aircraft_icao != "")
615 615
 	{
616
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
616
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
617 617
 	    if (!is_string($aircraft_icao))
618 618
 	    {
619 619
 		return false;
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 	
625 625
 	if ($aircraft_manufacturer != "")
626 626
 	{
627
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
627
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
628 628
 	    if (!is_string($aircraft_manufacturer))
629 629
 	    {
630 630
 		return false;
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 	
646 646
 	if ($airline_icao != "")
647 647
 	{
648
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
648
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
649 649
 	    if (!is_string($airline_icao))
650 650
 	    {
651 651
 		return false;
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
 	
657 657
 	if ($airline_country != "")
658 658
 	{
659
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
659
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
660 660
 	    if (!is_string($airline_country))
661 661
 	    {
662 662
 		return false;
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	
668 668
 	if ($airline_type != "")
669 669
 	{
670
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
670
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
671 671
 	    if (!is_string($airline_type))
672 672
 	    {
673 673
 		return false;
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 	
690 690
 	if ($airport != "")
691 691
 	{
692
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
692
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
693 693
 	    if (!is_string($airport))
694 694
 	    {
695 695
 		return false;
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 	
701 701
 	if ($airport_country != "")
702 702
 	{
703
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
703
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
704 704
 	    if (!is_string($airport_country))
705 705
 	    {
706 706
 		return false;
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
     
712 712
 	if ($callsign != "")
713 713
 	{
714
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
714
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
715 715
 	    if (!is_string($callsign))
716 716
 	    {
717 717
 		return false;
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 		$translate = $Translation->ident2icao($callsign);
720 720
 		if ($translate != $callsign) {
721 721
 			$additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)";
722
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
722
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
723 723
 		} else {
724 724
 			$additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')";
725 725
 		}
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 
729 729
 	if ($owner != "")
730 730
 	{
731
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
731
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
732 732
 	    if (!is_string($owner))
733 733
 	    {
734 734
 		return false;
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 
740 740
 	if ($pilot_name != "")
741 741
 	{
742
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
742
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
743 743
 	    if (!is_string($pilot_name))
744 744
 	    {
745 745
 		return false;
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 	
751 751
 	if ($pilot_id != "")
752 752
 	{
753
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
753
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
754 754
 	    if (!is_string($pilot_id))
755 755
 	    {
756 756
 		return false;
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	
762 762
 	if ($departure_airport_route != "")
763 763
 	{
764
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
764
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
765 765
 	    if (!is_string($departure_airport_route))
766 766
 	    {
767 767
 		return false;
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 	
773 773
 	if ($arrival_airport_route != "")
774 774
 	{
775
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
775
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
776 776
 	    if (!is_string($arrival_airport_route))
777 777
 	    {
778 778
 		return false;
@@ -785,8 +785,8 @@  discard block
 block discarded – undo
785 785
 	{
786 786
 	    $altitude_array = explode(",", $altitude);
787 787
 	    
788
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
789
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
790 790
 	    
791 791
 
792 792
 	    if ($altitude_array[1] != "")
@@ -804,8 +804,8 @@  discard block
 block discarded – undo
804 804
 	{
805 805
 	    $date_array = explode(",", $date_posted);
806 806
 	    
807
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
807
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
808
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
809 809
 	    
810 810
 	    if ($globalTimezone != '') {
811 811
 		date_default_timezone_set($globalTimezone);
@@ -837,8 +837,8 @@  discard block
 block discarded – undo
837 837
 	{
838 838
 	    $limit_array = explode(",", $limit);
839 839
 	    
840
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
840
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
841
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
842 842
 	    
843 843
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844 844
 	    {
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	
850 850
 
851 851
 	if ($origLat != "" && $origLon != "" && $dist != "") {
852
-		$dist = number_format($dist*0.621371,2,'.','');
853
-		$query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
852
+		$dist = number_format($dist*0.621371, 2, '.', '');
853
+		$query = "SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
854 854
                           FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
855 855
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
856 856
 	} else {
@@ -867,12 +867,12 @@  discard block
 block discarded – undo
867 867
 			$additional_query .= " AND (tracker_archive_output.waypoints <> '')";
868 868
 		}
869 869
 
870
-		$query  = "SELECT tracker_archive_output.* FROM tracker_archive_output 
870
+		$query = "SELECT tracker_archive_output.* FROM tracker_archive_output 
871 871
 		    WHERE tracker_archive_output.ident <> '' 
872 872
 		    ".$additional_query."
873 873
 		    ".$filter_query.$orderby_query;
874 874
 	}
875
-	$spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query);
875
+	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
876 876
 
877 877
 	return $spotter_array;
878 878
     }
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
                 try {
890 890
                         $sth = $this->db->prepare($query);
891 891
                         $sth->execute();
892
-                } catch(PDOException $e) {
892
+                } catch (PDOException $e) {
893 893
                         return "error";
894 894
                 }
895 895
 	}
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
 	{
927 927
 	    $limit_array = explode(",", $limit);
928 928
 	    
929
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
929
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
930
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
931 931
 	    
932 932
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933 933
 	    {
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 	$query_values = array();
969 969
 	$limit_query = '';
970 970
 	$additional_query = '';
971
-	$filter_query = $this->getFilter($filter,true,true);
971
+	$filter_query = $this->getFilter($filter, true, true);
972 972
 	
973 973
 	if ($owner != "")
974 974
 	{
@@ -985,8 +985,8 @@  discard block
 block discarded – undo
985 985
 	{
986 986
 	    $limit_array = explode(",", $limit);
987 987
 	    
988
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
989
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
990 990
 	    
991 991
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992 992
 	    {
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 	$query_values = array();
1027 1027
 	$limit_query = '';
1028 1028
 	$additional_query = '';
1029
-	$filter_query = $this->getFilter($filter,true,true);
1029
+	$filter_query = $this->getFilter($filter, true, true);
1030 1030
 	
1031 1031
 	if ($pilot != "")
1032 1032
 	{
@@ -1038,8 +1038,8 @@  discard block
 block discarded – undo
1038 1038
 	{
1039 1039
 	    $limit_array = explode(",", $limit);
1040 1040
 	    
1041
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1041
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1042
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1043 1043
 	    
1044 1044
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045 1045
 	    {
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
     * @return Array the airline country list
1070 1070
     *
1071 1071
     */
1072
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1072
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1073 1073
     {
1074 1074
 	global $globalDBdriver;
1075 1075
 	/*
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 	$flight_array = array();
1099 1099
 	$temp_array = array();
1100 1100
         
1101
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1101
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1102 1102
 	{
1103 1103
 	    $temp_array['flight_count'] = $row['nb'];
1104 1104
 	    $temp_array['flight_country'] = $row['name'];
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
     * @return Array the airline country list
1116 1116
     *
1117 1117
     */
1118
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1118
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1119 1119
     {
1120 1120
 	global $globalDBdriver;
1121 1121
 	/*
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
 	$flight_array = array();
1145 1145
 	$temp_array = array();
1146 1146
         
1147
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1147
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1148 1148
 	{
1149 1149
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1150 1150
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1162,14 +1162,14 @@  discard block
 block discarded – undo
1162 1162
     * @return Array the spotter information
1163 1163
     *
1164 1164
     */
1165
-    public function getDateArchiveTrackerDataById($id,$date)
1165
+    public function getDateArchiveTrackerDataById($id, $date)
1166 1166
     {
1167 1167
 	$Tracker = new Tracker($this->db);
1168 1168
 	date_default_timezone_set('UTC');
1169 1169
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1170
-	$query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1171
-	$date = date('c',$date);
1172
-	$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date));
1170
+	$query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1171
+	$date = date('c', $date);
1172
+	$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1173 1173
 	return $spotter_array;
1174 1174
     }
1175 1175
 
@@ -1179,14 +1179,14 @@  discard block
 block discarded – undo
1179 1179
     * @return Array the spotter information
1180 1180
     *
1181 1181
     */
1182
-    public function getDateArchiveTrackerDataByIdent($ident,$date)
1182
+    public function getDateArchiveTrackerDataByIdent($ident, $date)
1183 1183
     {
1184 1184
 	$Tracker = new Tracker($this->db);
1185 1185
 	date_default_timezone_set('UTC');
1186 1186
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1187
-	$query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1188
-	$date = date('c',$date);
1189
-	$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1187
+	$query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1188
+	$date = date('c', $date);
1189
+	$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1190 1190
 	return $spotter_array;
1191 1191
     }
1192 1192
 
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
     * @return Array the spotter information
1197 1197
     *
1198 1198
     */
1199
-    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1199
+    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1200 1200
     {
1201 1201
 	global $global_query;
1202 1202
 	$Tracker = new Tracker($this->db);
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 	$query_values = array();
1205 1205
 	$limit_query = '';
1206 1206
 	$additional_query = '';
1207
-	$filter_query = $this->getFilter($filters,true,true);
1207
+	$filter_query = $this->getFilter($filters, true, true);
1208 1208
 	
1209 1209
 	if ($airport != "")
1210 1210
 	{
@@ -1221,8 +1221,8 @@  discard block
 block discarded – undo
1221 1221
 	{
1222 1222
 	    $limit_array = explode(",", $limit);
1223 1223
 	    
1224
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1224
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1225
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1226 1226
 	    
1227 1227
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228 1228
 	    {
Please login to merge, or discard this patch.
Braces   +42 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 	public function __construct($dbc = null) {
7 7
 		$Connection = new Connection($dbc);
8 8
 		$this->db = $Connection->db;
9
-		if ($this->db === null) die('Error: No DB connection. (TrackerArchive)');
9
+		if ($this->db === null) {
10
+			die('Error: No DB connection. (TrackerArchive)');
11
+		}
10 12
 	}
11 13
 
12 14
 	/**
@@ -27,7 +29,9 @@  discard block
 block discarded – undo
27 29
 		if (isset($filter[0]['source'])) {
28 30
 			$filters = array_merge($filters,$filter);
29 31
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
31 35
 		$filter_query_join = '';
32 36
 		$filter_query_where = '';
33 37
 		foreach($filters as $flt) {
@@ -73,8 +77,11 @@  discard block
 block discarded – undo
73 77
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
74 78
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
75 79
 		}
76
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
77
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
80
+		if ($filter_query_where == '' && $where) {
81
+			$filter_query_where = ' WHERE';
82
+		} elseif ($filter_query_where != '' && $and) {
83
+			$filter_query_where .= ' AND';
84
+		}
78 85
 		if ($filter_query_where != '') {
79 86
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
80 87
 		}
@@ -88,9 +95,14 @@  discard block
 block discarded – undo
88 95
 		if ($over_country == '') {
89 96
 			$Tracker = new Tracker($this->db);
90 97
 			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude);
91
-			if (!empty($data_country)) $country = $data_country['iso2'];
92
-			else $country = '';
93
-		} else $country = $over_country;
98
+			if (!empty($data_country)) {
99
+				$country = $data_country['iso2'];
100
+			} else {
101
+				$country = '';
102
+			}
103
+		} else {
104
+			$country = $over_country;
105
+		}
94 106
 		// Route is not added in tracker_archive
95 107
 		$query  = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
96 108
 		    VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
@@ -168,8 +180,11 @@  discard block
 block discarded – undo
168 180
 	{
169 181
                 date_default_timezone_set('UTC');
170 182
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
171
-                if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
172
-                else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
183
+                if ($date == '') {
184
+                	$query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
185
+                } else {
186
+                	$query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
187
+                }
173 188
 
174 189
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
175 190
 
@@ -593,7 +608,9 @@  discard block
 block discarded – undo
593 608
 		    $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
594 609
 		    $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
595 610
 		    $translate = $Translation->ident2icao($q_item);
596
-		    if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
611
+		    if ($translate != $q_item) {
612
+		    	$additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
613
+		    }
597 614
 		    $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
598 615
 		    $additional_query .= ")";
599 616
 		}
@@ -811,7 +828,9 @@  discard block
 block discarded – undo
811 828
 		date_default_timezone_set($globalTimezone);
812 829
 		$datetime = new DateTime();
813 830
 		$offset = $datetime->format('P');
814
-	    } else $offset = '+00:00';
831
+	    } else {
832
+	    	$offset = '+00:00';
833
+	    }
815 834
 
816 835
 
817 836
 	    if ($date_array[1] != "")
@@ -1087,9 +1106,13 @@  discard block
 block discarded – undo
1087 1106
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1088 1107
 			}
1089 1108
 		}
1090
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1109
+                if ($sincedate != '') {
1110
+                	$query .= "AND date > '".$sincedate."' ";
1111
+                }
1091 1112
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1092
-	if ($limit) $query .= " LIMIT 0,10";
1113
+	if ($limit) {
1114
+		$query .= " LIMIT 0,10";
1115
+	}
1093 1116
       
1094 1117
 	
1095 1118
 	$sth = $this->db->prepare($query);
@@ -1133,9 +1156,13 @@  discard block
 block discarded – undo
1133 1156
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1134 1157
 			}
1135 1158
 		}
1136
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1159
+                if ($sincedate != '') {
1160
+                	$query .= "AND s.date > '".$sincedate."' ";
1161
+                }
1137 1162
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1138
-	if ($limit) $query .= " LIMIT 0,10";
1163
+	if ($limit) {
1164
+		$query .= " LIMIT 0,10";
1165
+	}
1139 1166
       
1140 1167
 	
1141 1168
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
js/map-marine.2d.js.php 3 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once('../require/settings.php');
3 3
 require_once('../require/class.Language.php'); 
4 4
 
5
-setcookie("MapFormat",'2d');
5
+setcookie("MapFormat", '2d');
6 6
 
7 7
 // Compressed GeoJson is used if true
8 8
 if (!isset($globalJsonCompress)) $compress = true;
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
 
17 17
 <?php
18 18
 	if (isset($_GET['fammarine_id'])) {
19
-		$fammarine_id = filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING);
19
+		$fammarine_id = filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING);
20 20
 	}
21 21
 	if (isset($_GET['ident'])) {
22
-		$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
22
+		$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
23 23
 	}
24 24
 	if (!isset($ident) && !isset($fammarine_id)) {
25 25
 ?>
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 <?php
183 183
 		} else {
184 184
 ?>
185
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
185
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
186 186
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
187 187
 <?php
188 188
 		}
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 			    /*
199 199
 			    shadowUrl: iconURLShadowpath,
200 200
 			    shadowSize: [<?php print $globalAircraftSize; ?>, <?php print $globalAircraftSize; ?>],
201
-			    shadowAnchor: [<?php print ($globalAircraftSize/2)+1; ?>, <?php print $globalAircraftSize; ?>]
201
+			    shadowAnchor: [<?php print ($globalAircraftSize/2) + 1; ?>, <?php print $globalAircraftSize; ?>]
202 202
 			    */
203 203
 			})
204 204
 		    })
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 <?php
232 232
 		} else {
233 233
 ?>
234
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
234
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
235 235
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
236 236
 <?php
237 237
 		}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 <?php
280 280
 		} else {
281 281
 ?>
282
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
282
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000 + 20000; ?>+feature.properties.sqt*1000);
283 283
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
284 284
 <?php
285 285
 		}
Please login to merge, or discard this patch.
Braces   +42 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,8 +5,11 @@  discard block
 block discarded – undo
5 5
 setcookie("MapFormat",'2d');
6 6
 
7 7
 // Compressed GeoJson is used if true
8
-if (!isset($globalJsonCompress)) $compress = true;
9
-else $compress = $globalJsonCompress;
8
+if (!isset($globalJsonCompress)) {
9
+	$compress = true;
10
+} else {
11
+	$compress = $globalJsonCompress;
12
+}
10 13
 ?>
11 14
 
12 15
 
@@ -156,9 +159,13 @@  discard block
 block discarded – undo
156 159
 		    if (callsign != ""){ markerMarineLabel += callsign; }
157 160
 		    if (type != ""){ markerMarineLabel += ' - '+type; }
158 161
 <?php
159
-	if (isset($_COOKIE['MarineIconColor'])) $MarineIconColor = $_COOKIE['MarineIconColor'];
160
-	elseif (isset($globalMarineIconColor)) $MarineIconColor = $globalMarineIconColor;
161
-	else $MarineIconColor = '1a3151';
162
+	if (isset($_COOKIE['MarineIconColor'])) {
163
+		$MarineIconColor = $_COOKIE['MarineIconColor'];
164
+	} elseif (isset($globalMarineIconColor)) {
165
+		$MarineIconColor = $globalMarineIconColor;
166
+	} else {
167
+		$MarineIconColor = '1a3151';
168
+	}
162 169
 	if (!isset($ident) && !isset($fammarine_id)) {
163 170
 ?>
164 171
 		    //info_marine_update(feature.properties.fc);
@@ -193,7 +200,12 @@  discard block
 block discarded – undo
193 200
 <?php
194 201
 		} else {
195 202
 ?>
196
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
203
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
204
+	print $archiveupdatetime*1000;
205
+} else {
206
+	print $globalMapRefresh*1000+20000;
207
+}
208
+?>+feature.properties.sqt*1000);
197 209
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
198 210
 <?php
199 211
 		}
@@ -249,7 +261,12 @@  discard block
 block discarded – undo
249 261
 <?php
250 262
 		} else {
251 263
 ?>
252
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
264
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
265
+	print $archiveupdatetime*1000;
266
+} else {
267
+	print $globalMapRefresh*1000+20000;
268
+}
269
+?>+feature.properties.sqt*1000);
253 270
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
254 271
 <?php
255 272
 		}
@@ -304,7 +321,12 @@  discard block
 block discarded – undo
304 321
 <?php
305 322
 		} else {
306 323
 ?>
307
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
324
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
325
+	print $archiveupdatetime*1000;
326
+} else {
327
+	print $globalMapRefresh*1000+20000;
328
+}
329
+?>+feature.properties.sqt*1000);
308 330
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
309 331
 <?php
310 332
 		}
@@ -594,14 +616,24 @@  discard block
 block discarded – undo
594 616
 	if (isset($archive) && $archive) {
595 617
 ?>
596 618
 //then load it again every 30 seconds
597
-//  var reload = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>);
619
+//  var reload = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) {
620
+	print ($globalMapRefresh*1000)/2;
621
+} else {
622
+	print '15000';
623
+}
624
+?>);
598 625
 reloadMarinePage = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php print $archiveupdatetime*1000; ?>);
599 626
 <?php
600 627
 	} else {
601 628
 ?>
602 629
 //then load it again every 30 seconds
603 630
 reloadMarinePage = setInterval(
604
-    function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
631
+    function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) {
632
+	print $globalMapRefresh*1000;
633
+} else {
634
+	print '30000';
635
+}
636
+?>);
605 637
 <?php
606 638
 	}
607 639
 ?>
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
 			}
554 554
                     }
555 555
 		    <?php
556
-            		} else {
557
-            	    ?>
556
+					} else {
557
+					?>
558 558
 		    if (map.getZoom() > 7) {
559 559
                 	var style = {
560 560
                     	    "color": "#1a3151",
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
                 	layer_marine_data.addLayer(layer);
574 574
 		    }
575 575
 <?php
576
-            		}
576
+					}
577 577
 ?>
578 578
 				}
579 579
 			    }
@@ -598,11 +598,11 @@  discard block
 block discarded – undo
598 598
 $( document ).ready(function() {
599 599
     map.on('moveend', function() {
600 600
 <?php
601
-    if (isset($globalMapUseBbox) && $globalMapUseBbox) {
601
+	if (isset($globalMapUseBbox) && $globalMapUseBbox) {
602 602
 ?>
603 603
 	getLiveMarineData(1);
604 604
 <?php
605
-    }
605
+	}
606 606
 ?>
607 607
     });
608 608
  //load the function on startup
Please login to merge, or discard this patch.