Completed
Push — master ( 4c9919...b817a3 )
by Yannick
121:29 queued 94:05
created
aircraft-statistics-airline-country.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -21,18 +21,18 @@  discard block
 block discarded – undo
21 21
 	print '<div class="select-item">';
22 22
 	print '<form action="'.$globalURL.'/aircraft" method="post">';
23 23
 	print '<select name="aircraft_type" class="selectpicker" data-live-search="true">';
24
-    	print '<option></option>';
25
-    	$Stats = new Stats();
26
-    	$aircraft_types = $Stats->getAllAircraftTypes();
27
-    	if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes();
28
-    	foreach($aircraft_types as $aircrafttype)
29
-    	{
30
-    		if($aircraft_type == $aircrafttype['aircraft_icao'])
31
-    		{
32
-    			print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
33
-    		} else {
34
-    			print '<option value="'.$aircrafttype['aircraft_icao'].'">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
35
-    		}
24
+		print '<option></option>';
25
+		$Stats = new Stats();
26
+		$aircraft_types = $Stats->getAllAircraftTypes();
27
+		if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes();
28
+		foreach($aircraft_types as $aircrafttype)
29
+		{
30
+			if($aircraft_type == $aircrafttype['aircraft_icao'])
31
+			{
32
+				print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
33
+			} else {
34
+				print '<option value="'.$aircrafttype['aircraft_icao'].'">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
35
+			}
36 36
 	}
37 37
 	print '</select>';
38 38
 	print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
@@ -61,18 +61,18 @@  discard block
 block discarded – undo
61 61
 	print '<script type="text/javascript" src="'.$globalURL.'/js/datamaps.world.min.js"></script>';
62 62
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
63 63
 	print 'var series = [';
64
-        $country_data = '';
64
+		$country_data = '';
65 65
 	foreach($airline_array as $airline_item)
66 66
 	{
67 67
 		$country_data .= '[ "'.$airline_item['airline_country_iso3'].'",'.$airline_item['airline_country_count'].'],';
68 68
 	}
69
-        $country_data = substr($country_data, 0, -1);
70
-        print $country_data;
71
-        print '];';
72
-        print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
73
-        print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
74
-        print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
75
-        print 'new Datamap({
69
+		$country_data = substr($country_data, 0, -1);
70
+		print $country_data;
71
+		print '];';
72
+		print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
73
+		print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
74
+		print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
75
+		print 'new Datamap({
76 76
 	    element: document.getElementById("chartCountry"),
77 77
 	    projection: "mercator", // big world map
78 78
 	    fills: { defaultFill: "#F5F5F5" },
Please login to merge, or discard this patch.
require/class.MarineArchive.php 1 patch
Indentation   +603 added lines, -603 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 	}
10 10
 
11 11
 	/**
12
-	* Get SQL query part for filter used
13
-	* @param Array $filter the filter
14
-	* @return Array the SQL part
15
-	*/
12
+	 * Get SQL query part for filter used
13
+	 * @param Array $filter the filter
14
+	 * @return Array the SQL part
15
+	 */
16 16
 	public function getFilter($filter = array(),$where = false,$and = false) {
17 17
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 		$filters = array();
@@ -110,44 +110,44 @@  discard block
 block discarded – undo
110 110
 	}
111 111
 
112 112
 
113
-        /**
114
-        * Gets all the spotter information based on a particular callsign
115
-        *
116
-        * @return Array the spotter information
117
-        *
118
-        */
119
-        public function getLastArchiveMarineDataByIdent($ident)
120
-        {
113
+		/**
114
+		 * Gets all the spotter information based on a particular callsign
115
+		 *
116
+		 * @return Array the spotter information
117
+		 *
118
+		 */
119
+		public function getLastArchiveMarineDataByIdent($ident)
120
+		{
121 121
 		$Marine = new Marine($this->db);
122
-                date_default_timezone_set('UTC');
122
+				date_default_timezone_set('UTC');
123 123
 
124
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
125
-                //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
126
-                $query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
124
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
125
+				//$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
126
+				$query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
127 127
 
128
-                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
128
+				$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
129 129
 
130
-                return $spotter_array;
131
-        }
130
+				return $spotter_array;
131
+		}
132 132
 
133 133
 
134
-        /**
135
-        * Gets last the spotter information based on a particular id
136
-        *
137
-        * @return Array the spotter information
138
-        *
139
-        */
140
-        public function getLastArchiveMarineDataById($id)
141
-        {
142
-    		$Marine = new Marine($this->db);
143
-                date_default_timezone_set('UTC');
144
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
145
-                //$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
146
-                //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
147
-                $query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
134
+		/**
135
+		 * Gets last the spotter information based on a particular id
136
+		 *
137
+		 * @return Array the spotter information
138
+		 *
139
+		 */
140
+		public function getLastArchiveMarineDataById($id)
141
+		{
142
+			$Marine = new Marine($this->db);
143
+				date_default_timezone_set('UTC');
144
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
145
+				//$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
146
+				//$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
147
+				$query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
148 148
 
149 149
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
150
-                  /*
150
+				  /*
151 151
                 try {
152 152
                         $Connection = new Connection();
153 153
                         $sth = Connection->$db->prepare($query);
@@ -157,232 +157,232 @@  discard block
 block discarded – undo
157 157
                 }
158 158
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
159 159
                 */
160
-                $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
161
-
162
-                return $spotter_array;
163
-        }
164
-
165
-        /**
166
-        * Gets all the spotter information based on a particular id
167
-        *
168
-        * @return Array the spotter information
169
-        *
170
-        */
171
-        public function getAllArchiveMarineDataById($id)
160
+				$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
161
+
162
+				return $spotter_array;
163
+		}
164
+
165
+		/**
166
+		 * Gets all the spotter information based on a particular id
167
+		 *
168
+		 * @return Array the spotter information
169
+		 *
170
+		 */
171
+		public function getAllArchiveMarineDataById($id)
172 172
 	{
173
-                date_default_timezone_set('UTC');
174
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
175
-                $query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
173
+				date_default_timezone_set('UTC');
174
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
175
+				$query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
176 176
 
177 177
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
178 178
 
179
-                try {
180
-                        $sth = $this->db->prepare($query);
181
-                        $sth->execute(array(':id' => $id));
182
-                } catch(PDOException $e) {
183
-                        echo $e->getMessage();
184
-                        die;
185
-                }
186
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
187
-
188
-                return $spotter_array;
189
-        }
190
-
191
-        /**
192
-        * Gets coordinate & time spotter information based on a particular id
193
-        *
194
-        * @return Array the spotter information
195
-        *
196
-        */
197
-        public function getCoordArchiveMarineDataById($id)
198
-        {
199
-                date_default_timezone_set('UTC');
200
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
201
-                $query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
179
+				try {
180
+						$sth = $this->db->prepare($query);
181
+						$sth->execute(array(':id' => $id));
182
+				} catch(PDOException $e) {
183
+						echo $e->getMessage();
184
+						die;
185
+				}
186
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
187
+
188
+				return $spotter_array;
189
+		}
190
+
191
+		/**
192
+		 * Gets coordinate & time spotter information based on a particular id
193
+		 *
194
+		 * @return Array the spotter information
195
+		 *
196
+		 */
197
+		public function getCoordArchiveMarineDataById($id)
198
+		{
199
+				date_default_timezone_set('UTC');
200
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
201
+				$query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
202 202
 
203 203
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
204 204
 
205
-                try {
206
-                        $sth = $this->db->prepare($query);
207
-                        $sth->execute(array(':id' => $id));
208
-                } catch(PDOException $e) {
209
-                        echo $e->getMessage();
210
-                        die;
211
-                }
212
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
205
+				try {
206
+						$sth = $this->db->prepare($query);
207
+						$sth->execute(array(':id' => $id));
208
+				} catch(PDOException $e) {
209
+						echo $e->getMessage();
210
+						die;
211
+				}
212
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
213 213
 
214
-                return $spotter_array;
215
-        }
214
+				return $spotter_array;
215
+		}
216 216
 
217 217
 
218
-        /**
219
-        * Gets altitude information based on a particular callsign
220
-        *
221
-        * @return Array the spotter information
222
-        *
223
-        */
224
-        public function getAltitudeArchiveMarineDataByIdent($ident)
225
-        {
218
+		/**
219
+		 * Gets altitude information based on a particular callsign
220
+		 *
221
+		 * @return Array the spotter information
222
+		 *
223
+		 */
224
+		public function getAltitudeArchiveMarineDataByIdent($ident)
225
+		{
226 226
 
227
-                date_default_timezone_set('UTC');
227
+				date_default_timezone_set('UTC');
228 228
 
229
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
230
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
229
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
230
+				$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
231 231
 
232
-                try {
233
-                        $sth = $this->db->prepare($query);
234
-                        $sth->execute(array(':ident' => $ident));
235
-                } catch(PDOException $e) {
236
-                        echo $e->getMessage();
237
-                        die;
238
-                }
239
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
232
+				try {
233
+						$sth = $this->db->prepare($query);
234
+						$sth->execute(array(':ident' => $ident));
235
+				} catch(PDOException $e) {
236
+						echo $e->getMessage();
237
+						die;
238
+				}
239
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
240 240
 
241
-                return $spotter_array;
242
-        }
241
+				return $spotter_array;
242
+		}
243 243
 
244
-        /**
245
-        * Gets altitude information based on a particular id
246
-        *
247
-        * @return Array the spotter information
248
-        *
249
-        */
250
-        public function getAltitudeArchiveMarineDataById($id)
251
-        {
244
+		/**
245
+		 * Gets altitude information based on a particular id
246
+		 *
247
+		 * @return Array the spotter information
248
+		 *
249
+		 */
250
+		public function getAltitudeArchiveMarineDataById($id)
251
+		{
252 252
 
253
-                date_default_timezone_set('UTC');
253
+				date_default_timezone_set('UTC');
254 254
 
255
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
256
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
255
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
256
+				$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
257 257
 
258
-                try {
259
-                        $sth = $this->db->prepare($query);
260
-                        $sth->execute(array(':id' => $id));
261
-                } catch(PDOException $e) {
262
-                        echo $e->getMessage();
263
-                        die;
264
-                }
265
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
258
+				try {
259
+						$sth = $this->db->prepare($query);
260
+						$sth->execute(array(':id' => $id));
261
+				} catch(PDOException $e) {
262
+						echo $e->getMessage();
263
+						die;
264
+				}
265
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
266 266
 
267
-                return $spotter_array;
268
-        }
267
+				return $spotter_array;
268
+		}
269 269
 
270
-        /**
271
-        * Gets altitude & speed information based on a particular id
272
-        *
273
-        * @return Array the spotter information
274
-        *
275
-        */
276
-        public function getAltitudeSpeedArchiveMarineDataById($id)
277
-        {
270
+		/**
271
+		 * Gets altitude & speed information based on a particular id
272
+		 *
273
+		 * @return Array the spotter information
274
+		 *
275
+		 */
276
+		public function getAltitudeSpeedArchiveMarineDataById($id)
277
+		{
278 278
 
279
-                date_default_timezone_set('UTC');
279
+				date_default_timezone_set('UTC');
280 280
 
281
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
282
-                $query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
281
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
282
+				$query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
283 283
 
284
-                try {
285
-                        $sth = $this->db->prepare($query);
286
-                        $sth->execute(array(':id' => $id));
287
-                } catch(PDOException $e) {
288
-                        echo $e->getMessage();
289
-                        die;
290
-                }
291
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
284
+				try {
285
+						$sth = $this->db->prepare($query);
286
+						$sth->execute(array(':id' => $id));
287
+				} catch(PDOException $e) {
288
+						echo $e->getMessage();
289
+						die;
290
+				}
291
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
292 292
 
293
-                return $spotter_array;
294
-        }
293
+				return $spotter_array;
294
+		}
295 295
 
296 296
 
297
-        /**
298
-        * Gets altitude information based on a particular callsign
299
-        *
300
-        * @return Array the spotter information
301
-        *
302
-        */
303
-        public function getLastAltitudeArchiveMarineDataByIdent($ident)
304
-        {
297
+		/**
298
+		 * Gets altitude information based on a particular callsign
299
+		 *
300
+		 * @return Array the spotter information
301
+		 *
302
+		 */
303
+		public function getLastAltitudeArchiveMarineDataByIdent($ident)
304
+		{
305 305
 
306
-                date_default_timezone_set('UTC');
306
+				date_default_timezone_set('UTC');
307 307
 
308
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
309
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
308
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
309
+				$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
310 310
 //                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";
311 311
 
312
-                try {
313
-                        $sth = $this->db->prepare($query);
314
-                        $sth->execute(array(':ident' => $ident));
315
-                } catch(PDOException $e) {
316
-                        echo $e->getMessage();
317
-                        die;
318
-                }
319
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
312
+				try {
313
+						$sth = $this->db->prepare($query);
314
+						$sth->execute(array(':ident' => $ident));
315
+				} catch(PDOException $e) {
316
+						echo $e->getMessage();
317
+						die;
318
+				}
319
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
320 320
 
321
-                return $spotter_array;
322
-        }
321
+				return $spotter_array;
322
+		}
323 323
 
324 324
 
325 325
 
326
-       /**
327
-        * Gets all the archive spotter information
328
-        *
329
-        * @return Array the spotter information
330
-        *
331
-        */
332
-        public function getMarineArchiveData($ident,$fammarine_id,$date)
333
-        {
334
-    		$Marine = new Marine($this->db);
335
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
336
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";
326
+	   /**
327
+	    * Gets all the archive spotter information
328
+	    *
329
+	    * @return Array the spotter information
330
+	    *
331
+	    */
332
+		public function getMarineArchiveData($ident,$fammarine_id,$date)
333
+		{
334
+			$Marine = new Marine($this->db);
335
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
336
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";
337 337
 
338
-                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%'));
338
+				$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%'));
339 339
 
340
-                return $spotter_array;
341
-        }
340
+				return $spotter_array;
341
+		}
342 342
         
343
-        public function deleteMarineArchiveTrackData()
344
-        {
343
+		public function deleteMarineArchiveTrackData()
344
+		{
345 345
 		global $globalArchiveKeepTrackMonths;
346
-                date_default_timezone_set('UTC');
346
+				date_default_timezone_set('UTC');
347 347
 		$query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
348
-                try {
349
-                        $sth = $this->db->prepare($query);
350
-                        $sth->execute();
351
-                } catch(PDOException $e) {
352
-                        echo $e->getMessage();
353
-                        die;
354
-                }
348
+				try {
349
+						$sth = $this->db->prepare($query);
350
+						$sth->execute();
351
+				} catch(PDOException $e) {
352
+						echo $e->getMessage();
353
+						die;
354
+				}
355 355
 	}
356 356
 
357 357
 	/**
358
-        * Gets Minimal Live Marine data
359
-        *
360
-        * @return Array the spotter information
361
-        *
362
-        */
363
-        public function getMinLiveMarineData($begindate,$enddate,$filter = array())
364
-        {
365
-                global $globalDBdriver, $globalLiveInterval;
366
-                date_default_timezone_set('UTC');
367
-
368
-                $filter_query = '';
369
-                if (isset($filter['source']) && !empty($filter['source'])) {
370
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
371
-                }
372
-                // Use spotter_output also ?
373
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
375
-                }
376
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
378
-                }
379
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
381
-                }
358
+	 * Gets Minimal Live Marine data
359
+	 *
360
+	 * @return Array the spotter information
361
+	 *
362
+	 */
363
+		public function getMinLiveMarineData($begindate,$enddate,$filter = array())
364
+		{
365
+				global $globalDBdriver, $globalLiveInterval;
366
+				date_default_timezone_set('UTC');
367
+
368
+				$filter_query = '';
369
+				if (isset($filter['source']) && !empty($filter['source'])) {
370
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
371
+				}
372
+				// Use spotter_output also ?
373
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
374
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
375
+				}
376
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
377
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
378
+				}
379
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
380
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
381
+				}
382 382
 
383
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
384
-                if ($globalDBdriver == 'mysql') {
385
-                        /*
383
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
384
+				if ($globalDBdriver == 'mysql') {
385
+						/*
386 386
                         $query  = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk 
387 387
                     		    FROM marine_archive 
388 388
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
@@ -401,56 +401,56 @@  discard block
 block discarded – undo
401 401
 				    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
402 402
 				    WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
403 403
                         	    '.$filter_query.' ORDER BY fammarine_id';
404
-                } else {
405
-                        //$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
406
-                        $query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
404
+				} else {
405
+						//$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
406
+						$query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
407 407
                         	    FROM marine_archive 
408 408
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
409 409
                         	    WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'
410 410
                         	    '.$filter_query.' ORDER BY fammarine_id';
411
-                }
412
-                //echo $query;
413
-                try {
414
-                        $sth = $this->db->prepare($query);
415
-                        $sth->execute();
416
-                } catch(PDOException $e) {
417
-                        echo $e->getMessage();
418
-                        die;
419
-                }
420
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
411
+				}
412
+				//echo $query;
413
+				try {
414
+						$sth = $this->db->prepare($query);
415
+						$sth->execute();
416
+				} catch(PDOException $e) {
417
+						echo $e->getMessage();
418
+						die;
419
+				}
420
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
421 421
 
422
-                return $spotter_array;
423
-        }
422
+				return $spotter_array;
423
+		}
424 424
 
425 425
 	/**
426
-        * Gets Minimal Live Marine data
427
-        *
428
-        * @return Array the spotter information
429
-        *
430
-        */
431
-        public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
432
-        {
433
-                global $globalDBdriver, $globalLiveInterval;
434
-                date_default_timezone_set('UTC');
435
-
436
-                $filter_query = '';
437
-                if (isset($filter['source']) && !empty($filter['source'])) {
438
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
439
-                }
440
-                // Should use spotter_output also ?
441
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
443
-                }
444
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
446
-                }
447
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
449
-                }
426
+	 * Gets Minimal Live Marine data
427
+	 *
428
+	 * @return Array the spotter information
429
+	 *
430
+	 */
431
+		public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
432
+		{
433
+				global $globalDBdriver, $globalLiveInterval;
434
+				date_default_timezone_set('UTC');
435
+
436
+				$filter_query = '';
437
+				if (isset($filter['source']) && !empty($filter['source'])) {
438
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
439
+				}
440
+				// Should use spotter_output also ?
441
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
442
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
443
+				}
444
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
445
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
446
+				}
447
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
448
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
449
+				}
450 450
 
451
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
452
-                if ($globalDBdriver == 'mysql') {
453
-                        /*
451
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
452
+				if ($globalDBdriver == 'mysql') {
453
+						/*
454 454
                         $query  = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk 
455 455
                     		    FROM marine_archive 
456 456
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
@@ -461,95 +461,95 @@  discard block
 block discarded – undo
461 461
 				    WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
462 462
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
463 463
 
464
-                } else {
465
-                        //$query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';
466
-                       /*
464
+				} else {
465
+						//$query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';
466
+					   /*
467 467
                         $query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
468 468
                         	    FROM marine_archive_output 
469 469
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
470 470
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
471 471
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
472 472
                         */
473
-                        $query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
473
+						$query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
474 474
                         	    FROM marine_archive_output 
475 475
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
476 476
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
477 477
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
478 478
 //                        	    .' GROUP BY spotter_output.fammarine_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
479 479
                         	    
480
-                }
481
-                //echo $query;
482
-                try {
483
-                        $sth = $this->db->prepare($query);
484
-                        $sth->execute();
485
-                } catch(PDOException $e) {
486
-                        echo $e->getMessage();
487
-                        die;
488
-                }
489
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
480
+				}
481
+				//echo $query;
482
+				try {
483
+						$sth = $this->db->prepare($query);
484
+						$sth->execute();
485
+				} catch(PDOException $e) {
486
+						echo $e->getMessage();
487
+						die;
488
+				}
489
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
490 490
 
491
-                return $spotter_array;
492
-        }
491
+				return $spotter_array;
492
+		}
493 493
 
