Completed
Push — master ( 6c4f55...213543 )
by Yannick
10:31
created

TrackerLive   D

Complexity

Total Complexity 136

Size/Duplication

Total Lines 900
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 900
rs 4.4444
c 0
b 0
f 0
wmc 136
lcom 1
cbo 3

25 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
F getFilter() 0 68 36
C getLiveTrackerData() 0 39 8
B getMinLiveTrackerData() 0 31 4
B getMinLastLiveTrackerData() 0 28 4
B getLiveTrackerCount() 0 22 4
A getLiveTrackerDatabyCoord() 0 21 4
B getMinLiveTrackerDatabyCoord() 0 24 4
C getLatestTrackerForLayar() 0 54 11
A getLastLiveTrackerDataByIdent() 0 12 1
A getDateLiveTrackerDataByIdent() 0 13 1
A getLastLiveTrackerDataById() 0 12 1
A getDateLiveTrackerDataById() 0 12 1
A getAltitudeLiveTrackerDataByIdent() 0 20 2
B getAllLiveTrackerDataById() 0 26 5
A getAllLiveTrackerDataByIdent() 0 16 2
A deleteLiveTrackerData() 0 21 3
C deleteLiveTrackerDataNotUpdated() 0 91 11
A deleteLiveTrackerDataByIdent() 0 15 2
A deleteLiveTrackerDataById() 0 15 2
B getIdentFromLastHour() 0 26 3
B checkIdentRecent() 0 26 3
B checkIdRecent() 0 26 3
F addLiveTrackerData() 0 97 19
A getOrderBy() 0 5 1

How to fix   Complexity   

Complex Class

Complex classes like TrackerLive often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use TrackerLive, and based on these observations, apply Extract Interface, too.

1
<?php
2
//$global_query = "SELECT tracker_live.* FROM tracker_live";
3
4
class TrackerLive {
5
	public $db;
6
	static $global_query = "SELECT tracker_live.* FROM tracker_live";
7
8
	public function __construct($dbc = null) {
9
		$Connection = new Connection($dbc);
10
		$this->db = $Connection->db();
11
	}
12
13
14
	/**
15
	* Get SQL query part for filter used
16
	* @param Array $filter the filter
17
	* @return Array the SQL part
18
	*/
19
	public function getFilter($filter = array(),$where = false,$and = false) {
20
		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21
		$filters = array();
22
		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23
			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24
				$filters = $globalStatsFilters[$globalFilterName];
25
			} else {
26
				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
			}
28
		}
29
		if (isset($filter[0]['source'])) {
30
			$filters = array_merge($filters,$filter);
31
		}
32
		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
		$filter_query_join = '';
34
		$filter_query_where = '';
35
		foreach($filters as $flt) {
36
			if (isset($flt['idents']) && !empty($flt['idents'])) {
37
				if (isset($flt['source'])) {
38
					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
39
				} else {
40
					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
41
				}
42
			}
43
		}
44
		if (isset($filter['source']) && !empty($filter['source'])) {
45
			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
46
		}
47
		if (isset($filter['ident']) && !empty($filter['ident'])) {
48
			$filter_query_where .= " AND ident = '".$filter['ident']."'";
49
		}
50
		if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) {
51
			$filter_query_date = '';
52
			
53
			if (isset($filter['year']) && $filter['year'] != '') {
54
				if ($globalDBdriver == 'mysql') {
55
					$filter_query_date .= " AND YEAR(tracker_output.date) = '".$filter['year']."'";
56
				} else {
57
					$filter_query_date .= " AND EXTRACT(YEAR FROM tracker_output.date) = '".$filter['year']."'";
58
				}
59
			}
60
			if (isset($filter['month']) && $filter['month'] != '') {
61
				if ($globalDBdriver == 'mysql') {
62
					$filter_query_date .= " AND MONTH(tracker_output.date) = '".$filter['month']."'";
63
				} else {
64
					$filter_query_date .= " AND EXTRACT(MONTH FROM tracker_output.date) = '".$filter['month']."'";
65
				}
66
			}
67
			if (isset($filter['day']) && $filter['day'] != '') {
68
				if ($globalDBdriver == 'mysql') {
69
					$filter_query_date .= " AND DAY(tracker_output.date) = '".$filter['day']."'";
70
				} else {
71
					$filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
72
				}
73
			}
74
			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
75
		}
76
		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77
			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78
		}
