Completed
Push — master ( db7024...3e0d90 )
by Yannick
07:40
created

MarineLive::getAllLiveMarineDataById()   B

Complexity

Conditions 5
Paths 12

Size

Total Lines 26
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

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

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
897
			if ($globalDebug) echo $result.')';
898
		}
899
		return "success";
900
	}
901
902
	public function getOrderBy()
903
	{
904
		$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"));
905
		return $orderby;
906
	}
907
908
}
909
910
911
?>
912