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

MarineLive::deleteLiveMarineDataByIdent()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 3
nop 1
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
2
//$global_query = "SELECT marine_live.* FROM marine_live";
3
4
class MarineLive {
5
	public $db;
6
	static $global_query = "SELECT marine_live.* FROM marine_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 fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
39
				} else {
40
					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
41
				}
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(marine_output.date) = '".$filter['year']."'";
56
				} else {
57
					$filter_query_date .= " AND EXTRACT(YEAR FROM marine_output.date) = '".$filter['year']."'";
58
				}
59
			}
60
			if (isset($filter['month']) && $filter['month'] != '') {
61
				if ($globalDBdriver == 'mysql') {
62
					$filter_query_date .= " AND MONTH(marine_output.date) = '".$filter['month']."'";
63
				} else {
64
					$filter_query_date .= " AND EXTRACT(MONTH FROM marine_output.date) = '".$filter['month']."'";
65
				}
66
			}
67
			if (isset($filter['day']) && $filter['day'] != '') {
68
				if ($globalDBdriver == 'mysql') {
69
					$filter_query_date .= " AND DAY(marine_output.date) = '".$filter['day']."'";
70
				} else {
71
					$filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
72
				}
73
			}
74
			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
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 getLiveMarineData($limit = '', $sort = '', $filter = array())
95
	{
96
		global $globalDBdriver, $globalLiveInterval;
97
		$Marine = new Marine($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 marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate";
125
			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query;
126
		} else {
127
			$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query;
128
		}
129
		$spotter_array = $Marine->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 getMinLiveMarineData($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 marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
150
			FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0";
151
		} else {
152
			$query  = "SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
153
			FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query." marine_live.latitude <> '0' AND marine_live.longitude <> '0'";
154
		}
155
156
		try {
157
			$sth = $this->db->prepare($query);
158
			$sth->execute();
159
		} catch(PDOException $e) {
160
			echo $e->getMessage();
161
			die;
162
		}
163
		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
164
165
		return $spotter_array;
166
	}
167
168
	/**
169
	* Gets Minimal Live Spotter data since xx seconds
170
	*
171
	* @return Array the spotter information
172
	*
173
	*/
174
	public function getMinLastLiveMarineData($filter = array())
175
	{
176
		global $globalDBdriver, $globalLiveInterval;
177
		date_default_timezone_set('UTC');
178
179
		$filter_query = $this->getFilter($filter,true,true);
180
181
		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
182
		if ($globalDBdriver == 'mysql') {
183
			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
184
			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
185
			ORDER BY marine_live.fammarine_id, marine_live.date";
186
                } else {
187
			$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
188
			FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
189
			ORDER BY marine_live.fammarine_id, marine_live.date";
190
		}
191
192
    		try {
193
			$sth = $this->db->prepare($query);
194
			$sth->execute();
195
		} catch(PDOException $e) {
196
			echo $e->getMessage();
197
			die;
198
		}
199
		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
200
		return $spotter_array;
201
	}
202
203
	/**
204
	* Gets number of latest data entry
205
	*
206
	* @return String number of entry
207
	*
208
	*/
209
	public function getLiveMarineCount($filter = array())
210
	{
211
		global $globalDBdriver, $globalLiveInterval;
212
		$filter_query = $this->getFilter($filter,true,true);
213
214
		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
215
		if ($globalDBdriver == 'mysql') {
216
			$query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
217
		} else {
218
			$query = "SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
219
		}
220
		try {
221
			$sth = $this->db->prepare($query);
222
			$sth->execute();
223
		} catch(PDOException $e) {
224
			echo $e->getMessage();
225
			die;
226
		}
227
		$result = $sth->fetch(PDO::FETCH_ASSOC);
228
		$sth->closeCursor();
229
		return $result['nb'];
230
	}
231
232
	/**
233
	* Gets all the spotter information based on the latest data entry and coord
234
	*
235
	* @return Array the spotter information
236
	*
237
	*/
238
	public function getLiveMarineDatabyCoord($coord, $filter = array())