79
		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80
		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81
		if ($filter_query_where != '') {
82
			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83
		}
84
		$filter_query = $filter_query_join.$filter_query_where;
85
		return $filter_query;
86
	}
87
88
	/**
89
	* Gets all the spotter information based on the latest data entry
90
	*
91
	* @return Array the spotter information
92
	*
93
	*/
94
	public function getLiveTrackerData($limit = '', $sort = '', $filter = array())
95
	{
96
		global $globalDBdriver, $globalLiveInterval;
97
		$Tracker = new Tracker($this->db);
98
		date_default_timezone_set('UTC');
99
100
		$filter_query = $this->getFilter($filter);
101
		$limit_query = '';
102
		if ($limit != '')
103
		{
104
			$limit_array = explode(',', $limit);
105
			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
106
			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
107
			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
108
			{
109
				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
110
			}
111
		}
112
		$orderby_query = '';
113
		if ($sort != '')
114
		{
115
			$search_orderby_array = $this->getOrderBy();
116
			if (isset($search_orderby_array[$sort]['sql'])) 
117
			{
118
				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
119
			}
120
		}
121
122
		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
123
		if ($globalDBdriver == 'mysql') {
124
			//$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";
125
			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query;
126
		} else {
127
			$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query;
128
		}
129
		$spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true);
130
131
		return $spotter_array;
132
	}
133
134
	/**
135
	* Gets Minimal Live Spotter data
136
	*
137
	* @return Array the spotter information
138
	*
139
	*/
140
	public function getMinLiveTrackerData($filter = array())
141
	{
142
		global $globalDBdriver, $globalLiveInterval;
143
		date_default_timezone_set('UTC');
144
145
		$filter_query = $this->getFilter($filter,true,true);
146
147
		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
148
		if ($globalDBdriver == 'mysql') {
149
			$query  = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
150
			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";
151
		} else {
152
			$query  = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
153
			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query." tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'";
154
155
156
		}
157
//		$spotter_array = Spotter->getDataFromDB($query.$limit_query);
158
//		echo $query;
159
160
		try {
161
			$sth = $this->db->prepare($query);
162
			$sth->execute();
163
		} catch(PDOException $e) {
164
			echo $e->getMessage();
165
			die;
166
		}
167
		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
168
169
		return $spotter_array;
170
	}
171
172
	/**
173
	* Gets Minimal Live Spotter data since xx seconds
174
	*
175
	* @return Array the spotter information
176
	*
177
	*/
178
	public function getMinLastLiveTrackerData($filter = array())
179
	{
180
		global $globalDBdriver, $globalLiveInterval;
181
		date_default_timezone_set('UTC');
182
183
		$filter_query = $this->getFilter($filter,true,true);
184
185
		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
186
		if ($globalDBdriver == 'mysql') {
187
			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
188
			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
189
			ORDER BY tracker_live.famtrackid, tracker_live.date";
190
                } else {
191
			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
192
			FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
193
			ORDER BY tracker_live.famtrackid, tracker_live.date";
194
		}
195
196
    		try {
197
			$sth = $this->db->prepare($query);
198
			$sth->execute();
199
		} catch(PDOException $e) {
200
			echo $e->getMessage();
201
			die;
202
		}
203
		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
204
		return $spotter_array;
205
	}
206
207
	/**
208
	* Gets number of latest data entry
209
	*
210
	* @return String number of entry
211
	*
212
	*/
213
	public function getLiveTrackerCount($filter = array())
214
	{
215
		global $globalDBdriver, $globalLiveInterval;
216
		$filter_query = $this->getFilter($filter,true,true);
217
218
		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
219
		if ($globalDBdriver == 'mysql') {
220
			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
221
		} else {
222
			$query = "SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
223
		}
224
		try {
225
			$sth = $this->db->prepare($query);
226
			$sth->execute();
227
		} catch(PDOException $e) {
228
			echo $e->getMessage();
229
			die;
230
		}
231
		$result = $sth->fetch(PDO::FETCH_ASSOC);
232
		$sth->closeCursor();
233
		return $result['nb'];
234
	}
235
236
	/**
237
	* Gets all the spotter information based on the latest data entry and coord
238
	*
239
	* @return Array the spotter information
240
	*
241
	*/
242
	public function getLiveTrackerDatabyCoord($coord, $filter = array())
