Completed
Push — master ( c396ef...4342b6 )
by Yannick
34:34
created
require/class.Satellite.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/libs/Predict/Predict/TLE.php');
15 15
 
16 16
 class Satellite {
17
-    /** @var $db PDOStatement  */
17
+	/** @var $db PDOStatement  */
18 18
 	public $db;
19 19
 
20 20
 	public function __construct($dbc = null) {
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 		else return array();
134 134
 	}
135 135
 
136
-    /**
137
-     * Gets all launch site
138
-     *
139
-     * @param bool $limit
140
-     * @param array $filters
141
-     * @return array the launch site list
142
-     */
136
+	/**
137
+	 * Gets all launch site
138
+	 *
139
+	 * @param bool $limit
140
+	 * @param array $filters
141
+	 * @return array the launch site list
142
+	 */
143 143
 	public function countAllLaunchSite($limit = true, $filters = array())
144 144
 	{
145 145
 		//$filter_query = $this->getFilter($filters,true,true);
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
 	}
164 164
 
165 165
 	/**
166
-	* Gets all owners
167
-	*
168
-	* @return array the owners list
169
-	*
170
-	*/
166
+	 * Gets all owners
167
+	 *
168
+	 * @return array the owners list
169
+	 *
170
+	 */
171 171
 	public function countAllOwners($limit = true, $filters = array())
172 172
 	{
173 173
 		//$filter_query = $this->getFilter($filters,true,true);
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
 		return $owner_array;
191 191
 	}
192 192
 
193
-    /**
194
-     * Gets all countries owners
195
-     *
196
-     * @param bool $limit
197
-     * @param array $filters
198
-     * @return array the countries list
199
-     */
193
+	/**
194
+	 * Gets all countries owners
195
+	 *
196
+	 * @param bool $limit
197
+	 * @param array $filters
198
+	 * @return array the countries list
199
+	 */
200 200
 	public function countAllCountriesOwners($limit = true, $filters = array())
201 201
 	{
202 202
 		global $globalDBdriver;
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 		return $owner_array;
221 221
 	}
222 222
 
223
-    /**
224
-     * Counts all launch dates during the last year
225
-     *
226
-     * @param array $filters
227
-     * @param string $sincedate
228
-     * @return array the launch date list
229
-     */
223
+	/**
224
+	 * Counts all launch dates during the last year
225
+	 *
226
+	 * @param array $filters
227
+	 * @param string $sincedate
228
+	 * @return array the launch date list
229
+	 */
230 230
 	public function countAllMonthsLastYear($filters = array(), $sincedate = '')
231 231
 	{
232 232
 		global $globalTimezone, $globalDBdriver;
@@ -266,13 +266,13 @@  discard block
 block discarded – undo
266 266
 		return $date_array;
267 267
 	}
268 268
 
269
-    /**
270
-     * Counts all dates during the last 10 years
271
-     *
272
-     * @param array $filters
273
-     * @param string $sincedate
274
-     * @return array the date list
275
-     */
269
+	/**
270
+	 * Counts all dates during the last 10 years
271
+	 *
272
+	 * @param array $filters
273
+	 * @param string $sincedate
274
+	 * @return array the date list
275
+	 */
276 276
 	public function countAllYears($filters = array(), $sincedate = '')
277 277
 	{
278 278
 		global $globalTimezone, $globalDBdriver;
Please login to merge, or discard this patch.
require/class.MarineArchive.php 1 patch
Indentation   +931 added lines, -931 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 		if ($this->db === null) die('Error: No DB connection. (MarineArchive)');
17 17
 	}
18 18
 
19
-    /**
20
-     * Get SQL query part for filter used
21
-     * @param array $filter the filter
22
-     * @param bool $where
23
-     * @param bool $and
24
-     * @return string the SQL part
25
-     */
19
+	/**
20
+	 * Get SQL query part for filter used
21
+	 * @param array $filter the filter
22
+	 * @param bool $where
23
+	 * @param bool $and
24
+	 * @return string the SQL part
25
+	 */
26 26
 	public function getFilter($filter = array(),$where = false,$and = false) {
27 27
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
28 28
 		$filters = array();
@@ -91,40 +91,40 @@  discard block
 block discarded – undo
91 91
 		return $filter_query;
92 92
 	}
93 93
 
94
-    /**
95
-     * Add to Mariche archive
96
-     *
97
-     * @param string $fammarine_id
98
-     * @param string $ident
99
-     * @param string $latitude
100
-     * @param string $longitude
101
-     * @param string $heading
102
-     * @param string $groundspeed
103
-     * @param string $date
104
-     * @param bool $putinarchive
105
-     * @param string $mmsi
106
-     * @param string $type
107
-     * @param string $typeid
108
-     * @param string $imo
109
-     * @param string $callsign
110
-     * @param string $arrival_code
111
-     * @param string $arrival_date
112
-     * @param string $status
113
-     * @param string $statusid
114
-     * @param bool $noarchive
115
-     * @param string $format_source
116
-     * @param string $source_name
117
-     * @param string $over_country
118
-     * @param string $captain_id
119
-     * @param string $captain_name
120
-     * @param string $race_id
121
-     * @param string $race_name
122
-     * @param string $distance
123
-     * @param string $race_rank
124
-     * @param string $race_time
125
-     * @return string
126
-     */
127
-    public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') {
94
+	/**
95
+	 * Add to Mariche archive
96
+	 *
97
+	 * @param string $fammarine_id
98
+	 * @param string $ident
99
+	 * @param string $latitude
100
+	 * @param string $longitude
101
+	 * @param string $heading
102
+	 * @param string $groundspeed
103
+	 * @param string $date
104
+	 * @param bool $putinarchive
105
+	 * @param string $mmsi
106
+	 * @param string $type
107
+	 * @param string $typeid
108
+	 * @param string $imo
109
+	 * @param string $callsign
110
+	 * @param string $arrival_code
111
+	 * @param string $arrival_date
112
+	 * @param string $status
113
+	 * @param string $statusid
114
+	 * @param bool $noarchive
115
+	 * @param string $format_source
116
+	 * @param string $source_name
117
+	 * @param string $over_country
118
+	 * @param string $captain_id
119
+	 * @param string $captain_name
120
+	 * @param string $race_id
121
+	 * @param string $race_name
122
+	 * @param string $distance
123
+	 * @param string $race_rank
124
+	 * @param string $race_time
125
+	 * @return string
126
+	 */
127
+	public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') {
128 128
 		require_once(dirname(__FILE__).'/class.Marine.php');
129 129
 		if ($over_country == '') {
130 130
 			$Marine = new Marine($this->db);
@@ -149,42 +149,42 @@  discard block
 block discarded – undo
149 149
 	}
150 150
 
151 151
 
152
-    /**
153
-     * Gets all the spotter information based on a particular callsign
154
-     *
155
-     * @param $ident
156
-     * @return array the spotter information
157
-     */
158
-    public function getLastArchiveMarineDataByIdent($ident)
159
-    {
160
-	    $Marine = new Marine($this->db);
161
-        date_default_timezone_set('UTC');
162
-
163
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
164
-        //$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";
165
-        $query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
166
-        $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
167
-        return $spotter_array;
168
-    }
169
-
170
-
171
-    /**
172
-     * Gets last the spotter information based on a particular id
173
-     *
174
-     * @param $id
175
-     * @return array the spotter information
176
-     */
177
-    public function getLastArchiveMarineDataById($id)
178
-    {
179
-        $Marine = new Marine($this->db);
180
-        date_default_timezone_set('UTC');
181
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
182
-        //$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
183
-        //$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";
184
-        $query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
152
+	/**
153
+	 * Gets all the spotter information based on a particular callsign
154
+	 *
155
+	 * @param $ident
156
+	 * @return array the spotter information
157
+	 */
158
+	public function getLastArchiveMarineDataByIdent($ident)
159
+	{
160
+		$Marine = new Marine($this->db);
161
+		date_default_timezone_set('UTC');
162
+
163
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
164
+		//$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";
165
+		$query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
166
+		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
167
+		return $spotter_array;
168
+	}
169
+
170
+
171
+	/**
172
+	 * Gets last the spotter information based on a particular id
173
+	 *
174
+	 * @param $id
175
+	 * @return array the spotter information
176
+	 */
177
+	public function getLastArchiveMarineDataById($id)
178
+	{
179
+		$Marine = new Marine($this->db);
180
+		date_default_timezone_set('UTC');
181
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
182
+		//$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
183
+		//$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";
184
+		$query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
185 185
 
186 186
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
187
-                  /*
187
+				  /*
188 188
                 try {
189 189
                         $Connection = new Connection();
190 190
                         $sth = Connection->$db->prepare($query);
@@ -194,196 +194,196 @@  discard block
 block discarded – undo
194 194
                 }
195 195
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
196 196
                 */
197
-        $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
198
-        return $spotter_array;
199
-    }
200
-
201
-    /**
202
-     * Gets all the spotter information based on a particular id
203
-     *
204
-     * @param $id
205
-     * @return array the spotter information
206
-     */
207
-    public function getAllArchiveMarineDataById($id)
197
+		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
198
+		return $spotter_array;
199
+	}
200
+
201
+	/**
202
+	 * Gets all the spotter information based on a particular id
203
+	 *
204
+	 * @param $id
205
+	 * @return array the spotter information
206
+	 */
207
+	public function getAllArchiveMarineDataById($id)
208 208
 	{
209
-        date_default_timezone_set('UTC');
210
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
211
-        $query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
209
+		date_default_timezone_set('UTC');
210
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
211
+		$query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
212 212
 
213 213
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
214 214
 
215
-        try {
216
-            $sth = $this->db->prepare($query);
217
-            $sth->execute(array(':id' => $id));
218
-        } catch(PDOException $e) {
219
-            echo $e->getMessage();
220
-            die;
221
-        }
222
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
223
-        return $spotter_array;
215
+		try {
216
+			$sth = $this->db->prepare($query);
217
+			$sth->execute(array(':id' => $id));
218
+		} catch(PDOException $e) {
219
+			echo $e->getMessage();
220
+			die;
221
+		}
222
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
223
+		return $spotter_array;
224 224
 	}
225 225
 
226
-    /**
227
-     * Gets coordinate & time spotter information based on a particular id
228
-     *
229
-     * @param $id
230
-     * @return array the spotter information
231
-     */
232
-    public function getCoordArchiveMarineDataById($id)
233
-    {
234
-        date_default_timezone_set('UTC');
235
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
236
-        $query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
226
+	/**
227
+	 * Gets coordinate & time spotter information based on a particular id
228
+	 *
229
+	 * @param $id
230
+	 * @return array the spotter information
231
+	 */
232
+	public function getCoordArchiveMarineDataById($id)
233
+	{
234
+		date_default_timezone_set('UTC');
235
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
236
+		$query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
237 237
 
238 238
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
239 239
 
240
-        try {
241
-            $sth = $this->db->prepare($query);
242
-            $sth->execute(array(':id' => $id));
243
-        } catch(PDOException $e) {
244
-            echo $e->getMessage();
245
-            die;
246
-        }
247
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
248
-
249
-        return $spotter_array;
250
-    }
251
-
252
-
253
-    /**
254
-     * Gets altitude information based on a particular callsign
255
-     *
256
-     * @param $ident
257
-     * @return array the spotter information
258
-     */
259
-    public function getAltitudeArchiveMarineDataByIdent($ident)
260
-    {
261
-
262
-        date_default_timezone_set('UTC');
263
-
264
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
265
-        $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";
266
-
267
-        try {
268
-            $sth = $this->db->prepare($query);
269
-            $sth->execute(array(':ident' => $ident));
270
-        } catch(PDOException $e) {
271
-            echo $e->getMessage();
272
-            die;
273
-        }
274
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
275
-
276
-        return $spotter_array;
277
-    }
278
-
279
-    /**
280
-     * Gets altitude information based on a particular id
281
-     *
282
-     * @param $id
283
-     * @return array the spotter information
284
-     */
285
-    public function getAltitudeArchiveMarineDataById($id)
286
-    {
287
-
288
-        date_default_timezone_set('UTC');
289
-
290
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
291
-        $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";
292
-
293
-        try {
294
-            $sth = $this->db->prepare($query);
295
-            $sth->execute(array(':id' => $id));
296
-        } catch(PDOException $e) {
297
-            echo $e->getMessage();
298
-            die;
299
-        }
300
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
301
-
302
-        return $spotter_array;
303
-    }
304
-
305
-    /**
306
-     * Gets altitude & speed information based on a particular id
307
-     *
308
-     * @param $id
309
-     * @return array the spotter information
310
-     */
311
-    public function getAltitudeSpeedArchiveMarineDataById($id)
312
-    {
313
-        date_default_timezone_set('UTC');
314
-
315
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
316
-        $query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
317
-
318
-        try {
319
-            $sth = $this->db->prepare($query);
320
-            $sth->execute(array(':id' => $id));
321
-        } catch(PDOException $e) {
322
-            echo $e->getMessage();
323
-            die;
324
-        }
325
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
326
-
327
-        return $spotter_array;
328
-    }
329
-
330
-
331
-    /**
332
-     * Gets altitude information based on a particular callsign
333
-     *
334
-     * @param $ident
335
-     * @return array the spotter information
336
-     */
337
-    public function getLastAltitudeArchiveMarineDataByIdent($ident)
338
-    {
339
-
340
-        date_default_timezone_set('UTC');
341
-
342
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
343
-        $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";
240
+		try {
241
+			$sth = $this->db->prepare($query);
242
+			$sth->execute(array(':id' => $id));
243
+		} catch(PDOException $e) {
244
+			echo $e->getMessage();
245
+			die;
246
+		}
247
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
248
+
249
+		return $spotter_array;
250
+	}
251
+
252
+
253
+	/**
254
+	 * Gets altitude information based on a particular callsign
255
+	 *
256
+	 * @param $ident
257
+	 * @return array the spotter information
258
+	 */
259
+	public function getAltitudeArchiveMarineDataByIdent($ident)
260
+	{
261
+
262
+		date_default_timezone_set('UTC');
263
+
264
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
265
+		$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";
266
+
267
+		try {
268
+			$sth = $this->db->prepare($query);
269
+			$sth->execute(array(':ident' => $ident));
270
+		} catch(PDOException $e) {
271
+			echo $e->getMessage();
272
+			die;
273
+		}
274
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
275
+
276
+		return $spotter_array;
277
+	}
278
+
279
+	/**
280
+	 * Gets altitude information based on a particular id
281
+	 *
282
+	 * @param $id
283
+	 * @return array the spotter information
284
+	 */
285
+	public function getAltitudeArchiveMarineDataById($id)
286
+	{
287
+
288
+		date_default_timezone_set('UTC');
289
+
290
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
291
+		$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";
292
+
293
+		try {
294
+			$sth = $this->db->prepare($query);
295
+			$sth->execute(array(':id' => $id));
296
+		} catch(PDOException $e) {
297
+			echo $e->getMessage();
298
+			die;
299
+		}
300
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
301
+
302
+		return $spotter_array;
303
+	}
304
+
305
+	/**
306
+	 * Gets altitude & speed information based on a particular id
307
+	 *
308
+	 * @param $id
309
+	 * @return array the spotter information
310
+	 */
311
+	public function getAltitudeSpeedArchiveMarineDataById($id)
312
+	{
313
+		date_default_timezone_set('UTC');
314
+
315
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
316
+		$query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
317
+
318
+		try {
319
+			$sth = $this->db->prepare($query);
320
+			$sth->execute(array(':id' => $id));
321
+		} catch(PDOException $e) {
322
+			echo $e->getMessage();
323
+			die;
324
+		}
325
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
326
+
327
+		return $spotter_array;
328
+	}
329
+
330
+
331
+	/**
332
+	 * Gets altitude information based on a particular callsign
333
+	 *
334
+	 * @param $ident
335
+	 * @return array the spotter information
336
+	 */
337
+	public function getLastAltitudeArchiveMarineDataByIdent($ident)
338
+	{
339
+
340
+		date_default_timezone_set('UTC');
341
+
342
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
343
+		$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";
344 344
 //                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";
345 345
 
346
-        try {
347
-            $sth = $this->db->prepare($query);
348
-            $sth->execute(array(':ident' => $ident));
349
-        } catch(PDOException $e) {
350
-            echo $e->getMessage();
351
-            die;
352
-        }
353
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
354
-
355
-        return $spotter_array;
356
-    }
357
-
358
-
359
-    /**
360
-     * Gets all the archive spotter information
361
-     *
362
-     * @param $ident
363
-     * @param $fammarine_id
364
-     * @param $date
365
-     * @return array the spotter information
366
-     */
367
-    public function getMarineArchiveData($ident,$fammarine_id,$date)
368
-    {
369
-        $Marine = new Marine($this->db);
370
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
371
-        $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";
372
-        $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%'));
373
-        return $spotter_array;
374
-    }
375
-
376
-    /**
377
-     * Delete all tracking data
378
-     *
379
-     */
380
-    public function deleteMarineArchiveTrackData()
381
-    {
382
-        global $globalArchiveKeepTrackMonths, $globalDBdriver;
383
-        if ($globalDBdriver == 'mysql') {
384
-            $query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
385
-        } else {
386
-            $query = "DELETE FROM marine_archive WHERE marine_archive_id IN (SELECT marine_archive_id FROM marine_archive WHERE marine_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)";
346
+		try {
347
+			$sth = $this->db->prepare($query);
348
+			$sth->execute(array(':ident' => $ident));
349
+		} catch(PDOException $e) {
350
+			echo $e->getMessage();
351
+			die;
352
+		}
353
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
354
+
355
+		return $spotter_array;
356
+	}
357
+
358
+
359
+	/**
360
+	 * Gets all the archive spotter information
361
+	 *
362
+	 * @param $ident
363
+	 * @param $fammarine_id
364
+	 * @param $date
365
+	 * @return array the spotter information
366
+	 */
367
+	public function getMarineArchiveData($ident,$fammarine_id,$date)
368
+	{
369
+		$Marine = new Marine($this->db);
370
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
371
+		$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";
372
+		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%'));
373
+		return $spotter_array;
374
+	}
375
+
376
+	/**
377
+	 * Delete all tracking data
378
+	 *
379
+	 */
380
+	public function deleteMarineArchiveTrackData()
381
+	{
382
+		global $globalArchiveKeepTrackMonths, $globalDBdriver;
383
+		if ($globalDBdriver == 'mysql') {
384
+			$query = 'DELETE FROM marine_archive WHERE marine_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
385
+		} else {
386
+			$query = "DELETE FROM marine_archive WHERE marine_archive_id IN (SELECT marine_archive_id FROM marine_archive WHERE marine_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)";
387 387
 		}
388 388
 		try {
389 389
 			$sth = $this->db->prepare($query);
@@ -394,42 +394,42 @@  discard block
 block discarded – undo
394 394
 		}
395 395
 	}
396 396
 
397
-    /**
398
-     * Gets Minimal Live Marine data
399
-     *
400
-     * @param $begindate
401
-     * @param $enddate
402
-     * @param array $filter
403
-     * @return array the spotter information
404
-     */
405
-    public function getMinLiveMarineData($begindate,$enddate,$filter = array())
406
-    {
407
-        global $globalDBdriver;
408
-        date_default_timezone_set('UTC');
409
-
410
-        $filter_query = '';
411
-        if (isset($filter['source']) && !empty($filter['source'])) {
412
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
413
-        }
414
-        // Use spotter_output also ?
415
-        if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
-            $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 ";
417
-        }
418
-        if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419
-            $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 ";
420
-        }
421
-        if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
422
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
423
-        }
424
-
425
-        //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
426
-        if ($globalDBdriver == 'mysql') {
427
-            /*
397
+	/**
398
+	 * Gets Minimal Live Marine data
399
+	 *
400
+	 * @param $begindate
401
+	 * @param $enddate
402
+	 * @param array $filter
403
+	 * @return array the spotter information
404
+	 */
405
+	public function getMinLiveMarineData($begindate,$enddate,$filter = array())
406
+	{
407
+		global $globalDBdriver;
408
+		date_default_timezone_set('UTC');
409
+
410
+		$filter_query = '';
411
+		if (isset($filter['source']) && !empty($filter['source'])) {
412
+			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
413
+		}
414
+		// Use spotter_output also ?
415
+		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
+			$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 ";
417
+		}
418
+		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419
+			$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 ";
420
+		}
421
+		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
422
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
423
+		}
424
+
425
+		//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
426
+		if ($globalDBdriver == 'mysql') {
427
+			/*
428 428
                         $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 
429 429
                     		    FROM marine_archive 
430 430
                     		    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';
431 431
 			*/
432
-            /*
432
+			/*
433 433
 			$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 
434 434
 				    FROM marine_archive 
435 435
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
@@ -438,541 +438,541 @@  discard block
 block discarded – undo
438 438
 						GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id 
439 439
 				    AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
440 440
 */
441
-            $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 
441
+			$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 
442 442
 				    FROM marine_archive 
443 443
 				    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
444 444
 				    WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
445 445
                         	    '.$filter_query.' ORDER BY fammarine_id';
446
-        } else {
447
-            //$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';
448
-            $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 
446
+		} else {
447
+			//$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';
448
+			$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 
449 449
                         	    FROM marine_archive 
450 450
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
451 451
                         	    WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'
452 452
                         	    '.$filter_query.' ORDER BY fammarine_id';
453
-        }
454
-        //echo $query;
455
-        try {
456
-            $sth = $this->db->prepare($query);
457
-            $sth->execute();
458
-        } catch(PDOException $e) {
459
-            echo $e->getMessage();
460
-            die;
461
-        }
462
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
463
-
464
-        return $spotter_array;
465
-    }
466
-
467
-    /**
468
-     * Gets Minimal Live Marine data
469
-     *
470
-     * @param $begindate
471
-     * @param $enddate
472
-     * @param array $filter
473
-     * @return array the spotter information
474
-     */
475
-    public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
476
-    {
477
-        global $globalDBdriver;
478
-        date_default_timezone_set('UTC');
479
-
480
-        $filter_query = '';
481
-        if (isset($filter['source']) && !empty($filter['source'])) {
482
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
483
-        }
484
-        // Should use spotter_output also ?
485
-        if (isset($filter['airlines']) && !empty($filter['airlines'])) {
486
-            $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 ";
487
-        }
488
-        if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
489
-            $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 ";
490
-        }
491
-        if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
492
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
493
-        }
494
-
495
-        //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
496
-        if ($globalDBdriver == 'mysql') {
497
-            /*
453
+		}
454
+		//echo $query;
455
+		try {
456
+			$sth = $this->db->prepare($query);
457
+			$sth->execute();
458
+		} catch(PDOException $e) {
459
+			echo $e->getMessage();
460
+			die;
461
+		}
462
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
463
+
464
+		return $spotter_array;
465
+	}
466
+
467
+	/**
468
+	 * Gets Minimal Live Marine data
469
+	 *
470
+	 * @param $begindate
471
+	 * @param $enddate
472
+	 * @param array $filter
473
+	 * @return array the spotter information
474
+	 */
475
+	public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
476
+	{
477
+		global $globalDBdriver;
478
+		date_default_timezone_set('UTC');
479
+
480
+		$filter_query = '';
481
+		if (isset($filter['source']) && !empty($filter['source'])) {
482
+			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
483
+		}
484
+		// Should use spotter_output also ?
485
+		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
486
+			$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 ";
487
+		}
488
+		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
489
+			$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 ";
490
+		}
491
+		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
492
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
493
+		}
494
+
495
+		//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
496
+		if ($globalDBdriver == 'mysql') {
497
+			/*
498 498
                         $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 
499 499
                     		    FROM marine_archive 
500 500
                     		    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';
501 501
 			*/
502
-            $query  = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk 
502
+			$query  = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk 
503 503
 				    FROM marine_archive_output 
504 504
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao 
505 505
 				    WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
506 506
                         	    '.$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';
507 507
 
508
-        } else {
509
-            //$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';
510
-            /*
508
+		} else {
509
+			//$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';
510
+			/*
511 511
                         $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
512 512
                         	    FROM marine_archive_output 
513 513
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
514 514
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
515 515
                         	    '.$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';
516 516
                         */
517
-            $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
517
+			$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
518 518
                         	    FROM marine_archive_output 
519 519
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
520 520
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
521 521
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
522 522
 //                        	    .' 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';
523 523
                         	    
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
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
534
-
535
-        return $spotter_array;
536
-    }
537
-
538
-    /**
539
-     * Gets count Live Marine data
540
-     *
541
-     * @param $begindate
542
-     * @param $enddate
543
-     * @param array $filter
544
-     * @return array the spotter information
545
-     */
546
-    public function getLiveMarineCount($begindate,$enddate,$filter = array())
547
-    {
548
-        global $globalDBdriver, $globalLiveInterval;
549
-        date_default_timezone_set('UTC');
550
-
551
-        $filter_query = '';
552
-        if (isset($filter['source']) && !empty($filter['source'])) {
553
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
554
-        }
555
-        if (isset($filter['airlines']) && !empty($filter['airlines'])) {
556
-            $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 ";
557
-        }
558
-        if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
559
-            $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 ";
560
-        }
561
-        if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
562
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
563
-        }
564
-
565
-        //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
566
-        if ($globalDBdriver == 'mysql') {
567
-            $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb 
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
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
534
+
535
+		return $spotter_array;
536
+	}
537
+
538
+	/**
539
+	 * Gets count Live Marine data
540
+	 *
541
+	 * @param $begindate
542
+	 * @param $enddate
543
+	 * @param array $filter
544
+	 * @return array the spotter information
545
+	 */
546
+	public function getLiveMarineCount($begindate,$enddate,$filter = array())
547
+	{
548
+		global $globalDBdriver, $globalLiveInterval;
549
+		date_default_timezone_set('UTC');
550
+
551
+		$filter_query = '';
552
+		if (isset($filter['source']) && !empty($filter['source'])) {
553
+			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
554
+		}
555
+		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
556
+			$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 ";
557
+		}
558
+		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
559
+			$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 ";
560
+		}
561
+		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
562
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
563
+		}
564
+
565
+		//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
566
+		if ($globalDBdriver == 'mysql') {
567
+			$query = 'SELECT COUNT(DISTINCT fammarine_id) as nb 
568 568
 			FROM marine_archive l 
569 569
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
570
-        } else {
571
-            $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
572
-        }
573
-        //echo $query;
574
-        try {
575
-            $sth = $this->db->prepare($query);
576
-            $sth->execute();
577
-        } catch(PDOException $e) {
578
-            echo $e->getMessage();
579
-            die;
580
-        }
581
-        $result = $sth->fetch(PDO::FETCH_ASSOC);
582
-        $sth->closeCursor();
583
-        return $result['nb'];
584
-    }
570
+		} else {
571
+			$query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
572
+		}
573
+		//echo $query;
574
+		try {
575
+			$sth = $this->db->prepare($query);
576
+			$sth->execute();
577
+		} catch(PDOException $e) {
578
+			echo $e->getMessage();
579
+			die;
580
+		}
581
+		$result = $sth->fetch(PDO::FETCH_ASSOC);
582
+		$sth->closeCursor();
583
+		return $result['nb'];
584
+	}
585 585
 
586 586
 
587 587
 
588 588
 	// marine_archive_output
589 589
 