239
	{
240
		global $globalDBdriver, $globalLiveInterval;
241
		$Spotter = new Spotter($this->db);
242
		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
243
		$filter_query = $this->getFilter($filter);
244
245
		if (is_array($coord)) {
246
			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
247
			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
248
			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
249
			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
250
		} else return array();
251
		if ($globalDBdriver == 'mysql') {
252
			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;
253
		} else {
254
			$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE NOW() at time zone 'UTC'  - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY marine_live.fammarine_id".$filter_query;
255
		}
256
		$spotter_array = $Spotter->getDataFromDB($query);
257
		return $spotter_array;
258
	}
259
260
	/**
261
	* Gets all the spotter information based on the latest data entry and coord
262
	*
263
	* @return Array the spotter information
264
	*
265
	*/
266
	public function getMinLiveMarineDatabyCoord($coord, $filter = array())
267
	{
268
		global $globalDBdriver, $globalLiveInterval;
269
		$Spotter = new Spotter($this->db);
270
		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
271
		$filter_query = $this->getFilter($filter);
272
273
		if (is_array($coord)) {
274
			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
275
			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
276
			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
277
			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
278
		} else return array();
279
		if ($globalDBdriver == 'mysql') {
280
			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
281
			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
282
			ORDER BY marine_live.fammarine_id, marine_live.date";
283
		} else {
284
			$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
285
			FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong."
286
			ORDER BY marine_live.fammarine_id, marine_live.date";
287
		}
288
		$spotter_array = $Spotter->getDataFromDB($query);
289
		return $spotter_array;
290
	}
291
292
	/**
293
	* Gets all the spotter information based on a user's latitude and longitude
294
	*
295
	* @return Array the spotter information
296
	*
297
	*/
298
	public function getLatestMarineForLayar($lat, $lng, $radius, $interval)
299
	{
300
		$Marine = new Marine($this->db);
301
		date_default_timezone_set('UTC');
302
		if ($lat != '') {
303
			if (!is_numeric($lat)) {
304
				return false;
305
			}
306
		}
307
		if ($lng != '')
308
		{
309
			if (!is_numeric($lng))
310
                        {
311
                                return false;
312
                        }
313
                }
314
315
                if ($radius != '')
316
                {
317
                        if (!is_numeric($radius))
318
                        {
319
                                return false;
320
                        }
321
                }
322
		$additional_query = '';
323
		if ($interval != '')
324
                {
325
                        if (!is_string($interval))
326
                        {
327
                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
328
			        return false;
329
                        } else {
330
                if ($interval == '1m')
331
                {
332
                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
333
                } else if ($interval == '15m'){
334
                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
335
                } 
336
            }
337
                } else {
338
         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
339
        }
340
341
                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
342
                   WHERE marine_live.latitude <> '' 
343
                                   AND marine_live.longitude <> '' 
344
                   ".$additional_query."
345
                   HAVING distance < :radius  
346
                                   ORDER BY distance";
347
348
                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
349
350
                return $spotter_array;
351
        }
352
353
    
354
        /**
355
	* Gets all the spotter information based on a particular callsign
356
	*
357
	* @return Array the spotter information
358
	*
359
	*/
360
	public function getLastLiveMarineDataByIdent($ident)
361
	{
362
		$Marine = new Marine($this->db);
363
		date_default_timezone_set('UTC');
364
365
		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
366
                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
367
368
		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
369
370
		return $spotter_array;
371
	}
372
373
        /**
374
	* Gets all the spotter information based on a particular callsign
375
	*
376
	* @return Array the spotter information
377
	*
378
	*/
379
	public function getDateLiveMarineDataByIdent($ident,$date)
380
	{
381
		$Marine = new Marine($this->db);
382
		date_default_timezone_set('UTC');
383
384
		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
385
                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
386
387
                $date = date('c',$date);
388
		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
389
390
		return $spotter_array;
391
	}
392
393
        /**
394
	* Gets last spotter information based on a particular callsign
395
	*
396
	* @return Array the spotter information
397
	*
398
	*/
399
	public function getLastLiveMarineDataById($id)
400
	{
401
		$Marine = new Marine($this->db);
402
		date_default_timezone_set('UTC');
403
404
		$id = filter_var($id, FILTER_SANITIZE_STRING);
405
                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
406
407
		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
408
409
		return $spotter_array;
410
	}
411
412
        /**
413
	* Gets last spotter information based on a particular callsign
414
	*
415
	* @return Array the spotter information
416
	*
417
	*/
418
	public function getDateLiveMarineDataById($id,$date)