243
	{
244
		global $globalDBdriver, $globalLiveInterval;
245
		$Spotter = new Spotter($this->db);
246
		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
247
		$filter_query = $this->getFilter($filter);
248
249
		if (is_array($coord)) {
250
			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
251
			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
252
			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
253
			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
254
		} else return array();
255
		if ($globalDBdriver == 'mysql') {
256
			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
257
		} else {
258
			$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE NOW() at time zone 'UTC'  - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY tracker_live.famtrackid".$filter_query;
259
		}
260
		$spotter_array = $Spotter->getDataFromDB($query);
261
		return $spotter_array;
262
	}
263
264
	/**
265
	* Gets all the spotter information based on the latest data entry and coord
266
	*
267
	* @return Array the spotter information
268
	*
269
	*/
270
	public function getMinLiveTrackerDatabyCoord($coord, $filter = array())
271
	{
272
		global $globalDBdriver, $globalLiveInterval;
273
		$Spotter = new Spotter($this->db);
274
		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
275
		$filter_query = $this->getFilter($filter);
276
277
		if (is_array($coord)) {
278
			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
279
			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
280
			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
281
			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
282
		} else return array();
283
		if ($globalDBdriver == 'mysql') {
284
			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
285
			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
286
			ORDER BY tracker_live.famtrackid, tracker_live.date";
287
		} else {
288
			$query  = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
289
			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date l.latitude BETWEEN ".$minlat." AND ".$maxlat." AND l.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query." tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'";
290
		}
291
		$spotter_array = $Spotter->getDataFromDB($query);
292
		return $spotter_array;
293
	}
294
295
	/**
296
	* Gets all the spotter information based on a user's latitude and longitude
297
	*
298
	* @return Array the spotter information
299
	*
300
	*/
301
	public function getLatestTrackerForLayar($lat, $lng, $radius, $interval)
302
	{
303
		$Tracker = new Tracker($this->db);
304
		date_default_timezone_set('UTC');
305
		if ($lat != '') {
306
			if (!is_numeric($lat)) {
307
				return false;
308
			}
309
		}
310
		if ($lng != '')
311
		{
312
			if (!is_numeric($lng))
313
                        {
314
                                return false;
315
                        }
316
                }
317
318
                if ($radius != '')
319
                {
320
                        if (!is_numeric($radius))
321
                        {
322
                                return false;
323
                        }
324
                }
325
		$additional_query = '';
326
		if ($interval != '')
327
                {
328
                        if (!is_string($interval))
329
                        {
330
                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
331
			        return false;
332
                        } else {
333
                if ($interval == '1m')
334
                {
335
                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
336
                } else if ($interval == '15m'){
337
                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
338
                } 
339
            }
340
                } else {
341
         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
342
        }
343
344
                $query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
345
                   WHERE tracker_live.latitude <> '' 
346
                                   AND tracker_live.longitude <> '' 
347
                   ".$additional_query."
348
                   HAVING distance < :radius  
349
                                   ORDER BY distance";
350
351
                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
352
353
                return $spotter_array;
354
        }
355
356
    
357
        /**
358
	* Gets all the spotter information based on a particular callsign
359
	*
360
	* @return Array the spotter information
361
	*
362
	*/
363
	public function getLastLiveTrackerDataByIdent($ident)
364
	{
365
		$Tracker = new Tracker($this->db);
366
		date_default_timezone_set('UTC');
367
368
		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
369
                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
370
371
		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true);
372
373
		return $spotter_array;
374
	}
375
376
        /**
377
	* Gets all the spotter information based on a particular callsign
378
	*
379
	* @return Array the spotter information
380
	*
381
	*/
382
	public function getDateLiveTrackerDataByIdent($ident,$date)
383
	{
384
		$Tracker = new Tracker($this->db);
385
		date_default_timezone_set('UTC');
386
387
		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
388
                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
389
390
                $date = date('c',$date);
391
		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
392
393
		return $spotter_array;
394
	}
395
396
        /**
397
	* Gets last spotter information based on a particular callsign
398
	*
399
	* @return Array the spotter information
400
	*
401
	*/
402
	public function getLastLiveTrackerDataById($id)
403
	{
404
		$Tracker = new Tracker($this->db);
405
		date_default_timezone_set('UTC');
406
407
		$id = filter_var($id, FILTER_SANITIZE_STRING);
408
                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
409
410
		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true);
411
412
		return $spotter_array;
413
	}