494 494
 	 /**
495
-        * Gets count Live Marine data
496
-        *
497
-        * @return Array the spotter information
498
-        *
499
-        */
500
-        public function getLiveMarineCount($begindate,$enddate,$filter = array())
501
-        {
502
-                global $globalDBdriver, $globalLiveInterval;
503
-                date_default_timezone_set('UTC');
504
-
505
-                $filter_query = '';
506
-                if (isset($filter['source']) && !empty($filter['source'])) {
507
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
508
-                }
509
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
511
-                }
512
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
514
-                }
515
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
517
-                }
495
+	  * Gets count Live Marine data
496
+	  *
497
+	  * @return Array the spotter information
498
+	  *
499
+	  */
500
+		public function getLiveMarineCount($begindate,$enddate,$filter = array())
501
+		{
502
+				global $globalDBdriver, $globalLiveInterval;
503
+				date_default_timezone_set('UTC');
518 504
 
519
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
520
-                if ($globalDBdriver == 'mysql') {
505
+				$filter_query = '';
506
+				if (isset($filter['source']) && !empty($filter['source'])) {
507
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
508
+				}
509
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
510
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
511
+				}
512
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
513
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
514
+				}
515
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
516
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
517
+				}
518
+
519
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
520
+				if ($globalDBdriver == 'mysql') {
521 521
 			$query = 'SELECT COUNT(DISTINCT fammarine_id) as nb 
522 522
 			FROM marine_archive l 
523 523
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
524
-                } else {
524
+				} else {
525 525
 			$query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
526
-                }
527
-                //echo $query;
528
-                try {
529
-                        $sth = $this->db->prepare($query);
530
-                        $sth->execute();
531
-                } catch(PDOException $e) {
532
-                        echo $e->getMessage();
533
-                        die;
534
-                }
526
+				}
527
+				//echo $query;
528
+				try {
529
+						$sth = $this->db->prepare($query);
530
+						$sth->execute();
531
+				} catch(PDOException $e) {
532
+						echo $e->getMessage();
533
+						die;
534
+				}
535 535
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
536 536
 		$sth->closeCursor();
537
-                return $result['nb'];
537
+				return $result['nb'];
538 538
 
539
-        }
539
+		}
540 540
 
541 541
 
542 542
 
543 543
 	// marine_archive_output
544 544
 	
545
-    /**
546
-    * Gets all the spotter information
547
-    *
548
-    * @return Array the spotter information
549
-    *
550
-    */
551
-    public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
552
-    {
545
+	/**
546
+	 * Gets all the spotter information
547
+	 *
548
+	 * @return Array the spotter information
549
+	 *
550
+	 */
551
+	public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
552
+	{
553 553
 	global $globalTimezone, $globalDBdriver;
554 554
 	require_once(dirname(__FILE__).'/class.Translation.php');
555 555
 	$Translation = new Translation();
@@ -563,159 +563,159 @@  discard block
 block discarded – undo
563 563
 	$filter_query = $this->getFilter($filters);
564 564
 	if ($q != "")
565 565
 	{
566
-	    if (!is_string($q))
567
-	    {
566
+		if (!is_string($q))
567
+		{
568 568
 		return false;
569
-	    } else {
569
+		} else {
570 570
 	        
571 571
 		$q_array = explode(" ", $q);
572 572
 		
573 573
 		foreach ($q_array as $q_item){
574
-		    $additional_query .= " AND (";
575
-		    $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
576
-		    $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
577
-		    $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";
578
-		    $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
579
-		    $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";
580
-		    $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";
581
-		    $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";
582
-		    $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
583
-		    $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";
584
-		    $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";
585
-		    $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";
586
-		    $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
587
-		    $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
588
-		    $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
589
-		    $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
590
-		    $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";
591
-		    $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";
592
-		    $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";
593
-		    $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
594
-		    $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
595
-		    $translate = $Translation->ident2icao($q_item);
596
-		    if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
597
-		    $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
598
-		    $additional_query .= ")";
574
+			$additional_query .= " AND (";
575
+			$additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
576
+			$additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
577
+			$additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";
578
+			$additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
579
+			$additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";
580
+			$additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";
581
+			$additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";
582
+			$additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
583
+			$additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";
584
+			$additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";
585
+			$additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";
586
+			$additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
587
+			$additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
588
+			$additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
589
+			$additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
590
+			$additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";
591
+			$additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";
592
+			$additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";
593
+			$additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
594
+			$additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
595
+			$translate = $Translation->ident2icao($q_item);
596
+			if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
597
+			$additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
598
+			$additional_query .= ")";
599
+		}
599 600
 		}
600
-	    }
601 601
 	}
602 602
 	
603 603
 	if ($registration != "")
604 604
 	{
605
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
606
-	    if (!is_string($registration))
607
-	    {
605
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
606
+		if (!is_string($registration))
607
+		{
608 608
 		return false;
609
-	    } else {
609
+		} else {
610 610
 		$additional_query .= " AND (marine_archive_output.registration = '".$registration."')";
611
-	    }
611
+		}
612 612
 	}
613 613
 	
614 614
 	if ($aircraft_icao != "")
615 615
 	{
616
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
617
-	    if (!is_string($aircraft_icao))
618
-	    {
616
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
617
+		if (!is_string($aircraft_icao))
618
+		{
619 619
 		return false;
620
-	    } else {
620
+		} else {
621 621
 		$additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')";
622
-	    }
622
+		}
623 623
 	}
624 624
 	
625 625
 	if ($aircraft_manufacturer != "")
626 626
 	{
627
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
628
-	    if (!is_string($aircraft_manufacturer))
629
-	    {
627
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
628
+		if (!is_string($aircraft_manufacturer))
629
+		{
630 630
 		return false;
631
-	    } else {
631
+		} else {
632 632
 		$additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
633
-	    }
633
+		}
634 634
 	}
635 635
 	
636 636
 	if ($highlights == "true")
637 637
 	{
638
-	    if (!is_string($highlights))
639
-	    {
638
+		if (!is_string($highlights))
639
+		{
640 640
 		return false;
641
-	    } else {
641
+		} else {
642 642
 		$additional_query .= " AND (marine_archive_output.highlight <> '')";
643
-	    }
643
+		}
644 644
 	}
645 645
 	
646 646
 	if ($airline_icao != "")
647 647
 	{
648
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
649
-	    if (!is_string($airline_icao))
650
-	    {
648
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
649
+		if (!is_string($airline_icao))
650
+		{
651 651
 		return false;
652
-	    } else {
652
+		} else {
653 653
 		$additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')";
654
-	    }
654
+		}
655 655
 	}
656 656
 	
657 657
 	if ($airline_country != "")
658 658
 	{
659
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
660
-	    if (!is_string($airline_country))
661
-	    {
659
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
660
+		if (!is_string($airline_country))
661
+		{
662 662
 		return false;
663
-	    } else {
663
+		} else {
664 664
 		$additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')";
665
-	    }
665
+		}
666 666
 	}
667 667
 	
668 668
 	if ($airline_type != "")
669 669
 	{
670
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
671
-	    if (!is_string($airline_type))
672
-	    {
670
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
671
+		if (!is_string($airline_type))
672
+		{
673 673
 		return false;
674
-	    } else {
674
+		} else {
675 675
 		if ($airline_type == "passenger")
676 676
 		{
677
-		    $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";
677
+			$additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";
678 678
 		}
679 679
 		if ($airline_type == "cargo")
680 680
 		{
681
-		    $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";
681
+			$additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";
682 682
 		}
683 683
 		if ($airline_type == "military")
684 684
 		{
685
-		    $additional_query .= " AND (marine_archive_output.airline_type = 'military')";
685
+			$additional_query .= " AND (marine_archive_output.airline_type = 'military')";
686
+		}
686 687
 		}
687
-	    }
688 688
 	}
689 689
 	
690 690
 	if ($airport != "")
691 691
 	{
692
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
693
-	    if (!is_string($airport))
694
-	    {
692
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
693
+		if (!is_string($airport))
694
+		{
695 695
 		return false;
696
-	    } else {
696
+		} else {
697 697
 		$additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))";
698
-	    }
698
+		}
699 699
 	}
700 700
 	
701 701
 	if ($airport_country != "")
702 702
 	{
703
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
704
-	    if (!is_string($airport_country))
705
-	    {
703
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
704
+		if (!is_string($airport_country))
705
+		{
706 706
 		return false;
707
-	    } else {
707
+		} else {
708 708
 		$additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))";
709
-	    }
709
+		}
710 710
 	}
711 711
     
712 712
 	if ($callsign != "")
713 713
 	{
714
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
715
-	    if (!is_string($callsign))
716
-	    {
714
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
715
+		if (!is_string($callsign))
716
+		{
717 717
 		return false;
718
-	    } else {
718
+		} else {
719 719
 		$translate = $Translation->ident2icao($callsign);
720 720
 		if ($translate != $callsign) {
721 721
 			$additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";
@@ -723,99 +723,99 @@  discard block
 block discarded – undo
723 723
 		} else {
724 724
 			$additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";
725 725
 		}
726
-	    }
726
+		}
727 727
 	}
728 728
 
729 729
 	if ($owner != "")
730 730
 	{
731
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
732
-	    if (!is_string($owner))
733
-	    {
731
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
732
+		if (!is_string($owner))
733
+		{
734 734
 		return false;
735
-	    } else {
735
+		} else {
736 736
 		$additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')";
737
-	    }
737
+		}
738 738
 	}
739 739
 
740 740
 	if ($pilot_name != "")
741 741
 	{
742
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
743
-	    if (!is_string($pilot_name))
744
-	    {
742
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
743
+		if (!is_string($pilot_name))
744
+		{
745 745
 		return false;
746
-	    } else {
746
+		} else {
747 747
 		$additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')";
748
-	    }
748
+		}
749 749
 	}
750 750
 	
751 751
 	if ($pilot_id != "")
752 752
 	{
753
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
754
-	    if (!is_string($pilot_id))
755
-	    {
753
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
754
+		if (!is_string($pilot_id))
755
+		{
756 756
 		return false;
757
-	    } else {
757
+		} else {
758 758
 		$additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')";
759
-	    }
759
+		}
760 760
 	}
761 761
 	
762 762
 	if ($departure_airport_route != "")
763 763
 	{
764
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
765
-	    if (!is_string($departure_airport_route))
766
-	    {
764
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
765
+		if (!is_string($departure_airport_route))
766
+		{
767 767
 		return false;
768
-	    } else {
768
+		} else {
769 769
 		$additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')";
770
-	    }
770
+		}
771 771
 	}
772 772
 	
773 773
 	if ($arrival_airport_route != "")
774 774
 	{
775
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
776
-	    if (!is_string($arrival_airport_route))
777
-	    {
775
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
776
+		if (!is_string($arrival_airport_route))
777
+		{
778 778
 		return false;
779
-	    } else {
779
+		} else {
780 780
 		$additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
781
-	    }
781
+		}
782 782
 	}
783 783
 	
784 784
 	if ($altitude != "")
785 785
 	{
786
-	    $altitude_array = explode(",", $altitude);
786
+		$altitude_array = explode(",", $altitude);
787 787
 	    
788
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
790 790
 	    
791 791
 
792
-	    if ($altitude_array[1] != "")
793
-	    {                
792
+		if ($altitude_array[1] != "")
793
+		{                
794 794
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
795 795
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
796 796
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
797
-	    } else {
797
+		} else {
798 798
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
799 799
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
800
-	    }
800
+		}
801 801
 	}
802 802
 	
803 803
 	if ($date_posted != "")
804 804
 	{
805
-	    $date_array = explode(",", $date_posted);
805
+		$date_array = explode(",", $date_posted);
806 806
 	    
807
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
807
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
808
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
809 809
 	    
810
-	    if ($globalTimezone != '') {
810
+		if ($globalTimezone != '') {
811 811
 		date_default_timezone_set($globalTimezone);
812 812
 		$datetime = new DateTime();
813 813
 		$offset = $datetime->format('P');
814
-	    } else $offset = '+00:00';
814
+		} else $offset = '+00:00';
815 815
 
816 816
 
817
-	    if ($date_array[1] != "")
818
-	    {                
817
+		if ($date_array[1] != "")
818
+		{                
819 819
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
820 820
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
821 821
 		if ($globalDBdriver == 'mysql') {
@@ -823,28 +823,28 @@  discard block
 block discarded – undo
823 823
 		} else {
824 824
 			$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
825 825
 		}
826
-	    } else {
826
+		} else {
827 827
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
828
-                if ($globalDBdriver == 'mysql') {
828
+				if ($globalDBdriver == 'mysql') {
829 829
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
830 830
 		} else {
831 831
 			$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
832 832
 		}
833
-	    }
833
+		}
834 834
 	}
835 835
 	
836 836
 	if ($limit != "")
837 837
 	{
838
-	    $limit_array = explode(",", $limit);
838
+		$limit_array = explode(",", $limit);
839 839
 	    
840
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
840
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
841
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
842 842
 	    
843
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844
-	    {
843
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
844
+		{
845 845
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
846 846
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
847
-	    }
847
+		}
848 848
 	}
849 849
 	
850 850
 
@@ -875,33 +875,33 @@  discard block
 block discarded – undo
875 875
 	$spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);
876 876
 
877 877
 	return $spotter_array;
878
-    }
878
+	}
879 879
 
880
-    public function deleteMarineArchiveData()
881
-    {
880
+	public function deleteMarineArchiveData()
881
+	{
882 882
 		global $globalArchiveKeepMonths, $globalDBdriver;
883
-                date_default_timezone_set('UTC');
884
-                if ($globalDBdriver == 'mysql') {
883
+				date_default_timezone_set('UTC');
884
+				if ($globalDBdriver == 'mysql') {
885 885
 			$query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
886 886
 		} else {
887 887
 			$query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
888 888
 		}
889
-                try {
890
-                        $sth = $this->db->prepare($query);
891
-                        $sth->execute();
892
-                } catch(PDOException $e) {
893
-                        return "error";
894
-                }
889
+				try {
890
+						$sth = $this->db->prepare($query);
891
+						$sth->execute();
892
+				} catch(PDOException $e) {
893
+						return "error";
894
+				}
895 895
 	}
896 896
 
897
-    /**
898
-    * Gets all the spotter information based on the callsign
899
-    *
900
-    * @return Array the spotter information
901
-    *
902
-    */
903
-    public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')
904
-    {
897
+	/**
898
+	 * Gets all the spotter information based on the callsign
899
+	 *
900
+	 * @return Array the spotter information
901
+	 *
902
+	 */
903
+	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')
904
+	{
905 905
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
906 906
 	
907 907
 	date_default_timezone_set('UTC');
@@ -913,35 +913,35 @@  discard block
 block discarded – undo
913 913
 	
914 914
 	if ($ident != "")
915 915
 	{
916
-	    if (!is_string($ident))
917
-	    {
916
+		if (!is_string($ident))
917
+		{
918 918
 		return false;
919
-	    } else {
919
+		} else {
920 920
 		$additional_query = " AND (marine_archive_output.ident = :ident)";
921 921
 		$query_values = array(':ident' => $ident);
922
-	    }
922
+		}
923 923
 	}
924 924
 	
925 925
 	if ($limit != "")
926 926
 	{
927
-	    $limit_array = explode(",", $limit);
927
+		$limit_array = explode(",", $limit);
928 928
 	    
929
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
929
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
930
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
931 931
 	    
932
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933
-	    {
932
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
933
+		{
934 934
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
935 935
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
936
-	    }
936
+		}
937 937
 	}
938 938
 
939 939
 	if ($sort != "")
940 940
 	{
941
-	    $search_orderby_array = $Marine->getOrderBy();
942
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
941
+		$search_orderby_array = $Marine->getOrderBy();
942
+		$orderby_query = $search_orderby_array[$sort]['sql'];
943 943
 	} else {
944
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
944
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
945 945
 	}
946 946
 
947 947
 	$query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -949,17 +949,17 @@  discard block
 block discarded – undo
949 949
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
950 950
 
951 951
 	return $spotter_array;
952
-    }
952
+	}
953 953
 
954 954
 
955
-    /**
956
-    * Gets all the spotter information based on the owner
957
-    *
958
-    * @return Array the spotter information
959
-    *
960
-    */
961
-    public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
962
-    {
955
+	/**
956
+	 * Gets all the spotter information based on the owner
957
+	 *
958
+	 * @return Array the spotter information
959
+	 *
960
+	 */
961
+	public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
962
+	{
963 963
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
964 964
 	
965 965
 	date_default_timezone_set('UTC');
@@ -972,35 +972,35 @@  discard block
 block discarded – undo
972 972
 	
973 973
 	if ($owner != "")
974 974
 	{
975
-	    if (!is_string($owner))
976
-	    {
975
+		if (!is_string($owner))
976
+		{
977 977
 		return false;
978
-	    } else {
978
+		} else {
979 979
 		$additional_query = " AND (marine_archive_output.owner_name = :owner)";
980 980
 		$query_values = array(':owner' => $owner);
981
-	    }
981
+		}
982 982
 	}
983 983
 	
984 984
 	if ($limit != "")
985 985
 	{
986
-	    $limit_array = explode(",", $limit);
986
+		$limit_array = explode(",", $limit);
987 987
 	    
988
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
990 990
 	    
991
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992
-	    {
991
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992
+		{
993 993
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
994 994
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
995
-	    }
995
+		}
996 996
 	}
997 997
 
998 998
 	if ($sort != "")
999 999
 	{
1000
-	    $search_orderby_array = $Marine->getOrderBy();
1001
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1000
+		$search_orderby_array = $Marine->getOrderBy();
1001
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1002 1002
 	} else {
1003
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1003
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1004 1004
 	}
1005 1005
 
1006 1006
 	$query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1008,16 +1008,16 @@  discard block
 block discarded – undo
1008 1008
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1009 1009
 
1010 1010
 	return $spotter_array;
1011
-    }
1012
-
1013
-    /**
1014
-    * Gets all the spotter information based on the pilot
1015
-    *
1016
-    * @return Array the spotter information
1017
-    *
1018
-    */
1019
-    public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1020
-    {
1011
+	}
1012
+
1013
+	/**
1014
+	 * Gets all the spotter information based on the pilot
1015
+	 *
1016
+	 * @return Array the spotter information
1017
+	 *
1018
+	 */
1019
+	public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1020
+	{
1021 1021
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
1022 1022
 	
1023 1023
 	date_default_timezone_set('UTC');
@@ -1036,24 +1036,24 @@  discard block
 block discarded – undo
1036 1036
 	
1037 1037
 	if ($limit != "")
1038 1038
 	{
1039
-	    $limit_array = explode(",", $limit);
1039
+		$limit_array = explode(",", $limit);
1040 1040
 	    
1041
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1041
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1042
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1043 1043
 	    
1044
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045
-	    {
1044
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1045
+		{
1046 1046
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1047 1047
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1048
-	    }
1048
+		}
1049 1049
 	}
1050 1050
 
1051 1051
 	if ($sort != "")
1052 1052
 	{
1053
-	    $search_orderby_array = $Marine->getOrderBy();
1054
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1053
+		$search_orderby_array = $Marine->getOrderBy();
1054
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1055 1055
 	} else {
1056
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1056
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1057 1057
 	}
1058 1058
 
1059 1059
 	$query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1061,16 +1061,16 @@  discard block
 block discarded – undo
1061 1061
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1062 1062
 
1063 1063
 	return $spotter_array;
1064
-    }
1065
-
1066
-    /**
1067
-    * Gets all number of flight over countries
1068
-    *
1069
-    * @return Array the airline country list
1070
-    *
1071
-    */
1072
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1073
-    {
1064
+	}
1065
+
1066
+	/**
1067
+	 * Gets all number of flight over countries
1068
+	 *
1069
+	 * @return Array the airline country list
1070
+	 *
1071
+	 */
1072
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1073
+	{
1074 1074
 	global $globalDBdriver;
1075 1075
 	/*
1076 1076
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1080,14 +1080,14 @@  discard block
 block discarded – undo
1080 1080
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1081 1081
 		    FROM countries c, marine_archive s
1082 1082
 		    WHERE c.iso2 = s.over_country ";
1083
-                if ($olderthanmonths > 0) {
1084
-            		if ($globalDBdriver == 'mysql') {
1083
+				if ($olderthanmonths > 0) {
1084
+					if ($globalDBdriver == 'mysql') {
1085 1085
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1086 1086
 			} else {
1087 1087
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1088 1088
 			}
1089 1089
 		}
1090
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1090
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1091 1091
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1092 1092
 	if ($limit) $query .= " LIMIT 0,10";
1093 1093
       
@@ -1100,23 +1100,23 @@  discard block
 block discarded – undo
1100 1100
         
1101 1101
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1102 1102
 	{
1103
-	    $temp_array['flight_count'] = $row['nb'];
1104
-	    $temp_array['flight_country'] = $row['name'];
1105
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1106
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1107
-	    $flight_array[] = $temp_array;
1103
+		$temp_array['flight_count'] = $row['nb'];
1104
+		$temp_array['flight_country'] = $row['name'];
1105
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1106
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1107
+		$flight_array[] = $temp_array;
1108 1108
 	}
1109 1109
 	return $flight_array;
1110
-    }
1111
-
1112
-    /**
1113
-    * Gets all number of flight over countries
1114
-    *
1115
-    * @return Array the airline country list
1116
-    *
1117
-    */
1118
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1119
-    {
1110
+	}
1111
+
1112
+	/**
1113
+	 * Gets all number of flight over countries
1114
+	 *
1115
+	 * @return Array the airline country list
1116
+	 *
1117
+	 */
1118
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1119
+	{
1120 1120
 	global $globalDBdriver;
1121 1121
 	/*
1122 1122
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1126,14 +1126,14 @@  discard block
 block discarded – undo
1126 1126
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1127 1127
 		    FROM countries c, marine_archive s, spotter_output o
1128 1128
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id ";
1129
-                if ($olderthanmonths > 0) {
1130
-            		if ($globalDBdriver == 'mysql') {
1129
+				if ($olderthanmonths > 0) {
1130
+					if ($globalDBdriver == 'mysql') {
1131 1131
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1132 1132
 			} else {
1133 1133
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1134 1134
 			}
1135 1135
 		}
1136
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1136
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1137 1137
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1138 1138
 	if ($limit) $query .= " LIMIT 0,10";
1139 1139
       
@@ -1146,24 +1146,24 @@  discard block
 block discarded – undo
1146 1146
         
1147 1147
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1148 1148
 	{
1149
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1150
-	    $temp_array['flight_count'] = $row['nb'];
1151
-	    $temp_array['flight_country'] = $row['name'];
1152
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1153
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1154
-	    $flight_array[] = $temp_array;
1149
+		$temp_array['airline_icao'] = $row['airline_icao'];
1150
+		$temp_array['flight_count'] = $row['nb'];
1151
+		$temp_array['flight_country'] = $row['name'];
1152
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1153
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1154
+		$flight_array[] = $temp_array;
1155 1155
 	}
1156 1156
 	return $flight_array;
1157
-    }
1158
-
1159
-    /**
1160
-    * Gets last spotter information based on a particular callsign
1161
-    *
1162
-    * @return Array the spotter information
1163
-    *
1164
-    */
1165
-    public function getDateArchiveMarineDataById($id,$date)
1166
-    {
1157
+	}
1158
+
1159
+	/**
1160
+	 * Gets last spotter information based on a particular callsign
1161
+	 *
1162
+	 * @return Array the spotter information
1163
+	 *
1164
+	 */
1165
+	public function getDateArchiveMarineDataById($id,$date)
1166
+	{
1167 1167
 	$Marine = new Marine($this->db);
1168 1168
 	date_default_timezone_set('UTC');
1169 1169
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1171,16 +1171,16 @@  discard block
 block discarded – undo
1171 1171
 	$date = date('c',$date);
1172 1172
 	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date));
1173 1173
 	return $spotter_array;
1174
-    }
1175
-
1176
-    /**
1177
-    * Gets all the spotter information based on a particular callsign
1178
-    *
1179
-    * @return Array the spotter information
1180
-    *
1181
-    */
1182
-    public function getDateArchiveMarineDataByIdent($ident,$date)
1183
-    {
1174
+	}
1175
+
1176
+	/**
1177
+	 * Gets all the spotter information based on a particular callsign
1178
+	 *
1179
+	 * @return Array the spotter information
1180
+	 *
1181
+	 */
1182
+	public function getDateArchiveMarineDataByIdent($ident,$date)
1183
+	{
1184 1184
 	$Marine = new Marine($this->db);
1185 1185
 	date_default_timezone_set('UTC');
1186 1186
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1188,16 +1188,16 @@  discard block
 block discarded – undo
1188 1188
 	$date = date('c',$date);
1189 1189
 	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1190 1190
 	return $spotter_array;
1191
-    }
1192
-
1193
-    /**
1194
-    * Gets all the spotter information based on the airport
1195
-    *
1196
-    * @return Array the spotter information
1197
-    *
1198
-    */
1199
-    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1200
-    {
1191
+	}
1192
+
1193
+	/**
1194
+	 * Gets all the spotter information based on the airport
1195
+	 *
1196
+	 * @return Array the spotter information
1197
+	 *
1198
+	 */
1199
+	public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1200
+	{
1201 1201
 	global $global_query;
1202 1202
 	$Marine = new Marine();
1203 1203
 	date_default_timezone_set('UTC');
@@ -1208,35 +1208,35 @@  discard block
 block discarded – undo
1208 1208
 	
1209 1209
 	if ($airport != "")
1210 1210
 	{
1211
-	    if (!is_string($airport))
1212
-	    {
1211
+		if (!is_string($airport))
1212
+		{
1213 1213
 		return false;
1214
-	    } else {
1214
+		} else {
1215 1215
 		$additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))";
1216 1216
 		$query_values = array(':airport' => $airport);
1217
-	    }
1217
+		}
1218 1218
 	}
1219 1219
 	
1220 1220
 	if ($limit != "")
1221 1221
 	{
1222
-	    $limit_array = explode(",", $limit);
1222
+		$limit_array = explode(",", $limit);
1223 1223
 	    
1224
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1224
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1225
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1226 1226
 	    
1227
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228
-	    {
1227
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1228
+		{
1229 1229
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1230 1230
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1231
-	    }
1231
+		}
1232 1232
 	}
1233 1233
 	
1234 1234
 	if ($sort != "")
1235 1235
 	{
1236
-	    $search_orderby_array = $Marine->getOrderBy();
1237
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1236
+		$search_orderby_array = $Marine->getOrderBy();
1237
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1238 1238
 	} else {
1239
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1239
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1240 1240
 	}
1241 1241
 
1242 1242
 	$query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1244,6 +1244,6 @@  discard block
 block discarded – undo
1244 1244
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1245 1245
 
1246 1246
 	return $spotter_array;
1247
-    }
1247
+	}
1248 1248
 }