419
	{
420
		$Marine = new Marine($this->db);
421
		date_default_timezone_set('UTC');
422
423
		$id = filter_var($id, FILTER_SANITIZE_STRING);
424
                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
425
                $date = date('c',$date);
426
		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
427
428
		return $spotter_array;
429
	}
430
431
432
        /**
433
	* Gets all the spotter information based on a particular id
434
	*
435
	* @return Array the spotter information
436
	*
437
	*/
438
	public function getAllLiveMarineDataById($id,$liveinterval = false)
439
	{
440
		global $globalDBdriver, $globalLiveInterval;
441
		date_default_timezone_set('UTC');
442
		$id = filter_var($id, FILTER_SANITIZE_STRING);
443
		//$query  = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';
444
		if ($globalDBdriver == 'mysql') {
445
			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
446
			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
447
			$query .= ' ORDER BY date';
448
		} else {
449
			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
450
			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
451
			$query .= ' ORDER BY date';
452
		}
453
454
		try {
455
			$sth = $this->db->prepare($query);
456
			$sth->execute(array(':id' => $id));
457
		} catch(PDOException $e) {
458
			echo $e->getMessage();
459
			die;
460
		}
461
		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
462
		return $spotter_array;
463
	}
464
465
        /**
466
	* Gets all the spotter information based on a particular ident
467
	*
468
	* @return Array the spotter information
469
	*
470
	*/
471
	public function getAllLiveMarineDataByIdent($ident)
472
	{
473
		date_default_timezone_set('UTC');
474
		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
475
		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
476
    		try {
477
			
478
			$sth = $this->db->prepare($query);
479
			$sth->execute(array(':ident' => $ident));
480
		} catch(PDOException $e) {
481
			echo $e->getMessage();
482
			die;
483
		}
484
		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
485
		return $spotter_array;
486
	}
487
488
489
	/**
490
	* Deletes all info in the table
491
	*
492
	* @return String success or false
493
	*
494
	*/
495
	public function deleteLiveMarineData()
496
	{
497
		global $globalDBdriver;
498
		if ($globalDBdriver == 'mysql') {
499
			//$query  = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date";
500
			$query  = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date';
501
            		//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
502
		} else {
503
			$query  = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date";
504
		}
505
        
506
    		try {
507
			
508
			$sth = $this->db->prepare($query);
509
			$sth->execute();
510
		} catch(PDOException $e) {
511
			return "error";
512
		}
513
514
		return "success";
515
	}
516
517
	/**
518
	* Deletes all info in the table for aircraft not seen since 2 HOUR
519
	*
520
	* @return String success or false
521
	*
522
	*/
523
	public function deleteLiveMarineDataNotUpdated()
524
	{
525
		global $globalDBdriver, $globalDebug;
526
		if ($globalDBdriver == 'mysql') {
527
			//$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0';
528
    			$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
529
    			try {
530
				
531
				$sth = $this->db->prepare($query);
532
				$sth->execute();
533
			} catch(PDOException $e) {
534
				return "error";
535
			}
536
			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
537
                        $i = 0;
538
                        $j =0;
539
			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
540
			foreach($all as $row)
541
			{
542
				$i++;
543
				$j++;
544
				if ($j == 30) {
545
					if ($globalDebug) echo ".";
546
				    	try {
547
						
548
						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
549
						$sth->execute();
550
					} catch(PDOException $e) {
551
						return "error";
552
					}
553
                                	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
554
                                	$j = 0;
555
				}
556
				$query_delete .= "'".$row['fammarine_id']."',";
557
			}
558
			if ($i > 0) {
559
    				try {
560
					
561
					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
562
					$sth->execute();
563
				} catch(PDOException $e) {
564
					return "error";
565
				}
566
			}
567
			return "success";
568
		} elseif ($globalDBdriver == 'pgsql') {
569
			//$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0";
570
    			//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
571
    			$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
572
    			try {
573
				
574
				$sth = $this->db->prepare($query);
575
				$sth->execute();
576
			} catch(PDOException $e) {
577
				return "error";
578
			}
579
/*			$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN (";
580
                        $i = 0;
581
                        $j =0;
582
			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
583
			foreach($all as $row)
584
			{
585
				$i++;
586
				$j++;
587
				if ($j == 100) {
588
					if ($globalDebug) echo ".";
589
				    	try {
590
						
591
						$sth = $this->db->query(substr($query_delete,0,-1).")");
592
						//$sth->execute();
593
					} catch(PDOException $e) {
594
						return "error";
595
					}
596
                                	$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN (";
597
                                	$j = 0;
598
				}
599
				$query_delete .= "'".$row['fammarine_id']."',";
600
			}
601
			if ($i > 0) {
602
    				try {
603
					
604
					$sth = $this->db->query(substr($query_delete,0,-1).")");
605
					//$sth->execute();
606
				} catch(PDOException $e) {
607
					return "error";
608
				}
609
			}
610
*/
611
			return "success";
612
		}
613
	}