590
-    /**
591
-     * Gets all the spotter information
592
-     *
593
-     * @param string $q
594
-     * @param string $registration
595
-     * @param string $aircraft_icao
596
-     * @param string $aircraft_manufacturer
597
-     * @param string $highlights
598
-     * @param string $airline_icao
599
-     * @param string $airline_country
600
-     * @param string $airline_type
601
-     * @param string $airport
602
-     * @param string $airport_country
603
-     * @param string $callsign
604
-     * @param string $departure_airport_route
605
-     * @param string $arrival_airport_route
606
-     * @param string $owner
607
-     * @param string $pilot_id
608
-     * @param string $pilot_name
609
-     * @param string $altitude
610
-     * @param string $date_posted
611
-     * @param string $limit
612
-     * @param string $sort
613
-     * @param string $includegeodata
614
-     * @param string $origLat
615
-     * @param string $origLon
616
-     * @param string $dist
617
-     * @param array $filters
618
-     * @return array the spotter information
619
-     */
620
-    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())
621
-    {
622
-        global $globalTimezone, $globalDBdriver;
623
-        require_once(dirname(__FILE__).'/class.Translation.php');
624
-        $Translation = new Translation($this->db);
625
-        $Marine = new Marine($this->db);
626
-
627
-        date_default_timezone_set('UTC');
590
+	/**
591
+	 * Gets all the spotter information
592
+	 *
593
+	 * @param string $q
594
+	 * @param string $registration
595
+	 * @param string $aircraft_icao
596
+	 * @param string $aircraft_manufacturer
597
+	 * @param string $highlights
598
+	 * @param string $airline_icao
599
+	 * @param string $airline_country
600
+	 * @param string $airline_type
601
+	 * @param string $airport
602
+	 * @param string $airport_country
603
+	 * @param string $callsign
604
+	 * @param string $departure_airport_route
605
+	 * @param string $arrival_airport_route
606
+	 * @param string $owner
607
+	 * @param string $pilot_id
608
+	 * @param string $pilot_name
609
+	 * @param string $altitude
610
+	 * @param string $date_posted
611
+	 * @param string $limit
612
+	 * @param string $sort
613
+	 * @param string $includegeodata
614
+	 * @param string $origLat
615
+	 * @param string $origLon
616
+	 * @param string $dist
617
+	 * @param array $filters
618
+	 * @return array the spotter information
619
+	 */
620
+	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())
621
+	{
622
+		global $globalTimezone, $globalDBdriver;
623
+		require_once(dirname(__FILE__).'/class.Translation.php');
624
+		$Translation = new Translation($this->db);
625
+		$Marine = new Marine($this->db);
626
+
627
+		date_default_timezone_set('UTC');
628 628
 	
629
-        $query_values = array();
630
-        $additional_query = '';
631
-        $limit_query = '';
632
-        $filter_query = $this->getFilter($filters);
633
-        if ($q != "")
634
-        {
635
-            if (!is_string($q))
636
-            {
637
-                return array();
638
-            } else {
639
-                $q_array = explode(" ", $q);
629
+		$query_values = array();
630
+		$additional_query = '';
631
+		$limit_query = '';
632
+		$filter_query = $this->getFilter($filters);
633
+		if ($q != "")
634
+		{
635
+			if (!is_string($q))
636
+			{
637
+				return array();
638
+			} else {
639
+				$q_array = explode(" ", $q);
640 640
 		
641
-                foreach ($q_array as $q_item){
642
-                    $additional_query .= " AND (";
643
-                    $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
644
-                    $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
645
-                    $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";
646
-                    $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
647
-                    $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";
648
-                    $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";
649
-                    $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";
650
-                    $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
651
-                    $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";
652
-                    $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";
653
-                    $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";
654
-                    $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
655
-                    $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
656
-                    $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
657
-                    $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
658
-                    $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";
659
-                    $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";
660
-                    $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";
661
-                    $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
662
-                    $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
663
-                    $translate = $Translation->ident2icao($q_item);
664
-                    if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
665
-                    $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
666
-                    $additional_query .= ")";
667
-                }
668
-            }
669
-        }
641
+				foreach ($q_array as $q_item){
642
+					$additional_query .= " AND (";
643
+					$additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
644
+					$additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
645
+					$additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";
646
+					$additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
647
+					$additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";
648
+					$additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";
649
+					$additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";
650
+					$additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
651
+					$additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";
652
+					$additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";
653
+					$additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";
654
+					$additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
655
+					$additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
656
+					$additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
657
+					$additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
658
+					$additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";
659
+					$additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";
660
+					$additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";
661
+					$additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
662
+					$additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
663
+					$translate = $Translation->ident2icao($q_item);
664
+					if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
665
+					$additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
666
+					$additional_query .= ")";
667
+				}
668
+			}
669
+		}
670 670
 	
671
-        if ($registration != "")
672
-        {
673
-            $registration = filter_var($registration,FILTER_SANITIZE_STRING);
674
-            if (!is_string($registration))
675
-            {
676
-                return array();
677
-            } else {
678
-                $additional_query .= " AND (marine_archive_output.registration = '".$registration."')";
679
-            }
680
-        }
671
+		if ($registration != "")
672
+		{
673
+			$registration = filter_var($registration,FILTER_SANITIZE_STRING);
674
+			if (!is_string($registration))
675
+			{
676
+				return array();
677
+			} else {
678
+				$additional_query .= " AND (marine_archive_output.registration = '".$registration."')";
679
+			}
680
+		}
681 681
 	
682
-        if ($aircraft_icao != "")
683
-        {
684
-            $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
685
-            if (!is_string($aircraft_icao))
686
-            {
687
-                return array();
688
-            } else {
689
-                $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')";
690
-            }
691
-        }
682
+		if ($aircraft_icao != "")
683
+		{
684
+			$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
685
+			if (!is_string($aircraft_icao))
686
+			{
687
+				return array();
688
+			} else {
689
+				$additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')";
690
+			}
691
+		}
692 692
 	
693
-        if ($aircraft_manufacturer != "")
694
-        {
695
-            $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
696
-            if (!is_string($aircraft_manufacturer))
697
-            {
698
-                return array();
699
-	    } else {
700
-                $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
701
-            }
702
-        }
693
+		if ($aircraft_manufacturer != "")
694
+		{
695
+			$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
696
+			if (!is_string($aircraft_manufacturer))
697
+			{
698
+				return array();
699
+		} else {
700
+				$additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
701
+			}
702
+		}
703 703
 	
704
-        if ($highlights == "true")
705
-        {
706
-            if (!is_string($highlights))
707
-            {
708
-                return array();
709
-            } else {
710
-                $additional_query .= " AND (marine_archive_output.highlight <> '')";
711
-            }
712
-        }
704
+		if ($highlights == "true")
705
+		{
706
+			if (!is_string($highlights))
707
+			{
708
+				return array();
709
+			} else {
710
+				$additional_query .= " AND (marine_archive_output.highlight <> '')";
711
+			}
712
+		}
713 713
 	
714
-        if ($airline_icao != "")
715
-        {
716
-            $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
717
-            if (!is_string($airline_icao))
718
-            {
719
-                return array();
720
-            } else {
721
-                $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')";
722
-            }
723
-        }
714
+		if ($airline_icao != "")
715
+		{
716
+			$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
717
+			if (!is_string($airline_icao))
718
+			{
719
+				return array();
720
+			} else {
721
+				$additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')";
722
+			}
723
+		}
724 724
 	
725
-        if ($airline_country != "")
726
-        {
727
-            $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
728
-            if (!is_string($airline_country))
729
-            {
730
-                return array();
731
-            } else {
732
-                $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')";
733
-            }
734
-        }
725
+		if ($airline_country != "")
726
+		{
727
+			$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
728
+			if (!is_string($airline_country))
729
+			{
730
+				return array();
731
+			} else {
732
+				$additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')";
733
+			}
734
+		}
735 735
 	
736
-        if ($airline_type != "")
737
-        {
738
-            $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
739
-            if (!is_string($airline_type))
740
-            {
741
-                return array();
742
-            } else {
743
-                if ($airline_type == "passenger")
744
-                {
745
-                    $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";
746
-                }
747
-                if ($airline_type == "cargo")
748
-                {
749
-                    $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";
750
-                }
751
-                if ($airline_type == "military")
752
-                {
753
-                    $additional_query .= " AND (marine_archive_output.airline_type = 'military')";
754
-                }
755
-            }
756
-        }
736
+		if ($airline_type != "")
737
+		{
738
+			$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
739
+			if (!is_string($airline_type))
740
+			{
741
+				return array();
742
+			} else {
743
+				if ($airline_type == "passenger")
744
+				{
745
+					$additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";
746
+				}
747
+				if ($airline_type == "cargo")
748
+				{
749
+					$additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";
750
+				}
751
+				if ($airline_type == "military")
752
+				{
753
+					$additional_query .= " AND (marine_archive_output.airline_type = 'military')";
754
+				}
755
+			}
756
+		}
757 757
 	
758
-        if ($airport != "")
759
-        {
760
-            $airport = filter_var($airport,FILTER_SANITIZE_STRING);
761
-            if (!is_string($airport))
762
-            {
763
-                return array();
764
-            } else {
765
-                $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))";
766
-            }
767
-        }
758
+		if ($airport != "")
759
+		{
760
+			$airport = filter_var($airport,FILTER_SANITIZE_STRING);
761
+			if (!is_string($airport))
762
+			{
763
+				return array();
764
+			} else {
765
+				$additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))";
766
+			}
767
+		}
768 768
 	
769
-        if ($airport_country != "")
770
-        {
771
-            $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
772
-            if (!is_string($airport_country))
773
-            {
774
-                return array();
775
-            } else {
776
-                $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))";
777
-            }
778
-        }
769
+		if ($airport_country != "")
770
+		{
771
+			$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
772
+			if (!is_string($airport_country))
773
+			{
774
+				return array();
775
+			} else {
776
+				$additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))";
777
+			}
778
+		}
779 779
     
780
-        if ($callsign != "")
781
-        {
782
-            $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
783
-            if (!is_string($callsign))
784
-            {
785
-                return array();
786
-            } else {
787
-                $translate = $Translation->ident2icao($callsign);
788
-                if ($translate != $callsign) {
789
-                    $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";
790
-                    $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
791
-                } else {
792
-                    $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";
793
-                }
794
-            }
795
-        }
796
-
797
-        if ($owner != "")
798
-        {
799
-            $owner = filter_var($owner,FILTER_SANITIZE_STRING);
800
-            if (!is_string($owner))
801
-            {
802
-                return array();
803
-            } else {
804
-                $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')";
805
-            }
806
-        }
807
-
808
-        if ($pilot_name != "")
809
-        {
810
-            $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
811
-            if (!is_string($pilot_name))
812
-            {
813
-                return array();
814
-            } else {
815
-                $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')";
816
-            }
817
-        }
780
+		if ($callsign != "")
781
+		{
782
+			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
783
+			if (!is_string($callsign))
784
+			{
785
+				return array();
786
+			} else {
787
+				$translate = $Translation->ident2icao($callsign);
788
+				if ($translate != $callsign) {
789
+					$additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";
790
+					$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
791
+				} else {
792
+					$additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";
793
+				}
794
+			}
795
+		}
796
+
797
+		if ($owner != "")
798
+		{
799
+			$owner = filter_var($owner,FILTER_SANITIZE_STRING);
800
+			if (!is_string($owner))
801
+			{
802
+				return array();
803
+			} else {
804
+				$additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')";
805
+			}
806
+		}
807
+
808
+		if ($pilot_name != "")
809
+		{
810
+			$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
811
+			if (!is_string($pilot_name))
812
+			{
813
+				return array();
814
+			} else {
815
+				$additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')";
816
+			}
817
+		}
818 818
 	
819
-        if ($pilot_id != "")
820
-        {
821
-            $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
822
-            if (!is_string($pilot_id))
823
-            {
824
-                return array();
825
-            } else {
826
-                $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')";
827
-            }
828
-        }
819
+		if ($pilot_id != "")
820
+		{
821
+			$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
822
+			if (!is_string($pilot_id))
823
+			{
824
+				return array();
825
+			} else {
826
+				$additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')";
827
+			}
828
+		}
829 829
 	
830
-        if ($departure_airport_route != "")
831
-        {
832
-            $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
833
-            if (!is_string($departure_airport_route))
834
-            {
835
-                return array();
836
-            } else {
837
-                $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')";
838
-            }
839
-        }
830
+		if ($departure_airport_route != "")
831
+		{
832
+			$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
833
+			if (!is_string($departure_airport_route))
834
+			{
835
+				return array();
836
+			} else {
837
+				$additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')";
838
+			}
839
+		}
840 840
 	
841
-        if ($arrival_airport_route != "")
842
-        {
843
-            $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
844
-            if (!is_string($arrival_airport_route))
845
-            {
846
-                return array();
847
-            } else {
848
-                $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
849
-            }
850
-        }
841
+		if ($arrival_airport_route != "")
842
+		{
843
+			$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
844
+			if (!is_string($arrival_airport_route))
845
+			{
846
+				return array();
847
+			} else {
848
+				$additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
849
+			}
850
+		}
851 851
 	
852
-        if ($altitude != "")
853
-        {
854
-            $altitude_array = explode(",", $altitude);
852
+		if ($altitude != "")
853
+		{
854
+			$altitude_array = explode(",", $altitude);
855 855
 	    
856
-            $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
857
-            $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
856
+			$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
857
+			$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
858 858
 	    
859 859
 
860
-            if ($altitude_array[1] != "")
861
-            {
862
-                $altitude_array[0] = substr($altitude_array[0], 0, -2);
863
-                $altitude_array[1] = substr($altitude_array[1], 0, -2);
864
-                $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
865
-            } else {
866
-                $altitude_array[0] = substr($altitude_array[0], 0, -2);
867
-                $additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
868
-            }
869
-        }
860
+			if ($altitude_array[1] != "")
861
+			{
862
+				$altitude_array[0] = substr($altitude_array[0], 0, -2);
863
+				$altitude_array[1] = substr($altitude_array[1], 0, -2);
864
+				$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
865
+			} else {
866
+				$altitude_array[0] = substr($altitude_array[0], 0, -2);
867
+				$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
868
+			}
869
+		}
870 870
 	
871
-        if ($date_posted != "")
872
-        {
873
-            $date_array = explode(",", $date_posted);
871
+		if ($date_posted != "")
872
+		{
873
+			$date_array = explode(",", $date_posted);
874 874
 	    
875
-            $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
876
-            $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
875
+			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
876
+			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
877 877
 	    
878
-            if ($globalTimezone != '') {
879
-                date_default_timezone_set($globalTimezone);
880
-                $datetime = new DateTime();
881
-                $offset = $datetime->format('P');
882
-            } else $offset = '+00:00';
883
-
884
-
885
-            if ($date_array[1] != "")
886
-            {
887
-                $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
888
-                $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
889
-                if ($globalDBdriver == 'mysql') {
890
-                    $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' ";
891
-                } else {
892
-                    $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) ";
893
-                }
894
-            } else {
895
-                $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
896
-                if ($globalDBdriver == 'mysql') {
897
-                    $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
898
-                } else {
899
-                    $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
900
-                }
901
-            }
902
-        }
878
+			if ($globalTimezone != '') {
879
+				date_default_timezone_set($globalTimezone);
880
+				$datetime = new DateTime();
881
+				$offset = $datetime->format('P');
882
+			} else $offset = '+00:00';
883
+
884
+
885
+			if ($date_array[1] != "")
886
+			{
887
+				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
888
+				$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
889
+				if ($globalDBdriver == 'mysql') {
890
+					$additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' ";
891
+				} else {
892
+					$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) ";
893
+				}
894
+			} else {
895
+				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
896
+				if ($globalDBdriver == 'mysql') {
897
+					$additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
898
+				} else {
899
+					$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
900
+				}
901
+			}
902
+		}
903 903
 	
904
-        if ($limit != "")
905
-        {
906
-            $limit_array = explode(",", $limit);
904
+		if ($limit != "")
905
+		{
906
+			$limit_array = explode(",", $limit);
907 907
 	    
908
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
909
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
908
+			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
909
+			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
910 910
 	    
911
-            if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
912
-            {
913
-                //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
914
-                $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
915
-            }
916
-        }
911
+			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
912
+			{
913
+				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
914
+				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
915
+			}
916
+		}
917 917
 	
918 918
 
919
-        if ($origLat != "" && $origLon != "" && $dist != "") {
920
-            $dist = number_format($dist*0.621371,2,'.','');
921
-            $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
919
+		if ($origLat != "" && $origLon != "" && $dist != "") {
920
+			$dist = number_format($dist*0.621371,2,'.','');
921
+			$query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
922 922
                           FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
923 923
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
924
-        } else {
925
-            if ($sort != "")
926
-            {
927
-                $search_orderby_array = $Marine->getOrderBy();
928
-                $orderby_query = $search_orderby_array[$sort]['sql'];
929
-            } else {
930
-                $orderby_query = " ORDER BY marine_archive_output.date DESC";
931
-            }
924
+		} else {
925
+			if ($sort != "")
926
+			{
927
+				$search_orderby_array = $Marine->getOrderBy();
928
+				$orderby_query = $search_orderby_array[$sort]['sql'];
929
+			} else {
930
+				$orderby_query = " ORDER BY marine_archive_output.date DESC";
931
+			}
932 932
 	
933
-            if ($includegeodata == "true")
934
-            {
935
-                $additional_query .= " AND (marine_archive_output.waypoints <> '')";
936
-            }
933
+			if ($includegeodata == "true")
934
+			{
935
+				$additional_query .= " AND (marine_archive_output.waypoints <> '')";
936
+			}
937 937
 
938
-            $query  = "SELECT marine_archive_output.* FROM marine_archive_output 
938
+			$query  = "SELECT marine_archive_output.* FROM marine_archive_output 
939 939
 		    WHERE marine_archive_output.ident <> '' 
940 940
 		    ".$additional_query."
941 941
 		    ".$filter_query.$orderby_query;
942
-        }
943
-        $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);
944
-
945
-        return $spotter_array;
946
-    }
947
-
948
-    public function deleteMarineArchiveData()
949
-    {
950
-        global $globalArchiveKeepMonths, $globalDBdriver;
951
-        date_default_timezone_set('UTC');
952
-        if ($globalDBdriver == 'mysql') {
953
-            $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
954
-        } else {
955
-            $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
956
-        }
957
-        try {
958
-            $sth = $this->db->prepare($query);
959
-            $sth->execute();
960
-        } catch(PDOException $e) {
961
-            return "error";
962
-        }
963
-        return '';
964
-    }
965
-
966
-    /**
967
-     * Gets all the spotter information based on the callsign
968
-     *
969
-     * @param string $ident
970
-     * @param string $limit
971
-     * @param string $sort
972
-     * @return array the spotter information
973
-     */
974
-    public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')
975
-    {
942
+		}
943
+		$spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);
944
+
945
+		return $spotter_array;
946
+	}
947
+
948
+	public function deleteMarineArchiveData()
949
+	{
950
+		global $globalArchiveKeepMonths, $globalDBdriver;
951
+		date_default_timezone_set('UTC');
952
+		if ($globalDBdriver == 'mysql') {
953
+			$query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
954
+		} else {
955
+			$query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
956
+		}
957
+		try {
958
+			$sth = $this->db->prepare($query);
959
+			$sth->execute();
960
+		} catch(PDOException $e) {
961
+			return "error";
962
+		}
963
+		return '';
964
+	}
965
+
966
+	/**
967
+	 * Gets all the spotter information based on the callsign
968
+	 *
969
+	 * @param string $ident
970
+	 * @param string $limit
971
+	 * @param string $sort
972
+	 * @return array the spotter information
973
+	 */
974
+	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')
975
+	{
976 976
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
977 977
 	
978 978
 	date_default_timezone_set('UTC');
@@ -984,35 +984,35 @@  discard block
 block discarded – undo
984 984
 	
985 985
 	if ($ident != "")
986 986
 	{
987
-	    if (!is_string($ident))
988
-	    {
989
-            return array();
990
-        } else {
991
-            $additional_query = " AND (marine_archive_output.ident = :ident)";
992
-            $query_values = array(':ident' => $ident);
993
-	    }
987
+		if (!is_string($ident))
988
+		{
989
+			return array();
990
+		} else {
991
+			$additional_query = " AND (marine_archive_output.ident = :ident)";
992
+			$query_values = array(':ident' => $ident);
993
+		}
994 994
 	}
995 995
 	
996 996
 	if ($limit != "")
997 997
 	{
998
-	    $limit_array = explode(",", $limit);
998
+		$limit_array = explode(",", $limit);
999 999
 	    
1000
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1001
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1000
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1001
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1002 1002
 	    
1003
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1004
-	    {
1003
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1004
+		{
1005 1005
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1006 1006
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1007
-	    }
1007
+		}
1008 1008
 	}
1009 1009
 
1010 1010
 	if ($sort != "")
1011 1011
 	{
1012
-	    $search_orderby_array = $Marine->getOrderBy();
1013
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1012
+		$search_orderby_array = $Marine->getOrderBy();
1013
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1014 1014
 	} else {
1015
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1015
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1016 1016
 	}
1017 1017
 
1018 1018
 	$query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -1020,20 +1020,20 @@  discard block
 block discarded – undo
1020 1020
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1021 1021
 
1022 1022
 	return $spotter_array;
1023
-    }
1024
-
1025
-
1026
-    /**
1027
-     * Gets all the spotter information based on the owner
1028
-     *
1029
-     * @param string $owner
1030
-     * @param string $limit
1031
-     * @param string $sort
1032
-     * @param array $filter
1033
-     * @return array the spotter information
1034
-     */
1035
-    public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1036
-    {
1023
+	}
1024
+
1025
+
1026
+	/**
1027
+	 * Gets all the spotter information based on the owner
1028
+	 *
1029
+	 * @param string $owner
1030
+	 * @param string $limit
1031
+	 * @param string $sort
1032
+	 * @param array $filter
1033
+	 * @return array the spotter information
1034
+	 */
1035
+	public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1036
+	{
1037 1037
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
1038 1038
 	
1039 1039
 	date_default_timezone_set('UTC');
@@ -1046,35 +1046,35 @@  discard block
 block discarded – undo
1046 1046
 	
1047 1047
 	if ($owner != "")
1048 1048
 	{
1049
-	    if (!is_string($owner))
1050
-	    {
1049
+		if (!is_string($owner))
1050
+		{
1051 1051
 		return array();
1052
-	    } else {
1052
+		} else {
1053 1053
 		$additional_query = " AND (marine_archive_output.owner_name = :owner)";
1054 1054
 		$query_values = array(':owner' => $owner);
1055
-	    }
1055
+		}
1056 1056
 	}
1057 1057
 	
1058 1058
 	if ($limit != "")
1059 1059
 	{
1060
-	    $limit_array = explode(",", $limit);
1060
+		$limit_array = explode(",", $limit);
1061 1061
 	    
1062
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1063
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1062
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1063
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1064 1064
 	    
1065
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1066
-	    {
1065
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1066
+		{
1067 1067
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1068 1068
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1069
-	    }
1069
+		}
1070 1070
 	}
1071 1071
 
1072 1072
 	if ($sort != "")
1073 1073
 	{
1074
-	    $search_orderby_array = $Marine->getOrderBy();
1075
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1074
+		$search_orderby_array = $Marine->getOrderBy();
1075
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1076 1076
 	} else {
1077
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1077
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1078 1078
 	}
1079 1079
 
1080 1080
 	$query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1082,19 +1082,19 @@  discard block
 block discarded – undo
1082 1082
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1083 1083
 
1084 1084
 	return $spotter_array;
1085
-    }
1086
-
1087
-    /**
1088
-     * Gets all the spotter information based on the pilot
1089
-     *
1090
-     * @param string $pilot
1091
-     * @param string $limit
1092
-     * @param string $sort
1093
-     * @param array $filter
1094
-     * @return array the spotter information
1095
-     */
1096
-    public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1097
-    {
1085
+	}
1086
+
1087
+	/**
1088
+	 * Gets all the spotter information based on the pilot
1089
+	 *
1090
+	 * @param string $pilot
1091
+	 * @param string $limit
1092
+	 * @param string $sort
1093
+	 * @param array $filter
1094
+	 * @return array the spotter information
1095
+	 */
1096
+	public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1097
+	{
1098 1098
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
1099 1099
 	
1100 1100
 	date_default_timezone_set('UTC');
@@ -1113,24 +1113,24 @@  discard block
 block discarded – undo
1113 1113
 	
1114 1114
 	if ($limit != "")
1115 1115
 	{
1116
-	    $limit_array = explode(",", $limit);
1116
+		$limit_array = explode(",", $limit);
1117 1117
 	    
1118
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1119
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1118
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1119
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1120 1120
 	    
1121
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1122
-	    {
1121
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1122
+		{
1123 1123
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1124 1124
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1125
-	    }
1125
+		}
1126 1126
 	}
1127 1127
 
1128 1128
 	if ($sort != "")
1129 1129
 	{
1130
-	    $search_orderby_array = $Marine->getOrderBy();
1131
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1130
+		$search_orderby_array = $Marine->getOrderBy();
1131
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1132 1132
 	} else {
1133
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1133
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1134 1134
 	}
1135 1135
 
1136 1136
 	$query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1138,18 +1138,18 @@  discard block
 block discarded – undo
1138 1138
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1139 1139
 
1140 1140
 	return $spotter_array;
1141
-    }
1142
-
1143
-    /**
1144
-     * Gets all number of flight over countries
1145
-     *
1146
-     * @param bool $limit
1147
-     * @param int $olderthanmonths
1148
-     * @param string $sincedate
1149
-     * @return array the airline country list
1150
-     */
1151
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1152
-    {
1141
+	}
1142
+
1143
+	/**
1144
+	 * Gets all number of flight over countries
1145
+	 *
1146
+	 * @param bool $limit
1147
+	 * @param int $olderthanmonths
1148
+	 * @param string $sincedate
1149
+	 * @return array the airline country list
1150
+	 */
1151
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1152
+	{
1153 1153
 	global $globalDBdriver;
1154 1154
 	/*
1155 1155
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1159,14 +1159,14 @@  discard block
 block discarded – undo
1159 1159
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1160 1160
 		    FROM countries c, marine_archive s
1161 1161
 		    WHERE c.iso2 = s.over_country ";
1162
-                if ($olderthanmonths > 0) {
1163
-            		if ($globalDBdriver == 'mysql') {
1162
+				if ($olderthanmonths > 0) {
1163
+					if ($globalDBdriver == 'mysql') {
1164 1164
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1165 1165
 			} else {
1166 1166
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1167 1167
 			}
1168 1168
 		}
1169
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1169
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1170 1170
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1171 1171
 	if ($limit) $query .= " LIMIT 0,10";
1172 1172
       
@@ -1179,25 +1179,25 @@  discard block
 block discarded – undo
1179 1179
         
1180 1180
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1181 1181
 	{
1182
-	    $temp_array['flight_count'] = $row['nb'];
1183
-	    $temp_array['flight_country'] = $row['name'];
1184
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1185
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1186
-	    $flight_array[] = $temp_array;
1182
+		$temp_array['flight_count'] = $row['nb'];
1183
+		$temp_array['flight_country'] = $row['name'];
1184
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1185
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1186
+		$flight_array[] = $temp_array;
1187 1187
 	}
1188 1188
 	return $flight_array;
1189
-    }
1190
-
1191
-    /**
1192
-     * Gets all number of flight over countries
1193
-     *
1194
-     * @param bool $limit
1195
-     * @param int $olderthanmonths
1196
-     * @param string $sincedate
1197
-     * @return array the airline country list
1198
-     */
1199
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1200
-    {
1189
+	}
1190
+
1191
+	/**
1192
+	 * Gets all number of flight over countries
1193
+	 *
1194
+	 * @param bool $limit
1195
+	 * @param int $olderthanmonths
1196
+	 * @param string $sincedate
1197
+	 * @return array the airline country list
1198
+	 */
1199
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1200
+	{
1201 1201
 	global $globalDBdriver;
1202 1202
 	/*
1203 1203
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1207,14 +1207,14 @@  discard block
 block discarded – undo
1207 1207
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1208 1208
 		    FROM countries c, marine_archive s, spotter_output o
1209 1209
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id ";
1210
-                if ($olderthanmonths > 0) {
1211
-            		if ($globalDBdriver == 'mysql') {
1210
+				if ($olderthanmonths > 0) {
1211
+					if ($globalDBdriver == 'mysql') {
1212 1212
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1213 1213
 			} else {
1214 1214
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1215 1215
 			}
1216 1216
 		}
1217
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1217
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1218 1218
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1219 1219
 	if ($limit) $query .= " LIMIT 0,10";
1220 1220
       
@@ -1227,25 +1227,25 @@  discard block
 block discarded – undo
1227 1227
         
1228 1228
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1229 1229
 	{
1230
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1231
-	    $temp_array['flight_count'] = $row['nb'];
1232
-	    $temp_array['flight_country'] = $row['name'];
1233
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1234
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1235
-	    $flight_array[] = $temp_array;
1230
+		$temp_array['airline_icao'] = $row['airline_icao'];
1231
+		$temp_array['flight_count'] = $row['nb'];
1232
+		$temp_array['flight_country'] = $row['name'];
1233
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1234
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1235
+		$flight_array[] = $temp_array;
1236 1236
 	}
1237 1237
 	return $flight_array;
1238
-    }
1239
-
1240
-    /**
1241
-     * Gets last spotter information based on a particular callsign
1242
-     *
1243
-     * @param $id
1244
-     * @param $date
1245
-     * @return array the spotter information
1246
-     */
1247
-    public function getDateArchiveMarineDataById($id,$date)
1248
-    {
1238
+	}
1239
+
1240
+	/**
1241
+	 * Gets last spotter information based on a particular callsign
1242
+	 *
1243
+	 * @param $id
1244
+	 * @param $date
1245
+	 * @return array the spotter information
1246
+	 */
1247
+	public function getDateArchiveMarineDataById($id,$date)
1248
+	{
1249 1249
 	$Marine = new Marine($this->db);
1250 1250
 	date_default_timezone_set('UTC');
1251 1251
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1253,17 +1253,17 @@  discard block
 block discarded – undo
1253 1253
 	$date = date('c',$date);
1254 1254
 	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date));
1255 1255
 	return $spotter_array;
1256
-    }
1257
-
1258
-    /**
1259
-     * Gets all the spotter information based on a particular callsign
1260
-     *
1261
-     * @param $ident
1262
-     * @param $date
1263
-     * @return array the spotter information
1264
-     */
1265
-    public function getDateArchiveMarineDataByIdent($ident,$date)
1266
-    {
1256
+	}
1257
+
1258
+	/**
1259
+	 * Gets all the spotter information based on a particular callsign
1260
+	 *
1261
+	 * @param $ident
1262
+	 * @param $date
1263
+	 * @return array the spotter information
1264
+	 */
1265
+	public function getDateArchiveMarineDataByIdent($ident,$date)
1266
+	{
1267 1267
 	$Marine = new Marine($this->db);
1268 1268
 	date_default_timezone_set('UTC');
1269 1269
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1271,65 +1271,65 @@  discard block
 block discarded – undo
1271 1271
 	$date = date('c',$date);
1272 1272
 	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1273 1273
 	return $spotter_array;
1274
-    }
1275
-
1276
-    /**
1277
-     * Gets all the spotter information based on the airport
1278
-     *
1279
-     * @param string $airport
1280
-     * @param string $limit
1281
-     * @param string $sort
1282
-     * @param array $filters
1283
-     * @return array the spotter information
1284
-     */
1285
-    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1286
-    {
1287
-        global $global_query;
1288
-        $Marine = new Marine($this->db);
1289
-        date_default_timezone_set('UTC');
1290
-        $query_values = array();
1291
-        $limit_query = '';
1292
-        $additional_query = '';
1293
-        $filter_query = $this->getFilter($filters,true,true);
1274
+	}
1275
+
1276
+	/**
1277
+	 * Gets all the spotter information based on the airport
1278
+	 *
1279
+	 * @param string $airport
1280
+	 * @param string $limit
1281
+	 * @param string $sort
1282
+	 * @param array $filters
1283
+	 * @return array the spotter information
1284
+	 */
1285
+	public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1286
+	{
1287
+		global $global_query;
1288
+		$Marine = new Marine($this->db);
1289
+		date_default_timezone_set('UTC');
1290
+		$query_values = array();
1291
+		$limit_query = '';
1292
+		$additional_query = '';
1293
+		$filter_query = $this->getFilter($filters,true,true);
1294 1294
 	
1295
-        if ($airport != "")
1296
-        {
1297
-            if (!is_string($airport))
1298
-            {
1299
-                return array();
1300
-            } else {
1301
-                $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))";
1302
-                $query_values = array(':airport' => $airport);
1303
-            }
1304
-        }
1295
+		if ($airport != "")
1296
+		{
1297
+			if (!is_string($airport))
1298
+			{
1299
+				return array();
1300
+			} else {
1301
+				$additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))";
1302
+				$query_values = array(':airport' => $airport);
1303
+			}
1304
+		}
1305 1305
 	