1249 1249
 ?>
1250 1250
\ No newline at end of file
Please login to merge, or discard this patch.
require/class.Image.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
 	}
13 13
 
14 14
 	/**
15
-	* Gets the images based on the aircraft registration
16
-	*
17
-	* @return Array the images list
18
-	*
19
-	*/
15
+	 * Gets the images based on the aircraft registration
16
+	 *
17
+	 * @return Array the images list
18
+	 *
19
+	 */
20 20
 	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
21 21
 	{
22 22
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	}
38 38
 
39 39
 	/**
40
-	* Gets the images based on the ship name
41
-	*
42
-	* @return Array the images list
43
-	*
44
-	*/
40
+	 * Gets the images based on the ship name
41
+	 *
42
+	 * @return Array the images list
43
+	 *
44
+	 */
45 45
 	public function getMarineImage($mmsi,$imo = '',$name = '')
46 46
 	{
47 47
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 	}
69 69
 
70 70
 	/**
71
-	* Gets the image copyright based on the Exif data
72
-	*
73
-	* @return String image copyright
74
-	*
75
-	*/
71
+	 * Gets the image copyright based on the Exif data
72
+	 *
73
+	 * @return String image copyright
74
+	 *
75
+	 */
76 76
 	public function getExifCopyright($url) {
77 77
 		$exif = exif_read_data($url);
78 78
 		$copyright = '';
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 	}
88 88
 
89 89
 	/**
90
-	* Adds the images based on the aircraft registration
91
-	*
92
-	* @return String either success or error
93
-	*
94
-	*/
90
+	 * Adds the images based on the aircraft registration
91
+	 *
92
+	 * @return String either success or error
93
+	 *
94
+	 */
95 95
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
96 96
 	{
97 97
 		global $globalDebug,$globalAircraftImageFetch;
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 	}
120 120
 
121 121
 	/**
122
-	* Adds the images based on the marine name
123
-	*
124
-	* @return String either success or error
125
-	*
126
-	*/
122
+	 * Adds the images based on the marine name
123
+	 *
124
+	 * @return String either success or error
125
+	 *
126
+	 */
127 127
 	public function addMarineImage($mmsi,$imo = '',$name = '')
128 128
 	{
129 129
 		global $globalDebug,$globalMarineImageFetch;
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
 	}
161 161
 
162 162
 	/**
163
-	* Gets the aircraft image
164
-	*
165
-	* @param String $aircraft_registration the registration of the aircraft
166
-	* @return Array the aircraft thumbnail, orignal url and copyright
167
-	*
168
-	*/
163
+	 * Gets the aircraft image
164
+	 *
165
+	 * @param String $aircraft_registration the registration of the aircraft
166
+	 * @return Array the aircraft thumbnail, orignal url and copyright
167
+	 *
168
+	 */
169 169
 	public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '')
170 170
 	{
171 171
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
 	}
210 210
 
211 211
 	/**
212
-	* Gets the vessel image
213
-	*
214
-	* @param String $mmsi the vessel mmsi
215
-	* @param String $imo the vessel imo
216
-	* @param String $name the vessel name
217
-	* @return Array the aircraft thumbnail, orignal url and copyright
218
-	*
219
-	*/
212
+	 * Gets the vessel image
213
+	 *
214
+	 * @param String $mmsi the vessel mmsi
215
+	 * @param String $imo the vessel imo
216
+	 * @param String $name the vessel name
217
+	 * @return Array the aircraft thumbnail, orignal url and copyright
218
+	 *
219
+	 */
220 220
 	public function findMarineImage($mmsi,$imo = '',$name = '')
221 221
 	{
222 222
 		global $globalMarineImageSources;
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
 	}
251 251
 
252 252
 	/**
253
-	* Gets the aircraft image from Planespotters
254
-	*
255
-	* @param String $aircraft_registration the registration of the aircraft
256
-	* @param String $aircraft_name type of the aircraft
257
-	* @return Array the aircraft thumbnail, orignal url and copyright
258
-	*
259
-	*/
253
+	 * Gets the aircraft image from Planespotters
254
+	 *
255
+	 * @param String $aircraft_registration the registration of the aircraft
256
+	 * @param String $aircraft_name type of the aircraft
257
+	 * @return Array the aircraft thumbnail, orignal url and copyright
258
+	 *
259
+	 */
260 260
 	public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') {
261 261
 		$Common = new Common();
262 262
 		// If aircraft registration is only number, also check with aircraft model
@@ -283,13 +283,13 @@  discard block
 block discarded – undo
283 283
 	}
284 284
 
285 285
 	/**
286
-	* Gets the aircraft image from Deviantart
287
-	*
288
-	* @param String $registration the registration of the aircraft
289
-	* @param String $name type of the aircraft
290
-	* @return Array the aircraft thumbnail, orignal url and copyright
291
-	*
292
-	*/
286
+	 * Gets the aircraft image from Deviantart
287
+	 *
288
+	 * @param String $registration the registration of the aircraft
289
+	 * @param String $name type of the aircraft
290
+	 * @return Array the aircraft thumbnail, orignal url and copyright
291
+	 *
292
+	 */
293 293
 	public function fromDeviantart($type,$registration, $name='') {
294 294
 		$Common = new Common();
295 295
 		if ($type == 'aircraft') {
@@ -321,13 +321,13 @@  discard block
 block discarded – undo
321 321
 	}
322 322
 
323 323
 	/**
324
-	* Gets the aircraft image from JetPhotos
325
-	*
326
-	* @param String $aircraft_registration the registration of the aircraft
327
-	* @param String $aircraft_name type of the aircraft
328
-	* @return Array the aircraft thumbnail, orignal url and copyright
329
-	*
330
-	*/
324
+	 * Gets the aircraft image from JetPhotos
325
+	 *
326
+	 * @param String $aircraft_registration the registration of the aircraft
327
+	 * @param String $aircraft_name type of the aircraft
328
+	 * @return Array the aircraft thumbnail, orignal url and copyright
329
+	 *
330
+	 */
331 331
 	public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
332 332
 		$Common = new Common();
333 333
 		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
@@ -363,13 +363,13 @@  discard block
 block discarded – undo
363 363
 	}
364 364
 
365 365
 	/**
366
-	* Gets the aircraft image from PlanePictures
367
-	*
368
-	* @param String $aircraft_registration the registration of the aircraft
369
-	* @param String $aircraft_name type of the aircraft
370
-	* @return Array the aircraft thumbnail, orignal url and copyright
371
-	*
372
-	*/
366
+	 * Gets the aircraft image from PlanePictures
367
+	 *
368
+	 * @param String $aircraft_registration the registration of the aircraft
369
+	 * @param String $aircraft_name type of the aircraft
370
+	 * @return Array the aircraft thumbnail, orignal url and copyright
371
+	 *
372
+	 */
373 373
 	public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
374 374
 		$Common = new Common();
375 375
 		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
@@ -397,13 +397,13 @@  discard block
 block discarded – undo
397 397
 	}
398 398
 
399 399
 	/**
400
-	* Gets the aircraft image from Flickr
401
-	*
402
-	* @param String $registration the registration of the aircraft
403
-	* @param String $name type of the aircraft
404
-	* @return Array the aircraft thumbnail, orignal url and copyright
405
-	*
406
-	*/
400
+	 * Gets the aircraft image from Flickr
401
+	 *
402
+	 * @param String $registration the registration of the aircraft
403
+	 * @param String $name type of the aircraft
404
+	 * @return Array the aircraft thumbnail, orignal url and copyright
405
+	 *
406
+	 */
407 407
 	public function fromFlickr($type,$registration,$name='') {
408 408
 		$Common = new Common();
409 409
 		if ($type == 'aircraft') {
@@ -446,13 +446,13 @@  discard block
 block discarded – undo
446 446
 	}
447 447
 
448 448
 	/**
449
-	* Gets the aircraft image from Bing
450
-	*
451
-	* @param String $aircraft_registration the registration of the aircraft
452
-	* @param String $aircraft_name type of the aircraft
453
-	* @return Array the aircraft thumbnail, orignal url and copyright
454
-	*
455
-	*/
449
+	 * Gets the aircraft image from Bing
450
+	 *
451
+	 * @param String $aircraft_registration the registration of the aircraft
452
+	 * @param String $aircraft_name type of the aircraft
453
+	 * @return Array the aircraft thumbnail, orignal url and copyright
454
+	 *
455
+	 */
456 456
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
457 457
 		global $globalImageBingKey;
458 458
 		$Common = new Common();
@@ -478,13 +478,13 @@  discard block
 block discarded – undo
478 478
 	}
479 479
 
480 480
 	/**
481
-	* Gets the aircraft image from airport-data
482
-	*
483
-	* @param String $aircraft_registration the registration of the aircraft
484
-	* @param String $aircraft_name type of the aircraft
485
-	* @return Array the aircraft thumbnail, orignal url and copyright
486
-	*
487
-	*/
481
+	 * Gets the aircraft image from airport-data
482
+	 *
483
+	 * @param String $aircraft_registration the registration of the aircraft
484
+	 * @param String $aircraft_name type of the aircraft
485
+	 * @return Array the aircraft thumbnail, orignal url and copyright
486
+	 *
487
+	 */
488 488
 	public function fromAirportData($type,$aircraft_registration,$aircraft_name='') {
489 489
 		$Common = new Common();
490 490
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
@@ -503,13 +503,13 @@  discard block
 block discarded – undo
503 503
 	}
504 504
 
505 505
 	/**
506
-	* Gets image from WikiMedia
507
-	*
508
-	* @param String $registration the registration of the aircraft/mmsi
509
-	* @param String $name name
510
-	* @return Array the aircraft thumbnail, orignal url and copyright
511
-	*
512
-	*/
506
+	 * Gets image from WikiMedia
507
+	 *
508
+	 * @param String $registration the registration of the aircraft/mmsi
509
+	 * @param String $name name
510
+	 * @return Array the aircraft thumbnail, orignal url and copyright
511
+	 *
512
+	 */
513 513
 	public function fromWikimedia($type,$registration,$name='') {
514 514
 		$Common = new Common();
515 515
 		if ($type == 'aircraft') {
@@ -564,13 +564,13 @@  discard block
 block discarded – undo
564 564
 	}
565 565
 
566 566
 	/**
567
-	* Gets the aircraft image from custom url
568
-	*
569
-	* @param String $registration the registration of the aircraft
570
-	* @param String $name type of the aircraft
571
-	* @return Array the aircraft thumbnail, orignal url and copyright
572
-	*
573
-	*/
567
+	 * Gets the aircraft image from custom url
568
+	 *
569
+	 * @param String $registration the registration of the aircraft
570
+	 * @param String $name type of the aircraft
571
+	 * @return Array the aircraft thumbnail, orignal url and copyright
572
+	 *
573
+	 */
574 574
 	public function fromCustomSource($type,$registration,$name='') {
575 575
 		global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug;
576 576
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Indentation   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 
14 14
 	/**
15
-	* Get SQL query part for filter used
16
-	* @param Array $filter the filter
17
-	* @return Array the SQL part
18
-	*/
15
+	 * Get SQL query part for filter used
16
+	 * @param Array $filter the filter
17
+	 * @return Array the SQL part
18
+	 */
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 	}
87 87
 
88 88
 	/**
89
-	* Gets all the spotter information based on the latest data entry
90
-	*
91
-	* @return Array the spotter information
92
-	*
93
-	*/
89
+	 * Gets all the spotter information based on the latest data entry
90
+	 *
91
+	 * @return Array the spotter information
92
+	 *
93
+	 */
94 94
 	public function getLiveMarineData($limit = '', $sort = '', $filter = array())
95 95
 	{
96 96
 		global $globalDBdriver, $globalLiveInterval;
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 	}
133 133
 
134 134
 	/**
135
-	* Gets Minimal Live Spotter data
136
-	*
137
-	* @return Array the spotter information
138
-	*
139
-	*/
135
+	 * Gets Minimal Live Spotter data
136
+	 *
137
+	 * @return Array the spotter information
138
+	 *
139
+	 */
140 140
 	public function getMinLiveMarineData($filter = array())
141 141
 	{
142 142
 		global $globalDBdriver, $globalLiveInterval;
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
 	}
167 167
 
168 168
 	/**
169
-	* Gets Minimal Live Spotter data since xx seconds
170
-	*
171
-	* @return Array the spotter information
172
-	*
173
-	*/
169
+	 * Gets Minimal Live Spotter data since xx seconds
170
+	 *
171
+	 * @return Array the spotter information
172
+	 *
173
+	 */
174 174
 	public function getMinLastLiveMarineData($filter = array())
175 175
 	{
176 176
 		global $globalDBdriver, $globalLiveInterval;
@@ -183,13 +183,13 @@  discard block
 block discarded – undo
183 183
 			$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 
184 184
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
185 185
 			ORDER BY marine_live.fammarine_id, marine_live.date";
186
-                } else {
186
+				} else {
187 187
 			$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 
188 188
 			FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
189 189
 			ORDER BY marine_live.fammarine_id, marine_live.date";
190 190
 		}
191 191
 
192
-    		try {
192
+			try {
193 193
 			$sth = $this->db->prepare($query);
194 194
 			$sth->execute();
195 195
 		} catch(PDOException $e) {
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 	}
202 202
 
203 203
 	/**
204
-	* Gets number of latest data entry
205
-	*
206
-	* @return String number of entry
207
-	*
208
-	*/
204
+	 * Gets number of latest data entry
205
+	 *
206
+	 * @return String number of entry
207
+	 *
208
+	 */
209 209
 	public function getLiveMarineCount($filter = array())
210 210
 	{
211 211
 		global $globalDBdriver, $globalLiveInterval;
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 	}
231 231
 
232 232
 	/**
233
-	* Gets all the spotter information based on the latest data entry and coord
234
-	*
235
-	* @return Array the spotter information
236
-	*
237
-	*/
233
+	 * Gets all the spotter information based on the latest data entry and coord
234
+	 *
235
+	 * @return Array the spotter information
236
+	 *
237
+	 */
238 238
 	public function getLiveMarineDatabyCoord($coord, $filter = array())
239 239
 	{
240 240
 		global $globalDBdriver, $globalLiveInterval;
@@ -258,11 +258,11 @@  discard block
 block discarded – undo
258 258
 	}
259 259
 
260 260
 	/**
261
-	* Gets all the spotter information based on the latest data entry and coord
262
-	*
263
-	* @return Array the spotter information
264
-	*
265
-	*/
261
+	 * Gets all the spotter information based on the latest data entry and coord
262
+	 *
263
+	 * @return Array the spotter information
264
+	 *
265
+	 */
266 266
 	public function getMinLiveMarineDatabyCoord($coord, $filter = array())
267 267
 	{
268 268
 		global $globalDBdriver, $globalLiveInterval;
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
 	}
291 291
 
292 292
 	/**
293
-	* Gets all the spotter information based on a user's latitude and longitude
294
-	*
295
-	* @return Array the spotter information
296
-	*
297
-	*/
293
+	 * Gets all the spotter information based on a user's latitude and longitude
294
+	 *
295
+	 * @return Array the spotter information
296
+	 *
297
+	 */
298 298
 	public function getLatestMarineForLayar($lat, $lng, $radius, $interval)
299 299
 	{
300 300
 		$Marine = new Marine($this->db);
@@ -307,134 +307,134 @@  discard block
 block discarded – undo
307 307
 		if ($lng != '')
308 308
 		{
309 309
 			if (!is_numeric($lng))
310
-                        {
311
-                                return false;
312
-                        }
313
-                }
314
-
315
-                if ($radius != '')
316
-                {
317
-                        if (!is_numeric($radius))
318
-                        {
319
-                                return false;
320
-                        }
321
-                }
310
+						{
311
+								return false;
312
+						}
313
+				}
314
+
315
+				if ($radius != '')
316
+				{
317
+						if (!is_numeric($radius))
318
+						{
319
+								return false;
320
+						}
321
+				}
322 322
 		$additional_query = '';
323 323
 		if ($interval != '')
324
-                {
325
-                        if (!is_string($interval))
326
-                        {
327
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
328
-			        return false;
329
-                        } else {
330
-                if ($interval == '1m')
331
-                {
332
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
333
-                } else if ($interval == '15m'){
334
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
335
-                } 
336
-            }
337
-                } else {
338
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
339
-        }
340
-
341
-                $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 
324
+				{
325
+						if (!is_string($interval))
326
+						{
327
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
328
+					return false;
329
+						} else {
330
+				if ($interval == '1m')
331
+				{
332
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
333
+				} else if ($interval == '15m'){
334
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
335
+				} 
336
+			}
337
+				} else {
338
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
339
+		}
340
+
341
+				$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 
342 342
                    WHERE marine_live.latitude <> '' 
343 343
                                    AND marine_live.longitude <> '' 
344 344
                    ".$additional_query."
345 345
                    HAVING distance < :radius  
346 346
                                    ORDER BY distance";
347 347
 
348
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
348
+				$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
349 349
 
350
-                return $spotter_array;
351
-        }
350
+				return $spotter_array;
351
+		}
352 352
 