414
415
        /**
416
	* Gets last spotter information based on a particular callsign
417
	*
418
	* @return Array the spotter information
419
	*
420
	*/
421
	public function getDateLiveTrackerDataById($id,$date)
422
	{
423
		$Tracker = new Tracker($this->db);
424
		date_default_timezone_set('UTC');
425
426
		$id = filter_var($id, FILTER_SANITIZE_STRING);
427
                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
428
                $date = date('c',$date);
429
		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
430
431
		return $spotter_array;
432
	}
433
434
        /**
435
	* Gets altitude information based on a particular callsign
436
	*
437
	* @return Array the spotter information
438
	*
439
	*/
440
	public function getAltitudeLiveTrackerDataByIdent($ident)
441
	{
442
443
		date_default_timezone_set('UTC');
444
445
		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
446
                $query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
447
448
    		try {
449
			
450
			$sth = $this->db->prepare($query);
451
			$sth->execute(array(':ident' => $ident));
452
		} catch(PDOException $e) {
453
			echo $e->getMessage();
454
			die;
455
		}
456
		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
457
458
		return $spotter_array;
459
	}
460
461
        /**
462
	* Gets all the spotter information based on a particular id
463
	*
464
	* @return Array the spotter information
465
	*
466
	*/
467
	public function getAllLiveTrackerDataById($id,$liveinterval = false)
468
	{
469
		global $globalDBdriver, $globalLiveInterval;
470
		date_default_timezone_set('UTC');
471
		$id = filter_var($id, FILTER_SANITIZE_STRING);
472
		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
473
		if ($globalDBdriver == 'mysql') {
474
			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
475
			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
476
			$query .= ' ORDER BY date';
477
		} else {
478
			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
479
			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
480
			$query .= ' ORDER BY date';
481
		}
482
483
		try {
484
			$sth = $this->db->prepare($query);
485
			$sth->execute(array(':id' => $id));
486
		} catch(PDOException $e) {
487
			echo $e->getMessage();
488
			die;
489
		}
490
		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
491
		return $spotter_array;
492
	}
493
494
        /**
495
	* Gets all the spotter information based on a particular ident
496
	*
497
	* @return Array the spotter information
498
	*
499
	*/
500
	public function getAllLiveTrackerDataByIdent($ident)
501
	{
502
		date_default_timezone_set('UTC');
503
		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
504
		$query  = self::$global_query.' WHERE tracker_live.ident = :ident';
505
    		try {
506
			
507
			$sth = $this->db->prepare($query);
508
			$sth->execute(array(':ident' => $ident));
509
		} catch(PDOException $e) {
510
			echo $e->getMessage();
511
			die;
512
		}
513
		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
514
		return $spotter_array;
515
	}
516
517
518
	/**
519
	* Deletes all info in the table
520
	*
521
	* @return String success or false
522
	*
523
	*/
524
	public function deleteLiveTrackerData()
525
	{
526
		global $globalDBdriver;
527
		if ($globalDBdriver == 'mysql') {
528
			//$query  = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date";
529
			$query  = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date';
530
            		//$query  = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)";
531
		} else {
532
			$query  = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date";
533
		}
534
        
535
    		try {
536
			
537
			$sth = $this->db->prepare($query);
538
			$sth->execute();
539
		} catch(PDOException $e) {
540
			return "error";
541
		}
542
543
		return "success";
544
	}
545
546
	/**
547
	* Deletes all info in the table for aircraft not seen since 2 HOUR
548
	*
549
	* @return String success or false
550
	*
551
	*/
552
	public function deleteLiveTrackerDataNotUpdated()