614
615
	/**
616
	* Deletes all info in the table for an ident
617
	*
618
	* @return String success or false
619
	*
620
	*/
621
	public function deleteLiveMarineDataByIdent($ident)
622
	{
623
		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
624
		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
625
        
626
    		try {
627
			
628
			$sth = $this->db->prepare($query);
629
			$sth->execute(array(':ident' => $ident));
630
		} catch(PDOException $e) {
631
			return "error";
632
		}
633
634
		return "success";
635
	}
636
637
	/**
638
	* Deletes all info in the table for an id
639
	*
640
	* @return String success or false
641
	*
642
	*/
643
	public function deleteLiveMarineDataById($id)
644
	{
645
		$id = filter_var($id, FILTER_SANITIZE_STRING);
646
		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
647
        
648
    		try {
649
			
650
			$sth = $this->db->prepare($query);
651
			$sth->execute(array(':id' => $id));
652
		} catch(PDOException $e) {
653
			return "error";
654
		}
655
656
		return "success";
657
	}
658
659
660
	/**
661
	* Gets the aircraft ident within the last hour
662
	*
663
	* @return String the ident
664
	*
665
	*/
666
	public function getIdentFromLastHour($ident)
667
	{
668
		global $globalDBdriver, $globalTimezone;
669
		if ($globalDBdriver == 'mysql') {
670
			$query  = 'SELECT marine_live.ident FROM marine_live 
671
				WHERE marine_live.ident = :ident 
672
				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
673
				AND marine_live.date < UTC_TIMESTAMP()';
674
			$query_data = array(':ident' => $ident);
675
		} else {
676
			$query  = "SELECT marine_live.ident FROM marine_live 
677
				WHERE marine_live.ident = :ident 
678
				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
679
				AND marine_live.date < now() AT TIME ZONE 'UTC'";
680
			$query_data = array(':ident' => $ident);
681
		}
682
		
683
		$sth = $this->db->prepare($query);
684
		$sth->execute($query_data);
685
		$ident_result='';
686
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
687
		{
688
			$ident_result = $row['ident'];
689
		}
690
		return $ident_result;
691
        }
692
693
	/**
694
	* Check recent aircraft
695
	*
696
	* @return String the ident
697
	*
698
	*/
699
	public function checkIdentRecent($ident)
700
	{
701
		global $globalDBdriver, $globalTimezone;
702
		if ($globalDBdriver == 'mysql') {
703
			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
704
				WHERE marine_live.ident = :ident 
705
				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
706
//				AND marine_live.date < UTC_TIMESTAMP()";
707
			$query_data = array(':ident' => $ident);
708
		} else {
709
			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
710
				WHERE marine_live.ident = :ident 
711
				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
712
//				AND marine_live.date < now() AT TIME ZONE 'UTC'";
713
			$query_data = array(':ident' => $ident);
714
		}
715
		
716
		$sth = $this->db->prepare($query);
717
		$sth->execute($query_data);
718
		$ident_result='';
719
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
720
		{
721
			$ident_result = $row['fammarine_id'];
722
		}
723
		return $ident_result;
724
        }
725
726
	/**
727
	* Check recent aircraft by id
728
	*
729
	* @return String the ident
730
	*
731
	*/
732
	public function checkIdRecent($id)
733
	{
734
		global $globalDBdriver, $globalTimezone;
735
		if ($globalDBdriver == 'mysql') {
736
			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
737
				WHERE marine_live.fammarine_id = :id 
738
				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
739
//				AND marine_live.date < UTC_TIMESTAMP()";
740
			$query_data = array(':id' => $id);
741
		} else {
742
			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
743
				WHERE marine_live.fammarine_id = :id 
744
				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
745
//				AND marine_live.date < now() AT TIME ZONE 'UTC'";
746
			$query_data = array(':id' => $id);
747
		}
748
		
749
		$sth = $this->db->prepare($query);
750
		$sth->execute($query_data);
751
		$ident_result='';
752
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
753
		{
754
			$ident_result = $row['fammarine_id'];
755
		}
756
		return $ident_result;
757
        }