353 353
     
354
-        /**
355
-	* Gets all the spotter information based on a particular callsign
356
-	*
357
-	* @return Array the spotter information
358
-	*
359
-	*/
354
+		/**
355
+		 * Gets all the spotter information based on a particular callsign
356
+		 *
357
+		 * @return Array the spotter information
358
+		 *
359
+		 */
360 360
 	public function getLastLiveMarineDataByIdent($ident)
361 361
 	{
362 362
 		$Marine = new Marine($this->db);
363 363
 		date_default_timezone_set('UTC');
364 364
 
365 365
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
366
-                $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';
366
+				$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';
367 367
 
368 368
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
369 369
 
370 370
 		return $spotter_array;
371 371
 	}
372 372
 
373
-        /**
374
-	* Gets all the spotter information based on a particular callsign
375
-	*
376
-	* @return Array the spotter information
377
-	*
378
-	*/
373
+		/**
374
+		 * Gets all the spotter information based on a particular callsign
375
+		 *
376
+		 * @return Array the spotter information
377
+		 *
378
+		 */
379 379
 	public function getDateLiveMarineDataByIdent($ident,$date)
380 380
 	{
381 381
 		$Marine = new Marine($this->db);
382 382
 		date_default_timezone_set('UTC');
383 383
 
384 384
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
385
-                $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';
385
+				$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';
386 386
 
387
-                $date = date('c',$date);
387
+				$date = date('c',$date);
388 388
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
389 389
 
390 390
 		return $spotter_array;
391 391
 	}
392 392
 
393
-        /**
394
-	* Gets last spotter information based on a particular callsign
395
-	*
396
-	* @return Array the spotter information
397
-	*
398
-	*/
393
+		/**
394
+		 * Gets last spotter information based on a particular callsign
395
+		 *
396
+		 * @return Array the spotter information
397
+		 *
398
+		 */
399 399
 	public function getLastLiveMarineDataById($id)
400 400
 	{
401 401
 		$Marine = new Marine($this->db);
402 402
 		date_default_timezone_set('UTC');
403 403
 
404 404
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
405
-                $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';
405
+				$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';
406 406
 
407 407
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
408 408
 
409 409
 		return $spotter_array;
410 410
 	}
411 411
 
412
-        /**
413
-	* Gets last spotter information based on a particular callsign
414
-	*
415
-	* @return Array the spotter information
416
-	*
417
-	*/
412
+		/**
413
+		 * Gets last spotter information based on a particular callsign
414
+		 *
415
+		 * @return Array the spotter information
416
+		 *
417
+		 */
418 418
 	public function getDateLiveMarineDataById($id,$date)
419 419
 	{
420 420
 		$Marine = new Marine($this->db);
421 421
 		date_default_timezone_set('UTC');
422 422
 
423 423
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
424
-                $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';
425
-                $date = date('c',$date);
424
+				$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';
425
+				$date = date('c',$date);
426 426
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
427 427
 
428 428
 		return $spotter_array;
429 429
 	}
430 430
 
431 431
 
432
-        /**
433
-	* Gets all the spotter information based on a particular id
434
-	*
435
-	* @return Array the spotter information
436
-	*
437
-	*/
432
+		/**
433
+		 * Gets all the spotter information based on a particular id
434
+		 *
435
+		 * @return Array the spotter information
436
+		 *
437
+		 */
438 438
 	public function getAllLiveMarineDataById($id,$liveinterval = false)
439 439
 	{
440 440
 		global $globalDBdriver, $globalLiveInterval;
@@ -462,18 +462,18 @@  discard block
 block discarded – undo
462 462
 		return $spotter_array;
463 463
 	}
464 464
 
465
-        /**
466
-	* Gets all the spotter information based on a particular ident
467
-	*
468
-	* @return Array the spotter information
469
-	*
470
-	*/
465
+		/**
466
+		 * Gets all the spotter information based on a particular ident
467
+		 *
468
+		 * @return Array the spotter information
469
+		 *
470
+		 */
471 471
 	public function getAllLiveMarineDataByIdent($ident)