1306
-        if ($limit != "")
1307
-        {
1308
-            $limit_array = explode(",", $limit);
1306
+		if ($limit != "")
1307
+		{
1308
+			$limit_array = explode(",", $limit);
1309 1309
 	    
1310
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1311
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1310
+			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1311
+			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1312 1312
 	    
1313
-            if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1314
-            {
1315
-                //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1316
-                $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1317
-            }
1318
-        }
1313
+			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1314
+			{
1315
+				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1316
+				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1317
+			}
1318
+		}
1319 1319
 	
1320
-        if ($sort != "")
1321
-        {
1322
-            $search_orderby_array = $Marine->getOrderBy();
1323
-            $orderby_query = $search_orderby_array[$sort]['sql'];
1324
-        } else {
1325
-            $orderby_query = " ORDER BY marine_archive_output.date DESC";
1326
-        }
1320
+		if ($sort != "")
1321
+		{
1322
+			$search_orderby_array = $Marine->getOrderBy();
1323
+			$orderby_query = $search_orderby_array[$sort]['sql'];
1324
+		} else {
1325
+			$orderby_query = " ORDER BY marine_archive_output.date DESC";
1326
+		}
1327 1327
 
1328
-        $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;
1328
+		$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;
1329 1329
 
1330
-        $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1330
+		$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1331 1331
 
1332
-        return $spotter_array;
1333
-    }
1332
+		return $spotter_array;
1333
+	}
1334 1334
 }
1335 1335
 ?>
1336 1336
\ No newline at end of file
Please login to merge, or discard this patch.
require/class.TrackerArchive.php 1 patch
Indentation   +1070 added lines, -1070 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 		if ($this->db === null) die('Error: No DB connection. (TrackerArchive)');
17 17
 	}
18 18
 
19
-    /**
20
-     * Get SQL query part for filter used
21
-     * @param array $filter the filter
22
-     * @param bool $where
23
-     * @param bool $and
24
-     * @return string the SQL part
25
-     */
19
+	/**
20
+	 * Get SQL query part for filter used
21
+	 * @param array $filter the filter
22
+	 * @param bool $where
23
+	 * @param bool $and
24
+	 * @return string the SQL part
25
+	 */
26 26
 	public function getFilter($filter = array(),$where = false,$and = false) {
27 27
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
28 28
 		$filters = array();
@@ -91,27 +91,27 @@  discard block
 block discarded – undo
91 91
 		return $filter_query;
92 92
 	}
93 93
 
94
-    /**
95
-     * Add to tracker_archive
96
-     *
97
-     * @param string $famtrackid
98
-     * @param string $ident
99
-     * @param string $latitude
100
-     * @param string $longitude
101
-     * @param string $altitude
102
-     * @param string $heading
103
-     * @param string $groundspeed
104
-     * @param string $date
105
-     * @param bool $putinarchive
106
-     * @param string $comment
107
-     * @param string $type
108
-     * @param bool $noarchive
109
-     * @param string $format_source
110
-     * @param string $source_name
111
-     * @param string $over_country
112
-     * @return string
113
-     */
114
-    public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') {
94
+	/**
95
+	 * Add to tracker_archive
96
+	 *
97
+	 * @param string $famtrackid
98
+	 * @param string $ident
99
+	 * @param string $latitude
100
+	 * @param string $longitude
101
+	 * @param string $altitude
102
+	 * @param string $heading
103
+	 * @param string $groundspeed
104
+	 * @param string $date
105
+	 * @param bool $putinarchive
106
+	 * @param string $comment
107
+	 * @param string $type
108
+	 * @param bool $noarchive
109
+	 * @param string $format_source
110
+	 * @param string $source_name
111
+	 * @param string $over_country
112
+	 * @return string
113
+	 */
114
+	public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') {
115 115
 		require_once(dirname(__FILE__).'/class.Tracker.php');
116 116
 		if ($over_country == '') {
117 117
 			$Tracker = new Tracker($this->db);
@@ -134,40 +134,40 @@  discard block
 block discarded – undo
134 134
 	}
135 135
 
136 136
 
137
-    /**
138
-     * Gets all the spotter information based on a particular callsign
139
-     *
140
-     * @param $ident
141
-     * @return array the spotter information
142
-     */
143
-    public function getLastArchiveTrackerDataByIdent($ident)
144
-    {
145
-        $Tracker = new Tracker($this->db);
146
-        date_default_timezone_set('UTC');
147
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
148
-        $query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
149
-        $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
150
-        return $spotter_array;
151
-    }
152
-
153
-
154
-    /**
155
-     * Gets last the spotter information based on a particular id
156
-     *
157
-     * @param $id
158
-     * @return array the spotter information
159
-     */
160
-    public function getLastArchiveTrackerDataById($id)
161
-    {
162
-        $Tracker = new Tracker($this->db);
163
-        date_default_timezone_set('UTC');
164
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
165
-        //$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
166
-        //$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";
167
-        $query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
137
+	/**
138
+	 * Gets all the spotter information based on a particular callsign
139
+	 *
140
+	 * @param $ident
141
+	 * @return array the spotter information
142
+	 */
143
+	public function getLastArchiveTrackerDataByIdent($ident)
144
+	{
145
+		$Tracker = new Tracker($this->db);
146
+		date_default_timezone_set('UTC');
147
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
148
+		$query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
149
+		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
150
+		return $spotter_array;
151
+	}
152
+
153
+
154
+	/**
155
+	 * Gets last the spotter information based on a particular id
156
+	 *
157
+	 * @param $id
158
+	 * @return array the spotter information
159
+	 */
160
+	public function getLastArchiveTrackerDataById($id)
161
+	{
162
+		$Tracker = new Tracker($this->db);
163
+		date_default_timezone_set('UTC');
164
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
165
+		//$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
166
+		//$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";
167
+		$query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
168 168
 
169 169
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
170
-        /*
170
+		/*
171 171
                 try {
172 172
                         $Connection = new Connection();
173 173
                         $sth = Connection->$db->prepare($query);
@@ -177,245 +177,245 @@  discard block
 block discarded – undo
177 177
                 }
178 178
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
179 179
                 */
180
-        $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
181
-
182
-        return $spotter_array;
183
-    }
184
-
185
-    /**
186
-     * Gets all the spotter information based on a particular id
187
-     *
188
-     * @param $id
189
-     * @param string $date
190
-     * @return array the spotter information
191
-     */
192
-    public function getAllArchiveTrackerDataById($id,$date = '')
193
-    {
194
-        date_default_timezone_set('UTC');
195
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
196
-        if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
197
-        else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
180
+		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
181
+
182
+		return $spotter_array;
183
+	}
184
+
185
+	/**
186
+	 * Gets all the spotter information based on a particular id
187
+	 *
188
+	 * @param $id
189
+	 * @param string $date
190
+	 * @return array the spotter information
191
+	 */
192
+	public function getAllArchiveTrackerDataById($id,$date = '')
193
+	{
194
+		date_default_timezone_set('UTC');
195
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
196
+		if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
197
+		else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
198 198
 
199 199
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
200 200
 
201
-        try {
202
-            $sth = $this->db->prepare($query);
203
-            $sth->execute(array(':id' => $id));
204
-        } catch(PDOException $e) {
205
-            echo $e->getMessage();
206
-            die;
207
-        }
208
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
209
-
210
-        return $spotter_array;
211
-    }
212
-
213
-    /**
214
-     * Gets coordinate & time spotter information based on a particular id
215
-     *
216
-     * @param $id
217
-     * @return array the spotter information
218
-     */
219
-    public function getCoordArchiveTrackerDataById($id)
220
-    {
221
-        date_default_timezone_set('UTC');
222
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
223
-        $query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
201
+		try {
202
+			$sth = $this->db->prepare($query);
203
+			$sth->execute(array(':id' => $id));
204
+		} catch(PDOException $e) {
205
+			echo $e->getMessage();
206
+			die;
207
+		}
208
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
209
+
210
+		return $spotter_array;
211
+	}
212
+
213
+	/**
214
+	 * Gets coordinate & time spotter information based on a particular id
215
+	 *
216
+	 * @param $id
217
+	 * @return array the spotter information
218
+	 */
219
+	public function getCoordArchiveTrackerDataById($id)
220
+	{
221
+		date_default_timezone_set('UTC');
222
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
223
+		$query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
224 224
 
225 225
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
226 226
 
227
-        try {
228
-            $sth = $this->db->prepare($query);
229
-            $sth->execute(array(':id' => $id));
230
-        } catch(PDOException $e) {
231
-            echo $e->getMessage();
232
-            die;
233
-        }
234
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
235
-
236
-        return $spotter_array;
237
-    }
238
-
239
-
240
-    /**
241
-     * Gets altitude information based on a particular callsign
242
-     *
243
-     * @param $ident
244
-     * @return array the spotter information
245
-     */
246
-    public function getAltitudeArchiveTrackerDataByIdent($ident)
247
-    {
248
-
249
-        date_default_timezone_set('UTC');
250
-
251
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
252
-        $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";
253
-
254
-        try {
255
-            $sth = $this->db->prepare($query);
256
-            $sth->execute(array(':ident' => $ident));
257
-        } catch(PDOException $e) {
258
-            echo $e->getMessage();
259
-            die;
260
-        }
261
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
262
-
263
-        return $spotter_array;
264
-    }
265
-
266
-    /**
267
-     * Gets altitude information based on a particular id
268
-     *
269
-     * @param $id
270
-     * @return array the spotter information
271
-     */
272
-    public function getAltitudeArchiveTrackerDataById($id)
273
-    {
274
-
275
-        date_default_timezone_set('UTC');
276
-
277
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
278
-        $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";
279
-
280
-        try {
281
-            $sth = $this->db->prepare($query);
282
-            $sth->execute(array(':id' => $id));
283
-        } catch(PDOException $e) {
284
-            echo $e->getMessage();
285
-            die;
286
-        }
287
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
288
-
289
-        return $spotter_array;
290
-    }
291
-
292
-    /**
293
-     * Gets altitude & speed information based on a particular id
294
-     *
295
-     * @param $id
296
-     * @return array the spotter information
297
-     */
298
-    public function getAltitudeSpeedArchiveTrackerDataById($id)
299
-    {
300
-
301
-        date_default_timezone_set('UTC');
302
-
303
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
304
-        $query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
305
-
306
-        try {
307
-            $sth = $this->db->prepare($query);
308
-            $sth->execute(array(':id' => $id));
309
-        } catch(PDOException $e) {
310
-            echo $e->getMessage();
311
-            die;
312
-        }
313
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
314
-
315
-        return $spotter_array;
316
-    }
317
-
318
-
319
-    /**
320
-     * Gets altitude information based on a particular callsign
321
-     *
322
-     * @param $ident
323
-     * @return array the spotter information
324
-     */
325
-    public function getLastAltitudeArchiveTrackerDataByIdent($ident)
326
-    {
327
-
328
-        date_default_timezone_set('UTC');
329
-
330
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
331
-        $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";
227
+		try {
228
+			$sth = $this->db->prepare($query);
229
+			$sth->execute(array(':id' => $id));
230
+		} catch(PDOException $e) {
231
+			echo $e->getMessage();
232
+			die;
233
+		}
234
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
235
+
236
+		return $spotter_array;
237
+	}
238
+
239
+
240
+	/**
241
+	 * Gets altitude information based on a particular callsign
242
+	 *
243
+	 * @param $ident
244
+	 * @return array the spotter information
245
+	 */
246
+	public function getAltitudeArchiveTrackerDataByIdent($ident)
247
+	{
248
+
249
+		date_default_timezone_set('UTC');
250
+
251
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
252
+		$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";
253
+
254
+		try {
255
+			$sth = $this->db->prepare($query);
256
+			$sth->execute(array(':ident' => $ident));
257
+		} catch(PDOException $e) {
258
+			echo $e->getMessage();
259
+			die;
260
+		}
261
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
262
+
263
+		return $spotter_array;
264
+	}
265
+
266
+	/**
267
+	 * Gets altitude information based on a particular id
268
+	 *
269
+	 * @param $id
270
+	 * @return array the spotter information
271
+	 */
272
+	public function getAltitudeArchiveTrackerDataById($id)
273
+	{
274
+
275
+		date_default_timezone_set('UTC');
276
+
277
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
278
+		$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";
279
+
280
+		try {
281
+			$sth = $this->db->prepare($query);
282
+			$sth->execute(array(':id' => $id));
283
+		} catch(PDOException $e) {
284
+			echo $e->getMessage();
285
+			die;
286
+		}
287
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
288
+
289
+		return $spotter_array;
290
+	}
291
+
292
+	/**
293
+	 * Gets altitude & speed information based on a particular id
294
+	 *
295
+	 * @param $id
296
+	 * @return array the spotter information
297
+	 */
298
+	public function getAltitudeSpeedArchiveTrackerDataById($id)
299
+	{
300
+
301
+		date_default_timezone_set('UTC');
302
+
303
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
304
+		$query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
305
+
306
+		try {
307
+			$sth = $this->db->prepare($query);
308
+			$sth->execute(array(':id' => $id));
309
+		} catch(PDOException $e) {
310
+			echo $e->getMessage();
311
+			die;
312
+		}
313
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
314
+
315
+		return $spotter_array;
316
+	}
317
+
318
+
319
+	/**
320
+	 * Gets altitude information based on a particular callsign
321
+	 *
322
+	 * @param $ident
323
+	 * @return array the spotter information
324
+	 */
325
+	public function getLastAltitudeArchiveTrackerDataByIdent($ident)
326
+	{
327
+
328
+		date_default_timezone_set('UTC');
329
+
330
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
331
+		$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";
332 332
 //                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident";
333 333
 
334
-        try {
335
-            $sth = $this->db->prepare($query);
336
-            $sth->execute(array(':ident' => $ident));
337
-        } catch(PDOException $e) {
338
-            echo $e->getMessage();
339
-            die;
340
-        }
341
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
342
-
343
-        return $spotter_array;
344
-    }
345
-
346
-
347
-    /**
348
-     * Gets all the archive spotter information
349
-     *
350
-     * @param $ident
351
-     * @param $famtrackid
352
-     * @param $date
353
-     * @return array the spotter information
354
-     */
355
-    public function getTrackerArchiveData($ident,$famtrackid,$date)
356
-    {
357
-        $Tracker = new Tracker($this->db);
358
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
359
-        $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";
360
-
361
-        $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
362
-
363
-        return $spotter_array;
364
-    }
365
-
366
-    public function deleteTrackerArchiveTrackData()
367
-    {
368
-        global $globalArchiveKeepTrackMonths, $globalDBdriver;
369
-        if ($globalDBdriver == 'mysql') {
370
-            $query = 'DELETE FROM tracker_archive WHERE tracker_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
371
-        } else {
372
-            $query = "DELETE FROM tracker_archive WHERE tracker_archive_id IN (SELECT tracker_archive_id FROM tracker_archive WHERE tracker_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)";
373
-        }
374
-        try {
375
-            $sth = $this->db->prepare($query);
376
-            $sth->execute();
377
-        } catch(PDOException $e) {
378
-            echo $e->getMessage();
379
-            die;
380
-        }
381
-    }
382
-
383
-    /**
384
-     * Gets Minimal Live Tracker data
385
-     *
386
-     * @param $begindate
387
-     * @param $enddate
388
-     * @param array $filter
389
-     * @return array the spotter information
390
-     */
391
-    public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
392
-    {
393
-        global $globalDBdriver;
394
-        date_default_timezone_set('UTC');
395
-
396
-        $filter_query = '';
397
-        if (isset($filter['source']) && !empty($filter['source'])) {
398
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
399
-        }
400
-        // Use spotter_output also ?
401
-        if (isset($filter['airlines']) && !empty($filter['airlines'])) {
402
-            $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 ";
403
-        }
404
-        if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
405
-            $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 ";
406
-        }
407
-        if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
408
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
409
-        }
410
-
411
-        //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
412
-        if ($globalDBdriver == 'mysql') {
413
-            /*
334
+		try {
335
+			$sth = $this->db->prepare($query);
336
+			$sth->execute(array(':ident' => $ident));
337
+		} catch(PDOException $e) {
338
+			echo $e->getMessage();
339
+			die;
340
+		}
341
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
342
+
343
+		return $spotter_array;
344
+	}
345
+
346
+
347
+	/**
348
+	 * Gets all the archive spotter information
349
+	 *
350
+	 * @param $ident
351
+	 * @param $famtrackid
352
+	 * @param $date
353
+	 * @return array the spotter information
354
+	 */
355
+	public function getTrackerArchiveData($ident,$famtrackid,$date)
356
+	{
357
+		$Tracker = new Tracker($this->db);
358
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
359
+		$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";
360
+
361
+		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
362
+
363
+		return $spotter_array;
364
+	}
365
+
366
+	public function deleteTrackerArchiveTrackData()
367
+	{
368
+		global $globalArchiveKeepTrackMonths, $globalDBdriver;
369
+		if ($globalDBdriver == 'mysql') {
370
+			$query = 'DELETE FROM tracker_archive WHERE tracker_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
371
+		} else {
372
+			$query = "DELETE FROM tracker_archive WHERE tracker_archive_id IN (SELECT tracker_archive_id FROM tracker_archive WHERE tracker_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)";
373
+		}
374
+		try {
375
+			$sth = $this->db->prepare($query);
376
+			$sth->execute();
377
+		} catch(PDOException $e) {
378
+			echo $e->getMessage();
379
+			die;
380
+		}
381
+	}
382
+
383
+	/**
384
+	 * Gets Minimal Live Tracker data
385
+	 *
386
+	 * @param $begindate
387
+	 * @param $enddate
388
+	 * @param array $filter
389
+	 * @return array the spotter information
390
+	 */
391
+	public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
392
+	{
393
+		global $globalDBdriver;
394
+		date_default_timezone_set('UTC');
395
+
396
+		$filter_query = '';
397
+		if (isset($filter['source']) && !empty($filter['source'])) {
398
+			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
399
+		}
400
+		// Use spotter_output also ?
401
+		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
402
+			$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 ";
403
+		}
404
+		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
405
+			$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 ";
406
+		}
407
+		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
408
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
409
+		}
410
+
411
+		//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
412
+		if ($globalDBdriver == 'mysql') {
413
+			/*
414 414
                         $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 
415 415
                     		    FROM tracker_archive 
416 416
                     		    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';
417 417
 			*/
418
-            /*
418
+			/*
419 419
 			$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 
420 420
 				    FROM tracker_archive 
421 421
 				    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate 
@@ -424,900 +424,900 @@  discard block
 block discarded – undo
424 424
 						GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid 
425 425
 				    AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
426 426
 */
427
-            $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 
427
+			$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 
428 428
 				    FROM tracker_archive 
429 429
 				    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
430 430
 				    WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
431 431
                         	    '.$filter_query.' ORDER BY famtrackid';
432
-        } else {
433
-            //$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';
434
-            $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 
432
+		} else {
433
+			//$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';
434
+			$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 
435 435
                         	    FROM tracker_archive 
436 436
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
437 437
                         	    WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".'
438 438
                         	    '.$filter_query.' ORDER BY famtrackid';
439
-        }
440
-        //echo $query;
441
-        try {
442
-            $sth = $this->db->prepare($query);
443
-            $sth->execute();
444
-        } catch(PDOException $e) {
445
-            echo $e->getMessage();
446
-            die;
447
-        }
448
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
449
-
450
-        return $spotter_array;
451
-    }
452
-
453
-    /**
454
-     * Gets Minimal Live Tracker data
455
-     *
456
-     * @param $begindate
457
-     * @param $enddate
458
-     * @param array $filter
459
-     * @return array the spotter information
460
-     */
461
-    public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
462
-    {
463
-        global $globalDBdriver;
464
-        date_default_timezone_set('UTC');
465
-
466
-        $filter_query = '';
467
-        if (isset($filter['source']) && !empty($filter['source'])) {
468
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
469
-        }
470
-        // Should use spotter_output also ?
471
-        if (isset($filter['airlines']) && !empty($filter['airlines'])) {
472
-            $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 ";
473
-        }
474
-        if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
475
-            $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 ";
476
-        }
477
-        if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
478
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
479
-        }
480
-
481
-        //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
482
-        if ($globalDBdriver == 'mysql') {
483
-            /*
439
+		}
440
+		//echo $query;
441
+		try {
442
+			$sth = $this->db->prepare($query);
443
+			$sth->execute();
444
+		} catch(PDOException $e) {
445
+			echo $e->getMessage();
446
+			die;
447
+		}
448
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
449
+
450
+		return $spotter_array;
451
+	}
452
+
453
+	/**
454
+	 * Gets Minimal Live Tracker data
455
+	 *
456
+	 * @param $begindate
457
+	 * @param $enddate
458
+	 * @param array $filter
459
+	 * @return array the spotter information
460
+	 */
461
+	public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
462
+	{
463
+		global $globalDBdriver;
464
+		date_default_timezone_set('UTC');
465
+
466
+		$filter_query = '';
467
+		if (isset($filter['source']) && !empty($filter['source'])) {
468
+			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
469
+		}
470
+		// Should use spotter_output also ?
471
+		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
472
+			$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 ";
473
+		}
474
+		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
475
+			$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 ";
476
+		}
477
+		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
478
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
479
+		}
480
+
481
+		//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
482
+		if ($globalDBdriver == 'mysql') {
483
+			/*
484 484
                         $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 
485 485
                     		    FROM tracker_archive 
486 486
                     		    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';
487 487
 			*/
488
-            $query  = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
488
+			$query  = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
489 489
 				    FROM tracker_archive_output 
490 490
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao 
491 491
 				    WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
492 492
                         	    '.$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';
493 493
 
494
-        } else {
495
-            //$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';
496
-            /*
494
+		} else {
495
+			//$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';
496
+			/*
497 497
                         $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
498 498
                         	    FROM tracker_archive_output 
499 499
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
500 500
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
501 501
                         	    '.$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';
502 502
                         */
503
-            $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
503
+			$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
504 504
                         	    FROM tracker_archive_output 
505 505
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
506 506
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
507 507
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
508 508
 //                        	    .' 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';
509 509
                         	    
510
-        }
511
-        //echo $query;
512
-        try {
513
-            $sth = $this->db->prepare($query);
514
-            $sth->execute();
515
-        } catch(PDOException $e) {
516
-            echo $e->getMessage();
517
-            die;
518
-        }
519
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
520
-
521
-        return $spotter_array;
522
-    }
523
-
524
-    /**
525
-     * Gets count Live Tracker data
526
-     *
527
-     * @param $begindate
528
-     * @param $enddate
529
-     * @param array $filter
530
-     * @return array the spotter information
531
-     */
532
-    public function getLiveTrackerCount($begindate,$enddate,$filter = array())
533
-    {
534
-        global $globalDBdriver, $globalLiveInterval;
535
-        date_default_timezone_set('UTC');
536
-
537
-        $filter_query = '';
538
-        if (isset($filter['source']) && !empty($filter['source'])) {
539
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
540
-        }
541
-        if (isset($filter['airlines']) && !empty($filter['airlines'])) {
542
-            $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 ";
543
-        }
544
-        if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
545
-            $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
546
-        }
547
-        if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
548
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
549
-        }
550
-
551
-        //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
552
-        if ($globalDBdriver == 'mysql') {
553
-            $query = 'SELECT COUNT(DISTINCT famtrackid) as nb 
510
+		}
511
+		//echo $query;
512
+		try {
513
+			$sth = $this->db->prepare($query);
514
+			$sth->execute();
515
+		} catch(PDOException $e) {
516
+			echo $e->getMessage();
517
+			die;
518
+		}
519
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
520
+
521
+		return $spotter_array;
522
+	}
523
+
524
+	/**
525
+	 * Gets count Live Tracker data
526
+	 *
527
+	 * @param $begindate
528
+	 * @param $enddate
529
+	 * @param array $filter
530
+	 * @return array the spotter information
531
+	 */
532
+	public function getLiveTrackerCount($begindate,$enddate,$filter = array())
533
+	{
534
+		global $globalDBdriver, $globalLiveInterval;
535
+		date_default_timezone_set('UTC');
536
+
537
+		$filter_query = '';
538
+		if (isset($filter['source']) && !empty($filter['source'])) {
539
+			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
540
+		}
541
+		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
542
+			$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 ";
543
+		}
544
+		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
545
+			$filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
546
+		}
547
+		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
548
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
549
+		}
550
+
551
+		//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
552
+		if ($globalDBdriver == 'mysql') {
553
+			$query = 'SELECT COUNT(DISTINCT famtrackid) as nb 
554 554
 			FROM tracker_archive l 
555 555
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
556
-        } else {
557
-            $query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
558
-        }
559
-        //echo $query;
560
-        try {
561
-            $sth = $this->db->prepare($query);
562
-            $sth->execute();
563
-        } catch(PDOException $e) {
564
-            echo $e->getMessage();
565
-            die;
566
-        }
567
-        $result = $sth->fetch(PDO::FETCH_ASSOC);
568
-        $sth->closeCursor();
569
-        return $result['nb'];
570
-
571
-    }
572
-
573
-
574
-
575
-    // tracker_archive_output
576
-
577
-    /**
578
-     * Gets all the spotter information
579
-     *
580
-     * @param string $q
581
-     * @param string $registration
582
-     * @param string $aircraft_icao
583
-     * @param string $aircraft_manufacturer
584
-     * @param string $highlights
585
-     * @param string $airline_icao
586
-     * @param string $airline_country
587
-     * @param string $airline_type
588
-     * @param string $airport
589
-     * @param string $airport_country
590
-     * @param string $callsign
591
-     * @param string $departure_airport_route
592
-     * @param string $arrival_airport_route
593
-     * @param string $owner
594
-     * @param string $pilot_id
595
-     * @param string $pilot_name
596
-     * @param string $altitude
597
-     * @param string $date_posted
598
-     * @param string $limit
599
-     * @param string $sort
600
-     * @param string $includegeodata
601
-     * @param string $origLat
602
-     * @param string $origLon
603
-     * @param string $dist
604
-     * @param array $filters
605
-     * @return array the spotter information
606
-     */
607
-    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())
608
-    {
609
-        global $globalTimezone, $globalDBdriver;
610
-        require_once(dirname(__FILE__).'/class.Translation.php');
611
-        $Translation = new Translation($this->db);
612
-        $Tracker = new Tracker($this->db);
613
-
614
-        date_default_timezone_set('UTC');
556
+		} else {
557
+			$query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
558
+		}
559
+		//echo $query;
560
+		try {
561
+			$sth = $this->db->prepare($query);
562
+			$sth->execute();
563
+		} catch(PDOException $e) {
564
+			echo $e->getMessage();
565
+			die;
566
+		}
567
+		$result = $sth->fetch(PDO::FETCH_ASSOC);
568
+		$sth->closeCursor();
569
+		return $result['nb'];
570
+
571
+	}
572
+
573
+
574
+
575
+	// tracker_archive_output
576
+
577
+	/**
578
+	 * Gets all the spotter information
579
+	 *
580
+	 * @param string $q
581
+	 * @param string $registration
582
+	 * @param string $aircraft_icao
583
+	 * @param string $aircraft_manufacturer
584
+	 * @param string $highlights
585
+	 * @param string $airline_icao
586
+	 * @param string $airline_country
587
+	 * @param string $airline_type
588
+	 * @param string $airport
589
+	 * @param string $airport_country
590
+	 * @param string $callsign
591
+	 * @param string $departure_airport_route
592
+	 * @param string $arrival_airport_route
593
+	 * @param string $owner
594
+	 * @param string $pilot_id
595
+	 * @param string $pilot_name
596
+	 * @param string $altitude
597
+	 * @param string $date_posted
598
+	 * @param string $limit
599
+	 * @param string $sort
600
+	 * @param string $includegeodata
601
+	 * @param string $origLat
602
+	 * @param string $origLon
603
+	 * @param string $dist
604
+	 * @param array $filters
605
+	 * @return array the spotter information
606
+	 */
607
+	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())
608
+	{
609
+		global $globalTimezone, $globalDBdriver;
610
+		require_once(dirname(__FILE__).'/class.Translation.php');
611
+		$Translation = new Translation($this->db);
612
+		$Tracker = new Tracker($this->db);
613
+
614
+		date_default_timezone_set('UTC');
615 615
 	
616
-        $query_values = array();
617
-        $additional_query = '';
618
-        $limit_query = '';
619
-        $filter_query = $this->getFilter($filters);
620
-        if ($q != "")
621
-        {
622
-            if (!is_string($q))
623
-            {
624
-                return array();
625
-            } else {
616
+		$query_values = array();
617
+		$additional_query = '';
618
+		$limit_query = '';
619
+		$filter_query = $this->getFilter($filters);
620
+		if ($q != "")
621
+		{
622
+			if (!is_string($q))
623
+			{
624
+				return array();
625
+			} else {
626 626
 	        
627
-                $q_array = explode(" ", $q);
627
+				$q_array = explode(" ", $q);
628 628
 		
629
-                foreach ($q_array as $q_item){
630
-                    $additional_query .= " AND (";
631
-                    $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
632
-                    $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
633
-                    $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR ";
634
-                    $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
635
-                    $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR ";
636
-                    $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR ";
637
-                    $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR ";
638
-                    $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
639
-                    $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR ";
640
-                    $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR ";
641
-                    $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR ";
642
-                    $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
643
-                    $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
644
-                    $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
645
-                    $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
646
-                    $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR ";
647
-                    $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR ";
648
-                    $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR ";
649
-                    $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
650
-                    $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
651
-                    $translate = $Translation->ident2icao($q_item);
652
-                    if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
653
-                    $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
654
-                    $additional_query .= ")";
655
-                }
656
-            }
657
-        }
629
+				foreach ($q_array as $q_item){
630
+					$additional_query .= " AND (";
631
+					$additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
632
+					$additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
633
+					$additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR ";
634
+					$additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
635
+					$additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR ";
636
+					$additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR ";
637
+					$additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR ";
638
+					$additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
639
+					$additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR ";
640
+					$additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR ";
641
+					$additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR ";
642
+					$additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
643
+					$additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
644
+					$additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
645
+					$additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
646
+					$additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR ";
647
+					$additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR ";
648
+					$additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR ";
649
+					$additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
650
+					$additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
651
+					$translate = $Translation->ident2icao($q_item);
652
+					if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
653
+					$additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
654
+					$additional_query .= ")";
655
+				}
656
+			}
657
+		}
658 658
 	
659
-        if ($registration != "")
660
-        {
661
-            $registration = filter_var($registration,FILTER_SANITIZE_STRING);
662
-            if (!is_string($registration))
663
-            {
664
-                return array();
665
-            } else {
666
-                $additional_query .= " AND (tracker_archive_output.registration = '".$registration."')";
667
-            }
668
-        }
659
+		if ($registration != "")
660
+		{
661
+			$registration = filter_var($registration,FILTER_SANITIZE_STRING);
662
+			if (!is_string($registration))
663
+			{
664
+				return array();
665
+			} else {
666
+				$additional_query .= " AND (tracker_archive_output.registration = '".$registration."')";
667
+			}
668
+		}
669 669
 	
670
-        if ($aircraft_icao != "")
671
-        {
672
-            $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
673
-            if (!is_string($aircraft_icao))
674
-            {
675
-                return array();
676
-            } else {
677
-                $additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')";
678
-            }
679
-        }
670
+		if ($aircraft_icao != "")
671
+		{
672
+			$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
673
+			if (!is_string($aircraft_icao))
674
+			{
675
+				return array();
676
+			} else {
677
+				$additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')";
678
+			}
679
+		}
680 680
 	
681
-        if ($aircraft_manufacturer != "")
682
-        {
683
-            $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
684
-            if (!is_string($aircraft_manufacturer))
685
-            {
686
-                return array();
687
-            } else {
688
-                $additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
689
-            }
690
-        }
681
+		if ($aircraft_manufacturer != "")
682
+		{
683
+			$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
684
+			if (!is_string($aircraft_manufacturer))
685
+			{
686
+				return array();
687
+			} else {
688
+				$additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
689
+			}
690
+		}
691 691
 	
692
-        if ($highlights == "true")
693
-        {
694
-            if (!is_string($highlights))
695
-            {
696
-                return array();
697
-            } else {
698
-                $additional_query .= " AND (tracker_archive_output.highlight <> '')";
699
-            }
700
-        }
692
+		if ($highlights == "true")
693
+		{
694
+			if (!is_string($highlights))
695
+			{
696
+				return array();
697
+			} else {
698
+				$additional_query .= " AND (tracker_archive_output.highlight <> '')";
699
+			}
700
+		}
701 701
 	
702
-        if ($airline_icao != "")
703
-        {
704
-            $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
705
-            if (!is_string($airline_icao))
706
-            {
707
-                return array();
708
-            } else {
709
-                $additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')";
710
-            }
711
-        }
702
+		if ($airline_icao != "")
703
+		{
704
+			$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
705
+			if (!is_string($airline_icao))
706
+			{
707
+				return array();
708
+			} else {
709
+				$additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')";
710
+			}
711
+		}
712 712
 	
713
-        if ($airline_country != "")
714
-        {
715
-            $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
716
-            if (!is_string($airline_country))
717
-            {
718
-                return array();
719
-            } else {
720
-                $additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')";
721
-            }
722
-        }
713
+		if ($airline_country != "")
714
+		{
715
+			$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
716
+			if (!is_string($airline_country))
717
+			{
718
+				return array();
719
+			} else {
720
+				$additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')";
721
+			}
722
+		}
723 723
 	
724
-        if ($airline_type != "")
725
-        {
726
-            $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
727
-            if (!is_string($airline_type))
728
-            {
729
-                return array();
730
-            } else {
731
-                if ($airline_type == "passenger")
732
-                {
733
-                    $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')";
734
-                }
735
-                if ($airline_type == "cargo")
736
-                {
737
-                    $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')";
738
-                }
739
-                if ($airline_type == "military")
740
-                {
741
-                    $additional_query .= " AND (tracker_archive_output.airline_type = 'military')";
742
-                }
743
-            }
744
-        }
724
+		if ($airline_type != "")
725
+		{
726
+			$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
727
+			if (!is_string($airline_type))
728
+			{
729
+				return array();
730
+			} else {
731
+				if ($airline_type == "passenger")
732
+				{
733
+					$additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')";
734
+				}
735
+				if ($airline_type == "cargo")
736
+				{
737
+					$additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')";
738
+				}
739
+				if ($airline_type == "military")
740
+				{
741
+					$additional_query .= " AND (tracker_archive_output.airline_type = 'military')";
742
+				}
743
+			}
744
+		}
745 745
 	
746
-        if ($airport != "")
747
-        {
748
-            $airport = filter_var($airport,FILTER_SANITIZE_STRING);
749
-            if (!is_string($airport))
750
-            {
751
-                return array();
752
-            } else {
753
-                $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))";
754
-            }
755
-        }
746
+		if ($airport != "")
747
+		{
748
+			$airport = filter_var($airport,FILTER_SANITIZE_STRING);
749
+			if (!is_string($airport))
750
+			{
751
+				return array();
752
+			} else {
753
+				$additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))";
754
+			}
755
+		}
756 756
 	