758
759
	/**
760
	* Check recent aircraft by mmsi
761
	*
762
	* @return String the ident
763
	*
764
	*/
765
	public function checkMMSIRecent($mmsi)
766
	{
767
		global $globalDBdriver, $globalTimezone;
768
		if ($globalDBdriver == 'mysql') {
769
			$query  = 'SELECT marine_live.fammarine_id FROM marine_live 
770
				WHERE marine_live.mmsi = :mmsi 
771
				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
772
//				AND marine_live.date < UTC_TIMESTAMP()";
773
			$query_data = array(':mmsi' => $mmsi);
774
		} else {
775
			$query  = "SELECT marine_live.fammarine_id FROM marine_live 
776
				WHERE marine_live.mmsi = :mmsi 
777
				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
778
//				AND marine_live.date < now() AT TIME ZONE 'UTC'";
779
			$query_data = array(':mmsi' => $mmsi);
780
		}
781
		
782
		$sth = $this->db->prepare($query);
783
		$sth->execute($query_data);
784
		$ident_result='';
785
		while($row = $sth->fetch(PDO::FETCH_ASSOC))
786
		{
787
			$ident_result = $row['fammarine_id'];
788
		}
789
		return $ident_result;
790
        }
791
792
	/**
793
	* Adds a new spotter data
794
	*
795
	* @param String $fammarine_id the ID from flightaware
796
	* @param String $ident the flight ident
797
	* @param String $aircraft_icao the aircraft type
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...
798
	* @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...
799
	* @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...
800
	* @return String success or false
801
	*
802
	*/
803
	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$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 $typeid 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...
804
	{
805
		global $globalURL, $globalArchive, $globalDebug;
806
		$Common = new Common();
807
		date_default_timezone_set('UTC');
808
809
		//getting the airline information
810
		if ($ident != '')
811
		{
812
			if (!is_string($ident))
813
			{
814
				return false;
815
			} 
816
		}
817
818
819
		if ($latitude != '')
820
		{
821
			if (!is_numeric($latitude))
822
			{
823
				return false;
824
			}
825
		} else return '';
826
827
		if ($longitude != '')
828
		{
829
			if (!is_numeric($longitude))
830
			{
831
				return false;
832
			}
833
		} else return '';
834
835
836
		if ($heading != '')
837
		{
838
			if (!is_numeric($heading))
839
			{
840
				return false;
841
			}
842
		} else $heading = 0;
843
844
		if ($groundspeed != '')
845
		{
846
			if (!is_numeric($groundspeed))
847
			{
848
				return false;
849
			}
850
		} else $groundspeed = 0;
851
		date_default_timezone_set('UTC');
852
		if ($date == '') $date = date("Y-m-d H:i:s", time());
853
854
        
855
		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
856
		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
857
		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
858
		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
859
		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
860
		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
861
		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
862
		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
863
		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
864
		$type = filter_var($type,FILTER_SANITIZE_STRING);
865
		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
866
		$status = filter_var($status,FILTER_SANITIZE_STRING);
867
		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
868
		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
0 ignored issues
show
Unused Code introduced by
$callsign is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
869
		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
870
		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
871
		
872
873
            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
874
            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
875
            	if ($arrival_date == '') $arrival_date = NULL;
876
		$query  = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
877
		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';
878
879
		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
880
		try {
881
			
882
			$sth = $this->db->prepare($query);
883
			$sth->execute($query_values);
884
                } catch(PDOException $e) {
885
                	return "error : ".$e->getMessage();
886
                }
887
		/*
888
		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
889
		    if ($globalDebug) echo '(Add to SBS archive : ';
890
		    $MarineArchive = new MarineArchive($this->db);
891
		    $result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
892
		    if ($globalDebug) echo $result.')';
893
		}
894
		*/
895
		return "success";
896
897
	}
898
899
	public function getOrderBy()
900
	{
901
		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
902
		return $orderby;
903
	}
904
905
}
906
907
908
?>
909