472 472
 	{
473 473
 		date_default_timezone_set('UTC');
474 474
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
475 475
 		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
476
-    		try {
476
+			try {
477 477
 			
478 478
 			$sth = $this->db->prepare($query);
479 479
 			$sth->execute(array(':ident' => $ident));
@@ -487,23 +487,23 @@  discard block
 block discarded – undo
487 487
 
488 488
 
489 489
 	/**
490
-	* Deletes all info in the table
491
-	*
492
-	* @return String success or false
493
-	*
494
-	*/
490
+	 * Deletes all info in the table
491
+	 *
492
+	 * @return String success or false
493
+	 *
494
+	 */
495 495
 	public function deleteLiveMarineData()
496 496
 	{
497 497
 		global $globalDBdriver;
498 498
 		if ($globalDBdriver == 'mysql') {
499 499
 			//$query  = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date";
500 500
 			$query  = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date';
501
-            		//$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)";
501
+					//$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)";
502 502
 		} else {
503 503
 			$query  = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date";
504 504
 		}
505 505
         
506
-    		try {
506
+			try {
507 507
 			
508 508
 			$sth = $this->db->prepare($query);
509 509
 			$sth->execute();
@@ -515,18 +515,18 @@  discard block
 block discarded – undo
515 515
 	}
516 516
 
517 517
 	/**
518
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
519
-	*
520
-	* @return String success or false
521
-	*
522
-	*/
518
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
519
+	 *
520
+	 * @return String success or false
521
+	 *
522
+	 */
523 523
 	public function deleteLiveMarineDataNotUpdated()
524 524
 	{
525 525
 		global $globalDBdriver, $globalDebug;
526 526
 		if ($globalDBdriver == 'mysql') {
527 527
 			//$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';
528
-    			$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";
529
-    			try {
528
+				$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";
529
+				try {
530 530
 				
531 531
 				$sth = $this->db->prepare($query);
532 532
 				$sth->execute();
@@ -534,8 +534,8 @@  discard block
 block discarded – undo
534 534
 				return "error";
535 535
 			}
536 536
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
537
-                        $i = 0;
538
-                        $j =0;
537
+						$i = 0;
538
+						$j =0;
539 539
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
540 540
 			foreach($all as $row)
541 541
 			{
@@ -543,20 +543,20 @@  discard block
 block discarded – undo
543 543
 				$j++;
544 544
 				if ($j == 30) {
545 545
 					if ($globalDebug) echo ".";
546
-				    	try {
546
+						try {
547 547
 						
548 548
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
549 549
 						$sth->execute();
550 550
 					} catch(PDOException $e) {
551 551
 						return "error";
552 552
 					}
553
-                                	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
554
-                                	$j = 0;
553
+									$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
554
+									$j = 0;
555 555
 				}
556 556
 				$query_delete .= "'".$row['fammarine_id']."',";
557 557
 			}
558 558
 			if ($i > 0) {
559
-    				try {
559
+					try {
560 560
 					
561 561
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
562 562
 					$sth->execute();
@@ -567,9 +567,9 @@  discard block
 block discarded – undo
567 567
 			return "success";
568 568
 		} elseif ($globalDBdriver == 'pgsql') {
569 569
 			//$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";
570
-    			//$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";
571
-    			$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)";
572
-    			try {
570
+				//$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";
571
+				$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)";
572
+				try {
573 573
 				
574 574
 				$sth = $this->db->prepare($query);
575 575
 				$sth->execute();
@@ -613,17 +613,17 @@  discard block
 block discarded – undo
613 613
 	}
614 614
 
615 615
 	/**
616
-	* Deletes all info in the table for an ident
617
-	*
618
-	* @return String success or false
619
-	*
620
-	*/
616
+	 * Deletes all info in the table for an ident
617
+	 *
618
+	 * @return String success or false
619
+	 *
620
+	 */
621 621
 	public function deleteLiveMarineDataByIdent($ident)
622 622
 	{
623 623
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
624 624
 		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
625 625
         
626
-    		try {
626
+			try {
627 627
 			
628 628
 			$sth = $this->db->prepare($query);
629 629
 			$sth->execute(array(':ident' => $ident));
@@ -635,17 +635,17 @@  discard block
 block discarded – undo
635 635
 	}
636 636
 
637 637
 	/**
638
-	* Deletes all info in the table for an id
639
-	*
640
-	* @return String success or false
641
-	*
642
-	*/
638
+	 * Deletes all info in the table for an id
639
+	 *
640
+	 * @return String success or false
641
+	 *
642
+	 */
643 643
 	public function deleteLiveMarineDataById($id)
644 644
 	{
645 645
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
646 646
 		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
647 647
         
648
-    		try {
648
+			try {
649 649
 			
650 650
 			$sth = $this->db->prepare($query);
651 651
 			$sth->execute(array(':id' => $id));
@@ -658,11 +658,11 @@  discard block
 block discarded – undo
658 658
 
659 659
 
660 660
 	/**
661
-	* Gets the aircraft ident within the last hour
662
-	*
663
-	* @return String the ident
664
-	*
665
-	*/
661
+	 * Gets the aircraft ident within the last hour
662
+	 *
663
+	 * @return String the ident
664
+	 *
665
+	 */
666 666
 	public function getIdentFromLastHour($ident)
667 667
 	{
668 668
 		global $globalDBdriver, $globalTimezone;
@@ -688,14 +688,14 @@  discard block
 block discarded – undo
688 688
 			$ident_result = $row['ident'];
689 689
 		}
690 690
 		return $ident_result;
691
-        }
691
+		}
692 692
 
693 693
 	/**
694
-	* Check recent aircraft
695
-	*
696
-	* @return String the ident
697
-	*
698
-	*/
694
+	 * Check recent aircraft
695
+	 *
696
+	 * @return String the ident
697
+	 *
698
+	 */
699 699
 	public function checkIdentRecent($ident)
700 700
 	{
701 701
 		global $globalDBdriver, $globalTimezone;
@@ -721,14 +721,14 @@  discard block
 block discarded – undo
721 721
 			$ident_result = $row['fammarine_id'];
722 722
 		}
723 723
 		return $ident_result;
724
-        }
724
+		}
725 725
 
726 726
 	/**
727
-	* Check recent aircraft by id
728
-	*
729
-	* @return String the ident
730
-	*
731
-	*/
727
+	 * Check recent aircraft by id
728
+	 *
729
+	 * @return String the ident
730
+	 *
731
+	 */
732 732
 	public function checkIdRecent($id)
733 733
 	{
734 734
 		global $globalDBdriver, $globalTimezone;
@@ -754,14 +754,14 @@  discard block
 block discarded – undo
754 754
 			$ident_result = $row['fammarine_id'];
755 755
 		}
756 756
 		return $ident_result;
757
-        }
757
+		}
758 758
 
759 759
 	/**
760
-	* Check recent aircraft by mmsi
761
-	*
762
-	* @return String the ident
763
-	*
764
-	*/
760
+	 * Check recent aircraft by mmsi
761
+	 *
762
+	 * @return String the ident
763
+	 *
764
+	 */
765 765
 	public function checkMMSIRecent($mmsi)
766 766
 	{
767 767
 		global $globalDBdriver, $globalTimezone;
@@ -787,19 +787,19 @@  discard block
 block discarded – undo
787 787
 			$ident_result = $row['fammarine_id'];
788 788
 		}
789 789
 		return $ident_result;
790
-        }
790
+		}
791 791
 
792 792
 	/**
793
-	* Adds a new spotter data
794
-	*
795
-	* @param String $fammarine_id the ID from flightaware
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
-	*
802
-	*/
793
+	 * Adds a new spotter data
794
+	 *
795
+	 * @param String $fammarine_id the ID from flightaware
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
+	 *
802
+	 */
803 803
 	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 = '')
804 804
 	{
805 805
 		global $globalURL, $globalArchive, $globalDebug;
@@ -870,10 +870,10 @@  discard block
 block discarded – undo
870 870
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
871 871
 		
872 872
 
873
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
874
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
875
-            	if ($arrival_date == '') $arrival_date = NULL;
876
-            	$query = '';
873
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
874
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
875
+				if ($arrival_date == '') $arrival_date = NULL;
876
+				$query = '';
877 877
 		if ($globalArchive) {
878 878
 			if ($globalDebug) echo '-- Delete previous data -- ';
879 879
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
Please login to merge, or discard this patch.
require/class.TrackerArchive.php 1 patch
Indentation   +603 added lines, -603 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 	}
10 10
 
11 11
 	/**
12
-	* Get SQL query part for filter used
13
-	* @param Array $filter the filter
14
-	* @return Array the SQL part
15
-	*/
12
+	 * Get SQL query part for filter used
13
+	 * @param Array $filter the filter
14
+	 * @return Array the SQL part
15
+	 */
16 16
 	public function getFilter($filter = array(),$where = false,$and = false) {
17 17
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 		$filters = array();
@@ -108,44 +108,44 @@  discard block
 block discarded – undo
108 108
 	}
109 109
 
110 110
 
111
-        /**
112
-        * Gets all the spotter information based on a particular callsign
113
-        *
114
-        * @return Array the spotter information
115
-        *
116
-        */
117
-        public function getLastArchiveTrackerDataByIdent($ident)
118
-        {
111
+		/**
112
+		 * Gets all the spotter information based on a particular callsign
113
+		 *
114
+		 * @return Array the spotter information
115
+		 *
116
+		 */
117
+		public function getLastArchiveTrackerDataByIdent($ident)
118
+		{
119 119
 		$Tracker = new Tracker($this->db);
120
-                date_default_timezone_set('UTC');
120
+				date_default_timezone_set('UTC');
121 121
 
122
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
123
-                //$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";
124
-                $query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
122
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
123
+				//$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";
124
+				$query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
125 125
 
126
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
126
+				$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
127 127
 
128
-                return $spotter_array;
129
-        }
128
+				return $spotter_array;
129
+		}
130 130
 
131 131
 
132
-        /**
133
-        * Gets last the spotter information based on a particular id
134
-        *
135
-        * @return Array the spotter information
136
-        *
137
-        */
138
-        public function getLastArchiveTrackerDataById($id)
139
-        {
140
-    		$Tracker = new Tracker($this->db);
141
-                date_default_timezone_set('UTC');
142
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
143
-                //$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
144
-                //$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";
145
-                $query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
132
+		/**
133
+		 * Gets last the spotter information based on a particular id
134
+		 *
135
+		 * @return Array the spotter information
136
+		 *
137
+		 */
138
+		public function getLastArchiveTrackerDataById($id)
139
+		{
140
+			$Tracker = new Tracker($this->db);
141
+				date_default_timezone_set('UTC');
142
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
143
+				//$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
144
+				//$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";
145
+				$query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
146 146
 
147 147
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
148
-                  /*
148
+				  /*
149 149
                 try {
150 150
                         $Connection = new Connection();
151 151
                         $sth = Connection->$db->prepare($query);
@@ -155,232 +155,232 @@  discard block
 block discarded – undo
155 155
                 }
156 156
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
157 157
                 */
158
-                $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
159
-
160
-                return $spotter_array;
161
-        }
162
-
163
-        /**
164
-        * Gets all the spotter information based on a particular id
165
-        *
166
-        * @return Array the spotter information
167
-        *
168
-        */
169
-        public function getAllArchiveTrackerDataById($id)
158
+				$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
159
+
160
+				return $spotter_array;
161
+		}
162
+
163
+		/**
164
+		 * Gets all the spotter information based on a particular id
165
+		 *
166
+		 * @return Array the spotter information
167
+		 *
168
+		 */
169
+		public function getAllArchiveTrackerDataById($id)
170 170
 	{
171
-                date_default_timezone_set('UTC');
172
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
173
-                $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
171
+				date_default_timezone_set('UTC');
172
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
173
+				$query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
174 174
 
175 175
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
176 176
 
177
-                try {
178
-                        $sth = $this->db->prepare($query);
179
-                        $sth->execute(array(':id' => $id));
180
-                } catch(PDOException $e) {
181
-                        echo $e->getMessage();
182
-                        die;
183
-                }
184
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
185
-
186
-                return $spotter_array;
187
-        }
188
-
189
-        /**
190
-        * Gets coordinate & time spotter information based on a particular id
191
-        *
192
-        * @return Array the spotter information
193
-        *
194
-        */
195
-        public function getCoordArchiveTrackerDataById($id)
196
-        {
197
-                date_default_timezone_set('UTC');
198
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
199
-                $query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
177
+				try {
178
+						$sth = $this->db->prepare($query);
179
+						$sth->execute(array(':id' => $id));
180
+				} catch(PDOException $e) {
181
+						echo $e->getMessage();
182
+						die;
183
+				}
184
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
185
+
186
+				return $spotter_array;
187
+		}
188
+
189
+		/**
190
+		 * Gets coordinate & time spotter information based on a particular id
191
+		 *
192
+		 * @return Array the spotter information
193
+		 *
194
+		 */
195
+		public function getCoordArchiveTrackerDataById($id)
196
+		{
197
+				date_default_timezone_set('UTC');
198
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
199
+				$query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
200 200
 
201 201
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
202 202
 
203
-                try {
204
-                        $sth = $this->db->prepare($query);
205
-                        $sth->execute(array(':id' => $id));
206
-                } catch(PDOException $e) {
207
-                        echo $e->getMessage();
208
-                        die;
209
-                }
210
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
203
+				try {
204
+						$sth = $this->db->prepare($query);
205
+						$sth->execute(array(':id' => $id));
206
+				} catch(PDOException $e) {
207
+						echo $e->getMessage();
208
+						die;
209
+				}
210
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
211 211
 
212
-                return $spotter_array;
213
-        }
212
+				return $spotter_array;
213
+		}
214 214
 
215 215
 
216
-        /**
217
-        * Gets altitude information based on a particular callsign
218
-        *
219
-        * @return Array the spotter information
220
-        *
221
-        */
222
-        public function getAltitudeArchiveTrackerDataByIdent($ident)
223
-        {
216
+		/**
217
+		 * Gets altitude information based on a particular callsign
218
+		 *
219
+		 * @return Array the spotter information
220
+		 *
221
+		 */
222
+		public function getAltitudeArchiveTrackerDataByIdent($ident)
223
+		{
224 224
 
225
-                date_default_timezone_set('UTC');
225
+				date_default_timezone_set('UTC');
226 226
 
227
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
228
-                $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
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
228
+				$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";
229 229
 
230
-                try {
231
-                        $sth = $this->db->prepare($query);
232
-                        $sth->execute(array(':ident' => $ident));
233
-                } catch(PDOException $e) {
234
-                        echo $e->getMessage();
235
-                        die;
236
-                }
237
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
230
+				try {
231
+						$sth = $this->db->prepare($query);
232
+						$sth->execute(array(':ident' => $ident));
233
+				} catch(PDOException $e) {
234
+						echo $e->getMessage();
235
+						die;
236
+				}
237
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
238 238
 
239
-                return $spotter_array;
240
-        }
239
+				return $spotter_array;
240
+		}
241 241
 
242
-        /**
243
-        * Gets altitude information based on a particular id
244
-        *
245
-        * @return Array the spotter information
246
-        *
247
-        */
248
-        public function getAltitudeArchiveTrackerDataById($id)
249
-        {
242
+		/**
243
+		 * Gets altitude information based on a particular id
244
+		 *
245
+		 * @return Array the spotter information
246
+		 *
247
+		 */
248
+		public function getAltitudeArchiveTrackerDataById($id)
249
+		{
250 250
 
251
-                date_default_timezone_set('UTC');
251
+				date_default_timezone_set('UTC');
252 252
 
253
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
254
-                $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
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
254
+				$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";
255 255
 
256
-                try {
257
-                        $sth = $this->db->prepare($query);
258
-                        $sth->execute(array(':id' => $id));
259
-                } catch(PDOException $e) {
260
-                        echo $e->getMessage();
261
-                        die;
262
-                }
263
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
256
+				try {
257
+						$sth = $this->db->prepare($query);
258
+						$sth->execute(array(':id' => $id));
259
+				} catch(PDOException $e) {
260
+						echo $e->getMessage();
261
+						die;
262
+				}
263
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
264 264
 
265
-                return $spotter_array;
266
-        }
265
+				return $spotter_array;
266
+		}
267 267
 
268
-        /**
269
-        * Gets altitude & speed information based on a particular id
270
-        *
271
-        * @return Array the spotter information
272
-        *
273
-        */
274
-        public function getAltitudeSpeedArchiveTrackerDataById($id)
275
-        {
268
+		/**
269
+		 * Gets altitude & speed information based on a particular id
270
+		 *
271
+		 * @return Array the spotter information
272
+		 *
273
+		 */
274
+		public function getAltitudeSpeedArchiveTrackerDataById($id)
275
+		{
276 276
 
277
-                date_default_timezone_set('UTC');
277
+				date_default_timezone_set('UTC');
278 278
 
279
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
280
-                $query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
279
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
280
+				$query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
281 281
 
282
-                try {
283
-                        $sth = $this->db->prepare($query);
284
-                        $sth->execute(array(':id' => $id));
285
-                } catch(PDOException $e) {
286
-                        echo $e->getMessage();
287
-                        die;
288
-                }
289
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
282
+				try {
283
+						$sth = $this->db->prepare($query);
284
+						$sth->execute(array(':id' => $id));
285
+				} catch(PDOException $e) {
286
+						echo $e->getMessage();
287
+						die;
288
+				}
289
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
290 290
 
291
-                return $spotter_array;
292
-        }
291
+				return $spotter_array;
292
+		}
293 293
 
294 294
 
295
-        /**
296
-        * Gets altitude information based on a particular callsign
297
-        *
298
-        * @return Array the spotter information
299
-        *
300
-        */
301
-        public function getLastAltitudeArchiveTrackerDataByIdent($ident)
302
-        {
295
+		/**
296
+		 * Gets altitude information based on a particular callsign
297
+		 *
298
+		 * @return Array the spotter information
299
+		 *
300
+		 */
301
+		public function getLastAltitudeArchiveTrackerDataByIdent($ident)
302
+		{
303 303
 
304
-                date_default_timezone_set('UTC');
304
+				date_default_timezone_set('UTC');
305 305
 
306
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
307
-                $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
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
307
+				$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";
308 308
 //                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident";
309 309
 
310
-                try {
311
-                        $sth = $this->db->prepare($query);
312
-                        $sth->execute(array(':ident' => $ident));
313
-                } catch(PDOException $e) {
314
-                        echo $e->getMessage();
315
-                        die;
316
-                }
317
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
310
+				try {
311
+						$sth = $this->db->prepare($query);
312
+						$sth->execute(array(':ident' => $ident));
313
+				} catch(PDOException $e) {
314
+						echo $e->getMessage();
315
+						die;
316
+				}
317
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
318 318
 
319
-                return $spotter_array;
320
-        }
319
+				return $spotter_array;
320
+		}
321 321
 
322 322
 
323 323
 
324
-       /**
325
-        * Gets all the archive spotter information
326
-        *
327
-        * @return Array the spotter information
328
-        *
329
-        */
330
-        public function getTrackerArchiveData($ident,$famtrackid,$date)
331
-        {
332
-    		$Tracker = new Tracker($this->db);
333
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
334
-                $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";
324
+	   /**
325
+	    * Gets all the archive spotter information
326
+	    *
327
+	    * @return Array the spotter information
328
+	    *
329
+	    */
330
+		public function getTrackerArchiveData($ident,$famtrackid,$date)
331
+		{
332
+			$Tracker = new Tracker($this->db);
333
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
334
+				$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";
335 335
 
336
-                $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
336
+				$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
337 337
 
338
-                return $spotter_array;
339
-        }
338
+				return $spotter_array;
339
+		}
340 340
         
341
-        public function deleteTrackerArchiveTrackData()
342
-        {
341
+		public function deleteTrackerArchiveTrackData()
342
+		{
343 343
 		global $globalArchiveKeepTrackMonths;
344
-                date_default_timezone_set('UTC');
344
+				date_default_timezone_set('UTC');
345 345
 		$query = 'DELETE FROM tracker_archive WHERE tracker_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
346
-                try {
347
-                        $sth = $this->db->prepare($query);
348
-                        $sth->execute();
349
-                } catch(PDOException $e) {
350
-                        echo $e->getMessage();
351
-                        die;
352
-                }
346
+				try {
347
+						$sth = $this->db->prepare($query);
348
+						$sth->execute();
349
+				} catch(PDOException $e) {
350
+						echo $e->getMessage();
351
+						die;
352
+				}
353 353
 	}
354 354
 
355 355
 	/**
356
-        * Gets Minimal Live Tracker data
357
-        *
358
-        * @return Array the spotter information
359
-        *
360
-        */
361
-        public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
362
-        {
363
-                global $globalDBdriver, $globalLiveInterval;
364
-                date_default_timezone_set('UTC');
365
-
366
-                $filter_query = '';
367
-                if (isset($filter['source']) && !empty($filter['source'])) {
368
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
369
-                }
370
-                // Use spotter_output also ?
371
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
372
-                        $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 ";
373
-                }
374
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
375
-                        $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 ";
376
-                }
377
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
378
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
379
-                }
356
+	 * Gets Minimal Live Tracker data
357
+	 *
358
+	 * @return Array the spotter information
359
+	 *
360
+	 */
361
+		public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
362
+		{
363
+				global $globalDBdriver, $globalLiveInterval;
364
+				date_default_timezone_set('UTC');
365
+
366
+				$filter_query = '';
367
+				if (isset($filter['source']) && !empty($filter['source'])) {
368
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
369
+				}
370
+				// Use spotter_output also ?
371
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
372
+						$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 ";
373
+				}
374
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
375
+						$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 ";
376
+				}
377
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
378
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
379
+				}
380 380
 
381
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
382
-                if ($globalDBdriver == 'mysql') {
383
-                        /*
381
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
382
+				if ($globalDBdriver == 'mysql') {
383
+						/*
384 384
                         $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 
385 385
                     		    FROM tracker_archive 
386 386
                     		    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';
@@ -399,56 +399,56 @@  discard block
 block discarded – undo
399 399
 				    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
400 400
 				    WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
401 401
                         	    '.$filter_query.' ORDER BY famtrackid';
402
-                } else {
403
-                        //$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';
404
-                        $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 
402
+				} else {
403
+						//$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';
404
+						$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 
405 405
                         	    FROM tracker_archive 
406 406
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
407 407
                         	    WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".'
408 408
                         	    '.$filter_query.' ORDER BY famtrackid';
409
-                }
410
-                //echo $query;
411
-                try {
412
-                        $sth = $this->db->prepare($query);
413
-                        $sth->execute();
414
-                } catch(PDOException $e) {
415
-                        echo $e->getMessage();
416
-                        die;
417
-                }
418
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
409
+				}
410
+				//echo $query;
411
+				try {
412
+						$sth = $this->db->prepare($query);
413
+						$sth->execute();
414
+				} catch(PDOException $e) {
415
+						echo $e->getMessage();
416
+						die;
417
+				}
418
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
419 419
 
420
-                return $spotter_array;
421
-        }
420
+				return $spotter_array;
421
+		}
422 422
 
423 423
 	/**
424
-        * Gets Minimal Live Tracker data
425
-        *
426
-        * @return Array the spotter information
427
-        *
428
-        */
429
-        public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
430
-        {
431
-                global $globalDBdriver, $globalLiveInterval;
432
-                date_default_timezone_set('UTC');
433
-
434
-                $filter_query = '';
435
-                if (isset($filter['source']) && !empty($filter['source'])) {
436
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
437
-                }
438
-                // Should use spotter_output also ?
439
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
440
-                        $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 ";
441
-                }
442
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
443
-                        $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 ";
444
-                }
445
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
446
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
447
-                }
424
+	 * Gets Minimal Live Tracker data
425
+	 *
426
+	 * @return Array the spotter information
427
+	 *
428
+	 */
429
+		public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
430
+		{
431
+				global $globalDBdriver, $globalLiveInterval;
432
+				date_default_timezone_set('UTC');
433
+
434
+				$filter_query = '';
435
+				if (isset($filter['source']) && !empty($filter['source'])) {
436
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
437
+				}
438
+				// Should use spotter_output also ?
439
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
440
+						$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 ";
441
+				}
442
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
443
+						$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 ";
444
+				}
445
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
446
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
447
+				}
448 448
 
449
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
450
-                if ($globalDBdriver == 'mysql') {
451
-                        /*
449
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
450
+				if ($globalDBdriver == 'mysql') {
451
+						/*
452 452
                         $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 
453 453
                     		    FROM tracker_archive 
454 454
                     		    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';
@@ -459,95 +459,95 @@  discard block
 block discarded – undo
459 459
 				    WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
460 460
                         	    '.$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';
461 461
 
462
-                } else {
463
-                        //$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';
464
-                       /*
462
+				} else {
463
+						//$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';
464
+					   /*
465 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
466 466
                         	    FROM tracker_archive_output 
467 467
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
468 468
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
469 469
                         	    '.$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';
470 470
                         */
471
-                        $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
471
+						$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
472 472
                         	    FROM tracker_archive_output 
473 473
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
474 474
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
475 475
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
476 476
 //                        	    .' 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';
477 477
                         	    
478
-                }
479
-                //echo $query;
480
-                try {
481
-                        $sth = $this->db->prepare($query);
482
-                        $sth->execute();
483
-                } catch(PDOException $e) {
484
-                        echo $e->getMessage();
485
-                        die;
486
-                }
487
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
478
+				}
479
+				//echo $query;
480
+				try {
481
+						$sth = $this->db->prepare($query);
482
+						$sth->execute();
483
+				} catch(PDOException $e) {
484
+						echo $e->getMessage();
485
+						die;
486
+				}
487
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
488 488
 
489
-                return $spotter_array;
490
-        }
489
+				return $spotter_array;
490
+		}
491 491
 
492 492
 	 /**
493
-        * Gets count Live Tracker data
494
-        *
495
-        * @return Array the spotter information
496
-        *
497
-        */
498
-        public function getLiveTrackerCount($begindate,$enddate,$filter = array())
499
-        {
500
-                global $globalDBdriver, $globalLiveInterval;
501
-                date_default_timezone_set('UTC');
502
-
503
-                $filter_query = '';
504
-                if (isset($filter['source']) && !empty($filter['source'])) {
505
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
506
-                }
507
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
508
-                        $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 ";
509
-                }
510
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
511
-                        $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
512
-                }
513
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
514
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
515
-                }
493
+	  * Gets count Live Tracker data
494
+	  *
495
+	  * @return Array the spotter information
496
+	  *
497
+	  */
498
+		public function getLiveTrackerCount($begindate,$enddate,$filter = array())
499
+		{
500
+				global $globalDBdriver, $globalLiveInterval;
501
+				date_default_timezone_set('UTC');
516 502
 
517
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
518
-                if ($globalDBdriver == 'mysql') {
503
+				$filter_query = '';
504
+				if (isset($filter['source']) && !empty($filter['source'])) {
505
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
506
+				}
507
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
508
+						$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 ";
509
+				}
510
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
511
+						$filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
512
+				}
513
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
514
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
515
+				}
516
+
517
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
518
+				if ($globalDBdriver == 'mysql') {
519 519
 			$query = 'SELECT COUNT(DISTINCT famtrackid) as nb 
520 520
 			FROM tracker_archive l 
521 521
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
522
-                } else {
522
+				} else {
523 523
 			$query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
524
-                }
525
-                //echo $query;
526
-                try {
527
-                        $sth = $this->db->prepare($query);
528
-                        $sth->execute();
529
-                } catch(PDOException $e) {
530
-                        echo $e->getMessage();
531
-                        die;
532
-                }
524
+				}
525
+				//echo $query;
526
+				try {
527
+						$sth = $this->db->prepare($query);
528
+						$sth->execute();
529
+				} catch(PDOException $e) {
530
+						echo $e->getMessage();
531
+						die;
532
+				}
533 533
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
534 534
 		$sth->closeCursor();
535
-                return $result['nb'];
535
+				return $result['nb'];
536 536
 
537
-        }
537
+		}
538 538
 
539 539
 
540 540
 
541 541
 	// tracker_archive_output
542 542
 	
543
-    /**
544
-    * Gets all the spotter information
545
-    *
546
-    * @return Array the spotter information
547
-    *
548
-    */
549
-    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())
550
-    {
543
+	/**
544
+	 * Gets all the spotter information
545
+	 *
546
+	 * @return Array the spotter information
547
+	 *
548
+	 */
549
+	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())
550
+	{
551 551
 	global $globalTimezone, $globalDBdriver;
552 552
 	require_once(dirname(__FILE__).'/class.Translation.php');
553 553
 	$Translation = new Translation();
@@ -561,159 +561,159 @@  discard block
 block discarded – undo
561 561
 	$filter_query = $this->getFilter($filters);
562 562
 	if ($q != "")
563 563
 	{
564
-	    if (!is_string($q))
565
-	    {
564
+		if (!is_string($q))
565
+		{
566 566
 		return false;
567
-	    } else {
567
+		} else {
568 568
 	        
569 569
 		$q_array = explode(" ", $q);
570 570
 		
571 571
 		foreach ($q_array as $q_item){
572
-		    $additional_query .= " AND (";
573
-		    $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
574
-		    $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
575
-		    $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR ";
576
-		    $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
577
-		    $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR ";
578
-		    $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR ";
579
-		    $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR ";
580
-		    $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
581
-		    $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR ";
582
-		    $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR ";
583
-		    $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR ";
584
-		    $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
585
-		    $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
586
-		    $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
587
-		    $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
588
-		    $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR ";
589
-		    $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR ";
590
-		    $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR ";
591
-		    $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
592
-		    $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
593
-		    $translate = $Translation->ident2icao($q_item);
594
-		    if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
595
-		    $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
596
-		    $additional_query .= ")";
572
+			$additional_query .= " AND (";
573
+			$additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
574
+			$additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
575
+			$additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR ";
576
+			$additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
577
+			$additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR ";
578
+			$additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR ";
579
+			$additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR ";
580
+			$additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
581
+			$additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR ";
582
+			$additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR ";
583
+			$additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR ";
584
+			$additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
585
+			$additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
586
+			$additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
587
+			$additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
588
+			$additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR ";
589
+			$additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR ";
590
+			$additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR ";
591
+			$additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
592
+			$additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
593
+			$translate = $Translation->ident2icao($q_item);
594
+			if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
595
+			$additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
596
+			$additional_query .= ")";
597
+		}
597 598
 		}
598
-	    }
599 599
 	}
600 600
 	
601 601
 	if ($registration != "")
602 602
 	{
603
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
604
-	    if (!is_string($registration))
605
-	    {
603
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
604
+		if (!is_string($registration))
605
+		{
606 606
 		return false;
607
-	    } else {
607
+		} else {
608 608
 		$additional_query .= " AND (tracker_archive_output.registration = '".$registration."')";
609
-	    }
609
+		}
610 610
 	}
611 611
 	
612 612
 	if ($aircraft_icao != "")
613 613
 	{
614
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
615
-	    if (!is_string($aircraft_icao))
616
-	    {
614
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
615
+		if (!is_string($aircraft_icao))
616
+		{
617 617
 		return false;
618
-	    } else {
618
+		} else {
619 619
 		$additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')";
620
-	    }
620
+		}
621 621
 	}
622 622
 	
623 623
 	if ($aircraft_manufacturer != "")
624 624
 	{
625
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
626
-	    if (!is_string($aircraft_manufacturer))
627
-	    {
625
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
626
+		if (!is_string($aircraft_manufacturer))
627
+		{
628 628
 		return false;
629
-	    } else {
629
+		} else {
630 630
 		$additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
631
-	    }
631
+		}
632 632
 	}
633 633
 	
634 634
 	if ($highlights == "true")
635 635
 	{
636
-	    if (!is_string($highlights))
637
-	    {
636
+		if (!is_string($highlights))
637
+		{
638 638
 		return false;
639
-	    } else {
639
+		} else {
640 640
 		$additional_query .= " AND (tracker_archive_output.highlight <> '')";
641
-	    }
641
+		}
642 642
 	}
643 643
 	
644 644
 	if ($airline_icao != "")
645 645
 	{
646
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
647
-	    if (!is_string($airline_icao))
648
-	    {
646
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
647
+		if (!is_string($airline_icao))
648
+		{
649 649
 		return false;
650
-	    } else {
650
+		} else {
651 651
 		$additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')";
652
-	    }
652
+		}
653 653
 	}
654 654
 	
655 655
 	if ($airline_country != "")
656 656
 	{
657
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
658
-	    if (!is_string($airline_country))
659
-	    {
657
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
658
+		if (!is_string($airline_country))
659
+		{
660 660
 		return false;
661
-	    } else {
661
+		} else {
662 662
 		$additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')";
663
-	    }
663
+		}
664 664
 	}
665 665
 	
666 666
 	if ($airline_type != "")
667 667
 	{
668
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
669
-	    if (!is_string($airline_type))
670
-	    {
668
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
669
+		if (!is_string($airline_type))
670
+		{
671 671
 		return false;
672
-	    } else {
672
+		} else {
673 673
 		if ($airline_type == "passenger")
674 674
 		{
675
-		    $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')";
675
+			$additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')";
676 676
 		}
677 677
 		if ($airline_type == "cargo")
678 678
 		{
679
-		    $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')";
679
+			$additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')";
680 680
 		}
681 681
 		if ($airline_type == "military")
682 682
 		{
683
-		    $additional_query .= " AND (tracker_archive_output.airline_type = 'military')";
683
+			$additional_query .= " AND (tracker_archive_output.airline_type = 'military')";
684
+		}
684 685
 		}
685
-	    }
686 686
 	}
687 687
 	
688 688
 	if ($airport != "")
689 689
 	{
690
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
691
-	    if (!is_string($airport))
692
-	    {
690
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
691
+		if (!is_string($airport))
692
+		{
693 693
 		return false;
694
-	    } else {
694
+		} else {
695 695
 		$additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))";
696
-	    }
696
+		}
697 697
 	}