757
-        if ($airport_country != "")
758
-        {
759
-            $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
760
-            if (!is_string($airport_country))
761
-            {
762
-                return array();
763
-            } else {
764
-                $additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))";
765
-            }
766
-        }
757
+		if ($airport_country != "")
758
+		{
759
+			$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
760
+			if (!is_string($airport_country))
761
+			{
762
+				return array();
763
+			} else {
764
+				$additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))";
765
+			}
766
+		}
767 767
     
768
-        if ($callsign != "")
769
-        {
770
-            $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
771
-            if (!is_string($callsign))
772
-            {
773
-                return array();
774
-            } else {
775
-                $translate = $Translation->ident2icao($callsign);
776
-                if ($translate != $callsign) {
777
-                    $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)";
778
-                    $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
779
-                } else {
780
-                    $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')";
781
-                }
782
-            }
783
-        }
784
-
785
-        if ($owner != "")
786
-        {
787
-            $owner = filter_var($owner,FILTER_SANITIZE_STRING);
788
-            if (!is_string($owner))
789
-            {
790
-                return array();
791
-            } else {
792
-                $additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')";
793
-            }
794
-        }
795
-
796
-        if ($pilot_name != "")
797
-        {
798
-            $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
799
-            if (!is_string($pilot_name))
800
-            {
801
-                return array();
802
-            } else {
803
-                $additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')";
804
-            }
805
-        }
768
+		if ($callsign != "")
769
+		{
770
+			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
771
+			if (!is_string($callsign))
772
+			{
773
+				return array();
774
+			} else {
775
+				$translate = $Translation->ident2icao($callsign);
776
+				if ($translate != $callsign) {
777
+					$additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)";
778
+					$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
779
+				} else {
780
+					$additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')";
781
+				}
782
+			}
783
+		}
784
+
785
+		if ($owner != "")
786
+		{
787
+			$owner = filter_var($owner,FILTER_SANITIZE_STRING);
788
+			if (!is_string($owner))
789
+			{
790
+				return array();
791
+			} else {
792
+				$additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')";
793
+			}
794
+		}
795
+
796
+		if ($pilot_name != "")
797
+		{
798
+			$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
799
+			if (!is_string($pilot_name))
800
+			{
801
+				return array();
802
+			} else {
803
+				$additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')";
804
+			}
805
+		}
806 806
 	
807
-        if ($pilot_id != "")
808
-        {
809
-            $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
810
-            if (!is_string($pilot_id))
811
-            {
812
-                return array();
813
-            } else {
814
-                $additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')";
815
-            }
816
-        }
807
+		if ($pilot_id != "")
808
+		{
809
+			$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
810
+			if (!is_string($pilot_id))
811
+			{
812
+				return array();
813
+			} else {
814
+				$additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')";
815
+			}
816
+		}
817 817
 	
818
-        if ($departure_airport_route != "")
819
-        {
820
-            $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
821
-            if (!is_string($departure_airport_route))
822
-            {
823
-                return array();
824
-            } else {
825
-                $additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')";
826
-            }
827
-        }
818
+		if ($departure_airport_route != "")
819
+		{
820
+			$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
821
+			if (!is_string($departure_airport_route))
822
+			{
823
+				return array();
824
+			} else {
825
+				$additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')";
826
+			}
827
+		}
828 828
 	
829
-        if ($arrival_airport_route != "")
830
-        {
831
-            $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
832
-            if (!is_string($arrival_airport_route))
833
-            {
834
-                return array();
835
-            } else {
836
-                $additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
837
-            }
838
-        }
829
+		if ($arrival_airport_route != "")
830
+		{
831
+			$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
832
+			if (!is_string($arrival_airport_route))
833
+			{
834
+				return array();
835
+			} else {
836
+				$additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
837
+			}
838
+		}
839 839
 	
840
-        if ($altitude != "")
841
-        {
842
-            $altitude_array = explode(",", $altitude);
840
+		if ($altitude != "")
841
+		{
842
+			$altitude_array = explode(",", $altitude);
843 843
 	    
844
-            $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
845
-            $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
844
+			$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
845
+			$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
846 846
 	    
847 847
 
848
-            if ($altitude_array[1] != "")
849
-            {
850
-                $altitude_array[0] = substr($altitude_array[0], 0, -2);
851
-                $altitude_array[1] = substr($altitude_array[1], 0, -2);
852
-                $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
853
-            } else {
854
-                $altitude_array[0] = substr($altitude_array[0], 0, -2);
855
-                $additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
856
-            }
857
-        }
848
+			if ($altitude_array[1] != "")
849
+			{
850
+				$altitude_array[0] = substr($altitude_array[0], 0, -2);
851
+				$altitude_array[1] = substr($altitude_array[1], 0, -2);
852
+				$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
853
+			} else {
854
+				$altitude_array[0] = substr($altitude_array[0], 0, -2);
855
+				$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
856
+			}
857
+		}
858 858
 	
859
-        if ($date_posted != "")
860
-        {
861
-            $date_array = explode(",", $date_posted);
859
+		if ($date_posted != "")
860
+		{
861
+			$date_array = explode(",", $date_posted);
862 862
 	    
863
-            $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
864
-            $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
863
+			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
864
+			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
865 865
 	    
866
-            if ($globalTimezone != '') {
867
-                date_default_timezone_set($globalTimezone);
868
-                $datetime = new DateTime();
869
-                $offset = $datetime->format('P');
870
-            } else $offset = '+00:00';
871
-
872
-
873
-            if ($date_array[1] != "")
874
-            {
875
-                $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
876
-                $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
877
-                if ($globalDBdriver == 'mysql') {
878
-                    $additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' ";
879
-                } else {
880
-                    $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) ";
881
-                }
882
-            } else {
883
-                $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
884
-                if ($globalDBdriver == 'mysql') {
885
-                    $additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
886
-                } else {
887
-                    $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
888
-                }
889
-            }
890
-        }
866
+			if ($globalTimezone != '') {
867
+				date_default_timezone_set($globalTimezone);
868
+				$datetime = new DateTime();
869
+				$offset = $datetime->format('P');
870
+			} else $offset = '+00:00';
871
+
872
+
873
+			if ($date_array[1] != "")
874
+			{
875
+				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
876
+				$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
877
+				if ($globalDBdriver == 'mysql') {
878
+					$additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' ";
879
+				} else {
880
+					$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) ";
881
+				}
882
+			} else {
883
+				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
884
+				if ($globalDBdriver == 'mysql') {
885
+					$additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
886
+				} else {
887
+					$additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
888
+				}
889
+			}
890
+		}
891 891
 	
892
-        if ($limit != "")
893
-        {
894
-            $limit_array = explode(",", $limit);
892
+		if ($limit != "")
893
+		{
894
+			$limit_array = explode(",", $limit);
895 895
 	    
896
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
897
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
896
+			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
897
+			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
898 898
 	    
899
-            if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
900
-            {
901
-                //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
902
-                $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
903
-            }
904
-        }
899
+			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
900
+			{
901
+				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
902
+				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
903
+			}
904
+		}
905 905
 	
906 906
 
907
-        if ($origLat != "" && $origLon != "" && $dist != "") {
908
-            $dist = number_format($dist*0.621371,2,'.','');
909
-            $query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
907
+		if ($origLat != "" && $origLon != "" && $dist != "") {
908
+			$dist = number_format($dist*0.621371,2,'.','');
909
+			$query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
910 910
                           FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
911 911
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
912
-        } else {
913
-            if ($sort != "")
914
-            {
915
-                $search_orderby_array = $Tracker->getOrderBy();
916
-                $orderby_query = $search_orderby_array[$sort]['sql'];
917
-            } else {
918
-                $orderby_query = " ORDER BY tracker_archive_output.date DESC";
919
-            }
912
+		} else {
913
+			if ($sort != "")
914
+			{
915
+				$search_orderby_array = $Tracker->getOrderBy();
916
+				$orderby_query = $search_orderby_array[$sort]['sql'];
917
+			} else {
918
+				$orderby_query = " ORDER BY tracker_archive_output.date DESC";
919
+			}
920 920
 	
921
-            if ($includegeodata == "true")
922
-            {
923
-                $additional_query .= " AND (tracker_archive_output.waypoints <> '')";
924
-            }
921
+			if ($includegeodata == "true")
922
+			{
923
+				$additional_query .= " AND (tracker_archive_output.waypoints <> '')";
924
+			}
925 925
 
926
-            $query  = "SELECT tracker_archive_output.* FROM tracker_archive_output 
926
+			$query  = "SELECT tracker_archive_output.* FROM tracker_archive_output 
927 927
 		    WHERE tracker_archive_output.ident <> '' 
928 928
 		    ".$additional_query."
929 929
 		    ".$filter_query.$orderby_query;
930
-        }
931
-        $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query);
932
-
933
-        return $spotter_array;
934
-    }
935
-
936
-    public function deleteTrackerArchiveData()
937
-    {
938
-        global $globalArchiveKeepMonths, $globalDBdriver;
939
-        date_default_timezone_set('UTC');
940
-        if ($globalDBdriver == 'mysql') {
941
-            $query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
942
-        } else {
943
-            $query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
944
-        }
945
-        try {
946
-            $sth = $this->db->prepare($query);
947
-            $sth->execute();
948
-        } catch(PDOException $e) {
949
-            return "error";
950
-        }
951
-        return '';
952
-    }
953
-
954
-    /**
955
-     * Gets all the spotter information based on the callsign
956
-     *
957
-     * @param string $ident
958
-     * @param string $limit
959
-     * @param string $sort
960
-     * @return array the spotter information
961
-     */
962
-    public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '')
963
-    {
964
-        $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
930
+		}
931
+		$spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query);
932
+
933
+		return $spotter_array;
934
+	}
935
+
936
+	public function deleteTrackerArchiveData()
937
+	{
938
+		global $globalArchiveKeepMonths, $globalDBdriver;
939
+		date_default_timezone_set('UTC');
940
+		if ($globalDBdriver == 'mysql') {
941
+			$query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
942
+		} else {
943
+			$query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
944
+		}
945
+		try {
946
+			$sth = $this->db->prepare($query);
947
+			$sth->execute();
948
+		} catch(PDOException $e) {
949
+			return "error";
950
+		}
951
+		return '';
952
+	}
953
+
954
+	/**
955
+	 * Gets all the spotter information based on the callsign
956
+	 *
957
+	 * @param string $ident
958
+	 * @param string $limit
959
+	 * @param string $sort
960
+	 * @return array the spotter information
961
+	 */
962
+	public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '')
963
+	{
964
+		$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
965 965
 	
966
-        date_default_timezone_set('UTC');
967
-        $Tracker = new Tracker($this->db);
966
+		date_default_timezone_set('UTC');
967
+		$Tracker = new Tracker($this->db);
968 968
 	
969
-        $query_values = array();
970
-        $limit_query = '';
971
-        $additional_query = '';
969
+		$query_values = array();
970
+		$limit_query = '';
971
+		$additional_query = '';
972 972
 	
973
-        if ($ident != "")
974
-        {
975
-            if (!is_string($ident))
976
-            {
977
-                return array();
978
-            } else {
979
-                $additional_query = " AND (tracker_archive_output.ident = :ident)";
980
-                $query_values = array(':ident' => $ident);
981
-            }
982
-        }
973
+		if ($ident != "")
974
+		{
975
+			if (!is_string($ident))
976
+			{
977
+				return array();
978
+			} else {
979
+				$additional_query = " AND (tracker_archive_output.ident = :ident)";
980
+				$query_values = array(':ident' => $ident);
981
+			}
982
+		}
983 983
 	
984
-        if ($limit != "")
985
-        {
986
-            $limit_array = explode(",", $limit);
984
+		if ($limit != "")
985
+		{
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
-            {
993
-                //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
994
-                $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
995
-            }
996
-        }
997
-
998
-        if ($sort != "")
999
-        {
1000
-            $search_orderby_array = $Tracker->getOrderBy();
1001
-            $orderby_query = $search_orderby_array[$sort]['sql'];
1002
-        } else {
1003
-            $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1004
-        }
1005
-
1006
-        $query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
1007
-
1008
-        $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1009
-
1010
-        return $spotter_array;
1011
-    }
1012
-
1013
-
1014
-    /**
1015
-     * Gets all the spotter information based on the owner
1016
-     *
1017
-     * @param string $owner
1018
-     * @param string $limit
1019
-     * @param string $sort
1020
-     * @param array $filter
1021
-     * @return array the spotter information
1022
-     */
1023
-    public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1024
-    {
1025
-        $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
991
+			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992
+			{
993
+				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
994
+				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
995
+			}
996
+		}
997
+
998
+		if ($sort != "")
999
+		{
1000
+			$search_orderby_array = $Tracker->getOrderBy();
1001
+			$orderby_query = $search_orderby_array[$sort]['sql'];
1002
+		} else {
1003
+			$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1004
+		}
1005
+
1006
+		$query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
1007
+
1008
+		$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1009
+
1010
+		return $spotter_array;
1011
+	}
1012
+
1013
+
1014
+	/**
1015
+	 * Gets all the spotter information based on the owner
1016
+	 *
1017
+	 * @param string $owner
1018
+	 * @param string $limit
1019
+	 * @param string $sort
1020
+	 * @param array $filter
1021
+	 * @return array the spotter information
1022
+	 */
1023
+	public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1024
+	{
1025
+		$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
1026 1026
 	
1027
-        date_default_timezone_set('UTC');
1028
-        $Tracker = new Tracker($this->db);
1027
+		date_default_timezone_set('UTC');
1028
+		$Tracker = new Tracker($this->db);
1029 1029
 	
1030
-        $query_values = array();
1031
-        $limit_query = '';
1032
-        $additional_query = '';
1033
-        $filter_query = $this->getFilter($filter,true,true);
1030
+		$query_values = array();
1031
+		$limit_query = '';
1032
+		$additional_query = '';
1033
+		$filter_query = $this->getFilter($filter,true,true);
1034 1034
 	
1035
-        if ($owner != "")
1036
-        {
1037
-            if (!is_string($owner))
1038
-            {
1039
-                return array();
1040
-            } else {
1041
-                $additional_query = " AND (tracker_archive_output.owner_name = :owner)";
1042
-                $query_values = array(':owner' => $owner);
1043
-            }
1044
-        }
1035
+		if ($owner != "")
1036
+		{
1037
+			if (!is_string($owner))
1038
+			{
1039
+				return array();
1040
+			} else {
1041
+				$additional_query = " AND (tracker_archive_output.owner_name = :owner)";
1042
+				$query_values = array(':owner' => $owner);
1043
+			}
1044
+		}
1045 1045
 	
1046
-        if ($limit != "")
1047
-        {
1048
-            $limit_array = explode(",", $limit);
1046
+		if ($limit != "")
1047
+		{
1048
+			$limit_array = explode(",", $limit);
1049 1049
 	    
1050
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1051
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1050
+			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1051
+			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1052 1052
 	    
1053
-            if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1054
-            {
1055
-                //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1056
-                $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1057
-            }
1058
-        }
1059
-
1060
-        if ($sort != "")
1061
-        {
1062
-            $search_orderby_array = $Tracker->getOrderBy();
1063
-            $orderby_query = $search_orderby_array[$sort]['sql'];
1064
-        } else {
1065
-            $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1066
-        }
1067
-
1068
-        $query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
1069
-
1070
-        $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1071
-
1072
-        return $spotter_array;
1073
-    }
1074
-
1075
-    /**
1076
-     * Gets all the spotter information based on the pilot
1077
-     *
1078
-     * @param string $pilot
1079
-     * @param string $limit
1080
-     * @param string $sort
1081
-     * @param array $filter
1082
-     * @return array the spotter information
1083
-     */
1084
-    public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1085
-    {
1086
-        $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
1053
+			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1054
+			{
1055
+				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1056
+				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1057
+			}
1058
+		}
1059
+
1060
+		if ($sort != "")
1061
+		{
1062
+			$search_orderby_array = $Tracker->getOrderBy();
1063
+			$orderby_query = $search_orderby_array[$sort]['sql'];
1064
+		} else {
1065
+			$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1066
+		}
1067
+
1068
+		$query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
1069
+
1070
+		$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1071
+
1072
+		return $spotter_array;
1073
+	}
1074
+
1075
+	/**
1076
+	 * Gets all the spotter information based on the pilot
1077
+	 *
1078
+	 * @param string $pilot
1079
+	 * @param string $limit
1080
+	 * @param string $sort
1081
+	 * @param array $filter
1082
+	 * @return array the spotter information
1083
+	 */
1084
+	public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1085
+	{
1086
+		$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
1087 1087
 	
1088
-        date_default_timezone_set('UTC');
1089
-        $Tracker = new Tracker($this->db);
1088
+		date_default_timezone_set('UTC');
1089
+		$Tracker = new Tracker($this->db);
1090 1090
 	
1091
-        $query_values = array();
1092
-        $limit_query = '';
1093
-        $additional_query = '';
1094
-        $filter_query = $this->getFilter($filter,true,true);
1091
+		$query_values = array();
1092
+		$limit_query = '';
1093
+		$additional_query = '';
1094
+		$filter_query = $this->getFilter($filter,true,true);
1095 1095
 	
1096
-        if ($pilot != "")
1097
-        {
1098
-            $additional_query = " AND (tracker_archive_output.pilot_id = :pilot OR tracker_archive_output.pilot_name = :pilot)";
1099
-            $query_values = array(':pilot' => $pilot);
1100
-        }
1096
+		if ($pilot != "")
1097
+		{
1098
+			$additional_query = " AND (tracker_archive_output.pilot_id = :pilot OR tracker_archive_output.pilot_name = :pilot)";
1099
+			$query_values = array(':pilot' => $pilot);
1100
+		}
1101 1101
 	
1102
-        if ($limit != "")
1103
-        {
1104
-            $limit_array = explode(",", $limit);
1102
+		if ($limit != "")
1103
+		{
1104
+			$limit_array = explode(",", $limit);
1105 1105
 	    
1106
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1107
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1106
+			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1107
+			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1108 1108
 	    
1109
-            if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1110
-            {
1111
-                //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1112
-                $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1113
-            }
1114
-        }
1115
-
1116
-        if ($sort != "")
1117
-        {
1118
-            $search_orderby_array = $Tracker->getOrderBy();
1119
-            $orderby_query = $search_orderby_array[$sort]['sql'];
1120
-        } else {
1121
-            $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1122
-        }
1123
-
1124
-        $query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
1125
-
1126
-        $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1127
-
1128
-        return $spotter_array;
1129
-    }
1130
-
1131
-    /**
1132
-     * Gets all number of flight over countries
1133
-     *
1134
-     * @param bool $limit
1135
-     * @param int $olderthanmonths
1136
-     * @param string $sincedate
1137
-     * @return array the airline country list
1138
-     */
1139
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1140
-    {
1141
-        global $globalDBdriver;
1142
-        /*
1109
+			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1110
+			{
1111
+				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1112
+				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1113
+			}
1114
+		}
1115
+
1116
+		if ($sort != "")
1117
+		{
1118
+			$search_orderby_array = $Tracker->getOrderBy();
1119
+			$orderby_query = $search_orderby_array[$sort]['sql'];
1120
+		} else {
1121
+			$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1122
+		}
1123
+
1124
+		$query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
1125
+
1126
+		$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1127
+
1128
+		return $spotter_array;
1129
+	}
1130
+
1131
+	/**
1132
+	 * Gets all number of flight over countries
1133
+	 *
1134
+	 * @param bool $limit
1135
+	 * @param int $olderthanmonths
1136
+	 * @param string $sincedate
1137
+	 * @return array the airline country list
1138
+	 */
1139
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1140
+	{
1141
+		global $globalDBdriver;
1142
+		/*
1143 1143
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
1144 1144
 		    FROM countries c, tracker_archive s
1145 1145
 		    WHERE Within(GeomFromText(CONCAT('POINT(',s.longitude,' ',s.latitude,')')), ogc_geom) ";
1146 1146
 	*/
1147
-        $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1147
+		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1148 1148
 		    FROM countries c, tracker_archive s
1149 1149
 		    WHERE c.iso2 = s.over_country ";
1150
-        if ($olderthanmonths > 0) {
1151
-            if ($globalDBdriver == 'mysql') {
1152
-                $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1153
-            } else {
1154
-                $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1155
-            }
1156
-        }
1157
-        if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1158
-        $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1159
-        if ($limit) $query .= " LIMIT 0,10";
1150
+		if ($olderthanmonths > 0) {
1151
+			if ($globalDBdriver == 'mysql') {
1152
+				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1153
+			} else {
1154
+				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1155
+			}
1156
+		}
1157
+		if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1158
+		$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1159
+		if ($limit) $query .= " LIMIT 0,10";
1160 1160
       
1161 1161
 	
1162
-        $sth = $this->db->prepare($query);
1163
-        $sth->execute();
1162
+		$sth = $this->db->prepare($query);
1163
+		$sth->execute();
1164 1164
  
1165
-        $flight_array = array();
1166
-        $temp_array = array();
1165
+		$flight_array = array();
1166
+		$temp_array = array();
1167 1167
         
1168
-        while($row = $sth->fetch(PDO::FETCH_ASSOC))
1169
-        {
1170
-            $temp_array['flight_count'] = $row['nb'];
1171
-            $temp_array['flight_country'] = $row['name'];
1172
-            $temp_array['flight_country_iso3'] = $row['iso3'];
1173
-            $temp_array['flight_country_iso2'] = $row['iso2'];
1174
-            $flight_array[] = $temp_array;
1175
-        }
1176
-        return $flight_array;
1177
-    }
1178
-
1179
-    /**
1180
-     * Gets all number of flight over countries
1181
-     *
1182
-     * @param bool $limit
1183
-     * @param int $olderthanmonths
1184
-     * @param string $sincedate
1185
-     * @return array the airline country list
1186
-     */
1187
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1188
-    {
1189
-        global $globalDBdriver;
1190
-        /*
1168
+		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1169
+		{
1170
+			$temp_array['flight_count'] = $row['nb'];
1171
+			$temp_array['flight_country'] = $row['name'];
1172
+			$temp_array['flight_country_iso3'] = $row['iso3'];
1173
+			$temp_array['flight_country_iso2'] = $row['iso2'];
1174
+			$flight_array[] = $temp_array;
1175
+		}
1176
+		return $flight_array;
1177
+	}
1178
+
1179
+	/**
1180
+	 * Gets all number of flight over countries
1181
+	 *
1182
+	 * @param bool $limit
1183
+	 * @param int $olderthanmonths
1184
+	 * @param string $sincedate
1185
+	 * @return array the airline country list
1186
+	 */
1187
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1188
+	{
1189
+		global $globalDBdriver;
1190
+		/*
1191 1191
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
1192 1192
 		    FROM countries c, tracker_archive s
1193 1193
 		    WHERE Within(GeomFromText(CONCAT('POINT(',s.longitude,' ',s.latitude,')')), ogc_geom) ";
1194 1194
 	*/
1195
-        $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1195
+		$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1196 1196
 		    FROM countries c, tracker_archive s, spotter_output o
1197 1197
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.famtrackid = s.famtrackid ";
1198
-        if ($olderthanmonths > 0) {
1199
-            if ($globalDBdriver == 'mysql') {
1200
-                $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1201
-            } else {
1202
-                $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1203
-            }
1204
-        }
1205
-        if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1206
-        $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1207
-        if ($limit) $query .= " LIMIT 0,10";
1198
+		if ($olderthanmonths > 0) {
1199
+			if ($globalDBdriver == 'mysql') {
1200
+				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1201
+			} else {
1202
+				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1203
+			}
1204
+		}
1205
+		if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1206
+		$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1207
+		if ($limit) $query .= " LIMIT 0,10";
1208 1208
       
1209 1209
 	
1210
-        $sth = $this->db->prepare($query);
1211
-        $sth->execute();
1210
+		$sth = $this->db->prepare($query);
1211
+		$sth->execute();
1212 1212
  
1213
-        $flight_array = array();
1214
-        $temp_array = array();
1213
+		$flight_array = array();
1214
+		$temp_array = array();
1215 1215
         
1216
-        while($row = $sth->fetch(PDO::FETCH_ASSOC))
1217
-        {
1218
-            $temp_array['airline_icao'] = $row['airline_icao'];
1219
-            $temp_array['flight_count'] = $row['nb'];
1220
-            $temp_array['flight_country'] = $row['name'];
1221
-            $temp_array['flight_country_iso3'] = $row['iso3'];
1222
-            $temp_array['flight_country_iso2'] = $row['iso2'];
1223
-            $flight_array[] = $temp_array;
1224
-        }
1225
-        return $flight_array;
1226
-    }
1227
-
1228
-    /**
1229
-     * Gets last spotter information based on a particular callsign
1230
-     *
1231
-     * @param $id
1232
-     * @param $date
1233
-     * @return array the spotter information
1234
-     */
1235
-    public function getDateArchiveTrackerDataById($id,$date)
1236
-    {
1237
-        $Tracker = new Tracker($this->db);
1238
-        date_default_timezone_set('UTC');
1239
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
1240
-        $query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1241
-        $date = date('c',$date);
1242
-        $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date));
1243
-        return $spotter_array;
1244
-    }
1245
-
1246
-    /**
1247
-     * Gets all the spotter information based on a particular callsign
1248
-     *
1249
-     * @param $ident
1250
-     * @param $date
1251
-     * @return array the spotter information
1252
-     */
1253
-    public function getDateArchiveTrackerDataByIdent($ident,$date)
1254
-    {
1255
-        $Tracker = new Tracker($this->db);
1256
-        date_default_timezone_set('UTC');
1257
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
1258
-        $query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1259
-        $date = date('c',$date);
1260
-        $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1261
-        return $spotter_array;
1262
-    }
1263
-
1264
-    /**
1265
-     * Gets all the spotter information based on the airport
1266
-     *
1267
-     * @param string $airport
1268
-     * @param string $limit
1269
-     * @param string $sort
1270
-     * @param array $filters
1271
-     * @return array the spotter information
1272
-     */
1273
-    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1274
-    {
1275
-        global $global_query;
1276
-        $Tracker = new Tracker($this->db);
1277
-        date_default_timezone_set('UTC');
1278
-        $query_values = array();
1279
-        $limit_query = '';
1280
-        $additional_query = '';
1281
-        $filter_query = $this->getFilter($filters,true,true);
1216
+		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1217
+		{
1218
+			$temp_array['airline_icao'] = $row['airline_icao'];
1219
+			$temp_array['flight_count'] = $row['nb'];
1220
+			$temp_array['flight_country'] = $row['name'];
1221
+			$temp_array['flight_country_iso3'] = $row['iso3'];
1222
+			$temp_array['flight_country_iso2'] = $row['iso2'];
1223
+			$flight_array[] = $temp_array;
1224
+		}
1225
+		return $flight_array;
1226
+	}
1227
+
1228
+	/**
1229
+	 * Gets last spotter information based on a particular callsign
1230
+	 *
1231
+	 * @param $id
1232
+	 * @param $date
1233
+	 * @return array the spotter information
1234
+	 */
1235
+	public function getDateArchiveTrackerDataById($id,$date)
1236
+	{
1237
+		$Tracker = new Tracker($this->db);
1238
+		date_default_timezone_set('UTC');
1239
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
1240
+		$query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1241
+		$date = date('c',$date);
1242
+		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date));
1243
+		return $spotter_array;
1244
+	}
1245
+
1246
+	/**
1247
+	 * Gets all the spotter information based on a particular callsign
1248
+	 *
1249
+	 * @param $ident
1250
+	 * @param $date
1251
+	 * @return array the spotter information
1252
+	 */
1253
+	public function getDateArchiveTrackerDataByIdent($ident,$date)
1254
+	{
1255
+		$Tracker = new Tracker($this->db);
1256
+		date_default_timezone_set('UTC');
1257
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1258
+		$query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1259
+		$date = date('c',$date);
1260
+		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1261
+		return $spotter_array;
1262
+	}
1263
+
1264
+	/**
1265
+	 * Gets all the spotter information based on the airport
1266
+	 *
1267
+	 * @param string $airport
1268
+	 * @param string $limit
1269
+	 * @param string $sort
1270
+	 * @param array $filters
1271
+	 * @return array the spotter information
1272
+	 */
1273
+	public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1274
+	{
1275
+		global $global_query;
1276
+		$Tracker = new Tracker($this->db);
1277
+		date_default_timezone_set('UTC');
1278
+		$query_values = array();
1279
+		$limit_query = '';
1280
+		$additional_query = '';
1281
+		$filter_query = $this->getFilter($filters,true,true);
1282 1282
 	
1283
-        if ($airport != "")
1284
-        {
1285
-            if (!is_string($airport))
1286
-            {
1287
-                return array();
1288
-            } else {
1289
-                $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))";
1290
-                $query_values = array(':airport' => $airport);
1291
-            }
1292
-        }
1283
+		if ($airport != "")
1284
+		{
1285
+			if (!is_string($airport))
1286
+			{
1287
+				return array();
1288
+			} else {
1289
+				$additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))";
1290
+				$query_values = array(':airport' => $airport);
1291
+			}
1292
+		}
1293 1293
 	