553
	{
554
		global $globalDBdriver, $globalDebug;
555
		if ($globalDBdriver == 'mysql') {
556
			//$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0';
557
    			$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
558
    			try {
559
				
560
				$sth = $this->db->prepare($query);
561
				$sth->execute();
562
			} catch(PDOException $e) {
563
				return "error";
564
			}
565
			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
566
                        $i = 0;
567
                        $j =0;
568
			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
569
			foreach($all as $row)
570
			{
571
				$i++;
572
				$j++;
573
				if ($j == 30) {
574
					if ($globalDebug) echo ".";
575
				    	try {
576
						
577
						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
578
						$sth->execute();
579
					} catch(PDOException $e) {
580
						return "error";
581
					}
582
                                	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
583
                                	$j = 0;
584
				}
585
				$query_delete .= "'".$row['famtrackid']."',";
586
			}
587
			if ($i > 0) {
588
    				try {
589
					
590
					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
591
					$sth->execute();
592
				} catch(PDOException $e) {
593
					return "error";
594
				}
595
			}
596
			return "success";
597
		} elseif ($globalDBdriver == 'pgsql') {
598
			//$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0";
599
    			//$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
600
    			$query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
601
    			try {
602
				
603
				$sth = $this->db->prepare($query);
604
				$sth->execute();
605
			} catch(PDOException $e) {
606
				return "error";
607
			}
608
/*			$query_delete = "DELETE FROM tracker_live WHERE famtrackid IN (";
609
                        $i = 0;
610
                        $j =0;
611
			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
612
			foreach($all as $row)
613
			{
614
				$i++;
615
				$j++;
616
				if ($j == 100) {
617
					if ($globalDebug) echo ".";
618
				    	try {
619
						
620
						$sth = $this->db->query(substr($query_delete,0,-1).")");
621
						//$sth->execute();
622
					} catch(PDOException $e) {
623
						return "error";
624
					}
625
                                	$query_delete = "DELETE FROM tracker_live WHERE famtrackid IN (";
626
                                	$j = 0;
627
				}
628
				$query_delete .= "'".$row['famtrackid']."',";
629
			}
630
			if ($i > 0) {
631
    				try {
632
					
633
					$sth = $this->db->query(substr($query_delete,0,-1).")");
634
					//$sth->execute();
635
				} catch(PDOException $e) {
636
					return "error";
637
				}
638
			}
639
*/
640
			return "success";
641
		}
642
	}
643
644
	/**
645
	* Deletes all info in the table for an ident
646
	*
647
	* @return String success or false
648
	*
649
	*/
650
	public function deleteLiveTrackerDataByIdent($ident)
651
	{
652
		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
653
		$query  = 'DELETE FROM tracker_live WHERE ident = :ident';
654
        
655
    		try {
656
			
657
			$sth = $this->db->prepare($query);
658
			$sth->execute(array(':ident' => $ident));
659
		} catch(PDOException $e) {
660
			return "error";
661
		}
662
663
		return "success";
664
	}
665
666
	/**
667
	* Deletes all info in the table for an id
668
	*
669
	* @return String success or false
670
	*
671
	*/
672
	public function deleteLiveTrackerDataById($id)
673
	{
674
		$id = filter_var($id, FILTER_SANITIZE_STRING);
675
		$query  = 'DELETE FROM tracker_live WHERE famtrackid = :id';
676
        
677
    		try {
678
			
679
			$sth = $this->db->prepare($query);
680
			$sth->execute(array(':id' => $id));
681
		} catch(PDOException $e) {
682
			return "error";
683
		}
684
685
		return "success";
686
	}
687
688
689
	/**
690
	* Gets the aircraft ident within the last hour
691
	*
692
	* @return String the ident
693
	*
694
	*/
695
	public function getIdentFromLastHour($ident)
696
	{
697
		global $globalDBdriver, $globalTimezone;
698
		if ($globalDBdriver == 'mysql') {
699
			$query  = 'SELECT tracker_live.ident FROM tracker_live 
700
				WHERE tracker_live.ident = :ident 
701
				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
702
				AND tracker_live.date < UTC_TIMESTAMP()';
703
			$query_data = array(':ident' => $ident);
704
		} else {
705
			$query  = "SELECT tracker_live.ident FROM tracker_live 
706
				WHERE tracker_live.ident = :ident 
707
				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
708
				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
709
			$query_data = array(':ident' => $ident);
710
		}
711
		
712
		$sth = $this->db->prepare($query);
713
		$sth->execute($query_data);
714
		$ident_result='';
715
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
716
		{
717
			$ident_result = $row['ident'];
718
		}
719
		return $ident_result;
720
        }
721
722
	/**
723
	* Check recent aircraft
724
	*
725
	* @return String the ident
726
	*
727
	*/
728
	public function checkIdentRecent($ident)