698 698
 	
699 699
 	if ($airport_country != "")
700 700
 	{
701
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
702
-	    if (!is_string($airport_country))
703
-	    {
701
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
702
+		if (!is_string($airport_country))
703
+		{
704 704
 		return false;
705
-	    } else {
705
+		} else {
706 706
 		$additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))";
707
-	    }
707
+		}
708 708
 	}
709 709
     
710 710
 	if ($callsign != "")
711 711
 	{
712
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
713
-	    if (!is_string($callsign))
714
-	    {
712
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
713
+		if (!is_string($callsign))
714
+		{
715 715
 		return false;
716
-	    } else {
716
+		} else {
717 717
 		$translate = $Translation->ident2icao($callsign);
718 718
 		if ($translate != $callsign) {
719 719
 			$additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)";
@@ -721,99 +721,99 @@  discard block
 block discarded – undo
721 721
 		} else {
722 722
 			$additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')";
723 723
 		}
724
-	    }
724
+		}
725 725
 	}
726 726
 
727 727
 	if ($owner != "")
728 728
 	{
729
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
730
-	    if (!is_string($owner))
731
-	    {
729
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
730
+		if (!is_string($owner))
731
+		{
732 732
 		return false;
733
-	    } else {
733
+		} else {
734 734
 		$additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')";
735
-	    }
735
+		}
736 736
 	}
737 737
 
738 738
 	if ($pilot_name != "")
739 739
 	{
740
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
741
-	    if (!is_string($pilot_name))
742
-	    {
740
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
741
+		if (!is_string($pilot_name))
742
+		{
743 743
 		return false;
744
-	    } else {
744
+		} else {
745 745
 		$additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')";
746
-	    }
746
+		}
747 747
 	}
748 748
 	
749 749
 	if ($pilot_id != "")
750 750
 	{
751
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
752
-	    if (!is_string($pilot_id))
753
-	    {
751
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
752
+		if (!is_string($pilot_id))
753
+		{
754 754
 		return false;
755
-	    } else {
755
+		} else {
756 756
 		$additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')";
757
-	    }
757
+		}
758 758
 	}
759 759
 	
760 760
 	if ($departure_airport_route != "")
761 761
 	{
762
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
763
-	    if (!is_string($departure_airport_route))
764
-	    {
762
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
763
+		if (!is_string($departure_airport_route))
764
+		{
765 765
 		return false;
766
-	    } else {
766
+		} else {
767 767
 		$additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')";
768
-	    }
768
+		}
769 769
 	}
770 770
 	
771 771
 	if ($arrival_airport_route != "")
772 772
 	{
773
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
774
-	    if (!is_string($arrival_airport_route))
775
-	    {
773
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
774
+		if (!is_string($arrival_airport_route))
775
+		{
776 776
 		return false;
777
-	    } else {
777
+		} else {
778 778
 		$additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
779
-	    }
779
+		}
780 780
 	}
781 781
 	
782 782
 	if ($altitude != "")
783 783
 	{
784
-	    $altitude_array = explode(",", $altitude);
784
+		$altitude_array = explode(",", $altitude);
785 785
 	    
786
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
787
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
786
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
787
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788 788
 	    
789 789
 
790
-	    if ($altitude_array[1] != "")
791
-	    {                
790
+		if ($altitude_array[1] != "")
791
+		{                
792 792
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
793 793
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
794 794
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
795
-	    } else {
795
+		} else {
796 796
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
797 797
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
798
-	    }
798
+		}
799 799
 	}
800 800
 	
801 801
 	if ($date_posted != "")
802 802
 	{
803
-	    $date_array = explode(",", $date_posted);
803
+		$date_array = explode(",", $date_posted);
804 804
 	    
805
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
806
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
805
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
806
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
807 807
 	    
808
-	    if ($globalTimezone != '') {
808
+		if ($globalTimezone != '') {
809 809
 		date_default_timezone_set($globalTimezone);
810 810
 		$datetime = new DateTime();
811 811
 		$offset = $datetime->format('P');
812
-	    } else $offset = '+00:00';
812
+		} else $offset = '+00:00';
813 813
 
814 814
 
815
-	    if ($date_array[1] != "")
816
-	    {                
815
+		if ($date_array[1] != "")
816
+		{                
817 817
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
818 818
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
819 819
 		if ($globalDBdriver == 'mysql') {
@@ -821,28 +821,28 @@  discard block
 block discarded – undo
821 821
 		} else {
822 822
 			$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) ";
823 823
 		}
824
-	    } else {
824
+		} else {
825 825
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
826
-                if ($globalDBdriver == 'mysql') {
826
+				if ($globalDBdriver == 'mysql') {
827 827
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
828 828
 		} else {
829 829
 			$additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
830 830
 		}
831
-	    }
831
+		}
832 832
 	}
833 833
 	
834 834
 	if ($limit != "")
835 835
 	{
836
-	    $limit_array = explode(",", $limit);
836
+		$limit_array = explode(",", $limit);
837 837
 	    
838
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
839
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
838
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
839
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
840 840
 	    
841
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
842
-	    {
841
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
842
+		{
843 843
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
844 844
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
845
-	    }
845
+		}
846 846
 	}
847 847
 	
848 848
 
@@ -873,33 +873,33 @@  discard block
 block discarded – undo
873 873
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query);
874 874
 
875 875
 	return $spotter_array;
876
-    }
876
+	}
877 877
 
878
-    public function deleteTrackerArchiveData()
879
-    {
878
+	public function deleteTrackerArchiveData()
879
+	{
880 880
 		global $globalArchiveKeepMonths, $globalDBdriver;
881
-                date_default_timezone_set('UTC');
882
-                if ($globalDBdriver == 'mysql') {
881
+				date_default_timezone_set('UTC');
882
+				if ($globalDBdriver == 'mysql') {
883 883
 			$query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
884 884
 		} else {
885 885
 			$query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
886 886
 		}
887
-                try {
888
-                        $sth = $this->db->prepare($query);
889
-                        $sth->execute();
890
-                } catch(PDOException $e) {
891
-                        return "error";
892
-                }
887
+				try {
888
+						$sth = $this->db->prepare($query);
889
+						$sth->execute();
890
+				} catch(PDOException $e) {
891
+						return "error";
892
+				}
893 893
 	}
894 894
 
895
-    /**
896
-    * Gets all the spotter information based on the callsign
897
-    *
898
-    * @return Array the spotter information
899
-    *
900
-    */
901
-    public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '')
902
-    {
895
+	/**
896
+	 * Gets all the spotter information based on the callsign
897
+	 *
898
+	 * @return Array the spotter information
899
+	 *
900
+	 */
901
+	public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '')
902
+	{
903 903
 	$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
904 904
 	
905 905
 	date_default_timezone_set('UTC');
@@ -911,35 +911,35 @@  discard block
 block discarded – undo
911 911
 	
912 912
 	if ($ident != "")
913 913
 	{
914
-	    if (!is_string($ident))
915
-	    {
914
+		if (!is_string($ident))
915
+		{
916 916
 		return false;
917
-	    } else {
917
+		} else {
918 918
 		$additional_query = " AND (tracker_archive_output.ident = :ident)";
919 919
 		$query_values = array(':ident' => $ident);
920
-	    }
920
+		}
921 921
 	}
922 922
 	
923 923
 	if ($limit != "")
924 924
 	{
925
-	    $limit_array = explode(",", $limit);
925
+		$limit_array = explode(",", $limit);
926 926
 	    
927
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
928
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
927
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
928
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
929 929
 	    
930
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
931
-	    {
930
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
931
+		{
932 932
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
933 933
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
934
-	    }
934
+		}
935 935
 	}
936 936
 
937 937
 	if ($sort != "")
938 938
 	{
939
-	    $search_orderby_array = $Tracker->getOrderBy();
940
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
939
+		$search_orderby_array = $Tracker->getOrderBy();
940
+		$orderby_query = $search_orderby_array[$sort]['sql'];
941 941
 	} else {
942
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
942
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
943 943
 	}
944 944
 
945 945
 	$query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -947,17 +947,17 @@  discard block
 block discarded – undo
947 947
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
948 948
 
949 949
 	return $spotter_array;
950
-    }
950
+	}
951 951
 
952 952
 
953
-    /**
954
-    * Gets all the spotter information based on the owner
955
-    *
956
-    * @return Array the spotter information
957
-    *
958
-    */
959
-    public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
960
-    {
953
+	/**
954
+	 * Gets all the spotter information based on the owner
955
+	 *
956
+	 * @return Array the spotter information
957
+	 *
958
+	 */
959
+	public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
960
+	{
961 961
 	$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
962 962
 	
963 963
 	date_default_timezone_set('UTC');
@@ -970,35 +970,35 @@  discard block
 block discarded – undo
970 970
 	
971 971
 	if ($owner != "")
972 972
 	{
973
-	    if (!is_string($owner))
974
-	    {
973
+		if (!is_string($owner))
974
+		{
975 975
 		return false;
976
-	    } else {
976
+		} else {
977 977
 		$additional_query = " AND (tracker_archive_output.owner_name = :owner)";
978 978
 		$query_values = array(':owner' => $owner);
979
-	    }
979
+		}
980 980
 	}
981 981
 	
982 982
 	if ($limit != "")
983 983
 	{
984
-	    $limit_array = explode(",", $limit);
984
+		$limit_array = explode(",", $limit);
985 985
 	    
986
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
987
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
986
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
987
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988 988
 	    
989
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
990
-	    {
989
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
990
+		{
991 991
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
992 992
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
993
-	    }
993
+		}
994 994
 	}
995 995
 
996 996
 	if ($sort != "")
997 997
 	{
998
-	    $search_orderby_array = $Tracker->getOrderBy();
999
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
998
+		$search_orderby_array = $Tracker->getOrderBy();
999
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1000 1000
 	} else {
1001
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1001
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1002 1002
 	}
1003 1003
 
1004 1004
 	$query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1006,16 +1006,16 @@  discard block
 block discarded – undo
1006 1006
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1007 1007
 
1008 1008
 	return $spotter_array;
1009
-    }
1010
-
1011
-    /**
1012
-    * Gets all the spotter information based on the pilot
1013
-    *
1014
-    * @return Array the spotter information
1015
-    *
1016
-    */
1017
-    public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1018
-    {
1009
+	}
1010
+
1011
+	/**
1012
+	 * Gets all the spotter information based on the pilot
1013
+	 *
1014
+	 * @return Array the spotter information
1015
+	 *
1016
+	 */
1017
+	public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1018
+	{
1019 1019
 	$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
1020 1020
 	
1021 1021
 	date_default_timezone_set('UTC');
@@ -1034,24 +1034,24 @@  discard block
 block discarded – undo
1034 1034
 	
1035 1035
 	if ($limit != "")
1036 1036
 	{
1037
-	    $limit_array = explode(",", $limit);
1037
+		$limit_array = explode(",", $limit);
1038 1038
 	    
1039
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1040
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1039
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1040
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1041 1041
 	    
1042
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1043
-	    {
1042
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1043
+		{
1044 1044
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1045 1045
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1046
-	    }
1046
+		}
1047 1047
 	}
1048 1048
 
1049 1049
 	if ($sort != "")
1050 1050
 	{
1051
-	    $search_orderby_array = $Tracker->getOrderBy();
1052
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1051
+		$search_orderby_array = $Tracker->getOrderBy();
1052
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1053 1053
 	} else {
1054
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1054
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1055 1055
 	}
1056 1056
 
1057 1057
 	$query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1059,16 +1059,16 @@  discard block
 block discarded – undo
1059 1059
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1060 1060
 
1061 1061
 	return $spotter_array;
1062
-    }
1063
-
1064
-    /**
1065
-    * Gets all number of flight over countries
1066
-    *
1067
-    * @return Array the airline country list
1068
-    *
1069
-    */
1070
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1071
-    {
1062
+	}
1063
+
1064
+	/**
1065
+	 * Gets all number of flight over countries
1066
+	 *
1067
+	 * @return Array the airline country list
1068
+	 *
1069
+	 */
1070
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1071
+	{
1072 1072
 	global $globalDBdriver;
1073 1073
 	/*
1074 1074
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1078,14 +1078,14 @@  discard block
 block discarded – undo
1078 1078
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1079 1079
 		    FROM countries c, tracker_archive s
1080 1080
 		    WHERE c.iso2 = s.over_country ";
1081
-                if ($olderthanmonths > 0) {
1082
-            		if ($globalDBdriver == 'mysql') {
1081
+				if ($olderthanmonths > 0) {
1082
+					if ($globalDBdriver == 'mysql') {
1083 1083
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1084 1084
 			} else {
1085 1085
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1086 1086
 			}
1087 1087
 		}
1088
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1088
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1089 1089
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1090 1090
 	if ($limit) $query .= " LIMIT 0,10";
1091 1091
       
@@ -1098,23 +1098,23 @@  discard block
 block discarded – undo
1098 1098
         
1099 1099
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1100 1100
 	{
1101
-	    $temp_array['flight_count'] = $row['nb'];
1102
-	    $temp_array['flight_country'] = $row['name'];
1103
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1104
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1105
-	    $flight_array[] = $temp_array;
1101
+		$temp_array['flight_count'] = $row['nb'];
1102
+		$temp_array['flight_country'] = $row['name'];
1103
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1104
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1105
+		$flight_array[] = $temp_array;
1106 1106
 	}
1107 1107
 	return $flight_array;
1108
-    }
1109
-
1110
-    /**
1111
-    * Gets all number of flight over countries
1112
-    *
1113
-    * @return Array the airline country list
1114
-    *
1115
-    */
1116
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1117
-    {
1108
+	}
1109
+
1110
+	/**
1111
+	 * Gets all number of flight over countries
1112
+	 *
1113
+	 * @return Array the airline country list
1114
+	 *
1115
+	 */
1116
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1117
+	{
1118 1118
 	global $globalDBdriver;
1119 1119
 	/*
1120 1120
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1124,14 +1124,14 @@  discard block
 block discarded – undo
1124 1124
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1125 1125
 		    FROM countries c, tracker_archive s, spotter_output o
1126 1126
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.famtrackid = s.famtrackid ";
1127
-                if ($olderthanmonths > 0) {
1128
-            		if ($globalDBdriver == 'mysql') {
1127
+				if ($olderthanmonths > 0) {
1128
+					if ($globalDBdriver == 'mysql') {
1129 1129
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1130 1130
 			} else {
1131 1131
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1132 1132
 			}
1133 1133
 		}
1134
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1134
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1135 1135
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1136 1136
 	if ($limit) $query .= " LIMIT 0,10";
1137 1137
       
@@ -1144,24 +1144,24 @@  discard block
 block discarded – undo
1144 1144
         
1145 1145
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1146 1146
 	{
1147
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1148
-	    $temp_array['flight_count'] = $row['nb'];
1149
-	    $temp_array['flight_country'] = $row['name'];
1150
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1151
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1152
-	    $flight_array[] = $temp_array;
1147
+		$temp_array['airline_icao'] = $row['airline_icao'];
1148
+		$temp_array['flight_count'] = $row['nb'];
1149
+		$temp_array['flight_country'] = $row['name'];
1150
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1151
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1152
+		$flight_array[] = $temp_array;
1153 1153
 	}
1154 1154
 	return $flight_array;
1155
-    }
1156
-
1157
-    /**
1158
-    * Gets last spotter information based on a particular callsign
1159
-    *
1160
-    * @return Array the spotter information
1161
-    *
1162
-    */
1163
-    public function getDateArchiveTrackerDataById($id,$date)
1164
-    {
1155
+	}
1156
+
1157
+	/**
1158
+	 * Gets last spotter information based on a particular callsign
1159
+	 *
1160
+	 * @return Array the spotter information
1161
+	 *
1162
+	 */
1163
+	public function getDateArchiveTrackerDataById($id,$date)
1164
+	{
1165 1165
 	$Tracker = new Tracker($this->db);
1166 1166
 	date_default_timezone_set('UTC');
1167 1167
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1169,16 +1169,16 @@  discard block
 block discarded – undo
1169 1169
 	$date = date('c',$date);
1170 1170
 	$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date));
1171 1171
 	return $spotter_array;
1172
-    }
1173
-
1174
-    /**
1175
-    * Gets all the spotter information based on a particular callsign
1176
-    *
1177
-    * @return Array the spotter information
1178
-    *
1179
-    */
1180
-    public function getDateArchiveTrackerDataByIdent($ident,$date)
1181
-    {
1172
+	}
1173
+
1174
+	/**
1175
+	 * Gets all the spotter information based on a particular callsign
1176
+	 *
1177
+	 * @return Array the spotter information
1178
+	 *
1179
+	 */
1180
+	public function getDateArchiveTrackerDataByIdent($ident,$date)
1181
+	{
1182 1182
 	$Tracker = new Tracker($this->db);
1183 1183
 	date_default_timezone_set('UTC');
1184 1184
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1186,16 +1186,16 @@  discard block
 block discarded – undo
1186 1186
 	$date = date('c',$date);
1187 1187
 	$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1188 1188
 	return $spotter_array;
1189
-    }
1190
-
1191
-    /**
1192
-    * Gets all the spotter information based on the airport
1193
-    *
1194
-    * @return Array the spotter information
1195
-    *
1196
-    */
1197
-    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1198
-    {
1189
+	}
1190
+
1191
+	/**
1192
+	 * Gets all the spotter information based on the airport
1193
+	 *
1194
+	 * @return Array the spotter information
1195
+	 *
1196
+	 */
1197
+	public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1198
+	{
1199 1199
 	global $global_query;
1200 1200
 	$Tracker = new Tracker();
1201 1201
 	date_default_timezone_set('UTC');
@@ -1206,35 +1206,35 @@  discard block
 block discarded – undo
1206 1206
 	
1207 1207
 	if ($airport != "")
1208 1208
 	{
1209
-	    if (!is_string($airport))
1210
-	    {
1209
+		if (!is_string($airport))
1210
+		{
1211 1211
 		return false;
1212
-	    } else {
1212
+		} else {
1213 1213
 		$additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))";
1214 1214
 		$query_values = array(':airport' => $airport);
1215
-	    }
1215
+		}
1216 1216
 	}
1217 1217
 	
1218 1218
 	if ($limit != "")
1219 1219
 	{
1220
-	    $limit_array = explode(",", $limit);
1220
+		$limit_array = explode(",", $limit);
1221 1221
 	    
1222
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1223
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1222
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1223
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1224 1224
 	    
1225
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1226
-	    {
1225
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1226
+		{
1227 1227
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1228 1228
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1229
-	    }
1229
+		}
1230 1230
 	}
1231 1231
 	
1232 1232
 	if ($sort != "")
1233 1233
 	{
1234
-	    $search_orderby_array = $Tracker->getOrderBy();
1235
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1234
+		$search_orderby_array = $Tracker->getOrderBy();
1235
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1236 1236
 	} else {
1237
-	    $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1237
+		$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1238 1238
 	}