1294
-        if ($limit != "")
1295
-        {
1296
-            $limit_array = explode(",", $limit);
1294
+		if ($limit != "")
1295
+		{
1296
+			$limit_array = explode(",", $limit);
1297 1297
 	    
1298
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1299
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1298
+			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1299
+			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1300 1300
 	    
1301
-            if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1302
-            {
1303
-                //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1304
-                $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1305
-            }
1306
-        }
1301
+			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1302
+			{
1303
+				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1304
+				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1305
+			}
1306
+		}
1307 1307
 	
1308
-        if ($sort != "")
1309
-        {
1310
-            $search_orderby_array = $Tracker->getOrderBy();
1311
-            $orderby_query = $search_orderby_array[$sort]['sql'];
1312
-        } else {
1313
-            $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1314
-        }
1308
+		if ($sort != "")
1309
+		{
1310
+			$search_orderby_array = $Tracker->getOrderBy();
1311
+			$orderby_query = $search_orderby_array[$sort]['sql'];
1312
+		} else {
1313
+			$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1314
+		}
1315 1315
 
1316
-        $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;
1316
+		$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;
1317 1317
 
1318
-        $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1318
+		$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1319 1319
 
1320
-        return $spotter_array;
1321
-    }
1320
+		return $spotter_array;
1321
+	}
1322 1322
 }
1323 1323
 ?>
1324 1324
\ No newline at end of file
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Indentation   +463 added lines, -463 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
 		if ($this->db === null) die('Error: No DB connection. (Marine)');
19 19
 	}
20 20
 
21
-    /**
22
-     * Get SQL query part for filter used
23
-     * @param array $filter the filter
24
-     * @param bool $where
25
-     * @param bool $and
26
-     * @return string the SQL part
27
-     */
21
+	/**
22
+	 * Get SQL query part for filter used
23
+	 * @param array $filter the filter
24
+	 * @param bool $where
25
+	 * @param bool $and
26
+	 * @return string the SQL part
27
+	 */
28 28
 	public function getFilter($filter = array(),$where = false,$and = false) {
29 29
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
30 30
 		$filters = array();
@@ -95,15 +95,15 @@  discard block
 block discarded – undo
95 95
 		return $filter_query;
96 96
 	}
97 97
 
98
-    /**
99
-     * Executes the SQL statements to get the spotter information
100
-     *
101
-     * @param String $query the SQL query
102
-     * @param array $params parameter of the query
103
-     * @param String $limitQuery the limit query
104
-     * @param bool $schedules
105
-     * @return array the spotter information
106
-     */
98
+	/**
99
+	 * Executes the SQL statements to get the spotter information
100
+	 *
101
+	 * @param String $query the SQL query
102
+	 * @param array $params parameter of the query
103
+	 * @param String $limitQuery the limit query
104
+	 * @param bool $schedules
105
+	 * @return array the spotter information
106
+	 */
107 107
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
108 108
 	{
109 109
 		global $globalVM;
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
 	}
254 254
 
255 255
 
256
-    /**
257
-     * Gets all the spotter information based on the latest data entry
258
-     *
259
-     * @param string $limit
260
-     * @param string $sort
261
-     * @param array $filter
262
-     * @return array the spotter information
263
-     */
256
+	/**
257
+	 * Gets all the spotter information based on the latest data entry
258
+	 *
259
+	 * @param string $limit
260
+	 * @param string $sort
261
+	 * @param array $filter
262
+	 * @return array the spotter information
263
+	 */
264 264
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
265 265
 	{
266 266
 		global $global_marine_query;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
      * @param string $id
296 296
      * @return array the spotter information
297 297
      */
298
-    public function getMarineDataByID($id = '')
298
+	public function getMarineDataByID($id = '')
299 299
 	{
300 300
 		global $global_marine_query;
301 301
 		
@@ -308,15 +308,15 @@  discard block
 block discarded – undo
308 308
 		return $spotter_array;
309 309
 	}
310 310
 
311
-    /**
312
-     * Gets all the spotter information based on the callsign
313
-     *
314
-     * @param string $ident
315
-     * @param string $limit
316
-     * @param string $sort
317
-     * @param array $filter
318
-     * @return array the spotter information
319
-     */
311
+	/**
312
+	 * Gets all the spotter information based on the callsign
313
+	 *
314
+	 * @param string $ident
315
+	 * @param string $limit
316
+	 * @param string $sort
317
+	 * @param array $filter
318
+	 * @return array the spotter information
319
+	 */
320 320
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
321 321
 	{
322 322
 		global $global_marine_query;
@@ -367,15 +367,15 @@  discard block
 block discarded – undo
367 367
 		return $spotter_array;
368 368
 	}
369 369
 
370
-    /**
371
-     * Gets all the marine information based on the type
372
-     *
373
-     * @param string $type
374
-     * @param string $limit
375
-     * @param string $sort
376
-     * @param array $filter
377
-     * @return array the marine information
378
-     */
370
+	/**
371
+	 * Gets all the marine information based on the type
372
+	 *
373
+	 * @param string $type
374
+	 * @param string $limit
375
+	 * @param string $sort
376
+	 * @param array $filter
377
+	 * @return array the marine information
378
+	 */
379 379
 	public function getMarineDataByType($type = '', $limit = '', $sort = '', $filter = array())
380 380
 	{
381 381
 		global $global_marine_query;
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
 		return $spotter_array;
422 422
 	}
423 423
 
424
-    /**
425
-     * @param string $date
426
-     * @param string $limit
427
-     * @param string $sort
428
-     * @param array $filter
429
-     * @return array
430
-     */
431
-    public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
424
+	/**
425
+	 * @param string $date
426
+	 * @param string $limit
427
+	 * @param string $sort
428
+	 * @param array $filter
429
+	 * @return array
430
+	 */
431
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
432 432
 	{
433 433
 		global $global_marine_query, $globalTimezone, $globalDBdriver;
434 434
 		
@@ -485,15 +485,15 @@  discard block
 block discarded – undo
485 485
 		return $spotter_array;
486 486
 	}
487 487
 
488
-    /**
489
-     * Gets all the marine information based on the captain
490
-     *
491
-     * @param string $captain
492
-     * @param string $limit
493
-     * @param string $sort
494
-     * @param array $filter
495
-     * @return array the marine information
496
-     */
488
+	/**
489
+	 * Gets all the marine information based on the captain
490
+	 *
491
+	 * @param string $captain
492
+	 * @param string $limit
493
+	 * @param string $sort
494
+	 * @param array $filter
495
+	 * @return array the marine information
496
+	 */
497 497
 	public function getMarineDataByCaptain($captain = '', $limit = '', $sort = '', $filter = array())
498 498
 	{
499 499
 		global $global_marine_query;
@@ -531,15 +531,15 @@  discard block
 block discarded – undo
531 531
 		return $spotter_array;
532 532
 	}
533 533
 
534
-    /**
535
-     * Gets all the marine information based on the race
536
-     *
537
-     * @param string $race
538
-     * @param string $limit
539
-     * @param string $sort
540
-     * @param array $filter
541
-     * @return array the marine information
542
-     */
534
+	/**
535
+	 * Gets all the marine information based on the race
536
+	 *
537
+	 * @param string $race
538
+	 * @param string $limit
539
+	 * @param string $sort
540
+	 * @param array $filter
541
+	 * @return array the marine information
542
+	 */
543 543
 	public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array())
544 544
 	{
545 545
 		global $global_marine_query,$globalDBdriver;
@@ -581,13 +581,13 @@  discard block
 block discarded – undo
581 581
 		return $spotter_array;
582 582
 	}
583 583
 
584
-    /**
585
-     * Count races by captain
586
-     *
587
-     * @param $captain
588
-     * @param array $filters
589
-     * @return Integer number of race for a captain
590
-     */
584
+	/**
585
+	 * Count races by captain
586
+	 *
587
+	 * @param $captain
588
+	 * @param array $filters
589
+	 * @return Integer number of race for a captain
590
+	 */
591 591
 	public function countRacesByCaptain($captain,$filters = array())
592 592
 	{
593 593
 		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
@@ -602,13 +602,13 @@  discard block
 block discarded – undo
602 602
 		return $result[0]['nb'];
603 603
 	}
604 604
 
605
-    /**
606
-     * Count captains by race
607
-     *
608
-     * @param $race
609
-     * @param array $filters
610
-     * @return String Duration of all races
611
-     */
605
+	/**
606
+	 * Count captains by race
607
+	 *
608
+	 * @param $race
609
+	 * @param array $filters
610
+	 * @return String Duration of all races
611
+	 */
612 612
 	public function countCaptainsByRace($race,$filters = array())
613 613
 	{
614 614
 		$race = filter_var($race,FILTER_SANITIZE_STRING);
@@ -623,16 +623,16 @@  discard block
 block discarded – undo
623 623
 		return $result[0]['nb'];
624 624
 	}
625 625
 
626
-    /**
627
-     * Gets all boat types that have been used by a captain
628
-     *
629
-     * @param $captain
630
-     * @param array $filters
631
-     * @param string $year
632
-     * @param string $month
633
-     * @param string $day
634
-     * @return array the boat list
635
-     */
626
+	/**
627
+	 * Gets all boat types that have been used by a captain
628
+	 *
629
+	 * @param $captain
630
+	 * @param array $filters
631
+	 * @param string $year
632
+	 * @param string $month
633
+	 * @param string $day
634
+	 * @return array the boat list
635
+	 */
636 636
 	public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
637 637
 	{
638 638
 		global $globalDBdriver;
@@ -676,16 +676,16 @@  discard block
 block discarded – undo
676 676
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
677 677
 	}
678 678
 
679
-    /**
680
-     * Gets all boat types that have been used on a race
681
-     *
682
-     * @param $race
683
-     * @param array $filters
684
-     * @param string $year
685
-     * @param string $month
686
-     * @param string $day
687
-     * @return array the boat list
688
-     */
679
+	/**
680
+	 * Gets all boat types that have been used on a race
681
+	 *
682
+	 * @param $race
683
+	 * @param array $filters
684
+	 * @param string $year
685
+	 * @param string $month
686
+	 * @param string $day
687
+	 * @return array the boat list
688
+	 */
689 689
 	public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '')
690 690
 	{
691 691
 		global $globalDBdriver;
@@ -729,16 +729,16 @@  discard block
 block discarded – undo
729 729
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
730 730
 	}
731 731
 
732
-    /**
733
-     * Gets race duration by captain
734
-     *
735
-     * @param $captain
736
-     * @param array $filters
737
-     * @param string $year
738
-     * @param string $month
739
-     * @param string $day
740
-     * @return String Duration of all race
741
-     */
732
+	/**
733
+	 * Gets race duration by captain
734
+	 *
735
+	 * @param $captain
736
+	 * @param array $filters
737
+	 * @param string $year
738
+	 * @param string $month
739
+	 * @param string $day
740
+	 * @return String Duration of all race
741
+	 */
742 742
 	public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
743 743
 	{
744 744
 		global $globalDBdriver;
@@ -783,16 +783,16 @@  discard block
 block discarded – undo
783 783
 		else return $result[0]['duration'];
784 784
 	}
785 785
 
786
-    /**
787
-     * Gets race duration by captains
788
-     *
789
-     * @param bool $limit
790
-     * @param array $filters
791
-     * @param string $year
792
-     * @param string $month
793
-     * @param string $day
794
-     * @return array Duration of all race
795
-     */
786
+	/**
787
+	 * Gets race duration by captains
788
+	 *
789
+	 * @param bool $limit
790
+	 * @param array $filters
791
+	 * @param string $year
792
+	 * @param string $month
793
+	 * @param string $day
794
+	 * @return array Duration of all race
795
+	 */
796 796
 	public function getRaceDurationByCaptains($limit = true,$filters = array(),$year = '',$month = '',$day = '')
797 797
 	{
798 798
 		global $globalDBdriver;
@@ -850,12 +850,12 @@  discard block
 block discarded – undo
850 850
 
851 851
 	}
852 852
 
853
-    /**
854
-     * Gets a list of all captain names and captain ids
855
-     *
856
-     * @param array $filters
857
-     * @return array list of captain names and captain ids
858
-     */
853
+	/**
854
+	 * Gets a list of all captain names and captain ids
855
+	 *
856
+	 * @param array $filters
857
+	 * @return array list of captain names and captain ids
858
+	 */
859 859
 	public function getAllCaptainNames($filters = array())
860 860
 	{
861 861
 		$filter_query = $this->getFilter($filters,true,true);
@@ -868,12 +868,12 @@  discard block
 block discarded – undo
868 868
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
869 869
 	}
870 870
 
871
-    /**
872
-     * Gets a list of all race names and race ids
873
-     *
874
-     * @param array $filters
875
-     * @return array list of race names and race ids
876
-     */
871
+	/**
872
+	 * Gets a list of all race names and race ids
873
+	 *
874
+	 * @param array $filters
875
+	 * @return array list of race names and race ids
876
+	 */
877 877
 	public function getAllRaceNames($filters = array())
878 878
 	{
879 879
 		$filter_query = $this->getFilter($filters,true,true);
@@ -887,13 +887,13 @@  discard block
 block discarded – undo
887 887
 	}
888 888
 
889 889
 
890
-    /**
891
-     * Gets all source name
892
-     *
893
-     * @param String type format of source
894
-     * @param array $filters
895
-     * @return array list of source name
896
-     */
890
+	/**
891
+	 * Gets all source name
892
+	 *
893
+	 * @param String type format of source
894
+	 * @param array $filters
895
+	 * @return array list of source name
896
+	 */
897 897
 	public function getAllSourceName($type = '',$filters = array())
898 898
 	{
899 899
 		$filter_query = $this->getFilter($filters,true,true);
@@ -922,12 +922,12 @@  discard block
 block discarded – undo
922 922
 	}
923 923
 
924 924
 
925
-    /**
926
-     * Gets a list of all idents/callsigns
927
-     *
928
-     * @param array $filters
929
-     * @return array list of ident/callsign names
930
-     */
925
+	/**
926
+	 * Gets a list of all idents/callsigns
927
+	 *
928
+	 * @param array $filters
929
+	 * @return array list of ident/callsign names
930
+	 */
931 931
 	public function getAllIdents($filters = array())
932 932
 	{
933 933
 		$filter_query = $this->getFilter($filters,true,true);
@@ -950,12 +950,12 @@  discard block
 block discarded – undo
950 950
 		return $ident_array;
951 951
 	}
952 952
 
953
-    /**
954
-     * Gets all info from a mmsi
955
-     *
956
-     * @param $mmsi
957
-     * @return array ident
958
-     */
953
+	/**
954
+	 * Gets all info from a mmsi
955
+	 *
956
+	 * @param $mmsi
957
+	 * @return array ident
958
+	 */
959 959
 	public function getIdentity($mmsi)
960 960
 	{
961 961
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -967,14 +967,14 @@  discard block
 block discarded – undo
967 967
 		else return array();
968 968
 	}
969 969
 
970
-    /**
971
-     * Add identity
972
-     * @param $mmsi
973
-     * @param $imo
974
-     * @param $ident
975
-     * @param $callsign
976
-     * @param $type
977
-     */
970
+	/**
971
+	 * Add identity
972
+	 * @param $mmsi
973
+	 * @param $imo
974
+	 * @param $ident
975
+	 * @param $callsign
976
+	 * @param $type
977
+	 */
978 978
 	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
979 979
 	{
980 980
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -1040,13 +1040,13 @@  discard block
 block discarded – undo
1040 1040
 	}
1041 1041
 
1042 1042
 	/**
1043
-	* Update ident tracker data
1044
-	*
1045
-	* @param String $fammarine_id the ID
1046
-	* @param String $ident the marine ident
1047
-	* @return String success or false
1048
-	*
1049
-	*/
1043
+	 * Update ident tracker data
1044
+	 *
1045
+	 * @param String $fammarine_id the ID
1046
+	 * @param String $ident the marine ident
1047
+	 * @return String success or false
1048
+	 *
1049
+	 */
1050 1050
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
1051 1051
 	{
1052 1052
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
@@ -1061,13 +1061,13 @@  discard block
 block discarded – undo
1061 1061
 	}
1062 1062
 
1063 1063
 	/**
1064
-	* Update arrival marine data
1065
-	*
1066
-	* @param String $fammarine_id the ID
1067
-	* @param String $arrival_code the marine ident
1068
-	* @return String success or false
1069
-	*
1070
-	*/
1064
+	 * Update arrival marine data
1065
+	 *
1066
+	 * @param String $fammarine_id the ID
1067
+	 * @param String $arrival_code the marine ident
1068
+	 * @return String success or false
1069
+	 *
1070
+	 */
1071 1071
 	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL)
1072 1072
 	{
1073 1073
 		$query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id';
@@ -1082,19 +1082,19 @@  discard block
 block discarded – undo
1082 1082
 	}
1083 1083
 
1084 1084
 	/**
1085
-	* Update Status data
1086
-	*
1087
-	* @param String $fammarine_id the ID
1088
-	* @param String $status_id the marine status id
1089
-	* @param String $status the marine status
1090
-	* @return String success or false
1091
-	*
1092
-	*/
1085
+	 * Update Status data
1086
+	 *
1087
+	 * @param String $fammarine_id the ID
1088
+	 * @param String $status_id the marine status id
1089
+	 * @param String $status the marine status
1090
+	 * @return String success or false
1091
+	 *
1092
+	 */
1093 1093
 	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
1094 1094
 	{
1095 1095
 
1096 1096
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
1097
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
1097
+				$query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
1098 1098
 
1099 1099
 		try {
1100 1100
 			$sth = $this->db->prepare($query);
@@ -1107,22 +1107,22 @@  discard block
 block discarded – undo
1107 1107
 
1108 1108
 	}
1109 1109
 
1110
-    /**
1111
-     * Update latest marine data
1112
-     *
1113
-     * @param String $fammarine_id the ID
1114
-     * @param String $ident the marine ident
1115
-     * @param string $latitude
1116
-     * @param string $longitude
1117
-     * @param float $groundspeed
1118
-     * @param string $date
1119
-     * @param float $distance
1120
-     * @param integer $race_rank
1121
-     * @param integer $race_time
1122
-     * @param string $status
1123
-     * @param string $race_begin
1124
-     * @return String success or false
1125
-     */
1110
+	/**
1111
+	 * Update latest marine data
1112
+	 *
1113
+	 * @param String $fammarine_id the ID
1114
+	 * @param String $ident the marine ident
1115
+	 * @param string $latitude
1116
+	 * @param string $longitude
1117
+	 * @param float $groundspeed
1118
+	 * @param string $date
1119
+	 * @param float $distance
1120
+	 * @param integer $race_rank
1121
+	 * @param integer $race_time
1122
+	 * @param string $status
1123
+	 * @param string $race_begin
1124
+	 * @return String success or false
1125
+	 */
1126 1126
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1127 1127
 	{
1128 1128
 		if ($latitude == '') $latitude = NULL;
@@ -1147,36 +1147,36 @@  discard block
 block discarded – undo
1147 1147
 
1148 1148
 	}
1149 1149
 
1150
-    /**
1151
-     * Adds a new marine data
1152
-     *
1153
-     * @param String $fammarine_id the ID
1154
-     * @param String $ident the marine ident
1155
-     * @param String $latitude latitude of flight
1156
-     * @param String $longitude latitude of flight
1157
-     * @param String $heading heading of flight
1158
-     * @param String $groundspeed speed of flight
1159
-     * @param String $date date of flight
1160
-     * @param string $mmsi
1161
-     * @param string $type
1162
-     * @param string $typeid
1163
-     * @param string $imo
1164
-     * @param string $callsign
1165
-     * @param string $arrival_code
1166
-     * @param string $arrival_date
1167
-     * @param string $status
1168
-     * @param string $statusid
1169
-     * @param string $format_source
1170
-     * @param string $source_name
1171
-     * @param string $captain_id
1172
-     * @param string $captain_name
1173
-     * @param string $race_id
1174
-     * @param string $race_name
1175
-     * @param string $distance
1176
-     * @param string $race_rank
1177
-     * @param string $race_time
1178
-     * @return String success or false
1179
-     */
1150
+	/**
1151
+	 * Adds a new marine data
1152
+	 *
1153
+	 * @param String $fammarine_id the ID
1154
+	 * @param String $ident the marine ident
1155
+	 * @param String $latitude latitude of flight
1156
+	 * @param String $longitude latitude of flight
1157
+	 * @param String $heading heading of flight
1158
+	 * @param String $groundspeed speed of flight
1159
+	 * @param String $date date of flight
1160
+	 * @param string $mmsi
1161
+	 * @param string $type
1162
+	 * @param string $typeid
1163
+	 * @param string $imo
1164
+	 * @param string $callsign
1165
+	 * @param string $arrival_code
1166
+	 * @param string $arrival_date
1167
+	 * @param string $status
1168
+	 * @param string $statusid
1169
+	 * @param string $format_source
1170
+	 * @param string $source_name
1171
+	 * @param string $captain_id
1172
+	 * @param string $captain_name
1173
+	 * @param string $race_id
1174
+	 * @param string $race_name
1175
+	 * @param string $distance
1176
+	 * @param string $race_rank
1177
+	 * @param string $race_time
1178
+	 * @return String success or false
1179
+	 */
1180 1180
 	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 = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '')
1181 1181
 	{
1182 1182
 		global $globalMarineImageFetch;
@@ -1309,12 +1309,12 @@  discard block
 block discarded – undo
1309 1309
 	}
1310 1310
 
1311 1311
 
1312
-    /**
1313
-     * Gets the aircraft ident within the last hour
1314
-     *
1315
-     * @param $ident
1316
-     * @return String the ident
1317
-     */
1312
+	/**
1313
+	 * Gets the aircraft ident within the last hour
1314
+	 *
1315
+	 * @param $ident
1316
+	 * @return String the ident
1317
+	 */
1318 1318
 	public function getIdentFromLastHour($ident)
1319 1319
 	{
1320 1320
 		global $globalDBdriver, $globalTimezone;
@@ -1330,11 +1330,11 @@  discard block
 block discarded – undo
1330 1330
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
1331 1331
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
1332 1332
 			$query_data = array(':ident' => $ident);
1333
-    		}
1333
+			}
1334 1334
 		
1335 1335
 		$sth = $this->db->prepare($query);
1336 1336
 		$sth->execute($query_data);
1337
-    		$ident_result='';
1337
+			$ident_result='';
1338 1338
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1339 1339
 		{
1340 1340
 			$ident_result = $row['ident'];
@@ -1344,12 +1344,12 @@  discard block
 block discarded – undo
1344 1344
 	}
1345 1345
 
1346 1346
 
1347
-    /**
1348
-     * Gets the aircraft data from the last 20 seconds
1349
-     *
1350
-     * @param string $q
1351
-     * @return array the marine data
1352
-     */
1347
+	/**
1348
+	 * Gets the aircraft data from the last 20 seconds
1349
+	 *
1350
+	 * @param string $q
1351
+	 * @return array the marine data
1352
+	 */
1353 1353
 	public function getRealTimeData($q = '')
1354 1354
 	{
1355 1355
 		global $globalDBdriver;
@@ -1384,15 +1384,15 @@  discard block
 block discarded – undo
1384 1384
 	}
1385 1385
 
1386 1386
 
1387
-    /**
1388
-     * Gets all number of flight over countries
1389
-     *
1390
-     * @param bool $limit
1391
-     * @param int $olderthanmonths
1392
-     * @param string $sincedate
1393
-     * @param array $filters
1394
-     * @return array the airline country list
1395
-     */
1387
+	/**
1388
+	 * Gets all number of flight over countries
1389
+	 *
1390
+	 * @param bool $limit
1391
+	 * @param int $olderthanmonths
1392
+	 * @param string $sincedate
1393
+	 * @param array $filters
1394
+	 * @return array the airline country list
1395
+	 */
1396 1396
 
1397 1397
 	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1398 1398
 	{
@@ -1463,18 +1463,18 @@  discard block
 block discarded – undo
1463 1463
 	}
1464 1464
 
1465 1465
 
1466
-    /**
1467
-     * Gets all callsigns that have flown over
1468
-     *
1469
-     * @param bool $limit
1470
-     * @param int $olderthanmonths
1471
-     * @param string $sincedate
1472
-     * @param array $filters
1473
-     * @param string $year
1474
-     * @param string $month
1475
-     * @param string $day
1476
-     * @return array the callsign list
1477
-     */
1466
+	/**
1467
+	 * Gets all callsigns that have flown over
1468
+	 *
1469
+	 * @param bool $limit
1470
+	 * @param int $olderthanmonths
1471
+	 * @param string $sincedate
1472
+	 * @param array $filters
1473
+	 * @param string $year
1474
+	 * @param string $month
1475
+	 * @param string $day
1476
+	 * @return array the callsign list
1477
+	 */
1478 1478
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
1479 1479
 	{
1480 1480
 		global $globalDBdriver;
@@ -1540,12 +1540,12 @@  discard block
 block discarded – undo
1540 1540
 	}
1541 1541
 
1542 1542
 
1543
-    /**
1544
-     * Counts all dates
1545
-     *
1546
-     * @param array $filters
1547
-     * @return array the date list
1548
-     */
1543
+	/**
1544
+	 * Counts all dates
1545
+	 *
1546
+	 * @param array $filters
1547
+	 * @return array the date list
1548
+	 */
1549 1549
 	public function countAllDates($filters = array())
1550 1550
 	{
1551 1551
 		global $globalTimezone, $globalDBdriver;
@@ -1590,12 +1590,12 @@  discard block
 block discarded – undo
1590 1590
 	}
1591 1591
 
1592 1592
 
1593
-    /**
1594
-     * Counts all dates during the last 7 days
1595
-     *
1596
-     * @param array $filters
1597
-     * @return array the date list
1598
-     */
1593
+	/**
1594
+	 * Counts all dates during the last 7 days
1595
+	 *
1596
+	 * @param array $filters
1597
+	 * @return array the date list
1598
+	 */
1599 1599
 	public function countAllDatesLast7Days($filters = array())
1600 1600
 	{
1601 1601
 		global $globalTimezone, $globalDBdriver;
@@ -1617,7 +1617,7 @@  discard block
 block discarded – undo
1617 1617
 			$query .= " GROUP BY date_name 
1618 1618
 								ORDER BY date_name ASC";
1619 1619
 			$query_data = array(':offset' => $offset);
1620
-    		}
1620
+			}
1621 1621
 		
1622 1622
 		$sth = $this->db->prepare($query);
1623 1623
 		$sth->execute($query_data);
@@ -1636,12 +1636,12 @@  discard block
 block discarded – undo
1636 1636
 		return $date_array;
1637 1637
 	}
1638 1638
 