729
	{
730
		global $globalDBdriver, $globalTimezone;
731
		if ($globalDBdriver == 'mysql') {
732
			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
733
				WHERE tracker_live.ident = :ident 
734
				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
735
//				AND tracker_live.date < UTC_TIMESTAMP()";
736
			$query_data = array(':ident' => $ident);
737
		} else {
738
			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
739
				WHERE tracker_live.ident = :ident 
740
				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
741
//				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
742
			$query_data = array(':ident' => $ident);
743
		}
744
		
745
		$sth = $this->db->prepare($query);
746
		$sth->execute($query_data);
747
		$ident_result='';
748
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
749
		{
750
			$ident_result = $row['famtrackid'];
751
		}
752
		return $ident_result;
753
        }
754
755
	/**
756
	* Check recent aircraft by id
757
	*
758
	* @return String the ident
759
	*
760
	*/
761
	public function checkIdRecent($id)
762
	{
763
		global $globalDBdriver, $globalTimezone;
764
		if ($globalDBdriver == 'mysql') {
765
			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
766
				WHERE tracker_live.famtrackid = :id 
767
				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
768
//				AND tracker_live.date < UTC_TIMESTAMP()";
769
			$query_data = array(':id' => $id);
770
		} else {
771
			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
772
				WHERE tracker_live.famtrackid = :id 
773
				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
774
//				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
775
			$query_data = array(':id' => $id);
776
		}
777
		
778
		$sth = $this->db->prepare($query);
779
		$sth->execute($query_data);
780
		$ident_result='';
781
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
782
		{
783
			$ident_result = $row['famtrackid'];
784
		}
785
		return $ident_result;
786
        }
787
788
	/**
789
	* Adds a new spotter data
790
	*
791
	* @param String $famtrackid the ID from flightaware
792
	* @param String $ident the flight ident
793
	* @param String $aircraft_icao the aircraft type
0 ignored issues
show
Bug introduced by
There is no parameter named $aircraft_icao. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
794
	* @param String $departure_airport_icao the departure airport
0 ignored issues
show
Bug introduced by
There is no parameter named $departure_airport_icao. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
795
	* @param String $arrival_airport_icao the arrival airport
0 ignored issues
show
Bug introduced by
There is no parameter named $arrival_airport_icao. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
796
	* @return String success or false
797
	*
798
	*/
799
	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
0 ignored issues
show
Unused Code introduced by
The parameter $putinarchive is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $noarchive is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
800
	{
801
		global $globalURL, $globalArchive, $globalDebug;
802
		$Common = new Common();
803
		date_default_timezone_set('UTC');
804
805
		//getting the airline information
806
		if ($ident != '')
807
		{
808
			if (!is_string($ident))
809
			{
810
				return false;
811
			} 
812
		}
813
814
815
		if ($latitude != '')
816
		{
817
			if (!is_numeric($latitude))
818
			{
819
				return false;
820
			}
821
		} else return '';
822
823
		if ($longitude != '')
824
		{
825
			if (!is_numeric($longitude))
826
			{
827
				return false;
828
			}
829
		} else return '';
830
831
		if ($altitude != '')
832
		{
833
			if (!is_numeric($altitude))
834
			{
835
				return false;
836
			}
837
		} else $altitude = 0;
838
839
		if ($heading != '')
840
		{
841
			if (!is_numeric($heading))
842
			{
843
				return false;
844
			}
845
		} else $heading = 0;
846
847
		if ($groundspeed != '')
848
		{
849
			if (!is_numeric($groundspeed))
850
			{
851
				return false;
852
			}
853
		} else $groundspeed = 0;
854
		date_default_timezone_set('UTC');
855
		if ($date == '') $date = date("Y-m-d H:i:s", time());
856
857
        
858
		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
859
		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
860
		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
861
		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
862
		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
863
		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
864
		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
865
		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
866
		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
867
		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
868
		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
869
		$type = filter_var($type,FILTER_SANITIZE_STRING);
870
871
            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
872
            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
873
            	
874
		$query  = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
875
		VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
876
877
		$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type);
878
		try {
879
			
880
			$sth = $this->db->prepare($query);
881
			$sth->execute($query_values);
882
                } catch(PDOException $e) {
883
                	return "error : ".$e->getMessage();
884
                }
885
		/*
886
		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
887
		    if ($globalDebug) echo '(Add to SBS archive : ';
888
		    $TrackerArchive = new TrackerArchive($this->db);
889
		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
890
		    if ($globalDebug) echo $result.')';
891
		}
892
		*/
893
		return "success";
894
895
	}
896
897
	public function getOrderBy()
898
	{
899
		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
900
		return $orderby;
901
	}
902
903
}
904
905
906
?>
907