1239 1239
 
1240 1240
 	$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;
@@ -1242,6 +1242,6 @@  discard block
 block discarded – undo
1242 1242
 	$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1243 1243
 
1244 1244
 	return $spotter_array;
1245
-    }
1245
+	}
1246 1246
 }
1247 1247
 ?>
1248 1248
\ No newline at end of file
Please login to merge, or discard this patch.
require/class.SBS.php 1 patch
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class SBS {
3
-    static $latlon = array();
3
+	static $latlon = array();
4 4
     
5
-    public function parse($buffer) {
5
+	public function parse($buffer) {
6 6
 	// Not yet finished, no CRC checks
7 7
 	//echo $buffer."\n";
8 8
 	$data = array();
@@ -13,47 +13,47 @@  discard block
 block discarded – undo
13 13
 	$bin = gmp_strval( gmp_init($hex,16), 2);
14 14
 	//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
15 15
 	if (strlen($hex) == 28) {
16
-	    $df = intval(substr($bin,0,5),2);
17
-	    //$ca = intval(substr($bin,5,3),2);
18
-	    // Only support DF17 for now
19
-	    //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) {
20
-	    if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) {
16
+		$df = intval(substr($bin,0,5),2);
17
+		//$ca = intval(substr($bin,5,3),2);
18
+		// Only support DF17 for now
19
+		//if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) {
20
+		if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) {
21 21
 		$icao = substr($hex,2,6);
22 22
 		$data['hex'] = $icao;
23 23
 		$tc = intval(substr($bin,32,5),2);
24 24
 		if ($tc >= 1 && $tc <= 4) {
25
-		    //callsign
26
-		    $csbin = substr($bin,40,56);
27
-		    $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######');
28
-		    $cs = '';
29
-		    $cs .= $charset[intval(substr($csbin,0,6),2)];
30
-		    $cs .= $charset[intval(substr($csbin,6,6),2)];
31
-		    $cs .= $charset[intval(substr($csbin,12,6),2)];
32
-		    $cs .= $charset[intval(substr($csbin,18,6),2)];
33
-		    $cs .= $charset[intval(substr($csbin,24,6),2)];
34
-		    $cs .= $charset[intval(substr($csbin,30,6),2)];
35
-		    $cs .= $charset[intval(substr($csbin,36,6),2)];
36
-		    $cs .= $charset[intval(substr($csbin,42,6),2)];
37
-		    $cs = str_replace('_','',$cs);
38
-		    $cs = str_replace('#','',$cs);
39
-		    $callsign = $cs;
40
-		    $data['ident'] = $callsign;
25
+			//callsign
26
+			$csbin = substr($bin,40,56);
27
+			$charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######');
28
+			$cs = '';
29
+			$cs .= $charset[intval(substr($csbin,0,6),2)];
30
+			$cs .= $charset[intval(substr($csbin,6,6),2)];
31
+			$cs .= $charset[intval(substr($csbin,12,6),2)];
32
+			$cs .= $charset[intval(substr($csbin,18,6),2)];
33
+			$cs .= $charset[intval(substr($csbin,24,6),2)];
34
+			$cs .= $charset[intval(substr($csbin,30,6),2)];
35
+			$cs .= $charset[intval(substr($csbin,36,6),2)];
36
+			$cs .= $charset[intval(substr($csbin,42,6),2)];
37
+			$cs = str_replace('_','',$cs);
38
+			$cs = str_replace('#','',$cs);
39
+			$callsign = $cs;
40
+			$data['ident'] = $callsign;
41 41
 		} elseif ($tc >= 9 && $tc <= 18) {
42
-		    // Check Q-bit
43
-		    $q = substr($bin,47,1);
44
-		    if ($q) {
42
+			// Check Q-bit
43
+			$q = substr($bin,47,1);
44
+			if ($q) {
45 45
 			$n = intval(substr($bin,40,7).substr($bin,48,4),2);
46 46
 			$alt = $n*25-1000;
47 47
 			$data['altitude'] = $alt;
48
-		    }
49
-		    // Check odd/even flag
50
-		    $oe = substr($bin,53,1);
51
-		    //if ($oe) => odd else even
52
-		    //  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
53
-		    $cprlat = intval(substr($bin,54,17),2)/131072.0;
54
-		    $cprlon = intval(substr($bin,71,17),2)/131072.0;
55
-		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
56
-		    elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
48
+			}
49
+			// Check odd/even flag
50
+			$oe = substr($bin,53,1);
51
+			//if ($oe) => odd else even
52
+			//  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
53
+			$cprlat = intval(substr($bin,54,17),2)/131072.0;
54
+			$cprlon = intval(substr($bin,71,17),2)/131072.0;
55
+			if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
56
+			elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
57 57
 			$cprlat_odd = $cprlat;
58 58
 			$cprlon_odd = $cprlon;
59 59
 			$cprlat_even = $this::$latlon[$icao]['latitude'];
@@ -66,53 +66,53 @@  discard block
 block discarded – undo
66 66
 			if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
67 67
 			// check latitude zone
68 68
 			if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
69
-			    if ($this::$latlon[$icao]['created'] > time()) {
69
+				if ($this::$latlon[$icao]['created'] > time()) {
70 70
 				$ni = $this->cprN($lat_even,0);
71 71
 				$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
72 72
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
73 73
 				$lat = $lat_even;
74 74
 				if ($lon > 180) $lon = $lon -360;
75 75
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
76
-				    //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
77
-				    $data['latitude'] = $lat;
78
-				    $data['longitude'] = $lon;
76
+					//if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
77
+					$data['latitude'] = $lat;
78
+					$data['longitude'] = $lon;
79 79
 				}
80
-			    } else {
80
+				} else {
81 81
 				$ni = $this->cprN($lat_odd,1);
82 82
 				$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
83 83
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
84 84
 				$lat = $lat_odd;
85 85
 				if ($lon > 180) $lon = $lon -360;
86 86
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
87
-				    //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
88
-				    $data['latitude'] = $lat;
89
-				    $data['longitude'] = $lon;
87
+					//if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
88
+					$data['latitude'] = $lat;
89
+					$data['longitude'] = $lon;
90
+				}
90 91
 				}
91
-			    }
92 92
 			} else echo "Not cprNL";
93 93
 			unset($this::$latlon[$icao]);
94
-		    }
94
+			}
95 95
 		} elseif ($tc == 19) {
96
-		    // speed & heading
97
-		    $v_ew_dir = intval(substr($bin,45,1));
98
-		    $v_ew = intval(substr($bin,46,10),2);
99
-		    $v_ns_dir = intval(substr($bin,56,1));
100
-		    $v_ns = intval(substr($bin,57,10),2);
101
-		    if ($v_ew_dir) $v_ew = -1*$v_ew;
102
-		    if ($v_ns_dir) $v_ns = -1*$v_ns;
103
-		    $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
104
-		    $heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
105
-		    if ($heading <0) $heading = $heading+360;
106
-		    $data['speed'] = $speed;
107
-		    $data['heading'] = $heading;
96
+			// speed & heading
97
+			$v_ew_dir = intval(substr($bin,45,1));
98
+			$v_ew = intval(substr($bin,46,10),2);
99
+			$v_ns_dir = intval(substr($bin,56,1));
100
+			$v_ns = intval(substr($bin,57,10),2);
101
+			if ($v_ew_dir) $v_ew = -1*$v_ew;
102
+			if ($v_ns_dir) $v_ns = -1*$v_ns;
103
+			$speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
104
+			$heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
105
+			if ($heading <0) $heading = $heading+360;
106
+			$data['speed'] = $speed;
107
+			$data['heading'] = $heading;
108
+		}
108 109
 		}
109
-	    }
110
-	    if (isset($data)) {
110
+		if (isset($data)) {
111 111
 		//print_r($data);
112 112
 		return $data;
113
-	    }
114
-        }
115
-    }
113
+		}
114
+		}
115
+	}
116 116
 
117 117
 
118 118
 	public function cprNL($lat) {
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
 	if ($lat < 86.53536998) return 3;
178 178
 	if ($lat < 87.00000000) return 2;
179 179
 	return 1;
180
-    }
180
+	}
181 181
     
182
-    public function cprN($lat,$isodd) {
182
+	public function cprN($lat,$isodd) {
183 183
 	$nl = $this->cprNL($lat) - $isodd;
184 184
 	if ($nl > 1) return $nl;
185 185
 	else return 1;
186
-    }
186
+	}
187 187
 
188 188
 
189
-    function parityCheck($msg, $bin) {
189
+	function parityCheck($msg, $bin) {
190 190
 $modes_checksum_table = array(
191 191
 0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178,
192 192
 0x2c38bc, 0x161c5e, 0x0b0e2f, 0xfa7d13, 0x82c48d, 0xbe9842, 0x5f4c21, 0xd05c14,
@@ -208,75 +208,75 @@  discard block
 block discarded – undo
208 208
 	$checksum = intval(substr($msg,22,6),16);
209 209
 
210 210
 	for ($j = 0; $j < strlen($bin); $j++) {
211
-	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
211
+		if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
212 212
 	}
213 213
 	if ($crc == $checksum) return true;
214 214
 	else {
215
-	    //echo "**** CRC ERROR ****\n";
216
-	    return false;
215
+		//echo "**** CRC ERROR ****\n";
216
+		return false;
217
+	}
217 218
 	}
218
-    }
219 219
     
220
-    public function famaprs_to_basestation($data) {
220
+	public function famaprs_to_basestation($data) {
221 221
 	$result = array();
222
-        if (isset($data['ident']) && $data['ident'] != '') {
223
-	    $msg = array();
224
-	    $msg['msg_type'] = 'MSG';
225
-	    $msg['transmission_type'] = 1;
226
-	    $msg['session_id'] = 5;
227
-	    $msg['aircraftid'] = hexdec($data['address']);
228
-	    $msg['hex'] = $data['address'];
229
-	    $msg['flightid'] = hexdec($data['address']);
230
-	    $msg['date_gen'] = date('Y/m/d',$data['timestamp']);
231
-	    $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
232
-	    $msg['date_log'] = date('Y/m/d',$data['timestamp']);
233
-	    $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
234
-	    $msg['callsign'] = $data['ident'];
235
-	    $msg['altitude'] = '';
236
-	    $msg['speed'] = '';
237
-	    $msg['track'] = '';
238
-	    $msg['latitude'] = '';
239
-	    $msg['longitude'] = '';
240
-	    $msg['verticalrate'] = '';
241
-	    $msg['squawk'] = '';
242
-	    $msg['alert'] = '';
243
-	    $msg['emergency'] = '';
244
-	    $msg['SPI'] = '';
245
-	    $msg['ground'] = '';
246
-    	    $result[] = implode(',',$msg);
247
-    	}
248
-    	if (isset($data['latitude']) && $data['latitude'] != 0) {
249
-	    $msg = array();
250
-	    $msg['msg_type'] = 'MSG';
251
-	    $msg['transmission_type'] = 2;
252
-	    $msg['session_id'] = 5;
253
-	    $msg['aircraftid'] = hexdec($data['address']);
254
-	    $msg['hex'] = $data['address'];
255
-	    $msg['flightid'] = hexdec($data['address']);
256
-	    $msg['date_gen'] = date('Y/m/d',$data['timestamp']);
257
-	    $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
258
-	    $msg['date_log'] = date('Y/m/d',$data['timestamp']);
259
-	    $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
260
-	    $msg['callsign'] = '';
261
-	    if (isset($data['altitude'])) $msg['altitude'] = $data['altitude'];
262
-	    else $msg['altitude'] = '';
263
-	    $msg['speed'] = $data['speed'];
264
-	    if (isset($data['heading'])) $msg['track'] = $data['heading'];
265
-	    else $msg['track'] = '';
266
-	    $msg['latitude'] = $data['latitude'];
267
-	    $msg['longitude'] = $data['longitude'];
268
-	    if (isset($data['verticalrate'])) $msg['verticalrate'] = $data['verticalrate'];
269
-	    else $msg['verticalrate'] = '';
270
-	    if (isset($data['squawk'])) $msg['squawk'] = $data['squawk'];
271
-	    else $msg['squawk'] = 0;
272
-	    $msg['alert'] = 0;
273
-	    $msg['emergency'] = 0;
274
-	    $msg['SPI'] = 0;
275
-	    if (isset($data['ground'])) $msg['ground'] = 1;
276
-	    else $msg['ground'] = 0;
277
-    	    $result[] = implode(',',$msg);
278
-        }
279
-        return $result;
280
-    }
222
+		if (isset($data['ident']) && $data['ident'] != '') {
223
+		$msg = array();
224
+		$msg['msg_type'] = 'MSG';
225
+		$msg['transmission_type'] = 1;
226
+		$msg['session_id'] = 5;
227
+		$msg['aircraftid'] = hexdec($data['address']);
228
+		$msg['hex'] = $data['address'];
229
+		$msg['flightid'] = hexdec($data['address']);
230
+		$msg['date_gen'] = date('Y/m/d',$data['timestamp']);
231
+		$msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
232
+		$msg['date_log'] = date('Y/m/d',$data['timestamp']);
233
+		$msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
234
+		$msg['callsign'] = $data['ident'];
235
+		$msg['altitude'] = '';
236
+		$msg['speed'] = '';
237
+		$msg['track'] = '';
238
+		$msg['latitude'] = '';
239
+		$msg['longitude'] = '';
240
+		$msg['verticalrate'] = '';
241
+		$msg['squawk'] = '';
242
+		$msg['alert'] = '';
243
+		$msg['emergency'] = '';
244
+		$msg['SPI'] = '';
245
+		$msg['ground'] = '';
246
+			$result[] = implode(',',$msg);
247
+		}
248
+		if (isset($data['latitude']) && $data['latitude'] != 0) {
249
+		$msg = array();
250
+		$msg['msg_type'] = 'MSG';
251
+		$msg['transmission_type'] = 2;
252
+		$msg['session_id'] = 5;
253
+		$msg['aircraftid'] = hexdec($data['address']);
254
+		$msg['hex'] = $data['address'];
255
+		$msg['flightid'] = hexdec($data['address']);
256
+		$msg['date_gen'] = date('Y/m/d',$data['timestamp']);
257
+		$msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180';
258
+		$msg['date_log'] = date('Y/m/d',$data['timestamp']);
259
+		$msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
260
+		$msg['callsign'] = '';
261
+		if (isset($data['altitude'])) $msg['altitude'] = $data['altitude'];
262
+		else $msg['altitude'] = '';
263
+		$msg['speed'] = $data['speed'];
264
+		if (isset($data['heading'])) $msg['track'] = $data['heading'];
265
+		else $msg['track'] = '';
266
+		$msg['latitude'] = $data['latitude'];
267
+		$msg['longitude'] = $data['longitude'];
268
+		if (isset($data['verticalrate'])) $msg['verticalrate'] = $data['verticalrate'];
269
+		else $msg['verticalrate'] = '';
270
+		if (isset($data['squawk'])) $msg['squawk'] = $data['squawk'];
271
+		else $msg['squawk'] = 0;
272
+		$msg['alert'] = 0;
273
+		$msg['emergency'] = 0;
274
+		$msg['SPI'] = 0;
275
+		if (isset($data['ground'])) $msg['ground'] = 1;
276
+		else $msg['ground'] = 0;
277
+			$result[] = implode(',',$msg);
278
+		}
279
+		return $result;
280
+	}
281 281
 }
282 282
 ?>
Please login to merge, or discard this patch.
statistics-country.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 }
22 22
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
23 23
 if ($airline_icao == '' && isset($globalFilter)) {
24
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
24
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
25 25
 }
26 26
 
27 27
 require_once('header.php');
Please login to merge, or discard this patch.
statistics-sub-menu.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 ?>
38 38
 	</div>
39 39
 <?php 
40
-    if (!isset($year) || (isset($year) && $year == '') && !isset($month) || (isset($month) && $month == '')) {
40
+	if (!isset($year) || (isset($year) && $year == '') && !isset($month) || (isset($month) && $month == '')) {
41 41
 ?>
42 42
 <div class="sub-menu sub-menu-container">
43 43
 	<ul class="nav">
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		    </ul>
96 96
 		</li>
97 97
 		<?php
98
-		    if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) {
98
+			if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) {
99 99
 		?>
100 100
 		<li class="dropdown">
101 101
 		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "statistics-fatalities-year" || strtolower($current_page) == "statistics-fatalities-month"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		    </ul>
108 108
 		</li>
109 109
 		<?php
110
-		    }
110
+			}
111 111
 		?>
112 112
 <?php
113 113
 	} elseif ($type == 'marine' || $type == 'tracker') {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	</ul>
128 128
 </div>
129 129
 <?php
130
-    } else {
130
+	} else {
131 131
 ?>
132 132
 <div class="sub-menu sub-menu-container">
133 133
 	<ul class="nav">
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		</li>
190 190
 		-->
191 191
 		<?php
192
-		    if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) {
192
+			if (isset($globalAccidents) && $globalAccidents && (!isset($airline_icao) || $airline_icao == '' || $airline_icao == 'all')) {
193 193
 		?>
194 194
 		<!--
195 195
 		<li class="dropdown">
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		</li>
204 204
 		-->
205 205
 		<?php
206
-		    }
206
+			}
207 207
 		?>
208 208
 <?php
209 209
 	} elseif ($type == 'marine' || $type == 'tracker') {
@@ -224,5 +224,5 @@  discard block
 block discarded – undo
224 224
 	</ul>
225 225
 </div>
226 226
 <?php
227
-    }
227
+	}
228 228
 ?>
229 229
\ No newline at end of file
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 	}
12 12
 
13 13
 	/**
14
-	* Get SQL query part for filter used
15
-	* @param Array $filter the filter
16
-	* @return Array the SQL part
17
-	*/
14
+	 * Get SQL query part for filter used
15
+	 * @param Array $filter the filter
16
+	 * @return Array the SQL part
17
+	 */
18 18
 	
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 	}
79 79
 