1639
-    /**
1640
-     * Counts all dates during the last month
1641
-     *
1642
-     * @param array $filters
1643
-     * @return array the date list
1644
-     */
1639
+	/**
1640
+	 * Counts all dates during the last month
1641
+	 *
1642
+	 * @param array $filters
1643
+	 * @return array the date list
1644
+	 */
1645 1645
 	public function countAllDatesLastMonth($filters = array())
1646 1646
 	{
1647 1647
 		global $globalTimezone, $globalDBdriver;
@@ -1663,7 +1663,7 @@  discard block
 block discarded – undo
1663 1663
 			$query .= " GROUP BY date_name 
1664 1664
 								ORDER BY date_name ASC";
1665 1665
 			$query_data = array(':offset' => $offset);
1666
-    		}
1666
+			}
1667 1667
 		
1668 1668
 		$sth = $this->db->prepare($query);
1669 1669
 		$sth->execute($query_data);
@@ -1683,12 +1683,12 @@  discard block
 block discarded – undo
1683 1683
 	}
1684 1684
 
1685 1685
 
1686
-    /**
1687
-     * Counts all month
1688
-     *
1689
-     * @param array $filters
1690
-     * @return array the month list
1691
-     */
1686
+	/**
1687
+	 * Counts all month
1688
+	 *
1689
+	 * @param array $filters
1690
+	 * @return array the month list
1691
+	 */
1692 1692
 	public function countAllMonths($filters = array())
1693 1693
 	{
1694 1694
 		global $globalTimezone, $globalDBdriver;
@@ -1730,12 +1730,12 @@  discard block
 block discarded – undo
1730 1730
 	}
1731 1731
 
1732 1732
 
1733
-    /**
1734
-     * Counts all dates during the last year
1735
-     *
1736
-     * @param $filters
1737
-     * @return array the date list
1738
-     */
1733
+	/**
1734
+	 * Counts all dates during the last year
1735
+	 *
1736
+	 * @param $filters
1737
+	 * @return array the date list
1738
+	 */
1739 1739
 	public function countAllMonthsLastYear($filters)
1740 1740
 	{
1741 1741
 		global $globalTimezone, $globalDBdriver;
@@ -1757,7 +1757,7 @@  discard block
 block discarded – undo
1757 1757
 			$query .= " GROUP BY year_name, month_name
1758 1758
 								ORDER BY year_name, month_name ASC";
1759 1759
 			$query_data = array(':offset' => $offset);
1760
-    		}
1760
+			}
1761 1761
 		
1762 1762
 		$sth = $this->db->prepare($query);
1763 1763
 		$sth->execute($query_data);
@@ -1778,13 +1778,13 @@  discard block
 block discarded – undo
1778 1778
 	}
1779 1779
 
1780 1780
 
1781
-    /**
1782
-     * Counts all hours
1783
-     *
1784
-     * @param $orderby
1785
-     * @param array $filters
1786
-     * @return array the hour list
1787
-     */
1781
+	/**
1782
+	 * Counts all hours
1783
+	 *
1784
+	 * @param $orderby
1785
+	 * @param array $filters
1786
+	 * @return array the hour list
1787
+	 */
1788 1788
 	public function countAllHours($orderby,$filters = array())
1789 1789
 	{
1790 1790
 		global $globalTimezone, $globalDBdriver;
@@ -1845,13 +1845,13 @@  discard block
 block discarded – undo
1845 1845
 	}
1846 1846
 
1847 1847
 
1848
-    /**
1849
-     * Counts all hours by date
1850
-     *
1851
-     * @param $date
1852
-     * @param array $filters
1853
-     * @return array the hour list
1854
-     */
1848
+	/**
1849
+	 * Counts all hours by date
1850
+	 *
1851
+	 * @param $date
1852
+	 * @param array $filters
1853
+	 * @return array the hour list
1854
+	 */
1855 1855
 	public function countAllHoursByDate($date, $filters = array())
1856 1856
 	{
1857 1857
 		global $globalTimezone, $globalDBdriver;
@@ -1893,13 +1893,13 @@  discard block
 block discarded – undo
1893 1893
 	}
1894 1894
 
1895 1895
 
1896
-    /**
1897
-     * Counts all hours by a ident/callsign
1898
-     *
1899
-     * @param $ident
1900
-     * @param array $filters
1901
-     * @return array the hour list
1902
-     */
1896
+	/**
1897
+	 * Counts all hours by a ident/callsign
1898
+	 *
1899
+	 * @param $ident
1900
+	 * @param array $filters
1901
+	 * @return array the hour list
1902
+	 */
1903 1903
 	public function countAllHoursByIdent($ident, $filters = array())
1904 1904
 	{
1905 1905
 		global $globalTimezone, $globalDBdriver;
@@ -1941,15 +1941,15 @@  discard block
 block discarded – undo
1941 1941
 		return $hour_array;
1942 1942
 	}
1943 1943
 
1944
-    /**
1945
-     * Gets all aircraft registrations that have flown over
1946
-     *
1947
-     * @param bool $limit
1948
-     * @param int $olderthanmonths
1949
-     * @param string $sincedate
1950
-     * @param array $filters
1951
-     * @return array the aircraft list
1952
-     */
1944
+	/**
1945
+	 * Gets all aircraft registrations that have flown over
1946
+	 *
1947
+	 * @param bool $limit
1948
+	 * @param int $olderthanmonths
1949
+	 * @param string $sincedate
1950
+	 * @param array $filters
1951
+	 * @return array the aircraft list
1952
+	 */
1953 1953
 	public function countAllCaptainsByRaces($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1954 1954
 	{
1955 1955
 		global $globalDBdriver;
@@ -1987,14 +1987,14 @@  discard block
 block discarded – undo
1987 1987
 		return $marine_array;
1988 1988
 	}
1989 1989
 
1990
-    /**
1991
-     * Counts all vessels
1992
-     *
1993
-     * @param array $filters
1994
-     * @param string $year
1995
-     * @param string $month
1996
-     * @return Integer the number of vessels
1997
-     */
1990
+	/**
1991
+	 * Counts all vessels
1992
+	 *
1993
+	 * @param array $filters
1994
+	 * @param string $year
1995
+	 * @param string $month
1996
+	 * @return Integer the number of vessels
1997
+	 */
1998 1998
 	public function countOverallMarine($filters = array(),$year = '',$month = '')
1999 1999
 	{
2000 2000
 		global $globalDBdriver;
@@ -2028,14 +2028,14 @@  discard block
 block discarded – undo
2028 2028
 		return $sth->fetchColumn();
2029 2029
 	}
2030 2030
 
2031
-    /**
2032
-     * Counts all vessel type
2033
-     *
2034
-     * @param array $filters
2035
-     * @param string $year
2036
-     * @param string $month
2037
-     * @return Integer the number of vessels
2038
-     */
2031
+	/**
2032
+	 * Counts all vessel type
2033
+	 *
2034
+	 * @param array $filters
2035
+	 * @param string $year
2036
+	 * @param string $month
2037
+	 * @return Integer the number of vessels
2038
+	 */
2039 2039
 	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
2040 2040
 	{
2041 2041
 		global $globalDBdriver;
@@ -2068,14 +2068,14 @@  discard block
 block discarded – undo
2068 2068
 		return $sth->fetchColumn();
2069 2069
 	}
2070 2070
 
2071
-    /**
2072
-     * Gets a number of all race
2073
-     *
2074
-     * @param array $filters
2075
-     * @param string $year
2076
-     * @param string $month
2077
-     * @return Integer number of races
2078
-     */
2071
+	/**
2072
+	 * Gets a number of all race
2073
+	 *
2074
+	 * @param array $filters
2075
+	 * @param string $year
2076
+	 * @param string $month
2077
+	 * @return Integer number of races
2078
+	 */
2079 2079
 	public function countOverallMarineRaces($filters = array(),$year = '',$month = '')
2080 2080
 	{
2081 2081
 		global $globalDBdriver;
@@ -2108,14 +2108,14 @@  discard block
 block discarded – undo
2108 2108
 		return $sth->fetchColumn();
2109 2109
 	}
2110 2110
 
2111
-    /**
2112
-     * Gets a number of all captain
2113
-     *
2114
-     * @param array $filters
2115
-     * @param string $year
2116
-     * @param string $month
2117
-     * @return Integer number of captain
2118
-     */
2111
+	/**
2112
+	 * Gets a number of all captain
2113
+	 *
2114
+	 * @param array $filters
2115
+	 * @param string $year
2116
+	 * @param string $month
2117
+	 * @return Integer number of captain
2118
+	 */
2119 2119
 	public function countOverallMarineCaptains($filters = array(),$year = '',$month = '')
2120 2120
 	{
2121 2121
 		global $globalDBdriver;
@@ -2148,12 +2148,12 @@  discard block
 block discarded – undo
2148 2148
 		return $sth->fetchColumn();
2149 2149
 	}
2150 2150
 
2151
-    /**
2152
-     * Counts all hours of today
2153
-     *
2154
-     * @param array $filters
2155
-     * @return array the hour list
2156
-     */
2151
+	/**
2152
+	 * Counts all hours of today
2153
+	 *
2154
+	 * @param array $filters
2155
+	 * @return array the hour list
2156
+	 */
2157 2157
 	public function countAllHoursFromToday($filters = array())
2158 2158
 	{
2159 2159
 		global $globalTimezone, $globalDBdriver;
@@ -2193,12 +2193,12 @@  discard block
 block discarded – undo
2193 2193
 	}
2194 2194
 
2195 2195
 
2196
-    /**
2197
-     * Gets the Barrie Spotter ID based on the FlightAware ID
2198
-     *
2199
-     * @param $fammarine_id
2200
-     * @return Integer the Barrie Spotter ID
2201
-     */
2196
+	/**
2197
+	 * Gets the Barrie Spotter ID based on the FlightAware ID
2198
+	 *
2199
+	 * @param $fammarine_id
2200
+	 * @return Integer the Barrie Spotter ID
2201
+	 */
2202 2202
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
2203 2203
 	{
2204 2204
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -2219,13 +2219,13 @@  discard block
 block discarded – undo
2219 2219
   
2220 2220
  
2221 2221
 	/**
2222
-	* Parses a date string
2223
-	*
2224
-	* @param String $dateString the date string
2225
-	* @param String $timezone the timezone of a user
2226
-	* @return array the time information
2227
-	*
2228
-	*/
2222
+	 * Parses a date string
2223
+	 *
2224
+	 * @param String $dateString the date string
2225
+	 * @param String $timezone the timezone of a user
2226
+	 * @return array the time information
2227
+	 *
2228
+	 */
2229 2229
 	public function parseDateString($dateString, $timezone = '')
2230 2230
 	{
2231 2231
 		$time_array = array();
@@ -2258,12 +2258,12 @@  discard block
 block discarded – undo
2258 2258
 	}
2259 2259
 	
2260 2260
 	/**
2261
-	* Parses the direction degrees to working
2262
-	*
2263
-	* @param Float $direction the direction in degrees
2264
-	* @return array the direction information
2265
-	*
2266
-	*/
2261
+	 * Parses the direction degrees to working
2262
+	 *
2263
+	 * @param Float $direction the direction in degrees
2264
+	 * @return array the direction information
2265
+	 *
2266
+	 */
2267 2267
 	public function parseDirection($direction = 0)
2268 2268
 	{
2269 2269
 		if ($direction == '') $direction = 0;
@@ -2342,12 +2342,12 @@  discard block
 block discarded – undo
2342 2342
 	
2343 2343
 	
2344 2344
 	/**
2345
-	* Gets Country from latitude/longitude
2346
-	*
2347
-	* @param Float $latitude latitute of the flight
2348
-	* @param Float $longitude longitute of the flight
2349
-	* @return String the countries
2350
-	*/
2345
+	 * Gets Country from latitude/longitude
2346
+	 *
2347
+	 * @param Float $latitude latitute of the flight
2348
+	 * @param Float $longitude longitute of the flight
2349
+	 * @return String the countries
2350
+	 */
2351 2351
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
2352 2352
 	{
2353 2353
 		global $globalDebug;
@@ -2384,11 +2384,11 @@  discard block
 block discarded – undo
2384 2384
 	}
2385 2385
 
2386 2386
 	/**
2387
-	* Gets Country from iso2
2388
-	*
2389
-	* @param String $iso2 ISO2 country code
2390
-	* @return String the countries
2391
-	*/
2387
+	 * Gets Country from iso2
2388
+	 *
2389
+	 * @param String $iso2 ISO2 country code
2390
+	 * @return String the countries
2391
+	 */
2392 2392
 	public function getCountryFromISO2($iso2)
2393 2393
 	{
2394 2394
 		global $globalDebug;
@@ -2417,12 +2417,12 @@  discard block
 block discarded – undo
2417 2417
 
2418 2418
 	
2419 2419
 	/**
2420
-	* Gets the short url from bit.ly
2421
-	*
2422
-	* @param String $url the full url
2423
-	* @return String the bit.ly url
2424
-	*
2425
-	*/
2420
+	 * Gets the short url from bit.ly
2421
+	 *
2422
+	 * @param String $url the full url
2423
+	 * @return String the bit.ly url
2424
+	 *
2425
+	 */
2426 2426
 	public function getBitlyURL($url)
2427 2427
 	{
2428 2428
 		global $globalBitlyAccessToken;
@@ -2448,18 +2448,18 @@  discard block
 block discarded – undo
2448 2448
 	}
2449 2449
 
2450 2450
 
2451
-    /**
2452
-     * Gets all vessels types that have flown over
2453
-     *
2454
-     * @param bool $limit
2455
-     * @param int $olderthanmonths
2456
-     * @param string $sincedate
2457
-     * @param array $filters
2458
-     * @param string $year
2459
-     * @param string $month
2460
-     * @param string $day
2461
-     * @return array the vessel type list
2462
-     */
2451
+	/**
2452
+	 * Gets all vessels types that have flown over
2453
+	 *
2454
+	 * @param bool $limit
2455
+	 * @param int $olderthanmonths
2456
+	 * @param string $sincedate
2457
+	 * @param array $filters
2458
+	 * @param string $year
2459
+	 * @param string $month
2460
+	 * @param string $day
2461
+	 * @return array the vessel type list
2462
+	 */
2463 2463
 	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
2464 2464
 	{
2465 2465
 		global $globalDBdriver;
@@ -2524,27 +2524,27 @@  discard block
 block discarded – undo
2524 2524
 		return $marine_array;
2525 2525
 	}
2526 2526
 
2527
-    /**
2528
-     * Gets all the tracker information
2529
-     *
2530
-     * @param string $q
2531
-     * @param string $callsign
2532
-     * @param string $mmsi
2533
-     * @param string $imo
2534
-     * @param string $date_posted
2535
-     * @param string $limit
2536
-     * @param string $sort
2537
-     * @param string $includegeodata
2538
-     * @param string $origLat
2539
-     * @param string $origLon
2540
-     * @param string $dist
2541
-     * @param string $captain_id
2542
-     * @param string $captain_name
2543
-     * @param string $race_id
2544
-     * @param string $race_name
2545
-     * @param array $filters
2546
-     * @return array the tracker information
2547
-     */
2527
+	/**
2528
+	 * Gets all the tracker information
2529
+	 *
2530
+	 * @param string $q
2531
+	 * @param string $callsign
2532
+	 * @param string $mmsi
2533
+	 * @param string $imo
2534
+	 * @param string $date_posted
2535
+	 * @param string $limit
2536
+	 * @param string $sort
2537
+	 * @param string $includegeodata
2538
+	 * @param string $origLat
2539
+	 * @param string $origLon
2540
+	 * @param string $dist
2541
+	 * @param string $captain_id
2542
+	 * @param string $captain_name
2543
+	 * @param string $race_id
2544
+	 * @param string $race_name
2545
+	 * @param array $filters
2546
+	 * @return array the tracker information
2547
+	 */
2548 2548
 	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$captain_id = '',$captain_name = '',$race_id = '',$race_name = '',$filters = array())
2549 2549
 	{
2550 2550
 		global $globalTimezone, $globalDBdriver;
@@ -2720,12 +2720,12 @@  discard block
 block discarded – undo
2720 2720
 		return $marine_array;
2721 2721
 	}
2722 2722
 
2723
-    /**
2724
-     * Check marine by id
2725
-     *
2726
-     * @param $id
2727
-     * @return String the ident
2728
-     */
2723
+	/**
2724
+	 * Check marine by id
2725
+	 *
2726
+	 * @param $id
2727
+	 * @return String the ident
2728
+	 */
2729 2729
 	public function checkId($id)
2730 2730
 	{
2731 2731
 		$query  = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id';
@@ -2740,12 +2740,12 @@  discard block
 block discarded – undo
2740 2740
 		return $ident_result;
2741 2741
 	}
2742 2742
 
2743
-    /**
2744
-     * Gets all info from a race
2745
-     *
2746
-     * @param $race_name
2747
-     * @return array race
2748
-     */
2743
+	/**
2744
+	 * Gets all info from a race
2745
+	 *
2746
+	 * @param $race_name
2747
+	 * @return array race
2748
+	 */
2749 2749
 	public function getRaceByName($race_name)
2750 2750
 	{
2751 2751
 		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
@@ -2757,12 +2757,12 @@  discard block
 block discarded – undo
2757 2757
 		else return array();
2758 2758
 	}
2759 2759
 
2760
-    /**
2761
-     * Gets all info from a race
2762
-     *
2763
-     * @param $race_id
2764
-     * @return array race
2765
-     */
2760
+	/**
2761
+	 * Gets all info from a race
2762
+	 *
2763
+	 * @param $race_id
2764
+	 * @return array race
2765
+	 */
2766 2766
 	public function getRace($race_id)
2767 2767
 	{
2768 2768
 		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
@@ -2774,15 +2774,15 @@  discard block
 block discarded – undo
2774 2774
 		else return array();
2775 2775
 	}
2776 2776
 
2777
-    /**
2778
-     * Add race
2779
-     * @param $race_id
2780
-     * @param $race_name
2781
-     * @param $race_creator
2782
-     * @param $race_desc
2783
-     * @param $race_startdate
2784
-     * @param $race_markers
2785
-     */
2777
+	/**
2778
+	 * Add race
2779
+	 * @param $race_id
2780
+	 * @param $race_name
2781
+	 * @param $race_creator
2782
+	 * @param $race_desc
2783
+	 * @param $race_startdate
2784
+	 * @param $race_markers
2785
+	 */
2786 2786
 	public function addRace($race_id,$race_name,$race_creator,$race_desc,$race_startdate,$race_markers)
2787 2787
 	{
2788 2788
 		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.
require/class.Scheduler.php 1 patch
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
 		if ($this->db === null) die('Error: No DB connection.');
28 28
 	}
29 29
 
30
-    /**
31
-     * Add schedule data to database
32
-     * @param String $ident aircraft ident
33
-     * @param String $departure_airport_icao departure airport icao
34
-     * @param String $departure_airport_time departure airport time
35
-     * @param String $arrival_airport_icao arrival airport icao
36
-     * @param String $arrival_airport_time arrival airport time
37
-     * @param String $source source of data
38
-     * @return string
39
-     */
30
+	/**
31
+	 * Add schedule data to database
32
+	 * @param String $ident aircraft ident
33
+	 * @param String $departure_airport_icao departure airport icao
34
+	 * @param String $departure_airport_time departure airport time
35
+	 * @param String $arrival_airport_icao arrival airport icao
36
+	 * @param String $arrival_airport_time arrival airport time
37
+	 * @param String $source source of data
38
+	 * @return string
39
+	 */
40 40
 	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
41 41
 		date_default_timezone_set('UTC');
42 42
 		$date = date("Y-m-d H:i:s",time());
@@ -52,18 +52,18 @@  discard block
 block discarded – undo
52 52
 		}
53 53
 		if ($sth->fetchColumn() > 0) {
54 54
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
55
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
56
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
55
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
56
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
57 57
 			} elseif ($arrival_airport_time == '') {
58
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
59
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
58
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
59
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
60 60
 			} elseif ($departure_airport_time == '') {
61
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
62
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
61
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
62
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
63 63
 			} else {
64
-			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
65
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
66
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
64
+				//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
65
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
66
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
67 67
 			}
68 68
 			try {
69 69
 				$sth = $this->db->prepare($query);
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
 	*/
152 152
 	public function checkSchedule($ident) {
153 153
 		global $globalDBdriver;
154
-	        //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
155
-	        if ($globalDBdriver == 'mysql') {
154
+			//$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
155
+			if ($globalDBdriver == 'mysql') {
156 156
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1";
157 157
 		} else {
158 158
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident 
159 159
 			AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL)
160 160
 			     OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1";
161 161
 		}
162
-	        $query_values = array(':ident' => $ident);
162
+			$query_values = array(':ident' => $ident);
163 163
 		 try {
164 164
 			$sth = $this->db->prepare($query);
165 165
 			$sth->execute($query_values);
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
 		return $row['nb'];
172 172
 	}
173 173
 
174
-    /**
175
-     * Get flight info from Air France
176
-     * @param String $callsign The callsign
177
-     * @param String $date date we want flight number info
178
-     * @param String $carrier IATA code
179
-     * @return array departure and arrival airports and time
180
-     */
174
+	/**
175
+	 * Get flight info from Air France
176
+	 * @param String $callsign The callsign
177
+	 * @param String $date date we want flight number info
178
+	 * @param String $carrier IATA code
179
+	 * @return array departure and arrival airports and time
180
+	 */
181 181
 	public function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
182 182
 		$Common = new Common();
183 183
 		$check_date = new Datetime($date);
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
 		} else return array();
213 213
 	}
214 214
 
215
-    /**
216
-     * Get flight info from EasyJet
217
-     * @param String $callsign The callsign
218
-     * @param String $date date we want flight number info
219
-     * @return array departure and arrival airports and time
220
-     */
215
+	/**
216
+	 * Get flight info from EasyJet
217
+	 * @param String $callsign The callsign
218
+	 * @param String $date date we want flight number info
219
+	 * @return array departure and arrival airports and time
220
+	 */
221 221
 	private function getEasyJet($callsign, $date = 'NOW') {
222 222
 		global $globalTimezone;
223 223
 		$Common = new Common();
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
 		} else return array();
241 241
 	}
242 242
 
243
-    /**
244
-     * Get flight info from Ryanair
245
-     * @param String $callsign The callsign
246
-     * @return array Flight departure and arrival airports and time
247
-     */
243
+	/**
244
+	 * Get flight info from Ryanair
245
+	 * @param String $callsign The callsign
246
+	 * @return array Flight departure and arrival airports and time
247
+	 */
248 248
 	private function getRyanair($callsign) {
249 249
 		$Common = new Common();
250 250
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 	}
268 268
 
269 269
 	/**
270
-	* Get flight info from Swiss
271
-	* @param string $callsign The callsign
272
-	* @return array Flight departure and arrival airports and time
273
-	*/
270
+	 * Get flight info from Swiss
271
+	 * @param string $callsign The callsign
272
+	 * @return array Flight departure and arrival airports and time
273
+	 */
274 274
 	private function getSwiss($callsign) {
275 275
 		$Common = new Common();
276 276
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -299,11 +299,11 @@  discard block
 block discarded – undo
299 299
 	}
300 300
 	
301 301
 	/**
302
-	* Get flight info from British Airways API
303
-	* @param String $callsign The callsign
304
-	* @param String $date date we want flight number info
305
-	* @return array Flight departure and arrival airports and time
306
-	*/
302
+	 * Get flight info from British Airways API
303
+	 * @param String $callsign The callsign
304
+	 * @param String $date date we want flight number info
305
+	 * @return array Flight departure and arrival airports and time
306
+	 */
307 307
 	public function getBritishAirways($callsign, $date = 'NOW') {
308 308
 		global $globalBritishAirwaysKey;
309 309
 		$Common = new Common();
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
 	}
328 328
 
329 329
 	/**
330
-	* Get flight info from Lutfhansa API
331
-	* @param String $callsign The callsign
332
-	* @param String $date date we want flight number info
333
-	* @return array Flight departure and arrival airports and time
334
-	*/
330
+	 * Get flight info from Lutfhansa API
331
+	 * @param String $callsign The callsign
332
+	 * @param String $date date we want flight number info
333
+	 * @return array Flight departure and arrival airports and time
334
+	 */
335 335
 	public function getLufthansa($callsign, $date = 'NOW') {
336 336
 		global $globalLufthansaKey;
337 337
 		$Common = new Common();
@@ -361,11 +361,11 @@  discard block
 block discarded – undo
361 361
 	}
362 362
 
363 363
 	/**
364
-	* Get flight info from Transavia API
365
-	* @param string $callsign The callsign
366
-	* @param string $date date we want flight number info
367
-	* @return array Flight departure and arrival airports and time
368
-	*/
364
+	 * Get flight info from Transavia API
365
+	 * @param string $callsign The callsign
366
+	 * @param string $date date we want flight number info
367
+	 * @return array Flight departure and arrival airports and time
368
+	 */
369 369
 	public function getTransavia($callsign, $date = 'NOW') {
370 370
 		global $globalTransaviaKey;
371 371
 		$Common = new Common();
@@ -391,10 +391,10 @@  discard block
 block discarded – undo
391 391
 	}
392 392
 
393 393
 	/**
394
-	* Get flight info from Tunisair
395
-	* @param string $callsign The callsign
396
-	* @return array Flight departure and arrival airports and time
397
-	*/
394
+	 * Get flight info from Tunisair
395
+	 * @param string $callsign The callsign
396
+	 * @return array Flight departure and arrival airports and time
397
+	 */
398 398
 	public function getTunisair($callsign) {
399 399
 		$Common = new Common();
400 400
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -410,12 +410,12 @@  discard block
 block discarded – undo
410 410
 		return array();
411 411
 	}
412 412
 
413
-    /**
414
-     * Get flight info from Vueling
415
-     * @param String $callsign The callsign
416
-     * @param string $date
417
-     * @return array Flight departure and arrival airports and time
418
-     */
413
+	/**
414
+	 * Get flight info from Vueling
415
+	 * @param String $callsign The callsign
416
+	 * @param string $date
417
+	 * @return array Flight departure and arrival airports and time
418
+	 */
419 419
 	public function getVueling($callsign,$date = 'NOW') {
420 420
 		$Common = new Common();
421 421
 		$check_date = new Datetime($date);
@@ -437,11 +437,11 @@  discard block
 block discarded – undo
437 437
 	}
438 438
 
439 439
 	/**
440
-	* Get flight info from Iberia
441
-	* @param String $callsign The callsign
442
-	* @param String $date date we want flight number info
443
-	* @return array Flight departure and arrival airports and time
444
-	*/
440
+	 * Get flight info from Iberia
441
+	 * @param String $callsign The callsign
442
+	 * @param String $date date we want flight number info
443
+	 * @return array Flight departure and arrival airports and time
444
+	 */
445 445
 	public function getIberia($callsign, $date = 'NOW') {
446 446
 		$Common = new Common();
447 447
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -470,13 +470,13 @@  discard block
 block discarded – undo
470 470
 		return array();
471 471
 	}
472 472
 
473
-    /**
474
-     * Get flight info from Star Alliance
475
-     * @param String $callsign The callsign
476
-     * @param String $date date we want flight number info
477
-     * @param string $carrier
478
-     * @return array Flight departure and arrival airports and time
479
-     */
473
+	/**
474
+	 * Get flight info from Star Alliance
475
+	 * @param String $callsign The callsign
476
+	 * @param String $date date we want flight number info
477
+	 * @param string $carrier
478
+	 * @return array Flight departure and arrival airports and time
479
+	 */
480 480
 
481 481
 	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
482 482
 		$Common = new Common();
@@ -508,11 +508,11 @@  discard block
 block discarded – undo
508 508
 
509 509
 
510 510
 	/**
511
-	* Get flight info from Alitalia
512
-	* @param String $callsign The callsign
513
-	* @param String $date date we want flight number info
514
-	* @return array Flight departure and arrival airports and time
515
-	*/
511
+	 * Get flight info from Alitalia
512
+	 * @param String $callsign The callsign
513
+	 * @param String $date date we want flight number info
514
+	 * @return array Flight departure and arrival airports and time
515
+	 */
516 516
 	private function getAlitalia($callsign, $date = 'NOW') {
517 517
 		$Common = new Common();
518 518
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
 	}
533 533
 
534 534
 	/**
535
-	* Get flight info from Brussels airlines
536
-	* @param String $callsign The callsign
537
-	* @param String $date date we want flight number info
538
-	* @return array Flight departure and arrival airports and time
539
-	*/
535
+	 * Get flight info from Brussels airlines
536
+	 * @param String $callsign The callsign
537
+	 * @param String $date date we want flight number info
538
+	 * @return array Flight departure and arrival airports and time
539
+	 */
540 540
 	private function getBrussels($callsign, $date = 'NOW') {
541 541
 		$Common = new Common();
542 542
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -546,25 +546,25 @@  discard block
 block discarded – undo
546 546
 		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
547 547
 		$data = $Common->getData($url);
548 548
 		if ($data != '') {
549
-		    //echo $data;
550
-		    $parsed_json = json_decode($data,true);
551
-		    if (isset($parsed_json[0]['FromAirportCode'])) {
549
+			//echo $data;
550
+			$parsed_json = json_decode($data,true);
551
+			if (isset($parsed_json[0]['FromAirportCode'])) {
552 552
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
553 553
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
554 554
 			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
555 555
 			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
556 556
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
557
-		    }
557
+			}
558 558
 		}
559 559
 		return array();
560 560
 	}
561 561
 
562 562
 	/**
563
-	* Get flight info from FlightRadar24
564
-	* @param String $callsign The callsign
565
-	* @param String $date date we want flight number info
566
-	* @return array Flight departure and arrival airports and time
567
-	*/
563
+	 * Get flight info from FlightRadar24
564
+	 * @param String $callsign The callsign
565
+	 * @param String $date date we want flight number info
566
+	 * @return array Flight departure and arrival airports and time
567
+	 */
568 568
 /*
569 569
 	public function getFlightRadar24($callsign, $date = 'NOW') {
570 570
 		$Common = new Common();
@@ -593,11 +593,11 @@  discard block
 block discarded – undo
593 593
 	}
594 594
   */
595 595
 	/**
596
-	* Get flight info from Lufthansa
597
-	* @param String $callsign The callsign
598
-	* @param String $date date we want flight number info
599
-	* @return array Flight departure and arrival airports and time
600
-	*/
596
+	 * Get flight info from Lufthansa
597
+	 * @param String $callsign The callsign
598
+	 * @param String $date date we want flight number info
599
+	 * @return array Flight departure and arrival airports and time
600
+	 */
601 601
 
602 602
 /*	private function getLufthansa($callsign, $date = 'NOW') {
603 603
 		$Common = new Common();
@@ -625,10 +625,10 @@  discard block
 block discarded – undo
625 625
 	}
626 626
   */
627 627
 	/**
628
-	* Get flight info from flytap
629
-	* @param String $callsign The callsign
630
-	* @return array Flight departure and arrival airports and time
631
-	*/
628
+	 * Get flight info from flytap
629
+	 * @param String $callsign The callsign
630
+	 * @return array Flight departure and arrival airports and time
631
+	 */
632 632
 	private function getFlyTap($callsign) {
633 633
 		$Common = new Common();
634 634
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -651,10 +651,10 @@  discard block
 block discarded – undo
651 651
 	}
652 652
 
653 653
 	/**
654
-	* Get flight info from flightmapper
655
-	* @param String $callsign The callsign
656
-	* @return array Flight departure and arrival airports and time
657
-	*/
654
+	 * Get flight info from flightmapper
655
+	 * @param String $callsign The callsign
656
+	 * @return array Flight departure and arrival airports and time
657
+	 */
658 658
 	public function getFlightMapper($callsign) {
659 659
 		$Common = new Common();
660 660
 		$airline_icao = '';
@@ -682,11 +682,11 @@  discard block
 block discarded – undo
682 682
 				$aarr = '';
683 683
 				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
684 684
 				if ($n == 7) {
685
-				    $departureTime = $dhour;
686
-				    $arrivalTime = $ahour;
687
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
688
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
689
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
685
+					$departureTime = $dhour;
686
+					$arrivalTime = $ahour;
687
+					$DepartureAirportIata = str_replace(array('(',')'),'',$darr);
688
+					$ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
689
+					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
690 690
 				}
691 691
 			}
692 692
 		}