80 80
 	/**
81
-	* Executes the SQL statements to get the spotter information
82
-	*
83
-	* @param String $query the SQL query
84
-	* @param Array $params parameter of the query
85
-	* @param String $limitQuery the limit query
86
-	* @return Array the spotter information
87
-	*
88
-	*/
81
+	 * Executes the SQL statements to get the spotter information
82
+	 *
83
+	 * @param String $query the SQL query
84
+	 * @param Array $params parameter of the query
85
+	 * @param String $limitQuery the limit query
86
+	 * @return Array the spotter information
87
+	 *
88
+	 */
89 89
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
90 90
 	{
91 91
 		date_default_timezone_set('UTC');
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 	
214 214
 	
215 215
 	/**
216
-	* Gets all the spotter information based on the latest data entry
217
-	*
218
-	* @return Array the spotter information
219
-	*
220
-	*/
216
+	 * Gets all the spotter information based on the latest data entry
217
+	 *
218
+	 * @return Array the spotter information
219
+	 *
220
+	 */
221 221
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
222 222
 	{
223 223
 		global $global_query;
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 	}
267 267
 
268 268
 	/**
269
-	* Gets all the spotter information based on the callsign
270
-	*
271
-	* @return Array the spotter information
272
-	*
273
-	*/
269
+	 * Gets all the spotter information based on the callsign
270
+	 *
271
+	 * @return Array the spotter information
272
+	 *
273
+	 */
274 274
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
275 275
 	{
276 276
 		global $global_query;
@@ -381,12 +381,12 @@  discard block
 block discarded – undo
381 381
 
382 382
 
383 383
 	/**
384
-	* Gets all source name
385
-	*
386
-	* @param String type format of source
387
-	* @return Array list of source name
388
-	*
389
-	*/
384
+	 * Gets all source name
385
+	 *
386
+	 * @param String type format of source
387
+	 * @return Array list of source name
388
+	 *
389
+	 */
390 390
 	public function getAllSourceName($type = '',$filters = array())
391 391
 	{
392 392
 		$filter_query = $this->getFilter($filters,true,true);
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
 
417 417
 
418 418
 	/**
419
-	* Gets a list of all idents/callsigns
420
-	*
421
-	* @return Array list of ident/callsign names
422
-	*
423
-	*/
419
+	 * Gets a list of all idents/callsigns
420
+	 *
421
+	 * @return Array list of ident/callsign names
422
+	 *
423
+	 */
424 424
 	public function getAllIdents($filters = array())
425 425
 	{
426 426
 		$filter_query = $this->getFilter($filters,true,true);
@@ -444,11 +444,11 @@  discard block
 block discarded – undo
444 444
 	}
445 445
 
446 446
 	/**
447
-	* Gets all info from a mmsi
448
-	*
449
-	* @return Array list of mmsi info
450
-	*
451
-	*/
447
+	 * Gets all info from a mmsi
448
+	 *
449
+	 * @return Array list of mmsi info
450
+	 *
451
+	 */
452 452
 	public function getIdentity($mmsi)
453 453
 	{
454 454
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -505,18 +505,18 @@  discard block
 block discarded – undo
505 505
 	
506 506
 	
507 507
 	/**
508
-	* Update ident tracker data
509
-	*
510
-	* @param String $fammarine_id the ID
511
-	* @param String $ident the marine ident
512
-	* @return String success or false
513
-	*
514
-	*/	
508
+	 * Update ident tracker data
509
+	 *
510
+	 * @param String $fammarine_id the ID
511
+	 * @param String $ident the marine ident
512
+	 * @return String success or false
513
+	 *
514
+	 */	
515 515
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
516 516
 	{
517 517
 
518 518
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
519
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
519
+				$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
520 520
 
521 521
 		try {
522 522
 			$sth = $this->db->prepare($query);
@@ -530,19 +530,19 @@  discard block
 block discarded – undo
530 530
 	}
531 531
 
532 532
 	/**
533
-	* Update Status data
534
-	*
535
-	* @param String $fammarine_id the ID
536
-	* @param String $status_id the marine status id
537
-	* @param String $status the marine status
538
-	* @return String success or false
539
-	*
540
-	*/	
533
+	 * Update Status data
534
+	 *
535
+	 * @param String $fammarine_id the ID
536
+	 * @param String $status_id the marine status id
537
+	 * @param String $status the marine status
538
+	 * @return String success or false
539
+	 *
540
+	 */	
541 541
 	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
542 542
 	{
543 543
 
544 544
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
545
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
545
+				$query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
546 546
 
547 547
 		try {
548 548
 			$sth = $this->db->prepare($query);
@@ -555,17 +555,17 @@  discard block
 block discarded – undo
555 555
 
556 556
 	}
557 557
 	/**
558
-	* Update latest marine data
559
-	*
560
-	* @param String $fammarine_id the ID
561
-	* @param String $ident the marine ident
562
-	* @return String success or false
563
-	*
564
-	*/	
558
+	 * Update latest marine data
559
+	 *
560
+	 * @param String $fammarine_id the ID
561
+	 * @param String $ident the marine ident
562
+	 * @return String success or false
563
+	 *
564
+	 */	
565 565
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
566 566
 	{
567 567
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
568
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
568
+				$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
569 569
 
570 570
 		try {
571 571
 			$sth = $this->db->prepare($query);
@@ -579,30 +579,30 @@  discard block
 block discarded – undo
579 579
 	}
580 580
 
581 581
 	/**
582
-	* Adds a new spotter data
583
-	*
584
-	* @param String $fammarine_id the ID
585
-	* @param String $ident the marine ident
586
-	* @param String $departure_airport_icao the departure airport
587
-	* @param String $arrival_airport_icao the arrival airport
588
-	* @param String $latitude latitude of flight
589
-	* @param String $longitude latitude of flight
590
-	* @param String $waypoints waypoints of flight
591
-	* @param String $heading heading of flight
592
-	* @param String $groundspeed speed of flight
593
-	* @param String $date date of flight
594
-	* @param String $departure_airport_time departure time of flight
595
-	* @param String $arrival_airport_time arrival time of flight
596
-	* @param String $squawk squawk code of flight
597
-	* @param String $route_stop route stop of flight
598
-	* @param String $highlight highlight or not
599
-	* @param String $ModeS ModesS code of flight
600
-	* @param String $registration registration code of flight
601
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
602
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
603
-	* @param String $verticalrate vertival rate of flight
604
-	* @return String success or false
605
-	*/
582
+	 * Adds a new spotter data
583
+	 *
584
+	 * @param String $fammarine_id the ID
585
+	 * @param String $ident the marine ident
586
+	 * @param String $departure_airport_icao the departure airport
587
+	 * @param String $arrival_airport_icao the arrival airport
588
+	 * @param String $latitude latitude of flight
589
+	 * @param String $longitude latitude of flight
590
+	 * @param String $waypoints waypoints of flight
591
+	 * @param String $heading heading of flight
592
+	 * @param String $groundspeed speed of flight
593
+	 * @param String $date date of flight
594
+	 * @param String $departure_airport_time departure time of flight
595
+	 * @param String $arrival_airport_time arrival time of flight
596
+	 * @param String $squawk squawk code of flight
597
+	 * @param String $route_stop route stop of flight
598
+	 * @param String $highlight highlight or not
599
+	 * @param String $ModeS ModesS code of flight
600
+	 * @param String $registration registration code of flight
601
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
602
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
603
+	 * @param String $verticalrate vertival rate of flight
604
+	 * @return String success or false
605
+	 */
606 606
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '')
607 607
 	{
608 608
 		global $globalURL, $globalMarineImageFetch;
@@ -699,13 +699,13 @@  discard block
 block discarded – undo
699 699
 			unset($Image);
700 700
 		}
701 701
 		
702
-                if ($latitude == '' && $longitude == '') {
703
-            		$latitude = 0;
704
-            		$longitude = 0;
705
-            	}
706
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708
-                if ($arrival_date == '') $arrival_date = NULL;
702
+				if ($latitude == '' && $longitude == '') {
703
+					$latitude = 0;
704
+					$longitude = 0;
705
+				}
706
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708
+				if ($arrival_date == '') $arrival_date = NULL;
709 709
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
710 710
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
711 711
 
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 			$sth->execute($query_values);
717 717
 			$this->db = null;
718 718
 		} catch (PDOException $e) {
719
-		    return "error : ".$e->getMessage();
719
+			return "error : ".$e->getMessage();
720 720
 		}
721 721
 		
722 722
 		return "success";
@@ -725,11 +725,11 @@  discard block
 block discarded – undo
725 725
 	
726 726
   
727 727
 	/**
728
-	* Gets the aircraft ident within the last hour
729
-	*
730
-	* @return String the ident
731
-	*
732
-	*/
728
+	 * Gets the aircraft ident within the last hour
729
+	 *
730
+	 * @return String the ident
731
+	 *
732
+	 */
733 733
 	public function getIdentFromLastHour($ident)
734 734
 	{
735 735
 		global $globalDBdriver, $globalTimezone;
@@ -745,11 +745,11 @@  discard block
 block discarded – undo
745 745
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
746 746
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
747 747
 			$query_data = array(':ident' => $ident);
748
-    		}
748
+			}
749 749
 		
750 750
 		$sth = $this->db->prepare($query);
751 751
 		$sth->execute($query_data);
752
-    		$ident_result='';
752
+			$ident_result='';
753 753
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
754 754
 		{
755 755
 			$ident_result = $row['ident'];
@@ -760,11 +760,11 @@  discard block
 block discarded – undo
760 760
 	
761 761
 	
762 762
 	/**
763
-	* Gets the aircraft data from the last 20 seconds
764
-	*
765
-	* @return Array the spotter data
766
-	*
767
-	*/
763
+	 * Gets the aircraft data from the last 20 seconds
764
+	 *
765
+	 * @return Array the spotter data
766
+	 *
767
+	 */
768 768
 	public function getRealTimeData($q = '')
769 769
 	{
770 770
 		global $globalDBdriver;
@@ -802,11 +802,11 @@  discard block
 block discarded – undo
802 802
 	
803 803
 
804 804
 	/**
805
-	* Gets all number of flight over countries
806
-	*
807
-	* @return Array the airline country list
808
-	*
809
-	*/
805
+	 * Gets all number of flight over countries
806
+	 *
807
+	 * @return Array the airline country list
808
+	 *
809
+	 */
810 810
 
811 811
 	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
812 812
 	{
@@ -879,11 +879,11 @@  discard block
 block discarded – undo
879 879
 	
880 880
 	
881 881
 	/**
882
-	* Gets all callsigns that have flown over
883
-	*
884
-	* @return Array the callsign list
885
-	*
886
-	*/
882
+	 * Gets all callsigns that have flown over
883
+	 *
884
+	 * @return Array the callsign list
885
+	 *
886
+	 */
887 887
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
888 888
 	{
889 889
 		global $globalDBdriver;
@@ -950,11 +950,11 @@  discard block
 block discarded – undo
950 950
 
951 951
 
952 952
 	/**
953
-	* Counts all dates
954
-	*
955
-	* @return Array the date list
956
-	*
957
-	*/
953
+	 * Counts all dates
954
+	 *
955
+	 * @return Array the date list
956
+	 *
957
+	 */
958 958
 	public function countAllDates($filters = array())
959 959
 	{
960 960
 		global $globalTimezone, $globalDBdriver;
@@ -1000,11 +1000,11 @@  discard block
 block discarded – undo
1000 1000
 	
1001 1001
 	
1002 1002
 	/**
1003
-	* Counts all dates during the last 7 days
1004
-	*
1005
-	* @return Array the date list
1006
-	*
1007
-	*/
1003
+	 * Counts all dates during the last 7 days
1004
+	 *
1005
+	 * @return Array the date list
1006
+	 *
1007
+	 */
1008 1008
 	public function countAllDatesLast7Days($filters = array())
1009 1009
 	{
1010 1010
 		global $globalTimezone, $globalDBdriver;
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 			$query .= " GROUP BY date_name 
1027 1027
 								ORDER BY date_name ASC";
1028 1028
 			$query_data = array(':offset' => $offset);
1029
-    		}
1029
+			}
1030 1030
 		
1031 1031
 		$sth = $this->db->prepare($query);
1032 1032
 		$sth->execute($query_data);
@@ -1046,11 +1046,11 @@  discard block
 block discarded – undo
1046 1046
 	}
1047 1047
 
1048 1048
 	/**
1049
-	* Counts all dates during the last month
1050
-	*
1051
-	* @return Array the date list
1052
-	*
1053
-	*/
1049
+	 * Counts all dates during the last month
1050
+	 *
1051
+	 * @return Array the date list
1052
+	 *
1053
+	 */
1054 1054
 	public function countAllDatesLastMonth($filters = array())
1055 1055
 	{
1056 1056
 		global $globalTimezone, $globalDBdriver;
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 			$query .= " GROUP BY date_name 
1073 1073
 								ORDER BY date_name ASC";
1074 1074
 			$query_data = array(':offset' => $offset);
1075
-    		}
1075
+			}
1076 1076
 		
1077 1077
 		$sth = $this->db->prepare($query);
1078 1078
 		$sth->execute($query_data);
@@ -1094,11 +1094,11 @@  discard block
 block discarded – undo
1094 1094
 
1095 1095
 
1096 1096
 	/**
1097
-	* Counts all month
1098
-	*
1099
-	* @return Array the month list
1100
-	*
1101
-	*/
1097
+	 * Counts all month
1098
+	 *
1099
+	 * @return Array the month list
1100
+	 *
1101
+	 */
1102 1102
 	public function countAllMonths($filters = array())
1103 1103
 	{
1104 1104
 		global $globalTimezone, $globalDBdriver;
@@ -1143,11 +1143,11 @@  discard block
 block discarded – undo
1143 1143
 	
1144 1144
 
1145 1145
 	/**
1146
-	* Counts all dates during the last year
1147
-	*
1148
-	* @return Array the date list
1149
-	*
1150
-	*/
1146
+	 * Counts all dates during the last year
1147
+	 *
1148
+	 * @return Array the date list
1149
+	 *
1150
+	 */
1151 1151
 	public function countAllMonthsLastYear($filters)
1152 1152
 	{
1153 1153
 		global $globalTimezone, $globalDBdriver;
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 			$query .= " GROUP BY year_name, month_name
1170 1170
 								ORDER BY year_name, month_name ASC";
1171 1171
 			$query_data = array(':offset' => $offset);
1172
-    		}
1172
+			}
1173 1173
 		
1174 1174
 		$sth = $this->db->prepare($query);
1175 1175
 		$sth->execute($query_data);
@@ -1192,11 +1192,11 @@  discard block
 block discarded – undo
1192 1192
 	
1193 1193
 	
1194 1194
 	/**
1195
-	* Counts all hours
1196
-	*
1197
-	* @return Array the hour list
1198
-	*
1199
-	*/
1195
+	 * Counts all hours
1196
+	 *
1197
+	 * @return Array the hour list
1198
+	 *
1199
+	 */
1200 1200
 	public function countAllHours($orderby,$filters = array())
1201 1201
 	{
1202 1202
 		global $globalTimezone, $globalDBdriver;
@@ -1259,11 +1259,11 @@  discard block
 block discarded – undo
1259 1259
 	
1260 1260
 	
1261 1261
 	/**
1262
-	* Counts all hours by date
1263
-	*
1264
-	* @return Array the hour list
1265
-	*
1266
-	*/
1262
+	 * Counts all hours by date
1263
+	 *
1264
+	 * @return Array the hour list
1265
+	 *
1266
+	 */
1267 1267
 	public function countAllHoursByDate($date, $filters = array())
1268 1268
 	{
1269 1269
 		global $globalTimezone, $globalDBdriver;
@@ -1307,11 +1307,11 @@  discard block
 block discarded – undo
1307 1307
 	
1308 1308
 	
1309 1309
 	/**
1310
-	* Counts all hours by a ident/callsign
1311
-	*
1312
-	* @return Array the hour list
1313
-	*
1314
-	*/
1310
+	 * Counts all hours by a ident/callsign
1311
+	 *
1312
+	 * @return Array the hour list
1313
+	 *
1314
+	 */
1315 1315
 	public function countAllHoursByIdent($ident, $filters = array())
1316 1316
 	{
1317 1317
 		global $globalTimezone, $globalDBdriver;
@@ -1356,11 +1356,11 @@  discard block
 block discarded – undo
1356 1356
 	
1357 1357
 	
1358 1358
 	/**
1359
-	* Counts all vessels
1360
-	*
1361
-	* @return Integer the number of vessels
1362
-	*
1363
-	*/
1359
+	 * Counts all vessels
1360
+	 *
1361
+	 * @return Integer the number of vessels
1362
+	 *
1363
+	 */
1364 1364
 	public function countOverallMarine($filters = array(),$year = '',$month = '')
1365 1365
 	{
1366 1366
 		global $globalDBdriver;
@@ -1395,11 +1395,11 @@  discard block
 block discarded – undo
1395 1395
 	}
1396 1396
 	
1397 1397
 	/**
1398
-	* Counts all vessel type
1399
-	*
1400
-	* @return Integer the number of vessels
1401
-	*
1402
-	*/
1398
+	 * Counts all vessel type
1399
+	 *
1400
+	 * @return Integer the number of vessels
1401
+	 *
1402
+	 */
1403 1403
 	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1404 1404
 	{
1405 1405
 		global $globalDBdriver;
@@ -1434,11 +1434,11 @@  discard block
 block discarded – undo
1434 1434
 	
1435 1435
   
1436 1436
 	/**
1437
-	* Counts all hours of today
1438
-	*
1439
-	* @return Array the hour list
1440
-	*
1441
-	*/
1437
+	 * Counts all hours of today
1438
+	 *
1439
+	 * @return Array the hour list
1440
+	 *
1441
+	 */
1442 1442
 	public function countAllHoursFromToday($filters = array())
1443 1443
 	{
1444 1444
 		global $globalTimezone, $globalDBdriver;
@@ -1478,12 +1478,12 @@  discard block
 block discarded – undo
1478 1478
 	}
1479 1479
     
1480 1480
     
1481
-     /**
1482
-	* Gets the Barrie Spotter ID based on the FlightAware ID
1483
-	*
1484
-	* @return Integer the Barrie Spotter ID
1481
+	 /**
1482
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
1483
+	  *
1484
+	  * @return Integer the Barrie Spotter ID
1485 1485
 q	*
1486
-	*/
1486
+	  */
1487 1487
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1488 1488
 	{
1489 1489
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1504,13 +1504,13 @@  discard block
 block discarded – undo
1504 1504
   
1505 1505
  
1506 1506
 	/**
1507
-	* Parses a date string
1508
-	*
1509
-	* @param String $dateString the date string
1510
-	* @param String $timezone the timezone of a user
1511
-	* @return Array the time information
1512
-	*
1513
-	*/
1507
+	 * Parses a date string
1508
+	 *
1509
+	 * @param String $dateString the date string
1510
+	 * @param String $timezone the timezone of a user
1511
+	 * @return Array the time information
1512
+	 *
1513
+	 */
1514 1514
 	public function parseDateString($dateString, $timezone = '')
1515 1515
 	{
1516 1516
 		$time_array = array();
@@ -1543,12 +1543,12 @@  discard block
 block discarded – undo
1543 1543
 	}
1544 1544
 	
1545 1545
 	/**
1546
-	* Parses the direction degrees to working
1547
-	*
1548
-	* @param Float $direction the direction in degrees
1549
-	* @return Array the direction information
1550
-	*
1551
-	*/
1546
+	 * Parses the direction degrees to working
1547
+	 *
1548
+	 * @param Float $direction the direction in degrees
1549
+	 * @return Array the direction information
1550
+	 *
1551
+	 */
1552 1552
 	public function parseDirection($direction = 0)
1553 1553
 	{
1554 1554
 		if ($direction == '') $direction = 0;
@@ -1627,12 +1627,12 @@  discard block
 block discarded – undo
1627 1627
 	
1628 1628
 	
1629 1629
 	/**
1630
-	* Gets Country from latitude/longitude
1631
-	*
1632
-	* @param Float $latitude latitute of the flight
1633
-	* @param Float $longitude longitute of the flight
1634
-	* @return String the countrie
1635
-	*/
1630
+	 * Gets Country from latitude/longitude
1631
+	 *
1632
+	 * @param Float $latitude latitute of the flight
1633
+	 * @param Float $longitude longitute of the flight
1634
+	 * @return String the countrie
1635
+	 */
1636 1636
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1637 1637
 	{
1638 1638
 		global $globalDBdriver, $globalDebug;
@@ -1669,11 +1669,11 @@  discard block
 block discarded – undo
1669 1669
 	}
1670 1670
 
1671 1671
 	/**
1672
-	* Gets Country from iso2
1673
-	*
1674
-	* @param String $iso2 ISO2 country code
1675
-	* @return String the countrie
1676
-	*/
1672
+	 * Gets Country from iso2
1673
+	 *
1674
+	 * @param String $iso2 ISO2 country code
1675
+	 * @return String the countrie
1676
+	 */
1677 1677
 	public function getCountryFromISO2($iso2)
1678 1678
 	{
1679 1679
 		global $globalDBdriver, $globalDebug;
@@ -1702,12 +1702,12 @@  discard block
 block discarded – undo
1702 1702
 
1703 1703
 	
1704 1704
 	/**
1705
-	* Gets the short url from bit.ly
1706
-	*
1707
-	* @param String $url the full url
1708
-	* @return String the bit.ly url
1709
-	*
1710
-	*/
1705
+	 * Gets the short url from bit.ly
1706
+	 *
1707
+	 * @param String $url the full url
1708
+	 * @return String the bit.ly url
1709
+	 *
1710
+	 */
1711 1711
 	public function getBitlyURL($url)
1712 1712
 	{
1713 1713
 		global $globalBitlyAccessToken;
@@ -1734,11 +1734,11 @@  discard block
 block discarded – undo
1734 1734
 
1735 1735
 	
1736 1736
 	/**
1737
-	* Gets all vessels types that have flown over
1738
-	*
1739
-	* @return Array the vessel type list
1740
-	*
1741
-	*/
1737
+	 * Gets all vessels types that have flown over
1738
+	 *
1739
+	 * @return Array the vessel type list
1740
+	 *
1741
+	 */
1742 1742
 	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1743 1743
 	{
1744 1744
 		global $globalDBdriver;
Please login to merge, or discard this patch.