@@ -694,10 +694,10 @@  discard block
 block discarded – undo
694 694
 	}
695 695
 
696 696
 	/**
697
-	* Get flight info from flightaware
698
-	* @param String $callsign The callsign
699
-	* @return array Flight departure and arrival airports and time
700
-	*/
697
+	 * Get flight info from flightaware
698
+	 * @param String $callsign The callsign
699
+	 * @return array Flight departure and arrival airports and time
700
+	 */
701 701
 	public function getFlightAware($callsign) {
702 702
 		global $globalFlightAwareUsername, $globalFlightAwarePassword;
703 703
 		date_default_timezone_set('UTC');
@@ -722,11 +722,11 @@  discard block
 block discarded – undo
722 722
 				$flight = $result['FlightInfoStatusResult']['flights'][0];
723 723
 				if (isset($flight['origin'])) {
724 724
 					return array(
725
-					    'DepartureAirportIATA' => $flight['origin']['alternate_ident'],
726
-					    'DepartureTime' => $flight['filed_departure_time']['time'],
727
-					    'ArrivalAirportIATA' => $flight['destination']['alternate_ident'],
728
-					    'ArrivalTime' => $flight['filed_arrival_time']['time'],
729
-					    'Source' => 'website_flightaware');
725
+						'DepartureAirportIATA' => $flight['origin']['alternate_ident'],
726
+						'DepartureTime' => $flight['filed_departure_time']['time'],
727
+						'ArrivalAirportIATA' => $flight['destination']['alternate_ident'],
728
+						'ArrivalTime' => $flight['filed_arrival_time']['time'],
729
+						'Source' => 'website_flightaware');
730 730
 				}
731 731
 			}
732 732
 		}
@@ -739,21 +739,21 @@  discard block
 block discarded – undo
739 739
 			$flight = reset($flights['flights']);
740 740
 			if (isset($flight['activityLog']['flights'][0]['origin'])) {
741 741
 				return array(
742
-				    'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
743
-				    'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
744
-				    'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
745
-				    'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
746
-				    'Source' => 'website_flightaware');
742
+					'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
743
+					'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
744
+					'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
745
+					'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
746
+					'Source' => 'website_flightaware');
747 747
 			}
748 748
 		}
749 749
 		return array();
750 750
 	}
751 751
 
752 752
 	/**
753
-	* Get flight info from CostToTravel
754
-	* @param String $callsign The callsign
755
-	* @return array Flight departure and arrival airports and time
756
-	*/
753
+	 * Get flight info from CostToTravel
754
+	 * @param String $callsign The callsign
755
+	 * @return array Flight departure and arrival airports and time
756
+	 */
757 757
 	public function getCostToTravel($callsign) {
758 758
 		$Common = new Common();
759 759
 		$url= "http://www.costtotravel.com/flight-number/".$callsign;
@@ -776,11 +776,11 @@  discard block
 block discarded – undo
776 776
 	}
777 777
 
778 778
 	/**
779
-	* Get flight info from Air Canada
780
-	* @param string $callsign The callsign
781
-	* @param string $date date we want flight number info
782
-	* @return array Flight departure and arrival airports and time
783
-	*/
779
+	 * Get flight info from Air Canada
780
+	 * @param string $callsign The callsign
781
+	 * @param string $date date we want flight number info
782
+	 * @return array Flight departure and arrival airports and time
783
+	 */
784 784
 	private function getAirCanada($callsign,$date = 'NOW') {
785 785
 		$Common = new Common();
786 786
 		if (class_exists("DomDocument") === FALSE) return array();
@@ -805,11 +805,11 @@  discard block
 block discarded – undo
805 805
 	}
806 806
 
807 807
 	/**
808
-	* Get flight info from Vietnam Airlines
809
-	* @param String $callsign The callsign
810
-	* @param String $date date we want flight number info
811
-	* @return array Flight departure and arrival airports and time
812
-	*/
808
+	 * Get flight info from Vietnam Airlines
809
+	 * @param String $callsign The callsign
810
+	 * @param String $date date we want flight number info
811
+	 * @return array Flight departure and arrival airports and time
812
+	 */
813 813
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
814 814
 		$Common = new Common();
815 815
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -832,12 +832,12 @@  discard block
 block discarded – undo
832 832
 	}
833 833
 
834 834
 	/**
835
-	* Get flight info from Air Berlin
836
-	* @param String $callsign The callsign
837
-	* @param String $date date we want flight number info
838
-	* @param String $carrier airline code
839
-	* @return array Flight departure and arrival airports and time
840
-	*/
835
+	 * Get flight info from Air Berlin
836
+	 * @param String $callsign The callsign
837
+	 * @param String $date date we want flight number info
838
+	 * @param String $carrier airline code
839
+	 * @return array Flight departure and arrival airports and time
840
+	 */
841 841
 	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
842 842
 		$Common = new Common();
843 843
 		date_default_timezone_set('UTC');
@@ -866,11 +866,11 @@  discard block
 block discarded – undo
866 866
 			$table = $Common->table2array($data);
867 867
 			$flight = $table;
868 868
 			if (isset($flight[5][4])) {
869
-			    $arrivalTime = $flight[5][4];
870
-			    $arrivalAirport = $flight[5][3];
869
+				$arrivalTime = $flight[5][4];
870
+				$arrivalAirport = $flight[5][3];
871 871
 			} else {
872
-			    $arrivalTime = '';
873
-			    $arrivalAirport = '';
872
+				$arrivalTime = '';
873
+				$arrivalAirport = '';
874 874
 			}
875 875
 		} else return array();
876 876
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
Please login to merge, or discard this patch.
require/class.Translation.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 	}
26 26
 
27 27
 	/**
28
-	* Change IATA to ICAO value for ident
29
-	* 
30
-	* @param string $ident ident
31
-	* @return string the icao
32
-	*/
28
+	 * Change IATA to ICAO value for ident
29
+	 * 
30
+	 * @param string $ident ident
31
+	 * @return string the icao
32
+	 */
33 33
 	public function ident2icao($ident) {
34 34
 		$Spotter = new Spotter();
35 35
 		if (!is_numeric(substr($ident, 0, 3))) {
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 		return $icao;
53 53
 	}
54 54
 
55
-    /**
56
-     * @param $ident
57
-     * @return string
58
-     */
59
-    public function getOperator($ident) {
55
+	/**
56
+	 * @param $ident
57
+	 * @return string
58
+	 */
59
+	public function getOperator($ident) {
60 60
 		$query = "SELECT * FROM translation WHERE Operator = :ident LIMIT 1";
61 61
 		$query_values = array(':ident' => $ident);
62 62
 		try {
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
 		} else return $ident;
73 73
 	}
74 74
 
75
-    /**
76
-     * @param $ident
77
-     * @param $correct_ident
78
-     * @param $source
79
-     * @return string
80
-     */
81
-    public function addOperator($ident, $correct_ident, $source) {
75
+	/**
76
+	 * @param $ident
77
+	 * @param $correct_ident
78
+	 * @param $source
79
+	 * @return string
80
+	 */
81
+	public function addOperator($ident, $correct_ident, $source) {
82 82
 		$query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)";
83 83
 		$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
84 84
 		try {
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 		}
90 90
 	}
91 91
 
92
-    /**
93
-     * @param $ident
94
-     * @param $correct_ident
95
-     * @param $source
96
-     * @return string
97
-     */
98
-    public function updateOperator($ident, $correct_ident, $source) {
92
+	/**
93
+	 * @param $ident
94
+	 * @param $correct_ident
95
+	 * @param $source
96
+	 * @return string
97
+	 */
98
+	public function updateOperator($ident, $correct_ident, $source) {
99 99
 		$query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident";
100 100
 		$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
101 101
 		try {
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 		}
107 107
 	}
108 108
 
109
-    /**
110
-     * @param $ident
111
-     * @param bool $web
112
-     * @return string
113
-     */
114
-    public function checkTranslation($ident, $web = false) {
109
+	/**
110
+	 * @param $ident
111
+	 * @param bool $web
112
+	 * @return string
113
+	 */
114
+	public function checkTranslation($ident, $web = false) {
115 115
 		global $globalTranslationSources, $globalTranslationFetch;
116 116
 		//if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder');
117 117
 		$globalTranslationSources = array();
Please login to merge, or discard this patch.
require/class.Tracker.php 1 patch
Indentation   +268 added lines, -268 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 		if ($this->db === null) die('Error: No DB connection. (Tracker)');
21 21
 	}
22 22
 
23
-    /**
24
-     * Get SQL query part for filter used
25
-     * @param array $filter the filter
26
-     * @param bool $where
27
-     * @param bool $and
28
-     * @return string the SQL part
29
-     */
23
+	/**
24
+	 * Get SQL query part for filter used
25
+	 * @param array $filter the filter
26
+	 * @param bool $where
27
+	 * @param bool $and
28
+	 * @return string the SQL part
29
+	 */
30 30
 	
31 31
 	public function getFilter($filter = array(),$where = false,$and = false) {
32 32
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -92,15 +92,15 @@  discard block
 block discarded – undo
92 92
 		return $filter_query;
93 93
 	}
94 94
 
95
-    /**
96
-     * Executes the SQL statements to get the tracker information
97
-     *
98
-     * @param String $query the SQL query
99
-     * @param array $params parameter of the query
100
-     * @param String $limitQuery the limit query
101
-     * @param bool $schedules
102
-     * @return array the tracker information
103
-     */
95
+	/**
96
+	 * Executes the SQL statements to get the tracker information
97
+	 *
98
+	 * @param String $query the SQL query
99
+	 * @param array $params parameter of the query
100
+	 * @param String $limitQuery the limit query
101
+	 * @param bool $schedules
102
+	 * @return array the tracker information
103
+	 */
104 104
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
105 105
 	{
106 106
 		date_default_timezone_set('UTC');
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
 	}
213 213
 
214 214
 
215
-    /**
216
-     * Gets all the tracker information based on the latest data entry
217
-     *
218
-     * @param string $limit
219
-     * @param string $sort
220
-     * @param array $filter
221
-     * @return array the tracker information
222
-     */
215
+	/**
216
+	 * Gets all the tracker information based on the latest data entry
217
+	 *
218
+	 * @param string $limit
219
+	 * @param string $sort
220
+	 * @param array $filter
221
+	 * @return array the tracker information
222
+	 */
223 223
 	public function getLatestTrackerData($limit = '', $sort = '', $filter = array())
224 224
 	{
225 225
 		global $global_tracker_query;
@@ -276,15 +276,15 @@  discard block
 block discarded – undo
276 276
 		return $tracker_array;
277 277
 	}
278 278
 
279
-    /**
280
-     * Gets all the tracker information based on the callsign
281
-     *
282
-     * @param string $ident
283
-     * @param string $limit
284
-     * @param string $sort
285
-     * @param array $filter
286
-     * @return array the tracker information
287
-     */
279
+	/**
280
+	 * Gets all the tracker information based on the callsign
281
+	 *
282
+	 * @param string $ident
283
+	 * @param string $limit
284
+	 * @param string $sort
285
+	 * @param array $filter
286
+	 * @return array the tracker information
287
+	 */
288 288
 	public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
289 289
 	{
290 290
 		global $global_tracker_query;
@@ -393,13 +393,13 @@  discard block
 block discarded – undo
393 393
 	}
394 394
 
395 395
 
396
-    /**
397
-     * Gets all source name
398
-     *
399
-     * @param String type format of source
400
-     * @param array $filters
401
-     * @return array list of source name
402
-     */
396
+	/**
397
+	 * Gets all source name
398
+	 *
399
+	 * @param String type format of source
400
+	 * @param array $filters
401
+	 * @return array list of source name
402
+	 */
403 403
 	public function getAllSourceName($type = '',$filters = array())
404 404
 	{
405 405
 		$filter_query = $this->getFilter($filters,true,true);
@@ -428,12 +428,12 @@  discard block
 block discarded – undo
428 428
 	}
429 429
 
430 430
 
431
-    /**
432
-     * Gets a list of all idents/callsigns
433
-     *
434
-     * @param array $filters
435
-     * @return array list of ident/callsign names
436
-     */
431
+	/**
432
+	 * Gets a list of all idents/callsigns
433
+	 *
434
+	 * @param array $filters
435
+	 * @return array list of ident/callsign names
436
+	 */
437 437
 	public function getAllIdents($filters = array())
438 438
 	{
439 439
 		$filter_query = $this->getFilter($filters,true,true);
@@ -500,19 +500,19 @@  discard block
 block discarded – undo
500 500
 	}
501 501
 
502 502
 
503
-    /**
504
-     * Update ident tracker data
505
-     *
506
-     * @param string $famtrackid
507
-     * @param String $ident the flight ident
508
-     * @param null $fromsource
509
-     * @return String success or false
510
-     */
503
+	/**
504
+	 * Update ident tracker data
505
+	 *
506
+	 * @param string $famtrackid
507
+	 * @param String $ident the flight ident
508
+	 * @param null $fromsource
509
+	 * @return String success or false
510
+	 */
511 511
 	public function updateIdentTrackerData($famtrackid = '', $ident = '',$fromsource = NULL)
512 512
 	{
513 513
 
514 514
 		$query = 'UPDATE tracker_output SET ident = :ident WHERE famtrackid = :famtrackid';
515
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident);
515
+				$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident);
516 516
 
517 517
 		try {
518 518
 			$sth = $this->db->prepare($query);
@@ -525,22 +525,22 @@  discard block
 block discarded – undo
525 525
 
526 526
 	}
527 527
 
528
-    /**
529
-     * Update latest tracker data
530
-     *
531
-     * @param string $famtrackid
532
-     * @param String $ident the flight ident
533
-     * @param string $latitude
534
-     * @param string $longitude
535
-     * @param string $altitude
536
-     * @param null $groundspeed
537
-     * @param string $date
538
-     * @return String success or false
539
-     */
528
+	/**
529
+	 * Update latest tracker data
530
+	 *
531
+	 * @param string $famtrackid
532
+	 * @param String $ident the flight ident
533
+	 * @param string $latitude
534
+	 * @param string $longitude
535
+	 * @param string $altitude
536
+	 * @param null $groundspeed
537
+	 * @param string $date
538
+	 * @return String success or false
539
+	 */
540 540
 	public function updateLatestTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $groundspeed = NULL, $date = '')
541 541
 	{
542 542
 		$query = 'UPDATE tracker_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE famtrackid = :famtrackid';
543
-                $query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
543
+				$query_values = array(':famtrackid' => $famtrackid,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
544 544
 
545 545
 		try {
546 546
 			$sth = $this->db->prepare($query);
@@ -553,23 +553,23 @@  discard block
 block discarded – undo
553 553
 
554 554
 	}
555 555
 
556
-    /**
557
-     * Adds a new tracker data
558
-     *
559
-     * @param string $famtrackid
560
-     * @param String $ident the flight ident
561
-     * @param String $latitude latitude of flight
562
-     * @param String $longitude latitude of flight
563
-     * @param String $altitude altitude of flight
564
-     * @param String $heading heading of flight
565
-     * @param String $groundspeed speed of flight
566
-     * @param String $date date of flight
567
-     * @param string $comment
568
-     * @param string $type
569
-     * @param string $format_source
570
-     * @param string $source_name
571
-     * @return String success or false
572
-     */
556
+	/**
557
+	 * Adds a new tracker data
558
+	 *
559
+	 * @param string $famtrackid
560
+	 * @param String $ident the flight ident
561
+	 * @param String $latitude latitude of flight
562
+	 * @param String $longitude latitude of flight
563
+	 * @param String $altitude altitude of flight
564
+	 * @param String $heading heading of flight
565
+	 * @param String $groundspeed speed of flight
566
+	 * @param String $date date of flight
567
+	 * @param string $comment
568
+	 * @param string $type
569
+	 * @param string $format_source
570
+	 * @param string $source_name
571
+	 * @return String success or false
572
+	 */
573 573
 	public function addTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $comment = '', $type = '',$format_source = '', $source_name = '')
574 574
 	{
575 575
 		//$Image = new Image($this->db);
@@ -652,16 +652,16 @@  discard block
 block discarded – undo
652 652
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
653 653
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
654 654
 	
655
-                if ($latitude == '' && $longitude == '') {
656
-            		$latitude = 0;
657
-            		$longitude = 0;
658
-            	}
659
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
660
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
661
-                $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
655
+				if ($latitude == '' && $longitude == '') {
656
+					$latitude = 0;
657
+					$longitude = 0;
658
+				}
659
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
660
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
661
+				$query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
662 662
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
663 663
 
664
-                $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type);
664
+				$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':comment' => $comment,':type' => $type);
665 665
 
666 666
 		try {
667 667
 		        
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 			$sth->execute($query_values);
670 670
 			$this->db = null;
671 671
 		} catch (PDOException $e) {
672
-		    return "error : ".$e->getMessage();
672
+			return "error : ".$e->getMessage();
673 673
 		}
674 674
 		
675 675
 		return "success";
@@ -677,12 +677,12 @@  discard block
 block discarded – undo
677 677
 	}
678 678
 
679 679
 
680
-    /**
681
-     * Gets the aircraft ident within the last hour
682
-     *
683
-     * @param $ident
684
-     * @return String the ident
685
-     */
680
+	/**
681
+	 * Gets the aircraft ident within the last hour
682
+	 *
683
+	 * @param $ident
684
+	 * @return String the ident
685
+	 */
686 686
 	public function getIdentFromLastHour($ident)
687 687
 	{
688 688
 		global $globalDBdriver;
@@ -698,11 +698,11 @@  discard block
 block discarded – undo
698 698
 								AND tracker_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
699 699
 								AND tracker_output.date < now() AT TIME ZONE 'UTC'";
700 700
 			$query_data = array(':ident' => $ident);
701
-    		}
701
+			}
702 702
 		
703 703
 		$sth = $this->db->prepare($query);
704 704
 		$sth->execute($query_data);
705
-    		$ident_result='';
705
+			$ident_result='';
706 706
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
707 707
 		{
708 708
 			$ident_result = $row['ident'];
@@ -712,12 +712,12 @@  discard block
 block discarded – undo
712 712
 	}
713 713
 
714 714
 
715
-    /**
716
-     * Gets the aircraft data from the last 20 seconds
717
-     *
718
-     * @param string $q
719
-     * @return array the tracker data
720
-     */
715
+	/**
716
+	 * Gets the aircraft data from the last 20 seconds
717
+	 *
718
+	 * @param string $q
719
+	 * @return array the tracker data
720
+	 */
721 721
 	public function getRealTimeData($q = '')
722 722
 	{
723 723
 		global $globalDBdriver;
@@ -750,15 +750,15 @@  discard block
 block discarded – undo
750 750
 		return $tracker_array;
751 751
 	}
752 752
 
753
-    /**
754
-     * Gets all number of flight over countries
755
-     *
756
-     * @param bool $limit
757
-     * @param int $olderthanmonths
758
-     * @param string $sincedate
759
-     * @param array $filters
760
-     * @return array the airline country list
761
-     */
753
+	/**
754
+	 * Gets all number of flight over countries
755
+	 *
756
+	 * @param bool $limit
757
+	 * @param int $olderthanmonths
758
+	 * @param string $sincedate
759
+	 * @param array $filters
760
+	 * @return array the airline country list
761
+	 */
762 762
 	public function countAllTrackerOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
763 763
 	{
764 764
 		global $globalDBdriver, $globalArchive;
@@ -827,18 +827,18 @@  discard block
 block discarded – undo
827 827
 		return $flight_array;
828 828
 	}
829 829
 
830
-    /**
831
-     * Gets all callsigns that have flown over
832
-     *
833
-     * @param bool $limit
834
-     * @param int $olderthanmonths
835
-     * @param string $sincedate
836
-     * @param array $filters
837
-     * @param string $year
838
-     * @param string $month
839
-     * @param string $day
840
-     * @return array the callsign list
841
-     */
830
+	/**
831
+	 * Gets all callsigns that have flown over
832
+	 *
833
+	 * @param bool $limit
834
+	 * @param int $olderthanmonths
835
+	 * @param string $sincedate
836
+	 * @param array $filters
837
+	 * @param string $year
838
+	 * @param string $month
839
+	 * @param string $day
840
+	 * @return array the callsign list
841
+	 */
842 842
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
843 843
 	{
844 844
 		global $globalDBdriver;
@@ -904,12 +904,12 @@  discard block
 block discarded – undo
904 904
 	}
905 905
 
906 906
 
907
-    /**
908
-     * Counts all dates
909
-     *
910
-     * @param array $filters
911
-     * @return array the date list
912
-     */
907
+	/**
908
+	 * Counts all dates
909
+	 *
910
+	 * @param array $filters
911
+	 * @return array the date list
912
+	 */
913 913
 	public function countAllDates($filters = array())
914 914
 	{
915 915
 		global $globalTimezone, $globalDBdriver;
@@ -954,12 +954,12 @@  discard block
 block discarded – undo
954 954
 	}
955 955
 
956 956
 
957
-    /**
958
-     * Counts all dates during the last 7 days
959
-     *
960
-     * @param array $filters
961
-     * @return array the date list
962
-     */
957
+	/**
958
+	 * Counts all dates during the last 7 days
959
+	 *
960
+	 * @param array $filters
961
+	 * @return array the date list
962
+	 */
963 963
 	public function countAllDatesLast7Days($filters = array())
964 964
 	{
965 965
 		global $globalTimezone, $globalDBdriver;
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 			$query .= " GROUP BY date_name 
982 982
 								ORDER BY date_name ASC";
983 983
 			$query_data = array(':offset' => $offset);
984
-    		}
984
+			}
985 985
 		
986 986
 		$sth = $this->db->prepare($query);
987 987
 		$sth->execute($query_data);
@@ -1000,12 +1000,12 @@  discard block
 block discarded – undo
1000 1000
 		return $date_array;
1001 1001
 	}
1002 1002
 
1003
-    /**
1004
-     * Counts all dates during the last month
1005
-     *
1006
-     * @param array $filters
1007
-     * @return array the date list
1008
-     */
1003
+	/**
1004
+	 * Counts all dates during the last month
1005
+	 *
1006
+	 * @param array $filters
1007
+	 * @return array the date list
1008
+	 */
1009 1009
 	public function countAllDatesLastMonth($filters = array())
1010 1010
 	{
1011 1011
 		global $globalTimezone, $globalDBdriver;
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 			$query .= " GROUP BY date_name 
1028 1028
 								ORDER BY date_name ASC";
1029 1029
 			$query_data = array(':offset' => $offset);
1030
-    		}
1030
+			}
1031 1031
 		
1032 1032
 		$sth = $this->db->prepare($query);
1033 1033
 		$sth->execute($query_data);
@@ -1047,12 +1047,12 @@  discard block
 block discarded – undo
1047 1047
 	}
1048 1048
 
1049 1049
 
1050
-    /**
1051
-     * Counts all month
1052
-     *
1053
-     * @param array $filters
1054
-     * @return array the month list
1055
-     */
1050
+	/**
1051
+	 * Counts all month
1052
+	 *
1053
+	 * @param array $filters
1054
+	 * @return array the month list
1055
+	 */
1056 1056
 	public function countAllMonths($filters = array())
1057 1057
 	{
1058 1058
 		global $globalTimezone, $globalDBdriver;
@@ -1094,12 +1094,12 @@  discard block
 block discarded – undo
1094 1094
 	}
1095 1095
 
1096 1096
 
1097
-    /**
1098
-     * Counts all dates during the last year
1099
-     *
1100
-     * @param $filters
1101
-     * @return array the date list
1102
-     */
1097
+	/**
1098
+	 * Counts all dates during the last year
1099
+	 *
1100
+	 * @param $filters
1101
+	 * @return array the date list
1102
+	 */
1103 1103
 	public function countAllMonthsLastYear($filters)
1104 1104
 	{
1105 1105
 		global $globalTimezone, $globalDBdriver;
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 			$query .= " GROUP BY year_name, month_name
1122 1122
 								ORDER BY year_name, month_name ASC";
1123 1123
 			$query_data = array(':offset' => $offset);
1124
-    		}
1124
+			}
1125 1125
 		
1126 1126
 		$sth = $this->db->prepare($query);
1127 1127
 		$sth->execute($query_data);
@@ -1142,13 +1142,13 @@  discard block
 block discarded – undo
1142 1142
 	}
1143 1143
 
1144 1144
 
1145
-    /**
1146
-     * Counts all hours
1147
-     *
1148
-     * @param $orderby
1149
-     * @param array $filters
1150
-     * @return array the hour list
1151
-     */
1145
+	/**
1146
+	 * Counts all hours
1147
+	 *
1148
+	 * @param $orderby
1149
+	 * @param array $filters
1150
+	 * @return array the hour list
1151
+	 */
1152 1152
 	public function countAllHours($orderby,$filters = array())
1153 1153
 	{
1154 1154
 		global $globalTimezone, $globalDBdriver;
@@ -1209,13 +1209,13 @@  discard block
 block discarded – undo
1209 1209
 	}
1210 1210
 
1211 1211
 
1212
-    /**
1213
-     * Counts all hours by date
1214
-     *
1215
-     * @param $date
1216
-     * @param array $filters
1217
-     * @return array the hour list
1218
-     */
1212
+	/**
1213
+	 * Counts all hours by date
1214
+	 *
1215
+	 * @param $date
1216
+	 * @param array $filters
1217
+	 * @return array the hour list
1218
+	 */
1219 1219
 	public function countAllHoursByDate($date, $filters = array())
1220 1220
 	{
1221 1221
 		global $globalTimezone, $globalDBdriver;
@@ -1257,13 +1257,13 @@  discard block
 block discarded – undo
1257 1257
 	}
1258 1258
 
1259 1259
 
1260
-    /**
1261
-     * Counts all hours by a ident/callsign
1262
-     *
1263
-     * @param $ident
1264
-     * @param array $filters
1265
-     * @return array the hour list
1266
-     */
1260
+	/**
1261
+	 * Counts all hours by a ident/callsign
1262
+	 *
1263
+	 * @param $ident
1264
+	 * @param array $filters
1265
+	 * @return array the hour list
1266
+	 */
1267 1267
 	public function countAllHoursByIdent($ident, $filters = array())
1268 1268
 	{
1269 1269
 		global $globalTimezone, $globalDBdriver;
@@ -1306,14 +1306,14 @@  discard block
 block discarded – undo
1306 1306
 	}
1307 1307
 
1308 1308
 
1309
-    /**
1310
-     * Counts all trackers that have flown over
1311
-     *
1312
-     * @param array $filters
1313
-     * @param string $year
1314
-     * @param string $month
1315
-     * @return Integer the number of trackers
1316
-     */
1309
+	/**
1310
+	 * Counts all trackers that have flown over
1311
+	 *
1312
+	 * @param array $filters
1313
+	 * @param string $year
1314
+	 * @param string $month
1315
+	 * @return Integer the number of trackers
1316
+	 */
1317 1317
 	public function countOverallTracker($filters = array(),$year = '',$month = '')
1318 1318
 	{
1319 1319
 		global $globalDBdriver;
@@ -1347,14 +1347,14 @@  discard block
 block discarded – undo
1347 1347
 		return $sth->fetchColumn();
1348 1348
 	}
1349 1349
 
1350
-    /**
1351
-     * Counts all trackers type that have flown over
1352
-     *
1353
-     * @param array $filters
1354
-     * @param string $year
1355
-     * @param string $month
1356
-     * @return Integer the number of flights
1357
-     */
1350
+	/**
1351
+	 * Counts all trackers type that have flown over
1352
+	 *
1353
+	 * @param array $filters
1354
+	 * @param string $year
1355
+	 * @param string $month
1356
+	 * @return Integer the number of flights
1357
+	 */
1358 1358
 	public function countOverallTrackerTypes($filters = array(),$year = '',$month = '')
1359 1359
 	{
1360 1360
 		global $globalDBdriver;
@@ -1388,12 +1388,12 @@  discard block
 block discarded – undo
1388 1388
 	}
1389 1389
 
1390 1390
 
1391
-    /**
1392
-     * Counts all hours of today
1393
-     *
1394
-     * @param array $filters
1395
-     * @return array the hour list
1396
-     */
1391
+	/**
1392
+	 * Counts all hours of today
1393
+	 *
1394
+	 * @param array $filters
1395
+	 * @return array the hour list
1396
+	 */
1397 1397
 	public function countAllHoursFromToday($filters = array())
1398 1398
 	{
1399 1399
 		global $globalTimezone, $globalDBdriver;
@@ -1433,12 +1433,12 @@  discard block
 block discarded – undo
1433 1433
 	}
1434 1434
 
1435 1435
 
1436
-    /**
1437
-     * Gets the Barrie Spotter ID based on the FlightAware ID
1438
-     *
1439
-     * @param $famtrackid
1440
-     * @return Integer the Barrie Spotter ID
1441
-     */
1436
+	/**
1437
+	 * Gets the Barrie Spotter ID based on the FlightAware ID
1438
+	 *
1439
+	 * @param $famtrackid
1440
+	 * @return Integer the Barrie Spotter ID
1441
+	 */
1442 1442
 	public function getTrackerIDBasedOnFamTrackID($famtrackid)
1443 1443
 	{
1444 1444
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -1459,13 +1459,13 @@  discard block
 block discarded – undo
1459 1459
   
1460 1460
  
1461 1461
 	/**
1462
-	* Parses a date string
1463
-	*
1464
-	* @param String $dateString the date string
1465
-	* @param String $timezone the timezone of a user
1466
-	* @return array the time information
1467
-	*
1468
-	*/
1462
+	 * Parses a date string
1463
+	 *
1464
+	 * @param String $dateString the date string
1465
+	 * @param String $timezone the timezone of a user
1466
+	 * @return array the time information
1467
+	 *
1468
+	 */
1469 1469
 	public function parseDateString($dateString, $timezone = '')
1470 1470
 	{
1471 1471
 		$time_array = array();
@@ -1498,12 +1498,12 @@  discard block
 block discarded – undo
1498 1498
 	}
1499 1499
 	
1500 1500
 	/**
1501
-	* Parses the direction degrees to working
1502
-	*
1503
-	* @param Float $direction the direction in degrees
1504
-	* @return array the direction information
1505
-	*
1506
-	*/
1501
+	 * Parses the direction degrees to working
1502
+	 *
1503
+	 * @param Float $direction the direction in degrees
1504
+	 * @return array the direction information
1505
+	 *
1506
+	 */
1507 1507
 	public function parseDirection($direction = 0)
1508 1508
 	{
1509 1509
 		if ($direction == '') $direction = 0;
@@ -1582,12 +1582,12 @@  discard block
 block discarded – undo
1582 1582
 	
1583 1583
 	
1584 1584
 	/**
1585
-	* Gets Country from latitude/longitude
1586
-	*
1587
-	* @param Float $latitude latitute of the flight
1588
-	* @param Float $longitude longitute of the flight
1589
-	* @return String the countrie
1590
-	*/
1585
+	 * Gets Country from latitude/longitude
1586
+	 *
1587
+	 * @param Float $latitude latitute of the flight
1588
+	 * @param Float $longitude longitute of the flight
1589
+	 * @return String the countrie
1590
+	 */
1591 1591
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1592 1592
 	{
1593 1593
 		global $globalDebug;
@@ -1615,11 +1615,11 @@  discard block
 block discarded – undo
1615 1615
 	}
1616 1616
 
1617 1617
 	/**
1618
-	* Gets Country from iso2
1619
-	*
1620
-	* @param String $iso2 ISO2 country code
1621
-	* @return String the countrie
1622
-	*/
1618
+	 * Gets Country from iso2
1619
+	 *
1620
+	 * @param String $iso2 ISO2 country code
1621
+	 * @return String the countrie
1622
+	 */
1623 1623
 	public function getCountryFromISO2($iso2)
1624 1624
 	{
1625 1625
 		global $globalDebug;
@@ -1646,18 +1646,18 @@  discard block
 block discarded – undo
1646 1646
 	
1647 1647
 	}
1648 1648
 
1649
-    /**
1650
-     * Gets all vessels types that have flown over
1651
-     *
1652
-     * @param bool $limit
1653
-     * @param int $olderthanmonths
1654
-     * @param string $sincedate
1655
-     * @param array $filters
1656
-     * @param string $year
1657
-     * @param string $month
1658
-     * @param string $day
1659
-     * @return array the vessel type list
1660
-     */
1649
+	/**
1650
+	 * Gets all vessels types that have flown over
1651
+	 *
1652
+	 * @param bool $limit
1653
+	 * @param int $olderthanmonths
1654
+	 * @param string $sincedate
1655
+	 * @param array $filters
1656
+	 * @param string $year
1657
+	 * @param string $month
1658
+	 * @param string $day
1659
+	 * @return array the vessel type list
1660
+	 */
1661 1661
 	public function countAllTrackerTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1662 1662
 	{
1663 1663
 		global $globalDBdriver;
@@ -1721,21 +1721,21 @@  discard block
 block discarded – undo
1721 1721
 		return $tracker_array;
1722 1722
 	}
1723 1723
 
1724
-    /**
1725
-     * Gets all the tracker information
1726
-     *
1727
-     * @param string $q
1728
-     * @param string $callsign
1729
-     * @param string $date_posted
1730
-     * @param string $limit
1731
-     * @param string $sort
1732
-     * @param string $includegeodata
1733
-     * @param string $origLat
1734
-     * @param string $origLon
1735
-     * @param string $dist
1736
-     * @param array $filters
1737
-     * @return array the tracker information
1738
-     */
1724
+	/**
1725
+	 * Gets all the tracker information
1726
+	 *
1727
+	 * @param string $q
1728
+	 * @param string $callsign
1729
+	 * @param string $date_posted
1730
+	 * @param string $limit
1731
+	 * @param string $sort
1732
+	 * @param string $includegeodata
1733
+	 * @param string $origLat
1734
+	 * @param string $origLon
1735
+	 * @param string $dist
1736
+	 * @param array $filters
1737
+	 * @return array the tracker information
1738
+	 */
1739 1739
 	public function searchTrackerData($q = '', $callsign = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
1740 1740
 	{
1741 1741
 		global $globalTimezone, $globalDBdriver;
@@ -1840,12 +1840,12 @@  discard block
 block discarded – undo
1840 1840
 	}
1841 1841
 
1842 1842
 	/**
1843
-	* Gets the short url from bit.ly
1844
-	*
1845
-	* @param String $url the full url
1846
-	* @return String the bit.ly url
1847
-	*
1848
-	*/
1843
+	 * Gets the short url from bit.ly
1844
+	 *
1845
+	 * @param String $url the full url
1846
+	 * @return String the bit.ly url
1847
+	 *
1848
+	 */
1849 1849
 	public function getBitlyURL($url)
1850 1850
 	{
1851 1851
 		global $globalBitlyAccessToken;
Please login to merge, or discard this patch.
require/class.Accident.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 	}
37 37
 
38 38
 	/**
39
-	* Get Accidents data from DB
40
-	* @param String $limit Limit
41
-	* @param String $type Set type accident or incident
42
-	* @param String $date get data for a date
43
-	* @return array Return Accidents data in array
44
-	*/
39
+	 * Get Accidents data from DB
40
+	 * @param String $limit Limit
41
+	 * @param String $type Set type accident or incident
42
+	 * @param String $date get data for a date
43
+	 * @return array Return Accidents data in array
44
+	 */
45 45
 	public function getAccidentData($limit = '',$type = '',$date = '') {
46 46
 		global $globalDBdriver;
47 47
 		$Image = new Image($this->db);
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
 		return $row['nb'];
385 385
 	}
386 386
 
387
-    /**
388
-     * Check if lastest accident update date is older than 1 day
389
-     * @return bool|string
390
-     */
391
-    public static function check_last_accidents_update() {
387
+	/**
388
+	 * Check if lastest accident update date is older than 1 day
389
+	 * @return bool|string
390
+	 */
391
+	public static function check_last_accidents_update() {
392 392
 		global $globalDBdriver;
393 393
 		if ($globalDBdriver == 'mysql') {
394 394
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_accident_db' AND value > DATE_SUB(NOW(), INTERVAL 1 DAY)";
@@ -407,11 +407,11 @@  discard block
 block discarded – undo
407 407
 		else return true;
408 408
 	}
409 409
 
410
-    /**
411
-     * Insert accident update date
412
-     * @return string
413
-     */
414
-    public static function insert_last_accidents_update() {
410
+	/**
411
+	 * Insert accident update date
412
+	 * @return string
413
+	 */
414
+	public static function insert_last_accidents_update() {
415 415
 		$query = "DELETE FROM config WHERE name = 'last_update_accident_db';
416 416
 		    INSERT INTO config (name,value) VALUES ('last_update_accident_db',NOW());";
417 417
 		try {
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 	}
21 21
 
22 22
 
23
-    /**
24
-     * Get SQL query part for filter used
25
-     * @param array $filter the filter
26
-     * @param bool $where
27
-     * @param bool $and
28
-     * @return string the SQL part
29
-     */
23
+	/**
24
+	 * Get SQL query part for filter used
25
+	 * @param array $filter the filter
26
+	 * @param bool $where
27
+	 * @param bool $and
28
+	 * @return string the SQL part
29
+	 */
30 30
 	public function getFilter($filter = array(),$where = false,$and = false) {
31 31
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
32 32
 		$filters = array();
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
 		return $filter_query;
106 106
 	}
107 107
 
108
-    /**
109
-     * Gets all the spotter information based on the latest data entry
110
-     *
111
-     * @param string $limit
112
-     * @param string $sort
113
-     * @param array $filter
114
-     * @return array the spotter information
115
-     */
108
+	/**
109
+	 * Gets all the spotter information based on the latest data entry
110
+	 *
111
+	 * @param string $limit
112
+	 * @param string $sort
113
+	 * @param array $filter
114
+	 * @return array the spotter information
115
+	 */
116 116
 	public function getLiveMarineData($limit = '', $sort = '', $filter = array())
117 117
 	{
118 118
 		global $globalDBdriver, $globalLiveInterval;
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
 		return $spotter_array;
155 155
 	}
156 156
 
157
-    /**
158
-     * Gets Minimal Live Spotter data
159
-     *
160
-     * @param array $filter
161
-     * @return array the spotter information
162
-     */
157
+	/**
158
+	 * Gets Minimal Live Spotter data
159
+	 *
160
+	 * @param array $filter
161
+	 * @return array the spotter information
162
+	 */
163 163
 	public function getMinLiveMarineData($filter = array())
164 164
 	{
165 165
 		global $globalDBdriver, $globalLiveInterval;
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
 		return $spotter_array;
189 189
 	}
190 190
 
191
-    /**
192
-     * Gets Minimal Live Spotter data since xx seconds
193
-     *
194
-     * @param array $coord
195
-     * @param array $filter
196
-     * @param bool $limit
197
-     * @param string $id
198
-     * @return array the spotter information
199
-     */
191
+	/**
192
+	 * Gets Minimal Live Spotter data since xx seconds
193
+	 *
194
+	 * @param array $coord
195
+	 * @param array $filter
196
+	 * @param bool $limit
197
+	 * @param string $id
198
+	 * @return array the spotter information
199
+	 */
200 200
 	public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '')
201 201
 	{
202 202
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
@@ -275,14 +275,14 @@  discard block
 block discarded – undo
275 275
 		return $spotter_array;
276 276
 	}
277 277
 
278
-    /**
279
-     * Gets Minimal Live Spotter data since xx seconds
280
-     *
281
-     * @param string $id
282
-     * @param array $filter
283
-     * @param bool $limit
284
-     * @return array the spotter information
285
-     */
278
+	/**
279
+	 * Gets Minimal Live Spotter data since xx seconds
280
+	 *
281
+	 * @param string $id
282
+	 * @param array $filter
283
+	 * @param bool $limit
284
+	 * @return array the spotter information
285
+	 */
286 286
 	public function getMinLastLiveMarineDataByID($id = '',$filter = array(), $limit = false)
287 287
 	{
288 288
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
@@ -341,12 +341,12 @@  discard block
 block discarded – undo
341 341
 		return $spotter_array;
342 342
 	}
343 343
 
344
-    /**
345
-     * Gets number of latest data entry
346
-     *
347
-     * @param array $filter
348
-     * @return String number of entry
349
-     */
344
+	/**
345
+	 * Gets number of latest data entry
346
+	 *
347
+	 * @param array $filter
348
+	 * @return String number of entry
349
+	 */
350 350
 	public function getLiveMarineCount($filter = array())
351 351
 	{
352 352
 		global $globalDBdriver, $globalLiveInterval;
@@ -370,13 +370,13 @@  discard block
 block discarded – undo
370 370
 		return $result['nb'];
371 371
 	}
372 372
 
373
-    /**
374
-     * Gets all the spotter information based on the latest data entry and coord
375
-     *
376
-     * @param $coord
377
-     * @param array $filter
378
-     * @return array the spotter information
379
-     */
373
+	/**
374
+	 * Gets all the spotter information based on the latest data entry and coord
375
+	 *
376
+	 * @param $coord
377
+	 * @param array $filter
378
+	 * @return array the spotter information
379
+	 */
380 380
 	public function getLiveMarineDatabyCoord($coord, $filter = array())
381 381
 	{
382 382
 		global $globalDBdriver, $globalLiveInterval;
@@ -399,13 +399,13 @@  discard block
 block discarded – undo
399 399
 		return $spotter_array;
400 400
 	}
401 401
 
402
-    /**
403
-     * Gets all the spotter information based on the latest data entry and coord
404
-     *
405
-     * @param $coord
406
-     * @param array $filter
407
-     * @return array the spotter information
408
-     */
402
+	/**
403
+	 * Gets all the spotter information based on the latest data entry and coord
404
+	 *
405
+	 * @param $coord
406
+	 * @param array $filter
407
+	 * @return array the spotter information
408
+	 */
409 409
 	public function getMinLiveMarineDatabyCoord($coord, $filter = array())
410 410
 	{
411 411
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -473,15 +473,15 @@  discard block
 block discarded – undo
473 473
 		return $spotter_array;
474 474
 	}
475 475
 
476
-    /**
477
-     * Gets all the spotter information based on a user's latitude and longitude
478
-     *
479
-     * @param $lat
480
-     * @param $lng
481
-     * @param $radius
482
-     * @param $interval
483
-     * @return array the spotter information
484
-     */
476
+	/**
477
+	 * Gets all the spotter information based on a user's latitude and longitude
478
+	 *
479
+	 * @param $lat
480
+	 * @param $lng
481
+	 * @param $radius
482
+	 * @param $interval
483
+	 * @return array the spotter information
484
+	 */
485 485
 	public function getLatestMarineForLayar($lat, $lng, $radius, $interval)
486 486
 	{
487 487
 		$Marine = new Marine($this->db);
@@ -538,32 +538,32 @@  discard block
 block discarded – undo
538 538
 	}
539 539
 
540 540
 
541
-    /**
542
-     * Gets all the spotter information based on a particular callsign
543
-     *
544
-     * @param $ident
545
-     * @return array the spotter information
546
-     */
541
+	/**
542
+	 * Gets all the spotter information based on a particular callsign
543
+	 *
544
+	 * @param $ident
545
+	 * @return array the spotter information
546
+	 */
547 547
 	public function getLastLiveMarineDataByIdent($ident)
548 548
 	{
549 549
 		$Marine = new Marine($this->db);
550 550
 		date_default_timezone_set('UTC');
551 551
 
552 552
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
553
-                $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';
553
+				$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';
554 554
 
555 555
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
556 556
 
557 557
 		return $spotter_array;
558 558
 	}
559 559
 
560
-    /**
561
-     * Gets all the spotter information based on a particular callsign
562
-     *
563
-     * @param $ident
564
-     * @param $date
565
-     * @return array the spotter information
566
-     */
560
+	/**
561
+	 * Gets all the spotter information based on a particular callsign
562
+	 *
563
+	 * @param $ident
564
+	 * @param $date
565
+	 * @return array the spotter information
566
+	 */
567 567
 	public function getDateLiveMarineDataByIdent($ident,$date)
568 568
 	{
569 569
 		$Marine = new Marine($this->db);
@@ -575,13 +575,13 @@  discard block
 block discarded – undo
575 575
 		return $spotter_array;
576 576
 	}
577 577
 
578
-    /**
579
-     * Gets all the spotter information based on a particular MMSI
580
-     *
581
-     * @param $mmsi
582
-     * @param $date
583
-     * @return array the spotter information
584
-     */
578
+	/**
579
+	 * Gets all the spotter information based on a particular MMSI
580
+	 *
581
+	 * @param $mmsi
582
+	 * @param $date
583
+	 * @return array the spotter information
584
+	 */
585 585
 	public function getDateLiveMarineDataByMMSI($mmsi,$date)
586 586
 	{
587 587
 		$Marine = new Marine($this->db);
@@ -593,53 +593,53 @@  discard block
 block discarded – undo
593 593
 		return $spotter_array;
594 594
 	}
595 595
 
596
-    /**
597
-     * Gets last spotter information based on a particular callsign
598
-     *
599
-     * @param $id
600
-     * @return array the spotter information
601
-     */
596
+	/**
597
+	 * Gets last spotter information based on a particular callsign
598
+	 *
599
+	 * @param $id
600
+	 * @return array the spotter information
601
+	 */
602 602
 	public function getLastLiveMarineDataById($id)
603 603
 	{
604 604
 		$Marine = new Marine($this->db);
605 605
 		date_default_timezone_set('UTC');
606 606
 
607 607
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
608
-                $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';
608
+				$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';
609 609
 
610 610
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
611 611
 
612 612
 		return $spotter_array;
613 613
 	}
614 614
 
615
-    /**
616
-     * Gets last spotter information based on a particular callsign
617
-     *
618
-     * @param $id
619
-     * @param $date
620
-     * @return array the spotter information
621
-     */
615
+	/**
616
+	 * Gets last spotter information based on a particular callsign
617
+	 *
618
+	 * @param $id
619
+	 * @param $date
620
+	 * @return array the spotter information
621
+	 */
622 622
 	public function getDateLiveMarineDataById($id,$date)
623 623
 	{
624 624
 		$Marine = new Marine($this->db);
625 625
 		date_default_timezone_set('UTC');
626 626
 
627 627
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
628
-                $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';
629
-                $date = date('c',$date);
628
+				$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';
629
+				$date = date('c',$date);
630 630
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
631 631
 
632 632
 		return $spotter_array;
633 633
 	}
634 634
 
635 635
 
636
-    /**
637
-     * Gets all the spotter information based on a particular id
638
-     *
639
-     * @param $id
640
-     * @param bool $liveinterval
641
-     * @return array the spotter information
642
-     */
636
+	/**
637
+	 * Gets all the spotter information based on a particular id
638
+	 *
639
+	 * @param $id
640
+	 * @param bool $liveinterval
641
+	 * @return array the spotter information
642
+	 */
643 643
 	public function getAllLiveMarineDataById($id,$liveinterval = false)
644 644
 	{
645 645
 		global $globalDBdriver, $globalLiveInterval;
@@ -667,18 +667,18 @@  discard block
 block discarded – undo
667 667
 		return $spotter_array;
668 668
 	}
669 669
 
670
-    /**
671
-     * Gets all the spotter information based on a particular ident
672
-     *
673
-     * @param $ident
674
-     * @return array the spotter information
675
-     */
670
+	/**
671
+	 * Gets all the spotter information based on a particular ident
672
+	 *
673
+	 * @param $ident
674
+	 * @return array the spotter information
675
+	 */
676 676
 	public function getAllLiveMarineDataByIdent($ident)
677 677
 	{
678 678
 		date_default_timezone_set('UTC');
679 679
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
680 680
 		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
681
-    		try {
681
+			try {
682 682
 			
683 683
 			$sth = $this->db->prepare($query);
684 684
 			$sth->execute(array(':ident' => $ident));
@@ -692,23 +692,23 @@  discard block
 block discarded – undo
692 692
 
693 693
 
694 694
 	/**
695
-	* Deletes all info in the table
696
-	*
697
-	* @return String success or false
698
-	*
699
-	*/
695
+	 * Deletes all info in the table
696
+	 *
697
+	 * @return String success or false
698
+	 *
699
+	 */
700 700
 	public function deleteLiveMarineData()
701 701
 	{
702 702
 		global $globalDBdriver;
703 703
 		if ($globalDBdriver == 'mysql') {
704 704
 			//$query  = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date";
705 705
 			$query  = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date';
706
-            		//$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)";
706
+					//$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)";
707 707
 		} else {
708 708
 			$query  = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date";
709 709
 		}
710 710
         
711
-    		try {
711
+			try {
712 712
 			
713 713
 			$sth = $this->db->prepare($query);
714 714
 			$sth->execute();
@@ -720,18 +720,18 @@  discard block
 block discarded – undo
720 720
 	}
721 721
 
722 722
 	/**
723
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
724
-	*
725
-	* @return String success or false
726
-	*
727
-	*/
723
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
724
+	 *
725
+	 * @return String success or false
726
+	 *
727
+	 */
728 728
 	public function deleteLiveMarineDataNotUpdated()
729 729
 	{
730 730
 		global $globalDBdriver, $globalDebug;
731 731
 		if ($globalDBdriver == 'mysql') {
732 732
 			//$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';
733
-    			$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";
734
-    			try {
733
+				$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";
734
+				try {
735 735
 				
736 736
 				$sth = $this->db->prepare($query);
737 737
 				$sth->execute();
@@ -739,8 +739,8 @@  discard block
 block discarded – undo
739 739
 				return "error";
740 740
 			}
741 741
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
742
-                        $i = 0;
743
-                        $j =0;
742
+						$i = 0;
743
+						$j =0;
744 744
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
745 745
 			foreach($all as $row)
746 746
 			{
@@ -748,20 +748,20 @@  discard block
 block discarded – undo
748 748
 				$j++;
749 749
 				if ($j == 30) {
750 750
 					if ($globalDebug) echo ".";
751
-				    	try {
751
+						try {
752 752
 						
753 753
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
754 754
 						$sth->execute();
755 755
 					} catch(PDOException $e) {
756 756
 						return "error";
757 757
 					}
758
-                                	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
759
-                                	$j = 0;
758
+									$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
759
+									$j = 0;
760 760
 				}
761 761
 				$query_delete .= "'".$row['fammarine_id']."',";
762 762
 			}
763 763
 			if ($i > 0) {
764
-    				try {
764
+					try {
765 765
 					
766 766
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
767 767
 					$sth->execute();
@@ -772,9 +772,9 @@  discard block
 block discarded – undo
772 772
 			return "success";
773 773
 		} elseif ($globalDBdriver == 'pgsql') {
774 774
 			//$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";
775
-    			//$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";
776
-    			$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)";
777
-    			try {
775
+				//$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";
776
+				$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)";
777
+				try {
778 778
 				
779 779
 				$sth = $this->db->prepare($query);
780 780
 				$sth->execute();
@@ -818,18 +818,18 @@  discard block
 block discarded – undo
818 818
 		return 'error';
819 819
 	}
820 820
 
821
-    /**
822
-     * Deletes all info in the table for an ident
823
-     *
824
-     * @param $ident
825
-     * @return String success or false
826
-     */
821
+	/**
822
+	 * Deletes all info in the table for an ident
823
+	 *
824
+	 * @param $ident
825
+	 * @return String success or false
826
+	 */
827 827
 	public function deleteLiveMarineDataByIdent($ident)
828 828
 	{
829 829
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
830 830
 		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
831 831
         
832
-    		try {
832
+			try {
833 833
 			
834 834
 			$sth = $this->db->prepare($query);
835 835
 			$sth->execute(array(':ident' => $ident));
@@ -840,18 +840,18 @@  discard block
 block discarded – undo
840 840
 		return "success";
841 841
 	}
842 842
 
843
-    /**
844
-     * Deletes all info in the table for an id
845
-     *
846
-     * @param $id
847
-     * @return String success or false
848
-     */
843
+	/**
844
+	 * Deletes all info in the table for an id
845
+	 *
846
+	 * @param $id
847
+	 * @return String success or false
848
+	 */
849 849
 	public function deleteLiveMarineDataById($id)
850 850
 	{
851 851
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
852 852
 		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
853 853
         
854
-    		try {
854
+			try {
855 855
 			
856 856
 			$sth = $this->db->prepare($query);
857 857
 			$sth->execute(array(':id' => $id));
@@ -864,11 +864,11 @@  discard block
 block discarded – undo
864 864
 
865 865
 
866 866
 	/**
867
-	* Gets the marine races
868
-	*
869
-	* @return array all races
870
-	*
871
-	*/
867
+	 * Gets the marine races
868
+	 *
869
+	 * @return array all races
870
+	 *
871
+	 */
872 872
 	public function getAllRaces()
873 873
 	{
874 874
 		$query  = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name';
@@ -877,12 +877,12 @@  discard block
 block discarded – undo
877 877
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
878 878
 	}
879 879
 
880
-    /**
881
-     * Gets the aircraft ident within the last hour
882
-     *
883
-     * @param $ident
884
-     * @return String the ident
885
-     */
880
+	/**
881
+	 * Gets the aircraft ident within the last hour
882
+	 *
883
+	 * @param $ident
884
+	 * @return String the ident
885
+	 */
886 886
 	public function getIdentFromLastHour($ident)
887 887
 	{
888 888
 		global $globalDBdriver;
@@ -908,14 +908,14 @@  discard block
 block discarded – undo
908 908
 			$ident_result = $row['ident'];
909 909
 		}
910 910
 		return $ident_result;
911
-        }
912
-
913
-    /**
914
-     * Check recent aircraft
915
-     *
916
-     * @param $ident
917
-     * @return String the ident
918
-     */
911
+		}
912
+
913
+	/**
914
+	 * Check recent aircraft
915
+	 *
916
+	 * @param $ident
917
+	 * @return String the ident
918
+	 */
919 919
 	public function checkIdentRecent($ident)
920 920
 	{
921 921
 		global $globalDBdriver;
@@ -941,14 +941,14 @@  discard block
 block discarded – undo
941 941
 			$ident_result = $row['fammarine_id'];
942 942
 		}
943 943
 		return $ident_result;
944
-        }
945
-
946
-    /**
947
-     * Check recent aircraft by id
948
-     *
949
-     * @param $id
950
-     * @return String the ident
951
-     */
944
+		}
945
+
946
+	/**
947
+	 * Check recent aircraft by id
948
+	 *
949
+	 * @param $id
950
+	 * @return String the ident
951
+	 */
952 952
 	public function checkIdRecent($id)
953 953
 	{
954 954
 		global $globalDBdriver;
@@ -974,14 +974,14 @@  discard block
 block discarded – undo
974 974
 			$ident_result = $row['fammarine_id'];
975 975
 		}
976 976
 		return $ident_result;
977
-        }
978
-
979
-    /**
980
-     * Check recent aircraft by mmsi
981
-     *
982
-     * @param $mmsi
983
-     * @return String the ident
984
-     */
977
+		}
978
+
979
+	/**
980
+	 * Check recent aircraft by mmsi
981
+	 *
982
+	 * @param $mmsi
983
+	 * @return String the ident
984
+	 */
985 985
 	public function checkMMSIRecent($mmsi)
986 986
 	{
987 987
 		global $globalDBdriver;
@@ -1007,41 +1007,41 @@  discard block
 block discarded – undo
1007 1007
 			$ident_result = $row['fammarine_id'];
1008 1008
 		}
1009 1009
 		return $ident_result;
1010
-        }
1011
-
1012
-    /**
1013
-     * Adds a new spotter data
1014
-     *
1015
-     * @param String $fammarine_id the ID from flightaware
1016
-     * @param String $ident the flight ident
1017
-     * @param string $latitude
1018
-     * @param string $longitude
1019
-     * @param string $heading
1020
-     * @param string $groundspeed
1021
-     * @param string $date
1022
-     * @param bool $putinarchive
1023
-     * @param string $mmsi
1024
-     * @param string $type
1025
-     * @param string $typeid
1026
-     * @param string $imo
1027
-     * @param string $callsign
1028
-     * @param string $arrival_code
1029
-     * @param string $arrival_date
1030
-     * @param string $status
1031
-     * @param string $statusid
1032
-     * @param bool $noarchive
1033
-     * @param string $format_source
1034
-     * @param string $source_name
1035
-     * @param string $over_country
1036
-     * @param string $captain_id
1037
-     * @param string $captain_name
1038
-     * @param string $race_id
1039
-     * @param string $race_name
1040
-     * @param string $distance
1041
-     * @param string $race_rank
1042
-     * @param string $race_time
1043
-     * @return String success or false
1044
-     */
1010
+		}
1011
+
1012
+	/**
1013
+	 * Adds a new spotter data
1014
+	 *
1015
+	 * @param String $fammarine_id the ID from flightaware
1016
+	 * @param String $ident the flight ident
1017
+	 * @param string $latitude
1018
+	 * @param string $longitude
1019
+	 * @param string $heading
1020
+	 * @param string $groundspeed
1021
+	 * @param string $date
1022
+	 * @param bool $putinarchive
1023
+	 * @param string $mmsi
1024
+	 * @param string $type
1025
+	 * @param string $typeid
1026
+	 * @param string $imo
1027
+	 * @param string $callsign
1028
+	 * @param string $arrival_code
1029
+	 * @param string $arrival_date
1030
+	 * @param string $status
1031
+	 * @param string $statusid
1032
+	 * @param bool $noarchive
1033
+	 * @param string $format_source
1034
+	 * @param string $source_name
1035
+	 * @param string $over_country
1036
+	 * @param string $captain_id
1037
+	 * @param string $captain_name
1038
+	 * @param string $race_id
1039
+	 * @param string $race_name
1040
+	 * @param string $distance
1041
+	 * @param string $race_rank
1042
+	 * @param string $race_time
1043
+	 * @return String success or false
1044
+	 */
1045 1045
 	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 = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '')
1046 1046
 	{
1047 1047
 		global $globalArchive, $globalDebug;
@@ -1123,10 +1123,10 @@  discard block
 block discarded – undo
1123 1123
 		if ($statusid == '') $statusid = NULL;
1124 1124
 		if ($distance == '') $distance = NULL;
1125 1125
 
1126
-            	//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1127
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1128
-            	if ($arrival_date == '') $arrival_date = NULL;
1129
-            	$query = '';
1126
+				//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1127
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1128
+				if ($arrival_date == '') $arrival_date = NULL;
1129
+				$query = '';
1130 1130
 		if ($globalArchive) {
1131 1131
 			if ($globalDebug) echo '-- Delete previous data -- ';
1132 1132
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
Please login to merge, or discard this patch.